view clojure/com/aurellem/gb/hxc.clj @ 246:921d2277bb57

Got hardcoded move effect data, put it into a map hxc-move-data. Since descriptions are handwritten, they may be buggy.
author Dylan Holmes <ocsenave@gmail.com>
date Mon, 26 Mar 2012 01:56:57 -0500
parents a50faba43967
children 99227bec1123
line wrap: on
line source
1 (ns com.aurellem.gb.hxc
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]))
9 (def pkmn-types
10 [:normal
11 :fighting
12 :flying
13 :poison
14 :ground
15 :rock
16 :bird
17 :bug
18 :ghost
19 :A
20 :B
21 :C
22 :D
23 :E
24 :F
25 :G
26 :H
27 :I
28 :J
29 :K
30 :fire
31 :water
32 :grass
33 :electric
34 :psychic
35 :ice
36 :dragon
37 ])
40 ;; question: when status effects claim to take
41 ;; their accuracy from the move accuracy, does
42 ;; this mean that the move always "hits" but the
43 ;; status effect may not?
45 (def move-effects
46 ["normal damage"
47 "no damage, just opponent sleep" ;; how many turns? is atk power ignored?
48 "0x4C chance of poison"
49 "leech half of inflicted damage"
50 "0x19 chance of burn"
51 "0x19 chance of freeze"
52 "0x19 chance of paralyze"
53 "user faints; opponent defense halved."
54 "leech half of inflicted damage ONLY if sleeping opponent."
55 "imitate last attack"
56 "user atk +1"
57 "user def +1"
58 "user spd +1"
59 "user spc +1"
60 "user acr +1" ;; unused?!
61 "user evd +1"
62 "get post-battle $ = 2*level*uses"
63 "0xFE acr, no matter what."
64 "opponent atk -1" ;; acr taken from move acr?
65 "opponent def -1" ;;
66 "opponent spd -1" ;;
67 "opponent spc -1" ;;
68 "opponent acr -1";;
69 "opponent evd -1"
70 "converts user's type to opponent's."
71 "(haze)"
72 "(bide)"
73 "(thrash)"
74 "(teleport)"
75 "(fury swipes)"
76 "attacks 2-5 turns" ;; unused? like rollout?
77 "0x19 chance of flinch"
78 "opponent sleep for 1-7 turns"
79 "0x66 chance of poison"
80 "0x4D chance of burn"
81 "0x4D chance of freeze"
82 "0x4D chance of paralyze"
83 "0x4D chance of flinch"
84 "one-hit KO"
85 "charge one turn, atk next."
86 "fixed damage, leaves 1HP." ;; how is dmg determined?
87 "fixed damage." ;; cf seismic toss, dragon rage, psywave.
88 "atk 2-5 turns; opponent can't attack" ;; unnormalized? (0 0x60 0x60 0x20 0x20)
89 "charge one turn, atk next. (can't be hit when charging)"
90 "atk hits twice."
91 "user takes 1 damage if misses."
92 "evade status-lowering effects" ;;caused by you or also your opponent?
93 "(broken) if user is slower than opponent, makes critical hit impossible, otherwise has no effect"
94 "atk causes recoil dmg = 1/4 dmg dealt"
95 "confuses opponent" ;; acr taken from move acr
96 "user atk +2"
97 "user def +2"
98 "user spd +2"
99 "user spc +2"
100 "user acr +2" ;; unused!
101 "user evd +2" ;; unused!
102 "restores up to half of user's max hp." ;; broken: fails if the difference
103 ;; b/w max and current hp is one less than a multiple of 256.
104 "(transform)"
105 "opponent atk -2"
106 "opponent def -2"
107 "opponent spd -2"
108 "opponent spc -2"
109 "opponent acr -2"
110 "opponent evd -2"
111 "doubles user spc when attacked"
112 "doubles user def when attacked"
113 "poisons opponent" ;;acr taken from move acr
114 "paralyzes opponent" ;;
115 "0x19 chance opponent atk -1"
116 "0x19 chance opponent def -1"
117 "0x19 chance opponent spd -1"
118 "0x4C chance opponent spc -1" ;; context suggest chance is 0x19
119 "0x19 chance opponent acr -1"
120 "0x19 chance opponent evd -1"
121 "???" ;; unused? no effect?
122 "???" ;; unused? no effect?
123 "0x19 chance opponent confused"
124 "atk hits twice. 0x33 chance opponent poisioned."
125 "broken. crash the game after attack."
126 "(substitute)"
127 "unless opponent faints, user must recharge after atk. some
128 exceptions apply."
129 "(rage)"
130 "(mimic)"
131 "(metronome)"
132 "(leech seed)"
133 "does nothing (splash)"
134 "(disable)"
135 ])
141 (def hxc-items
142 "The hardcoded names of the items in memory. List begins at ROM@045B7 "
143 (map character-codes->str
144 (take-nth 2
145 (partition-by #(= % 0x50)
146 (take 1200
147 (drop 0x45B7 (rom (root))))))))
149 (def hxc-types
150 "The hardcoded type names in memory. List begins at ROM@27D99,
151 shortly before hxc-titles."
152 (map character-codes->str
153 (take-nth 2
154 (partition-by #(= 0x50 %)
155 (take 102
156 (drop 0x27D99
157 (rom (root))))))))
159 (def hxc-titles
160 "The hardcoded names of the trainer titles in memory. List begins at
161 ROM@27E77"
162 (map character-codes->str
163 (take-nth 2
164 (partition-by #(= 0x50 %)
165 (take 196
166 (drop 0x27E77
167 (rom (root))))))))
170 (def hxc-places
171 "The hardcoded place names in memory. List begins at
172 ROM@71500. Cinnabar Mansion is dynamically calculated."
173 (map character-codes->str
174 (take-nth 2
175 (partition-by #(= % 0x50)
176 (take 560
177 (drop 0x71500
178 (rom (root))))))))
181 (def hxc-dialog
182 "The hardcoded dialogue in memory, including in-game alerts. List begins at ROM@98000."
183 (character-codes->str(take 0x0F728
184 (drop (+ 0x98000)
185 (rom (root))))))
187 (def hxc-pokedex
188 "The hardcoded pokedex entries in memory. List begins at
189 ROM@B8000, shortly before move names."
190 (map character-codes->str
191 (take-nth 2
192 (partition-by #(= % 0x50)
193 (take 14754
194 (drop 0xB8000
195 (rom (root))))))))
196 (def hxc-move-names
197 "The hardcoded move names in memory. List begins at ROM@BC000"
198 (map character-codes->str
199 (take-nth 2
200 (partition-by #(= % 0x50)
201 (take 1551
202 (drop 0xBC000
203 (rom (root))))))))
205 (def hxc-move-data
206 "The hardcoded (basic (move effects)) in memory. List begins at
207 0x38000. Effect descriptions were handwritten and aren't hardcoded."
208 (let [names (vec hxc-move-names)
209 move-count (count names)
210 move-size 6
211 format-name (fn [s]
212 (keyword (.toLowerCase
213 (apply str
214 (map #(if (= % \space) "-" %) s)))))
215 ]
216 (zipmap (map format-name names)
217 (map
218 (fn [[idx effect power type accuracy pp]]
219 {:name (names (dec idx))
220 :power power
221 :accuracy (hex accuracy)
222 :pp pp
223 :fx-id (hex effect)
224 :fx-txt (get move-effects effect)
225 }
226 )
228 (partition move-size
229 (take (* move-size move-count)
230 (drop 0x38000 (rom(root)))))))))
234 (def hxc-pokenames
235 "The hardcoded names of the 190 species in memory. List begins at ROM@E8000."
236 (let [count-species 190
237 name-length 10]
238 (map character-codes->str
239 (partition name-length
240 (take (* count-species name-length)
241 (drop 0xE8000
242 (rom(root))))))))
252 (def hxc-advantage
253 "The hardcoded type advantages in memory, returned as tuples of [atk-type def-type multiplier]. By default (i.e. if not listed here), the multiplier is 1."
254 (map
255 (fn [[atk def mult]] [(get pkmn-types atk (hex atk))
256 (get pkmn-types def (hex def))
257 (/ mult 10)])
258 (partition 3
259 (take-while (partial not= 0xFF)
260 (drop 0x3E62D (rom(root)))))))
276 ;; note for later: credits start at F1290
280 (comment
282 (def hxc-later
283 "Running this code produces, e.g. hardcoded names NPCs give
284 their pokemon. Will sort through it later."
285 (print (character-codes->str(take 10000
286 (drop 0x71597
287 (rom (root)))))))
289 (let [dex
290 (partition-by #(= 0x50 %)
291 (take 2540
292 (drop 0x40687
293 (rom (root)))))]
294 (def dex dex)
295 (def hxc-species
296 (map character-codes->str
297 (take-nth 4 dex))))