From 7610a965a5a0b3c62b8a944941293f7dde6c51aa Mon Sep 17 00:00:00 2001 From: John Brandwood Date: Sat, 20 Nov 2021 15:10:56 -0500 Subject: [PATCH] Make 6502 decompress_faster_v2.asm (& v1) 3-4% faster at the cost of 1 byte. --- asm/6502/decompress_faster_v1.asm | 220 +++++++++++++++--------------- asm/6502/decompress_faster_v2.asm | 68 +++++---- 2 files changed, 142 insertions(+), 146 deletions(-) diff --git a/asm/6502/decompress_faster_v1.asm b/asm/6502/decompress_faster_v1.asm index 2e29c5d..76d1b59 100644 --- a/asm/6502/decompress_faster_v1.asm +++ b/asm/6502/decompress_faster_v1.asm @@ -7,7 +7,7 @@ ; ; This code is written for the ACME assembler. ; -; The code is 167 bytes for the small version, and 192 bytes for the normal. +; The code is 169 bytes for the small version, and 193 bytes for the normal. ; ; Copyright John Brandwood 2021. ; @@ -37,15 +37,16 @@ LZSA_SMALL_SIZE = 0 ; *************************************************************************** ; *************************************************************************** ; -; Data usage is last 8 bytes of zero-page. +; Data usage is last 7 bytes of zero-page. ; -lzsa_length = $F8 ; 1 byte. lzsa_cmdbuf = $F9 ; 1 byte. lzsa_winptr = $FA ; 1 word. lzsa_srcptr = $FC ; 1 word. lzsa_dstptr = $FE ; 1 word. +lzsa_offset = lzsa_winptr + LZSA_SRC_LO = $FC LZSA_SRC_HI = $FD LZSA_DST_LO = $FE @@ -60,7 +61,6 @@ LZSA_DST_HI = $FF ; ; Args: lzsa_srcptr = ptr to compessed data ; Args: lzsa_dstptr = ptr to output buffer -; Uses: lots! ; DECOMPRESS_LZSA1_FAST: @@ -95,19 +95,14 @@ lzsa1_unpack: ldy #0 ; Initialize source index. lsr lsr cmp #$07 ; Extended length? - bcc .inc_cp_len + bcc .cp_got_len - jsr .get_length ; CS from CMP, X=0. + jsr .get_length ; X=0, CS from CMP, returns CC. + stx .cp_npages + 1 ; Hi-byte of length. - ora #0 ; Check the lo-byte of length - beq .put_cp_len ; without effecting CC. +.cp_got_len: tax ; Lo-byte of length. -.inc_cp_len: inx ; Increment # of pages to copy. - -.put_cp_len: stx