Mercurial > vba-clojure
changeset 102:4d9ce3188655
made first 'hello-world' item based assembly insertion.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Mon, 12 Mar 2012 20:03:05 -0500 |
parents | 37711ff4a7bc |
children | 3305490a8f62 |
files | clojure/com/aurellem/items.clj |
diffstat | 1 files changed, 134 insertions(+), 76 deletions(-) [+] |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/items.clj Mon Mar 12 12:41:55 2012 -0500 1.2 +++ b/clojure/com/aurellem/items.clj Mon Mar 12 20:03:05 2012 -0500 1.3 @@ -99,65 +99,65 @@ 1.4 81 :max-ether 1.5 82 :elixer 1.6 83 :max-elixer 1.7 - 196 :HM01 1.8 - 197 :HM02 1.9 - 198 :HM03 1.10 - 199 :HM04 1.11 - 200 :HM05 1.12 - 201 :TM01 1.13 - 202 :TM02 1.14 - 203 :TM03 1.15 - 204 :TM04 1.16 - 205 :TM05 1.17 - 206 :TM06 1.18 - 207 :TM07 1.19 - 208 :TM08 1.20 - 209 :TM09 1.21 - 210 :TM10 1.22 - 211 :TM11 1.23 - 212 :TM12 1.24 - 213 :TM13 1.25 - 214 :TM13 1.26 - 215 :TM15 1.27 - 216 :TM16 1.28 - 217 :TM17 1.29 - 218 :TM18 1.30 - 219 :TM19 1.31 - 220 :TM20 1.32 - 221 :TM21 1.33 - 222 :TM22 1.34 - 223 :TM23 1.35 - 224 :TM24 1.36 - 225 :TM25 1.37 - 226 :TM26 1.38 - 227 :TM27 1.39 - 228 :TM28 1.40 - 229 :TM29 1.41 - 230 :TM30 1.42 - 231 :TM31 1.43 - 232 :TM32 1.44 - 233 :TM33 1.45 - 234 :TM34 1.46 - 235 :TM35 1.47 - 236 :TM36 1.48 - 237 :TM37 1.49 - 238 :TM38 1.50 - 239 :TM39 1.51 - 240 :TM40 1.52 - 241 :TM41 1.53 - 242 :TM42 1.54 - 243 :TM43 1.55 - 244 :TM44 1.56 - 245 :TM45 1.57 - 246 :TM46 1.58 - 247 :TM47 1.59 - 248 :TM48 1.60 - 249 :TM49 1.61 - 250 :TM50 1.62 - 251 :TM51 1.63 - 252 :TM52 1.64 - 253 :TM53 1.65 - 254 :TM54 1.66 + 196 :HM01 ;; cut 1.67 + 197 :HM02 ;; fly 1.68 + 198 :HM03 ;; surf 1.69 + 199 :HM04 ;; strength 1.70 + 200 :HM05 ;; flash 1.71 + 201 :TM01 ;; mega punch 1.72 + 202 :TM02 ;; razor wind 1.73 + 203 :TM03 ;; swords dance 1.74 + 204 :TM04 ;; whirlwind 1.75 + 205 :TM05 ;; mega kick 1.76 + 206 :TM06 ;; toxic 1.77 + 207 :TM07 ;; horn drill 1.78 + 208 :TM08 ;; body slam 1.79 + 209 :TM09 ;; take down 1.80 + 210 :TM10 ;; double-edge 1.81 + 211 :TM11 ;; bubblebeam 1.82 + 212 :TM12 ;; water gun 1.83 + 213 :TM13 ;; ice beam 1.84 + 214 :TM14 ;; blizzard 1.85 + 215 :TM15 ;; hyper beam 1.86 + 216 :TM16 ;; pay day 1.87 + 217 :TM17 ;; submission 1.88 + 218 :TM18 ;; counter 1.89 + 219 :TM19 ;; seismic toss 1.90 + 220 :TM20 ;; rage 1.91 + 221 :TM21 ;; mega drain 1.92 + 222 :TM22 ;; solarbeam 1.93 + 223 :TM23 ;; dragon rage 1.94 + 224 :TM24 ;; thunderbolt 1.95 + 225 :TM25 ;; thunder 1.96 + 226 :TM26 ;; earthquake 1.97 + 227 :TM27 ;; fissure 1.98 + 228 :TM28 ;; dig 1.99 + 229 :TM29 ;; psychic 1.100 + 230 :TM30 ;; teleport 1.101 + 231 :TM31 ;; mimic 1.102 + 232 :TM32 ;; double team 1.103 + 233 :TM33 ;; reflect 1.104 + 234 :TM34 ;; bide 1.105 + 235 :TM35 ;; metronome 1.106 + 236 :TM36 ;; self destruct 1.107 + 237 :TM37 ;; eggbomb 1.108 + 238 :TM38 ;; fire blast 1.109 + 239 :TM39 ;; swift 1.110 + 240 :TM40 ;; skull bash 1.111 + 241 :TM41 ;; softboiled 1.112 + 242 :TM42 ;; dream eater 1.113 + 243 :TM43 ;; sky attack 1.114 + 244 :TM44 ;; rest 1.115 + 245 :TM45 ;; thunder wave 1.116 + 246 :TM46 ;; psywave 1.117 + 247 :TM47 ;; explosion 1.118 + 248 :TM48 ;; rock slide 1.119 + 249 :TM49 ;; tri attack 1.120 + 250 :TM50 ;; substitute 1.121 + 251 :TM51 ;; "cut" 1.122 + 252 :TM52 ;; "fly" 1.123 + 253 :TM53 ;; "surf" 1.124 + 254 :TM54 ;; "strength" 1.125 255 :end-of-list-sentinel)) 1.126 1.127 (def item-name->item-code 1.128 @@ -174,24 +174,26 @@ 1.129 2 1.130 (next (take-while (partial not= 255) items)))))) 1.131 1.132 -(defn print-inventory [^SaveState state] 1.133 - (println 1.134 - (let [inv (inventory state)] 1.135 - (reduce 1.136 - str 1.137 - (concat 1.138 - ["+-------------------+----------+\n" 1.139 - "|##| Item | Quantity |\n" 1.140 - "+--+----------------+----------+\n"] 1.141 +(defn print-inventory 1.142 + ([] (print-inventory @current-state)) 1.143 + ([^SaveState state] 1.144 + (println 1.145 + (let [inv (inventory state)] 1.146 + (reduce 1.147 + str 1.148 + (concat 1.149 + ["+-------------------+----------+\n" 1.150 + "|##| Item | Quantity |\n" 1.151 + "+--+----------------+----------+\n"] 1.152 1.153 - (map 1.154 - (fn [index [item-name quantity]] 1.155 - (str 1.156 - (format "|%-2d| %-14s | %3d |\n" index 1.157 - (apply str (rest (str item-name))) 1.158 - quantity))) 1.159 - (range 0 (count inv)) inv) 1.160 - ["+--+----------------+----------+\n"]))))) 1.161 + (map 1.162 + (fn [index [item-name quantity]] 1.163 + (str 1.164 + (format "|%-2d| %-14s | %3d |\n" index 1.165 + (apply str (rest (str item-name))) 1.166 + quantity))) 1.167 + (range 0 (count inv)) inv) 1.168 + ["+--+----------------+----------+\n"])))))) 1.169 1.170 (defn inventory-codes [inventory] 1.171 (flatten 1.172 @@ -212,4 +214,60 @@ 1.173 (+ item-list-start (count inv))) inv)) 1.174 (write-memory! mem) 1.175 (update-state))) 1.176 + 1.177 +(def gliched-tms 1.178 + [[:TM51 1] 1.179 + [:TM52 1] 1.180 + [:TM53 1] 1.181 + [:TM54 1]]) 1.182 + 1.183 +(def good-items 1.184 + [[:bicycle 1] 1.185 + [:ultra-ball 15] 1.186 + [:pp-up 1] 1.187 + [:master-ball 5] 1.188 + [:rare-candy 99] 1.189 + [:full-restore 25] 1.190 + [:max-revive 8] 1.191 + [:max-repel 40] 1.192 + [:TM25 1] 1.193 + [:TM11 1] 1.194 + [:TM15 1] 1.195 + ]) 1.196 1.197 +(def some-badges 1.198 + [[:cascadebadge 1] 1.199 + [:thunderbadge 1] 1.200 + [:rainbowbadge 1] 1.201 + [:soulbadge 1] 1.202 + ]) 1.203 + 1.204 +(defn run-item-program 1.205 + "This is my first assembly/item program! 1.206 + it just increments BC by one. 1.207 + 1.208 + The code places a single 'great ball' at the beginning of the 1.209 + inventory, then directly sets the program counter to start 1.210 + executing at the position of the 'great ball' in memory. 1.211 + 1.212 + Since a 'great ball' is represented in memory as 0x03, which 1.213 + corresponts to the opcode which increments BC by one, that is 1.214 + what happens. 1.215 + 1.216 + Obviously, the game crashes more or less immediately after the 1.217 + program counter advances past the 'great ball' into the next items 1.218 + in the inventory." 1.219 + [] 1.220 + (set-inventory (read-state 578544) [[:great-ball 1]]) 1.221 + (print-inventory) 1.222 + (println "3 ticks") (tick) (tick) (tick) 1.223 + (println "PC before:" (PC)) 1.224 + (println "BC before:" (BC)) 1.225 + (PC! (inc item-list-start)) 1.226 + (println "PC after setting:" (PC)) 1.227 + (println "data at PC:" (aget (memory) (PC))) 1.228 + (println "one tick") 1.229 + (tick) 1.230 + (println "PC after one tick:" (PC)) 1.231 + (println "BC after one tick:" (BC))) 1.232 + 1.233 \ No newline at end of file