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

added function to set ROM
author Robert McIntyre <rlm@mit.edu>
date Thu, 22 Mar 2012 20:10:09 -0500
parents 9a7a46c4aa1b
children fd549c8f42ae
comparison
equal deleted inserted replaced
190:9a7a46c4aa1b 191:893c753f8088
185 (defn read-moves 185 (defn read-moves
186 ([^SaveState state poke-num] 186 ([^SaveState state poke-num]
187 (let [start (moves-codes-start poke-num)] 187 (let [start (moves-codes-start poke-num)]
188 (vec 188 (vec
189 (take-while 189 (take-while
190 (partial not= (move-name->move-code :end-of-moves)) 190 (partial not= :end-of-moves)
191 (map 191 (map
192 move-code->move-name 192 move-code->move-name
193 (subvec (vec (memory state)) 193 (subvec (vec (memory state))
194 start (+ start (num-moves state poke-num)))))))) 194 start (+ start (num-moves state poke-num))))))))
195 ([poke-num] 195 ([poke-num]
196 (read-moves @current-state poke-num))) 196 (read-moves @current-state poke-num)))
197 197
198
199
200 (defn give-moves 198 (defn give-moves
201 ([^SaveState state pokemon-num moves] 199 ([^SaveState state pokemon-num moves]
200 (assert (<= (count moves) 4))
202 (set-memory-range 201 (set-memory-range
203 state 202 state
204 (moves-codes-start pokemon-num) 203 (moves-codes-start pokemon-num)
205 (map #(move-name->move-code % %) moves))) 204 (map #(move-name->move-code % %)
205 (concat moves
206 (repeat (- 4 (count moves)) :end-of-moves)))))
206 ([pokemon-num moves] 207 ([pokemon-num moves]
207 (give-moves @current-state pokemon-num moves)) 208 (give-moves @current-state pokemon-num moves))
208 ([moves] 209 ([moves]
209 (give-moves 0 moves))) 210 (give-moves 0 moves)))
210 211
213 ;; they are bit-packed, with the first 2 bits containing the 214 ;; they are bit-packed, with the first 2 bits containing the
214 ;; number of pp-ups that have been applied, and the next 215 ;; number of pp-ups that have been applied, and the next
215 ;; six bits containing the current pp of the move. 216 ;; six bits containing the current pp of the move.
216 ;; thus, a move can have up to 63 current pp and up to 217 ;; thus, a move can have up to 63 current pp and up to
217 ;; three pp-ups applied. 218 ;; three pp-ups applied.
218
219 219
220 (def pokemon-1-pp-start 0xD187) 220 (def pokemon-1-pp-start 0xD187)
221 221
222 (defn moves-pp-start [pokemon-num] 222 (defn moves-pp-start [pokemon-num]
223 (assert (<= 0 pokemon-num 5)) 223 (assert (<= 0 pokemon-num 5))