I'm working on an emulator in C# (my first, total noob) and using nestest to help implement all my instructions.
I've got a reasonable way; my PC and registers are all correct down to line 863, but now I've hit a problem:
The last action to be executed was LDA $0180 and nestest got a 33 but I got a 0!
I've added logging to my memory and discovered that nothing has ever been written to $0180, which explains it being zero. The value 33 is written to other places (for example, $0080!). I've reviewed the nestest log trying to locate where the 33 is supposed to be written to $0180 with no luck (obviously this is complicated because of indexes, indirect writes, etc.). Strangely, the Accumulator is already 33 at the point this LDA executes (but I presume it's not normal to skip writing to the accumulator if the memory value is 0?!).
So, I'm not expecting anyone to know what my bug is, but I wonder whether there's a good way to debug this. Since the nestest log doesn't contain all memory writes (or at least, I don't think so), is there a good way for me to be able to identify the instruction where it's writing 33 to 0180 so I can check my implementation for that instruction?
Thanks!
I've got a reasonable way; my PC and registers are all correct down to line 863, but now I've hit a problem:
Code:
Instruction not processed correctly at line 863:
CE1E AD 80 01 LDA $0180 = 33 A:33 X:80 Y:01 P:27 SP:80 CYC:158 SL:258
CE21 C9 33 A:33 X:80 Y:01 P:25 SP:80 (expected next state)
CE21 C9 33 A:00 X:80 Y:01 P:27 SP:80 (actual next state)
CE1E AD 80 01 LDA $0180 = 33 A:33 X:80 Y:01 P:27 SP:80 CYC:158 SL:258
CE21 C9 33 A:33 X:80 Y:01 P:25 SP:80 (expected next state)
CE21 C9 33 A:00 X:80 Y:01 P:27 SP:80 (actual next state)
The last action to be executed was LDA $0180 and nestest got a 33 but I got a 0!
I've added logging to my memory and discovered that nothing has ever been written to $0180, which explains it being zero. The value 33 is written to other places (for example, $0080!). I've reviewed the nestest log trying to locate where the 33 is supposed to be written to $0180 with no luck (obviously this is complicated because of indexes, indirect writes, etc.). Strangely, the Accumulator is already 33 at the point this LDA executes (but I presume it's not normal to skip writing to the accumulator if the memory value is 0?!).
So, I'm not expecting anyone to know what my bug is, but I wonder whether there's a good way to debug this. Since the nestest log doesn't contain all memory writes (or at least, I don't think so), is there a good way for me to be able to identify the instruction where it's writing 33 to 0180 so I can check my implementation for that instruction?
Thanks!