Kernel 0.93+

This commit is contained in:
Rémy GIBERT 2019-09-24 17:25:07 +02:00
parent 13a2d390ca
commit 171189247a
5 changed files with 329 additions and 206 deletions

Binary file not shown.

View File

@ -190,7 +190,7 @@ CS.RUN.LOOP ldy #S.PS.hStdIn
cmp (ZPBufPtr2),y
beq .8
lda #1
lda #$E0
sta bDiff
bit bVerbose
@ -225,7 +225,7 @@ CS.RUN.OPEN >PUSHWZ Aux type
CS.RUN.SEEK >LDYA ZPPtr1
>SYSCALL atol
bcs .9
>PULLL SeekOfs
lda bSkip1
@ -234,6 +234,7 @@ CS.RUN.SEEK >LDYA ZPPtr1
>PUSHBI SEEK.SET
>PUSHL SeekOfs
lda hFile1
>SYSCALL fseek
bcs .9

View File

@ -16,20 +16,17 @@ CHNK.SIZE .EQ 4096
.OR ZPBIN
ZS.START
ZPPtr1 .BS 2
ZPInBufPtr .BS 2
ZPULen .BS 2
ZPPtr2 .BS 2
ZPPakHdrPtr .BS 2
ZPPakDataPtr .BS 2
ZPPakSrcPtr .BS 2
ZPFullPathPtr .BS 2
ZPRelPathPtr .BS 2
UNPAK.Mask .BS 2
UNPAK.LastByte .BS 2
UNPAK.Cnt .BS 2
UNPAK.Ofs .BS 2
UNPAK.BLOfs .BS 2
ZPInBufPtr .BS 2
ZPOutBufPtr .BS 2
ZPULen .BS 2
ZPnCnt .BS 2
ZPInMask .BS 1
ZPOutLastByte .BS 1
ZS.END .ED
*--------------------------------------
* File Header (16 Bytes)
@ -342,196 +339,6 @@ CS.RUN.WriteFile
>SYSCALL fwrite
rts
*--------------------------------------
* Y,A = Ptr to Shunk Header:
* +0 : Flags
* 10000000 : LZ8 encoded, 1 byte (ESC) follow
* 01000000 : BS
*--------------------------------------
CS.RUN.UnpakChnk
lda ZPPakHdrPtr
clc
adc #S.PAKSTAT
sta ZPPakDataPtr
lda ZPPakHdrPtr+1
adc /S.PAKSTAT
sta ZPPakDataPtr+1
lda (ZPPakHdrPtr)
eor #$ff
sta UNPAK.Cnt
ldy #1
lda (ZPPakHdrPtr),y
eor #$ff
sta UNPAK.Cnt+1
lda #$80
sta UNPAK.Mask
stz UNPAK.Ofs
stz UNPAK.Ofs+1
.1 inc UNPAK.Cnt
bne .2
inc UNPAK.Cnt+1
bne .2
lda #0
sec
rts
.2 lda #'>'
>SYSCALL PutChar
jsr CS.RUN.UnpakGetBitInC
bcs .3
*--------------------------------------
* SHORT3
ldx #3
jsr CS.RUN.UnpakGetXBitInA
clc
* adc #S.PAKHDR.SHORT3
tay
lda (ZPPakHdrPtr),y
sta UNPAK.LastByte
jsr CS.RUN.UnpakCmpA
bcs .9
bra .1
.3 jsr CS.RUN.UnpakGetBitInC
bcs .4
*--------------------------------------
* SHORT4
ldx #4
jsr CS.RUN.UnpakGetXBitInA
clc
* adc #S.PAKHDR.SHORT4
tay
lda (ZPPakHdrPtr),y
sta UNPAK.LastByte
jsr CS.RUN.UnpakCmpA
bcs .9
bra .1
.4 jsr CS.RUN.UnpakGetBitInC
bcs .5
*--------------------------------------
* REPn
ldx #4
jsr CS.RUN.UnpakGetXBitInA
tay
tax
lda UNPAK.LastByte
.41 jsr CS.RUN.UnpakCmpA
bcs .9
dey
bne .41
.42 txa
clc
adc UNPAK.Cnt
sta UNPAK.Cnt
bcc .2
inc UNPAK.Cnt+1
bra .2
.5 jsr CS.RUN.UnpakGetBitInC
bcs .6
*--------------------------------------
* BACKLINK
ldx #4
jsr CS.RUN.UnpakGetXBitInA
sta UNPAK.BLOfs+1
jsr CS.RUN.UnpakGetByteInA
sta UNPAK.BLOfs
jsr CS.RUN.UnpakGetByteInA
tax
tay
.51
bra .42
*--------------------------------------
* STOREn
.6 ldx #4
jsr CS.RUN.UnpakGetXBitInA
tay
tax
.61 jsr CS.RUN.UnpakGetByteInA
dey
bne .61
sta UNPAK.LastByte
bra .42
.9 >PUSHW UNPAK.Ofs
>PUSHBI 2
>LDYA L.MSG.ERR
>SYSCALL printf
lda #0
sec
rts
*--------------------------------------
CS.RUN.UnpakGetByteInA
ldx #8
*--------------------------------------
CS.RUN.UnpakGetXBitInA
lda #0
.1 jsr CS.RUN.UnpakGetBitInC
rol
dex
bne .1
rts
*--------------------------------------
CS.RUN.UnpakGetBitInC
pha
clc
lda (ZPPakDataPtr)
and UNPAK.Mask
beq .1
sec
.1 php
lsr UNPAK.Mask
bne .8
lda #$80
sta UNPAK.Mask
inc ZPPakDataPtr
bne .8
inc ZPPakDataPtr+1
.8 plp
pla
rts
*--------------------------------------
CS.RUN.UnpakCmpA
cmp (ZPPakSrcPtr)
bne .9
inc ZPPakSrcPtr
bne .1
inc ZPPakSrcPtr+1
.1 inc UNPAK.Ofs
bne .8
inc UNPAK.Ofs+1
.8 clc
rts
.9 sec
rts
*--------------------------------------
CS.DOEVENT sec
rts
*--------------------------------------
@ -562,6 +369,8 @@ CS.QUIT >LDA.G hFile
.8 clc
rts
*--------------------------------------
.INB USR/SRC/SHARED/X.UNPAK.S
*--------------------------------------
CS.END
MSG.USAGE .AZ "Usage : UNPAK Archive [DstDir]\r\n"

314
SHARED/X.UNPAK.S.txt Normal file
View File

@ -0,0 +1,314 @@
NEW
AUTO 3,1
.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)
*--------------------------------------
X.Unpak lda ZPInBufPtr
clc
adc #24 skip SHORT4 & SHORT3
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
*-NEW----------------------------------
* STOREn : 0 xxxx
* {
* BYTE8 : 0 xxxxxxxx
* SHORT32 : 10 xxxx
* REPn : 11 xxxx (1-16)
* }
* BACKLINK : 1 oooooooo OOOO llllll (3-66)
*--------------------------------------
X.Unpak2 lda ZPInBufPtr
clc
adc #24 skip SHORT32
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
X.Unpak.GetXBitInA
lda #0
.1 jsr X.Unpak.GetBitInC
rol
dex
bne .1
rts
*--------------------------------------
X.Unpak.GetBitInC
pha
clc
lda (ZPPtr1)
and ZPInMask
beq .1
sec
.1 php
lsr ZPInMask
bne .8
ror ZPInMask
inc ZPPtr1
bne .8
inc ZPPtr1+1
.8 plp
pla
rts
*--------------------------------------
X.Unpak.PutByte sta ZPOutLastByte
X.Unpak.PutByte.1
sta (ZPOutBufPtr)
inc ZPOutBufPtr
bne .1
inc ZPOutBufPtr+1
.1 inc ZPnCnt
bne .2
inc ZPnCnt+1
.2 rts
*--------------------------------------
.LIST ON
X.Unpak.Size .EQ *-X.Unpak
.LIST OFF
*--------------------------------------
MAN
SAVE USR/SRC/SHARED/X.UNPAK.S
LOAD USR/SRC/BIN/UNPAK.S
ASM

View File

@ -1121,15 +1121,14 @@ K.FSeek jsr PFT.CheckNodeA
.11 lda (pFD)
bne STDIO.IOERR
>PULLA whence
tax
>PULLL ACC32
>PULLA whence
cpx #SEEK.END
cmp #SEEK.END
beq .30
bcs .98
dex
dec
beq .20
stz K.MLI.PARAMS+2