I'm trying to figure out why my emulator and every other emulator I've tried behave differently during the first few instructions of Donkey Kong (Japan) being executed.
Nintendulator initializes the PPU registers with 0xFF. When it does
One would expect $2000 to have the value 0x10 in it. This isn't reflected in the CPU memory viewer.
Next, when it does
I would expect 0xFF to be loaded into the accumulator (since $2002 is initialized with 0xFF in this emulator. That's not the case. It actually loads the value 0x10 into the accumulator. Where does this value come from?
In my emulator, my memory is initialized to 0x00, so when it does the load from $2002, I load the value 0x00 into the accumulator.
Code:
;Disable interrupts
C79E : 78 sei ;
;Clear the CPU's decimal flag
C79F : D8 cld ;
;Reset PPU control (including the disabling of VBL interrupts)
C7A0 : A9 10 lda #$10 ;
C7A2 : 8D 00 20 sta $2000 ;
;Init stack pointer
C7A5 : A2 FF ldx #$FF ;
C7A7 : 9A txs ;
;Wait for VBL, looping until it happens
C7A8 : AD 02 20 lda $2002 ;
C7AB : 29 80 and #$80 ;
C7AD : F0 F9 beq $C7A8 ;
C79E : 78 sei ;
;Clear the CPU's decimal flag
C79F : D8 cld ;
;Reset PPU control (including the disabling of VBL interrupts)
C7A0 : A9 10 lda #$10 ;
C7A2 : 8D 00 20 sta $2000 ;
;Init stack pointer
C7A5 : A2 FF ldx #$FF ;
C7A7 : 9A txs ;
;Wait for VBL, looping until it happens
C7A8 : AD 02 20 lda $2002 ;
C7AB : 29 80 and #$80 ;
C7AD : F0 F9 beq $C7A8 ;
Nintendulator initializes the PPU registers with 0xFF. When it does
Code:
C7A0 : A9 10 lda #$10 ;
C7A2 : 8D 00 20 sta $2000 ;
C7A2 : 8D 00 20 sta $2000 ;
One would expect $2000 to have the value 0x10 in it. This isn't reflected in the CPU memory viewer.
Next, when it does
Code:
C7A8 : AD 02 20 lda $2002 ;
I would expect 0xFF to be loaded into the accumulator (since $2002 is initialized with 0xFF in this emulator. That's not the case. It actually loads the value 0x10 into the accumulator. Where does this value come from?
In my emulator, my memory is initialized to 0x00, so when it does the load from $2002, I load the value 0x00 into the accumulator.