mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-12-28 05:29:33 +00:00
100 lines
1.5 KiB
Plaintext
100 lines
1.5 KiB
Plaintext
|
|
;#define LIBARGS ,
|
|
|
|
;
|
|
; iNES header
|
|
;
|
|
|
|
.segment "HEADER"
|
|
|
|
INES_MAPPER = 0 ; 0 = NROM
|
|
INES_MIRROR = 1 ; 0 = horizontal mirroring, 1 = vertical mirroring
|
|
INES_SRAM = 0 ; 1 = battery backed SRAM at $6000-7FFF
|
|
|
|
.byte 'N', 'E', 'S', $1A ; ID
|
|
.byte $02 ; 16k PRG chunk count
|
|
.byte $01 ; 8k CHR chunk count
|
|
.byte INES_MIRROR | (INES_SRAM << 1) | ((INES_MAPPER & $f) << 4)
|
|
.byte (INES_MAPPER & %11110000)
|
|
.byte $0, $0, $0, $0, $0, $0, $0, $0 ; padding
|
|
|
|
;;;;; START OF CODE
|
|
|
|
.segment "CODE"
|
|
Start:
|
|
sei ; mask interrupts
|
|
lda #0
|
|
sta $2000 ; disable NMI
|
|
sta $2001 ; disable rendering
|
|
sta $4015 ; disable APU sound
|
|
sta $4010 ; disable DMC IRQ
|
|
lda #$40
|
|
sta $4017 ; disable APU IRQ
|
|
cld ; disable decimal mode
|
|
ldx #$FF
|
|
txs ; initialize stack
|
|
; wait for first vblank
|
|
bit $2002
|
|
:
|
|
bit $2002
|
|
bpl :-
|
|
; clear all RAM to 0
|
|
lda #0
|
|
ldx #0
|
|
:
|
|
sta $0000, X
|
|
sta $0100, X
|
|
sta $0200, X
|
|
sta $0300, X
|
|
sta $0400, X
|
|
sta $0500, X
|
|
sta $0600, X
|
|
sta $0700, X
|
|
inx
|
|
bne :-
|
|
; place all sprites offscreen at Y=255
|
|
lda #255
|
|
ldx #0
|
|
:
|
|
sta $200, X
|
|
inx
|
|
inx
|
|
inx
|
|
inx
|
|
bne :-
|
|
; wait for second vblank
|
|
:
|
|
bit $2002
|
|
bpl :-
|
|
; NES is initialized, ready to begin!
|
|
; enable the NMI for graphical updates, and jump to our main program
|
|
lda #%10001000
|
|
sta $2000
|
|
Endless:
|
|
jmp Endless ; endless loop
|
|
|
|
;;;;; INTERRUPT HANDLERS
|
|
|
|
NMIHandler:
|
|
rti
|
|
|
|
;;;;; CPU VECTORS
|
|
|
|
.segment "VECTORS"
|
|
|
|
.word NMIHandler
|
|
.word Start
|
|
.word NMIHandler
|
|
|
|
;
|
|
; CHR ROM
|
|
;
|
|
.segment "CHARS"
|
|
.incbin "jroatch.chr"
|
|
|
|
;
|
|
; .etc
|
|
;
|
|
.segment "STARTUP"
|
|
.segment "SAMPLES"
|