2019-09-19 15:22:14 +00:00
|
|
|
|
NEW
|
|
|
|
|
AUTO 3,1
|
2016-12-09 16:36:24 +00:00
|
|
|
|
.LIST OFF
|
|
|
|
|
.OP 65C02
|
|
|
|
|
.OR $2000
|
2019-12-03 15:42:17 +00:00
|
|
|
|
.TF lib/libpak
|
2017-03-29 15:48:15 +00:00
|
|
|
|
*--------------------------------------
|
2021-01-12 21:14:13 +00:00
|
|
|
|
.INB inc/macros.i
|
|
|
|
|
.INB inc/a2osx.i
|
|
|
|
|
.INB inc/libpak.i
|
2017-03-29 15:48:15 +00:00
|
|
|
|
*--------------------------------------
|
2019-10-16 14:31:49 +00:00
|
|
|
|
STATS .EQ 0
|
2019-10-14 05:23:09 +00:00
|
|
|
|
*--------------------------------------
|
2018-03-16 16:33:11 +00:00
|
|
|
|
ZPSrcPtr .EQ ZPLIB
|
2019-10-04 15:47:26 +00:00
|
|
|
|
ZPDstPtr .EQ ZPLIB+2
|
|
|
|
|
ZPStatPtr .EQ ZPLIB+4
|
2019-10-14 05:23:09 +00:00
|
|
|
|
ZPSrcBLPtr .EQ ZPLIB+6
|
|
|
|
|
ZPCnt .EQ ZPLIB+8
|
|
|
|
|
ZPBLCnt .EQ ZPLIB+10
|
2017-03-29 15:48:15 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
* File Header (16 Bytes)
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.START cld
|
|
|
|
|
jmp (.1,x)
|
|
|
|
|
.DA #$61 6502,Level 1 (65c02)
|
|
|
|
|
.DA #1 BIN Layout Version 1
|
|
|
|
|
.DA 0
|
|
|
|
|
.DA CS.END-CS.START
|
|
|
|
|
.DA 0
|
|
|
|
|
.DA 0
|
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Relocation Table
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.1 .DA LIB.LOAD
|
|
|
|
|
.DA LIB.UNLOAD
|
|
|
|
|
.DA Pak
|
2019-10-14 05:23:09 +00:00
|
|
|
|
.DO STATS=1
|
2019-10-02 15:21:03 +00:00
|
|
|
|
L.MSG.Stats .DA MSG.Stats
|
2019-10-11 13:53:03 +00:00
|
|
|
|
L.MSG.TopBytes .DA MSG.TopBytes
|
2019-10-14 05:23:09 +00:00
|
|
|
|
.FIN
|
2017-03-29 15:48:15 +00:00
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
LIB.LOAD
|
|
|
|
|
LIB.UNLOAD clc
|
|
|
|
|
rts
|
2018-02-05 16:25:25 +00:00
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # Pak
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* ##ASM
|
2019-10-02 15:21:03 +00:00
|
|
|
|
* `>PUSHW StatPtr`
|
|
|
|
|
* `>PUSHW DstPtr`
|
|
|
|
|
* `>PUSHW SrcLen`
|
|
|
|
|
* `>PUSHW SrcPtr`
|
|
|
|
|
* `>LIBCALL hLIBPAK,Pak`
|
|
|
|
|
* ## RETURN VALUE
|
|
|
|
|
* CC, Y,A = CLEN
|
|
|
|
|
* CS, Pak failure
|
2018-02-05 16:25:25 +00:00
|
|
|
|
*\--------------------------------------
|
2019-09-25 15:34:43 +00:00
|
|
|
|
Pak >PULLW Pak.SrcPtr
|
2019-10-03 15:39:08 +00:00
|
|
|
|
>PULLW Pak.Shnk+S.PAKSHNK.ULEN
|
2019-09-25 15:34:43 +00:00
|
|
|
|
>PULLW ZPDstPtr
|
|
|
|
|
>PULLW ZPStatPtr
|
2018-02-09 16:02:47 +00:00
|
|
|
|
|
|
|
|
|
* Reset Byte counters
|
|
|
|
|
|
|
|
|
|
ldx #0
|
|
|
|
|
|
|
|
|
|
.1 stz Pak.CntL,x
|
|
|
|
|
stz Pak.CntH,x
|
|
|
|
|
inx
|
|
|
|
|
bne .1
|
2019-10-16 14:31:49 +00:00
|
|
|
|
|
|
|
|
|
ldx #S.PAKSTAT.PASS2+1
|
|
|
|
|
|
|
|
|
|
.2 stz Pak.Stat,x Reset Stats
|
|
|
|
|
dex
|
|
|
|
|
bpl .2
|
2019-10-02 15:21:03 +00:00
|
|
|
|
|
2019-09-27 14:53:44 +00:00
|
|
|
|
* PASS #1 : no store, update byte counters
|
2018-02-08 16:39:56 +00:00
|
|
|
|
|
2018-02-09 16:02:47 +00:00
|
|
|
|
stz Pak.bPass2
|
2018-02-08 16:39:56 +00:00
|
|
|
|
|
2019-11-05 13:36:10 +00:00
|
|
|
|
jsr Pak.Out.Init Initialize properly for first "PutBit" Call
|
|
|
|
|
bcs .9
|
|
|
|
|
|
2018-02-09 07:04:19 +00:00
|
|
|
|
jsr Pak.Run
|
2019-10-02 15:21:03 +00:00
|
|
|
|
|
2019-10-11 13:06:33 +00:00
|
|
|
|
jsr Pak.ComputeLenBits
|
2019-09-27 14:53:44 +00:00
|
|
|
|
jsr Pak.BuildTOPTable
|
2019-10-02 15:21:03 +00:00
|
|
|
|
|
2019-10-14 05:23:09 +00:00
|
|
|
|
.DO STATS=1
|
2019-10-02 15:21:03 +00:00
|
|
|
|
jsr Pak.PrintStats
|
2019-10-14 05:23:09 +00:00
|
|
|
|
.FIN
|
2018-02-09 07:04:19 +00:00
|
|
|
|
|
2019-09-27 14:53:44 +00:00
|
|
|
|
* PASS #2 : store with TOP bytes
|
2018-02-08 16:39:56 +00:00
|
|
|
|
|
2018-02-09 16:02:47 +00:00
|
|
|
|
dec Pak.bPass2
|
2018-02-08 16:39:56 +00:00
|
|
|
|
|
2019-09-25 15:34:43 +00:00
|
|
|
|
jsr Pak.Out.Init Initialize properly for first "PutBit" Call
|
2019-10-15 15:32:50 +00:00
|
|
|
|
bcs .9
|
2018-02-08 16:39:56 +00:00
|
|
|
|
|
2018-02-09 07:04:19 +00:00
|
|
|
|
jsr Pak.Run
|
|
|
|
|
bcs .9
|
2019-10-03 15:39:08 +00:00
|
|
|
|
|
2019-10-16 06:09:13 +00:00
|
|
|
|
jsr Pak.Out.Close
|
|
|
|
|
bcs .9
|
|
|
|
|
|
2018-02-08 16:39:56 +00:00
|
|
|
|
ldy #S.PAKSTAT-1
|
|
|
|
|
|
2019-10-02 15:21:03 +00:00
|
|
|
|
.7 lda Pak.Stat,y
|
2018-02-08 16:39:56 +00:00
|
|
|
|
sta (ZPStatPtr),y
|
|
|
|
|
dey
|
2019-10-02 15:21:03 +00:00
|
|
|
|
bpl .7
|
2019-10-11 13:53:03 +00:00
|
|
|
|
|
2019-11-05 13:36:10 +00:00
|
|
|
|
.DO STATS=1
|
|
|
|
|
jsr Pak.PrintStats
|
|
|
|
|
.FIN
|
2019-10-03 15:39:08 +00:00
|
|
|
|
>LDYA Pak.Stat+S.PAKSTAT.PASS2
|
2018-02-08 16:39:56 +00:00
|
|
|
|
clc
|
2018-02-09 07:04:19 +00:00
|
|
|
|
|
2019-11-05 13:36:10 +00:00
|
|
|
|
.DO STATS=1
|
|
|
|
|
rts
|
|
|
|
|
.FIN
|
2019-10-02 15:21:03 +00:00
|
|
|
|
|
2019-11-05 13:36:10 +00:00
|
|
|
|
.9
|
|
|
|
|
.DO STATS=1
|
|
|
|
|
jsr Pak.PrintStats
|
|
|
|
|
sec
|
|
|
|
|
.FIN
|
|
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
Pak.Out.Init lda Pak.Shnk+S.PAKSHNK.ULEN
|
2019-10-04 15:47:26 +00:00
|
|
|
|
eor #$ff
|
|
|
|
|
sta Pak.SrcCnt
|
|
|
|
|
sta Pak.DstCnt
|
2018-02-08 16:39:56 +00:00
|
|
|
|
|
2019-10-04 15:47:26 +00:00
|
|
|
|
lda Pak.Shnk+S.PAKSHNK.ULEN+1
|
|
|
|
|
eor #$ff
|
|
|
|
|
sta Pak.SrcCnt+1
|
|
|
|
|
sta Pak.DstCnt+1
|
2019-10-10 15:52:45 +00:00
|
|
|
|
|
2019-11-05 13:36:10 +00:00
|
|
|
|
bit Pak.bPass2
|
|
|
|
|
bpl .8
|
|
|
|
|
|
|
|
|
|
lda Pak.Shnk+S.PAKSHNK.BLBITS
|
|
|
|
|
jsr Pak.Out.PutByte
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
lda Pak.Shnk+S.PAKSHNK.ULEN
|
|
|
|
|
jsr Pak.Out.PutByte
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
lda Pak.Shnk+S.PAKSHNK.ULEN+1
|
|
|
|
|
jsr Pak.Out.PutByte
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
lda Pak.Shnk+S.PAKSHNK.TOPCNT
|
|
|
|
|
jsr Pak.Out.PutByte
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
tax
|
|
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
.1 lda Pak.Shnk+S.PAKSHNK.TOPBYTES,y
|
|
|
|
|
jsr Pak.Out.PutByte
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
dex
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
lda #$80
|
|
|
|
|
sta Pak.Out.Mask
|
|
|
|
|
stz Pak.Out.Byte
|
|
|
|
|
|
|
|
|
|
.8 clc
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
Pak.Run >LDYA Pak.SrcPtr
|
|
|
|
|
>STYA ZPSrcPtr
|
|
|
|
|
|
|
|
|
|
stz Pak.BL.Longest
|
|
|
|
|
stz Pak.BL.Farest
|
|
|
|
|
stz Pak.BL.Farest+1
|
|
|
|
|
|
2019-10-16 14:31:49 +00:00
|
|
|
|
ldx #S.PAKSTAT.TOP8
|
2019-10-03 15:39:08 +00:00
|
|
|
|
|
2019-10-04 15:47:26 +00:00
|
|
|
|
.1 stz Pak.Stat,x Reset Stats
|
|
|
|
|
inx
|
|
|
|
|
cpx #S.PAKSTAT
|
2018-02-08 16:39:56 +00:00
|
|
|
|
bne .1
|
2019-10-04 15:47:26 +00:00
|
|
|
|
|
2019-10-02 15:21:03 +00:00
|
|
|
|
Pak.Run.1 inc Pak.SrcCnt
|
2018-02-09 07:04:19 +00:00
|
|
|
|
bne .1
|
2018-02-08 16:39:56 +00:00
|
|
|
|
|
2019-10-02 15:21:03 +00:00
|
|
|
|
inc Pak.SrcCnt+1
|
2018-02-09 07:04:19 +00:00
|
|
|
|
beq .8 0 byte left...
|
|
|
|
|
|
2019-10-14 05:23:09 +00:00
|
|
|
|
.1 jsr Pak.ScanBL
|
2019-10-09 15:43:31 +00:00
|
|
|
|
bcs .20
|
2019-10-07 15:49:03 +00:00
|
|
|
|
|
2019-10-11 13:06:33 +00:00
|
|
|
|
jsr Pak.PutBL
|
2019-10-07 15:49:03 +00:00
|
|
|
|
bcs .9
|
2019-10-11 13:06:33 +00:00
|
|
|
|
|
|
|
|
|
ldy Pak.BestBLLen
|
2019-10-10 15:52:45 +00:00
|
|
|
|
|
2019-10-09 15:43:31 +00:00
|
|
|
|
.6 tya
|
2018-02-08 16:39:56 +00:00
|
|
|
|
clc
|
|
|
|
|
adc ZPSrcPtr
|
|
|
|
|
sta ZPSrcPtr
|
2019-10-09 15:43:31 +00:00
|
|
|
|
bcc .7
|
2018-02-08 16:39:56 +00:00
|
|
|
|
inc ZPSrcPtr+1
|
|
|
|
|
|
2019-10-09 15:43:31 +00:00
|
|
|
|
.7 tya
|
2019-10-02 15:21:03 +00:00
|
|
|
|
clc
|
2018-02-08 16:39:56 +00:00
|
|
|
|
adc Pak.SrcCnt
|
|
|
|
|
sta Pak.SrcCnt
|
2019-10-02 15:21:03 +00:00
|
|
|
|
bcc .1
|
2018-02-08 16:39:56 +00:00
|
|
|
|
inc Pak.SrcCnt+1
|
2019-10-02 15:21:03 +00:00
|
|
|
|
bmi .1
|
2019-10-10 15:52:45 +00:00
|
|
|
|
|
2019-10-13 08:35:31 +00:00
|
|
|
|
.8 clc
|
2019-10-02 15:21:03 +00:00
|
|
|
|
|
|
|
|
|
.9 rts
|
2019-10-09 15:43:31 +00:00
|
|
|
|
|
|
|
|
|
.20 lda (ZPSrcPtr) Not found...
|
|
|
|
|
jsr Pak.PutByte8
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
inc ZPSrcPtr
|
|
|
|
|
bne Pak.Run.1
|
|
|
|
|
inc ZPSrcPtr+1
|
|
|
|
|
bra Pak.Run.1
|
2019-10-07 15:49:03 +00:00
|
|
|
|
*--------------------------------------
|
2019-10-09 05:45:36 +00:00
|
|
|
|
Pak.ScanBL >LDYA Pak.SrcPtr Start at beginning of Src buf
|
|
|
|
|
>STYA ZPSrcBLPtr
|
|
|
|
|
|
|
|
|
|
lda #$ff
|
|
|
|
|
sta Pak.bBLFound
|
|
|
|
|
stz Pak.BestBLLen
|
|
|
|
|
|
|
|
|
|
.1 lda ZPSrcBLPtr
|
|
|
|
|
sec
|
|
|
|
|
sbc ZPSrcPtr
|
|
|
|
|
sta ZPBLCnt
|
|
|
|
|
|
|
|
|
|
lda ZPSrcBLPtr+1
|
|
|
|
|
sbc ZPSrcPtr+1
|
|
|
|
|
sta ZPBLCnt+1 ZPSrcBLPtr < !BlCnt < ZPSrcPtr
|
|
|
|
|
bcs .8 ZPSrcBLPtr = ZPSrcPtr, exit
|
|
|
|
|
|
|
|
|
|
>LDYA Pak.SrcCnt make sure not going past End Buffer
|
|
|
|
|
>STYA ZPCnt while reading ahead
|
|
|
|
|
|
|
|
|
|
ldy #0 ...or Y = BL.MAX
|
|
|
|
|
|
|
|
|
|
.2 inc ZPBLCnt
|
|
|
|
|
bne .3
|
|
|
|
|
|
|
|
|
|
inc ZPBLCnt+1
|
|
|
|
|
beq .6 ZPSrcBLPtr = ZPSrcPtr
|
|
|
|
|
|
|
|
|
|
.3 inc ZPCnt
|
|
|
|
|
bne .4
|
|
|
|
|
|
|
|
|
|
inc ZPCnt+1
|
|
|
|
|
beq .6 Last Src Data
|
|
|
|
|
|
|
|
|
|
.4 lda (ZPSrcPtr),y
|
|
|
|
|
cmp (ZPSrcBLPtr),y
|
|
|
|
|
bne .6 End of string matching
|
|
|
|
|
|
|
|
|
|
.5 iny
|
|
|
|
|
cpy #BL.MAX
|
|
|
|
|
bne .2 Max BL len
|
|
|
|
|
|
|
|
|
|
.6 cpy #BL.MIN
|
|
|
|
|
bcc .7 not long enough
|
|
|
|
|
|
|
|
|
|
cpy Pak.BestBLLen
|
|
|
|
|
bcc .7 not better ...
|
|
|
|
|
* beq .7 !!! same...but closer !!!
|
|
|
|
|
|
|
|
|
|
sty Pak.BestBLLen
|
|
|
|
|
|
|
|
|
|
lda ZPSrcPtr
|
|
|
|
|
sec
|
|
|
|
|
sbc ZPSrcBLPtr
|
|
|
|
|
sta Pak.BestBL
|
|
|
|
|
|
|
|
|
|
lda ZPSrcPtr+1
|
|
|
|
|
sbc ZPSrcBLPtr+1
|
|
|
|
|
sta Pak.BestBL+1
|
|
|
|
|
|
|
|
|
|
stz Pak.bBLFound
|
|
|
|
|
|
|
|
|
|
.7 inc ZPSrcBLPtr
|
|
|
|
|
bne .1
|
|
|
|
|
inc ZPSrcBLPtr+1
|
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
|
|
.8 rol Pak.bBLFound
|
|
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2019-10-11 13:06:33 +00:00
|
|
|
|
Pak.ComputeLenBits
|
2019-10-14 05:23:09 +00:00
|
|
|
|
ldx #0
|
|
|
|
|
lda Pak.BL.Longest
|
|
|
|
|
beq .10
|
2019-10-11 13:06:33 +00:00
|
|
|
|
|
2019-10-15 15:32:50 +00:00
|
|
|
|
ldx #3
|
2019-10-11 13:06:33 +00:00
|
|
|
|
|
2019-10-07 15:49:03 +00:00
|
|
|
|
dec
|
|
|
|
|
dec
|
|
|
|
|
dec
|
2019-10-15 15:32:50 +00:00
|
|
|
|
beq .10
|
|
|
|
|
|
|
|
|
|
ldx #8
|
2018-02-08 16:39:56 +00:00
|
|
|
|
|
2019-10-07 15:49:03 +00:00
|
|
|
|
.1 asl
|
|
|
|
|
bcs .10
|
|
|
|
|
dex
|
|
|
|
|
bra .1
|
2016-12-09 16:36:24 +00:00
|
|
|
|
|
2019-10-07 15:49:03 +00:00
|
|
|
|
.10 stx Pak.BL.LenBits
|
|
|
|
|
|
2019-10-14 05:23:09 +00:00
|
|
|
|
ldx #0
|
2019-10-07 15:49:03 +00:00
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
lda Pak.BL.Farest+1
|
|
|
|
|
beq .22
|
|
|
|
|
|
|
|
|
|
ldy #8
|
2019-10-14 05:23:09 +00:00
|
|
|
|
ldx #8
|
|
|
|
|
|
2019-10-07 15:49:03 +00:00
|
|
|
|
.2 asl
|
|
|
|
|
bcs .4
|
|
|
|
|
dey
|
|
|
|
|
bra .2
|
|
|
|
|
|
|
|
|
|
.22 lda Pak.BL.Farest
|
2019-10-14 05:23:09 +00:00
|
|
|
|
beq .4
|
|
|
|
|
|
|
|
|
|
ldx #8
|
|
|
|
|
|
2019-10-07 15:49:03 +00:00
|
|
|
|
.3 asl
|
|
|
|
|
bcs .4
|
|
|
|
|
dex
|
|
|
|
|
bra .3
|
|
|
|
|
|
|
|
|
|
.4 stx Pak.BL.OfsBitsL
|
|
|
|
|
sty Pak.BL.OfsBitsH
|
2019-10-09 15:43:31 +00:00
|
|
|
|
|
|
|
|
|
lda Pak.BL.LenBits
|
|
|
|
|
asl
|
|
|
|
|
asl
|
|
|
|
|
asl
|
|
|
|
|
asl
|
|
|
|
|
|
|
|
|
|
adc Pak.BL.OfsBitsL
|
|
|
|
|
adc Pak.BL.OfsBitsH
|
|
|
|
|
ora #$80
|
|
|
|
|
sta Pak.Shnk+S.PAKSHNK.BLBITS
|
|
|
|
|
|
2019-10-07 15:49:03 +00:00
|
|
|
|
rts
|
2018-02-08 16:39:56 +00:00
|
|
|
|
*--------------------------------------
|
2019-10-04 15:47:26 +00:00
|
|
|
|
Pak.BuildTOPTable
|
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
.1 stz Pak.Cnt Init best score to 0
|
|
|
|
|
stz Pak.Cnt+1
|
2019-10-03 15:39:08 +00:00
|
|
|
|
|
2019-10-04 15:47:26 +00:00
|
|
|
|
sec
|
|
|
|
|
ror Pak.bStop
|
2019-10-03 15:39:08 +00:00
|
|
|
|
|
2019-10-04 15:47:26 +00:00
|
|
|
|
ldx #0
|
2019-10-03 15:39:08 +00:00
|
|
|
|
|
2019-10-04 15:47:26 +00:00
|
|
|
|
.2 lda Pak.CntL,x
|
|
|
|
|
ora Pak.CntH,x
|
|
|
|
|
beq .3
|
|
|
|
|
|
|
|
|
|
stz Pak.bStop
|
|
|
|
|
|
|
|
|
|
lda Pak.Cnt
|
|
|
|
|
cmp Pak.CntL,x is it better at X
|
|
|
|
|
lda Pak.Cnt+1
|
|
|
|
|
sbc Pak.CntH,x
|
|
|
|
|
bcs .3 not better or equal...
|
2019-10-03 15:39:08 +00:00
|
|
|
|
|
2019-10-14 05:23:09 +00:00
|
|
|
|
stx Pak.Top.Best save new score index...
|
2019-10-03 15:39:08 +00:00
|
|
|
|
|
2019-10-04 15:47:26 +00:00
|
|
|
|
lda Pak.CntL,x
|
|
|
|
|
sta Pak.Cnt ...and value
|
|
|
|
|
lda Pak.CntH,x
|
|
|
|
|
sta Pak.Cnt+1
|
2019-10-03 15:39:08 +00:00
|
|
|
|
|
2019-10-04 15:47:26 +00:00
|
|
|
|
.3 inx
|
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
|
|
bit Pak.bStop
|
|
|
|
|
bmi .8
|
|
|
|
|
|
2019-10-14 05:23:09 +00:00
|
|
|
|
lda Pak.Top.Best
|
2019-10-04 15:47:26 +00:00
|
|
|
|
sta Pak.Shnk+S.PAKSHNK.TOPBYTES,y
|
|
|
|
|
tax
|
|
|
|
|
stz Pak.CntL,x Discard this entry
|
|
|
|
|
stz Pak.CntH,x
|
|
|
|
|
iny
|
2019-10-11 13:53:03 +00:00
|
|
|
|
cpy #TOP.MAX
|
2019-10-03 15:39:08 +00:00
|
|
|
|
bne .1
|
|
|
|
|
|
2019-10-14 05:23:09 +00:00
|
|
|
|
.8 sty Pak.Shnk+S.PAKSHNK.TOPCNT
|
2019-10-15 15:32:50 +00:00
|
|
|
|
Pak.BuildTOPTable.RTS
|
2019-10-03 15:39:08 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2019-10-07 15:49:03 +00:00
|
|
|
|
Pak.PutBL ldx #S.PAKSTAT.BL
|
|
|
|
|
jsr Pak.UpdateStats
|
2019-10-04 15:47:26 +00:00
|
|
|
|
|
2019-10-07 15:49:03 +00:00
|
|
|
|
lda Pak.BestBLLen
|
|
|
|
|
cmp Pak.BL.Longest
|
2019-10-15 15:32:50 +00:00
|
|
|
|
bcc .1
|
2016-12-09 16:36:24 +00:00
|
|
|
|
|
2019-10-07 15:49:03 +00:00
|
|
|
|
sta Pak.BL.Longest
|
2016-12-09 16:36:24 +00:00
|
|
|
|
|
2019-10-15 15:32:50 +00:00
|
|
|
|
.1 ldy Pak.BestBL
|
2019-10-07 15:49:03 +00:00
|
|
|
|
cpy Pak.BL.Farest
|
|
|
|
|
|
|
|
|
|
lda Pak.BestBL+1
|
|
|
|
|
pha
|
|
|
|
|
sbc Pak.BL.Farest+1
|
|
|
|
|
pla
|
2019-10-15 15:32:50 +00:00
|
|
|
|
bcc .2
|
2019-10-03 15:39:08 +00:00
|
|
|
|
|
2019-10-07 15:49:03 +00:00
|
|
|
|
>STYA Pak.BL.Farest
|
2019-10-03 15:39:08 +00:00
|
|
|
|
|
2019-10-15 15:32:50 +00:00
|
|
|
|
.2 bit Pak.bPass2
|
|
|
|
|
bmi .3
|
2019-10-07 15:49:03 +00:00
|
|
|
|
|
|
|
|
|
ldx #S.PAKSTAT.PASS1 Assume 1 BL worse case is 3 bytes
|
|
|
|
|
jsr Pak.UpdateStats
|
|
|
|
|
jsr Pak.UpdateStats
|
|
|
|
|
jsr Pak.UpdateStats
|
|
|
|
|
clc
|
2017-03-29 15:48:15 +00:00
|
|
|
|
rts
|
2019-10-07 15:49:03 +00:00
|
|
|
|
|
2019-10-15 15:32:50 +00:00
|
|
|
|
.3 ldy #PAK.B.BL.W
|
2019-10-08 15:58:43 +00:00
|
|
|
|
lda #PAK.B.BL
|
|
|
|
|
jsr Pak.Out.PutYBits
|
2019-10-15 15:32:50 +00:00
|
|
|
|
bcs Pak.BuildTOPTable.RTS
|
|
|
|
|
|
|
|
|
|
ldy Pak.BL.OfsBitsL
|
|
|
|
|
lda Pak.BestBL
|
|
|
|
|
jsr Pak.Out.PutYBits
|
|
|
|
|
bcs Pak.BuildTOPTable.RTS
|
2019-10-07 15:49:03 +00:00
|
|
|
|
|
|
|
|
|
ldy Pak.BL.OfsBitsH
|
2019-10-15 15:32:50 +00:00
|
|
|
|
beq .4
|
2019-10-07 15:49:03 +00:00
|
|
|
|
|
|
|
|
|
lda Pak.BestBL+1
|
|
|
|
|
jsr Pak.Out.PutYBits
|
2019-10-15 15:32:50 +00:00
|
|
|
|
bcs Pak.BuildTOPTable.RTS
|
2019-10-07 15:49:03 +00:00
|
|
|
|
|
2019-10-15 15:32:50 +00:00
|
|
|
|
.4 ldy Pak.BL.LenBits
|
2019-10-07 15:49:03 +00:00
|
|
|
|
lda Pak.BestBLLen
|
|
|
|
|
dec
|
|
|
|
|
dec
|
|
|
|
|
dec
|
2019-10-10 15:52:45 +00:00
|
|
|
|
jmp Pak.Out.PutYBits
|
2018-02-08 16:39:56 +00:00
|
|
|
|
*--------------------------------------
|
2019-10-14 05:23:09 +00:00
|
|
|
|
Pak.PutByte8 bit Pak.bPass2
|
2019-10-10 15:52:45 +00:00
|
|
|
|
bmi Pak.PutByte8.2
|
2019-10-02 15:21:03 +00:00
|
|
|
|
|
2019-10-08 15:58:43 +00:00
|
|
|
|
.5 tax
|
|
|
|
|
inc Pak.CntL,x
|
|
|
|
|
bne .6
|
2019-10-02 15:21:03 +00:00
|
|
|
|
|
2019-10-07 15:49:03 +00:00
|
|
|
|
inc Pak.CntH,x
|
2019-10-08 15:58:43 +00:00
|
|
|
|
|
2019-10-13 08:35:31 +00:00
|
|
|
|
.6 ldx #S.PAKSTAT.BYTE8
|
2019-10-07 15:49:03 +00:00
|
|
|
|
jsr Pak.UpdateStats
|
|
|
|
|
|
2019-10-13 08:35:31 +00:00
|
|
|
|
ldx #S.PAKSTAT.PASS1
|
2019-10-02 15:21:03 +00:00
|
|
|
|
jsr Pak.UpdateStats
|
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
rts
|
2019-10-15 15:32:50 +00:00
|
|
|
|
|
2019-10-14 05:23:09 +00:00
|
|
|
|
Pak.PutByte8.2 ldy Pak.Shnk+S.PAKSHNK.TOPCNT
|
2019-11-05 13:36:10 +00:00
|
|
|
|
beq .2 No TOP Table
|
2018-02-09 07:04:19 +00:00
|
|
|
|
|
2019-09-27 14:53:44 +00:00
|
|
|
|
.1 cmp Pak.Shnk+S.PAKSHNK.TOPBYTES-1,y
|
2018-02-09 07:04:19 +00:00
|
|
|
|
beq .3
|
|
|
|
|
dey
|
2019-10-04 15:47:26 +00:00
|
|
|
|
bne .1
|
2018-02-09 07:04:19 +00:00
|
|
|
|
|
2019-11-05 13:36:10 +00:00
|
|
|
|
.2 ldx #S.PAKSTAT.BYTE8
|
2019-10-13 08:35:31 +00:00
|
|
|
|
jsr Pak.UpdateStats
|
2019-10-10 15:52:45 +00:00
|
|
|
|
|
2019-10-13 08:35:31 +00:00
|
|
|
|
pha
|
|
|
|
|
ldy #PAK.B.BYTE8.W
|
|
|
|
|
lda #PAK.B.BYTE8
|
|
|
|
|
jsr Pak.Out.PutYBits
|
|
|
|
|
pla
|
2019-10-10 15:52:45 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
2019-10-13 08:35:31 +00:00
|
|
|
|
ldy #8
|
|
|
|
|
jmp Pak.Out.PutYBits
|
|
|
|
|
|
|
|
|
|
.3 dey Range 0-31
|
2019-10-04 15:47:26 +00:00
|
|
|
|
|
|
|
|
|
tya
|
2019-09-27 14:53:44 +00:00
|
|
|
|
lsr
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
2019-10-13 08:35:31 +00:00
|
|
|
|
tax Range 0-3
|
2019-10-11 06:40:08 +00:00
|
|
|
|
|
2019-09-27 14:53:44 +00:00
|
|
|
|
tya
|
|
|
|
|
and #7
|
|
|
|
|
ora TOP.Bits,x
|
|
|
|
|
ldy TOP.BitCnt,x
|
2019-10-15 15:32:50 +00:00
|
|
|
|
|
|
|
|
|
.4 pha
|
2019-10-11 06:40:08 +00:00
|
|
|
|
|
2019-09-27 14:53:44 +00:00
|
|
|
|
lda TOP.Stat,x
|
|
|
|
|
tax
|
|
|
|
|
jsr Pak.UpdateStats
|
2019-10-11 06:40:08 +00:00
|
|
|
|
|
|
|
|
|
pla
|
2019-09-25 15:34:43 +00:00
|
|
|
|
jmp Pak.Out.PutYBits
|
2019-10-10 15:52:45 +00:00
|
|
|
|
|
|
|
|
|
.9 rts
|
2016-12-09 16:36:24 +00:00
|
|
|
|
*--------------------------------------
|
2019-10-03 15:39:08 +00:00
|
|
|
|
Pak.Out.Close bit Pak.Out.Mask
|
|
|
|
|
bmi .8
|
2019-10-17 10:36:45 +00:00
|
|
|
|
|
2019-10-03 15:39:08 +00:00
|
|
|
|
lda Pak.Out.Byte
|
2019-10-17 10:36:45 +00:00
|
|
|
|
bra Pak.Out.PutByte
|
|
|
|
|
|
2019-10-03 15:39:08 +00:00
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
Pak.Out.PutYBits
|
2019-10-10 15:52:45 +00:00
|
|
|
|
phy
|
|
|
|
|
|
|
|
|
|
.1 cpy #8
|
|
|
|
|
beq .2
|
|
|
|
|
|
|
|
|
|
asl
|
|
|
|
|
iny
|
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
|
|
.2 ply
|
|
|
|
|
|
2019-10-14 15:58:16 +00:00
|
|
|
|
.3 asl
|
|
|
|
|
|
|
|
|
|
pha
|
2019-10-10 15:52:45 +00:00
|
|
|
|
|
2019-10-11 06:40:08 +00:00
|
|
|
|
bcc .4
|
2019-10-14 15:58:16 +00:00
|
|
|
|
|
2019-10-03 15:39:08 +00:00
|
|
|
|
lda Pak.Out.Mask
|
|
|
|
|
tsb Pak.Out.Byte
|
|
|
|
|
|
2019-10-11 06:40:08 +00:00
|
|
|
|
.4 lsr Pak.Out.Mask
|
|
|
|
|
bcc .5
|
2019-10-03 15:39:08 +00:00
|
|
|
|
|
|
|
|
|
ror Pak.Out.Mask
|
|
|
|
|
|
2019-10-10 15:52:45 +00:00
|
|
|
|
lda Pak.Out.Byte
|
2019-10-14 15:58:16 +00:00
|
|
|
|
stz Pak.Out.Byte
|
2019-10-15 15:32:50 +00:00
|
|
|
|
|
2019-10-10 15:52:45 +00:00
|
|
|
|
jsr Pak.Out.PutByte
|
2019-10-03 15:39:08 +00:00
|
|
|
|
|
2019-10-11 06:40:08 +00:00
|
|
|
|
.5 pla
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
dey
|
2019-10-14 15:58:16 +00:00
|
|
|
|
bne .3
|
2019-10-11 06:40:08 +00:00
|
|
|
|
|
|
|
|
|
* clc
|
|
|
|
|
|
2021-01-13 16:57:41 +00:00
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.9 lda #E.BUF
|
|
|
|
|
sec
|
|
|
|
|
rts
|
2019-10-03 15:39:08 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
Pak.Out.PutByte inc Pak.DstCnt
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
inc Pak.DstCnt+1
|
|
|
|
|
beq .9
|
|
|
|
|
|
|
|
|
|
.1 sta (ZPDstPtr)
|
|
|
|
|
|
|
|
|
|
inc ZPDstPtr
|
2019-10-16 06:09:13 +00:00
|
|
|
|
|
2019-10-03 15:39:08 +00:00
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
|
|
inc ZPDstPtr+1
|
|
|
|
|
|
|
|
|
|
.2 inc Pak.Stat+S.PAKSTAT.PASS2
|
|
|
|
|
bne .8
|
|
|
|
|
|
|
|
|
|
inc Pak.Stat+S.PAKSTAT.PASS2+1
|
|
|
|
|
|
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
|
|
|
|
|
2021-01-13 16:57:41 +00:00
|
|
|
|
.9 lda #E.BUF
|
|
|
|
|
sec
|
2019-10-03 15:39:08 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2018-02-08 16:39:56 +00:00
|
|
|
|
Pak.UpdateStats inc Pak.Stat,x
|
2016-12-09 16:36:24 +00:00
|
|
|
|
bne .8
|
2018-02-08 16:39:56 +00:00
|
|
|
|
inc Pak.Stat+1,x
|
2016-12-09 16:36:24 +00:00
|
|
|
|
.8 rts
|
|
|
|
|
*--------------------------------------
|
2019-10-14 05:23:09 +00:00
|
|
|
|
.DO STATS=1
|
2019-10-07 15:49:03 +00:00
|
|
|
|
Pak.PrintStats lda Pak.BL.OfsBitsL
|
2019-10-04 15:47:26 +00:00
|
|
|
|
clc
|
2019-10-07 15:49:03 +00:00
|
|
|
|
adc Pak.BL.OfsBitsH
|
2019-10-04 15:47:26 +00:00
|
|
|
|
>PUSHA
|
|
|
|
|
|
2019-10-07 15:49:03 +00:00
|
|
|
|
>PUSHW Pak.BL.Farest
|
|
|
|
|
>PUSHB Pak.BL.LenBits
|
|
|
|
|
>PUSHB Pak.BL.Longest
|
2019-10-09 15:43:31 +00:00
|
|
|
|
>PUSHW Pak.Stat+S.PAKSTAT.BL
|
|
|
|
|
|
2019-10-11 13:06:33 +00:00
|
|
|
|
ldx #S.PAKSTAT.BYTE8
|
2019-10-02 15:21:03 +00:00
|
|
|
|
|
|
|
|
|
.1 >PUSHW Pak.Stat,x
|
|
|
|
|
dex
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
|
|
|
|
|
2019-10-14 05:23:09 +00:00
|
|
|
|
>PUSHW Pak.Shnk+S.PAKSHNK.ULEN
|
|
|
|
|
|
|
|
|
|
>PUSHBI 23
|
2019-10-02 15:21:03 +00:00
|
|
|
|
>LDYA L.MSG.Stats
|
2020-02-28 07:21:46 +00:00
|
|
|
|
>SYSCALL PrintF
|
2019-10-02 15:21:03 +00:00
|
|
|
|
|
2019-10-13 08:35:31 +00:00
|
|
|
|
ldx #TOP.MAX-1
|
2019-10-02 15:21:03 +00:00
|
|
|
|
|
2019-10-13 08:35:31 +00:00
|
|
|
|
.2 >PUSHB Pak.Shnk+S.PAKSHNK.TOPBYTES,x
|
2019-10-02 15:21:03 +00:00
|
|
|
|
dex
|
|
|
|
|
bpl .2
|
|
|
|
|
|
2019-10-14 05:23:09 +00:00
|
|
|
|
>PUSHB Pak.Shnk+S.PAKSHNK.TOPCNT
|
2019-10-13 08:35:31 +00:00
|
|
|
|
|
2019-10-11 13:53:03 +00:00
|
|
|
|
>PUSHBI TOP.MAX+1
|
|
|
|
|
>LDYA L.MSG.TopBytes
|
2020-02-28 07:21:46 +00:00
|
|
|
|
>SYSCALL PrintF
|
2019-11-05 13:36:10 +00:00
|
|
|
|
|
|
|
|
|
bit Pak.bPass2
|
|
|
|
|
bpl .9
|
|
|
|
|
>DEBUG
|
|
|
|
|
|
|
|
|
|
.9 rts
|
2019-10-14 05:23:09 +00:00
|
|
|
|
.FIN
|
2019-10-07 15:49:03 +00:00
|
|
|
|
*--------------------------------------
|
2017-03-29 15:48:15 +00:00
|
|
|
|
CS.END
|
2019-09-27 14:53:44 +00:00
|
|
|
|
*--------------------------------------
|
2019-10-14 05:23:09 +00:00
|
|
|
|
.DO STATS=1
|
2022-11-02 06:54:30 +00:00
|
|
|
|
MSG.Stats .CS "\r\nLength : %5D\r\n"
|
|
|
|
|
.CS "Pass 1 : %5D\r\n"
|
|
|
|
|
.CS "Pass 2 : %5D\r\n"
|
|
|
|
|
.CS "Top 8 : %5D\r\n"
|
|
|
|
|
.CS "Top 16 : %5D\r\n"
|
|
|
|
|
.CS "Top 24 : %5D\r\n"
|
|
|
|
|
.CS "Top 32 : %5D\r\n"
|
|
|
|
|
.CS "Byte 8 : %5D\r\n"
|
|
|
|
|
.CZ "BL : %5D, Longest : %d (%d bits), Farest : %D (%d bits)\r\n"
|
|
|
|
|
MSG.TopBytes .CS "Top : (%2d) %h.%h.%h.%h.%h.%h.%h.%h %h.%h.%h.%h.%h.%h.%h.%h\r\n"
|
|
|
|
|
.CZ " %h.%h.%h.%h.%h.%h.%h.%h %h.%h.%h.%h.%h.%h.%h.%h\r\n"
|
2019-10-14 05:23:09 +00:00
|
|
|
|
.FIN
|
2019-10-11 13:53:03 +00:00
|
|
|
|
TOP.Bits .DA #PAK.B.TOP8,#PAK.B.TOP16,#PAK.B.TOP24,#PAK.B.TOP32
|
|
|
|
|
TOP.BitCnt .DA #PAK.B.TOP8.W,#PAK.B.TOP16.W,#PAK.B.TOP24.W,#PAK.B.TOP32.W
|
|
|
|
|
TOP.Stat .DA #S.PAKSTAT.TOP8,#S.PAKSTAT.TOP16,#S.PAKSTAT.TOP24,#S.PAKSTAT.TOP32
|
2019-09-27 14:53:44 +00:00
|
|
|
|
*--------------------------------------
|
2018-02-08 16:39:56 +00:00
|
|
|
|
Pak.SrcPtr .BS 2
|
2019-09-25 15:34:43 +00:00
|
|
|
|
|
2017-03-29 15:48:15 +00:00
|
|
|
|
Pak.SrcCnt .BS 2
|
2018-02-05 16:25:25 +00:00
|
|
|
|
Pak.DstCnt .BS 2
|
2018-02-08 16:39:56 +00:00
|
|
|
|
|
2019-10-04 15:47:26 +00:00
|
|
|
|
Pak.bPass2 .BS 1
|
|
|
|
|
|
|
|
|
|
Pak.BL.Longest .BS 1
|
|
|
|
|
Pak.BL.Farest .BS 2
|
2018-02-08 16:39:56 +00:00
|
|
|
|
|
2019-10-07 15:49:03 +00:00
|
|
|
|
Pak.BL.LenBits .BS 1
|
|
|
|
|
Pak.BL.OfsBitsL .BS 1
|
|
|
|
|
Pak.BL.OfsBitsH .BS 1
|
2019-10-02 15:21:03 +00:00
|
|
|
|
|
|
|
|
|
Pak.bBLFound .BS 1
|
|
|
|
|
Pak.BestBLLen .BS 1
|
|
|
|
|
Pak.BestBL .BS 2
|
|
|
|
|
|
2019-10-14 05:23:09 +00:00
|
|
|
|
Pak.Top.Best .BS 1
|
|
|
|
|
|
2018-02-08 16:39:56 +00:00
|
|
|
|
Pak.Cnt .BS 2
|
2019-09-27 14:53:44 +00:00
|
|
|
|
Pak.bStop .BS 1
|
2018-02-08 16:39:56 +00:00
|
|
|
|
|
2018-03-16 16:33:11 +00:00
|
|
|
|
Pak.Out.Byte .BS 1
|
|
|
|
|
Pak.Out.Mask .BS 1
|
2017-03-29 15:48:15 +00:00
|
|
|
|
*--------------------------------------
|
2018-02-08 16:39:56 +00:00
|
|
|
|
Pak.CntL .BS 256
|
|
|
|
|
Pak.CntH .BS 256
|
2019-09-25 15:34:43 +00:00
|
|
|
|
Pak.Shnk .BS S.PAKSHNK
|
2018-02-08 16:39:56 +00:00
|
|
|
|
Pak.Stat .BS S.PAKSTAT
|
2017-03-29 15:48:15 +00:00
|
|
|
|
*--------------------------------------
|
2016-12-09 16:36:24 +00:00
|
|
|
|
MAN
|
2021-01-12 21:14:13 +00:00
|
|
|
|
SAVE usr/src/lib/libpak.s
|
2016-12-09 16:36:24 +00:00
|
|
|
|
ASM
|