annotate clojure/com/aurellem/dylans-code @ 139:74ec1ac044bb

write-memory-assembly* confirmed...stage one.
author Dylan Holmes <ocsenave@gmail.com>
date Mon, 19 Mar 2012 05:12:05 -0500
parents bcb5c41626b4
children
rev   line source
rlm@117 1
rlm@117 2 (defn count-frames* []
rlm@117 3 (-> (tick (mid-game))
rlm@117 4 (IE! 0) ; disable interrupts
rlm@117 5 (inject-item-assembly
rlm@117 6 ;; write 00010000 to 0xFF00 to select joypad
rlm@117 7 [0x18 ;D31D ; jump over
rlm@117 8 0x02 ;D31E ; the next 2 bytes
rlm@117 9 0x00 ;D31F ; frame-count
rlm@117 10 0x00 ;D320 ; v-blank-prev
rlm@117 11
rlm@117 12
rlm@117 13 0xFA ;D321
rlm@117 14 0x41 ;D322 ; load (FF41) into A
rlm@117 15 0xFF ;D323 ; this contains mode flags
rlm@117 16
rlm@117 17 0x47 ;; copy A -> B
rlm@117 18
rlm@117 19 0xCB
rlm@117 20 0x3F ;; shift A right
rlm@117 21 0x2F ;; complement A
rlm@117 22
rlm@117 23 0xA0 ;; A & B -> A.
rlm@117 24 0x47 ;; copy A -> B. Now the first bit of B is (VB == 1)
rlm@117 25
rlm@117 26 0xFA
rlm@117 27 0x20
rlm@117 28 0xD3 ;; load v-blank-prev into A
rlm@117 29
rlm@117 30 0xA0 ;; A & B -> A.
rlm@117 31 0x4F ;; copy A to C. Now C contains increment-counter?
rlm@117 32
rlm@117 33 0xFA
rlm@117 34 0x1F
rlm@117 35 0xD3 ;; load frame-count into A
rlm@117 36
rlm@117 37 0x81 ;; add increment-counter? to frame-count
rlm@117 38 0xEA ;; store A into frame-count
rlm@117 39 0x1F
rlm@117 40 0xD3
rlm@117 41
rlm@117 42 0x3E ;; load 1 into A
rlm@117 43 0x01
rlm@117 44 0xA0 ;; A & B -> A. Now A is (VB==1)
rlm@117 45 0xEA ;; store A into v-blank-prev
rlm@117 46 0x20
rlm@117 47 0xD3
rlm@117 48
rlm@117 49 0xC3 ;D348 ; return to beginning
rlm@117 50 0x1D ;D349
rlm@117 51 0xD3 ;D34A
rlm@117 52
rlm@117 53
rlm@117 54 ])))