diff --git a/.gitignore b/.gitignore index 76b94df..5aef988 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ .DS_Store __pycache__ -/build/ +build diff --git a/res/ports/common/res/PRODOS#FF0000 b/res/ports/common/res/PRODOS#FF0000 new file mode 100644 index 0000000..7760a27 Binary files /dev/null and b/res/ports/common/res/PRODOS#FF0000 differ diff --git a/res/ports/common/src/constants.a b/res/ports/common/src/constants.a new file mode 100644 index 0000000..69bef79 --- /dev/null +++ b/res/ports/common/src/constants.a @@ -0,0 +1,71 @@ +;license:MIT +;(c) 2024 by 4am +; + +!ifndef _CONSTANTS_ { + +SELF_MODIFIED_BYTE = $FD +SELF_MODIFIED_WORD = $FDFD + +; standard memory addresses +CH = $24 +CV = $25 +BASL = $28 +INVFLG = $32 +RWTS_PTR = $48 +RNDL = $4E +RNDH = $4F +PRODOS_MLI = $BF00 +PRODOS_BOOT_UNIT = $BF30 +PRODOS_MEMORY_MAP = $BF58 +PRODOS_MACHID = $BF98 +KBD = $C000 +CLEARKBD = $C010 +STOREOFF = $C000 ; STA then use the following 4 flags: +READMAINMEM = $C002 ; STA to read from main mem +READAUXMEM = $C003 ; STA to read from aux mem +WRITEMAINMEM = $C004 ; STA to write to main mem +WRITEAUXMEM = $C005 ; STA to write to aux mem +CLR80VID = $C00C ; 40 columns +PRIMARYCHARSET = $C00E ; no mousetext for you +ALTCHARSET = $C00F ; yay mousetext +CLEARKBD = $C010 ; clear last key pressed +SLOT3STATUS = $C017 ; bit 7 only +MONOCOLOR = $C021 ; IIgs bit 7 switches composite mono/color modes +TBCOLOR = $C022 ; IIgs text foreground and background colors (also VidHD but write-only) +NEWVIDEO = $C029 ; IIgs graphics modes (also VidHD) +CLOCKCTL = $C034 ; bits 0-3 are IIgs border color (also VidHD) +GFXMODE = $C050 +TEXTMODE = $C051 +FULLGFX = $C052 +MIXEDGFX = $C053 +PAGE1 = $C054 ; page 1 (affects text, HGR, DHGR) +PAGE2 = $C055 ; page 2 (affects text, HGR, DHGR) +HIRES = $C057 +ROM_TEXT = $FB2F +ROM_FINALIZE_RESET = $FB6F +ROM_MACHINEID = $FBB3 +ROM_BASCALC = $FBC1 +ROM_HOME = $FC58 +ROM_CLREOL_FROM_Y = $FC9E +ROM_WAIT = $FCA8 +ROM_KEYIN = $FD1B +ROM_COUT = $FDED +ROM_INVERSE = $FE80 ; INVERSE text +ROM_NORMAL = $FE84 ; NORMAL text (instead of INVERSE or FLASH) +ROM_IN0 = $FE89 ; SETKBD +ROM_PR0 = $FE93 ; SETVID + +; ProDOS constants +CMD_QUIT = $65 +CMD_ONLINE = $C5 +CMD_SETPREFIX = $C6 +CMD_GETPREFIX = $C7 +CMD_OPEN = $C8 +CMD_READ = $CA +CMD_WRITE = $CB +CMD_CLOSE = $CC +CMD_SEEK = $CE + +_CONSTANTS_=* +} diff --git a/res/ports/common/src/exodecrunch.a b/res/ports/common/src/exodecrunch.a new file mode 100644 index 0000000..6b5198c --- /dev/null +++ b/res/ports/common/src/exodecrunch.a @@ -0,0 +1,489 @@ +; This source code is altered and is not the original version found on +; the Exomizer homepage. +; It contains modifications made by qkumba to depack a packed file +; optionally crunched forward, and additional modifications by 4am +; for an optional progress UI. +; +; Original copyright statement follows: +; +; Copyright (c) 2002 - 2018 Magnus Lind. +; +; This software is provided 'as-is', without any express or implied warranty. +; In no event will the authors be held liable for any damages arising from +; the use of this software. +; +; Permission is granted to anyone to use this software for any purpose, +; including commercial applications, and to alter it and redistribute it +; freely, subject to the following restrictions: +; +; 1. The origin of this software must not be misrepresented; you must not +; claim that you wrote the original software. If you use this software in a +; product, an acknowledgment in the product documentation would be +; appreciated but is not required. +; +; 2. Altered source versions must be plainly marked as such, and must not +; be misrepresented as being the original software. +; +; 3. This notice may not be removed or altered from any distribution. +; +; 4. The names of this software and/or it's copyright holders may not be +; used to endorse or promote products derived from this software without +; specific prior written permission. +; +; ------------------------------------------------------------------- +; The decruncher jsr:s to the get_crunched_byte address when it wants to +; read a crunched byte into A. This subroutine has to preserve X and Y +; register and must not modify the state of the carry nor the overflow flag. +; ------------------------------------------------------------------- +;.import get_crunched_byte +; ------------------------------------------------------------------- +; this function is the heart of the decruncher. +; It initializes the decruncher zeropage locations and precalculates the +; decrunch tables and decrunches the data +; This function will not change the interrupt status bit and it will not +; modify the memory configuration. +; ------------------------------------------------------------------- +;.export decrunch + +; ------------------------------------------------------------------- +; Controls if the shared get_bits routines should be inlined or not. +;INLINE_GET_BITS=1 +; ------------------------------------------------------------------- +; if literal sequences is not used (the data was crunched with the -c +; flag) then the following line can be uncommented for shorter and. +; slightly faster code. +;LITERAL_SEQUENCES_NOT_USED = 1 +; ------------------------------------------------------------------- +; if the sequence length is limited to 256 (the data was crunched with +; the -M256 flag) then the following line can be uncommented for +; shorter and slightly faster code. +;MAX_SEQUENCE_LENGTH_256 = 1 +; ------------------------------------------------------------------- +; if the sequence length 3 has its own offset table then the following +; line can be uncommented for in some situations slightly better +; compression at the cost of a larger decrunch table. +EXTRA_TABLE_ENTRY_FOR_LENGTH_THREE = 1 +; ------------------------------------------------------------------- +; optional progress UI +!IFNDEF SHOW_PROGRESS_DURING_DECRUNCH { + !set SHOW_PROGRESS_DURING_DECRUNCH = 0 +} +; ------------------------------------------------------------------- +; zero page addresses used +; ------------------------------------------------------------------- +zp_len_lo = $a7 +zp_len_hi = $a8 + +zp_src_lo = $ae +zp_src_hi = zp_src_lo + 1 + +zp_bits_hi = $fc + +zp_bitbuf = $fd +zp_dest_lo = zp_bitbuf + 1 ; dest addr lo +zp_dest_hi = zp_bitbuf + 2 ; dest addr hi + +!IFDEF EXTRA_TABLE_ENTRY_FOR_LENGTH_THREE { +encoded_entries = 68 +} ELSE { +encoded_entries = 52 +} + +tabl_bi = decrunch_table +tabl_lo = decrunch_table + encoded_entries +tabl_hi = decrunch_table + encoded_entries * 2 + + ;; refill bits is always inlined +!MACRO mac_refill_bits { + pha + jsr get_crunched_byte + rol + sta zp_bitbuf + pla +} + +!IFDEF INLINE_GET_BITS { +!MACRO mac_get_bits { + adc #$80 ; needs c=0, affects v + asl + bpl gb_skip +gb_next: + asl zp_bitbuf + bne gb_ok + mac_refill_bits +gb_ok: + rol + bmi gb_next +gb_skip: + bvc skip +gb_get_hi: + sec + sta zp_bits_hi + jsr get_crunched_byte +skip: +} +} ELSE { +!MACRO mac_get_bits { + jsr get_bits +} +get_bits: + adc #$80 ; needs c=0, affects v + asl + bpl gb_skip +gb_next: + asl zp_bitbuf + bne gb_ok + +mac_refill_bits +gb_ok: + rol + bmi gb_next +gb_skip: + bvs gb_get_hi + rts +gb_get_hi: + sec + sta zp_bits_hi + jmp get_crunched_byte +} +; ------------------------------------------------------------------- +; no code below this comment has to be modified in order to generate +; a working decruncher of this source file. +; However, you may want to relocate the tables last in the file to a +; more suitable address. +; ------------------------------------------------------------------- + +; ------------------------------------------------------------------- +; jsr this label to decrunch, it will in turn init the tables and +; call the decruncher +; no constraints on register content, however the +; decimal flag has to be #0 (it almost always is, otherwise do a cld) +decrunch: + +!IF SHOW_PROGRESS_DURING_DECRUNCH = 1 { + ldx #(kExoProgressWidth+2) + lda #$DF +- sta $0528+(20-(kExoProgressWidth/2))-1, x + sta $05A8+(20-(kExoProgressWidth/2))-1, x + dex + bpl - + lda #$20 + sta $05A8+(20-(kExoProgressWidth/2))-1 + sta $05A8+(20-(kExoProgressWidth/2))+kExoProgressWidth+1 + lda #$A8+(20-(kExoProgressWidth/2)) + sta ExoProgressPtr+1 +} +; ------------------------------------------------------------------- +; init zeropage, x and y regs. (12 bytes) +; + ldy #0 + ldx #3 +init_zp: + jsr get_crunched_byte + sta zp_bitbuf - 1,x + dex + bne init_zp +; ------------------------------------------------------------------- +; calculate tables (62 bytes) + get_bits macro +; x and y must be #0 when entering +; + clc +table_gen: + tax + tya + and #$0f + sta tabl_lo,y + beq shortcut ; start a new sequence +; ------------------------------------------------------------------- + txa + adc tabl_lo - 1,y + sta tabl_lo,y + lda zp_len_hi + adc tabl_hi - 1,y +shortcut: + sta tabl_hi,y +; ------------------------------------------------------------------- + lda #$01 + sta