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