diff clojure/com/aurellem/dylans-code @ 117:bcb5c41626b4

saving progress
author Robert McIntyre <rlm@mit.edu>
date Fri, 16 Mar 2012 17:50:35 -0500
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/clojure/com/aurellem/dylans-code	Fri Mar 16 17:50:35 2012 -0500
     1.3 @@ -0,0 +1,54 @@
     1.4 +
     1.5 +(defn count-frames* []
     1.6 +  (-> (tick (mid-game))
     1.7 +      (IE! 0) ; disable interrupts
     1.8 +      (inject-item-assembly
     1.9 +       ;; write 00010000 to 0xFF00 to select joypad
    1.10 +       [0x18   ;D31D                    ; jump over          
    1.11 +        0x02   ;D31E                    ; the next 2 bytes
    1.12 +        0x00   ;D31F                    ; frame-count
    1.13 +        0x00   ;D320                    ; v-blank-prev
    1.14 +
    1.15 +        
    1.16 +        0xFA   ;D321
    1.17 +        0x41   ;D322                    ; load (FF41) into A
    1.18 +        0xFF   ;D323                    ; this contains mode flags
    1.19 +
    1.20 +        0x47   ;; copy A -> B
    1.21 +        
    1.22 +        0xCB
    1.23 +        0x3F ;; shift A right
    1.24 +        0x2F ;; complement A
    1.25 +
    1.26 +        0xA0 ;; A & B -> A.
    1.27 +        0x47 ;; copy A -> B. Now the first bit of B is (VB == 1)
    1.28 +        
    1.29 +        0xFA
    1.30 +        0x20
    1.31 +        0xD3 ;; load v-blank-prev into A
    1.32 +
    1.33 +        0xA0 ;; A & B -> A. 
    1.34 +        0x4F ;; copy A to C. Now C contains increment-counter?
    1.35 +
    1.36 +        0xFA
    1.37 +        0x1F
    1.38 +        0xD3 ;; load frame-count into A
    1.39 +
    1.40 +        0x81 ;; add increment-counter? to frame-count
    1.41 +        0xEA ;; store A into frame-count
    1.42 +        0x1F
    1.43 +        0xD3
    1.44 +
    1.45 +        0x3E ;; load 1 into A
    1.46 +        0x01
    1.47 +        0xA0 ;; A & B -> A. Now A is (VB==1)
    1.48 +        0xEA ;; store A into v-blank-prev
    1.49 +        0x20
    1.50 +        0xD3
    1.51 +
    1.52 +        0xC3   ;D348                   ; return to beginning
    1.53 +        0x1D   ;D349
    1.54 +        0xD3   ;D34A
    1.55 +
    1.56 +
    1.57 +        ])))
    1.58 \ No newline at end of file