Mercurial > vba-clojure
view clojure/com/aurellem/gb/items.clj @ 207:a67f1df5d096
More hardcode expeditions.
author | Dylan Holmes <ocsenave@gmail.com> |
---|---|
date | Fri, 23 Mar 2012 04:43:44 -0500 |
parents | 893c753f8088 |
children | 7ceaac84be57 |
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-name7 "return pokemon-yellow header information"8 []9 (map char (subvec (vec (memory)) 0x134 0x142)))11 (def item-list-start 0xD31C)13 (defn item-list14 ([^SaveState state]15 (subvec16 (vec (memory state))17 item-list-start18 (+ item-list-start 255)))19 ([] (item-list @current-state)))21 (def item-code->item-name22 (hash-map23 0x01 :master-ball24 0x02 :ultra-ball25 0x03 :great-ball26 0x04 :poke-ball27 0x05 :town-map28 0x06 :bicycle29 0x07 :surfboard30 0x08 :safari-ball31 0x09 :pokedex32 0x0A :moon-stone33 0x0B :antidote34 0x0C :burn-heal35 0x0D :ice-heal36 0x0E :awakening37 0x0F :parlyz-heal38 0x10 :full-restore39 0x11 :max-potion40 0x12 :hyper-potion41 0x13 :super-potion42 0x14 :potion43 0x15 :boulderbadge44 0x16 :cascadebadge45 0x17 :thunderbadge46 0x18 :rainbowbadge47 0x19 :soulbadge48 0x1A :marshbadge49 0x1B :volcanobadge50 0x1C :earthbadge51 0x1D :escape-rope52 0x1E :repel53 0x1F :old-amber54 0x20 :fire-stone55 0x21 :thunderstone56 0x22 :water-stone57 0x23 :hp-up58 0x24 :protein59 0x25 :iron60 0x26 :carbos61 0x27 :calcium62 0x28 :rare-candy63 0x29 :dome-fossil64 0x2A :helix-fossil65 0x2B :secret-key66 0x2D :bike-voucher67 0x2E :x-accuracy68 0x2F :leaf-stone69 0x30 :card-key70 0x31 :nugget71 0x32 :pp-up72 0x33 :poke-doll73 0x34 :full-heal74 0x35 :revive75 0x36 :max-revive76 0x37 :guard-spec77 0x38 :super-repel78 0x39 :max-repel79 0x3A :dire-hit80 0x3B :coin81 0x3C :fresh-water82 0x3D :soda-pop83 0x3E :lemonade84 0x3F :s.s.ticket85 0x40 :gold-teeth86 0x41 :x-attack87 0x42 :x-defend88 0x43 :x-speed89 0x44 :x-special90 0x45 :coin-case91 0x46 :oaks-parcel92 0x47 :itemfinder93 0x48 :silph-scope94 0x49 :poke-flute95 0x4A :lift-key96 0x4B :exp.all97 0x4C :old-rod98 0x4D :good-rod99 0x4E :super-rod100 0x4F :pp-up101 0x50 :ether102 0x51 :max-ether103 0x52 :elixer104 0x53 :max-elixer105 0xC4 :HM01 ;; cut106 0xC5 :HM02 ;; fly107 0xC6 :HM03 ;; surf108 0xC7 :HM04 ;; strength109 0xC8 :HM05 ;; flash110 0xC9 :TM01 ;; mega punch111 0xCA :TM02 ;; razor wind112 0xCB :TM03 ;; swords dance113 0xCC :TM04 ;; whirlwind114 0xCD :TM05 ;; mega kick115 0xCE :TM06 ;; toxic116 0xCF :TM07 ;; horn drill117 0xD0 :TM08 ;; body slam118 0xD1 :TM09 ;; take down119 0xD2 :TM10 ;; double-edge120 0xD3 :TM11 ;; bubblebeam121 0xD4 :TM12 ;; water gun122 0xD5 :TM13 ;; ice beam123 0xD6 :TM14 ;; blizzard124 0xD7 :TM15 ;; hyper beam125 0xD8 :TM16 ;; pay day126 0xD9 :TM17 ;; submission127 0xDA :TM18 ;; counter128 0xDB :TM19 ;; seismic toss129 0xDC :TM20 ;; rage130 0xDD :TM21 ;; mega drain131 0xDE :TM22 ;; solarbeam132 0xDF :TM23 ;; dragon rage133 0xE0 :TM24 ;; thunderbolt134 0xE1 :TM25 ;; thunder135 0xE2 :TM26 ;; earthquake136 0xE3 :TM27 ;; fissure137 0xE4 :TM28 ;; dig138 0xE5 :TM29 ;; psychic139 0xE6 :TM30 ;; teleport140 0xE7 :TM31 ;; mimic141 0xE8 :TM32 ;; double team142 0xE9 :TM33 ;; reflect143 0xEA :TM34 ;; bide144 0xEB :TM35 ;; metronome145 0xEC :TM36 ;; self destruct146 0xED :TM37 ;; eggbomb147 0xEE :TM38 ;; fire blast148 0xEF :TM39 ;; swift149 0xF0 :TM40 ;; skull bash150 0xF1 :TM41 ;; softboiled151 0xF2 :TM42 ;; dream eater152 0xF3 :TM43 ;; sky attack153 0xF4 :TM44 ;; rest154 0xF5 :TM45 ;; thunder wave155 0xF6 :TM46 ;; psywave156 0xF7 :TM47 ;; explosion157 0xF8 :TM48 ;; rock slide158 0xF9 :TM49 ;; tri attack159 0xFA :TM50 ;; substitute160 0xFB :TM51 ;; "cut"161 0xFC :TM52 ;; "fly"162 0xFD :TM53 ;; "surf"163 0xFE :TM54 ;; "strength"164 0xFF :end-of-list-sentinel ;; also "flash"165 ))167 (def item-name->item-code168 (zipmap (vals item-code->item-name)169 (keys item-code->item-name)))171 (defn inventory [^SaveState state]172 (let [items (item-list state)]173 (map174 (fn [[item-code quantity]]175 [(item-code->item-name176 item-code177 item-code)178 quantity])179 (partition180 2181 (next (take-while (partial not= 255) items))))))183 (defn print-inventory184 ([] (print-inventory @current-state))185 ([^SaveState state]186 (println187 (let [inv (inventory state)]188 (reduce189 str190 (concat191 ["+-------------------+----------+\n"192 "|##| Item | Quantity |\n"193 "+--+----------------+----------+\n"]195 (map196 (fn [index [item-name quantity]]197 (str198 (format "|%-2d| %-14s | %3d |\n" index199 (apply str (rest (str item-name)))200 quantity)))201 (range 0 (count inv)) inv)202 ["+--+----------------+----------+\n"]))))203 state))205 (defn inventory-codes [inventory]206 (flatten207 (concat [(count inventory)]208 (map (fn [[item-name quantity]]209 [(item-name->item-code item-name item-name)210 quantity]) inventory)211 [(item-name->item-code :end-of-list-sentinel)])))213 (defn set-inv-mem [^SaveState state inv-codes]214 (set-memory-range state item-list-start215 inv-codes))218 (defn set-inventory [^SaveState state new-inventory]219 (set-inv-mem state (inventory-codes new-inventory)))221 (defn give-items222 ([^SaveState state items]223 (set-inventory state224 (concat items (inventory state))))225 ([items]226 (give-items @current-state items)))228 (defn clear-inventory229 ([^SaveState state]230 (set-inventory state []))231 ([] (clear-inventory @current-state)))