-
Notifications
You must be signed in to change notification settings - Fork 2
/
scr-beeb.asm
1640 lines (1405 loc) · 42.2 KB
/
scr-beeb.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
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
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
; *****************************************************************************
; STUNT CAR RACER
; *****************************************************************************
; *****************************************************************************
; BEEB OS DEFINES
; *****************************************************************************
INCLUDE "lib/bbc.h.asm"
; *****************************************************************************
; GLOBAL DEFINES
; *****************************************************************************
; Load process:
;
; 1. $.Loader - loads into main RAM, below $3000. Loads title screen
; to shadow RAM, displays it, and runs $.Loader2
;
; 2. $.Loader2 - loads into main RAM between $4e00 and $6000. Loads
; more stuff as follows:
;
; 2.1. <<ROM banks>> - $0e00 - $4e00 (buffered, then copied out)
; 2.2. $.Core - $0e00 - $3f00 (in situ)
; 2.3. $.Data - $6000 - $8000 (in situ)
; 2.4. $.Hazel - <<wherever fits>> (buffered, then copied out)
;
; Loader2 has to start at >=$4e00, because there must be 16K somewhere
; for loading the ROMs. The address of this 16K is not important, but
; $.Loader2 is too large to start at $3f00 (as required to leave room
; for loading $.Core) while still leaving 16K free from $4000, so that
; limits things. And it has to finish <$6000, because that's where
; $.Data has to end up.
;
; And $.Hazel has to be able to fit somewhere in this region too
; (again, exact address unimportant), along with $.Loader2, because it
; has to be loaded into main RAM before being copied out.
;
; This is all probably not as data-driven as it should be.
; Where ROM banks are buffered to when being loaded.
disksys_loadto_addr = $0e00
; Where $.Hazel is loaded to.
hazel_load_addr=$4000
; Where loader2 should live.
loader2_addr=$4e00
MAX_LOADABLE_ROM_SIZE = $8000 - disksys_loadto_addr
_TODO = FALSE
_NOT_BEEB = FALSE
_DEBUG = FALSE
; Both are one digit. We're unlikely to run out. Even having
; major/minor is probably overkill.
BUILD_VERSION_MAJOR = '1'
BUILD_VERSION_MINOR = '1'
If _DEBUG
BUILD_VERSION_SUFFIX = 'd'
ELSE
BUILD_VERSION_SUFFIX = 'r'
ENDIF
DEFAULT_TRACK_DRAW_DISTANCE = $02 ; $06 for longer draw
DEFAULT_SOUND_VOLUME = 12 ; 0=silent, 15=loudest
BEEB_SCREEN_MODE = 4
BEEB_KERNEL_SLOT = 4
BEEB_CART_SLOT = 5
BEEB_GRAPHICS_SLOT = 6
BEEB_MUSIC_SLOT = 7
BEEB_PIXELS_COLOUR1 = &0F ; C64=$55
BEEB_PIXELS_COLOUR2 = &F0 ; C64=$AA
BEEB_PIXELS_COLOUR3 = &FF ; C64=$FF
; C64 controls
; Left/Right = S/D
; Boost = Return
; Brake = '='
; Reverse = Space
; Pause = P
; Resume = O
; Redefine Keys whilst paused = F1
; Quit = 'Commodore'
KEY_DEF_FIRE = IKN_return ; Return
KEY_DEF_LEFT = IKN_s ; S
KEY_DEF_RIGHT = IKN_d ; D
KEY_DEF_BACK = IKN_space ; Space
KEY_DEF_BRAKE = IKN_colon ; =
KEY_DEF_PAUSE = IKN_p ;$0D ; P
KEY_DEF_REDEFINE = IKN_f1 ;$20 ; F1
KEY_DEF_QUIT = IKN_esc ;$2F ; Commodore
KEY_DEF_CONTINUE = IKN_o ;$34 ; O
KEY_DEF_CANCEL = IKN_esc ;$3F ; run stop?
KEY_DEF_WIN_TRAINER = IKN_q ; cheat!
KEY_MENU_OPTION_1 = IKN_1
KEY_MENU_OPTION_2 = IKN_2
KEY_MENU_OPTION_3 = IKN_3
KEY_MENU_OPTION_4 = IKN_4
KEY_MENU_MUSIC = IKN_m
KEY_RETURN = IKN_return
KEY_RIGHT_SHIFT = IKN_shift ;$26 ; right shift
KEY_LEFT_SHIFT = IKN_shift ;$39 ; left shift
KEY_VOLUME_UP = IKN_keypad_plus
KEY_VOLUME_DOWN = IKN_keypad_minus
; *****************************************************************************
; MACROS
; *****************************************************************************
MACRO PAGE_ALIGN
PRINT " ALIGN LOST ", ~LO(((P% AND &FF) EOR &FF)+1), " BYTES"
ALIGN &100
ENDMACRO
MACRO SWR_SELECT_SLOT bank
{
LDA #bank:STA &F4:STA &FE30
}
ENDMACRO
; *****************************************************************************
; C64 KERNEL DEFINES
; *****************************************************************************
KERNEL_RAM_VECTORS = $FD30
KERNEL_READST = $FFB7 ; Read the I/O Status Word
KERNEL_SETLFS = $FFBA ; Set Logical File Number, Device Number, and Secondary Address
KERNEL_SETNAM = $FFBD ; Set Filename Parameters
KERNEL_OPEN = $FFC0 ; Open a Logical I/O File
KERNEL_CLOSE = $FFC3 ; Close a Logical I/O File
;KERNEL_LOAD = $FFD5 ; Load RAM from a device
;KERNEL_SAVE = $FFD8 ; Save RAM to a device
KERNEL_GETIN = $FFE4 ; Get One Byte from the Input Device
BEEB_VIC_BASE = $300 ; $D000
BEEB_SID_BASE = $330 ; $D400
; BEEB_COLOR_BASE = $D800
BEEB_CIA1_BASE = $350 ; $DC00
BEEB_CIA2_BASE = $360 ; $DD00
; Not sure what this is used for - depends on which C64 bank is paged in?
L_A000 = $370 ;$A000 ; Cold Start Vector?
; NOTE! space from $03A0 to $03D0 is used to store ZP vars during FS operations
VIC_SP0X = BEEB_VIC_BASE + $00 ; Sprite 0 Horizontal Position
VIC_SP0Y = BEEB_VIC_BASE + $01 ; Sprite 0 Vertical Position
VIC_SP1X = BEEB_VIC_BASE + $02 ; Sprite 1 Horizontal Position
VIC_SP1Y = BEEB_VIC_BASE + $03 ; Sprite 1 Vertical Position
VIC_SP2X = BEEB_VIC_BASE + $04 ; Sprite 2 Horizontal Position
VIC_SP2Y = BEEB_VIC_BASE + $05 ; Sprite 2 Vertical Position
VIC_SP3X = BEEB_VIC_BASE + $06 ; Sprite 3 Horizontal Position
VIC_SP3Y = BEEB_VIC_BASE + $07 ; Sprite 3 Vertical Position
VIC_SP4X = BEEB_VIC_BASE + $08 ; Sprite 4 Horizontal Position
VIC_SP4Y = BEEB_VIC_BASE + $09 ; Sprite 4 Vertical Position
VIC_SP5X = BEEB_VIC_BASE + $0A ; Sprite 5 Horizontal Position
VIC_SP5Y = BEEB_VIC_BASE + $0B ; Sprite 5 Vertical Position
VIC_SP6X = BEEB_VIC_BASE + $0C ; Sprite 6 Horizontal Position
VIC_SP6Y = BEEB_VIC_BASE + $0D ; Sprite 6 Vertical Position
VIC_SP7X = BEEB_VIC_BASE + $0E ; Sprite 7 Horizontal Position
VIC_SP7Y = BEEB_VIC_BASE + $0F ; Sprite 7 Vertical Position
VIC_MSIGX = BEEB_VIC_BASE + $10 ; Most Significant Bits of Sprites 0-7 Horizontal Position
VIC_SCROLY = BEEB_VIC_BASE + $11 ; Vertical Fine Scrolling and Control Register
VIC_RASTER = BEEB_VIC_BASE + $12 ; Read Current Raster Scan Line/Write Line to Compare for Raster IRQ
VIC_SPENA = BEEB_VIC_BASE + $15 ; Sprite Enable Register
VIC_SCROLX = BEEB_VIC_BASE + $16 ; Horizontal Fine Scrolling and Control Register
VIC_YXPAND = BEEB_VIC_BASE + $17 ; Sprite Vertical Expansion Register
VIC_VMCSB = BEEB_VIC_BASE + $18 ; VIC-II Chip Memory Control Register
VIC_VICIRQ = BEEB_VIC_BASE + $19 ; VIC Interrupt Flag Register
VIC_IRQMASK = BEEB_VIC_BASE + $1A ; IRQ Mask Register
VIC_SPBGPR = BEEB_VIC_BASE + $1B ; Sprite to Foreground Display Priority Register
VIC_SPMC = BEEB_VIC_BASE + $1C ; Sprite Multicolor Registers
VIC_XXPAND = BEEB_VIC_BASE + $1D ; Sprite Horizontal Expansion Register
VIC_SPSPCL = BEEB_VIC_BASE + $1E ; Sprite to Sprite Collision Register
VIC_SPBGCL = BEEB_VIC_BASE + $1F ; Sprite to Foreground Collision Register
VIC_EXTCOL = BEEB_VIC_BASE + $20 ; Border Color Register
VIC_BGCOL0 = BEEB_VIC_BASE + $21 ; Background Color 0
VIC_BGCOL1 = BEEB_VIC_BASE + $22 ; Background Color 1
VIC_BGCOL2 = BEEB_VIC_BASE + $23 ; Background Color 2
VIC_BGCOL3 = BEEB_VIC_BASE + $24 ; Background Color 3
VIC_SPMC0 = BEEB_VIC_BASE + $25 ; Sprite Multicolor Register 0
VIC_SPMC1 = BEEB_VIC_BASE + $26 ; Sprite Multicolor Register 1
VIC_SP0COL = BEEB_VIC_BASE + $27 ; Sprite 0 Color Register (the default color value is 1, white)
VIC_SP1COL = BEEB_VIC_BASE + $28 ; Sprite 1 Color Register (the default color value is 2, red)
VIC_SP2COL = BEEB_VIC_BASE + $29 ; Sprite 2 Color Register (the default color value is 3, cyan)
VIC_SP3COL = BEEB_VIC_BASE + $2A ; Sprite 3 Color Register (the default color value is 4, purple)
VIC_SP4COL = BEEB_VIC_BASE + $2B ; Sprite 4 Color Register (the default color value is 5, green)
VIC_SP5COL = BEEB_VIC_BASE + $2C ; Sprite 5 Color Register (the default color value is 6, blue)
VIC_SP6COL = BEEB_VIC_BASE + $2D ; Sprite 6 Color Register (the default color value is 7, yellow)
VIC_SP7COL = BEEB_VIC_BASE + $2E ; Sprite 7 Color Register (the default color value is 12, medium gray)
SID_FRELO1 = BEEB_SID_BASE + $00 ; Voice 1 Frequency Control (low byte)
SID_FREHI1 = BEEB_SID_BASE + $01 ; Voice 1 Frequency Control (high byte)
SID_PWLO1 = BEEB_SID_BASE + $02 ; Voice 1 Pulse Waveform Width (low byte)
SID_PWHI1 = BEEB_SID_BASE + $03 ; Voice 1 Pulse Waveform Width (high nybble)
SID_VCREG1 = BEEB_SID_BASE + $04 ; Voice 1 Control Register
SID_ATDCY1 = BEEB_SID_BASE + $05 ; Voice 1 Attack/Decay Register
SID_SUREL1 = BEEB_SID_BASE + $06 ; Voice 1 Sustain/Release Control Register
SID_FRELO2 = BEEB_SID_BASE + $07 ; Voice 2 Frequency Control (low byte)
SID_FREHI2 = BEEB_SID_BASE + $08 ; Voice 2 Frequency Control (high byte)
SID_PWLO2 = BEEB_SID_BASE + $09 ; Voice 2 Pulse Waveform Width (low byte)
SID_PWHI2 = BEEB_SID_BASE + $0A ; Voice 2 Pulse Waveform Width (high nybble)
SID_VCREG2 = BEEB_SID_BASE + $0B ; Voice 2 Control Register
SID_ATDCY2 = BEEB_SID_BASE + $0C ; Voice 2 Attack/Decay Register
SID_SUREL2 = BEEB_SID_BASE + $0D ; Voice 2 Sustain/Release Control Register
SID_FRELO3 = BEEB_SID_BASE + $0E ; Voice 3 Frequency Control (low byte)
SID_FREHI3 = BEEB_SID_BASE + $0F ; Voice 3 Frequency Control (high byte)
SID_PWLO3 = BEEB_SID_BASE + $10 ; Voice 3 Pulse Waveform Width (low byte)
SID_PWHI3 = BEEB_SID_BASE + $11 ; Voice 3 Pulse Waveform Width (high nybble)
SID_VCREG3 = BEEB_SID_BASE + $12 ; Voice 3 Control Register
SID_ATDCY3 = BEEB_SID_BASE + $13 ; Voice 3 Attack/Decay Register
SID_SUREL3 = BEEB_SID_BASE + $14 ; Voice 3 Sustain/Release Control Register
SID_CUTLO = BEEB_SID_BASE + $15 ; Bits 0-2: Low portion of filter cutoff frequency
SID_CUTHI = BEEB_SID_BASE + $16 ; Filter Cutoff Frequency (high byte)
SID_RESON = BEEB_SID_BASE + $17 ; Filter Resonance Control Register
SID_SIGVOL = BEEB_SID_BASE + $18 ; Volume and Filter Select Register
CIA1_CIAPRA = BEEB_CIA1_BASE + $00 ; Data Port Register A
CIA1_CIAPRB = BEEB_CIA1_BASE + $01 ; Data Port Register B
CIA1_CIDDRA = BEEB_CIA1_BASE + $02 ; Data Direction Register A
CIA1_CIDDRB = BEEB_CIA1_BASE + $03 ; Data Direction Register B
CIA1_TIMALO = BEEB_CIA1_BASE + $04 ; Timer A (low byte)
CIA1_TIMAHI = BEEB_CIA1_BASE + $05 ; Timer A (high byte)
CIA1_TIMBLO = BEEB_CIA1_BASE + $06 ; Timer B (low byte)
CIA1_TIMBHI = BEEB_CIA1_BASE + $07 ; Timer B (high byte)
CIA1_CIAICR = BEEB_CIA1_BASE + $0D ; Interrupt Control Register
CIA1_CIACRA = BEEB_CIA1_BASE + $0E ; Control Register A
CIA1_CIACRB = BEEB_CIA1_BASE + $0F ; Control Register B
CIA2_CI2PRA = BEEB_CIA2_BASE + $00
CIA2_C2DDRA = BEEB_CIA2_BASE + $02
CIA2_CIAICR = BEEB_CIA2_BASE + $0D ; Interrupt Control Register
C64_NO_IO_NO_KERNAL = $34
C64_IO_NO_KERNAL = $35
C64_IO_AND_KERNAL = $36
C64_VIC_BITMAP_SCREEN1 = $70
C64_VIC_BITMAP_SCREEN2 = $78
C64_VIC_IRQ_DISABLE = $00
C64_VIC_IRQ_RASTERCMP = $01
; *****************************************************************************
; VARIABLES
; *****************************************************************************
BEEB_ZP_OFFSET = &800
BEEB_ZP_REMAP = $E0 - $50 ; remap $E0 onwards to $40 onwards
_DATA_6510 = $00 ; 6510 On-Chip I/O DATA Direction Register
_RAM_SELECT = $01 ; 6510 RAM Selection Register
ZP_02 = $02
ZP_03 = $03
ZP_04 = $04
ZP_05 = $05
ZP_06 = $06
ZP_07 = $07
ZP_08 = $08
ZP_09 = $09
ZP_0A = $0A
ZP_0B = $0B
ZP_0C = $0C
ZP_0D = $0D
ZP_0E = $0E
ZP_0F = $0F
ZP_10 = $10
ZP_11 = $11
ZP_12 = $12 ; display buffer page
ZP_13 = $13
ZP_14 = $14
ZP_15 = $15
ZP_16 = $16
ZP_17 = $17
ZP_18 = $18
ZP_19 = $19
ZP_1A = $1A
ZP_1B = $1B
ZP_1C = $1C
ZP_1D = $1D
ZP_1E = $1E ; used as generic read_ptr
ZP_1F = $1F
ZP_20 = $20 ; used as ptr in cart-ram.asm
ZP_21 = $21
ZP_22 = $22
ZP_23 = $23
ZP_24 = $24
ZP_25 = $25
ZP_27 = $27
ZP_28 = $28
ZP_29 = $29
ZP_2A = $2A
ZP_2B = $2B
ZP_2C = $2C
ZP_2D = $2D
ZP_2E = $2E
ZP_2F = $2F ; some sort of timer for crane
ZP_30 = $30
ZP_31 = $31
ZP_32 = $32
ZP_33 = $33
ZP_34 = $34
ZP_35 = $35
ZP_36 = $36
ZP_37 = $37
ZP_38 = $38
ZP_39 = $39
ZP_3A = $3A
ZP_3B = $3B
ZP_3C = $3C
ZP_3D = $3D
ZP_3E = $3E
ZP_3F = $3F
ZP_40 = $40
ZP_41 = $41
ZP_43 = $43
ZP_44 = $44
ZP_45 = $45
ZP_46 = $46
ZP_48 = $48
ZP_49 = $49
ZP_4A = $4A
ZP_4B = $4B
ZP_4C = $4C
ZP_4D = $4D
ZP_4E = $4E
ZP_4F = $4F
ZP_50 = $50
ZP_51 = $51
ZP_52 = $52
ZP_53 = $53
ZP_54 = $54
ZP_55 = $55
ZP_56 = $56
ZP_57 = $57
ZP_58 = $58
ZP_59 = $59
ZP_5A = $5A
ZP_5B = $5B
ZP_5C = $5C + BEEB_ZP_OFFSET
ZP_5D = $5D + BEEB_ZP_OFFSET
ZP_5E = $5E + BEEB_ZP_OFFSET
ZP_5F = $5F + BEEB_ZP_OFFSET
ZP_60 = $60 + BEEB_ZP_OFFSET
ZP_61 = $61 + BEEB_ZP_OFFSET
ZP_62 = $62 + BEEB_ZP_OFFSET
ZP_63 = $63 + BEEB_ZP_OFFSET
ZP_64 = $64 + BEEB_ZP_OFFSET
ZP_66 = $66 + BEEB_ZP_OFFSET
ZP_68 = $68 + BEEB_ZP_OFFSET
ZP_69 = $69 + BEEB_ZP_OFFSET
ZP_6A = $6A + BEEB_ZP_OFFSET
ZP_6B = $6B + BEEB_ZP_OFFSET ; 0=on track,$80=off track (sometimes $C0)
ZP_6C = $6C + BEEB_ZP_OFFSET ; end of game timer (either too much damage or lost to opponent)
ZP_6D = $6D + BEEB_ZP_OFFSET
ZP_6E = $6E + BEEB_ZP_OFFSET
ZP_6F = $6F + BEEB_ZP_OFFSET ; dashboard_sprites_enabled
ZP_70 = $70
ZP_71 = $71
ZP_72 = $72
ZP_73 = $73
ZP_74 = $74
ZP_75 = $75
ZP_76 = $76
ZP_77 = $77
ZP_78 = $78
ZP_79 = $79
ZP_7A = $7A
ZP_7B = $7B
ZP_7C = $7C
ZP_7D = $7D
ZP_7E = $7E
ZP_7F = $7F
ZP_80 = $80
ZP_81 = $81
ZP_82 = $82
ZP_83 = $83
ZP_86 = $86
ZP_89 = $89
ZP_8A = $8A
ZP_8B = $8B
ZP_8C = $8C
ZP_8D = $8D
ZP_8E = $8E
ZP_8F = $8F
ZP_90 = $90
ZP_91 = $91
ZP_92 = $92
ZP_93 = $93
ZP_94 = $94
ZP_95 = $95
; $96
ZP_97 = $97
ZP_98 = $98 ; used as ptr for track stuff
ZP_99 = $99
ZP_9A = $9A ; used as ptr for track stuff
ZP_9B = $9B
ZP_9C = $9C
ZP_9D = $9D
ZP_9E = $9E
ZP_9F = $9F
ZP_A0 = $A0
ZP_A1 = $A1
ZP_A2 = $A2
ZP_A3 = $A3
ZP_A4 = $A4
ZP_A5 = $A5
ZP_A6 = $A6
ZP_A7 = $A7
ZP_A8 = $A8
ZP_A9 = $A9
ZP_AA = $AA
ZP_AB = $AB
ZP_AC = $AC
ZP_AD = $AD
ZP_AF = $AF
ZP_B0 = $B0
ZP_B1 = $B1
ZP_B2 = $B2
ZP_B3 = $B3
ZP_B4 = $B4
ZP_B5 = $B5
ZP_B6 = $B6
ZP_B7 = $B7
ZP_B8 = $B8
ZP_B9 = $B9
ZP_BA = $BA
ZP_BB = $BB
ZP_BC = $BC
ZP_BD = $BD
ZP_BE = $BE
ZP_BF = $BF
ZP_C0 = $C0
ZP_C1 = $C1
ZP_C2 = $C2
ZP_C3 = $C3
ZP_C4 = $C4
ZP_C5 = $C5
ZP_C6 = $C6
ZP_C7 = $C7
ZP_C8 = $C8
ZP_C9 = $C9
ZP_CA = $CA ; frequently used as ptr
ZP_CB = $CB
ZP_CC = $CC
ZP_CD = $CD
ZP_CE = $CE
ZP_CF = $CF
ZP_D0 = $D0
ZP_D1 = $D1
ZP_D2 = $D2
ZP_D3 = $D3
ZP_D4 = $D4
ZP_D5 = $D5
ZP_D6 = $D6
ZP_D7 = $D7
ZP_D8 = $D8
ZP_D9 = $D9
ZP_DA = $DA
ZP_DB = $DB
ZP_DC = $DC
ZP_DD = $DD
ZP_DE = $DE
ZP_DF = $DF
ZP_E0 = $E0 + BEEB_ZP_OFFSET
ZP_E1 = $E1 + BEEB_ZP_OFFSET
ZP_E3 = $E3 + BEEB_ZP_OFFSET
ZP_E4 = $E4 + BEEB_ZP_OFFSET
ZP_E7 = $E7 + BEEB_ZP_OFFSET
ZP_E8 = $E8 + BEEB_ZP_OFFSET
ZP_E9 = $E9 + BEEB_ZP_OFFSET
ZP_EA = $EA + BEEB_ZP_OFFSET
ZP_EB = $EB + BEEB_ZP_OFFSET
ZP_EC = $EC - BEEB_ZP_REMAP
ZP_ED = $ED - BEEB_ZP_REMAP
ZP_EE = $EE - BEEB_ZP_REMAP
ZP_EF = $EF - BEEB_ZP_REMAP
ZP_F0 = $F0 - BEEB_ZP_REMAP ; frequently used as ptr
ZP_F1 = $F1 - BEEB_ZP_REMAP
ZP_F2 = $F2 - BEEB_ZP_REMAP
ZP_F4 = $F4 - BEEB_ZP_REMAP ; frequently used as ptr
ZP_F5 = $F5 - BEEB_ZP_REMAP
ZP_F6 = $F6 - BEEB_ZP_REMAP ; frequently used as ptr
ZP_F7 = $F7 - BEEB_ZP_REMAP
ZP_F8 = $F8 - BEEB_ZP_REMAP ; frequently used as ptr
ZP_F9 = $F9 - BEEB_ZP_REMAP
ZP_FA = $FA - BEEB_ZP_REMAP
ZP_FB = $FB - BEEB_ZP_REMAP
ZP_FC = $FC - BEEB_ZP_REMAP
ZP_FD = $FD - BEEB_ZP_REMAP
ZP_FE = $FE - BEEB_ZP_REMAP
; *****************************************************************************
; VARIABLES IN LOWER RAM
; *****************************************************************************
BEEB_LOWER_OFFSET = $800
L_0100 = $0100 + BEEB_LOWER_OFFSET
L_0101 = $0101 + BEEB_LOWER_OFFSET
L_0102 = $0102 + BEEB_LOWER_OFFSET
L_0103 = $0103 + BEEB_LOWER_OFFSET
L_0104 = $0104 + BEEB_LOWER_OFFSET
L_0105 = $0105 + BEEB_LOWER_OFFSET
L_0106 = $0106 + BEEB_LOWER_OFFSET
L_0107 = $0107 + BEEB_LOWER_OFFSET
L_0108 = $0108 + BEEB_LOWER_OFFSET
L_0109 = $0109 + BEEB_LOWER_OFFSET
L_010A = $010A + BEEB_LOWER_OFFSET
L_010B = $010B + BEEB_LOWER_OFFSET
L_010C = $010C + BEEB_LOWER_OFFSET
L_010D = $010D + BEEB_LOWER_OFFSET
L_010E = $010E + BEEB_LOWER_OFFSET
L_010F = $010F + BEEB_LOWER_OFFSET
L_0110 = $0110 + BEEB_LOWER_OFFSET
L_0111 = $0111 + BEEB_LOWER_OFFSET
L_0112 = $0112 + BEEB_LOWER_OFFSET
L_0113 = $0113 + BEEB_LOWER_OFFSET
L_0114 = $0114 + BEEB_LOWER_OFFSET
L_0115 = $0115 + BEEB_LOWER_OFFSET
L_0118 = $0118 + BEEB_LOWER_OFFSET
L_0119 = $0119 + BEEB_LOWER_OFFSET
L_011A = $011A + BEEB_LOWER_OFFSET
L_011B = $011B + BEEB_LOWER_OFFSET
L_011E = $011E + BEEB_LOWER_OFFSET
L_011F = $011F + BEEB_LOWER_OFFSET
L_0120 = $0120 + BEEB_LOWER_OFFSET
L_0121 = $0121 + BEEB_LOWER_OFFSET
L_0122 = $0122 + BEEB_LOWER_OFFSET
L_0123 = $0123 + BEEB_LOWER_OFFSET
L_0124 = $0124 + BEEB_LOWER_OFFSET
L_0125 = $0125 + BEEB_LOWER_OFFSET
L_0126 = $0126 + BEEB_LOWER_OFFSET
L_0130 = $0130 + BEEB_LOWER_OFFSET
L_0131 = $0131 + BEEB_LOWER_OFFSET
L_0132 = $0132 + BEEB_LOWER_OFFSET
L_0133 = $0133 + BEEB_LOWER_OFFSET
L_0134 = $0134 + BEEB_LOWER_OFFSET
L_0135 = $0135 + BEEB_LOWER_OFFSET
L_0136 = $0136 + BEEB_LOWER_OFFSET
L_0137 = $0137 + BEEB_LOWER_OFFSET
L_0138 = $0138 + BEEB_LOWER_OFFSET
L_0139 = $0139 + BEEB_LOWER_OFFSET
L_013A = $013A + BEEB_LOWER_OFFSET
L_013B = $013B + BEEB_LOWER_OFFSET
L_013C = $013C + BEEB_LOWER_OFFSET
L_013D = $013D + BEEB_LOWER_OFFSET
L_013E = $013E + BEEB_LOWER_OFFSET
L_013F = $013F + BEEB_LOWER_OFFSET
L_0140 = $0140 + BEEB_LOWER_OFFSET
L_0141 = $0141 + BEEB_LOWER_OFFSET
L_0142 = $0142 + BEEB_LOWER_OFFSET
L_0145 = $0145 + BEEB_LOWER_OFFSET
L_0148 = $0148 + BEEB_LOWER_OFFSET
L_0149 = $0149 + BEEB_LOWER_OFFSET
L_014A = $014A + BEEB_LOWER_OFFSET
L_014B = $014B + BEEB_LOWER_OFFSET
L_014C = $014C + BEEB_LOWER_OFFSET
L_014D = $014D + BEEB_LOWER_OFFSET
L_014E = $014E + BEEB_LOWER_OFFSET
L_014F = $014F + BEEB_LOWER_OFFSET
L_0150 = $0150 + BEEB_LOWER_OFFSET
L_0151 = $0151 + BEEB_LOWER_OFFSET
L_0154 = $0154 + BEEB_LOWER_OFFSET
L_0156 = $0156 + BEEB_LOWER_OFFSET
L_0157 = $0157 + BEEB_LOWER_OFFSET
L_0159 = $0159 + BEEB_LOWER_OFFSET
L_015A = $015A + BEEB_LOWER_OFFSET
L_015B = $015B + BEEB_LOWER_OFFSET
L_015C = $015C + BEEB_LOWER_OFFSET
L_015D = $015D + BEEB_LOWER_OFFSET
L_015E = $015E + BEEB_LOWER_OFFSET
L_015F = $015F + BEEB_LOWER_OFFSET
L_0160 = $0160 + BEEB_LOWER_OFFSET
L_0161 = $0161 + BEEB_LOWER_OFFSET
L_0166 = $0166 + BEEB_LOWER_OFFSET
L_0167 = $0167 + BEEB_LOWER_OFFSET
L_016A = $016A + BEEB_LOWER_OFFSET
L_016B = $016B + BEEB_LOWER_OFFSET
L_016C = $016C + BEEB_LOWER_OFFSET
L_016D = $016D + BEEB_LOWER_OFFSET
L_016E = $016E + BEEB_LOWER_OFFSET
L_016F = $016F + BEEB_LOWER_OFFSET
L_0170 = $0170 + BEEB_LOWER_OFFSET
L_0171 = $0171 + BEEB_LOWER_OFFSET
L_0172 = $0172 + BEEB_LOWER_OFFSET
L_0173 = $0173 + BEEB_LOWER_OFFSET
L_0174 = $0174 + BEEB_LOWER_OFFSET
L_0175 = $0175 + BEEB_LOWER_OFFSET
L_0176 = $0176 + BEEB_LOWER_OFFSET
L_0177 = $0177 + BEEB_LOWER_OFFSET
L_0178 = $0178 + BEEB_LOWER_OFFSET
L_0179 = $0179 + BEEB_LOWER_OFFSET
L_017A = $017A + BEEB_LOWER_OFFSET
L_017B = $017B + BEEB_LOWER_OFFSET
L_017C = $017C + BEEB_LOWER_OFFSET
L_017D = $017D + BEEB_LOWER_OFFSET
L_017E = $017E + BEEB_LOWER_OFFSET
L_017F = $017F + BEEB_LOWER_OFFSET
L_0180 = $0180 + BEEB_LOWER_OFFSET
L_0181 = $0181 + BEEB_LOWER_OFFSET
L_0182 = $0182 + BEEB_LOWER_OFFSET
L_0183 = $0183 + BEEB_LOWER_OFFSET
L_0184 = $0184 + BEEB_LOWER_OFFSET
L_0188 = $0188 + BEEB_LOWER_OFFSET
L_0189 = $0189 + BEEB_LOWER_OFFSET
L_018A = $018A + BEEB_LOWER_OFFSET
L_0190 = $0190 + BEEB_LOWER_OFFSET
L_01C1 = $01C1 + BEEB_LOWER_OFFSET
\\ Pretty sure these need to be contiguous
L_0200 = $0200 + BEEB_LOWER_OFFSET
L_0240 = $0240 + BEEB_LOWER_OFFSET
L_0241 = $0241 + BEEB_LOWER_OFFSET
L_0242 = $0242 + BEEB_LOWER_OFFSET
L_0243 = $0243 + BEEB_LOWER_OFFSET
L_0280 = $0280 + BEEB_LOWER_OFFSET
L_0291 = $0291 + BEEB_LOWER_OFFSET
L_02C0 = $02C0 + BEEB_LOWER_OFFSET
\\ These have to be contiguous as the value at $300 are indexed from L_0280
; Camera matrices?
L_0300 = $0300 + BEEB_LOWER_OFFSET
L_0314 = $0314 + BEEB_LOWER_OFFSET
L_0380 = $0380 + BEEB_LOWER_OFFSET
; Some sort of track variables?
; MAX ROAD SECTIONS = $4E = 78
L_0400 = $0400
L_0401 = $0401
L_0402 = $0402
road_section_angle_and_piece = $0400
L_042A = $042A
road_section_xz_positions = $044E
L_0480 = $0480
left_y_coordinate_IDs = $049C
L_04A0 = $04A0
right_y_coordinate_IDs = $04EA
L_04FA = $04FA
L_0500 = $0500
overall_left_y_shifts_LSBs = $0538
overall_left_y_shifts_MSBs = $0586
overall_right_y_shifts_LSBs = $05D4
L_05F4 = $05F4
L_0600 = $0600
overall_right_y_shifts_MSBs = $0622
distances_around_road_LSBs = $0670
distances_around_road_MSBs = $06BE
L_06EE = $06EE
L_0700 = $0700
L_0710 = $0710
L_0740 = $0740
L_0743 = $0743
L_0744 = $0744
L_075E = $075E
L_0769 = $0769
L_0774 = $0774
L_0775 = $0775
L_077A = $077A
L_077B = $077B
L_077C = $077C
L_077D = $077D
L_077E = $077E
L_077F = $077F
L_0780 = $0780
L_0781 = $0781
L_0782 = $0782
L_0784 = $0784
L_0786 = $0786
L_0788 = $0788
L_0789 = $0789
L_078A = $078A
L_078B = $078B
L_078C = $078C
L_078E = $078E
L_0790 = $0790
L_0793 = $0793
L_0795 = $0795
L_0796 = $0796
L_0797 = $0797
L_079C = $079C
L_079D = $079D
L_07A2 = $07A2
L_07A3 = $07A3
L_07A4 = $07A4
L_07A5 = $07A5
L_07A6 = $07A6
L_07A7 = $07A7
L_07A8 = $07A8
L_07A9 = $07A9
L_07AA = $07AA
L_07AC = $07AC
L_07AE = $07AE
L_07B0 = $07B0
L_07B1 = $07B1
L_07B2 = $07B2
L_07B3 = $07B3
L_07B4 = $07B4
L_07B6 = $07B6
L_07B8 = $07B8
L_07BB = $07BB
L_07BD = $07BD
L_07BE = $07BE
L_07BF = $07BF
L_07C4 = $07C4
L_07C8 = $07C8
L_07CC = $07CC
L_07D0 = $07D0
L_07D4 = $07D4
L_07D8 = $07D8
L_07DC = $07DC
L_07DE = $07DE
L_07E0 = $07E0
L_07E2 = $07E2
L_07E4 = $07E4
L_07E6 = $07E6
L_07E8 = $07E8
L_07EA = $07EA
L_07EC = $07EC
L_07ED = $07ED
L_07EE = $07EE
L_07F0 = $07F0
L_07F1 = $07F1
L_07F2 = $07F2
L_5800 = $5800
L_5900 = $5900
L_5A00 = $5A00
L_5B00 = $5B00
L_5C00 = $5C00
L_5D00 = $5D00
L_5E00 = $5E00
L_5F00 = $5f00
; this is where the VIC fetches the sprite pointers from, so I've left
; the addresses as-is for now. But these 8 bytes could go pretty much
; anywhere, really...
vic_sprite_ptr0=$5ff8
vic_sprite_ptr1=$5ff9
vic_sprite_ptr2=$5ffa
vic_sprite_ptr3=$5ffb
vic_sprite_ptr4=$5ffc
vic_sprite_ptr5=$5ffd
vic_sprite_ptr6=$5ffe
vic_sprite_ptr7=$5fff
INCLUDE "lib/vgmplayer.h.asm"
; *****************************************************************************
; CORE RAM: $0800 - $4000
;
; $0800 = Game code? (inc. game_update)
; $1400 = Rendering code? (inc. font, sprites, lines?)
; $1C00 = Game code? (inc. AI, )
; $2700 = Camera code?
; $2F00 = Rendering code? (track preview)
; $3000 = Front end (game select etc.)
; $3900 = Rendering code? (color map, menus)
; $3D00 = Main loop?
; $3F00 = System code? (page flip, VIC control, misc)
; *****************************************************************************
PRINT "***"
ORG &E00
GUARD hazel_load_addr ; using .boot_start doesn't seem to guard?
\\ Core Code
INCLUDE "game/core-ram.asm"
INCLUDE "game/beeb-dll.asm"
INCLUDE "game/beeb-code.asm"
;INCLUDE "lib/unpack.asm" ; could probably be move to SWRAM beeb-graphics
INCLUDE "lib/exo.asm" ; could probably be move to SWRAM beeb-graphics
\\ Core Data
INCLUDE "game/core-data.asm"
; *****************************************************************************
\\ Core RAM area
; *****************************************************************************
PRINT "--------"
PRINT "CORE RAM"
PRINT "--------"
PRINT " Start =", ~core_start
PRINT " End =", ~P%
PRINT " Size =", ~(P% - core_start)
PRINT " Free =", ~(hazel_load_addr - P%)
PRINT " DLL Jump Table Size =", ~(beeb_dll_end - beeb_dll_start)
PRINT " Core Data Size =", ~(core_data_end - core_data_start)
PRINT "--------"
SAVE "Core", core_start, P%, 0
PRINT "--------"
CLEAR loader2_addr, &8000
ORG loader2_addr
GUARD &6000
.boot_start
; *****************************************************************************
; BEEB APP ENTRY
; *****************************************************************************
.scr_entry
{
; BEEB EARLY INIT
LDA #200
LDX #2
JSR osbyte
lda #15
ldx #0
ldy #0
jsr osbyte
; BEEB SET SCREEN MODE 4
; LDA #22
; JSR oswrch
; LDA #BEEB_SCREEN_MODE
; JSR oswrch
; LDA #10: STA &FE00 ; turn off cursor
; LDA #32: STA &FE01
; ; BEEB SET SCREEN TO 8K
; LDA #6:STA &FE00 ; R6 = vertical displayed
; LDA #25:STA &FE01 ; 25 rows = 200 scanlines
; LDA #12:STA &FE00
; LDA #HI(screen1_address/8):STA &FE01
; LDA #13:STA &FE00
; LDA #LO(screen1_address/8):STA &FE01
\ Ensure HAZEL RAM is writeable - assume this says writable throughout?
LDA &FE34:ORA #&8:STA &FE34
; Load ROMs first, as they use the space later required by $.Core.
SWR_SELECT_SLOT BEEB_CART_SLOT
LDX #LO(cart_filename)
LDY #HI(cart_filename)
LDA #HI(cart_start)
JSR disksys_load_file
SWR_SELECT_SLOT BEEB_KERNEL_SLOT
LDX #LO(kernel_filename)
LDY #HI(kernel_filename)
LDA #HI(kernel_start)
JSR disksys_load_file
SWR_SELECT_SLOT BEEB_GRAPHICS_SLOT
ldx #lo(beeb_graphics_filename)
ldy #hi(beeb_graphics_filename)
lda #hi(beeb_graphics_start)
jsr disksys_load_file
SWR_SELECT_SLOT BEEB_MUSIC_SLOT
ldx #lo(beeb_music_filename)
ldy #hi(beeb_music_filename)
lda #hi(beeb_music_start)
jsr disksys_load_file
; Load $.Core.
LDX #LO(core_filename)
LDY #HI(core_filename)
LDA #HI(core_start)
JSR disksys_load_file
\\ HAZEL must be last as stomping on FS workspace
LDX #LO(hazel_filename)
LDY #HI(hazel_filename)
LDA #HI(hazel_load_addr)
JSR disksys_load_direct
\\ Load boot data to screen
LDX #LO(data_filename)
LDY #HI(data_filename)
LDA #HI(boot_data_start)
JSR disksys_load_file
\\ Clear Hazel RAM for BSS
; this will copy the MOS data into ANDY, and fill HAZEL with
; whatever junk was in ANDY before. But that's fine - it's all
; about to get zapped.
jsr hazel_scr
{
ldx #0
lda #0
.clear_loop
sta hazel_start, X
inx
bne clear_loop
inc clear_loop+2
ldy clear_loop+2
cpy #HI(hazel_end)
bcc clear_loop
}
\\ Now copy data from screen1 up to Hazel
LDA #HI(hazel_load_addr)
LDX #HI(hazel_data_start)
LDY #HI(hazel_data_end - hazel_data_start + &FF)
JSR disksys_copy_block
\\ FS is now unusable as HAZEL has been trashed
jsr graphics_show_keys_screen
; Save off original top of HUD.
{
SWR_SELECT_SLOT BEEB_KERNEL_SLOT
ldx #0
.save_top_of_hud_loop
lda L_6028,x
sta original_top_of_hud_data,x
inx
cpx #$f0
bne save_top_of_hud_loop
}
; C64 init at L_400F
; Set up VIC etc.
; Set up COLOR RAM
ldx #$7F ;40A5 A2 7F
.L_40A7 lda L_5780,X ;40A7 BD 80 57
sta L_C280,X ;40AA 9D 80 C2
dex ;40AD CA
bpl L_40A7 ;40AE 10 F7 ; copy $80 bytes from $5780 to $C280
\\ <SNIP C64 SETUP CODE TO COPY DATA THAT IS NOW IN PLACE>
ldx #$00 ;414B A2 00
.L_414D
; top row of engine
lda L_72E0,X ;414D BD E0 72
sta L_C000,X ;4150 9D 00 C0
; next row of engine
lda L_7420,X ;4153 BD 20 74
sta L_C100,X ;4156 9D 00 C1
dex ;4159 CA
bne L_414D ;415A D0 F1 ; copy 2x pages from $72E0 to $C000
ldx #$17 ;415C A2 17
.L_415E
; gap between left exhausts and left side of engine
lda L_75A0,X ;415E BD A0 75
sta L_C200,X ;4161 9D 00 C2
; gap between right exhausts and right side of engine
lda L_7608,X ;4164 BD 08 76
sta L_C218,X ;4167 9D 18 C2