-
Notifications
You must be signed in to change notification settings - Fork 3
/
hiscore.asm
1227 lines (1127 loc) · 33.3 KB
/
hiscore.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
; Provided under the CC0 license. See the included LICENSE.txt for details.
ifconst HSSUPPORT
detectatarivoxeeprom
hiscoremodulestart
; do a test to see if atarivox eeprom can be accessed, and save results
jsr AVoxDetect
eor #$ff ; invert for easy 7800basic if...then logic
sta avoxdetected
lda #$0
sta SWACNT
lda avoxdetected
rts
detecthsc
; check for the HSC ROM signature...
lda XCTRL1s
ora #%00001100
sta XCTRL1s
sta XCTRL1
lda $3900
eor #$C6
bne detecthscfail
lda $3904
eor #$FE
bne detecthscfail
; check if it's initialized...
ldy #0
lda #$ff
checkhscinit
and $1000,y
dey
bpl checkhscinit
cmp #$ff
bne hscisalreadyinit
; if we're here, we need to do a minimal HSC init...
ldy #$28
hscinitloop1
lda hscheader,y
sta $1000,y
dey
bpl hscinitloop1
ldy #$89
lda #$7F
hscinitloop2
sta $10B3,y
dey
cpy #$ff
bne hscinitloop2
hscisalreadyinit
lda #$ff
rts
hscheader
.byte $00,$00,$68,$83,$AA,$55,$9C,$FF,$07,$12,$02,$1F,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$03
detecthscfail
lda XCTRL1s
and #%11110111
sta XCTRL1s
lda #0
rts
endif ; HSSUPPORT
ifconst HSSUPPORT
ifnconst hiscorefont
echo ""
echo "WARNING: High score support is enabled, but the hiscorefont.png was"
echo " NOT imported with incgraphic. The high score display code"
echo " has been omitted from this build."
echo ""
else
hscdrawscreen
; we use 20 lines on a 24 line display
; HSSCOREY to dynamically centers based on
;HSSCOREY = 0
HSSCOREY = ((WZONECOUNT*WZONEHEIGHT/8)-22)/2
HSCURSORY = ((HSSCOREY/(WZONEHEIGHT/8))*WZONEHEIGHT)
ifconst HSSCORESIZE
SCORESIZE = HSSCORESIZE
else
SCORESIZE = 6
endif
;save shadow registers for later return...
lda sCTRL
sta ssCTRL
lda sCHARBASE
sta ssCHARBASE
lda #$60
sta charactermode
jsr drawwait
jsr blacken320colors
jsr clearscreen
;set the character base to the HSC font
lda #>hiscorefont
sta CHARBASE
sta sCHARBASE
lda #%01000011 ;Enable DMA, mode=320A
sta CTRL
sta sCTRL
lda #60
sta hsjoydebounce
lda #0
sta hscursorx
sta framecounter
ifnconst HSCOLORCHASESTART
lda #$8D ; default is blue. why not?
else
lda #HSCOLORCHASESTART
endif
sta hscolorchaseindex
lda #$0F
sta P0C2 ; base text is white
jsr hschasecolors
; ** plot all of the initials
lda #<HSRAMInitials
sta temp1 ; charmaplo
lda #>HSRAMInitials
sta temp2 ; charmaphi
lda #32+29 ; palette=0-29 | 32-(width=3)
sta temp3 ; palette/width
lda #104
sta temp4 ; X
lda #((HSSCOREY+6)/(WZONEHEIGHT/8))
sta temp5 ; Y
plothsinitialsloop
jsr plotcharacters
clc
lda temp3
adc #32
sta temp3
inc temp5
if WZONEHEIGHT = 8
inc temp5
endif
clc
lda #3
adc temp1
sta temp1
cmp #(<(HSRAMInitials+15))
bcc plothsinitialsloop
ifconst HSGAMENAMELEN
;plot the game name...
lda #<HSGAMENAMEtable
sta temp1 ; charmaplo
lda #>HSGAMENAMEtable
sta temp2 ; charmaphi
lda #(32-HSGAMENAMELEN) ; palette=0*29 | 32-(width=3)
sta temp3 ; palette/width
lda #(80-(HSGAMENAMELEN*2))
sta temp4 ; X
lda #((HSSCOREY+0)/(WZONEHEIGHT/8))
sta temp5 ; Y
jsr plotcharacters
endif ; HSGAMENAMELEN
;plot "difficulty"...
ldy gamedifficulty
ifnconst HSNOLEVELNAMES
lda highscoredifficultytextlo,y
sta temp1
lda highscoredifficultytexthi,y
sta temp2
sec
lda #32
sbc highscoredifficultytextlen,y
sta temp3 ; palette/width
sec
lda #40
sbc highscoredifficultytextlen,y
asl
sta temp4 ; X
else
lda #<HSHIGHSCOREStext
sta temp1 ; charmaplo
lda #>HSHIGHSCOREStext
sta temp2 ; charmaphi
lda #(32-11) ; palette=0*29 | 32-(width=3)
sta temp3 ; palette/width
lda #(80-(11*2))
sta temp4 ; X
endif ; HSNOLEVELNAMES
lda #((HSSCOREY+2)/(WZONEHEIGHT/8))
sta temp5 ; Y
jsr plotcharacters
ldy hsdisplaymode ; 0=attact mode, 1=player eval, 2=player 1 eval, 3=player 2 player eval, 4=player 2 player evel (joy1)
bne carronwithscoreevaluation
jmp donoscoreevaluation
carronwithscoreevaluation
dey
lda highscorelabeltextlo,y
sta temp1
lda highscorelabeltexthi,y
sta temp2
sec
lda #(32-15) ; palette=0*29 | 32-(width=3)
sta temp3 ; palette/width
lda highscorelabeladjust1,y
sta temp4 ; X
lda #((HSSCOREY+18)/(WZONEHEIGHT/8))
sta temp5 ; Y
jsr plotcharacters
ldy hsdisplaymode ; 0=attact mode, 1=player eval, 2=player 1 eval, 3=player 2 player eval, 4=player 2 player evel (joy1)
dey
;plot the current player score...
lda #(32-SCORESIZE) ; palette=0*32
sta temp3 ; palette/width
lda highscorelabeladjust2,y
sta temp4 ; X
lda #((HSSCOREY+18)/(WZONEHEIGHT/8))
sta temp5 ; Y
lda scorevarlo,y
sta temp7 ; score variable lo
lda scorevarhi,y
sta temp8 ; score variable hi
lda #(hiscorefont_mode | %01100000) ; charactermode
sta temp9
lda #<(hiscorefont+33) ; +33 to get to '0' character
sta temp1 ; charmaplo
lda #>(hiscorefont+33)
sta temp2 ; charmaphi
lda #SCORESIZE
sta temp6
ifnconst DOUBLEWIDE
jsr plotvalue
else
jsr plotvaluedw
endif
USED_PLOTVALUE = 1 ; ensure that plotvalue gets compiled in
ifconst HSGAMERANKS
ldx #$ff ; start at 0 after the inx...
comparescore2rankloop
inx
ldy #0
lda rankvalue_0,x
cmp (temp7),y
bcc score2rankloopdone
bne comparescore2rankloop
iny
lda rankvalue_1,x
cmp (temp7),y
bcc score2rankloopdone
bne comparescore2rankloop
iny
lda (temp7),y
cmp rankvalue_2,x
bcs score2rankloopdone
jmp comparescore2rankloop
score2rankloopdone
stx hsnewscorerank
lda ranklabello,x
sta temp1
lda ranklabelhi,x
sta temp2
sec
lda #32 ; palette=0*29 | 32-(width=3)
sbc ranklabellengths,x
sta temp3 ; palette/width
sec
lda #(40+6)
sbc ranklabellengths,x
asl
sta temp4 ; X
lda #((HSSCOREY+20)/(WZONEHEIGHT/8))
sta temp5 ; Y
jsr plotcharacters
ldx hsnewscorerank
lda #<highscoreranklabel
sta temp1
lda #>highscoreranklabel
sta temp2
lda #(32-5) ; palette=0*29 | 32-(width=3)
sta temp3 ; palette/width
lda #(40-6)
sec
sbc ranklabellengths,x
asl
sta temp4 ; X
lda #((HSSCOREY+20)/(WZONEHEIGHT/8))
sta temp5 ; Y
jsr plotcharacters
endif
; ** which line did this player beat?
lda #$ff
sta hsnewscoreline
ldx #$fd
comparescoreadd2x
inx
comparescoreadd1x
inx
comparescore2lineloop
inc hsnewscoreline
inx ; initialrun, x=0
cpx #15
beq nohighscoreforyou
ldy #0
lda HSRAMScores,x
cmp (temp7),y ; first score digit
bcc score2lineloopdonedel1x
bne comparescoreadd2x
iny
inx
lda HSRAMScores,x
cmp (temp7),y
bcc score2lineloopdonedel2x
bne comparescoreadd1x
iny
inx
lda (temp7),y
cmp HSRAMScores,x
bcs score2lineloopdonedel3x
jmp comparescore2lineloop
nohighscoreforyou
lda #$ff
sta hsnewscoreline
sta countdownseconds
jmp donoscoreevaluation
score2lineloopdonedel3x
dex
score2lineloopdonedel2x
dex
score2lineloopdonedel1x
dex
; 0 1 2
; 3 4 5
; 6 7 8
; 9 0 1
; 2 3 4
stx temp9
cpx #11
beq postsortscoresuploop
ldx #11
sortscoresuploop
lda HSRAMScores,x
sta HSRAMScores+3,x
lda HSRAMInitials,x
sta HSRAMInitials+3,x
dex
cpx temp9
bne sortscoresuploop
postsortscoresuploop
;stick the score and cleared initials in the slot...
inx
ldy #0
sty hsinitialhold
lda (temp7),y
sta HSRAMScores,x
iny
lda (temp7),y
sta HSRAMScores+1,x
iny
lda (temp7),y
sta HSRAMScores+2,x
lda #0
sta HSRAMInitials,x
lda #29
sta HSRAMInitials+1,x
sta HSRAMInitials+2,x
stx hsinitialpos
ifconst vox_highscore
lda <#vox_highscore
sta speech_addr
lda >#vox_highscore
sta speech_addr+1
endif
ifconst sfx_highscore
lda <#sfx_highscore
sta temp1
lda >#sfx_highscore
sta temp2
lda #0
sta temp3
jsr schedulesfx
endif
ifconst songdatastart_song_highscore
lda #<songchanneltable_song_highscore
sta songpointerlo
lda #>songchanneltable_song_highscore
sta songpointerhi
lda #73
sta songtempo
jsr setsongchannels
endif
donoscoreevaluation
lda #(32+(32-SCORESIZE)) ; palette=0*32 | 32-(width=6)
sta temp3 ; palette/width
lda #(72+(4*(6-SCORESIZE)))
sta temp4 ; X
lda #((HSSCOREY+6)/(WZONEHEIGHT/8))
sta temp5 ; Y
lda #<HSRAMScores
sta temp7 ; score variable lo
lda #>HSRAMScores
sta temp8 ; score variable hi
lda #(hiscorefont_mode | %01100000) ; charactermode
sta temp9
plothsscoresloop
lda #<(hiscorefont+33) ; +33 to get to '0' character
sta temp1 ; charmaplo
lda #>(hiscorefont+33)
sta temp2 ; charmaphi
lda #6
sta temp6
ifnconst DOUBLEWIDE
jsr plotvalue
else
jsr plotvaluedw
endif
clc
lda temp3
adc #32
sta temp3
inc temp5
if WZONEHEIGHT = 8
inc temp5
endif
clc
lda #3
adc temp7
sta temp7
cmp #(<(HSRAMScores+15))
bcc plothsscoresloop
plothsindex
lda #32+31 ; palette=0*32 | 32-(width=1)
sta temp3 ; palette/width
lda #44
sta temp4 ; X
lda #((HSSCOREY+6)/(WZONEHEIGHT/8))
sta temp5 ; Y
lda #<hsgameslotnumbers
sta temp7 ; score variable lo
lda #>hsgameslotnumbers
sta temp8 ; score variable hi
lda #(hiscorefont_mode | %01100000) ; charactermode
sta temp9
plothsindexloop
lda #<(hiscorefont+33)
sta temp1 ; charmaplo
lda #>(hiscorefont+33)
sta temp2 ; charmaphi
lda #1
sta temp6 ; number of characters
ifnconst DOUBLEWIDE
jsr plotvalue
else
jsr plotvaluedw
endif
clc
lda temp3
adc #32
sta temp3
inc temp5
if WZONEHEIGHT = 8
inc temp5
endif
inc temp7
lda temp7
cmp #(<(hsgameslotnumbers+5))
bcc plothsindexloop
jsr savescreen
ifnconst HSSECONDS
lda #6
else
lda #HSSECONDS
endif
sta countdownseconds
keepdisplayinghs
jsr restorescreen
jsr setuphsinpt1
lda hsnewscoreline
bpl carryonkeepdisplayinghs
jmp skipenterscorecontrol
carryonkeepdisplayinghs
ifnconst HSSECONDS
lda #6
else
lda #HSSECONDS
endif
sta countdownseconds
;plot the "cursor" initial sprite...
lda hsinitialhold
sta temp1
lda #>(hiscorefont+32)
sta temp2
lda #31 ; palette=0*32 | 32-(width=1)
sta temp3 ; palette/width
lda hscursorx
asl
asl
clc
adc #104
sta temp4 ; X
lda hsnewscoreline
asl
asl
asl
asl
adc #((3*16)+HSCURSORY)
sta temp5 ; Y
lda #%01000000
sta temp6
jsr plotsprite
ldx hscursorx
ldy hsdisplaymode
lda SWCHA
cpy #3
bne hsskipadjustjoystick1
asl
asl
asl
asl
hsskipadjustjoystick1
sta hsswcha
lda SWCHB
and #%00000010
bne hsskipselectswitch
lda #%00010000
sta hsswcha
bne hsdodebouncecheck
hsskipselectswitch
lda hsswcha
and #%00110000
cmp #%00110000
beq hsjoystickskipped
hsdodebouncecheck
lda hsjoydebounce
beq hsdontdebounce
jmp hspostjoystick
hsdontdebounce
ldx #1 ; small tick sound
jsr playhssfx
lda hsswcha
and #%00110000
ldx hscursorx
cmp #%00100000 ; check down
bne hsjoycheckup
ldy hsinitialhold
cpx #0
bne skipavoid31_1
cpy #0 ; if we're about to change to the <- char (#31) then double-decrement to skip over it
bne skipavoid31_1
dey
skipavoid31_1
dey
jmp hssetdebounce
hsjoycheckup
cmp #%00010000 ; check up
bne hsjoystickskipped
ldy hsinitialhold
cpx #0
bne skipavoid31_2
cpy #30 ; if we're about to change to the <- char (#31) then double-increment to skip over it
bne skipavoid31_2
iny
skipavoid31_2
iny
hssetdebounce
tya
and #31
sta hsinitialhold
lda #15
sta hsjoydebounce
bne hspostjoystick
hsjoystickskipped
; check the fire button only when the stick isn't engaged
lda hsinpt1
bpl hsbuttonskipped
lda hsjoydebounce
beq hsfiredontdebounce
bne hspostjoystick
hsfiredontdebounce
lda hsinitialhold
cmp #31
beq hsmovecursorback
inc hscursorx
inc hsinitialpos
lda hscursorx
cmp #3
bne skiphsentryisdone
lda #0
sta framecounter
lda #$ff
sta hsnewscoreline
dec hsinitialpos
bne skiphsentryisdone
hsmovecursorback
lda hscursorx
beq skiphsmovecursorback
lda #29
ldx hsinitialpos
sta HSRAMInitials,x
dec hsinitialpos
dec hscursorx
dex
lda HSRAMInitials,x
sta hsinitialhold
skiphsmovecursorback
skiphsentryisdone
ldx #0
jsr playhssfx
lda #20
sta hsjoydebounce
bne hspostjoystick
hsbuttonskipped
lda #0
sta hsjoydebounce
hspostjoystick
ldx hsinitialpos
lda hsinitialhold
sta HSRAMInitials,x
jmp skiphschasecolors
skipenterscorecontrol
jsr hschasecolors
jsr setuphsinpt1
lda hsjoydebounce
bne skiphschasecolors
lda hsinpt1
bmi returnfromhs
skiphschasecolors
jsr drawscreen
lda countdownseconds
beq returnfromhs
jmp keepdisplayinghs
returnfromhs
ifconst songdatastart_song_highscore
lda hsdisplaymode
beq skipclearHSCsong
lda #0
sta songtempo
skipclearHSCsong
endif
jsr drawwait
jsr clearscreen
lda #0
ldy #7
jsr blacken320colors
lda ssCTRL
sta sCTRL
lda ssCHARBASE
sta sCHARBASE
rts
setuphsinpt1
lda #$ff
sta hsinpt1
lda hsjoydebounce
beq skipdebounceadjust
dec hsjoydebounce
bne skipstorefirebuttonstatus
skipdebounceadjust
lda SWCHB
and #%00000001
bne hscheckresetover
lda #$ff
sta hsinpt1
rts
hscheckresetover
ldx hsdisplaymode
cpx #3
bne hsskipadjustjoyfire1
lda sINPT3
jmp hsskipadjustjoyfire1done
hsskipadjustjoyfire1
lda sINPT1
hsskipadjustjoyfire1done
sta hsinpt1
skipstorefirebuttonstatus
rts
blacken320colors
ldy #7
blacken320colorsloop
sta P0C2,y
dey
bpl blacken320colorsloop
rts
hschasecolors
lda framecounter
and #3
bne hschasecolorsreturn
inc hscolorchaseindex
lda hscolorchaseindex
sta P5C2
sbc #$02
sta P4C2
sbc #$02
sta P3C2
sbc #$02
sta P2C2
sbc #$02
sta P1C2
hschasecolorsreturn
rts
playhssfx
lda hssfx_lo,x
sta temp1
lda hssfx_hi,x
sta temp2
lda #0
sta temp3
jmp schedulesfx
hssfx_lo
.byte <sfx_hsletterpositionchange, <sfx_hslettertick
hssfx_hi
.byte >sfx_hsletterpositionchange, >sfx_hslettertick
sfx_hsletterpositionchange
.byte $10,$18,$00
.byte $02,$06,$08
.byte $02,$06,$04
.byte $00,$00,$00
sfx_hslettertick
.byte $10,$18,$00
.byte $00,$00,$0a
.byte $00,$00,$00
highscorelabeladjust1
.byte (80-(14*2)-(SCORESIZE*2)),(80-(16*2)-(SCORESIZE*2)),(80-(16*2)-(SCORESIZE*2)),(80-(16*2)-(SCORESIZE*2))
highscorelabeladjust2
.byte (80+(14*2)-(SCORESIZE*2)),(80+(16*2)-(SCORESIZE*2)),(80+(16*2)-(SCORESIZE*2)),(80+(16*2)-(SCORESIZE*2))
scorevarlo
.byte <(score0+((6-SCORESIZE)/2)),<(score0+((6-SCORESIZE)/2)),<(score1+((6-SCORESIZE)/2)),<(score1+((6-SCORESIZE)/2))
scorevarhi
.byte >(score0+((6-SCORESIZE)/2)),>(score0+((6-SCORESIZE)/2)),>(score1+((6-SCORESIZE)/2)),>(score1+((6-SCORESIZE)/2))
ifnconst HSNOLEVELNAMES
highscoredifficultytextlo
.byte <easylevelname, <mediumlevelname, <hardlevelname, <expertlevelname
highscoredifficultytexthi
.byte >easylevelname, >mediumlevelname, >hardlevelname, >expertlevelname
ifnconst HSCUSTOMLEVELNAMES
highscoredifficultytextlen
.byte 22, 30, 26, 24
easylevelname
.byte $04,$00,$12,$18,$1d,$0b,$04,$15,$04,$0b,$1d,$07,$08,$06,$07,$1d,$12,$02,$0e,$11,$04,$12
mediumlevelname
.byte $08,$0d,$13,$04,$11,$0c,$04,$03,$08,$00,$13,$04,$1d,$0b,$04,$15,$04,$0b,$1d,$07,$08,$06,$07,$1d,$12,$02,$0e,$11,$04,$12
hardlevelname
.byte $00,$03,$15,$00,$0d,$02,$04,$03,$1d,$0b,$04,$15,$04,$0b,$1d,$07,$08,$06,$07,$1d,$12,$02,$0e,$11,$04,$12
expertlevelname
.byte $04,$17,$0f,$04,$11,$13,$1d,$0b,$04,$15,$04,$0b,$1d,$07,$08,$06,$07,$1d,$12,$02,$0e,$11,$04,$12
else
include "7800hsgamediffnames.asm"
endif ; HSCUSTOMLEVELNAMES
else
HSHIGHSCOREStext
.byte $07,$08,$06,$07,$1d,$12,$02,$0e,$11,$04,$12
endif ; HSNOLEVELNAMES
highscorelabeltextlo
.byte <player0label, <player1label, <player2label, <player2label
highscorelabeltexthi
.byte >player0label, >player1label, >player2label, >player2label
player0label
.byte $0f,$0b,$00,$18,$04,$11,$1d,$12,$02,$0e,$11,$04,$1a,$1d,$1d
player1label
.byte $0f,$0b,$00,$18,$04,$11,$1d,$22,$1d,$12,$02,$0e,$11,$04,$1a
player2label
.byte $0f,$0b,$00,$18,$04,$11,$1d,$23,$1d,$12,$02,$0e,$11,$04,$1a
ifconst HSGAMENAMELEN
HSGAMENAMEtable
include "7800hsgamename.asm"
endif
ifconst HSGAMERANKS
include "7800hsgameranks.asm"
highscoreranklabel
.byte $11,$00,$0d,$0a,$1a
endif
;ensure our table doesn't wrap a page...
if ((<*)>251)
align 256
endif
hsgameslotnumbers
.byte 33,34,35,36,37
endif
loaddifficultytable
lda gamedifficulty
and #$03 ; ensure the user hasn't selected an invalid difficulty
sta gamedifficulty
cmp hsdifficulty; check game difficulty is the same as RAM table
bne loaddifficultytablecontinue1
rts ; this high score difficulty table is already loaded
loaddifficultytablecontinue1
lda gamedifficulty
sta hsdifficulty
;we need to check the device for the table
lda hsdevice
bne loaddifficultytablecontinue2
; there's no save device. clear out this table.
jmp cleardifficultytablemem
loaddifficultytablecontinue2
lda hsdevice
and #1
beq memdeviceisntHSC
jmp loaddifficultytableHSC
memdeviceisntHSC
jmp loaddifficultytableAVOX
savedifficultytable
;*** we need to check wich device we should use...
lda hsdevice
bne savedifficultytablerealdevice
rts ; its a ram device
savedifficultytablerealdevice
and #1
beq savememdeviceisntHSC
jmp savedifficultytableHSC
savememdeviceisntHSC
jmp savedifficultytableAVOX
savedifficultytableAVOX
; the load call already setup the memory structure and atarivox memory location
jsr savealoadedHSCtablecontinue
savedifficultytableAVOXskipconvert
lda #HSIDHI
sta eeprombuffer
lda #HSIDLO
sta eeprombuffer+1
lda hsdifficulty
sta eeprombuffer+2
lda #32
jsr AVoxWriteBytes
rts
savedifficultytableHSC
;we always load a table before reaching here, so the
;memory structures from the load should be intact...
ldy hsgameslot
bpl savealoadedHSCtable
rts
savealoadedHSCtable
lda HSCGameDifficulty,y
cmp #$7F
bne savealoadedHSCtablecontinue
jsr initializeHSCtableentry
savealoadedHSCtablecontinue
;convert our RAM table to HSC format and write it out...
ldy #0
ldx #0
savedifficultytableScores
lda HSRAMInitials,x
sta temp3
lda HSRAMInitials+1,x
sta temp4
lda HSRAMInitials+2,x
sta temp5
jsr encodeHSCInitials ; takes 3 byte initials from temp3,4,5 and stores 2 byte initials in temp1,2
lda temp1
sta (HSGameTableLo),y
iny
lda temp2
sta (HSGameTableLo),y
iny
lda HSRAMScores,x
sta (HSGameTableLo),y
iny
lda HSRAMScores+1,x
sta (HSGameTableLo),y
iny
lda HSRAMScores+2,x
sta (HSGameTableLo),y
iny
inx
inx
inx ; +3
cpx #15
bne savedifficultytableScores
rts
loaddifficultytableHSC
; routine responsible for loading the difficulty table from HSC
jsr findindexHSC
ldy hsgameslot
lda HSCGameDifficulty,y
cmp #$7F
bne loaddifficultytableHSCcontinue
;there was an error. use a new RAM table instead...
jsr initializeHSCtableentry
jmp cleardifficultytablemem
loaddifficultytableHSCcontinue
; parse the data into the HS memory...
ldy #0
ldx #0
loaddifficultytableScores
lda (HSGameTableLo),y
sta temp1
iny
lda (HSGameTableLo),y
sta temp2
jsr decodeHSCInitials ; takes 2 byte initials from temp1,2 and stores 3 byte initials in temp3,4,5
iny
lda (HSGameTableLo),y
sta HSRAMScores,x
lda temp3
sta HSRAMInitials,x
inx
iny
lda (HSGameTableLo),y
sta HSRAMScores,x
lda temp4
sta HSRAMInitials,x
inx
iny
lda (HSGameTableLo),y
sta HSRAMScores,x
lda temp5
sta HSRAMInitials,x
inx
iny
cpx #15
bne loaddifficultytableScores
rts
decodeHSCInitials
; takes 2 byte initials from temp1,2 and stores 3 byte initials in temp3,4,5
; 2 bytes are packed in the form: 22211111 22_33333
lda #0
sta temp4
lda temp1
and #%00011111
sta temp3
lda temp2
and #%00011111
sta temp5
lda temp1
asl
rol temp4
asl
rol temp4
asl
rol temp4
lda temp2
asl