-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvgmtest.6502
286 lines (189 loc) · 7.78 KB
/
vgmtest.6502
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
\ ******************************************************************
\ * VGM Player
\ * Based on Beeb Tracker
\ * Music player & visualiser in MODE 7
\ * Kieran Connell & Simon Morris
\ ******************************************************************
\\ Common global defines
INCLUDE "lib/bbc.h.6502"
\ ******************************************************************
\ * Define compilation flags
\ ******************************************************************
CODE_ORIGIN = &1100 ; assuming standard BBC Micro DFS this is safe!
_DEBUG = FALSE ; include extra stuff for debugging
COMPILE_OPTION_EXIT = FALSE ; enable "Exit" in selection menu
\ ******************************************************************
\ * Define global constants
\ ******************************************************************
\ ******************************************************************
\ * Define app constants
\ ******************************************************************
\\ Number of entries in our file table
NUM_vgm_files = 26
\ ******************************************************************
\ * Define fast (zero page) runtime variables
\ ******************************************************************
\\ Our own app variables
ORG &00
GUARD &9F ; user ZP + econet ZP
\\ Any includes here can declare ZP vars from the pool using SKIP
INCLUDE "lib/exomiser.h.6502"
INCLUDE "lib/vgmplayer.h.6502"
INCLUDE "lib/beebtracker.h.6502"
\ ******************************************************************
\ * Start address to be saved
\ ******************************************************************
LARGEST_VGM_SIZE = 20837 - 256 ; minus size of title screen file "loader_volume1.bin.exo"
ORG CODE_ORIGIN ; code origin - assume standard BBC Micro
GUARD MODE7_base_addr-LARGEST_VGM_SIZE ; ensure code size plus size of largest VGM file doesn't hit start of screen memory
.start
\ ******************************************************************
\ * Code entry
\ ******************************************************************
INCLUDE "lib/exomiser.s.6502"
INCLUDE "lib/vgmplayer.s.6502"
INCLUDE "lib/beebtracker.s.6502"
\ ******************************************************************
\ * Main loop including high-level state machine
\ ******************************************************************
.main
{
\\ ***** System initialise ***** \\
\\ *FX 200,3 - clear memory on break as we use OS memory areas and can cause nasty effects
LDA #200
LDX #3
JSR osbyte
\\ Set MODE 7
LDA #22: JSR oswrch
LDA #7: JSR oswrch
\\ Turn off cursor by directly poking crtc
SEI
LDA #10: STA &FE00
LDA #32: STA &FE01
CLI
\\ Present intro screen
; JSR show_intro
\\ Run the tracker demo
JSR tracker_main
\\ ***** Exit app entirely ***** \\
\\ Credits / Outro screen goes here \\
\\ Exit cleanly - tidy up anything else here!
LDA #12: JSR oswrch
\\ Would be nice to clear escape state and issue BASIC NEW to avoid "Bad Program" error
.return
RTS
}
\\ *** Show loading screen ***
.show_intro
{
\\ Initialize compressed data stream
\\ the title screen is an included binary at the VGM_stream_data memory address
\\ (later overwritten by loaded VGMs)
LDX #LO(VGM_stream_data)
LDY #HI(VGM_stream_data)
JSR exo_init_decruncher
\\ unpack to screen
LDX #&00
LDY #&7c
JSR exo_unpack
\\ wait for keypress within 2 secs
LDA#&81:LDX#200:LDY#0:JSR osbyte
RTS
}
.code_end
\ ******************************************************************
\ * Stored data
\ ******************************************************************
.data_start
.menu_data_filename EQUS "BeebDat", 13
\\ Need to put this macro last as I don't know how to undo the character map!
\\
SET_TELETEXT_FONT_CHAR_MAP
\\ Scrolltext messages stored as font glyph byte offsets
.scrolltext_start
.demo_message
\\ Short message (<256 bytes)
;EQUS " Welcome to the Bitshifters Battle of the Bits BeebTracker Demo... Showcasing 27 awesome VGM chiptune music files that have been converted from other platforms to work on your BBC Micro 4MHz SN76489 sound chip! Find us at bitshifters.github.io. "
;EQUB 0
\\ Long text blows out the 200KB disk size - removed one tune
EQUS " ... Bitshifters VGM Test Demo ... "
EQUB 0
.load_message
EQUS "Loading... ", 0
\\ ** ANY EQUS LINES AFTER THIS POINT WILL STILL CONTAIN REMAPPED CHARACTERS ** \\
.scrolltext_end
\\ Clear character mappings
RESET_MAPCHAR
\ ******************************************************************
\ * EXO VGM data file
\ * This must be compressed using the following flags:
\ * exomizer.exe raw -c -m 1024 <file.raw> -o <file.exo>
\ ******************************************************************
.VGM_stream_data
\\ Now loaded at run-time so don't know end of data!
INCBIN "data/loader_volume1.bin.exo"
\ ******************************************************************
\ * End address to be saved
\ ******************************************************************
.end
ORG &0900
GUARD &0CFF
.menu_data_start
\\ No longer require loading_table but each entry must be exactly 4 bytes
\\ Does not have to be aligned but entries have to be fixed size
\\ This isn't actually any smaller than using pointer tables but fewer things to type I suppose :)
\\ V.B is an invalid filename for some reason with BeebASM
.vgm_filenames
EQUS "V.0", 13
\\ No longer require pointer table but each entry must be exactly 32 bytes
\\ Does not have to be aligned but entries have to be fixed size
\\ Code to multiple by 32 probably takes up as much space as the previous pointer tables!
.menu_entries
EQUS " 1. Bad Apple "
IF COMPILE_OPTION_EXIT
EQUS "Exit "
ENDIF
.menu_entries_end
.menu_data_end
\ ******************************************************************
\ * Print out code & data metrics
\ ******************************************************************
D_MENU_SIZE = menu_data_end-menu_data_start
D_LOOKUP_SIZE = lookup_tables_end-lookup_tables_start
D_NOTES_SIZE = note_tables_end-note_tables_start
D_SCROLLTEXT_SIZE = scrolltext_end-scrolltext_start
D_SCREENS_SIZE = mode7_data_end-mode7_data_start
D_EXO_CODE_SIZE = exo_end-exo_start
D_VGM_PLAYER_CODE_SIZE = vgm_player_end-vgm_player_start
D_MENU_ENTRIES_SIZE = menu_entries_end-menu_entries
PRINT "------------------------------------------------------------"
PRINT "Code origin = ", ~CODE_ORIGIN
PRINT "Code size =", end-start-D_MENU_SIZE-D_LOOKUP_SIZE-D_NOTES_SIZE-D_SCROLLTEXT_SIZE-D_SCREENS_SIZE
PRINT " menu data size =",D_MENU_SIZE
PRINT " menu entries size =",D_MENU_ENTRIES_SIZE
PRINT " lookup tables size =",D_LOOKUP_SIZE
PRINT " note tables size =",D_NOTES_SIZE
PRINT " scrolltext size =",D_SCROLLTEXT_SIZE
PRINT " MODE 7 screen size =", D_SCREENS_SIZE
PRINT " VGM Player code size = ", D_VGM_PLAYER_CODE_SIZE
PRINT " EXO code size = ", D_EXO_CODE_SIZE
PRINT "Run-time vars (above origin) =", VGM_stream_data-end
PRINT "------------------------------------------------------------"
PRINT "Total size (disk) =", end-start
PRINT "Total size (code + data + vars above origin) =", VGM_stream_data-start
PRINT "Available memory (above origin) =", &7C00 - CODE_ORIGIN
PRINT "Max song size =", &7C00 - VGM_stream_data
PRINT "------------------------------------------------------------"
\ ******************************************************************
\ * Save the code
\ ******************************************************************
SAVE "!Boot", start, end, main
SAVE "BeebDat", menu_data_start, menu_data_end
PUTFILE "vgm_test/test.bin.exo", "V.0", 0
PUTFILE "beebtrk.md", "README", 0
IF _DEBUG ; only needed for debug purposes
PUTFILE "data/screen3.mode7", "screen", &7C00
PUTFILE "data/font_5x5.mode7", "font", &7C00
PUTFILE "data/font_5x5_shifted.mode7", "font2", &7C00
PUTFILE "data/menu_overlay.mode7", "menu", &7C00
ENDIF