comparison clojure/com/aurellem/gb/pokedex.clj @ 235:5becef6312b9

working on item-injection; fixed off-by-one error in print-pokedex.
author Robert McIntyre <rlm@mit.edu>
date Sat, 24 Mar 2012 20:05:47 -0500
parents 3dfb9dd3db9d
children 0e31aff20d5f
comparison
equal deleted inserted replaced
233:49a709c555f2 235:5becef6312b9
8 8
9 (defn pokedex-offset [capture? species-num] 9 (defn pokedex-offset [capture? species-num]
10 (+ (if capture? 10 (+ (if capture?
11 pokedex-captured-start-address 11 pokedex-captured-start-address
12 pokedex-seen-start-address) 12 pokedex-seen-start-address)
13 (int (/ (dec species-num) 8)))) 13 (int (/ (dec species-num) 8))))
14 14
15 (defn read-pokedex 15 (defn read-pokedex
16 ([^SaveState state capture? species-num] 16 ([^SaveState state capture? species-num]
17 (bit-test 17 (bit-test
18 (aget (memory state) 18 (aget (memory state)
19 (pokedex-offset capture? species-num)) 19 (pokedex-offset capture? species-num))
20 (rem species-num 8)))) 20 (rem (dec species-num) 8))))
21 21
22 (defn set-pokedex 22 (defn set-pokedex
23 ([^SaveState state capture? set? species-num] 23 ([^SaveState state capture? set? species-num]
24 (let [target (pokedex-offset capture? species-num) 24 (let [target (pokedex-offset capture? species-num)
25 current-bits 25 current-bits
73 (map 73 (map
74 #(printf "|%-11s|%s|%s|\n" %1 %2 %3) 74 #(printf "|%-11s|%s|%s|\n" %1 %2 %3)
75 (map #(.toUpperCase (.substring (str %) 1)) 75 (map #(.toUpperCase (.substring (str %) 1))
76 (map pokedex-num->species-name (range 1 152))) 76 (map pokedex-num->species-name (range 1 152)))
77 (map #(if % " X " " ") 77 (map #(if % " X " " ")
78 (map read-pokedex-seen (range 152))) 78 (map read-pokedex-seen (range 1 152)))
79 (map #(if % " X " " ") 79 (map #(if % " X " " ")
80 (map read-pokedex-captured (range 152))))) 80 (map read-pokedex-captured (range 1 152)))))
81 (println "+-----------+-------+-------+")) 81 (println "+-----------+-------+-------+"))
82 ([] (print-pokedex @current-state))) 82 ([] (print-pokedex @current-state)))
83 83
84 (defn give-full-pokedex 84 (defn give-full-pokedex
85 ([^SaveState state] 85 ([^SaveState state]