comparison clojure/com/aurellem/run/adv_choreo.clj @ 579:9f2b221bbf9b

row and columns increment correctly now.
author Robert McIntyre <rlm@mit.edu>
date Sat, 01 Sep 2012 06:03:08 -0500
parents 385799ea1e9c
children 46bbeac1b329
comparison
equal deleted inserted replaced
578:385799ea1e9c 579:9f2b221bbf9b
194 194
195 ;; restore all registers 195 ;; restore all registers
196 0xF1 0xE1 0xD1 0xC1]) 196 0xF1 0xE1 0xD1 0xC1])
197 197
198 ;; RLM: for TESTING ONLY!!! 198 ;; RLM: for TESTING ONLY!!!
199 ;;clear-screen (repeat 10 0) 199 clear-screen (repeat 10 0)
200 increment-row-column 200 increment-row-column
201 [;; D contains row and E contains column 201 [;; D contains row and E contains column
202 202
203 ;; every time column (E) reaches 20, set 203 ;; every time column (E) reaches 20, set
204 ;; column to 0 and increment row 204 ;; column to 0 and increment row
205 0x1C ;; inc E 205 0x1C ;; inc E
206 0x3E 20 0xBB ;; compare E to 20 206 0x3E 20 0xBB ;; compare E to 20
207 0x20 207 0x20
208 3
209 0x14
210 0x1E 0
211
212
213 0x3E 18
214 0xBA
215 0x20
208 2 216 2
209 0x1E 0 217 0x16 0
210
211
212 218
213 ;; 0x00 ;;0x1C ;; inc E 219 ;; 0x00 ;;0x1C ;; inc E
214 ;; 0x3E 20 0xBB ;; compare E to 20 220 ;; 0x3E 20 0xBB ;; compare E to 20
215 ;; 0x20 ;; if E is 20 221 ;; 0x20 ;; if E is 20
216 ;; 3 222 ;; 3
228 [;; formula for memory offset is: 234 [;; formula for memory offset is:
229 ;; (+ 0x9800 (* 32 row) column) == 235 ;; (+ 0x9800 (* 32 row) column) ==
230 ;; (+ 0x97E0 (* 32 (+ 1 row)) column) 236 ;; (+ 0x97E0 (* 32 (+ 1 row)) column)
231 0xD5 0xC5 ;; push D E B C 237 0xD5 0xC5 ;; push D E B C
232 238
233 0x21 0x00 0x98 ;; load HL with 0x97E0 239 ;; RLM: this should be 0x9800, investigate
240 0x21 0xE0 0x97 ;; load HL with 0x97E0
234 241
235 0x06 0 242 0x06 0
236 0x4B 243 0x4B
237 0x09 244 0x09
238 245
239 ;; 0x06 0 246
240 ;; 0x0E 32 ;; load 32 into BC 247 0xAF ;; 0 -> A
248
249 0x06 0
250 0x0E 32 ;; load 32 into BC
251
252 0xBA
253 0x20
254 4
255 0x09 ;; HL += 32
256 0x3C
257 0x18
258 (->signed-8-bit -7)
241 259
242 ;; 0x14 ;; inc D to handle case where D == 0 260 ;; 0x14 ;; inc D to handle case where D == 0
243 ;; ;; D will never be > 20, so this will never overflow. 261 ;; ;; D will never be > 20, so this will never overflow.
244 262
245 ;; ;; do 263 ;; ;; do
254 272
255 render-glyph 273 render-glyph
256 (flatten 274 (flatten
257 [;; Render each nybble of A as a character 275 [;; Render each nybble of A as a character
258 ;; there are two characters to a glyph. 276 ;; there are two characters to a glyph.
277 0x21
278 (reverse (disect-bytes-2 data-start))
279 ;; load row and column into DE
280 0x2A 0x57 ;; row -> D
281 0x2A 0x5F ;; column -> E
259 282
260 set-HL-from-row-and-column 283 set-HL-from-row-and-column
261 0xF1 ;; pop A, now A is equal to key input 284 0xF1 ;; pop A, now A is equal to key input
262 0xF5 ;; save A 285 0xF5 ;; save A
263 286
264 0xE6 0xF0 ;; clear second nybble 287 0xE6 0xF0 ;; clear second nybble
265 0xCB 0x37 ;; swap nybbles 288 0xCB 0x37 ;; swap nybbles
266 0x22 ;; store A in video RAM as a character (pun) 289 0x77 ;; store A in video RAM as a character (pun)
267 increment-row-column 290 increment-row-column
268 291
269 set-HL-from-row-and-column 292 set-HL-from-row-and-column
270 0xF1 ;; restore A 293 0xF1 ;; restore A
271 0xE6 0x0F ;; select second nybble 294 0xE6 0x0F ;; select second nybble
272 0x22 ;; store second nybble as character 295 0x77 ;; store second nybble as character
273 increment-row-column 296 increment-row-column
274 ]) 297 ])
275 298
276 299
277 init (replace 300 init (replace
284 ;; restore all registers 307 ;; restore all registers
285 (flatten 308 (flatten
286 [;; Reset HL to initial value 309 [;; Reset HL to initial value
287 0x21 310 0x21
288 (reverse (disect-bytes-2 data-start)) 311 (reverse (disect-bytes-2 data-start))
289 0x23 312 ;;0x23
290 ;;0x7A 0x22 ;; D -> rows -> to RAM 313 0x7A 0x22 ;; D -> rows -> to RAM
291 0x7B 0x22 ;; E -> columns 314 0x7B 0x22 ;; E -> columns
292 ]) 315 ])
293 316
294 stack-cleanup 317 stack-cleanup
295 [0xF1 0xE1 0xD1 0xC1] 318 [0xF1 0xE1 0xD1 0xC1]