Remove CurrentBank as game runs in NMI handler only
parent
23ac63a261
commit
9711b4ecc1
27
src/main.asm
27
src/main.asm
|
@ -532,7 +532,6 @@ AltRegContentFlag = $07ca
|
|||
|
||||
; mapper specific defines
|
||||
|
||||
CurrentBank = $15 ; The mapper is read-only; need to track its state separately
|
||||
CharsCopy = $41 ; Reserving $41 and $42
|
||||
XStore = $43 ; To store the X register
|
||||
|
||||
|
@ -868,7 +867,7 @@ SkipMainOper:
|
|||
pla
|
||||
ora #%10000000 ; reactivate NMIs
|
||||
sta PPU_CTRL_REG1
|
||||
rts ; we are done until the next frame!
|
||||
rti ; we are done until the next frame!
|
||||
|
||||
;-------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -17309,24 +17308,21 @@ StartBankSwitch:
|
|||
jsr BankSwitch
|
||||
jmp Start
|
||||
|
||||
; We make sure to have Bank 0 loaded at NMI, as the NMI code is located there; we switch back to the saved bank when we are done
|
||||
; We make sure to have Bank 0 loaded at NMI, as the NMI code is located there
|
||||
NonMaskableInterruptBankSwitch:
|
||||
ldx #$00
|
||||
jsr BankSwitchNoSave
|
||||
jsr NonMaskableInterrupt
|
||||
ldx CurrentBank
|
||||
jsr BankSwitchNoSave
|
||||
rti
|
||||
jsr BankSwitch
|
||||
jmp NonMaskableInterrupt
|
||||
|
||||
; Area data is located in Bank 1; we switch back to Bank 0 when we are done
|
||||
AreaDataBankSwitch:
|
||||
stx XStore ; We need to save the value of X because X is used for bank switching
|
||||
ldx #$01
|
||||
jsr BankSwitchNoSave
|
||||
jsr BankSwitch
|
||||
lda (AreaData),y
|
||||
pha ; We need to save the byte because A is used for bank switching
|
||||
ldx #$00
|
||||
jsr BankSwitchNoSave
|
||||
jsr BankSwitch
|
||||
pla
|
||||
ldx XStore
|
||||
rts
|
||||
|
@ -17335,11 +17331,11 @@ AreaDataBankSwitch:
|
|||
EnemyDataBankSwitch:
|
||||
stx XStore ; We need to save the value of X because X is used for bank switching
|
||||
ldx #$01
|
||||
jsr BankSwitchNoSave
|
||||
jsr BankSwitch
|
||||
lda (EnemyData),y
|
||||
pha ; We need to save the byte because A is used for bank switching
|
||||
ldx #$00
|
||||
jsr BankSwitchNoSave
|
||||
jsr BankSwitch
|
||||
pla
|
||||
ldx XStore
|
||||
rts
|
||||
|
@ -17356,16 +17352,13 @@ CopyCharsBankSwitch:
|
|||
; The sound engine is located in Bank 2; we switch back to Bank 0 when we are done
|
||||
SoundEngineBankSwitch:
|
||||
ldx #$02
|
||||
jsr BankSwitchNoSave
|
||||
jsr BankSwitch
|
||||
jsr SoundEngine
|
||||
ldx #$00
|
||||
jsr BankSwitchNoSave
|
||||
jsr BankSwitch
|
||||
rts
|
||||
|
||||
BankSwitch:
|
||||
stx CurrentBank ; save the current bank in RAM so the NMI handler can restore it
|
||||
|
||||
BankSwitchNoSave:
|
||||
lda BankTable,x ; remap from the convenient banks numbered 0 through 2 to the value needed by the hardware
|
||||
sta BankTable,x ; and write it to the corresponding entry, switching banks
|
||||
rts
|
||||
|
|
Loading…
Reference in New Issue