2018-07-12 16:30:35 +00:00
|
|
|
#if not(NES)
|
|
|
|
#warn nes_routines module should be only used on NES/Famicom targets
|
|
|
|
#endif
|
2018-03-15 22:46:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
asm void on_reset() {
|
|
|
|
SEI
|
|
|
|
CLD
|
|
|
|
LDX #$40
|
|
|
|
STX $4017
|
|
|
|
LDX #$ff
|
|
|
|
TXS
|
|
|
|
INX
|
|
|
|
STX ppu_ctrl
|
|
|
|
STX ppu_mask
|
|
|
|
STX $4010
|
|
|
|
BIT ppu_status
|
|
|
|
vwait1:
|
|
|
|
BIT ppu_status
|
|
|
|
BPL vwait1
|
|
|
|
vwait2:
|
|
|
|
BIT ppu_status
|
|
|
|
BPL vwait2
|
|
|
|
|
|
|
|
|
|
|
|
LDA #$00
|
|
|
|
LDX #$00
|
|
|
|
clean_byte:
|
|
|
|
STA $000,x
|
|
|
|
STA $100,x
|
|
|
|
STA $200,x
|
|
|
|
STA $300,x
|
|
|
|
STA $400,x
|
|
|
|
STA $500,x
|
|
|
|
STA $600,x
|
|
|
|
STA $700,x
|
|
|
|
INX
|
|
|
|
BNE clean_byte
|
|
|
|
|
|
|
|
LDA #$00
|
|
|
|
STA $2000
|
|
|
|
STA $2001
|
|
|
|
|
|
|
|
JMP main
|
|
|
|
JMP on_reset
|
|
|
|
}
|
|
|
|
|
|
|
|
interrupt void on_irq() {
|
|
|
|
irq()
|
|
|
|
}
|
|
|
|
|
|
|
|
interrupt void on_nmi() {
|
|
|
|
nmi()
|
|
|
|
}
|
|
|
|
|
2019-06-26 16:13:00 +00:00
|
|
|
const array nmi_vector @$FFFA = @word [on_nmi.addr]
|
2018-07-03 21:29:37 +00:00
|
|
|
|
2019-06-26 16:13:00 +00:00
|
|
|
const array reset_vector @$FFFC = @word [on_reset.addr]
|
2018-07-03 21:29:37 +00:00
|
|
|
|
2019-06-26 16:13:00 +00:00
|
|
|
const array irq_vector @$FFFE = @word [on_irq.addr]
|
2018-03-15 22:46:16 +00:00
|
|
|
|