Merge pull request #91 from peterferrie/master

use Exomizer 3 format, pack system file
This commit is contained in:
4am 2019-06-16 17:53:32 -04:00 committed by GitHub
commit be6e35f29c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 618 additions and 493 deletions

View File

@ -17,7 +17,7 @@ ACME=acme
CADIUS=cadius
# https://bitbucket.org/magli143/exomizer/wiki/Home
# requires Exomizer 3.0 or later
EXOMIZER=exomizer raw -P0 -q
EXOMIZER=exomizer raw -q -P23
BUILDDISK=build/passport
@ -29,8 +29,33 @@ asm:
cd src/mods && $(ACME) -r ../../build/t00only.lst t00only.a
$(EXOMIZER) build/t00only.bin -o build/t00only.tmp
printf "\x20\x00" | cat - build/t00only.tmp > build/t00only.pak
cd src && $(ACME) -r ../build/passport.lst passport.a 2> ../build/relbase.log
cd src && $(ACME) -DRELBASE=`cat ../build/relbase.log | cut -d"=" -f2 | cut -d"(" -f2 | cut -d")" -f1` passport.a
cd src && $(ACME) -r ../build/passport.lst -DFORWARD_DECRUNCHING=1 passport.a 2> ../build/relbase.log
cd src && $(ACME) -DRELBASE=`cat ../build/relbase.log | grep "RELBASE =" | cut -d"=" -f2 | cut -d"(" -f2 | cut -d")" -f1` -DFORWARD_DECRUNCHING=1 passport.a 2> ../build/vars.log
grep "SaveProDOS=" build/vars.log | cut -d":" -f3 | cut -d"(" -f1 > build/vars.a
grep "kForceLower=" build/vars.log | cut -d":" -f3 | cut -d"(" -f1 >> build/vars.a
grep "DiskIIArray=" build/vars.log | cut -d":" -f3 | cut -d"(" -f1 >> build/vars.a
grep "PrintByID=" build/vars.log | cut -d":" -f3 | cut -d"(" -f1 >> build/vars.a
grep "WaitForKey=" build/vars.log | cut -d":" -f3 | cut -d"(" -f1 >> build/vars.a
grep "CleanExit=" build/vars.log | cut -d":" -f3 | cut -d"(" -f1 >> build/vars.a
grep "GetVolumeName=" build/vars.log | cut -d":" -f3 | cut -d"(" -f1 >> build/vars.a
grep "OnlineReturn=" build/vars.log | cut -d":" -f3 | cut -d"(" -f1 >> build/vars.a
grep "GetVolumeInfo=" build/vars.log | cut -d":" -f3 | cut -d"(" -f1 >> build/vars.a
grep "filetype=" build/vars.log | cut -d":" -f3 | cut -d"(" -f1 >> build/vars.a
grep "VolumeName=" build/vars.log | cut -d":" -f3 | cut -d"(" -f1 >> build/vars.a
grep "auxtype=" build/vars.log | cut -d":" -f3 | cut -d"(" -f1 >> build/vars.a
grep "blocks=" build/vars.log | cut -d":" -f3 | cut -d"(" -f1 >> build/vars.a
grep "PREFSVER=" build/vars.log | cut -d":" -f3 | cut -d"(" -f1 >> build/vars.a
grep "PREFSFILE=" build/vars.log | cut -d":" -f3 | cut -d"(" -f1 >> build/vars.a
grep "PREFSREADLEN=" build/vars.log | cut -d":" -f3 | cut -d"(" -f1 >> build/vars.a
grep "PREFSBUFFER=" build/vars.log | cut -d":" -f3 | cut -d"(" -f1 >> build/vars.a
grep "ValidatePrefs=" build/vars.log | cut -d":" -f3 | cut -d"(" -f1 >> build/vars.a
grep "SavePrefs=" build/vars.log | cut -d":" -f3 | cut -d"(" -f1 >> build/vars.a
grep "mliparam=" build/vars.log | cut -d":" -f3 | cut -d"(" -f1 >> build/vars.a
grep "OpenFile=" build/vars.log | cut -d":" -f3 | cut -d"(" -f1 >> build/vars.a
grep "ReadFile=" build/vars.log | cut -d":" -f3 | cut -d"(" -f1 >> build/vars.a
grep "CloseFile=" build/vars.log | cut -d":" -f3 | cut -d"(" -f1 >> build/vars.a
$(EXOMIZER) -b build/passport.tmp -o build/passport.pak
cd src && $(ACME) -DFORWARD_DECRUNCHING=0 wrapper.a
cp res/work.po "$(BUILDDISK)".po
cp res/_FileInformation.txt build/
$(CADIUS) ADDFILE "${BUILDDISK}".po "/PASSPORT/" "build/PASSPORT.SYSTEM"

View File

@ -144,10 +144,11 @@ SetupF7F6SecondRound
ldy gSector
lda #kSectorIgnore
.a sta $D1D1 ; modifed at runtime
dec .a+1
ldx .a+1
bne +
dec .a+2
+ dey
+ dec .a+1
dey
bpl .a
; print that we found the protection track
lda #s_f7

450
src/exodecrunch.s Normal file
View File

@ -0,0 +1,450 @@
; 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
; -------------------------------------------------------------------
; 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
; -------------------------------------------------------------------
; 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:
; -------------------------------------------------------------------
; 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 <zp_len_hi
lda #$78 ; %01111000
+mac_get_bits
; -------------------------------------------------------------------
lsr
tax
beq rolled
php
rolle:
asl zp_len_hi
sec
ror
dex
bne rolle
plp
rolled:
ror
sta tabl_bi,y
bmi no_fixup_lohi
lda zp_len_hi
stx zp_len_hi
!BYTE $24
no_fixup_lohi:
txa
; -------------------------------------------------------------------
iny
cpy #encoded_entries
bne table_gen
; -------------------------------------------------------------------
; prepare for main decruncher
ldy zp_dest_lo
stx zp_dest_lo
stx zp_bits_hi
; -------------------------------------------------------------------
; copy one literal byte to destination (11(10) bytes)
;
!if FORWARD_DECRUNCHING = 0 {
literal_start1:
tya
bne no_hi_decr
dec zp_dest_hi
no_hi_decr:
dey
jsr get_crunched_byte
sta (zp_dest_lo),y
} else {
literal_start1:
jsr get_crunched_byte
sta (zp_dest_lo),y
iny
bne no_hi_incr
inc zp_dest_hi
no_hi_incr:
}
; -------------------------------------------------------------------
; fetch sequence length index (15 bytes)
; x must be #0 when entering and contains the length index + 1
; when exiting or 0 for literal byte
next_round:
dex
lda zp_bitbuf
no_literal1:
asl
bne nofetch8
jsr get_crunched_byte
rol
nofetch8:
inx
bcc no_literal1
sta zp_bitbuf
; -------------------------------------------------------------------
; check for literal byte (2 bytes)
;
beq literal_start1
; -------------------------------------------------------------------
; check for decrunch done and literal sequences (4 bytes)
;
cpx #$11
!IFDEF INLINE_GET_BITS {
bcc skip_jmp
jmp exit_or_lit_seq
skip_jmp:
} ELSE {
bcs exit_or_lit_seq
}
; -------------------------------------------------------------------
; calulate length of sequence (zp_len) (18(11) bytes) + get_bits macro
;
lda tabl_bi - 1,x
+mac_get_bits
adc tabl_lo - 1,x ; we have now calculated zp_len_lo
sta zp_len_lo
!IFNDEF MAX_SEQUENCE_LENGTH_256 {
lda zp_bits_hi
adc tabl_hi - 1,x ; c = 0 after this.
sta zp_len_hi
; -------------------------------------------------------------------
; here we decide what offset table to use (27(26) bytes) + get_bits_nc macro
; z-flag reflects zp_len_hi here
;
ldx zp_len_lo
} ELSE {
tax
}
lda #$e1
!IFDEF EXTRA_TABLE_ENTRY_FOR_LENGTH_THREE {
cpx #$04
} ELSE {
cpx #$03
}
bcs gbnc2_next
lda tabl_bit - 1,x
gbnc2_next:
asl zp_bitbuf
bne gbnc2_ok
tax
jsr get_crunched_byte
rol
sta zp_bitbuf
txa
gbnc2_ok:
rol
bcs gbnc2_next
tax
; -------------------------------------------------------------------
; calulate absolute offset (zp_src) (21(23) bytes) + get_bits macro
;
!IFNDEF MAX_SEQUENCE_LENGTH_256 {
lda #0
sta zp_bits_hi
}
lda tabl_bi,x
+mac_get_bits
!if FORWARD_DECRUNCHING = 0 {
adc tabl_lo,x
sta zp_src_lo
lda zp_bits_hi
adc tabl_hi,x
adc zp_dest_hi
} else {
clc
adc tabl_lo,x
eor #$ff
sta zp_src_lo
lda zp_dest_hi
bcc skip_dest_hi
sbc #1
clc
skip_dest_hi:
sbc zp_bits_hi
sbc tabl_hi,x
clc
}
sta zp_src_hi
; -------------------------------------------------------------------
; prepare for copy loop (2 bytes)
;
pre_copy:
ldx zp_len_lo
; -------------------------------------------------------------------
; main copy loop (30 bytes)
;
copy_next:
!if FORWARD_DECRUNCHING = 0 {
tya
bne copy_skip_hi
dec zp_dest_hi
dec zp_src_hi
copy_skip_hi:
dey
}
!IFNDEF LITERAL_SEQUENCES_NOT_USED {
bcs get_literal_byte
}
lda (zp_src_lo),y
literal_byte_gotten:
sta (zp_dest_lo),y
!if FORWARD_DECRUNCHING = 1 {
iny
bne copy_skip_hi
inc zp_dest_hi
inc zp_src_hi
copy_skip_hi:
}
dex
bne copy_next
!IFNDEF MAX_SEQUENCE_LENGTH_256 {
lda zp_len_hi
!IFDEF INLINE_GET_BITS {
bne copy_next_hi
}
}
begin_stx:
stx zp_bits_hi
!IFNDEF INLINE_GET_BITS {
beq next_round
} ELSE {
jmp next_round
}
!IFNDEF MAX_SEQUENCE_LENGTH_256 {
copy_next_hi:
dec zp_len_hi
jmp copy_next
}
!IFNDEF LITERAL_SEQUENCES_NOT_USED {
get_literal_byte:
jsr get_crunched_byte
bcs literal_byte_gotten
}
; -------------------------------------------------------------------
; exit or literal sequence handling (16(12) bytes)
;
exit_or_lit_seq:
!IFNDEF LITERAL_SEQUENCES_NOT_USED {
beq decr_exit
jsr get_crunched_byte
!IFNDEF MAX_SEQUENCE_LENGTH_256 {
sta zp_len_hi
}
jsr get_crunched_byte
tax
bcs copy_next
decr_exit:
}
rts
!IFDEF EXTRA_TABLE_ENTRY_FOR_LENGTH_THREE {
; -------------------------------------------------------------------
; the static stable used for bits+offset for lengths 1, 2 and 3 (3 bytes)
; bits 2, 4, 4 and offsets 64, 48, 32 corresponding to
; %10010000, %11100011, %11100010
tabl_bit:
!BYTE $90, $e3, $e2
} ELSE {
; -------------------------------------------------------------------
; the static stable used for bits+offset for lengths 1 and 2 (2 bytes)
; bits 2, 4 and offsets 48, 32 corresponding to %10001100, %11100010
tabl_bit:
!BYTE $8c, $e2
}
; -------------------------------------------------------------------
; end of decruncher
; -------------------------------------------------------------------
; -------------------------------------------------------------------
; this 156 (204) byte table area may be relocated. It may also be
; clobbered by other data between decrunches.
; -------------------------------------------------------------------
decrunch_table=$200;;:
;; .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;;.IFDEF EXTRA_TABLE_ENTRY_FOR_LENGTH_THREE
;; .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;;.ENDIF
;; .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; .byte 0,0,0,0,0,0,0,0,0,0,0,0
; -------------------------------------------------------------------
; end of decruncher
; -------------------------------------------------------------------

View File

@ -1,5 +1,9 @@
!cpu 6502
!ifdef RELBASE {
*=RELBASE
} else {
*=$2000
}
;-------------------------------
; Passport
@ -46,7 +50,7 @@ FINNISH = 5 ; src/strings/fi, PASSPORT.FI
LANG = ENGLISH
!if LANG=ENGLISH {
!to "../build/PASSPORT.SYSTEM",plain
!to "../build/PASSPORT.TMP",plain
}
!if LANG=FRENCH {
!to "../build/PASSPORT.FR",plain
@ -86,39 +90,9 @@ UNIV_D3 = $B8FC
!source "apidefs.a"
ldx #$00
FM lda LastMover - 256,x
sta HIGHPOINT-$100,x
inx
bne FM
dec FM+2
dec FM+5
lda FM+5
cmp #(>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 #<universalrwts
sta _byte_lo
jsr decrunch
sta jCallRWTS+1
sty jCallRWTS+1
lda #$BD
sta jCallRWTS+2
ldy #$96
@ -654,12 +628,6 @@ CleanExit
.quitparm
!byte $04,$00,$00,$00,$00,$00,$00
FatalNoSlot6
lda #s_noslot6
jsr PrintByID
jsr WaitForKey
jmp CleanExit
!source "progress.a"
;-------------------------------
@ -844,11 +812,22 @@ _applyToAll
universalrwts
!bin "../build/universalrwts.pak"
!source "unpack.a"
!source "exodecrunch.s"
get_crunched_byte:
_byte_lo = * + 1
_byte_hi = * + 2
lda $1234 ; needs to be set correctly before
; decrunch_file is called.
inc _byte_lo
bne _byte_skip_hi
inc _byte_hi
_byte_skip_hi:
rts
AnalyzeT00 ; placeholder to identify stack of packed data
!bin "../build/t00only.pak"
!source "apicode.a"
}
LastMover
!if RELBASE = $2000 {
@ -861,4 +840,28 @@ LastMover
!if (HIGHPOINT - (LastMover - FirstMover)) < LOWPOINT {
!serious "code end (", HIGHPOINT - (LastMover - FirstMover), ") is below minimum (", LOWPOINT, ")!"
}
!warn "CleanExit=",CleanExit
!warn "WaitForKey=",WaitForKey
!warn "SaveProDOS=",SaveProDOS
!warn "OpenFile=",OpenFile
!warn "ReadFile=",ReadFile
!warn "CloseFile=",CloseFile
!warn "GetVolumeName=",GetVolumeName
!warn "OnlineReturn=",OnlineReturn
!warn "VolumeName=",VolumeName
!warn "GetVolumeInfo=",GetVolumeInfo
!warn "mliparam=",mliparam
!warn "filetype=",filetype
!warn "auxtype=",auxtype
!warn "blocks=",blocks
!warn "PREFSFILE=",PREFSFILE
!warn "PREFSBUFFER=",PREFSBUFFER
!warn "PREFSREADLEN=",PREFSREADLEN
!warn "PREFSVER=",PREFSVER
!warn "SavePrefs=",SavePrefs
!warn "ValidatePrefs=",ValidatePrefs
!warn "kForceLower=",kForceLower
!warn "PrintByID=",PrintByID
!warn "DiskIIArray=",DiskIIArray
}

View File

@ -280,7 +280,7 @@ StringTableHigh
; can be set directly before calling PrintByID.
;
.header
!text "Passport by 4am 2019-05-28",$00
!text "Passport by 4am 2019-06-16",$00
.mainmenu
!text "________________________________________",$8D,$8D,$8D,$8D,$8D,$8D,$8D,$8D
!text " "
@ -575,7 +575,7 @@ StringTableHigh
.microfun
!text "T%t,S%0 Found Micro Fun protection check",$00
.advent
!text "T%t,S%0 Found Interplay bootloader",$8D,$00
!text "T00,S00 Found Interplay bootloader",$8D,$00
.gathering
!text "Gathering per-file encryption keys",$8D,$00
.davidson

View File

@ -1,436 +0,0 @@
; This source code is altered and is not the original version found on
; the Exomizer homepage.
; It contains modifications made by Krill/Plush to depack a packed file
; crunched forward and to work with his loader.
;
; Copyright (c) 2002 - 2005 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. This subroutine has to preserve x and y register and,
; if FORWARD_DECRUNCHING = 0, must not modify the state of the carry 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
; -------------------------------------------------------------------
; if literal sequences is not used (the data was crunched with the -c
; flag) then the following line can be uncommented for shorter code.
;LITERAL_SEQUENCES_NOT_USED=1
; -------------------------------------------------------------------
; set this flag to 0 if the data are depacked backwards,
; and non-0 otherwise
; -------------------------------------------------------------------
FORWARD_DECRUNCHING=1
; -------------------------------------------------------------------
; zero page addresses used
; -------------------------------------------------------------------
zp_len_lo = $a7
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
; -------------------------------------------------------------------
; 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.
;
ldy #0
ldx #3
init_zp:
jsr get_crunched_byte
sta zp_bitbuf - 1,x
dex
bne init_zp
; -------------------------------------------------------------------
; calculate tables (50 bytes)
; x and y must be #0 when entering
;
nextone:
inx
tya
and #$0f
beq shortcut ; start with new sequence
txa ; this clears reg a
lsr ; and sets the carry flag
ldx tabl_bi-1,y
rolle:
rol
rol zp_bits_hi
dex
bpl rolle ; c = 0 after this (rol zp_bits_hi)
adc tabl_lo-1,y
tax
lda zp_bits_hi
adc tabl_hi-1,y
shortcut:
sta tabl_hi,y
txa
sta tabl_lo,y
ldx #4
jsr get_bits ; clears x-reg.
sta tabl_bi,y
iny
cpy #52
bne nextone
beq begin
get_crunched_byte:
_byte_lo = * + 1
_byte_hi = * + 2
lda $1234 ; needs to be set correctly before
; decrunch_file is called.
inc _byte_lo
bne _byte_skip_hi
inc _byte_hi
_byte_skip_hi:
rts
; -------------------------------------------------------------------
; get bits (29 bytes)
;
; args:
; x = number of bits to get
; returns:
; a = #bits_lo
; x = #0
; c = 0
; z = 1
; zp_bits_hi = #bits_hi
; notes:
; y is untouched
; -------------------------------------------------------------------
get_bits:
lda #$00
sta zp_bits_hi
cpx #$01
bcc bits_done
bits_next:
lsr zp_bitbuf
bne ok
pha
!IF FORWARD_DECRUNCHING = 0 {
literal_get_byte:
jsr get_crunched_byte
bcc literal_byte_gotten
} ELSE {
jsr get_crunched_byte
;; sec
}
ror
sta zp_bitbuf
pla
ok:
rol
rol zp_bits_hi
dex
bne bits_next
bits_done:
rts
!IF FORWARD_DECRUNCHING {
; -------------------------------------------------------------------
; literal sequence handling
;
literal_start:
ldx #$10 ; these 16 bits
jsr get_bits; tell the length of the sequence
ldx zp_bits_hi
literal_start1: ; if literal byte, a = 1, zp_bits_hi = 0
sta zp_len_lo
!byte $2c ; skip next instruction
; -------------------------------------------------------------------
; main copy loop
; x = length hi
; y = length lo
;
copy_start:
stx zp_bits_hi
ldy #$00
copy_next:
!IFNDEF LITERAL_SEQUENCES_NOT_USED {
bcs +
jsr get_crunched_byte
clc
!byte $2c; skip next instruction
+
}
lda (zp_src_lo),y
sta (zp_dest_lo),y
iny
bne +
dex
inc <zp_dest_hi
inc zp_src_hi
+ tya
eor zp_len_lo
bne copy_next
txa
bne copy_next
tya
clc
adc <zp_dest_lo
sta <zp_dest_lo
bcc +
inc <zp_dest_hi
+
} ELSE {
; -------------------------------------------------------------------
; main copy loop
; x = length hi
; y = length lo
; (18(16) bytes)
;
copy_next_hi:
dex
dec zp_dest_hi
dec zp_src_hi
copy_next:
dey
!IFNDEF LITERAL_SEQUENCES_NOT_USED {
bcc literal_get_byte
}
lda (zp_src_lo),y
literal_byte_gotten: ; y = 0 when this label is jumped to
sta (zp_dest_lo),y
copy_start:
tya
bne copy_next
txa
bne copy_next_hi
}
; -------------------------------------------------------------------
; decruncher entry point, needs calculated tables (21(13) bytes)
; x and y must be #0 when entering
;
begin:
!IFNDEF LITERAL_SEQUENCES_NOT_USED {
inx
jsr get_bits
tay
bne literal_start1; if bit set, get a literal byte
} ELSE {
dey
}
getgamma:
inx
jsr bits_next
lsr
iny
bcc getgamma
!IFDEF LITERAL_SEQUENCES_NOT_USED {
beq literal_start
}
cpy #$11
!IFNDEF LITERAL_SEQUENCES_NOT_USED {
!IF FORWARD_DECRUNCHING {
beq bits_done ; gamma = 17 : end of file
bcs literal_start ; gamma = 18 : literal sequence
; gamma = 1..16: sequence
} ELSE {
bcc sequence_start; gamma = 1..16: sequence
beq bits_done ; gamma = 17 : end of file
; gamma = 18 : literal sequence
; -------------------------------------------------------------------
; literal sequence handling (13(2) bytes)
;
ldx #$10 ; these 16 bits
jsr get_bits; tell the length of the sequence
literal_start1: ; if literal byte, a = 1, zp_bits_hi = 0
sta zp_len_lo
ldx zp_bits_hi
ldy #0
bcc literal_start; jmp
sequence_start:
}
} ELSE {
bcs bits_done
}
; -------------------------------------------------------------------
; calulate length of sequence (zp_len) (11 bytes)
;
ldx tabl_bi - 1,y
jsr get_bits
adc tabl_lo - 1,y ; we have now calculated zp_len_lo
sta zp_len_lo
; -------------------------------------------------------------------
; now do the hibyte of the sequence length calculation (6 bytes)
lda zp_bits_hi
adc tabl_hi - 1,y ; c = 0 after this.
pha
; -------------------------------------------------------------------
; here we decide what offset table to use (20 bytes)
; x is 0 here
;
bne nots123
ldy zp_len_lo
cpy #$04
bcc size123
nots123:
ldy #$03
size123:
ldx tabl_bit - 1,y
jsr get_bits
adc tabl_off - 1,y ; c = 0 after this.
tay ; 1 <= y <= 52 here
; -------------------------------------------------------------------
!IF FORWARD_DECRUNCHING = 0 {
; Here we do the dest_lo -= len_lo subtraction to prepare zp_dest
; but we do it backwards: a - b == (b - a - 1) ^ ~0 (C-syntax)
; (16(16) bytes)
lda zp_len_lo
literal_start:
sbc zp_dest_lo
bcc noborrow
dec zp_dest_hi
noborrow:
eor #$ff
sta zp_dest_lo
cpy #$01 ; y < 1 then literal
!IFNDEF LITERAL_SEQUENCES_NOT_USED {
bcc pre_copy
} ELSE {
bcc literal_get_byte
}
}
; -------------------------------------------------------------------
; calulate absolute offset (zp_src)
;
ldx tabl_bi,y
jsr get_bits
adc tabl_lo,y
bcc skipcarry
inc zp_bits_hi
!IF FORWARD_DECRUNCHING {
skipcarry:
sec
eor #$ff
adc <zp_dest_lo
sta zp_src_lo
lda <zp_dest_hi
sbc zp_bits_hi
sbc tabl_hi,y
sta zp_src_hi
} ELSE {
clc
skipcarry:
adc zp_dest_lo
sta zp_src_lo
lda zp_bits_hi
adc tabl_hi,y
adc zp_dest_hi
sta zp_src_hi
}
; -------------------------------------------------------------------
; prepare for copy loop (8(6) bytes)
;
pla
tax
!IFNDEF LITERAL_SEQUENCES_NOT_USED {
sec
!IF FORWARD_DECRUNCHING = 0 {
pre_copy:
literal_start:
ldy zp_len_lo
}
jmp copy_start
} ELSE {
ldy zp_len_lo
bcc copy_start
}
; -------------------------------------------------------------------
; two small static tables (6(6) bytes)
;
tabl_bit:
!byte 2,4,4
tabl_off:
!byte 48,32,16
; -------------------------------------------------------------------
; end of decruncher
; -------------------------------------------------------------------
; -------------------------------------------------------------------
; this 156 byte table area may be relocated. It may also be clobbered
; by other data between decrunches.
; -------------------------------------------------------------------
decrunch_table=$200;;:
;; !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; !byte 0,0,0,0,0,0,0,0,0,0,0,0
; -------------------------------------------------------------------
; end of decruncher
; -------------------------------------------------------------------

54
src/wrapper.a Normal file
View File

@ -0,0 +1,54 @@
!cpu 6502
*=$2000
!to "../build/PASSPORT.SYSTEM",plain
!source "../build/vars.a"
jsr decrunch
sty $fe ;;zp_dest_lo
MACHINEID = $FBB3
OneTimeSetup
lda $C0E8
jsr SaveProDOS
ldx MACHINEID
cpx #$EA
bne .slotscan
lda #$DF
sta kForceLower
.slotscan
jsr ScanForDiskII
lda DiskIIArray+5
bne .founds6
lda #s_noslot6
jsr PrintByID
jsr WaitForKey
jmp CleanExit
.founds6
jsr ScanForRAMDisk
jsr LoadPrefs ; load preferences (if available)
jmp ($fe) ;;zp_dest_lo
!source "apidefs.a"
!source "strings/enid.a"
!source "initscan.a"
!source "exodecrunch.s"
get_crunched_byte:
lda _byte_lo
bne _byte_skip_hi
dec _byte_hi
_byte_skip_hi:
dec _byte_lo
_byte_lo = * + 1
_byte_hi = * + 2
lda packend ; needs to be set correctly before
; decrunch_file is called.
rts
!bin "../build/passport.pak"
!word HIGHPOINT
packend

View File

@ -5,32 +5,60 @@ echo y|1>nul rd build /s
goto :EOF
)
setlocal enabledelayedexpansion
set BUILDDISK=build\passport
set ACME=acme
set EXOMIZER=exomize
set EXOMIZER=exomizer raw -q -P23
set CADIUS=cadius
2>nul md build
cd src\mods
%ACME% universalrwts.a
cd ..\..\build
%EXOMIZER% raw -q universalrwts.bin -o universalrwts.tmp
%EXOMIZER% universalrwts.bin -o universalrwts.tmp
cscript /nologo //e:jscript %~f0 "b8" "00"
1>nul copy /b tmp+universalrwts.tmp universalrwts.pak
cd ..\src\mods
%ACME% -r ..\..\build\t00only.lst t00only.a
cd ..\..\build
%EXOMIZER% raw -q t00only.bin -o t00only.tmp
%EXOMIZER% t00only.bin -o t00only.tmp
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=4,* delims=:(" %%q in ('find "SaveProDOS=" ..\build\out.txt') do echo %%q > ..\build\vars.a
for /f "tokens=4,* delims=:(" %%q in ('find "kForceLower=" ..\build\out.txt') do echo %%q >> ..\build\vars.a
for /f "tokens=4,* delims=:(" %%q in ('find "DiskIIArray=" ..\build\out.txt') do echo %%q >> ..\build\vars.a
for /f "tokens=4,* delims=:(" %%q in ('find "PrintByID=" ..\build\out.txt') do echo %%q >> ..\build\vars.a
for /f "tokens=4,* delims=:(" %%q in ('find "WaitForKey=" ..\build\out.txt') do echo %%q >> ..\build\vars.a
for /f "tokens=4,* delims=:(" %%q in ('find "CleanExit=" ..\build\out.txt') do echo %%q >> ..\build\vars.a
for /f "tokens=4,* delims=:(" %%q in ('find "GetVolumeName=" ..\build\out.txt') do echo %%q >> ..\build\vars.a
for /f "tokens=4,* delims=:(" %%q in ('find "OnlineReturn=" ..\build\out.txt') do echo %%q >> ..\build\vars.a
for /f "tokens=4,* delims=:(" %%q in ('find "GetVolumeInfo=" ..\build\out.txt') do echo %%q >> ..\build\vars.a
for /f "tokens=4,* delims=:(" %%q in ('find "filetype=" ..\build\out.txt') do echo %%q >> ..\build\vars.a
for /f "tokens=4,* delims=:(" %%q in ('find "VolumeName=" ..\build\out.txt') do echo %%q >> ..\build\vars.a
for /f "tokens=4,* delims=:(" %%q in ('find "auxtype=" ..\build\out.txt') do echo %%q >> ..\build\vars.a
for /f "tokens=4,* delims=:(" %%q in ('find "blocks=" ..\build\out.txt') do echo %%q >> ..\build\vars.a
for /f "tokens=4,* delims=:(" %%q in ('find "PREFSVER=" ..\build\out.txt') do echo %%q >> ..\build\vars.a
for /f "tokens=4,* delims=:(" %%q in ('find "PREFSFILE=" ..\build\out.txt') do echo %%q >> ..\build\vars.a
for /f "tokens=4,* delims=:(" %%q in ('find "PREFSREADLEN=" ..\build\out.txt') do echo %%q >> ..\build\vars.a
for /f "tokens=4,* delims=:(" %%q in ('find "PREFSBUFFER=" ..\build\out.txt') do echo %%q >> ..\build\vars.a
for /f "tokens=4,* delims=:(" %%q in ('find "ValidatePrefs=" ..\build\out.txt') do echo %%q >> ..\build\vars.a
for /f "tokens=4,* delims=:(" %%q in ('find "SavePrefs=" ..\build\out.txt') do echo %%q >> ..\build\vars.a
for /f "tokens=4,* delims=:(" %%q in ('find "mliparam=" ..\build\out.txt') do echo %%q >> ..\build\vars.a
for /f "tokens=4,* delims=:(" %%q in ('find "OpenFile=" ..\build\out.txt') do echo %%q >> ..\build\vars.a
for /f "tokens=4,* delims=:(" %%q in ('find "ReadFile=" ..\build\out.txt') do echo %%q >> ..\build\vars.a
for /f "tokens=4,* delims=:(" %%q in ('find "CloseFile=" ..\build\out.txt') do echo %%q >> ..\build\vars.a
cd ..\build
%EXOMIZER% -b passport.tmp -o passport.pak
cd ..\src
%ACME% -DFORWARD_DECRUNCHING=0 wrapper.a
cd ..
1>nul copy res\work.po build\passport.po
1>nul copy res\work.po %BUILDDISK%.po
1>nul copy res\_FileInformation.txt build\
%CADIUS% ADDFILE "build\passport.po" "/PASSPORT/" "build\PASSPORT.SYSTEM"
%CADIUS% ADDFILE "%BUILDDISK%.po" "/PASSPORT/" "build\PASSPORT.SYSTEM"
cscript /nologo bin/po2do.js build\ build\
2>nul del "%BUILDDISK%.po"
goto :EOF