Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/scripts/BrunosRoom.asm
1270 views
1
BrunosRoom_Script:
2
call BrunoShowOrHideExitBlock
3
call EnableAutoTextBoxDrawing
4
ld hl, BrunosRoomTrainerHeaders
5
ld de, BrunosRoom_ScriptPointers
6
ld a, [wBrunosRoomCurScript]
7
call ExecuteCurMapScriptInTable
8
ld [wBrunosRoomCurScript], a
9
ret
10
11
BrunoShowOrHideExitBlock:
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_BRUNOS_ROOM_TRAINER_0
18
jr z, .blockExitToNextRoom
19
ld a, $5
20
jp .setExitBlock
21
.blockExitToNextRoom
22
ld a, $24
23
.setExitBlock
24
ld [wNewTileBlockID], a
25
lb bc, 0, 2
26
predef_jump ReplaceTileBlock
27
28
ResetBrunoScript:
29
xor a ; SCRIPT_BRUNOSROOM_DEFAULT
30
ld [wBrunosRoomCurScript], a
31
ret
32
33
BrunosRoom_ScriptPointers:
34
def_script_pointers
35
dw_const BrunosRoomDefaultScript, SCRIPT_BRUNOSROOM_DEFAULT
36
dw_const DisplayEnemyTrainerTextAndStartBattle, SCRIPT_BRUNOSROOM_BRUNO_START_BATTLE
37
dw_const BrunosRoomBrunoEndBattleScript, SCRIPT_BRUNOSROOM_BRUNO_END_BATTLE
38
dw_const BrunosRoomPlayerIsMovingScript, SCRIPT_BRUNOSROOM_PLAYER_IS_MOVING
39
dw_const BrunosRoomNoopScript, SCRIPT_BRUNOSROOM_NOOP
40
41
BrunosRoomNoopScript:
42
ret
43
44
BrunoScriptWalkIntoRoom:
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_BRUNOSROOM_PLAYER_IS_MOVING
58
ld [wBrunosRoomCurScript], a
59
ld [wCurMapScript], a
60
ret
61
62
BrunosRoomDefaultScript:
63
ld hl, BrunoEntranceCoords
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_BRUNOS_ROOM
75
jr z, BrunoScriptWalkIntoRoom
76
.stopPlayerFromLeaving
77
ld a, TEXT_BRUNOSROOM_BRUNO_DONT_RUN_AWAY
78
ldh [hTextID], a
79
call DisplayTextID ; "Don't run away!"
80
ld a, PAD_UP
81
ld [wSimulatedJoypadStatesEnd], a
82
ld a, $1
83
ld [wSimulatedJoypadStatesIndex], a
84
call StartSimulatingJoypadStates
85
ld a, SCRIPT_BRUNOSROOM_PLAYER_IS_MOVING
86
ld [wBrunosRoomCurScript], a
87
ld [wCurMapScript], a
88
ret
89
90
BrunoEntranceCoords:
91
dbmapcoord 4, 10
92
dbmapcoord 5, 10
93
dbmapcoord 4, 11
94
dbmapcoord 5, 11
95
db -1 ; end
96
97
BrunosRoomPlayerIsMovingScript:
98
ld a, [wSimulatedJoypadStatesIndex]
99
and a
100
ret nz
101
call Delay3
102
xor a ; SCRIPT_BRUNOSROOM_DEFAULT
103
ld [wJoyIgnore], a
104
ld [wBrunosRoomCurScript], a
105
ld [wCurMapScript], a
106
ret
107
108
BrunosRoomBrunoEndBattleScript:
109
call EndTrainerBattle
110
ld a, [wIsInBattle]
111
cp $ff
112
jp z, ResetBrunoScript
113
ld a, TEXT_BRUNOSROOM_BRUNO
114
ldh [hTextID], a
115
jp DisplayTextID
116
117
BrunosRoom_TextPointers:
118
def_text_pointers
119
dw_const BrunosRoomBrunoText, TEXT_BRUNOSROOM_BRUNO
120
dw_const BrunosRoomBrunoDontRunAwayText, TEXT_BRUNOSROOM_BRUNO_DONT_RUN_AWAY
121
122
BrunosRoomTrainerHeaders:
123
def_trainers
124
BrunosRoomTrainerHeader0:
125
trainer EVENT_BEAT_BRUNOS_ROOM_TRAINER_0, 0, BrunoBeforeBattleText, BrunoEndBattleText, BrunoAfterBattleText
126
db -1 ; end
127
128
BrunosRoomBrunoText:
129
text_asm
130
ld hl, BrunosRoomTrainerHeader0
131
call TalkToTrainer
132
jp TextScriptEnd
133
134
BrunoBeforeBattleText:
135
text_far _BrunoBeforeBattleText
136
text_end
137
138
BrunoEndBattleText:
139
text_far _BrunoEndBattleText
140
text_end
141
142
BrunoAfterBattleText:
143
text_far _BrunoAfterBattleText
144
text_end
145
146
BrunosRoomBrunoDontRunAwayText:
147
text_far _BrunosRoomBrunoDontRunAwayText
148
text_end
149
150