comparison clojure/com/aurellem/gb/characters.clj @ 176:95b2758dd517

wrote functions to read and write pokemon DV values and status
author Robert McIntyre <rlm@mit.edu>
date Wed, 21 Mar 2012 22:13:43 -0500
parents 06426d25c65b
children 67c42608ef9d
comparison
equal deleted inserted replaced
175:5d9a7a0ca09a 176:95b2758dd517
1 (ns com.aurellem.gb.characters 1 (ns com.aurellem.gb.characters
2 (:use (com.aurellem.gb gb-driver)) 2 (:use (com.aurellem.gb gb-driver constants))
3 (:import [com.aurellem.gb.gb_driver SaveState])) 3 (:import [com.aurellem.gb.gb_driver SaveState]))
4 4
5 (def character-code->character 5 (def character-code->character
6 { 6 {
7 0x00 "end-of-name-sentinel" 7 0x00 "end-of-name-sentinel"
112 (apply str 112 (apply str
113 (map #(character-code->character 113 (map #(character-code->character
114 % 114 %
115 (format "[0x%02X]" %)) 115 (format "[0x%02X]" %))
116 codes))) 116 codes)))
117
118 117
118 (defn print-text
119 ([^SaveState state begin end]
120 (dorun
121 (map (fn [character-code line]
122 (println
123 (format "0x%04X: " line)
124 (str (character-code->character character-code))))
125 (subvec (vec (memory state)) begin end)
126 (range begin end)))
127 state)
128 ([begin end]
129 (print-text @current-state begin end)))
130
131 (defn read-name [codes]
132 (character-codes->str
133 (take-while
134 (partial not= end-of-name-marker) codes)))