; 03-bitmap.s - a 256-color bitmap behind the text screen, drawn by the blitter ; ; cl65 -t c64 -C c64-asm.cfg -u __EXEHDR__ --asm-include-dir ../include -o 03-bitmap.prg 03-bitmap.s .include "vicx.inc" .include "vicxlib.inc" CLRSCR = $E544 ; KERNAL: clear the text screen STROUT = $AB1E ; BASIC ROM: print the text at A (low), Y (high) addr = $FB ; three free zero-page bytes .code sei ; nothing may write $D000-$D3FF mid-unlock VICX_UNLOCK_SEQ cli lda VICX_ID0 ; "VX" only reads back on VIC-X cmp #$56 bne novicx lda VICX_ID1 cmp #$58 beq found novicx: rts ; stock C64: nothing has changed found: SET_PAL 16, 16, 16, 48 ; five colors of our own SET_PAL 17, 228, 60, 40 SET_PAL 18, 250, 212, 64 SET_PAL 19, 120, 178, 238 SET_PAL 20, 255, 255, 255 ; Four chained descriptors: clear the bitmap, then three rectangles. ; n operation flags src dst len rows sstr dstr fill tr next DMA_DESC 0, VICX_DMA_FILL, VICX_DMA_DST_VRAM, 0, 0, 64000, 0, 0, 0, 16, 0, 1 DMA_DESC 1, VICX_DMA_FILL, VICX_DMA_DST_VRAM | VICX_DMA_2D, 0, 40*320 + 40, 240, 120, 0, 320, 17, 0, 2 DMA_DESC 2, VICX_DMA_FILL, VICX_DMA_DST_VRAM | VICX_DMA_2D, 0, 60*320 + 80, 160, 80, 0, 320, 18, 0, 3 DMA_DESC 3, VICX_DMA_FILL, VICX_DMA_DST_VRAM | VICX_DMA_2D, 0, 80*320 + 120, 80, 40, 0, 320, 19, 0, VICX_DMA_NONE lda #0 sta VICX_DMA_CMD ; start at descriptor 0 DMA_WAIT ; VRAM transfers run in the background ; A diagonal line, pixel by pixel: address = y * 320 + x. lda #60 sta addr lda #0 sta addr+1 sta addr+2 ldx #200 line: lda addr sta VICX_P0_ADDRL lda addr+1 sta VICX_P0_ADDRM lda addr+2 ; no step bits: step 0 sta VICX_P0_ADDRH lda #20 sta VICX_P0_DATA clc ; one line down and one pixel right lda addr adc #<321 sta addr lda addr+1 adc #>321 sta addr+1 bcc :+ inc addr+2 : dex bne line ; Layer 0: an 8-bit bitmap at VRAM 0, 320 bytes per line. LAYER_SET VICX_LAYER0, VICX_LMODE_BITMAP8, 0, 0, 0, 0, 0, 320, 0 ; Layer on, and make the VIC-II background transparent so it shows. lda #VICX_CTRL_L0 | VICX_CTRL_BGTRANS sta VICX_CTRL jsr CLRSCR lda #text jmp STROUT ; back to BASIC, with the layer behind the text text: .byte "text on top of 256 colors", 13, 0