-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParking.asm
3548 lines (2983 loc) · 70.3 KB
/
Parking.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
!to "parking.prg",cbm
;SID Notes
SID_C_0_H = $01
SID_C_0_L = $0C
SID_CS_0_H = $01
SID_CS_0_L = $1C
SID_D_0_H = $01
SID_D_0_L = $2D
SID_DS_0_H = $01
SID_DS_0_L = $3E
SID_E_0_H = $01
SID_E_0_L = $51
SID_F_0_H = $01
SID_F_0_L = $66
SID_FS_0_H = $01
SID_FS_0_L = $7B
SID_G_0_H = $01
SID_G_0_L = $91
SID_GS_0_H = $01
SID_GS_0_L = $A9
SID_A_0_H = $01
SID_A_0_L = $C3
SID_AS_0_H = $01
SID_AS_0_L = $DD
SID_B_0_H = $01
SID_B_0_L = $FA
SID_C_1_H = $02
SID_C_1_L = $18
SID_CS_1_H = $02
SID_CS_1_L = $38
SID_D_1_H = $02
SID_D_1_L = $5A
SID_DS_1_H = $02
SID_DS_1_L = $7D
SID_E_1_H = $02
SID_E_1_L = $A3
SID_F_1_H = $02
SID_F_1_L = $CC
SID_FS_1_H = $02
SID_FS_1_L = $F6
SID_G_1_H = $03
SID_G_1_L = $23
SID_GS_1_H = $03
SID_GS_1_L = $53
SID_A_1_H = $03
SID_A_1_L = $86
SID_AS_1_H = $03
SID_AS_1_L = $BB
SID_B_1_H = $03
SID_B_1_L = $F4
SID_C_2_H = $04
SID_C_2_L = $30
SID_CS_2_H = $04
SID_CS_2_L = $70
SID_D_2_H = $04
SID_D_2_L = $B4
SID_DS_2_H = $04
SID_DS_2_L = $FB
SID_E_2_H = $05
SID_E_2_L = $47
SID_F_2_H = $05
SID_F_2_L = $98
SID_FS_2_H = $05
SID_FS_2_L = $ED
SID_G_2_H = $06
SID_G_2_L = $47
SID_GS_2_H = $06
SID_GS_2_L = $A7
SID_A_2_H = $07
SID_A_2_L = $0C
SID_AS_2_H = $07
SID_AS_2_L = $77
SID_B_2_H = $07
SID_B_2_L = $E9
SID_C_3_H = $08
SID_C_3_L = $61
SID_CS_3_H = $08
SID_CS_3_L = $E1
SID_D_3_H = $09
SID_D_3_L = $68
SID_DS_3_H = $09
SID_DS_3_L = $F7
SID_E_3_H = $0A
SID_E_3_L = $8F
SID_F_3_H = $0B
SID_F_3_L = $30
SID_FS_3_H = $0B
SID_FS_3_L = $DA
SID_G_3_H = $0C
SID_G_3_L = $8F
SID_GS_3_H = $0D
SID_GS_3_L = $4E
SID_A_3_H = $0E
SID_A_3_L = $18
SID_AS_3_H = $0E
SID_AS_3_L = $EF
SID_B_3_H = $0F
SID_B_3_L = $D2
SID_C_4_H = $10
SID_C_4_L = $C3
SID_CS_4_H = $11
SID_CS_4_L = $C3
SID_D_4_H = $12
SID_D_4_L = $D1
SID_DS_4_H = $13
SID_DS_4_L = $EF
SID_E_4_H = $15
SID_E_4_L = $1F
SID_F_4_H = $16
SID_F_4_L = $60
SID_FS_4_H = $17
SID_FS_4_L = $BF
SID_G_4_H = $19
SID_G_4_L = $1E
SID_GS_4_H = $1A
SID_GS_4_L = $9C
SID_A_4_H = $1C
SID_A_4_L = $31
SID_AS_4_H = $1D
SID_AS_4_L = $DF
SID_B_4_H = $1F
SID_B_4_L = $A5
SID_C_5_H = $21
SID_C_5_L = $87
SID_CS_5_H = $23
SID_CS_5_L = $86
SID_D_5_H = $25
SID_D_5_L = $A2
SID_DS_5_H = $27
SID_DS_5_L = $DF
SID_E_5_H = $2A
SID_E_5_L = $3E
SID_F_5_H = $2C
SID_F_5_L = $C1
SID_FS_5_H = $2F
SID_FS_5_L = $6B
SID_G_5_H = $32
SID_G_5_L = $3C
SID_GS_5_H = $35
SID_GS_5_L = $39
SID_A_5_H = $38
SID_A_5_L = $63
SID_AS_5_H = $3B
SID_AS_5_L = $BE
SID_B_5_H = $3F
SID_B_5_L = $4B
SID_C_6_H = $43
SID_C_6_L = $0F
SID_CS_6_H = $47
SID_CS_6_L = $0C
SID_D_6_H = $4B
SID_D_6_L = $45
SID_DS_6_H = $4F
SID_DS_6_L = $BF
SID_E_6_H = $54
SID_E_6_L = $7D
SID_F_6_H = $59
SID_F_6_L = $83
SID_FS_6_H = $5E
SID_FS_6_L = $D6
SID_G_6_H = $64
SID_G_6_L = $79
SID_GS_6_H = $6A
SID_GS_6_L = $73
SID_A_6_H = $70
SID_A_6_L = $C7
SID_AS_6_H = $77
SID_AS_6_L = $7C
SID_B_6_H = $7E
SID_B_6_L = $97
SID_C_7_H = $86
SID_C_7_L = $1E
SID_CS_7_H = $8E
SID_CS_7_L = $18
SID_D_7_H = $96
SID_D_7_L = $8B
SID_DS_7_H = $9F
SID_DS_7_L = $7E
SID_E_7_H = $A8
SID_E_7_L = $FA
SID_F_7_H = $B3
SID_F_7_L = $06
SID_FS_7_H = $BD
SID_FS_7_L = $AC
SID_G_7_H = $C8
SID_G_7_L = $F3
SID_GS_7_H = $D4
SID_GS_7_L = $E6
SID_A_7_H = $E1
SID_A_7_L = $8F
SID_AS_7_H = $EE
SID_AS_7_L = $F8
SID_B_7_H = $FD
SID_B_7_L = $2E
COLOR_BLACK = $00 ;schwarz
COLOR_WHITE = $01 ;weiß
COLOR_RED = $02 ;rot
COLOR_CYAN = $03 ;türkis
COLOR_PURPLE = $04 ;lila
COLOR_GREEN = $05 ;grün
COLOR_BLUE = $06 ;blau
COLOR_YELLOW = $07 ;gelb
COLOR_ORANGE = $08 ;orange
COLOR_BROWN = $09 ;braun
COLOR_PINK = $0a ;rosa
COLOR_DARKGREY = $0b ;dunkelgrau
COLOR_GREY = $0c ;grau
COLOR_LIGHTGREEN = $0d ;hellgrün
COLOR_LIGHTBLUE = $0e ;hellblau
COLOR_LIGHTGREY = $0f ;hellgrau
VICBASE = $d000
VICCHARSET = $d018
VICBORDERCOLOR = $d020
VICBACKGROUNDCOLOR = $d021
SCREENRAMADR = $0400
COLORRAMADR = $d800
CIA1_A = $dc00
CIA1_B = $dc01
AUTOSTACK = $29C0
ZP_SCREENRAMADR = $02
ZP_COLORRAMADR = $04
ZP_SCREENTODRAW = $06
ZP_COLORTODRAW = $08
ZP_HILFSVAR01 = $0A
ZP_HILFSVAR02 = $0B
ZP_HILFSVAR03 = $0C
ZP_HILFSVAR04 = $0D
ZP_DIVISOR = $0E
ZP_REMOVEDCARS = $0F
ZP_COLORRAMADR02 = $10
ZP_SID_CHANNEL_1_Timer = $20
ZP_SID_CHANNEL_1_Pat_Pos = $21
ZP_SID_CHANNEL_1_Wave_Pos = $22
ZP_SID_CHANNEL_1_Channel_Pos = $23
ZP_SID_CHANNEL_1_Pat_Addr_Hi = $24
ZP_SID_CHANNEL_1_Pat_Addr_Lo = $25
ZP_SID_CHANNEL_2_Timer = $27
ZP_SID_CHANNEL_2_Pat_Pos = $28
ZP_SID_CHANNEL_2_Wave_Pos = $29
ZP_SID_CHANNEL_2_Channel_Pos = $2A
ZP_SID_CHANNEL_2_Pat_Addr_Hi = $2B
ZP_SID_CHANNEL_2_Pat_Addr_Lo = $2C
ZP_SID_CHANNEL_3_Timer = $2E
ZP_SID_CHANNEL_3_Pat_Pos = $2F
ZP_SID_CHANNEL_3_Wave_Pos = $30
ZP_SID_CHANNEL_3_Channel_Pos = $31
ZP_SID_CHANNEL_3_Pat_Addr_Hi = $32
ZP_SID_CHANNEL_3_Pat_Addr_Lo = $33
ZP_SID_CHANNEL_3_Pulse_Lo = $34
ZP_SID_CHANNEL_3_Pulse_Hi = $35
ZP_PARKING_ROWS_L = $50
ZP_PARKING_ROWS_H_S = $60
ZP_WAVETABLE = $FC
INPUT_NONE = $00
INPUT_JOY1 = $01
INPUT_JOY2 = $02
JOY_UP = %00000001
JOY_DOWN = %00000010
JOY_LEFT = %00000100
JOY_RIGHT = %00001000
JOY_FIRE = %00010000
;*** Startadresse
*=$0801
;*** BASIC-Zeile
!word main-2
!word 2018
!text $9E, " 2062", $00,$00,$00
main
lda $01 ;clear basic rom
and #%11111110
sta $01
lda #$18
sta VICCHARSET
lda $d016 ;Multicolor Textmode aktivieren
ora #%00010000
sta $d016
; set first and second multicolor
lda #COLOR_LIGHTGREY
sta $d022
lda #COLOR_DARKGREY
sta $d023
;get PAL / NTSC
.loop_line_count
lda $d012
.loop_line_count_2
cmp $d012
beq .loop_line_count_2
bmi .loop_line_count
cmp #$37
beq .found_pal
;.found NTSC
lda #$1E
sta gameTimeSlow
lda #$0A
sta gameTimeFast
lda #07
sta calc_note_length.loop_note_length+1
lda #$02
jmp .load_game
.found_pal
lda #$00
.load_game
jsr load_sid_notes
jsr load_parking_rows
jsr clear_sid
jsr init_song_0
jsr activateIRQs
jsr showScreen_Title ;Startbildschirm anzeigen
gameMainLoop
jsr checkInput
jmp gameMainLoop
rts ;Zurück zum Basic
!zone load_sid_notes
load_sid_notes
pha
ldx #$05
lda #<notetable
sta ZP_SCREENTODRAW
lda #>notetable
sta ZP_SCREENTODRAW+1
.loop_notes
pla
tay
pha
lda (ZP_SCREENTODRAW),y
sta ZP_HILFSVAR01
iny
lda (ZP_SCREENTODRAW),y
ldy #$01
sta (ZP_SCREENTODRAW),y
dey
lda ZP_HILFSVAR01
sta (ZP_SCREENTODRAW),y
ldy #$00
.loop_octaves
lda (ZP_SCREENTODRAW),y
iny
asl
sta ZP_HILFSVAR01
lda (ZP_SCREENTODRAW),y
rol
iny
iny
sta (ZP_SCREENTODRAW),y
dey
lda ZP_HILFSVAR01
sta (ZP_SCREENTODRAW),y
cpy #$0A
bne .loop_octaves
lda #$0C
jsr addToScreenToDraw
dex
bne .loop_notes
pla
rts
!zone load_parking_rows
load_parking_rows
ldx #$00
ldy #$09
lda #$04
sta ZP_PARKING_ROWS_H_S
lda #$52
sta ZP_PARKING_ROWS_L
.loop
tya
pha
lda ZP_PARKING_ROWS_H_S,x
tay
lda ZP_PARKING_ROWS_L,x
inx
clc
adc #$50
sta ZP_PARKING_ROWS_L,x
tya
adc #$00
sta ZP_PARKING_ROWS_H_S,x
pla
tay
dey
bpl .loop
rts
!zone fillBoardWithRandomCars
fillBoardWithRandomCars
ldy #$08
.loop_through_cars
tya
pha
lda #$0B
sta ZP_DIVISOR
jsr rndTimer
and #%01111111
jsr getModulo
asl
asl
asl
asl
sta carList+$1B
lda #$09
sta ZP_DIVISOR
jsr rndTimer
and #%01111111
jsr getModulo
ora carList+$1B
sta carList+$1B
lda #$04
sta ZP_DIVISOR
jsr rndTimer
and #%01111111
jsr getModulo
sta carList+$1C
lda #$06
sta ZP_DIVISOR
jsr rndTimer
and #%01111111
jsr getModulo
clc
adc #$0A
sta carList+$1D
lda #$01
jsr drawCar
pla
tay
dey
bne .loop_through_cars
rts
;*******************************************************************************
;*** clears sid registers to start sid chip
;*******************************************************************************
!zone clear_sid
clear_sid
lda #$00 ;load 0 into A
ldy #$18 ;load 24 into Y
.loop_1
sta $d400,Y ;store 0 in SID RAM ENTRY + Y bits
dey ;decrease Y
bpl .loop_1 ;as long as Y is not 0 jump to loop_1
rts ;return from subroutine (this time we also jump back to main)
;********************************************************************************************************************************
;*** Select input device and draw the parking ground
;********************************************************************************************************************************
!zone showScreen_Title
showScreen_Title
lda #INPUT_NONE
sta inputDevice
jsr drawScreen
.wait
jsr selectInputDevice
lda inputDevice
beq .wait
rts
;********************************************************************************************************************************
;*** Set random cars into the next box
;********************************************************************************************************************************
!zone setRandomCars
setRandomCars
lda maxCars
sta ZP_DIVISOR
jsr rndTimer
and #%01111111
jsr getModulo
clc
adc #$01
tay
lda #$DB
sta ZP_COLORRAMADR+1
lda #$B4
sta ZP_COLORRAMADR
sta ZP_SCREENRAMADR
lda #$07
sta ZP_SCREENRAMADR+1
lda #$06
sta ZP_DIVISOR
.loop
jsr rndTimer
and #%01111111
jsr getModulo
clc
adc #$0A
sta (ZP_COLORRAMADR),y
lda #$41
sta (ZP_SCREENRAMADR),y
dey
bne .loop
rts
;********************************************************************************************************************************
;*** activate the raster IRQ
;********************************************************************************************************************************
activateIRQs
sei
lda #<rasterIRQ
sta $0314
lda #>rasterIRQ
sta $0315
lda #$00
sta $d012
lda $d011
and #%01111111
sta $d011
lda $d01a
ora #%00000001
sta $d01a
cli
rts
;********************************************************************************************************************************
;*** Draws the parking ground and the player statistic boxes
;********************************************************************************************************************************
!zone drawScreen
drawScreen
lda #COLOR_WHITE
jsr fillScreenWithColor
jsr drawTitleScreen
rts
!zone drawHowTo
drawHowTo
lda #$01
sta title_state
jsr fillScreenWithColor
; write label how to play
lda #<how_to_label
sta ZP_SCREENTODRAW
lda #>how_to_label
sta ZP_SCREENTODRAW+1
lda #$40
sta ZP_SCREENRAMADR
sta ZP_COLORRAMADR
lda #$05
sta ZP_SCREENRAMADR+1
lda #$D8
sta ZP_COLORRAMADR+1
ldx #COLOR_WHITE
ldy #$27
jsr write_text
; write label clear cars
lda #$28
jsr addToScreenToDraw
lda #$50
jsr addToScreenAndColorRam
jsr write_text
; write label squares
lda #$28
jsr addToScreenToDraw
lda #$50
jsr addToScreenAndColorRam
jsr write_text
; write label raise combo
lda #$28
jsr addToScreenToDraw
lda #$50
jsr addToScreenAndColorRam
jsr write_text
; write label raise combo
lda #$28
jsr addToScreenToDraw
lda #$50
jsr addToScreenAndColorRam
jsr write_text
; write label raise combo
lda #$28
jsr addToScreenToDraw
lda #$50
jsr addToScreenAndColorRam
jsr write_text
rts
!zone drawTitleScreen
drawTitleScreen
ldy #$A0
.loop_background
lda #$6C
sta $04EF,y
sta $058F,y
sta $062F,y
cpy #$29
bpl .next_loop_background
lda #$6F
sta $06cf,y
lda #$6E
sta $04c7,y
.next_loop_background
dey
bne .loop_background
;.drawTexts
; write label game by
lda #<game_by_label
sta ZP_SCREENTODRAW
lda #>game_by_label
sta ZP_SCREENTODRAW+1
lda #$C6
sta ZP_SCREENRAMADR
sta ZP_COLORRAMADR
lda #$07
sta ZP_SCREENRAMADR+1
lda #$DB
sta ZP_COLORRAMADR+1
ldy #$0A
ldx #COLOR_WHITE
jsr write_text
; write label fire
lda #$0B
jsr addToScreenToDraw
lda #$B9
sta ZP_SCREENRAMADR
sta ZP_COLORRAMADR
lda #$07
sta ZP_SCREENRAMADR+1
lda #$DB
sta ZP_COLORRAMADR+1
ldy #$03
jsr write_text
; write label start
lda #$04
jsr addToScreenToDraw
lda #$E2
sta ZP_SCREENRAMADR
sta ZP_COLORRAMADR
lda #$07
sta ZP_SCREENRAMADR+1
lda #$DB
sta ZP_COLORRAMADR+1
ldy #$04
jsr write_text
; write highscore
lda #<highscore-$10
sta ZP_SCREENTODRAW
lda #>highscore
sta ZP_SCREENTODRAW+1
lda #$FC
sta ZP_SCREENRAMADR
sta ZP_COLORRAMADR
lda #$04
sta ZP_SCREENRAMADR+1
lda #$D8
sta ZP_COLORRAMADR+1
ldx #$05
ldy current_score
.loop_highscore
lda #$10
jsr addToScreenToDraw
lda #$50
jsr addToScreenAndColorRam
dey
cpy #$FF
bne .continue_highscore
sec
lda ZP_SCREENRAMADR
pha
sbc #$01
sta ZP_SCREENRAMADR
lda ZP_SCREENRAMADR+1
pha
sbc #$00
sta ZP_SCREENRAMADR+1
lda #$6D
ldy #$00
sta (ZP_SCREENRAMADR),y
pla
sta ZP_SCREENRAMADR+1
pla
sta ZP_SCREENRAMADR
lda #$FF
tay
.continue_highscore
txa
pha
tya
pha
ldx #COLOR_WHITE
ldy #$0F
jsr write_text
pla
tay
pla
tax
dex
bne .loop_highscore
;.adding cars to title
ldx #$64
lda #$2C
sta ZP_SCREENRAMADR
sta ZP_COLORRAMADR
lda #$04
sta ZP_SCREENRAMADR+1
lda #$d8
sta ZP_COLORRAMADR+1
lda #$0A
sta ZP_COLORTODRAW
jsr drawParkingLot
ldx #$68
lda #$4B
sta ZP_SCREENRAMADR
sta ZP_COLORRAMADR
jsr drawParkingLot
;.add title "Parking Ticket"
; X Position
clc
lda #$6B
sta $D000
adc #$18
sta $D002
adc #$18
sta $D004
adc #$18
sta $D006
adc #$18
sta $D008
adc #$18
sta $D00A
adc #$18
sta $D00C
;Y Position
lda #$32
sta $D001
sta $D003
sta $D005
sta $D007
sta $D009
sta $D00B
sta $D00D
; Off some sprite options
lda #$00
sta $D010 ; X+255
sta $D017 ; Double Height
sta $D01B ; Behind background
sta $D01C ; Multicolor
sta $D01D ; Double Width
lda #$7F
sta $D015 ; Visibility
lda #COLOR_LIGHTBLUE
sta $D027
sta $D028
sta $D029
sta $D02A
sta $D02B
sta $D02C
sta $D02D
lda #$A0
sta $07f8
adc #$01
sta $07f9
adc #$01
sta $07fa
adc #$01
sta $07fb
adc #$01
sta $07fc
adc #$01
sta $07fd
adc #$01
sta $07fe
rts
;*******************************************************************************
;*** Fills borders and background with color in Akku and clears screen
;*******************************************************************************
!zone fillScreenWithColor ;and again a zone for jump labels (in this funtion we also have our first jump label) :0D
fillScreenWithColor ;name of the subroutine
;*** Make borders and background black
tay
lda #$00
sta VICBORDERCOLOR ;write A into the border color address
sta VICBACKGROUNDCOLOR ;write A into the background color address
;*** Clear Screen
ldx #$FA ;load #$00 into X (# means we write a number, $ means it is a hex number, just $ without # means ram address)
.loop_clear ;our first jump label (it marks an address we can jump to later, so we don't need to hard code that address)
lda #$00 ;load #$E0 into A (thats a filled out rect in the Char-Rom)
sta $03FF,x ;write that sign into a part of the screen ram ($0400 in the first loop, $0401 in the second, until $04ff)
sta $04F9,x ;same for $0500
sta $05F3,x ;the ,x means add X to the address written there sta means store A
sta $06ED,x ;up until we reach $07ff
tya ;now we transfer our color back from Y into A
sta $D7FF,x ;same as above with the screen ram, but for the color ram
sta $D8F9,x
sta $D9F3,x
sta $DAED,x
dex ;we decrease X (our initial #$00 becomes #$ff, so it's an underflow?!)
bne .loop_clear ;bne means branch on not equal (so we jump to our label if the last operation doesn't result in #$00)
;that means we have a loop that goes from X=#$00 over all 256 values back to #$00
rts ;return from subroutine
;********************************************************************************************************************************
;*** Draws the parking lines to the ground
;********************************************************************************************************************************
!zone drawParkingLines
drawParkingLines
; set parking ground lines
lda #$22
pha
lda #$20
ldx #$17
.loop_field
eor #%00000001
sta $0452,x
sta $04A2,x
sta $04F2,x
sta $0542,x
sta $0592,x
sta $05E2,x
sta $0632,x
sta $0682,x
sta $06D2,x
sta $0722,x
tay
pla
eor #%00000001
sta $047A,x
sta $04CA,x
sta $051A,x
sta $056A,x
sta $05BA,x
sta $060A,x
sta $065A,x
sta $06AA,x
sta $06FA,x
sta $074A,x
pha
tya
dex
bpl .loop_field
pla
; add right border
lda #$07
sta ZP_SCREENRAMADR+1
lda #$B2
sta ZP_SCREENRAMADR
lda #$22
ldx #$16
ldy #$00
.loop_right_border
sta (ZP_SCREENRAMADR),y
pha
lda ZP_SCREENRAMADR
sec
sbc #$28
sta ZP_SCREENRAMADR
lda ZP_SCREENRAMADR+1
sbc #$00
sta ZP_SCREENRAMADR+1
pla
eor #%00001110
dex
bne .loop_right_border
; add bottom border
lda #$21
ldx #$18
.loop_bottom_border
sta $0771,x
eor #%00001100
dex
bne .loop_bottom_border
lda #$22
sta $07B0
lda #$20
sta $0788
rts
;********************************************************************************************************************************