Mercurial > vba-clojure
view clojure/com/aurellem/gb/characters.clj @ 234:00e4efa7c104
saving progress...
author | Dylan Holmes <ocsenave@gmail.com> |
---|---|
date | Sat, 24 Mar 2012 18:21:16 -0500 |
parents | d5dddf33543c |
children | 30ced394823a |
line wrap: on
line source
1 (ns com.aurellem.gb.characters2 (:use (com.aurellem.gb gb-driver constants))3 (:import [com.aurellem.gb.gb_driver SaveState]))6 (def pronouns7 ;; Note: 0x0 seems to be the end-of-name sentinel8 {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 })25 (def meta-characters26 {0x00 "non-meta text follows"27 0x01 "load text from RAM (nn)"28 0x02 "BCD number (nn)C" ;; C is 3 flags and 5 length bits."29 0x03 "store text in RAM (nn)"30 0x04 "draw box (nn)WH"31 0x05 "BEGIN text on textbox line 2"32 0x06 "wait for A or B"33 0x07 "scrolling text"34 0x08 "BEGIN routine"35 0x09 "load RAM (nn) hex-to-dec. (nn)BC. B is bytes to read, C is36 digits to display"37 0x0A "wait 30 vblanks iff you pressed A or B"39 0x0B "sound: got item"40 0x0E "sound: learned skill"41 0x0F "sound: got rarecandy" ;; incidentally, same as 'got item'42 0x10 "sound: caught pokemon!"43 0x11 "sound: gave OAK the parcel"44 0x12 "sound: same as 0x10???"45 0x13 "sound: new data added"46 0x14 "sound: cry-nidorina"47 0x15 "sound: cry-pidgeot"48 0x16 "sound: cry-dewgong"50 0x4E "new line"51 0x51 "new page"52 0x55 "scroll page"53 0x50 "END command" ;; the pair 0x50 0x50 ??54 0x57 "END command"55 0x58 "END after you press A or B"56 })61 (def end-of-name-sentinel 0x00)63 (def character-code->character64 {65 0x0 "" ;; separator character?66 0x58 "\n"67 ;;0x00 "<";;"end-of-name-sentinel" ;; begin messsage68 ;;0x49 "\n //" ;; ocsenave: pagebreak pokedex69 ;;0x4E "\n..." ; ocsenave: clearscroll pokedex page70 ;;0x4F "\n" ; newline71 ;;0x50 "#";;"end-of-pokemon-name-sentinel"72 ;;0x51 "\n\n" ;; ocsenave: clear screen73 0x52 "[RED]" ;;ocsenave: placeholder for your name?74 0x54 "[POKE]"75 ;;0x55 "_" ;; ocsenave: breaking space?76 ;0x57 ">" ;; ocsenave: end message77 ;0x5F ">" ;; ocsenave: end pokedex entry??78 0x60 "A-bold"79 0x61 "B-bold"80 0x62 "C-bold"81 0x63 "D-bold"82 0x64 "E-bold"83 0x65 "F-bold"84 0x66 "G-bold"85 0x67 "H-bold"86 0x68 "I-bold"87 0x69 "V-bold"88 0x6A "S-bold"89 0x6B "L-bold"90 0x6C "M-bold"91 0x7F " " ;space92 0x80 "A"93 0x81 "B"94 0x82 "C"95 0x83 "D"96 0x84 "E"97 0x85 "F"98 0x86 "G"99 0x87 "H"100 0x88 "I"101 0x89 "J"102 0x8A "K"103 0x8B "L"104 0x8C "M"105 0x8D "N"106 0x8E "O"107 0x8F "P"108 0x90 "Q"109 0x91 "R"110 0x92 "S"111 0x93 "T"112 0x94 "U"113 0x95 "V"114 0x96 "W"115 0x97 "X"116 0x98 "Y"117 0x99 "Z"118 0x9A "("119 0x9B ")"120 0x9C ":"121 0x9D ";"122 0xA0 "a"123 0xA1 "b"124 0xA2 "c"125 0xA3 "d"126 0xA4 "e"127 0xA5 "f"128 0xA6 "g"129 0xA7 "h"130 0xA8 "i"131 0xA9 "j"132 0xAA "k"133 0xAB "l"134 0xAC "m"135 0xAD "n"136 0xAE "o"137 0xAF "p"138 0xB0 "q"139 0xB1 "r"140 0xB2 "s"141 0xB3 "t"142 0xB4 "u"143 0xB5 "v"144 0xB6 "w"145 0xB7 "x"146 0xB8 "y"147 0xB9 "z"148 0xBA "[e]" ;é149 0xBB "'d" ;ocsenave150 0xBC "'l" ;ocsenave151 0xBD "'s" ;ocsenave152 0xBE "'t" ;ocsenave153 0xBF "'v" ; ocsenave155 0xE0 "'"156 0xE1 "PK"157 0xE2 "MN"158 0xE3 "-"159 0xE4 "'r" ;ocsenave160 0xE5 "'m" ;ocsenave161 0xE6 "?"162 0xE7 "!"163 0xE8 "."164 0xEF "male-symbol"165 0xF0 "$" ;;"pokemon-money-symbol"166 0xF1 "."167 0xF2 "/"168 0xF3 ","169 0xF4 ", "170 0xF5 "female-symbol" ;; ocsenave171 0xF6 "0 "172 0xF7 "1"173 0xF8 "2"174 0xF9 "3"175 0xFA "4"176 0xFB "5"177 0xFC "6"178 0xFD "7"179 0xFE "8"180 0xFF "9"181 })183 (def character->character-code184 (zipmap (vals character-code->character)185 (keys character-code->character)))187 (defn str->character-codes [s]188 (map character->character-code (map str s)))190 (defn character-codes->str [codes]191 (apply str192 (map #(character-code->character193 %194 (format "[0x%02X]" %))195 codes)))197 (defn print-text198 ([^SaveState state begin end]199 (dorun200 (map (fn [character-code line]201 (println202 (format "0x%04X: " line)203 (str (character-code->character character-code))))204 (subvec (vec (memory state)) begin end)205 (range begin end)))206 state)207 ([begin end]208 (print-text @current-state begin end)))210 (defn read-name [codes]211 (character-codes->str212 (take-while213 (partial not= end-of-name-marker) codes)))