view clojure/com/aurellem/gb/characters.clj @ 213:57258c269bcb

Added spelling bee.
author Dylan Holmes <ocsenave@gmail.com>
date Fri, 23 Mar 2012 19:05:08 -0500
parents a67f1df5d096
children 0587f266a735
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]
18 :n-times [0x50 0x09 0x05 0xCD 0x11 0x0]
21 })
24 (def character-code->character
25 {
26 0x0 "" ;; separator character?
27 0x58 "\n"
28 ;0x00 "<";;"end-of-name-sentinel" ;; begin messsage
29 ;;0x49 "\n //" ;; ocsenave: pagebreak pokedex
30 ;;0x4E "\n..." ; ocsenave: clearscroll pokedex page
31 0x4F "\n" ; newline
32 ;;0x50 "#";;"end-of-pokemon-name-sentinel"
33 0x51 "\n\n" ;; ocsenave: clear screen
34 0x52 "[RED]" ;;ocsenave: placeholder for your name?
35 0x54 "[POKE]"
36 0x55 "_" ;; ocsenave: breaking space?
37 ;0x57 ">" ;; ocsenave: end message
38 ;0x5F ">" ;; ocsenave: end pokedex entry??
39 0x60 "A-bold"
40 0x61 "B-bold"
41 0x62 "C-bold"
42 0x63 "D-bold"
43 0x64 "E-bold"
44 0x65 "F-bold"
45 0x66 "G-bold"
46 0x67 "H-bold"
47 0x68 "I-bold"
48 0x69 "V-bold"
49 0x6A "S-bold"
50 0x6B "L-bold"
51 0x6C "M-bold"
52 0x7F " " ;space
53 0x80 "A"
54 0x81 "B"
55 0x82 "C"
56 0x83 "D"
57 0x84 "E"
58 0x85 "F"
59 0x86 "G"
60 0x87 "H"
61 0x88 "I"
62 0x89 "J"
63 0x8A "K"
64 0x8B "L"
65 0x8C "M"
66 0x8D "N"
67 0x8E "O"
68 0x8F "P"
69 0x90 "Q"
70 0x91 "R"
71 0x92 "S"
72 0x93 "T"
73 0x94 "U"
74 0x95 "V"
75 0x96 "W"
76 0x97 "X"
77 0x98 "Y"
78 0x99 "Z"
79 0x9A "("
80 0x9B ")"
81 0x9C ":"
82 0x9D ";"
83 0xA0 "a"
84 0xA1 "b"
85 0xA2 "c"
86 0xA3 "d"
87 0xA4 "e"
88 0xA5 "f"
89 0xA6 "g"
90 0xA7 "h"
91 0xA8 "i"
92 0xA9 "j"
93 0xAA "k"
94 0xAB "l"
95 0xAC "m"
96 0xAD "n"
97 0xAE "o"
98 0xAF "p"
99 0xB0 "q"
100 0xB1 "r"
101 0xB2 "s"
102 0xB3 "t"
103 0xB4 "u"
104 0xB5 "v"
105 0xB6 "w"
106 0xB7 "x"
107 0xB8 "y"
108 0xB9 "z"
109 0xBA "[e]" ;é
110 0xBB "'d" ;ocsenave
111 0xBC "'l" ;ocsenave
112 0xBD "'s" ;ocsenave
113 0xBE "'t" ;ocsenave
114 0xBF "'v" ; ocsenave
116 0xE0 "'"
117 0xE1 "PK"
118 0xE2 "MN"
119 0xE3 "-"
120 0xE4 "'r" ;ocsenave
121 0xE5 "'m" ;ocsenave
122 0xE6 "?"
123 0xE7 "!"
124 0xE8 "."
125 0xEF "male-symbol"
126 0xF0 "$" ;;"pokemon-money-symbol"
127 0xF1 "."
128 0xF2 "/"
129 0xF3 ","
130 0xF4 ", "
131 0xF5 "female-symbol" ;; ocsenave
132 0xF6 "0 "
133 0xF7 "1"
134 0xF8 "2"
135 0xF9 "3"
136 0xFA "4"
137 0xFB "5"
138 0xFC "6"
139 0xFD "7"
140 0xFE "8"
141 0xFF "9"
142 })
144 (def character->character-code
145 (zipmap (vals character-code->character)
146 (keys character-code->character)))
148 (defn str->character-codes [s]
149 (map character->character-code (map str s)))
151 (defn character-codes->str [codes]
152 (apply str
153 (map #(character-code->character
154 %
155 (format "[0x%02X]" %))
156 codes)))
160 (defn print-text
161 ([^SaveState state begin end]
162 (dorun
163 (map (fn [character-code line]
164 (println
165 (format "0x%04X: " line)
166 (str (character-code->character character-code))))
167 (subvec (vec (memory state)) begin end)
168 (range begin end)))
169 state)
170 ([begin end]
171 (print-text @current-state begin end)))
173 (defn read-name [codes]
174 (character-codes->str
175 (take-while
176 (partial not= end-of-name-marker) codes)))