Mercurial > vba-clojure
diff clojure/com/aurellem/gb/rlm_assembly.clj @ 387:47d44bb54d32
saving progress...
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Thu, 12 Apr 2012 09:21:40 -0500 |
parents | d8cbbf2a3133 |
children | a0d0e1a46b1d |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/gb/rlm_assembly.clj Thu Apr 12 06:27:03 2012 -0500 1.2 +++ b/clojure/com/aurellem/gb/rlm_assembly.clj Thu Apr 12 09:21:40 2012 -0500 1.3 @@ -66,16 +66,16 @@ 1.4 (defn frame-metronome [] 1.5 (let [timing-loop 1.6 [;;0x01 ; \ 1.7 - ;;0x43 ; | 1.8 - ;;0xFE ; | load 0xFF44 into BC without repeats 1.9 - ;;0x0C ; | 1.10 + ;;0x43 ; | 1.11 + ;;0xFE ; | load 0xFF44 into BC without repeats 1.12 + ;;0x0C ; | 1.13 ;;0x04 ; / 1.14 ;;0x0A ;; (BC) -> A, now A = LY (vertical line coord) 1.15 1.16 0x11 ; \ 1.17 - 0x43 ; | 1.18 - 0xFE ; | load 0xFF44 into DE without repeats 1.19 - 0x1C ; | 1.20 + 0x43 ; | 1.21 + 0xFE ; | load 0xFF44 into DE without repeats 1.22 + 0x1C ; | 1.23 0x14 ; / 1.24 0x1A ;; (DE) -> A, now A = LY (vertical line coord) 1.25 ] 1.26 @@ -115,15 +115,15 @@ 1.27 1.28 (defn read-user-input [] 1.29 [;;0x01 ;\ 1.30 - ;;0x01 ;| 1.31 - ;;0xFE ;| load 0xFF00 into BC without repeats 1.32 - ;;0x04 ;| 1.33 + ;;0x01 ; | 1.34 + ;;0xFE ; | load 0xFF00 into BC without repeats 1.35 + ;;0x04 ; | 1.36 ;;0x0D ;/ 1.37 1.38 0x11 ; \ 1.39 - 0x01 ; | 1.40 - 0xFE ; | load 0xFF44 into DE without repeats 1.41 - 0x14 ; | 1.42 + 0x01 ; | 1.43 + 0xFE ; | load 0xFF44 into DE without repeats 1.44 + 0x14 ; | 1.45 0x1D ; / 1.46 1.47 0x3E 1.48 @@ -144,7 +144,7 @@ 1.49 0xE6 ;; select bottom bits of A 1.50 0x0F 1.51 1.52 - 0x47 ;; A->B 1.53 + 0x57 ;; A->D 1.54 1.55 0xF1 ;; pop AF 1.56 1.57 @@ -153,9 +153,10 @@ 1.58 1.59 0xCB 1.60 0x37 ;; swap A nybbles 1.61 - 1.62 - 0xB0 ;; (AND A B) -> A 1.63 - 1.64 + 1.65 + 0x5A ;; D->E \ necessary to 1.66 + 0xB3 ;; (or A D) -> A / prevent repeats. 1.67 + 1.68 0x2F ;; (NOT A) -> A 1.69 ]) 1.70 1.71 @@ -204,20 +205,31 @@ 1.72 (read-user-input))) 1.73 1.74 init 1.75 - [0x1E 0xFF 0x1C] ;; 0-> E without repeats 1.76 - 1.77 + [0xAF 0x4F] ;; 0->A; 0->C; 1.78 1.79 - ;; HL -> BC 1.80 ;; HL = here 1.81 - ;; add E to HL 1.82 + ;; add C to HL 1.83 ;; jp HL 1.84 1.85 + prepare-HL 1.86 + [0x21] ;; load HL from literal nn 1.87 + ;; nn == here defined below 1.88 + 1.89 mode-dispatch 1.90 - [0x44 1.91 + [0x06 ;\ 1.92 + 0x01 ; | 0->B without repeats 1.93 + 0x05 ;/ 1.94 + 0x09 ;; add BC to HL 1.95 + 0xE9] ;; jp 1.96 1.97 + here 1.98 + (disect-bytes-2 (+ 2 start-address (count init) 1.99 + jump-distance prepare-HL 1.100 + (count mode-dispatch))) 1.101 + 1.102 1.103 1.104 - ;;(here) jr metronome 1.105 + ;;(here) jr end 1.106 1.107 ;;stuff 1.108 ;;modify E 1.109 @@ -225,59 +237,29 @@ 1.110 1.111 ;;stuff 1.112 ;;jr metronome 1.113 + 1.114 + input-number 1.115 + 1.116 + [0x47 ;; A->B 1.117 + 0x1E ;; 1.118 + input-high-write-jump 1.119 + 0x18 1.120 + (jump-distance ??)] 1.121 + 1.122 1.123 1.124 + input-high-write 1.125 + [0x 1.126 + 1.127 1.128 1.129 1.130 1.131 - 1.132 - mode-dispatch 1.133 - [0xCB 1.134 - 0x43 ;; test bit 0 1.135 - 1.136 - 0xCB 1.137 - 0x4B ;; test bit 1 1.138 - 1.139 - 0xCB 1.140 - 0x53 ;; test bit 2 1.141 - 1.142 - 0xCB 1.143 - 0x5B ;; test bit 3 1.144 - 1.145 - 0xCB 1.146 - 0x63 ;; test bit 4 1.147 - 1.148 - 0xCB 1.149 - 0x6B ;; test bit 5 1.150 - 1.151 - ];;default 1.152 - 1.153 - 1.154 - mode-select 1.155 - [0x5F] ;; A->E 1.156 - 1.157 - ;; delayed inputs 1.158 - input-high 0x67 ;; A->H 1.159 - input-low 0x6F ;; A->L 1.160 - input-num 0x57 ;; A->D 1.161 - 1.162 - ;; final-actions 1.163 - jump 0xE9 ;; jp (HL) 1.164 - write 0x22 ;; A->(HL); inc HL 1.165 - input-mode 0x00 ;; no-op 1.166 - 1.167 - 1.168 - 1.169 - input-high 1.170 - [0x67 ;; A->H 1.171 - 0x1E ;; change mode 1.172 - input-low-mode] 1.173 - 1.174 - 1.175 1.176 1.177 - mode-dispatch 1.178 + (concat init (frame-metronome) (read-user-input) 1.179 + prepare-HL here mode-dispatch) 1.180 + 1.181 1.182 1.183