fix text compression and decompression routines.
This commit is contained in:
1 parent
0050fe03c9
commit
50f6f0d123
2 files changed
+25
-18
No files matched your search
@@ -100,11 +100,9 @@ found_packed_word:
|
|||||||
clc
|
clc
|
||||||
adc temp_string_ptr+0
|
adc temp_string_ptr+0
|
||||||
sta temp_string_ptr+0
|
sta temp_string_ptr+0
|
||||||
sta $0426
|
|
||||||
lda temp_string_ptr+1
|
lda temp_string_ptr+1
|
||||||
adc #$00
|
adc #$00
|
||||||
sta temp_string_ptr+1
|
sta temp_string_ptr+1
|
||||||
sta $0427
|
|
||||||
ldy #$ff
|
ldy #$ff
|
||||||
|
|
||||||
next_packed_word_char:
|
next_packed_word_char:
|
||||||
@@ -176,21 +174,30 @@ has_nybl:
|
|||||||
no_lo_nybl_char:
|
no_lo_nybl_char:
|
||||||
|
|
||||||
;; If current byte has $0F in low nybl, then the next
|
;; If current byte has $0F in low nybl, then the next
|
||||||
;; byte is a whole byte shifted left one bit.
|
;; byte is a whole byte.
|
||||||
;; bit 0 indicates if it is the end of the word.
|
|
||||||
lda (temp_string_ptr),y
|
lda (temp_string_ptr),y
|
||||||
and #$0f
|
and #$0f
|
||||||
bne +
|
cmp #$0f
|
||||||
|
beq next_is_literal_char
|
||||||
|
|
||||||
;; XXX - Implement decoding of this case
|
ready_for_next_char:
|
||||||
|
|
||||||
*
|
|
||||||
cpy #$ff
|
cpy #$ff
|
||||||
bne next_packed_word_char
|
bne next_packed_word_char
|
||||||
end_of_packed_word:
|
end_of_packed_word:
|
||||||
;; Hit end of packed data
|
;; Hit end of packed data
|
||||||
rts
|
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:
|
is_uncommon_char:
|
||||||
;; Lower nybl has offset into low-frequency part of the table
|
;; Lower nybl has offset into low-frequency part of the table
|
||||||
|
|
||||||
|
|||||||
+10
-10
@@ -293,15 +293,8 @@ int pack_word(const char *w,unsigned char *out,int *len)
|
|||||||
fprintf(stderr,"ERROR: Extended characters must be < 0x80\n");
|
fprintf(stderr,"ERROR: Extended characters must be < 0x80\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
if (w[j+1]) {
|
out[(*len)++]=w[j];
|
||||||
out[(*len)++]=(char_num<<1)+1;
|
fprintf(stderr," XS[$%02x]",w[j]);
|
||||||
fprintf(stderr," XS[$%02x]",char_num);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
out[(*len)++]=(char_num<<1)+0;
|
|
||||||
fprintf(stderr," XS0[$%02x]\n",char_num);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (char_num < (14+13)) {
|
if (char_num < (14+13)) {
|
||||||
out[(*len)++]=0xF1+(char_num-14);
|
out[(*len)++]=0xF1+(char_num-14);
|
||||||
@@ -396,9 +389,16 @@ int main(void)
|
|||||||
|
|
||||||
// Now encode the words
|
// Now encode the words
|
||||||
for(int i=0;i<word_count;i++) {
|
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++) {
|
for(int i=0;keyword_list[i];i++) {
|
||||||
|
fprintf(stderr,"$%03X : ",i);
|
||||||
pack_word(keyword_list[i],packed_keywords,&packedkey_len);
|
pack_word(keyword_list[i],packed_keywords,&packedkey_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user