view clojure/com/aurellem/gb/types.clj @ 203:85a2c2e2d318

have to add default types for all pokemon.
author Robert McIntyre <rlm@mit.edu>
date Fri, 23 Mar 2012 04:00:42 -0500
parents 9a7a46c4aa1b
children 43bb461a7419
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)))
60 (def pokemon->type
61 {:rhydon
62 :kangaskhan
63 :nidoran-male
64 :clefairy
65 :spearow
66 :voltorb
67 :nidoking
68 :slowbro
69 :ivysaur
70 :exeggutor
71 :lickitung
72 :exeggcute
73 :grimer
74 :gengar
75 :nidoran-female
76 :nidoqueen
77 :cubone
78 :rhyhorn
79 :lapras
80 :arcanine
81 :mew
82 :gyarados
83 :shellder
84 :tentacool
85 :gastly
86 :scyther
87 :staryu
88 :blastoise
89 :pinsir
90 :tangela
91 :growlithe
92 :onix
93 :fearow
94 :pidgey
95 :slowpoke
96 :kadabra
97 :graveler
98 :chansey
99 :machoke
100 :mr-mime
101 :hitmonlee
102 :hitmonchan
103 :arbok
104 :parasect
105 :psyduck
106 :drowzee
107 :golem
108 :magmar
109 :electabuzz
110 :magneton
111 :koffing
112 :mankey
113 :seel
114 :diglett
115 :tauros
116 :farfetch'd
117 :venonat
118 :dragonite
119 :doduo
120 :poliwag
121 :jynx
122 :moltres
123 :articuno
124 :zapdos
125 :ditto
126 :meowth
127 :krabby
128 :vulpix
129 :ninetails
130 :pikachu
131 :riachu
132 :dratini
133 :dragonair
134 :kabuto
135 :kabutops
136 :horsea
137 :sedra
138 :sandshrew
139 :sandslash
140 :omanyte
141 :omastar
142 :jigglypuff
143 :wigglytuff
144 :eevee
145 :flareon
146 :jolteon
147 :vaporeon
148 :machop
149 :zubat
150 :ekans
151 :paras
152 :poliwhirl
153 :poliwrath
154 :weedle
155 :kakuna
156 :beedrill
157 :dodrio
158 :primeape
159 :dugtrio
160 :venomoth
161 :dewgong
162 :caterpie
163 :metapod
164 :butterfree
165 :machamp
166 :golduck
167 :hypno
168 :golbat
169 :mewtwo
170 :snorlax
171 :magikarp
172 :muk
173 :kingler
174 :cloyster
175 :electrode
176 :clefable
177 :wheezing
178 :persian
179 :marowak
180 :haunter
181 :abra
182 :alakazam
183 :pidgeotto
184 :pidgeot
185 :starmie
186 :bulbasaur
187 :venusaur
188 :tentacruel
189 :goldeen
190 :seaking
191 :ponyta
192 :rapidash
193 :rattata
194 :raticate
195 :nidorino
196 :nidorina
197 :geodude
198 :porygon
199 :aerodactyl
200 :magnemite
201 :charmander
202 :squirtle
203 :charmeleon
204 :wartortle
205 :charizard
206 :oddish
207 :gloom
208 :vileplume
209 :bellsprout
210 :weepenbell
211 :victreebel