-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.asm
executable file
·310 lines (237 loc) · 4.76 KB
/
main.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
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
;
; _/ _/
; _/_/_/ _/_/ _/_/_/ _/ _/ _/ _/ _/_/ _/_/_/
; _/ _/ _/_/_/_/ _/_/ _/ _/ _/ _/_/ _/ _/
; _/ _/ _/ _/_/ _/ _/ _/ _/ _/ _/
;_/ _/ _/_/_/ _/_/_/ _/ _/_/_/ _/ _/ _/_/_/
; _/
; _/_/
; neslyric 8-bit animation framework
; creative commons attribution
; by 0xabad1dea 2011
;;;; reset -- hardwired final prg bank
Reset_Routine:
; fixing stack stuff
cld
sei
ldx #$ff
txs
.WaitV:
lda $2002
bpl .WaitV
.WaitV2:
lda $2002
bpl .WaitV2
ldx #$00 ; kill graphics
stx $2000
stx $2001
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; we have switched from mmc1 to mmc3 :>
;;; it helps to init the mmc
lda #0
sta $8000
lda #1
sta $8001
lda #1
sta $8000
lda #2
sta $8001
lda #2
sta $8000
lda #4
sta $8001
lda #3
sta $8000
lda #5
sta $8001
lda #4
sta $8000
lda #6
sta $8001
lda #5
sta $8000
lda #7
sta $8001
lda #6
sta $8000
lda #0
sta $8001
lda #7
sta $8000
lda #1
sta $8001
lda #1
sta $a000
lda #0
sta $a001
lda #0
sta Timer
sta SecondsTimer
sta XScroll
sta YScroll
lda #$3F ; palette stuffing
sta $2006
lda #$00
sta $2006
ldx #$00
.LoadPal:
lda BGPalettes,x
sta $2007
inx
cpx #$20
bne .LoadPal
.ClearName: ; filling the background with... nothing
lda #$20
sta $2006
lda #$40
sta $2006
ldy #4
ldx #0
lda #$c1 ; fill
.loop: ; counting to 1024 (256x4)
sta $2007
inx
bne .loop
dey
bne .loop
DoMainLogo:
lda #$0
ldy #0
clc
LogoLoop:
ldx #$21
stx $2006
ldx TitleOffsetTable,y
stx $2006
ldx #$00
ldx #0
.LoadLogo1:
sta $2007
inx
adc #1
;clc
cpx #16
bne .LoadLogo1
iny
cpy #8
bne LogoLoop
; laaaaaaaaazyyy
clc ; EVERY DANG TIME, CLC GETS ME
ldy #0
lda #128
LogoLoop2:
ldx #$22
stx $2006
ldx TitleOffsetTable,y
stx $2006
ldx #$00
ldx #0
.LoadLogo1:
sta $2007
inx
adc #1
;clc
cpx #16
bne .LoadLogo1
iny
cpy #8
bne LogoLoop2
lda #$23
sta $2006
lda #$20
sta $2006
clc
ldx #0
LoadTempText:
lda TemporaryText,x
sta $2007
inx
cpx #32
bne LoadTempText
lda #0 ; whoops this is kind of important, no wonder i was getting sprite
; corruption with a letter q flying around...
.DoClearNSF:
; and other stuff.
sta $0000,x ; zp - used by ppmck and our variables
sta $0200,x ; used by ppmck
sta $0300,x ; sprite page
inx
;cpx #255
bne .DoClearNSF
; this code came from nullsleep
; *** CLEAR SOUND REGISTERS ***
lda #$00 ; clear all the sound registers by setting
ldx #$00 ; everything to 0 in the Clear_Sound loop
.Clear_Sound:
sta $4000,x ; store accumulator at $4000 offset by x
inx ; increment x
cpx #$0F ; compare x to $0F
bne .Clear_Sound ; branch back to Clear_Sound if x != $0F
lda #$10 ; load accumulator with $10
sta $4010 ; store accumulator in $4010
lda #$00 ; load accumulator with 0
sta $4011 ; clear these 3 registers that are
sta $4012 ; associated with the delta modulation
sta $4013 ; channel of the NES
; *** ENABLE SOUND CHANNELS ***
lda #%00001111 ; enable all sound channels except
sta $4015 ; the delta modulation channel
; *** RESET FRAME COUNTER AND CLOCK DIVIDER ***
lda #$C0 ; synchronize the sound playback routine
sta $4017 ; to the internal timing of the NES
lda #0
ldx #0
jsr $8080 ;sound_init
lda #0 ; set scroll (none)
sta $2005
sta $2005
; bg colors
lda #$23
sta $2006
lda #$C0
sta $2006
ldx #0
lda #%00000000
.LoadColors: ;
sta $2007
inx
cpx #64
bne .LoadColors
;;;; set up sprite zero for rescroll trigger
ldx #0
.ZeroSprite:
lda SpritePages,x
sta $0300,x
inx
cpx #$4
bne .ZeroSprite
; derp I can't believe I forgot this
lda #%10001000
sta $2000
lda #$1A ; no bias
sta $2001
;; enable mmc3 interrupts
lda #1
;sta $E000
lda #120
sta $C000
sta $C001
lda #1
sta $e000
sta $E001
; here is some IRQ magic
lda #$40
sta $4017
cli
looploop:
; lda $2002
; and #%01000000
; cmp #%01000000
; beq ScrollNowNowNow
jmp looploop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ResumeInit:
TitleOffsetTable:
.db $08,$28,$48,$68,$88,$a8,$c8,$e8
TemporaryText:
.db " This Is Neslyric Version 0.0.1 "