changeset 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 718abf3bec8a
children ffeeabae7dcd
files clojure/com/aurellem/assembly.clj clojure/com/aurellem/vbm.clj
diffstat 2 files changed, 155 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/assembly.clj	Sun Mar 18 00:56:29 2012 -0500
     1.2 +++ b/clojure/com/aurellem/assembly.clj	Sun Mar 18 05:13:19 2012 -0500
     1.3 @@ -390,7 +390,7 @@
     1.4     0x50   ;D354      -->       
     1.5     0xD3   ;D355      -->  D31F     
     1.6     
     1.7 -   0xEA   ;D356                    ; load (A), which is 
     1.8 +   0xEA   ;D356                    ; load A, which is 
     1.9     0x00   ;D357      -->           ; 00010000, into FF00
    1.10     0xFF   ;D358      -->  FF00     
    1.11  
    1.12 @@ -467,55 +467,122 @@
    1.13  
    1.14      
    1.15  
    1.16 +
    1.17 +
    1.18 +
    1.19 +
    1.20 +
    1.21 +
    1.22 +
    1.23 +
    1.24 +
    1.25 +
    1.26 +
    1.27 +
    1.28 +
    1.29 +
    1.30 +
    1.31 +
    1.32 +
    1.33 +
    1.34 +
    1.35 +
    1.36 +
    1.37 +
    1.38 +
    1.39 +
    1.40 +
    1.41  (defn write-memory-assembly* []
    1.42    [
    1.43 +   ;; --------- FRAME METRONOME
    1.44 +   
    1.45     0x18 ;; D31D
    1.46 -   0x02
    1.47 -   0x00 ;; frame-count D31F
    1.48 -   0x00 ;; v-blank-prev D320
    1.49 +   0x01
    1.50 +   0x00 ;; v-blank-prev D31F
    1.51  
    1.52     0xFA ;; load modes into A
    1.53     0x41
    1.54     0xFF
    1.55 -   
    1.56 -   0x47
    1.57 -   
    1.58 -   0xCB
    1.59 +
    1.60 +   0x47 ;; A -> B
    1.61 +   0xCB ;; rotate A
    1.62     0x2F
    1.63 -   0x2F
    1.64 +   0x2F ;; invert A
    1.65  
    1.66     0xA0
    1.67 -   0xE6
    1.68 -   0x01
    1.69 -   0x47 ;; now B contains (VB==1)
    1.70 +   0x47 ;; now B_0 contains (VB==1)
    1.71  
    1.72     0xFA ;; load v-blank-prev
    1.73 -   0x20
    1.74 -   0xD3
    1.75 -
    1.76 -   0x2F
    1.77 -   
    1.78 -   0xA0
    1.79 -   0x4F ;; now C contains increment?
    1.80 -
    1.81 -   0xFA ;; load frame count
    1.82     0x1F
    1.83     0xD3
    1.84  
    1.85 -   0x81 ;; add A+C->A
    1.86 -   0xEA ;; spit A --> fc
    1.87 -   0x1F
    1.88 -   0xD3
    1.89 +   0x2F ;; complement v-blank-prev
    1.90 +   
    1.91 +   0xA0 ;; A & B --> A
    1.92 +   0x4F ;; now C_0 contains increment?
    1.93 +
    1.94  
    1.95     0x78 ;; B->A
    1.96     
    1.97     0xEA ;; spit A --> vbprev
    1.98 -   0x20
    1.99 +   0x1F
   1.100     0xD3
   1.101  
   1.102 -   0xC3   ;D40F                    ; go back to beginning
   1.103 -   0x1D   ;D410
   1.104 -   0xD3   ;D411
   1.105 +   0x41   ;test C_0
   1.106 +   0x20   ; nonzero jump
   1.107 +   0x04
   1.108 +   
   1.109 +   0xC3   ;                    ; go back to beginning
   1.110 +   0x1D   ;
   1.111 +   0xD3   ;
   1.112 +   
   1.113 +   ;; -------- GET BUTTON INPUT
   1.114 +   0x00 ;; var: which-input D339
   1.115 +        ;; prepare to select bits
   1.116 +
   1.117 +   0x01 ;; load 0x0000 into BC
   1.118 +   0x00 
   1.119 +   0x00
   1.120 +   
   1.121 +   0x3E ;; load 0x20 into A
   1.122 +   0x20
   1.123 +
   1.124 +   
   1.125 +   0xEA ;; load A into [FF00] ;; D33F (not D33C)
   1.126 +   0x00
   1.127 +   0xFF
   1.128 +
   1.129 +   0xFA ;; load A from [FF00]
   1.130 +   0x00
   1.131 +   0xFF
   1.132 +
   1.133 +   0xE6 ;; bitmask 00001111
   1.134 +   0x0F
   1.135 +   
   1.136 +   0xB0 ;; A or B --> A
   1.137 +
   1.138 +   0xCB
   1.139 +   0x41 ;; test bit 0 of C
   1.140 +   0x20 ;; jump forward if 1
   1.141 +   0x08
   1.142 +
   1.143 +   0x47 ;; A -> B
   1.144 +   0xCB ;; swap B nybbles
   1.145 +   0x30 
   1.146 +   0x0C ;; increment C
   1.147 +   0x3E ;; load 0x10 into A
   1.148 +   0x10
   1.149 +   0x18 ;; JUMP back to "load A into [FF00]" [20 steps?]
   1.150 +   0xEB
   1.151 +
   1.152 +   ;; now A contains the pressed keys
   1.153 +   0xEA ;; copy keys to input-number [D339]
   1.154 +   0x39 
   1.155 +   0xD3
   1.156 +   0x18 ;;
   1.157 +   0xEB
   1.158 +   
   1.159 +   
   1.160     ]
   1.161    )
   1.162  
   1.163 @@ -525,6 +592,51 @@
   1.164        (inject-item-assembly (write-memory-assembly*))))
   1.165  
   1.166  
   1.167 +(defn dylan []
   1.168 +  (->
   1.169 +   (write-mem-dyl)
   1.170 +   (tick)
   1.171 +   (tick)
   1.172 +   (tick)
   1.173 +   (tick)
   1.174 +   (tick)
   1.175 +   (tick)
   1.176 +   (tick)
   1.177 +   (tick)
   1.178 +   (tick)
   1.179 +   (tick)
   1.180 +   (tick)
   1.181 +   (tick)
   1.182 +   (tick)
   1.183 +   (tick)
   1.184 +   (tick)
   1.185 +   (tick)
   1.186 +   (tick)
   1.187 +   (tick)
   1.188 +   (tick)
   1.189 +   (tick)
   1.190 +   (tick)
   1.191 +   (tick)
   1.192 +   (tick)
   1.193 +   (tick)
   1.194 +   (tick)
   1.195 +   (tick)
   1.196 +   (tick)
   1.197 +   (tick)
   1.198 +
   1.199 +   
   1.200 +   (d-tick)
   1.201 +
   1.202 +   
   1.203 +   (view-register "A" A)
   1.204 +   (view-register "B" B)
   1.205 +   (view-register "C" C)
   1.206 +   
   1.207 +   ))
   1.208 +
   1.209 +
   1.210 +
   1.211 +
   1.212  (defn d2 []
   1.213    (->
   1.214     (write-mem-dyl)
   1.215 @@ -532,34 +644,21 @@
   1.216     step step step step step
   1.217     (view-memory 0xD31F)))
   1.218  
   1.219 -(defn dylan []
   1.220 -  (->
   1.221 -   (write-mem-dyl)
   1.222 -   (tick)
   1.223 -   (tick)
   1.224 -   (tick)
   1.225 -   (tick)
   1.226 -   (tick)
   1.227 -   (tick)
   1.228 -   (tick)
   1.229 -   (tick)
   1.230 -   (tick)
   1.231 -   (tick)
   1.232 -   (tick)
   1.233 -   (tick)
   1.234  
   1.235 -   (tick)
   1.236 -   (tick)
   1.237 -   (tick)
   1.238 -   (tick)
   1.239 -   (tick)
   1.240  
   1.241 -   (d-tick)
   1.242 -   (view-register "A" A)
   1.243 -   (view-register "B" B)
   1.244 -   (view-register "C" C)
   1.245 -   
   1.246 -   ))
   1.247 +
   1.248 +
   1.249 +
   1.250 +
   1.251 +
   1.252 +
   1.253 +
   1.254 +
   1.255 +
   1.256 +
   1.257 +
   1.258 +
   1.259 +
   1.260  
   1.261  
   1.262  
     2.1 --- a/clojure/com/aurellem/vbm.clj	Sun Mar 18 00:56:29 2012 -0500
     2.2 +++ b/clojure/com/aurellem/vbm.clj	Sun Mar 18 05:13:19 2012 -0500
     2.3 @@ -6,7 +6,7 @@
     2.4  ;;;;;;;;;;;;; read vbm file 
     2.5  
     2.6  (def ^:dynamic *moves-cache*
     2.7 -     (File. user-home "proj/pokemon-escape/moves/")))
     2.8 +     (File. user-home "proj/pokemon-escape/moves/"))
     2.9  
    2.10  (defn buttons [mask]
    2.11    (loop [buttons []