forked from mitch3b/BlockDude
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreset.s
executable file
·200 lines (161 loc) · 2.84 KB
/
reset.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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
; Startup code for cc65/ca65
.import _main
.export __STARTUP__:absolute=1, _hide_sprites
.importzp _NMI_flag, _Frame_Count
.importzp _Horiz_scroll, _Nametable, _Erase_X, _Erase_Y, _Block_X, _Block_Y
; Linker generated symbols
.import __STACK_START__, __STACK_SIZE__
.import NES_PRG_BANKS, NES_CHR_BANKS
.include "zeropage.inc"
.import initlib, copydata
.segment "ZEROPAGE"
NTSC_MODE: .res 1
;FT_TEMP: .res 3
TEMP: .res 11
.segment "HEADER"
.byte $4e,$45,$53,$1a
.byte 01 ;<NES_PRG_BANKS
.byte 01 ;<NES_CHR_BANKS
.byte 01 ;vertical mirroring = horizontal scrolling
.byte 00
.res 8,0
.segment "STARTUP"
start:
sei
cld
ldx #$40
stx $4017
ldx #$ff
txs
inx
stx $2000
stx $2001
stx $4010
:
lda $2002
bpl :-
lda #$00
Blankram:
sta $00, x
sta $0100, x
sta $0200, x
sta $0300, x
sta $0400, x
sta $0500, x
sta $0600, x
sta $0700, x
inx
bne Blankram
:
lda $2002
bpl :-
Isprites:
jsr hide_sprites
jsr ClearNT
MusicInit: ;turns music channels off
lda #0
sta $4015
lda #<(__STACK_START__+__STACK_SIZE__)
sta sp
lda #>(__STACK_START__+__STACK_SIZE__)
sta sp+1 ; Set the c stack pointer
lda #1
sta NTSC_MODE
;init sfx
ldx #<sounds ;set sound effects data location
ldy #>sounds
jsr FamiToneSfxInit
jsr copydata
jsr initlib
lda $2002 ;reset the 'latch'
jmp _main ;jumps to main in c code
_hide_sprites:
hide_sprites:
ldy #$40
ldx #$00
lda #$f8
hide_sprites2: ;puts all sprites off screen
sta $0200, x
inx
inx
inx
inx
dey
bne hide_sprites2
rts
_ClearNT:
ClearNT:
lda $2002
lda #$20
sta $2006
lda #$00
sta $2006
lda #$00 ;tile 00 is blank
ldy #$10
ldx #$00
BlankName: ;blanks screen
sta $2007
dex
bne BlankName
dey
bne BlankName
rts
nmi:
pha
tya
pha
txa
pha
inc _NMI_flag
inc _Frame_Count
lda #0
sta $2003
lda #2
sta $4014 ;push sprite data to OAM from $200-2ff
lda #$80
clc
adc _Nametable
sta $2000 ;nmi on
lda #$1e
sta $2001 ;screen on
lda $2002 ;reset the latch
lda _Block_Y ; TODO I bet this would be faster to check if there's something to write
beq SkipBlockWrite
sta $2006
lda _Block_X
sta $2006
lda #$03
sta $2007
SkipBlockWrite:
lda _Erase_Y
beq SkipEraseBlock
sta $2006
lda _Erase_X
sta $2006
lda #$01
sta $2007
SkipEraseBlock:
lda _Horiz_scroll
sta $2005
lda #$ff
sta $2005
pla
tax
pla
tay
pla
irq:
rti
.segment "RODATA"
.include "Music/famitone4.s"
music_data:
.include "Music/blockDude.s"
sounds_data:
.include "Music/soundFx.s"
;none yet
.segment "VECTORS"
.word nmi ;$fffa vblank nmi
.word start ;$fffc reset
.word irq ;$fffe irq / brk
.segment "CHARS"
.incbin "BlockDude.chr"