# HG changeset patch # User Robert McIntyre # Date 1331600585 18000 # Node ID 4d9ce3188655351863aa4641c17066180e780f8d # Parent 37711ff4a7bc42e5f101393c6a896f8a6ee49d27 made first 'hello-world' item based assembly insertion. diff -r 37711ff4a7bc -r 4d9ce3188655 clojure/com/aurellem/items.clj --- a/clojure/com/aurellem/items.clj Mon Mar 12 12:41:55 2012 -0500 +++ b/clojure/com/aurellem/items.clj Mon Mar 12 20:03:05 2012 -0500 @@ -99,65 +99,65 @@ 81 :max-ether 82 :elixer 83 :max-elixer - 196 :HM01 - 197 :HM02 - 198 :HM03 - 199 :HM04 - 200 :HM05 - 201 :TM01 - 202 :TM02 - 203 :TM03 - 204 :TM04 - 205 :TM05 - 206 :TM06 - 207 :TM07 - 208 :TM08 - 209 :TM09 - 210 :TM10 - 211 :TM11 - 212 :TM12 - 213 :TM13 - 214 :TM13 - 215 :TM15 - 216 :TM16 - 217 :TM17 - 218 :TM18 - 219 :TM19 - 220 :TM20 - 221 :TM21 - 222 :TM22 - 223 :TM23 - 224 :TM24 - 225 :TM25 - 226 :TM26 - 227 :TM27 - 228 :TM28 - 229 :TM29 - 230 :TM30 - 231 :TM31 - 232 :TM32 - 233 :TM33 - 234 :TM34 - 235 :TM35 - 236 :TM36 - 237 :TM37 - 238 :TM38 - 239 :TM39 - 240 :TM40 - 241 :TM41 - 242 :TM42 - 243 :TM43 - 244 :TM44 - 245 :TM45 - 246 :TM46 - 247 :TM47 - 248 :TM48 - 249 :TM49 - 250 :TM50 - 251 :TM51 - 252 :TM52 - 253 :TM53 - 254 :TM54 + 196 :HM01 ;; cut + 197 :HM02 ;; fly + 198 :HM03 ;; surf + 199 :HM04 ;; strength + 200 :HM05 ;; flash + 201 :TM01 ;; mega punch + 202 :TM02 ;; razor wind + 203 :TM03 ;; swords dance + 204 :TM04 ;; whirlwind + 205 :TM05 ;; mega kick + 206 :TM06 ;; toxic + 207 :TM07 ;; horn drill + 208 :TM08 ;; body slam + 209 :TM09 ;; take down + 210 :TM10 ;; double-edge + 211 :TM11 ;; bubblebeam + 212 :TM12 ;; water gun + 213 :TM13 ;; ice beam + 214 :TM14 ;; blizzard + 215 :TM15 ;; hyper beam + 216 :TM16 ;; pay day + 217 :TM17 ;; submission + 218 :TM18 ;; counter + 219 :TM19 ;; seismic toss + 220 :TM20 ;; rage + 221 :TM21 ;; mega drain + 222 :TM22 ;; solarbeam + 223 :TM23 ;; dragon rage + 224 :TM24 ;; thunderbolt + 225 :TM25 ;; thunder + 226 :TM26 ;; earthquake + 227 :TM27 ;; fissure + 228 :TM28 ;; dig + 229 :TM29 ;; psychic + 230 :TM30 ;; teleport + 231 :TM31 ;; mimic + 232 :TM32 ;; double team + 233 :TM33 ;; reflect + 234 :TM34 ;; bide + 235 :TM35 ;; metronome + 236 :TM36 ;; self destruct + 237 :TM37 ;; eggbomb + 238 :TM38 ;; fire blast + 239 :TM39 ;; swift + 240 :TM40 ;; skull bash + 241 :TM41 ;; softboiled + 242 :TM42 ;; dream eater + 243 :TM43 ;; sky attack + 244 :TM44 ;; rest + 245 :TM45 ;; thunder wave + 246 :TM46 ;; psywave + 247 :TM47 ;; explosion + 248 :TM48 ;; rock slide + 249 :TM49 ;; tri attack + 250 :TM50 ;; substitute + 251 :TM51 ;; "cut" + 252 :TM52 ;; "fly" + 253 :TM53 ;; "surf" + 254 :TM54 ;; "strength" 255 :end-of-list-sentinel)) (def item-name->item-code @@ -174,24 +174,26 @@ 2 (next (take-while (partial not= 255) items)))))) -(defn print-inventory [^SaveState state] - (println - (let [inv (inventory state)] - (reduce - str - (concat - ["+-------------------+----------+\n" - "|##| Item | Quantity |\n" - "+--+----------------+----------+\n"] +(defn print-inventory + ([] (print-inventory @current-state)) + ([^SaveState state] + (println + (let [inv (inventory state)] + (reduce + str + (concat + ["+-------------------+----------+\n" + "|##| Item | Quantity |\n" + "+--+----------------+----------+\n"] - (map - (fn [index [item-name quantity]] - (str - (format "|%-2d| %-14s | %3d |\n" index - (apply str (rest (str item-name))) - quantity))) - (range 0 (count inv)) inv) - ["+--+----------------+----------+\n"]))))) + (map + (fn [index [item-name quantity]] + (str + (format "|%-2d| %-14s | %3d |\n" index + (apply str (rest (str item-name))) + quantity))) + (range 0 (count inv)) inv) + ["+--+----------------+----------+\n"])))))) (defn inventory-codes [inventory] (flatten @@ -212,4 +214,60 @@ (+ item-list-start (count inv))) inv)) (write-memory! mem) (update-state))) + +(def gliched-tms + [[:TM51 1] + [:TM52 1] + [:TM53 1] + [:TM54 1]]) + +(def good-items + [[:bicycle 1] + [:ultra-ball 15] + [:pp-up 1] + [:master-ball 5] + [:rare-candy 99] + [:full-restore 25] + [:max-revive 8] + [:max-repel 40] + [:TM25 1] + [:TM11 1] + [:TM15 1] + ]) +(def some-badges + [[:cascadebadge 1] + [:thunderbadge 1] + [:rainbowbadge 1] + [:soulbadge 1] + ]) + +(defn run-item-program + "This is my first assembly/item program! + it just increments BC by one. + + The code places a single 'great ball' at the beginning of the + inventory, then directly sets the program counter to start + executing at the position of the 'great ball' in memory. + + Since a 'great ball' is represented in memory as 0x03, which + corresponts to the opcode which increments BC by one, that is + what happens. + + Obviously, the game crashes more or less immediately after the + program counter advances past the 'great ball' into the next items + in the inventory." + [] + (set-inventory (read-state 578544) [[:great-ball 1]]) + (print-inventory) + (println "3 ticks") (tick) (tick) (tick) + (println "PC before:" (PC)) + (println "BC before:" (BC)) + (PC! (inc item-list-start)) + (println "PC after setting:" (PC)) + (println "data at PC:" (aget (memory) (PC))) + (println "one tick") + (tick) + (println "PC after one tick:" (PC)) + (println "BC after one tick:" (BC))) + \ No newline at end of file