home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR8
/
PCMCVT.ZIP
/
PCMASM.ZIP
/
WP51CONV.INC
< prev
next >
Wrap
Text File
|
1993-05-29
|
7KB
|
235 lines
;WP51CONV.INC
;Copyright (c) 1993 Jay Munro
;First Published in PC Magazine June 29 1993
;PCMCVT Conversion module for WordPerfect 5.1, 5.2
;final
WordPerfectCVT Proc Near
ReadWPFile:
Lea SI,HeaderBuffer
Invoke Seek,SHandle,[SI].WPDocStart ;go to start of text
Call WP51ReadIt ;go read the file
Jnc RWPLoop
Jmp WP51Exit
RWPLoop:
LodSb ;grab a character
Cmp AL,13 ;a soft return?
Jnz @F
Cmp Byte Ptr WordWrapFlag,-1 ;are we doing word wrap?
Jz RepWSpace ;yes, then just test for a space
Mov AL,10 ;no, put in a linefeed to preserve
Jmp @F ; original formatting
RepWSpace:
Cmp SI,TopEnd ;can we look ahead?
Jnz Ret2Space
Call WP51ReadIt
Jnc Ret2Space
Jmp WP51Exit
Ret2Space:
Cmp Byte Ptr [SI],32 ;[+1] ;is the next character a space?
Jz @F ;yes, then we don't need to include it.
Mov AL,32 ;replace the character with a space
Call WriteIt
Jmp ReLoop ;skip over
@@:
Cmp AL,10 ;hard cr for WP
Jnz @F
Mov AL,13
Call WriteIt ;write what's in AL
Mov AL,10 ;make it a hard return
Call WriteIt
Jmp ReLoop
@@:
Cmp AL,0A9h ;hard hyphen
Jnz @F
Mov AL,'-'
Call WriteIt ;write it
Jmp ReLoop
@@:
Cmp AL,0AAh ;hard hyphen at end of line
Jnz @F
Mov AL,'-'
Call WriteIt ;write it
Jmp ReLoop
@@:
Cmp AL,0ABh ;hard hyphen at end of page
Jnz @F
Mov AL,'-'
Call WriteIt ;write it
Jmp ReLoop
@@:
Cmp AL,0A0h ;hard space
Jnz @F
Mov AL,32
Call WriteIt ;write it
Jmp ReLoop
@@: ;tabs
Cmp AL,0C1h ;code for tabs
Jnz SoftReturn
WPTabLoop:
Cmp SI,TopEnd
Jz WPTabReRead
LodSb ;grab the next character
And AL,1100000b
Jnz NoTab
Call DoTabs ;expand the tabs
NoTab:
Cmp SI,TopEnd ;hit the end of the read buffer?
Jnz WPTabOk ;no, continue
Push AX ;else preserve AX and reread
Call WP51ReadIt ;a piece of the file
Pop AX ;retrieve AX
Jc WPExitLeap ;if file error, exit peacefully
WPTabOk:
LodSb
Cmp AL,0C1h ;is it the end function code?
Jnz NoTab
Jmp ReLoop
WPTabReRead:
Push AX
Call WP51ReadIt
Pop AX
Jc WPExitLeap
Jmp WPTabLoop
SoftReturn:
Cmp AL,13 ;soft return? (*in for future ref*)
Jz ReLoopLeap ;skip it
Cmp AL,1Fh ;is it a control char?
Jbe ReLoopLeap ;skip it
Cmp AL,80h ;start of single byte function
Jb @F
Jmp Short FunctionCheck ;check function
@@:
Call WriteIt ;no, then write it
ReLoopLeap: ;leap frog to avoid warning errors
Jmp ReLoop
WPExitLeap:
Jmp Wp51Exit ;leap frog to avoid warning errors
FunctionCheck: ;Single character control codes
Cmp AL,0BFh ;is it single or multibyte
Jbe ReLoopLeap
Cmp AL,0D0h ;variable length multibyte
Jae MultiByte
Mov AH,AL ;save the function code (0Cx) into AH
FixedLenMB: ;fixed length multibyte
LodSb ;get a byte
Cmp AH,AL ;did we get to the end of the function
Jz ReLoop ;yes, then exit and continue
Cmp Word Ptr SI,TopEnd
Jz FLMBReread
Jmp FixedLenMB
FLMBReread:
Push AX ;ran out of buffer, read more from file
Call WP51ReadIt ;read file
Pop AX ;retrieve character (AH is of interest)
Jc Wp51Exit ;exit out if no more character (error)
Jmp FixedLenMB ;go back for more
MultiByte:
Cmp AL,0DCh ;is it a column ?
Jz ColumnCode ;yes
Cmp AL,0D4h ;how about a soft or hard page
Jnz ByteLoop ;no, continue
Cmp SI,TopEnd ;can we look ahead?
Jnz @F ;yes, then do it
Call WP51ReadIt
Jc WPExitLeap
@@:
Cmp Byte Ptr [SI],0 ;ok, service 0 ?
Jnz ByteLoop ;not service 0, skip ahead
Mov AL,12 ;write page feed
Call WriteIt ;
Jmp ByteLoop ;
ColumnCode:
Cmp SI,TopEnd ;can we look ahead?
Jnz @F ;yes, then do it
Call WP51ReadIt
Jc WPExitLeap
@@:
Cmp Byte Ptr [SI],0 ;ok, service 0 ?
Jnz ByteLoop ;not service 0, skip ahead
Mov AL,13
Call WriteIt
Mov AL,10
Call WriteIt
ByteLoop:
Inc SI ;move up a character
Cmp SI,TopEnd ;did we get to the last byte?
Jnz @F ;re-read file
Call WP51ReadIt
Jc WPExitLeap
@@:
Mov DX,[SI]
Add DX,2 ;add difference
ByteLoop2:
Inc SI ;point to next character
Cmp SI,TopEnd ;time to read more?
Jg @F ;yes, go read
ReByte2:
Dec DX ;count inner loop
Jz ReLoop ;go back when done
Jmp ByteLoop2
@@:
Call WP51ReadIt
Jc @F
Jmp ByteLoop2
@@:
Jmp WP51Exit
ReLoop:
Cmp Word Ptr SI,TopEnd
Jz @F
Jmp RWPLeap
@@:
Call WP51ReadIt
Jc Wp51Exit
RWPLeap:
Jmp RWPLoop
WP51Exit:
Ret
WP51ReadIt:
Push DX ;save function loop counter
Call ReadIt ;go read the file
Jnc @F
Mov AL,-1 ;flush buffer
Call WriteIt ;clear it
Stc
@@:
Pop DX
RetN
WordPerfectCVT EndP