mirror of
https://github.com/emmanuel-marty/lzsa.git
synced 2024-12-22 16:30:01 +00:00
Small improvement over 6502 LZSA2 depacker
This commit is contained in:
parent
affa08c213
commit
659f6c14a9
@ -56,8 +56,9 @@ DECODE_TOKEN
|
||||
BNE PREPARE_COPY_LITERALS ; if less, literals count is complete
|
||||
|
||||
JSR GETSRC ; get extra byte of variable literals count
|
||||
CLC
|
||||
ADC #$12 ; overflow?
|
||||
; the carry is always set by the CMP above
|
||||
; GETSRC doesn't change it
|
||||
SBC #$EE ; overflow?
|
||||
BCC PREPARE_COPY_LITERALS ; if not, literals count is complete
|
||||
|
||||
; handle 16 bits literals count
|
||||
@ -155,8 +156,9 @@ REP_MATCH
|
||||
BNE PREPARE_COPY_MATCH ; if less, match length is complete
|
||||
|
||||
JSR GETSRC ; get extra byte of variable match length
|
||||
CLC
|
||||
ADC #$18 ; overflow?
|
||||
; the carry is always set by the CMP above
|
||||
; GETSRC doesn't change it
|
||||
SBC #$E8 ; overflow?
|
||||
BCC PREPARE_COPY_MATCH ; if not, the match length is complete
|
||||
BEQ DECOMPRESSION_DONE ; if EOD code, bail
|
||||
|
||||
|
@ -185,8 +185,9 @@ lzsa_status_t lzsa_decompress_stream(lzsa_stream_t *pInStream, lzsa_stream_t *pO
|
||||
}
|
||||
size_t nReadBytes = pInStream->read(pInStream, pInBlock, nBlockSize);
|
||||
if (nFlags & LZSA_FLAG_RAW_BLOCK) {
|
||||
if (nReadBytes > 2)
|
||||
nReadBytes -= 2;
|
||||
size_t nEODBytes = (nFormatVersion == 2) ? 2 : 4;
|
||||
if (nReadBytes > nEODBytes)
|
||||
nReadBytes -= nEODBytes;
|
||||
else
|
||||
nReadBytes = 0;
|
||||
nBlockSize = (unsigned int)nReadBytes;
|
||||
|
Loading…
Reference in New Issue
Block a user