view clojure/com/aurellem/gb/types.clj @ 204:43bb461a7419

constructing default types....
author Robert McIntyre <rlm@mit.edu>
date Fri, 23 Mar 2012 04:19:38 -0500
parents 85a2c2e2d318
children 28d35c9e3ab6
line wrap: on
line source
1 (ns com.aurellem.gb.types
2 (:use (com.aurellem.gb gb-driver util constants))
3 (:import [com.aurellem.gb.gb_driver SaveState]))
5 (def type-code->type-name
6 {0x00 :normal
7 0x01 :fighting
8 0x02 :flying
9 0x03 :poision
10 0x04 :ground
11 0x05 :rock
12 0x07 :bug
13 0x08 :ghost
14 0x14 :fire
15 0x15 :water
16 0x16 :grass
17 0x17 :electric
18 0x18 :psychic
19 0x19 :ice
20 0x1A :dragon })
22 (def type-name->type-code
23 (zipmap (vals type-code->type-name)
24 (keys type-code->type-name)))
26 (def pokemon-1-type-start-address 0xD16F)
28 (defn pokemon-type-start-address [poke-num]
29 (+ pokemon-1-type-start-address
30 (* pokemon-record-width poke-num)))
32 (defn give-type
33 ([^SaveState state poke-num types]
34 (assert (<= 0 poke-num 5))
35 (let [types*
36 (if (= (count types) 1)
37 [(first types) (first types)]
38 types)]
39 (set-memory-range
40 state
41 (pokemon-type-start-address poke-num)
42 (map type-name->type-code types))))
43 ([poke-num types]
44 (give-type @current-state poke-num types)))
46 (defn read-type
47 ([^SaveState state poke-num]
48 (assert (<= 0 poke-num 5))
49 (let [types-start (pokemon-type-start-address poke-num)
50 [type-1 type-2]
51 (subvec (vec (memory state))
52 types-start (+ 2 types-start))]
53 (if (= type-1 type-2)
54 [(type-code->type-name type-1)]
55 (mapv type-code->type-name [type-1 type-2]))))
56 ([poke-num]
57 (read-type @current-state poke-num)))
61 :normal nor
62 :fighting fig
63 :flying fly
64 :poision poi
65 :ground gro
66 :rock roc
67 :bug bug
68 :ghost gho
69 :fire fir
70 :water wat
71 :grass gra
72 :electric ele
73 :psychic psy
74 :ice ice
75 :dragon dra
79 (def pokemon->type
80 {
81 :abra psy
82 :aerodactyl rck fly
83 :alakazam psy
84 :arbok poi
85 :arcanine fir
86 :articuno ice fly
87 :beedrill bug poi
88 :bellsprout gra poi
89 :blastoise wat
90 :bulbasaur gra poi
91 :butterfree bug fly
92 :caterpie bug
93 :chansey nor
94 :charizard fir fly
95 :charmander fir
96 :charmeleon fir
97 :clefable nor
98 :clefairy nor
99 :cloyster wat ice
100 :cubone gro
101 :dewgong wat ice
102 :diglett gro
103 :ditto nor
104 :dodrio nor fly
105 :doduo nor fly
106 :dragonair drg
107 :dragonite drg fly
108 :dratini drg
109 :drowzee psy
110 :dugtrio gro
111 :eevee nor
112 :ekans poi
113 :electabuzz ele
114 :electrode ele
115 :exeggcute gra psy
116 :exeggutor gra psy
117 :farfetchd nor fly
118 :fearow nor fly
119 :flareon fir
120 :gastly gho poi
121 :gengar gho poi
122 :geodude rck gro
123 :gloom gra poi
124 :golbat poi fly
125 :goldeen wat
126 :golduck wat
127 :golem rck gro
128 :graveler rck gro
129 :grimer poi
130 :growlithe fir
131 :gyarados wat fly
132 :haunter gho poi
133 :hitmonchan fgt
134 :hitmonlee fgt
135 :horsea wat
136 :hypno psy
137 :ivysaur gra poi
138 :jigglypuff nor
139 :jolteon ele
140 :jynx ice psy
141 :kabuto rck wat
142 :kabutops rck wat
143 :kadabra psy
144 :kakuna bug poi
145 :kangaskhan nor
146 :kingler wat
147 :koffing poi
148 :krabby wat
149 :lapras wat ice
150 :lickitung nor
151 :machamp fgt
152 :machoke fgt
153 :machop fgt
154 :magikarp wat
155 :magmar fir
156 :magnemite ele
157 :magneton ele
158 :mankey fgt
159 :marowak gro
160 :meowth nor
161 :metapod bug
162 :mew psy
163 :mewtwo psy
164 :moltres fir fly
165 :mr-mime psy
166 :muk poi
167 :nidoking poi gro
168 :nidoqueen poi gro
169 :nidoran-female poi
170 :nidoran-male poi
171 :nidorina poi
172 :nidorino poi
173 :ninetails fir
174 :oddish gra poi
175 :omanyte rck wat
176 :omastar rck wat
177 :onix rck gro
178 :paras bug gra
179 :parasect bug gra
180 :persian nor
181 :pidgeot nor fly
182 :pidgeotto nor fly
183 :pidgey nor fly
184 :pikachu ele
185 :pinsir bug
186 :poliwag wat
187 :poliwhirl wat
188 :poliwrath wat fgt
189 :ponyta fir
190 :porygon nor
191 :primeape fgt
192 :psyduck wat
193 :raichu ele
194 :rapidash fir
195 :raticate nor
196 :rattata nor
197 :rhydon gro rck
198 :rhyhorn gro rck
199 :sandshrew gro
200 :sandslash gro
201 :scyther bug fly
202 :seaking wat
203 :sedra wat
204 :seel wat
205 :shellder wat
206 :slowbro wat psy
207 :slowpoke wat psy
208 :snorlax nor
209 :spearow nor fly
210 :squirtle wat
211 :starmie wat psy
212 :staryu wat
213 :tangela gra
214 :tauros nor
215 :tentacool wat poi
216 :tentacruel wat poi
217 :vaporeon wat
218 :venomoth bug poi
219 :venonat bug poi
220 :venusaur gra poi
221 :victreebel gra poi
222 :vileplume gra poi
223 :voltorb ele
224 :vulpix fir
225 :wartortle wat
226 :weedle bug poi
227 :weepenbell gra poi
228 :wheezing poi
229 :wigglytuff nor
230 :zapdos ele fly
231 :zubat poi fly