mirror of
https://github.com/emmanuel-marty/lzsa.git
synced 2024-08-28 15:29:03 +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
|
BNE PREPARE_COPY_LITERALS ; if less, literals count is complete
|
||||||
|
|
||||||
JSR GETSRC ; get extra byte of variable literals count
|
JSR GETSRC ; get extra byte of variable literals count
|
||||||
CLC
|
; the carry is always set by the CMP above
|
||||||
ADC #$12 ; overflow?
|
; GETSRC doesn't change it
|
||||||
|
SBC #$EE ; overflow?
|
||||||
BCC PREPARE_COPY_LITERALS ; if not, literals count is complete
|
BCC PREPARE_COPY_LITERALS ; if not, literals count is complete
|
||||||
|
|
||||||
; handle 16 bits literals count
|
; handle 16 bits literals count
|
||||||
@ -155,8 +156,9 @@ REP_MATCH
|
|||||||
BNE PREPARE_COPY_MATCH ; if less, match length is complete
|
BNE PREPARE_COPY_MATCH ; if less, match length is complete
|
||||||
|
|
||||||
JSR GETSRC ; get extra byte of variable match length
|
JSR GETSRC ; get extra byte of variable match length
|
||||||
CLC
|
; the carry is always set by the CMP above
|
||||||
ADC #$18 ; overflow?
|
; GETSRC doesn't change it
|
||||||
|
SBC #$E8 ; overflow?
|
||||||
BCC PREPARE_COPY_MATCH ; if not, the match length is complete
|
BCC PREPARE_COPY_MATCH ; if not, the match length is complete
|
||||||
BEQ DECOMPRESSION_DONE ; if EOD code, bail
|
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);
|
size_t nReadBytes = pInStream->read(pInStream, pInBlock, nBlockSize);
|
||||||
if (nFlags & LZSA_FLAG_RAW_BLOCK) {
|
if (nFlags & LZSA_FLAG_RAW_BLOCK) {
|
||||||
if (nReadBytes > 2)
|
size_t nEODBytes = (nFormatVersion == 2) ? 2 : 4;
|
||||||
nReadBytes -= 2;
|
if (nReadBytes > nEODBytes)
|
||||||
|
nReadBytes -= nEODBytes;
|
||||||
else
|
else
|
||||||
nReadBytes = 0;
|
nReadBytes = 0;
|
||||||
nBlockSize = (unsigned int)nReadBytes;
|
nBlockSize = (unsigned int)nReadBytes;
|
||||||
|
Loading…
Reference in New Issue
Block a user