-
Notifications
You must be signed in to change notification settings - Fork 2
/
player.s
1013 lines (897 loc) · 15.8 KB
/
player.s
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
; Double Action Blaster Guys
;
; Copyright 2012-2014 NovaSquirrel
;
; This software is provided 'as-is', without any express or implied
; warranty. In no event will the authors be held liable for any damages
; arising from the use of this software.
;
; Permission is granted to anyone to use this software for any purpose,
; including commercial applications, and to alter it and redistribute it
; freely, subject to the following restrictions:
;
; 1. The origin of this software must not be misrepresented; you must not
; claim that you wrote the original software. If you use this software
; in a product, an acknowledgment in the product documentation would be
; appreciated but is not required.
; 2. Altered source versions must be plainly marked as such, and must not be
; misrepresented as being the original software.
; 3. This notice may not be removed or altered from any source distribution.
;
.proc PlayerGameOver
lda #0
sta PlayerEnabled,x
rts
.endproc
.proc RunPlayer
lda PlayerDead,x
beq NotDead
; increase gravity
lda PlayerVYL,x
add #32
bcc :+
inc PlayerVYH,x
: sta PlayerVYL,x
; apply gravity
lda PlayerPYL,x
add PlayerVYL,x
sta PlayerPYL,x
lda PlayerPYH,x
adc PlayerVYH,x
sta PlayerPYH,x
cmp #<-12
bcc :+
; revive player
dec PlayerLives,x
lda PlayerLives,x
jeq PlayerGameOver
lda #0
sta PlayerDead,x
jsr PlayerResetPos
lda #60
sta PlayerInvincible,x
jsr ResetPlayerHealthX
:
jmp DispPlayer
NotDead:
lda #255
sta PlayerPowerEnabled
lda PlayerPowerTime,x
beq :+
lda PlayerPowerType,x
sta PlayerPowerEnabled
lda retraces
and #3
bne :+
dec PlayerPowerTime,x
:
lda keydown,x
sta 0
; keep running if you were running before you jumped,
; or keep walkng if you were walking before you jumped
lda PlayerVYH,x
ora PlayerVYL,x
beq :+
lda PlayerWasRunning,x
sta 0
:
; holding B lets you go twice as fast
ldy #2
lda 0
and #KEY_B
beq :+
ldy #4
: sty 0
; moving left and right
lda keydown,x
and #KEY_LEFT
beq :+
lda PlayerPX,x
sub 0
lsr
lsr
lsr
lsr
sta 1
lda PlayerPYH,x
add #8
and #$f0
ora 1
tay
lda LevelBuf,y
jsr BlockIsSolid
bne :+
lda PlayerPX,x
sub 0
sta PlayerPX,x
lda #1
sta PlayerDir,x
: lda keydown,x
and #KEY_RIGHT
beq :+
lda PlayerPX,x
add #7
add 0
lsr
lsr
lsr
lsr
sta 1
lda PlayerPYH,x
add #8
and #$f0
ora 1
tay
lda LevelBuf,y
jsr BlockIsSolid
bne :+
lda PlayerPX,x
add 0
sta PlayerPX,x
lda #0
sta PlayerDir,x
:
; select skips to the next level, or skips to the level edit screen
lda keydown,x
and #KEY_SELECT
beq :+
; lda ScrollGameMode
; bne :+
jsr init_sound
lda LevelEditMode
jne StartEditorNormal
lda retraces
beq :+
sta r_seed
pla ; don't mess up the stack
pla
jmp NewLevel
:
; gravity
lda PlayerPYL,x
add PlayerVYL,x
bcc :+
inc PlayerPYH,x
: sta PlayerPYL,x
lda PlayerVYH,x
bmi GravityOkay
cmp #8
bcs GravitySkip
GravityOkay:
lda PlayerVYL,x
add #32
bcc :+
inc PlayerVYH,x
: sta PlayerVYL,x
GravitySkip:
; check for collision with blocks above before adding gravity
lda PlayerVYH,x
bpl :+
lda PlayerPX,x
add #4
lsr
lsr
lsr
lsr
sta 1
lda PlayerPYH,x
add PlayerVYH,x
and #$f0
ora 1
tay
lda LevelBuf,y
jsr BlockIsSolid
beq :+
lda #0
sta PlayerVYH,x
:
; more gravity
lda PlayerPYH,x
add PlayerVYH,x
sta PlayerPYH,x
; rapid fire
lda PlayerPowerEnabled
cmp #APOWERUP_DIAGSHOOT
bne :+
lda keydown,x
and #KEY_B
beq :+
lda retraces
and #7
beq ShootAnyway
:
lda keydown,x
and #KEY_B
beq NoShoot
lda keylast,x
and #KEY_B
bne NoShoot
ShootAnyway:
lda #SOUND_SHOOT
jsr start_sound
lda PlayerPowerEnabled
cmp #APOWERUP_BILLBLOCK
jeq ShootBillBlock
jsr FindFreeBulletY
bcc NoShoot
sty 0
ldy PlayerDir,x
lda OffsetHeldX,y
ldy 0
add PlayerPX,x
sta BulletPX,y
ldy PlayerDir,x
lda BulletSpeed,y
ldy 0
sta BulletVX,y
lda #0
sta BulletVY,y
sta BulletVXL,y
sta BulletVYL,y
sta BulletPYL,y
sta BulletPYL,y
lda PlayerPYH,x
add #4
sta BulletPY,y
lda #8
sta 1 ; bullet type
lda PlayerPowerEnabled
cmp #APOWERUP_BOMBS
bne :+
lda #12 ; bomb
sta 1
:
lda PlayerPowerEnabled
cmp #APOWERUP_DIAGSHOOT
bne :+
jsr huge_rand
and #3
sub #2
sta BulletVY,y
:
lda #%11000000 ; enabled, player-made
ora 1 ; bullet type
sta BulletF,y
lda #15
sta BulletLife,y
NoShoot:
lda PlayerVYH,x
bpl :+
lda keydown,x ; cancel a jump (doesn't appear to work?)
and #KEY_A
bne :+
lda PlayerJumpCancelLock,x
bne :+
lda #0
sta PlayerVYH,x
sta PlayerVYL,x
:
; lower PlayerDropLock if it isn't zero yet
lda PlayerDropLock,x
beq :+
dec PlayerDropLock,x
:
lda PlayerPX,x
add #4 ; start from middle
lsr
lsr
lsr
lsr
sta PlayerXShifted
sta 0 ; for the falling through platforms stuff after
pha
lda PlayerPYH,x
add #15
and #$f0
ora 0
tay
sty 11
; check for things that don't care about Y velocity first
lda LevelBuf,y
cmp #METATILE_PICKUP
bne NotPickup
lda #0
jsr ChangeBlock
lda #POWERUP_HEALTH
jsr CreatePowerup
lda #SOUND_MONEY
jsr start_sound
jmp SkipWalkthrough2
NotPickup:
cmp #METATILE_BOMB_TRAP
bne NotBombTrap
lda PlayerTeleportCooldown,x
jne SkipWalkthrough2
lda #20
sta PlayerTeleportCooldown,x
jsr DropBomb
ldy BombDroppedIndex
bmi :+
lda 11
and #$f0
sub #32
sta ObjectPYH,y
lda 11
asl
asl
asl
asl
add #4
sta ObjectPX,y
:
jmp SkipWalkthrough2
NotBombTrap:
cmp #METATILE_INSTANT_SWITCH
bne NotInstaswitch
lda PlayerTeleportCooldown,x
jne SkipWalkthrough2
.if 0
lda ScrollGameMode ; only instant switch on metatile boundaries
beq :+
lda ScrollX+1
and #15
jne SkipWalkthrough2
:
.endif
lda #40
sta PlayerTeleportCooldown,x
jsr wait_vblank
lda #0
sta PPUMASK
ldy #0
: sty 9
lda LevelBuf,y
jsr DoCycleChange
lda BlockUpdateA1
beq :+
sta PPUADDR
lda BlockUpdateA2
sta PPUADDR
lda BlockUpdateT1
sta PPUDATA
lda BlockUpdateT2
sta PPUDATA
lda BlockUpdateB1
sta PPUADDR
lda BlockUpdateB2
sta PPUADDR
lda BlockUpdateT3
sta PPUDATA
lda BlockUpdateT4
sta PPUDATA
lda #0
sta BlockUpdateA1
:
ldy 9
iny
cpy #240
bne :--
lda ScrollX+1
sta PPUSCROLL
lda #0
sta PPUSCROLL
jsr wait_vblank
lda #BG_ON|OBJ_ON
sta PPUMASK
jmp SkipWalkthrough2
NotInstaswitch:
lda LevelBuf,y
cmp #METATILE_MONEY
bne NotMoney
sty 1
jsr IndexToBitmap
sta 0
and CollectMap,y
bne NotMoney
lda 0
ora CollectMap,y
sta CollectMap,y
ldy 1
lda #0
jsr ChangeBlockColor
lda LevelGoalType
cmp #3
bne NotMoneyType
lda LevelGoalParam
beq NotMoneyType
dec LevelGoalParam
NotMoneyType:
lda #SOUND_MONEY
jsr start_sound
lda #1
jsr PlayerAddScore
NotMoney:
lda LevelBuf,y
cmp #METATILE_TELEPORT_LEFT
bne NotTeleportLeft
lda PlayerTeleportCooldown,x
jne SkipWalkthrough2
: dey
lda LevelBuf,y
cmp #METATILE_TELEPORT_LEFT
beq :+
cmp #METATILE_TELEPORT_RIGHT
beq :+
bne :-
: jsr MovePlayerToLevelY
lda #60
sta PlayerTeleportCooldown,x
lda #SOUND_TELEPORT
jsr start_sound
jmp SkipWalkthrough2
NotTeleportLeft:
cmp #METATILE_TELEPORT_RIGHT
bne NotTeleportRight
lda PlayerTeleportCooldown,x
jne SkipWalkthrough2
: iny
lda LevelBuf,y
cmp #METATILE_TELEPORT_LEFT
beq :+
cmp #METATILE_TELEPORT_RIGHT
beq :+
bne :-
: jsr MovePlayerToLevelY
lda #60
sta PlayerTeleportCooldown,x
lda #SOUND_TELEPORT
jsr start_sound
jmp SkipWalkthrough2
NotTeleportRight:
;---------------------------------------------
SkipWalkthrough2:
pla
sta 0
lda PlayerPowerEnabled,x
cmp #APOWERUP_JUMP
bne :+
lda keydown,x
and #KEY_A
beq :+
lda keylast,x
and #KEY_A
jeq StartJump
:
; it's only OK to fall through platforms, nothing else
lda PlayerPYH,x
add #16
and #$f0
ora 0
tay
lda LevelBuf,y
cmp #METATILE_CYCLE_ON_PLATF
beq :+
cmp #METATILE_PLATFM
bne :++
: lda keydown,x
and #KEY_A|KEY_DOWN
cmp #KEY_A|KEY_DOWN
beq DropThroughPlatform ; fallthrough
lda PlayerDropLock,x
bne SkipPlatformCheck
: ; collision with platforms
lda PlayerVYH,x
bpl NotSkipMi
jmp :+
NotSkipMi:
lda PlayerXShifted
sta 0
lda PlayerPYH,x
add #16
and #$f0
ora 0
tay
sty 0
lda LevelBuf,y
cmp #FirstSolidTop
bcc SkipPlatformCheck
lda PlayerPYH,x
and #$f0
sta PlayerPYH,x
lda keydown,x
and #KEY_B
sta PlayerWasRunning,x
lda #0
sta PlayerVYH,x
sta PlayerVYL,x
sta PlayerJumpCancelLock,x
lda keydown,x ; start a jump
and #KEY_A
beq SkipPlatformCheck
StartJump:
lda #SOUND_JUMP
jsr start_sound
lda #<-4
sta PlayerVYH,x
lda #0
sta PlayerVYL,x
beq SkipPlatformCheck
DropThroughPlatform:
lda #13
sta PlayerDropLock,x
SkipPlatformCheck:
; check for block types you walk through instead
ldy 11
lda LevelBuf,y
cmp #METATILE_SPRING
bne NotSpring
lda #METATILE_SPRING2
jsr ChangeBlock
lda retraces
add #4
sta 0
lda #METATILE_SPRING
jsr AddDelayMetaEdit
lda #<-5
sta PlayerVYH,x
lda #80
sta PlayerVYL,x
lda #1
sta PlayerJumpCancelLock,x
lda #SOUND_SPRING
jsr start_sound
jmp SkipWalkthrough
NotSpring:
cmp #METATILE_SPIKES
bne NotSpikes
txa
tay
jsr PlayerHurt
jmp SkipWalkthrough
NotSpikes:
cmp #METATILE_KILL_SPIKES
bne NotDeathSpikes
lda #1
sta PlayerDead,x
lda #SOUND_YOUDEAD
jsr start_sound
NotDeathSpikes:
SkipWalkthrough:
lda ScrollMode
beq NotScrollMode
lda PlayerPX,x
sub ScrollX+1
cmp #16+2+8
bcs :+
lda #1
sta PlayerDead,x
lda #SOUND_YOUDEAD
jsr start_sound
:
NotScrollMode:
lda PlayerInvincible,x
beq :+
dec PlayerInvincible,x
:
lda PlayerTeleportCooldown,x
beq :+
dec PlayerTeleportCooldown,x
:
; collision with bullets
jsr PlayerGetShot
bcc :+
txa
tay
jsr PlayerHurt
: jmp DispPlayer
BlockXSpeed:
.byt 3, <-3
BlockXOffset:
.byt 12, <(-12-16)
ShootBillBlock:
stx TempVal
jsr FindFreeObjectX
bcc :+
ldy TempVal
lda PlayerDir,y
sta 3
and #1
ora #OBJECT_BOMB*2
sta ObjectF1,x
lda #EXTOBJ_BILLBLOCK
sta ObjectF3,x
lda PlayerPX,y
ldy 3
add BlockXOffset,y
sta ObjectPX,x
ldy TempVal
lda PlayerPYH,y
add #4
sta ObjectPYH,x
lda #5
sta ObjectTimer,x
: ldx TempVal
jmp NoShoot
.endproc
.proc MovePlayerToLevelY
tya
pha
asl
asl
asl
asl
add #4
sta PlayerPX,x
pla
and #$f0
sta PlayerPYH,x
rts
.endproc
.proc BodyTypeAnims
.byt $18, $19, $18, $1a ; style the player uses
.byt $3f, $1c, $3f, $1d ; stick figure style
.byt $11, $12, $11, $12 ; fat guy
.byt $14, $14, $14, $14 ; hover guy?
.byt $15, $15, $15, $15 ; solid guy
.byt $16, $17, $16, $17 ; tilty pogo guy
.byt $1e, $1e, $1e, $1e ; hover guy 2
.byt $5d, $5e, $5d, $5f ; player style 2
.endproc
.proc PlayerGetShot
lda PlayerPYH,x
add #8
lsr
lsr
and #%111000
sta TempVal
lda PlayerPX,x
add #4
lsr ; / 32 pixels
lsr
lsr
lsr
lsr
ora TempVal
tay
lda BulletMap,y
beq Exit
ldy #0
BulletLoop:
lda BulletF,y
and #%10000000
cmp #%10000000 ;enabled, enemy-made bullets only
bne SkipBullet
lda BulletPX,y
sta TouchLeftA
lda BulletPY,y
sta TouchTopA
lda PlayerPX,x
sta TouchLeftB
lda PlayerPYH,x
sta TouchTopB
lda #8
sta TouchWidthA
sta TouchWidthB
sta TouchHeightA
asl
sta TouchHeightB
jsr ChkTouchGeneric
bcs ShotHit
SkipBullet:
iny
cpy #BulletLen
bne BulletLoop
Exit:
clc
rts
ShotHit:
lda PlayerInvincible,x
bne :+
lda #0
sta BulletF,y
sec
: rts
.endproc
.proc DispPlayer
; 0 - attribute
; 1 - used to preserve Y (register)
; 2 - used to preserve Y (position)
; x - player num
lda PlayerInvincible,x
beq :+
lda retraces
and #1
beq :+
rts
:
; change stuff when player is facing left
lda #0|OAM_COLOR_0
ldy PlayerDir,x ; garbage load; we only care about the flags
beq :+
lda #OAM_XFLIP|OAM_COLOR_0
: sta 0
.ifdef fourscore
txa ; Player 2 and 4 use different colors
lsr
bcc :+
.else
cpx #1 ; Player 2 uses a different color
bne :+
.endif
lda 0
ora #OAM_COLOR_2
sta 0
:
lda PlayerPowerTime,x ; flashy if we have a powerup
beq :+
lda 0
ora #OAM_COLOR_3
sta 0
:
ldy OamPtr
lda PlayerPYH,x
sub #1
sta OAM_YPOS+(4*0),y
add #6
sta OAM_YPOS+(4*2),y
add #2
sta OAM_YPOS+(4*1),y
lda 0
sta OAM_ATTR+(4*0),y
sta OAM_ATTR+(4*1),y
sta OAM_ATTR+(4*2),y
lda PlayerHead,x
sta OAM_TILE+(4*0),y
; walking animation
sty 1 ; save Y
lda PlayerBody,x
asl
asl
sta 0
tay
lda keydown,x
and #KEY_LEFT + KEY_RIGHT
beq :+
lda retraces
lsr
lsr
and #3
add 0
tay
:
lda BodyTypeAnims,y
ldy 1 ; restore Y
sta OAM_TILE+(4*1),y
lda PlayerHeld,x
ora #$20
sta OAM_TILE+(4*2),y
lda PlayerPX,x
sub ScrollX+1
sta OAM_XPOS+(4*0),y
sta OAM_XPOS+(4*1),y
sty 1
lda PlayerDir,x
tay
lda OffsetHeldX,y
ldy 1
add PlayerPX,x
sub ScrollX+1
sta OAM_XPOS+(4*2),y
tya
add #16
tay
sty OamPtr
rts
.endproc
.proc OffsetHeldX
.byt 8, <-8
.endproc
.proc BulletSpeed
.byt 6, <-6
.endproc
.proc IsPlayerTouching
; X - player number
lda PlayerPX,x
sta TouchLeftA,x
lda PlayerPYH,x
sta TouchTopA,x
lda #8
sta TouchWidthA
lda #16
sta TouchHeightA
; jmp ChkTouchGeneric
.endproc
.proc ChkTouchGeneric
; http://atariage.com/forums/topic/71120-6502-killer-hacks/page-3?&#entry1054049
; X positions
lda TouchWidthB
sub #1
sta TouchTemp
add TouchWidthA
sta TouchTemp2 ; carry now set
lda TouchLeftA
sbc TouchLeftB ; Note will subtract n-1
sbc TouchTemp ;#SIZE2-1
adc TouchTemp2 ;#SIZE1+SIZE2-1 ; Carry set if overlap
bcc No
; Y positions
lda TouchHeightB
sub #1
sta TouchTemp
add TouchHeightA
sta TouchTemp2 ; carry now set
lda TouchTopA
sbc TouchTopB ; Note will subtract n-1
sbc TouchTemp ;#SIZE2-1
adc TouchTemp2 ;#SIZE1+SIZE2-1 ; Carry set if overlap
bcc No
sec
rts
No:
clc
rts
.endproc
.proc PlayerHurt ; Y is actually the player here, not X
txa
pha
lda PlayerHealth,y
beq :+
lda PlayerInvincible,y
bne :+
sty TempVal
lda #SOUND_YOUHURT
jsr start_sound
ldy TempVal
dcp PlayerHealth,y
lda #60
sta PlayerInvincible,y
lda PlayerHealth,y
bne :+
lda #1
sta PlayerDead,y
: pla
tax
rts
.endproc
.proc PlayerAddScore
tay
lda BCD64,y
unpack TempVal,TempVal+1
ldy PlayerScoreIndex,x
tya
pha
lda ScoreDigits+2,y
pha
lda ScoreDigits,y
add TempVal
sta ScoreDigits,y
lda ScoreDigits+1,y
add TempVal+1
sta ScoreDigits+1,y
FixLoop: ; if it goes past 9, carry it over
lda ScoreDigits,y
cmp #'9'+1 ; 9 or less: no fixing
bcc Next
sub #10
sta ScoreDigits,y
isc ScoreDigits+1,y
Next:
iny
cpy #NumScoreDigits
beq Exit
cpy #NumScoreDigits*2
bne FixLoop
Exit:
pla
sta TempVal
pla
tay
lda TempVal
cmp ScoreDigits+2,y
beq :+
lda ScoreDigits+2,y
cmp #'0'
beq AddLife
cmp #'5'