home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FreeWare Collection 2
/
FreeSoftwareCollection2pd199x-jp.img
/
ms_dos
/
mcpr
/
cpropt.asm
< prev
next >
Wrap
Assembly Source File
|
1990-06-14
|
16KB
|
885 lines
page 95,132
;§∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞§
;§ §
;§ マルチカラム コンパクト プリント ユーティリティ §
;§ §
;§ Multicolumn Compact PRint utility MCPR.EXE Ver1.40 §
;§ ~ ~ ~~ §
;§ Copyright (C) by 福地 邦雄 1989-1990. All rights reserved. §
;§∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞§
public options
public startpage
public lastpage
public clmcnt
public lincnt
public blkcnt
public gapsize
public formfeed
public creturns
public marginleft
public marginhead
public hdrprint
public header
public headeroff
public headerseg
public pgwidth
public pghight
public rawpitch
public clmpitch
public pprtype
public frmtype
public hopper
public pgtype
public filline
public linsiz
public linumb
public numclm
public numsepchar
public tabcount
extrn asctoint:near
extrn inttoascb:near
extrn filelist:near
extrn abort:near
extrn asmpage:near
extrn baspage:near
extrn cpage:near
;
YES equ 1
NO equ 0
EXT equ 1
ASM equ 2
BASIC equ 3
C equ 4
CR equ 0dh
LF equ 0ah
PORT equ 0
LAND equ 1
STOCK136 equ 0
STOCK80 equ 1
A4 equ 2
B4 equ 3
;
findf struc
; namstr label dword
namoff dw ?
namseg dw ?
; dtaadr label dword
dtaoff dw ?
dtaseg dw ?
; bufadr label dword
bufoff dw ?
bufseg dw ?
bufsiz dw ?
findf ends
;
pgform struc
allwidth dw ?
leftmrgn dw ?
blckclmn dw ?
gapclmn dw ?
blckcount dw ?
physline dw ?
prntline dw ?
headmrgn dw ?
pgform ends
;
data segment para public 'DATA'
;
extrn namebuf:dword
extrn nameptr:dword
extrn argv:dword
extrn argc:word
extrn errorno:word
extrn pageproc:word
;
startpage dw 1
lastpage dw 0ffffh
clmcnt dw 132
lincnt dw 90
blkcnt dw 2
gapsize dw 8
tabcount dw 8
formfeed dw YES
frmtype dw PORT
pprtype dw STOCK136
formbase dw stk136
marginleft dw 0
marginhead dw 0
hdrprint dw NO
header label dword
headeroff dw ?
headerseg dw ?
pgwidth dw 272
pghight dw 90
rawpitch dw 3
clmpitch dw 3
hopper dw 1
pgtype dw NO
creturns dw NO
filline dw ?
linsiz dw ?
linumb dw NO
numclm dw 4
numsepchar db ' '
even
cset dw NO
gset dw NO
lset dw NO
wset dw NO
bset dw NO
rset dw NO
frmset dw NO
mhset dw NO
mlset dw NO
;
formlist label word
dw stk136,stk136
dw stka4p,stk80
dw a4port,a4land
dw b4port,b4land
;
;全幅,左マージン,カラム幅,カラム間幅,カラム数,物理行,論理行,上マージン
stk136 pgform <136,0,136,0,1 ,66,60,0>
pgform <204,0,100,4,2 ,82,75,0>
pgform <272,0,132,8,2 ,99,90,0>
;
stk80 pgform <80,0,80,0,1 ,66,60,0>
pgform <120,0,120,0,1 ,82,75,0>
pgform <160,0,78,4,2 ,99,90,0>
;
stka4p pgform <78,7,71,0,1 ,64,64,0>
pgform <117,10,107,0,1 ,79,79,0>
pgform <157,14,143,0,1 ,94,94,0>
;
a4port pgform <78,7,71,0,1 ,67,67,0>
pgform <117,10,107,0,1 ,83,83,0>
pgform <157,14,143,0,1 ,100,100,0>
;
a4land pgform <113,0,113,0,1 ,46,46,3>
pgform <169,0,82,5,2 ,58,58,4>
pgform <226,0,110,6,2 ,69,69,4>
;
b4port pgform <97,7,90,0,1 ,82,82,0>
pgform <146,10,136,0,1 ,103,103,0>
pgform <194,14,88,4,2 ,123,123,0>
;
b4land pgform <136,0,136,0,1 ,57,57,3>
pgform <204,0,100,4,2 ,72,72,4>
pgform <272,0,132,8,2 ,85,85,5>
;
srch findf <>
;
clmerror db '各種 桁数指定の値が許容範囲外です',CR,LF
clmerrsz equ $-clmerror
;
stdfrm label byte
db 'ドットPRT 桁ピッチ 用紙幅 左マージン カラム幅 カラム間幅 カラム数 行ピッチ 物理行 印刷行 上マージン',CR,LF
hlplnbs label byte
dotform label byte
db 'W 136桁 '
selclm equ $-hlplnbs
db ' 1 '
stddot db ' 136 0 136 0 1 '
selraw equ $-hlplnbs
db ' 1 66 60 0',CR,LF
hlplnsz equ $-hlplnbs
db ' 2 204 0 100 4 2 2 82 75 0',CR,LF
db ' 3 272 0 132 8 2 3 99 90 0',CR,LF
db 'SL 80桁 1 80 0 80 0 1 1 66 60 0',CR,LF
db ' 2 120 0 120 0 1 2 82 75 0',CR,LF
db ' 3 160 0 78 4 2 3 99 90 0',CR,LF
db 'SP A4縦 1 78 7 71 0 1 1 64 64 0',CR,LF
db ' 2 117 10 107 0 1 2 79 79 0',CR,LF
db ' 3 157 14 143 0 1 3 94 94 0',CR,LF
db 'ページPRT 桁ピッチ 用紙幅 左マージン カラム幅 カラム間幅 カラム数 行ピッチ 物理行 印刷行 上マージン',CR,LF
pageform label byte
db 'AP A4縦 1 '
stdpag db ' 78 7 71 0 1 1 67 67 0',CR,LF
db ' 2 117 10 107 0 1 2 83 83 0',CR,LF
db ' 3 157 14 143 0 1 3 100 100 0',CR,LF
db 'AL A4横 1 113 0 113 0 1 1 46 46 3',CR,LF
db ' 2 169 0 82 5 2 2 57 57 4',CR,LF
db ' 3 226 0 110 6 2 3 69 69 4',CR,LF
db 'BP B4縦 1 97 7 90 0 1 1 82 82 0',CR,LF
db ' 2 146 10 136 0 1 2 103 103 0',CR,LF
db ' 3 194 14 88 4 2 3 123 123 0',CR,LF
db 'BL B4横 1 136 0 136 0 1 1 57 57 3',CR,LF
db ' 2 204 0 100 4 2 2 72 72 4',CR,LF
db ' 3 272 0 132 8 2 3 85 85 5',CR
stdfrmsz equ $-stdfrm
;
data ends
;
code segment para public 'CODE'
assume cs:code,ds:data
;
options proc
;
les bx,namebuf
mov srch.bufoff,bx
mov srch.bufseg,es
mov srch.bufsiz,4096
mov ah,2fh
int 21h
lea bx,[bx+1eh]
mov srch.dtaoff,bx
mov srch.dtaseg,es
;
mov bx,offset argv
evaloop:
les di,[bx]
mov al,es:[di]
inc di
cmp al,'+'
je plusoption
cmp al,'-'
jne srchfilelist
call evaloption
jmp short nextloop
plusoption:
call asctoint
jz nostart
mov startpage,ax
nostart:
cmp byte ptr es:[di],'-'
jne relativepage
inc di
call asctoint
jz nextloop
cmp ax,startpage
jb nextloop
mov lastpage,ax
jmp short nextloop
relativepage:
cmp byte ptr es:[di],','
jne nextloop
inc di
call asctoint
jz nextloop
dec ax
add ax,startpage
jc nextloop
mov lastpage,ax
jmp short nextloop
srchfilelist:
dec di
mov srch.namoff,di
mov srch.namseg,es
push bx
mov bx,offset srch
call filelist
pop bx
nextloop:
lea bx,[bx+4]
dec argc
jnz evaloop
;
call defadjst
;
push ds
les di,namebuf
mov cx,srch.bufoff
lds si,nameptr
xor al,al
ptrsetloop:
jcxz namend
cmp si,1024
jae namend
mov ds:[si],di
mov ds:[si+2],es
lea si,[si+4]
repne scasb
jmp short ptrsetloop
namend:
pop ds
shr si,1
shr si,1
mov ax,si
test ax,ax
ret
;
options endp
;
evaloption proc
;
mov al,es:[di]
inc di
cmp al,'a'
jb optchar
cmp al,'z'
ja optchar
sub al,20h
optchar:
cmp al,'?'
jne optunit
jmp formdisp
optunit:
cmp al,'U'
jne optcls
call asctoint
jz binend
cmp ax,3
ja binend
mov hopper,ax
binend: ret
optcls:
cmp al,'C'
jne optgap
mov formfeed,NO
ret
optgap:
cmp al,'G'
jne opthdr
call asctoint
cmp ax,256
jae gapend
mov gapsize,ax
mov gset,YES
gapend: ret
opthdr:
cmp al,'H'
jne optclmsiz
mov headeroff,di
mov headerseg,es
mov hdrprint,YES
ret
optclmsiz:
cmp al,'K'
jne optlincnt
call asctoint
jz clmend
cmp ax,512
ja clmend
mov clmcnt,ax
mov cset,YES
clmend: ret
optlincnt:
cmp al,'L'
jne optlinumb
call asctoint
jz linend
cmp ax,256
ja linend
mov lincnt,ax
mov lset,YES
linend: ret
optlinumb:
cmp al,'N'
jne optpage
mov linumb,YES
call asctoint
jz numdflt
cmp ax,10
ja numdflt
mov numclm,ax
ret
mov numclm,4
numdflt:ret
optpage:
cmp al,'P'
jne optrtn
mov al,es:[di]
cmp al,'a'
jb pguppr
sub al,20h
pguppr: cmp al,'A'
jne pgtypeb
mov pgtype,ASM
mov pageproc,offset asmpage
ret
pgtypeb:cmp al,'B'
jne pgtypec
mov pgtype,BASIC
mov pageproc,offset baspage
ret
pgtypec:cmp al,'C'
jne pgtypex
mov pgtype,C
mov pageproc,offset cpage
ret
pgtypex:mov pgtype,EXT
ret
optrtn:
cmp al,'R'
jne optpgform
mov creturns,YES
call asctoint
jz rtnend
cmp ax,384
ja rtnend
mov pghight,ax
mov rset,YES
rtnend: ret
optpgform:
cmp al,'F'
jne optwidth
mov frmset,NO
call checkform
cmp frmset,YES
je formend
call asctoint
jz formraw
cmp ax,3
ja formraw
mov clmpitch,ax
formraw:cmp byte ptr es:[di],','
jne formend
inc di
call checkform
cmp frmset,YES
je formend
call asctoint
jz formpag
cmp ax,3
ja formpag
mov rawpitch,ax
formpag:cmp byte ptr es:[di],','
jne formend
inc di
call checkform
formend:ret
optwidth:
cmp al,'W'
jne opttabcnt
call asctoint
jz wdhend
cmp ax,512
ja wdhend
mov pgwidth,ax
mov wset,YES
wdhend: ret
opttabcnt:
cmp al,'T'
jne optmargin
call asctoint
jz tabcend
cmp ax,128
ja tabcend
mov tabcount,ax
tabcend:ret
optmargin:
cmp al,'M'
jne optmclm
cmp byte ptr es:[di],','
je mrgnhdr2
call asctoint
cmp ax,256
ja mrgnhdr
mov marginleft,ax
mov mlset,YES
mrgnhdr:cmp byte ptr es:[di],','
jne mrgnend
mrgnhdr2:inc di
call asctoint
cmp ax,256
ja mrgnend
mov marginhead,ax
mov mhset,YES
mrgnend:ret
optmclm:
cmp al,'0'
jb others
cmp al,'9'
ja others
dec di
call asctoint
jz others
cmp ax,512
ja others
mov blkcnt,ax
mov bset,YES
cmp gset,YES
je others
mov gapsize,2
mov gset,YES
others: ret
;
evaloption endp
;
checkform proc
;
mov al,es:[di]
cmp al,'a'
jb cfuppr
sub al,20h
cfuppr: cmp al,'A'
jne fmtypeb
mov pprtype,A4
mov frmtype,PORT
mov frmset,YES
inc di
jmp checkform
fmtypeb:cmp al,'B'
jne fmtypep
mov pprtype,B4
mov frmtype,LAND
mov frmset,YES
inc di
jmp checkform
fmtypep:cmp al,'P'
jne fmtypel
mov frmtype,PORT
mov frmset,YES
inc di
ret
fmtypel:cmp al,'L'
jne fmtypes
mov frmtype,LAND
mov frmset,YES
inc di
ret
fmtypes:cmp al,'S'
jne fmtypew
mov pprtype,STOCK80
mov frmtype,LAND
mov frmset,YES
inc di
jmp checkform
fmtypew:cmp al,'W'
jne fmtypee
mov pprtype,STOCK136
mov frmtype,LAND
mov frmset,YES
inc di
fmtypee:ret
;
checkform endp
;
defadjst proc
;
cmp clmpitch,3
je pagecheck
cmp rawpitch,3
jne pagecheck
mov ax,clmpitch
mov rawpitch,ax
pagecheck:
mov bx,pprtype
shl bx,1
add bx,frmtype
shl bx,1
mov bx,[bx+offset formlist]
mov formbase,bx
;
mov ax,size pgform
mov cx,rawpitch
dec cx
mul cx
add bx,ax
;
cmp rset,YES
je rseted
mov ax,[bx].physline
mov pghight,ax
rseted:
cmp lset,YES
je lseted
mov ax,[bx].prntline
mov lincnt,ax
lseted:
cmp mhset,YES
je mhseted
mov ax,[bx].headmrgn
mov marginhead,ax
mhseted:
mov bx,formbase
mov ax,size pgform
mov cx,clmpitch
dec cx
mul cx
add bx,ax
;
cmp wset,YES
je wseted
mov ax,[bx].allwidth
mov pgwidth,ax
wseted:
cmp cset,YES
je cseted
mov ax,[bx].blckclmn
mov clmcnt,ax
cseted:
cmp gset,YES
je gseted
mov ax,[bx].gapclmn
mov gapsize,ax
gseted:
cmp bset,YES
je bseted
mov ax,[bx].blckcount
mov blkcnt,ax
bseted:
cmp mlset,YES
je mlseted
mov ax,[bx].leftmrgn
mov marginleft,ax
mlseted:
;
cmp rset,YES
jne realine
mov ax,pghight
cmp ax,lincnt
jae linerange
mov lincnt,ax
jmp linerange
realine:
cmp lset,YES
jne linerange
mov ax,lincnt
cmp ax,pghight
jbe linerange
mov pghight,ax
linerange:
mov ax,pghight
sub ax,lincnt
mov filline,ax
;
mov ax,marginhead
cmp hdrprint,YES
jne noheadprint
add ax,2
noheadprint:
sub lincnt,ax
ja remainline
add lincnt,ax
mov marginhead,0
mov hdrprint,NO
remainline:
;
mov bx,pgwidth
mov cx,blkcnt
sub bx,marginleft
ja blkchk
add bx,marginleft
mov marginleft,0
mov mhset,NO
blkchk:
cmp blkcnt,1
ja blkchk2
mov gapsize,0
cmp bx,clmcnt
ja blk1
mov clmcnt,bx
blk1: jmp adjlnum
blkchk2:
cmp bx,cx
jae clmnchk
jmp clmseterrors
clmnchk:
mov ax,clmcnt
mul cx
test dx,dx
jnz calclm
cmp bx,ax
jae gapchk
calclm:
mov ax,bx
cwd
div cx
mov clmcnt,ax
mov cset,NO
gapchk:
dec cx
mov ax,gapsize
mul cx
test dx,dx
jnz setgap
cmp bx,ax
ja chkend
setgap:
mov gapsize,2
mov gset,NO
chkend:
mov ax,wset
add ax,mlset
add ax,cset
add ax,gset
add ax,bset
jnz adjclm
jmp adjlnum
adjclm:
mov bx,pgwidth
sub bx,marginleft
mov cx,bx
cmp gset,YES
je dominagap
mov ax,clmcnt
mul blkcnt
test dx,dx
jnz adjdefault
sub cx,ax
jae remaingap
adjdefault:
mov ax,bx
mov cx,blkcnt
dec cx
shl cx,1
sub ax,cx
jbe clmseterrors
cwd
div blkcnt
test ax,ax
jz clmseterrors
mov clmcnt,ax
mov gapsize,2
jmp adjlnum
remaingap:
mov ax,cx
mov bx,blkcnt
dec bx
cwd
div bx
cmp ax,gapsize
ja inrangegap
mov gapsize,ax
inrangegap:
jmp adjlnum
;
clmseterrors:
mov errorno,-1
mov dx,offset clmerror
mov cx,clmerrsz
jmp abort
;
dominagap:
mov ax,blkcnt
dec ax
mul gapsize
test dx,dx
jnz adjdefault
sub cx,ax
jbe adjdefault
mov ax,cx
cwd
div blkcnt
test ax,ax
jz adjdefault
cmp cset,YES
jne adjustclm
cmp ax,clmcnt
jb adjdefault
jmp short adjlnum
adjustclm:
mov clmcnt,ax
adjlnum:
cmp linumb,YES
jne adjend
mov ax,numclm
inc ax
sub clmcnt,ax
ja adjend
add clmcnt,ax
mov linumb,NO
mov numclm,0
adjend:
mov bx,blkcnt
mov ax,clmcnt
mul bx
xchg ax,bx
dec ax
mul gapsize
add ax,bx
add ax,marginleft
cmp ax,pgwidth
jae widthovr
mov ax,pgwidth
widthovr:
add ax,1fh
and ax,0fff0h
mov linsiz,ax
;
ret
;
defadjst endp
;
formdisp proc
;
mov ax,ds
mov es,ax
cld
mov di,offset stddot
mov si,offset stk136
mov cx,9
call frmsetloop
;
mov di,offset stdpag
mov si,offset a4port
mov cx,12
call frmsetloop
;
mov ax,pprtype
cmp ax,A4
jae pageprtr
mov bx,offset dotform
test ax,ax
jz setdefmrk
mov dx,frmtype
xor dx,1
add ax,dx
jmp short setdefmrk
pageprtr:
mov bx,offset pageform
sub ax,A4
shl ax,1
add ax,frmtype
setdefmrk:
mov dx,(hlplnsz * 3)
mul dx
add bx,ax
mov cx,hlplnsz
mov ax,clmpitch
dec ax
mul cx
add ax,selclm
mov si,ax
mov word ptr [bx+si],07381h
mov word ptr [bx+si+4],07481h
mov ax,rawpitch
dec ax
mul cx
add ax,selraw
mov si,ax
mov word ptr [bx+si],07381h
mov word ptr [bx+si+4],07481h
;
mov dx,offset stdfrm
mov cx,stdfrmsz
mov errorno,0
jmp abort
;
formdisp endp
;
frmsetloop proc
;
lodsw
call inttoascb
inc di
lodsw
call inttoascb
lea di,[di+3]
lodsw
call inttoascb
inc di
lodsw
call inttoascb
lea di,[di+2]
lodsw
call inttoascb
lea di,[di+9]
lodsw
call inttoascb
lea di,[di+2]
lodsw
call inttoascb
lea di,[di+2]
lodsw
call inttoascb
lea di,[di+18]
loop frmsetloop
ret
;
frmsetloop endp
;
code ends
end