-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmainBank2.asm
More file actions
4031 lines (3845 loc) · 171 KB
/
mainBank2.asm
File metadata and controls
4031 lines (3845 loc) · 171 KB
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
; following is needed for VIDE
; to replace "vars" in this bank with values from the other bank
; #genVarlist# varFrom0
;
CURRENT_BANK EQU 2 ;
Bank 2
include "commonGround.i"
optionsMenu
db $40, $c0 , "DIFFICULTY",$80
afterDifficult
db $30, $c0 , "MODE",$80
db $20, $c0 , "CALIBRATE",$80
db $10, $c0 , "RESET",$80
db $00, $c0 , "SECRETS",$80
afterSecrets
db -$40, $c0 , "BACK",$80
dw 0
OPTION_DIFFICULTY = 0
OPTION_MODE = 1
OPTION_CALIBRATE = 2
OPTION_RESET = 3 ;
OPTION_SECRETS = 4 ;
OPTION_BACK = 5
MAX_OPTION = OPTION_BACK
dw dif_hc
difficultyStrings2
dw dif_e
dw dif_n
dw dif_h
dw dif_i
dw dif_s
dif_e
db "EASY", $80
dw 0
dif_n
db "NORMAL", $80
dw 0
dif_h
db "HARD", $80
dw 0
dif_i
db "ABSURD", $80
dw 0
dif_s
db "MANIAC", $80
dw 0
dif_hc
db "HARDCORE", $80
dw 0
if TIMER_LEVEL
dif_tt
db "TIME TRIAL", $80
dw 0
endif
;
;***************************************************************************
; CODE SECTION
;***************************************************************************
main_0_0: ;#isfunction
main00
clr isDemoMode
; init VecVox
if TEST_VOX = 1
REPLACE_1_2_voxInit_varFromIRQ0_1
ldx #0 ;voxInit
jsr jsrBank0_fromBank2_Shift
endif
lda #DEFAULT_DIFFICULTY
sta difficulty
; if not done before -> do calibration -> than a warm reset
lda #%10110011
sta random_seed
lda #%01100111
sta random_seed2
lds #MY_STACK ; CBFC correct the stack to default address (Overwriting IRQ vectors etc)
lda #1
sta current_button_state
sta last_button_state
clr additionalFlags
REPLACE_1_2_checkFlash_varFromIRQ0_1
ldx #0 ;checkFlash
jsr jsrBank0_fromBank2_Shift
if VECFEVER = 1
else
lda flashAvailable
anda #FLASH_AVAILABLE_BIT
bne doFlashInit
REPLACE_1_2_displayFlashError_varFromIRQ0_12
ldx #0 ;displayFlashError
jmp jmpBankIRQ0Shift
doFlashInit
REPLACE_1_2_initFlash_varFromIRQ0_1
ldx #0 ;initFlash
jsr jsrBank0_fromBank2_Shift
endif
clr joystickDir
fromGameOver
lds #MY_STACK ; CBFC correct the stack to default address (Overwriting IRQ vectors etc)
lda #1
sta current_button_state
sta last_button_state
lda diverseFlags
ora #%00000010
sta diverseFlags
againB1
JSR Read_Btns ; get button status
ldb $C811 ; button pressed - any
andb #$ff
bne againB1
lda additionalFlags
anda #BIT_RAN_CALIBRATION
lbne main01 ; calibration was already done!
REPLACE_1_2_showFirstHelp_varFromIRQ0_1
ldx #0 ;showFirstHelp
jmp jmpBankIRQ0Shift
;***************************************************************************
LoadDisk
db -$42, $01, $44, hi(SMVB_continue_single), lo(SMVB_continue_single)
db $00, $01, $10, hi(SMVB_startDraw_single), lo(SMVB_startDraw_single)
db -$0A, $01, $00, hi(SMVB_continue3_single), lo(SMVB_continue3_single)
db $00, $01, -$10
db $0A, $01, $00
db -$0C, $01, -$4F, hi(SMVB_startMove_double), lo(SMVB_startMove_double)
db $00, $01, $5B, hi(SMVB_startDraw_double), lo(SMVB_startDraw_double)
db $5B, $01, $00, hi(SMVB_continue_double), lo(SMVB_continue_double)
db $00, $01, -$5B, hi(SMVB_continue_double), lo(SMVB_continue_double)
db -$5B, $01, $00, hi(SMVB_continue_double), lo(SMVB_continue_double)
db $57, $01, $37, hi(SMVB_startMove_double), lo(SMVB_startMove_double)
db $00, $01, $18, hi(SMVB_startDraw_single), lo(SMVB_startDraw_single)
db -$30, $01, $00, hi(SMVB_continue3_single), lo(SMVB_continue3_single)
db $00, $01, -$18
db $30, $01, $00
db $07, $01, $23, hi(SMVB_startMove_single), lo(SMVB_startMove_single)
db -$3F, $01, $00, hi(SMVB_startDraw_single), lo(SMVB_startDraw_single)
db $00, $01, -$69, hi(SMVB_continue2_single), lo(SMVB_continue2_single)
db $3F, $01, $00
db $40, $00, $00, hi(SMVB_lastDraw_rts), lo(SMVB_lastDraw_rts)
;***************************************************************************
beQuiet
ldd #0
std sfx_pointer_3
std sfx_pointer_2
std sfx_pointer_1
CLR Vec_Music_Flag ; no music is playing ->0 (is placed in rottist!
JSR Init_Music_Buf ; shadow regs
jmp Do_Sound ; ROM function that does the sound playing, here used to clear all regs
; rts
exitOptions
lda difficulty
cmpa #HARDCORE
bne notHardcore
lda #$80
sta difficulty
notHardcore
jmp fromGameOver
doOptions
if MAX_LEVEL_SELECT_ALLOWED = 1
lda #100
sta maxLevelReached
endif
bsr beQuiet
clr optionDir
LDA #1 ;
STA Vec_Joy_Mux_1_X ;
LDA #3 ;
STA Vec_Joy_Mux_1_Y ;
lda #OPTION_BACK ;4 ; default on BACK
sta selectedOption
optionsLoop
lda selectedOption
cmpa #OPTION_DIFFICULTY
bne noJoy
lda Vec_Joy_1_X
beq noLevelChange
bmi levelDec
levelInc
inc chosenStartLevel
lda chosenStartLevel
cmpa maxLevelReached
blo noLevelChange
lda maxLevelReached
sta chosenStartLevel
bra noLevelChange
levelDec
dec chosenStartLevel
lda chosenStartLevel
bpl noLevelChange
clr chosenStartLevel
noLevelChange
noJoy
JSR Read_Btns ; get button status
lda $C811
lbeq noButtonPressedOptions
if ADDITIONAL_INPUT = 1
bita #2
bne goleft_O
bita #4
bne goRight_O
bra JoyDone_O1
goleft_O
ldb #-10
bra JoyDone_O
goRight_O
ldb #10
JoyDone_O
endif
stb Vec_Joy_1_Y
; do not reakt on buttons that we just mapped
jmp noButtonPressedOptions_buttonwaspressed
JoyDone_O1
bita #1
beq noOptionHelp
REPLACE_1_2_showOptionHelp_varFromIRQ0_1
ldx #0 ;showOptionHelp
jmp jmpBankIRQ0Shift
noOptionHelp
bita #2
beq noMH
jsr beQuiet
jmp displayTitlePic1
noMH
lda selectedOption
cmpa #OPTION_BACK
lbeq exitOptions
cmpa #OPTION_RESET
lbeq doReset
cmpa #OPTION_SECRETS
lbeq doSecrets
cmpa #OPTION_CALIBRATE
lbeq doCalib0
cmpa #OPTION_MODE
lbeq doMode
cmpa #OPTION_DIFFICULTY
bne notDifficultOption
inc difficulty
lda difficulty
anda #$f
cmpa #SUPER_IMPOSSIBLE
bls diffOc
lda difficulty
anda #$f0
sta difficulty
bra difOk
diffOc
cmpa #SUPER_IMPOSSIBLE
bne notSuperImpossible
ldb achievements + 2
bitb #ACHIEVEMENT_FLAG_BYTE3_BLADEMASTER_RANK2
bne difOk
ldb difficulty
andb #$f0
stb difficulty
notSuperImpossible
cmpa #IMPOSSIBLE
bne notImpossible
ldb achievements + 2
bitb #ACHIEVEMENT_FLAG_BYTE3_BLADEMASTER_RANK3
bne difOk
ldb difficulty
andb #$f0
stb difficulty
notImpossible
cmpa #HARD
bne notHard
ldb achievements + 2
bitb #ACHIEVEMENT_FLAG_BYTE3_BLADEMASTER_RANK4
bne difOk
ldb difficulty
andb #$f0
stb difficulty
notHard
cmpa #NORMAL
bne notNormal
ldb achievements + 2
bitb #ACHIEVEMENT_FLAG_BYTE3_BLADEMASTER_RANK5
bne difOk
ldb difficulty
andb #$f0
stb difficulty
notNormal
cmpa #EASY
bne notEasy
ldb difficulty
andb #$f0
addb #SUPER_IMPOSSIBLE
stb difficulty
notEasy
difOk
notDifficultOption
noButtonPressedOptions
; jsr Joy_Digital
jsr JoyDigitalHorizontal00
jsr JoyDigitalVertical00
noButtonPressedOptions_buttonwaspressed
lda Vec_Joy_1_Y
beq noChangeSelPos
bmi selPosAdvance
lda optionDir
bmi noChangeSelPos2
lda selectedOption
if ADDITIONAL_INPUT = 1
beq toggleInput
else
beq noChangeSelPos
endif
dec selectedOption
lda #-1
sta optionDir
bra noChangeSelPos2
if ADDITIONAL_INPUT = 1
toggleInput
REPLACE_1_2_toggleInputOption_varFromIRQ0_1
ldx #0 ;toggleInputOption
jmp jmpBankIRQ0Shift
endif
doMode
ldb difficulty
bpl selectHardcore
; here either negative
; or != 0 positive
if TIMER_LEVEL = 1
bmi makeTimerTrial
makeNormal
andb #$f
bra stroeDif2
makeTimerTrial
andb #$f
orb #%01000000
bra stroeDif2
endif
andb #$f
stroeDif2
stb difficulty
bra noChangeSelPos2
selectHardcore
orb #$80
stb difficulty
bra noChangeSelPos2
selPosAdvance
lda optionDir
cmpa #1
beq noChangeSelPos2
lda selectedOption
cmpa #MAX_OPTION
beq saveGameCheck ; noChangeSelPos
inc selectedOption
lda #1
sta optionDir
bra noChangeSelPos2
saveGameCheck
if RECORD_GAME_DATA = 1
bra doNotLoadAfterAll
endif
lda flashAvailable
anda # SAVEGAME_AVAILABLE_BIT ; no game available
lbeq noChangeSelPos
; save game is availabel and "asked for
REPLACE_1_2_showLoadMessage_varFromIRQ0_54
ldx #0 ;showLoadMessage
jsr jsrBank0_fromBank2_Shift
cmpu #3 ; yes
bne doNotLoadAfterAll
if ALLOW_SAVING = 1
if VECFEVER = 1
REPLACE_1_2_loadGameFromVecFever_varFromIRQ1_1
ldx #0 ;loadGameFromVecFever
jmp jmpBankIRQ1Shift
else
REPLACE_1_2_loadGameFromFlash_varFromIRQ0_123
ldx #0 ;loadGameFromFlash
jmp doShiftIRQ
endif
endif
doNotLoadAfterAll
noChangeSelPos
clr optionDir
noChangeSelPos2
if IS_VIA_FAULTY_RESISTENT = 1
JSR my_wait_recal ;Wait_Recal
else
JSR Wait_Recal
endif
ldd #$8100
std <VIA_port_b
deca
sta <VIA_port_b
ldb >calibrationValue16
lda additionalFlags
anda #%00000001
bne buzzVectrex16
lda #$82
std <VIA_port_b
ldd #$83FF ; 2 cycles
stb <VIA_port_a
sta <VIA_port_b
bra calibDone16
buzzVectrex16
lda #$82
std <VIA_port_b
ldd #$83FF ; 2 cycles
stb <VIA_port_a
nop 2
sta <VIA_port_b
calibDone16
jsr Intensity_3F
lda #16 ;OBJECT_SCALE
sta stringScale
clr currentPrintedOption
; ------ print Menu Start
ldu #optionsMenu
printVectorStringList7
modeCheckDone
lda currentPrintedOption
cmpa selectedOption
bne notSelected1
jsr Intensity_5F
notSelected1
lda gameScale
sta <VIA_t1_cnt_lo
ldd ,u++
jsr printOneVectorString_D
_ZERO_VECTOR_BEAM
lda currentPrintedOption
cmpa selectedOption
bne notSelected2
jsr Intensity_3F
notSelected2
inc currentPrintedOption
ldd ,u
bne printVectorStringList7
optionPrintDone
; output new MODE
_ZERO_VECTOR_BEAM
lda gameScale
sta <VIA_t1_cnt_lo
ldu #dif_n
lda difficulty
bpl notHardcoreMode
ldu #dif_hc
notHardcoreMode
if TIMER_LEVEL
lda difficulty
anda #%01000000
beq noTimeTrial
ldu #dif_tt
noTimeTrial
endif
ldd #$3010
bsr printOneVectorString_D
_ZERO_VECTOR_BEAM
lda gameScale
sta <VIA_t1_cnt_lo
lda difficulty
anda #0x0f
lsla
ldu #difficultyStrings2
ldu a,u
ldd #$4010
bsr printOneVectorString_D
_ZERO_VECTOR_BEAM
lda gameScale
sta <VIA_t1_cnt_lo
ldb chosenStartLevel
incb
; change with Joy left right
sex
ldu #levelConversionString
jsr wordToDecString
leau 2,u
jsr leadingZeroToSpace
ldd #$4095
ldu #levelConversionString +2
bsr printOneVectorString_D
_ZERO_VECTOR_BEAM
if ALLOW_SAVING = 1
lda flashAvailable
anda # SAVEGAME_AVAILABLE_BIT ; no game available
lbeq optionsLoop
lda gameScale
sta <VIA_t1_cnt_lo
ldd #$a8c8
if IS_VIA_FAULTY_RESISTENT = 1
jsr my_Moveto_d ; Moveto_d
else
JSR Moveto_d
endif
lda #7
sta <VIA_t1_cnt_lo
ldu #LoadDisk
jsr SMVB_drawSmart
endif
; ------ print Menu End
jmp optionsLoop
; in U pointer to string
; in D position
printOneVectorString_D
MY_MOVE_TO_D_START_NO_SHIFT
lda stringScale
sta <VIA_t1_cnt_lo
ldy #Alphabet-64 ; font starts at 32, *2 because of 16 bit pointer
lda #-1
MY_MOVE_TO_B_END
sta <VIA_port_a
clra
sta <VIA_port_b
ldb ,u+
nextLetter2_72_2
lslb ; must be d, because otherwise it could be "negative"
ldx d,y
Draw_VLp_lessGap7
ldb ,u+
bpl nextLetter2_72_2
donePrintVectorString3_72
rts
if IS_VIA_FAULTY_RESISTENT = 1
my_Moveto_d
myMovetod
MY_MOVE_TO_D_START
MY_MOVE_TO_B_END
rts
myWaitRecal
endif
my_wait_recal
MY_WAIT_RECAL
rts
doCalib0
REPLACE_1_2_initCalibration1_varFromIRQ0_1 ; bank 1 replace
ldx #0 ; initCalibration1
jmp jmpBankIRQ0Shift
;;main_01
main01
lda #25 ; wait 1/2 second until button reacts again
sta buttonWait
jsr beQuiet
jsr initTitleRAM
lda additionalFlags
anda #BIT_TITLE_SEEN
bne noTitleTitle
displayTitlePic1
if SKIP_TITLE_SCREEN = 1
else
REPLACE_1_2_displayTitlePicture_varFromIRQ1_1 ; bank 1 replace
ldx #0 ; displayTitlePicture
jsr jsrBank1_fromBank2_T1
endif
noTitleTitle
lda #1
sta songLoop
REPLACE_1_2_titleMusic_varFromIRQ1_1
ldu #0 ; titleMusic
REPLACE_1_2_PLYINIT_varFromIRQ1_1
ldx #0 ; PLYINIT
jsr jsrBank1_fromBank2_T1
REPLACE_1_2_initAllTitle_varFromIRQ0_1
ldx #0 ; initAllTitle
jsr jsrBank0_fromBank2_T1
Titleloop1
title_0_0 ;#isfunction
RANDOM_A ; random number of random inits (till player hits a button)
RANDOM_A2
clra
dec buttonWait
bpl bwok
clr buttonWait
bwok
sta <VIA_shift_reg
if IS_VIA_FAULTY_RESISTENT = 1
JSR my_wait_recal ;Wait_Recal
else
JSR Wait_Recal
endif
REPLACE_1_2_playAKSMusic_varFromIRQ1_1
ldx #0 ; playAKSMusic
jsr jsrBank1_fromBank2_T1
JSR Read_Btns ; get button status
tst buttonWait
bne doNotStartGame
if ADDITIONAL_INPUT = 1
ldb additionalFlags
andb #BIT_INPUT_VARIANT
beq defaultTitleInput
ldb $C811 ; button pressed - any
andb #$f ; is button 1
beq doNotStartGame
cmpb #1
lbeq doStartGame
cmpb #2
lbeq doOptions
cmpb #4
lbeq HighScoreTest_Start
cmpb #8
lbeq doAchiements
defaultTitleInput
endif
lda joystickDir
beq doNotStartGame2
ldb $C811 ; button pressed - any
andb #$f ; is button 1
beq doNotStartGame
cmpa #RIGHT
lbeq doOptions ; doCalib0
cmpa #LEFT
lbeq doAchiements ;majorHavocB2
cmpa #UP
beq doStartGame
cmpa #DOWN
lbeq HighScoreTest_Start
; if no direction, but a button was pressed - display help
doNotStartGame2
ldb $C811 ; button pressed - any
andb #$7 ; is button 1
beq doNotStartGame
REPLACE_1_2_showTitleHelp_varFromIRQ0_1
ldx #0 ;showTitleHelp
jmp jmpBankIRQ0Shift
doStartGame
REPLACE_1_2_readyPlayerOne_varFromIRQ0_1 ; bank 1 replace
ldx #0 ;readyPlayerOne
jsr jsrBank0_fromBank2_T1
REPLACE_1_2_main11_varFrom1_1 ; bank 1 replace
ldx #0 ; main11
jmp jmpBank1X
doNotStartGame
REPLACE_1_2_oneVBTitleStep_varFromIRQ0_1
ldx #0 ; oneVBTitleStep
jsr jsrBank0_fromBank2_Shift
jmp title_0_0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Button 1-4
; returns in B the current button state in relation to last button state
; bit 0 represents current button state
; bit 1 last button state
; 1 = pressed
; 0 = not pressed
; in a state of current button 1-4
; bit == 0 = pressed
; bit == 1 = not pressed
; a = xxxx 0000
; 4321 - buttons
if ADDITIONAL_INPUT = 1
getButtonState: ;#isfunction
; save last states, and shift the old current one bit
; query buttons from psg
LDA #$0E ;Sound chip register 0E to port A
STA <VIA_port_a
LDD #$9981 ;sound BDIR on, BC1 on, mux off
sta <VIA_port_b ; VIA Port B = 99, mux disabled, RAMP disabled, BC1/BDIR = 11 (Latch address)
NOP ;pause
STB <VIA_port_b ; VIA Port B = 81, mux disabled, RAMP disabled, BC1/BDIR = 00 (PSG inactive)
CLR <VIA_DDR_a ;DDR A to input
LDD #$8981 ;sound BDIR off, BC1 on, mux off
STA <VIA_port_b ; VIA Port B = 89, mux disabled, RAMP disabled, BC1/BDIR = 01 (PSG Read)
NOP ;pause
LDA <VIA_port_a ;Read buttons
STB <VIA_port_b ; VIA Port B = 81, mux disabled, RAMP disabled, BC1/BDIR = 00 (PSG inactive)
LDB #$FF
STB <VIA_DDR_a ;DDR A to output
; query done, in A current button state directly from psg
if RECORD_GAME_DATA = 1
tst saveState
bne loadButtonData
tfr a,b
stb buttonTmp
REPLACE_1_2_putOneInputByte_varFromIRQ0_1
ldx #0 ;putOneInputByte
jsr jsrBank0_fromBank2_T1
lda buttonTmp
bra contButton
loadButtonData
REPLACE_1_2_getOneInputByte_varFromIRQ0_1
ldx #0 ;getOneInputByte
jsr jsrBank0_fromBank2_T1
tfr b,a
contButton
endif
ldb additionalFlags
andb #BIT_INPUT_VARIANT
beq defaultInput_B ; beq
;;;;;;;;;;;;;;;;;
; conversion start
;;;;;;;;;;;;;;;;;
; insert x,y movement for button 2,3
; map all 4 to button 3 (pause)
; map button 1 to button 2 bomb
clrb
bita #2
beq goleft
bita #4
beq goRight
bra JoyDone_b
goleft
ldb #-10
bra JoyDone_b
goRight
ldb #10
JoyDone_b
stb Vec_Joy_1_X
negb
stb Vec_Joy_1_Y
tfr a,b
ora #1+2+4 ; delete button 1+2+3
bitb #1 ; button 1
bne noSuperbomb_b
anda #$f-2; add superbomb
noSuperbomb_b
andb #2+4+8+1 ; all four buttons
bne noPauseMode_b
anda #$f-4 ; add pause mode
noPauseMode_b
;;;;;;;;;;;;;;;;;
; conversion end
;;;;;;;;;;;;;;;;;
ldb current_button_state
stb last_button_state
lslb
anda #$f ; only joystick 1 button 4
bita #$8;8
bne noButtonPressed
incb
bra noButtonPressed
defaultInput_B
ldb current_button_state
stb last_button_state
lslb
anda #$f ; only joystick 1
cmpa #$0f
beq noButtonPressed
incb
noButtonPressed:
stb current_button_state
andb #3
rts
else
getButtonState: ;#isfunction
; save last states, and shift the old current one bit
; query buttons from psg
LDA #$0E ;Sound chip register 0E to port A
STA <VIA_port_a
LDD #$9981 ;sound BDIR on, BC1 on, mux off
sta <VIA_port_b ; VIA Port B = 99, mux disabled, RAMP disabled, BC1/BDIR = 11 (Latch address)
NOP ;pause
STB <VIA_port_b ; VIA Port B = 81, mux disabled, RAMP disabled, BC1/BDIR = 00 (PSG inactive)
CLR <VIA_DDR_a ;DDR A to input
LDD #$8981 ;sound BDIR off, BC1 on, mux off
STA <VIA_port_b ; VIA Port B = 89, mux disabled, RAMP disabled, BC1/BDIR = 01 (PSG Read)
NOP ;pause
LDA <VIA_port_a ;Read buttons
STB <VIA_port_b ; VIA Port B = 81, mux disabled, RAMP disabled, BC1/BDIR = 00 (PSG inactive)
LDB #$FF
STB <VIA_DDR_a ;DDR A to output
; query done, in A current button state directly from psg
if RECORD_GAME_DATA = 1
tst saveState
bne loadButtonData
tfr a,b
stb buttonTmp
REPLACE_1_2_putOneInputByte_varFromIRQ0_1
ldx #0 ;putOneInputByte
jsr jsrBank0_fromBank2_T1
lda buttonTmp
bra contButton
loadButtonData
REPLACE_1_2_getOneInputByte_varFromIRQ0_1
ldx #0 ;getOneInputByte
jsr jsrBank0_fromBank2_T1
tfr b,a
contButton
endif
ldb current_button_state
stb last_button_state
lslb
anda #$f ; only joystick 1
cmpa #$0f
beq noButtonPressed
incb
noButtonPressed:
stb current_button_state
andb #3
rts
endif
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
JoyDigitalHorizontal00 ;#isfunction
Joy_Digital_horizontal_0_0
if ADDITIONAL_INPUT = 1
ldb additionalFlags
andb #BIT_INPUT_VARIANT
beq defaultInput_J ; beq
ldb current_button_state
pshs b
jsr getButtonState
puls b
stb current_button_state
bra contInput_J
defaultInput_J
endif
QUERY_JOYSTICK_HORIZINTAL
contInput_J
if RECORD_GAME_DATA = 1
tst saveState
bne loadJoyData
ldb Vec_Joy_1_X
stb buttonTmp
REPLACE_1_2_putOneInputByte_varFromIRQ0_2
ldx #0 ;putOneInputByte
jsr jsrBank0_fromBank2_T1
ldb buttonTmp
stb Vec_Joy_1_X
rts
loadJoyData
REPLACE_1_2_getOneInputByte_varFromIRQ0_2
ldx #0 ;getOneInputByte
jsr jsrBank0_fromBank2_T1
ldb buttonTmp
stb Vec_Joy_1_X
endif
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
JoyDigitalVertical00 ;#isfunction
Joy_Digital_vertical_0_0
QUERY_JOYSTICK_VERTICAL
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
adjustShotDamage
ReturnFromRankCheck
ADJUST_SHOT_DAMAGE
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
msRating
db $40, $a0, "RATING:", $80
dw 0
DodgerResultListSnail
db -$38, $a0, "100 MONEY ", $80
db $10, $a0, "SNAIL", $80
db -$20, $a0, "1000 BONUS", $80
dw 0
DodgerResultListTurtle
db -$38, $a0, "200 MONEY ", $80
db $10, $a0, "TURTLE", $80
db -$20, $a0, "2000 BONUS", $80
dw 0
DodgerResultListNormal
db -$38, $a0, "500 MONEY ", $80
db $10, $a0, "BORING", $80
db -$20, $a0, "5000 BONUS", $80
dw 0
DodgerResultListRABBIT
db -$38, $a0, "1000 MONEY", $80
db $10, $a0, "RABBIT", $80
db -$20, $a0, "50000 BONUS", $80
dw 0
DodgerResultListFalcon
db -$38, $a0, "5000 MONEY", $80
db $10, $a0, "FALCON", $80
db -$20, $a0, "100000 BONUS", $80
dw 0
DodgerResultDiamond
db -$38, $a0, "NO MONEY ", $80
db $10, $a0, "DIAMOND CHASER", $80
db -$20, $a0, "NO BONUS", $80
dw 0
DodgerResultListBad
db $40, $a0, "MINESTORM!",$80
db $10, $a0, "MISSION ABORTED",$80
dw 0
dodgeResultStringPointer
dw DodgerResultListSnail
dw DodgerResultListTurtle
dw DodgerResultListNormal
dw DodgerResultListRABBIT
dw DodgerResultListFalcon
dw DodgerResultDiamond
displayMinestormResult00 ;#isfunction
displayMinestormResult_0_0
jsr Reset0Ref
jsr Intensity_3F
lda #STRING_SCALE
sta stringScale
tst dodgerGotKilled
beq dodgerNotKilledDisplay
ldu #DodgerResultListBad
bra nextDodgerResultString
dodgerNotKilledDisplay
ldu #msRating
jsr printVectorStringList
lda dodgeResult
lsla
ldu #dodgeResultStringPointer
ldu a,u
lda isDiamondRun
bne isDiamondRunNoMoney
lda difficulty
bpl notHardcoreMine
isDiamondRunNoMoney
leau 13,u ; size of money - minestorm in hardcore receives no money!
notHardcoreMine
nextDodgerResultString
jmp printVectorStringList
displaySuperDiamondsExtro
jsr Reset0Ref
; display PERFECT
lda #STRING_SCALE
sta stringScale
ldu #DiamondsExtroStrings
jmp printVectorStringList
DiamondsExtroStrings
db $10, $a8, "100000 POINTS", $80
dw 0
displaySuperDiamondsIntro ;#isfunction
jsr Reset0Ref
lda #STRING_SCALE
sta stringScale
ldu #DiamondsIntoStrings
jmp printVectorStringList
DiamondsIntoStrings
db $10, $a8, "SUPER DIAMOND!", $80
dw 0
calibTest
db $40,$d0, "STRAIGHTEN",$80