Mercurial > vba-clojure
view clojure/com/aurellem/gb/items.clj @ 168:04dfda91db9c
discovered locations of Stat experience and lost location of DV values
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 20 Mar 2012 20:26:00 -0500 |
parents | cd7979aa544e |
children | 8665160f0f3d |
line wrap: on
line source
1 (ns com.aurellem.gb.items2 (:use (com.aurellem.gb gb-driver util))3 ;; this is bullshit4 (:import [com.aurellem.gb.gb_driver SaveState]))6 (defn game-name []7 (map char (subvec (vec (memory)) 0x134 0x142)))9 (def item-list-start 0xD31C)11 (defn item-list [^SaveState state]12 (subvec13 (vec (memory state))14 item-list-start15 (+ item-list-start 150)))17 (def item-code->item-name18 (hash-map19 0x01 :master-ball20 0x02 :ultra-ball21 0x03 :great-ball22 0x04 :poke-ball23 0x05 :town-map24 0x06 :bicycle25 0x08 :safari-ball26 0x09 :pokedex27 0x0A :moon-stone28 0x0B :antidote29 0x0C :burn-heal30 0x0D :ice-heal31 0x0E :awakening32 0x0F :parlyz-heal33 0x10 :full-restore34 0x11 :max-potion35 0x12 :hyper-potion36 0x13 :super-potion37 0x14 :potion38 0x15 :boulderbadge39 0x16 :cascadebadge40 0x17 :thunderbadge41 0x18 :rainbowbadge42 0x19 :soulbadge43 0x1A :marshbadge44 0x1B :volcanobadge45 0x1C :earthbadge46 0x1D :escape-rope47 0x1E :repel48 0x1F :old-amber49 0x20 :fire-stone50 0x21 :thunderstone51 0x22 :water-stone52 0x23 :hp-up53 0x24 :protein54 0x25 :iron55 0x26 :carbos56 0x27 :calcium57 0x28 :rare-candy58 0x29 :dome-fossil59 0x2A :helix-fossil60 0x2B :secret-key61 0x2D :bike-voucher62 0x2E :x-accuracy63 0x2F :leaf-stone64 0x30 :card-key65 0x31 :nugget66 0x32 :pp-up67 0x33 :poke-doll68 0x34 :full-heal69 0x35 :revive70 0x36 :max-revive71 0x37 :guard-spec72 0x38 :super-repel73 0x39 :max-repel74 0x3A :dire-hit75 0x3B :coin76 0x3C :fresh-water77 0x3D :soda-pop78 0x3E :lemonade79 0x3F :s.s.ticket80 0x40 :gold-teeth81 0x41 :x-attach82 0x42 :x-defend83 0x43 :x-speed84 0x44 :x-special85 0x45 :coin-case86 0x46 :oaks-parcel87 0x47 :itemfinder88 0x48 :silph-scope89 0x49 :poke-flute90 0x4A :lift-key91 0x4B :exp.all92 0x4C :old-rod93 0x4D :good-rod94 0x4E :super-rod95 0x4F :pp-up96 0x50 :ether97 0x51 :max-ether98 0x52 :elixer99 0x53 :max-elixer100 0xC4 :HM01 ;; cut101 0xC5 :HM02 ;; fly102 0xC6 :HM03 ;; surf103 0xC7 :HM04 ;; strength104 0xC8 :HM05 ;; flash105 0xC9 :TM01 ;; mega punch106 0xCA :TM02 ;; razor wind107 0xCB :TM03 ;; swords dance108 0xCC :TM04 ;; whirlwind109 0xCD :TM05 ;; mega kick110 0xCE :TM06 ;; toxic111 0xCF :TM07 ;; horn drill112 0xD0 :TM08 ;; body slam113 0xD1 :TM09 ;; take down114 0xD2 :TM10 ;; double-edge115 0xD3 :TM11 ;; bubblebeam116 0xD4 :TM12 ;; water gun117 0xD5 :TM13 ;; ice beam118 0xD6 :TM14 ;; blizzard119 0xD7 :TM15 ;; hyper beam120 0xD8 :TM16 ;; pay day121 0xD9 :TM17 ;; submission122 0xDA :TM18 ;; counter123 0xDB :TM19 ;; seismic toss124 0xDC :TM20 ;; rage125 0xDD :TM21 ;; mega drain126 0xDE :TM22 ;; solarbeam127 0xDF :TM23 ;; dragon rage128 0xE0 :TM24 ;; thunderbolt129 0xE1 :TM25 ;; thunder130 0xE2 :TM26 ;; earthquake131 0xE3 :TM27 ;; fissure132 0xE4 :TM28 ;; dig133 0xE5 :TM29 ;; psychic134 0xE6 :TM30 ;; teleport135 0xE7 :TM31 ;; mimic136 0xE8 :TM32 ;; double team137 0xE9 :TM33 ;; reflect138 0xEA :TM34 ;; bide139 0xEB :TM35 ;; metronome140 0xEC :TM36 ;; self destruct141 0xED :TM37 ;; eggbomb142 0xEE :TM38 ;; fire blast143 0xEF :TM39 ;; swift144 0xF0 :TM40 ;; skull bash145 0xF1 :TM41 ;; softboiled146 0xF2 :TM42 ;; dream eater147 0xF3 :TM43 ;; sky attack148 0xF4 :TM44 ;; rest149 0xF5 :TM45 ;; thunder wave150 0xF6 :TM46 ;; psywave151 0xF7 :TM47 ;; explosion152 0xF8 :TM48 ;; rock slide153 0xF9 :TM49 ;; tri attack154 0xFA :TM50 ;; substitute155 0xFB :TM51 ;; "cut"156 0xFC :TM52 ;; "fly"157 0xFD :TM53 ;; "surf"158 0xFE :TM54 ;; "strength"159 0xFF :end-of-list-sentinel))161 (def item-name->item-code162 (zipmap (vals item-code->item-name)163 (keys item-code->item-name)))165 (defn inventory [^SaveState state]166 (let [items (item-list state)]167 (map168 (fn [[item-code quantity]]169 [(item-code->item-name170 item-code171 (str ":0x" (.toUpperCase (Integer/toHexString item-code))))172 quantity])173 (partition174 2175 (next (take-while (partial not= 255) items))))))177 (defn print-inventory178 ([] (print-inventory @current-state))179 ([^SaveState state]180 (println181 (let [inv (inventory state)]182 (reduce183 str184 (concat185 ["+-------------------+----------+\n"186 "|##| Item | Quantity |\n"187 "+--+----------------+----------+\n"]189 (map190 (fn [index [item-name quantity]]191 (str192 (format "|%-2d| %-14s | %3d |\n" index193 (apply str (rest (str item-name)))194 quantity)))195 (range 0 (count inv)) inv)196 ["+--+----------------+----------+\n"]))))197 state))199 (defn inventory-codes [inventory]200 (flatten201 (concat [(count inventory)]202 (map (fn [[item-name quantity]]203 [(item-name->item-code item-name)204 quantity]) inventory)205 [(item-name->item-code :end-of-list-sentinel)])))207 (defn set-inv-mem [^SaveState state inv-codes]208 (set-memory-range state item-list-start209 inv-codes))212 (defn set-inventory [^SaveState state new-inventory]213 (set-inv-mem state (inventory-codes new-inventory)))215 (defn give-items216 ([^SaveState state items]217 (set-inventory state218 (concat items (inventory state))))219 ([items]220 (give-items @current-state items)))222 (defn clear-inventory223 ([^SaveState state]224 (set-inventory state []))225 ([] (clear-inventory @current-state)))