#jsmess 2017-07-13,Thu

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

WhoWhatWhen
db48xJohnTalen: that's fun :P
JohnTalen: so, you were asking how to add support for Vice.js to Emularity last night
JohnTalen: to start with, you can just ignore IALoader
it's a separate layer from the rest, and you don't need to use it to test things locally
[00:05]
JohnTalendb48x: okay.
db48x: I didn't look at the source for emularity that long.
db48x: My take was that I use the loader as a fundemental understanding of how to go through it but I can make my own to suit my needs.
My gripe was adding sockets. Which is strange, because you would only do this to two servers otherwise you'd use HttpRequest via AJAX.
[00:20]
db48xsockets? [00:31]
.......... (idle for 48mn)
JohnTalenYeah, someone here wanted me to add sockets to Emularity.
Smoething about using it to mount disks.
which in byitself is extremely strange.
[01:19]
db48xah, yes
that has nothing to do with network connections or servers
a socket is just a type of file that allows IPC between two processes on the same machine
our filesystem library supports them, and PCE.js will listen on the socket at a certain filename
when it recieves commands on that socket, it mounts and unmounts disks in the emulator
yes, that's a bit of a hack
but compared to some of the hacks we use, it's pretty well thought out
[01:25]
JohnTalenhow can it support them when it isn't written?
And how would you call a socket from a browser?
[01:28]
db48xPCE opens the file and waits for someone to write to it
but Emularity never writes to it
so that part of PCE just waits quietly and never has to do anything (the rest of PCE works just fine, of course)
as for how it's implemented, I've never read this part of the BrowserFS library
but presumably when you call open on the socket it adds your callback to a list
then, whenever someone writes to the socket, it calls all the callbacks
[01:30]
JohnTalenHm, you want to share an emulated disk between multiple clients? [01:35]
db48xthat would be cool, but not really
we'd like to be able to show the user the status of all the disks in the item (sometimes there are more than one), to eject and reinsert them, to be able to add blank disks, etc
and of course we'd like the user to be able to save the disks to their own machine, etc
lots of ideas about that
[01:39]
JohnTalenOk, I suppose ReadFile/WriteFile in BrowserFS can do most of the work for this process? [01:41]
db48xpresumably [01:41]
JohnTalenokay understood. So you used this because of native support and didn't want to write a file name which classes with another opened file?
s/classed/clashes.
bah
classes=clashes
[01:43]
db48xof course, a lot of this is pie-in-the sky dreaming, along side ideas like using save states to implement pausing, rewinding, and replaying, or listening on the emulated serial or parrallel ports to support printer emulation, etc
well, we would use it for PCE because PCE.js has already implemented it
MAME and DosBox don't really have anything like it at all
[01:43]
JohnTalenWhat platforms did you want it for? [01:44]
db48xthough MAME can be scripted with lua, and we've had some ideas about how to use that
naturally, we want to support all of the features for all of the platforms
but like I said, these are all just ideas that anyone could work on if they want, at this point
[01:44]
JohnTalenOkay. I'll review this further after I'm done with Vice.
As far as pausing, rewinding etc. In those cases you're just bound by memory. You could probably hold a stack inside a compressed state file.
A stack in this case being a linked list of sorts.
[01:48]
db48xyep
the real problem is betting a save-state out of MAME
the user can press a sequence of hot-keys to make it dump one out to disk, but this is not exactly an intuitive interface
(DosBox is worse, of course, since I don't think it has any kind of save-state functionality)
one option we thought of was to tell emcc to export enough functions from MAME that we could call in and initiate the dump ourselves
or to export the Lua interpreter's functions so that we could call in and tell it to run some lua which would make MAME dump the save-state to disk
neither idea has really been explored properly
and we have no idea how long it takes MAME to do this; if it slows down MAME at all that rather limits what we can do with it
[01:52]
JohnTalenhm,as far as MAME how about a write/update online RAM guardaian that acts like a trigger in a sql database? linear arrays would be compressed and be written to a compressed diff file as addr/value keys. [01:55]
db48xalso, there's no guarantee that MAME supports this for every single machine it can emulate
hmm. if I understood correctly, that would let you save the state of MAME, but disentangling MAME's state from the state of the machine that MAME is emulating would be ridiculously annoying
[01:56]
JohnTalenthe idea is to store the high scores? [01:57]
db48xthat or just to let the user pause the game
or, if saving the state is fast enough, we could silently dump the state every second and give the user a way to rewind to previous states
we could also publish save states on IA for various reasons
[01:57]
JohnTalenif so, if there was a way to know the Insert Coin state screen to the next whenever you get there just write out the diff between the entry Insert Coin and the current Insert Coin. otherwise you're saving game state as well. [01:58]
db48xspeeding up the startup process of certain games would be nice (take a look at https://archive.org/details/msdos_Dragons_Lair_1993_1993 if you need a laugh)
SketchCow: that reminds me; one of the screen shots for Dragon's Lair is busted
[01:58]
JohnTalento pause the game sounds like easiest.
User could select update interval for saving if you're storing game state.
[02:02]
baidb48x: if we export the mame functions for snapshots we could trigger the saving and loading of those from js relatively easily
I thought we actually already supported persistent save states, maybe I'm misremembering
[02:04]
JohnTalenSo a driver has to be created for each emulator that writes out to a PCE kernel that accepts sokets. This is exactly like writing an operating system. [02:04]
db48xJohnTalen: not quite; PCE is just one of the emulators we support [02:05]
JohnTalenwell, for example. [02:05]
baiyeah some systems would be nice to boot off of a running state....like joust, and many other arcade games, when you first turned them on they expected the operator to press a button to step through the booting process, then it would enter play mode
most people have no idea when they see the test screens during boot-up that they're supposed to be hitting a key
[02:05]
db48xyea [02:06]
baimaybe I'm misremembering, I think what we had set up was for dosbox, the unionfs which would save changes to localstorage [02:08]
db48xyes
and it does let people save their games, which is awesome
but arcades don't have quite the same functinality :)
[02:09]
baibut it should be possible to do the same thing with mame, whatever directory mame is saving states to, we just need to map that to a browserfs filesystem in the config [02:09]
db48xsure [02:10]
baithen users could save and restore using mame's state management keys, or we could export the functions which tell mame to save or load, and trigger them programatically [02:10]
db48xthat much is already done
we do the OverlayFS for all emulators, not just DosBox
[02:10]
baioh ok [02:12]
db48xbut it's all just handwaving until someone figures out which MAME functions to export
and then there's still the UI to write
while that someone is in there, they could figure out how to pause MAME directly
(because while we could implement pausing using save states, it'd be easier just to pause the emulation without stopping MAME entirely)
[02:13]
baiI actually did the work to figure that all out like a year or more ago...actually there may be some patches which never made their way into mame as well [02:16]
JohnTalenOffhand, what is the name of the listener function in PCE.js? [02:16]
baiI'm trying the state save stuff now, I think it's not currently functional
but I know I did have save states working at some point
[02:16]
db48xbai: heh
JohnTalen: I have no idea :D
[02:17]
JohnTalenokay. I remember going through the code two weeks ago. I saw some comments about sockets but I was in a state of General Disarray.
I'll just search it again possibly referencing BrowseFS api functions.
[02:18]
baihttps://github.com/mamedev/mame/blob/536b2153d995430def817091867b3cfde71e688a/src/emu/machine.cpp#L657
https://github.com/mamedev/mame/blob/536b2153d995430def817091867b3cfde71e688a/src/emu/machine.cpp#L620
and I think the changes necessary are just to duplicate these lines in the emscripten loop https://github.com/mamedev/mame/blob/536b2153d995430def817091867b3cfde71e688a/src/emu/machine.cpp#L365-L367
[02:20]
db48xthat looks like it could be made to work
you'll have to allocate a std::string inside the Emscripten HEAP
and find the running_machine instance to call those methods on
[02:27]
baithe emscripten code stores a reference to the running machine as a static global, https://github.com/mamedev/mame/blob/536b2153d995430def817091867b3cfde71e688a/src/emu/machine.cpp#L1321
basically emscripten busts out of that first loop I linked, lets that part of the app exit, and sets up the async handler which calls js_main_loop() in response to the browser's requestAnimationFrame() event
so we'd need that same save state handling in that loop...and that's work I did somewhere, I should dig it back up
[02:29]
...... (idle for 25mn)
I've been through too many laptops and too many VMs in the past few years. where the hell did I put all that code [02:57]
........ (idle for 35mn)
JohnTalenwow, boring and mindless. i almost want to write a emcc screen scraper. [03:32]
.... (idle for 18mn)
hm, machine_name. i can't seem to find the duplicate. There are 11 instances and each one seems to be unique or needed where they are. tomorrow. have to be up early.
bbt
[03:50]
***JohnTalen has quit IRC (Quit: leaving) [03:51]
................ (idle for 1h16mn)
i0npulse has quit IRC (Ping timeout: 268 seconds)
i0npulse has joined #jsmess
[05:07]
.......... (idle for 47mn)
DFJustinmame has an -autosave setting that saves/loads the save state on exit, if that's enabled it might be enough to have an on quit callback that calls mame's exit code
saving state every second or whatever would have a huge performance hit I think
[05:54]
baiDFJustin: ah, that's good to know yeah, we definitely wouldn't want it every second, yeah
but the main problem is the code to check the save/load schedule just isn't executed in the emscripten codepath
I'm working on fixing that now
[05:56]
cool, got save states working....pausing is still not quite right though [06:02]
................... (idle for 1h31mn)
***bwn has quit IRC (Read error: Operation timed out) [07:33]
........ (idle for 37mn)
bwn has joined #jsmess [08:10]
bwn has quit IRC (Ping timeout: 260 seconds) [08:16]
bwn has joined #jsmess [08:22]
....... (idle for 32mn)
SketchCow has quit IRC (Read error: Connection reset by peer) [08:54]
SketchCow has joined #jsmess [09:00]
......... (idle for 40mn)
bwn has quit IRC (Read error: Operation timed out) [09:40]
bwn has joined #jsmess [09:52]
.... (idle for 17mn)
baihttps://github.com/mamedev/mame/pull/2470
while I was at it, I poked at the sleep() functions a bit, with promising results
I was able to eliminate the spinlock when osd_sleep() is called, by overriding the behavior for throttle_until_ticks() to bail when called under emscripten, and moving a bit of that logic into the emscripten main loop, so if the emulator is told to throttle it just waits until the next frame instead of spinlocking to use up wall time
that lead to inconsistent framerates because the delays weren't always correct when I do that, but for pacman it went from the cpu being busy for 100% of the frametime (~16.7ms) to only being used for about 2ms per frame, and idling for the rest
so it's promising, I just have to account for the actual delay time to smooth out the fps
[10:09]
.... (idle for 16mn)
for comparison: http://imgur.com/a/w0EqG
guess it's more like 4-5ms per frame, but still much more time spent just relaxing than there was before
[10:31]
............................................ (idle for 3h38mn)
DFJustinexcellent [14:09]
........ (idle for 36mn)
SketchCowAs expected, there is resistance.
(On you putting a patch in)
But please, can you continue down this road and explore the benefits you're finding, and maybe eventually it will express itself as a patch.
Or it's something we patch the code with for a while, like the good old days.
[14:45]
I'd jump into the github thread, but as has been told to me countless times, I don't make things better in there when I show up. [14:54]
***arkiver sets mode: +o SketchCow [14:55]
............... (idle for 1h10mn)
SketchCowbai: Perhaps it's time to make a github project called "mame-emscription-optimize" [16:05]
***JohnTalen has joined #jsmess [16:07]
JohnTalenprogress, but slow.
The initial make works fine for clang. It's the linking process that gives the unibug. Almost always a nameclash.
So, plodding through still.
[16:07]
.......... (idle for 45mn)
***azakai has joined #jsmess [16:54]
JohnTalen has quit IRC (Read error: Operation timed out) [17:00]
Vito`I think even being able to load previously saved save states, even if they had to be made in the native version, would be a big win. Roll back at the user level is cool but not a common use case. I think even a button to save a state locally would be more likely to see real use than onexit, people are trying a bunch of different games but don't care about their saves in most. [17:07]
baiI dunno about you but I use save state a lot when playing games in emulators, heh
it's a bit of a cheat though :D
like in zelda, quicksave before playing money-making game, quickload if you lose
[17:11]
.... (idle for 18mn)
db48xbai: that's a nice graph [17:29]
baiyeah, if I can get the timing stuff worked out that could help....not sure if it'll necessarily increase speed for things like jaguar that are running < 100%, but for those doing > 100% it means less pegging of the cpu, lower battery usage / heat generation, in theory better interactivity with the rest of the page, etc [17:33]
DFJustinI was curious if it would help with sound crackling on those doing > 100% [17:34]
baiactually as it is now it's introducing more lag on the sound, I think the sound system is coded to assume everything runs at exactly 60 frames per second [17:37]
DFJustindrat [17:37]
baiso if it's either too slow or too fast, you get crackles or lag, respectively [17:37]
db48xheh
just introduce a one-frame delay
[17:37]
DFJustinit's worth pointing out that pacman runs at roughly 60fps but there are systems in mame that run e.g. 50fps or 75fps so it really doesn't make much sense to talk about frames [17:38]
baiyeah you're right [17:38]
DFJustinjust 'however much time there is between browser animation callbacks' [17:39]
baiI think I triggered a few people on that pull request by using the term frames :D
do you have any thoughts on addressing the concerns of the people who don't want to "enshrine the run for one frame concept"?
[17:39]
DFJustinthere's also an issue with the current code where the browser callbacks change based on the host system refresh rate, so for example my laptop goes to 50Hz on battery and that fucks up the speed
and last time I checked there's no actual web api for what the refresh rate is other than "measure it for a while"
which blows my mind
[17:41]
baiyeah that's a good point - never seen a system which drops refresh rate on the fly myself, but makes sense [17:43]
DFJustinI don't really have time to review the patch until later but I guess it should be as independent from mame's screen objects as possible
at the cost of probably having tearing on scrolling and the like
well even if the refresh rate doesn't change it's currently hardcoded to assume 60 but some monitors are 120 etc
[17:44]
baiyeah, I started to look into removing the 60hz hardcoded bit, in theory I can just measure the time between when the emscripten main loop was last called and use that as our time to advance the emulator
but my initial attempt I think I was just getting the scale wrong, fucking attoseconds
[17:50]
DFJustinI tried doing that at one point but it's tricky because the gap can be very large if e.g. you switch tabs and come back [17:53]
baiyeah true, maybe cap it at, say, 10fps minimum
reminds me, pausing doesn't really work either
it stops updating the screen but the system continues to advance
[17:53]
DFJustinyeah the check for that is outside our loop [17:55]
baiactually someone moved it in, and my patch consolidates them so our loop and the native loop are actually running the same codepath now
but I think there's some other state flag being set somewhere which isn't being used, or something
[17:56]
DFJustinthis is what I had for measuring the time https://gist.github.com/DopefishJustin/d79b5fce9621c78dca50fdaefe6cc1d0
plus some audio stuff that didn't seem to help
[17:57]
baihmm, alright. yeah looks like similar sort of logic as I had...I could get it to run either > 100% or like 1 frame every few secods, but somehow getting the right value just didn't want to work, heh [18:00]
DFJustiniirc it basically seemed to just run the maximum 1/30 every time [18:01]
SketchCow: this is pretty mild as pull request pushback goes (there's another one which is a dumpster fire at the moment), I would expect it to get ironed out with some back and forth [18:09]
baididn't help that my pull request was failing the automated tests because I forgot I was compiling with NOWERROR=1 heh
fixed now and I addressed all the small concerns, now it's just a matter of ironing out the "web is weird, we shouldn't do it that way" "but web" discussions
it's also possible for me to split it out a bit more and keep the weirdo stuff in the emscripten define, I suppose
[18:14]
....................... (idle for 1h52mn)
SketchCowas long as you are not dissuaded
and I realize it is mild bht MAME is legendary fir "bite the newbie"
as long as bai continues lab work, and I am not against tbe patch cluster I mentioned
I bet we can have something super spectacular
[20:08]
***JohnTalen has joined #jsmess [20:17]
baiI hit all the high notes too....wrong indentation style, broke the native build, and failed automated testing :D [20:20]
SketchCowyou are scum but I love you [20:29]
..... (idle for 21mn)
balrogbai: not sure if the final PR is right, I see a call to jsmess_machine->run_frame() in js_main_loop() but isn't run_frame() renamed to run_timeslices()? [20:50]
.................. (idle for 1h25mn)
baishoot, did I miss something?
you're right XD
think I just forgot one push
but I'll follow up with one which does this in a less objectionable way anyway
[22:15]
db48xyou should attach your profiles (or at least the screenshots you took) to your pull request [22:19]
baiwell, those are for a different change
this change itself doesn't have any performance impact
[22:20]
db48xit's not about rendering a frame, it's about not spinning the cpu
ah
[22:21]
............ (idle for 59mn)
baibalrog: just pushed some updates to that pull request, thanks for letting me know about the missing code. that's what happens when I try to work on two separate changes at once :D
new version is a lot simpler, mostly puts things back how they were before, just moves some code around to make it accessible to the emscripten loop
[23:20]

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