diff options
Diffstat (limited to 'render.s')
-rw-r--r-- | render.s | 57 |
1 files changed, 31 insertions, 26 deletions
@@ -1,11 +1,24 @@ ;;; Subroutine: render ;;; Convert 1px per byte array at pixarray to packed 8px/byte at screen. -; pixarray is 170x170. screen is 256x170 (TODO: fix display list). +; pixarray is 170x170. screen is 256x170. ; each screen line is: 43 blank px, 170 graphics px, 43 blank. + +; This is slow. It takes around 40 jiffies (0.6 sec). However, it only +; happens once per generate. So not worth optimizing, really. + screenbyte = FR0 colcount = FR0+1 +; RENDER_PROFILE = 1 + render: +.ifdef RENDER_PROFILE + lda RTCLOK+1 + sta $0600 + lda RTCLOK+2 + sta $0601 +.endif + lda #<screen sta screenptr lda #>screen @@ -16,26 +29,11 @@ render: sta pixptr+1 ldx #0 -rline: +rline_loop: lda #0 sta colcount sta screenbyte -; ; clear 40px on left -; ldy #4 -;lclr: -; sta (screenptr),y -; dey -; bpl lclr -; -; ; clear 40px on right -; ldy #$1b -;rclr: -; sta (screenptr),y -; iny -; cpy #$20 -; bne rclr - ; clear whole line. this is why pixarray is offset from screen by ; one screen line. ldy #$1f @@ -44,13 +42,13 @@ rclr: dey bpl rclr - ; first pixels start at column 40, plus... + ; first pixels start at column 40 (5 bytes in)... lda #5 sta screenbyte - lda #$10 ; ...mask starts out 0001000, 3 more blank px on left + lda #$10 ; ...plus, mask starts out 0001000, 3 more columns to the right. sta pixmask -rpix: +rpix_loop: ldy colcount ; ranges 0 to 169 lda (pixptr),y beq notset ; 0 = not set, non-zero = set @@ -60,18 +58,19 @@ rpix: ora pixmask sta (screenptr),y notset: + ; pixmask >>= 1; if(pixmask == 0) { pixmask = 0x80; screenbyte++; } lsr pixmask - bne pmok - ;ror pixmask - lda #$80 - sta pixmask + bcc pmok + ror pixmask inc screenbyte pmok: + inc colcount lda colcount cmp #$aa - bne rpix + bne rpix_loop + ; pixptr += 0xaa; clc adc pixptr @@ -89,6 +88,12 @@ pmok: sta screenptr+1 inx cpx #$aa ; hit last line yet? - bne rline ; if not, go render next line. + bne rline_loop ; if not, go render next line. +.ifdef RENDER_PROFILE + lda RTCLOK+1 + sta $0602 + lda RTCLOK+2 + sta $0603 +.endif rts |