sa: try to encrypt the ascii art

turns out it is too slow, and we can't re-use the lz4 code
without duplicating it completely.
This commit is contained in:
Vince Weaver 2018-05-23 16:04:27 -04:00
parent cf9c367e32
commit e6c001287d
7 changed files with 512 additions and 48 deletions

View File

@ -18,7 +18,7 @@ still_alive.o: still_alive.s \
../asm_routines/lz4_decode.s \
display_art.s display_lyrics.s \
interrupt_handler.s \
ascii_art.inc lyrics.inc zp.inc
ascii_art.inc ascii_art_lz4.inc lyrics.inc zp.inc
ca65 -o still_alive.o still_alive.s -l still_alive.lst
TITLE.BAS: title.bas

View File

@ -13,6 +13,8 @@ add raw ascii art: 9142
add 3-channel music+lyrics,then slim a bit: 18787
initial 40 col support: 18864
have art loading properly 40col: 18910
lz4 encode the ascii art: 15529
revert because lz4 code not re-entrant: 18910

View File

@ -4,7 +4,7 @@ CFLAGS = -O2 -Wall
all: create_lz4_art
create_lz4_art: create_lz4_art.c
$(CC) $(CFLAGS) -o create_lz4_art create_lz4_art.c
$(CC) $(CFLAGS) -o create_lz4_art create_lz4_art.c -llz4
clean:
rm -f *.o *~ *.lz4 create_lz4_art

View File

@ -2,6 +2,10 @@
#include <fcntl.h>
#include <unistd.h>
/* Need liblz4 installed */
#include "lz4.h"
#include "lz4hc.h"
#define NUM_FILES 10
static char art_files[NUM_FILES][20]={
@ -33,10 +37,30 @@ static char art_names[NUM_FILES][20]={
#define MAX_SIZE 1024
static unsigned char buffer[MAX_SIZE];
static unsigned char compressed_buffer[MAX_SIZE];
static void dump_asm(char *name,int size,unsigned char *buffer) {
int j;
printf("%s:\n",name);
for(j=0;j<size+1;j++) {
if (j%16==0) {
printf("\n\t.byte $%02X",buffer[j]);
}
else {
printf(",$%02X",buffer[j]);
}
}
printf("\n");
}
int main(int argc, char **argv) {
int i,j,fd,size,original_size=0,compressed_size=0;
int i,j,fd,size,total_size=0,compressed_size=0,total_compressed=0;
printf("ascii_art:\n");
for(i=0;i<NUM_FILES;i++) {
@ -56,32 +80,37 @@ int main(int argc, char **argv) {
if (size<0) {
fprintf(stderr,"Error reading %s\n",art_files[i]);
}
original_size+=size;
total_size+=size;
/* Conver to Apple II ASCII */
/* Convert to Apple II ASCII */
for(j=0;j<size;j++) {
if (buffer[j]=='\n') buffer[j]=13;
buffer[j]=buffer[j]|0x80;
}
buffer[j]=0;
fprintf(stderr,"%s %d\n",art_files[i],size);
compressed_size=LZ4_compress_HC ((char *)buffer,
(char *)compressed_buffer,
size,
MAX_SIZE,
16);
if (compressed_size>MAX_SIZE) {
fprintf(stderr,"Error! Compressed data too big!\n");
}
total_compressed+=compressed_size;
fprintf(stderr,"%s %d %d\n",art_files[i],size,compressed_size);
close(fd);
printf("%s:\n",art_names[i]);
for(j=0;j<size+1;j++) {
if (j%16==0) {
printf("\n\t.byte $%02X",buffer[j]);
}
else {
printf(",$%02X",buffer[j]);
}
}
printf("\n");
dump_asm(art_names[i],compressed_size,compressed_buffer);
}
fprintf(stderr,"Total original: %d\n",original_size);
fprintf(stderr,"Total compressed: %d\n",compressed_size);
fprintf(stderr,"Total original: %d\n",total_size);
fprintf(stderr,"Total compressed: %d\n",total_compressed);
return 0;

View File

@ -0,0 +1,264 @@
ascii_art:
.byte <aperture,>aperture
.byte <radioactive,>radioactive
.byte <atom,>atom
.byte <broken_heart,>broken_heart
.byte <explosion,>explosion
.byte <fire,>fire
.byte <check,>check
.byte <black_mesa,>black_mesa
.byte <cake,>cake
.byte <glados,>glados
aperture:
.byte $19,$A0,$01,$00,$C7,$AE,$AC,$AD,$BA,$BB,$AF,$AF,$BB,$BA,$BD,$AC
.byte $8D,$16,$00,$F5,$03,$A0,$BA,$C8,$C0,$C0,$C0,$CD,$CD,$C0,$CD,$A3
.byte $C8,$AF,$AE,$AC,$AB,$A5,$BB,$1F,$00,$F3,$0A,$AC,$AF,$D8,$AB,$A0
.byte $AB,$CD,$C0,$C0,$CD,$C0,$CD,$CD,$A5,$BD,$AC,$AD,$A5,$C8,$CD,$CD
.byte $CD,$C0,$D8,$AF,$22,$00,$80,$AD,$AB,$C0,$CD,$CD,$BB,$A0,$A4,$22
.byte $00,$70,$C8,$AB,$AD,$AC,$BB,$D8,$CD,$20,$00,$01,$05,$00,$21,$AB
.byte $AD,$24,$00,$20,$BB,$C0,$1D,$00,$C0,$AD,$A0,$D8,$CD,$C0,$D8,$BB
.byte $AE,$A0,$AD,$AB,$D8,$01,$00,$30,$C8,$C8,$C8,$54,$00,$A1,$A3,$C0
.byte $AF,$AE,$8D,$A0,$A0,$AC,$A5,$CD,$42,$00,$59,$A0,$AC,$C0,$A5,$BD
.byte $B2,$00,$90,$AD,$AD,$AD,$BD,$AD,$BD,$BA,$BD,$AC,$27,$00,$30,$BD
.byte $C0,$A3,$A9,$00,$4A,$D8,$A0,$AE,$AC,$D9,$00,$F0,$02,$AD,$A5,$C8
.byte $D8,$A4,$A4,$A5,$A5,$A5,$AB,$BB,$8D,$A0,$BD,$AD,$AE,$AF,$5C,$00
.byte $2D,$A4,$A0,$01,$00,$33,$AE,$BB,$C0,$A0,$00,$DF,$BA,$8D,$A0,$D8
.byte $C0,$AF,$A0,$AD,$A4,$CD,$CD,$AF,$A0,$01,$00,$00,$20,$AE,$AB,$92
.byte $00,$EF,$C0,$CD,$A4,$8D,$AC,$C0,$CD,$C0,$C8,$BA,$A0,$BA,$C0,$BA
.byte $28,$00,$02,$30,$A0,$BD,$D8,$95,$00,$41,$C0,$AD,$8D,$AC,$45,$01
.byte $4F,$D8,$AC,$A0,$AE,$29,$00,$01,$31,$AF,$C8,$AD,$0B,$01,$40,$CD
.byte $BD,$8D,$AE,$6F,$01,$5F,$C0,$CD,$C0,$AB,$AC,$29,$00,$01,$D3,$A5
.byte $CD,$CD,$AB,$AE,$AE,$A5,$A3,$A4,$AE,$8D,$A0,$AF,$AE,$00,$2F,$C8
.byte $AF,$54,$00,$00,$FA,$08,$D8,$CD,$C0,$CD,$C8,$BB,$A0,$BD,$BB,$8D
.byte $A0,$A0,$AF,$A5,$AB,$A5,$A4,$D8,$C8,$C8,$C0,$A4,$BD,$25,$00,$23
.byte $AC,$A0,$6E,$00,$11,$D8,$B2,$01,$33,$AE,$BD,$AD,$01,$00,$1A,$AE
.byte $3F,$01,$38,$AE,$AC,$C0,$27,$00,$01,$90,$01,$F0,$06,$C0,$C8,$C8
.byte $C8,$D8,$D8,$A4,$A4,$A4,$A5,$AB,$AD,$A0,$AE,$BA,$A4,$CD,$CD,$D8
.byte $A0,$BD,$A8,$01,$32,$CD,$A5,$AE,$FF,$01,$22,$BD,$D8,$A0,$00,$A0
.byte $C0,$CD,$CD,$A3,$C8,$BB,$AC,$AD,$AB,$C8,$0C,$00,$11,$AB,$B8,$00
.byte $24,$D8,$BD,$45,$02,$22,$BD,$A5,$EB,$01,$62,$A4,$AD,$AE,$BD,$A4
.byte $C0,$58,$01,$76,$BB,$A0,$A5,$CD,$A5,$BD,$8D,$A8,$00,$A2,$BA,$AB
.byte $A4,$AB,$AD,$AC,$AF,$C8,$A3,$CD,$01,$00,$39,$C0,$BD,$A0,$A6,$02
.byte $02,$4A,$00,$C0,$AB,$AB,$A5,$A5,$A5,$A5,$AB,$AF,$BA,$AD,$AE,$8D
.byte $00
radioactive:
.byte $18,$A0,$01,$00,$F6,$00,$BD,$AB,$A4,$C8,$CD,$A3,$A3,$A3,$A3,$C0
.byte $C8,$A5,$BB,$AC,$8D,$19,$00,$3A,$AF,$C8,$A3,$01,$00,$28,$CD,$A4
.byte $1F,$00,$2B,$AC,$C0,$1F,$00,$27,$A3,$AB,$1E,$00,$3F,$A0,$AE,$C8
.byte $1D,$00,$08,$38,$A0,$A0,$D8,$1C,$00,$1A,$AF,$1C,$00,$2F,$A0,$A4
.byte $1B,$00,$07,$2F,$A0,$A5,$1A,$00,$06,$AD,$A0,$AF,$D8,$AF,$BB,$BB
.byte $AB,$D8,$AF,$8D,$1A,$00,$7D,$A0,$AD,$D8,$C8,$C8,$D8,$AD,$18,$00
.byte $12,$AC,$4B,$00,$29,$AC,$8D,$AB,$00,$41,$D8,$A0,$A0,$AE,$12,$01
.byte $2B,$CD,$AE,$A9,$00,$1A,$A3,$29,$00,$20,$A3,$AD,$5B,$00,$21,$AF
.byte $AF,$07,$00,$0A,$1A,$00,$1A,$8D,$38,$00,$33,$A3,$A5,$AC,$72,$00
.byte $1A,$AB,$18,$00,$2B,$D8,$8D,$39,$00,$1F,$D8,$22,$01,$02,$69,$A3
.byte $A3,$AD,$8D,$A0,$A5,$51,$00,$0F,$13,$01,$00,$01,$18,$00,$19,$8D
.byte $11,$00,$18,$BB,$EF,$00,$1A,$BB,$27,$00,$05,$10,$00,$2A,$CD,$BD
.byte $17,$01,$24,$BD,$CD,$3E,$00,$01,$32,$01,$20,$AE,$AB,$10,$00,$2D
.byte $C0,$AC,$3E,$01,$00,$02,$02,$34,$CD,$AB,$AE,$57,$01,$4D,$BA,$D8
.byte $C8,$AE,$7A,$01,$60,$A0,$AE,$C8,$D8,$BA,$8D,$BA
atom:
.byte $1C,$A0,$01,$00,$7C,$BD,$AF,$BB,$BB,$AF,$AD,$8D,$17,$00,$20,$AB
.byte $BA,$06,$00,$2C,$AF,$AF,$19,$00,$24,$AF,$BB,$08,$00,$0B,$1A,$00
.byte $24,$AD,$D8,$0A,$00,$F4,$04,$C8,$AE,$8D,$AE,$AF,$AF,$BB,$BB,$BB
.byte $BA,$BB,$BB,$AD,$AC,$A0,$A0,$A0,$D8,$BD,$1B,$00,$F3,$04,$BA,$AB
.byte $A0,$A0,$A0,$AE,$AD,$BB,$BA,$BD,$BB,$BA,$BB,$A5,$BB,$AE,$8D,$CD
.byte $AD,$1A,$00,$83,$AC,$BD,$BB,$BB,$BB,$A3,$BA,$AC,$0E,$00,$74,$BA
.byte $A3,$BB,$BB,$BA,$BD,$AC,$1D,$00,$47,$C0,$8D,$BA,$A5,$6C,$00,$E7
.byte $BA,$A5,$AE,$BD,$AF,$AB,$AB,$AB,$AB,$AF,$BD,$AE,$A4,$BD,$19,$00
.byte $76,$A5,$BD,$8D,$A0,$AC,$A5,$BB,$10,$00,$D5,$AF,$BA,$AB,$AF,$BB
.byte $AC,$AC,$AF,$AB,$AB,$BA,$AB,$AF,$17,$00,$30,$BB,$AB,$AE,$BE,$00
.byte $41,$AC,$AB,$AF,$AE,$5F,$00,$34,$BB,$C0,$AB,$6B,$00,$51,$A0,$AC
.byte $A5,$C8,$BB,$0D,$00,$54,$AC,$AF,$AB,$AC,$8D,$30,$00,$E2,$BB,$BB
.byte $AF,$BD,$A0,$C0,$AE,$A0,$A0,$AE,$C8,$A3,$A3,$D8,$EF,$00,$65,$BA
.byte $AF,$AF,$AF,$AB,$BB,$23,$00,$00,$C1,$00,$F0,$00,$AE,$C0,$AC,$A0
.byte $A0,$AE,$D8,$CD,$C0,$A4,$AE,$A0,$A0,$BD,$D8,$07,$01,$32,$BD,$A5
.byte $AF,$6D,$00,$23,$BB,$BA,$BD,$00,$25,$C0,$A5,$B3,$00,$32,$BD,$A4
.byte $C8,$16,$00,$40,$AE,$AB,$A5,$AD,$BB,$00,$06,$CD,$00,$D6,$A5,$BB
.byte $AD,$AF,$AF,$AF,$BD,$BD,$AF,$AF,$AF,$AD,$AF,$BB,$00,$69,$BD,$A5
.byte $AC,$8D,$BB,$AB,$0C,$01,$12,$AD,$6B,$01,$59,$BB,$BB,$AD,$D8,$AD
.byte $C2,$01,$23,$8D,$C0,$10,$00,$10,$AE,$23,$00,$15,$BB,$6C,$01,$30
.byte $A0,$BD,$CD,$9F,$01,$24,$AD,$AE,$BA,$01,$74,$8D,$A0,$BA,$BB,$BB
.byte $BA,$BA,$13,$00,$29,$A5,$AD,$B0,$01,$50,$A0,$AC,$AD,$BB,$BB,$B4
.byte $01,$1B,$BD,$F3,$01,$18,$AC,$F3,$01,$0B,$28,$02,$26,$BB,$AF,$92
.byte $01,$0C,$43,$02,$01,$1B,$00,$2D,$AB,$BB,$19,$00,$80,$A0,$AC,$AF
.byte $AF,$AF,$AF,$AC,$8D,$CD
broken_heart:
.byte $1F,$A0,$01,$00,$06,$7F,$AE,$AC,$AD,$AD,$AD,$AE,$8D,$1F,$00,$05
.byte $BF,$AC,$AF,$D8,$CD,$A3,$CD,$CD,$CD,$D8,$BB,$AC,$24,$00,$04,$35
.byte $AD,$A5,$A3,$01,$00,$2F,$CD,$A5,$26,$00,$04,$22,$AD,$C0,$21,$00
.byte $A6,$A5,$A0,$A0,$A4,$A3,$A3,$A3,$C0,$BD,$8D,$7E,$00,$16,$AC,$26
.byte $00,$13,$C8,$48,$00,$22,$A4,$A0,$28,$00,$20,$CD,$BA,$28,$00,$40
.byte $AC,$BB,$A4,$CD,$0D,$00,$32,$CD,$D8,$BB,$35,$00,$16,$BB,$72,$00
.byte $30,$A4,$BB,$C8,$1C,$00,$76,$D8,$BD,$8D,$A0,$AC,$AF,$C0,$18,$00
.byte $22,$C8,$BD,$53,$00,$2B,$BB,$A3,$01,$00,$49,$AB,$8D,$AD,$AB,$11
.byte $00,$23,$CD,$AF,$81,$00,$1C,$A5,$29,$00,$2B,$A5,$CD,$3C,$00,$03
.byte $54,$00,$1A,$AF,$16,$00,$3C,$BA,$8D,$C8,$65,$00,$03,$DD,$00,$0A
.byte $40,$00,$4B,$BB,$AE,$8D,$C0,$28,$00,$13,$CD,$65,$01,$08,$18,$00
.byte $5C,$CD,$BA,$AE,$8D,$D8,$51,$00,$03,$A3,$00,$34,$AD,$A4,$BD,$1B
.byte $00,$38,$C0,$BA,$8D,$F0,$00,$04,$01,$00,$21,$A5,$AD,$29,$00,$03
.byte $E3,$00,$5E,$A4,$AD,$8D,$AE,$BB,$25,$00,$12,$D8,$9F,$00,$02,$4B
.byte $00,$6D,$AB,$AC,$8D,$A0,$AE,$BB,$C3,$00,$12,$AF,$71,$00,$01,$24
.byte $00,$22,$AB,$AE,$87,$01,$1F,$D8,$95,$00,$02,$53,$A0,$AE,$CD,$CD
.byte $AF,$D0,$01,$64,$AC,$BA,$AB,$A4,$C8,$C0,$F8,$00,$31,$CD,$A3,$A4
.byte $8F,$00,$5A,$AE,$A4,$A4,$BD,$8D,$74,$02,$40,$BD,$BB,$AB,$A4,$BF
.byte $00,$21,$D8,$BA,$A6,$01,$2F,$AF,$BD,$83,$02,$01,$50,$AE,$AC,$AF
.byte $D8,$A4,$F4,$01,$3F,$AE,$BA,$BA,$7F,$02,$05,$90,$AE,$AC,$A0,$A0
.byte $A0,$A0,$AE,$AE,$8D,$24
explosion:
.byte $17,$A0,$01,$00,$38,$AE,$AB,$8D,$0F,$00,$4A,$A0,$AF,$CD,$BB,$11
.byte $00,$5A,$A0,$C8,$A3,$C0,$BA,$12,$00,$2B,$BB,$AC,$23,$00,$67,$AD
.byte $A3,$A3,$A3,$C8,$AD,$10,$00,$2B,$C0,$AF,$22,$00,$FC,$03,$A0,$A5
.byte $A3,$A3,$A3,$A3,$A4,$AE,$A0,$A0,$AD,$BB,$A0,$A0,$AE,$A5,$A3,$D8
.byte $21,$00,$20,$A0,$CD,$22,$00,$E8,$A3,$AB,$BB,$A3,$C8,$A0,$BA,$CD
.byte $A3,$CD,$AE,$8D,$AE,$AE,$A7,$00,$44,$AF,$BB,$A5,$A3,$01,$00,$F0
.byte $01,$D8,$A3,$A3,$A3,$AD,$8D,$A0,$AD,$AF,$A5,$C8,$A5,$AB,$BB,$AD
.byte $AC,$22,$00,$29,$AB,$A3,$01,$00,$02,$81,$00,$30,$AE,$BA,$A4,$57
.byte $00,$49,$CD,$C8,$A4,$A5,$20,$00,$95,$D8,$A0,$A0,$AC,$AD,$AD,$BD
.byte $BB,$AD,$86,$00,$4F,$AD,$AF,$C8,$A3,$01,$00,$01,$59,$C8,$AB,$BD
.byte $AE,$8D,$30,$01,$0D,$23,$00,$17,$D8,$21,$00,$3F,$BD,$A5,$CD,$46
.byte $00,$02,$19,$BB,$45,$00,$3B,$A0,$AF,$C0,$21,$00,$68,$AB,$BB,$BB
.byte $AF,$A5,$A5,$59,$01,$2F,$AD,$A5,$48,$00,$00,$15,$A4,$47,$00,$1F
.byte $BB,$AF,$00,$03,$31,$A3,$CD,$BD,$22,$00,$12,$AC,$3E,$00,$00,$F9
.byte $00,$12,$BB,$B2,$00,$00,$98,$00,$12,$AD,$78,$00,$60,$A5,$8D,$A0
.byte $A0,$BA,$A4,$3B,$01,$26,$BD,$AD,$C1,$01,$60,$A3,$D8,$AE,$AC,$C8
.byte $A3,$0D,$00,$9A,$AB,$CD,$A3,$A3,$C0,$AD,$8D,$A0,$AE,$A1,$01,$51
.byte $AC,$A3,$A3,$A3,$BB,$7C,$00,$03,$EC,$00,$4D,$A4,$A3,$A3,$AB,$C7
.byte $01,$4B,$AE,$A3,$C8,$AC,$13,$00,$4D,$BA,$D8,$C8,$AC,$28,$00,$2D
.byte $A0,$AB,$12,$00,$60,$A0,$A0,$AE,$BB,$AD,$8D,$90
fire:
.byte $1F,$A0,$01,$00,$01,$4F,$AD,$A4,$AD,$8D,$18,$00,$01,$6F,$AE,$C8
.byte $A3,$A3,$C8,$AC,$1B,$00,$01,$21,$AB,$A3,$01,$00,$1D,$AB,$1C,$00
.byte $34,$AE,$AB,$A3,$01,$00,$3C,$C8,$AE,$8D,$67,$00,$17,$A3,$01,$00
.byte $1A,$C0,$1F,$00,$3A,$BD,$C8,$A3,$01,$00,$67,$C0,$A0,$A0,$AD,$D8
.byte $BA,$24,$00,$3D,$AE,$A4,$A3,$01,$00,$63,$BA,$A0,$A0,$C0,$A3,$C0
.byte $BE,$00,$6E,$AC,$BB,$A0,$A0,$AE,$CD,$25,$00,$40,$A3,$BB,$A0,$A0
.byte $5E,$00,$10,$BB,$27,$00,$22,$BB,$C0,$35,$00,$0E,$01,$00,$42,$C0
.byte $A0,$A0,$AC,$55,$00,$30,$8D,$A0,$AD,$47,$00,$3E,$AE,$A0,$A0,$4E
.byte $00,$53,$C0,$AE,$A0,$A0,$BB,$E1,$00,$12,$8D,$20,$00,$15,$AD,$10
.byte $01,$05,$26,$00,$10,$A4,$D2,$00,$04,$65,$00,$44,$D8,$8D,$A0,$C8
.byte $15,$00,$18,$AD,$52,$00,$55,$AB,$A0,$A0,$A0,$BA,$0E,$00,$10,$CD
.byte $6A,$01,$11,$AF,$31,$00,$10,$AD,$3F,$00,$04,$18,$00,$10,$A5,$26
.byte $00,$05,$37,$00,$22,$C0,$AF,$38,$01,$74,$AC,$BB,$A5,$C8,$C0,$D8
.byte $BB,$18,$01,$12,$D8,$4B,$00,$7F,$CD,$CD,$C0,$A5,$AB,$BB,$BA,$CF
.byte $01,$00,$10,$AE,$37,$00,$7A,$AD,$AF,$BB,$BA,$AD,$AC,$AE,$1A,$00
.byte $65,$AC,$AC,$AD,$BD,$BD,$AB,$61,$00,$4F,$C8,$8D,$A0,$AD,$1D,$01
.byte $00,$E2,$C8,$D8,$A5,$A5,$AB,$A5,$A5,$A4,$A5,$A5,$A5,$AB,$BA,$AC
.byte $15,$02,$52,$AE,$AD,$AF,$C8,$A5,$17,$00,$1C,$C8,$52,$01,$E2,$CD
.byte $C0,$AB,$BD,$BA,$AF,$AB,$BA,$8D,$AF,$D8,$C8,$D8,$A5,$E6,$00,$41
.byte $CD,$C8,$A5,$BD,$72,$00,$F0,$00,$AD,$AD,$AD,$BA,$BB,$BB,$BB,$BB
.byte $AF,$A5,$A5,$D8,$C8,$CD,$AC,$1E,$00,$DF,$A4,$8D,$A4,$C0,$A3,$CD
.byte $D8,$A0,$A5,$AB,$BB,$AD,$A0,$01,$00,$04,$50,$A0,$A0,$A0,$AE,$8D
.byte $01
check:
.byte $1F,$A0,$01,$00,$11,$4F,$BA,$D8,$AD,$8D,$26,$00,$11,$3F,$A3,$A3
.byte $A3,$28,$00,$0E,$7F,$BB,$C0,$A3,$A3,$A3,$A3,$C0,$28,$00,$0C,$31
.byte $BB,$CD,$A3,$01,$00,$1F,$D8,$28,$00,$0A,$33,$AD,$C0,$A3,$01,$00
.byte $1F,$A4,$28,$00,$08,$24,$AE,$A4,$26,$00,$0F,$78,$00,$0A,$37,$BD
.byte $CD,$A3,$01,$00,$0F,$F1,$00,$07,$18,$AB,$27,$00,$0F,$7A,$00,$07
.byte $29,$AE,$C8,$26,$00,$26,$BD,$AE,$28,$00,$36,$AC,$AF,$BA,$0C,$00
.byte $07,$76,$00,$24,$CD,$BB,$25,$00,$20,$AD,$AB,$DA,$00,$14,$BB,$9A
.byte $00,$08,$23,$00,$00,$22,$00,$24,$BD,$A5,$36,$00,$02,$23,$00,$16
.byte $BA,$20,$00,$48,$AF,$8D,$AD,$A4,$C9,$00,$19,$BB,$1F,$00,$69,$AF
.byte $8D,$A0,$AC,$BB,$D8,$1F,$00,$05,$5D,$00,$13,$A4,$7D,$00,$16,$BB
.byte $B9,$00,$04,$EB,$00,$24,$CD,$BD,$BD,$00,$1B,$AC,$FE,$00,$17,$AB
.byte $FE,$00,$16,$AF,$78,$00,$3F,$C0,$AD,$8D,$CE,$01,$01,$2F,$A5,$8D
.byte $4B,$01,$00,$1C,$BA,$41,$01,$50,$AC,$A4,$CD,$AD,$8D,$C8
black_mesa:
.byte $16,$A0,$01,$00,$71,$AE,$AD,$BB,$AB,$A4,$D8,$C8,$01,$00,$74,$D8
.byte $A4,$AB,$BB,$AD,$AE,$8D,$1B,$00,$F0,$03,$AC,$BB,$D8,$C0,$C0,$D8
.byte $A5,$AF,$BB,$BD,$AD,$AD,$AD,$AD,$BD,$BA,$AF,$A5,$10,$00,$23,$AF
.byte $AC,$21,$00,$89,$BD,$A4,$C0,$C0,$A5,$BD,$AE,$A0,$01,$00,$71,$AE
.byte $BD,$AB,$C8,$C0,$D8,$BA,$23,$00,$6F,$AD,$D8,$CD,$D8,$BA,$A0,$01
.byte $00,$02,$50,$BD,$D8,$CD,$D8,$BD,$25,$00,$5F,$AF,$C0,$C0,$BA,$A0
.byte $01,$00,$06,$CF,$BD,$C8,$C0,$AB,$8D,$A0,$A0,$A5,$C0,$D8,$AC,$A0
.byte $01,$00,$08,$BF,$AE,$A4,$C0,$A4,$8D,$A0,$AB,$C0,$D8,$AE,$A0,$01
.byte $00,$0B,$9F,$A4,$C0,$A5,$8D,$AD,$C0,$C0,$AC,$A0,$01,$00,$0C,$9F
.byte $AE,$C0,$C0,$BD,$8D,$A5,$C0,$A5,$A0,$01,$00,$0E,$7F,$AB,$C0,$A4
.byte $8D,$C8,$C0,$BA,$29,$00,$0F,$39,$BA,$C0,$C8,$29,$00,$2D,$BA,$C8
.byte $01,$00,$02,$E5,$00,$39,$BD,$C0,$C8,$7B,$00,$4C,$BB,$C0,$CD,$C0
.byte $01,$00,$23,$C8,$AD,$7B,$00,$17,$BD,$CD,$00,$2F,$BA,$C0,$01,$00
.byte $01,$10,$BD,$CD,$00,$11,$BA,$1E,$01,$0F,$29,$00,$05,$03,$60,$00
.byte $50,$BA,$A5,$C0,$A5,$8D,$24,$01,$24,$A4,$AC,$7A,$00,$1F,$C0,$2A
.byte $00,$03,$11,$A4,$24,$02,$33,$AB,$C0,$C0,$B9,$00,$1F,$C0,$01,$00
.byte $03,$22,$AB,$8D,$EB,$01,$1F,$C0,$01,$00,$08,$02,$06,$02,$00,$95
.byte $00,$3F,$A4,$C0,$C0,$70,$00,$03,$27,$A4,$BA,$92,$02,$0F,$26,$00
.byte $00,$4D,$D8,$AF,$AD,$8D,$D1,$02,$02,$D2,$02,$70,$D8,$A4,$AB,$BB
.byte $AD,$AE,$8D,$BD
cake:
.byte $17,$A0,$01,$00,$78,$AC,$BA,$AF,$AB,$AF,$AD,$8D,$13,$00,$49,$AF
.byte $CD,$AF,$A0,$01,$00,$85,$AE,$AC,$AD,$BD,$BB,$AF,$AF,$BB,$27,$00
.byte $A1,$AE,$BA,$AF,$BD,$A0,$BB,$CD,$C8,$AF,$AC,$43,$00,$D3,$BD,$AF
.byte $AB,$A5,$A4,$D8,$C8,$C0,$CD,$CD,$A3,$C0,$BA,$24,$00,$B0,$AD,$A4
.byte $A3,$A3,$C0,$AB,$A4,$A3,$A3,$A3,$C0,$19,$00,$22,$CD,$A3,$01,$00
.byte $31,$C8,$BA,$AE,$1E,$00,$D2,$AF,$C8,$A3,$8D,$A0,$AE,$AC,$C8,$C0
.byte $C8,$C0,$A0,$D8,$1B,$00,$42,$C0,$A0,$AD,$C8,$09,$00,$22,$AB,$AD
.byte $43,$00,$10,$AB,$10,$00,$30,$C0,$D8,$8D,$82,$00,$52,$C0,$A3,$A3
.byte $C8,$BB,$5B,$00,$62,$AB,$D8,$CD,$A3,$A3,$CD,$7C,$00,$41,$A0,$BD
.byte $A5,$C0,$25,$00,$B5,$BB,$AD,$8D,$D8,$A5,$AD,$A0,$A0,$BA,$CD,$A3
.byte $01,$00,$22,$A4,$AE,$AD,$00,$10,$A5,$14,$00,$80,$C0,$A5,$BA,$8D
.byte $CD,$A3,$A3,$C8,$37,$00,$E2,$AB,$C8,$C0,$C0,$C0,$A4,$AF,$AD,$AE
.byte $A0,$A0,$AC,$BB,$A4,$1E,$00,$16,$AC,$F0,$00,$21,$AD,$8D,$45,$00
.byte $C1,$CD,$BD,$AC,$AC,$AD,$AD,$AD,$AC,$AE,$AD,$A5,$A5,$9A,$00,$37
.byte $CD,$A4,$BA,$39,$01,$7D,$AB,$C0,$A3,$A3,$8D,$C0,$A3,$01,$00,$35
.byte $C0,$AF,$AE,$25,$00,$10,$BA,$39,$00,$23,$C0,$A4,$51,$00,$07,$25
.byte $00,$16,$C8,$6F,$00,$20,$BB,$C8,$CF,$00,$3D,$A4,$BD,$8D,$4A,$00
.byte $02,$BF,$00,$2F,$BD,$A4,$20,$00,$04,$52,$C8,$AE,$AE,$BB,$D8,$1C
.byte $00,$07,$AC,$01,$2D,$BA,$AB,$6D,$00,$01,$96,$00,$17,$A5,$25,$00
.byte $7E,$A0,$BD,$AB,$C0,$CD,$C8,$A5,$BE,$00,$38,$CD,$AF,$AE,$25,$00
.byte $8B,$C8,$A3,$D8,$A5,$BD,$8D,$BD,$AB,$51,$00,$14,$CD,$BD,$00,$80
.byte $AD,$AF,$D8,$A3,$D8,$AB,$BB,$AE,$A2,$01,$27,$BB,$D8,$26,$00,$11
.byte $C8,$6D,$00,$82,$AC,$AF,$D8,$A3,$C8,$AB,$BA,$AC,$13,$02,$43,$AE
.byte $BD,$AB,$C8,$23,$00,$B8,$CD,$AB,$AF,$AB,$C8,$CD,$C0,$AB,$BD,$AE
.byte $8D,$89,$02,$12,$A5,$43,$00,$27,$C8,$AF,$17,$00,$C0,$A0,$A0,$A0
.byte $A0,$A0,$AC,$AE,$BA,$BD,$AD,$AE,$8D,$C8
glados:
.byte $12,$A0,$01,$00,$43,$A3,$AB,$A0,$C0,$0A,$00,$39,$A0,$A3,$A0,$01
.byte $00,$60,$CD,$A3,$C0,$8D,$A0,$AE,$0A,$00,$B2,$AE,$D8,$A0,$A0,$D8
.byte $AE,$A5,$A3,$A3,$C0,$BB,$26,$00,$32,$AB,$C0,$A3,$01,$00,$D0,$D8
.byte $AE,$A0,$C0,$A3,$A5,$8D,$A0,$A0,$A0,$AC,$BD,$BD,$2C,$00,$12,$AC
.byte $18,$00,$51,$CD,$AB,$A0,$A0,$AD,$0A,$00,$21,$A5,$CD,$10,$00,$11
.byte $AD,$63,$00,$F1,$07,$8D,$A0,$A0,$BA,$C8,$A3,$A3,$CD,$A5,$BA,$BD
.byte $A3,$A3,$AB,$A0,$AE,$CD,$A3,$A3,$CD,$AC,$BB,$28,$00,$23,$AF,$AB
.byte $53,$00,$61,$A5,$A0,$AC,$CD,$A3,$8D,$1C,$00,$02,$01,$00,$92,$BD
.byte $A0,$A0,$BD,$C0,$A3,$C0,$AE,$BD,$5A,$00,$26,$BD,$CD,$18,$00,$90
.byte $D8,$A3,$8D,$A0,$BA,$C0,$C0,$CD,$CD,$49,$00,$11,$AE,$73,$00,$23
.byte $CD,$AE,$83,$00,$14,$A3,$28,$00,$79,$AE,$A0,$BD,$A0,$A0,$CD,$8D
.byte $DC,$00,$92,$C0,$A3,$A3,$AE,$AE,$A3,$A3,$A3,$BA,$E0,$00,$12,$C8
.byte $28,$00,$50,$C0,$C0,$A0,$D8,$AC,$29,$00,$17,$A3,$01,$00,$10,$BA
.byte $0E,$00,$20,$AC,$AF,$0B,$00,$40,$BB,$A0,$A0,$AF,$78,$00,$3A,$C0
.byte $A3,$AE,$51,$00,$F0,$02,$AC,$CD,$A3,$A3,$A0,$BB,$A3,$A3,$AC,$C0
.byte $A3,$CD,$BB,$AF,$CD,$A3,$CD,$62,$00,$40,$A0,$D8,$A3,$A5,$A2,$00
.byte $35,$AE,$A5,$BD,$53,$00,$00,$28,$00,$60,$A3,$A3,$AE,$CD,$A3,$BA
.byte $77,$00,$70,$AF,$A3,$CD,$A0,$AC,$CD,$A0,$06,$00,$65,$A3,$A4,$8D
.byte $A3,$A3,$AF,$51,$00,$10,$A4,$28,$00,$22,$AB,$BB,$7D,$00,$00,$5B
.byte $00,$60,$AF,$A0,$CD,$A0,$CD,$AD,$56,$00,$A1,$BA,$8D,$A3,$AB,$A0
.byte $A3,$CD,$C0,$CD,$CD,$58,$01,$F1,$0A,$BB,$CD,$A0,$A3,$BA,$A4,$A3
.byte $AD,$A3,$A3,$A4,$C8,$A3,$A0,$AE,$A3,$D8,$A0,$C0,$A0,$AB,$A0,$A4
.byte $A3,$AE,$6E,$01,$15,$A0,$7A,$00,$F0,$05,$AF,$AE,$BA,$A0,$A3,$A5
.byte $BD,$A3,$A0,$CD,$A3,$BA,$CD,$CD,$AE,$AF,$A3,$AE,$AD,$A3,$A6,$00
.byte $92,$BA,$A0,$C8,$A3,$8D,$AB,$AC,$AE,$BD,$16,$01,$A0,$A3,$BA,$A0
.byte $AF,$C0,$A0,$A5,$A3,$AC,$C0,$39,$00,$90,$C0,$D8,$A0,$A3,$AC,$AD
.byte $A3,$C0,$AE,$97,$01,$41,$AE,$C0,$A3,$8D,$4B,$00,$30,$AB,$BB,$AF
.byte $AC,$00,$21,$C0,$A3,$41,$00,$23,$AC,$AB,$B4,$00,$00,$CE,$00,$00
.byte $D6,$00,$03,$44,$01,$11,$BB,$EF,$00,$20,$C0,$A0,$A7,$00,$33,$C8
.byte $A0,$AE,$03,$02,$00,$21,$02,$70,$CD,$A0,$A0,$BB,$C0,$C0,$BB,$99
.byte $00,$00,$29,$00,$20,$AE,$CD,$17,$01,$11,$C8,$31,$00,$44,$A3,$D8
.byte $A0,$AC,$5C,$02,$40,$CD,$AF,$A0,$AD,$3D,$00,$72,$A4,$A0,$A0,$AD
.byte $C8,$8D,$A0,$2A,$00,$00,$89,$00,$31,$A0,$D8,$A3,$54,$00,$20,$A0
.byte $AE,$FB,$01,$20,$C0,$BB,$4F,$00,$33,$A3,$CD,$C0,$EF,$00,$12,$C8
.byte $87,$00,$11,$AF,$47,$00,$03,$52,$01,$B1,$AC,$AB,$AB,$AE,$A0,$A0
.byte $AF,$A0,$BD,$BD,$AD,$9C,$00,$08,$01,$00,$F0,$0B,$AC,$BD,$AF,$BA
.byte $AC,$A0,$AE,$AB,$D8,$C0,$CD,$CD,$C8,$C0,$A3,$C8,$A0,$A0,$A3,$A3
.byte $A3,$A3,$A3,$A4,$BD,$8D,$00

View File

@ -70,15 +70,13 @@ dal_loop:
rts
.if 0
;=============================
; Draw ASCII art
;=============================
; Eventually will be LZ4 encoded to save room
; It's 7063 bytes of data unencoded
; A is which one to draw
; Decode it to 0x800 (text page 2) which we aren't using
; and we shouldn't have to worry about screen holes
draw_ascii_art:
sty TEMPY
@ -144,39 +142,210 @@ done_ascii_total:
ldy TEMPY
rts
;============================
; Setup Art Bounds
;============================
art_bounds:
.endif
lda FORTYCOL
bne fortycol_art_bounds
;=======================
; art update y
; set output to point at right row on screen
eightycol_art_bounds:
; on 80 column, art goes from 39,1 to 40,23 (????)
lda #2
sta WNDLFT
lda #35
sta WNDWDTH
art_update_y:
pha
sty TEMPY ; save Y (FIXME: always 0? so no need to save)
; (just set to 0 when done?)
ldy YY
lda gr_offsets,Y ; load offset of line
sta GBASL
lda gr_offsets+1,Y
sta GBASH
iny
iny
sty YY
ldy TEMPY
pla
rts
; LZ4 decode Art
; Based on Code by Peter Ferrie (qkumba) (peter.ferrie@gmail.com)
;======================
; LZ4 decode art
;======================
; input buffer in LZ4_SRC
; output buffer is both $800 (graphics page2, for delta lookups)
; as well as screen
lz4_decode_art:
draw_ascii_art:
asl ; point to ascii art we want
tay
dey
dey
lda ascii_art,Y
sta LZ4_SRC
lda ascii_art+1,Y
sta LZ4_SRC+1
lda #0 ; store output to $800
sta LZ4_DST
lda #8
sta LZ4_DST+1
; Also write to graphics mem
ldy #8 ; Start at line 4 (2-byte addresses)
sty YY
jsr art_update_y
; begin LZ4 code
art_unpmain:
ldy #0 ; used to index, always zero
sty LZ4_DONE
art_parsetoken:
jsr getsrc ; get next token
pha ; save for later (need bottom 4 bits)
lsr ; number of literals in top 4 bits
lsr ; so shift into place
lsr
lsr
beq art_copymatches ; if zero, then no literals
; jump ahead and copy
jsr buildcount ; add up all the literal sizes
; result is in ram[count+1]-1:A
tax ; now in ram[count+1]-1:X
jsr docopy_art ; copy the literals
; we end on 0, not on size
lda LZ4_DONE
bne done_lz4_art
; lda LZ4_SRC ; 16-bit compare
; cmp LZ4_END ; to see if we have reached the end
; lda LZ4_SRC+1
; sbc LZ4_END+1
; bcs done_lz4_art
art_copymatches:
jsr getsrc ; get 16-bit delta value
sta DELTA
jsr getsrc
sta DELTA+1
pla ; restore token
and #$0f ; get bottom 4 bits
; match count. 0 means 4
; 15 means 19+, must be calculated
jsr buildcount ; add up count bits, in ram[count+1]-:A
clc
adc #4 ; adjust count by 4 (minmatch)
tax ; now in ramp[count+1]-1:X
beq art_copy_no_adjust ; BUGFIX, don't increment if
; exactly a multiple of 0x100
bcc art_copy_no_adjust
inc COUNT+1 ; increment if we overflowed
art_copy_no_adjust:
lda LZ4_SRC+1 ; save src on stack
pha
lda LZ4_SRC
pha
sec ; subtract delta
lda LZ4_DST ; from destination, make new src
sbc DELTA
sta LZ4_SRC
lda LZ4_DST+1
sbc DELTA+1
sta LZ4_SRC+1
jsr docopy_art ; do the copy
pla ; restore the src
sta LZ4_SRC
pla
sta LZ4_SRC+1
jmp art_parsetoken ; back to parsing tokens
done_lz4_art:
pla
rts
;============
; getput_art
;============
; gets a byte, then puts the byte
getput_art:
jsr getsrc
; fallthrough to putdst
;=============
; putdst_art
;=============
; store A into destination
putdst_art:
cmp #0
bne putdst_check_cr
lda #1
sta WNDTOP
lda #21
sta WNDBTM
sta LZ4_DONE
rts
putdst_check_cr:
cmp #13+$80
bne putdst_normal_art
jsr art_update_y ; FIXME: inline?
jmp putdst_notext_art
putdst_normal_art:
sta (GBASL), Y ; store to text page
inc GBASL ; increment 16-bit pointer
bne putdst_end_art2 ; if overflow, increment top byte
inc GBASL+1
putdst_end_art2:
putdst_notext_art:
sta (LZ4_DST), Y ; store A into destination
inc LZ4_DST ; increment 16-bit pointer
bne putdst_end_art ; if overflow, increment top byte
inc LZ4_DST+1
putdst_end_art:
rts
fortycol_art_bounds:
; on 40 column, art goes from 0,4 to 40,24
;=============================
; docopy_art
;=============================
; copies ram[count+1]-1:X bytes
; from src to dst
docopy_art:
lda #0
sta WNDLFT
lda #40
sta WNDWDTH
lda #4
sta WNDTOP
lda #24
sta WNDBTM
docopy_loop_art:
jsr getput_art ; get/put byte
dex ; decrement count
bne docopy_loop_art ; if not zero, loop
dec COUNT+1 ; if zero, decrement high byte
bne docopy_loop_art ; if not zero, loop
rts

View File

@ -351,7 +351,7 @@ loading_message: .asciiz "LOADING"
lyrics:
.include "lyrics.inc"
.include "ascii_art.inc"
.include "ascii_art_lz4.inc"
LZ4_BUFFER:
.incbin "SA.KRW"