Mercurial > vba-clojure
comparison clojure/com/aurellem/item_bridge.clj @ 133:424510993296
saving progress
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sun, 18 Mar 2012 00:33:00 -0500 |
parents | d16cf9d829dd |
children | b12d2408fd9b |
comparison
equal
deleted
inserted
replaced
132:d16cf9d829dd | 133:424510993296 |
---|---|
7 (second (destroy-item-end-of-list-marker))) | 7 (second (destroy-item-end-of-list-marker))) |
8 | 8 |
9 (defn corrupt-item-state [] | 9 (defn corrupt-item-state [] |
10 (read-state "corrupt-items")) | 10 (read-state "corrupt-items")) |
11 | 11 |
12 (defn talk-to-rival [] | |
13 (read-state "talk-to-rival")) | |
14 | 12 |
15 (def rival-name-start 0xD349) | 13 (defn view-memory-range [state start end] |
14 (dorun | |
15 (map (fn [loc val] | |
16 (println (format "%04X : %02X" loc val))) | |
17 | |
18 (range start end) (subvec (vec (memory state)) start end))) | |
19 state) | |
16 | 20 |
17 | 21 (defn set-memory [state location value] |
18 (defn set-rival-name [^SaveState state codes] | |
19 (set-state! state) | 22 (set-state! state) |
20 (let [mem (memory state)] | 23 (let [mem (memory state)] |
21 (dorun (map (fn [index val] | 24 (aset mem location value) |
22 (aset mem index val)) | |
23 (range rival-name-start | |
24 (+ rival-name-start | |
25 (count codes))) codes)) | |
26 (write-memory! mem) | 25 (write-memory! mem) |
27 (update-state))) | 26 (update-state))) |
28 | 27 |
29 (defn view-rival-name [name-codes] | 28 (defn almost-broken |
30 (-> | 29 "if one more memory location is turned into 0x03, the game crashes." |
31 (set-rival-name (talk-to-rival) name-codes) | 30 [n] |
32 (step [:a]) | 31 (view-memory-range |
33 (play 50))) | 32 (set-inv-mem (mid-game) |
33 (concat [0xFF] (repeat 64 0x03) | |
34 (subvec (vec (memory (mid-game))) | |
35 (+ item-list-start 65) | |
36 (+ item-list-start 65 n)) | |
37 (repeat (- 255 65 n) 0x03) | |
38 )) | |
39 | |
40 item-list-start (+ item-list-start 255))) | |
34 | 41 |
35 (defn rival-name-sequence [] | 42 (defn actually-broken |
36 (let [i (atom 1)] | 43 "if one more memory location is turned into 0x03, the game crashes." |
37 (fn [] | 44 [] |
38 (let [codes (range @i (+ 5 @i))] | 45 (set-memory (mid-game) 0xD35D 0x03)) |
39 (println codes) | |
40 (view-rival-name codes) | |
41 (reset! i (+ 5 @i)))))) | |
42 | |
43 | 46 |
44 | 47 |
45 ;; 0x00 : end-of-name-sentinel | 48 ;; (almost-broken 20) more or less works |
46 ;; 0x01 : | 49 |
47 ;; 0x02 : | 50 (defn capture-program-counter |
48 ;; 0x03 : | 51 "records the program counter for each tick" |
49 ;; 0x04 : | 52 [^SaveState state ticks] |
50 ;; 0x05 : | 53 (let [i (atom 0)] |
51 ;; 0x06 : | 54 (reduce (fn [[program-counters state] _] |
52 ;; 0x07 : | 55 (println (swap! i inc)) |
53 ;; 0x08 : | 56 [(conj program-counters (PC state)) |
54 ;; 0x09 : | 57 (tick state)]) |
55 ;; 0x0A : | 58 [[] state] |
56 ;; 0x0B : | 59 (range ticks)))) |
57 ;; 0x0C : | 60 |
58 ;; 0x0D : | 61 |
59 ;; 0x0E : | 62 (defn capture-program-counter |
60 ;; 0x0F : | 63 [^SaveState state ticks] |
61 ;; 0x10 : | 64 (set-state! state) |
62 ;; 0x11 : | 65 (loop [i 0 |
63 ;; 0x12 : | 66 pcs []] |
64 ;; 0x13 : | 67 (if (= i ticks) |
65 ;; 0x14 : | 68 pcs |
66 ;; 0x15 : | 69 (do |
67 ;; 0x16 : | 70 (com.aurellem.gb.Gb/tick) |
68 ;; 0x17 : | 71 (recur (inc i) |
69 ;; 0x18 : | 72 (conj pcs (first (registers)))))))) |
70 ;; 0x19 : | |
71 ;; 0x1A : | |
72 ;; 0x1B : | |
73 ;; 0x1C : | |
74 ;; 0x1D : | |
75 ;; 0x1E : | |
76 ;; 0x1F : | |
77 ;; 0x20 : | |
78 ;; 0x21 : | |
79 ;; 0x22 : | |
80 ;; 0x23 : | |
81 ;; 0x24 : | |
82 ;; 0x25 : | |
83 ;; 0x26 : | |
84 ;; 0x27 : | |
85 ;; 0x28 : | |
86 ;; 0x29 : | |
87 ;; 0x2A : | |
88 ;; 0x2B : | |
89 ;; 0x2C : | |
90 ;; 0x2D : | |
91 ;; 0x2E : | |
92 ;; 0x2F : | |
93 ;; 0x30 : | |
94 ;; 0x31 : | |
95 ;; 0x32 : | |
96 ;; 0x33 : | |
97 ;; 0x34 : | |
98 ;; 0x35 : | |
99 ;; 0x36 : | |
100 ;; 0x37 : | |
101 ;; 0x38 : | |
102 ;; 0x39 : | |
103 ;; 0x3A : | |
104 ;; 0x3B : | |
105 ;; 0x3C : | |
106 ;; 0x3D : | |
107 ;; 0x3E : | |
108 ;; 0x3F : | |
109 ;; 0x40 : | |
110 ;; 0x41 : | |
111 ;; 0x42 : | |
112 ;; 0x43 : | |
113 ;; 0x44 : | |
114 ;; 0x45 : | |
115 ;; 0x46 : | |
116 ;; 0x47 : | |
117 ;; 0x48 : | |
118 ;; 0x49 : | |
119 ;; 0x4A : | |
120 ;; 0x4B : | |
121 ;; 0x4C : | |
122 ;; 0x4D : | |
123 ;; 0x4E : | |
124 ;; 0x4F : | |
125 ;; 0x50 : | |
126 ;; 0x51 : | |
127 ;; 0x52 : | |
128 ;; 0x53 : | |
129 ;; 0x54 : | |
130 ;; 0x55 : | |
131 ;; 0x56 : | |
132 ;; 0x57 : | |
133 ;; 0x58 : | |
134 ;; 0x59 : | |
135 ;; 0x5A : | |
136 ;; 0x5B : | |
137 ;; 0x5C : | |
138 ;; 0x5D : | |
139 ;; 0x5E : | |
140 ;; 0x5F : | |
141 ;; 0x60 : A (small-bold) | |
142 ;; 0x61 : B (small-bold) | |
143 ;; 0x62 : C (small-bold) | |
144 ;; 0x63 : D (small-bold) | |
145 ;; 0x64 : E (small-bold) | |
146 ;; 0x65 : F (small-bold) | |
147 ;; 0x66 : G (small-bold) | |
148 ;; 0x67 : H (small-bold) | |
149 ;; 0x68 : I (small-bold) | |
150 ;; 0x69 : V (small-bold) | |
151 ;; 0x6A : S (small-bold) | |
152 ;; 0x6B : L (small-bold) | |
153 ;; 0x6C : M (small-bold) | |
154 ;; 0x6D : | |
155 ;; 0x6E : | |
156 ;; 0x6F : | |
157 ;; 0x70 : | |
158 ;; 0x71 : | |
159 ;; 0x72 : | |
160 ;; 0x73 : | |
161 ;; 0x74 : | |
162 ;; 0x75 : | |
163 ;; 0x76 : | |
164 ;; 0x77 : | |
165 ;; 0x78 : | |
166 ;; 0x79 : | |
167 ;; 0x7A : | |
168 ;; 0x7B : | |
169 ;; 0x7C : | |
170 ;; 0x7D : | |
171 ;; 0x7E : | |
172 ;; 0x7F : | |
173 ;; 0x80 : A | |
174 ;; 0x81 : B | |
175 ;; 0x82 : C | |
176 ;; 0x83 : D | |
177 ;; 0x84 : E | |
178 ;; 0x85 : F | |
179 ;; 0x86 : G | |
180 ;; 0x87 : H | |
181 ;; 0x88 : I | |
182 ;; 0x89 : J | |
183 ;; 0x8A : K | |
184 ;; 0x8B : L | |
185 ;; 0x8C : M | |
186 ;; 0x8D : N | |
187 ;; 0x8E : O | |
188 ;; 0x8F : P | |
189 ;; 0x90 : Q | |
190 ;; 0x91 : R | |
191 ;; 0x92 : S | |
192 ;; 0x93 : T | |
193 ;; 0x94 : U | |
194 ;; 0x95 : V | |
195 ;; 0x96 : W | |
196 ;; 0x97 : X | |
197 ;; 0x98 : Y | |
198 ;; 0x99 : Z | |
199 ;; 0x9A : ( | |
200 ;; 0x9B : ) | |
201 ;; 0x9C : : | |
202 ;; 0x9D : ; | |
203 ;; 0x9E : | |
204 ;; 0x9F : | |
205 ;; 0xA0 : a | |
206 ;; 0xA1 : b | |
207 ;; 0xA2 : c | |
208 ;; 0xA3 : d | |
209 ;; 0xA4 : e | |
210 ;; 0xA5 : f | |
211 ;; 0xA6 : g | |
212 ;; 0xA7 : h | |
213 ;; 0xA8 : i | |
214 ;; 0xA9 : j | |
215 ;; 0xAA : k | |
216 ;; 0xAB : l | |
217 ;; 0xAC : m | |
218 ;; 0xAD : n | |
219 ;; 0xAE : o | |
220 ;; 0xAF : p | |
221 ;; 0xB0 : q | |
222 ;; 0xB1 : r | |
223 ;; 0xB2 : s | |
224 ;; 0xB3 : t | |
225 ;; 0xB4 : u | |
226 ;; 0xB5 : v | |
227 ;; 0xB6 : w | |
228 ;; 0xB7 : x | |
229 ;; 0xB8 : y | |
230 ;; 0xB9 : z | |
231 ;; 0xBA : e-with-grave | |
232 ;; 0xBB : | |
233 ;; 0xBC : | |
234 ;; 0xBD : | |
235 ;; 0xBE : | |
236 ;; 0xBF : | |
237 ;; 0xC0 : | |
238 ;; 0xC1 : | |
239 ;; 0xC2 : | |
240 ;; 0xC3 : | |
241 ;; 0xC4 : | |
242 ;; 0xC5 : | |
243 ;; 0xC6 : | |
244 ;; 0xC7 : | |
245 ;; 0xC8 : | |
246 ;; 0xC9 : | |
247 ;; 0xCA : | |
248 ;; 0xCB : | |
249 ;; 0xCC : | |
250 ;; 0xCD : | |
251 ;; 0xCE : | |
252 ;; 0xCF : | |
253 ;; 0xD0 : | |
254 ;; 0xD1 : | |
255 ;; 0xD2 : | |
256 ;; 0xD3 : | |
257 ;; 0xD4 : | |
258 ;; 0xD5 : | |
259 ;; 0xD6 : | |
260 ;; 0xD7 : | |
261 ;; 0xD8 : | |
262 ;; 0xD9 : | |
263 ;; 0xDA : | |
264 ;; 0xDB : | |
265 ;; 0xDC : | |
266 ;; 0xDD : | |
267 ;; 0xDE : | |
268 ;; 0xDF : | |
269 ;; 0xE0 : ' | |
270 ;; 0xE1 : PK | |
271 ;; 0xE2 : MN | |
272 ;; 0xE3 : | |
273 ;; 0xE4 : | |
274 ;; 0xE5 : | |
275 ;; 0xE6 : ? | |
276 ;; 0xE7 : ! | |
277 ;; 0xE8 : . | |
278 ;; 0xE9 : | |
279 ;; 0xEA : | |
280 ;; 0xEB : | |
281 ;; 0xEC : | |
282 ;; 0xED : | |
283 ;; 0xEE : | |
284 ;; 0xEF : male-symbol | |
285 ;; 0xF0 : pokemon-money-symbol | |
286 ;; 0xF1 : . | |
287 ;; 0xF2 : / | |
288 ;; 0xF3 : , | |
289 ;; 0xF4 : female-symbol | |
290 ;; 0xF5 : | |
291 ;; 0xF6 : 0 | |
292 ;; 0xF7 : 1 | |
293 ;; 0xF8 : 2 | |
294 ;; 0xF9 : 3 | |
295 ;; 0xFA : 4 | |
296 ;; 0xFB : 5 | |
297 ;; 0xFC : 6 | |
298 ;; 0xFD : 7 | |
299 ;; 0xFE : 8 | |
300 ;; 0xFF : 9 | |
301 | |
302 |