comparison clojure/com/aurellem/gb/rlm_assembly.clj @ 596:747d47d96d2f

determined that I cannot shorten the long B sequeuce during bootstrap.
author Robert McIntyre <rlm@mit.edu>
date Sun, 02 Sep 2012 06:36:57 -0500
parents 96ee9d72aeb9
children
comparison
equal deleted inserted replaced
595:96ee9d72aeb9 596:747d47d96d2f
4 (:use (com.aurellem.gb gb-driver assembly util vbm constants)) 4 (:use (com.aurellem.gb gb-driver assembly util vbm constants))
5 (:import [com.aurellem.gb.gb_driver SaveState])) 5 (:import [com.aurellem.gb.gb_driver SaveState]))
6 6
7 (defn pc-item-writer-program 7 (defn pc-item-writer-program
8 [] 8 []
9 (let [limit 201 ;; should be more like 92 9 (let [;;limit 75
10 limit 201 ;; (item-hack 201 is the smallest I could make this.)
10 [target-high target-low] (disect-bytes-2 pokemon-list-start)] 11 [target-high target-low] (disect-bytes-2 pokemon-list-start)]
11 (flatten 12 (flatten
12 [[0x00 ;; (item-hack) set increment stack pointer no-op 13 [[0x00 ;; (item-hack) no-op (can't buy repel (1E) at celadon)
13 0x1E ;; load limit into E 14 0x1E ;; load limit into E
14 limit 15 limit
15 0x3F ;; (item-hack) set carry flag no-op 16 0x3F ;; (item-hack) set carry flag no-op
16 17
17 ;; load 2 into C. 18 ;; load 2 into C.
492 [assembly] 493 [assembly]
493 (let [nybbles (flatten (map byte->nybbles assembly)) 494 (let [nybbles (flatten (map byte->nybbles assembly))
494 moves (map (comp buttons (partial - 15)) nybbles) 495 moves (map (comp buttons (partial - 15)) nybbles)
495 header (map buttons 496 header (map buttons
496 (concat (repeat 497 (concat (repeat
497 50 498 23 ;; found by manual binary search
498 (- 15 (first nybbles))) 499 (- 15 (first nybbles)))
499 [(first nybbles)]))] 500 [(first nybbles)]))]
500 (assert (no-consecutive-repeats? nybbles)) 501 (assert (no-consecutive-repeats? nybbles))
501 (concat header moves))) 502 (concat header moves)))
502 503