xmas2018: scrolling text works

This commit is contained in:
Vince Weaver 2018-12-17 22:58:19 -05:00
parent 4de3183240
commit f70de4c203
5 changed files with 302 additions and 39 deletions

View File

@ -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;x<width;x++) {
for(j=0;j<4;j++) {
row[j][length]=xmas_tree[j][x];
}
length++;
}
continue;
}
/* holly */
if (string[i]==11) {
width=9;
for(x=0;x<width;x++) {
for(j=0;j<4;j++) {
row[j][length]=holly[j][x];
}
length++;
}
continue;
}
width=font[(int)string[i]][0];
for(x=0;x<width;x++) {
for(j=0;j<4;j++) {

View File

@ -27,7 +27,7 @@ xmas2018.o: xmas2018.s \
vapor_lock.s delay_a.s wait_keypress.s \
play_music.s mockingboard.s rts.s \
wreath.s wreath.img.lz4 sprites.inc \
ball.s ball.img.lz4 \
ball.s ball.img.lz4 greets.inc gr_scroll.s \
merry.s merry.img.lz4
ca65 -o xmas2018.o xmas2018.s -l xmas2018.lst

View File

@ -20,24 +20,24 @@ ball:
sta FRAMEH
;=============================
; Load graphic hgr
; ball graphic already loaded to $4000 (HGR page1)
; lda #<ball_hgr
; sta LZ4_SRC
; lda #>ball_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 #<a2_scroll
sta INL
jsr decompress_scroll
; jsr lz4_decode
;==============================
; setup graphics for vapor lock
@ -137,24 +137,29 @@ baloopF:dex ; 2
;======================================================
; do_nothing should be 4550
; -1023 music
; -1841 scroll
; -10 keypress
; ===========
; 4540
; 1676
; jsr play_music ; 6+1032
jsr play_music ; 6+1017
jsr scroll_loop ; 6+1835
; Try X=9 Y=89 cycles=4540
; Try X=1 Y=152 cycles=1673 R3
ldy #89 ; 2
baloop1:ldx #9 ; 2
lda $0 ; nop
ldy #152 ; 2
baloop1:ldx #1 ; 2
baloop2:dex ; 2
bne baloop2 ; 2nt/3
dey ; 2
bne baloop1 ; 2nt/3
; no keypress = 10+(24) = 34
; keypress = 10
lda KEYPRESS ; 4
bpl ba_no_keypress ; 3
@ -168,3 +173,5 @@ ba_handle_keypress:
rts ; 6
.include "gr_scroll.s"
.include "greets.inc"

145
xmas_2018/gr_scroll.s Normal file
View File

@ -0,0 +1,145 @@
scroll_row1 = $800
scroll_row2 = $900
scroll_row3 = $A00
scroll_row4 = $B00
SCROLL_LENGTH = $61
;OFFSET = $62
; 5 + (45*40) +4 + 13 + 7 + 6 = 1835
scroll_loop:
ldx #0 ; 2
ldy OFFSET ; 3
draw_loop:
lda scroll_row1,Y ; 4
sta $650,X ; 5
lda scroll_row2,Y ; 4
sta $6d0,X ; 5
lda scroll_row3,Y ; 4
sta $750,X ; 5
lda scroll_row4,Y ; 4
sta $7d0,X ; 5
iny ; 2
inx ; 2
cpx #40 ; 2
bne draw_loop ; 2nt/3
;===============
; 45
; -1
inc OFFSET ; 5
;============
; 4
;==================
; wrap scrolltext
;==================
clc ; 2
lda OFFSET ; 3
adc #40 ; 2
cmp SCROLL_LENGTH ; 3
bne no_wrap ; 3
;============
; 13
; -1
lda #0 ; 2
sta OFFSET ; 3
jmp done_wrap ; 3
no_wrap:
lda $0 ; 3
nop ; 2
nop ; 2
;===========
; 7
done_wrap:
rts ; 6
;=======================
; decompress scroll
;=======================
decompress_scroll:
ldy #0
jsr scroll_load_and_increment
sta SCROLL_LENGTH
lda #<scroll_row1
sta OUTL
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

10
xmas_2018/greets.inc Normal file
View File

@ -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