Can mother 3 be hacked to expand battle rhythm system for emulator input lag?

Started by skroops, September 20, 2016, 05:16:45 PM

Previous topic - Next topic

skroops

Mother 3's battle system doesn't work on emulators. That's because the process of emulating always introduces some amount of input lag, that is, a delay between what you see (and hear) on the screen and when the emulator is actually capturing your input.

This is especially problematic in Mother 3, because when you attempt to tap the a button in the battle music rhythm system, the opportunity to hit at the right time and build up combos is very tight. A good way of thinking of it is that there is a window when the system expects you to tap the a button that corresponds to the beat of the music, and that "window" is very small. So when you play on a GBA, it can be challenging to hit the rhythm consistently. On the GBA, that's pretty cool, because you feel rewarded when you are able to hit the rhythm and get that extra damage.

However, because the window is so tight, the input lag of emulators makes it virtually impossible to hit the rhythm in Mother 3. The only way to really hit it is to tap early, and even then it is extremely difficult.

I'm not very good at romhacking, but I have an idea of it. There must be some code in the game that does something like:

1. "start window to press A button for rhythm system"
2. "check if user has pressed A button"
-2a. "if user pressed A button, register combo hit"
3. "close window"

Wouldn't it be possible to modify the battle code so that the system allows input for a few extra cycles? Then, Mother 3 would be fully playable on emulators. This would make it "easier", technically, but effectively just makes it possible to use the rhythm system.

Some people might say that mother 3 is fully playable without the rhythm system working. I would respond that Mother 3 is fully playable in Japanese.

FCandChill

###
#1
 Comment removed because reasons...

FAST6191

You are not the first person to ask this
http://www.romhacking.net/forum/index.php/topic,3282.msg305567.html#msg305567

I have still yet to investigate this properly or try the stuff I mentioned in reply to that.

Disch

Quote from: FCandChill on September 20, 2016, 09:09:30 PM
Also I'm what the actual cause of the lag is ... is it the emulator itself or does one need to acquire a more powerful machine?

Short answer:

It's the emulator.  It has to do with audio latency.  It's unavoidable.



Long answer:

Audio streaming on PCs works by having a circular buffer (or series of buffers) that you fill with audio data.  The audio device/sound card takes these buffers and plays them back at a steady rate.

You can think of it like an hourglass.  You pour audio (sand) in the top, and it slowly drains out the bottom at a steady pace.  If you ever run out of audio in the buffers (sand in the top), the stream breaks and your audio is disrupted.

A bigger buffer (cup) means less chance of that happening... but also a bigger delay between when the audio is generated and when it is actually heard.


Emulators generate audio when they emulate the frame.  At 60fps that means they're generating roughly 17ms worth of audio.  But usually the buffer is around 100 ms long, so it's several frames between when the audio is generated and when it actually gets to the speakers.  The buffer size is also called "audio latency" and many emus have it configurable.  Again, lower=less delay (better) but higher risk of underrun (breaks in the audio).


The original GBA did not have latency because the PSG likely connected directly to the speakers.  There was no intermediary buffer, so you heard the sound immediately as it was played.  Same can't be done on PCs because audio hardware doesn't allow for on-the-fly audio generation -- that has to be done in software.  Which means a buffer.  Which means latency.

skroops

Thanks for your reply guys

@Disch:  I definitely realize the limitations of emulating the sound on Mother 3.  That's why I'm suggesting a hack to essentially make MOther 3 work in easy-mode.  We can't fix input latency on emulators beyond a certain point, I realize that, and Mother 3 is especially picky on input.

@Fast6191:  Thanks.  I will look at this information more thoroughly.  I'm not opposed to doing it myself.  I don't know if I'm capable, but if I can just trace the code that accepts input presses in Mother 3, then slightly modify it to give a bigger window, Mother 3 would be playable on emulators, I hope. 
Is there any good debugging solution for GBA on Windows?  Like, if it was a PC game, I think I could track the input call for the A button battle system press in Cheat Engine.  Can I apply that skill somehow to make a hack on GBA?  I mean, forgetting a romhack, I think this even might be able to be done with a gameshark code.  It's just a matter of finding the timing constant, maybe?

@FCandChill
Yes, a hack to allow laggy input is exactly what I'm talking about.  My PC is pretty sweet, but regardless, even average PC's should be able to enjoy mother.

PresidentLeever

I remember reading about changing the emulator settings to fix it when the translation was new, not sure where though.
Mini-reviews, retro sound chip tribute, romhacks and general listage at my site: Mini-Revver.

FAST6191

If you are used to playing with IDA on a PC/X86 then nothing on any other system approaches it but you are certainly not without options. Hacking wise I would put the GBA as only slightly behind the NES (fceux there provides a very high bar to beat), there are a few emulators with debug capabilities but http://problemkaputt.de/gba.htm#debug is free these days and beats vba-sdl-h and BoycottAdvance in most ways that matter.
I actually have yet to get around to properly doing the GBA audio side of things in this but I do link a few things, as well as cover some assembly concepts and have links there too
http://trastindustries.com/randomfiles/romhacking2016_copy_1.pdf

Doing it with a RAM code... I would be impressed for the GBA. For the DS the binary is in memory so can be fiddled with by RAM codes rather than game genie codes. Technically the gameshark does have the option for a single 16 bit ROM patch http://doc.kodewerx.org/hacking_gba.html#gsadescribe but for emulator purposes it is typically all RAM codes. That is not a problem though as you can hardpatch cheats into GBA games fairly readily with various tools, though GBAATM is probably the one most would go for these days.

Jorpho

Quote from: skroops on September 20, 2016, 05:16:45 PMSo when you play on a GBA, it can be challenging to hit the rhythm consistently. On the GBA, that's pretty cool, because you feel rewarded when you are able to hit the rhythm and get that extra damage.

However, because the window is so tight, the input lag of emulators makes it virtually impossible to hit the rhythm in Mother 3. The only way to really hit it is to tap early, and even then it is extremely difficult.
Have you played the game on a GBA personally?  As Mr. Jink640 says in that other thread, "the combo system is just strict as hell".

I feel that this is another occasion in which, if some kind of fix was at all feasible, someone in the massed legions of Earthbound fans (some of whom surely have considerably more experience with hacking) would have surely pulled it off in all the years since the game was released.
This signature is an illusion and is a trap devisut by Satan. Go ahead dauntlessly! Make rapid progres!

Tsukiyomaru0

Mother 3 really has a stupidly strict combo system. Heck, even Rhythm Tengoku is LENIENT compared to it!

henke37

The gba has a audio buffer of its own, since all games that want decent audio has to run a software mixer and more or less ignore the hardware waveform generators.

rainponcho

Not very good at tracing gba games.

809f2de = start attack routine (01 = pre-beat section)
809d852 = in-beat section, sets flag 02
809d810 = post-beat section, sets flag 04

809d728 = actual attack
- 809d79c = 01 flag, miss - done
- 809d728 = 02 flag, okay - repeat


note: by setting flag 04 -> 02 ~ 809d810, you get infinite chance to hit if too late.


Maybe someone can continue - this is hard to follow.