From fdf4b1cc1df329ff8cee249f38decdd5fea79df6 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Wed, 24 Jun 2020 15:54:30 +0200 Subject: [PATCH] maximum keyword length is not 16 bytes --- c64/,,config_custom.s | 2 +- c64/basic/tokenizer/tk_pack.s | 16 +++++++++------- c64/basic/tokenizer/tk_shorten.s | 3 ++- tools/generate_strings.cc | 2 +- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/c64/,,config_custom.s b/c64/,,config_custom.s index f2ec3464..4465b483 100644 --- a/c64/,,config_custom.s +++ b/c64/,,config_custom.s @@ -143,4 +143,4 @@ // Other -#define CONFIG_COMPRESSION_LVL_2 // work on this option stopped - it would not give any improvement +// #define CONFIG_COMPRESSION_LVL_2 // work on this option stopped - it would not give any improvement diff --git a/c64/basic/tokenizer/tk_pack.s b/c64/basic/tokenizer/tk_pack.s index 5c9143dd..58e906e3 100644 --- a/c64/basic/tokenizer/tk_pack.s +++ b/c64/basic/tokenizer/tk_pack.s @@ -29,16 +29,16 @@ tk_pack: // Reuse the CPU stack - addresses below $102 are used by 'tokenise_line.s' .label tk__len_unpacked = $103 // length of unpacked data; it could replace 'tk__nibble_flag', but at the cost of code size/performance - .label tk__shorten_bits = $104 // for quick shortening of packed candidate - .label tk__nibble_flag = $105 // $00 = start from new byte, $FF = start from high nibble - .label tk__byte_offset = $106 // offset of the current byte (to place new data) in tk__packed + .label tk__shorten_bits = $104 // 2 bytes for quick shortening of packed candidate + .label tk__nibble_flag = $106 // $00 = start from new byte, $FF = start from high nibble + .label tk__byte_offset = $107 // offset of the current byte (to place new data) in tk__packed - .label tk__packed = $107 // packed candidate, 13 bytes is enough for worst case - 8 byte keyword + .label tk__packed = $108 // packed candidate, 13 bytes is enough for worst case - 8 byte keyword // Initialize variables lda #$00 - ldy #(tk__packed - tk__len_unpacked + 13) // XXX maybe do not clear that much, just put 0 at the end while compressing + ldy #(tk__packed - tk__len_unpacked + 14) // XXX maybe do not clear that much, just put 0 at the end while compressing !: sta tk__len_unpacked, y dey @@ -126,7 +126,8 @@ tk_pack_1n_done: // Put the bit mark - to indicate 1-nibble encoding clc - ror tk__shorten_bits + ror tk__shorten_bits+0 + ror tk__shorten_bits+1 // FALLTROUGH @@ -193,7 +194,8 @@ tk_pack_3n_done: // Put the bit mark - to indicate 3-nibble encoding sec - ror tk__shorten_bits + ror tk__shorten_bits+0 + ror tk__shorten_bits+1 bcc tk_pack_loop_next // branch always diff --git a/c64/basic/tokenizer/tk_shorten.s b/c64/basic/tokenizer/tk_shorten.s index 9b14833f..1d3fe0a1 100644 --- a/c64/basic/tokenizer/tk_shorten.s +++ b/c64/basic/tokenizer/tk_shorten.s @@ -20,7 +20,8 @@ tk_shorten: // Now check if the last character was encoded as 1 nibble or 3 nibbles - asl tk__nibble_flag + asl tk__shorten_bits+1 + rol tk__shorten_bits+0 bcs tk_shorten_3n // FALLTROUGH diff --git a/tools/generate_strings.cc b/tools/generate_strings.cc index 6207451a..fdbbcd26 100644 --- a/tools/generate_strings.cc +++ b/tools/generate_strings.cc @@ -1034,7 +1034,7 @@ void DataSet::validateLists() // Check mor maximum keyword length if (stringEntryList.type == ListType::KEYWORDS) { - if (stringEntry.string.length() > 8) ERROR("keyword cannot be longer than 8 characters"); + if (stringEntry.string.length() > 16) ERROR("keyword cannot be longer than 16 characters"); tk__max_keyword_len = std::max(tk__max_keyword_len, (uint8_t) stringEntry.string.length()); }