Mercurial > vba-clojure
changeset 273:69184558fcf3
further improvements on hxc-pokemon-base.
author | Dylan Holmes <ocsenave@gmail.com> |
---|---|
date | Tue, 27 Mar 2012 02:05:16 -0500 |
parents | a60ea8632ff4 |
children | 18336ab5d6ea |
files | clojure/com/aurellem/gb/hxc.clj clojure/com/aurellem/gb/util.clj |
diffstat | 2 files changed, 98 insertions(+), 64 deletions(-) [+] |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/gb/hxc.clj Tue Mar 27 00:59:43 2012 -0500 1.2 +++ b/clojure/com/aurellem/gb/hxc.clj Tue Mar 27 02:05:16 2012 -0500 1.3 @@ -203,67 +203,6 @@ 1.4 (hxc-thunk-words 0xB8000 14754)) 1.5 1.6 1.7 - 1.8 -(defn hxc-pokemon-base 1.9 - ([] (hxc-pokemon-base com.aurellem.gb.gb-driver/original-rom)) 1.10 - ([rom] 1.11 - (let [entry-size 28 1.12 - pkmn-count (count (hxc-pokedex-text rom)) 1.13 - types (apply assoc {} 1.14 - (interleave 1.15 - (range) 1.16 - pkmn-types)) ;;!! softcoded 1.17 - moves (apply assoc {} 1.18 - (interleave 1.19 - (range) 1.20 - (map format-name 1.21 - (hxc-move-names rom)))) 1.22 - 1.23 - ] 1.24 - (map 1.25 - 1.26 - (fn [[n 1.27 - rating-hp 1.28 - rating-atk 1.29 - rating-def 1.30 - rating-speed 1.31 - rating-special 1.32 - type-1 1.33 - type-2 1.34 - rarity 1.35 - rating-xp 1.36 - _ 1.37 - ptr-pic-obverse-1 1.38 - ptr-pic-obverse-2 1.39 - ptr-pic-reverse-1 1.40 - ptr-pic-reverse-2 1.41 - move-1 1.42 - move-2 1.43 - move-3 1.44 - move-4 1.45 - & 1.46 - TMs]] 1.47 - {:dex# n 1.48 - :base-moves 1.49 - (mapv moves 1.50 - ((comp 1.51 - ;; since the game uses zero as a delimiter, 1.52 - ;; it must also increment all move indices by 1. 1.53 - ;; here we decrement to correct this. 1.54 - (partial map dec) 1.55 - (partial take-while (comp not zero?))) 1.56 - [move-1 move-2 move-3 move-4])) 1.57 - 1.58 - :types (set (list (types type-1) 1.59 - (types type-2)))}) 1.60 - 1.61 - (partition entry-size 1.62 - (take (* entry-size pkmn-count) 1.63 - (drop 0x383DE 1.64 - rom))))))) 1.65 - 1.66 - 1.67 - 1.68 ;; In red/blue, pokedex stats are in internal order. 1.69 ;; In yellow, pokedex stats are in pokedex order. 1.70 1.71 @@ -617,6 +556,101 @@ 1.72 1.73 1.74 1.75 +(defn hxc-pokemon-base 1.76 + ([] (hxc-pokemon-base com.aurellem.gb.gb-driver/original-rom)) 1.77 + ([rom] 1.78 + (let [entry-size 28 1.79 + pkmn-count (count (hxc-pokedex-text rom)) 1.80 + types (apply assoc {} 1.81 + (interleave 1.82 + (range) 1.83 + pkmn-types)) ;;!! softcoded 1.84 + moves (apply assoc {} 1.85 + (interleave 1.86 + (range) 1.87 + (map format-name 1.88 + (hxc-move-names rom)))) 1.89 + ] 1.90 + (map 1.91 + 1.92 + (fn [[n 1.93 + rating-hp 1.94 + rating-atk 1.95 + rating-def 1.96 + rating-speed 1.97 + rating-special 1.98 + type-1 1.99 + type-2 1.100 + rarity 1.101 + rating-xp 1.102 + pic-dimensions 1.103 + ptr-pic-obverse-1 1.104 + ptr-pic-obverse-2 1.105 + ptr-pic-reverse-1 1.106 + ptr-pic-reverse-2 1.107 + move-1 1.108 + move-2 1.109 + move-3 1.110 + move-4 1.111 + growth-rate 1.112 + & 1.113 + TMs|HMs]] 1.114 + (let 1.115 + [base-moves 1.116 + (mapv moves 1.117 + ((comp 1.118 + ;; since the game uses zero as a delimiter, 1.119 + ;; it must also increment all move indices by 1. 1.120 + ;; heren we decrement to correct this. 1.121 + (partial map dec) 1.122 + (partial take-while (comp not zero?))) 1.123 + [move-1 move-2 move-3 move-4])) 1.124 + 1.125 + types 1.126 + (set (list (types type-1) 1.127 + (types type-2))) 1.128 + TMs|HMs 1.129 + (map 1.130 + (comp 1.131 + (partial map first) 1.132 + (partial remove (comp zero? second))) 1.133 + (split-at 1.134 + 50 1.135 + (map vector 1.136 + (rest(range)) 1.137 + (reduce concat 1.138 + (map 1.139 + #(take 8 1.140 + (concat (bit-list %) 1.141 + (repeat 0))) 1.142 + 1.143 + TMs|HMs))))) 1.144 + 1.145 + TMs (vec (first TMs|HMs)) 1.146 + HMs (take 5 (map (partial + -50) (vec (second TMs|HMs)))) 1.147 + 1.148 + 1.149 + ] 1.150 + 1.151 + 1.152 + {:dex# n 1.153 + :base-moves base-moves 1.154 + :types types 1.155 + :TMs TMs 1.156 + :HMs HMs 1.157 + :base-hp rating-hp 1.158 + :base-atk rating-atk 1.159 + :base-def rating-def 1.160 + :base-speed rating-speed 1.161 + :base-special rating-special 1.162 + })) 1.163 + 1.164 + (partition entry-size 1.165 + (take (* entry-size pkmn-count) 1.166 + (drop 0x383DE 1.167 + rom))))))) 1.168 + 1.169 + 1.170 ;; ********************** MANIPULATION FNS 1.171 1.172 1.173 @@ -690,4 +724,3 @@ 1.174 1.175 1.176 1.177 -
2.1 --- a/clojure/com/aurellem/gb/util.clj Tue Mar 27 00:59:43 2012 -0500 2.2 +++ b/clojure/com/aurellem/gb/util.clj Tue Mar 27 02:05:16 2012 -0500 2.3 @@ -29,6 +29,7 @@ 2.4 (Integer/parseInt 2.5 (Integer/toBinaryString num) 10))) 2.6 2.7 + 2.8 (defn view-register [state name reg-fn] 2.9 (println (format "%s: %s" name 2.10 (binary-str (reg-fn state)))) 2.11 @@ -122,8 +123,8 @@ 2.12 2.13 (defn disect-bytes-2 2.14 "return a vector consiting of the last 16 bytes of the 2.15 - integer expressed as two 8 bit nimbers (inside an integer) 2.16 - in the form [high-bits low-bits." 2.17 + integer expressed as two 8 bit numbers (inside an integer) 2.18 + in the form [high-bits low-bits]." 2.19 [num] 2.20 [(bit-shift-right 2.21 (bit-and num 0xFF00) 8)