Mercurial > vba-clojure
view clojure/com/aurellem/gb/types.clj @ 198:5055ec9de278
competed move-table printing component of pokemon printing function.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Fri, 23 Mar 2012 00:30:34 -0500 |
parents | 9a7a46c4aa1b |
children | 85a2c2e2d318 |
line wrap: on
line source
1 (ns com.aurellem.gb.types2 (:use (com.aurellem.gb gb-driver util constants))3 (:import [com.aurellem.gb.gb_driver SaveState]))5 (def type-code->type-name6 {0x00 :normal7 0x01 :fighting8 0x02 :flying9 0x03 :poision10 0x04 :ground11 0x05 :rock12 0x07 :bug13 0x08 :ghost14 0x14 :fire15 0x15 :water16 0x16 :grass17 0x17 :electric18 0x18 :psychic19 0x19 :ice20 0x1A :dragon})22 (def type-name->type-code23 (zipmap (vals type-code->type-name)24 (keys type-code->type-name)))26 (def pokemon-1-type-start-address 0xD16F)28 (defn pokemon-type-start-address [poke-num]29 (+ pokemon-1-type-start-address30 (* pokemon-record-width poke-num)))32 (defn give-type33 ([^SaveState state poke-num types]34 (assert (<= 0 poke-num 5))35 (let [types*36 (if (= (count types) 1)37 [(first types) (first types)]38 types)]39 (set-memory-range40 state41 (pokemon-type-start-address poke-num)42 (map type-name->type-code types))))43 ([poke-num types]44 (give-type @current-state poke-num types)))46 (defn read-type47 ([^SaveState state poke-num]48 (assert (<= 0 poke-num 5))49 (let [types-start (pokemon-type-start-address poke-num)50 [type-1 type-2]51 (subvec (vec (memory state))52 types-start (+ 2 types-start))]53 (if (= type-1 type-2)54 [(type-code->type-name type-1)]55 (mapv type-code->type-name [type-1 type-2]))))56 ([poke-num]57 (read-type @current-state poke-num)))