-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.s
63 lines (53 loc) · 1.2 KB
/
template.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
PPUCTRL = $2000
PPUMASK = $2001
PPUSTATUS = $2002
PPUADDR = $2006
PPUDATA = $2007
OAMADDR = $2003
OAMDMA = $4014
.segment "HEADER"
.byte $4e, $45, $53, $1a ; Magic string that always begins an iNES header
.byte $02 ; Number of 16KB PRG-ROM banks
.byte $01 ; Number of 8KB CHR-ROM banks
.byte %00000001 ; Vertical mirroring, no save RAM, no mapper
.byte %00000000 ; No special-case flags set, no mapper
.byte $00 ; No PRG-RAM present
.byte $00 ; NTSC format
.segment "STARTUP"
.segment "CODE"
.proc irq_handler
rti
.endproc
.proc nmi_handler
lda #$00
sta OAMADDR
lda #$02
sta OAMDMA
rti
.endproc
.proc reset_handler
sei
cld
ldx #$00
stx PPUCTRL
stx PPUMASK
vblankwait:
bit PPUSTATUS
bpl vblankwait
.endproc
.proc main
;; Prepare PPU to load a palette
vblankwait: ; wait for another vblank before continuing
bit PPUSTATUS
bpl vblankwait
lda #%10010000 ; turn on NMIs, sprites use first pattern table
sta PPUCTRL
lda #%00011110 ; turn on screen
sta PPUMASK
forever:
jmp forever
.endproc
.segment "VECTORS"
.addr nmi_handler, reset_handler, irq_handler
.segment "CHARS"
.incbin "cart-rom.chr"