The MAME hacking continues! Momoko 120% is a run-n-jump platform shooter with an interesting history. I've always enjoyed it, and I've begun doing a full disassembly of the code, partially to learn Z80 assembly and also, as always, to look for any bits of leftovers or unused data. And find something I did!
The game concludes with Momoko getting married, with wedding music and a slow walk. However, there is an unused bit of the ending in which the text "CONGRATULATIONS! ALL PATURN CLR" appears:
Before I give a long technical explanation, here's a MAME cheat to enable the 'proper' ending:
<cheat desc="Fixed ending"> <comment>Set this to view the extra line of text during the game ending</comment> <script state="run"> <action>maincpu.mb@0F3F=85</action> </script> </cheat>
So, the routine to display this 'lost' text begins at 0x0F49. It is called when the game state value (tracked at 0xC080) is 44. Game state 40 initiates the special timed final level; 41 is Momoko's turn towards the church door. The end of that routine sets game state 42, which is Momoko and her groom's slow walk towards each other; it then calls game state 43, which is the fluttering hearts and the appearance of the baby. And at the end of 43, it sets game state to 44, which is the display of our text. So from this we can infer that the game is supposed to display the text but doesn't due to a bug, rather than the text being intentionally removed.
In short, the timer (tracked at 0xC085) is not set to 0 as it should be when entering 0x0F49. For the cheat above, I've patched a tiny bit of the code: in the game state 43 routine, at the end, it sets 0xC01D to zero, for reasons I am not sure of. I've hijacked that opcode and had it write zero to 0xC085 instead, to reset the timer before the state 44 routine is called. I saw no discernible problems with this, and thus the broken ending is restored.