view clojure/com/aurellem/run/bootstrap_1.clj @ 368:08f8284e2f1b

cleaning up code
author Robert McIntyre <rlm@mit.edu>
date Tue, 10 Apr 2012 03:32:47 -0500
parents 845b2d88bef9
children abcc522a3242
line wrap: on
line source
1 (ns com.aurellem.run.bootstrap-1
2 (:use (com.aurellem.gb saves gb-driver util
3 items vbm characters money))
4 (:use (com.aurellem.run util title save-corruption bootstrap-0))
5 (:use (com.aurellem.exp item-bridge))
6 (:import [com.aurellem.gb.gb_driver SaveState]))
8 (defn pc-item-writer-program
9 []
10 (let [limit 201
11 [target-high target-low] (disect-bytes-2 0xD162)]
12 (flatten
13 [[0x00 ;; (item-hack) set increment stack pointer no-op
14 0x1E ;; load limit into E
15 limit
16 0x3F ;; (item-hack) set carry flag no-op
18 ;; load 2 into C.
19 0x0E ;; C == 1 means input-first nybble
20 0x04 ;; C == 0 means input-second nybble
22 0x21 ;; load target into HL
23 target-low
24 target-high
25 0x37 ;; (item-hack) set carry flag no-op
27 0x00 ;; (item-hack) no-op
28 0x37 ;; (item-hack) set carry flag no-op
30 0x00 ;; (item-hack) no-op
31 0xF3 ;; disable interrupts
32 ;; Input Section
34 0x3E ;; load 0x20 into A, to measure buttons
35 0x10
37 0x00 ;; (item-hack) no-op
38 0xE0 ;; load A into [FF00]
39 0x00
41 0xF0 ;; load 0xFF00 into A to get
42 0x00 ;; button presses
44 0xE6
45 0x0F ;; select bottom four bits of A
46 0x37 ;; (item-hack) set carry flag no-op
48 0x00 ;; (item-hack) no-op
49 0xB8 ;; see if input is different (CP A B)
51 0x00 ;; (item-hack) (INC SP)
52 0x28 ;; repeat above steps if input is not different
53 ;; (jump relative backwards if B != A)
54 0xED ;; (literal -19) (item-hack) -19 == egg bomb (TM37)
56 0x47 ;; load A into B
58 0x0D ;; dec C
59 0x37 ;; (item-hack) set-carry flag
60 ;; branch based on C:
61 0x20 ;; JR NZ
62 23 ;; skip "input second nybble" and "jump to target" below
64 ;; input second nybble
66 0x0C ;; inc C
67 0x0C ;; inc C
69 0x00 ;; (item-hack) no-op
70 0xE6 ;; select bottom bits
71 0x0F
72 0x37 ;; (item-hack) set-carry flag no-op
74 0x00 ;; (item-hack) no-op
75 0xB2 ;; (OR A D) -> A
77 0x22 ;; (do (A -> (HL)) (INC HL))
79 0x1D ;; (DEC E)
81 0x00 ;; (item-hack)
82 0x20 ;; jump back to input section if not done
83 0xDA ;; literal -36 == TM 18 (counter)
84 0x01 ;; (item-hack) set BC to literal (no-op)
86 ;; jump to target
87 0x00 ;; (item-hack) these two bytes can be anything.
88 0x01
90 0x00 ;; (item-hack) no-op
91 0xBF ;; (CP A A) ensures Z
93 0xCA ;; (item-hack) jump if Z
94 target-low
95 target-high
96 0x01 ;; (item-hack) will never be reached.
98 ;; input first nybble
99 0x00
100 0xCB
101 0x37 ;; swap nybbles on A
103 0x57 ;; A -> D
105 0x37 ;; (item-hack) set carry flag no-op
106 0x18 ;; relative jump backwards
107 0xCD ;; literal -51 == TM05; go back to input section
108 0x01 ;; (item-hack) will never reach this instruction
110 ]
111 (repeat 8 [0x00 0x02]);; these can be anything
113 [;; jump to actual program
114 0x00
115 0x37 ;; (item-hack) set carry flag no-op
117 0x2E ;; 0x3A -> L
118 0x3A
121 0x00 ;; (item-hack) no-op
122 0x26 ;; 0xD5 -> L
123 0xD5
124 0x01 ;; (item-hack) set-carry BC
126 0x00 ;; (item-hack) these can be anything
127 0x01
129 0x00
130 0xE9 ;; jump to (HL)
131 ]])))
133 (defn print-desired-item-layout []
134 (clojure.pprint/pprint
135 (raw-inventory->inventory (pc-item-writer-program))))
137 (defn pc-item-writer-state []
138 (-> (read-state "bootstrap-init")
139 (set-memory pc-item-list-start 50)
140 (set-memory-range
141 map-function-address-start
142 [0x8B 0xD5])
143 (set-memory-range
144 (inc pc-item-list-start)
145 (pc-item-writer-program))))
147 (defn test-pc-item-writer []
148 (let [orig (read-state "pc-item-writer")]
149 (-> orig
150 (print-listing 0xD162 (+ 0xD162 20))
151 (run-moves (reduce concat
152 (repeat 10 [[:a :b :start :select] []])))
153 ((fn [_] (println "===========") _))
154 (print-listing 0xD162 (+ 0xD162 20)))))
156 (defn close-all-menus [[moves state :as script]]
157 (loop [s script]
158 (let [depth (current-depth (second (do-nothing 50 s)))]
159 (println "depth" depth)
160 (if (= depth 1)
161 s
162 (recur (close-menu s))))))
164 (defn-memo name-rival
165 ([] (name-rival (to-rival-name)))
166 ([script]
167 (->> script
168 (first-difference [] [:a] AF)
169 (first-difference [] [:r] DE)
170 (play-moves
171 [[]
172 [] [] [:r] [] [:d] [:a] ;; L
173 [:r] [] [:r] [] [:r] [] [:r] []
174 [:r] [] [:d] [] [:d] [:a] ;; [PK]
175 [:d] [] [:r] [:a]
176 ]))))
178 (defn-memo to-room-pc
179 ([] (to-room-pc (name-rival)))
180 ([script]
181 (->> script
182 finish-title
183 (walk [← ← ↑ ← ↑ ↑ ↑]))))
185 (defn-memo bootstrap-corrupt-save
186 ([] (bootstrap-corrupt-save (to-room-pc)))
187 ([script]
188 (->> script
189 (do-save-corruption 2)
190 (corrupt-item-list 0)
191 close-all-menus)))
193 (defn-memo begin-initial-deposits
194 ([] (begin-initial-deposits
195 (bootstrap-corrupt-save)))
196 ([script]
197 (->> script
198 (first-difference [] [:a] AF)
199 (scroll-text)
200 (set-cursor 1)
201 select-menu-entry)))
203 (defn wait-for-quantity
204 [[moves state :as script]]
205 (if (not= (item-quantity-selected state) 1)
206 (repeat-until-different [] item-quantity-selected script)
207 script))
209 ;; TODO use this:
210 ;;(wait-until (partial set-cursor-relative 1))
212 (defn wait-for-cursor
213 [[moves state :as script]]
214 (if (not= (list-offset state) 0)
215 (repeat-until-different [] list-offset script)
216 script))
218 (defn deposit-held-item [n quantity [moves state :as script]]
219 (let [total-quantity (second (nth-item state n))]
220 (println "total-quantity" total-quantity)
221 (->> script
222 (set-cursor n)
223 (select-menu-entry 1)
224 (wait-for-quantity)
225 (set-quantity total-quantity quantity)
226 (delayed-difference [] [:a] 100 #(search-string % "stored"))
227 (scroll-text))))
229 (defn sell-held-item [n quantity [moves state :as script]]
230 (let [total-quantity (second (nth-item state n))]
231 (->> script
232 (wait-for-cursor) ;; when selling, the cursor always
233 (set-cursor n) ;; returns to the top of the list.
234 (select-menu-entry 1)
235 (wait-for-quantity)
236 (set-quantity total-quantity quantity)
237 (delayed-difference [] [:a] 100 current-depth)
238 (play-moves (repeat 20 [:b]))
239 (delayed-difference [] [:a] 100 #(search-string % "What"))
240 )))
242 (defn widthdraw-pc-item [n quantity [moves state :as script]]
243 (let [total-quantity (second (nth-pc-item state n))]
244 (->> script
245 (set-cursor n)
246 (select-menu-entry 1)
247 (wait-for-quantity)
248 (set-quantity total-quantity quantity)
249 (delayed-difference [] [:a] 100 #(search-string % "Withdrew"))
250 (scroll-text))))
252 (defn toss-held-item [n quantity [moves state :as script]]
253 (let [total-quantity (second (nth-item state n))]
254 (->> script
255 (set-cursor n)
256 (select-menu-entry 1)
257 (set-cursor-relative 1)
258 (select-menu-entry -1)
259 (wait-for-quantity)
260 (set-quantity total-quantity quantity)
261 (play-moves [[:a]])
262 (scroll-text)
263 (delayed-difference [] [:a] 100 #(search-string % "Threw"))
264 (scroll-text)
265 )))
267 (defn buy-item [n quantity [moves state :as script]]
268 (->> script
269 (set-cursor n)
270 (purchase-item quantity)))
273 (def desired-zero-quantities
274 (map second (filter (comp (partial = 0) first)
275 (partition 2 (pc-item-writer-program)))))
277 (defn-memo initial-deposits
278 ([] (initial-deposits (begin-initial-deposits)))
279 ([script]
280 (->> script
281 (deposit-held-item 0 0x1)
282 ((fn [script]
283 (reduce
284 (fn [script item] (deposit-held-item item 0xFF script))
285 script
286 (range 3 (+ 13 3)))))
287 close-all-menus)))
290 (defn-memo prepare-celadon-warp
291 ([] (prepare-celadon-warp (initial-deposits)))
292 ([script]
293 (->> script
294 (activate-start-menu)
295 (set-cursor-relative 1)
296 (select-menu-entry)
297 (toss-held-item 35 0xFA)
298 (close-all-menus))))
301 ;;0 -- 256
302 ;;1 -- 254
303 ;;2 -- 254
304 ;;3 -- 255
306 (defn-memo restore-items
307 ([] (restore-items (prepare-celadon-warp)))
308 ([script]
309 (->> script
310 (first-difference [] [:a] AF)
311 (scroll-text)
312 (select-menu-entry)
313 (widthdraw-pc-item 0 1)
314 ;;(widthdraw-pc-item 0 99)
315 ;;(widthdraw-pc-item 1 1)
316 (widthdraw-pc-item 13 255)
317 (close-all-menus))))
319 (defn-memo to-celadon
320 ([] (to-celadon (restore-items)))
321 ([script]
322 (->> script
323 (walk [→ → → → → → → ↑
324 ↓ ↓ ↓ ↓ ↓ ← ← ← ←
325 ↓ ↓]))))
328 ;; celadon store inventory
330 ;; Floor 2
331 ;;=====================================
332 ;; Great Ball TM32 (double-team)
333 ;; Super Potion TM33 (reflect)
334 ;; Revive TM02 (razor-wind)
335 ;; Super Repel TM07 (horn-drill)
336 ;; Antidote TM37 (egg-bomb)
337 ;; Burn Heal TM01 (mega-punch)
338 ;; Ice Heal TM05 (mega-kick)
339 ;; Awakening TM09 (take-down)
340 ;; Parlyz Heal TM17 (submission)
343 ;; Floor 3
344 ;;=====================================
345 ;; TM18 (counter)
348 ;; Floor 4
349 ;;=====================================
350 ;; Poke Doll
351 ;; Fire Stone
352 ;; Thunder Stone
353 ;; Water Stone
354 ;; Leaf Stone
356 ;; Floor 5
357 ;;=====================================
358 ;; X Accuracy HP UP
359 ;; Guard Spec. Protein
360 ;; Dire Hit Iron
361 ;; X Attack Carbos
362 ;; X Defend Calcium
363 ;; X Speed
364 ;; X Special
366 ;; Roof
367 ;;=====================================
368 ;; Fresh Water TM13 (ice-beam)
369 ;; Soda Pop TM48 (rock-slide)
370 ;; Lemonade :) TM49 (tri-attack)
373 (defn-memo go-to-floor-two
374 ([] (go-to-floor-two (to-celadon)))
375 ([script]
376 (->> script
377 (walk [↑ → → → → → → → → → → →
378 ↑ ↑ ↑ ↑ ↑ ↑
379 ← ← ← ←
380 ↓ ↓ ↓
381 ← ←])
382 (first-difference [] ↑ AF))))
384 (defn talk
385 "Assumes that you are facing something that initiates text and
386 causes it to do so."
387 [script]
388 (->> script
389 (delayed-difference [] [:a] 100
390 first-character)))
392 (defn-memo get-money-floor-two
393 ([] (get-money-floor-two (go-to-floor-two)))
394 ([script]
395 (->> script
396 talk
397 (set-cursor 1)
398 (select-menu-entry)
399 (sell-held-item 0 1)
400 (sell-held-item 0 1)
401 (close-menu))))
403 (defn-memo floor-two-TMs
404 ([] (floor-two-TMs (get-money-floor-two)))
405 ([script]
406 (->> script
407 (wait-for-cursor)
408 (select-menu-entry)
409 (buy-item 2 98) ;; TM02 (razor-wind)
410 (buy-item 4 71) ;; TM37 (doubleteam)
411 (buy-item 5 63) ;; TM01 (mega-punch)
412 (buy-item 6 1) ;; TM05 (mega-kick)
413 (buy-item 7 56) ;; TM09 (take-down)
414 (close-menu))))
416 (defn end-shop-conversation
417 [script]
418 (->> script
419 (wait-until scroll-text [:b])
420 (play-moves [[] [:b]])
421 close-menu))
423 (defn-memo floor-two-more-money
424 ([] (floor-two-more-money (floor-two-TMs)))
425 ([script]
426 (->> script
427 (wait-for-cursor)
428 (set-cursor 1)
429 (select-menu-entry)
430 (sell-held-item 0 1)
431 (sell-held-item 0 1)
432 close-menu
433 end-shop-conversation)))
435 (defn turn [direction script]
436 (->> script
437 (first-difference [] direction AF)))
439 (defn-memo floor-two-items
440 ([] (floor-two-items (floor-two-more-money)))
441 ([script]
442 (->> script
443 (walk [←])
444 (turn ↑)
445 talk
446 select-menu-entry
447 (buy-item 5 12) ;; burn heal
448 (buy-item 6 55) ;; ice heal
449 (buy-item 7 4) ;; awakening
450 (buy-item 8 99) ;; parlyz heal
451 (buy-item 8 55) ;; parlyz heal
452 close-menu
453 end-shop-conversation)))
455 (defn-memo go-to-floor-three
456 ([] (go-to-floor-three (floor-two-items)))
457 ([script]
458 (->> script
459 (walk [→ → → → → → → → → → ↑ ↑ ↑
460 → ↑]))))
461 (defn-memo get-TM18
462 ([] (get-TM18 (go-to-floor-three)))
463 ([script]
464 (->> script
465 (walk [↓ ↓])
466 talk
467 (scroll-text 3)
468 end-text)))
470 (defn-memo go-to-floor-four
471 ([] (go-to-floor-four (get-TM18)))
472 ([script]
473 (->> script
474 (walk [← ← ← ← ↑ ↑
475 ↓ ← ← ↓ ↓ ↓
476 ← ← ← ← ←])
477 (turn ↓))))
479 (defn-memo floor-four-items
480 ([] (floor-four-items (go-to-floor-four)))
481 ([script]
482 (->> script
483 talk
484 select-menu-entry
485 (buy-item 1 23) ;; Fire Stone
486 (buy-item 2 98) ;; Thunder Stone
487 (buy-item 3 29) ;; Water Stone
488 close-menu
489 end-shop-conversation)))
491 (defn-memo go-to-floor-five
492 ([] (go-to-floor-five (floor-four-items)))
493 ([script]
494 (->> script
495 (walk [→ → → → → →
496 ↑ ↑ ↑
497 → → → → → ↑ ;; leave floor four
498 ↓ ← ← ← ← ← ← ← ←
499 ↓ ↓ ↓ ← ← ← ]);; go to five's clerk
500 (turn ↑))))
502 (defn-memo floor-five-items
503 ([] (floor-five-items (go-to-floor-five)))
504 ([script]
505 (->> script
506 talk
507 select-menu-entry
508 (buy-item 0 58) ;; X-Accuracy
509 (buy-item 1 99) ;; Guard Spec.
510 (buy-item 1 24) ;; Guard Spec.
511 close-menu
512 end-shop-conversation)))
514 (defn-memo go-to-roof
515 ([] (go-to-roof (floor-five-items)))
516 ([script]
517 (->> script
518 (walk [→ → → → ↑ ↑ ↑ → → → ↑ ;; leave floor five
519 ↓ ← ← ←]) ;; walk to vending machine
520 (turn ↑))))
522 (defn buy-drink
523 "Assumes you're in front of the vending machine. Buys the indicated
524 drink."
525 [n script]
526 (->> script
527 (do-nothing 20)
528 (play-moves [[:a][:a]])
529 scroll-text
530 (wait-for-cursor)
531 (set-cursor n)
532 select-menu-entry
533 close-menu))
535 (defn-memo roof-drinks
536 ([] (roof-drinks (go-to-roof)))
537 ([script]
538 (->> script
539 (buy-drink 0) ;; fresh water (for TM13)
540 ;; buy 16 lemonades
541 ;; LEMONADE is the best item <3 :)
542 (multiple-times 16 (partial buy-drink 2)))))
544 (defn-memo get-TM13
545 ([] (get-TM13 (roof-drinks)))
546 ([script]
547 (->> script
548 (walk [← ← ← ← ← ← ↓])
549 (play-moves [[][:a][:a][]])
550 (scroll-text 3)
551 select-menu-entry
552 select-menu-entry
553 (scroll-text 6)
554 close-menu)))
556 (defn-memo to-celadon-poke-center
557 ([] (to-celadon-poke-center (get-TM13)))
558 ([script]
559 (->> script
560 (walk [↑ → → → → → → → → → ↑]) ; leave roof
561 (walk [↓ ← ← ← ← ↓ ↓ ↓ ← ← ← ← ←
562 ↑ ↑ ↑ ← ← ↑]) ; to elevator
564 (walk [→ → ↑ ↑]) ; to controls
565 talk
566 select-menu-entry ; to floor 1
567 (walk [↓ ↓ ← ←])
568 (walk [↓ → ↓ ↓ ↓ ↓ ↓ ↓]) ; leave store
569 (walk [↓ → → → → → → → → → → ↑ ↑])
570 (walk (repeat 23 →))
571 (walk [↑ ↑ ↑ ↑]) ; enter poke center
572 (walk [↑ ↑ ↑ → → → → → → → → → →]) ; to computer
573 (turn ↑))))
575 (defn activate-rlm-pc [script]
576 (->> script
577 talk
578 scroll-text
579 wait-for-cursor
580 (set-cursor 1)
581 select-menu-entry
582 (scroll-text 2)))
584 (defn begin-deposit [script]
585 (->> script
586 (set-cursor 1)
587 select-menu-entry))
589 (defn begin-withdraw [script]
590 (->> script
591 (set-cursor 0)
592 (select-menu-entry)))
594 (defn deposit-held-item-named
595 [item-name quantity [moves state :as script]]
596 (let [index (count
597 (take-while
598 (fn [[name quant]]
599 (or (not= name item-name)
600 (< quant quantity)))
601 (inventory state)))]
602 (println "index" index)
603 (deposit-held-item index quantity script)))
606 (defn-memo begin-hacking
607 ([] (begin-hacking(to-celadon-poke-center)))
608 ([script]
609 (->> script
610 activate-rlm-pc
611 begin-deposit
612 (deposit-held-item-named 0x00 30)
613 (deposit-held-item-named :TM01 63)
614 (deposit-held-item-named :awakening 4)
615 (deposit-held-item-named :thunderstone 98)
616 (deposit-held-item-named :TM09 55)
617 (deposit-held-item-named 0x00 55))))
619 (defn open-held-items
620 [script]
621 (->> script
622 select-menu-entry))
624 (defn to-held-items
625 [script]
626 (->> script
627 close-menu
628 close-menu
629 end-text;;; grr
631 activate-start-menu
632 open-held-items))
634 (defn-memo hacking-2
635 ([] (hacking-2 (begin-hacking)))
636 ([script]
637 (->> script
638 (to-held-items)
639 (toss-held-item 0 166) ;; discard cruft
640 close-menu
641 close-menu)))
643 (defn-memo hacking-3
644 ([] (hacking-3 (hacking-2)))
645 ([script]
646 (->> script
647 activate-rlm-pc
648 begin-withdraw
649 (widthdraw-pc-item 0 99)
650 (widthdraw-pc-item 0 1)
651 (widthdraw-pc-item 2 0xFE)
652 (widthdraw-pc-item 3 0xFE)
653 close-menu)))
655 (defn-memo hacking-4
656 ([] (hacking-4 (hacking-3)))
657 ([script]
658 (->> script
659 begin-deposit
660 (deposit-held-item 19 243)
661 (deposit-held-item-named :lemonade 16)
662 (deposit-held-item 18 224))))
664 (defn-memo hacking-5
665 "clean out the held-item list again"
666 ([] (hacking-5 (hacking-4)))
667 ([script]
668 (->> script
669 (to-held-items)
670 (toss-held-item 18 30)
671 (toss-held-item 17 1)
672 close-menu
673 close-menu)))
675 (defn-memo hacking-6
676 ([] (hacking-6 (hacking-5)))
677 ([script]
678 (->> script
679 activate-rlm-pc
680 begin-withdraw
681 (widthdraw-pc-item 4 0xFE)
682 (widthdraw-pc-item 5 0xFE)
683 (widthdraw-pc-item 6 0xFE)
684 close-menu)))
686 (defn-memo hacking-7
687 ([] (hacking-7 (hacking-6)))
688 ([script]
689 (->> script
690 begin-deposit
691 (deposit-held-item 19 240)
692 (deposit-held-item 18 230)
693 (deposit-held-item-named :parlyz-heal 55)
694 (deposit-held-item 17 184)
695 (deposit-held-item 17 40)
696 (deposit-held-item-named :TM37 71)
697 (deposit-held-item-named :ice-heal 55)
698 (deposit-held-item-named :fire-stone 23)
699 (deposit-held-item-named :burn-heal 12)
700 close-menu)))
702 (defn switch-items [item-fn idx-1 idx-2 script]
703 (->> script
704 (wait-until select-menu-entry)
705 (set-cursor idx-1)
706 (wait-until select-menu-entry)
707 (play-moves [[][:select][]])
708 (set-cursor idx-2)
709 (delayed-difference [] [:select] 100
710 #(item-fn % (list-offset %)))))
712 (def switch-pc-items (partial switch-items nth-pc-item))
713 (def switch-held-items (partial switch-items nth-item))
715 (defn combine-pc-items [idx-1 script]
716 (->> script
717 (switch-pc-items idx-1 (inc idx-1))))
719 (defn combine-items [idx-1 script]
720 (->> script
721 (wait-until select-menu-entry)
722 (set-cursor idx-1)
723 (wait-until select-menu-entry)
724 (play-moves [[][:select][]])
725 (set-cursor-relative 1)
726 (delayed-difference [] [:select] 100
727 #(nth-pc-item % (list-offset %)))))
729 (defn-memo hacking-8
730 "Clear cruft away from held item list."
731 ([] (hacking-8 (hacking-7)))
732 ([script]
733 (->> script
734 to-held-items
735 (toss-held-item 15 1)
736 (toss-held-item 14 1)
737 (toss-held-item 13 1)
738 close-menu
739 close-menu)))
741 (defn-memo hacking-9
742 ([] (hacking-9 (hacking-8)))
743 ([script]
744 (->> script
745 activate-rlm-pc
746 begin-withdraw
747 (widthdraw-pc-item 7 0xFE)
748 (widthdraw-pc-item 8 0xFC)
749 (widthdraw-pc-item 8 1)
750 (widthdraw-pc-item 8 1)
751 (widthdraw-pc-item 9 0xFE)
752 (multiple-times
753 7
754 (partial combine-pc-items 2))
755 close-menu)))
757 (defn-memo hacking-10
758 ([] (hacking-10 (hacking-9)))
759 ([script]
760 (->> script
761 begin-deposit
762 (deposit-held-item 17 230)
763 (deposit-held-item-named :parlyz-heal 55)
764 (deposit-held-item 14 178)
765 (deposit-held-item-named :water-stone 29)
766 (deposit-held-item 14 32)
767 (deposit-held-item-named :TM18 1)
768 (deposit-held-item 13 1)
769 (deposit-held-item 13 191)
770 (deposit-held-item-named :TM02 98)
771 (deposit-held-item-named :TM09 1)
772 close-menu
773 close-menu)))
775 (defn-memo hacking-11
776 ([] (hacking-11 (hacking-10)))
777 ([script]
778 (->> script
779 begin-withdraw
780 (widthdraw-pc-item 3 0xFE)
781 (widthdraw-pc-item 4 0xFE)
782 (widthdraw-pc-item 5 1)
783 (widthdraw-pc-item 5 1)
784 (widthdraw-pc-item 5 1)
785 (widthdraw-pc-item 5 0xFB)
786 (multiple-times
787 3
788 (partial combine-items 2))
789 close-menu)))
791 (defn-memo hacking-12
792 ([] (hacking-12 (hacking-11)))
793 ([script]
794 (->> script
795 begin-deposit
796 (deposit-held-item 18 203)
797 (deposit-held-item-named :guard-spec 87)
798 (deposit-held-item-named :guard-spec 24)
799 (deposit-held-item-named :TM05 1)
800 (multiple-times
801 8
802 (partial deposit-held-item 14 2))
803 (deposit-held-item 14 55)
804 (deposit-held-item-named :x-accuracy 58)
805 (deposit-held-item 14 38)
806 (deposit-held-item-named :TM13 1)
807 (deposit-held-item 13 1)
808 (deposit-held-item 13 233)
809 close-menu
810 close-menu)))
813 (defn toss-pc-item [n quantity [moves state :as script]]
814 (let [total-quantity (second (nth-pc-item state n))]
815 (->> script
816 (set-cursor n)
817 (select-menu-entry 1)
818 (wait-for-quantity)
819 (set-quantity total-quantity quantity)
820 (delayed-difference [] [:a] 100 #(search-string % "Is"))
821 (scroll-text)
822 select-menu-entry
823 (scroll-text))))
825 (defn-memo hacking-13
826 ([] (hacking-13 (hacking-12)))
827 ([script]
828 (->> script
829 (set-cursor-relative 1)
830 (select-menu-entry)
831 (toss-pc-item 1 1)
832 (toss-pc-item 0 156)
833 (toss-pc-item 0 11))))
835 (defn confirm-pattern []
836 (let [start-address (inc pc-item-list-start)
837 target-pattern (pc-item-writer-program)
838 actual-pattern
839 (subvec (vec (memory (second (hacking-13))))
840 start-address
841 (+ start-address (count target-pattern)))]
842 (println target-pattern)
843 (println actual-pattern)
844 (= target-pattern actual-pattern)))
846 ;; this will be useful for starting program
849 (defn-memo go-to-mansion-for-the-lulz
850 ([] (go-to-mansion-for-the-lulz (hacking-13)))
851 ([script]
852 (->> script
853 close-menu
854 close-menu
855 end-text ;;grr
856 (walk [↓ ← ← ← ← ← ← ← ← ← ↓ ↓ ↓])
857 (walk (repeat 17 ←))
858 (walk [↑ → → → → ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑])
859 (walk [↓ ← ↑])
860 (walk [↓ ↓ ↓ ↓ ↓ ↓ ↓
861 ← ← ← ← ↑ ↑ ↑ ← ↑])
862 (talk)
863 (scroll-text 2)
864 close-menu)))
866 (defn get-cursor [script]
867 (wait-until (partial set-cursor-relative 1) script))
869 (defn-memo launch-bootstrap-program
870 ([] (launch-bootstrap-program
871 (go-to-mansion-for-the-lulz)))
872 ([script]
873 (->> script
874 ;; must corrupt item list again by switching pokemon
875 activate-start-menu
876 ;;get-cursor
877 (set-cursor 0)
878 select-menu-entry
879 ;;get-cursor
880 (select-menu-entry)
881 ;;get-cursor
882 (set-cursor 1)
883 (select-menu-entry)
884 ;;get-cursor
885 (set-cursor 3)
886 (delayed-difference [] [:a] 50 first-character)
887 close-menu
888 ;; now, open items and set map-function
889 ;;get-cursor
890 (set-cursor 1)
891 (select-menu-entry)
892 (toss-held-item 22 12)
893 (switch-held-items 22 40)
894 close-all-menus)))