Delay clearing high part of literals count until we really have to in 6809 LZSA2 depacker

This commit is contained in:
Doug Masten 2020-06-27 00:00:53 -05:00
parent 137c6201be
commit c7b3ffc067

View File

@ -31,7 +31,6 @@ decompress_lzsa2
lz2token ldb ,-x ; load next token into B: XYZ|LL|MMM
pshs b ; save it
clra ; clear A (high part of literals count)
andb #$18 ; isolate LLL (embedded literals count) in B
beq lz2nolt ; skip if no literals
cmpb #$18 ; LITERALS_RUN_LEN_V2?
@ -40,10 +39,10 @@ lz2token ldb ,-x ; load next token into B: XYZ|LL|MMM
bsr lz2nibl ; get extra literals length nibble in B
addb #$03 ; add LITERALS_RUN_LEN_V2
cmpb #$12 ; LITERALS_RUN_LEN_V2 + 15 ?
bne lz2gotlt ; if not, we have the full literals count, go copy
bne lz2gotla ; if not, we have the full literals count, go copy
addb ,-x ; add extra literals count byte + LITERALS_RUN_LEN + 15
bcc lz2gotlt ; if no overflow, we got the complete count, copy
bcc lz2gotla ; if no overflow, we got the complete count, copy
ldd ,--x ; load 16 bit count in D (low part in B, high in A)
bra lz2gotlt ; we now have the complete count, go copy
@ -51,6 +50,7 @@ lz2token ldb ,-x ; load next token into B: XYZ|LL|MMM
lz2declt lsrb ; shift literals count into place
lsrb
lsrb
lz2gotla clra ; clear A (high part of literals count)
lz2gotlt tfr x,u
tfr d,x ; transfer 16-bit count into X