view clojure/com/aurellem/gb/species.clj @ 212:8523faa122b0

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