-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgame.asm
1070 lines (822 loc) · 23.4 KB
/
game.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
TILE_EMPTY = 0
TILE_EMPTY_SHADOW_1 = 1
TILE_EMPTY_SHADOW_2 = 2
TILE_EMPTY_SHADOW_3 = 3
TILE_EMPTY_SHADOW_4 = 4
TILE_EMPTY_SHADOW_5 = 5
TILE_EMPTY_SHADOW_6 = 6
TILE_EMPTY_SHADOW_7 = 7
TILE_BLUE = 8
TILE_RED = 9
TILE_GREEN = 10
TILE_YELLOW = 11
TILE_VIOLET = 12
TILE_BROWN = 13
TILE_STEEL = 14
TILE_COLOR_BLUE = 15
TILE_COLOR_RED = 16
TILE_COLOR_GREEN = 17
TILE_COLOR_YELLOW = 18
TILE_COLOR_VIOLET = 19
TILE_COLOR_BROWN = 20
TILE_SKULL = 21
TILE_DISK_BLUE = 22
TILE_DISK_RED = 23
TILE_DISK_GREEN = 24
TILE_DISK_YELLOW = 25
TILE_DISK_VIOLET = 26
TILE_DISK_BROWN = 27
TILE_DIR_TOGGLE = 28
TILE_KEY_BLUE = 29
TILE_KEY_RED = 30
TILE_KEY_GREEN = 31
TILE_KEY_YELLOW = 32
TILE_KEY_VIOLET = 33
TILE_KEY_BROWN = 34
TILE_LOCK_BLUE = 35
TILE_LOCK_RED = 36
TILE_LOCK_GREEN = 37
TILE_LOCK_YELLOW = 38
TILE_LOCK_VIOLET = 39
TILE_LOCK_BROWN = 40
TILE_GREY = 41
COLOR_BLUE = 0
COLOR_RED = 1
COLOR_GREEN = 2
COLOR_YELLOW = 3
COLOR_VIOLET = 4
COLOR_BROWN = 5
DIR_N = 0
DIR_S = 1
DIR_W = 2
DIR_E = 3
SCORE_OFFSET_X = 1
TIMER_OFFSET_X = 18
LIVES_OFFSET_X = 36
!zone StartGame
StartGame
;lda #$01
;ldx #$10 ;Pages to clear
;jsr ColorClear32bitAddr
;set sprite pal to bank 1
lda #%01010101
sta VIC4.PALSEL
lda #0
sta VIC.BACKGROUND_COLOR
;enable palette 00 from ROM
lda #$04
;tsb VIC3.ROMBANK
lda #$00
ldx #$10;Pages to clear
jsr ScreenClear32bitAddr
;prepare score bar
;empty out score bar
lda #28
ldx #0
-
sta SCREEN_CHAR + 24 * 80,x
inx
inx
cpx #80
bne -
;SC
lda #60
sta SCREEN_CHAR + 2 * ( 24 * 40 + SCORE_OFFSET_X )
;LI
lda #63
sta SCREEN_CHAR + 2 * ( 24 * 40 + LIVES_OFFSET_X )
lda #64 + 2 * 3
sta SCREEN_CHAR + 2 * ( 24 * 40 + LIVES_OFFSET_X + 1 )
inc
sta SCREEN_CHAR + 2 * ( 24 * 40 + LIVES_OFFSET_X + 2 )
;score
lda #64
sta SCREEN_CHAR + 2 * ( 24 * 40 + SCORE_OFFSET_X + 1 )
sta SCREEN_CHAR + 2 * ( 24 * 40 + SCORE_OFFSET_X + 3 )
sta SCREEN_CHAR + 2 * ( 24 * 40 + SCORE_OFFSET_X + 5 )
sta SCREEN_CHAR + 2 * ( 24 * 40 + SCORE_OFFSET_X + 7 )
sta SCREEN_CHAR + 2 * ( 24 * 40 + SCORE_OFFSET_X + 9 )
sta SCREEN_CHAR + 2 * ( 24 * 40 + SCORE_OFFSET_X + 11 )
lda #65
sta SCREEN_CHAR + 2 * ( 24 * 40 + SCORE_OFFSET_X + 2 )
sta SCREEN_CHAR + 2 * ( 24 * 40 + SCORE_OFFSET_X + 4 )
sta SCREEN_CHAR + 2 * ( 24 * 40 + SCORE_OFFSET_X + 6 )
sta SCREEN_CHAR + 2 * ( 24 * 40 + SCORE_OFFSET_X + 8 )
sta SCREEN_CHAR + 2 * ( 24 * 40 + SCORE_OFFSET_X + 10 )
sta SCREEN_CHAR + 2 * ( 24 * 40 + SCORE_OFFSET_X + 12 )
;clock
lda #31
sta SCREEN_CHAR + 2 * ( 24 * 40 + 17 )
lda #0
;lda #15
sta LEVEL_NR
lda #3
sta PLAYER_LIVES
RestartLevel
NextLevel
lda LEVEL_NR
cmp #SCREENS_NUM_MAPS
bne +
jmp HandleWellDone
+
ldx #0
txa
-
sta SPRITE_ACTIVE,x
inx
cpx #8
bne -
jsr BuildScreen
;clock to 500
lda #64 + 5 * 2
sta SCREEN_CHAR + 2 * ( 24 * 40 + 18 )
lda #64 + 0 * 2
sta SCREEN_CHAR + 2 * ( 24 * 40 + 20 )
sta SCREEN_CHAR + 2 * ( 24 * 40 + 22 )
lda #65 + 5 * 2
sta SCREEN_CHAR + 2 * ( 24 * 40 + 19 )
lda #65 + 0 * 2
sta SCREEN_CHAR + 2 * ( 24 * 40 + 21 )
sta SCREEN_CHAR + 2 * ( 24 * 40 + 23 )
lda #0
sta VIC.SPRITE_ENABLE
sta VIC4.SPR16EN
sta VIC4.SPRX64EN
sta PLAYER_KILLED
sta PLAYER_AFFECTED
sta TIMER_DELAY
sta LEVEL_START_DELAY
lda PLAYER_START_X
sta PARAM1
lda PLAYER_START_Y
sta PARAM2
lda #TYPE_PLAYER
sta PARAM3
jsr SpawnObject
;set player start color
lda PLAYER_COLOR
asl
asl
clc
adc #SPRITE_BASE
sta SPRITE_POINTER_BASE
;start moving down
lda #2
sta SPRITE_DIRECTION_Y
lda #0
sta SPRITE_DIRECTION
lda #0
sta PLAYER_DIR
lda #0
sta PLAYER_KEYS
sta PLAYER_KEYS + 1
sta PLAYER_KEYS + 2
sta PLAYER_KEYS + 3
sta PLAYER_KEYS + 4
sta PLAYER_KEYS + 5
;lda #0
;sta SPRITE_DIRECTION_Y
;lda #2
;sta SPRITE_DIRECTION
;lda #1
;sta PLAYER_DIR
;wait a bit
-
jsr WaitFrame
inc LEVEL_START_DELAY
lda LEVEL_START_DELAY
cmp #64
bne -
!zone GameLoop
GameLoop
jsr WaitFrame
jsr SFXUpdate
lda CIA1.DATA_PORT_B
sta JOY_VALUE
lda SPRITE_ACTIVE
bne .PlayerIsAliveOrExploding
lda JOY_VALUE
and #$10
bne .NotFirePressed
;wait for fire to be released
.FirePressed
jsr WaitFrame
lda $dc01
and #$10
beq .FirePressed
lda PLAYER_LIVES
lbne RestartLevel
jmp HandleTitle
.PlayerIsAliveOrExploding
;bonus
lda SCREEN_CHAR + 2 * ( 24 * 40 + TIMER_OFFSET_X )
cmp #64
bne .TimerTick
lda SCREEN_CHAR + 2 * ( 24 * 40 + TIMER_OFFSET_X + 2 )
cmp #64
bne .TimerTick
lda SCREEN_CHAR + 2 * ( 24 * 40 + TIMER_OFFSET_X + 4 )
cmp #64
bne .TimerTick
jmp .NoTimer
.TimerTick
inc TIMER_DELAY
lda TIMER_DELAY
and #$07
bne +
ldx #TIMER_OFFSET_X + 4
jsr DecTime
+
.NoTimer
.NotFirePressed
lda Mega65.PRESSED_KEY
beq +
;clear key
sta Mega65.PRESSED_KEY
cmp #$f1
bne +
lda SPRITE_ACTIVE
cmp #TYPE_PLAYER
bne +
jsr HitTile.KillPlayer
jmp GameLoop
+
cmp #49
bne +
inc LEVEL_NR
jmp NextLevel
+
lda NUM_BLOCKS
bne .GameIsOn
jmp LevelDoneAnimation
.GameIsOn
ldx #0
jsr ObjectControl
jmp GameLoop
!zone LevelDoneAnimation
.DONE_STATE
!byte 0
LevelDoneAnimation
lda #0
sta .DONE_STATE
.NextFrame
jsr WaitFrame
ldx #1
jsr ObjectControl
inc .DONE_STATE
lda .DONE_STATE
and #$03
bne .NextFrame
lda .DONE_STATE
lsr
lsr
tay
cpy #7
beq .AnimDone
lda FLASH_TABLE,y
sta PARAM1
;replace char colors
ldx #0
-
ldy $4000,x
beq .NextByte
sta $4000,x
.NextByte
ldy $4800,x
beq .NextByte2
sta $4800,x
.NextByte2
inx
cpx #128
bne -
jmp .NextFrame
.AnimDone
;and wait
lda #0
sta .DONE_STATE
-
jsr WaitFrame
inc .DONE_STATE
lda .DONE_STATE
cmp #64
bne -
.BonusTick
jsr WaitFrame
;bonus
lda SCREEN_CHAR + 2 * ( 24 * 40 + TIMER_OFFSET_X )
cmp #64
bne .TimerTick
lda SCREEN_CHAR + 2 * ( 24 * 40 + TIMER_OFFSET_X + 2 )
cmp #64
bne .TimerTick
lda SCREEN_CHAR + 2 * ( 24 * 40 + TIMER_OFFSET_X + 4 )
cmp #64
bne .TimerTick
inc LEVEL_NR
jmp NextLevel
.TimerTick
ldx #TIMER_OFFSET_X + 4
jsr DecTime
inc TIMER_DELAY
lda TIMER_DELAY
and #$07
bne +
ldy #SFX_BONUS_BLIP
jsr PlaySoundEffectInChannel0
+
;+1
lda #1
ldx #5 * 4
jsr IncScore
jmp .BonusTick
FLASH_TABLE
!byte 10,12,15,12,10,11,11,11
!zone HitTile
;PARAM1,PARAM2 = x,y of tile
; can be off screen!!
HitTile
;get tile index
ldy PARAM2
sty PARAM4
lda PARAM1
sta PARAM3
clc
adc TILE_OFFSET,y
tay
sty PARAM7
lda LEVEL_DATA,y
;direction changer?
cmp #TILE_DIR_TOGGLE
bne +
lda PLAYER_DIR
eor #$01
sta PLAYER_DIR
lda #1
sta PLAYER_AFFECTED
ldy #SFX_COLOR_CHANGE
jsr PlaySoundEffectInChannel0
;is target dir set to move?
ldy MOVE_DIR
lda PLAYER_DIR
beq .CheckH
;turned to horizontal movement
lda DIR_TOGGLE_TABLE_H_H,y
sta SPRITE_DIRECTION
lda DIR_TOGGLE_TABLE_H_V,y
sta SPRITE_DIRECTION_Y
rts
.CheckH
lda DIR_TOGGLE_TABLE_V_H,y
sta SPRITE_DIRECTION
lda DIR_TOGGLE_TABLE_V_V,y
sta SPRITE_DIRECTION_Y
rts
+
;skull?
cmp #TILE_SKULL
bne +
.KillPlayer
ldy #SFX_BALL_KILLED
jsr PlaySoundEffectInChannel0
ldx #0
lda #TYPE_EXPLOSION
sta PARAM3
jsr CreateObjectInSlot
ldy PLAYER_COLOR
lda SMOKE_COLOR_TABLE,y
sta VIC.SPRITE_COLOR,x
lda #8
sta PARAM1
-
jsr ObjectMoveLeft
jsr ObjectMoveUp
dec PARAM1
bne -
lda #1
sta PLAYER_KILLED
sta PLAYER_AFFECTED
dec SCREEN_CHAR + 2 * ( 24 * 40 + LIVES_OFFSET_X + 1 )
dec SCREEN_CHAR + 2 * ( 24 * 40 + LIVES_OFFSET_X + 1 )
dec SCREEN_CHAR + 2 * ( 24 * 40 + LIVES_OFFSET_X + 2 )
dec SCREEN_CHAR + 2 * ( 24 * 40 + LIVES_OFFSET_X + 2 )
dec PLAYER_LIVES
rts
;temporary store color of destroyed tile for smoke
.TILE_COLOR
!byte 0
+
;hit color block?
cmp #TILE_GREY
bne +
;grey is always match
lda #6
sta .TILE_COLOR
jmp .ColorMatch
+
cmp #TILE_BLUE
bcs +
jmp .NoColorBlock
+
cmp #TILE_BROWN + 1
bcc +
jmp .NoColorBlock
+
;is the color matching?
sec
sbc #TILE_BLUE
cmp PLAYER_COLOR
lbne .WrongColorBlock
lda PLAYER_COLOR
sta .TILE_COLOR
.ColorMatch
;fix shadow quad 2x2
ldy PARAM7
lda #TILE_EMPTY
jsr SetTileAndUpdateShadows
;spawn smoke
lda PARAM3
asl
sta PARAM1
inc PARAM1
lda PARAM4
asl
sta PARAM2
lda #TYPE_SMOKE
sta PARAM3
jsr SpawnObject
ldy .TILE_COLOR
lda SMOKE_COLOR_TABLE,y
sta VIC.SPRITE_COLOR,x
;add to score +10
lda #1
ldx #4 * 4
jsr IncScore
dec NUM_BLOCKS
ldy #SFX_BRICK_BREAK
jsr PlaySoundEffectInChannel0
;restore player index
ldx CURRENT_INDEX
rts
.NoColorBlock
;hit color changer block?
cmp #TILE_COLOR_BLUE
bcc .NoColorChangerBlock
cmp #TILE_COLOR_BROWN + 1
bcs .NoColorChangerBlock
sec
sbc #TILE_COLOR_BLUE
sta PLAYER_COLOR
asl
asl
clc
adc #SPRITE_BASE
sta SPRITE_POINTER_BASE
ldy #SFX_COLOR_CHANGE
jsr PlaySoundEffectInChannel0
jmp .NoRemove
.NoColorChangerBlock
cmp #TILE_DISK_BLUE
bcc .NoDiskBlock
cmp #TILE_DISK_BROWN + 1
bcs .NoDiskBlock
;hit a disk
sec
sbc #TILE_DISK_BLUE
cmp PLAYER_COLOR
lbne .CantPushDisk
sta .TEMP_COLOR
;is block behind disk free?
lda PARAM7
ldy HIT_DIR
clc
adc HIT_OFFSET_BY_DIR,y
tay
lda LEVEL_DATA,y
jsr IsTileBlocking
lbne .DiskIsBlocked
;push disk!
ldy PARAM7
lda #TILE_EMPTY
jsr SetTileAndUpdateShadows
;spawn smoke
lda PARAM3
asl
sta PARAM1
inc PARAM1
lda PARAM4
asl
sta PARAM2
lda #TYPE_DISK
sta PARAM3
jsr SpawnObject
lda HIT_DIR
sta SPRITE_ANIM_POS,x
lda #16
sta SPRITE_STATE,x
lda PARAM7
ldy HIT_DIR
clc
adc HIT_OFFSET_BY_DIR,y
sta SPRITE_ANIM_DELAY,x
.TEMP_COLOR = * + 1
lda #0
asl
asl
clc
adc #SPRITE_DISK
sta SPRITE_POINTER_BASE,x
ldy #SFX_DISK_PUSH
jsr PlaySoundEffectInChannel0
;restore player index
ldx CURRENT_INDEX
rts
.NoDiskBlock
cmp #TILE_KEY_BLUE
bcc .NoKeyBlock
cmp #TILE_KEY_BROWN + 1
bcs .NoKeyBlock
;hit a key
sec
sbc #TILE_KEY_BLUE
cmp PLAYER_COLOR
bne .NoKeyBlock
sta .TEMP_COLOR
tay
lda #1
sta PLAYER_KEYS,y
;collect block
ldy PARAM7
lda #TILE_EMPTY
jsr SetTileAndUpdateShadows
ldy #SFX_COLOR_CHANGE
jsr PlaySoundEffectInChannel0
;restore player index
ldx CURRENT_INDEX
rts
.NoKeyBlock
cmp #TILE_LOCK_BLUE
lbcc .NoLockBlock
cmp #TILE_LOCK_BROWN + 1
lbcs .NoLockBlock
;hit a lock
sec
sbc #TILE_LOCK_BLUE
cmp PLAYER_COLOR
lbne .NoLockBlock
;has key?
tay
lda PLAYER_KEYS,y
lbeq .NoLockBlock
;yes!
ldy PARAM7
lda #TILE_EMPTY
jsr SetTileAndUpdateShadows
ldy #SFX_BRICK_BREAK
jsr PlaySoundEffectInChannel0
;restore player index
ldx CURRENT_INDEX
rts
.DiskIsBlocked
.CantPushDisk
.NoLockBlock
.WrongColorBlock
ldy #SFX_BALL_BOUNCE
lda #1
jsr PlaySoundEffect
.NoRemove
ldx CURRENT_INDEX
rts
.HitWallSound
ldy #SFX_BALL_BOUNCE
lda #1
jsr PlaySoundEffect
ldx CURRENT_INDEX
lda #0
rts
DIR_TOGGLE_TABLE_H_H
!byte 1 ;n > e
!byte 1 ;s > e
!byte 1 ;w > e
!byte 2 ;e > w
DIR_TOGGLE_TABLE_H_V
!byte 2 ;n > s
!byte 1 ;s > n
!byte 2 ;w > s
!byte 2 ;e > s
DIR_TOGGLE_TABLE_V_H
!byte 0 ;n > e
!byte 0 ;s > e
!byte 1 ;w > e
!byte 2 ;e > w
DIR_TOGGLE_TABLE_V_V
!byte 2 ;n > s
!byte 1 ;s > n
!byte 2 ;w > s
!byte 2 ;e > s
HIT_OFFSET_BY_DIR
!byte 256 - 20
!byte 20
!byte 256 - 1
!byte 1
SMOKE_COLOR_TABLE
!byte 3
!byte 8
!byte 4
!byte 13
!byte 11
!byte 9
!byte 1
!zone SetTileAndUpdateShadows
;a = tile to set
;y = offset in tiles
;PARAM1 = tile x
;PARAM2 = tile y
SetTileAndUpdateShadows
sta LEVEL_DATA,y
jsr FixTileShadow
lda LEVEL_DATA,y
jsr DrawTile
;tile to right
iny
inc PARAM1
lda LEVEL_DATA,y
jsr IsTileBlocking
bne .Skip1
jsr FixTileShadow
lda LEVEL_DATA,y
jsr DrawTile
.Skip1
tya
clc
adc #19
tay
inc PARAM2
dec PARAM1
lda LEVEL_DATA,y
jsr IsTileBlocking
bne .Skip2
jsr FixTileShadow
lda LEVEL_DATA,y
jsr DrawTile
.Skip2
;tile to right
iny
inc PARAM1
lda LEVEL_DATA,y
jsr IsTileBlocking
bne .Skip3
jsr FixTileShadow
lda LEVEL_DATA,y
jsr DrawTile
.Skip3
rts
!zone IncScore
;x = offset in chars
IncScore
asl
clc
adc SCREEN_CHAR + 2 * ( 24 * 40 + SCORE_OFFSET_X + 1 ),x
cmp #64 + 20
bcc .Done
sec
sbc #20
sta SCREEN_CHAR + 2 * ( 24 * 40 + SCORE_OFFSET_X + 1 ),x
inc
sta SCREEN_CHAR + 2 * ( 24 * 40 + SCORE_OFFSET_X + 2 ),x
dex
dex
dex
dex
lda #1
jmp IncScore
.Done
sta SCREEN_CHAR + 2 * ( 24 * 40 + SCORE_OFFSET_X + 1 ),x
;second half of digit
inc
sta SCREEN_CHAR + 2 * ( 24 * 40 + SCORE_OFFSET_X + 2 ),x
rts
!zone DecTime
;x = offset in chars
DecTime
txa
asl
tax
.DecTime
lda SCREEN_CHAR + 2 * 24 * 40,x
cmp #64
beq .Overflow
dec SCREEN_CHAR + 2 * 24 * 40,x
dec SCREEN_CHAR + 2 * 24 * 40,x
dec SCREEN_CHAR + 2 * 24 * 40 + 2,x
dec SCREEN_CHAR + 2 * 24 * 40 + 2,x
.Done
rts
.Overflow
lda #64 + 2 * 9
sta SCREEN_CHAR + 2 * 24 * 40,x
lda #64 + 2 * 9 + 1
sta SCREEN_CHAR + 2 * 24 * 40 + 2,x
cpx #TIMER_OFFSET_X
beq .Done
dex
dex
dex
dex
jmp .DecTime
!zone DrawTile
;PARAM1, PARAM2 = tile x,y
;A = tile index
DrawTile
phy
;ldx #0
; lda PARAM1
; jsr DisplayHex
;
; ldx #3
; lda PARAM2
; jsr DisplayHex
;
; lda #TILE_RED
tax
lda PARAM1
sta PARAM8
;*2 = char index
asl PARAM8
;*2 = 16 bit char index!
asl PARAM8
lda PARAM2
asl
tay
lda SCREEN_LINE_OFFSET_TABLE_LO,y
sta ZEROPAGE_POINTER_3
lda SCREEN_LINE_OFFSET_TABLE_HI,y
sta ZEROPAGE_POINTER_3 + 1
lda SCREENS_TILE_CHARS_0_0,x
ldy PARAM8
sta (ZEROPAGE_POINTER_3),y
iny
iny
lda SCREENS_TILE_CHARS_1_0,x
sta (ZEROPAGE_POINTER_3),y
tya
clc
adc #39 * 2
tay
lda SCREENS_TILE_CHARS_0_1,x
sta (ZEROPAGE_POINTER_3),y
iny
iny
lda SCREENS_TILE_CHARS_1_1,x
sta (ZEROPAGE_POINTER_3),y
ply
rts
!zone WaitFrame
WaitFrame
lda #$f0
WaitForLine