Mercurial > vba-clojure
view clojure/com/aurellem/gb/characters.clj @ 194:67c42608ef9d
Further explorations in memory.
author | Dylan Holmes <ocsenave@gmail.com> |
---|---|
date | Fri, 23 Mar 2012 00:24:54 -0500 |
parents | 95b2758dd517 |
children | a67f1df5d096 |
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]))5 (def character-code->character6 {7 0x00 "<";;"end-of-name-sentinel" ;; begin messsage8 0x4F "\n" ; newline9 0x50 "#";;"end-of-pokemon-name-sentinel"10 0x51 "\n\n" ;; ocsenave: clear screen11 0x54 "[POKE]"12 0x55 "_" ;; ocsenave: breaking space?13 0x57 ">" ;; ocsenave: end message14 0x60 "A-bold"15 0x61 "B-bold"16 0x62 "C-bold"17 0x63 "D-bold"18 0x64 "E-bold"19 0x65 "F-bold"20 0x66 "G-bold"21 0x67 "H-bold"22 0x68 "I-bold"23 0x69 "V-bold"24 0x6A "S-bold"25 0x6B "L-bold"26 0x6C "M-bold"27 0x7F " " ;space28 0x80 "A"29 0x81 "B"30 0x82 "C"31 0x83 "D"32 0x84 "E"33 0x85 "F"34 0x86 "G"35 0x87 "H"36 0x88 "I"37 0x89 "J"38 0x8A "K"39 0x8B "L"40 0x8C "M"41 0x8D "N"42 0x8E "O"43 0x8F "P"44 0x90 "Q"45 0x91 "R"46 0x92 "S"47 0x93 "T"48 0x94 "U"49 0x95 "V"50 0x96 "W"51 0x97 "X"52 0x98 "Y"53 0x99 "Z"54 0x9A "("55 0x9B ")"56 0x9C ":"57 0x9D ";"58 0xA0 "a"59 0xA1 "b"60 0xA2 "c"61 0xA3 "d"62 0xA4 "e"63 0xA5 "f"64 0xA6 "g"65 0xA7 "h"66 0xA8 "i"67 0xA9 "j"68 0xAA "k"69 0xAB "l"70 0xAC "m"71 0xAD "n"72 0xAE "o"73 0xAF "p"74 0xB0 "q"75 0xB1 "r"76 0xB2 "s"77 0xB3 "t"78 0xB4 "u"79 0xB5 "v"80 0xB6 "w"81 0xB7 "x"82 0xB8 "y"83 0xB9 "z"84 0xBA "[e]" ;é85 0xBB "'d" ;ocsenave86 0xBC "'l" ;ocsenave87 0xBD "'s" ;ocsenave88 0xBE "'t" ;ocsenave89 0xBF "'v" ; ocsenave91 0xE0 "'"92 0xE1 "PK"93 0xE2 "MN"94 0xE3 "-"95 0xE4 "'r" ;ocsenave96 0xE5 "'m" ;ocsenave97 0xE6 "?"98 0xE7 "!"99 0xE8 "."100 0xEF "male-symbol"101 0xF0 "$" ;;"pokemon-money-symbol"102 0xF1 "."103 0xF2 "/"104 0xF3 ","105 0xF4 ", "106 0xF5 "female-symbol" ;; ocsenave107 0xF6 "0 "108 0xF7 "1"109 0xF8 "2"110 0xF9 "3"111 0xFA "4"112 0xFB "5"113 0xFC "6"114 0xFD "7"115 0xFE "8"116 0xFF "9"117 })119 (def character->character-code120 (zipmap (vals character-code->character)121 (keys character-code->character)))123 (defn str->character-codes [s]124 (map character->character-code (map str s)))126 (defn character-codes->str [codes]127 (apply str128 (map #(character-code->character129 %130 (format "[0x%02X]" %))131 codes)))135 (defn print-text136 ([^SaveState state begin end]137 (dorun138 (map (fn [character-code line]139 (println140 (format "0x%04X: " line)141 (str (character-code->character character-code))))142 (subvec (vec (memory state)) begin end)143 (range begin end)))144 state)145 ([begin end]146 (print-text @current-state begin end)))148 (defn read-name [codes]149 (character-codes->str150 (take-while151 (partial not= end-of-name-marker) codes)))