# HG changeset patch # User Robert McIntyre # Date 1332048780 18000 # Node ID 4245109932965208fc0b9c44d323f0a81ac984e5 # Parent d16cf9d829ddcfad507a693f12c8c9599b20391b saving progress diff -r d16cf9d829dd -r 424510993296 clojure/com/aurellem/item_bridge.clj --- a/clojure/com/aurellem/item_bridge.clj Sat Mar 17 21:32:29 2012 -0500 +++ b/clojure/com/aurellem/item_bridge.clj Sun Mar 18 00:33:00 2012 -0500 @@ -9,294 +9,64 @@ (defn corrupt-item-state [] (read-state "corrupt-items")) -(defn talk-to-rival [] - (read-state "talk-to-rival")) -(def rival-name-start 0xD349) +(defn view-memory-range [state start end] + (dorun + (map (fn [loc val] + (println (format "%04X : %02X" loc val))) + + (range start end) (subvec (vec (memory state)) start end))) + state) - -(defn set-rival-name [^SaveState state codes] +(defn set-memory [state location value] (set-state! state) (let [mem (memory state)] - (dorun (map (fn [index val] - (aset mem index val)) - (range rival-name-start - (+ rival-name-start - (count codes))) codes)) + (aset mem location value) (write-memory! mem) (update-state))) -(defn view-rival-name [name-codes] - (-> - (set-rival-name (talk-to-rival) name-codes) - (step [:a]) - (play 50))) +(defn almost-broken + "if one more memory location is turned into 0x03, the game crashes." + [n] + (view-memory-range + (set-inv-mem (mid-game) + (concat [0xFF] (repeat 64 0x03) + (subvec (vec (memory (mid-game))) + (+ item-list-start 65) + (+ item-list-start 65 n)) + (repeat (- 255 65 n) 0x03) + )) + + item-list-start (+ item-list-start 255))) -(defn rival-name-sequence [] - (let [i (atom 1)] - (fn [] - (let [codes (range @i (+ 5 @i))] - (println codes) - (view-rival-name codes) - (reset! i (+ 5 @i)))))) - +(defn actually-broken + "if one more memory location is turned into 0x03, the game crashes." + [] + (set-memory (mid-game) 0xD35D 0x03)) -;; 0x00 : end-of-name-sentinel -;; 0x01 : -;; 0x02 : -;; 0x03 : -;; 0x04 : -;; 0x05 : -;; 0x06 : -;; 0x07 : -;; 0x08 : -;; 0x09 : -;; 0x0A : -;; 0x0B : -;; 0x0C : -;; 0x0D : -;; 0x0E : -;; 0x0F : -;; 0x10 : -;; 0x11 : -;; 0x12 : -;; 0x13 : -;; 0x14 : -;; 0x15 : -;; 0x16 : -;; 0x17 : -;; 0x18 : -;; 0x19 : -;; 0x1A : -;; 0x1B : -;; 0x1C : -;; 0x1D : -;; 0x1E : -;; 0x1F : -;; 0x20 : -;; 0x21 : -;; 0x22 : -;; 0x23 : -;; 0x24 : -;; 0x25 : -;; 0x26 : -;; 0x27 : -;; 0x28 : -;; 0x29 : -;; 0x2A : -;; 0x2B : -;; 0x2C : -;; 0x2D : -;; 0x2E : -;; 0x2F : -;; 0x30 : -;; 0x31 : -;; 0x32 : -;; 0x33 : -;; 0x34 : -;; 0x35 : -;; 0x36 : -;; 0x37 : -;; 0x38 : -;; 0x39 : -;; 0x3A : -;; 0x3B : -;; 0x3C : -;; 0x3D : -;; 0x3E : -;; 0x3F : -;; 0x40 : -;; 0x41 : -;; 0x42 : -;; 0x43 : -;; 0x44 : -;; 0x45 : -;; 0x46 : -;; 0x47 : -;; 0x48 : -;; 0x49 : -;; 0x4A : -;; 0x4B : -;; 0x4C : -;; 0x4D : -;; 0x4E : -;; 0x4F : -;; 0x50 : -;; 0x51 : -;; 0x52 : -;; 0x53 : -;; 0x54 : -;; 0x55 : -;; 0x56 : -;; 0x57 : -;; 0x58 : -;; 0x59 : -;; 0x5A : -;; 0x5B : -;; 0x5C : -;; 0x5D : -;; 0x5E : -;; 0x5F : -;; 0x60 : A (small-bold) -;; 0x61 : B (small-bold) -;; 0x62 : C (small-bold) -;; 0x63 : D (small-bold) -;; 0x64 : E (small-bold) -;; 0x65 : F (small-bold) -;; 0x66 : G (small-bold) -;; 0x67 : H (small-bold) -;; 0x68 : I (small-bold) -;; 0x69 : V (small-bold) -;; 0x6A : S (small-bold) -;; 0x6B : L (small-bold) -;; 0x6C : M (small-bold) -;; 0x6D : -;; 0x6E : -;; 0x6F : -;; 0x70 : -;; 0x71 : -;; 0x72 : -;; 0x73 : -;; 0x74 : -;; 0x75 : -;; 0x76 : -;; 0x77 : -;; 0x78 : -;; 0x79 : -;; 0x7A : -;; 0x7B : -;; 0x7C : -;; 0x7D : -;; 0x7E : -;; 0x7F : -;; 0x80 : A -;; 0x81 : B -;; 0x82 : C -;; 0x83 : D -;; 0x84 : E -;; 0x85 : F -;; 0x86 : G -;; 0x87 : H -;; 0x88 : I -;; 0x89 : J -;; 0x8A : K -;; 0x8B : L -;; 0x8C : M -;; 0x8D : N -;; 0x8E : O -;; 0x8F : P -;; 0x90 : Q -;; 0x91 : R -;; 0x92 : S -;; 0x93 : T -;; 0x94 : U -;; 0x95 : V -;; 0x96 : W -;; 0x97 : X -;; 0x98 : Y -;; 0x99 : Z -;; 0x9A : ( -;; 0x9B : ) -;; 0x9C : : -;; 0x9D : ; -;; 0x9E : -;; 0x9F : -;; 0xA0 : a -;; 0xA1 : b -;; 0xA2 : c -;; 0xA3 : d -;; 0xA4 : e -;; 0xA5 : f -;; 0xA6 : g -;; 0xA7 : h -;; 0xA8 : i -;; 0xA9 : j -;; 0xAA : k -;; 0xAB : l -;; 0xAC : m -;; 0xAD : n -;; 0xAE : o -;; 0xAF : p -;; 0xB0 : q -;; 0xB1 : r -;; 0xB2 : s -;; 0xB3 : t -;; 0xB4 : u -;; 0xB5 : v -;; 0xB6 : w -;; 0xB7 : x -;; 0xB8 : y -;; 0xB9 : z -;; 0xBA : e-with-grave -;; 0xBB : -;; 0xBC : -;; 0xBD : -;; 0xBE : -;; 0xBF : -;; 0xC0 : -;; 0xC1 : -;; 0xC2 : -;; 0xC3 : -;; 0xC4 : -;; 0xC5 : -;; 0xC6 : -;; 0xC7 : -;; 0xC8 : -;; 0xC9 : -;; 0xCA : -;; 0xCB : -;; 0xCC : -;; 0xCD : -;; 0xCE : -;; 0xCF : -;; 0xD0 : -;; 0xD1 : -;; 0xD2 : -;; 0xD3 : -;; 0xD4 : -;; 0xD5 : -;; 0xD6 : -;; 0xD7 : -;; 0xD8 : -;; 0xD9 : -;; 0xDA : -;; 0xDB : -;; 0xDC : -;; 0xDD : -;; 0xDE : -;; 0xDF : -;; 0xE0 : ' -;; 0xE1 : PK -;; 0xE2 : MN -;; 0xE3 : -;; 0xE4 : -;; 0xE5 : -;; 0xE6 : ? -;; 0xE7 : ! -;; 0xE8 : . -;; 0xE9 : -;; 0xEA : -;; 0xEB : -;; 0xEC : -;; 0xED : -;; 0xEE : -;; 0xEF : male-symbol -;; 0xF0 : pokemon-money-symbol -;; 0xF1 : . -;; 0xF2 : / -;; 0xF3 : , -;; 0xF4 : female-symbol -;; 0xF5 : -;; 0xF6 : 0 -;; 0xF7 : 1 -;; 0xF8 : 2 -;; 0xF9 : 3 -;; 0xFA : 4 -;; 0xFB : 5 -;; 0xFC : 6 -;; 0xFD : 7 -;; 0xFE : 8 -;; 0xFF : 9 - - +;; (almost-broken 20) more or less works + +(defn capture-program-counter + "records the program counter for each tick" + [^SaveState state ticks] + (let [i (atom 0)] + (reduce (fn [[program-counters state] _] + (println (swap! i inc)) + [(conj program-counters (PC state)) + (tick state)]) + [[] state] + (range ticks)))) + + +(defn capture-program-counter + [^SaveState state ticks] + (set-state! state) + (loop [i 0 + pcs []] + (if (= i ticks) + pcs + (do + (com.aurellem.gb.Gb/tick) + (recur (inc i) + (conj pcs (first (registers)))))))) diff -r d16cf9d829dd -r 424510993296 clojure/com/aurellem/rival_name.clj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/clojure/com/aurellem/rival_name.clj Sun Mar 18 00:33:00 2012 -0500 @@ -0,0 +1,295 @@ +(ns com.aurellem.rival-name + (:use (com.aurellem gb-driver vbm title save-corruption items assembly)) + (:import [com.aurellem.gb_driver SaveState])) + + +(defn talk-to-rival [] + (read-state "talk-to-rival")) + +(def rival-name-start 0xD349) + +(defn set-rival-name [^SaveState state codes] + (set-state! state) + (let [mem (memory state)] + (dorun (map (fn [index val] + (aset mem index val)) + (range rival-name-start + (+ rival-name-start + (count codes))) codes)) + (write-memory! mem) + (update-state))) + +(defn view-rival-name [name-codes] + (-> + (set-rival-name (talk-to-rival) name-codes) + (step [:a]) + (play 50))) + +(defn rival-name-sequence [] + (let [i (atom 1)] + (fn [] + (let [codes (range @i (+ 5 @i))] + (println codes) + (view-rival-name codes) + (reset! i (+ 5 @i)))))) + + + +;; 0x00 : end-of-name-sentinel +;; 0x01 : +;; 0x02 : +;; 0x03 : +;; 0x04 : +;; 0x05 : +;; 0x06 : +;; 0x07 : +;; 0x08 : +;; 0x09 : +;; 0x0A : +;; 0x0B : +;; 0x0C : +;; 0x0D : +;; 0x0E : +;; 0x0F : +;; 0x10 : +;; 0x11 : +;; 0x12 : +;; 0x13 : +;; 0x14 : +;; 0x15 : +;; 0x16 : +;; 0x17 : +;; 0x18 : +;; 0x19 : +;; 0x1A : +;; 0x1B : +;; 0x1C : +;; 0x1D : +;; 0x1E : +;; 0x1F : +;; 0x20 : +;; 0x21 : +;; 0x22 : +;; 0x23 : +;; 0x24 : +;; 0x25 : +;; 0x26 : +;; 0x27 : +;; 0x28 : +;; 0x29 : +;; 0x2A : +;; 0x2B : +;; 0x2C : +;; 0x2D : +;; 0x2E : +;; 0x2F : +;; 0x30 : +;; 0x31 : +;; 0x32 : +;; 0x33 : +;; 0x34 : +;; 0x35 : +;; 0x36 : +;; 0x37 : +;; 0x38 : +;; 0x39 : +;; 0x3A : +;; 0x3B : +;; 0x3C : +;; 0x3D : +;; 0x3E : +;; 0x3F : +;; 0x40 : +;; 0x41 : +;; 0x42 : +;; 0x43 : +;; 0x44 : +;; 0x45 : +;; 0x46 : +;; 0x47 : +;; 0x48 : +;; 0x49 : +;; 0x4A : +;; 0x4B : +;; 0x4C : +;; 0x4D : +;; 0x4E : +;; 0x4F : +;; 0x50 : +;; 0x51 : +;; 0x52 : +;; 0x53 : +;; 0x54 : +;; 0x55 : +;; 0x56 : +;; 0x57 : +;; 0x58 : +;; 0x59 : +;; 0x5A : +;; 0x5B : +;; 0x5C : +;; 0x5D : +;; 0x5E : +;; 0x5F : +;; 0x60 : A (small-bold) +;; 0x61 : B (small-bold) +;; 0x62 : C (small-bold) +;; 0x63 : D (small-bold) +;; 0x64 : E (small-bold) +;; 0x65 : F (small-bold) +;; 0x66 : G (small-bold) +;; 0x67 : H (small-bold) +;; 0x68 : I (small-bold) +;; 0x69 : V (small-bold) +;; 0x6A : S (small-bold) +;; 0x6B : L (small-bold) +;; 0x6C : M (small-bold) +;; 0x6D : +;; 0x6E : +;; 0x6F : +;; 0x70 : +;; 0x71 : +;; 0x72 : +;; 0x73 : +;; 0x74 : +;; 0x75 : +;; 0x76 : +;; 0x77 : +;; 0x78 : +;; 0x79 : +;; 0x7A : +;; 0x7B : +;; 0x7C : +;; 0x7D : +;; 0x7E : +;; 0x7F : +;; 0x80 : A +;; 0x81 : B +;; 0x82 : C +;; 0x83 : D +;; 0x84 : E +;; 0x85 : F +;; 0x86 : G +;; 0x87 : H +;; 0x88 : I +;; 0x89 : J +;; 0x8A : K +;; 0x8B : L +;; 0x8C : M +;; 0x8D : N +;; 0x8E : O +;; 0x8F : P +;; 0x90 : Q +;; 0x91 : R +;; 0x92 : S +;; 0x93 : T +;; 0x94 : U +;; 0x95 : V +;; 0x96 : W +;; 0x97 : X +;; 0x98 : Y +;; 0x99 : Z +;; 0x9A : ( +;; 0x9B : ) +;; 0x9C : : +;; 0x9D : ; +;; 0x9E : +;; 0x9F : +;; 0xA0 : a +;; 0xA1 : b +;; 0xA2 : c +;; 0xA3 : d +;; 0xA4 : e +;; 0xA5 : f +;; 0xA6 : g +;; 0xA7 : h +;; 0xA8 : i +;; 0xA9 : j +;; 0xAA : k +;; 0xAB : l +;; 0xAC : m +;; 0xAD : n +;; 0xAE : o +;; 0xAF : p +;; 0xB0 : q +;; 0xB1 : r +;; 0xB2 : s +;; 0xB3 : t +;; 0xB4 : u +;; 0xB5 : v +;; 0xB6 : w +;; 0xB7 : x +;; 0xB8 : y +;; 0xB9 : z +;; 0xBA : e-with-grave +;; 0xBB : +;; 0xBC : +;; 0xBD : +;; 0xBE : +;; 0xBF : +;; 0xC0 : +;; 0xC1 : +;; 0xC2 : +;; 0xC3 : +;; 0xC4 : +;; 0xC5 : +;; 0xC6 : +;; 0xC7 : +;; 0xC8 : +;; 0xC9 : +;; 0xCA : +;; 0xCB : +;; 0xCC : +;; 0xCD : +;; 0xCE : +;; 0xCF : +;; 0xD0 : +;; 0xD1 : +;; 0xD2 : +;; 0xD3 : +;; 0xD4 : +;; 0xD5 : +;; 0xD6 : +;; 0xD7 : +;; 0xD8 : +;; 0xD9 : +;; 0xDA : +;; 0xDB : +;; 0xDC : +;; 0xDD : +;; 0xDE : +;; 0xDF : +;; 0xE0 : ' +;; 0xE1 : PK +;; 0xE2 : MN +;; 0xE3 : +;; 0xE4 : +;; 0xE5 : +;; 0xE6 : ? +;; 0xE7 : ! +;; 0xE8 : . +;; 0xE9 : +;; 0xEA : +;; 0xEB : +;; 0xEC : +;; 0xED : +;; 0xEE : +;; 0xEF : male-symbol +;; 0xF0 : pokemon-money-symbol +;; 0xF1 : . +;; 0xF2 : / +;; 0xF3 : , +;; 0xF4 : female-symbol +;; 0xF5 : +;; 0xF6 : 0 +;; 0xF7 : 1 +;; 0xF8 : 2 +;; 0xF9 : 3 +;; 0xFA : 4 +;; 0xFB : 5 +;; 0xFC : 6 +;; 0xFD : 7 +;; 0xFE : 8 +;; 0xFF : 9 + +