#jsmess 2018-03-03,Sat

↑back Search ←Prev date Next date→ Show only urls(Click on time to select a line by its url)

WhoWhatWhen
SketchCowSNDTST: HELLO
I apologize for disappearing.
And oscar as well
Had to get bunch of stuff going here at Work
[00:03]
........... (idle for 50mn)
***SNDTST has quit IRC (Read error: Operation timed out) [00:54]
........ (idle for 37mn)
Vito` has joined #jsmess [01:31]
oscarYes, likewise. It's been a week.
I think I came here with the same objective as you, SNDTST.
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).
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:39]
baiI 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
this will probably all boil down to a couple one-liners in the end
[01:44]
oscarIf 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.
I was trying to have a think about the ideal mechanism inside the browser, though.
[01:45]
baithere's likely some function in mame that basically boils down to execute_lua_script(str) [01:46]
oscarThe magic Lua incantations probably aren't all that magical. [01:46]
baiwe can expose that function, then inject lua scripts from the client [01:46]
oscarSure, 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:47]
baiyeah, that seems like the best place to start [01:48]
.... (idle for 16mn)
oscarAs 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.
Depending on what machine we're emulating, some combination of load() and unload() for switching disks should work.
Of course, it won't do much for the stuff that's using pce or DOSBox.
But this is a good place to start, I think.
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.
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?
(this was easier in Quake...)
[02:04]
baiemscripten 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
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:13]
SketchCowoscar: Good to ask DFJustin or Lord_Nigh about how to do the interface part for you
The framework for making this get called by a key might be a lot easier than that
[02:16]
***Ipggi has joined #jsmess [02:19]
oscarYeah, I was hoping more for stdin/stdout emulation.
The MAME Lua console extension (which starts if you start it with -console on a regular machine) just uses that.
[02:21]
baithere 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]
oscarI just wanted it to be able to test things using the Lua console to start with.
But I can do that with the desktop version, worst case.
[02:25]
.... (idle for 17mn)
Console works fine in the desktop version, now to fire that up with some useful ROMs... [02:42]
SketchCowSo...
We ALWAYS suggest using the desktop version for your whacky tests
And THEN we see where it blows up in the emscripten
Then you're not wondering which 3-4 layers might have gone boom
[02:46]
oscarRight.
So in any case, this works from the Lua console, assuming you have the proper disk image in the current working directory:
manager:machine().images["flop1"]:load("Wasteland_disk_1.dsk");
That's on machine apple2ee, so disk drive names may vary.
The drives all live in the images[] table.
There are a few image devices for apple2ee, for example:
for k,v in pairs(manager:machine().images) do print(k); end
That'll give you: floppydisk1, floppydisk2, flop2, flop1, cassette, cass
Presumably the long names are just aliases for the short names, but I'm too lazy to verify right now.
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.
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.
In any case, there's a corresponding unload() method for when we want to make the drive empty.
All of this should be relatively compatible with BrowserFS. I'll probably need to wait until after the weekend to assemble my test, though.
[02:57]
db48xyes, when we compile MAME we can mark arbitrary C functions as exported
then we can call them from javascript
[03:11]
oscarWell, that's handy. [03:11]
db48xthe lua engine has a C api, so we should be able to make function calls or inject scripts on demand [03:11]
oscarDefinitely. [03:11]
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.
mame's lua can check for keyboard inputs I believe, so it could be bound to a hotkey?
[03:12]
db48xsure
but I'd want to have a drop-down menu on the screen as well
[03:12]
oscarDFJustin: Yes, that's what I was thinking.
The Lua engine also lets you draw UI elements.
[03:13]
***SNDTST has joined #jsmess [03:14]
db48xnice
but probably not super useful for us, since we're running MAME at such a low resolution
[03:14]
oscarI'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.
Or it might not, I dunno.
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:14]
baiI think if we just expose the underlying functionality in a good way, then we can handle the ui any number of ways
yeah, exactly
[03:15]
SNDTSTI 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:16]
db48xSNDTST: almost [03:17]
baiSAE is specifically for amiga [03:17]
db48xSAE has some special sauce that MAME doesn't [03:17]
oscarI was gonna say, that's sorta along the right lines, but for the wrong emulator.
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:17]
db48xoscar: almost :)
we would want a method or two on the MAMERunner that let you pick an image
[03:20]
oscarRight. [03:20]
db48xthe MAMELoader would have a method to set the list of images for a device [03:20]
oscarYou probably also want to make methods for unloading (empty drive) and also loading a blank disk?
Well, blank disk is maybe a step too far.
[03:21]
db48xno, it's not :D [03:21]
oscarFor images that need a "blank" (but formatted) disk, you probably want to have a default image around for that.
Depends on the program, anyway.
[03:21]
db48xwe would need different blank disk images for different emulators though, so that would be something we could do later [03:22]
oscarExactly. [03:22]
baithere's no such thing as too much when it comes to this project :D [03:22]
oscarHaha, obviously. [03:22]
baiif we can tie a cdrom directly into your system's burner via js, we would do it! [03:22]
oscarNot even just individual emulators, but given how many low-level variations there are on RWTS on Apple II, even on individual programs. [03:23]
baiwe still want to hook printing in [03:23]
oscarIf I can print to my ImageWriter II via USB->Serial from The Print Shop, I'll be a happy man. :-) [03:23]
baiprint up some nice Print Shop Pro banners and invitations [03:23]
db48xyea, I've read about the Apple II and the RWTS, but I don't know much about it [03:24]
oscarI 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]
baihaha [03:24]
db48xI assume there's a generic type of disk image that will hold any data any RWTS can write [03:24]
oscarWell, I've seen talk.
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.
All the control for the motor, head stepper, and even the spacing and alignment of bits on the track are done in software.
It's not like the C64, where the 1541 is just a serial device that does EVERYTHING for you.
[03:26]
db48xyea, I always enjoy reading 4am's notes on how he cracks apple2 software [03:27]
oscarSo 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.
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]
db48xseems like there should be
you can address any quarter track, and you can start and stop writing at any phase angle
and you can use any nibble translation table you want
[03:28]
oscarMy 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]
db48xit doesn't seem hard to make a file that can hold that information, and let the software format it however it wants [03:29]
oscarSo 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]
db48xbut I agree that there's no universal _formatted_ disk [03:30]
oscarRight.
But that may not strictly matter, as long as the image format is capable of representing it.
Because most programs that need a weird format for saving data, for example, are going to be able to format their own.
[03:30]
db48xindeed [03:31]
oscarThe 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]
db48xtrue [03:32]
oscarI've gotta get to bed soon... does the Lua stuff I pasted above give you enough information to bang on it over the weekend?
We're headed out of town tomorrow, but I'll probably be able to revisit it some Sunday.
[03:33]
baiyeah, in the case of disk storage right now we just use browserfs to map localStorage to a directory
so we can store things like high scores, etc. for each user
[03:33]
oscarRight, I figured. BrowserFS solves a lot of problems. [03:34]
baiit's a great project, yeah [03:34]
db48xtime for me to sleep
I'll be around all weekend
[03:36]
oscarSounds good! I'll probably be back Sunday evening, but if not, Monday. [03:37]
........ (idle for 36mn)
***Vito` has quit IRC (Read error: Connection reset by peer)
Ipggi has quit IRC (Read error: Connection reset by peer)
SNDTST has quit IRC (Read error: Operation timed out)
[04:13]
............... (idle for 1h13mn)
SNDTST has joined #jsmess [05:28]
.................. (idle for 1h26mn)
SNDTST has quit IRC (Read error: Operation timed out) [06:54]
.................... (idle for 1h38mn)
hook54321 has quit IRC (irc.Prison.NET west.us.hub)
oscar has quit IRC (irc.Prison.NET west.us.hub)
BnARobin has quit IRC (irc.Prison.NET west.us.hub)
pfalleno1 has quit IRC (irc.Prison.NET west.us.hub)
DFJustin has quit IRC (irc.Prison.NET west.us.hub)
ted______ has quit IRC (irc.Prison.NET west.us.hub)
arkiver has quit IRC (irc.Prison.NET west.us.hub)
i0npulse has quit IRC (irc.Prison.NET west.us.hub)
decay_ has quit IRC (irc.Prison.NET west.us.hub)
godane has quit IRC (irc.Prison.NET west.us.hub)
Lord_Nigh has quit IRC (irc.Prison.NET west.us.hub)
Rai-chan has quit IRC (irc.Prison.NET west.us.hub)
SketchCow has quit IRC (irc.Prison.NET west.us.hub)
Ash has quit IRC (irc.Prison.NET west.us.hub)
bai has quit IRC (irc.Prison.NET west.us.hub)
datajerk has quit IRC (irc.Prison.NET west.us.hub)
bwn has quit IRC (irc.Prison.NET west.us.hub)
zino has quit IRC (irc.Prison.NET west.us.hub)
balrog has quit IRC (irc.Prison.NET west.us.hub)
azakai has quit IRC (Read error: Operation timed out)
db48x has quit IRC (Read error: Operation timed out)
[08:32]
..... (idle for 21mn)
logchfoo1 starts logging #jsmess at Sat Mar 03 08:55:43 2018
logchfoo1 has joined #jsmess
[08:55]
..................................................................... (idle for 5h42mn)
db48x has joined #jsmess [14:37]
................... (idle for 1h33mn)
Vito` has joined #jsmess [16:10]
........... (idle for 52mn)
SNDTST has joined #jsmess [17:02]
.................... (idle for 1h37mn)
SNDTST has quit IRC (Leaving) [18:39]
...................................... (idle for 3h7mn)
azakai_ has quit IRC (Read error: Operation timed out) [21:46]
.............. (idle for 1h8mn)
azakai_ has joined #jsmess [22:54]

↑back Search ←Prev date Next date→ Show only urls(Click on time to select a line by its url)