; *************************************************************************** ; *************************************************************************** ; ; 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 Macros ; ; ; Macro to increment the source pointer to the next page. ; !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. ; .copy_large: jsr .get_gamma ; Bits 8..15 of offset (min 2). sty = 32000, length += 2. bcs .match_plus2 cpy #$05 ; If offset >= 1280, length += 1. bcs .match_plus1 bcc .do_match .lt256: ldy