Mercurial > vba-clojure
annotate clojure/com/aurellem/gb/characters.clj @ 179:d63886d63b2f
cleaned up code; added gb.saves
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Wed, 21 Mar 2012 23:02:45 -0500 |
parents | 95b2758dd517 |
children | 67c42608ef9d |
rev | line source |
---|---|
rlm@145 | 1 (ns com.aurellem.gb.characters |
rlm@176 | 2 (:use (com.aurellem.gb gb-driver constants)) |
rlm@145 | 3 (:import [com.aurellem.gb.gb_driver SaveState])) |
rlm@145 | 4 |
rlm@145 | 5 (def character-code->character |
rlm@145 | 6 { |
rlm@145 | 7 0x00 "end-of-name-sentinel" |
rlm@147 | 8 0x50 "end-of-pokemon-name-sentinel" |
rlm@145 | 9 0x60 "A-bold" |
rlm@145 | 10 0x61 "B-bold" |
rlm@145 | 11 0x62 "C-bold" |
rlm@145 | 12 0x63 "D-bold" |
rlm@145 | 13 0x64 "E-bold" |
rlm@145 | 14 0x65 "F-bold" |
rlm@145 | 15 0x66 "G-bold" |
rlm@145 | 16 0x67 "H-bold" |
rlm@145 | 17 0x68 "I-bold" |
rlm@145 | 18 0x69 "V-bold" |
rlm@145 | 19 0x6A "S-bold" |
rlm@145 | 20 0x6B "L-bold" |
rlm@145 | 21 0x6C "M-bold" |
rlm@145 | 22 0x80 "A" |
rlm@145 | 23 0x81 "B" |
rlm@145 | 24 0x82 "C" |
rlm@145 | 25 0x83 "D" |
rlm@145 | 26 0x84 "E" |
rlm@145 | 27 0x85 "F" |
rlm@145 | 28 0x86 "G" |
rlm@145 | 29 0x87 "H" |
rlm@145 | 30 0x88 "I" |
rlm@145 | 31 0x89 "J" |
rlm@145 | 32 0x8A "K" |
rlm@145 | 33 0x8B "L" |
rlm@145 | 34 0x8C "M" |
rlm@145 | 35 0x8D "N" |
rlm@145 | 36 0x8E "O" |
rlm@145 | 37 0x8F "P" |
rlm@145 | 38 0x90 "Q" |
rlm@145 | 39 0x91 "R" |
rlm@145 | 40 0x92 "S" |
rlm@145 | 41 0x93 "T" |
rlm@145 | 42 0x94 "U" |
rlm@145 | 43 0x95 "V" |
rlm@145 | 44 0x96 "W" |
rlm@145 | 45 0x97 "X" |
rlm@145 | 46 0x98 "Y" |
rlm@145 | 47 0x99 "Z" |
rlm@145 | 48 0x9A "(" |
rlm@145 | 49 0x9B ")" |
rlm@145 | 50 0x9C ":" |
rlm@145 | 51 0x9D ";" |
rlm@145 | 52 0xA0 "a" |
rlm@145 | 53 0xA1 "b" |
rlm@145 | 54 0xA2 "c" |
rlm@145 | 55 0xA3 "d" |
rlm@145 | 56 0xA4 "e" |
rlm@145 | 57 0xA5 "f" |
rlm@145 | 58 0xA6 "g" |
rlm@145 | 59 0xA7 "h" |
rlm@145 | 60 0xA8 "i" |
rlm@145 | 61 0xA9 "j" |
rlm@145 | 62 0xAA "k" |
rlm@145 | 63 0xAB "l" |
rlm@145 | 64 0xAC "m" |
rlm@145 | 65 0xAD "n" |
rlm@145 | 66 0xAE "o" |
rlm@145 | 67 0xAF "p" |
rlm@145 | 68 0xB0 "q" |
rlm@145 | 69 0xB1 "r" |
rlm@145 | 70 0xB2 "s" |
rlm@145 | 71 0xB3 "t" |
rlm@145 | 72 0xB4 "u" |
rlm@145 | 73 0xB5 "v" |
rlm@145 | 74 0xB6 "w" |
rlm@145 | 75 0xB7 "x" |
rlm@145 | 76 0xB8 "y" |
rlm@145 | 77 0xB9 "z" |
rlm@145 | 78 0xBA "e-with-grave" |
rlm@145 | 79 0xE0 "'" |
rlm@145 | 80 0xE1 "PK" |
rlm@145 | 81 0xE2 "MN" |
rlm@148 | 82 0xE3 "-" |
rlm@145 | 83 0xE6 "?" |
rlm@145 | 84 0xE7 "!" |
rlm@145 | 85 0xE8 "." |
rlm@145 | 86 0xEF "male-symbol" |
rlm@145 | 87 0xF0 "pokemon-money-symbol" |
rlm@145 | 88 0xF1 "." |
rlm@145 | 89 0xF2 "/" |
rlm@145 | 90 0xF3 "," |
rlm@145 | 91 0xF4 "female-symbol" |
rlm@145 | 92 0xF6 "0 " |
rlm@145 | 93 0xF7 "1" |
rlm@145 | 94 0xF8 "2" |
rlm@145 | 95 0xF9 "3" |
rlm@145 | 96 0xFA "4" |
rlm@145 | 97 0xFB "5" |
rlm@145 | 98 0xFC "6" |
rlm@145 | 99 0xFD "7" |
rlm@145 | 100 0xFE "8" |
rlm@145 | 101 0xFF "9" |
rlm@145 | 102 }) |
rlm@145 | 103 |
rlm@145 | 104 (def character->character-code |
rlm@145 | 105 (zipmap (vals character-code->character) |
rlm@145 | 106 (keys character-code->character))) |
rlm@145 | 107 |
rlm@145 | 108 (defn str->character-codes [s] |
rlm@145 | 109 (map character->character-code (map str s))) |
rlm@145 | 110 |
rlm@145 | 111 (defn character-codes->str [codes] |
rlm@145 | 112 (apply str |
rlm@145 | 113 (map #(character-code->character |
rlm@145 | 114 % |
rlm@145 | 115 (format "[0x%02X]" %)) |
rlm@145 | 116 codes))) |
rlm@145 | 117 |
rlm@176 | 118 (defn print-text |
rlm@176 | 119 ([^SaveState state begin end] |
rlm@176 | 120 (dorun |
rlm@176 | 121 (map (fn [character-code line] |
rlm@176 | 122 (println |
rlm@176 | 123 (format "0x%04X: " line) |
rlm@176 | 124 (str (character-code->character character-code)))) |
rlm@176 | 125 (subvec (vec (memory state)) begin end) |
rlm@176 | 126 (range begin end))) |
rlm@176 | 127 state) |
rlm@176 | 128 ([begin end] |
rlm@176 | 129 (print-text @current-state begin end))) |
rlm@176 | 130 |
rlm@176 | 131 (defn read-name [codes] |
rlm@176 | 132 (character-codes->str |
rlm@176 | 133 (take-while |
rlm@176 | 134 (partial not= end-of-name-marker) codes))) |