SNES stack pushing to zero page? ...and other SNES related questions
Posted: Thu Feb 20, 2020 11:50 am
While debugging code I noticed that the return address for a subroutine was pushed to $00:00FE - $00:00FF instead of $00:01FE - $00:01FF. As far as I have read, SNES should use page 1 for stack just like NES, but still it seems to go to zero page. Not sure if I need to post any code, but here is all code until the subroutine:
I'll be posting other questions here as they come up so I don't have to keep making new threads for them.
Code: Select all
WRAM_Clear_DMA_Table:
.byte %00001000 ; DMAPx
.byte $80 ; BBADx
.byte <WRAM_Clear_DMA_Table+7 ; A1TxL
.byte >WRAM_Clear_DMA_Table+7 ; A1TxH
.byte $00 ; A1Bx
.byte $FF ; DASxL
.byte $FF ; DASxH
.byte $00 ; Fill Byte
RESET:
CLC
XCE ; Disable Emulation Mode
SEI
CLD
.a8
.i8
SEP #$30
LDA #$80
STA INIDISP
STZ NMITIMEN
STZ MDMAEN
STZ HDMAEN
LDA #$01
STA MEMSEL
LDX #$FF
TXS
LDX #$01
Memory_Clear_Loop:
LDY #$00
STZ WMADDL ; Set WRAM address for DMA
STZ WMADDM
STX WMADDH
LDA WRAM_Clear_DMA_Table,Y ; Set DMA with fixed Source
STA DMAP0
INY
LDA WRAM_Clear_DMA_Table,Y ; Set DMA destination to $2180
STA BBAD0
INY
LDA WRAM_Clear_DMA_Table,Y
STA A1T0L
INY
LDA WRAM_Clear_DMA_Table,Y
STA A1T0H
INY
LDA WRAM_Clear_DMA_Table,Y
STA A1B0
INY
LDA WRAM_Clear_DMA_Table,Y ; Set DMA transfer to $FFFF bytes
STA DAS0L
INY
LDA WRAM_Clear_DMA_Table,Y
STA DAS0H
LDA #$01
STA MDMAEN ; Start DMA transfer
DEX ; Decrement X and loop to clear the second page
BPL Memory_Clear_Loop
JSR Reset_Register_Setup