Mercurial > vba-clojure
changeset 390:dbf7b5a2e9e7
saving progress.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Wed, 11 Apr 2012 23:40:01 -0500 |
parents | bb8978d370d8 |
children | 2e9b2d27f32f |
files | clojure/com/aurellem/gb/rlm_assembly.clj moves/temp.vbm |
diffstat | 2 files changed, 56 insertions(+), 66 deletions(-) [+] |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/gb/rlm_assembly.clj Thu Apr 12 12:08:36 2012 -0500 1.2 +++ b/clojure/com/aurellem/gb/rlm_assembly.clj Wed Apr 11 23:40:01 2012 -0500 1.3 @@ -5,6 +5,13 @@ 1.4 (:use (com.aurellem.run bootstrap-1)) 1.5 (:import [com.aurellem.gb.gb_driver SaveState])) 1.6 1.7 + 1.8 +;; MODE-SELECT 1.9 +;; SET-LENGTH 1.10 +;; SET-TARGET 1.11 +;; WRITE 1.12 +;; JUMP 1.13 + 1.14 ;; Specs for Main Bootstrap Program 1.15 1.16 ;; Number-Input 1.17 @@ -64,7 +71,8 @@ 1.18 (+ 256 n) n)) 1.19 1.20 (defn frame-metronome [] 1.21 - (let [timing-loop 1.22 + (let [init [0xC5] ;; save value of BC 1.23 + timing-loop 1.24 [0x01 ; \ 1.25 0x43 ; | 1.26 0xFE ; | load 0xFF44 into BC without repeats 1.27 @@ -81,7 +89,7 @@ 1.28 [0x05 ;; dec B, which is 0xFF 1.29 0x20 ;; spin until B==0 1.30 0xFD]] 1.31 - (concat timing-loop continue-if-144 spin-loop))) 1.32 + (concat init timing-loop continue-if-144 spin-loop))) 1.33 1.34 (defn test-frame-metronome 1.35 "Ensure that frame-metronome ticks exactly once every frame." 1.36 @@ -97,7 +105,8 @@ 1.37 (DE! 0) 1.38 (set-memory-range pokemon-list-start program) 1.39 (PC! pokemon-list-start)) 1.40 - E-after-moves (E (run-moves count-frames (repeat steps [])))] 1.41 + E-after-moves 1.42 + (E (run-moves count-frames (repeat steps [])))] 1.43 (println "E:" E-after-moves) 1.44 (assert (= steps E-after-moves)) 1.45 1.46 @@ -143,6 +152,7 @@ 1.47 0xB0 ;; (or A B) -> A 1.48 1.49 0x2F ;; (NOT A) -> A 1.50 + 1.51 ]) 1.52 1.53 (defn test-read-user-input [] 1.54 @@ -179,27 +189,54 @@ 1.55 (def do-write-mode (Integer/parseInt "00010000" 2)) 1.56 1.57 (defn main-bootstrap-program [start-address] 1.58 + ;; Register Use: 1.59 + 1.60 + ;; BC persistent scratch 1.61 + ;; 1.62 + ;; A user-input 1.63 + ;; HL target-address 1.64 + ;; D current-mode 1.65 + ;; E bytes-to-write 1.66 + 1.67 + 1.68 + ;; Modes are: 1.69 + 1.70 + ;; single-action-modes: 1.71 + ;; SET-MODE 1.72 + ;; SET-TARGET-HIGH 1.73 + ;; SET-TARGET-LOW 1.74 + ;; SET-WRITE-LENGTH 1.75 + ;; JUMP 1.76 + 1.77 + ;; multi-action-modes 1.78 + ;; WRITE 1.79 + 1.80 + 1.81 + 1.82 (let [[start-high start-low] (disect-bytes-2 start-address) 1.83 - jump-distance (+ (count (frame-metronome) 1.84 - (read-user-input))) 1.85 + jump-distance (+ (count (frame-metronome)) 1.86 + (read-user-input)) 1.87 1.88 init 1.89 - [0xAF 0x5F] ;; 0->A; 0->E; 1.90 + [0xAF 0x5F 0x57 0x47] ;; 0->A; 0->E; 0->D; 0->B 1.91 1.92 + 1.93 + 1.94 1.95 - header 1.96 - [0x47] ;; A->B 1.97 + input 1.98 + [0xC1 ;; pop BC so it's not volatile 1.99 + ;; some condition 1.100 + ;; to skip if not in input 1.101 + ;; mode 1.102 + 1.103 + 1.104 + 1.105 + 1.106 + 0xE9 ;; jump to (HL) 1.107 1.108 - mode-select 1.109 - [0xCB 0x43 ;; last-bit is zero 1.110 - 0x28 :to-beginning 1.111 - 0x5F];; A->E 1.112 - 1.113 - input-section 1.114 - [0xCB 0x4B ;; test bit 0 of E 1.115 - 0x28 0x03 1.116 - 1.117 - 1.118 + 0x22 ;; A->(HL) ; inc HL 1.119 + 1.120 + 1.121 0x57 ;; A->D 1.122 1.123 0x67 ;; A->H 1.124 @@ -219,54 +256,7 @@ 1.125 ;; add C to HL 1.126 ;; jp HL 1.127 1.128 - prepare-HL 1.129 - [0xD1 ;; pop DE causes D and E to be non-volitale 1.130 - 1.131 - 0x21 ;; load HL from literal nn 1.132 - :dispatch-high 1.133 - :dispatch-low] 1.134 - 1.135 - mode-dispatch 1.136 - [0xC5 ;; push BC 1.137 - 0x06 ;\ 1.138 - 0x01 ; | 0->B without repeats 1.139 - 0x05 ;/ 1.140 - 0x09 ;; add BC to HL 1.141 - 0xC1 ;; pop BC 1.142 - 0xE9] ;; jp 1.143 - 1.144 - mode-select 1.145 - [0x4F ;; A->C (this is the address of dispatch above) 1.146 - 0x18 ;; return 1.147 - :jump-to-end] 1.148 - 1.149 - input-bytes-to-write 1.150 - [0x47 ;; A->B 1.151 - 0x18 ;; return 1.152 - :jump-to-end] 1.153 - 1.154 - 1.155 - 1.156 - 1.157 - 1.158 - cleanup 1.159 - [0xD5 ;; push DE 1.160 - 0x18 1.161 - 0x??];; jump all the way back to frame-metronome 1.162 - 1.163 - 1.164 -;; (concat init (frame-metronome) (read-user-input) 1.165 -;; prepare-HL here mode-dispatch) 1.166 - 1.167 - 1.168 - 1.169 - 1.170 - 1.171 - 1.172 - 1.173 - 1.174 -;; )) 1.175 - 1.176 +]])) 1.177 1.178 1.179
2.1 Binary file moves/temp.vbm has changed