I'm working on a specific part of my Genesis hack right now and it's giving me a headache. The code I wrote looks correct, but it's causing the game to freeze.
I'm writing a condition that affects trading items in game. If the value at a particular RAM offset (FF028F*) is 00, the code points to one routine. If the same offset* is FF, it points to another routine.
Half of the code works (if the offset equals 00). The other half cause the game to freeze (the game is still "running", but you can't do anything). I've highlighted the parts that almost definitely work
in italics, and the parts that I think might be the problem
(offset being tested: FF028F*)01283A 4EF90024008D JMP $0024008D Jumps to $24008D
01286A 0C00002C CMPi.b #$2C, D0 The original ROM code, unedited
0128XX irrelevant code irrelevant N/A24008D 4A3900FF028F TST.b $00FF028F Checks if value at $FF028F* is $00
240093 6700F0C8 BEQ $002400D0 Branches to $2400D0 if ^TRUE^
240097 0C000017 CMPi.b #$17, D0 ***Compares $17 with the value at D024009B 6B2A BMI.s $0001286A If value at D0>$17, branch to $01286A
24009D 4EF900012842 JMP $00012C42 (if D0<$18) jumps to $012C42*** <I've just got a bunch of "00"s separating the next command>2400D0 4EF900012C42 JMP $00012C42 Jumps to $012C42, the original ROM code
<this is followed by a bunch of "00"s>
***This portion of code is paraphrased from the original code at ROM offset $01283A. It is checking a second set of conditions before performing the trade. The major difference in coding is the BMI function, which originally directed the PC to add a value to its current location and begin reading there (instead of my code that tells it directly where to read from).***
Any ideas? I obviously either coded something wrong or else maybe I skipped a step when expanding the ROM?