punesemu / puNES

Qt-based Nintendo Entertaiment System emulator and NSF/NSF2/NSFe Music Player (Linux, FreeBSD, OpenBSD and Windows)
GNU General Public License v2.0
597 stars 40 forks source link

Formation Z cheat for number of lives causes unexpected behaviour in puNES #360

Closed TCH68k closed 6 months ago

TCH68k commented 6 months ago

In the game called Formation Z (http://oscomp.hu/?details/Formation_Z_NES_881) the number of lives is stored at the address of $0032. If - for instance - you set a cheat to write $05 to here, then the game somewhy activates player 2 too and if you die, you have to wait until player 2 dies to regain control.

This cheat works in FCE Ultra 0.98.13-pre (http://oscomp.hu/?details/FCE_Ultra_Win32_0.98.13-pre_Win32_4) without player 2 being activated.

punesemu commented 6 months ago

The game uses this memory location as a temporary variable used by the routine to control the lives of both players (which will therefore actually be stored in another memory area). When the routine checks the number of lives left it does so for both players even if you have selected only one player, only in this case for player2 this value will always be 0xFF while for player1 it will be the actual number of lives left. Therefore, by always setting the value 0x05, the routine will also read it for player2 thinking that he is actually playing. To avoid running into your problem, set "compare" to enable, setting it to "0x00". In this way when the routine finds 0xFF for player2 and when player1 reaches 0 lives it will start again from 5. I hope I was able to explain well.

TCH68k commented 6 months ago

Yes, you've explained it perfectly and it works, thank you. However, i don't understand, that why did this work without comparing in FCE Ultra. I did not set any comparation in there either.