mirror of
https://github.com/A2osX/A2osX.git
synced 2025-03-24 09:33:48 +00:00
Kernel 0.93+
This commit is contained in:
parent
9d2e8cb421
commit
3fa2b42c7e
Binary file not shown.
@ -8,11 +8,10 @@ NEW
|
||||
.INB INC/MACROS.I
|
||||
.INB INC/A2OSX.I
|
||||
.INB INC/KERNEL.I
|
||||
.INB INC/PAK.I
|
||||
.INB INC/LIBPAK.I
|
||||
.INB INC/MLI.E.I
|
||||
*--------------------------------------
|
||||
CHNK.SIZE .EQ 4096
|
||||
*--------------------------------------
|
||||
X.ENTER.SUBDIR .EQ 0
|
||||
X.COPY.TO.DEST .EQ 0
|
||||
X.DELETE.SOURCE .EQ 0
|
||||
@ -54,6 +53,7 @@ CS.START cld
|
||||
.DA CS.RUN
|
||||
.DA CS.DOEVENT
|
||||
.DA CS.QUIT
|
||||
L.LIBPAK .DA LIBPAK
|
||||
L.MSG.USAGE .DA MSG.USAGE
|
||||
L.MSG.DIR .DA MSG.DIR
|
||||
L.MSG.FILE .DA MSG.FILE
|
||||
@ -63,8 +63,13 @@ L.MSG.E.IARC .DA MSG.E.IARC
|
||||
L.ARC.Header .DA ARC.Header
|
||||
.DA 0
|
||||
*--------------------------------------
|
||||
CS.INIT clc
|
||||
rts
|
||||
CS.INIT >LDYA L.LIBPAK
|
||||
>SYSCALL LoadLib
|
||||
bcs .9
|
||||
|
||||
sta hLIB
|
||||
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
CS.RUN >INC.G ArgIndex
|
||||
>SYSCALL ArgV
|
||||
@ -501,9 +506,14 @@ CS.QUIT jsr LeaveSubDir
|
||||
>SYSCALL fclose
|
||||
|
||||
.3 >LDA.G hMem
|
||||
beq .8
|
||||
beq .4
|
||||
>SYSCALL FreeMem
|
||||
|
||||
.4 lda hLIB
|
||||
beq .8
|
||||
|
||||
>SYSCALL UnloadLib
|
||||
|
||||
.8 clc
|
||||
rts
|
||||
*--------------------------------------
|
||||
@ -542,6 +552,9 @@ MSG.E.IARC .AZ "Invalid/corrupt archive"
|
||||
MSG.DIR .AZ "Reading Dir:%s..."
|
||||
MSG.FILE .AZ "Adding File:%s..."
|
||||
ARC.Header .AZ "PAK"
|
||||
*--------------------------------------
|
||||
LIBPAK .AZ "libpak"
|
||||
hLIB .BS 1
|
||||
*--------------------------------------
|
||||
.DUMMY
|
||||
.OR 0
|
||||
|
@ -8,9 +8,7 @@ NEW
|
||||
.INB INC/MACROS.I
|
||||
.INB INC/A2OSX.I
|
||||
.INB INC/MLI.E.I
|
||||
.INB INC/LIBPAK.I
|
||||
*--------------------------------------
|
||||
CHNK.SIZE .EQ 4096
|
||||
.INB INC/PAK.I
|
||||
*--------------------------------------
|
||||
.DUMMY
|
||||
.OR ZPBIN
|
||||
|
@ -2,50 +2,47 @@ NEW
|
||||
AUTO 3,1
|
||||
.LIST OFF
|
||||
*--------------------------------------
|
||||
CHNK.T .EQ 0
|
||||
CHNK.T.DIR .EQ 1
|
||||
CHNK.T.FILE .EQ 2
|
||||
CHNK.T.DATA .EQ 128
|
||||
*
|
||||
CHNK.TYPE .EQ 1 FILE/DIR
|
||||
CHNK.AUXTYPE .EQ 2
|
||||
CHNK.FNLEN .EQ 4
|
||||
*
|
||||
CHNK.ALG .EQ 1 DATA
|
||||
CHNK.ALG.STORE .EQ 0
|
||||
CHNK.ULEN .EQ 2
|
||||
*
|
||||
CHNK.CLEN .EQ 4
|
||||
REPMAX .EQ 16
|
||||
STRINGMAX .EQ 16
|
||||
WSIZE .EQ 4096
|
||||
*--------------------------------------
|
||||
STOREMAX .EQ 64
|
||||
PAK.B.SHORT3 .EQ %0
|
||||
PAK.B.SHORT4 .EQ %10
|
||||
PAK.B.REPn .EQ %110
|
||||
PAK.B.BACKLINK .EQ %1110
|
||||
PAK.B.STOREn .EQ %1111
|
||||
*--------------------------------------
|
||||
* File Header :
|
||||
*--------------------------------------
|
||||
S.PAKFILE.LEN .EQ 0 File Length (uncomp)
|
||||
S.PAKFILE.CRC .EQ 4 CRC of Target File
|
||||
S.PAKFILE.VER .EQ 8
|
||||
S.PAKFILE.TF .EQ 9 Target File (C-String)
|
||||
* STRINGn : 0 xxxx (1-16)
|
||||
* {
|
||||
* BYTE8 : 0 xxxxxxxx
|
||||
* TOP8 : 10 xxx
|
||||
* TOP16 : 110 xxx
|
||||
* TOP24 : 1110 xxx
|
||||
* REPn : 1111 xxxx (1-16)
|
||||
* }
|
||||
* BACKLINK : 1 !oooooooo !OOOO llllll (3-66)
|
||||
*--------------------------------------
|
||||
* Shunk Header :
|
||||
* WORD : Target UNCompressed Length
|
||||
* !!! USED TO STOP UNPACK,NO EOF TOKEN!!!
|
||||
*--------------------------------------
|
||||
S.PAKSHK.ULEN .EQ 0 Uncompressed length
|
||||
*
|
||||
S.PAKSHK .EQ 26
|
||||
S.PAKSHNK.ULEN .EQ 0 Uncompressed length
|
||||
S.PAKSHNK.TOPLEN .EQ 2
|
||||
* TOP Bytes ....
|
||||
* DATA
|
||||
*--------------------------------------
|
||||
S.PAKSTAT.PASS1 .EQ 0
|
||||
S.PAKSTAT.PASS2 .EQ 2
|
||||
S.PAKSTAT.BL .EQ 4
|
||||
S.PAKSTAT.REP .EQ 6
|
||||
S.PAKSTAT.S3 .EQ 8
|
||||
S.PAKSTAT.S4 .EQ 10
|
||||
S.PAKSTAT.STORE .EQ 12
|
||||
S.PAKSTAT.STR .EQ 4
|
||||
S.PAKSTAT.TOP8 .EQ 6
|
||||
S.PAKSTAT.TOP16 .EQ 8
|
||||
S.PAKSTAT.TOP24 .EQ 10
|
||||
S.PAKSTAT.REPN .EQ 12
|
||||
S.PAKSTAT.BL .EQ 14
|
||||
*
|
||||
S.PAKSTAT .EQ 14
|
||||
S.PAKSTAT .EQ 16
|
||||
*--------------------------------------
|
||||
LIBPAK.Pak .EQ 4
|
||||
LIBPAK.UnPak .EQ 6
|
||||
*--------------------------------------
|
||||
MAN
|
||||
SAVE INC/LIBPAK.I
|
||||
|
23
INC/PAK.I.txt
Normal file
23
INC/PAK.I.txt
Normal file
@ -0,0 +1,23 @@
|
||||
NEW
|
||||
AUTO 3,1
|
||||
.LIST OFF
|
||||
*--------------------------------------
|
||||
CHNK.SIZE .EQ 4096
|
||||
*--------------------------------------
|
||||
CHNK.T .EQ 0
|
||||
CHNK.T.DIR .EQ 1
|
||||
CHNK.T.FILE .EQ 2
|
||||
CHNK.T.DATA .EQ 128
|
||||
*
|
||||
CHNK.TYPE .EQ 1 FILE/DIR
|
||||
CHNK.AUXTYPE .EQ 2
|
||||
CHNK.FNLEN .EQ 4
|
||||
*
|
||||
CHNK.ALG .EQ 1 DATA
|
||||
CHNK.ALG.STORE .EQ 0
|
||||
CHNK.ULEN .EQ 2
|
||||
*
|
||||
CHNK.CLEN .EQ 4
|
||||
*--------------------------------------
|
||||
MAN
|
||||
SAVE INC/PAK.I
|
@ -1,16 +1,15 @@
|
||||
NEW
|
||||
PREFIX
|
||||
AUTO 4,1
|
||||
AUTO 3,1
|
||||
.LIST OFF
|
||||
*--------------------------------------
|
||||
Pak.In.Init >LDYA Pak.SrcPtr
|
||||
>STYA ZPSrcPtr
|
||||
|
||||
lda Pak.Hdr+S.PAKHDR.LEN
|
||||
lda Pak.Shnk+S.PAKSHNK.LEN
|
||||
eor #$ff
|
||||
sta Pak.SrcCnt
|
||||
|
||||
lda Pak.Hdr+S.PAKHDR.LEN+1
|
||||
lda Pak.Shnk+S.PAKSHNK.LEN+1
|
||||
eor #$ff
|
||||
sta Pak.SrcCnt+1
|
||||
|
||||
@ -50,7 +49,7 @@ Pak.In.GetBit ldx Pak.In.Mask
|
||||
ldx #8
|
||||
|
||||
.1 dex
|
||||
stx Pak.In.GetBit+1
|
||||
stx Pak.In.Mask
|
||||
|
||||
pha Don't trash A
|
||||
lda (UnZPSrcPtr)
|
||||
@ -68,4 +67,5 @@ Pak.In.NxtByte inc UnZPSrcPtr
|
||||
*--------------------------------------
|
||||
MAN
|
||||
SAVE USR/SRC/LIB/LIBPAK.S.IN
|
||||
LOAD USR/SRC/LIB/LIBPAK.S
|
||||
ASM
|
||||
|
@ -1,6 +1,5 @@
|
||||
NEW
|
||||
PREFIX
|
||||
AUTO 4,1
|
||||
AUTO 3,1
|
||||
.LIST OFF
|
||||
*--------------------------------------
|
||||
Pak.Out.Init lda #$80
|
||||
@ -28,14 +27,22 @@ Pak.Out.PutA ldy #8
|
||||
|
||||
Pak.Out.Put.rts rts
|
||||
*--------------------------------------
|
||||
Pak.Out.PutYBits
|
||||
asl
|
||||
jsr Pak.Out.PutBitC
|
||||
bcs .9
|
||||
dey
|
||||
bne Pak.Out.PutYBits
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
Pak.Out.PutBitC pha
|
||||
|
||||
bcc .1
|
||||
lda Pak.Mask
|
||||
tsb Pak.Byte
|
||||
lda Pak.Out.Mask
|
||||
tsb Pak.Out.Byte
|
||||
clc
|
||||
|
||||
.1 lsr Pak.Mask
|
||||
.1 lsr Pak.Out.Mask
|
||||
bne .8
|
||||
|
||||
jsr Pak.Out.PutByte
|
||||
@ -56,8 +63,8 @@ Pak.Out.PutByte inc Pak.DstCnt
|
||||
inc Pak.DstCnt+1
|
||||
beq .9
|
||||
|
||||
.1 ldx Pak.Pass
|
||||
bne .6
|
||||
.1 bit Pak.bPass2
|
||||
bmi .6
|
||||
|
||||
phx
|
||||
tax
|
||||
@ -88,4 +95,5 @@ Pak.Out.PutByte inc Pak.DstCnt
|
||||
*--------------------------------------
|
||||
MAN
|
||||
SAVE USR/SRC/LIB/LIBPAK.S.OUT
|
||||
LOAD USR/SRC/LIB/LIBPAK.S
|
||||
ASM
|
||||
|
207
LIB/LIBPAK.S.txt
207
LIB/LIBPAK.S.txt
@ -3,7 +3,7 @@ NEW
|
||||
.LIST OFF
|
||||
.OP 65C02
|
||||
.OR $2000
|
||||
.TF LIB/LIBPAK.O
|
||||
.TF LIB/LIBPAK
|
||||
*--------------------------------------
|
||||
.INB INC/MACROS.I
|
||||
.INB INC/A2OSX.I
|
||||
@ -33,7 +33,6 @@ CS.START cld
|
||||
.1 .DA LIB.LOAD
|
||||
.DA LIB.UNLOAD
|
||||
.DA Pak
|
||||
.DA Unpak
|
||||
.DA 0
|
||||
*--------------------------------------
|
||||
LIB.LOAD
|
||||
@ -43,32 +42,15 @@ LIB.UNLOAD clc
|
||||
* # Pak
|
||||
* **In:**
|
||||
* ##ASM
|
||||
* PUSHW = Src PTR
|
||||
* PUSHW = Src Length
|
||||
* PUSHW = Dst PTR Output Buffer
|
||||
* PUSHW = Dst PTR S.PAKSTAT
|
||||
* PUSHW = S.PAKSTAT Ptr
|
||||
* PUSHW = Output Buffer Ptr
|
||||
* PUSHW = Input Buffer Len
|
||||
* PUSHW = Input Buffer Ptr
|
||||
*\--------------------------------------
|
||||
* PASS #1 : BL+REP dryrun with raw BYTE store (no bit prefix) -> Dst
|
||||
* if BL stat=0, disable BL in PASS #2
|
||||
* BuildShortTable with DST
|
||||
* PASS #2 : BL with store real prefixed S3,S4,REP & STORE -> Dst
|
||||
*--------------------------------------
|
||||
Pak >PULLW ZPStatPtr
|
||||
|
||||
>PULLA
|
||||
sta ZPHdrPtr
|
||||
clc
|
||||
adc #S.PAKHDR
|
||||
sta ZPDstPtr
|
||||
|
||||
>PULLA
|
||||
sta ZPHdrPtr+1
|
||||
adc /S.PAKHDR
|
||||
sta ZPDstPtr+1
|
||||
|
||||
>PULLW Pak.Hdr+S.PAKHDR.LEN
|
||||
|
||||
>PULLW Pak.SrcPtr
|
||||
Pak >PULLW Pak.SrcPtr
|
||||
>PULLW Pak.SrcLen
|
||||
>PULLW ZPDstPtr
|
||||
>PULLW ZPStatPtr
|
||||
|
||||
* Reset Byte counters
|
||||
|
||||
@ -81,10 +63,10 @@ Pak >PULLW ZPStatPtr
|
||||
|
||||
* PASS #1 : REP & BL, no store, update byte counters
|
||||
|
||||
jsr Pak.InitPass
|
||||
|
||||
stz Pak.bPass2
|
||||
|
||||
jsr Pak.InitPass
|
||||
|
||||
jsr Pak.Run
|
||||
bcs .9
|
||||
|
||||
@ -92,22 +74,20 @@ Pak >PULLW ZPStatPtr
|
||||
|
||||
* PASS #2 : REP & BL, store with S3,S4
|
||||
|
||||
jsr Pak.InitPass
|
||||
|
||||
dec Pak.bPass2
|
||||
|
||||
lda #$80
|
||||
sta Pak.Mask Initialize properly for
|
||||
stz Pak.Byte first "PutBit" Call
|
||||
jsr Pak.InitPass
|
||||
|
||||
jsr Pak.Out.Init Initialize properly for first "PutBit" Call
|
||||
|
||||
stz Pak.StoreCnt
|
||||
|
||||
jsr Pak.Run
|
||||
bcs .9
|
||||
|
||||
ldy #S.PAKHDR-1
|
||||
ldy #S.PAKSHNK-1
|
||||
|
||||
.2 lda Pak.Hdr,y
|
||||
.2 lda Pak.Shnk,y
|
||||
sta (ZPHdrPtr),y
|
||||
dey
|
||||
bpl .2
|
||||
@ -130,11 +110,11 @@ Pak.InitPass >LDYA Pak.SrcPtr
|
||||
>STYA ZPSrcPtr
|
||||
>STYA Pak.WPtr
|
||||
|
||||
lda Pak.Hdr+S.PAKHDR.LEN
|
||||
lda Pak.SrcLen
|
||||
eor #$ff
|
||||
sta Pak.SrcCnt
|
||||
|
||||
lda Pak.Hdr+S.PAKHDR.LEN+1
|
||||
lda Pak.SrcLen+1
|
||||
eor #$ff
|
||||
sta Pak.SrcCnt+1
|
||||
|
||||
@ -328,7 +308,7 @@ Pak.BuildShortTable
|
||||
sbc Pak.CntH,x
|
||||
bcs .8 not better or equal...
|
||||
|
||||
stx Pak.Byte save new score index...
|
||||
stx Pak.In.Byte save new score index...
|
||||
|
||||
lda Pak.CntL,x
|
||||
sta Pak.Cnt ...and value
|
||||
@ -338,8 +318,8 @@ Pak.BuildShortTable
|
||||
.8 inx
|
||||
bne .7
|
||||
|
||||
lda Pak.Byte
|
||||
sta Pak.Hdr+S.PAKHDR.SHORT3,y
|
||||
lda Pak.In.Byte
|
||||
sta Pak.Shnk+S.PAKSHNK.SHORT3,y
|
||||
tax
|
||||
stz Pak.CntL,x Discard this entry
|
||||
stz Pak.CntH,x
|
||||
@ -411,14 +391,14 @@ Pak.PutA.1 bit Pak.bPass2
|
||||
|
||||
.10 ldy #7
|
||||
|
||||
.1 cmp Pak.Hdr+S.PAKHDR.SHORT3,y
|
||||
.1 cmp Pak.Shnk+S.PAKSHNK.SHORT3,y
|
||||
beq .3
|
||||
dey
|
||||
bpl .1
|
||||
|
||||
ldy #15
|
||||
|
||||
.2 cmp Pak.Hdr+S.PAKHDR.SHORT4,y
|
||||
.2 cmp Pak.Shnk+S.PAKSHNK.SHORT4,y
|
||||
beq .4
|
||||
dey
|
||||
bpl .2
|
||||
@ -452,21 +432,15 @@ Pak.PutA.1 bit Pak.bPass2
|
||||
clc
|
||||
rts
|
||||
|
||||
.8 jsr Pak.UpdateStats
|
||||
*--------------------------------------
|
||||
Pak.PutYBits asl
|
||||
jsr Pak.PutBit
|
||||
bcs .9
|
||||
dey
|
||||
bne Pak.PutYBits
|
||||
.9 rts
|
||||
.8 jsr Pak.UpdateStats
|
||||
jmp Pak.Out.PutYBits
|
||||
*--------------------------------------
|
||||
Pak.Flush ldx Pak.StoreCnt
|
||||
beq .8
|
||||
|
||||
lda #PAK.B.STOREn
|
||||
ldy #4
|
||||
jsr Pak.PutYBits
|
||||
jsr Pak.Out.PutYBits
|
||||
bcs .9
|
||||
|
||||
ldx #0
|
||||
@ -474,7 +448,7 @@ Pak.Flush ldx Pak.StoreCnt
|
||||
.1 lda Pak.StoreBuf,x
|
||||
sta Pak.LastByte update last byte for REP
|
||||
ldy #8
|
||||
jsr Pak.PutYBits
|
||||
jsr Pak.Out.PutYBits
|
||||
bcs .9
|
||||
|
||||
inc Pak.Stat+S.PAKSTAT.STORE
|
||||
@ -494,128 +468,14 @@ Pak.UpdateStats inc Pak.Stat,x
|
||||
bne .8
|
||||
inc Pak.Stat+1,x
|
||||
.8 rts
|
||||
*/--------------------------------------
|
||||
* #UnPak
|
||||
* ##ASM
|
||||
* **In:**
|
||||
* PUSHW = Src PTR Compressed Buffer
|
||||
* PUSHW = Dst PTR
|
||||
*\--------------------------------------
|
||||
UnZPSrcPtr .EQ ZPLIB
|
||||
UnZPDstPtr .EQ ZPLIB+2
|
||||
UnPak.ShrtTbl .EQ ZPLIB+4
|
||||
UnPak.Cnt .EQ ZPLIB+6
|
||||
*--------------------------------------
|
||||
UnPak >PULLA Get Dst PTR LO
|
||||
sec
|
||||
sbc #1
|
||||
sta UnZPDstPtr
|
||||
>PULLA Get Dst PTR HI
|
||||
sbc #0
|
||||
sta UnZPDstPtr+1 setup Dst PTR-1
|
||||
|
||||
>PULLW UnZPSrcPtr
|
||||
|
||||
jsr UnPak.GetByte Get !LEN for counting up to $0000
|
||||
sta UnPak.Cnt
|
||||
|
||||
jsr UnPak.GetByte
|
||||
sta UnPak.Cnt+1
|
||||
|
||||
>LDYA UnZPSrcPtr Get PTR to Short Table.....
|
||||
>STYA UnPak.ShrtTbl and save it for SHORTx
|
||||
|
||||
lda #8
|
||||
sta UnPak.GetBit+1 Initialize properly for first "GetBit" Call
|
||||
|
||||
.1 inc UnPak.Cnt
|
||||
bne .2
|
||||
inc UnPak.Cnt+1
|
||||
beq .99
|
||||
|
||||
.2 jsr UnPak.GetBit
|
||||
bcs .4 CMD....
|
||||
*---- STORE
|
||||
jsr UnPak.GetBit
|
||||
ldx #1
|
||||
bcc .3 if CC one byte
|
||||
jsr UnPak.Get4Bits CC
|
||||
adc #2 range is 2->17
|
||||
tax
|
||||
|
||||
.3 jsr UnPak.Get8Bits
|
||||
jsr UnPak.PutByte
|
||||
dex
|
||||
bne .3
|
||||
bra .1
|
||||
.99 rts
|
||||
*---- CMD
|
||||
.4 jsr UnPak.GetBit
|
||||
bcs .6 BACKLINK or REP...
|
||||
*---- CMD : SHORT
|
||||
lda #0
|
||||
ldy #4
|
||||
|
||||
jsr UnPak.GetBit if CS short3
|
||||
rol make offset 00000001
|
||||
asl ....00000010
|
||||
beq .5
|
||||
|
||||
dey if short3, only 3 bits
|
||||
|
||||
.5 jsr UnPak.GetBit
|
||||
rol
|
||||
dey
|
||||
bne .5
|
||||
|
||||
tay if s3, offset is 00010xxx
|
||||
lda (UnPak.ShrtTbl),y if s4, offset is 0000xxxx
|
||||
jsr UnPak.PutByte
|
||||
bra .1
|
||||
*---- CMD : BACKLINK or REP
|
||||
.6 jsr UnPak.GetBit
|
||||
bcs .8 if CS -> REP
|
||||
*---- CMD : BACKLINK
|
||||
jsr UnPak.Get8Bits get Offset LO, (CC)
|
||||
eor #$ff !offset LO
|
||||
adc UnZPDstPtr equiv. SUB offset
|
||||
sta .7+1 PTR to Backlink LO
|
||||
lda UnZPDstPtr+1
|
||||
bcs .61 if ADC sets C, no need to dec HI
|
||||
dec
|
||||
.61 jsr UnPak.GetBit get Offset HI in C
|
||||
bcc .62
|
||||
dec
|
||||
.62 sta .7+2 PTR to Backlink HI
|
||||
|
||||
jsr UnPak.Get4Bits CC
|
||||
adc #3 Backlink are ate least 3 bytes...
|
||||
tax
|
||||
ldy #0
|
||||
|
||||
.7 lda $ffff,y Self Modified code : PTR to Backlink
|
||||
jsr UnPak.PutByte
|
||||
iny
|
||||
dex
|
||||
bne .7
|
||||
beq .1
|
||||
*---- CMD : REP
|
||||
.8 jsr UnPak.GetBit
|
||||
ldx #1
|
||||
bcc .9 REP 1
|
||||
|
||||
jsr UnPak.Get4Bits REP xxxx, CC
|
||||
adc #2 range is 2->17
|
||||
tax
|
||||
|
||||
.9 lda (UnZPDstPtr) Get Last Byte
|
||||
jsr UnPak.PutByte
|
||||
dex
|
||||
bne .9
|
||||
jmp .1
|
||||
* .INB USR/SRC/LIB/LIBPAK.S.IN
|
||||
.INB USR/SRC/LIB/LIBPAK.S.OUT
|
||||
*--------------------------------------
|
||||
CS.END
|
||||
Pak.SrcPtr .BS 2
|
||||
Pak.SrcLen .BS 2
|
||||
|
||||
Pak.SrcCnt .BS 2
|
||||
Pak.DstCnt .BS 2
|
||||
|
||||
@ -642,14 +502,13 @@ Pak.In.Mask .BS 1
|
||||
|
||||
Pak.Out.Byte .BS 1
|
||||
Pak.Out.Mask .BS 1
|
||||
|
||||
*--------------------------------------
|
||||
Pak.CntL .BS 256
|
||||
Pak.CntH .BS 256
|
||||
Pak.Hdr .BS S.PAKHDR
|
||||
Pak.Shnk .BS S.PAKSHNK
|
||||
Pak.Stat .BS S.PAKSTAT
|
||||
*--------------------------------------
|
||||
UnPak.BitMask .HS 8040201008040201
|
||||
Pak.In.BitMask .HS 8040201008040201
|
||||
MAN
|
||||
SAVE USR/SRC/LIB/LIBPAK.S
|
||||
ASM
|
||||
|
@ -3,40 +3,36 @@ NEW
|
||||
.LIST OFF
|
||||
*--------------------------------------
|
||||
* ZPInBufPtr = Ptr to Shunk Data
|
||||
* Header : 16 SHORT4
|
||||
* 8 SHORT3
|
||||
* ZPOutBufPtr = Ptr to Uncompressed Data
|
||||
* ZPULen = Uncompressed length
|
||||
*--------------------------------------
|
||||
* ZPPtr1
|
||||
* ZPPtr2
|
||||
* ZPnCnt = !ZPULen
|
||||
* ZPInMask
|
||||
* ZPOutLastByte
|
||||
*-OLD----------------------------------
|
||||
* SHORT3 : 0 xxx
|
||||
* SHORT4 : 10 xxxx
|
||||
* REPn : 110 xxxx (1-16)
|
||||
* BACKLINK : 1110 oooooooo OO llllll (3-66)
|
||||
* STOREn : 1111 xxxx (1-16)
|
||||
* ZPInMask,ZPOutLastByte
|
||||
*--------------------------------------
|
||||
X.Unpak lda ZPInBufPtr
|
||||
X.Unpak lda (ZPInBufPtr) ULEN LO
|
||||
eor #$ff
|
||||
sta ZPnCnt
|
||||
|
||||
jsr X.Unpak.NextByte
|
||||
|
||||
lda (ZPInBufPtr) ULEN HI
|
||||
sta ZPnCnt+1
|
||||
|
||||
jsr X.Unpak.NextByte
|
||||
|
||||
lda (ZPInBufPtr) TOPLEN
|
||||
|
||||
clc
|
||||
adc #24 skip SHORT4 & SHORT3
|
||||
adc ZPInBufPtr skip TOP table
|
||||
sta ZPPtr1
|
||||
|
||||
lda ZPInBufPtr+1
|
||||
adc #0
|
||||
sta ZPPtr1+1
|
||||
|
||||
jsr X.Unpak.NextByte
|
||||
|
||||
lda ZPULen
|
||||
eor #$ff
|
||||
sta ZPnCnt
|
||||
|
||||
lda ZPULen+1
|
||||
eor #$ff
|
||||
sta ZPnCnt+1
|
||||
|
||||
lda #$80
|
||||
sta ZPInMask
|
||||
|
||||
@ -48,54 +44,66 @@ X.Unpak lda ZPInBufPtr
|
||||
rts
|
||||
*--------------------------------------
|
||||
.2 jsr X.Unpak.GetBitInC
|
||||
bcs .3
|
||||
* SHORT3 : 0 xxx
|
||||
ldx #3
|
||||
jsr X.Unpak.GetXBitInA
|
||||
ora #$16 Skip SHORT4 (16 bytes)
|
||||
bra .31
|
||||
bcs .7 ->BACKLINK
|
||||
|
||||
jsr X.Unpak.GetBitInC
|
||||
bcs .3 ->TOP
|
||||
* BYTE8
|
||||
jsr X.Unpak.GetByteInA
|
||||
bra .52
|
||||
*--------------------------------------
|
||||
.3 jsr X.Unpak.GetBitInC
|
||||
bcs .4
|
||||
* SHORT4 : 10 xxxx
|
||||
ldx #4
|
||||
bcs .4 ->TOP16
|
||||
* TOP8
|
||||
ldx #3
|
||||
jsr X.Unpak.GetXBitInA
|
||||
.31 tay
|
||||
|
||||
bra .51
|
||||
*--------------------------------------
|
||||
.4 jsr X.Unpak.GetBitInC
|
||||
bcs .5 ->TOP24
|
||||
* TOP16
|
||||
ldx #3
|
||||
jsr X.Unpak.GetXBitInA
|
||||
ora #8
|
||||
|
||||
bra .51
|
||||
*--------------------------------------
|
||||
.5 jsr X.Unpak.GetBitInC
|
||||
bcs .6 ->REPn
|
||||
* TOP24
|
||||
ldx #3
|
||||
jsr X.Unpak.GetXBitInA
|
||||
ora #16
|
||||
|
||||
.51 tay
|
||||
lda (ZPInBufPtr),y
|
||||
jsr X.Unpak.PutByte
|
||||
|
||||
.52 jsr X.Unpak.PutByte
|
||||
bne .2
|
||||
clc
|
||||
rts
|
||||
*--------------------------------------
|
||||
.4 jsr X.Unpak.GetBitInC
|
||||
bcs .5
|
||||
* REPn : 110 xxxx
|
||||
ldx #4
|
||||
jsr X.Unpak.GetXBitInA
|
||||
|
||||
tay
|
||||
|
||||
lda ZPOutLastByte
|
||||
|
||||
.41 jsr X.Unpak.PutByte.1
|
||||
*--------------------------------------
|
||||
* REPn
|
||||
.6 lda ZPOutLastByte
|
||||
|
||||
.61 jsr X.Unpak.PutByte.1
|
||||
beq .99
|
||||
dey
|
||||
bpl .41 +1
|
||||
bpl .61 +1
|
||||
|
||||
bra .1
|
||||
|
||||
.99 sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
.5 jsr X.Unpak.GetBitInC
|
||||
bcs .6
|
||||
* BACKLINK : 1110 oooooooo OO llllll
|
||||
jsr X.Unpak.GetByteInA
|
||||
* BACKLINK : 1 oooooooo OOOO llllll
|
||||
.7 jsr X.Unpak.GetByteInA
|
||||
clc
|
||||
adc ZPOutBufPtr
|
||||
sta ZPPtr2
|
||||
php
|
||||
ldx #2
|
||||
ldx #4
|
||||
jsr X.Unpak.GetXBitInA
|
||||
plp
|
||||
adc ZPOutBufPtr+1
|
||||
@ -109,154 +117,14 @@ X.Unpak lda ZPInBufPtr
|
||||
|
||||
tay
|
||||
|
||||
.51 lda (ZPPtr2),y
|
||||
.71 lda (ZPPtr2),y
|
||||
jsr X.Unpak.PutByte
|
||||
beq .99
|
||||
dey
|
||||
bpl .51 +1
|
||||
bpl .71 +1
|
||||
|
||||
bra .1
|
||||
*--------------------------------------
|
||||
* STOREn : 1111 cccc Byte Byte Byte ...
|
||||
.6 ldx #4
|
||||
jsr X.Unpak.GetXBitInA
|
||||
|
||||
tay
|
||||
|
||||
.61 jsr X.Unpak.GetByteInA
|
||||
jsr X.Unpak.PutByte
|
||||
beq .99
|
||||
dey
|
||||
bpl .61 +1
|
||||
|
||||
bra .1
|
||||
|
||||
.9 sec
|
||||
rts
|
||||
*-NEW----------------------------------
|
||||
* STRINGn : 0 xxxx
|
||||
* {
|
||||
* BYTE8 : 0 xxxxxxxx
|
||||
* SHORT8 : 10 xxx
|
||||
* SHORT16 : 110 xxxx
|
||||
* REPn : 111 xxxx (1-16)
|
||||
* }
|
||||
* BACKLINK : 1 oooooooo OOOO llllll (3-66)
|
||||
*--------------------------------------
|
||||
X.Unpak2 lda ZPInBufPtr
|
||||
clc
|
||||
adc #24 skip SHORTs
|
||||
sta ZPPtr1
|
||||
|
||||
lda ZPInBufPtr+1
|
||||
adc #0
|
||||
sta ZPPtr1+1
|
||||
|
||||
lda ZPULen
|
||||
eor #$ff
|
||||
sta ZPnCnt
|
||||
|
||||
lda ZPULen+1
|
||||
eor #$ff
|
||||
sta ZPnCnt+1
|
||||
|
||||
lda #$80
|
||||
sta ZPInMask
|
||||
|
||||
.1 lda ZPnCnt
|
||||
ora ZPnCnt+1
|
||||
bne .2
|
||||
|
||||
clc
|
||||
rts
|
||||
*--------------------------------------
|
||||
.2 jsr X.Unpak.GetBitInC
|
||||
bcs .3
|
||||
* SHORT3 : 0 xxx
|
||||
ldx #3
|
||||
jsr X.Unpak.GetXBitInA
|
||||
ora #$16 Skip SHORT4 (16 bytes)
|
||||
bra .31
|
||||
*--------------------------------------
|
||||
.3 jsr X.Unpak.GetBitInC
|
||||
bcs .4
|
||||
* SHORT4 : 10 xxxx
|
||||
ldx #4
|
||||
jsr X.Unpak.GetXBitInA
|
||||
.31 tay
|
||||
lda (ZPInBufPtr),y
|
||||
jsr X.Unpak.PutByte
|
||||
bne .2
|
||||
clc
|
||||
rts
|
||||
*--------------------------------------
|
||||
.4 jsr X.Unpak.GetBitInC
|
||||
bcs .5
|
||||
* REPn : 110 xxxx
|
||||
ldx #4
|
||||
jsr X.Unpak.GetXBitInA
|
||||
|
||||
tay
|
||||
|
||||
lda ZPOutLastByte
|
||||
|
||||
.41 jsr X.Unpak.PutByte.1
|
||||
beq .99
|
||||
dey
|
||||
bpl .41 +1
|
||||
|
||||
bra .1
|
||||
|
||||
.99 sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
.5 jsr X.Unpak.GetBitInC
|
||||
bcs .6
|
||||
* BACKLINK : 1110 oooooooo OO llllll
|
||||
jsr X.Unpak.GetByteInA
|
||||
clc
|
||||
adc ZPOutBufPtr
|
||||
sta ZPPtr2
|
||||
php
|
||||
ldx #2
|
||||
jsr X.Unpak.GetXBitInA
|
||||
plp
|
||||
adc ZPOutBufPtr+1
|
||||
sta ZPPtr2+1
|
||||
|
||||
jsr X.Unpak.GetByteInA
|
||||
|
||||
inc +1
|
||||
inc +1
|
||||
* inc +1
|
||||
|
||||
tay
|
||||
|
||||
.51 lda (ZPPtr2),y
|
||||
jsr X.Unpak.PutByte
|
||||
beq .99
|
||||
dey
|
||||
bpl .51 +1
|
||||
|
||||
bra .1
|
||||
*--------------------------------------
|
||||
* STOREn : 1111 cccc Byte Byte Byte ...
|
||||
.6 ldx #4
|
||||
jsr X.Unpak.GetXBitInA
|
||||
|
||||
tay
|
||||
|
||||
.61 jsr X.Unpak.GetByteInA
|
||||
jsr X.Unpak.PutByte
|
||||
beq .99
|
||||
dey
|
||||
bpl .61 +1
|
||||
|
||||
bra .1
|
||||
|
||||
.9 sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
X.Unpak.GetByteInA
|
||||
ldx #8
|
||||
|
||||
@ -281,17 +149,22 @@ X.Unpak.GetBitInC
|
||||
.1 php
|
||||
|
||||
lsr ZPInMask
|
||||
bne .8
|
||||
bcc .8
|
||||
|
||||
ror ZPInMask
|
||||
|
||||
jsr X.Unpak.NextByte
|
||||
|
||||
.8 plp
|
||||
pla
|
||||
rts
|
||||
*--------------------------------------
|
||||
X.Unpak.NextByte
|
||||
inc ZPPtr1
|
||||
bne .8
|
||||
inc ZPPtr1+1
|
||||
|
||||
.8 plp
|
||||
pla
|
||||
rts
|
||||
.8 rts
|
||||
*--------------------------------------
|
||||
X.Unpak.PutByte sta ZPOutLastByte
|
||||
X.Unpak.PutByte.1
|
||||
|
Loading…
x
Reference in New Issue
Block a user