Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/scripts/AgathasRoom.asm
1270 views
1
AgathasRoom_Script:
2
call AgathaShowOrHideExitBlock
3
call EnableAutoTextBoxDrawing
4
ld hl, AgathasRoomTrainerHeaders
5
ld de, AgathasRoom_ScriptPointers
6
ld a, [wAgathasRoomCurScript]
7
call ExecuteCurMapScriptInTable
8
ld [wAgathasRoomCurScript], a
9
ret
10
11
AgathaShowOrHideExitBlock:
12
; Blocks or clears the exit to the next room.
13
ld hl, wCurrentMapScriptFlags
14
bit BIT_CUR_MAP_LOADED_1, [hl]
15
res BIT_CUR_MAP_LOADED_1, [hl]
16
ret z
17
CheckEvent EVENT_BEAT_AGATHAS_ROOM_TRAINER_0
18
jr z, .blockExitToNextRoom
19
ld a, $e
20
jp .setExitBlock
21
.blockExitToNextRoom
22
ld a, $3b
23
.setExitBlock
24
ld [wNewTileBlockID], a
25
lb bc, 0, 2
26
predef_jump ReplaceTileBlock
27
28
ResetAgathaScript:
29
xor a ; SCRIPT_AGATHASROOM_DEFAULT
30
ld [wAgathasRoomCurScript], a
31
ret
32
33
AgathasRoom_ScriptPointers:
34
def_script_pointers
35
dw_const AgathasRoomDefaultScript, SCRIPT_AGATHASROOM_DEFAULT
36
dw_const DisplayEnemyTrainerTextAndStartBattle, SCRIPT_AGATHASROOM_AGATHA_START_BATTLE
37
dw_const AgathasRoomAgathaEndBattleScript, SCRIPT_AGATHASROOM_AGATHA_END_BATTLE
38
dw_const AgathasRoomPlayerIsMovingScript, SCRIPT_AGATHASROOM_PLAYER_IS_MOVING
39
dw_const AgathasRoomNoopScript, SCRIPT_AGATHASROOM_NOOP
40
41
AgathasRoomNoopScript:
42
ret
43
44
AgathaScriptWalkIntoRoom:
45
; Walk six steps upward.
46
ld hl, wSimulatedJoypadStatesEnd
47
ld a, PAD_UP
48
ld [hli], a
49
ld [hli], a
50
ld [hli], a
51
ld [hli], a
52
ld [hli], a
53
ld [hl], a
54
ld a, $6
55
ld [wSimulatedJoypadStatesIndex], a
56
call StartSimulatingJoypadStates
57
ld a, SCRIPT_AGATHASROOM_PLAYER_IS_MOVING
58
ld [wAgathasRoomCurScript], a
59
ld [wCurMapScript], a
60
ret
61
62
AgathasRoomDefaultScript:
63
ld hl, AgathaEntranceCoords
64
call ArePlayerCoordsInArray
65
jp nc, CheckFightingMapTrainers
66
xor a
67
ldh [hJoyPressed], a
68
ldh [hJoyHeld], a
69
ld [wSimulatedJoypadStatesEnd], a
70
ld [wSimulatedJoypadStatesIndex], a
71
ld a, [wCoordIndex]
72
cp $3 ; Is player standing one tile above the exit?
73
jr c, .stopPlayerFromLeaving
74
CheckAndSetEvent EVENT_AUTOWALKED_INTO_AGATHAS_ROOM
75
jr z, AgathaScriptWalkIntoRoom
76
.stopPlayerFromLeaving
77
ld a, TEXT_AGATHASROOM_AGATHA_DONT_RUN_AWAY
78
ldh [hTextID], a
79
call DisplayTextID
80
ld a, PAD_UP
81
ld [wSimulatedJoypadStatesEnd], a
82
ld a, $1
83
ld [wSimulatedJoypadStatesIndex], a
84
call StartSimulatingJoypadStates
85
ld a, SCRIPT_AGATHASROOM_PLAYER_IS_MOVING
86
ld [wAgathasRoomCurScript], a
87
ld [wCurMapScript], a
88
ret
89
90
AgathaEntranceCoords:
91
dbmapcoord 4, 10
92
dbmapcoord 5, 10
93
dbmapcoord 4, 11
94
dbmapcoord 5, 11
95
db -1 ; end
96
97
AgathasRoomPlayerIsMovingScript:
98
ld a, [wSimulatedJoypadStatesIndex]
99
and a
100
ret nz
101
call Delay3
102
xor a
103
ld [wJoyIgnore], a
104
ld [wAgathasRoomCurScript], a
105
ld [wCurMapScript], a
106
ret
107
108
AgathasRoomAgathaEndBattleScript:
109
call EndTrainerBattle
110
ld a, [wIsInBattle]
111
cp $ff
112
jp z, ResetAgathaScript
113
ld a, TEXT_AGATHASROOM_AGATHA
114
ldh [hTextID], a
115
call DisplayTextID
116
ld a, SCRIPT_CHAMPIONSROOM_PLAYER_ENTERS
117
ld [wChampionsRoomCurScript], a
118
ret
119
120
AgathasRoom_TextPointers:
121
def_text_pointers
122
dw_const AgathasRoomAgathaText, TEXT_AGATHASROOM_AGATHA
123
dw_const AgathasRoomAgathaDontRunAwayText, TEXT_AGATHASROOM_AGATHA_DONT_RUN_AWAY
124
125
AgathasRoomTrainerHeaders:
126
def_trainers
127
AgathasRoomTrainerHeader0:
128
trainer EVENT_BEAT_AGATHAS_ROOM_TRAINER_0, 0, AgathaBeforeBattleText, AgathaEndBattleText, AgathaAfterBattleText
129
db -1 ; end
130
131
AgathasRoomAgathaText:
132
text_asm
133
ld hl, AgathasRoomTrainerHeader0
134
call TalkToTrainer
135
jp TextScriptEnd
136
137
AgathaBeforeBattleText:
138
text_far _AgathaBeforeBattleText
139
text_end
140
141
AgathaEndBattleText:
142
text_far _AgathaEndBattleText
143
text_end
144
145
AgathaAfterBattleText:
146
text_far _AgathaAfterBattleText
147
text_end
148
149
AgathasRoomAgathaDontRunAwayText:
150
text_far _AgathasRoomAgathaDontRunAwayText
151
text_end
152
153