I'm writing a simple video player ROM from scratch, and I'm confused on something. With the following code:
I would expect NMI interrputs to jump to $C0FF10, based on the vector table, however, running it in bsnes-plus, if I set a breakpoint on $C0FF10, I never hit it. Instead, I hit $C0FF14 instead. Am I doing something wrong, or just misunderstanding how the vectors work? For now, I've just resorted to putting all of my NMI handling in the IRQ handler instead, which seems to be working, but I'm running into issues where I'm only able to DMA about half of the VRAM data I expect, and I'm curious if maybe this issue is somehow related. Even if not, I'd at least like to try and understand what's going on.
Code:
arch snes.cpu
macro seek(variable offset) {
origin (offset) & $3FFFFF
base offset
}
// ===Interrupt Handlers===
seek($C00500)
nmi:
// Do NMI stuff
rti
irq:
// Do IRQ stuff
rti
// ===Initialization Routine===
seek($C02000)
__init:
// Init stuff here
// . . .
jml __main
// ===Interrupt Vectors===
seek($C0FF00)
// RESET
sei
clc
xce
rep #$18
ldx #$1FFF
txs
jml __init
seek($C0FF10)
// NMI
jml nmi
seek($C0FF14)
// IRQ
jml irq
seek($C0FF18)
// BRK
-// lda $ABCDEF
bra -
seek($C0FFFF)
// EMPTY VECTOR
rti
seek($C0FFB0)
// ===Internal Header===
snes_header:
dw $3713 // Maker code
db 'M','S','U','1' // Game code
// Reserved
db $00,$00,$00,$00,$00,$00,$00
db $00 // Exp RAM size
db $00 // Special version
db $00 // Cartridge type
// ROM Name
db 'M','S','U','-','1',' ','V','i','d','e','o'
db ' ','T','e','s','t',' ','R','O','M',' '
db $31 // Mapper
db $02 // ROM type
db $0C // ROM size
db $03 // SRAM size
db $01 // Country code
db $33 // Reserved
db $01 // Version number
dw $AA00 // Checksum complement
dw $55FF // Checksum
// ===Vector Table===
// Native Mode
dd $FFFFFFFF // UNUSED
dw $FFFF // COP
dw $FF18 // BRK
dw $FFFF // ABORT
dw $FF10 // NMI
dw $FFFF // RESET
dw $FF14 // IRQ
// Emulation Mode
dd $FFFFFFFF // UNUSED
dw $FF18 // COP
dw $FFFF // BRK
dw $FFFF // ABORT
dw $FFFF // NMI
dw $FF00 // RESET
dw $FFFF // IRQ
seek($D00000)
__main:
sep #$20 // Set the A register to 8-bit.
lda #$80
sta $4200 // Enable NMI
// Loop forever.
-; bra -
macro seek(variable offset) {
origin (offset) & $3FFFFF
base offset
}
// ===Interrupt Handlers===
seek($C00500)
nmi:
// Do NMI stuff
rti
irq:
// Do IRQ stuff
rti
// ===Initialization Routine===
seek($C02000)
__init:
// Init stuff here
// . . .
jml __main
// ===Interrupt Vectors===
seek($C0FF00)
// RESET
sei
clc
xce
rep #$18
ldx #$1FFF
txs
jml __init
seek($C0FF10)
// NMI
jml nmi
seek($C0FF14)
// IRQ
jml irq
seek($C0FF18)
// BRK
-// lda $ABCDEF
bra -
seek($C0FFFF)
// EMPTY VECTOR
rti
seek($C0FFB0)
// ===Internal Header===
snes_header:
dw $3713 // Maker code
db 'M','S','U','1' // Game code
// Reserved
db $00,$00,$00,$00,$00,$00,$00
db $00 // Exp RAM size
db $00 // Special version
db $00 // Cartridge type
// ROM Name
db 'M','S','U','-','1',' ','V','i','d','e','o'
db ' ','T','e','s','t',' ','R','O','M',' '
db $31 // Mapper
db $02 // ROM type
db $0C // ROM size
db $03 // SRAM size
db $01 // Country code
db $33 // Reserved
db $01 // Version number
dw $AA00 // Checksum complement
dw $55FF // Checksum
// ===Vector Table===
// Native Mode
dd $FFFFFFFF // UNUSED
dw $FFFF // COP
dw $FF18 // BRK
dw $FFFF // ABORT
dw $FF10 // NMI
dw $FFFF // RESET
dw $FF14 // IRQ
// Emulation Mode
dd $FFFFFFFF // UNUSED
dw $FF18 // COP
dw $FFFF // BRK
dw $FFFF // ABORT
dw $FFFF // NMI
dw $FF00 // RESET
dw $FFFF // IRQ
seek($D00000)
__main:
sep #$20 // Set the A register to 8-bit.
lda #$80
sta $4200 // Enable NMI
// Loop forever.
-; bra -
I would expect NMI interrputs to jump to $C0FF10, based on the vector table, however, running it in bsnes-plus, if I set a breakpoint on $C0FF10, I never hit it. Instead, I hit $C0FF14 instead. Am I doing something wrong, or just misunderstanding how the vectors work? For now, I've just resorted to putting all of my NMI handling in the IRQ handler instead, which seems to be working, but I'm running into issues where I'm only able to DMA about half of the VRAM data I expect, and I'm curious if maybe this issue is somehow related. Even if not, I'd at least like to try and understand what's going on.