diff clojure/com/aurellem/gb/util.clj @ 222:c9a855de1d07

enabled pokedex printing.
author Robert McIntyre <rlm@mit.edu>
date Sat, 24 Mar 2012 03:10:56 -0500
parents 8523faa122b0
children fe26776e1a58
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/gb/util.clj	Sat Mar 24 00:13:06 2012 -0500
     1.2 +++ b/clojure/com/aurellem/gb/util.clj	Sat Mar 24 03:10:56 2012 -0500
     1.3 @@ -1,8 +1,8 @@
     1.4  (ns com.aurellem.gb.util
     1.5 -  (:use (com.aurellem.gb gb-driver vbm))
     1.6 +  (:use (com.aurellem.gb gb-driver vbm constants))
     1.7 +  (:import java.io.File)
     1.8    (:import [com.aurellem.gb.gb_driver SaveState]))
     1.9  
    1.10 -
    1.11  (defn A [state]
    1.12    (bit-shift-right (bit-and 0x0000FF00 (AF state)) 8))
    1.13  
    1.14 @@ -145,4 +145,30 @@
    1.15       (+ (glue-bytes m l)
    1.16          (bit-shift-left h 16))))
    1.17  
    1.18 +(def cartography
    1.19 +  (File. user-home
    1.20 +         "proj/vba-clojure/clojure/com/aurellem/exp/cartography"))
    1.21  
    1.22 +
    1.23 +
    1.24 +(defn print-D-memory
    1.25 +  ([^SaveState state]
    1.26 +     
    1.27 +     (let [descriptions
    1.28 +           (clojure.string/split-lines
    1.29 +            (slurp cartography))]
    1.30 +       (dorun
    1.31 +        (map
    1.32 +         (fn [line data desc]
    1.33 +           (printf "%04X  %02X%s\n"
    1.34 +                   line data (apply str
    1.35 +                                    (drop 20 desc))))
    1.36 +         (range pokemon-record-begin
    1.37 +                (inc D-memory-end))
    1.38 +         
    1.39 +         (subvec (vec (memory state))
    1.40 +                 pokemon-record-begin
    1.41 +                 (inc D-memory-end))
    1.42 +         descriptions))))
    1.43 +  ([] (print-D-memory @current-state)))
    1.44 +