-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWave_Menu.s
More file actions
455 lines (405 loc) · 6.57 KB
/
Wave_Menu.s
File metadata and controls
455 lines (405 loc) · 6.57 KB
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
;Wave_Menu.s
MenuKeyDescriptionIDList
.byt 6,7,24,24,77,98,99
MenuKeyAreaIDList
.byt 78,78,81,81,78,81,81
MenuKeyVectorLo
.byt <meLeft
.byt <meRight
.byt <meSelect
.byt <meSelect
.byt <GenericHelp
.byt <meDecrementTempo
.byt <meIncrementTempo
MenuKeyVectorHi
.byt >meLeft
.byt >meRight
.byt >meSelect
.byt >meSelect
.byt >GenericHelp
.byt >meDecrementTempo
.byt >meIncrementTempo
meLeft
lda MenuCursorX
.(
beq skip1
dec MenuCursorX
skip1 rts
.)
meRight
lda MenuCursorX
ldx MenuID
cmp MenuUltimateOption,x
.(
bcs skip1
inc MenuCursorX
skip1 rts
.)
MenuUltimateOption
.byt 8,6
meDecrementTempo
lda mmMusicTempo
sec
sbc #1
.(
beq skip2
bcs skip1
skip2 lda #99
skip1 sta mmMusicTempo
.)
jmp EmbedTempoInMenuScreen
meIncrementTempo
lda mmMusicTempo
clc
adc #1
.(
bcc skip1
lda #1
skip1 sta mmMusicTempo
.)
EmbedTempoInMenuScreen
lda #<MenuEmbeddedTempoText
sta screen
lda #>MenuEmbeddedTempoText
sta screen+1
lda mmMusicTempo
ldy #00
ldx #128
jmp Display2DD
meSelect
lda MenuID
bne FileMenu
ldx MenuCursorX
beq Switch2FileMenu
cpx #6
.(
beq skip1
bcs PlayControls
;swap 2/3
lda MenuX2EditorID-1,x
sta EditorID
skip1 rts
.)
MenuX2EditorID
.byt LISTEDITOR
.byt PATTERNEDITOR
.byt EFFECTEDITOR
.byt ORNAMENTEDITOR
.byt SAMPLEVIEWER
Switch2FileMenu
lda #1
sta MenuID
rts
GenericHelp
lda EditorID
sta PreviousEditorID
lda #HELPEDITOR
sta EditorID
lda #0
sta HelpPage
sta HelpCursorY
jsr PlotHelpLegend
jsr ClearPatternArea
jsr HelpPlot
lda #87+128
ldx #1
ldy #27
jsr DisplayMessage
rts
PlayControls
;7 Play
;8 Stop
cpx #7
beq CommencePlay
jmp TurnOffMusic
CommencePlayFromList
sei
lda ListCursorBase
clc
adc ListCursorX
jmp CommencePlayRent1
CommencePlay
;Initialise music
sei
lda #00
CommencePlayRent1
sta pzListIndex
lda #00
sta pzPatternRowPlayFlag
lda #%11000000
sta pzMusicElementActivity
;Setup List
jsr ProcList
;Set Default Music Tempo
lda mmMusicTempo
sta pmMusicTempo
;Setup Pattern
jsr ProcPattern
;Commence Playing
cli
rts
;EDIT LOAD SAVE UPDATE DIR MAIN-MENU
FileMenu
ldx MenuCursorX
beq Switch2EditMenu
cpx #2
bcc LoadNewFile
beq SaveNewFile
cpx #4
bcc UpdateSaveFile
beq ShowDirectory
jmp WaveMainMenu
Switch2EditMenu
lda #0
sta MenuID
rts
LoadNewFile
lda #1
FileOperation
pha
jsr CheckOverwriteExisting
pla
.(
bcc skip1
jmp Revert2BasicParsingParam
skip1 rts
.)
SaveNewFile
lda #2
jmp Revert2BasicParsingParam
UpdateSaveFile
lda #3
jmp Revert2BasicParsingParam
ShowDirectory
lda #4
jmp Revert2BasicParsingParam
WaveMainMenu
jsr CheckOverwriteExisting
.(
bcc skip1
ldx MenuCursorX
cpx #5
beq menuNew
menuBasic lda #5
jmp Revert2BasicParsingParam
menuNew ;Erase Headers
lda #10
sta mmMusicTempo
lda #128
sta mmListHeader
;Erase Ornament and Effect Loops
ldx #14
loop4 sta mmOrnamentLoops,x
sta mmEffectLoops,x
dex
bpl loop4
;Erase List memory
jsr EraseListMemory
;Erase Ornament and Effect Memory
ldx #00
loop6 sta mmOrnamentMemory,x
sta mmOrnamentMemory+224,x
sta mmEffectMemory,x
sta mmEffectMemory+224,x
inx
bne loop6
;Erase Patterns with default Pattern Row
ldx #23
loop3 jsr ErasePattern
dex
bpl loop3
;Redisplay all editors to reflect change
jsr EmbedTempoInMenuScreen
jsr PatternPlot
jsr ListPlot
jsr EffectPlot
jsr OrnamentPlot
skip1 rts
.)
EraseListMemory
ldx #00
txa
.(
loop5 sta mmListMemory,x
inx
bpl loop5
.)
rts
ErasePattern
stx mePatternID
lda PatternAddressLo,x
sta source
lda PatternAddressHi,x
sta source+1
ldx #64
.(
loop2 ldy #10
loop1 lda VoidPatternRow,y
sta (source),y
dey
bpl loop1
lda #11
jsr add_source
dex
bne loop2
.)
ldx mePatternID
rts
CheckOverwriteExisting
ldx #90
CheckOverwriteExisting2
jsr DisplayPrompt_Message
jsr FlushInputBuffer
jsr WaitOnKey
ldx #5
jsr DisplayPrompt_Message
lda pzKeyRegister
cmp #6
.(
beq skip1
clc
skip1 rts
.)
WaitOnKey
jsr FetchKey
lda pzKeyRegister
cmp #NULLKEYCODE
beq WaitOnKey
rts
Revert2BasicParsingParam
; nop
; jmp Revert2BasicParsingParam
pha
;Revert to BASIC to perform file ops
sei
;Restore original IRQ speed
lda #>10000
sta VIA_T1CH
sta VIA_T1LH
lda #<10000
sta VIA_T1CL
sta VIA_T1LL
;Disable Virtual AY
lda #$DD
sta VIA_PCR
;Turn off current song and disable any sample currently playing
jsr StopSample
lda #00
sta pzMusicElementActivity
;Store Screen and Std Character Set
;B500-B7FF 768
;BB80-BFDF 1120
ldx #00
.(
loop1 lda $B500,x
sta SCREENBACKUPPAGE1,x
lda $B600,x
sta SCREENBACKUPPAGE2,x
lda $B700,x
sta SCREENBACKUPPAGE3,x
lda $BB00,x
sta ScreenBackupPage4,x
lda $BC00,x
sta ScreenBackupPage5,x
lda $BD00,x
sta ScreenBackupPage6,x
lda $BE00,x
sta ScreenBackupPage7,x
lda $BF00,x
sta ScreenBackupPage8,x
inx
bne loop1
.)
;Restore Zero Page
jsr SwapZeroPage
;Store useful locations between 00 and 0B
;00 Reserved for passing back and forth from basic
; 0 Just entered WAVE
; 1 Returning from disk op
;01-02 Start of Music memory to save
;03-04 End Of Music memory to save
;05
;06 Line to return to
; 4 Load new music, Sample or Element file
; 5 Save new music file
; 6 Update Save music file
; 7 Show directory
; 8 Return to Main memory
;Code to return to WAVE from BASIC
pla
; 1 Load new music, Sample or Element file
; 2 Save new music file
; 3 Update Save music file
; 4 Show directory
; 5 Return to Main memory
tax
clc
adc #3
sta $06
lda ExtensionCharacter-1,x
sta $05
lda #<StartOfMusic
sta $01
lda #>StartOfMusic
sta $02
lda #<EndOfMusic
sta $03
lda #>EndOfMusic
sta $04
;Restore Original IRQ
lda BasicsIRQVector
sta SYS_IRQVECTOR
lda BasicsIRQVector+1
sta SYS_IRQVECTOR+1
;Restore original stack pointer
ldx OriginalStackPointer
txs
;Clear interrupt and return to BASIC
cli
rts
ExtensionCharacter
.byt "?" ;Load new music, Sample or Element file Allow loading of any Music element
.byt "A" ;Save new music file Always Save All
.byt "A" ;Update Save music file Always Save All
.byt "?" ;Show directory View All Types
.byt 0 ;Return to Main memory Not bothered
ScreenBackupPage4
.dsb 128,0
ActualScreen
.dsb 40,0
.dsb 22,0
FilenameText
.dsb 18,0
.dsb 40,0
.dsb 8,0
ScreenBackupPage5
.dsb 256,0
ScreenBackupPage6
.dsb 256,0
ScreenBackupPage7
.dsb 256,0
ScreenBackupPage8
.dsb 256,0
RestoreScreen
ldx #00
.(
loop1 lda SCREENBACKUPPAGE1,x
sta $B500,x
lda SCREENBACKUPPAGE2,x
sta $B600,x
lda SCREENBACKUPPAGE3,x
sta $B700,x
lda ScreenBackupPage4,x
sta $BB00,x
lda ScreenBackupPage5,x
sta $BC00,x
lda ScreenBackupPage6,x
sta $BD00,x
lda ScreenBackupPage7,x
sta $BE00,x
lda ScreenBackupPage8,x
sta $BF00,x
inx
bne loop1
.)
rts