diff clojure/com/aurellem/gb/text_speed.clj @ 225:0587f266a735

added functions for setting rival's name and text speed
author Robert McIntyre <rlm@mit.edu>
date Sat, 24 Mar 2012 05:26:33 -0500
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/clojure/com/aurellem/gb/text_speed.clj	Sat Mar 24 05:26:33 2012 -0500
     1.3 @@ -0,0 +1,30 @@
     1.4 +(ns com.aurellem.gb.text-speed
     1.5 +  (:use (com.aurellem.gb gb-driver util characters))
     1.6 +  (:import [com.aurellem.gb.gb_driver SaveState]))
     1.7 +
     1.8 +(def text-speed-address 0xD354)
     1.9 +
    1.10 +(def text-speed->code
    1.11 +  {:slow 69
    1.12 +   :mid 67
    1.13 +   :fast 65
    1.14 +   :ultra 64
    1.15 +   })
    1.16 +
    1.17 +(def code->text-speed
    1.18 +  (zipmap (vals text-speed->code)
    1.19 +          (keys text-speed->code)))
    1.20 +  
    1.21 +(defn read-text-speed
    1.22 +  ([^SaveState state]
    1.23 +     (code->text-speed (aget (memory state)
    1.24 +                             text-speed-address)))
    1.25 +  ([] (read-text-speed @current-state)))
    1.26 +
    1.27 +(defn set-text-speed
    1.28 +  ([^SaveState state new-speed]
    1.29 +     (set-memory 
    1.30 +      state 
    1.31 +      text-speed-address
    1.32 +      (text-speed->code new-speed new-speed)))
    1.33 +  ([new-speed] (set-text-speed @current-state new-speed)))
    1.34 \ No newline at end of file