-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathBank0B.asm
217 lines (132 loc) · 4.74 KB
/
Bank0B.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
; *$5FE70-$5FFA7 LONG
{
; Turn the subscreen off for the moment.
STZ $1D
REP #$30
LDX.w #$19C6
LDA $8A : CMP.w #$0080 : BNE .notMasterSwordArea
LDA $A0 : CMP.w #$0181 : BNE .setBgColor
INC $1D
BRA .useDefaultGreen
.notMasterSwordArea
; If area == 0x81 branch
CMP.w #$0081 : BEQ .setBgColor
LDX.w #$0000
CMP.w #$005B : BEQ .setBgColor
AND.w #$00BF : CMP.w #$0003 : BEQ .setBgColor
CMP.w #$0005 : BEQ .setBgColor
CMP.w #$0007 : BEQ .setBgColor
.useDefaultGreen
LDX.w #$2669
LDA $8A : AND.w #$0040 : BEQ .setBgColor
; Default tan color for the dark world
LDX.w #$2A32
.setBgColor
TXA : STA $7EC500 : STA $7EC300 : STA $7EC540 : STA $7EC340
; set fixed color to neutral
LDA.w #$4020 : STA $9C
LDA.w #$8040 : STA $9D
LDA $8A : BEQ .noCustomFixedColor
CMP.w #$0070 : BNE .notSwampOfEvil
JMP .subscreenOnAndReturn
.notSwampOfEvil
CMP.w #$0040 : BEQ .noCustomFixedColor
CMP.w #$005B : BEQ .noCustomFixedColor
LDX.w #$4C26
LDY.w #$8C4C
CMP.w #$0003 : BEQ .setCustomFixedColor
CMP.w #$0005 : BEQ .setCustomFixedColor
CMP.w #$0007 : BEQ .setCustomFixedColor
LDX.w #$4A26
LDY.w #$874A
CMP.w #$0043 : BEQ .setCustomFixedColor
CMP.w #$0045 : BEQ .setCustomFixedColor
SEP #$30
; Update CGRAM this frame
INC $15
RTL
.setCustomFixedColor
STX $9C
STY $9D ; Set the fixed color addition color values
.noCustomFixedColor
LDA $11 : AND.w #$00FF : CMP.w #$0004 : BEQ BRANCH_11
; Make sure BG2 and BG1 Y scroll values are synchronized. Same for X scroll
LDA $E8 : STA $E6
LDA $E2 : STA $E0
LDA $8A : AND.w #$003F
; Are we at Hyrule Castle or Pyramid of Power?
CMP.w #$001B : BNE .subscreenOnAndReturn
LDA $E2 : SUB.w #$0778 : LSR A : TAY : AND.w #$4000 : BEQ BRANCH_7
TYA : ORA.w #$8000 : TAY
BRANCH_7:
STY $00
LDA $E2 : SUB $00 : STA $E0
LDA $E6 : CMP.w #$06C0 : BCC BRANCH_9
SUB.w #$0600 : AND.w #$03FF : CMP.w #$0180 : BCS BRANCH_8
LSR A : ORA.w #$0600
BRA BRANCH_10
BRANCH_8:
LDA.w #$06C0
BRA BRANCH_10
BRANCH_9:
LDA $E6 : AND.w #$00FF : LSR A : ORA.w #$0600
BRANCH_10:
; Set BG1 vertical scroll
STA $E6
BRA .subscreenOnAndReturn
BRANCH_11:
LDA $8A : AND.w #$003F : CMP.w #$001B : BNE .subscreenOnAndReturn
; Synchronize Y scrolls on BG0 and BG1. Same for X scrolls
LDA $E8 : STA $E6
LDA $E2 : STA $E0
LDA $0410 : AND.w #$00FF : CMP.w #$0008 : BEQ BRANCH_12
; Handles scroll for special areas maybe?
LDA.w #$0838 : STA $E0
BRANCH_12:
LDA $06C0 : STA $E6
.subscreenOnAndReturn
SEP #$20
; Put BG0 on the subscreen
LDA.b #$01 : STA $1D
SEP #$30
; Update palette
INC $15
RTL
}
; ==============================================================================
; *$5FFA8-$5FFF5 LONG
WallMaster_SendPlayerToLastEntrance:
{
JSL Dungeon_SaveRoomData.justKeys
JSL Dungeon_SaveRoomQuadrantData
JSL Sprite_ResetAll
; Don't use a starting point entrance.
STZ $04AA
; Falling into an overworld hole mode.
LDA.b #$11 : STA $10
STZ $11
STZ $14
; *$5FFBF ALTERNATE ENTRY POINT
STZ $0345
; \wtf 0x11? Written here? I thought these were all even.
STA $005E
STZ $03F3
STZ $0322
STZ $02E4
STZ $0ABD
STZ $036B
STZ $0373
STZ $27
STZ $28
STZ $29
STZ $24
STZ $0351
STZ $0316
STZ $031F
LDA.b #$00 : STA $5D
STZ $4B
; *$5FFEE ALTERNATE ENTRY POINT
JSL Ancilla_TerminateSelectInteractives
JML Player_ResetState
}
; ==============================================================================