view clojure/com/aurellem/dylans-code @ 135:eb6ba88088d3

Wrote a more efficient input-number-assembly program; 91 oc -> 60 oc.
author Dylan Holmes <ocsenave@gmail.com>
date Sun, 18 Mar 2012 05:13:19 -0500
parents bcb5c41626b4
children
line wrap: on
line source

2 (defn count-frames* []
3 (-> (tick (mid-game))
4 (IE! 0) ; disable interrupts
5 (inject-item-assembly
6 ;; write 00010000 to 0xFF00 to select joypad
7 [0x18 ;D31D ; jump over
8 0x02 ;D31E ; the next 2 bytes
9 0x00 ;D31F ; frame-count
10 0x00 ;D320 ; v-blank-prev
13 0xFA ;D321
14 0x41 ;D322 ; load (FF41) into A
15 0xFF ;D323 ; this contains mode flags
17 0x47 ;; copy A -> B
19 0xCB
20 0x3F ;; shift A right
21 0x2F ;; complement A
23 0xA0 ;; A & B -> A.
24 0x47 ;; copy A -> B. Now the first bit of B is (VB == 1)
26 0xFA
27 0x20
28 0xD3 ;; load v-blank-prev into A
30 0xA0 ;; A & B -> A.
31 0x4F ;; copy A to C. Now C contains increment-counter?
33 0xFA
34 0x1F
35 0xD3 ;; load frame-count into A
37 0x81 ;; add increment-counter? to frame-count
38 0xEA ;; store A into frame-count
39 0x1F
40 0xD3
42 0x3E ;; load 1 into A
43 0x01
44 0xA0 ;; A & B -> A. Now A is (VB==1)
45 0xEA ;; store A into v-blank-prev
46 0x20
47 0xD3
49 0xC3 ;D348 ; return to beginning
50 0x1D ;D349
51 0xD3 ;D34A
54 ])))