forked from Vortyne/pureRGB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLancesRoom.asm
182 lines (164 loc) · 4.28 KB
/
LancesRoom.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
LancesRoom_Script:
call LanceShowOrHideEntranceBlocks
call EnableAutoTextBoxDrawing
ld hl, LancesRoomTrainerHeaders
ld de, LancesRoom_ScriptPointers
ld a, [wLancesRoomCurScript]
call ExecuteCurMapScriptInTable
ld [wLancesRoomCurScript], a
ret
LanceShowOrHideEntranceBlocks:
ld hl, wCurrentMapScriptFlags
bit 5, [hl]
res 5, [hl]
ret z
CheckEvent EVENT_LANCES_ROOM_LOCK_DOOR
jr nz, .closeEntrance
; open entrance
ld a, $31
ld b, $32
jp .setEntranceBlocks
.closeEntrance
ld a, $72
ld b, $73
.setEntranceBlocks
; Replaces the tile blocks so the player can't leave.
push bc
ld [wNewTileBlockID], a
lb bc, 6, 2
call .SetEntranceBlock
pop bc
ld a, b
ld [wNewTileBlockID], a
lb bc, 6, 3
call .SetEntranceBlock
ld hl, wCurrentMapScriptFlags
bit 3, [hl]
res 3, [hl]
ret z
jp GBFadeInFromWhite ; PureRGBnote: ADDED: since trainer instantly talks to us after battle we need to fade back in here
.SetEntranceBlock:
predef_jump ReplaceTileBlock
ResetLanceScript:
xor a ; SCRIPT_LANCESROOM_DEFAULT
ld [wLancesRoomCurScript], a
ret
LancesRoom_ScriptPointers:
def_script_pointers
dw_const LancesRoomDefaultScript, SCRIPT_LANCESROOM_DEFAULT
dw_const DisplayEnemyTrainerTextAndStartBattle, SCRIPT_LANCESROOM_LANCE_START_BATTLE
dw_const LancesRoomLanceEndBattleScript, SCRIPT_LANCESROOM_LANCE_END_BATTLE
dw_const LancesRoomPlayerIsMovingScript, SCRIPT_LANCESROOM_PLAYER_IS_MOVING
dw_const LancesRoomNoopScript, SCRIPT_LANCESROOM_NOOP
LancesRoomNoopScript:
ret
LancesRoomDefaultScript:
CheckEvent EVENT_BEAT_LANCE
ret nz
ld hl, LanceTriggerMovementCoords
call ArePlayerCoordsInArray
jp nc, CheckFightingMapTrainers
xor a
ldh [hJoyHeld], a
ld a, [wCoordIndex]
cp $3 ; Is player standing next to Lance's sprite?
jr nc, .notStandingNextToLance
call DoFacings
ld a, TEXT_LANCESROOM_LANCE
ldh [hSpriteIndexOrTextID], a
jp DisplayTextID
.notStandingNextToLance
cp $5 ; Is player standing on the entrance staircase?
jr z, WalkToLance
CheckAndSetEvent EVENT_LANCES_ROOM_LOCK_DOOR
ret nz
ld hl, wCurrentMapScriptFlags
set 5, [hl]
ld a, SFX_GO_INSIDE
rst _PlaySound
jp LanceShowOrHideEntranceBlocks
LanceTriggerMovementCoords:
dbmapcoord 5, 1
dbmapcoord 6, 2
dbmapcoord 5, 11
dbmapcoord 6, 11
dbmapcoord 24, 16
db -1 ; end
LancesRoomLanceEndBattleScript:
call EndTrainerBattle
ld a, [wIsInBattle]
cp $ff
jp z, ResetLanceScript
ld a, TEXT_LANCESROOM_LANCE
ldh [hSpriteIndexOrTextID], a
jp DisplayTextID
WalkToLance:
; Moves the player down the hallway to Lance's room.
ld a, A_BUTTON | B_BUTTON | SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN
ld [wJoyIgnore], a
ld hl, wSimulatedJoypadStatesEnd
ld de, WalkToLance_RLEList
call DecodeRLEList
dec a
ld [wSimulatedJoypadStatesIndex], a
call StartSimulatingJoypadStates
ld a, SCRIPT_LANCESROOM_PLAYER_IS_MOVING
ld [wLancesRoomCurScript], a
ld [wCurMapScript], a
ret
WalkToLance_RLEList:
db D_UP, 12
db D_LEFT, 12
db D_DOWN, 7
db D_LEFT, 6
db -1 ; end
LancesRoomPlayerIsMovingScript:
ld a, [wSimulatedJoypadStatesIndex]
and a
ret nz
call Delay3
xor a ; SCRIPT_LANCESROOM_DEFAULT
ld [wJoyIgnore], a
ld [wLancesRoomCurScript], a
ld [wCurMapScript], a
ret
LancesRoom_TextPointers:
def_text_pointers
dw_const LancesRoomLanceText, TEXT_LANCESROOM_LANCE
LancesRoomTrainerHeaders:
def_trainers
LancesRoomTrainerHeader0:
trainer EVENT_BEAT_LANCES_ROOM_TRAINER_0, 0, LancesRoomLanceBeforeBattleText, LancesRoomLanceEndBattleText, LancesRoomLanceAfterBattleText
db -1 ; end
LancesRoomLanceText:
text_asm
ld hl, LancesRoomTrainerHeader0
call TalkToTrainer
rst TextScriptEnd
LancesRoomLanceBeforeBattleText:
text_far _LancesRoomLanceBeforeBattleText
text_end
LancesRoomLanceEndBattleText:
text_far _LancesRoomLanceEndBattleText
text_end
LancesRoomLanceAfterBattleText:
text_far _LancesRoomLanceAfterBattleText
text_asm
SetEvent EVENT_BEAT_LANCE
rst TextScriptEnd
DoFacings: ; PureRGBnote: ADDED: when about to fight Lance, lance and the player will face each other properly to talk.
ld a, [wYCoord]
cp 1
jr z, .leftOfLance
ld a, PLAYER_DIR_UP
ld [wPlayerMovingDirection], a
ret
.leftOfLance
ld a, PLAYER_DIR_RIGHT
ld [wPlayerMovingDirection], a
ld a, 1
ldh [hSpriteIndex], a
ld a, SPRITE_FACING_LEFT
ldh [hSpriteFacingDirection], a
call SetSpriteFacingDirection
ret