-
Notifications
You must be signed in to change notification settings - Fork 0
/
nsf.asm
159 lines (131 loc) · 3.42 KB
/
nsf.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
; Demo sounds:
; 1: Homer Simpson from The Simpsons
; 2: The Scout from Team Fortress 2
; 3: Donkey Kong from Mario Kart 64
; 4: "Make your selection now" from Action 53, voiced by tepples
; 5: Drum loop from Sgt. Pepper Reprise by The Beatles
.include "adpcm.asm"
.segment "HEADER"
.byte 'N', 'E', 'S', 'M', $1A ; ID
.byte $01 ; Version
.byte 7 ; Number of songs
.byte 1 ; Start song
.word $8000
.word INIT
.word PLAY
.byte "ADPCM demo",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte "Kef Schecter",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte "CC0 (code only)",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.word $411A ; NTSC speed
.byte 0, 1, 2, 3, 4, 5, 6, 7 ; Bank values
.word 0 ; PAL speed
.byte 0 ; Flags, NTSC only
.byte 0
.byte 0,0,0,0 ; Reserved
.segment "ZEROPAGE"
SongID: .res 1
Done: .res 1
.segment "CODE"
INIT:
sta SongID
tax
ldy SampleBankTbl,x
sty $5ff9 ; set up banks
iny
sty $5ffa
iny
sty $5ffb
iny
sty $5ffc
iny
sty $5ffd
iny
sty $5ffe
iny
sty $5fff
asl ; indexing into table of 16-bit values
tax
lda SampleAddrTbl,x
sta SampleAddrLSB
lda SampleLenTbl,x
sta SampleBytesLeftLSB
inx
lda SampleAddrTbl,x
sta SampleAddrMSB
lda SampleLenTbl,x
sta SampleBytesLeftMSB
lda #0
sta Done
rts
PLAY:
lda Done
bne @done
jsr PlayAdpcm
ldx SongID
lda SampleLoopTbl,x
beq @done ; if sample desn't loop, well, don't loop
; sample loops
lda SongID
jsr INIT
rts
@done:
lda #1
sta Done
rts
SampleAddrTbl:
.word Sample1
.word Sample2
.word Sample3
.word Sample4
.word Sample5
.word Sample6
.word Sample7
SampleBankTbl:
.byte 1
.byte 8
.byte 8
.byte 8
.byte 8
.byte 15
.byte 22
SampleLenTbl:
.word Sample1Len
.word Sample2Len
.word Sample3Len
.word Sample4Len
.word Sample5Len
.word Sample6Len
.word Sample7Len
SampleLoopTbl:
.byte 0
.byte 0
.byte 0
.byte 0
.byte 1
.byte 0
.byte 0
.segment "ADPCM0"
Sample1:
.incbin "raws/kablammo-8948.raw"
Sample1Len = * - Sample1
.segment "ADPCM1"
Sample2:
.incbin "raws/scout-8948.raw"
Sample2Len = * - Sample2
Sample3:
.incbin "raws/dk-roar-8948.raw"
Sample3Len = * - Sample3
Sample4:
.incbin "raws/selnow-8948.raw"
Sample4Len = * - Sample4
Sample5:
.incbin "raws/beatles-8948.raw"
Sample5Len = * - Sample5
.segment "ADPCM2"
Sample6:
.incbin "raws/fart1-8948.raw"
Sample6Len = * - Sample6
.segment "ADPCM3"
Sample7:
.incbin "raws/fart2-8948.raw"
Sample7Len = * - Sample7