From 2fbdf974338bde8576efdae40a819a76b2391033 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sun, 5 Nov 2023 11:22:55 +0000 Subject: Initial import of the open source release --- tools/apultra_src/asm/6502/aplib_6502.asm | 371 ++++++++++++++++++++++++++++++ 1 file changed, 371 insertions(+) create mode 100644 tools/apultra_src/asm/6502/aplib_6502.asm (limited to 'tools/apultra_src/asm/6502') diff --git a/tools/apultra_src/asm/6502/aplib_6502.asm b/tools/apultra_src/asm/6502/aplib_6502.asm new file mode 100644 index 0000000..219ac86 --- /dev/null +++ b/tools/apultra_src/asm/6502/aplib_6502.asm @@ -0,0 +1,371 @@ +; *************************************************************************** +; *************************************************************************** +; +; aplib_6502.s +; +; NMOS 6502 decompressor for data stored in Jorgen Ibsen's aPLib format. +; +; Includes support for Emmanuel Marty's enhancements to the aPLib format. +; +; The code is 252 bytes long for standard format, 270 for enhanced format. +; +; This code is written for the ACME assembler. +; +; 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 +; + + ; + ; Use the enhanced format from Emmanuel Marty's APULTRA? + ; + ; The enhancements speed up decompression on an 8-bit CPU. + ; + ; This gives an 11% improvement in decompresison speed, but + ; breaks compatibility with standard aPLib encoders. + ; + +APL_ENHANCED = 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. + ; + +APL_FROM_BANK = 0 + + ; + ; Macro to increment the source pointer to the next page. + ; + + !if APL_FROM_BANK { + !macro APL_INC_PAGE { + jsr .next_page + } + } else { + !macro APL_INC_PAGE { + inc 64768 bytes has +; been removed, since these don't occur with a 16-bit address range. +; +; As an optimization, the code to handle window offsets > 32000 bytes can +; be commented-out, since these don't occur in typical 8-bit computer usage. +; + +apl_decompress: ldy #0 ; Initialize source index. + + lda #$80 ; Initialize an empty + sta + bne .skip2 + jsr .load_bit +.skip2: bcc .copy_large + + asl - gamma-coded LZSS pair. + ; + + !if APL_ENHANCED { + +.copy_large: jsr .get_gamma ; Bits 8..15 of offset (min 2). + + cpx #1 ; CC if LWM==0, CS if LWM==1. + ldx #0 ; Clear hi-byte of length. + sbc #2 ; -3 if LWM==0, -2 if LWM==1. + bcs .normal_pair ; CC if LWM==0 && offset==2. + + jsr .get_gamma ; Get length (A=lo-byte & CS). + bcs .do_match ; Use previous Offset. + +.normal_pair: sta = 32000, length += 2. + bcs .match_plus2 + cpy #$05 ; If offset >= 1280, length += 1. + bcs .match_plus1 + bcc .do_match +.lt256: ldy