From f70de4c203d24964e0c58119c9db0395483a178c Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Mon, 17 Dec 2018 22:58:19 -0500 Subject: [PATCH] xmas2018: scrolling text works --- mode7/scroller.c | 137 +++++++++++++++++++++++++++++++++------ xmas_2018/Makefile | 2 +- xmas_2018/ball.s | 47 ++++++++------ xmas_2018/gr_scroll.s | 145 ++++++++++++++++++++++++++++++++++++++++++ xmas_2018/greets.inc | 10 +++ 5 files changed, 302 insertions(+), 39 deletions(-) create mode 100644 xmas_2018/gr_scroll.s create mode 100644 xmas_2018/greets.inc diff --git a/mode7/scroller.c b/mode7/scroller.c index d161266e..c5ff93b2 100644 --- a/mode7/scroller.c +++ b/mode7/scroller.c @@ -71,25 +71,83 @@ static unsigned char font[256][9]={ }, {0,0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0,0}, // 48 + {4, // 48 + 0x00, + 0x40, // ** + 0xa0, // ** ** + 0xa0, // ** ** + 0xa0, // ** ** + 0xa0, // ** ** + 0xa0, // ** ** + 0x40, // ** + + }, + {4, + 0x00, + 0x40, // ** + 0xc0, // **** + 0x40, // ** + 0x40, // ** + 0x40, // ** + 0x40, // ** + 0xe0, // ****** + }, + {4, + 0x00, + 0x40, // ** + 0xa0, // ** ** + 0x20, // ** + 0x40, // ** + 0x40, // ** + 0x80, // ** + 0xe0, // ****** + }, + /* - ** ** ** **** ** ** ****** **** ****** ** **** -** ** **** ** ** ** ** ** ** ** ** ** ** ** ** -** ** ** ** ** ** ** ** ** ** ** ** ** ** -** ** ** ** ** ****** **** **** ** ** **** -** ** ** ** ** ** ** ** ** ** ** ** ** -** ** ** ** ** ** ** ** ** ** ** ** ** - ** ****** ****** **** ** **** ** ** ** ** +**** ** ** ****** **** ****** + ** ** ** ** ** ** + ** ** ** ** ** ** + ** ****** **** **** ** + ** ** ** ** ** ** + ** ** ** ** ** ** +**** ** **** ** ** */ - {0,0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0,0}, // 56 - {0,0,0,0,0,0,0,0,0}, + + + {4, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + }, + {4,0,0,0,0,0,0,0,0}, + {4,0,0,0,0,0,0,0,0}, + {4,0,0,0,0,0,0,0,0}, + {4,0,0,0,0,0,0,0,0}, + {4, // 56 + 0x00, + 0x40, // ** + 0xa0, // ** ** + 0xa0, // ** ** + 0x40, // ** + 0xa0, // ** ** + 0xa0, // ** ** + 0x40, // ** + }, + {4, + 0x00, + 0x60, // **** + 0xc0, // ** ** + 0xc0, // ** ** + 0x60, // **** + 0x20, // ** + 0x20, // ** + 0x20, // ** + }, {0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0}, @@ -460,13 +518,28 @@ static int rainbow_logo[4][6]={ {0x02,0x62,0x62,0x62,0x02,0x00 }, }; +static int xmas_tree[4][5]={ + {0x00,0x00,0x4d,0x00,0x00 }, + {0x00,0x44,0xd4,0x4d,0x00 }, + {0x40,0x4d,0x44,0x44,0x40 }, + {0x00,0x10,0x18,0x10,0x00 }, +}; + +static int holly[4][9]={ + {0x00,0x00,0x00,0x10,0x11,0x10,0x00,0x00,0x00 }, + {0x00,0xc0,0x4c,0xc1,0x11,0xc1,0x4c,0xc0,0x00 }, + {0xc0,0x4c,0xc4,0xcc,0x00,0xcc,0xc4,0x4c,0xc0 }, + {0xcc,0xc4,0x0c,0x00,0x00,0x00,0x0c,0xc4,0xcc }, +}; + int main(int argc, char **argv) { //char string[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; // char string[]=" \001DEATER \002WAS \003HERE!!! "; // char string[]=" \001BY DEATER... \002A \010 PRODUCTION "; - char string[]=" \003\011APPLE ][ FOREVER\011 "; +// char string[]=" \003\011APPLE ][ FOREVER\011 "; + char string[]=" \012 \001MERRY XMAS 2018 \003FROM DEATER \013 "; int length=0,width=0,x,y,i,j; int color,color1,color2; int which_color=0; @@ -508,6 +581,34 @@ int main(int argc, char **argv) { continue; } + /* christmas tree */ + if (string[i]==10) { + width=5; + for(x=0;xball_hgr -; sta LZ4_SRC+1 + ;============================= + ; set up scrolling -; lda #<(ball_hgr_end-8) ; skip checksum at end -; sta LZ4_END -; lda #>(ball_hgr_end-8) ; skip checksum at end -; sta LZ4_END+1 + lda #0 + sta OFFSET -; lda #<$2000 -; sta LZ4_DST -; lda #>$2000 -; sta LZ4_DST+1 + ;============================= + ; decompress scroll image to $800 + + lda #>a2_scroll + sta INH + lda #scroll_row1 + sta OUTH + +decompress_scroll_loop: + jsr scroll_load_and_increment ; load compressed value + + cmp #$A1 ; EOF marker + beq done_decompress_scroll ; if EOF, exit + + pha ; save + + and #$f0 ; mask + cmp #$a0 ; see if special AX + beq decompress_scroll_special + + pla ; note, PLA sets flags! + + ldx #$1 ; only want to print 1 + bne decompress_scroll_run + +decompress_scroll_special: + pla + + and #$0f ; check if was A0 + + bne decompress_scroll_color ; if A0 need to read run, color + +decompress_scroll_large: + jsr scroll_load_and_increment ; get run length + +decompress_scroll_color: + tax ; put runlen into X + jsr scroll_load_and_increment ; get color + +decompress_scroll_run: + sta (OUTL),Y + pha + + clc ; increment 16-bit pointer + lda OUTL + adc #$1 + sta OUTL + lda OUTH + adc #$0 + sta OUTH + + pla + + dex ; repeat for X times + bne decompress_scroll_run + + beq decompress_scroll_loop ; get next run + +done_decompress_scroll: + rts + + +scroll_load_and_increment: + lda (INL),Y ; load and increment 16-bit pointer + pha + clc + lda INL + adc #$1 + sta INL + lda INH + adc #$0 + sta INH + pla + rts + diff --git a/xmas_2018/greets.inc b/xmas_2018/greets.inc new file mode 100644 index 00000000..618c8309 --- /dev/null +++ b/xmas_2018/greets.inc @@ -0,0 +1,10 @@ +; Original size = 948 bytes +a2_scroll: +; scroll_length: +.byte 237 + .byte $A0,$2E,$00,$4D,$A6,$00,$20,$A3,$00,$20,$00,$A4,$20,$00,$A3,$20,$00,$00,$A3,$20,$00,$00,$20,$00,$20,$A5,$00,$20,$00,$20,$00,$20,$A3,$00,$20,$00,$00,$20,$20,$A3,$00,$A3,$20,$A6,$00,$20,$A3,$00,$20,$A3,$00,$20,$A3,$00,$20,$A6,$00,$A4,$10,$00,$A3,$10,$A3,$00,$10,$10,$00,$00,$10,$A3,$00,$10,$A5,$00,$10,$10,$A3,$00,$A4,$10,$00,$00,$10,$10,$00,$00,$A3,$10,$00,$A4,$10,$00,$A3,$10,$A9,$00,$10,$11,$10,$A0,$42,$00 + .byte $A0,$2D,$00,$44,$D4,$4D,$A5,$00,$E6,$06,$E0,$06,$E6,$00,$E6,$A4,$00,$E6,$00,$00,$E6,$00,$E6,$00,$00,$E6,$00,$E6,$00,$E6,$A5,$00,$E6,$00,$E6,$00,$E6,$06,$E0,$06,$E6,$00,$E6,$00,$00,$E6,$00,$E6,$A8,$00,$06,$00,$E6,$00,$E6,$00,$E6,$00,$06,$E6,$00,$00,$E6,$00,$E6,$A5,$00,$B3,$A4,$00,$B3,$00,$00,$B3,$00,$B3,$00,$00,$B3,$00,$B3,$03,$B0,$03,$B3,$A5,$00,$B3,$00,$03,$B0,$00,$B3,$A4,$00,$B3,$00,$00,$B3,$00,$00,$B3,$00,$00,$B3,$A4,$00,$B3,$00,$00,$B3,$A6,$00,$C0,$4C,$C1,$11,$C1,$4C,$C0,$A0,$40,$00 + .byte $A0,$2C,$00,$40,$4D,$44,$44,$40,$A4,$00,$EF,$A3,$00,$EF,$00,$EF,$0F,$0F,$00,$00,$EF,$0F,$0F,$E0,$00,$EF,$0F,$0F,$E0,$00,$00,$EF,$A6,$00,$E0,$0F,$E0,$00,$EF,$A3,$00,$EF,$00,$EF,$0F,$0F,$EF,$00,$00,$0F,$0F,$E0,$A6,$00,$EF,$00,$00,$EF,$00,$EF,$00,$00,$EF,$00,$00,$E0,$0F,$E0,$A5,$00,$BF,$0F,$0F,$00,$00,$BF,$0F,$0F,$B0,$00,$BF,$00,$00,$BF,$00,$BF,$A3,$00,$BF,$A5,$00,$BF,$00,$00,$BF,$00,$BF,$0F,$0F,$00,$00,$BF,$0F,$0F,$BF,$00,$00,$BF,$00,$00,$BF,$0F,$0F,$00,$00,$BF,$0F,$0F,$B0,$A5,$00,$C0,$4C,$C4,$CC,$00,$CC,$C4,$4C,$C0,$A0,$3F,$00 + .byte $A0,$2D,$00,$10,$18,$10,$A5,$00,$26,$A3,$00,$26,$00,$26,$A3,$20,$00,$26,$00,$00,$26,$00,$26,$00,$00,$26,$00,$00,$26,$A6,$00,$26,$00,$26,$00,$26,$A3,$00,$26,$00,$26,$00,$00,$26,$00,$A3,$20,$06,$A5,$00,$26,$20,$20,$00,$06,$20,$06,$00,$20,$26,$20,$00,$06,$20,$06,$A5,$00,$13,$A4,$00,$13,$00,$00,$13,$00,$03,$10,$10,$03,$00,$13,$A3,$00,$13,$A5,$00,$13,$10,$03,$00,$00,$13,$A3,$10,$00,$13,$00,$00,$13,$00,$00,$13,$00,$00,$13,$A3,$10,$00,$13,$00,$00,$13,$A5,$00,$CC,$C4,$0C,$A3,$00,$0C,$C4,$CC,$A0,$3F,$00 + .byte $A1 +; Compressed size = 484 bytes