Mercurial > vba-clojure
view clojure/com/aurellem/gb/characters.clj @ 235:5becef6312b9
working on item-injection; fixed off-by-one error in print-pokedex.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 24 Mar 2012 20:05:47 -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]17 :n-times [0x50 0x09 0x05 0xCD 0x11 0x0]18 })20 (def end-of-name-sentinel 0x00)22 (def character-code->character23 {24 0x0 "" ;; separator character?25 0x58 "\n"26 ;;0x00 "<";;"end-of-name-sentinel" ;; begin messsage27 ;;0x49 "\n //" ;; ocsenave: pagebreak pokedex28 ;;0x4E "\n..." ; ocsenave: clearscroll pokedex page29 ;;0x4F "\n" ; newline30 ;;0x50 "#";;"end-of-pokemon-name-sentinel"31 ;;0x51 "\n\n" ;; ocsenave: clear screen32 0x52 "[RED]" ;;ocsenave: placeholder for your name?33 0x54 "[POKE]"34 ;;0x55 "_" ;; ocsenave: breaking space?35 ;0x57 ">" ;; ocsenave: end message36 ;0x5F ">" ;; ocsenave: end pokedex entry??37 0x60 "A-bold"38 0x61 "B-bold"39 0x62 "C-bold"40 0x63 "D-bold"41 0x64 "E-bold"42 0x65 "F-bold"43 0x66 "G-bold"44 0x67 "H-bold"45 0x68 "I-bold"46 0x69 "V-bold"47 0x6A "S-bold"48 0x6B "L-bold"49 0x6C "M-bold"50 0x7F " " ;space51 0x80 "A"52 0x81 "B"53 0x82 "C"54 0x83 "D"55 0x84 "E"56 0x85 "F"57 0x86 "G"58 0x87 "H"59 0x88 "I"60 0x89 "J"61 0x8A "K"62 0x8B "L"63 0x8C "M"64 0x8D "N"65 0x8E "O"66 0x8F "P"67 0x90 "Q"68 0x91 "R"69 0x92 "S"70 0x93 "T"71 0x94 "U"72 0x95 "V"73 0x96 "W"74 0x97 "X"75 0x98 "Y"76 0x99 "Z"77 0x9A "("78 0x9B ")"79 0x9C ":"80 0x9D ";"81 0xA0 "a"82 0xA1 "b"83 0xA2 "c"84 0xA3 "d"85 0xA4 "e"86 0xA5 "f"87 0xA6 "g"88 0xA7 "h"89 0xA8 "i"90 0xA9 "j"91 0xAA "k"92 0xAB "l"93 0xAC "m"94 0xAD "n"95 0xAE "o"96 0xAF "p"97 0xB0 "q"98 0xB1 "r"99 0xB2 "s"100 0xB3 "t"101 0xB4 "u"102 0xB5 "v"103 0xB6 "w"104 0xB7 "x"105 0xB8 "y"106 0xB9 "z"107 0xBA "[e]" ;é108 0xBB "'d" ;ocsenave109 0xBC "'l" ;ocsenave110 0xBD "'s" ;ocsenave111 0xBE "'t" ;ocsenave112 0xBF "'v" ; ocsenave114 0xE0 "'"115 0xE1 "PK"116 0xE2 "MN"117 0xE3 "-"118 0xE4 "'r" ;ocsenave119 0xE5 "'m" ;ocsenave120 0xE6 "?"121 0xE7 "!"122 0xE8 "."123 0xEF "male-symbol"124 0xF0 "$" ;;"pokemon-money-symbol"125 0xF1 "."126 0xF2 "/"127 0xF3 ","128 0xF4 ", "129 0xF5 "female-symbol" ;; ocsenave130 0xF6 "0 "131 0xF7 "1"132 0xF8 "2"133 0xF9 "3"134 0xFA "4"135 0xFB "5"136 0xFC "6"137 0xFD "7"138 0xFE "8"139 0xFF "9"140 })142 (def character->character-code143 (zipmap (vals character-code->character)144 (keys character-code->character)))146 (defn str->character-codes [s]147 (map character->character-code (map str s)))149 (defn character-codes->str [codes]150 (apply str151 (map #(character-code->character152 %153 (format "[0x%02X]" %))154 codes)))156 (defn print-text157 ([^SaveState state begin end]158 (dorun159 (map (fn [character-code line]160 (println161 (format "0x%04X: " line)162 (str (character-code->character character-code))))163 (subvec (vec (memory state)) begin end)164 (range begin end)))165 state)166 ([begin end]167 (print-text @current-state begin end)))169 (defn read-name [codes]170 (character-codes->str171 (take-while172 (partial not= end-of-name-marker) codes)))