view clojure/com/aurellem/gb/species.clj @ 213:57258c269bcb

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