view clojure/com/aurellem/gb/status.clj @ 447:eea3b257ef59

removed some tracks.
author Robert McIntyre <rlm@mit.edu>
date Thu, 03 May 2012 06:22:34 -0500
parents fd549c8f42ae
children
line wrap: on
line source
1 (ns com.aurellem.gb.status
2 (:use (com.aurellem.gb gb-driver util constants))
3 (:import [com.aurellem.gb.gb_driver SaveState]))
5 (def status-name->status-code
6 {:normal (Integer/parseInt "00000000" 2)
7 :sleep-1 (Integer/parseInt "00000001" 2)
8 :sleep-2 (Integer/parseInt "00000010" 2)
9 :sleep-3 (Integer/parseInt "00000011" 2)
10 :sleep-4 (Integer/parseInt "00000100" 2)
11 :sleep-5 (Integer/parseInt "00000101" 2)
12 :sleep-6 (Integer/parseInt "00000111" 2)
13 :poisoned (Integer/parseInt "00001000" 2)
14 :burned (Integer/parseInt "00010000" 2)
15 :frozen (Integer/parseInt "00100000" 2)
16 :paralyzed (Integer/parseInt "01000000" 2)})
18 (def status-code->status-name
19 (zipmap (vals status-name->status-code)
20 (keys status-name->status-code)))
22 (def pokemon-1-status-address 0xD16E)
24 (defn pokemon-status-address [poke-num]
25 (+ pokemon-1-status-address
26 (* poke-num pokemon-record-width)))
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)))
37 (defn give-status
38 ([^SaveState state poke-num status]
39 (assert (<= 0 poke-num 5))
40 (let [status-code
41 (status-name->status-code status)]
42 (assert status-code)
43 (set-memory state
44 (pokemon-status-address poke-num)
45 status-code)))
46 ([poke-num status]
47 (give-status @current-state poke-num status))
48 ([status]
49 (give-status @current-state 0 status)))