Mercurial > vba-clojure
diff clojure/com/aurellem/gb/rlm_assembly.clj @ 384:8013915a07b3
completed read-user-input by working off of Dylan's version.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Wed, 11 Apr 2012 14:04:21 -0500 |
parents | 9eae7e914bf0 |
children | 3f3cfc89be91 |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/gb/rlm_assembly.clj Wed Apr 11 13:39:53 2012 -0500 1.2 +++ b/clojure/com/aurellem/gb/rlm_assembly.clj Wed Apr 11 14:04:21 2012 -0500 1.3 @@ -104,6 +104,63 @@ 1.4 (println "D =" D-after-moves "after" steps "steps") 1.5 count-frames))) 1.6 1.7 +(defn read-user-input [] 1.8 + [0x01 ;\ 1.9 + 0x01 ;| 1.10 + 0xFE ;| load 0xFF00 into BC without repeats 1.11 + 0x04 ;| 1.12 + 0x0D ;/ 1.13 + 1.14 + 0x3E 1.15 + (Integer/parseInt "00100000" 2) ; prepare to measure d-pad 1.16 + 1.17 + 0x02 1.18 + 0x0A ;; get D-pad info 1.19 + 1.20 + 0xE6 ;; select bottom bits of A 1.21 + 0x0F 1.22 + 1.23 + 0xCB 1.24 + 0x37 ;; swap A nybbles 1.25 + 1.26 + 0x57 ;; A->D 1.27 + 1.28 + 0x3E 1.29 + (Integer/parseInt "00010000" 2) ; prepare to measure buttons 1.30 + 1.31 + 0x02 1.32 + 0x0A ;; get button info 1.33 + 1.34 + 0xE6 1.35 + 0x0F ;; select bottom bits of A 1.36 + 1.37 + 0xB2 ;; combine together into A 1.38 + 0x2F ;; (NOT A) -> A 1.39 + ]) 1.40 + 1.41 +(defn test-read-user-input [] 1.42 + (let [program 1.43 + (concat 1.44 + (frame-metronome) (read-user-input) 1.45 + [0x5F ;; A-> E 1.46 + 0x18 1.47 + (->signed-8-bit 1.48 + (+ (- (count (frame-metronome))) 1.49 + (- (count (read-user-input))) 1.50 + (- 3)))]) 1.51 + read-input 1.52 + (-> (tick (mid-game)) 1.53 + (IE! 0) 1.54 + (set-memory-range pokemon-list-start program) 1.55 + (PC! pokemon-list-start))] 1.56 + (dorun 1.57 + (for [i (range 0x100)] 1.58 + (assert (= (E (step read-input (buttons i))) i)))) 1.59 + (println "Tested all inputs.") 1.60 + read-input)) 1.61 + 1.62 + 1.63 + 1.64 (defn main-bootstrap-program [start-address] 1.65 (let [[start-high start-low] (disect-bytes-2 start-address) 1.66 ]