comparison clojure/com/aurellem/gb/status.clj @ 191:893c753f8088

added function to set ROM
author Robert McIntyre <rlm@mit.edu>
date Thu, 22 Mar 2012 20:10:09 -0500
parents d63886d63b2f
children fd549c8f42ae
comparison
equal deleted inserted replaced
190:9a7a46c4aa1b 191:893c753f8088
23 23
24 (defn pokemon-status-address [poke-num] 24 (defn pokemon-status-address [poke-num]
25 (+ pokemon-1-status-address 25 (+ pokemon-1-status-address
26 (* poke-num pokemon-record-width))) 26 (* poke-num pokemon-record-width)))
27 27
28 (defn give-stat 28 (defn read-status
29 ([^SaveState state poke-num]
30 (assert (<= 0 poke-num 5))
31 (status-code->status-name
32 (aget (memory state)
33 (pokemon-status-address poke-num))))
34 ([poke-num]
35 (read-status @current-state poke-num)))
36
37 (defn give-status
29 ([^SaveState state poke-num status] 38 ([^SaveState state poke-num status]
30 (assert (<= 0 poke-num 5)) 39 (assert (<= 0 poke-num 5))
31 (let [status-code 40 (let [status-code
32 (status-name->status-code status)] 41 (status-name->status-code status)]
33 (assert status-code) 42 (assert status-code)
37 ([poke-num status] 46 ([poke-num status]
38 (give-stat @current-state poke-num status)) 47 (give-stat @current-state poke-num status))
39 ([status] 48 ([status]
40 (give-stat @current-state 0 status))) 49 (give-stat @current-state 0 status)))
41 50
42 (defn give-stat-all 51 (defn give-status-all
43 ([^SaveState state status] 52 ([^SaveState state status]
44 (reduce (fn [state num] 53 (reduce (fn [state num]
45 (give-stat state num status)) 54 (give-stat state num status))
46 state 55 state
47 (range (party-number state)))) 56 (range (party-number state))))