Mercurial > vba-clojure
view clojure/com/aurellem/gb/status.clj @ 176:95b2758dd517
wrote functions to read and write pokemon DV values and status
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Wed, 21 Mar 2012 22:13:43 -0500 |
parents | |
children | d63886d63b2f |
line wrap: on
line source
1 (ns com.aurellem.gb.status2 (:use (com.aurellem.gb gb-driver util constants))3 (:import [com.aurellem.gb.gb_driver SaveState]))5 (def status-name->status-code6 {: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-name19 (zipmap (vals status-name->status-code)20 (keys status-name->status-code)))23 (def pokemon-1-status-address 0xD16E)25 (defn pokemon-status-address [poke-num]26 (+ pokemon-1-status-address27 (* poke-num pokemon-record-width)))29 (defn give-stat30 ([^SaveState state poke-num status]31 (assert (<= 0 poke-num 5))32 (let [status-code33 (status-name->status-code status)]34 (assert status-code)35 (set-memory state36 (pokemon-status-address poke-num)37 status-code)))38 ([poke-num status]39 (give-stat @current-state poke-num status))40 ([status]41 (give-stat @current-state 0 status)))43 (defn give-stat-all44 ([^SaveState state status]45 (reduce (fn [state num]46 (give-stat state num status))47 state48 (range (party-number state))))49 ([status]50 (give-stat-all @current-state status)))