; ----------------------------------------------------------- ; common.asm - routines, tables and variables shared by the ; slides: screen clearing, text printing, big 3x5 block font ; ----------------------------------------------------------- ; ---- clear screen RAM, fill color RAM with white ---- clear_screen: ldx #0 cls_loop: lda #$20 ; space sta SCREEN,x sta SCREEN+$100,x sta SCREEN+$200,x sta SCREEN+$2e8,x lda #WHITE sta COLRAM,x sta COLRAM+$100,x sta COLRAM+$200,x sta COLRAM+$2e8,x inx bne cls_loop rts ; ---- print a text line: txtlo/hi, prow, pcol, pcolor, plen ---- print_text: ldx prow lda mul40lo,x clc adc pcol sta scrlo sta collo lda mul40hi,x adc #>SCREEN ; carry still valid from the low-byte add sta scrhi clc adc #$d4 ; COLRAM - SCREEN high byte distance sta colhi ldy #0 pt_loop: lda (txtlo),y sta (scrlo),y lda pcolor sta (collo),y iny cpy plen bne pt_loop rts ; ---- draw a text line with big 3x5 block letters ---- ; txtlo/hi = text (screen codes), bigrow/bigcol = top-left cell, ; bigcolor = color, biglen = char count; each letter is 3 cells ; wide + 1 gap, 5 cells tall draw_big: lda #0 sta bigi db_char: ldy bigi lda (txtlo),y cmp #$20 ; space: leave the cell empty beq db_next tax lda bigmap,x ; screen code -> glyph index sta glyphbase asl ; glyph base = index * 5 asl clc adc glyphbase sta glyphbase lda bigi ; cell x = bigcol + charindex * 4 asl asl clc adc bigcol sta charx lda #0 sta rowidx db_row: lda bigrow ; row pointers from the row*40 tables clc adc rowidx tax lda mul40lo,x sta scrlo sta collo lda mul40hi,x clc adc #>SCREEN sta scrhi clc adc #$d4 sta colhi lda glyphbase clc adc rowidx tax lda bigglyphs,x asl ; 3-bit pattern up to bits 7-5 asl asl asl asl sta curbits ldy charx lda #3 sta bitcnt db_bit: asl curbits ; leftmost pixel first bcc db_nobit lda #$a0 ; inverse space = solid block sta (scrlo),y lda bigcolor sta (collo),y db_nobit: iny dec bitcnt bne db_bit inc rowidx lda rowidx cmp #5 bne db_row db_next: inc bigi lda bigi cmp biglen beq db_done jmp db_char ; too far for a relative branch db_done: rts ; ---- shared tables ---- ; row * 40 lookup tables (25 rows) mul40lo: !byte $00, $28, $50, $78, $a0, $c8, $f0, $18, $40, $68 !byte $90, $b8, $e0, $08, $30, $58, $80, $a8, $d0, $f8 !byte $20, $48, $70, $98, $c0 mul40hi: !byte $00, $00, $00, $00, $00, $00, $00, $01, $01, $01 !byte $01, $01, $01, $02, $02, $02, $02, $02, $02, $02 !byte $03, $03, $03, $03, $03 ; 3x5 block font for the big slide titles (5 bytes per glyph, ; low 3 bits used, MSB side = left) bigglyphs: !byte 0, 0, 0, 0, 0 ; 0 space !byte 2, 5, 7, 5, 5 ; 1 A !byte 3, 4, 4, 4, 3 ; 2 C !byte 6, 5, 5, 5, 6 ; 3 D !byte 7, 4, 6, 4, 7 ; 4 E !byte 7, 4, 6, 4, 4 ; 5 F !byte 7, 2, 2, 2, 7 ; 6 I !byte 4, 4, 4, 4, 7 ; 7 L !byte 5, 7, 7, 5, 5 ; 8 M !byte 6, 5, 5, 5, 5 ; 9 N !byte 7, 5, 5, 5, 7 ; 10 O !byte 6, 5, 6, 4, 4 ; 11 P !byte 6, 5, 6, 5, 5 ; 12 R !byte 3, 4, 2, 1, 6 ; 13 S !byte 7, 2, 2, 2, 2 ; 14 T !byte 5, 5, 2, 2, 2 ; 15 Y !byte 3, 4, 5, 5, 7 ; 16 G bigmap: ; screen code (a=1..z=26) -> glyph index !byte 0 ; (unused) !byte 1, 0, 2, 3, 4, 5, 16, 0, 6, 0 ; a-j !byte 0, 7, 8, 9, 10, 11, 0, 12, 13, 14 ; k-t !byte 0, 0, 0, 0, 15, 0 ; u-z washtbl: ; gold glow ramp (16 entries, cyclic) !byte $09, $02, $08, $0a, $07, $07, $01, $01 !byte $01, $01, $07, $07, $0a, $08, $02, $09 pulsetbl: ; grey-white pulse (8 entries, cyclic) !byte $0b, $0c, $0f, $01, $01, $0f, $0c, $0b fadetbl: ; fade-to-black: each color -> one shade darker, ; every chain reaches black in at most 4 steps ; (e.g. white -> lgrey -> mgrey -> dgrey -> black) ; blk wht red cyn pur grn blu yel !byte $00, $0f, $09, $0e, $06, $0b, $00, $08 ; org brn lrd dgr mgr lgn lbl lgr !byte $02, $00, $02, $00, $0b, $05, $06, $0c ; ---- shared variables ---- framectr: !byte 0 ; frame counter, driven by the slide updates washphase: !byte 0 ; gold wash offset (slides 1 and 2) curbits: !byte 0 ; current bit pattern in the letter renderers prow: !byte 0 ; print_text: row, column, color, length pcol: !byte 0 pcolor: !byte 0 plen: !byte 0 bigrow: !byte 0 ; draw_big: row, column, color, length bigcol: !byte 0 bigcolor: !byte 0 biglen: !byte 0 bigi: !byte 0 ; draw_big internals glyphbase: !byte 0 charx: !byte 0 rowidx: !byte 0 bitcnt: !byte 0