comparison clojure/com/aurellem/run/bootstrap_0.clj @ 319:92c47a9cdaea

adapting bootstrap to new util functions.
author Robert McIntyre <rlm@mit.edu>
date Tue, 03 Apr 2012 04:16:20 -0500
parents 8e63b0bb8ea3
children 9637a0f52e7b
comparison
equal deleted inserted replaced
318:9a4d3f801c89 319:92c47a9cdaea
1 (ns com.aurellem.run.bootstrap-0 1 (ns com.aurellem.run.bootstrap-0
2 (:use (com.aurellem.gb gb-driver util items vbm characters money)) 2 (:use (com.aurellem.gb gb-driver util items vbm characters money))
3 (:use (com.aurellem.run title save-corruption)) 3 (:use (com.aurellem.run util title save-corruption))
4 (:use (com.aurellem.exp item-bridge)) 4 (:use (com.aurellem.exp item-bridge))
5 (:import [com.aurellem.gb.gb_driver SaveState])) 5 (:import [com.aurellem.gb.gb_driver SaveState]))
6 6
7 (defn-memo boot-root [] 7 (defn-memo boot-root []
8 [ [] (root)]) 8 [ [] (root)])
9 9
10 (defn-memo to-rival-name 10 (defn-memo to-rival-name
11 ([] (to-rival-name (boot-root))) 11 ([] (to-rival-name (boot-root)))
12 ([script] 12 ([script]
13 (-> script 13 (->> script
14 title 14 title
15 oak 15 oak
16 name-entry-rlm 16 name-entry-rlm
17 scroll-text 17 (scroll-text 5))))
18 scroll-text
19 scroll-text
20 scroll-text
21 scroll-text)))
22 18
23 (defn-memo name-rival-bootstrap 19 (defn-memo name-rival-bootstrap
24 ([] (name-rival-bootstrap (to-rival-name))) 20 ([] (name-rival-bootstrap (to-rival-name)))
25 ([script] 21 ([script]
26 (->> script 22 (->> script
27 (advance [] [:a]) 23 (first-difference [] [:a] AF)
28 (advance [] [:r] DE) 24 (first-difference [] [:r] DE)
29 (play-moves 25 (play-moves
30 [[] 26 [[]
31 [] [] [:r] [] [:d] [:a] ;; L 27 [] [] [:r] [] [:d] [:a] ;; L
32 [:r] [] [:r] [] [:r] [] [:r] [] 28 [:r] [] [:r] [] [:r] [] [:r] []
33 [:r] [] [:d] [] [:d] [:a] ;; [PK] 29 [:r] [] [:d] [] [:d] [:a] ;; [PK]
43 (defn-memo leave-house 39 (defn-memo leave-house
44 ([] (leave-house (name-rival-bootstrap))) 40 ([] (leave-house (name-rival-bootstrap)))
45 ([script] 41 ([script]
46 (->> script 42 (->> script
47 finish-title 43 finish-title
48 start-walking
49 walk-to-stairs 44 walk-to-stairs
50 walk-to-door 45 walk-to-door
51 (walk [↓ ↓])))) 46 (walk [↓ ↓]))))
52 47
53 (defn-memo to-pallet-town-edge 48 (defn-memo to-pallet-town-edge
54 ([] (to-pallet-town-edge (leave-house))) 49 ([] (to-pallet-town-edge (leave-house)))
55 ([script] 50 ([script]
56 (->> script 51 (->> script
57 start-walking
58 (walk [→ → → → → 52 (walk [→ → → → →
59 ↑ ↑ ↑ ↑ ↑ ↑])))) 53 ↑ ↑ ↑ ↑ ↑ ↑]))))
60 54
61 (defn-memo start-pikachu-battle 55 (defn-memo start-pikachu-battle
62 ([] (start-pikachu-battle 56 ([] (start-pikachu-battle
63 (to-pallet-town-edge))) 57 (to-pallet-town-edge)))
64 ([script] 58 ([script]
65 (->> script 59 (->> script
66 (advance [:b] [:b :a] DE) 60 (first-difference [:b] [:b :a] DE)
67 (scroll-text) 61 scroll-text
68 (play-moves [[:b]]) 62 (do-nothing 200)
69 (scroll-text) 63 (play-moves [[:b]]))))
70 (end-text) ;; battle begins
71 (scroll-text))))
72 64
73 (defn-memo capture-pikachu 65 (defn-memo capture-pikachu
74 ([] (capture-pikachu (start-pikachu-battle))) 66 ([] (capture-pikachu (start-pikachu-battle)))
75 ([script] 67 ([script]
76 (->> script 68 (->> script
77 (scroll-text 2) 69 (scroll-text 3))))
78 (end-text))))
79 70
80 (defn-memo go-to-lab 71 (defn-memo go-to-lab
81 ([] (go-to-lab (capture-pikachu))) 72 ([] (go-to-lab (capture-pikachu)))
82 ([script] 73 ([script]
83 (->> script 74 (->> script
75 end-text
84 (scroll-text 5) 76 (scroll-text 5)
85 (end-text) 77 end-text
86 (scroll-text) 78 ;; oak walks you to his lab; no input required.
87 (end-text) 79 (do-nothing 400))))
88 (scroll-text 8) 80
89 (end-text) 81 (defn-memo talk-to-oak-in-lab
90 (scroll-text) 82 ([] (talk-to-oak-in-lab (go-to-lab)))
83 ([script]
84 (->> script
85 (scroll-text 14)
86 end-text)))
87
88 (defn-memo try-to-get-eevee
89 ([] (try-to-get-eevee (talk-to-oak-in-lab)))
90 ([script]
91 (->> script
92 ;; walk to pokeball
93 (walk [↓ → →])
94 ;; and try to grab it
95 (play-moves
96 (concat [↑ ↑ [:a]]
97 (repeat 100 [])))
98 (scroll-text 10)
91 (end-text)))) 99 (end-text))))
92 100
93 (defn-memo obtain-pikachu 101 (defn-memo obtain-pikachu
94 ([] (obtain-pikachu (go-to-lab))) 102 ([] (obtain-pikachu (try-to-get-eevee)))
95 ([script] 103 ([script]
96 (->> script 104 (->> script
97 (scroll-text) 105 (scroll-text 6)
98 (play-moves 106 (end-text))))
99 (concat 107
100 (repeat 51 []) 108
101 [[:a] []]))
102 (walk [↓ ↓ → → ↑])
103 (play-moves
104 (concat [[] [:a]]
105 (repeat 100 [])))
106 (scroll-text 9)
107 (end-text)
108 (scroll-text 7)
109
110 (play-moves
111 (concat
112 (repeat 50 [])
113 [[:b] [] []])))))
114
115 (defn-memo begin-battle-with-rival 109 (defn-memo begin-battle-with-rival
116 ([] (begin-battle-with-rival 110 ([] (begin-battle-with-rival
117 (obtain-pikachu))) 111 (obtain-pikachu)))
118 ([script] 112 ([script]
119 (->> script 113 (->> script
120 (walk [↓ ↓ ↓ ↓]) 114 (walk [↓ ↓ ↓])
121 (scroll-text 3) 115 (scroll-text 3)
122 (end-text) 116 (end-text)
123 (scroll-text)))) 117 (scroll-text))))
124 118
125 (defn-memo battle-with-rival 119 (defn-memo defeat-eevee
126 ([] (battle-with-rival 120 ([] (defeat-eevee
127 (begin-battle-with-rival))) 121 (begin-battle-with-rival)))
128 ([script] 122 ([script]
129 (->> script 123 (->> script
130 (do-nothing 400) 124 (do-nothing 400)
131 (play-moves [[:a]]) 125 (play-moves [[:a]])
132 (critical-hit) 126 (critical-hit)
133 (do-nothing 100) 127 (do-nothing 200)
134 (scroll-text) 128 (scroll-text 2) ;; for eevee's tail-whip
135 (do-nothing 275) 129 (do-nothing 10)
136 (play-moves [[:a]]) 130 (play-moves [[:a]])
137 (critical-hit) 131 (critical-hit)
138 (do-nothing 100) 132 (do-nothing 200)
139 (scroll-text) 133 (scroll-text 2) ;; tail whip again
140 (do-nothing 270) 134 (do-nothing 10)
141 (play-moves [[:a]]) 135 (play-moves [[:a]])
142 (critical-hit) 136 (critical-hit)
143 (do-nothing 100) 137 (do-nothing 200))))
144 (scroll-text))))
145 138
146 (defn-memo finish-rival-text 139 (defn-memo finish-rival-text
147 ([] (finish-rival-text 140 ([] (finish-rival-text
148 (battle-with-rival))) 141 (defeat-eevee)))
149 ([script] 142 ([script]
150 (->> script 143 (->> script
151 (scroll-text 2) 144 (scroll-text 12)
152 (end-text)
153 (scroll-text 9)
154 (end-text)))) 145 (end-text))))
155 146
156 (defn-memo pikachu-comes-out 147 (defn-memo pikachu-comes-out
157 ([] (pikachu-comes-out 148 ([] (pikachu-comes-out
158 (finish-rival-text))) 149 (finish-rival-text)))
159 ([script] 150 ([script]
160 (->> script 151 (->> script
161 (do-nothing 177) 152 (scroll-text 8)
162 (end-text)
163 (scroll-text 7)
164 (end-text)))) 153 (end-text))))
165 154
166 (defn-memo leave-oaks-lab 155 (defn-memo leave-oaks-lab
167 ([] (leave-oaks-lab 156 ([] (leave-oaks-lab
168 (pikachu-comes-out))) 157 (pikachu-comes-out)))
169 ([script] 158 ([script]
170 (->> script 159 (->> script
171 (walk [← ← ↓ ↓ ↓ ↓ ↓ ↓])))) 160 (walk [↓ ↓ ↓ ↓ ↓ ↓]))))
172 161
173 (defn-memo oaks-lab->pallet-town-edge 162 (defn-memo oaks-lab->pallet-town-edge
174 ([] (oaks-lab->pallet-town-edge 163 ([] (oaks-lab->pallet-town-edge
175 (leave-oaks-lab))) 164 (leave-oaks-lab)))
176 ([script] 165 ([script]
177 (->> script 166 (->> script
178 (walk [← ← ← ← 167 (walk [← ← ←
179 ↑ ↑ ↑ ↑ 168 ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ →]))))
180 ↑ ↑ ↑ ↑ ↑ ↑
181 → ↑]))))
182 169
183 (defn-memo pallet-edge->viridian-mart 170 (defn-memo pallet-edge->viridian-mart
184 ([] (pallet-edge->viridian-mart true 171 ([] (pallet-edge->viridian-mart true
185 (oaks-lab->pallet-town-edge))) 172 (oaks-lab->pallet-town-edge)))
186 ([dodge-stupid-guy? script] 173 ([dodge-stupid-guy? script]
187 (let [dodge-1 (if dodge-stupid-guy? 174 (let [dodge-1 (if dodge-stupid-guy?
188 [→ →] 175 [→ →]
189 [→]) 176 [→])
190 dodge-2 (if dodge-stupid-guy? 177 dodge-2 (if dodge-stupid-guy?
191 [↑ ↑ ←] 178 [↑ ↑ ←]
192 [↑ ↑ ←])] 179 [↑ ↑])]
193 180
194 (->> script 181 (->> script
195 ;; leave straight grass 182 ;; leave straight grass
196 (walk-thru-grass 183 (walk-thru-grass
197 [↑ ↑ ↑ ↑ ↑]) 184 [↑ ↑ ↑ ↑ ↑])
230 (defn-memo get-oaks-parcel 217 (defn-memo get-oaks-parcel
231 ([] (get-oaks-parcel 218 ([] (get-oaks-parcel
232 (pallet-edge->viridian-mart))) 219 (pallet-edge->viridian-mart)))
233 ([script] 220 ([script]
234 (->> script 221 (->> script
222 (do-nothing 50)
235 (end-text) 223 (end-text)
236 (scroll-text 3) 224 (scroll-text 3)
237 (do-nothing 197) 225 (do-nothing 197)
238 (play-moves [[:a] []]) 226 (play-moves [[:a] []])
239 (walk [↓ ↓ → ↓])))) 227 (walk [↓ ↓ → ↓]))))
242 ([] (viridian-store->oaks-lab 230 ([] (viridian-store->oaks-lab
243 (get-oaks-parcel))) 231 (get-oaks-parcel)))
244 ([script] 232 ([script]
245 (->> script 233 (->> script
246 (walk [↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ 234 (walk [↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
247 ← ← ← ← ← ← ← ← ← ← 235 ← ← ← ← ← ← ← ← ←
248 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ 236 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
249 ← ← 237 ← ←
250 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ 238 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
251 ↓ ↓ ↓ ↓ ↓ ↓ ↓ 239 ↓ ↓ ↓ ↓ ↓ ↓ ↓
252 → → → → → → → → 240 → → → → → → → →
241 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
242 ← ← ← ← ←
253 ↓ ↓ ↓ ↓ 243 ↓ ↓ ↓ ↓
254 ← ← ← ← ← 244 ])
255 ↓ ↓ ↓ ↓])
256
257 (walk-thru-grass 245 (walk-thru-grass
258 [↓ ↓ ↓ ↓ ↓ ↓ ↓]) 246 [↓ ↓ ↓ ↓ ↓ ↓ ↓])
259
260 (walk [↓ ↓ ← ↓ ↓ ↓ ← 247 (walk [↓ ↓ ← ↓ ↓ ↓ ←
261 ↓ ↓ ↓ ↓ ↓ 248 ↓ ↓ ↓ ↓ ↓ ↓
262 → → → ↑])))) 249 → → → ↑])
250
251 (do-nothing 1))))
252
263 253
264 (defn-memo viridian-store->oaks-lab-like-a-boss 254 (defn-memo viridian-store->oaks-lab-like-a-boss
265 ([] (viridian-store->oaks-lab-like-a-boss 255 ([] (viridian-store->oaks-lab-like-a-boss
266 (get-oaks-parcel))) 256 (get-oaks-parcel)))
267 ([script] 257 ([script]
268 (->> script 258 (->> script
269 (walk [↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ 259 (walk [↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
270 ← ← ← ← ← ← ← ← ← ← 260 ← ← ← ← ← ← ← ← ←
271 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓]) 261 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓])
272 262
273 (walk-thru-grass 263 (walk-thru-grass
274 [↓ ↓ ↓ ↓ ↓]) 264 [↓ ↓ ↓ ↓ ↓])
275 265
276 (walk 266 (walk
277 [↓ ↓ ← ↓ 267 [↓ ↓ ← ↓
278 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ 268 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
279 → →]) 269 → → → ↓])
280 270
281 (walk-thru-grass 271 (walk-thru-grass
282 [→ ↓ ↓ ↓]) 272 [↓ ↓ ↓])
283 273
284 (walk [↓ ← ← ↓ ↓ ↓ ↓ ↓ ↓]) 274 (walk [↓ ← ← ↓ ↓ ↓ ↓ ↓ ↓])
285 275
286 (walk-thru-grass 276 (walk-thru-grass
287 [↓ ↓ ↓ ↓ ↓ ↓ ↓]) 277 [↓ ↓ ↓ ↓ ↓ ↓])
288 278
289 (walk [↓ ↓ ← ↓ ↓ ↓ ← 279 (walk [↓ ↓ ↓ ← ↓ ↓ ↓
290 ↓ ↓ ↓ ↓ ↓ 280 ↓ ↓ ↓ ↓ ↓
291 → → → ↑])))) 281 → → → ↑]))))
292 282
293 (defn-memo deliver-oaks-parcel 283 (defn-memo deliver-oaks-parcel
294 ([] (deliver-oaks-parcel 284 ([] (deliver-oaks-parcel
295 (viridian-store->oaks-lab-like-a-boss))) 285 (viridian-store->oaks-lab-like-a-boss)))
296 ([script] 286 ([script]
297 (->> script 287 (->> script
298 (walk [↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑]) 288 (walk [↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑])
299 (play-moves [[:a]]) 289 (play-moves [[] [:a]])
300 (scroll-text 11) 290 (scroll-text 13)
301 (end-text)
302 (end-text) 291 (end-text)
303 (do-nothing 200) 292 (do-nothing 200)
304 (end-text) 293 (scroll-text 2)
305 (scroll-text 3)
306 (end-text) 294 (end-text)
307 (scroll-text 2) 295 (scroll-text 2)
308 (end-text) 296 (end-text)
309 (scroll-text 5) 297 (scroll-text 8)
310 (end-text)
311 (scroll-text 2)
312 (end-text) 298 (end-text)
313 (scroll-text 9) 299 (scroll-text 9)
314 (end-text) 300 (end-text)
315 (scroll-text 7) 301 (scroll-text 7)
316 (end-text) 302 (end-text)
317 (walk [← ← ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓])))) 303 (walk [↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓]))))
318 304
319 (defn-memo return-to-viridian-mart 305 (defn-memo return-to-viridian-mart
320 ([] (return-to-viridian-mart 306 ([] (return-to-viridian-mart
321 (deliver-oaks-parcel))) 307 (deliver-oaks-parcel)))
322 ([script] 308 ([script]
327 (defn-memo walk-to-counter 313 (defn-memo walk-to-counter
328 ([] (walk-to-counter 314 ([] (walk-to-counter
329 (return-to-viridian-mart))) 315 (return-to-viridian-mart)))
330 ([script] 316 ([script]
331 (->> script 317 (->> script
332 (walk [↑ ↑ ← ←])))) 318 (walk [↑ ↑ ←]))))
333 319
334 (defn buy-item 320 (defn buy-item
335 "Assumes that the main item-screen is up, and buys 321 "Assumes that the main item-screen is up, and buys
336 quantity of the nth item in the list, assuming that you 322 quantity of the nth item in the list, assuming that you
337 have enough money." 323 have enough money."
470 (play-moves [[:b]]) 456 (play-moves [[:b]])
471 (do-nothing 100) 457 (do-nothing 100)
472 (play-moves [[:b]]) 458 (play-moves [[:b]])
473 (do-nothing 100) 459 (do-nothing 100)
474 (play-moves [[:b] []]) 460 (play-moves [[:b] []])
475 (advance [:b] [:b :start])))) 461 (first-difference [:b] [:b :start] AF))))
476 462
477 463
478 (defn-memo do-save-corruption 464 (defn-memo do-save-corruption
479 ([] (do-save-corruption 465 ([] (do-save-corruption
480 (buy-initial-items))) 466 (buy-initial-items)))
481 ([script] 467 ([script]
482 (->> script 468 (->> script
483 (advance [] [:d]) 469 (first-difference [] [:d] AF)
484 (play-moves [[] [] [] [:d] 470 (play-moves [[] [] [] [:d]
485 [] [] [] [:d] 471 [] [] [] [:d]
486 [] [] [] [:d] 472 [] [] [] [:d]
487 [] [] [:a]]) 473 [] [] [:a]])
488 scroll-text 474 scroll-text
492 ;; 0xFF, allowing manipulation of non-pokemon data in RAM 478 ;; 0xFF, allowing manipulation of non-pokemon data in RAM
493 ;; via the pokemon interface. 479 ;; via the pokemon interface.
494 [[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] 480 [[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
495 [] [] [] [] [] [] [] [] [] [] [] [:select] [:restart]]) 481 [] [] [] [] [] [] [] [] [] [] [] [:select] [:restart]])
496 (title) 482 (title)
497 (advance [] [:start]) 483 (first-difference [] [:start] AF)
498 (advance [] [:a]) 484 (first-difference [] [:a] AF)
499 (advance [:a] [:a :start])))) 485 (first-difference [:a] [:a :start] AF))))
486
487 (def menu do-nothing )
500 488
501 (defn-memo corrupt-item-list 489 (defn-memo corrupt-item-list
502 ([] (corrupt-item-list 490 ([] (corrupt-item-list
503 (do-save-corruption))) 491 (do-save-corruption)))
504 ([script] 492 ([script]
560 (play-moves [[:b]]) 548 (play-moves [[:b]])
561 (do-nothing 100) 549 (do-nothing 100)
562 (play-moves [[:b]]) 550 (play-moves [[:b]])
563 (do-nothing 40) 551 (do-nothing 40)
564 (play-moves [[:b]]) 552 (play-moves [[:b]])
565 (advance [:b] [:start :b]) 553 (first-difference [:b] [:start :b] AF)
566 (menu [[:a] ↑ ↑ ↑ ↑ ↑ ; get fifth pokemon 554 (menu [[:a] ↑ ↑ ↑ ↑ ↑ ; get fifth pokemon
567 [:a] ↓ [:a] ; and corrupt the 555 [:a] ↓ [:a] ; and corrupt the
568 ↓ ↓ ↓ ↓ ↓ [:a]]) ; item list again by 556 ↓ ↓ ↓ ↓ ↓ [:a]]) ; item list again by
569 ; switching it to 557 ; switching it to
570 ))) ; tenth place. 558 ))) ; tenth place.