diff clojure/com/aurellem/gb/hxc.clj @ 307:872e032949ff

completed cry functions.
author Dylan Holmes <ocsenave@gmail.com>
date Sat, 31 Mar 2012 03:54:21 -0500
parents 2873f50b7291
children de172acc5a03
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/gb/hxc.clj	Sat Mar 31 01:27:46 2012 -0500
     1.2 +++ b/clojure/com/aurellem/gb/hxc.clj	Sat Mar 31 03:54:21 2012 -0500
     1.3 @@ -1,7 +1,7 @@
     1.4  (ns com.aurellem.gb.hxc
     1.5    (:use (com.aurellem.gb assembly characters gb-driver util
     1.6                           constants species))
     1.7 - ;; (:use (com.aurellem.world practice))
     1.8 +  (:use (com.aurellem.world practice))
     1.9    (:import [com.aurellem.gb.gb_driver SaveState]))
    1.10  
    1.11  
    1.12 @@ -209,12 +209,49 @@
    1.13  
    1.14  
    1.15  ;; http://hax.iimarck.us/topic/581/
    1.16 -(defn hxc-pokedex-cry
    1.17 -  "The pokemon cry data in internal order. List begins at ROM@410B1
    1.18 -  []
    1.19 +(defn hxc-cry
    1.20 +  "The pokemon cry data in internal order. List begins at ROM@39462"
    1.21 +  ([](hxc-cry com.aurellem.gb.gb-driver/original-rom)
    1.22 +  ([rom]
    1.23 +     (zipmap
    1.24 +      (hxc-pokenames rom)
    1.25 +      (map
    1.26 +       (fn [[cry-id pitch length]]
    1.27 +         {:cry-id cry-id
    1.28 +         :pitch pitch
    1.29 +          :length length}
    1.30 +         )
    1.31 +       (partition 3
    1.32 +                  (drop 0x39462 rom)))))))
    1.33  
    1.34 +(defn hxc-cry-groups
    1.35 +  ([] (hxc-cry-ids com.aurellem.gb.gb-driver/original-rom))
    1.36 +  ([rom]
    1.37 +     (map #(mapv first
    1.38 +                (filter
    1.39 +                 (fn [[k v]]
    1.40 +                   (= % (:cry-id v)))
    1.41 +                 (hxc-cry rom)))
    1.42 +          ((comp
    1.43 +            range
    1.44 +            count
    1.45 +            set
    1.46 +            (partial map :cry-id)
    1.47 +            vals
    1.48 +            hxc-cry)
    1.49 +           rom))))
    1.50  
    1.51  
    1.52 +(defn cry-conversion!
    1.53 +  "Convert Porygon's cry in ROM to be the cry of the given pokemon."
    1.54 +  [pkmn]
    1.55 +  (write-rom!
    1.56 +   (rewrite-memory
    1.57 +    (vec(rom))
    1.58 +    0x3965D 
    1.59 +    (map second
    1.60 +         ((hxc-cry) pkmn)))))
    1.61 +
    1.62  (def hxc-items-raw
    1.63    "The hardcoded names of the items in memory. List begins at
    1.64  ROM@045B7"