Time |
Nickname |
Message |
00:03
🔗
|
SketchCow |
SNDTST: HELLO |
00:03
🔗
|
SketchCow |
I apologize for disappearing. |
00:04
🔗
|
SketchCow |
And oscar as well |
00:04
🔗
|
SketchCow |
Had to get bunch of stuff going here at Work |
00:54
🔗
|
|
SNDTST has quit IRC (Read error: Operation timed out) |
01:31
🔗
|
|
Vito` has joined #jsmess |
01:39
🔗
|
oscar |
Yes, likewise. It's been a week. |
01:40
🔗
|
oscar |
I think I came here with the same objective as you, SNDTST. |
01:42
🔗
|
oscar |
The short answer is: MAME is scriptable through Lua. Most of the internals are exposed through the Lua engine (looks like it's done mostly manually internally in luaengine.cpp). |
01:43
🔗
|
oscar |
It should be easy enough to write some simple Lua functions to switch disk images, since all that functionality is exposed. The challenge, I think, is going to be calling those from outside MAME. |
01:44
🔗
|
bai |
I would say it's not even so much that that part is particularly difficult - it's just a matter of working out the correct magic incantation |
01:44
🔗
|
bai |
this will probably all boil down to a couple one-liners in the end |
01:45
🔗
|
oscar |
If it were on a local machine, it'd be easy; just open up a local socket or the like, and feed some data back and forth over that. |
01:46
🔗
|
oscar |
I was trying to have a think about the ideal mechanism inside the browser, though. |
01:46
🔗
|
bai |
there's likely some function in mame that basically boils down to execute_lua_script(str) |
01:46
🔗
|
oscar |
The magic Lua incantations probably aren't all that magical. |
01:46
🔗
|
bai |
we can expose that function, then inject lua scripts from the client |
01:47
🔗
|
oscar |
Sure, I think looking at the Lua console plugin probably covers that pretty well; the Lua interpreter is pretty much just a read/evaluate/return/repeat loop. |
01:48
🔗
|
bai |
yeah, that seems like the best place to start |
02:04
🔗
|
oscar |
As for actually switching the floppy, it looks like it's probably pretty well exposed in the machine.images[] array. Check https://github.com/mamedev/mame/blob/master/src/frontend/mame/luaengine.cpp starting line 1974. |
02:05
🔗
|
oscar |
Depending on what machine we're emulating, some combination of load() and unload() for switching disks should work. |
02:06
🔗
|
oscar |
Of course, it won't do much for the stuff that's using pce or DOSBox. |
02:06
🔗
|
oscar |
But this is a good place to start, I think. |
02:07
🔗
|
oscar |
I just need to finish assembling the environment; I'd love to be able to do this without having to modify MAME at all, which might be possible. |
02:08
🔗
|
oscar |
What would be helpful is if there were an easy way to bring up the emscripten console... anyone a seasoned hand who knows how to wave the dead chicken just right? |
02:10
🔗
|
oscar |
(this was easier in Quake...) |
02:13
🔗
|
bai |
emscripten doesn't really have a console built in, but ctrl+shift+j (chrome) or ctrl+shift+i (ff) will get you the dev console. from there if you can get a reference to the running emscripten module, that's where the functions that control emscripten execution are defined |
02:14
🔗
|
bai |
in mame I believe you can press ` to get to the mame osd menu, but I'm not sue if the lua stuff is exposed through that or not |
02:16
🔗
|
SketchCow |
oscar: Good to ask DFJustin or Lord_Nigh about how to do the interface part for you |
02:17
🔗
|
SketchCow |
The framework for making this get called by a key might be a lot easier than that |
02:19
🔗
|
|
Ipggi has joined #jsmess |
02:21
🔗
|
oscar |
Yeah, I was hoping more for stdin/stdout emulation. |
02:22
🔗
|
oscar |
The MAME Lua console extension (which starts if you start it with -console on a regular machine) just uses that. |
02:25
🔗
|
bai |
there is a way of hooking stdin/stdout from emscripten, so that's one way to consider if injecting scripts via some exposed function doesn't work out |
02:25
🔗
|
oscar |
I just wanted it to be able to test things using the Lua console to start with. |
02:25
🔗
|
oscar |
But I can do that with the desktop version, worst case. |
02:42
🔗
|
oscar |
Console works fine in the desktop version, now to fire that up with some useful ROMs... |
02:46
🔗
|
SketchCow |
So... |
02:46
🔗
|
SketchCow |
We ALWAYS suggest using the desktop version for your whacky tests |
02:46
🔗
|
SketchCow |
And THEN we see where it blows up in the emscripten |
02:46
🔗
|
SketchCow |
Then you're not wondering which 3-4 layers might have gone boom |
02:57
🔗
|
oscar |
Right. |
02:57
🔗
|
oscar |
So in any case, this works from the Lua console, assuming you have the proper disk image in the current working directory: |
02:57
🔗
|
oscar |
manager:machine().images["flop1"]:load("Wasteland_disk_1.dsk"); |
02:57
🔗
|
oscar |
That's on machine apple2ee, so disk drive names may vary. |
02:58
🔗
|
oscar |
The drives all live in the images[] table. |
02:59
🔗
|
oscar |
There are a few image devices for apple2ee, for example: |
02:59
🔗
|
oscar |
for k,v in pairs(manager:machine().images) do print(k); end |
03:00
🔗
|
oscar |
That'll give you: floppydisk1, floppydisk2, flop2, flop1, cassette, cass |
03:01
🔗
|
oscar |
Presumably the long names are just aliases for the short names, but I'm too lazy to verify right now. |
03:02
🔗
|
oscar |
Doing <image object>:load(<filename>) immediately boots the image when the machine is in boot, similar to how it would work if you inserted the disk in the drive while it was in loading mode. |
03:03
🔗
|
oscar |
The Apple II doesn't have anything like a drive state sense, so all it knows is whether a valid data stream is coming off the head when the disk is spinning, but other systems might have more state sensing. |
03:04
🔗
|
oscar |
In any case, there's a corresponding unload() method for when we want to make the drive empty. |
03:07
🔗
|
oscar |
All of this should be relatively compatible with BrowserFS. I'll probably need to wait until after the weekend to assemble my test, though. |
03:11
🔗
|
db48x |
yes, when we compile MAME we can mark arbitrary C functions as exported |
03:11
🔗
|
db48x |
then we can call them from javascript |
03:11
🔗
|
oscar |
Well, that's handy. |
03:11
🔗
|
db48x |
the lua engine has a C api, so we should be able to make function calls or inject scripts on demand |
03:11
🔗
|
oscar |
Definitely. |
03:12
🔗
|
DFJustin |
<oscar> It should be easy enough to write some simple Lua functions to switch disk images, since all that functionality is exposed. The challenge, I think, is going to be calling those from outside MAME. |
03:12
🔗
|
DFJustin |
mame's lua can check for keyboard inputs I believe, so it could be bound to a hotkey? |
03:12
🔗
|
db48x |
sure |
03:12
🔗
|
db48x |
but I'd want to have a drop-down menu on the screen as well |
03:13
🔗
|
oscar |
DFJustin: Yes, that's what I was thinking. |
03:13
🔗
|
oscar |
The Lua engine also lets you draw UI elements. |
03:14
🔗
|
|
SNDTST has joined #jsmess |
03:14
🔗
|
db48x |
nice |
03:14
🔗
|
db48x |
but probably not super useful for us, since we're running MAME at such a low resolution |
03:14
🔗
|
oscar |
I'd say you might want to consider having an HTML drop-down menu for the current image in each drive, but that might be a bit much. |
03:14
🔗
|
oscar |
Or it might not, I dunno. |
03:15
🔗
|
oscar |
I think if you want to do it right, you probably want to expose the drive loading functionality through Emularity so arbitrary Javascript elements can call it, no? |
03:15
🔗
|
bai |
I think if we just expose the underlying functionality in a good way, then we can handle the ui any number of ways |
03:16
🔗
|
bai |
yeah, exactly |
03:16
🔗
|
SNDTST |
I saw the code in emularity for loading an image by index, is this as "simple" as supplying an array of images and then wiring up this function to a UI element? https://github.com/db48x/emularity/blob/master/loader.js#L577 |
03:17
🔗
|
db48x |
SNDTST: almost |
03:17
🔗
|
bai |
SAE is specifically for amiga |
03:17
🔗
|
db48x |
SAE has some special sauce that MAME doesn't |
03:17
🔗
|
oscar |
I was gonna say, that's sorta along the right lines, but for the wrong emulator. |
03:19
🔗
|
oscar |
But the MAME external functions are right above that, and I think that might be where you'd want to lash up the loading/unloading logic. |
03:20
🔗
|
db48x |
oscar: almost :) |
03:20
🔗
|
db48x |
we would want a method or two on the MAMERunner that let you pick an image |
03:20
🔗
|
oscar |
Right. |
03:20
🔗
|
db48x |
the MAMELoader would have a method to set the list of images for a device |
03:21
🔗
|
oscar |
You probably also want to make methods for unloading (empty drive) and also loading a blank disk? |
03:21
🔗
|
oscar |
Well, blank disk is maybe a step too far. |
03:21
🔗
|
db48x |
no, it's not :D |
03:21
🔗
|
oscar |
For images that need a "blank" (but formatted) disk, you probably want to have a default image around for that. |
03:22
🔗
|
oscar |
Depends on the program, anyway. |
03:22
🔗
|
db48x |
we would need different blank disk images for different emulators though, so that would be something we could do later |
03:22
🔗
|
oscar |
Exactly. |
03:22
🔗
|
bai |
there's no such thing as too much when it comes to this project :D |
03:22
🔗
|
oscar |
Haha, obviously. |
03:22
🔗
|
bai |
if we can tie a cdrom directly into your system's burner via js, we would do it! |
03:23
🔗
|
oscar |
Not even just individual emulators, but given how many low-level variations there are on RWTS on Apple II, even on individual programs. |
03:23
🔗
|
bai |
we still want to hook printing in |
03:23
🔗
|
oscar |
If I can print to my ImageWriter II via USB->Serial from The Print Shop, I'll be a happy man. :-) |
03:23
🔗
|
bai |
print up some nice Print Shop Pro banners and invitations |
03:24
🔗
|
db48x |
yea, I've read about the Apple II and the RWTS, but I don't know much about it |
03:24
🔗
|
oscar |
I have two whole cases of fanfold and a bunch of ribbons, birthday parties are gonna be lit af at my house for the next decade. |
03:24
🔗
|
bai |
haha |
03:24
🔗
|
db48x |
I assume there's a generic type of disk image that will hold any data any RWTS can write |
03:26
🔗
|
oscar |
Well, I've seen talk. |
03:26
🔗
|
oscar |
The thing about the Apple II is that the Disk II interface is so low-level; it's literally a bunch of control bits plus a simple decoding engine for the GCR formatting. |
03:27
🔗
|
oscar |
All the control for the motor, head stepper, and even the spacing and alignment of bits on the track are done in software. |
03:27
🔗
|
oscar |
It's not like the C64, where the 1541 is just a serial device that does EVERYTHING for you. |
03:27
🔗
|
db48x |
yea, I always enjoy reading 4am's notes on how he cracks apple2 software |
03:28
🔗
|
oscar |
So a lot of the copy protection regimes do incredibly fancy (or stupid) things with timing, changing the encoding bytes, other stuff. There's no way to make a "standard" blank disk. |
03:28
🔗
|
oscar |
But yeah, 4am's Twitter thread on Stupid Disk II Tricks is pretty amazing in terms of the really weird things people got up to. |
03:28
🔗
|
db48x |
seems like there should be |
03:28
🔗
|
db48x |
you can address any quarter track, and you can start and stop writing at any phase angle |
03:29
🔗
|
db48x |
and you can use any nibble translation table you want |
03:29
🔗
|
oscar |
My recollection is that the .DSK format pretty much just contains the encoded nibbles, but that isn't able to preserve the weird low-level variations you can have (like those ones, yes). |
03:29
🔗
|
db48x |
it doesn't seem hard to make a file that can hold that information, and let the software format it however it wants |
03:30
🔗
|
oscar |
So I know there's been a lot of talk about a new format that goes almost (or maybe actually) all the way down to the flux transition level. |
03:30
🔗
|
db48x |
but I agree that there's no universal _formatted_ disk |
03:30
🔗
|
oscar |
Right. |
03:30
🔗
|
oscar |
But that may not strictly matter, as long as the image format is capable of representing it. |
03:30
🔗
|
oscar |
Because most programs that need a weird format for saving data, for example, are going to be able to format their own. |
03:31
🔗
|
db48x |
indeed |
03:32
🔗
|
oscar |
The question of disk image formats, obviously, isn't 100% relevant to what we're looking at here; all we need to do is be able to point MAME to new filenames. :-) |
03:32
🔗
|
db48x |
true |
03:33
🔗
|
oscar |
I've gotta get to bed soon... does the Lua stuff I pasted above give you enough information to bang on it over the weekend? |
03:33
🔗
|
oscar |
We're headed out of town tomorrow, but I'll probably be able to revisit it some Sunday. |
03:33
🔗
|
bai |
yeah, in the case of disk storage right now we just use browserfs to map localStorage to a directory |
03:33
🔗
|
bai |
so we can store things like high scores, etc. for each user |
03:34
🔗
|
oscar |
Right, I figured. BrowserFS solves a lot of problems. |
03:34
🔗
|
bai |
it's a great project, yeah |
03:36
🔗
|
db48x |
time for me to sleep |
03:36
🔗
|
db48x |
I'll be around all weekend |
03:37
🔗
|
oscar |
Sounds good! I'll probably be back Sunday evening, but if not, Monday. |
04:13
🔗
|
|
Vito` has quit IRC (Read error: Connection reset by peer) |
04:13
🔗
|
|
Ipggi has quit IRC (Read error: Connection reset by peer) |
04:15
🔗
|
|
SNDTST has quit IRC (Read error: Operation timed out) |
05:28
🔗
|
|
SNDTST has joined #jsmess |
06:54
🔗
|
|
SNDTST has quit IRC (Read error: Operation timed out) |
08:32
🔗
|
|
hook54321 has quit IRC (irc.Prison.NET west.us.hub) |
08:32
🔗
|
|
oscar has quit IRC (irc.Prison.NET west.us.hub) |
08:32
🔗
|
|
BnARobin has quit IRC (irc.Prison.NET west.us.hub) |
08:32
🔗
|
|
pfalleno1 has quit IRC (irc.Prison.NET west.us.hub) |
08:32
🔗
|
|
DFJustin has quit IRC (irc.Prison.NET west.us.hub) |
08:32
🔗
|
|
ted______ has quit IRC (irc.Prison.NET west.us.hub) |
08:32
🔗
|
|
arkiver has quit IRC (irc.Prison.NET west.us.hub) |
08:32
🔗
|
|
i0npulse has quit IRC (irc.Prison.NET west.us.hub) |
08:32
🔗
|
|
decay_ has quit IRC (irc.Prison.NET west.us.hub) |
08:32
🔗
|
|
godane has quit IRC (irc.Prison.NET west.us.hub) |
08:32
🔗
|
|
Lord_Nigh has quit IRC (irc.Prison.NET west.us.hub) |
08:32
🔗
|
|
Rai-chan has quit IRC (irc.Prison.NET west.us.hub) |
08:32
🔗
|
|
SketchCow has quit IRC (irc.Prison.NET west.us.hub) |
08:32
🔗
|
|
Ash has quit IRC (irc.Prison.NET west.us.hub) |
08:32
🔗
|
|
bai has quit IRC (irc.Prison.NET west.us.hub) |
08:32
🔗
|
|
datajerk has quit IRC (irc.Prison.NET west.us.hub) |
08:32
🔗
|
|
bwn has quit IRC (irc.Prison.NET west.us.hub) |
08:32
🔗
|
|
zino has quit IRC (irc.Prison.NET west.us.hub) |
08:32
🔗
|
|
balrog has quit IRC (irc.Prison.NET west.us.hub) |
08:33
🔗
|
|
azakai has quit IRC (Read error: Operation timed out) |
08:34
🔗
|
|
db48x has quit IRC (Read error: Operation timed out) |
08:55
🔗
|
|
logchfoo1 starts logging #jsmess at Sat Mar 03 08:55:43 2018 |
08:55
🔗
|
|
logchfoo1 has joined #jsmess |
14:37
🔗
|
|
db48x has joined #jsmess |
16:10
🔗
|
|
Vito` has joined #jsmess |
17:02
🔗
|
|
SNDTST has joined #jsmess |
18:39
🔗
|
|
SNDTST has quit IRC (Leaving) |
21:46
🔗
|
|
azakai_ has quit IRC (Read error: Operation timed out) |
22:54
🔗
|
|
azakai_ has joined #jsmess |