view clojure/com/aurellem/gb/species.clj @ 573:40f62391db9d

implemented row and column increment logic.
author Robert McIntyre <rlm@mit.edu>
date Sat, 01 Sep 2012 03:56:30 -0500
parents 3dfb9dd3db9d
children
line wrap: on
line source
1 (ns com.aurellem.gb.species
2 (:use (com.aurellem.gb assembly characters gb-driver util
3 constants))
4 (:import [com.aurellem.gb.gb_driver SaveState]))
8 (def species-code->species-name
9 {0x01 :rhydon
10 0x02 :kangaskhan
11 0x03 :nidoran♂
12 0x04 :clefairy
13 0x05 :spearow
14 0x06 :voltorb
15 0x07 :nidoking
16 0x08 :slowbro
17 0x09 :ivysaur
18 0x0A :exeggutor
19 0x0B :lickitung
20 0x0C :exeggcute
21 0x0D :grimer
22 0x0E :gengar
23 0x0F :nidoran♀
24 0x10 :nidoqueen
25 0x11 :cubone
26 0x12 :rhyhorn
27 0x13 :lapras
28 0x14 :arcanine
29 0x15 :mew
30 0x16 :gyarados
31 0x17 :shellder
32 0x18 :tentacool
33 0x19 :gastly
34 0x1A :scyther
35 0x1B :staryu
36 0x1C :blastoise
37 0x1D :pinsir
38 0x1E :tangela
39 0x21 :growlithe
40 0x22 :onix
41 0x23 :fearow
42 0x24 :pidgey
43 0x25 :slowpoke
44 0x26 :kadabra
45 0x27 :graveler
46 0x28 :chansey
47 0x29 :machoke
48 0x2A :mr-mime
49 0x2B :hitmonlee
50 0x2C :hitmonchan
51 0x2D :arbok
52 0x2E :parasect
53 0x2F :psyduck
54 0x30 :drowzee
55 0x31 :golem
56 0x33 :magmar
57 0x35 :electabuzz
58 0x36 :magneton
59 0x37 :koffing
60 0x39 :mankey
61 0x3A :seel
62 0x3B :diglett
63 0x3C :tauros
64 0x40 :farfetch
65 0x41 :venonat
66 0x42 :dragonite
67 0x46 :doduo
68 0x47 :poliwag
69 0x48 :jynx
70 0x49 :moltres
71 0x4A :articuno
72 0x4B :zapdos
73 0x4C :ditto
74 0x4D :meowth
75 0x4E :krabby
76 0x52 :vulpix
77 0x53 :ninetales
78 0x54 :pikachu
79 0x55 :raichu
80 0x58 :dratini
81 0x59 :dragonair
82 0x5A :kabuto
83 0x5B :kabutops
84 0x5C :horsea
85 0x5D :seadra
86 0x60 :sandshrew
87 0x61 :sandslash
88 0x62 :omanyte
89 0x63 :omastar
90 0x64 :jigglypuff
91 0x65 :wigglytuff
92 0x66 :eevee
93 0x67 :flareon
94 0x68 :jolteon
95 0x69 :vaporeon
96 0x6A :machop
97 0x6B :zubat
98 0x6C :ekans
99 0x6D :paras
100 0x6E :poliwhirl
101 0x6F :poliwrath
102 0x70 :weedle
103 0x71 :kakuna
104 0x72 :beedrill
105 0x74 :dodrio
106 0x75 :primeape
107 0x76 :dugtrio
108 0x77 :venomoth
109 0x78 :dewgong
110 0x7B :caterpie
111 0x7C :metapod
112 0x7D :butterfree
113 0x7E :machamp
114 0x80 :golduck
115 0x81 :hypno
116 0x82 :golbat
117 0x83 :mewtwo
118 0x84 :snorlax
119 0x85 :magikarp
120 0x88 :muk
121 0x8A :kingler
122 0x8B :cloyster
123 0x8D :electrode
124 0x8E :clefable
125 0x8F :weezing
126 0x90 :persian
127 0x91 :marowak
128 0x93 :haunter
129 0x94 :abra
130 0x95 :alakazam
131 0x96 :pidgeotto
132 0x97 :pidgeot
133 0x98 :starmie
134 0x99 :bulbasaur
135 0x9A :venusaur
136 0x9B :tentacruel
137 0x9D :goldeen
138 0x9E :seaking
139 0xA3 :ponyta
140 0xA4 :rapidash
141 0xA5 :rattata
142 0xA6 :raticate
143 0xA7 :nidorino
144 0xA8 :nidorina
145 0xA9 :geodude
146 0xAA :porygon
147 0xAB :aerodactyl
148 0xAD :magnemite
149 0xB0 :charmander
150 0xB1 :squirtle
151 0xB2 :charmeleon
152 0xB3 :wartortle
153 0xB4 :charizard
154 0xB9 :oddish
155 0xBA :gloom
156 0xBB :vileplume
157 0xBC :bellsprout
158 0xBD :weepinbell
159 0xBE :victreebel})
161 (def species-ID-1 0xD163)
163 (def species-name->species-code
164 (zipmap (vals species-code->species-name)
165 (keys species-code->species-name)))
167 (defn pokemon-species-data-address [poke-num]
168 (+ species-ID-1 poke-num))
170 (defn read-species
171 ([^SaveState state poke-num]
172 (assert (<= 0 poke-num 5))
173 (species-code->species-name
174 (aget (memory state)
175 (pokemon-species-data-address poke-num))))
176 ([poke-num]
177 (read-species @current-state poke-num)))
179 (defn set-species
180 ([^SaveState state poke-num species-name]
181 (assert (<= 0 poke-num 5))
182 (let [species-code (species-name->species-code
183 species-name
184 species-name)]
186 (set-memory state (pokemon-species-data-address poke-num)
187 species-code)))
188 ([poke-num species-name]
189 (set-species @current-state poke-num species-name)))
192 (def pokemon-1-species2-address 0xD16A)
194 (defn pokemon-species2-address [poke-num]
195 (+ pokemon-1-species2-address
196 (* pokemon-record-width poke-num)))
198 (defn read-species2
199 ([^SaveState state poke-num]
200 (species-code->species-name
201 (aget (memory state)
202 (pokemon-species2-address poke-num))))
203 ([poke-num]
204 (read-species2 @current-state poke-num)))
206 (defn set-species2
207 ([^SaveState state poke-num new-species]
208 (let [species-code (species-name->species-code
209 new-species
210 new-species)]
212 (set-memory state (pokemon-species2-address poke-num)
213 species-code)))
214 ([poke-num new-species]
215 (set-species2 @current-state poke-num new-species)))
218 (def pokedex-num->species-name
219 {1 :bulbasaur
220 2 :ivysaur
221 3 :venusaur
222 4 :charmander
223 5 :charmeleon
224 6 :charizard
225 7 :squirtle
226 8 :wartortle
227 9 :blastoise
228 10 :caterpie
229 11 :metapod
230 12 :butterfree
231 13 :weedle
232 14 :kakuna
233 15 :beedrill
234 16 :pidgey
235 17 :pidgeotto
236 18 :pidgeot
237 19 :rattata
238 20 :raticate
239 21 :spearow
240 22 :fearow
241 23 :ekans
242 24 :arbok
243 25 :pikachu
244 26 :raichu
245 27 :sandshrew
246 28 :sandslash
247 29 :nidoran♀
248 30 :nidorina
249 31 :nidoqueen
250 32 :nidoran♂
251 33 :nidorino
252 34 :nidoking
253 35 :clefairy
254 36 :clefable
255 37 :vulpix
256 38 :ninetales
257 39 :jigglypuff
258 40 :wigglytuff
259 41 :zubat
260 42 :golbat
261 43 :oddish
262 44 :gloom
263 45 :vileplume
264 46 :paras
265 47 :parasect
266 48 :venonat
267 49 :venomoth
268 50 :diglett
269 51 :dugtrio
270 52 :meowth
271 53 :persian
272 54 :psyduck
273 55 :golduck
274 56 :mankey
275 57 :primeape
276 58 :growlithe
277 59 :arcanine
278 60 :poliwag
279 61 :poliwhirl
280 62 :poliwrath
281 63 :abra
282 64 :kadabra
283 65 :alakazam
284 66 :machop
285 67 :machoke
286 68 :machamp
287 69 :bellsprout
288 70 :weepinbell
289 71 :victreebel
290 72 :tentacool
291 73 :tentacruel
292 74 :geodude
293 75 :graveler
294 76 :golem
295 77 :ponyta
296 78 :rapidash
297 79 :slowpoke
298 80 :slowbro
299 81 :magnemite
300 82 :magneton
301 83 :farfetch
302 84 :doduo
303 85 :dodrio
304 86 :seel
305 87 :dewgong
306 88 :grimer
307 89 :muk
308 90 :shellder
309 91 :cloyster
310 92 :gastly
311 93 :haunter
312 94 :gengar
313 95 :onix
314 96 :drowzee
315 97 :hypno
316 98 :krabby
317 99 :kingler
318 100 :voltorb
319 101 :electrode
320 102 :exeggcute
321 103 :exeggutor
322 104 :cubone
323 105 :marowak
324 106 :hitmonlee
325 107 :hitmonchan
326 108 :lickitung
327 109 :koffing
328 110 :weezing
329 111 :rhyhorn
330 112 :rhydon
331 113 :chansey
332 114 :tangela
333 115 :kangaskhan
334 116 :horsea
335 117 :seadra
336 118 :goldeen
337 119 :seaking
338 120 :staryu
339 121 :starmie
340 122 :mr-mime
341 123 :scyther
342 124 :jynx
343 125 :electabuzz
344 126 :magmar
345 127 :pinsir
346 128 :tauros
347 129 :magikarp
348 130 :gyarados
349 131 :lapras
350 132 :ditto
351 133 :eevee
352 134 :vaporeon
353 135 :jolteon
354 136 :flareon
355 137 :porygon
356 138 :omanyte
357 139 :omastar
358 140 :kabuto
359 141 :kabutops
360 142 :aerodactyl
361 143 :snorlax
362 144 :articuno
363 145 :zapdos
364 146 :moltres
365 147 :dratini
366 148 :dragonair
367 149 :dragonite
368 150 :mewtwo
369 151 :mew})
371 (def species-name->pokedex-num
372 (zipmap (vals pokedex-num->species-name)
373 (keys pokedex-num->species-name)))