@@ -586,7 +586,7 @@ testCrash:
586
586
beq @dontClearCount
587
587
tax
588
588
ldy lineClearStatsByType-1 ,x
589
- beq @dontClearCount
589
+ bne @dontClearCount
590
590
lda #$0B ; 11 cycles for clearcount 10s place
591
591
adc allegroIndex
592
592
sta allegroIndex
@@ -648,11 +648,24 @@ testCrash:
648
648
clc
649
649
adc allegroIndex ; adds 8 cycles for current piece = 8 (horizontal Z)
650
650
sta allegroIndex
651
- @not8: bcc @randomFactors ; adc above means branch always when entered after it. piece < 8 adds 0 cycles.
651
+ @not8: bcc @palCycles ; adc above means branch always when entered after it. piece < 8 adds 0 cycles.
652
652
lda #$0B ; would be 12 but carry is set. for piece > 8
653
653
adc allegroIndex
654
654
sta allegroIndex
655
+ @palCycles:
656
+ lda palFlag ; if pal, move thresholds for crashes 3467 cycles away
657
+ beq @randomFactors
658
+ sec
659
+ lda cycleCount+1
660
+ sbc #$8B
661
+ sta cycleCount+1
662
+ lda cycleCount
663
+ sbc #$0D
664
+ sta cycleCount
665
+ clc
655
666
@randomFactors:
667
+ lda strictFlag
668
+ bne @noDMA ;for strict crash, do not add random cycles.
656
669
lda oneThirdPRNG ; RNG for which cycle of the last instruction the game returns to
657
670
adc allegroIndex
658
671
sta allegroIndex
@@ -697,6 +710,13 @@ testCrash:
697
710
;confettiB = 30765-31193
698
711
cmp #$74 ;high byte of cycle count is already loaded
699
712
bne @nextSwitch
713
+ lda strictFlag
714
+ beq @normalChecks ;special conditions for "strict" mode. crash on 7423-7442, check red on 7443-7448.
715
+ lda cycleCount+1
716
+ cmp #$23 ;up to 8 cycles could have been added, but weren't, so our low bound is 8 below the typical.
717
+ bcc @nextSwitch ;if too low, exit
718
+ bcs @highBoundary ;otherwise, check high bound and skip check for gap.
719
+ @normalChecks:
700
720
lda cycleCount+1
701
721
cmp #$2B ; minimum crash
702
722
bcc @nextSwitch
@@ -708,19 +728,31 @@ testCrash:
708
728
@continue:
709
729
cmp #$36
710
730
bcc @nextSwitch
731
+ @highBoundary:
711
732
cmp #$49
712
733
bcs @nextSwitch ;between 7436 & 7448
713
734
cmp #$43
714
735
bcc @notRed ;checking if crash is during first crashable instruction
736
+ txa
737
+ lsr ;all odd switches on PAL result in no crash.
738
+ bcs @oddSwitch
739
+ lda palFlag
740
+ bne @nextSwitch ;if PAL, no crash.
741
+ @oddSwitch:
715
742
cpx #$07 ; checking which switch routine is active.
716
- beq @nextSwitch ;continues crashless if sw2
743
+ beq @isPal ;checks version if sw2
717
744
cpx #$03
718
745
bne @notRed ; runs graphics corruption if sw6
719
746
ldx #$FF ; these are normally set by the code it would jump to after NMI.
720
747
ldy #$00
721
748
lda #$81 ; value normally held at this point in sw6
722
749
jsr satanSpawn
723
750
jmp @allegroClear ;allegroClear is basically return, just clears the variable first.
751
+ @isPal:
752
+ lda palFlag
753
+ beq @nextSwitch ;if NTSC, continue, no crash.
754
+ jsr blackBox
755
+ jmp @allegroClear
724
756
@notRed:
725
757
lda #$F0
726
758
sta crashState
@@ -867,6 +899,8 @@ confettiHandler:
867
899
beq @checkForNmi
868
900
jmp confettiHandler
869
901
@infiniteConfetti:
902
+ lda palFlag
903
+ bne @endConfetti ;infinite confetti does not exist on PAL
870
904
lda heldButtons_player1
871
905
adc #$80 ; loading 80 as Y coordinate of confetti text if nothing is held.
872
906
cmp #$80
@@ -876,6 +910,18 @@ confettiHandler:
876
910
sta allegroIndex
877
911
rts
878
912
satanSpawn: ; copied from routine vanilla game's memset_ppu_page_and_more which is no longer present in gym
913
+ lda palFlag
914
+ beq @ntsc
915
+ lda #$00
916
+ sta verticalBlankingInterval
917
+ @checkForNmi:
918
+ lda verticalBlankingInterval ;busyloop
919
+ beq @checkForNmi
920
+ ldx #$FF
921
+ ldy #$00
922
+
923
+ @ntsc:
924
+ lda #$AA
879
925
sta tmp1
880
926
stx tmp2
881
927
sty tmp3
@@ -913,3 +959,41 @@ LAC61: sty PPUDATA
913
959
bne LAC61
914
960
LAC67: ldx tmp2
915
961
rts
962
+ blackBox: ;copied from patchToPpu from original game as it's no longer present in gym
963
+ lda #$00
964
+ sta verticalBlankingInterval
965
+ @checkForNmi:
966
+ lda verticalBlankingInterval ;busyloop
967
+ beq @checkForNmi
968
+ ldy #$00
969
+ @patchAddr:
970
+ lda patchData,y
971
+ sta PPUADDR
972
+ iny
973
+ lda patchData,y
974
+ sta PPUADDR
975
+ iny
976
+ @patchValue:
977
+ lda patchData,y
978
+ iny
979
+ cmp #$FE
980
+ beq @patchAddr
981
+ cmp #$FD
982
+ beq @ret
983
+ sta PPUDATA
984
+ jmp @patchValue
985
+
986
+ @ret: rts
987
+ patchData:
988
+ .byte $22 ,$58 ,$FF ,$FE ,$22 ,$75 ,$FF ,$FF
989
+ .byte $FF ,$FF ,$FF ,$FF ,$FE ,$22 ,$94 ,$FF
990
+ .byte $FF ,$FF ,$FF ,$FF ,$FF ,$FF ,$FF ,$FE
991
+ .byte $22 ,$B4 ,$FF ,$FF ,$FF ,$FF ,$FF ,$FF
992
+ .byte $FF ,$FF ,$FE ,$22 ,$D4 ,$FF ,$FF ,$FF
993
+ .byte $FF ,$FF ,$FF ,$FF ,$FF ,$FE ,$22 ,$F4
994
+ .byte $FF ,$FF ,$FF ,$FF ,$FF ,$FF ,$FF ,$FF
995
+ .byte $FE ,$23 ,$14 ,$FF ,$FF ,$FF ,$FF ,$FF
996
+ .byte $FF ,$FF ,$FF ,$FE ,$23 ,$34 ,$FF ,$FF
997
+ .byte $FF ,$FF ,$FF ,$FF ,$FF ,$FF ,$FE ,$22
998
+ .byte $CA ,$46 ,$47 ,$FE ,$22 ,$EA ,$56 ,$57
999
+ .byte $FD
0 commit comments