Mercurial > vba-clojure
view clojure/com/aurellem/gb/pokedex.clj @ 222:c9a855de1d07
enabled pokedex printing.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 24 Mar 2012 03:10:56 -0500 |
parents | |
children | 3dfb9dd3db9d |
line wrap: on
line source
1 (ns com.aurellem.gb.pokedex2 (:use (com.aurellem.gb gb-driver util species))3 (:import [com.aurellem.gb.gb_driver SaveState]))5 (def pokedex-seen-start-address 0xD309)7 (def pokedex-captured-start-address 0xD2F6)9 (defn pokedex-offset [capture? species-num]10 (+ (if capture?11 pokedex-captured-start-address12 pokedex-seen-start-address)13 (int (/ species-num 8))))15 (defn read-pokedex16 ([^SaveState state capture? species-num]17 (bit-test18 (aget (memory state)19 (pokedex-offset capture? species-num))20 (rem species-num 8))))22 (defn set-pokedex23 ([^SaveState state capture? set? species-num]24 (let [target (pokedex-offset capture? species-num)25 current-bits26 (aget (memory state)27 (pokedex-offset capture? species-num))28 bit-offset (rem species-num 8)]29 (set-memory30 state target31 (if set?32 (bit-set current-bits bit-offset)33 (bit-clear current-bits bit-offset))))))35 (defn read-pokedex-seen36 ([^SaveState state species-num]37 (read-pokedex state false species-num))38 ([species-num]39 (read-pokedex-seen @current-state species-num)))41 (defn set-pokedex-seen42 ([^SaveState state species-num]43 (set-pokedex state false species-num))44 ([species-num]45 (set-pokedex-seen @current-state species-num)))47 (defn read-pokedex-captured48 ([^SaveState state species-num]49 (read-pokedex state true species-num))50 ([species-num]51 (read-pokedex-captured @current-state species-num)))53 (defn set-pokedex-captured54 ([^SaveState state species-num]55 (set-pokedex state true species-num))56 ([species-num]57 (set-pokedex-captured @current-state species-num)))59 (defn print-pokedex60 ([^SaveState state]61 (println "+-----------+-------+-------+")62 (println "|Pokemon | Seen? | Capt? |")63 (println "+-----------+-------+-------+")64 (dorun65 (map66 #(printf "|%-11s|%s|%s|\n" %1 %2 %3)67 (map #(.toUpperCase (.substring (str %) 1))68 (map pokedex-num->species-name (range 1 152)))69 (map #(if % " X " " ")70 (map read-pokedex-seen (range 152)))71 (map #(if % " X " " ")72 (map read-pokedex-captured (range 152)))))73 (println "+-----------+-------+-------+"))75 ([] (print-pokedex @current-state)))