mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-01-12 15:30:55 +00:00
xmas2018: make scroller use lz4 compression instead of RLE
saves 300 bytes or so
This commit is contained in:
parent
ee812d3e20
commit
50cc198a02
@ -1,6 +1,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static unsigned char font[256][9]={
|
||||
{0,0,0,0,0,0,0,0,0}, // 0
|
||||
@ -662,5 +664,17 @@ int main(int argc, char **argv) {
|
||||
printf("; Compressed size = %d bytes\n",new_size);
|
||||
|
||||
|
||||
int fd;
|
||||
|
||||
fd=open("scroll.raw",O_CREAT|O_WRONLY,0666);
|
||||
if (fd<0) {
|
||||
fprintf(stderr,"Error opening\n");
|
||||
exit(1);
|
||||
}
|
||||
for(y=0;y<4;y++) {
|
||||
write(fd,&row[y],256);
|
||||
}
|
||||
close(fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -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 greets.inc gr_scroll.s \
|
||||
ball.s ball.img.lz4 greets.raw.lz4 gr_scroll.s \
|
||||
merry.s merry.img.lz4
|
||||
ca65 -o xmas2018.o xmas2018.s -l xmas2018.lst
|
||||
|
||||
|
@ -4,11 +4,15 @@ Memory Map:
|
||||
01 Stack
|
||||
02-03 Reserved
|
||||
04-07 GR PAGE0
|
||||
08-0b GR PAGE1
|
||||
08-0b GR PAGE1 (scroll text)
|
||||
0c-1f CODE (5k)
|
||||
20-3f HGR PAGE0 (wreath)
|
||||
40-5f HGR PAGE1 (ball)
|
||||
60-7f (merry)
|
||||
80-9f (music)
|
||||
a0-bf (staging)
|
||||
a0-bf (music)
|
||||
c0-ff RESERVED/ROM
|
||||
|
||||
SIZE:
|
||||
3903 -- 12/18
|
||||
3647 -- use LZ4 encryption on scroll text
|
||||
|
@ -31,13 +31,25 @@ ball:
|
||||
;=============================
|
||||
; decompress scroll image to $800
|
||||
|
||||
lda #>a2_scroll
|
||||
sta INH
|
||||
lda #<a2_scroll
|
||||
sta INL
|
||||
lda #<greets
|
||||
sta LZ4_SRC
|
||||
lda #>greets
|
||||
sta LZ4_SRC+1
|
||||
|
||||
jsr decompress_scroll
|
||||
lda #<(greets_end-8) ; skip checksum at end
|
||||
sta LZ4_END
|
||||
lda #>(greets_end-8) ; skip checksum at end
|
||||
sta LZ4_END+1
|
||||
|
||||
lda #<$800
|
||||
sta LZ4_DST
|
||||
lda #>$800
|
||||
sta LZ4_DST+1
|
||||
|
||||
jsr lz4_decode
|
||||
|
||||
lda #237
|
||||
sta SCROLL_LENGTH
|
||||
|
||||
;==============================
|
||||
; setup graphics for vapor lock
|
||||
@ -231,4 +243,6 @@ ball_done:
|
||||
|
||||
|
||||
.include "gr_scroll.s"
|
||||
.include "greets.inc"
|
||||
greets:
|
||||
.incbin "greets.raw.lz4",11
|
||||
greets_end:
|
||||
|
@ -63,83 +63,3 @@ no_wrap:
|
||||
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
|
||||
|
||||
|
BIN
xmas_2018/greets.raw.lz4
Normal file
BIN
xmas_2018/greets.raw.lz4
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user