Mercurial > vba-clojure
annotate clojure/com/aurellem/gb/rival_name.clj @ 509:d2c40a12de28
problem turned out to be nothing.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Wed, 20 Jun 2012 22:08:56 -0500 |
parents | 0587f266a735 |
children |
rev | line source |
---|---|
rlm@225 | 1 (ns com.aurellem.gb.rival-name |
rlm@225 | 2 (:use (com.aurellem.gb gb-driver util characters)) |
rlm@225 | 3 (:import [com.aurellem.gb.gb_driver SaveState])) |
rlm@225 | 4 |
rlm@225 | 5 |
rlm@225 | 6 (def rival-name-start-address 0xD349) |
rlm@225 | 7 |
rlm@225 | 8 (def rival-name-width 12) |
rlm@225 | 9 |
rlm@225 | 10 (defn read-rival-name |
rlm@225 | 11 ([^SaveState state] |
rlm@225 | 12 (read-name (subvec (vec (memory state)) |
rlm@225 | 13 rival-name-start-address |
rlm@225 | 14 (+ rival-name-start-address |
rlm@225 | 15 rival-name-width)))) |
rlm@225 | 16 ([] (read-rival-name @current-state))) |
rlm@225 | 17 |
rlm@225 | 18 (defn set-rival-name |
rlm@225 | 19 ([^SaveState state new-name] |
rlm@225 | 20 (assert (<= (count new-name) 10)) |
rlm@225 | 21 (let [codes (str->character-codes new-name)] |
rlm@225 | 22 (set-memory-range state |
rlm@225 | 23 rival-name-start-address |
rlm@225 | 24 (concat codes [end-of-name-sentinel])))) |
rlm@225 | 25 ([new-name] (set-rival-name @current-state new-name))) |
rlm@225 | 26 |
rlm@225 | 27 |