fix text compression and decompression routines.

This commit is contained in:
Paul Gardner-Stephen committed 2019-04-25 16:45:39 +09:30
1 parent 0050fe03c9
commit 50f6f0d123
2 files changed
+25 -18

No files matched your search

+15 -8
View File
@@ -100,11 +100,9 @@ found_packed_word:
clc
adc temp_string_ptr+0
sta temp_string_ptr+0
sta $0426
lda temp_string_ptr+1
adc #$00
sta temp_string_ptr+1
sta $0427
ldy #$ff
next_packed_word_char:
@@ -176,21 +174,30 @@ has_nybl:
no_lo_nybl_char:
;; If current byte has $0F in low nybl, then the next
;; byte is a whole byte shifted left one bit.
;; bit 0 indicates if it is the end of the word.
;; byte is a whole byte.
lda (temp_string_ptr),y
and #$0f
bne +
cmp #$0f
beq next_is_literal_char
;; XXX - Implement decoding of this case
*
ready_for_next_char:
cpy #$ff
bne next_packed_word_char
end_of_packed_word:
;; Hit end of packed data
rts
next_is_literal_char:
;; Output the literal char, and ready for next char
iny
tya
pha
lda (temp_string_ptr),y
jsr $ffd2
pla
tay
jmp ready_for_next_char
is_uncommon_char:
;; Lower nybl has offset into low-frequency part of the table
+10 -10
View File
@@ -293,15 +293,8 @@ int pack_word(const char *w,unsigned char *out,int *len)
fprintf(stderr,"ERROR: Extended characters must be < 0x80\n");
exit(-1);
}
if (w[j+1]) {
out[(*len)++]=(char_num<<1)+1;
fprintf(stderr," XS[$%02x]",char_num);
}
else {
out[(*len)++]=(char_num<<1)+0;
fprintf(stderr," XS0[$%02x]\n",char_num);
return 0;
}
out[(*len)++]=w[j];
fprintf(stderr," XS[$%02x]",w[j]);
} else {
if (char_num < (14+13)) {
out[(*len)++]=0xF1+(char_num-14);
@@ -396,9 +389,16 @@ int main(void)
// Now encode the words
for(int i=0;i<word_count;i++) {
pack_word(words[i],packed_words,&packed_len);
fprintf(stderr,"$%03X : ",i);
int old_offset=packed_len;
pack_word(words[i],packed_words,&packed_len);
fprintf(stderr," Packing word: ");
for(int j=old_offset;j<packed_len;j++)
fprintf(stderr," $%02X",packed_words[j]);
fprintf(stderr,"\n");
}
for(int i=0;keyword_list[i];i++) {
fprintf(stderr,"$%03X : ",i);
pack_word(keyword_list[i],packed_keywords,&packedkey_len);
}