This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Funny Game Genie bug in Contra

Funny Game Genie bug in Contra
by on (#79725)
Hey all. I thought I found a bug in my emulator last night while playing contra with some game genie codes turned on. But I was able to reproduce the effect in Nestopia and realized it wasn't really a bug. It turns out that if you have both...

GXIIUX: keep gun after losing a life
...and...
PEIIXZ: start new life with machine gun

...codes turned on, then when you die your character will get stuck in an infinite loop of death (assuming you also have the cheat code for infinite lives turned on) in the bottom-left corner of the screen. lmao. Turn either of the above gun codes off in real-time and the looping will stop and the character will revive onto the screen as normal. Try it out for yourself!

Just thought I would share because it was funny. Good to know that it's not a problem with my emu!

Pz!

Jonathon

by on (#79746)
Did you examine the ASM cause of this? Or see if making it an 8 letter code would prevent that?

by on (#79748)
Nah, didn't try any of that. Though it might be interesting if someone wanted to find out. However, it's not that big of a deal since there is really no reason to be using both of those gun codes simultaneously - because their effects are almost identical. So easier to just stick with using one of the two rather than trying to find a fix. I only found it by accident because I forgot to deactivate the previous gun code when I entered the second one. Lol. :)

by on (#79788)
GXIIUX becomes [DAD3]<-$2C; PEIIXZ becomes [DAD2]<-$1. Contra is an UNROM game and this is in the fixed bank, so a 8-letter code won't help. The disasssembly right around here is

DAD1: lda #0 ; A9 00
DAD3: sta $AA,x ; 95 AA
DAD5: lda #0 ; A9 00

PEIIXZ is easier: it just changes DAD1 to "lda #1"

GXIIUX is a smidge messier-
DAD3: bit $a9aa
DAD6: brk

But that's safe, because the IRQ handler just points to RTI.

The reason it goes into an infinite loop has to do with what comes after:

DAD7: sta $300,x
DADA: sta $31A,x
DADD: sta $334,x
DAE0: sta $34E,x
DAE3...DB25: sta $92..$da,x

Clearly it needs to be writing 0 to all the later addresses for this to work. Weirdly, had the code just used BIT zeropage instead of BIT absolute it wouldn't have triggered this bug.

by on (#79790)
Haha, damn dude, that's awesome that you figured that out. Very cool! Thanks for this interesting info. :)