rlm@165
|
1 (ns com.aurellem.gb.species
|
ocsenave@207
|
2 (:use (com.aurellem.gb characters gb-driver util constants))
|
rlm@165
|
3 (:import [com.aurellem.gb.gb_driver SaveState]))
|
rlm@165
|
4
|
ocsenave@207
|
5
|
ocsenave@207
|
6 (def hxc-pokenames
|
ocsenave@207
|
7 "The hardcoded names of the 190 species in memory. List begins at ROM@E8000."
|
ocsenave@207
|
8 (let [count-species 190
|
ocsenave@207
|
9 name-length 10]
|
ocsenave@207
|
10 (map character-codes->str
|
ocsenave@207
|
11 (partition name-length
|
ocsenave@207
|
12 (take (* count-species name-length)
|
ocsenave@207
|
13 (drop 0xE8000
|
ocsenave@207
|
14 (rom(root))))))))
|
rlm@212
|
15
|
ocsenave@207
|
16 (def hxc-items
|
ocsenave@207
|
17 "The hardcoded names of the items in memory. List begins at ROM@45B7 "
|
ocsenave@207
|
18 (map character-codes->str
|
ocsenave@207
|
19 (take-nth 2
|
ocsenave@207
|
20 (partition-by #(= % 0x50)
|
ocsenave@207
|
21 (take 1200
|
ocsenave@207
|
22 (drop 0x45B7 (rom (root))))))))
|
ocsenave@207
|
23 (def hxc-titles
|
ocsenave@207
|
24 "The hardcoded names of the trainer titles in memory. List begins at
|
ocsenave@207
|
25 ROM@27E77"
|
ocsenave@207
|
26 (map character-codes->str
|
ocsenave@207
|
27 (take-nth 2
|
ocsenave@207
|
28 (partition-by #(= 0x50 %)
|
ocsenave@207
|
29 (take 196
|
ocsenave@207
|
30 (drop 0x27E77
|
ocsenave@207
|
31 (rom (root))))))))
|
ocsenave@207
|
32
|
ocsenave@207
|
33
|
ocsenave@207
|
34 (def hxc-pokedex
|
ocsenave@207
|
35 "The hardcoded pokedex entries in memory. List begins at
|
ocsenave@207
|
36 ROM@B8000, shortly before move names."
|
ocsenave@207
|
37 (map character-codes->str
|
ocsenave@207
|
38 (take-nth 2
|
ocsenave@207
|
39 (partition-by #(= % 0x50)
|
ocsenave@207
|
40 (take 14754
|
ocsenave@207
|
41 (drop 0xB8000
|
ocsenave@207
|
42 (rom (root))))))))
|
ocsenave@207
|
43 (def hxc-moves
|
ocsenave@207
|
44 "The hardcoded move names in memory. List begins at ROM@BC000"
|
ocsenave@207
|
45 (map character-codes->str
|
ocsenave@207
|
46 (take-nth 2
|
ocsenave@207
|
47 (partition-by #(= % 0x50)
|
ocsenave@207
|
48 (take 1551
|
ocsenave@207
|
49 (drop 0xBC000
|
ocsenave@207
|
50 (rom (root))))))))
|
ocsenave@207
|
51
|
ocsenave@207
|
52
|
ocsenave@207
|
53
|
ocsenave@207
|
54 (def hxc-places
|
ocsenave@207
|
55 "The hardcoded place names in memory. List begins at
|
ocsenave@207
|
56 ROM@71500. Cinnabar Mansion is dynamically calculated."
|
ocsenave@207
|
57 (map character-codes->str
|
ocsenave@207
|
58 (take-nth 2
|
ocsenave@207
|
59 (partition-by #(= % 0x50)
|
ocsenave@207
|
60 (take 560
|
ocsenave@207
|
61 (drop 0x71500
|
ocsenave@207
|
62 (rom (root))))))))
|
ocsenave@207
|
63
|
ocsenave@207
|
64 (def hxc-later
|
ocsenave@207
|
65 "Running this code produces, e.g. hardcoded names NPCs give
|
ocsenave@207
|
66 their pokemon"
|
ocsenave@207
|
67 (print (character-codes->str(take 10000
|
ocsenave@207
|
68 (drop 0x71597
|
ocsenave@207
|
69 (rom (root)))))))
|
ocsenave@207
|
70
|
ocsenave@207
|
71
|
ocsenave@207
|
72
|
ocsenave@207
|
73
|
ocsenave@207
|
74 (let [dex
|
ocsenave@207
|
75 (partition-by #(= 0x50 %)
|
ocsenave@207
|
76 (take 2540
|
ocsenave@207
|
77 (drop 0x40687
|
ocsenave@207
|
78 (rom (root)))))]
|
ocsenave@207
|
79 (def dex dex)
|
ocsenave@207
|
80 (def hxc-species
|
ocsenave@207
|
81 (map character-codes->str
|
ocsenave@207
|
82 (take-nth 4 dex))))
|
ocsenave@207
|
83
|
ocsenave@207
|
84
|
ocsenave@207
|
85
|
rlm@165
|
86 (def species-code->species-name
|
rlm@165
|
87 {0x01 :rhydon
|
rlm@165
|
88 0x02 :kangaskhan
|
rlm@165
|
89 0x03 :nidoran-male
|
rlm@165
|
90 0x04 :clefairy
|
rlm@165
|
91 0x05 :spearow
|
rlm@165
|
92 0x06 :voltorb
|
rlm@165
|
93 0x07 :nidoking
|
rlm@165
|
94 0x08 :slowbro
|
rlm@165
|
95 0x09 :ivysaur
|
rlm@165
|
96 0x0A :exeggutor
|
rlm@165
|
97 0x0B :lickitung
|
rlm@165
|
98 0x0C :exeggcute
|
rlm@165
|
99 0x0D :grimer
|
rlm@165
|
100 0x0E :gengar
|
rlm@165
|
101 0x0F :nidoran-female
|
rlm@165
|
102 0x10 :nidoqueen
|
rlm@165
|
103 0x11 :cubone
|
rlm@165
|
104 0x12 :rhyhorn
|
rlm@165
|
105 0x13 :lapras
|
rlm@165
|
106 0x14 :arcanine
|
rlm@165
|
107 0x15 :mew
|
rlm@165
|
108 0x16 :gyarados
|
rlm@165
|
109 0x17 :shellder
|
rlm@165
|
110 0x18 :tentacool
|
rlm@165
|
111 0x19 :gastly
|
rlm@165
|
112 0x1A :scyther
|
rlm@165
|
113 0x1B :staryu
|
rlm@165
|
114 0x1C :blastoise
|
rlm@165
|
115 0x1D :pinsir
|
rlm@165
|
116 0x1E :tangela
|
rlm@165
|
117 0x21 :growlithe
|
rlm@165
|
118 0x22 :onix
|
rlm@165
|
119 0x23 :fearow
|
rlm@165
|
120 0x24 :pidgey
|
rlm@165
|
121 0x25 :slowpoke
|
rlm@165
|
122 0x26 :kadabra
|
rlm@165
|
123 0x27 :graveler
|
rlm@165
|
124 0x28 :chansey
|
rlm@165
|
125 0x29 :machoke
|
rlm@165
|
126 0x2A :mr-mime
|
rlm@165
|
127 0x2B :hitmonlee
|
rlm@165
|
128 0x2C :hitmonchan
|
rlm@165
|
129 0x2D :arbok
|
rlm@165
|
130 0x2E :parasect
|
rlm@165
|
131 0x2F :psyduck
|
rlm@165
|
132 0x30 :drowzee
|
rlm@165
|
133 0x31 :golem
|
rlm@165
|
134 0x33 :magmar
|
rlm@165
|
135 0x35 :electabuzz
|
rlm@165
|
136 0x36 :magneton
|
rlm@165
|
137 0x37 :koffing
|
rlm@165
|
138 0x39 :mankey
|
rlm@165
|
139 0x3A :seel
|
rlm@165
|
140 0x3B :diglett
|
rlm@165
|
141 0x3C :tauros
|
rlm@165
|
142 0x40 :farfetch'd
|
rlm@165
|
143 0x41 :venonat
|
rlm@165
|
144 0x42 :dragonite
|
rlm@165
|
145 0x46 :doduo
|
rlm@165
|
146 0x47 :poliwag
|
rlm@165
|
147 0x48 :jynx
|
rlm@165
|
148 0x49 :moltres
|
rlm@165
|
149 0x4A :articuno
|
rlm@165
|
150 0x4B :zapdos
|
rlm@165
|
151 0x4C :ditto
|
rlm@165
|
152 0x4D :meowth
|
rlm@165
|
153 0x4E :krabby
|
rlm@165
|
154 0x52 :vulpix
|
rlm@165
|
155 0x53 :ninetails
|
rlm@165
|
156 0x54 :pikachu
|
rlm@204
|
157 0x55 :raichu
|
rlm@165
|
158 0x58 :dratini
|
rlm@165
|
159 0x59 :dragonair
|
rlm@165
|
160 0x5A :kabuto
|
rlm@165
|
161 0x5B :kabutops
|
rlm@165
|
162 0x5C :horsea
|
rlm@165
|
163 0x5D :sedra
|
rlm@165
|
164 0x60 :sandshrew
|
rlm@165
|
165 0x61 :sandslash
|
rlm@165
|
166 0x62 :omanyte
|
rlm@165
|
167 0x63 :omastar
|
rlm@165
|
168 0x64 :jigglypuff
|
rlm@165
|
169 0x65 :wigglytuff
|
rlm@165
|
170 0x66 :eevee
|
rlm@165
|
171 0x67 :flareon
|
rlm@165
|
172 0x68 :jolteon
|
rlm@165
|
173 0x69 :vaporeon
|
rlm@165
|
174 0x6A :machop
|
rlm@165
|
175 0x6B :zubat
|
rlm@165
|
176 0x6C :ekans
|
rlm@165
|
177 0x6D :paras
|
rlm@165
|
178 0x6E :poliwhirl
|
rlm@165
|
179 0x6F :poliwrath
|
rlm@165
|
180 0x70 :weedle
|
rlm@165
|
181 0x71 :kakuna
|
rlm@165
|
182 0x72 :beedrill
|
rlm@165
|
183 0x74 :dodrio
|
rlm@165
|
184 0x75 :primeape
|
rlm@165
|
185 0x76 :dugtrio
|
rlm@165
|
186 0x77 :venomoth
|
rlm@165
|
187 0x78 :dewgong
|
rlm@165
|
188 0x7B :caterpie
|
rlm@165
|
189 0x7C :metapod
|
rlm@165
|
190 0x7D :butterfree
|
rlm@165
|
191 0x7E :machamp
|
rlm@165
|
192 0x80 :golduck
|
rlm@165
|
193 0x81 :hypno
|
rlm@165
|
194 0x82 :golbat
|
rlm@165
|
195 0x83 :mewtwo
|
rlm@165
|
196 0x84 :snorlax
|
rlm@165
|
197 0x85 :magikarp
|
rlm@165
|
198 0x88 :muk
|
rlm@165
|
199 0x8A :kingler
|
rlm@165
|
200 0x8B :cloyster
|
rlm@165
|
201 0x8D :electrode
|
rlm@165
|
202 0x8E :clefable
|
rlm@165
|
203 0x8F :wheezing
|
rlm@165
|
204 0x90 :persian
|
rlm@165
|
205 0x91 :marowak
|
rlm@165
|
206 0x93 :haunter
|
rlm@165
|
207 0x94 :abra
|
rlm@165
|
208 0x95 :alakazam
|
rlm@165
|
209 0x96 :pidgeotto
|
rlm@165
|
210 0x97 :pidgeot
|
rlm@165
|
211 0x98 :starmie
|
rlm@165
|
212 0x99 :bulbasaur
|
rlm@165
|
213 0x9A :venusaur
|
rlm@165
|
214 0x9B :tentacruel
|
rlm@165
|
215 0x9D :goldeen
|
rlm@165
|
216 0x9E :seaking
|
rlm@165
|
217 0xA3 :ponyta
|
rlm@165
|
218 0xA4 :rapidash
|
rlm@165
|
219 0xA5 :rattata
|
rlm@165
|
220 0xA6 :raticate
|
rlm@165
|
221 0xA7 :nidorino
|
rlm@165
|
222 0xA8 :nidorina
|
rlm@165
|
223 0xA9 :geodude
|
rlm@165
|
224 0xAA :porygon
|
rlm@165
|
225 0xAB :aerodactyl
|
rlm@165
|
226 0xAD :magnemite
|
rlm@165
|
227 0xB0 :charmander
|
rlm@165
|
228 0xB1 :squirtle
|
rlm@165
|
229 0xB2 :charmeleon
|
rlm@165
|
230 0xB3 :wartortle
|
rlm@165
|
231 0xB4 :charizard
|
rlm@165
|
232 0xB9 :oddish
|
rlm@165
|
233 0xBA :gloom
|
rlm@165
|
234 0xBB :vileplume
|
rlm@165
|
235 0xBC :bellsprout
|
rlm@165
|
236 0xBD :weepenbell
|
rlm@165
|
237 0xBE :victreebel})
|
rlm@165
|
238
|
rlm@165
|
239 (def species-ID-1 0xD163)
|
rlm@165
|
240
|
rlm@165
|
241 (def species-name->species-code
|
rlm@165
|
242 (zipmap (vals species-code->species-name)
|
rlm@165
|
243 (keys species-code->species-name)))
|
rlm@165
|
244
|
rlm@190
|
245 (defn pokemon-species-data-address [poke-num]
|
rlm@190
|
246 (+ species-ID-1 poke-num))
|
rlm@190
|
247
|
rlm@190
|
248 (defn read-species
|
rlm@190
|
249 ([^SaveState state poke-num]
|
rlm@190
|
250 (assert (<= 0 poke-num 5))
|
rlm@190
|
251 (species-code->species-name
|
rlm@190
|
252 (aget (memory state)
|
rlm@190
|
253 (pokemon-species-data-address poke-num))))
|
rlm@190
|
254 ([poke-num]
|
rlm@190
|
255 (read-species @current-state poke-num)))
|
rlm@190
|
256
|
rlm@165
|
257 (defn set-species
|
rlm@190
|
258 ([^SaveState state poke-num species-name]
|
rlm@190
|
259 (assert (<= 0 poke-num 5))
|
rlm@165
|
260 (let [species-code (species-name->species-code
|
rlm@165
|
261 species-name
|
rlm@165
|
262 species-name)]
|
rlm@165
|
263
|
rlm@190
|
264 (set-memory state (pokemon-species-data-address poke-num)
|
rlm@165
|
265 species-code)))
|
rlm@190
|
266 ([poke-num species-name]
|
rlm@190
|
267 (set-species @current-state poke-num species-name)))
|
rlm@166
|
268
|
rlm@166
|
269
|
rlm@191
|
270 (def pokemon-1-species2-address 0xD16A)
|
rlm@191
|
271
|
rlm@191
|
272 (defn pokemon-species2-address [poke-num]
|
rlm@191
|
273 (+ pokemon-1-species2-address
|
rlm@191
|
274 (* pokemon-record-width poke-num)))
|
rlm@191
|
275
|
rlm@191
|
276 (defn read-species2
|
rlm@191
|
277 ([^SaveState state poke-num]
|
rlm@191
|
278 (species-code->species-name
|
rlm@191
|
279 (aget (memory state)
|
rlm@191
|
280 (pokemon-species2-address poke-num))))
|
rlm@191
|
281 ([poke-num]
|
rlm@191
|
282 (read-species2 @current-state poke-num)))
|
rlm@191
|
283
|
rlm@191
|
284 (defn set-species2
|
rlm@191
|
285 ([^SaveState state poke-num new-species]
|
rlm@191
|
286 (let [species-code (species-name->species-code
|
rlm@191
|
287 new-species
|
rlm@191
|
288 new-species)]
|
rlm@191
|
289
|
rlm@191
|
290 (set-memory state (pokemon-species2-address poke-num)
|
rlm@191
|
291 species-code)))
|
rlm@191
|
292 ([poke-num new-species]
|
rlm@191
|
293 (set-species2 @current-state poke-num new-species)))
|
rlm@191
|
294
|
rlm@203
|
295
|
rlm@203
|
296
|
rlm@203
|
297
|