-
Notifications
You must be signed in to change notification settings - Fork 0
/
beebtrk.6502
371 lines (275 loc) · 11.8 KB
/
beebtrk.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
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
\ ******************************************************************
\ * Beeb Tracker
\ * Music player & visualiser in MODE 7
\ * Kieran Connell & Simon Morris
\ * Demo team name TBD! :)
\ ******************************************************************
\\ 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 " Welcome to the Bitshifters Battle of the Bits BeebTracker Demo... Showcasing 26 awesome VGM chiptune music files converted from other 8 bit platforms to work on your BBC Micro. They have been retuned to 4Mhz and resampled at 50Hz"
EQUS " so can be played back on your SN76489 sound chip. You have never heard chiptunes like this before on the Beeb and not an ENVELOPE in sight! Press Escape to bring up the menu. Use the up and down arrow keys and return to select a new track."
EQUS " Released at the ABUG South Meet Up in Cambridge on 27 August 2016. This production was brought to you by Kieran and Henley. Find the full source to this demo and more at bitshifters.github.io. Come join the Collective...! "
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
EQUS "V.1", 13
EQUS "V.2", 13
EQUS "V.3", 13
EQUS "V.4", 13
EQUS "V.5", 13
EQUS "V.6", 13
EQUS "V.7", 13
EQUS "V.8", 13
EQUS "V.9", 13
EQUS "V.A", 13
\\ *** Removed
\\ EQUS "V.C", 13
\\ ***
EQUS "V.D", 13
EQUS "V.E", 13
EQUS "V.F", 13
EQUS "V.G", 13
EQUS "V.H", 13
EQUS "V.I", 13
EQUS "V.J", 13
EQUS "V.K", 13
EQUS "V.L", 13
EQUS "V.M", 13
EQUS "V.N", 13
EQUS "V.O", 13
EQUS "V.P", 13
EQUS "V.Q", 13
EQUS "V.R", 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. Master Tracker "
EQUS " 2. Exception "
EQUS " 3. Fluid Dynamics "
EQUS " 4. Bonus Zone "
EQUS " 5. MisSioN 76489 "
EQUS " 6. LOL I am late Sorry "
EQUS " 7. Sonic Enters a Dance Club "
EQUS " 8. I Can Haz D00ty "
EQUS " 9. Infiltration Mission "
EQUS "10. Overcast "
EQUS "11. iNTeNSiTY "
\\ *** Removed
\\ EQUS "12. Kill Chipsters on Sight! "
\\ ***
EQUS "12. Nintendo Entertainment Samba"
EQUS "13. Happy Fun Times "
EQUS "14. Pinky Plinky Thingy "
EQUS "15. Reg "
EQUS "16. Masks Revenge "
EQUS "17. Gost Haus "
EQUS "18. Adrenaline Lift "
EQUS "19. The Long Goodbye "
EQUS "20. Chilled Out Princess "
EQUS "21. The Circus Is In Town "
EQUS "22. Frozen Dancehall o/t Pharoah"
EQUS "23. PSG Strut "
EQUS "24. My Mission "
EQUS "25. My New Used Car "
EQUS "26. Run Under Fire "
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_botb/BotB 7832 MasterTracker.raw.exo", "V.0", 0
PUTFILE "vgm_botb/BotB 7383 exception.raw.exo", "V.1", 0 ; V.B fails for some wierd reason?
PUTFILE "vgm_botb/BotB 16433 Slimeball - Fluid Dynamics.raw.exo", "V.2", 0
PUTFILE "vgm_botb/BonusZone.raw.exo", "V.3", 0
PUTFILE "vgm_botb/MISSION76496.raw.exo", "V.4", 0
PUTFILE "vgm_botb/BotB 7639 lol i am late sorry.raw.exo", "V.5", 0
PUTFILE "vgm_botb/BotB 4406 sonic_enters_a_dance_club.raw.exo", "V.6", 0
PUTFILE "vgm_botb/BotB 1643 flashbob - I can haz d00ty caiclz plz.raw.exo", "V.7", 0
PUTFILE "vgm_botb/BotB 1819 Kulor - Snofer Apostrophy S Infiltration Mission.raw.exo", "V.8", 0
PUTFILE "vgm_botb/BotB 2310 chunter - overcast.raw.exo", "V.9", 0
PUTFILE "vgm_botb/BotB 5106 null1024 - iNTeNSiTY.raw.exo", "V.A", 0
\\ Removed this tune as we need disk space for text and this sounds harsh on the ears!
\\ PUTFILE "vgm_botb/BotB 5135 b00daw - kill chipsters on sight!.raw.exo", "V.C", 0
\\ ***
PUTFILE "vgm_botb/BotB 5181 Kulor - Nintendo Entertainment Samba.raw.exo", "V.D", 0
PUTFILE "vgm_botb/BotB 7637 happyfuntimes.raw.exo", "V.E", 0
PUTFILE "vgm_botb/BotB 8493 null1024 - pinky plinky thingy.raw.exo", "V.F", 0
PUTFILE "vgm_botb/BotB 9302 reg.raw.exo", "V.G", 0
PUTFILE "vgm_botb/BotB 10995 masks revenge.raw.exo", "V.H", 0
PUTFILE "vgm_botb/BotB 10996 gost haus.raw.exo", "V.I", 0
PUTFILE "vgm_botb/BotB 11925 Interrobang Pie - Adrenaline Lift.raw.exo", "V.J", 0
PUTFILE "vgm_botb/BotB 12143 DimWiddy - The Long Goodbye.raw.exo", "V.K", 0
PUTFILE "vgm_botb/BotB 14648 chilled out princess.raw.exo", "V.L", 0
PUTFILE "vgm_botb/BotB 16712 stewboy - The Circus is in Town.raw.exo", "V.M", 0
PUTFILE "vgm_botb/BotB 16439 Chip Champion - frozen dancehall of the pharaoh.raw.exo", "V.N", 0
PUTFILE "vgm_botb/BotB 20609 Jredd - PSG Strut.raw.exo", "V.O", 0
PUTFILE "vgm_botb/my_mission.raw.exo", "V.P", 0
PUTFILE "vgm_botb/my_new_used_car.raw.exo", "V.Q", 0
PUTFILE "vgm_botb/run_under_fire.raw.exo", "V.R", 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