Mercurial > vba-clojure
diff clojure/com/aurellem/gb/rlm_assembly.clj @ 386:d8cbbf2a3133
changed scratch ragisters from BC to DE.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Thu, 12 Apr 2012 06:27:03 -0500 |
parents | 3f3cfc89be91 |
children | 47d44bb54d32 |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/gb/rlm_assembly.clj Thu Apr 12 06:20:17 2012 -0500 1.2 +++ b/clojure/com/aurellem/gb/rlm_assembly.clj Thu Apr 12 06:27:03 2012 -0500 1.3 @@ -65,12 +65,20 @@ 1.4 1.5 (defn frame-metronome [] 1.6 (let [timing-loop 1.7 - [0x01 ; \ 1.8 - 0x43 ; | 1.9 - 0xFE ; | load 0xFF44 into BC without repeats 1.10 - 0x0C ; | 1.11 - 0x04 ; / 1.12 - 0x0A] ;; (BC) -> A, now A = LY (vertical line coord) 1.13 + [;;0x01 ; \ 1.14 + ;;0x43 ; | 1.15 + ;;0xFE ; | load 0xFF44 into BC without repeats 1.16 + ;;0x0C ; | 1.17 + ;;0x04 ; / 1.18 + ;;0x0A ;; (BC) -> A, now A = LY (vertical line coord) 1.19 + 1.20 + 0x11 ; \ 1.21 + 0x43 ; | 1.22 + 0xFE ; | load 0xFF44 into DE without repeats 1.23 + 0x1C ; | 1.24 + 0x14 ; / 1.25 + 0x1A ;; (DE) -> A, now A = LY (vertical line coord) 1.26 + ] 1.27 continue-if-144 1.28 [0xFE 1.29 144 ;; compare LY (in A) with 144 1.30 @@ -78,7 +86,8 @@ 1.31 (->signed-8-bit 1.32 (+ -4 (- (count timing-loop))))] 1.33 spin-loop 1.34 - [0x05 ;; dec B, which is 0xFF 1.35 + [;;0x05 ;; dec B, which is 0xFF 1.36 + 0x15 ;; dec D, which is 0xFF 1.37 0x20 ;; spin until B==0 1.38 0xFD]] 1.39 (concat timing-loop continue-if-144 spin-loop))) 1.40 @@ -87,43 +96,49 @@ 1.41 "Ensure that frame-metronome ticks exactly once every frame." 1.42 ([] (test-frame-metronome 151)) 1.43 ([steps] 1.44 - (let [inc-D [0x14 0x18 1.45 + (let [inc-B [0x04 0x18 1.46 (->signed-8-bit 1.47 (+ -3 (- (count (frame-metronome)))))] 1.48 - program (concat (frame-metronome) inc-D) 1.49 + program (concat (frame-metronome) inc-B) 1.50 count-frames 1.51 (-> (tick (mid-game)) 1.52 (IE! 0) 1.53 - (DE! 0) 1.54 + (BC! 0) 1.55 (set-memory-range pokemon-list-start program) 1.56 (PC! pokemon-list-start)) 1.57 - D-after-moves (D (run-moves count-frames (repeat steps [])))] 1.58 - (println "D:" D-after-moves) 1.59 - (assert (= steps D-after-moves)) 1.60 + B-after-moves (B (run-moves count-frames (repeat steps [])))] 1.61 + (println "B:" B-after-moves) 1.62 + (assert (= steps B-after-moves)) 1.63 1.64 - (println "D =" D-after-moves "after" steps "steps") 1.65 + (println "B =" B-after-moves "after" steps "steps") 1.66 count-frames))) 1.67 1.68 (defn read-user-input [] 1.69 - [0x01 ;\ 1.70 - 0x01 ;| 1.71 - 0xFE ;| load 0xFF00 into BC without repeats 1.72 - 0x04 ;| 1.73 - 0x0D ;/ 1.74 + [;;0x01 ;\ 1.75 + ;;0x01 ;| 1.76 + ;;0xFE ;| load 0xFF00 into BC without repeats 1.77 + ;;0x04 ;| 1.78 + ;;0x0D ;/ 1.79 1.80 + 0x11 ; \ 1.81 + 0x01 ; | 1.82 + 0xFE ; | load 0xFF44 into DE without repeats 1.83 + 0x14 ; | 1.84 + 0x1D ; / 1.85 + 1.86 0x3E 1.87 (Integer/parseInt "00100000" 2) ; prepare to measure d-pad 1.88 1.89 - 0x02 1.90 - 0x0A ;; get D-pad info 1.91 + 0x12 1.92 + 0x1A ;; get D-pad info 1.93 1.94 0xF5 ;; push AF 1.95 1.96 0x3E 1.97 (Integer/parseInt "00010000" 2) ; prepare to measure buttons 1.98 1.99 - 0x02 1.100 - 0x0A ;; get button info 1.101 + 0x12 1.102 + 0x1A ;; get button info 1.103 1.104 1.105 0xE6 ;; select bottom bits of A 1.106 @@ -148,7 +163,7 @@ 1.107 (let [program 1.108 (concat 1.109 (frame-metronome) (read-user-input) 1.110 - [0x5F ;; A-> E 1.111 + [0x47 ;; A->B 1.112 0x18 1.113 (->signed-8-bit 1.114 (+ (- (count (frame-metronome))) 1.115 @@ -161,7 +176,7 @@ 1.116 (PC! pokemon-list-start))] 1.117 (dorun 1.118 (for [i (range 0x100)] 1.119 - (assert (= (E (step read-input (buttons i))) i)))) 1.120 + (assert (= (B (step read-input (buttons i))) i)))) 1.121 (println "Tested all inputs.") 1.122 read-input)) 1.123