view clojure/com/aurellem/gb/characters.clj @ 595:96ee9d72aeb9

saving progress.... sleepy time :)
author Robert McIntyre <rlm@mit.edu>
date Sat, 01 Sep 2012 13:32:19 -0500
parents b2f9a0cb13e3
children
line wrap: on
line source
1 (ns com.aurellem.gb.characters
2 (:use (com.aurellem.gb gb-driver constants))
3 (:import [com.aurellem.gb.gb_driver SaveState]))
6 (def pronouns
7 ;; Note: 0x0 seems to be the end-of-name sentinel
8 {
9 ;; what is 0x57? what is 0x0?
10 :RED [0x52]
11 :BLUE [0x53]
12 :opponent [0x01 0x49 0xD0 0x0]
13 :turn-pokemon [0x5A]
14 :off-turn-pokemon [0x59]
15 :your-pokemon [0x01 0x08 0xD0 0x0]
16 :opponent-pokemon [0x50 0x01 0xD9 0xCF 0x0]
17 :n-times [0x50 0x09 0x05 0xCD 0x11 0x0]
18 })
22 (def meta-characters
23 {0x00 "non-meta text follows"
24 0x01 "load text from RAM (nn)"
25 0x02 "BCD number (nn)C" ;; C is 3 flags and 5 length bits."
26 0x03 "store text in RAM (nn)"
27 0x04 "draw box (nn)WH"
28 0x05 "BEGIN text on textbox line 2"
29 0x06 "wait for A or B"
30 0x07 "scrolling text"
31 0x08 "BEGIN routine"
32 0x09 "load RAM (nn) hex-to-dec. (nn)BC. B is bytes to read, C is
33 digits to display"
34 0x0A "wait 30 vblanks iff you pressed A or B"
36 0x0B "sound: got item"
37 0x0E "sound: learned skill"
38 0x0F "sound: got rarecandy" ;; incidentally, same as 'got item'
39 0x10 "sound: caught pokemon!"
40 0x11 "sound: gave OAK the parcel"
41 0x12 "sound: same as 0x10???"
42 0x13 "sound: new data added"
43 0x14 "sound: cry-nidorina"
44 0x15 "sound: cry-pidgeot"
45 0x16 "sound: cry-dewgong"
47 0x4E "new line"
48 0x51 "new page"
49 0x55 "scroll page"
50 0x50 "END command" ;; the pair 0x50 0x50 ??
51 0x57 "END command"
52 0x58 "END after you press A or B"
53 })
58 (def end-of-name-sentinel 0x00)
60 (def character-code->character
61 {
62 0x0 "" ;; separator character?
63 0x58 "\n"
64 ;;0x00 "<";;"end-of-name-sentinel" ;; begin messsage
65 0x49 "\n //" ;; ocsenave: pagebreak pokedex
66 0x4E "\n..." ; ocsenave: clearscroll pokedex page
67 0x4F "\n" ; newline
68 0x50 "#";;"end-of-pokemon-name-sentinel"
69 0x51 "\n\n" ;; ocsenave: clear screen
70 0x52 "[RED]" ;;ocsenave: placeholder for your name?
71 0x54 "[POKE]"
72 0x55 "_" ;; ocsenave: breaking space?
73 0x57 ">" ;; ocsenave: end message
74 0x5F ">" ;; ocsenave: end pokedex entry??
75 0x60 "A-bold"
76 0x61 "B-bold"
77 0x62 "C-bold"
78 0x63 "D-bold"
79 0x64 "E-bold"
80 0x65 "F-bold"
81 0x66 "G-bold"
82 0x67 "H-bold"
83 0x68 "I-bold"
84 0x69 "V-bold"
85 0x6A "S-bold"
86 0x6B "L-bold"
87 0x6C "M-bold"
88 0x7F " " ;space
89 0x80 "A"
90 0x81 "B"
91 0x82 "C"
92 0x83 "D"
93 0x84 "E"
94 0x85 "F"
95 0x86 "G"
96 0x87 "H"
97 0x88 "I"
98 0x89 "J"
99 0x8A "K"
100 0x8B "L"
101 0x8C "M"
102 0x8D "N"
103 0x8E "O"
104 0x8F "P"
105 0x90 "Q"
106 0x91 "R"
107 0x92 "S"
108 0x93 "T"
109 0x94 "U"
110 0x95 "V"
111 0x96 "W"
112 0x97 "X"
113 0x98 "Y"
114 0x99 "Z"
115 0x9A "("
116 0x9B ")"
117 0x9C ":"
118 0x9D ";"
119 0xA0 "a"
120 0xA1 "b"
121 0xA2 "c"
122 0xA3 "d"
123 0xA4 "e"
124 0xA5 "f"
125 0xA6 "g"
126 0xA7 "h"
127 0xA8 "i"
128 0xA9 "j"
129 0xAA "k"
130 0xAB "l"
131 0xAC "m"
132 0xAD "n"
133 0xAE "o"
134 0xAF "p"
135 0xB0 "q"
136 0xB1 "r"
137 0xB2 "s"
138 0xB3 "t"
139 0xB4 "u"
140 0xB5 "v"
141 0xB6 "w"
142 0xB7 "x"
143 0xB8 "y"
144 0xB9 "z"
145 0xBA "é"
146 0xBB "'d" ;ocsenave
147 0xBC "'l" ;ocsenave
148 0xBD "'s" ;ocsenave
149 0xBE "'t" ;ocsenave
150 0xBF "'v" ; ocsenave
152 0xE0 "'"
153 0xE1 "PK"
154 0xE2 "MN"
155 0xE3 "-"
156 0xE4 "'r" ;ocsenave
157 0xE5 "'m" ;ocsenave
158 0xE6 "?"
159 0xE7 "!"
160 0xE8 "."
161 0xEF "♂"
162 0xF0 "$" ;;"pokemon-money-symbol"
163 0xF1 "."
164 0xF2 "/"
165 0xF3 ","
166 0xF4 ", "
167 0xF5 "♀"
168 0xF6 "0 "
169 0xF7 "1"
170 0xF8 "2"
171 0xF9 "3"
172 0xFA "4"
173 0xFB "5"
174 0xFC "6"
175 0xFD "7"
176 0xFE "8"
177 0xFF "9"
178 })
180 (def character->character-code
181 (zipmap (vals character-code->character)
182 (keys character-code->character)))
184 (defn str->character-codes [s]
185 (map character->character-code (map str s)))
187 (defn character-codes->str [codes]
188 (apply str
189 (map #(character-code->character
190 %
191 (format "[0x%02X]" %))
192 codes)))
194 (defn print-text
195 ([^SaveState state begin end]
196 (dorun
197 (map (fn [character-code line]
198 (println
199 (format "0x%04X: " line)
200 (str (character-code->character character-code))))
201 (subvec (vec (memory state)) begin end)
202 (range begin end)))
203 state)
204 ([begin end]
205 (print-text @current-state begin end)))
207 (defn read-name [codes]
208 (character-codes->str
209 (take-while
210 (partial not= end-of-name-marker) codes)))