[04:11] I'll be right over
[04:11]
[04:14] heh
[04:19] *** taisel has joined #jsmess
[05:28] *** taisel has quit IRC (Quit: Leaving)
[05:33] *** icculus has joined #jsmess
[05:34] hello, Jason Scott sent me.
[05:35] oh man, bringing in the big guns :D
[05:36] welcome
[05:37] hi. :)
[05:38] so how much do you know about what's going on in here? I'm more than happy to get you up to speed
[05:38] Jason said there was some sort of MAME-vs-Emscripten issue, and I should come get technical details from the fine folk in this channel.
[05:38] Something about it using 100% CPU for no good reason
[05:39] yeah, so it's been working pretty solid for a while now, but we want it faster and yeah, less cpu burning when idle
[05:39] MAME is built using the standard game loop architecture, a tight loop executing as fast as possible, with some calls to a sleep wrapper which calls the appropriate sleep function for the platform
[05:40] to control timing of machine chips and ultimately frame output
[05:41] but with emscripten...well, how much do you know about that whole thing, specifically its async handler?
[05:41] I’ve gotten a few games running with Emscripten: https://icculus.org/ut99-emscripten/ and some stuff on playonjump.com
[05:41] So I’m pretty familiar
[05:43] cool, yeah I figured. so, we've modified MAME's main game loop to use emscripten_set_main_loop, and as it is now we basically have it hardcoded to assume 60fps, and to advance the machine's internal emulation clock by the appopriate number of ticks
[05:44] https://github.com/mamedev/mame/blob/master/src/emu/machine.cpp#L1321-L1360
[05:45] using that code, the cpu profile looks like this https://i.imgur.com/80HgKvk.png
[05:46] because scheduler->timeslice();
[05:46] oops
[05:46] because scheduler->timeslice() is where all the sleep() magic happens for timing
[05:47] and on the emscripten platform it's just doing the naive while (Date.now() < t) {} style sleep implementation
[05:47] So this is just burning the entire ~16 milliseconds, returning so the framebuffer can swap, and then starting again, 60 times a second
[05:47] yup
[05:48] This should be solvable, then.
[05:48] now, I've got an experimental branch which tries to handle it a bit more intelligently - if the system is asked to sleep() for longer than the amount of time left in this frame, it basically stops processing until the next emcripten main loop call
[05:49] this ends up looking like this https://i.imgur.com/YEEbT9b.png - much cleaner
[05:49] but it introduces some timing issues
[05:50] How long are these sleeps intended to be, generally?
[05:50] because I did it in a pretty hacky way while trying to work through some theories, and my feeble brain turns to mush when I try to consider the delicate timing balance of a system like this
[05:50] are they…five milliseconds or like 50 milliseconds?
[05:51] let me refresh myself on the code. I think the mame functions themselves are in something insane like picoseconds
[05:56] attoseconds
[05:59] that's right
[06:00] sorry dealing with space issues on my vm. I guess a stock ubuntu install chews right through 12 now
[06:00] 12 gigs*
[06:02] no worries
[06:03] the more direct question: where do I build this from? Is it on mamedev/mame, or is this a separate fork elsewhere?
[06:03] it's all part of the official release now, except for my hacks
[06:04] ok, I’m going to poke at it in the morning, then, and hopefully I’ll make some progress.
[06:04] sweet
[06:04] I'll dig up my own patches by then to give you a starting point of where in the codebase you'll want to poke things
[06:05] for now, though, I’m going to sleep. I’ll idle in this channel though, in case anyone wants me to hear any details.
[06:05] ok, that’s great, thank you!
[06:05] sounds good, looking forward to seeing what we can come up with
[06:05] been a long-standing issue
[06:45] Haha
[06:45] I think my internet is a closed loop now
[06:46] I need new circles, everyone I know ends up in here
[06:54] all roads lead to #jsmess
[07:24] I never stop
[07:24] You said we needed people, I got people
[07:26] icculus: Bai is the main person who was trying this but he got super busy because his company needs him
[07:27] icculus: DFJustin has worked in MAME a long time, he can help. A pile of other people are here and can help as well: azakai is the maintainer of Emscripten, db48x has done a bunch of work with all this, and Vito` and devesine also have done massive work in the past.
[12:46] *** icculus has quit IRC (icculus)
[13:30] *** icculus has joined #jsmess
[15:15] omg, this thing takes forever to build. Emulate less hardware next time! lol
[15:56] *** icculus has quit IRC (icculus)
[15:57] *** icculus has joined #jsmess
[15:57] *** icculus has quit IRC (Client Quit)
[15:57] *** icculus has joined #jsmess
[15:58] *** icculus has quit IRC (Client Quit)
[16:58] How's it going for you?
[17:05] :)
[17:07] On my side, I've been ripping CD-ROMs all morning.
[17:07] Someone sent me 500
[17:08] nice
[17:32] Yeah, it's going to kick ass to get these up
[17:33] Then it's time to sort them, and maybe consider breaking some out into emulated chunks.
[17:49] *** icculus has joined #jsmess
[18:47] *** icculus_ has joined #jsmess
[18:49] By the way, the latest podcast episode is about Emulation
[18:49] (and a demo I like that's an emulator)
[18:50] *** icculus has quit IRC (Read error: Operation timed out)
[18:50] *** icculus_ is now known as icculus
[18:51] *** icculus has quit IRC (Client Quit)
[19:31] *** icculus has joined #jsmess
[19:31] Uh, is it normal to not be able to link this in 16 gigabytes of RAM? https://gist.github.com/rcgordon/d57e1e3fb504cb698edb091543bda27b
[19:31] This was just a git clone, then CC=emcc make
[19:31] which might totally be the wrong way to do this
[19:33] icculus: oh, yeah you generally don't want to do a full build of all systems
[19:34] we normally do a build per system
[19:34] oh
[19:38] I think what you want is something like "emmake make SOURCES=src/mame/drivers/pacman.cpp"
[19:40] yeah, that builds much quicker. :)
[19:49] finding the right source file for the system you're targeting is a bit of black magic, mame has a -listsource file but it's....well....it's just dumb and wrong half the time :D
[19:49] eg, "mame -listsource pacman" tells you the source is "pacman.c" when really it's "src/mame/drivers/pacman.cpp"
[19:50] (plus you need a native build to do it, too)
[19:55] yea, I really want better automation there
[20:07] *** icculus has quit IRC (icculus)
[20:08] Oops, h's gone
[20:08] we killed him
[20:08] this seems promising
[20:31] *** azakai has quit IRC (Quit: Ex-Chat)
[21:57] -listsource should always be correct although it doesn't specify src/mame/drivers/
[21:57] if there's a mismatch, the mame in your path may be out of date
[22:07] *** azakai has joined #jsmess
[23:07] *** icculus has joined #jsmess
[23:11] hmm, I suppose that's not impossible, I might have a system-installed binary version
[23:12] wonder when they switched from .c to .cpp
[23:13] * db48x recommends running "type mame"
[23:15] yeah, it's definitely a system install, just not sure how old we're talking :D
[23:22] *** icculus has quit IRC (icculus)