diff --git a/asm/6502/decompress_faster_v1.asm b/asm/6502/decompress_faster_v1.asm new file mode 100644 index 0000000..bb1beb4 --- /dev/null +++ b/asm/6502/decompress_faster_v1.asm @@ -0,0 +1,392 @@ +; *************************************************************************** +; *************************************************************************** +; +; lzsa1_6502.s +; +; NMOS 6502 decompressor for data stored in Emmanuel Marty's LZSA1 format. +; +; This code is written for the PCEAS/NECASM assembler in HuC & MagicKit. +; +; Optional code is presented for one minor 6502 optimization that breaks +; compatibility with the current LZSA1 format standard. +; +; The code is 168 bytes for the small version, and 205 bytes for the normal. +; +; Copyright John Brandwood 2019. +; +; Distributed under the Boost Software License, Version 1.0. +; (See accompanying file LICENSE_1_0.txt or copy at +; http://www.boost.org/LICENSE_1_0.txt) +; +; *************************************************************************** +; *************************************************************************** + + + +; *************************************************************************** +; *************************************************************************** +; +; Decompression Options & Macros +; + + ; + ; Save 6 bytes of code and 21 cycles by swapping the order + ; of bytes in the 16-bit length encoding? + ; + ; N.B. Setting this breaks compatibility with LZSA v1.2 + ; + +LZSA_SWAP_LEN16 = 0 + + ; + ; Choose size over space (within sane limits)? + ; + +LZSA_SMALL_SIZE = 0 + + ; + ; Remove code inlining to save space? + ; + ; This saves 15 bytes of code at the cost of 7% speed. + ; + + !if LZSA_SMALL_SIZE { +LZSA_NO_INLINE = 1 + } else { +LZSA_NO_INLINE = 0 + } + + ; + ; Use smaller code for copying literals? + ; + ; This saves 11 bytes of code at the cost of 15% speed. + ; + + !if LZSA_SMALL_SIZE { +LZSA_SHORT_CP = 1 + } else { +LZSA_SHORT_CP = 0 + } + + ; + ; Use smaller code for copying literals? + ; + ; This saves 11 bytes of code at the cost of 30% speed. + ; + + !if LZSA_SMALL_SIZE { +LZSA_SHORT_LZ = 1 + } else { +LZSA_SHORT_LZ = 0 + } + + ; + ; Assume that we're decompessing from a large multi-bank + ; compressed data file, and that the next bank may need to + ; paged in when a page-boundary is crossed. + ; + +LZSA_FROM_BANK = 0 + + ; + ; Macro to increment the source pointer to the next page. + ; + ; This should call a subroutine to determine if a bank + ; has been crossed, and a new bank should be paged in. + ; + + !if LZSA_FROM_BANK { + !macro LZSA_INC_PAGE { + jsr lzsa1_next_page + } + } else { + !macro LZSA_INC_PAGE { + inc