view clojure/com/aurellem/gb/species.clj @ 193:da1a5ed61a8d

minor reformatting.
author Robert McIntyre <rlm@mit.edu>
date Thu, 22 Mar 2012 22:37:35 -0500
parents 893c753f8088
children 85a2c2e2d318
line wrap: on
line source
1 (ns com.aurellem.gb.species
2 (:use (com.aurellem.gb gb-driver util constants))
3 (:import [com.aurellem.gb.gb_driver SaveState]))
5 (def species-code->species-name
6 {0x01 :rhydon
7 0x02 :kangaskhan
8 0x03 :nidoran-male
9 0x04 :clefairy
10 0x05 :spearow
11 0x06 :voltorb
12 0x07 :nidoking
13 0x08 :slowbro
14 0x09 :ivysaur
15 0x0A :exeggutor
16 0x0B :lickitung
17 0x0C :exeggcute
18 0x0D :grimer
19 0x0E :gengar
20 0x0F :nidoran-female
21 0x10 :nidoqueen
22 0x11 :cubone
23 0x12 :rhyhorn
24 0x13 :lapras
25 0x14 :arcanine
26 0x15 :mew
27 0x16 :gyarados
28 0x17 :shellder
29 0x18 :tentacool
30 0x19 :gastly
31 0x1A :scyther
32 0x1B :staryu
33 0x1C :blastoise
34 0x1D :pinsir
35 0x1E :tangela
36 0x21 :growlithe
37 0x22 :onix
38 0x23 :fearow
39 0x24 :pidgey
40 0x25 :slowpoke
41 0x26 :kadabra
42 0x27 :graveler
43 0x28 :chansey
44 0x29 :machoke
45 0x2A :mr-mime
46 0x2B :hitmonlee
47 0x2C :hitmonchan
48 0x2D :arbok
49 0x2E :parasect
50 0x2F :psyduck
51 0x30 :drowzee
52 0x31 :golem
53 0x33 :magmar
54 0x35 :electabuzz
55 0x36 :magneton
56 0x37 :koffing
57 0x39 :mankey
58 0x3A :seel
59 0x3B :diglett
60 0x3C :tauros
61 0x40 :farfetch'd
62 0x41 :venonat
63 0x42 :dragonite
64 0x46 :doduo
65 0x47 :poliwag
66 0x48 :jynx
67 0x49 :moltres
68 0x4A :articuno
69 0x4B :zapdos
70 0x4C :ditto
71 0x4D :meowth
72 0x4E :krabby
73 0x52 :vulpix
74 0x53 :ninetails
75 0x54 :pikachu
76 0x55 :riachu
77 0x58 :dratini
78 0x59 :dragonair
79 0x5A :kabuto
80 0x5B :kabutops
81 0x5C :horsea
82 0x5D :sedra
83 0x60 :sandshrew
84 0x61 :sandslash
85 0x62 :omanyte
86 0x63 :omastar
87 0x64 :jigglypuff
88 0x65 :wigglytuff
89 0x66 :eevee
90 0x67 :flareon
91 0x68 :jolteon
92 0x69 :vaporeon
93 0x6A :machop
94 0x6B :zubat
95 0x6C :ekans
96 0x6D :paras
97 0x6E :poliwhirl
98 0x6F :poliwrath
99 0x70 :weedle
100 0x71 :kakuna
101 0x72 :beedrill
102 0x74 :dodrio
103 0x75 :primeape
104 0x76 :dugtrio
105 0x77 :venomoth
106 0x78 :dewgong
107 0x7B :caterpie
108 0x7C :metapod
109 0x7D :butterfree
110 0x7E :machamp
111 0x80 :golduck
112 0x81 :hypno
113 0x82 :golbat
114 0x83 :mewtwo
115 0x84 :snorlax
116 0x85 :magikarp
117 0x88 :muk
118 0x8A :kingler
119 0x8B :cloyster
120 0x8D :electrode
121 0x8E :clefable
122 0x8F :wheezing
123 0x90 :persian
124 0x91 :marowak
125 0x93 :haunter
126 0x94 :abra
127 0x95 :alakazam
128 0x96 :pidgeotto
129 0x97 :pidgeot
130 0x98 :starmie
131 0x99 :bulbasaur
132 0x9A :venusaur
133 0x9B :tentacruel
134 0x9D :goldeen
135 0x9E :seaking
136 0xA3 :ponyta
137 0xA4 :rapidash
138 0xA5 :rattata
139 0xA6 :raticate
140 0xA7 :nidorino
141 0xA8 :nidorina
142 0xA9 :geodude
143 0xAA :porygon
144 0xAB :aerodactyl
145 0xAD :magnemite
146 0xB0 :charmander
147 0xB1 :squirtle
148 0xB2 :charmeleon
149 0xB3 :wartortle
150 0xB4 :charizard
151 0xB9 :oddish
152 0xBA :gloom
153 0xBB :vileplume
154 0xBC :bellsprout
155 0xBD :weepenbell
156 0xBE :victreebel})
158 (def species-ID-1 0xD163)
160 (def species-name->species-code
161 (zipmap (vals species-code->species-name)
162 (keys species-code->species-name)))
164 (defn pokemon-species-data-address [poke-num]
165 (+ species-ID-1 poke-num))
167 (defn read-species
168 ([^SaveState state poke-num]
169 (assert (<= 0 poke-num 5))
170 (species-code->species-name
171 (aget (memory state)
172 (pokemon-species-data-address poke-num))))
173 ([poke-num]
174 (read-species @current-state poke-num)))
176 (defn set-species
177 ([^SaveState state poke-num species-name]
178 (assert (<= 0 poke-num 5))
179 (let [species-code (species-name->species-code
180 species-name
181 species-name)]
183 (set-memory state (pokemon-species-data-address poke-num)
184 species-code)))
185 ([poke-num species-name]
186 (set-species @current-state poke-num species-name)))
189 (def pokemon-1-species2-address 0xD16A)
191 (defn pokemon-species2-address [poke-num]
192 (+ pokemon-1-species2-address
193 (* pokemon-record-width poke-num)))
195 (defn read-species2
196 ([^SaveState state poke-num]
197 (species-code->species-name
198 (aget (memory state)
199 (pokemon-species2-address poke-num))))
200 ([poke-num]
201 (read-species2 @current-state poke-num)))
203 (defn set-species2
204 ([^SaveState state poke-num new-species]
205 (let [species-code (species-name->species-code
206 new-species
207 new-species)]
209 (set-memory state (pokemon-species2-address poke-num)
210 species-code)))
211 ([poke-num new-species]
212 (set-species2 @current-state poke-num new-species)))