diff clojure/com/aurellem/gb/hxc.clj @ 315:363b650a77cc

merge
author Robert McIntyre <rlm@mit.edu>
date Mon, 02 Apr 2012 20:30:28 -0500
parents 2060219691fa
children 5639312a393f
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/gb/hxc.clj	Mon Apr 02 20:30:02 2012 -0500
     1.2 +++ b/clojure/com/aurellem/gb/hxc.clj	Mon Apr 02 20:30:28 2012 -0500
     1.3 @@ -1,7 +1,6 @@
     1.4  (ns com.aurellem.gb.hxc
     1.5 -  (:use (com.aurellem.gb assembly characters gb-driver util
     1.6 +  (:use (com.aurellem.gb assembly characters gb-driver util mem-util
     1.7                           constants species))
     1.8 - ;; (:use (com.aurellem.world practice))
     1.9    (:import [com.aurellem.gb.gb_driver SaveState]))
    1.10  
    1.11  
    1.12 @@ -208,6 +207,49 @@
    1.13  
    1.14  
    1.15  
    1.16 +;; http://hax.iimarck.us/topic/581/
    1.17 +(defn hxc-cry
    1.18 +  "The pokemon cry data in internal order. List begins at ROM@39462"
    1.19 +  ([](hxc-cry com.aurellem.gb.gb-driver/original-rom))
    1.20 +  ([rom]
    1.21 +     (zipmap
    1.22 +      (hxc-pokenames rom)
    1.23 +      (map
    1.24 +       (fn [[cry-id pitch length]]
    1.25 +         {:cry-id cry-id
    1.26 +         :pitch pitch
    1.27 +          :length length}
    1.28 +         )
    1.29 +       (partition 3
    1.30 +                  (drop 0x39462 rom))))))
    1.31 +
    1.32 +(defn hxc-cry-groups
    1.33 +  ([] (hxc-cry-groups com.aurellem.gb.gb-driver/original-rom))
    1.34 +  ([rom]
    1.35 +     (map #(mapv first
    1.36 +                (filter
    1.37 +                 (fn [[k v]]
    1.38 +                   (= % (:cry-id v)))
    1.39 +                 (hxc-cry)))
    1.40 +          ((comp
    1.41 +            range
    1.42 +            count
    1.43 +            set
    1.44 +            (partial map :cry-id)
    1.45 +            vals
    1.46 +            hxc-cry)
    1.47 +           rom))))
    1.48 +
    1.49 +
    1.50 +(defn cry-conversion!
    1.51 +  "Convert Porygon's cry in ROM to be the cry of the given pokemon."
    1.52 +  [pkmn]
    1.53 +  (write-rom!
    1.54 +   (rewrite-memory
    1.55 +    (vec(rom))
    1.56 +    0x3965D 
    1.57 +    (map second
    1.58 +         ((hxc-cry) pkmn)))))
    1.59  
    1.60  (def hxc-items-raw
    1.61    "The hardcoded names of the items in memory. List begins at
    1.62 @@ -398,7 +440,7 @@
    1.63    
    1.64  
    1.65  (defn hxc-machines
    1.66 -  "The hardcoded moves taught by TMs and HMs. List begins at ROM@0x1232D."
    1.67 +  "The hardcoded moves taught by TMs and HMs. List begins at ROM@1232D."
    1.68    ([] (hxc-machines
    1.69         com.aurellem.gb.gb-driver/original-rom))
    1.70    ([rom]
    1.71 @@ -694,6 +736,9 @@
    1.72                :base-def rating-def
    1.73                :base-speed rating-speed
    1.74                :base-special rating-special
    1.75 +              :o0 pic-dimensions
    1.76 +              :o1 ptr-pic-obverse-1
    1.77 +              :o2 ptr-pic-obverse-2
    1.78                }))
    1.79           
    1.80           (partition entry-size
    1.81 @@ -702,7 +747,27 @@
    1.82                                  rom))))))))
    1.83    
    1.84    
    1.85 +(defn hxc-intro-pkmn
    1.86 +  "The hardcoded pokemon to display in Prof. Oak's introduction; the pokemon's
    1.87 +internal id is stored at ROM@5EDB."
    1.88 +  ([] (hxc-intro-pkmn
    1.89 +       com.aurellem.gb.gb-driver/original-rom))
    1.90 +  ([rom]
    1.91 +     (nth (hxc-pokenames rom) (nth rom 0x5EDB))))
    1.92 +
    1.93 +(defn sxc-intro-pkmn!
    1.94 +  "Set the hardcoded pokemon to display in Prof. Oak's introduction."
    1.95 +  [pokemon]
    1.96 +  (write-rom! 
    1.97 +   (rewrite-rom 0x5EDB
    1.98 +                [
    1.99 +                 (inc
   1.100 +                  ((zipmap
   1.101 +                    (hxc-pokenames)
   1.102 +                    (range))
   1.103 +                   pokemon))])))
   1.104    
   1.105 +
   1.106  (defn hxc-item-prices
   1.107    "The hardcoded list of item prices in memory. List begins at ROM@4495"
   1.108    ([] (hxc-item-prices com.aurellem.gb.gb-driver/original-rom))