# HG changeset patch # User Robert McIntyre # Date 1334168228 18000 # Node ID 3c24216e008016eb3a3d83df461c41c1a0e592b7 # Parent 1bfa43d354039397daaa2925b21904420e6514ee decreased frame-metronome by one opcode diff -r 1bfa43d35403 -r 3c24216e0080 clojure/com/aurellem/gb/rlm_assembly.clj --- a/clojure/com/aurellem/gb/rlm_assembly.clj Wed Apr 11 13:09:41 2012 -0500 +++ b/clojure/com/aurellem/gb/rlm_assembly.clj Wed Apr 11 13:17:08 2012 -0500 @@ -63,18 +63,21 @@ (if (< n 0) (+ 256 n) n)) +0x01 +0x44 +0xFF +inc C +inc D + (defn frame-metronome [] (let [timing-loop - [0x16 - 0xFE ;; load FF into D without repeats - 0x14 + [0x01 + 0x43 + 0xFE ;; load 0xFF44 into BC without repeats + 0x0C + 0x04 - 0x1E - 0x43 ;; load 44 into E without repeats - 0x1C - - 0x1A ;; (DE) -> A, now A = LY (vertical line coord) - ] + 0x0A] ;; (BC) -> A, now A = LY (vertical line coord) continue-if-144 [0xFE 144 ;; compare LY (in A) with 144 @@ -82,8 +85,8 @@ (->signed-8-bit (+ -4 (- (count timing-loop))))] spin-loop - [0x15 ;; dec D, which is 0xFF - 0x20 ;; spin until D==0 + [0x05 ;; dec B, which is 0xFF + 0x20 ;; spin until B==0 0xFD]] (concat timing-loop continue-if-144 spin-loop))) @@ -92,21 +95,21 @@ "Ensure that frame-metronome ticks exactly once every frame." ([] (test-frame-metronome 151)) ([steps] - (let [inc-C [0x0C 0x18 + (let [inc-D [0x14 0x18 (->signed-8-bit (+ -3 (- (count (frame-metronome)))))] - program (concat (frame-metronome) inc-C) + program (concat (frame-metronome) inc-D) count-frames (-> (tick (mid-game)) (IE! 0) - (BC! 0) + (DE! 0) (set-memory-range pokemon-list-start program) (PC! pokemon-list-start)) - C-after-moves (C (run-moves count-frames (repeat steps [])))] - (println "C:" C-after-moves) - ;;(assert (= steps C-after-moves)) + D-after-moves (D (run-moves count-frames (repeat steps [])))] + (println "D:" D-after-moves) + (assert (= steps D-after-moves)) - (println "C =" C-after-moves "after" steps "steps") + (println "D =" D-after-moves "after" steps "steps") count-frames))) (defn main-bootstrap-program [start-address]