Skip to content

Commit

Permalink
Add event vars access functions and debug tab
Browse files Browse the repository at this point in the history
  • Loading branch information
hanzi committed Jan 5, 2024
1 parent b3d963f commit 18c93e6
Show file tree
Hide file tree
Showing 8 changed files with 809 additions and 18 deletions.
48 changes: 48 additions & 0 deletions modules/data/event_vars/compile_pret_vars.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""
This needs to be run inside the pret decomp project, in the `include/constants/` directory.
Something like:
```
cd /path/to/pokefire/include/constants
python /path/to/pokebot-gen3/modules/data/event_vars/compile_pret_vars.py > \
/path/to/pokebot-gen3/modules/data/event_vars/pret_frlg.txt
```
Since it's invoking `gcc`, this will probably only work on Linux or in WSL.
"""

import os
import re

with open("vars.c", "w") as outfile:
outfile.write("#include <stdio.h>\n")
outfile.write('#include "constants/vars.h"\n')
outfile.write("int main() {\n")
with open("vars.h", "r") as file:
for line in file.readlines():
if not line.startswith("#define") or line.strip() == "#define GUARD_CONSTANTS_VARS_H":
continue
match = re.match(r"^#define\s+(\S+)\s+(.*)$", line.strip())
if match is None:
continue
name, value = match.groups()

if (
name.startswith("NUM_")
or name.endswith("_START")
or name.endswith("_END")
or name == "VARS_COUNT"
):
continue

if name.startswith("VAR_"):
short_name = name[4:]
else:
short_name = name

outfile.write(' if ('+name+' < 0x8000) printf("%d %s\\n", ' + name + ' - 0x4000, "' + short_name + '");\n')
outfile.write(" return 0;\n")
outfile.write("}\n")

os.system("gcc -I../ vars.c -o vars.bin")
os.system("./vars.bin")
os.remove("vars.c")
os.remove("vars.bin")
256 changes: 256 additions & 0 deletions modules/data/event_vars/emerald.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
0 TEMP_0
1 TEMP_1
2 TEMP_2
3 TEMP_3
4 TEMP_4
5 TEMP_5
6 TEMP_6
7 TEMP_7
8 TEMP_8
9 TEMP_9
10 TEMP_A
11 TEMP_B
12 TEMP_C
13 TEMP_D
14 TEMP_E
15 TEMP_F
16 OBJ_GFX_ID_0
17 OBJ_GFX_ID_1
18 OBJ_GFX_ID_2
19 OBJ_GFX_ID_3
20 OBJ_GFX_ID_4
21 OBJ_GFX_ID_5
22 OBJ_GFX_ID_6
23 OBJ_GFX_ID_7
24 OBJ_GFX_ID_8
25 OBJ_GFX_ID_9
26 OBJ_GFX_ID_A
27 OBJ_GFX_ID_B
28 OBJ_GFX_ID_C
29 OBJ_GFX_ID_D
30 OBJ_GFX_ID_E
31 OBJ_GFX_ID_F
32 RECYCLE_GOODS
33 REPEL_STEP_COUNT
34 ICE_STEP_COUNT
35 STARTER_MON
36 MIRAGE_RND_H
37 MIRAGE_RND_L
38 SECRET_BASE_MAP
39 CYCLING_ROAD_RECORD_COLLISIONS
40 CYCLING_ROAD_RECORD_TIME_L
41 CYCLING_ROAD_RECORD_TIME_H
42 FRIENDSHIP_STEP_COUNTER
43 POISON_STEP_COUNTER
44 RESET_RTC_ENABLE
45 ENIGMA_BERRY_AVAILABLE
46 WONDER_NEWS_STEP_COUNTER
47 FRONTIER_MANIAC_FACILITY
48 FRONTIER_GAMBLER_CHALLENGE
49 FRONTIER_GAMBLER_SET_CHALLENGE
50 FRONTIER_GAMBLER_AMOUNT_BET
51 FRONTIER_GAMBLER_STATE
52 DEOXYS_ROCK_STEP_COUNT
53 DEOXYS_ROCK_LEVEL
54 PC_BOX_TO_SEND_MON
55 ABNORMAL_WEATHER_LOCATION
56 ABNORMAL_WEATHER_STEP_COUNTER
57 SHOULD_END_ABNORMAL_WEATHER
58 FARAWAY_ISLAND_STEP_COUNTER
59 REGICE_STEPS_1
60 REGICE_STEPS_2
61 REGICE_STEPS_3
62 ALTERING_CAVE_WILD_SET
63 DISTRIBUTE_EON_TICKET
64 DAYS
65 FANCLUB_FAN_COUNTER
66 FANCLUB_LOSE_FAN_TIMER
67 DEPT_STORE_FLOOR
68 TRICK_HOUSE_LEVEL
69 POKELOT_PRIZE_ITEM
70 NATIONAL_DEX
71 SEEDOT_SIZE_RECORD
72 ASH_GATHER_COUNT
73 BIRCH_STATE
74 CRUISE_STEP_COUNT
75 POKELOT_RND1
76 POKELOT_RND2
77 POKELOT_PRIZE_PLACE
78 UNUSED_0x404E
79 LOTAD_SIZE_RECORD
80 LITTLEROOT_TOWN_STATE
81 OLDALE_TOWN_STATE
82 DEWFORD_TOWN_STATE
83 LAVARIDGE_TOWN_STATE
84 CURRENT_SECRET_BASE
85 VERDANTURF_TOWN_STATE
86 PACIFIDLOG_TOWN_STATE
87 PETALBURG_CITY_STATE
88 SLATEPORT_CITY_STATE
89 MAUVILLE_CITY_STATE
90 RUSTBORO_CITY_STATE
91 FORTREE_CITY_STATE
92 LILYCOVE_CITY_STATE
93 MOSSDEEP_CITY_STATE
94 SOOTOPOLIS_CITY_STATE
95 EVER_GRANDE_CITY_STATE
96 ROUTE101_STATE
97 ROUTE102_STATE
98 ROUTE103_STATE
99 ROUTE104_STATE
100 ROUTE105_STATE
101 ROUTE106_STATE
102 ROUTE107_STATE
103 ROUTE108_STATE
104 ROUTE109_STATE
105 ROUTE110_STATE
106 ROUTE111_STATE
107 ROUTE112_STATE
108 ROUTE113_STATE
109 ROUTE114_STATE
110 ROUTE115_STATE
111 ROUTE116_STATE
112 ROUTE117_STATE
113 ROUTE118_STATE
114 ROUTE119_STATE
115 ROUTE120_STATE
116 ROUTE121_STATE
117 ROUTE122_STATE
118 ROUTE123_STATE
119 ROUTE124_STATE
120 ROUTE125_STATE
121 ROUTE126_STATE
122 ROUTE127_STATE
123 ROUTE128_STATE
124 ROUTE129_STATE
125 ROUTE130_STATE
126 ROUTE131_STATE
127 ROUTE132_STATE
128 ROUTE133_STATE
129 ROUTE134_STATE
130 LITTLEROOT_HOUSES_STATE_MAY
131 UNUSED_0x4083
132 BIRCH_LAB_STATE
133 PETALBURG_GYM_STATE
134 CONTEST_HALL_STATE
135 CABLE_CLUB_STATE
136 CONTEST_TYPE
137 SECRET_BASE_INITIALIZED
138 CONTEST_PRIZE_PICKUP
139 UNUSED_0x408B
140 LITTLEROOT_HOUSES_STATE_BRENDAN
141 LITTLEROOT_RIVAL_STATE
142 BOARD_BRINEY_BOAT_STATE
143 DEVON_CORP_3F_STATE
144 BRINEY_HOUSE_STATE
145 UNUSED_0x4091
146 LITTLEROOT_INTRO_STATE
147 MAUVILLE_GYM_STATE
148 LILYCOVE_MUSEUM_2F_STATE
149 LILYCOVE_FAN_CLUB_STATE
150 BRINEY_LOCATION
151 INIT_SECRET_BASE
152 PETALBURG_WOODS_STATE
153 LILYCOVE_CONTEST_LOBBY_STATE
154 RUSTURF_TUNNEL_STATE
155 UNUSED_0x409B
156 ELITE_4_STATE
157 UNUSED_0x409D
158 MOSSDEEP_SPACE_CENTER_STAIR_GUARD_STATE
159 MOSSDEEP_SPACE_CENTER_STATE
160 SLATEPORT_HARBOR_STATE
161 UNUSED_0x40A1
162 SEAFLOOR_CAVERN_STATE
163 CABLE_CAR_STATION_STATE
164 SAFARI_ZONE_STATE
165 TRICK_HOUSE_BEING_WATCHED_STATE
166 TRICK_HOUSE_FOUND_TRICK_MASTER
167 TRICK_HOUSE_ENTRANCE_STATE
168 UNUSED_0x40A8
169 CYCLING_CHALLENGE_STATE
170 SLATEPORT_MUSEUM_1F_STATE
171 TRICK_HOUSE_PUZZLE_1_STATE
172 TRICK_HOUSE_PUZZLE_2_STATE
173 TRICK_HOUSE_PUZZLE_3_STATE
174 TRICK_HOUSE_PUZZLE_4_STATE
175 TRICK_HOUSE_PUZZLE_5_STATE
176 TRICK_HOUSE_PUZZLE_6_STATE
177 TRICK_HOUSE_PUZZLE_7_STATE
178 TRICK_HOUSE_PUZZLE_8_STATE
179 WEATHER_INSTITUTE_STATE
180 SS_TIDAL_STATE
181 TRICK_HOUSE_ENTER_FROM_CORRIDOR
182 TRICK_HOUSE_PUZZLE_7_STATE_2
183 SLATEPORT_FAN_CLUB_STATE
184 UNUSED_0x40B8
185 MT_PYRE_STATE
186 NEW_MAUVILLE_STATE
187 UNUSED_0x40BB
188 BRAVO_TRAINER_BATTLE_TOWER_ON
189 JAGGED_PASS_ASH_WEATHER
190 GLASS_WORKSHOP_STATE
191 METEOR_FALLS_STATE
192 SOOTOPOLIS_MYSTERY_EVENTS_STATE
193 TRICK_HOUSE_PRIZE_PICKUP
194 PACIFIDLOG_TM_RECEIVED_DAY
195 VICTORY_ROAD_1F_STATE
196 FOSSIL_RESURRECTION_STATE
197 WHICH_FOSSIL_REVIVED
198 STEVENS_HOUSE_STATE
199 OLDALE_RIVAL_STATE
200 JAGGED_PASS_STATE
201 SCOTT_PETALBURG_ENCOUNTER
202 SKY_PILLAR_STATE
203 MIRAGE_TOWER_STATE
204 FOSSIL_MANIAC_STATE
205 CABLE_CLUB_TUTORIAL_STATE
206 FRONTIER_BATTLE_MODE
207 FRONTIER_FACILITY
208 HAS_ENTERED_BATTLE_FRONTIER
209 SCOTT_STATE
210 SLATEPORT_OUTSIDE_MUSEUM_STATE
211 DEX_UPGRADE_JOHTO_STARTER_STATE
212 SS_TIDAL_SCOTT_STATE
213 ROAMER_POKEMON
214 TRAINER_HILL_IS_ACTIVE
215 SKY_PILLAR_RAYQUAZA_CRY_DONE
216 SOOTOPOLIS_WALLACE_STATE
217 HAS_TALKED_TO_SEAFLOOR_CAVERN_ENTRANCE_GRUNT
218 REGISTER_BIRCH_STATE
219 UNUSED_0x40DB
220 UNUSED_0x40DC
221 GIFT_PICHU_SLOT
222 GIFT_UNUSED_1
223 GIFT_UNUSED_2
224 GIFT_UNUSED_3
225 GIFT_UNUSED_4
226 GIFT_UNUSED_5
227 GIFT_UNUSED_6
228 GIFT_UNUSED_7
229 UNUSED_0x40E5
230 DAILY_SLOTS
231 DAILY_WILDS
232 DAILY_BLENDER
233 DAILY_PLANTED_BERRIES
234 DAILY_PICKED_BERRIES
235 DAILY_ROULETTE
236 SECRET_BASE_STEP_COUNTER
237 SECRET_BASE_LAST_ITEM_USED
238 SECRET_BASE_LOW_TV_FLAGS
239 SECRET_BASE_HIGH_TV_FLAGS
240 SECRET_BASE_IS_NOT_LOCAL
241 DAILY_BP
242 WALLY_CALL_STEP_COUNTER
243 SCOTT_FORTREE_CALL_STEP_COUNTER
244 ROXANNE_CALL_STEP_COUNTER
245 SCOTT_BF_CALL_STEP_COUNTER
246 RIVAL_RAYQUAZA_CALL_STEP_COUNTER
247 UNUSED_0x40F7
248 UNUSED_0x40F8
249 UNUSED_0x40F9
250 UNUSED_0x40FA
251 UNUSED_0x40FB
252 UNUSED_0x40FC
253 UNUSED_0x40FD
254 UNUSED_0x40FE
255 UNUSED_0x40FF
Loading

0 comments on commit 18c93e6

Please sign in to comment.