;;; Subroutine: render ;;; Convert 1px per byte array at pixarray to packed 8px/byte at screen. ; 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+1 lda #pixarray sta pixptr+1 ldx #0 rline_loop: lda #0 sta colcount sta screenbyte ; clear whole line. this is why pixarray is offset from screen by ; one screen line. ldy #$1f rclr: sta (screenptr),y dey bpl rclr ; first pixels start at column 40 (5 bytes in)... lda #5 sta screenbyte lda #$10 ; ...plus, mask starts out 0001000, 3 more columns to the right. sta pixmask rpix_loop: ldy colcount ; ranges 0 to 169 lda (pixptr),y beq notset ; 0 = not set, non-zero = set ; if we found a set pixel, set it in the bitmap ldy screenbyte lda (screenptr),y ora pixmask sta (screenptr),y notset: ; pixmask >>= 1; if(pixmask == 0) { pixmask = 0x80; screenbyte++; } lsr pixmask bcc pmok ror pixmask inc screenbyte pmok: inc colcount lda colcount cmp #$aa bne rpix_loop ; pixptr += 0xaa; clc adc pixptr sta pixptr lda pixptr+1 adc #0 sta pixptr+1 ; screenptr += 0x20; clc lda screenptr adc #$20 sta screenptr lda screenptr+1 adc #0 sta screenptr+1 inx cpx #$aa ; hit last line yet? bne rline_loop ; if not, go render next line. .ifdef RENDER_PROFILE lda RTCLOK+1 sta $0602 lda RTCLOK+2 sta $0603 .endif rts