-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnakes.asm
958 lines (838 loc) · 24.7 KB
/
snakes.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
; Copyright 2020 by Robin Sergeant. See license.txt distributed with this file.
processor 6502
include "vcs.h"
include "macro.h"
include "xmacro.h"
SEG.U vars
ORG $80
MOTION_DELAY = 10
MUNCH_DELAY = 20
HISCORE_DELAY = 40
SCORE_POS = 108
HISCORE_POS = 28
PLAY_AREA_WIDTH = 24
PLAY_AREA_HEIGHT = 16
DIR_LEFT = %10000000
DIR_RIGHT = %11000000
DIR_UP = %00100000
DIR_DOWN = %00110000
MOV_LEFT = %00000000
MOV_RIGHT = %01000000
MOV_UP = %10000000
MOV_DOWN = %11000000
SHOW_HI_SCORE = %00000001
GameState ds 1
Score ds 2
HiScore ds 2
Sound ds 1
RandomNum ds 1
PF0R_PF1L ds PLAY_AREA_HEIGHT
PF2L ds PLAY_AREA_HEIGHT
PF1R ds PLAY_AREA_HEIGHT
Direction ds 1
NewDirection ds 1
MotionCount ds 1
EventCount ds 1
HeadPosition_X ds 1
HeadPosition_Y ds 1
TailPosition_X ds 1
TailPosition_Y ds 1
FruitPosition_X ds 1
FruitPosition_Y ds 1
FreeIndex ds 1
FreeOffset ds 1
TailOffset ds 1
TailLoc = Body
FaceSpritePtr ds 2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Temp data / stack space here
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SpritePtr0 ds 2
SpritePtr1 ds 2
SpritePtr2 ds 2
SpritePtr3 ds 2
Mask_Current = SpritePtr0
Fruit_Current = SpritePtr1
Mask_Temp = SpritePtr2
Temp = SpritePtr0
STACK_POS = SpritePtr3+1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; end of stack space
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Body ds #$FF - STACK_POS
; calculate the maximum bodu length
MAX_BODY_LENGTH SET [$FF - Body + 1] * 4
SEG
ORG $F800 ; 2K Rom origin
Reset CLEAN_START
ldx #STACK_POS
txs
lda #$98
sta COLUPF
sta RandomNum ; use this color as random number seed!
lda #1
sta VDELP1
lda #5
sta AUDV0
lda #>Char0
sta FaceSpritePtr+1
lda #<Face
sta FaceSpritePtr
lda #PLAY_AREA_HEIGHT
sta FruitPosition_Y
Restart lda #0
sta TailLoc
sta FreeIndex
sta TailOffset
sta FreeOffset
sta EventCount
ldx #1
ldy #2
sty HeadPosition_Y
sty TailPosition_Y
stx TailPosition_X
jsr UpdatePlayField
inx
jsr UpdatePlayField
inx
stx HeadPosition_X
lda #MOTION_DELAY
sta MotionCount
lda #SHOW_HI_SCORE
sta GameState
lda #DIR_RIGHT
sta Direction
jsr GrowBody
jsr GrowBody
StartOfFrame
; Start of vertical blank processing
VERTICAL_SYNC
; 36 scanlines of vertical blank...
ldx #32
jsr WaitForLines
; 2 scan lines to position score sprites
ldy #SCORE_POS
lda GameState
and #SHOW_HI_SCORE
beq .+4
ldy #HISCORE_POS
tya
ldx #0
jsr SetHorizPos
sta WSYNC
tya
clc
adc #8
ldx #1
jsr SetHorizPos
; 1 scaline to move sprite
sta WSYNC
sta HMOVE
lda #0
sta VBLANK
; 192 scanlines of picture...
; 14 scan lines of nothing
ldx #14
jsr WaitForLines
; 1 scan line to choose score sprites
lda #>Char0
sta SpritePtr0+1
sta SpritePtr1+1
sta SpritePtr2+1
ldx #Score
lda GameState
and #SHOW_HI_SCORE
beq .+4
ldx #HiScore
lda $0,x
and #$0F
asl
asl
asl
sta SpritePtr0
lda $0,x
and #$F0
lsr
sta SpritePtr1
inx
lda $0,x
and #$0F
asl
asl
asl
bne SetLastDigit
lda #<Blank ; blank out leading zeros
ldx SpritePtr1
bne SetLastDigit
sta SpritePtr1
SetLastDigit sta SpritePtr2
;sta WSYNC
; 8 scan lines to draw sprite
ldy #7
ldx #$C2
lda #1
sta NUSIZ0
DrawSprite sta WSYNC
lda (SpritePtr1),y
sta GRP1
lda (SpritePtr2),y
lsr ; nudge MSD right 1 pixel
sta GRP0
stx COLUP1
stx COLUP0
lda (SpritePtr0),y
asl ; nudge LSD left 1 pixel
inx
sta GRP0
inx
lda (SpritePtr2),y
lsr ; nudge MSD right 1 pixel
sta GRP0
lda (SpritePtr0),y
asl ; nudge LSD left 1 pixel
dey
nop
sta GRP0
bpl DrawSprite
; 5 scan lines to position game sprites
sta WSYNC
lda FruitPosition_X
asl
asl
clc
adc #32
ldx #1
jsr SetHorizPos
sta WSYNC
lda HeadPosition_X
asl
asl
clc
adc #32
ldx #0
jsr SetHorizPos
sta WSYNC
sta HMOVE
ldx #0
stx Mask_Current
stx Fruit_Current
stx NUSIZ0
stx NUSIZ1
lda #$0E
sta COLUP1
lda #0
cmp HeadPosition_Y
bne SetMask
lda #$FF ; snakes head is on first row
SetMask sta Mask_Current
lda #0
cmp FruitPosition_Y
bne SetFruit
lda #%01100000 ; fruit is on first row
SetFruit sta Fruit_Current
ldy #7
TopWall sta WSYNC
lda #$1F ; 2
sta PF1 ; 3
lda #$FF ; 2
sta PF2 ; 3
lda #$F0 ; 2
SLEEP 12
sta PF0 ; 3 = 27
lda #$FF ; 2
SLEEP 5
sta PF1 ; 3 = 37
lda #$01 ; 2
SLEEP 6
sta PF2 ; 3 = 48
lda #0 ; 2
sta PF0 ; 3 = 53
dey
bpl TopWall
RenderRow ldy #7
sec
sta WSYNC
lda PF0R_PF1L,x ; 4
and #$0F ; 2
ora #$10 ; 2 = 8
sta PF1 ; 3
lda colors,y ; 4
sta COLUP0 ; 3
lda (FaceSpritePtr),y ; 5
and Mask_Current ; 3
sta GRP0 ; 3 = 29
lda PF2L,x ; 4 = 33
sta PF2 ; 3
lda PF0R_PF1L,x ; 4 = 40
sta PF0 ; 3
lda PF1R,x ; 4 = 47
sta PF1 ; 3
lda #$01 ; 2 = 52
sta PF2 ; 3
lda #0 ; 2 = 57
sta PF0 ; 3
dey ; 2
txa ; 2
sbc HeadPosition_Y ; 3
cmp #$FF ; 2
beq SetTempMask ; 2
lda #0 ; 2
SetTempMask sta Mask_Temp ; 3 = 76
lda PF0R_PF1L,x ; 4
and #$0F ; 2
ora #$10 ; 2 = 8
sta PF1 ; 3
lda colors,y ; 4
sta COLUP0 ; 3
lda (FaceSpritePtr),y ; 5
and Mask_Current ; 3
sta GRP0 ; 3 = 29
lda PF2L,x ; 4 = 33
sta PF2 ; 3
lda PF0R_PF1L,x ; 4 = 40
sta PF0 ; 3
lda PF1R,x ; 4 = 47
sta PF1 ; 3
lda #$01 ; 2 = 52
sta PF2 ; 3
lda #0 ; 2 = 57
sta PF0 ; 3
dey ; 2
lda Fruit_Current
sta GRP1
sec
sta WSYNC
lda PF0R_PF1L,x ; 4
and #$0F ; 2
ora #$10 ; 2 = 8
sta PF1 ; 3
lda colors,y ; 4
sta COLUP0 ; 3
lda (FaceSpritePtr),y ; 5
and Mask_Current ; 3
sta GRP0 ; 3 = 29
lda PF2L,x ; 4 = 33
sta PF2 ; 3
lda PF0R_PF1L,x ; 4 = 40
sta PF0 ; 3
lda PF1R,x ; 4 = 47
sta PF1 ; 3
lda #$01 ; 2 = 52
sta PF2 ; 3
lda #0 ; 2 = 57
sta PF0 ; 3
dey ; 2
txa
sbc FruitPosition_Y
sta Fruit_Current
;sta WSYNC
lda PF0R_PF1L,x ; 4
and #$0F ; 2
ora #$10 ; 2 = 8
sta PF1 ; 3
lda colors,y ; 4
sta COLUP0 ; 3
lda (FaceSpritePtr),y ; 5
and Mask_Current ; 3
sta GRP0 ; 3 = 29
lda PF2L,x ; 4 = 33
sta PF2 ; 3
lda PF0R_PF1L,x ; 4 = 40
sta PF0 ; 3
lda PF1R,x ; 4 = 47
sta PF1 ; 3
lda #$01 ; 2 = 52
sta PF2 ; 3
lda #0 ; 2 = 57
sta PF0 ; 3
dey ; 2
lda Fruit_Current
cmp #$FF
beq UpdateFruit
lda #0
UpdateFruit and #%01100000
sta Fruit_Current
RenderLine sta WSYNC
lda PF0R_PF1L,x ; 4
and #$0F ; 2
ora #$10 ; 2 = 8
sta PF1 ; 3
lda colors,y ; 4
sta COLUP0 ; 3
lda (FaceSpritePtr),y ; 5
and Mask_Current ; 3
sta GRP0 ; 3 = 29
lda PF2L,x ; 4 = 33
sta PF2 ; 3
lda PF0R_PF1L,x ; 4 = 40
sta PF0 ; 3
lda PF1R,x ; 4 = 47
sta PF1 ; 3
lda #$01 ; 2 = 52
sta PF2 ; 3
lda #0 ; 2 = 57
sta PF0 ; 3
cpy #2
bne KeepFruit
sta GRP1
KeepFruit dey
bne RenderLine
sta WSYNC
lda PF0R_PF1L,x ; 4
and #$0F ; 2
ora #$10 ; 2
sta PF1 ; 3 = 11
lda colors,y ; 4
sta COLUP0 ; 3
lda Mask_Temp ; 3
sta Mask_Current ; 3
lda PF2L,x ; 4
sta PF2 ; 3 = 31
lda PF0R_PF1L,x ; 4
sta PF0 ; 3 = 38
lda PF1R,x ; 4
inx
sta PF1 ; 3
lda #$01 ; 2
sta PF2 ; 3
lda #0 ; 2
sta PF0 ; 3
cpx #PLAY_AREA_HEIGHT
bcs Bottom
jmp RenderRow
Bottom ldy #7
BottomWall sta WSYNC
sta GRP0
lda #$1F ; 2
sta PF1 ; 3
lda #$FF ; 2
sta PF2 ; 3
lda #$F0 ; 2
SLEEP 9
sta PF0 ; 3 = 27
lda #$FF ; 2
SLEEP 5
sta PF1 ; 3 = 37
lda #$01 ; 2
SLEEP 6
sta PF2 ; 3 = 48
lda #0 ; 2
sta PF0 ; 3 = 53
dey
bpl BottomWall
sta WSYNC
ldx #0
stx PF1
stx PF2
stx PF0
stx PF1
stx PF2
; 20 scan lines of nothing
ldx #20
jsr WaitForLines
lda #%01000010
sta VBLANK ; end of screen - enter blanking
; 30 scanlines of overscan...
TIMER_SETUP 30
lda EventCount
beq HandleSound
dec EventCount
lda GameState
eor #SHOW_HI_SCORE
sta GameState
HandleSound ldx Sound
lda Effects,x
sta AUDC0
beq CheckStick
inx
lda Effects,x
sta AUDF0
inc Sound
inc Sound
CheckStick jsr CheckJoystick
stx NewDirection
Motion dec MotionCount
bne CheckFruit
Timeout lda #MOTION_DELAY
sta MotionCount
lda NewDirection
beq WaitOver
jsr UpdateDirection
lda #0
sta GameState
lda #<Face
sta FaceSpritePtr
jsr Move
bvc CheckFruit
jmp GameOver
CheckFruit lda FruitPosition_Y ; if invalid we need to place the next fruit
cmp #PLAY_AREA_HEIGHT
bne WaitOver
jsr GetRandomPos
txa
jsr CheckPlayField ; check pos corresponds to a free square
bvs WaitOver
cmp HeadPosition_X ; also check pos is not equal to snakes head
bne PlaceFruit
cpy HeadPosition_Y
beq WaitOver
PlaceFruit sta FruitPosition_X ; if so place fruit here
sty FruitPosition_Y
WaitOver jsr GetRandom ; cycle through random number every frame
sta WSYNC
TIMER_WAIT
sta WSYNC
jmp StartOfFrame
; wait for X scanlines
WaitForLines SUBROUTINE
dex
sta WSYNC
bne WaitForLines
rts
CheckJoystick SUBROUTINE
ldx NewDirection
bit SWCHA
bvs .CheckRight
ldx #DIR_LEFT
rts
.CheckRight bit SWCHA
bmi .CheckUP
ldx #DIR_RIGHT
rts
.CheckUP lda #$10
bit SWCHA
bne .CheckDOWN
ldx #DIR_UP
rts
.CheckDOWN lda #$20
bit SWCHA
bne .return
ldx #DIR_DOWN
.return rts
UpdateDirection SUBROUTINE
lda NewDirection
bit Direction
bne .return ; overlap indicates invalid direction change
sta Direction
.return rts
; Move snake
Move SUBROUTINE move
ldx HeadPosition_X
ldy HeadPosition_Y
jsr UpdatePlayField ; Put body segment at old head location
ldx HeadPosition_X
lda Direction ; Use direction to calculate new head loc
.left cmp #DIR_LEFT
bne .right
dex
bpl .continue
bmi .collision
.right cmp #DIR_RIGHT
bne .up
inx
cpx #PLAY_AREA_WIDTH
bne .continue
beq .collision
.up cmp #DIR_UP
bne .down
dey
bpl .continue
bmi .collision
.down iny
cpy #PLAY_AREA_HEIGHT
beq .collision
.continue txa
jsr CheckPlayField ; check that new location is empty
bvs .collision
sta HeadPosition_X
sty HeadPosition_Y
cmp FruitPosition_X
bne .move
cpy FruitPosition_Y
beq .grow ; if so grow rather than move
.move jsr TrimTail
jsr GrowBody
clv
rts
.grow jsr GrowBody
lda #PLAY_AREA_HEIGHT
sta FruitPosition_Y
jsr UpdateScore
bcs .setsprite
lda #HISCORE_DELAY ; flash hi-score if below it
sta EventCount
.setsprite lda #<FaceClose ; set face sprite to a closed mouth
sta FaceSpritePtr
lda #MUNCH_DELAY ; increase motion delay to make visible
sta MotionCount
lda #ChimeIndex ; trigger sound effect
sta Sound
clv
rts
.collision bit .return ; set overflow flag
.return rts
GrowBody SUBROUTINE
lda Direction ; convert direction to movement value
bpl .vertical
and #%01000000
bpl .store
.vertical asl
asl
.store ldx FreeOffset ; store new movement value
beq .done
.shift lsr
lsr
dex
bne .shift
.done ldx FreeIndex
ora Body,x
sta Body,x
inc FreeOffset
lda FreeOffset
cmp #4
bne .return
lda #0
sta FreeOffset
inc FreeIndex
ldx FreeIndex
sta Body,x
.return rts
TrimTail SUBROUTINE
lda TailLoc ; find movement value at tail
ldx TailOffset
beq .done
.shift asl
asl
dex
bne .shift
.done and #%11000000
ldx TailPosition_X ; clear tail position
ldy TailPosition_Y
jsr UpdatePlayField
ldx TailPosition_X ; update tail position
cmp #MOV_LEFT
bne .right
dex
.right cmp #MOV_RIGHT
bne .up
inx
.up cmp #MOV_UP
bne .down
dey
.down cmp #MOV_DOWN
bne .update
iny
.update stx TailPosition_X
sty TailPosition_Y
inc TailOffset
lda TailOffset
cmp #4
bne .return
lda #0
sta TailOffset
ldx FreeIndex
dec FreeIndex
lda Body,x
dex
.reorder ldy Body,x ; shift backwards overwriting tail byte
sta Body,x
tya
dex
bpl .reorder
.return rts
; on return the C flag will be set if Score >= HiScore
UpdateScore SUBROUTINE
sed ; use BCD mode for score arithmetic
lda Score
clc
adc #1 ; add one to low byte of score
sta Score
lda Score+1 ; add carry to high byte of score
adc #0
sta Score+1
cmp HiScore+1 ; check for new hi-score
bcc .return
bne .newhiscore
lda Score
cmp HiScore
bcc .return
.newhiscore lda Score
sta HiScore
lda Score+1
sta HiScore+1
.return cld
rts
; CheckScore SUBROUTINE
; lda Score+1
; cmp HiScore+1
; bcc .return
; lda Score
; cmp HiScore
; .return rts
GameOver SUBROUTINE
lda CrashIndex
sta Sound
ldx #PLAY_AREA_HEIGHT
lda #0
sta Score
sta Score+1
sta NewDirection
.ResetPF dex
sta PF0R_PF1L,x
sta PF2L,x
sta PF1R,x
bne .ResetPF
jmp Restart
; CheckPlayField routine
CheckPlayField SUBROUTINE
pha
cpx #4
bcs .pf2left
lda PF0R_PF1L,y
and BitMask_PF1L,x
bne .pixelset
beq .pixelclear
.pf2left txa
cpx #12
bcs .pf0right
sec
sbc #4
tax
lda PF2L,y
and BitMask_PF2,x
bne .pixelset
beq .pixelclear
.pf0right cpx #16
bcs .pf1right
sec
sbc #12
tax
lda PF0R_PF1L,y
and BitMask_PF0,x
bne .pixelset
beq .pixelclear
.pf1right sec
sbc #16
tax
lda PF1R,y
and BitMask_PF1,x
bne .pixelset
.pixelclear pla
clv
rts
.pixelset pla
bit .return ; set overflow flag
.return rts
; UpdatePlayField routine
UpdatePlayField SUBROUTINE
pha
cpx #4
bcs .pf2left
lda PF0R_PF1L,y
eor BitMask_PF1L,x
sta PF0R_PF1L,y
pla
rts
.pf2left txa
cpx #12
bcs .pf0right
sec
sbc #4
tax
lda PF2L,y
eor BitMask_PF2,x
sta PF2L,y
pla
rts
.pf0right cpx #16
bcs .pf1right
sec
sbc #12
tax
lda PF0R_PF1L,y
eor BitMask_PF0,x
sta PF0R_PF1L,y
pla
rts
.pf1right sec
sbc #16
tax
lda PF1R,y
eor BitMask_PF1,x
sta PF1R,y
pla
rts
; Get random X Y position
GetRandomPos SUBROUTINE
lda RandomNum
lsr
lsr
lsr
lsr
sta Temp ; store top half of RandomNum in Temp
lda RandomNum
and #$0F ; use bottom half for Y (0-15)
tay
jsr GetRandom ; get a second random number to extend X
and #$0F ; keep bottom half
lsr ; shift lsb into carry
adc Temp ; to add random number between 0 and 8 to Temp
tax ; X will now be between 0 and 23
rts
; Get next random number
GetRandom SUBROUTINE
lda RandomNum
lsr
bcc .NoEor
eor #$D4
.NoEor sta RandomNum
rts
ALIGN 256
; SetHorizPos routine
; A = X coordinate
; RESP0+X = reset register to strobe
SetHorizPos SUBROUTINE
cpx #2 ; carry flag will be set for balls and missiles
adc #0 ; (adding 1 to account for different timings)
sec
sta WSYNC
.loop sbc #15
bcs .loop
eor #7
asl
asl
asl
asl
sta.a HMP0,X ; force absolute addressing for timing!
sta RESP0,X
rts
ALIGN 256
SpriteData
Char0 .byte $00,$38,$44,$64,$54,$4C,$44,$38
Char1 .byte $00,$38,$10,$10,$10,$10,$30,$10
Char2 .byte $00,$7C,$40,$20,$18,$04,$44,$38
Char3 .byte $00,$38,$44,$04,$18,$08,$04,$7C
Char4 .byte $00,$08,$08,$7C,$48,$28,$18,$08
Char5 .byte $00,$38,$44,$04,$04,$78,$40,$7C
Char6 .byte $00,$38,$44,$44,$78,$40,$20,$1C
Char7 .byte $00,$20,$20,$20,$10,$08,$04,$7C
Char8 .byte $00,$38,$44,$44,$38,$44,$44,$38
Char9 .byte $00,$70,$08,$04,$3C,$44,$44,$38
Blank .byte $00,$00,$00,$00,$00,$00,$00,$00
Face .byte %11110000,%11110000,%10010000,%11110000,%01100000,%01100000,%11110000,%11110000
FaceClose .byte %11110000,%11110000,%11110000,%11110000,%01100000,%01100000,%11110000,%11110000
colors .byte $8E,$7E,$6E,$5E,$4E,$3E,$2E,$1E
Effects
ChimeEffect .byte 6,4,6,3,6,2,6,1,6,0,0
CrashEffect .byte 8,31,8,31,8,31,8,31,8,31,8,31,8,31,8,31,8,31,8,31,8,31,0
ChimeIndex = ChimeEffect - Effects
CrashIndex = CrashEffect - Effects
BitMask_PF2 .byte %00000001, %00000010, %00000100, %00001000
BitMask_PF0 .byte %00010000, %00100000, %01000000, %10000000
BitMask_PF1 .byte %10000000, %01000000, %00100000, %00010000
BitMask_PF1L .byte %00001000, %00000100, %00000010, %00000001
ORG $FFFA
.word Reset ; NMI
.word Reset ; RESET
.word Reset ; IRQ
END