Mercurial > vba-clojure
changeset 577:df3a7eac39d7
saving progress.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 01 Sep 2012 04:42:41 -0500 |
parents | 376f282bcbf1 |
children | 385799ea1e9c |
files | clojure/com/aurellem/run/adv_choreo.clj |
diffstat | 1 files changed, 33 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/run/adv_choreo.clj Sat Sep 01 04:19:15 2012 -0500 1.2 +++ b/clojure/com/aurellem/run/adv_choreo.clj Sat Sep 01 04:42:41 2012 -0500 1.3 @@ -128,11 +128,8 @@ 1.4 1.5 1.6 (defn glyph-display-program 1.7 - [start-address 1.8 - max-glyphs] 1.9 + [start-address] 1.10 (let [data-start (+ 2 start-address) 1.11 - [max-glyphs-high max-glyphs-low] 1.12 - (disect-bytes-2 max-glyphs) 1.13 load-data 1.14 (flatten 1.15 [;; data region 1.16 @@ -144,35 +141,23 @@ 1.17 1.18 ;; load data from data region into registers 1.19 1.20 - 0xF5 ;; push A 1.21 - 0x21 ;; begin data load 1.22 + 0xF5 ;; push A, which contains current glyph 1.23 + 1.24 + 0x21 1.25 (reverse (disect-bytes-2 data-start)) 1.26 - 1.27 - 0x2A 0x47 ;; glyphs-rendered -> BC 1.28 - 0x2A 0x4F 1.29 + ;; load row and column into DE 1.30 + 0x2A 0x57 ;; row -> D 1.31 + 0x2A 0x5F ;; column -> E 1.32 1.33 - 0x16 max-glyphs-high ;; load max-glyphs 1.34 - 0x1E max-glyphs-low ;; into DE 1.35 + 1.36 ]) 1.37 1.38 1.39 display-glyph 1.40 (let [init* 1.41 (flatten 1.42 - [;; BC is current number of glyphs rendered. 1.43 - ;; each glyph is two characters, and the screen can hold up 1.44 - ;; to 360 characters. Thus, if the current glyphs is a 1.45 - ;; multiple of 180, the screen must be refreshed. 1.46 - 1.47 - ;; DE contains max-glyphs and HL will be overwritten next 1.48 - ;; section, so both are free to use here. 1.49 - (repeat 100 0) 1.50 + [(repeat 100 0) 1.51 ;; Reset HL to initial value 1.52 - 0x21 1.53 - (reverse (disect-bytes-2 data-start)) 1.54 - ;; load row and column into DE 1.55 - 0x2A 0x57 ;; row -> D 1.56 - 0x2A 0x5F ;; column -> E 1.57 1.58 ;; clear screen if we are at 0,0 1.59 0x57 0xB3 ;; D->A, OR E A ==> (= D E 0) 1.60 @@ -210,6 +195,8 @@ 1.61 ;; restore all registers 1.62 0xF1 0xE1 0xD1 0xC1]) 1.63 1.64 + ;; RLM: for TESTING ONLY!!! 1.65 + clear-screen (repeat 10 0) 1.66 increment-row-column 1.67 [;; D contains row and E contains column 1.68 1.69 @@ -230,45 +217,48 @@ 1.70 1.71 set-HL-from-row-and-column 1.72 [;; formula for memory offset is: 1.73 - ;; (+ 0x9800 (* 32 row) column) 1.74 + ;; (+ 0x9800 (* 32 row) column) == 1.75 + ;; (+ 0x97E0 (* 32 (+ 1 row)) column) 1.76 0xD5 0xC5 ;; push D E B C 1.77 1.78 - 0x21 0x00 0x98 ;; load HL with 0x9800 1.79 + 0x21 0xE0 0x97 ;; load HL with 0x97E0 1.80 + 1.81 + 0x06 0 1.82 + 0x0E 32 ;; load 32 into BC 1.83 1.84 - 0x01 32 00 ;; load 32 into BC 1.85 + 0x14 ;; inc D to handle case where D == 0 1.86 + ;; D will never be > 20, so this will never overflow. 1.87 1.88 ;; do 1.89 - 0x09 ;; HL += 32 1.90 - 0x15 ;; dec D 1.91 + 0x09 ;; HL += 32 1.92 + 0x15 ;; dec D 1.93 ;; while D != 0 1.94 0x20 1.95 (->signed-8-bit -4) 1.96 - 1.97 - 0x4B ;; E->C 1.98 - 0x15 ;; add columns (E) to HL 1.99 - 1.100 + 1.101 0xC1 0xD1 ;; pop C B E D 1.102 ] 1.103 1.104 render-glyph 1.105 (flatten 1.106 - [set-HL-from-row-and-column 1.107 + [;; Render each nybble of A as a character 1.108 + ;; there are two characters to a glyph. 1.109 + 1.110 + set-HL-from-row-and-column 1.111 0xF1 ;; pop A, now A is equal to key input 1.112 0xF5 ;; save A 1.113 1.114 0xE6 0xF0 ;; clear second nybble 1.115 0xCB 0x37 ;; swap nybbles 1.116 - 0x22 ;; store A in video as a character (pun) 1.117 - 1.118 + 0x22 ;; store A in video RAM as a character (pun) 1.119 + increment-row-column 1.120 + 1.121 + set-HL-from-row-and-column 1.122 0xF1 ;; restore A 1.123 0xE6 0x0F ;; select second nybble 1.124 - 0x22 ;; store second nybble as glyph 1.125 - 1.126 + 0x22 ;; store second nybble as character 1.127 increment-row-column 1.128 - increment-row-column 1.129 - ;; Render each nybble of A as a character 1.130 - ;; there are two characters to a glyph. 1.131 - ]) 1.132 + ]) 1.133 1.134 1.135 init (replace 1.136 @@ -304,8 +294,7 @@ 1.137 glyph-display (glyph-display-program 1.138 (+ (count init) 1.139 (count header) 1.140 - start-address) 1.141 - 2000) 1.142 + start-address)) 1.143 ;;(- (count (program-data 0)) 100)) 1.144 1.145 state-machine-start-address