changeset 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 10e26e7ceedb
children 21641c1c3f87
files clojure/com/aurellem/exp/cartography clojure/com/aurellem/exp/play.clj clojure/com/aurellem/gb/characters.clj clojure/com/aurellem/gb/moves.clj clojure/com/aurellem/gb/rival_name.clj clojure/com/aurellem/gb/text_speed.clj
diffstat 6 files changed, 79 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/exp/cartography	Sat Mar 24 04:29:37 2012 -0500
     1.2 +++ b/clojure/com/aurellem/exp/cartography	Sat Mar 24 05:26:33 2012 -0500
     1.3 @@ -485,19 +485,19 @@
     1.4  D346                   /h (bcd) money
     1.5  D347                   |m (bcd) money
     1.6  D348                   \l (bcd) money
     1.7 -D349                   
     1.8 -D34A                   
     1.9 -D34B                   
    1.10 -D34C                   
    1.11 -D34D                   
    1.12 -D34E                   
    1.13 -D34F                   
    1.14 -D350                   
    1.15 -D351                   
    1.16 -D352                   
    1.17 -D353                   
    1.18 -D354                   
    1.19 -D355                   
    1.20 +D349                   /
    1.21 +D34A                   |
    1.22 +D34B                   |
    1.23 +D34C                   |
    1.24 +D34D                   |   
    1.25 +D34E                   |   Rival's Name
    1.26 +D34F                   |
    1.27 +D350                   |
    1.28 +D351                   |
    1.29 +D352                   |
    1.30 +D353                   \
    1.31 +D354                   Text Speed
    1.32 +D355                   Badges
    1.33  D356                   
    1.34  D357                   
    1.35  D358                   
     2.1 --- a/clojure/com/aurellem/exp/play.clj	Sat Mar 24 04:29:37 2012 -0500
     2.2 +++ b/clojure/com/aurellem/exp/play.clj	Sat Mar 24 05:26:33 2012 -0500
     2.3 @@ -4,7 +4,8 @@
     2.4                           assembly saves
     2.5                           items pokemon status types
     2.6                           characters species moves
     2.7 -                         pokedex))
     2.8 +                         pokedex money rival-name
     2.9 +                         text-speed))
    2.10    
    2.11    (:import java.io.File)
    2.12    (:import [com.aurellem.gb.gb_driver SaveState]))
     3.1 --- a/clojure/com/aurellem/gb/characters.clj	Sat Mar 24 04:29:37 2012 -0500
     3.2 +++ b/clojure/com/aurellem/gb/characters.clj	Sat Mar 24 05:26:33 2012 -0500
     3.3 @@ -20,12 +20,13 @@
     3.4     
     3.5     })
     3.6  
     3.7 +(def end-of-name-sentinel 0x00)
     3.8  
     3.9  (def character-code->character
    3.10    {
    3.11     0x0 "" ;; separator character?
    3.12     0x58 "\n"
    3.13 -   ;0x00   "<";;"end-of-name-sentinel" ;; begin messsage
    3.14 +   ;;0x00   "<";;"end-of-name-sentinel" ;; begin messsage
    3.15     ;;0x49   "\n //" ;; ocsenave: pagebreak pokedex
    3.16     ;;0x4E   "\n..." ; ocsenave: clearscroll pokedex page
    3.17     0x4F   "\n" ; newline
    3.18 @@ -155,8 +156,6 @@
    3.19                  (format "[0x%02X]" %))
    3.20                codes)))
    3.21  
    3.22 -
    3.23 -
    3.24  (defn print-text
    3.25    ([^SaveState state begin end]
    3.26       (dorun
     4.1 --- a/clojure/com/aurellem/gb/moves.clj	Sat Mar 24 04:29:37 2012 -0500
     4.2 +++ b/clojure/com/aurellem/gb/moves.clj	Sat Mar 24 05:26:33 2012 -0500
     4.3 @@ -288,7 +288,7 @@
     4.4    {
     4.5     :absorb        20
     4.6     :acid          30
     4.7 -   :acid-armor    40 ;; WTF happens with 3 PP-UPs??!
     4.8 +   :acid-armor    40 ;; WTF happens with 3 PP-UPs??! (answer: 61PP!)
     4.9     :agility       30
    4.10     :amnesia       20
    4.11     :aurora-beam   20
    4.12 @@ -453,5 +453,7 @@
    4.13     :wrap          20})
    4.14  
    4.15  (defn max-pp [name pp-ups]
    4.16 -  (int (* (+ 1 (* (/ 1 5) pp-ups))
    4.17 -          (move-name->move-pp name))))
    4.18 \ No newline at end of file
    4.19 +  (if (= 40 (move-name->move-pp name))
    4.20 +    (+ 40 (* 7 pp-ups))
    4.21 +    (int (* (+ 1 (* (/ 1 5) pp-ups))
    4.22 +            (move-name->move-pp name)))))
    4.23 \ No newline at end of file
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/clojure/com/aurellem/gb/rival_name.clj	Sat Mar 24 05:26:33 2012 -0500
     5.3 @@ -0,0 +1,27 @@
     5.4 +(ns com.aurellem.gb.rival-name
     5.5 +  (:use (com.aurellem.gb gb-driver util characters))
     5.6 +  (:import [com.aurellem.gb.gb_driver SaveState]))
     5.7 +
     5.8 +
     5.9 +(def rival-name-start-address 0xD349)
    5.10 +
    5.11 +(def rival-name-width 12)
    5.12 +
    5.13 +(defn read-rival-name
    5.14 +  ([^SaveState state]
    5.15 +     (read-name (subvec (vec (memory state))
    5.16 +                        rival-name-start-address
    5.17 +                        (+ rival-name-start-address
    5.18 +                           rival-name-width))))
    5.19 +  ([] (read-rival-name @current-state)))
    5.20 +
    5.21 +(defn set-rival-name
    5.22 +  ([^SaveState state new-name]
    5.23 +     (assert (<= (count new-name) 10))
    5.24 +     (let [codes (str->character-codes new-name)]
    5.25 +       (set-memory-range state
    5.26 +                         rival-name-start-address
    5.27 +                         (concat codes [end-of-name-sentinel]))))
    5.28 +  ([new-name] (set-rival-name @current-state new-name)))
    5.29 +     
    5.30 +
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/clojure/com/aurellem/gb/text_speed.clj	Sat Mar 24 05:26:33 2012 -0500
     6.3 @@ -0,0 +1,30 @@
     6.4 +(ns com.aurellem.gb.text-speed
     6.5 +  (:use (com.aurellem.gb gb-driver util characters))
     6.6 +  (:import [com.aurellem.gb.gb_driver SaveState]))
     6.7 +
     6.8 +(def text-speed-address 0xD354)
     6.9 +
    6.10 +(def text-speed->code
    6.11 +  {:slow 69
    6.12 +   :mid 67
    6.13 +   :fast 65
    6.14 +   :ultra 64
    6.15 +   })
    6.16 +
    6.17 +(def code->text-speed
    6.18 +  (zipmap (vals text-speed->code)
    6.19 +          (keys text-speed->code)))
    6.20 +  
    6.21 +(defn read-text-speed
    6.22 +  ([^SaveState state]
    6.23 +     (code->text-speed (aget (memory state)
    6.24 +                             text-speed-address)))
    6.25 +  ([] (read-text-speed @current-state)))
    6.26 +
    6.27 +(defn set-text-speed
    6.28 +  ([^SaveState state new-speed]
    6.29 +     (set-memory 
    6.30 +      state 
    6.31 +      text-speed-address
    6.32 +      (text-speed->code new-speed new-speed)))
    6.33 +  ([new-speed] (set-text-speed @current-state new-speed)))
    6.34 \ No newline at end of file