Mercurial > vba-clojure
diff clojure/com/aurellem/gb/hxc.clj @ 420:acc3d1ad24e8
Found HP restored by SODA POP, FRESH WATER, LEMONADE; also found number of steps for REPEL, SUPER REPEL, MAX REPEL.
author | Dylan Holmes <ocsenave@gmail.com> |
---|---|
date | Sat, 14 Apr 2012 09:27:49 -0500 |
parents | 7c89fe478de4 |
children |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/gb/hxc.clj Sat Apr 14 05:20:28 2012 -0500 1.2 +++ b/clojure/com/aurellem/gb/hxc.clj Sat Apr 14 09:27:49 2012 -0500 1.3 @@ -184,7 +184,8 @@ 1.4 1.5 1.6 (defn hxc-pokedex-names 1.7 - "The names of the pokemon in hardcoded pokedex order. List begins at 1.8 + "The names of the pokemon in hardcoded pokedex order. List of the 1.9 + pokedex numbers of each pokemon (in internal order) begins at 1.10 ROM@410B1. See also, hxc-pokenames." 1.11 ([] (hxc-pokedex-names 1.12 com.aurellem.gb.gb-driver/original-rom)) 1.13 @@ -350,10 +351,9 @@ 1.14 1.15 (def hxc-places 1.16 "The hardcoded place names in memory. List begins at 1.17 -ROM@71500. [Cinnabar] Mansion seems to be dynamically calculated." 1.18 +ROM@71500. [Cinnabar/Celadon] Mansion seems to be dynamically calculated." 1.19 (hxc-thunk-words 0x71500 560)) 1.20 1.21 - 1.22 (defn hxc-dialog 1.23 "The hardcoded dialogue in memory, including in-game alerts. Dialog 1.24 seems to be separated by 0x57 instead of 0x50 (END). Begins at ROM@98000." 1.25 @@ -923,25 +923,335 @@ 1.26 ;; note: 1195C-6A says ABLE#NOT ABLE#, but so does 119C0-119CE. 1.27 ;; The first instance is for Machines; the second, for stones. 1.28 1.29 -;; 0x251A (in indexable mem): image decompression routine seems to begin here. 1.30 +;; note: according to 1.31 +;; http://www.upokecenter.com/games/rby/guides/rgbtrainers.php 1.32 +;; the amount of money given by a trainer is equal to the 1.33 +;; base money times the level of the last Pokemon on that trainer's 1.34 +;; list. Other sources say it's the the level of the last pokemon 1.35 +;; /defeated/. 1.36 + 1.37 +;; todo: find base money. 1.38 + 1.39 + 1.40 +;; note: 0xDFEA (in indexable mem) is the dex# of the currently-viewed Pokemon in 1.41 + ;; in the pokedex. It's used for other purposes if there is none. 1.42 + 1.43 +;; note: 0x9D35 (index.) switches from 0xFF to 0x00 temporarily when 1.44 +;; you walk between areas. 1.45 + 1.46 +;; note: 0xD059 (index.) is the special battle type of your next battle: 1.47 +;; - 00 is a usual battle 1.48 +;; - 01 is a pre-scripted OLD MAN battle which always fails to catch the 1.49 +;; target Pokemon. 1.50 +;; - 02 is a safari zone battle 1.51 +;; - 03 obligates you to run away. (unused) 1.52 +;; - 04 is a pre-scripted OAK battle, which (temporarily) causes the 1.53 +;; enemy Pokemon to cry PIKAAA, and which always catches the target 1.54 +;; Pokemon. The target Pokemon is erased after the battle. 1.55 +;; - 05+ are glitch states in which you are sort of the Pokemon. 1.56 + 1.57 + 1.58 +;; note: 0x251A (in indexable mem): image decompression routine seems to begin here. 1.59 + 1.60 +;; note: 0x4845 (index): vending inventory is loaded here. possibly 1.61 + ;; other things, too. 1.62 +(comment 1.63 + ;; temporarily intercept/adjust what pops out of the vending 1.64 + ;; machine. 1.65 + ;; (and how much it costs) 1.66 + 1.67 + ;; located at 0x4845 1.68 + ;; not to be confused with shop inventory, 0xCF7B 1.69 + (do 1.70 + (step (read-state "vend-menu")) 1.71 + (write-memory! (rewrite-memory (vec(memory)) 0x4845 [2 0 1 0])) 1.72 + (step @current-state [:a]) 1.73 + (step @current-state []) 1.74 + (nstep @current-state 200) )) 1.75 1.76 1.77 ;; Note: There are two tile tables, one from 8000-8FFF, the other from 1.78 ;; 8800-97FF. The latter contains symbols, possibly map tiles(?), with some japanese chars and stuff at the end. 1.79 (defn print-pixel-letters! 1.80 "The pixel tiles representing letters. Neat!" 1.81 - ([] (print-pixel-letters! (read-state "oak-speaks"))) 1.82 - ([state] 1.83 - (map 1.84 - (comp 1.85 - println 1.86 - (partial map #(if (zero? %) \space 0)) 1.87 - #(if (< (count %) 8) 1.88 - (recur (cons 0 %)) 1.89 - %) 1.90 - reverse bit-list) 1.91 + ([] (print-pixel-letters! (read-state "oak-speaks"))) 1.92 +([state] 1.93 + (map 1.94 + (comp 1.95 + println 1.96 + (partial map #(if (zero? %) \space 0)) 1.97 + #(if (< (count %) 8) 1.98 + (recur (cons 0 %)) 1.99 + %) 1.100 + reverse bit-list) 1.101 + 1.102 + (take 0xFFF (drop 0x8800 (memory state)))))) 1.103 + 1.104 + 1.105 +;; (defn test-2 [] 1.106 +;; (loop [n 0 1.107 +;; pc-1 (pc-trail (-> state-defend (tick) (step [:a]) (step [:a]) (step []) (nstep 100)) 100000) 1.108 +;; pc-2 (pc-trail (-> state-speed (tick) (step [:a]) (step [:a]) 1.109 +;; (step []) (nstep 100)) 100000)] 1.110 +;; (cond (empty? (drop n pc-1)) [pc-1 n] 1.111 +;; (not= (take 10 (drop n pc-1)) (take 10 pc-2)) 1.112 +;; (recur pc-1 pc-2 (inc n)) 1.113 +;; :else 1.114 +;; [(take 1000 pc-2) n]))) 1.115 + 1.116 + 1.117 + 1.118 + 1.119 +(defn test-3 1.120 + "Explore trainer data" 1.121 + ([] (test-3 0x3A289)) 1.122 + ([start] 1.123 + (let [pokenames (vec(hxc-pokenames-raw))] 1.124 + (println 1.125 + (reduce 1.126 + str 1.127 + (map 1.128 + (fn [[adr lvl pkmn]] 1.129 + (str (format "%-11s %4d %02X %02X \t %05X\n" 1.130 + 1.131 + (cond 1.132 + (zero? lvl) "+" 1.133 + (nil? (get pokenames (dec pkmn))) 1.134 + "-" 1.135 + :else 1.136 + (get pokenames (dec pkmn))) 1.137 + lvl 1.138 + pkmn 1.139 + lvl 1.140 + adr 1.141 + ))) 1.142 + (map cons 1.143 + (take-nth 2 (drop start (range))) 1.144 + (partition 2 1.145 + (take 400;;703 1.146 + (drop 1.147 + start 1.148 + ;; 0x3A75D 1.149 + (rom))))))))))) 1.150 + 1.151 +(defn search-memory* [mem codes k] 1.152 + (loop [index 0 1.153 + index-next 1 1.154 + start-match 0 1.155 + to-match codes 1.156 + matches []] 1.157 + (cond 1.158 + (>= index (count mem)) matches 1.159 + 1.160 + (empty? to-match) 1.161 + (recur 1.162 + index-next 1.163 + (inc index-next) 1.164 + index-next 1.165 + codes 1.166 + (conj matches 1.167 + [(hex start-match) (take k (drop start-match mem))]) 1.168 + ) 1.169 + 1.170 + (or (= (first to-match) \_) ;; wildcard 1.171 + (= (first to-match) (nth mem index))) 1.172 + (recur 1.173 + (inc index) 1.174 + index-next 1.175 + start-match 1.176 + (rest to-match) 1.177 + matches) 1.178 + 1.179 + :else 1.180 + (recur 1.181 + index-next 1.182 + (inc index-next) 1.183 + index-next 1.184 + codes 1.185 + matches)))) 1.186 1.187 - (take 0xFFF (drop 0x88000 (memory state)))))) 1.188 + 1.189 +(defn search-pattern [ptn coll] 1.190 + (loop 1.191 + [index 0 1.192 + to-match ptn 1.193 + binds {} 1.194 + 1.195 + next-index 1 1.196 + match-start 0 1.197 + matches []] 1.198 + 1.199 + (cond 1.200 + (>= index (count coll)) matches 1.201 + (empty? to-match) 1.202 + (recur 1.203 + next-index 1.204 + ptn 1.205 + {} 1.206 + (inc next-index) 1.207 + next-index 1.208 + (conj match-start 1.209 + [(hex match-start) binds])) 1.210 + 1.211 + :else 1.212 + (let [k (first to-match) 1.213 + v (nth coll index)] 1.214 + (cond 1.215 + (= k \_) ;; wildcard 1.216 + (recur 1.217 + (inc index) 1.218 + (rest to-match) 1.219 + binds 1.220 + 1.221 + next-index 1.222 + match-start 1.223 + matches) 1.224 + 1.225 + (keyword? k) 1.226 + (if (binds k) 1.227 + (if (= (binds k) v) 1.228 + 1.229 + ;; consistent bindings 1.230 + (recur 1.231 + (inc index) 1.232 + (rest to-match) 1.233 + binds 1.234 + 1.235 + next-index 1.236 + match-start 1.237 + matches) 1.238 + 1.239 + ;; inconsistent bindings 1.240 + (recur 1.241 + next-index 1.242 + ptn 1.243 + {} 1.244 + (inc next-index) 1.245 + next-index 1.246 + matches)) 1.247 + 1.248 + (if ((set (vals binds)) v) 1.249 + ;; bindings are not unique 1.250 + (recur 1.251 + next-index 1.252 + ptn 1.253 + {} 1.254 + (inc next-index) 1.255 + next-index 1.256 + matches) 1.257 + 1.258 + ;; bindings are unique 1.259 + (recur 1.260 + (inc index) 1.261 + (rest to-match) 1.262 + (assoc binds k v) 1.263 + 1.264 + next-index 1.265 + match-start 1.266 + matches))) 1.267 + 1.268 + :else ;; k is just a number 1.269 + (if (= k v) 1.270 + (recur 1.271 + (inc index) 1.272 + (rest to-match) 1.273 + binds 1.274 + 1.275 + next-index 1.276 + match-start 1.277 + matches) 1.278 + 1.279 + (recur 1.280 + next-index 1.281 + ptn 1.282 + {} 1.283 + (inc next-index) 1.284 + next-index 1.285 + matches))))))) 1.286 + 1.287 + 1.288 + 1.289 + 1.290 + 1.291 + 1.292 + 1.293 + 1.294 + 1.295 +(defn search-pattern* [ptn coll] 1.296 + (loop 1.297 + [ 1.298 + binds {} 1.299 + index 0 1.300 + index-next 1 1.301 + start-match 0 1.302 + to-match ptn 1.303 + matches []] 1.304 + 1.305 + (cond 1.306 + (>= index (count coll)) matches 1.307 + (empty? to-match) 1.308 + (recur 1.309 + {} 1.310 + index-next 1.311 + (inc index-next) 1.312 + index-next 1.313 + ptn 1.314 + (conj matches 1.315 + [(hex start-match) binds])) 1.316 + 1.317 + :else 1.318 + (let [k (first to-match) 1.319 + v (nth coll index)] 1.320 + (cond 1.321 + (= k \_) ;; wildcard 1.322 + (recur 1.323 + binds 1.324 + (inc index) 1.325 + index-next 1.326 + start-match 1.327 + (rest to-match) 1.328 + matches) 1.329 + 1.330 + (keyword? k) 1.331 + (if (binds k) 1.332 + (if (= (binds k) v) 1.333 + (recur 1.334 + binds 1.335 + (inc index) 1.336 + index-next 1.337 + start-match 1.338 + (rest to-match) 1.339 + matches) 1.340 + (recur 1.341 + {} 1.342 + index-next 1.343 + (inc index-next) 1.344 + index-next 1.345 + ptn 1.346 + matches)) 1.347 + (if 1.348 + ;; every symbol must be bound to a different thing. 1.349 + ((set (vals binds)) v) 1.350 + (recur 1.351 + {} 1.352 + index-next 1.353 + (inc index-next) 1.354 + index-next 1.355 + ptn 1.356 + matches) 1.357 + (recur 1.358 + (assoc binds k v) 1.359 + (inc index) 1.360 + index-next 1.361 + start-match 1.362 + (rest to-match) 1.363 + matches)))))))) 1.364 + 1.365 + 1.366 + 1.367 + 1.368 +;; look for the rainbow badge in memory 1.369 +(println (reduce str (map #(str (first %) "\t" (vec(second %)) "\n") (search-memory (rom) [221] 10)))) 1.370 1.371 1.372 (comment