forked from KatDevsGames/z3randomizer
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathflipperkill.asm
137 lines (117 loc) · 3.42 KB
/
flipperkill.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
;================================================================================
; Fake Flippers Softlock Fix
;--------------------------------------------------------------------------------
FlipperKill:
PHP
LDA $5D : CMP #$04 : BNE .done ; skip if we're not swimming
LDA FlippersEquipment : BNE .done ; skip if we have the flippers
LDA $7F5001 : BEQ .done ; skip if we're not marked in danger for softlock
LDA $8A : CMP $7F5098 : BEQ .done ; skip if we're on the same screen we entered the water on
;JSL.l KillFairies ; take away fairies
LDA IgnoreFaeries : ORA.b #$04 : STA IgnoreFaeries
LDA.b #$00 : STA CurrentHealth ; kill link
LDA.b #$00 : STA $7F5001 ; mark fake flipper softlock as impossible
.done
PLP
LDA CurrentHealth ; thing we wrote over
RTL
;--------------------------------------------------------------------------------
IgnoreFairyCheck:
LDX.b #$00 ; thing we wrote over
LDA IgnoreFaeries : BIT.b #$04 : BEQ .normal
AND.b #$FB : STA IgnoreFaeries ; clear ignore fairy flag
LDA.b #$F0 ; set check to invalid entry
RTL
.normal
LDA.b #$06 ; set check to fairy
RTL
;--------------------------------------------------------------------------------
;KillFairies:
; LDA BottleContentsOne : CMP #$06 : BNE +
; LDA #$02 : STA BottleContentsOne
; + LDA BottleContentsTwo : CMP #$06 : BNE +
; LDA #$02 : STA BottleContentsTwo
; + LDA BottleContentsThree : CMP #$06 : BNE +
; LDA #$02 : STA BottleContentsThree
; + LDA BottleContentsFour : CMP #$06 : BNE +
; LDA #$02 : STA BottleContentsFour
; +
;RTL
;--------------------------------------------------------------------------------
FlipperReset:
JSL $0998E8 ; AddTransitionSplash
LDA #$00 : STA $7F5001 ; mark fake flipper softlock as impossible
.done
RTL
;--------------------------------------------------------------------------------
FlipperFlag:
LDA $5D : CMP #$04 : BNE .done ; skip if we're not swimming
LDA FlippersEquipment : BNE .safe ; skip if we have the flippers
LDA #$01 : STA $7F5001 ; mark fake flipper softlock as possible
BRA .done
.safe
LDA #$00 : STA $7F5001 ; mark fake flipper softlock as impossible
.done
RTL
;--------------------------------------------------------------------------------
RegisterWaterEntryScreen:
PHA
LDA $8A : STA $7F5098 ; store ow index
PLA
RTL
;--------------------------------------------------------------------------------
MysteryWaterFunction: ; *$3AE54 ALTERNATE ENTRY POINT
LDA.b #$20 : STA $02E2
STZ $037B
STZ $55
STZ $0360
RTL
;--------------------------------------------------------------------------------
;===================================================================================================
; More elegant solution
;===================================================================================================
protectff:
LDA.l AllowAccidentalMajorGlitch
BEQ .yes_protect
RTL
.yes_protect
REP #$30
LDA.b $20
AND.w #$1E00
ASL
ASL
ASL
STA.b $06
LDA.b $22
AND.w #$1E00
ORA.b $06
XBA
LSR
TAX
SEP #$30
; Remove dark world bit
; in game table that converts coordinates to actual screen ID
; special case for other areas
LDA.b $8A
BMI .special_overworld
AND.b #$3F
CMP.l $02A4E3,X
BEQ ++
.protect
LDA.b #$15
STA.b $5D
STZ.b $2E
STZ.b $67
LDA.b #$02
STA.b $2F
STZ.w $0112
STZ.w $02E4
STZ.w $0FFC
++ RTL
.special_overworld
CMP.l .spow,X
BNE .protect
RTL
.spow
db $80, $81, $81, $FF, $FF, $FF, $FF, $FF
db $FF, $81, $81, $FF, $FF, $FF, $FF, $FF