Mercurial > vba-clojure
annotate clojure/com/aurellem/gb/text_speed.clj @ 294:9f466a332448
merge
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Fri, 30 Mar 2012 18:15:28 -0500 |
parents | 0587f266a735 |
children |
rev | line source |
---|---|
rlm@225 | 1 (ns com.aurellem.gb.text-speed |
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 (def text-speed-address 0xD354) |
rlm@225 | 6 |
rlm@225 | 7 (def text-speed->code |
rlm@225 | 8 {:slow 69 |
rlm@225 | 9 :mid 67 |
rlm@225 | 10 :fast 65 |
rlm@225 | 11 :ultra 64 |
rlm@225 | 12 }) |
rlm@225 | 13 |
rlm@225 | 14 (def code->text-speed |
rlm@225 | 15 (zipmap (vals text-speed->code) |
rlm@225 | 16 (keys text-speed->code))) |
rlm@225 | 17 |
rlm@225 | 18 (defn read-text-speed |
rlm@225 | 19 ([^SaveState state] |
rlm@225 | 20 (code->text-speed (aget (memory state) |
rlm@225 | 21 text-speed-address))) |
rlm@225 | 22 ([] (read-text-speed @current-state))) |
rlm@225 | 23 |
rlm@225 | 24 (defn set-text-speed |
rlm@225 | 25 ([^SaveState state new-speed] |
rlm@225 | 26 (set-memory |
rlm@225 | 27 state |
rlm@225 | 28 text-speed-address |
rlm@225 | 29 (text-speed->code new-speed new-speed))) |
rlm@225 | 30 ([new-speed] (set-text-speed @current-state new-speed))) |