mirror of
https://github.com/a2-4am/passport.git
synced 2024-12-21 13:29:19 +00:00
use Exomizer 3 format, pack system file
This commit is contained in:
parent
48bcc53f25
commit
65447689a1
421
src/exodecrunch.s
Normal file
421
src/exodecrunch.s
Normal file
@ -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 <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 #52
|
||||
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
|
||||
cpx #$03
|
||||
bcs gbnc2_next
|
||||
lda tabl_bit,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
|
||||
; -------------------------------------------------------------------
|
||||
; the static stable used for bits+offset for lengths 3, 1 and 2 (3 bytes)
|
||||
; bits 4, 2, 4 and offsets 16, 48, 32
|
||||
tabl_bit:
|
||||
!BYTE %11100001, %10001100, %11100010
|
||||
; -------------------------------------------------------------------
|
||||
; 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
|
||||
; -------------------------------------------------------------------
|
@ -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
|
||||
}
|
||||
|
@ -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-13",$00
|
||||
.mainmenu
|
||||
!text "________________________________________",$8D,$8D,$8D,$8D,$8D,$8D,$8D,$8D
|
||||
!text " "
|
||||
|
436
src/unpack.a
436
src/unpack.a
@ -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
|
||||
; -------------------------------------------------------------------
|
52
src/wrapper.a
Normal file
52
src/wrapper.a
Normal file
@ -0,0 +1,52 @@
|
||||
!cpu 6502
|
||||
*=$2000
|
||||
!to "../build/PASSPORT.SYSTEM",plain
|
||||
|
||||
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
|
36
winmake.bat
36
winmake.bat
@ -5,10 +5,11 @@ echo y|1>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\
|
||||
|
Loading…
Reference in New Issue
Block a user