diff --git a/src/exodecrunch.s b/src/exodecrunch.s new file mode 100644 index 0000000..c88f17e --- /dev/null +++ b/src/exodecrunch.s @@ -0,0 +1,421 @@ +; 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. + +; +; 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 +; ------------------------------------------------------------------- +; 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 + +tabl_bi = decrunch_table +tabl_lo = decrunch_table + 52 +tabl_hi = decrunch_table + 104 + + ;; 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: +; ------------------------------------------------------------------- +; 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 RELBASE)-((>(RELBASE+255))->RELBASE)-1 - bne FM - -OneTimeSetup - lda $C0E8 - jsr SaveProDOS - ldx MACHINEID - cpx #$EA - bne .slotscan - lda #$DF - sta kForceLower -.slotscan - jsr ScanForDiskII - lda DiskIIArray+5 - bne .founds6 - jmp FatalNoSlot6 -.founds6 - jsr ScanForRAMDisk - jsr LoadPrefs ; load preferences (if available) - jmp ResetVector - - !source "initscan.a" - FirstMover - !pseudopc RELBASE { + jmp ResetVector + !zone ; use localized strings based on current language @@ -573,7 +547,7 @@ CopyUniversalAnywhere lda #nul rd build /s goto :EOF ) +setlocal enabledelayedexpansion set BUILDDISK=build\passport set ACME=acme -set EXOMIZER=exomize +set EXOMIZER=exomizer set CADIUS=cadius 2>nul md build cd src\mods @@ -24,9 +25,36 @@ cd ..\..\build cscript /nologo //e:jscript %~f0 "20" "00" 1>nul copy /b tmp+t00only.tmp t00only.pak cd ..\src -for /f "tokens=*" %%q in ('2^>^&1 %ACME% passport.a') do set _make=%%q -%ACME% -r ..\build\passport.lst -DRELBASE=$%_make:~-5,4% passport.a -set _make= +2>..\build\out.txt %ACME% -DFORWARD_DECRUNCHING=1 passport.a +for /f "tokens=2,3 delims=)" %%q in ('find "RELBASE =" ..\build\out.txt') do set _make=%%q +2>..\build\out.txt %ACME% -r ..\build\passport.lst -DRELBASE=$%_make:~-4% -DFORWARD_DECRUNCHING=1 passport.a +for /f "tokens=2,3 delims=)" %%q in ('find "SaveProDOS=" ..\build\out.txt') do set _SaveProDOS=%%q +for /f "tokens=2,3 delims=)" %%q in ('find "kForceLower=" ..\build\out.txt') do set _kForceLower=%%q +for /f "tokens=2,3 delims=)" %%q in ('find "DiskIIArray=" ..\build\out.txt') do set _DiskIIArray=%%q +for /f "tokens=2,3 delims=)" %%q in ('find "PrintByID=" ..\build\out.txt') do set _PrintByID=%%q +for /f "tokens=2,3 delims=)" %%q in ('find "WaitForKey=" ..\build\out.txt') do set _WaitForKey=%%q +for /f "tokens=2,3 delims=)" %%q in ('find "CleanExit=" ..\build\out.txt') do set _CleanExit=%%q +for /f "tokens=2,3 delims=)" %%q in ('find "GetVolumeName=" ..\build\out.txt') do set _GetVolumeName=%%q +for /f "tokens=2,3 delims=)" %%q in ('find "OnlineReturn=" ..\build\out.txt') do set _OnlineReturn=%%q +for /f "tokens=2,3 delims=)" %%q in ('find "GetVolumeInfo=" ..\build\out.txt') do set _GetVolumeInfo=%%q +for /f "tokens=2,3 delims=)" %%q in ('find "filetype=" ..\build\out.txt') do set _filetype=%%q +for /f "tokens=2,3 delims=)" %%q in ('find "VolumeName=" ..\build\out.txt') do set _VolumeName=%%q +for /f "tokens=2,3 delims=)" %%q in ('find "auxtype=" ..\build\out.txt') do set _auxtype=%%q +for /f "tokens=2,3 delims=)" %%q in ('find "blocks=" ..\build\out.txt') do set _blocks=%%q +for /f "tokens=2,3 delims=)" %%q in ('find "PREFSVER=" ..\build\out.txt') do set _PREFSVER=%%q +for /f "tokens=2,3 delims=)" %%q in ('find "PREFSFILE=" ..\build\out.txt') do set _PREFSFILE=%%q +for /f "tokens=2,3 delims=)" %%q in ('find "PREFSREADLEN=" ..\build\out.txt') do set _PREFSREADLEN=%%q +for /f "tokens=2,3 delims=)" %%q in ('find "PREFSBUFFER=" ..\build\out.txt') do set _PREFSBUFFER=%%q +for /f "tokens=2,3 delims=)" %%q in ('find "ValidatePrefs=" ..\build\out.txt') do set _ValidatePrefs=%%q +for /f "tokens=2,3 delims=)" %%q in ('find "SavePrefs=" ..\build\out.txt') do set _SavePrefs=%%q +for /f "tokens=2,3 delims=)" %%q in ('find "mliparam=" ..\build\out.txt') do set _mliparam=%%q +for /f "tokens=2,3 delims=)" %%q in ('find "OpenFile=" ..\build\out.txt') do set _OpenFile=%%q +for /f "tokens=2,3 delims=)" %%q in ('find "ReadFile=" ..\build\out.txt') do set _ReadFile=%%q +for /f "tokens=2,3 delims=)" %%q in ('find "CloseFile=" ..\build\out.txt') do set _CloseFile=%%q +cd ..\build +%EXOMIZER% raw -q -b passport.tmp -o passport.pak +cd ..\src +%ACME% -DSaveProDOS=$%_SaveProDOS:~-4% -DkForceLower=$%_kForceLower:~-4% -DDiskIIArray=$%_DiskIIArray:~-4% -DPrintByID=$%_PrintByID:~-4% -DWaitForKey=$%_WaitForKey:~-4% -DCleanExit=$%_CleanExit:~-4% -DGetVolumeName=$%_GetVolumeName:~-4% -DOnlineReturn=$%_OnlineReturn:~-4% -DGetVolumeInfo=$%_GetVolumeInfo:~-4% -Dfiletype=$%_filetype:~-4% -DVolumeName=$%_VolumeName:~-4% -Dauxtype=$%_auxtype:~-4% -Dblocks=$%_blocks:~-4% -DPREFSVER=$%_PREFSVER:~-4% -DPREFSFILE=$%_PREFSFILE:~-4% -DPREFSREADLEN=$%_PREFSREADLEN:~-1% -DPREFSBUFFER=$%_PREFSBUFFER:~-4% -DValidatePrefs=$%_ValidatePrefs:~-4% -DSavePrefs=$%_SavePrefs:~-4% -Dmliparam=$%_mliparam:~-4% -DOpenFile=$%_OpenFile:~-4% -DReadFile=$%_ReadFile:~-4% -DCloseFile=$%_CloseFile:~-4% -DFORWARD_DECRUNCHING=0 wrapper.a cd .. 1>nul copy res\work.po build\passport.po 1>nul copy res\_FileInformation.txt build\