-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboot.asm
116 lines (100 loc) · 1.75 KB
/
boot.asm
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
.include "include.mov-macros.asm"
.include "include.sys.asm"
.include "render_action.h.asm"
.include "level_data.h.asm"
.include "general_mapper.h.asm"
.include "memory_layout.h.asm"
.include "gfx.h.asm"
.include "random.h.asm"
.include "intro_outro.h.asm"
.include "famitone.h.asm"
.include "endboss.h.asm"
.importzp bg_x_scroll, bg_y_scroll, main_yield, debug_mode
.importzp ppu_ctrl_current, ppu_mask_current
.importzp player_removed
.import gameplay_palette, graphics0, graphics1
.export RESET, NMI
.segment "BOOT"
RESET:
sei
cld
ldy #$40
sty $4017
dey
StackAndGraphics:
ldx #$ff
txs
inx
stx PPU_CTRL
stx PPU_MASK
stx $4010
stx $4015
Wait0:
bit PPU_STATUS
bpl Wait0
ClearMemory:
ldx #0
:
mov {$000,x}, #0
sta $100,x
sta $300,x
sta $400,x
sta $500,x
sta $600,x
sta $700,x
mov {$200,x}, #$ff
inx
bne :-
Wait1:
bit PPU_STATUS
bpl Wait1
jsr MemoryLayoutInit
jsr ClearBothNametables
lda #1
ldx #<music_data
ldy #>music_data
jsr FamiToneInit
ldx #<sfx_data
ldy #>sfx_data
jsr FamiToneSfxInit
jsr RandomSeedInit
; Exit to the intro
jmp IntroScreen
NMI:
pha
txa
pha
tya
pha
; Yield to next frame.
mov main_yield, #$ff
; DMA sprites.
mov OAM_ADDR, #$00
mov OAM_DATA, #$02
; Execute any render actions that need to happen for level scrolling.
jsr LevelDataUpdateScroll
; Render changes to the PPU.
jsr RenderActionApplyAll
; Boss wing animation.
jsr EndbossAnimation
; Reset ppu pointer.
lda #0
sta PPU_ADDR
sta PPU_ADDR
; Assign the scroll.
lda #0
sta PPU_SCROLL
lda bg_y_scroll
sta PPU_SCROLL
; Assign ppu control.
lda ppu_ctrl_current
sta PPU_CTRL
; Assign ppu mask.
lda ppu_mask_current
sta PPU_MASK
pla
tay
pla
tax
pla
rti