home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mods Anthology 2
/
Music-AmigaModsAnthology-2of4-Psychodk.mcsteam.iso
/
Tools
/
Amiga
/
Misc
/
xList_v1.06
/
xList_Sources
/
xlist106.123.asm
next >
Wrap
Assembly Source File
|
1996-02-22
|
31KB
|
1,543 lines
; ezasm!
; xList.s v1.06 (23.02.96) rev. 123
; Needs OS v37+ (or v39? not tested on v37)
; freely distributable,modifiable,trashable ==> adapt it to your needs !
; xList has been ported to ezasm in early February. Later in the year it will
; be ported to C (jumping to v1.10, probably in July-August 96 ,release: Sept.)
; big new features will be probably added to v1.10
; includes
incdir include:
include dos/dos.i
; EQUATES *****************************************************
numfbuff = 16
VARSIZE = 8
FILE = 1
DIR = 0
FALSE = 0
TRUE = 1
GVF_GLOBAL_ONLY = $100
; STRUCTURE XpkHeader,0
xh_CLen = 4 ;4 Crunched size
xh_Type = 8 ;8 sublibrary (NUKE,SQSH,...)
xh_ULen = 12 ;12 Uncrunched size
xh_Sample = 16;16 (1st char of 16 bytes of the uncrunched file)
xheadlen = 20; old lenght of infos to be read (now read more datas)
;STRUCTURE StcHeader,0
stc_UnpackLen = 8
stc_CrunchLen = 12
dummysize1 = 16
;STRUCTURE CrmHeader,0
crm_UnpackLen = 6
crm_CrunchLen = 10
dummysize2 = 14
;STRUCTURE LhaHeader,0
lha_clen3 = 7 ;lenghts inverted. dunno why...
lha_clen2 = 8
lha_clen1 = 9
lha_clen0 = 10
lha_ulen3 = 11
lha_ulen2 = 12
lha_ulen1 = 13
lha_ulen0 = 14
lha_chksum = 15 ; perhaps checksum? dunno
lha_chksum2 = 19 ; =$2001 if done with lha on Unix
lha_namesize = 21 ; lenght of filename - last byte useful for lha
lha_char1 = 22 ; first char of filename
lha_size = 32 ; the new lenght of data - useful for XPK (modname)
;table offsets
;STRUCTURE Variables,0
args_result_oldv = 0
;dirs = 28; DIRS/M
;sw1 IT=INTROTEXT/K
;sw2 NT=NOTOTALS/S
;sw3 TR=TESTRIPP/S
;sw4 TD=TESTDURATION/S
;sw5 ET=ENDTEXT/K
;sw6 NS=NOSORT/S
;sw7 NH=NOHEADER/S
;sw8 FO=FILESONLY/S
;sw9 FP=FULLPATH/S
;sw10 H2=HEADER2/S
;sw11 LF/N/K
;sw12 DL=DRAWLIMITS/S
;sw13 COF=COUNTONLYFILES/S
;sw14 SN=SONGNAME/S
;sw15 SU=SHOWULEN/S
;sw16 LA=LINEASPECT/K
;sw17 NC=NOCRUNCHINFOS/S
;sw18 SF=SHORTFILENAMES/S
; /S switches are activated if <> 0
vars_sizeof = 204; total size of the array above
;output string structures
;STRUCTURE FileDatas,0
Str_File = 0; filename (null offset)
Dec_ULen = 4; unpacked
Dec_CLen = 8; packed
Str_Type = 12; compression format
Dec_Ratio = 16; compression ratio
Str_Comment = 20; file comments
strlen = 24; max lenght for the output string above
;STRUCTURE Totals,0
Tot_numf = 0
Tot_utot2 = 4
Tot_ctot2 = 8
Tot_ratio = 12
Tot_strlen2 = 16
MAXCHARS = 160
; START *********************************************
; vars
; args
; flags
_DOSBase equ -4
_UtilityBase equ -8
oldlock equ -12
ofh equ -16
acinq equ -20
myhandle equ -24
varfh equ -28
pplast equ -32
mylock equ -36
sp1 equ -40
fh equ -44
itbuffer equ -48
itsize equ -52
itlock equ -56
itfh equ -60
varlock equ -64
sumvarbuff equ -68
myseg equ -72
rdargs equ -76
lhafh equ -80
tmpfh equ -84
hbuffer equ -88
dirsptr equ -92
lh_utot equ -96
numfiles equ -100
numdirs equ -104
ctot equ -108
longsum equ -112
numf_buff equ -116
tmp_lhsize equ -120
sp2 equ -124
delim_strptr equ -128
strloc2 equ -132
utot equ -136
dummy_null_string_dont_remove equ -140
Packlib equ -144
filename equ -148
fib equ -152
output_buffer equ -156
membase equ -160
sf_arg equ -164
nc_arg equ -168
la_arg equ -172
su_arg equ -176
sn_arg equ -180
cof_arg equ -184
dl_arg equ -188
lf_arg equ -192
h2_arg equ -196
fp_arg equ -200
fo_arg equ -204
nh_arg equ -208
ns_arg equ -212
et_arg equ -216
td_arg equ -220
tr_arg equ -224
nt_arg equ -228
it_arg equ -232
mdirs equ -236
la_flag equ -238
tmpdeleted equ -240
entrytype equ -242
spcecnt equ -244
atleastone equ -246
sortflag equ -248
onlydirs equ -250
namegiv_bool equ -252
xpked equ -254
lhsize equ -264
newname equ -424
fib_buf equ -840
header_buf equ -872
files_data equ -904
total_data equ -936
numf_data equ -968
sum_buffer equ -1000
SECTION text,CODE
link a5,#-1000
movea.l a5,a1
moveq #0,d7
move.l #249,d1
_l1 move.l d7,-(a1)
dbf d1,_l1
movea.l $4.w,a6
lea _c0(pc),a1
moveq #37,d0
jsr -552(a6)
move.l d0,_DOSBase(a5)
beq _l0
lea _c1(pc),a1
moveq #0,d0
jsr -552(a6)
move.l d0,_UtilityBase(a5)
beq _l0
lea fib_buf(a5),a0
move.l a0,fib(a5)
lea header_buf(a5),a0
move.l a0,hbuffer(a5)
lea files_data(a5),a0
move.l a0,output_buffer(a5)
lea total_data(a5),a0
move.l a0,strloc2(a5)
lea numf_data(a5),a0
move.l a0,numf_buff(a5)
lea sum_buffer(a5),a0
move.l a0,sumvarbuff(a5)
movea.l _DOSBase(a5),a6
jsr -60(a6)
move.l d0,ofh(a5)
readargs
lea args_template(pc),a0
lea mdirs(a5),a1
movea.l _DOSBase(a5),a6
move.l a0,d1
move.l a1,d2
moveq #0,d3
jsr -798(a6)
move.l d0,rdargs(a5)
not.l h2_arg(a5) ; Finally H2 becomes the def output !
lea delim(pc),a0
move.l a0,delim_strptr(a5)
clr.b la_flag(a5)
movea.l la_arg(a5),a0 ; LINEASPECT/K
move.l a0,d7
beq _l2
move.l la_arg(a5),delim_strptr(a5)
move.b #1,la_flag(a5)
_l2
test_tr ; TESTRIPP
move.l tr_arg(a5),d7
beq _l3
lea tr.msg(pc),a0
movea.l _DOSBase(a5),a6
move.l a0,d1
jsr -948(a6)
_l3
test_td ; TESTDURATION
move.l td_arg(a5),d7
beq _l4
lea td.msg(pc),a0
movea.l _DOSBase(a5),a6
move.l a0,d1
jsr -948(a6)
_l4
test_it_arg
move.l it_arg(a5),d1 ; INTROTEXT
beq testsort1
bsr type ; write your intro text
testsort1 ; NOSORT/S - if specified, jumps to giveargs
move.l ns_arg(a5),d7
bne _l5
;findseg ; if Sort is not yet resident
lea segname(pc),a0
movea.l _DOSBase(a5),a6
move.l a0,d1
moveq #0,d2
moveq #0,d3
jsr -780(a6)
tst.l d0
bne _l6
lea cmdname(pc),a0
move.l a0,d1
jsr -150(a6)
move.l d0,myseg(a5)
bne _l7
moveq #1,d7
move.l d7,ns_arg(a5) ; unable to load c:Sort, activating NOSORT
bra.s giveargs
_l7
lea segname(pc),a0
movea.l _DOSBase(a5),a6
move.l a0,d1
move.l myseg(a5),d2
moveq #1,d3
jsr -774(a6)
_l6
_l5
giveargs
move.l mdirs(a5),d7
bne _l9
movea.l _DOSBase(a5),a6
pea newname(a5)
move.l (sp)+,d1
move.l #MAXCHARS,d2
jsr -564(a6)
tst.l d0
beq _l10 ; success ! very likely to append
lea newname(a5),a0
move.l a0,sp1(a5)
bra _l11
_l10
clr.l sp1(a5)
_l11
bra _l12
_l9
move.l mdirs(a5),dirsptr(a5) ; save dirs array
movea.l dirsptr(a5),a0
move.l (a0)+,sp1(a5) ; if a4 is null, no arg -> current dir is locked
move.l a0,dirsptr(a5)
move.l sp1(a5),d7
bne _l13
movea.l dirsptr(a5),a0
move.l d7,-(a0) ; if no arg was given, back to the old state
move.l a0,dirsptr(a5)
bra _l14
_l13
move.l sp1(a5),d1
_l14
_l12
lockfile ; lock for Examine().
movea.l _DOSBase(a5),a6
move.l sp1(a5),d1
move.l #ACCESS_READ,d2
jsr -84(a6)
move.l d0,mylock(a5)
beq _l15 ; branch to scan the dir, else...
move.l nh_arg(a5),d7
beq examine ; NOHEADER
bra testsort
_l15
movea.l _DOSBase(a5),a6
move.l sp1(a5),d1
jsr -948(a6)
lea inter2(pc),a0
move.l a0,d1
jsr -948(a6)
jsr -132(a6)
move.l d0,d1
moveq #0,d2
jsr -474(a6)
free_args
tst.b tmpdeleted(a5)
beq _l16 ; close+del tmpfile if break
move.l tmpfh(a5),d7
beq _l17
movea.l _DOSBase(a5),a6
move.l d7,d1
jsr -36(a6)
_l17
lea tmpname(pc),a0
movea.l _DOSBase(a5),a6
move.l a0,d1
jsr -72(a6)
_l16
free_args2
bsr multi_lf
movea.l _DOSBase(a5),a6
move.l rdargs(a5),d1
jsr -858(a6)
bra closeall
;--------------------------------------------
examine ; to get the comments and the crunched size
move.l delim_strptr(a5),d1
bsr wdelim
clr.b namegiv_bool(a5)
movea.l sp1(a5),a0
move.l a0,d7
bne _l18 ; remove hit
move.b #1,namegiv_bool(a5)
_l18
movea.l _DOSBase(a5),a6
move.l mylock(a5),d1
move.l fib(a5),d2
jsr -102(a6)
tst.l d0
beq exnext
tst.b namegiv_bool(a5)
bne _l19
movea.l sp1(a5),a0
findend
tst.b (a0)+
bne findend ; ENFORCER HIT ! offset $1A2
lea -2(a0),a0
cmpi.b #'/',(a0)
bne _l20 ; ENFORCER HIT ! offset $1AA
clr.b (a0) ; erase last '/' for good filepart (only dirname)
_l20
cmpi.b #':',(a0)
bne _l21 ; ENFORCER HIT ! offset $1B2
clr.b (a0)
_l21
move.l fp_arg(a5),d7
bne _l22
movea.l _DOSBase(a5),a6
move.l sp1(a5),d1
jsr -870(a6)
move.l d0,sp1(a5)
_l22
move.l h2_arg(a5),d7
bne _l23
lea stars(pc),a0
movea.l _DOSBase(a5),a6
move.l a0,d1
jsr -948(a6)
_l23
move.l sp1(a5),d1
bra _l24
_l19
movea.l fib(a5),a0
lea fib_FileName(a0),a1
move.l a1,d1
_l24
move.l h2_arg(a5),d7
beq _l25 ; H2=HEADER2/S
bsr centersub
_l25
movea.l _DOSBase(a5),a6
jsr -948(a6)
movea.l fib(a5),a0
lea fib_Comment(a0),a0
move.l a0,d7
beq nodircomms
sel_headerfmt
move.l a0,sp1(a5) ; save comments
move.l h2_arg(a5),d7
beq _l26 ; H2=HEADER2/S
bsr linefeed
bra _l27
_l26
lea inter(pc),a1
movea.l _DOSBase(a5),a6
move.l a1,d1
jsr -948(a6)
_l27
move.l sp1(a5),d1
move.l h2_arg(a5),d7
beq _l28 ; H2=HEADER2/S
bsr centersub
_l28
nocentercomms
movea.l _DOSBase(a5),a6
jsr -948(a6)
nodircomms
move.l ns_arg(a5),d7
beq _l29 ; NOSORT/S
bsr linefeed
bra _l30
_l29
move.l h2_arg(a5),d7
bne _l31 ; H2=HEADER2/S
bsr linefeed
_l31
_l30
move.l h2_arg(a5),d7
bne _l32 ; H2=HEADER2/S
move.l delim_strptr(a5),d1
bsr wdelim
_l32
bsr linefeed
movea.l _DOSBase(a5),a6
move.l ofh(a5),d1
jsr -360(a6)
;------------------------------- NH
testsort
move.l ns_arg(a5),d7
bne _l33 ; NOSORT/S
lea tmpname(pc),a0
movea.l _DOSBase(a5),a6
move.l a0,d1
move.l #MODE_NEWFILE,d2
jsr -30(a6)
move.l d0,tmpfh(a5)
beq _l34
move.b #1,tmpdeleted(a5)
bra.s currentdir
_l34
moveq #1,d7
move.l d7,ns_arg(a5) ; NOSORT/S
_l33
currentdir
movea.l sp1(a5),a0
movea.l _DOSBase(a5),a6
move.l mylock(a5),d1
jsr -126(a6)
move.l d0,oldlock(a5)
move.l mylock(a5),d1
move.l fib(a5),d2
jsr -102(a6)
tst.l d0
beq _l35 ; if error, unlock and try next arg
movea.l fib(a5),a0
move.l fib_DirEntryType(a0),d0
bhi exnext ; scan only if d0 > 0 (entry is a dir)
_l35
loop
bsr.s unlockdir
loop2
move.l mdirs(a5),d7
beq _l36
movea.l dirsptr(a5),a0
move.l (a0)+,d1 ; get the next arg
move.l a0,dirsptr(a5)
tst.l d1
bne gotonext ; continue if arg found
_l36
nomore
move.l et_arg(a5),d1 ; ET=ENDTEXT/K
beq free_args
bsr type
bra free_args ; no more args, exit
gotonext
move.l d1,sp1(a5)
lf_mdirs_gry ; added on 20.10.95 on request of gryzor
bsr multi_lf
move.l sp1(a5),d1
bra lockfile
unlockdir
movea.l _DOSBase(a5),a6
move.l oldlock(a5),d1
jsr -126(a6)
move.l d0,d1
jsr -90(a6)
rts
dirempty
move.l delim_strptr(a5),d1
bsr wdelim
lea empty.msg(pc),a0
movea.l _DOSBase(a5),a6
move.l a0,d1
jsr -948(a6)
move.l tmpfh(a5),d7
beq _l37
move.l d7,d1
jsr -36(a6)
clr.l d7
_l37
deltmp2
lea tmpname(pc),a0
movea.l _DOSBase(a5),a6
move.l a0,d1
jsr -72(a6)
bra free_args2
noexnext
bsr.s unlockdir
tst.b atleastone(a5)
beq dirempty
ins_totfiles
move.l ns_arg(a5),d7
bne notmpclose ; NOSORT/S
move.l h2_arg(a5),d7
beq noftot ; H2=HEADER2/S
move.l nh_arg(a5),d7
bne noftot ; NH=NOHEADER/S
movea.l strloc2(a5),a1
move.l cof_arg(a5),d7
bne _l38 ; COF=COUNTONLYFILES/S (not Jean-Pierre, you fool ! :)
move.l numdirs(a5),d0
add.l d0,numfiles(a5)
_l38
tst.b onlydirs(a5)
bne _l39
lea fmtdnum(pc),a0
bra _l40
_l39
lea fmtnum(pc),a0
_l40
keepfmt
move.l numfiles(a5),(a1)
move.l cof_arg(a5),d7
beq _l41
tst.b onlydirs(a5)
bne _l42
move.l numdirs(a5),(a1)
_l42
_l41
movea.l numf_buff(a5),a3
bsr sprintf
move.l numf_buff(a5),d1
bsr centersub
movea.l _DOSBase(a5),a6
jsr -948(a6)
bsr linefeed
limafthead
move.l delim_strptr(a5),d1
bsr wdelim
nolim1
bsr linefeed
movea.l _DOSBase(a5),a6
move.l ofh(a5),d1
jsr -360(a6)
noftot
move.l h2_arg(a5),d7
bne _l43
movea.l strloc2(a5),a1
move.l cof_arg(a5),d7
bne _l44
move.l numdirs(a5),d0
add.l d0,numfiles(a5)
_l44
_l43
move.l tmpfh(a5),d7
beq _l45
movea.l _DOSBase(a5),a6
move.l d7,d1
jsr -36(a6)
clr.l d7
tst.b sortflag(a5)
beq _l46
lea comline(pc),a0
move.l a0,d1
moveq #0,d2
moveq #0,d3
jsr -222(a6)
lea sortedname(pc),a0
move.l a0,d1
bsr type
tst.l d0
bne _l47
lea sortedname(pc),a0
move.l a0,d1
jsr -72(a6)
lea tmpname(pc),a0
move.l a0,d1
jsr -72(a6)
clr.b tmpdeleted(a5)
_l47
_l46
_l45
notmpclose
move.l nt_arg(a5),d7
bne loop2
movea.l strloc2(a5),a1
tst.b onlydirs(a5)
bne _l48
move.l numdirs(a5),(a1)
lea totdirfmt(pc),a0 ; the format
bra _l49
_l48
move.l numfiles(a5),(a1)
move.l utot(a5),Tot_utot2(a1)
move.l ctot(a5),Tot_ctot2(a1)
move.l utot(a5),d7
bne _l50
moveq #0,d2
bra _l51
_l50
move.l utot(a5),d3
move.l ctot(a5),d0
bsr calc_ratio ; in: d3=utot,d0=ctot / out: d2=ratio
_l51
move.l d2,Tot_ratio(a1) ; ratio=100-100*CLen/ULen
lea totfmt(pc),a0 ; the format
move.l su_arg(a5),d7
bne _l52 ; SU=SHOWULEN/S
move.l nc_arg(a5),d7
beq _l53 ; NC=NOCRUNCHINFOS/S
lea nctot(pc),a0
bra _l54
_l53
move.l sf_arg(a5),d7
beq _l55 ; SF=SHORTFILENAMES/S
lea shorttot(pc),a0
bra _l56
_l55
move.l Tot_ctot2(a1),(Tot_ctot2-4)(a1) ; shift up struct (gry fmt)
move.l Tot_ratio(a1),(Tot_ratio-4)(a1)
lea grytot(pc),a0
_l56
_l54
_l52
_l49
movea.l _DOSBase(a5),a6
move.l a0,d1
move.l a1,d2
jsr -954(a6)
move.l ofh(a5),d1
jsr -360(a6)
wxltot
lea totvarname(pc),a1
movea.l _DOSBase(a5),a6
move.l a1,d1
move.l #MODE_NEWFILE,d2
jsr -30(a6)
move.l d0,varfh(a5)
tst.b onlydirs(a5)
bne _l57
move.l cof_arg(a5),d7
beq _l58
movea.l strloc2(a5),a0
clr.l (a0)
_l58
_l57
lea fmtvar(pc),a1
movea.l _DOSBase(a5),a6
move.l varfh(a5),d1
move.l a1,d2
move.l strloc2(a5),d3
jsr -348(a6)
move.l varfh(a5),d1
jsr -36(a6)
bsr dosumvar
clrintvars
moveq #0,d0
clr.l utot(a5)
clr.l ctot(a5)
clr.l numfiles(a5)
clr.l numdirs(a5)
bra loop2
isdir ; called when filename was a dir
movea.l fib(a5),a0
move.l fib_DirEntryType(a0),d0
ble.s exnext
move.l fo_arg(a5),d7
bne _l59 ; FO=FILESONLY/S (not Marc Blondel, you fool ! :)
move.b #DIR,entrytype(a5)
lea fib_FileName(a0),a1
movea.l output_buffer(a5),a2
move.l a1,(a2)
move.l #'Dir ',Packlib(a5)
lea Packlib(a5),a1
move.l a1,Str_Type(a2)
clr.l Dec_Ratio(a2)
addq.l #1,numdirs(a5)
bra testsort2
_l59
;************ mainloop
exnext
movea.l _DOSBase(a5),a6
move.l #SIGBREAKF_CTRL_C,d1
jsr -792(a6)
tst.l d0
beq _l60
bsr unlockdir
bra free_args
_l60
movea.l _DOSBase(a5),a6
move.l mylock(a5),d1
move.l fib(a5),d2
jsr -108(a6)
tst.l d0
beq noexnext ; break if error (like no more entries)
movea.l fib(a5),a0
lea fib_FileName(a0),a1
move.l a1,filename(a5)
movea.l output_buffer(a5),a2
move.l fib_Size(a0),Dec_CLen(a2)
move.l fib_Size(a0),Dec_ULen(a2) ; ulen=clen for normal files
lea fib_Comment(a0),a1
move.l tr_arg(a5),d7
beq _l61
tst.b (a1)
beq exnext
moveq #25,d0
rip
cmpi.l #'Ripp',(a1,d0)
beq _l62
dbra d0,rip
bra exnext
_l62
_l61
move.l td_arg(a5),d7
beq _l63
tst.b (a1)
beq test_xfh
moveq #3,d0
dur
cmpi.b #'[',(a1,d0)
beq exnext
dbra d0,dur
_l63
test_xfh
cmpi.w #'XF',(a1)
bne _l64 ; detects XFH comments (by xScan). 'Erase' them.
clr.l (a1)
_l64
; lets read the first 16 bytes
movea.l output_buffer(a5),a2
move.l a1,Str_Comment(a2)
movea.l _DOSBase(a5),a6
move.l filename(a5),d1
move.l #MODE_OLDFILE,d2
jsr -30(a6)
move.l d0,myhandle(a5)
beq isdir ; if error (dir) examine next entry
move.b #FILE,entrytype(a5)
move.b #1,onlydirs(a5)
movea.l hbuffer(a5),a1 ; clear the readbuffer because old infos are...
clr.l (a1) ; ...still here. (Ex. if <.file> detected just before)
move.l myhandle(a5),d1
move.l hbuffer(a5),d2
move.l #lha_size,d3
jsr -42(a6)
move.l myhandle(a5),d1
jsr -36(a6)
testxpk__
movea.l hbuffer(a5),a1 ; a1=readbuffer
move.l (a1),d1 ; =xh_Reco(a1) d1=first 4 bytes of the file
cmpi.l #'XPKF',d1
bne testpp20
hereisxpk__
move.l sn_arg(a5),d7
beq _l65
movea.l output_buffer(a5),a2
lea xh_Sample(a1),a0
move.l a0,Str_File(a2)
moveq #$1f,d0
moveq #4,d1
.loop
cmp.b (a0,d1),d0
bge nosong
dbra d1,.loop
move.l #$80,d0
moveq #15,d1
.loop2
cmp.b (a0,d1),d0
bge nosong
dbra d1,.loop2
move.b #1,xpked(a5)
_l65
nosong
move.l xh_CLen(a1),d0
addq.l #8,d0
movea.l output_buffer(a5),a2
cmp.l Dec_CLen(a2),d0
bne _l66
move.l xh_ULen(a1),Dec_ULen(a2) ; Unpacked lenght
move.l xh_Type(a1),Packlib(a5) ; Packing method
bra print ; output to stdio
_l66
move.l #'!XPK',Packlib(a5)
bra print
testpp20
move.l d1,Packlib(a5) ; Packlib=PP20,Crm2 or S404
cmpi.l #'PP20',d1
bne testcrm2
hereispp20__ ; reopen file for decrunched size
movea.l _DOSBase(a5),a6
move.l filename(a5),d1
move.l #MODE_OLDFILE,d2
jsr -30(a6)
move.l d0,myhandle(a5)
beq exnext
move.l myhandle(a5),d1
moveq #-4,d2
move.l #OFFSET_END,d3
jsr -66(a6)
lea pplast(a5),a0
move.l myhandle(a5),d1
move.l a0,d2
moveq #4,d3
jsr -42(a6)
move.l myhandle(a5),d1
jsr -36(a6)
move.l pplast(a5),d0 ; XXXXXXxx
lsr.l #8,d0 ; calculating the PP-Decrunch-Info
movea.l output_buffer(a5),a2
move.l d0,Dec_ULen(a2) ; 00XXXXXX
cmp.l Dec_CLen(a2),d0
blt nopp
move.l Dec_CLen(a2),d1
move.l d1,d2
add.l d1,d1 ; C*2
add.l d1,d1 ; C*4
add.l d1,d2 ; C*5
add.l d2,d2 ; C*10
cmp.l d2,d0
blt print
nopp
move.l Dec_CLen(a2),Dec_ULen(a2)
move.l #'!PP2',Packlib(a5)
bra print
testcrm2
cmpi.l #'Crm2',d1
beq hereiscrm
cmpi.l #'CrM2',d1
beq hereiscrm
cmpi.l #'CrM!',d1
beq hereiscrm
cmpi.l #'Crm!',d1
bne teststc
hereiscrm
movea.l output_buffer(a5),a2
move.l crm_CrunchLen(a1),d0
add.l #14,d0
cmp.l Dec_CLen(a2),d0
bne.s nocrm
move.l crm_UnpackLen(a1),Dec_ULen(a2)
bra print
nocrm
move.l #'!Crm',Packlib(a5)
bra print
teststc
cmpi.l #'S403',d1
beq hereisstc
cmpi.l #'S404',d1
bne testlha
hereisstc
movea.l output_buffer(a5),a2
move.l stc_CrunchLen(a1),d0
add.l #20,d0
cmp.l Dec_CLen(a2),d0
bne.s nostc
move.l stc_UnpackLen(a1),Dec_ULen(a2)
bra print
nostc
move.l #'!S40',Packlib(a5)
bra print
testlha
movea.l hbuffer(a5),a1
move.w 3(a1),d1
cmpi.w #'lh',d1
bne nopacker
move.b 2(a1),d1
cmpi.b #'-',d1
bne nopacker
hereislh5
bsr getlhanfo
bra print
nopacker
move.l #' ',Packlib(a5)
print ; put the infos in the right places
movea.l _DOSBase(a5),a6
move.l filename(a5),d1
jsr -870(a6)
move.l sn_arg(a5),d7
beq _l67 ; SN=SONGNAME/S
tst.b xpked(a5)
bne _l68
movea.l output_buffer(a5),a2
move.l d0,Str_File(a2)
_l68
bra _l69
_l67
movea.l output_buffer(a5),a2
move.l d0,Str_File(a2)
_l69
printbis
movea.l d0,a1
cmpi.b #'.',(a1)
beq exnext ; strip out the ".*" files (.EPDir)
addq.l #1,numfiles(a5)
lea Packlib(a5),a1
movea.l output_buffer(a5),a2
move.l a1,Str_Type(a2)
move.l Dec_CLen(a2),d0
move.l Dec_ULen(a2),d3
add.l d0,ctot(a5)
add.l d3,utot(a5)
bsr calc_ratio
move.l d2,Dec_Ratio(a2) ; ratio=100-100*CLen/ULen
move.l nc_arg(a5),d7
bne _l70
move.l sf_arg(a5),d7
bne _l71
move.l su_arg(a5),d7
bne _l72
;------- for Gry fmt -------------------
move.l Dec_CLen(a2),(Dec_CLen-4)(a2)
move.l Str_Type(a2),(Str_Type-4)(a2)
move.l Dec_Ratio(a2),(Dec_Ratio-4)(a2)
move.l Str_Comment(a2),(Str_Comment-4)(a2)
_l72
bra _l73
_l71
move.l Str_Comment(a2),(Str_Comment-12)(a2)
_l73
bra _l74
_l70
;------------- for nc fmt --------------------
move.l Str_Comment(a2),(Str_Comment-12)(a2)
_l74
testsort2
move.l ns_arg(a5),d7
beq _l75
move.l ofh(a5),fh(a5)
bra _l76
_l75
move.l tmpfh(a5),fh(a5)
beq _l77
move.b #1,sortflag(a5)
bra _l78
_l77
move.l ofh(a5),fh(a5)
_l78
_l76
vfprint
movea.l output_buffer(a5),a2
cmpi.b #1,entrytype(a5)
bne _l79
;--------------- adjust file fmts ------------------
lea gryfmt(pc),a0
move.l su_arg(a5),d7
beq _l80 ; SU=SHOWULEN/S
lea cformat(pc),a0
bra _l81
_l80
move.l nc_arg(a5),d7
beq _l82 ; NC=NOCRUNCHINFOS/S
lea ncfmt(pc),a0
bra _l83
_l82
move.l sf_arg(a5),d7
beq _l84 ; SF=SHORTFILENAMES/S
lea shortfmt(pc),a0
_l84
_l83
_l81
bra _l85
_l79
lea dirfmt(pc),a0
move.l su_arg(a5),d7
bne _l86 ; SU=SHOWULEN/S
move.l nc_arg(a5),d7
beq _l87 ; NC=NOCRUNCHINFOS/S
move.l Str_Comment(a2),(Str_Comment-16)(a2)
lea ncdirfmt(pc),a0
bra _l88
_l87
move.l sf_arg(a5),d7
beq _l89 ; SF=SHORTFILENAMES/S
move.l Str_Comment(a2),(Str_Comment-16)(a2)
lea shortdirfmt(pc),a0
bra _l90
_l89
;---------- gry dir fmt --------------------
move.l Dec_CLen(a2),(Dec_CLen-4)(a2)
move.l Str_Type(a2),(Str_Type-4)(a2)
move.l Dec_Ratio(a2),(Dec_Ratio-4)(a2)
move.l Str_Comment(a2),(Str_Comment-4)(a2)
lea grydirfmt(pc),a0
;------------------------------------------
_l90
_l88
_l86
_l85
begin_print
movea.l _DOSBase(a5),a6
move.l fh(a5),d1
move.l a0,d2
move.l a2,d3
jsr -354(a6)
move.l fh(a5),d1
jsr -360(a6)
movea.l fib(a5),a0
lea fib_Comment(a0),a1
moveq #18,d0
clrcomm
clr.l (a1)+
dbra d0,clrcomm
move.b #1,atleastone(a5)
clr.b xpked(a5)
bra exnext ; next entry please
;#########********** SUBROUTINES *************#############
calc_ratio ; in: d0=ctot,d3=utot / out: d2=ratio
tst.l d3
beq _l91
tst.l d0
beq _l92 ; test if clen = ulen ( => ratio = 0% )
moveq #100,d1
move.l d0,d5
move.l d3,d0
cmpi.l #1000000,d3
bcs _l93 ; change method at 1 Mb
; 2nd method, for 1 Mb => 2 Gb (uncrunched) sizes
; if d3 is big enough for the "bigsizes" ratio
movea.l _UtilityBase(a5),a6
jsr -156(a6)
move.l d0,d1
move.l d5,d0
div
movea.l _UtilityBase(a5),a6
jsr -156(a6)
moveq #100,d2
sub.l d0,d2 ; 100 - quotient = ratio
rts
_l93
move.l d5,d0 ; classic method, for 0 => 21 Mo sizes
movea.l _UtilityBase(a5),a6
jsr -144(a6)
move.l d3,d1
bra.s div ; (clen * 100) / ulen
_l92
_l91
moveq #0,d2
rts
;**************** end (calc_ratio)
linefeed
movea.l _DOSBase(a5),a6
move.l ofh(a5),d1
moveq #10,d2
jsr -312(a6)
rts
multi_lf
move.l lf_arg(a5),d7
beq _l94 ; LF
movea.l d7,a0 ; LF
move.l (a0),d0
bls _l95 ; LF<=0
subq.l #1,d0
move.l d0,d4
putlf
bsr linefeed
dbra d4,putlf
_l95
_l94
rts
type ; d1: strptr on file to write to stdout
move.l d1,sp1(a5)
movea.l _DOSBase(a5),a6
move.l #ACCESS_READ,d2
jsr -84(a6)
move.l d0,itlock(a5)
bne _l96
moveq #-1,d0
rts
_l96
movea.l _DOSBase(a5),a6
move.l itlock(a5),d1
move.l fib(a5),d2
jsr -102(a6)
movea.l fib(a5),a0
move.l fib_Size(a0),itsize(a5)
move.l sp1(a5),d1
move.l #MODE_OLDFILE,d2
jsr -30(a6)
move.l d0,itfh(a5)
beq _l98
movea.l $4.w,a6
move.l itsize(a5),d0
move.l #$10001,d1
jsr -684(a6)
move.l d0,itbuffer(a5)
beq _l99
movea.l _DOSBase(a5),a6
move.l itfh(a5),d1
move.l itbuffer(a5),d2
move.l itsize(a5),d3
jsr -42(a6)
move.l ofh(a5),d1
move.l itbuffer(a5),d2
move.l itsize(a5),d3
jsr -48(a6)
movea.l $4.w,a6
movea.l itbuffer(a5),a1
jsr -690(a6)
_l99
movea.l _DOSBase(a5),a6
move.l itfh(a5),d1
jsr -36(a6)
_l98
movea.l _DOSBase(a5),a6
move.l itlock(a5),d1
jsr -90(a6)
moveq #0,d0
rts
centersub ; d1=strptr on string to center (80 cols display)
move.l d1,sp2(a5)
movea.l d1,a0
moveq #-1,d0
countlen
addq.l #1,d0
tst.b (a0)+
bne countlen
moveq #80,d1
sub.l d0,d1
bls _l100
lsr.l #1,d1
move.b d1,spcecnt(a5)
beq _l101
putspace
movea.l _DOSBase(a5),a6
move.l ofh(a5),d1
move.l #" ",d2
jsr -312(a6)
subq.b #1,spcecnt(a5)
bne putspace
_l101
_l100
move.l sp2(a5),d1
rts
dosumvar ; env:xlsumtot, sumvarfname
lea sumvarfname(pc),a0
movea.l _DOSBase(a5),a6
move.l a0,d1
move.l #ACCESS_READ,d2
jsr -84(a6)
move.l d0,varlock(a5)
bne _l102
lea sumvarfname(pc),a0
move.l a0,d1
move.l #MODE_NEWFILE,d2
jsr -30(a6)
move.l d0,varfh(a5)
beq _l103
lea fmtvar(pc),a0
move.l varfh(a5),d1
move.l a0,d2
move.l strloc2(a5),d3
jsr -348(a6)
_l103
bra _l104
_l102
movea.l _DOSBase(a5),a6
move.l varlock(a5),d1
jsr -90(a6)
lea sumvarname(pc),a0
move.l a0,d1
move.l sumvarbuff(a5),d2
move.l #VARSIZE,d3
move.l #GVF_GLOBAL_ONLY,d4
jsr -906(a6)
lea longsum(a5),a0
move.l sumvarbuff(a5),d1
move.l a0,d2
jsr -816(a6)
move.l numfiles(a5),d0
add.l d0,longsum(a5)
lea sumvarfname(pc),a0
move.l a0,d1
move.l #MODE_NEWFILE,d2
jsr -30(a6)
move.l d0,varfh(a5)
beq _l105
lea longsum(a5),a0
lea fmtvar(pc),a1
move.l varfh(a5),d1
move.l a1,d2
move.l a0,d3
jsr -348(a6)
_l105
_l104
move.l varfh(a5),d7
beq _l106
movea.l _DOSBase(a5),a6
move.l d7,d1
jsr -36(a6)
_l106
rts
sprintf ; a0 - format, a1 - data, a2 - PutChProc, a3 - buffer
lea stuffChar(pc),a2
movea.l $4.w,a6
jsr -522(a6)
rts
stuffChar
move.b d0,(a3)+
rts
wdelim ; d1 - strptr on line to write
move.l dl_arg(a5),d7
beq _l107 ; DRAWLIMITS/S
bsr centersub
movea.l _DOSBase(a5),a6
jsr -948(a6)
move.l ofh(a5),d1
jsr -360(a6)
tst.b la_flag(a5)
beq _l108
bsr linefeed
_l108
_l107
rts
getlhanfo
moveq #0,d4 ; index
bsr getlh_clen
move.l tmp_lhsize(a5),d0
cmp.l Dec_CLen(a2),d0
blt goodlha
move.l #'!LHA',Packlib(a5)
rts
goodlha
moveq #45,d7
add.l d7,d0
cmp.l Dec_CLen(a2),d0
bgt onefileinside
multiplelha
move.l #'LHAs',Packlib(a5)
clr.l lh_utot(a5)
movea.l _DOSBase(a5),a6
move.l filename(a5),d1
move.l #MODE_OLDFILE,d2
jsr -30(a6)
move.l d0,lhafh(a5)
bne _l109
move.l Dec_CLen(a2),Dec_ULen(a2)
rts
_l109
refreshindex
movea.l hbuffer(a5),a1
cmpi.w #$2001,lha_chksum2(a1)
bne _l110 ; whaw! I was lucky to find this.
addq.l #3,d4
_l110
moveq #0,d0
movea.l hbuffer(a5),a1
move.b lha_namesize(a1),d0
add.l d0,d4
moveq #24,d7
add.l d7,d4 ; 24=size of checksum and other stuff.
add.l tmp_lhsize(a5),d4 ; tmp_lhsize=clen of an arc file
move.l d4,d0
bsr getlh_ulen
move.l Dec_ULen(a2),d0
add.l d0,lh_utot(a5) ; lh_utot = total unpacked lenght of files
move.l lh_utot(a5),d0
readnextlha
movea.l _DOSBase(a5),a6
move.l lhafh(a5),d1
move.l d4,d2
move.l #OFFSET_BEGINNING,d3
jsr -66(a6)
moveq #-1,d7
cmp.l d7,d0
bne _l111
move.l lhafh(a5),d1
jsr -36(a6)
move.l Dec_ULen(a2),d1
sub.l d1,lh_utot(a5)
move.l lh_utot(a5),Dec_ULen(a2)
tst.b Dec_ULen(a2)
bpl _l112
move.l Dec_CLen(a2),Dec_ULen(a2)
_l112
rts
_l111
movea.l _DOSBase(a5),a6
move.l lhafh(a5),d1
move.l hbuffer(a5),d2
move.l #lha_size,d3
jsr -42(a6)
movea.l hbuffer(a5),a1
bsr getlh_clen
bra refreshindex
;*----------------------------------
onefileinside
; Dec_CLen(a2) = tmp_lhsize
;this line above put the crunched size appearing in Lha. I choose not to
;do this here but feel free to do it if you want.
bsr getlh_ulen
move.l #'LHA ',Packlib(a5)
rts
getlh_clen ; d1=index -> clen in tmp_lhsize
lea lhsize(a5),a0
move.b lha_clen3(a1),3(a0)
move.b lha_clen2(a1),2(a0)
move.b lha_clen1(a1),1(a0)
move.b lha_clen0(a1),(a0)
move.l lhsize(a5),tmp_lhsize(a5)
rts
getlh_ulen ; d1=index -> ulen in dec_ulen
move.b lha_ulen3(a1),(Dec_ULen+3)(a2)
move.b lha_ulen2(a1),(Dec_ULen+2)(a2)
move.b lha_ulen1(a1),(Dec_ULen+1)(a2)
move.b lha_ulen0(a1),Dec_ULen(a2)
rts
closeall ; ezasm inserts its exit routine below
_l0
movea.l $4.w,a6
move.l _DOSBase(a5),d7
beq.s _l114
movea.l d7,a1
jsr -414(a6)
_l114
move.l _UtilityBase(a5),d7
beq.s _l115
movea.l d7,a1
jsr -414(a6)
_l115
unlk a5
moveq #0,d0
rts
_c0 dc.b "dos.library",0
_c1 dc.b "utility.library",0
_c2 dc.b " ",0
;---- datas ----
cformat
dc.b '%-26.26s %8ld %8ld (%s/%2ld%%) %s',$a,0
gryfmt
dc.b '%-30.30s %8ld (%s/%2ld%%) %s',$a,0
ncfmt
dc.b '%-32.32s %8ld %s',$a,0
shortfmt
dc.b '%-20.20s %8ld %s',$a,0
;File Real Packed Type/Ratio Comment
dirfmt
dc.b ' %-25.25s %8ld %8ld (%s/%2ld%%) %s',$a,0
grydirfmt
dc.b ' %-29.29s %8ld (%s/%2ld%%) %s',$a,0
ncdirfmt
dc.b ' %-32.32s %s',$a,0
shortdirfmt
dc.b ' %-20.20s %s',$a,0
grytot
dc.b ' ~~~~~~~ ~~~~~',10
dc.b '=> %5ld files %8ld %2ld%%',10,0
totfmt
dc.b ' ~~~~~~~ ~~~~~~~ ~~~~~',10
dc.b '=> %5ld files %10ld %8ld %2ld%%',10,0
nctot
dc.b ' ~~~~~~~',10
dc.b '=> %5ld files %8ld',10,0
shorttot
dc.b ' ~~~~~~~',10
dc.b '=>%4ld files %8ld',10,0
totdirfmt
dc.b '~~~~~~~~~~~~',10,'=> %ld dirs',10,0
dosname
dc.b 'dos.library',0
uname
dc.b 'utility.library',0
empty.msg
dc.b 'Directory is empty!'
flush_string
dc.b 10,0
tr.msg
dc.b '(Filtering mods WITH "Ripp" in DOS_Comment)',10,0
td.msg
dc.b '(Filtering mods WITHOUT duration in DOS_Comment)',10,0
stars
dc.b '********** ',0
delim
dc.b '============================================================'
dc.b '===================',10,0
inter
dc.b ' - ',0
inter2
dc.b ' : ',0
fmtvar
dc.b '%N',0
fmtnum
dc.b '%ld files',0
fmtdnum
dc.b '%ld dirs',0
totvarname
dc.b 'ENV:xltotal',0
sumvarfname
dc.b 'ENV:'
sumvarname
dc.b 'xlsumtot',0
tmpname
dc.b 'T:xltmp1',0
sortedname
dc.b 'T:xltmp2',0
cmdname
dc.b 'C:'
segname
dc.b 'Sort',0
comline ; lame but true
dc.b 'Sort >NIL: T:xltmp1 to T:xltmp2',0
version_string
dc.b '$VER: xList 1.06 (23.02.96) by Reez/Osmose',0
dummylabel
dc.b '(David Le Corfec, lecorfec@diva.univ-mlv.fr)',0
args_template
dc.b 'DIR/M,IT=INTROTEXT/K,NT=NOTOTALS/S,TR=TESTRIPP/S,'
dc.b 'TD=TESTDURATION/S,ET=ENDTEXT/K,NS=NOSORT/S,NH=NOHEADER/S,'
dc.b 'FO=FILESONLY/S,FP=FULLPATH/S,H2=HEADER2/S,LF/N/K,'
dc.b 'DL=DRAWLIMITS/S,COF=COUNTONLYFILES/S,SN=SONGNAME/S,'
dc.b 'SU=SHOWUSIZE/S,LA=LINEASPECT/K,NC=NOCRUNCHINFOS/S,'
dc.b 'SF=SHORTFILENAMES/S',0
; Contact me for ANY reason ( I like to get (e)mails ! ) :
;Snail: David Le Corfec Email:
; 57 rue C.J. Romain <lecorfec@diva.univ-mlv.fr>
; 94170 Le Perreux
; - France -
; -=: 100% aNSWeR! :=-
; on IRC : Reez
; Special greets to The Cyborg / NGC, Gryzor,
; and VoDkA/Saturne^Osmose (Many Thanx for adverts in ur list and in Dream :)
; about the output formats:
; originally I had a format called 'cfmt' (C-Formatting String)
; lately I added the 'gryfmt' (Gryzor Format), which became the default output
; the cfmt is called with SU, but it's the default output internally (!)
; today I add the 'ncfmt' (with NC=NOCRUNCHINFOS) , so I had to rewrite the
; quick&bad coded fmtchange-routines.
; so dont worry for the mess with switches,offsets and formats at each printing.
; let's add a 'shortfmt'
END