# HG changeset patch # User Robert McIntyre # Date 1332869868 18000 # Node ID 18336ab5d6ea9f0c2c9e072fd39c4ef2734a35b0 # Parent 68f4e87c8f51c7664616f8085e3f58d7e1b2c256# Parent 69184558fcf366375a5efd5ba235d5021b8932e1 merge. diff -r 68f4e87c8f51 -r 18336ab5d6ea clojure/com/aurellem/gb/hxc.clj --- a/clojure/com/aurellem/gb/hxc.clj Tue Mar 27 12:36:48 2012 -0500 +++ b/clojure/com/aurellem/gb/hxc.clj Tue Mar 27 12:37:48 2012 -0500 @@ -27,15 +27,15 @@ (def pkmn-types - [:normal - :fighting - :flying - :poison - :ground - :rock - :bird - :bug - :ghost + [:normal ;;0 + :fighting ;;1 + :flying ;;2 + :poison ;;3 + :ground ;;4 + :rock ;;5 + :bird ;;6 + :bug ;;7 + :ghost ;;8 :A :B :C @@ -47,13 +47,13 @@ :I :J :K - :fire - :water - :grass - :electric - :psychic - :ice - :dragon + :fire ;;20 (0x14) + :water ;;21 (0x15) + :grass ;;22 (0x16) + :electric ;;23 (0x17) + :psychic ;;24 (0x18) + :ice ;;25 (0x19) + :dragon ;;26 (0x1A) ]) @@ -203,10 +203,12 @@ (hxc-thunk-words 0xB8000 14754)) -;; In red/blue, pokemon are in internal order. -;; In yellow, pokemon are in pokedex order. +;; In red/blue, pokedex stats are in internal order. +;; In yellow, pokedex stats are in pokedex order. (defn hxc-pokedex-stats + "The hardcoded pokedex stats (species height weight) in memory. List +begins at ROM@40687" ;; uses hxc-pokedex-text to count pokemon ;; since hxc-pokenames includes several missingno" ([] (hxc-pokedex-stats com.aurellem.gb.gb-driver/original-rom)) @@ -554,6 +556,101 @@ +(defn hxc-pokemon-base + ([] (hxc-pokemon-base com.aurellem.gb.gb-driver/original-rom)) + ([rom] + (let [entry-size 28 + pkmn-count (count (hxc-pokedex-text rom)) + types (apply assoc {} + (interleave + (range) + pkmn-types)) ;;!! softcoded + moves (apply assoc {} + (interleave + (range) + (map format-name + (hxc-move-names rom)))) + ] + (map + + (fn [[n + rating-hp + rating-atk + rating-def + rating-speed + rating-special + type-1 + type-2 + rarity + rating-xp + pic-dimensions + ptr-pic-obverse-1 + ptr-pic-obverse-2 + ptr-pic-reverse-1 + ptr-pic-reverse-2 + move-1 + move-2 + move-3 + move-4 + growth-rate + & + TMs|HMs]] + (let + [base-moves + (mapv moves + ((comp + ;; since the game uses zero as a delimiter, + ;; it must also increment all move indices by 1. + ;; heren we decrement to correct this. + (partial map dec) + (partial take-while (comp not zero?))) + [move-1 move-2 move-3 move-4])) + + types + (set (list (types type-1) + (types type-2))) + TMs|HMs + (map + (comp + (partial map first) + (partial remove (comp zero? second))) + (split-at + 50 + (map vector + (rest(range)) + (reduce concat + (map + #(take 8 + (concat (bit-list %) + (repeat 0))) + + TMs|HMs))))) + + TMs (vec (first TMs|HMs)) + HMs (take 5 (map (partial + -50) (vec (second TMs|HMs)))) + + + ] + + + {:dex# n + :base-moves base-moves + :types types + :TMs TMs + :HMs HMs + :base-hp rating-hp + :base-atk rating-atk + :base-def rating-def + :base-speed rating-speed + :base-special rating-special + })) + + (partition entry-size + (take (* entry-size pkmn-count) + (drop 0x383DE + rom))))))) + + ;; ********************** MANIPULATION FNS @@ -627,4 +724,3 @@ - diff -r 68f4e87c8f51 -r 18336ab5d6ea clojure/com/aurellem/gb/util.clj --- a/clojure/com/aurellem/gb/util.clj Tue Mar 27 12:36:48 2012 -0500 +++ b/clojure/com/aurellem/gb/util.clj Tue Mar 27 12:37:48 2012 -0500 @@ -29,6 +29,7 @@ (Integer/parseInt (Integer/toBinaryString num) 10))) + (defn view-register [state name reg-fn] (println (format "%s: %s" name (binary-str (reg-fn state)))) @@ -122,8 +123,8 @@ (defn disect-bytes-2 "return a vector consiting of the last 16 bytes of the - integer expressed as two 8 bit nimbers (inside an integer) - in the form [high-bits low-bits." + integer expressed as two 8 bit numbers (inside an integer) + in the form [high-bits low-bits]." [num] [(bit-shift-right (bit-and num 0xFF00) 8) diff -r 68f4e87c8f51 -r 18336ab5d6ea clojure/com/aurellem/world/practice.clj --- a/clojure/com/aurellem/world/practice.clj Tue Mar 27 12:36:48 2012 -0500 +++ b/clojure/com/aurellem/world/practice.clj Tue Mar 27 12:37:48 2012 -0500 @@ -206,8 +206,8 @@ ([rom str k] (map (fn [[address snip]] - [address (character-codes->str snip)] - (search-rom rom (str->character-codes str) k))))) + [address (character-codes->str snip)]) + (search-rom rom (str->character-codes str) k))))