-
Notifications
You must be signed in to change notification settings - Fork 1
/
driver.s
646 lines (555 loc) · 17.3 KB
/
driver.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
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
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
;;; ;; ;
;;; ;; ; 0CC-FamiTracker NSF Driver
;;; ;; ; By HertzDevil
;;; ;; ;
;
; Assembler code switches
;
USE_BANKSWITCH = 1 ; Enable bankswitching code
USE_OLDVIBRATO = 1 ;;; ;; ; Enable old vibrato code
USE_LINEARPITCH = 1 ;;; ;; ; Enable linear pitch code
USE_DPCM = 1 ; Enable DPCM channel (currently broken, leave enabled to avoid trouble).
; Also leave enabled when using expansion chips
;INC_MUSIC_ASM = 1 ; Music is in assembler style
RELOCATE_MUSIC = 1 ; Enable if music data must be relocated
ENABLE_ROW_SKIP = 1 ; Enable this to add code for seeking to a row > 0 when using skip command
;PACKAGE = 1 ; header
;USE_VRC6 = 1 ; Enable this to include VRC6 code
;USE_VRC7 = 1 ; Enable this to include VRC7 code
;USE_FDS = 1 ; Enable this to include FDS code
;USE_MMC5 = 1 ; Enable this to include MMC5 code
;USE_N163 = 1 ; Enable this to include N163 code
;USE_S5B = 1 ; Enable this to include 5B code
;USE_ALL = 1 ;;; ;; ; All expansion chips, always assumes 8 N163 channels
;USE_MMC5_MULTIPLIER = 1 ;;; ;; ; optimize multiplication using MMC5 hardware multiplier
.if .defined(USE_ALL) ;;; ;; ;
USE_VRC6 = 1
USE_VRC7 = 1
USE_FDS = 1
USE_MMC5 = 1
USE_N163 = 1
USE_S5B = 1
.endif
EXPANSION_FLAG = .defined(USE_VRC6) + .defined(USE_VRC7) << 1 + .defined(USE_FDS) << 2 + .defined(USE_MMC5) << 3 + .defined(USE_N163) << 4 + .defined(USE_S5B) << 5
MULTICHIP = (EXPANSION_FLAG & (EXPANSION_FLAG - 1)) <> 0
NTSC_PERIOD_TABLE = 1
.if !(EXPANSION_FLAG)
PAL_PERIOD_TABLE = 1 ; forbid PAL table when there is any expansion chip
.endif
;ENABLE_SFX = 1 ; Enable this to enable sound effect support (not yet working)
;SCALE_NOISE = 1 ; Enable 4 bit noise period scaling
;CHANNEL_CONTROL = 1 ; Enable to access channel enable/disable routines
;
; Constants
;
; Setup the pattern number -> channel mapping, as exported by the tracker
;;; ;; ; many of these have been renamed for consistency
;;; ;; ; some are moved from the respective chips' asm files
NAMCO_CHANNELS = 8
CH_COUNT_2A03 = 4
CH_COUNT_MMC5 = 2 * .defined(USE_MMC5)
CH_COUNT_VRC6 = 3 * .defined(USE_VRC6)
.if EXPANSION_FLAG - .defined(USE_N163) << 4
CH_COUNT_N163 = 8 * .defined(USE_N163) ; allow this to change once cc65 is embedded into 0CC-FT
.else
CH_COUNT_N163 = NAMCO_CHANNELS * .defined(USE_N163)
.endif
CH_COUNT_FDS = 1 * .defined(USE_FDS)
CH_COUNT_S5B = 3 * .defined(USE_S5B)
CH_COUNT_VRC7 = 6 * .defined(USE_VRC7)
APU_OFFSET = 0
MMC5_OFFSET = CH_COUNT_2A03 + APU_OFFSET
VRC6_OFFSET = CH_COUNT_MMC5 + MMC5_OFFSET
N163_OFFSET = CH_COUNT_VRC6 + VRC6_OFFSET
FDS_OFFSET = CH_COUNT_N163 + N163_OFFSET
S5B_OFFSET = CH_COUNT_FDS + FDS_OFFSET
VRC7_OFFSET = CH_COUNT_S5B + S5B_OFFSET
DPCM_OFFSET = CH_COUNT_VRC7 + VRC7_OFFSET
EFF_CHANS = DPCM_OFFSET ; # of channels using vibrato & arpeggio effects (not used by DPCM)
WAVE_CHANS = DPCM_OFFSET - CH_COUNT_VRC7
CHANNELS = DPCM_OFFSET + .defined(USE_DPCM)
;.if .defined(ENABLE_SFX)
; SFX_CHANS = CHANNELS * 2
; SFX_WAVE_CHANS = WAVE_CHANS * 2
;.else
SFX_CHANS = CHANNELS
SFX_WAVE_CHANS = WAVE_CHANS
;.endif
.enum
APU_PU1
APU_PU2
APU_TRI ; 0CC: should not be compared against
APU_NOI ; 0CC: should not be compared against
.endenum
; ;; ;;;
.enum ;;; ;; ; divide by 2
CHAN_2A03
CHAN_TRI
CHAN_NOI
CHAN_DPCM ; should not be used since the N163 channel count may change and invalidate ft_channel_type
; although in practice ft_channel_type should be patched
CHAN_VRC6 ; used
CHAN_SAW ; used
CHAN_VRC7 ; used
CHAN_FDS ; used
CHAN_MMC5 ; used
CHAN_N163 ; used
CHAN_S5B ; used
.endenum ; ;; ;;;
.enum
EFF_NONE
EFF_ARPEGGIO
EFF_PORTAMENTO
EFF_PORTA_UP
EFF_PORTA_DOWN
EFF_SLIDE_UP_LOAD
EFF_SLIDE_UP
EFF_SLIDE_DOWN_LOAD
EFF_SLIDE_DOWN
.endenum
.enum
STATE_RELEASE = %00000001
STATE_HOLD = %00000010
.endenum
.enum
FLAG_BANKSWITCH = %00000001
FLAG_OLDVIBRATO = %00000010
FLAG_LINEARPITCH = %00000100
FLAG_USEPAL = %10000000
.endenum
.segment "ZEROPAGE"
;
; Variables that must be on zero-page
;
var_Temp: .res 1 ; Temporary 8-bit
var_Temp2: .res 1
var_Temp3: .res 1
var_Temp4: .res 1
var_Temp16: .res 2 ; Temporary 16-bit
var_Temp_Pointer: .res 2 ; Temporary
var_Temp_Pointer2: .res 2
var_Temp_Pattern: .res 2 ; Pattern address (temporary)
var_Note_Table: .res 2
var_currentChannel: .res 1 ;;; ;; ;
ACC: .res 2 ; Used by division routine
AUX: .res 2
EXT: .res 2
;;; ;; ; all chip-specific variables have been moved to the zeropage
.if .defined(USE_MMC5)
var_ch_LengthCounter: .res 6 ; LLLLL-HC Length counter, Enable length counter, Enable decay/linear
var_ch_PrevFreqHighMMC5: .res 2
.else
var_ch_LengthCounter: .res 4 ; MMC5 has two extra pulse channels
.endif
var_Linear_Counter: .res 1 ; Triangle linear counter
.if .defined(USE_DPCM)
var_ch_SamplePtr: .res 1 ; DPCM sample pointer
var_ch_SampleLen: .res 1 ; DPCM sample length
var_ch_SampleBank: .res 1 ; DPCM sample bank
var_ch_SamplePitch: .res 1 ; DPCM sample pitch
var_ch_DPCMDAC: .res 1 ; DPCM delta counter setting
var_ch_DPCM_Offset: .res 1
var_ch_DPCM_Retrig: .res 1 ; DPCM retrigger
var_ch_DPCM_RetrigCntr: .res 1
var_ch_DPCM_EffPitch: .res 1
.endif
.if .defined(USE_VRC7)
;;; ;; ; removed, since other chips also use 2 bytes for duty
var_ch_vrc7_FnumLo: .res CH_COUNT_VRC7
var_ch_vrc7_FnumHi: .res CH_COUNT_VRC7
var_ch_vrc7_Bnum: .res CH_COUNT_VRC7
var_ch_vrc7_ActiveNote: .res CH_COUNT_VRC7
var_ch_vrc7_Command: .res CH_COUNT_VRC7 ; 0 = halt, 1 = trigger, 80 = update
var_ch_vrc7_OldOctave: .res 1 ; Temp variable for old octave when triggering new notes
var_ch_vrc7_EffPatch: .res CH_COUNT_VRC7 ;;; ;; ; V-command
var_ch_vrc7_CustomHi: .res CH_COUNT_VRC7
var_ch_vrc7_CustomLo: .res CH_COUNT_VRC7
var_CustomPatchPtr: .res 2
var_ch_vrc7_Port: .res CH_COUNT_VRC7 ;;; ;; ; Hxx
var_ch_vrc7_Write: .res 8 ;;; ;; ; Ixx
var_ch_vrc7_PatchFlag: .res 1
.endif
.if .defined(USE_FDS)
var_ch_ModDelay: .res 1
var_ch_ModDepth: .res 1
var_ch_ModRate: .res 2
var_ch_ModDelayTick: .res 1
var_ch_ModEffDepth: .res 1
var_ch_ModEffRate: .res 2
var_ch_ModInstDepth: .res 1 ;;; ;; ;
var_ch_ModInstRate: .res 2 ;;; ;; ;
var_ch_ModEffWritten: .res 1
var_ch_FDSVolume: .res 1 ;;; ;; ;
var_ch_ModBias: .res 1 ;;; ;; ;
.endif
.if .defined(USE_N163)
var_ch_WavePtrLo: .res CH_COUNT_N163
var_ch_WavePtrHi: .res CH_COUNT_N163
var_ch_WaveLen: .res CH_COUNT_N163 ;;; ;; ; MSB is used for N163 Yxx
var_ch_WavePos: .res CH_COUNT_N163
var_ch_WavePosOld: .res CH_COUNT_N163 ;;; ;; ; overridden by Yxx
var_NamcoChannels: .res 1 ; Number of active N163 channels
var_NamcoChannelsReg: .res 1
var_NamcoInstrument: .res CH_COUNT_N163
.endif
.if .defined(USE_S5B) ;;; ;; ;
var_Noise_Period: .res 1 ; $06
var_Noise_Prev: .res 1 ; cache noise value
var_Pul_Noi: .res 1 ; $07
var_EnvelopeRate: .res 2 ; $0B, $0C
var_EnvelopeType: .res 1 ; $0D
var_AutoEnv_Channel: .res 1 ;;; ;; ; 050B
var_EnvelopeTrigger: .res 1 ; Hxy issued
.endif ; ;; ;;;
last_zp_var: .res 1 ; Not used
.segment "BSS"
;
; Driver variables
;
; Song header (necessary to be in order)
var_Song_list: .res 2 ; Song list address
var_Instrument_list: .res 2 ; Instrument list address
.if .defined(USE_DPCM)
var_dpcm_inst_list: .res 2 ; DPCM instruments
var_dpcm_pointers: .res 2 ; DPCM sample pointers
.endif
var_Groove_Table: .res 2 ;;; ;; ; Grooves
var_SongFlags: .res 1 ; Song flags
.if .defined(USE_FDS)
var_Wavetables: .res 2 ; FDS waves
.endif
.if .defined(CHANNEL_CONTROL)
var_Channels: .res 1 ; Channel enable/disable
.endif
var_AllChannels: .res 1 ;;; ;; ; moved from N163
var_EffChannels: .res 1 ; ;; ;;; check against this for DPCM channel
; Track header (necessary to be in order)
var_Frame_List: .res 2 ; Pattern list address
var_Frame_Count: .res 1 ; Number of frames
var_Pattern_Length: .res 1 ; Global pattern length
var_Speed: .res 1 ; Speed setting
var_Tempo: .res 1 ; Tempo setting
var_GroovePointer: .res 1 ;;; ;; ; Groove setting
var_InitialBank: .res 1
; General
var_PlayerFlags: .res 1 ; Player flags
; bit 0 = playing
;;; ;; ; bit 1 = Cxx issued
; bit 2 - 7 unused
var_Pattern_Pos: .res 1 ; Global pattern row
var_Current_Frame: .res 1 ; Current frame
var_Load_Frame: .res 1 ; 1 if new frame should be loaded
var_Tempo_Accum: .res 2 ; Variables for speed division
var_Tempo_Count: .res 2 ; (if tempo support is not needed then this can be optimized)
var_Tempo_Dec: .res 2
var_Tempo_Modulus: .res 2 ;;; ;; ; from 0.4.6
var_Sweep: .res 1 ; This has to be saved
.if .defined(USE_BANKSWITCH)
;var_Bank: .res 1
.endif
var_Jump: .res 1 ; If a Jump should be executed
var_Skip: .res 1 ; If a Skip should be executed
.if .defined(ENABLE_ROW_SKIP)
var_SkipTo: .res 1 ; Skip to row number
.endif
var_sequence_ptr: .res 1
var_sequence_result: .res 1
;var_enabled_channels: .res 1
; Channel variables
; General channel variables, used by the pattern reader (all channels)
var_ch_PatternAddrLo: .res CHANNELS ; Holds current pattern position
var_ch_PatternAddrHi: .res CHANNELS
.if .defined(USE_BANKSWITCH)
var_ch_Bank: .res CHANNELS ; Pattern bank
.endif
var_ch_Note: .res CHANNELS ; Current channel note
var_ch_VolColumn: .res CHANNELS ; Volume column
var_ch_VolDelay: .res CHANNELS ;;; ;; ; Delayed channel volume
var_ch_VolDefault: .res CHANNELS ;;; ;; ; Existing channel volume
var_ch_Delay: .res CHANNELS ; Delay command
var_ch_NoteCut: .res CHANNELS
var_ch_NoteRelease: .res CHANNELS ;;; ;; ; Delayed note release
var_ch_Transpose: .res CHANNELS ;;; ;; ; Delayed transpose
var_ch_State: .res CHANNELS ;;; ;; ; overloaded to handle &&
var_ch_FinePitch: .res CHANNELS ; Fine pitch setting
var_ch_NoteDelay: .res CHANNELS ; Delay in rows until next note
var_ch_DefaultDelay: .res CHANNELS ; Default row delay, if exists
var_ch_Trigger: .res CHANNELS ;;; ;; ; Set for one frame when new note is encountered
; Following is specific to chip channels (2A03, VRC6...)
var_ch_TimerPeriodHi: .res EFF_CHANS ; Current channel note period
var_ch_TimerPeriodLo: .res EFF_CHANS
var_ch_PeriodCalcLo: .res EFF_CHANS ; Frequency after fine pitch and vibrato has been applied
var_ch_PeriodCalcHi: .res EFF_CHANS
;var_ch_OutVolume: .res EFF_CHANS ; Volume for the APU
var_ch_VolSlide: .res EFF_CHANS ;;; ;; ; Volume slide
var_ch_DutyDefault: .res EFF_CHANS ;;; ;; ; Duty cycle / Noise mode
var_ch_DutyCurrent: .res EFF_CHANS ; ;; ;;; do not rely on bitwise operations
; --- Testing ---
;var_ch_LoopCounter: .res CHANNELS
; --- Testing ---
; Square 1 & 2 variables
var_ch_Sweep: .res 2 ; Hardware sweep
var_ch_PrevFreqHigh: .res 2 ; Used only by 2A03 pulse channels
; Sequence variables
var_ch_SeqVolume: .res SFX_WAVE_CHANS * 2 ; Sequence 1: Volume
var_ch_SeqArpeggio: .res SFX_WAVE_CHANS * 2 ; Sequence 2: Arpeggio
var_ch_SeqPitch: .res SFX_WAVE_CHANS * 2 ; Sequence 3: Pitch bend
var_ch_SeqHiPitch: .res SFX_WAVE_CHANS * 2 ; Sequence 4: High speed pitch bend
var_ch_SeqDutyCycle: .res SFX_WAVE_CHANS * 2 ; Sequence 5: Duty cycle / Noise Mode
var_ch_Volume: .res SFX_WAVE_CHANS ; Output volume
var_ch_SequencePtr1: .res SFX_WAVE_CHANS ; Index pointers for sequences
var_ch_SequencePtr2: .res SFX_WAVE_CHANS
var_ch_SequencePtr3: .res SFX_WAVE_CHANS
var_ch_SequencePtr4: .res SFX_WAVE_CHANS
var_ch_SequencePtr5: .res SFX_WAVE_CHANS
var_ch_InstType: .res SFX_WAVE_CHANS ;;; ;; ; Chip type, used for duty conversion
; ;; ;;; valid since chip type = inst type right now
;var_ch_fixed: .res SFX_WAVE_CHANS
var_ch_ArpFixed: .res EFF_CHANS
; Track variables for effects
var_ch_Effect: .res EFF_CHANS ; Arpeggio & portamento
var_ch_EffParam: .res EFF_CHANS ; Effect parameter (used by portamento and arpeggio)
var_ch_PortaToHi: .res EFF_CHANS ; Portamento
var_ch_PortaToLo: .res EFF_CHANS
var_ch_ArpeggioCycle: .res EFF_CHANS ; Arpeggio cycle
var_ch_VibratoPos: .res EFF_CHANS ; Vibrato
var_ch_VibratoDepth: .res EFF_CHANS
var_ch_VibratoSpeed: .res EFF_CHANS
var_ch_TremoloPos: .res EFF_CHANS ; Tremolo
var_ch_TremoloDepth: .res EFF_CHANS ; combine these
var_ch_TremoloSpeed: .res EFF_CHANS
var_ch_TremoloResult: .res EFF_CHANS
;var_ch_VibratoParam: .res EFF_CHANS
;var_ch_TremoloParam: .res EFF_CHANS
ECHO_BUFFER_LENGTH = 3 ;;; ;; ; Echo buffer
var_ch_EchoBuffer: .res (ECHO_BUFFER_LENGTH + 1) * CHANNELS
; End of variable space
last_bss_var: .res 1 ; Not used
.segment "CODE"
.include "longbranch.mac" ;;; ;; ;
; $9000 - $9003
; $9010
; $9030
; $A000 - $A002
.macro padjmp count ; headerless padding
.local @end
.if .defined(USE_ALL)
.ifndef PACKAGE
.if count > 3
jmp @end
.repeat count - 3
nop
.endrep
.else
.repeat count
nop
.endrep
.endif
.endif
.endif
@end:
.endmacro
.macro padjmp_h count ; headered padding
.local @end
.if .defined(USE_ALL)
.ifdef PACKAGE
.if count > 3
jmp @end
.repeat count - 3
nop
.endrep
.else
.repeat count
nop
.endrep
.endif
.endif
.endif
@end:
.endmacro
.if MULTICHIP ;;; ;; ;
.macro CH_LOOP_START target
stx var_currentChannel
lda ft_channel_enable, x
jeq target
.endmacro
.else
.macro CH_LOOP_START target
stx var_currentChannel
.endmacro
.endif
.macro CH_LOOP_END target
ldx var_currentChannel
inx
CPX_ALL_CHANNELS
jne target
.endmacro
.macro CPX_ALL_CHANNELS
.if .defined(USE_ALL) ;;; ;; ;
cpx #CHANNELS
.elseif .defined(USE_N163)
cpx var_AllChannels
.else
cpx #CHANNELS
.endif
.endmacro
; NSF entry addresses
.if .defined(PACKAGE)
.byte "0CCFT ", $02, $0C
.endif
LOAD:
INIT:
jmp ft_music_init
PLAY:
jmp ft_music_play
.if .defined(CHANNEL_CONTROL)
;;; ;; ; TODO: channel flags for each expansion chip
; Disable channel in X, X = {00 : Square 1, 01 : Square 2, 02 : Triangle, 03 : Noise, 04 : DPCM}
ft_disable_channel:
lda bit_mask, x
eor #$FF
and var_Channels
sta var_Channels
rts
; Enable channel in X
ft_enable_channel:
lda bit_mask, x
ora var_Channels
sta var_Channels
lda #$FF
cpx #$00
beq :+
cpx #$01
beq :++
rts
: sta var_ch_PrevFreqHigh
rts
: sta var_ch_PrevFreqHigh + 1
rts
.endif
; The rest of the code
.include "init.s"
.include "player.s"
.include "effects.s"
.include "instrument.s"
.include "apu.s"
.if .defined(USE_VRC6)
.include "vrc6.s"
.endif
.if .defined(USE_VRC7)
.include "vrc7.s"
.endif
.if .defined(USE_MMC5)
.include "mmc5.s"
.endif
.if .defined(USE_FDS)
.include "fds.s"
.endif
.if .defined(USE_N163)
.include "n163.s"
.endif
.if .defined(USE_S5B)
.include "s5b.s"
.endif
ft_bankswitch:
; sta $5FFA
sta $5FFB
rts
ft_bankswitch2:
clc
sta $5FFC
adc #$01
sta $5FFD
adc #$01
sta $5FFE
; adc #$01
; sta $5FFF
rts
;
; Channel maps, will be moved to exported data
;
;;; ;; ; ft_channel_map is unnecessary
ft_channel_type:
.byte CHAN_2A03, CHAN_2A03, CHAN_TRI, CHAN_NOI
.repeat CH_COUNT_MMC5
.byte CHAN_MMC5
.endrep
.if .defined(USE_VRC6)
.byte CHAN_VRC6, CHAN_VRC6, CHAN_SAW
.endif
.repeat CH_COUNT_N163 ; 0CC: check
.byte CHAN_N163
.endrep
.repeat CH_COUNT_FDS
.byte CHAN_FDS
.endrep
.repeat CH_COUNT_S5B
.byte CHAN_S5B
.endrep
.repeat CH_COUNT_VRC7
.byte CHAN_VRC7
.endrep
.if .defined(USE_DPCM)
.byte CHAN_DPCM
.endif
.if MULTICHIP ;;; ;; ;
ft_channel_enable: ;; Patch
.byte 1, 1, 1, 1
.repeat CH_COUNT_MMC5
.byte .defined(USE_MMC5)
.endrep
.if .defined(USE_VRC6)
.repeat CH_COUNT_VRC6
.byte 1
.endrep
.endif
.repeat CH_COUNT_N163 ; 0CC: check
.byte .defined(USE_N163)
.endrep
.repeat CH_COUNT_FDS
.byte .defined(USE_FDS)
.endrep
.repeat CH_COUNT_S5B
.byte .defined(USE_S5B)
.endrep
.repeat CH_COUNT_VRC7
.byte .defined(USE_VRC7)
.endrep
.if .defined(USE_DPCM)
.byte 1
.endif
.endif
bit_mask: ;;; ;; ; general-purpose bit mask
.repeat 8, i
.byte 1 << i
.endrep
; Include period tables
.include "periods.s"
;;; ;; ; Include vibrato table
.include "vibrato.s"
;
; An example of including music follows
;
; The label that contains a pointer to the music data
; A simple way to handle multiple songs is to move this
; to RAM and setup a table of pointers to music data
ft_music_addr:
.word * + 2 ; This is the point where music data is stored
.if .defined(INC_MUSIC)
; Include music
.if .defined(INC_MUSIC_ASM)
; Included assembly file music, DPCM included
.include "music.asm"
.else
; Binary chunk music
.incbin "music.bin" ; Music data
.if .defined(USE_DPCM)
.segment "DPCM" ; DPCM samples goes here
.incbin "samples.bin"
.endif
.endif
.endif
.if .defined(HAS_NSF_HEADER)
.segment "HEADER"
.include "nsf_wrap.s"
.endif