-
Notifications
You must be signed in to change notification settings - Fork 0
/
teletextr.asm
545 lines (361 loc) · 16.2 KB
/
teletextr.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
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
; Let's have some 65C02 action!
CPU 1
;----------------------------------------------------------------------------------------------------------
; Build defines
;----------------------------------------------------------------------------------------------------------
DEBUG = TRUE
_ABUG = FALSE
_HEADER = TRUE ; teletext header is visible, so adjust line offsets +1 in effects
USE_SHADOW_RAM = TRUE
\ ******************************************************************
\ * Headers
\ ******************************************************************
; Allocate vars in ZP
.zp_start
ORG 0
GUARD &8f
;----------------------------------------------------------------------------------------------------------
; Common global defines
;----------------------------------------------------------------------------------------------------------
INCLUDE "lib/bbc.h.asm"
INCLUDE "lib/bbc_utils.h.asm"
;----------------------------------------------------------------------------------------------------------
; Common code headers
;----------------------------------------------------------------------------------------------------------
; Include common code headers here - these can declare ZP vars from the pool using SKIP...
INCLUDE "lib/exomiser.h.asm"
INCLUDE "lib/mode7_graphics.h.asm"
INCLUDE "lib/mode7_plot_pixel.h.asm"
INCLUDE "lib/mode7_sprites.h.asm"
INCLUDE "lib/mode7_gif_anim.h.asm"
INCLUDE "lib/bresenham.h.asm"
INCLUDE "lib/3d/3d.h.asm"
INCLUDE "src/main.h.asm"
.zp_end
; Master 128 PAGE is &0E00 since MOS uses other RAM buffers for DFS workspace
SCRATCH_RAM_ADDR = &0E00
; 0E00 - &11FF is a 1Kb buffer
; used by disksys and filesys as scratch RAM
; also used by 3d model system as scratch RAM
; also used as an offscreen draw buffer
\ ******************************************************************
\ * Utility code - always memory resident
\ ******************************************************************
ORG &0900
GUARD &0D00
.utils_start
INCLUDE "lib/swr.asm"
INCLUDE "lib/print.asm" ; feels unnecessary, hardly used, and only for debugging mainly
INCLUDE "lib/disksys.asm"
;INCLUDE "lib/filesys.asm" ; not needed anymore, as using disksys instead (faster)
INCLUDE "lib/shadowram.asm"
; this lot fits in 1Kb with 2 bytes to spare!
.utils_end
SAVE "System", utils_start, utils_end, 0
\ ******************************************************************
\ * Bootstrap loader code
\ ******************************************************************
; Loaded at &0400 at boot time, overwritten later as used by exomiser
ORG &0400
GUARD &07FF
.boot_start
INCLUDE "src/boot.asm"
.boot_end
SAVE "Teletxr", boot_start, boot_end, boot_entry
\ ******************************************************************
\ * Main Code
\ ******************************************************************
; &0E00-&11FF is SCRATCH_RAM_ADDR
; main code entry
ORG &1200
; new guard position of &3000 which is where shadow ram begins
; we cannot put code into video ram address range if we are to use shadow ram
GUARD &3000
.start
;----------------------------------------------------------------------------------------------------------
; Common code
;----------------------------------------------------------------------------------------------------------
; Include common code used by effects here...
.start_lib
WIREFRAME=TRUE
MODE7=TRUE
INCLUDE "lib/mode7_graphics.asm"
INCLUDE "lib/mode7_plot_pixel.asm"
INCLUDE "lib/mode7_sprites.asm"
INCLUDE "lib/mode7_gif_anim.asm"
INCLUDE "lib/exomiser.asm"
INCLUDE "lib/vgmplayer.h.asm"
INCLUDE "lib/vgmplayer.asm"
INCLUDE "lib/irq.asm"
INCLUDE "lib/vram.asm"
;----------------------------------------------------------------------------------------------------------
; demo config
;----------------------------------------------------------------------------------------------------------
INCLUDE "src/script.asm"
INCLUDE "src/config.asm"
\ ******************************************************************
\ * Code entry
\ ******************************************************************
INCLUDE "src/main.asm"
.end_lib
;----------------------------------------------------------------------------------------------------------
; Effect code
;----------------------------------------------------------------------------------------------------------
; Include your effects here...
.start_fx_code
INCLUDE "src/fx/music.asm"
INCLUDE "src/fx/copybuffer.asm"
.end_fx_code
.end
SAVE "Main", start, end, 0
\ ******************************************************************
\ * Data
\ ******************************************************************
;----------------------------------------------------------------------------------------------------------
; SWR Bank 0
;----------------------------------------------------------------------------------------------------------
CLEAR &8000, &BFFF
ORG &8000
GUARD &BFFF
.bank0_start
IF TRUE
; included first to ensure page alignment
FX_3DCODE_SLOT = 0
.graphics_3d_start
INCLUDE "lib/3d/fastmultiply.asm"
INCLUDE "lib/3d/sincos.asm"
INCLUDE "lib/3d/maths.asm"
INCLUDE "lib/3d/culling.asm"
INCLUDE "lib/3d/zsort.asm"
INCLUDE "lib/3d/model.asm"
INCLUDE "lib/bresenham.asm"
.graphics_3d_end
; All of the following effects make use of the 3d & bresenham routines which are now in SWR
;----------------------------------------------------------------------------------------------------------
FX_VECTORBALLS_SLOT = 0
INCLUDE "src/fx/vectorballs.asm"
;----------------------------------------------------------------------------------------------------------
FX_3DSHAPE_SLOT = 0
INCLUDE "src/fx/3dshape.asm"
;----------------------------------------------------------------------------------------------------------
FX_LINEBOX_SLOT = 0
INCLUDE "src/fx/linebox.asm"
;----------------------------------------------------------------------------------------------------------
FX_VECTORTEXT_SLOT = 0
INCLUDE "src/fx/vectortext.asm"
ENDIF
;----------------------------------------------------------------------------------------------------------
FX_ROTOZOOM_SLOT = 0
.start_fx_rotozoom
INCLUDE "src/fx/rotozoom.asm"
INCLUDE "src/fx/rotozoom1.asm"
INCLUDE "src/fx/rotozoom2.asm"
INCLUDE "src/fx/rotozoom3.asm"
.end_fx_rotozoom
;----------------------------------------------------------------------------------------------------------
IF MUSIC_SHADOW == FALSE
.music_en
; hack demo to temporarily use small music track to free up 16Kb SWR bank, and put music in main RAM instead
IF FALSE
MUSIC_EN_SLOT = 0
INCBIN "data/music_en.raw.exo" ; 16362 bytes
ELSE
MUSIC_EN_SLOT = 0
INCBIN "data/music_reg.raw.exo" ; 1548
ENDIF
ENDIF
;----------------------------------------------------------------------------------------------------------
FX_BACKGROUND_SLOT = 0
INCLUDE "src/fx/background.asm"
;----------------------------------------------------------------------------------------------------------
; Animated logo
FX_LOGOANIM_SLOT = 0
INCLUDE "src/fx/logoanim.asm"
FX_GREENSCREEN_SLOT = 0
INCLUDE "src/fx/greenscreen.asm"
FX_COPPERBARS_SLOT = 0
INCLUDE "src/fx/copperbars.asm"
.bank0_end
SAVE "Bank0", bank0_start, bank0_end, &8000
;----------------------------------------------------------------------------------------------------------
; SWR Bank 1
;----------------------------------------------------------------------------------------------------------
CLEAR &8000, &BFFF
ORG &8000
GUARD &BFFF
.bank1_start
IF MUSIC_SHADOW == FALSE
MUSIC_REG_SLOT = 1
.music_reg
INCBIN "data/music_reg.raw.exo" ; 1548
MUSIC_EXCEPTION_SLOT = 1
.music_exception
INCBIN "data/music_exception.raw.exo" ; 4297
ENDIF
;...
;----------------------------------------------------------------------------------------------------------
; common overlay effects
;----------------------------------------------------------------------------------------------------------
;----------------------------------------------------------------------------------------------------------
; Dot scroller
FX_DOTSCROLLER_SLOT = 1
INCLUDE "src/fx/dotscroller.asm"
FX_MIRRORFLOOR_SLOT = 1
INCLUDE "src/fx/mirrorfloor.asm"
;----------------------------------------------------------------------------------------------------------
; Teletext effect
FX_TELETEXT_SLOT = 1
INCLUDE "src/fx/teletext.asm"
;----------------------------------------------------------------------------------------------------------
; Noise effect
FX_NOISE_SLOT = 1
INCLUDE "src/fx/noise.asm"
.bank1_end
SAVE "Bank1", bank1_start, bank1_end, &8000
;----------------------------------------------------------------------------------------------------------
; SWR Bank 2
;----------------------------------------------------------------------------------------------------------
CLEAR &8000, &BFFF
ORG &8000
GUARD &BFFF
.bank2_start
;----------------------------------------------------------------------------------------------------------
; Interference effect
FX_INTERFERENCE_SLOT = 2
INCLUDE "src/fx/interference.asm"
;----------------------------------------------------------------------------------------------------------
; Particle system
FX_PARTICLES_SLOT = 2
INCLUDE "src/fx/particles.asm"
;----------------------------------------------------------------------------------------------------------
; Credit scroller
FX_CREDITSCROLL_SLOT = 2
INCLUDE "src/fx/creditscroll.asm"
.bank2_end
SAVE "Bank2", bank2_start, bank2_end, &8000
;----------------------------------------------------------------------------------------------------------
;----------------------------------------------------------------------------------------------------------
; SWR Bank 3
;----------------------------------------------------------------------------------------------------------
CLEAR &8000, &BFFF
ORG &8000
GUARD &BFFF
.bank3_start
;----------------------------------------------------------------------------------------------------------
; GIF player effect data
FX_PLAYGIFS_SLOT = 3
INCLUDE "src/fx/playgifs.asm"
;----------------------------------------------------------------------------------------------------------
FX_PLASMA_SLOT = 3
INCLUDE "src/fx/plasma.asm"
;----------------------------------------------------------------------------------------------------------
FX_TESTCARD_SLOT = 3
INCLUDE "src/fx/testcard.asm"
;----------------------------------------------------------------------------------------------------------
FX_LOGOWIBBLE_SLOT = 3
INCLUDE "src/fx/logowibble.asm"
FX_RASTERBARS_SLOT = 3
INCLUDE "src/fx/rasterbars.asm"
FX_STARFIELD_SLOT = 3
INCLUDE "src/fx/starfield.asm"
.bank3_end
SAVE "Bank3", bank3_start, bank3_end, &8000
;----------------------------------------------------------------------------------------------------------
; Shadow Bank 0 (20Kb) Main
;----------------------------------------------------------------------------------------------------------
CLEAR &3000, &7BFF
ORG &3000
GUARD &7BFF
.shadow_bank0_start
MUSIC_EN_SLOT_S = SELECT_RAM_MAIN
.music_en_s
INCBIN "data/music_en.raw.exo" ; 16362 bytes
MUSIC_REG_SLOT_S = SELECT_RAM_MAIN
.music_reg_s
INCBIN "data/music_reg.raw.exo" ; 1548
.shadow_bank0_end
SAVE "SBank0", shadow_bank0_start, shadow_bank0_end, &3000
;----------------------------------------------------------------------------------------------------------
; Shadow Bank 1 (20Kb)
;----------------------------------------------------------------------------------------------------------
CLEAR &3000, &7BFF
ORG &3000
GUARD &7BFF
.shadow_bank1_start
MUSIC_EXCEPTION_SLOT_S = SELECT_RAM_SHADOW
.music_exception_s
INCBIN "data/music_exception.raw.exo" ; 4297
.shadow_bank1_end
SAVE "SBank1", shadow_bank1_start, shadow_bank1_end, &3000
; Another 8Kb bank for &C000-&DFFF ?
; Another 4Kb bank for &8000-&8FFF ?
;----------------------------------------------------------------------------------------------------------
; Effect stats
;----------------------------------------------------------------------------------------------------------
PRINT "------------------------------------------------------------"
PRINT "Demo Sequence data from", ~demo_script_start, "to", ~demo_script_end, ", size is", (demo_script_end-demo_script_start), "bytes"
PRINT " fx_code size is", (end_fx_code-start_fx_code), "bytes"
PRINT "Main RAM effects:"
PRINT "SW RAM effects:"
PRINT " fx_teletext size is", (end_fx_teletext-start_fx_teletext), "bytes"
PRINT " fx_vectortext size is", (end_fx_vectortext-start_fx_vectortext), "bytes"
PRINT " fx_plasma size is", (end_fx_plasma-start_fx_plasma), "bytes"
PRINT " fx_vectorballs size is", (end_fx_vectorballs-start_fx_vectorballs), "bytes"
PRINT " fx_rotozoom size is", (end_fx_rotozoom-start_fx_rotozoom), "bytes"
PRINT " fx_interference size is", (end_fx_interference-start_fx_interference), "bytes"
PRINT " fx_playgifs size is", (end_fx_playgifs-start_fx_playgifs), "bytes"
PRINT " fx_testcard size is", (end_fx_testcard-start_fx_testcard), "bytes"
PRINT " fx_3dshape size is", (end_fx_3dshape-start_fx_3dshape), "bytes"
PRINT " fx_rasterbars size is", (end_fx_rasterbars-start_fx_rasterbars), "bytes"
PRINT " fx_mirrorfloor size is", (end_fx_mirrorfloor-start_fx_mirrorfloor), "bytes"
PRINT " fx_linebox size is", (end_fx_linebox-start_fx_linebox), "bytes"
PRINT " fx_copperbars size is", (end_fx_copperbars-start_fx_copperbars), "bytes"
PRINT " fx_particles size is", (end_fx_particles-start_fx_particles), "bytes"
PRINT " fx_starfield size is", (end_fx_starfield-start_fx_starfield), "bytes"
PRINT " fx_creditscroll size is", (end_fx_creditscroll-start_fx_creditscroll), "bytes"
PRINT " fx_dotscroller size is", (end_fx_dotscroller-start_fx_dotscroller), "bytes"
PRINT " fx_logowibble size is", (end_fx_logowibble-start_fx_logowibble), "bytes"
PRINT " fx_logoanim size is", (end_fx_logoanim-start_fx_logoanim), "bytes"
PRINT "------------------------------------------------------------"
PRINT " mode7_graphics.asm lib size is", (mode7_graphics_end-mode7_graphics_start), "bytes"
PRINT " graphics_3d lib size is ", (graphics_3d_end-graphics_3d_start), "bytes"
PRINT "------------------------------------------------------------"
;----------------------------------------------------------------------------------------------------------
; Build stats
;----------------------------------------------------------------------------------------------------------
PRINT "ZeroPage from", ~zp_start, "to", ~zp_end, ", size is", (zp_end-zp_start), "bytes"
PRINT "Lib code from", ~start_lib, "to", ~end_lib, ", size is", (end_lib-start_lib), "bytes"
PRINT " FX code from", ~start_fx_code, "to", ~end_fx_code, ", size is", (end_fx_code-start_fx_code), "bytes"
PRINT "All code from", ~start, "to", ~end, ", size is", (end-start), "bytes"
PRINT ""
PRINT "Bank0 from", ~bank0_start, "to", ~bank0_end, ", free mem is", 16384-(bank0_end-bank0_start), "bytes"
PRINT "Bank1 from", ~bank1_start, "to", ~bank1_end, ", free mem is", 16384-(bank1_end-bank1_start), "bytes"
PRINT "Bank2 from", ~bank2_start, "to", ~bank2_end, ", free mem is", 16384-(bank2_end-bank2_start), "bytes"
PRINT "Bank3 from", ~bank3_start, "to", ~bank3_end, ", free mem is", 16384-(bank3_end-bank3_start), "bytes"
PRINT ""
PRINT "Shadow Bank0 from", ~shadow_bank0_start, "to", ~shadow_bank0_end, ", free mem is", 19456-(shadow_bank0_end-shadow_bank0_start), "bytes"
PRINT "Shadow Bank1 from", ~shadow_bank1_start, "to", ~shadow_bank1_end, ", free mem is", 19456-(shadow_bank1_end-shadow_bank1_start), "bytes"
PRINT ""
PRINT "Bootstrap code from", ~boot_start, "to", ~boot_end, ", free mem is", 1024-(boot_end-boot_start), "bytes"
PRINT "Utility code from", ~utils_start, "to", ~utils_end, ", free mem is", 1024-(utils_end-utils_start), "bytes"
PRINT ""
PRINT "Main code space remaining", &3000-end, "bytes"
IF 0
PUTFILE "data/pages/holdtest.txt.bin", "HOLD", &7C00
PUTFILE "data/pages/testpage.txt.bin", "TEST", &7C00
PUTFILE "data/pages/Channl4","Channl4", &7C00
PUTFILE "data/pages/owl","owl", &7C00
PUTFILE "data/pages/TESTPAGE","TESTPAG", &7C00
PUTFILE "data/pages/TVB","TVB", &7C00
PUTFILE "data/pages/TVGuide","TVGuide", &7C00
PUTFILE "data/pages/Yorks","Yorks", &7C00
PUTBASIC "src/fx/6845.txt", "6845"
ENDIF
PRINT "Build successful."
; need to free up 10Kb in main RAM.
; move 3d stuff into one SWR bank0
; 3d routines
; fx_vectorballs
; fx_linebox
; fx_3dshape
; fx_vectortext