# HG changeset patch # User Dylan Holmes # Date 1332831916 18000 # Node ID 69184558fcf366375a5efd5ba235d5021b8932e1 # Parent a60ea8632ff4920277c87eb59d2c29942006484d further improvements on hxc-pokemon-base. diff -r a60ea8632ff4 -r 69184558fcf3 clojure/com/aurellem/gb/hxc.clj --- a/clojure/com/aurellem/gb/hxc.clj Tue Mar 27 00:59:43 2012 -0500 +++ b/clojure/com/aurellem/gb/hxc.clj Tue Mar 27 02:05:16 2012 -0500 @@ -203,67 +203,6 @@ (hxc-thunk-words 0xB8000 14754)) - -(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 - _ - ptr-pic-obverse-1 - ptr-pic-obverse-2 - ptr-pic-reverse-1 - ptr-pic-reverse-2 - move-1 - move-2 - move-3 - move-4 - & - TMs]] - {:dex# n - :base-moves - (mapv moves - ((comp - ;; since the game uses zero as a delimiter, - ;; it must also increment all move indices by 1. - ;; here 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)))}) - - (partition entry-size - (take (* entry-size pkmn-count) - (drop 0x383DE - rom))))))) - - - ;; In red/blue, pokedex stats are in internal order. ;; In yellow, pokedex stats are in pokedex order. @@ -617,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 @@ -690,4 +724,3 @@ - diff -r a60ea8632ff4 -r 69184558fcf3 clojure/com/aurellem/gb/util.clj --- a/clojure/com/aurellem/gb/util.clj Tue Mar 27 00:59:43 2012 -0500 +++ b/clojure/com/aurellem/gb/util.clj Tue Mar 27 02:05:16 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)