diff clojure/com/aurellem/gb/characters.clj @ 145:412ca096a9ba

major refactoring complete.
author Robert McIntyre <rlm@mit.edu>
date Mon, 19 Mar 2012 21:23:46 -0500
parents
children 279e9ee6fccb
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/clojure/com/aurellem/gb/characters.clj	Mon Mar 19 21:23:46 2012 -0500
     1.3 @@ -0,0 +1,116 @@
     1.4 +(ns com.aurellem.gb.characters
     1.5 +  (:use (com.aurellem.gb gb-driver))
     1.6 +  (:import [com.aurellem.gb.gb_driver SaveState]))
     1.7 +
     1.8 +(def character-code->character
     1.9 +  {
    1.10 +   0x00   "end-of-name-sentinel"
    1.11 +   0x60   "A-bold"
    1.12 +   0x61   "B-bold"
    1.13 +   0x62   "C-bold"
    1.14 +   0x63   "D-bold"
    1.15 +   0x64   "E-bold"
    1.16 +   0x65   "F-bold"
    1.17 +   0x66   "G-bold"
    1.18 +   0x67   "H-bold"
    1.19 +   0x68   "I-bold"
    1.20 +   0x69   "V-bold"
    1.21 +   0x6A   "S-bold"
    1.22 +   0x6B   "L-bold"
    1.23 +   0x6C   "M-bold"
    1.24 +   0x80   "A"
    1.25 +   0x81   "B"
    1.26 +   0x82   "C"
    1.27 +   0x83   "D"
    1.28 +   0x84   "E"
    1.29 +   0x85   "F"
    1.30 +   0x86   "G"
    1.31 +   0x87   "H"
    1.32 +   0x88   "I"
    1.33 +   0x89   "J"
    1.34 +   0x8A   "K"
    1.35 +   0x8B   "L"
    1.36 +   0x8C   "M"
    1.37 +   0x8D   "N"
    1.38 +   0x8E   "O"
    1.39 +   0x8F   "P"
    1.40 +   0x90   "Q"
    1.41 +   0x91   "R"
    1.42 +   0x92   "S"
    1.43 +   0x93   "T"
    1.44 +   0x94   "U"
    1.45 +   0x95   "V"
    1.46 +   0x96   "W"
    1.47 +   0x97   "X"
    1.48 +   0x98   "Y"
    1.49 +   0x99   "Z"
    1.50 +   0x9A   "("
    1.51 +   0x9B   ")"
    1.52 +   0x9C   ":"
    1.53 +   0x9D   ";"
    1.54 +   0xA0   "a"
    1.55 +   0xA1   "b"
    1.56 +   0xA2   "c"
    1.57 +   0xA3   "d"
    1.58 +   0xA4   "e"
    1.59 +   0xA5   "f"
    1.60 +   0xA6   "g"
    1.61 +   0xA7   "h"
    1.62 +   0xA8   "i"
    1.63 +   0xA9   "j"
    1.64 +   0xAA   "k"
    1.65 +   0xAB   "l"
    1.66 +   0xAC   "m"
    1.67 +   0xAD   "n"
    1.68 +   0xAE   "o"
    1.69 +   0xAF   "p"
    1.70 +   0xB0   "q"
    1.71 +   0xB1   "r"
    1.72 +   0xB2   "s"
    1.73 +   0xB3   "t"
    1.74 +   0xB4   "u"
    1.75 +   0xB5   "v"
    1.76 +   0xB6   "w"
    1.77 +   0xB7   "x"
    1.78 +   0xB8   "y"
    1.79 +   0xB9   "z"
    1.80 +   0xBA   "e-with-grave"
    1.81 +   0xE0   "'"
    1.82 +   0xE1   "PK"
    1.83 +   0xE2   "MN"
    1.84 +   0xE6   "?"
    1.85 +   0xE7   "!"
    1.86 +   0xE8   "."
    1.87 +   0xEF   "male-symbol"
    1.88 +   0xF0   "pokemon-money-symbol"
    1.89 +   0xF1   "."
    1.90 +   0xF2   "/"
    1.91 +   0xF3   ","
    1.92 +   0xF4   "female-symbol"
    1.93 +   0xF6   "0 "
    1.94 +   0xF7   "1"
    1.95 +   0xF8   "2"
    1.96 +   0xF9   "3"
    1.97 +   0xFA   "4"
    1.98 +   0xFB   "5"
    1.99 +   0xFC   "6"
   1.100 +   0xFD   "7"
   1.101 +   0xFE   "8"
   1.102 +   0xFF   "9"
   1.103 +   })
   1.104 +
   1.105 +(def character->character-code
   1.106 +  (zipmap (vals character-code->character)
   1.107 +          (keys character-code->character)))
   1.108 +
   1.109 +(defn str->character-codes [s]
   1.110 +  (map character->character-code (map str s)))
   1.111 +
   1.112 +(defn character-codes->str [codes]
   1.113 +  (apply str
   1.114 +         (map #(character-code->character
   1.115 +                %
   1.116 +                (format "[0x%02X]" %))
   1.117 +              codes)))
   1.118 +       
   1.119 +