Category : Printer + Display Graphics
Archive   : PMDUPS.ZIP
Filename : PMDUP.ASM

 
Output of file : PMDUP.ASM contained in archive : PMDUPS.ZIP

COMMENT |

PM-DUP.ASM The assembly language routines for PM-DUPS.BAS,
a duplicate graphic finder for use with PrintMaster files.
(C) Copyright 1989 Merlin R. Null

|
;----------------------------------------------------------------
; 0 BLACK 4 RED 8 GRAY 12 LIGHT RED
; 1 BLUE 5 MAGENTA 9 LIGHT BLUE 13 LIGHT MAGENTA
; 2 GREEN 6 BROWN 10 LIGHT GREEN 14 YELLOW
; 3 CYAN 7 WHITE 11 LIGHT CYAN 15 HIGH-INTENSITY WHITE

BlackOnWhite EQU 70h

MonoSegAddr EQU 0B000h ;address of monochrome buffer
GraphSegAddr EQU 0B800h ;address of graphics buffer

;----------------------------------------------------------------
DATA SEGMENT BYTE 'DATA'

TitleMes DB 'PMDUPS version 1.2 10-3-89 (C) Copyright '
DB '1989 Merlin R. Null',0


FunctKeysDat DB 'F4 Path',3,'V View',3,'Esc Exit',0

F8Dat DB 'T/U tag/untag',3,'F8 Compare against all files',0

FirstFilePrompt DB 'Arrow keys select first file to compare, return to'
DB ' accept.',0

SecondFilePrmpt DB 'Arrow keys select second graphic file, return to'
DB ' accept.',0

NewPathMes DB 'Path:',0

OldDTAaddr DW 0
OldDTAsegment DW 0
AtrByte DB 0
TextAtr DB 0
HighlightAtr DB 0

DATA ENDS


DGROUP GROUP DATA

CODE SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:CODE, DS:DGROUP

PUBLIC SetAsmColors, FindFirst, FindNext, RestoreDTA
PUBLIC Prompt1, Prompt2, DoTitle, NewPath, GetKey
PUBLIC ClearFileArea, ClearMesArea, ClearLine25, ScrollAll
PUBLIC FunctKeys, ClearName2

;----------------------------------------------------------------
FindFirst PROC FAR
PUSH BP
MOV BP,SP
PUSH ES
MOV AH,2Fh ;find DTA address function
INT 21h
MOV OldDTAaddr,BX ;store DTA offset
MOV OldDTAsegment,ES ;store DTA segment
POP ES

MOV AH,1Ah ;set DTA function
MOV BX,[BP]+6 ;get string descriptor address
MOV DX,[BX]+2 ;get address of new DTA
INT 21h

MOV AH,4Eh ;find first file function
XOR CX,CX ;file handle 0
MOV BX,[BP]+8 ;get string descriptor address
MOV DX,[BX]+2 ;get address of file mask
INT 21h

MOV BX,[BP]+10 ;return 0 if file found
MOV [BX],AX ; 1 if not found
POP BP
RET 6

FindFirst ENDP
;----------------------------------------------------------------
FindNext PROC FAR
PUSH BP
MOV BP,SP

MOV AH,4Fh ;find next file function
XOR CX,CX ;file handle 0
MOV BX,[BP]+6 ;get string descriptor address
MOV DX,[BX]+2 ;get address of file mask
INT 21h

MOV BX,[BP]+8 ;return flag 0 if file found
MOV [BX],AX ;1 if not found
POP BP
RET 4

FindNext ENDP
;----------------------------------------------------------------
;Restore original DTA

RestoreDTA PROC FAR

PUSH ES
PUSH DS
MOV AH,1Ah ;set DTA function
MOV DX,OldDTAaddr ;get old DTA offset
MOV DS,OldDTAsegment ;set to original segment value
INT 21h
POP DS
POP ES
RET

RestoreDTA ENDP
;----------------------------------------------------------------
ClearFileArea PROC FAR
MOV BH,TextAtr
MOV CX,0101h ;ul corner row 1 col 1
MOV DX,154Eh ;lr corner row 21 col 78
CALL ClearArea
RET

ClearFileArea ENDP
;----------------------------------------------------------------
ScrollAll PROC FAR
MOV BH,TextAtr
XOR CX,CX ;ul corner row 0 col 0
MOV DX,184Fh ;lr corner row 24 col 79
MOV AX,0601h ;scroll active page 1 line up
INT 10h
RET

ScrollAll ENDP
;----------------------------------------------------------------
ClearMesArea PROC FAR
MOV BH,TextAtr
MOV CX,1700h ;ul corner row 23 col 0
MOV DX,184Fh ;lr corner row 24 col 79
CALL ClearArea
RET

ClearMesArea ENDP
;----------------------------------------------------------------
ClearLine25 PROC FAR
MOV BH,TextAtr
MOV CX,1800h ;ul corner row 24 col 0
MOV DX,184Fh ;lr corner row 24 col 79
CALL ClearArea
RET

ClearLine25 ENDP
;----------------------------------------------------------------
ClearName2 PROC FAR
MOV BH,TextAtr
MOV CX,1800h ;ul corner row 24 col 0
MOV DX,1820h ;lr corner row 24 col 32
CALL ClearArea
RET

ClearName2 ENDP
;----------------------------------------------------------------
DoTitle PROC FAR
XOR CX,CX ;row 0 col 0
MOV DX,004Fh ;row 0 col 79
MOV AtrByte,BlackOnWhite ;reverse video
CALL ClearArea ;make top line rev vid
XOR CX,1600h ;row 22 col 0
MOV DX,164Fh ;row 22 col 79
CALL ClearArea ;now row 22 rev vid
LEA SI,TitleMes ;print title
MOV DX,0003h ;row 0 col 3
CALL InsertAsmString
RET

DoTitle ENDP
;----------------------------------------------------------------
FunctKeys PROC FAR
LEA SI,FunctKeysDat
MOV DX,1603h ;row 22 col 4
CALL InsertAsmString
FunctKeys ENDP

Prompt1 PROC FAR
MOV AL,TextAtr
MOV AtrByte,AL
CALL ClearMesArea
LEA SI,FirstFilePrompt
MOV DX,1701h ;row 23 col 1
CALL InsertAsmString
RET
Prompt1 ENDP
;----------------------------------------------------------------
Prompt2 PROC FAR
LEA SI,SecondFilePrmpt
MOV DX,1801h ;row 24 col 1
CALL InsertAsmString
LEA SI,F8Dat
MOV DX,1720h ;row 23 col 32
CALL InsertAsmString
RET
Prompt2 ENDP
;----------------------------------------------------------------
NewPath PROC FAR
CALL ClearLine25
LEA SI,NewPathMes
MOV DX,1801h ;row 24 col 1
CALL InsertAsmString
RET

NewPath ENDP
;----------------------------------------------------------------
;Get a key press with BIOS, return the ASCII value of the character and
;the scan code to BASIC.

GetKey PROC FAR
PUSH BP
MOV BP,SP
XOR AH,AH ;get a key press
INT 16h
MOV BX,AX ;copy result to BX
XOR AH,AH ;zero out scan code
XCHG BL,BH ;move scan code to BL
XOR BH,BH ;zero out character
MOV DI,[BP]+8 ;pass ascii value to BASIC
MOV [DI],AX
MOV DI,[BP]+6 ;pass scan code to BASIC
MOV [DI],BX
POP BP
RET 4
GetKey ENDP
;----------------------------------------------------------------
;Set highlight and normal text colors with values passed from BASIC

SetAsmColors PROC FAR
PUSH BP
MOV BP,SP
MOV BX,[BP]+6
MOV AX,[BX]
MOV HighlightAtr,AL
MOV BX,[BP]+8
MOV AX,[BX]
MOV TextATR,AL
MOV AtrByte,AL
POP BP
RET 4

SetAsmColors ENDP

;************ Start of Routines Local to the Assembly Module *****************

;-----------------------------------------------------------------------------
; ClearScreen - Clear the Screen and Home - AtrByte contains screen colors
; ClearEOS - Clear to end of screen, CX upper left
; ClearArea - AtrByte colors, CX upper left, DX lower right

ClearScreen: XOR CX,CX ;upper left (0,0)
ClearEOS: MOV DX,184Fh ;lower right (24,79)
ClearArea: MOV BH,AtrByte ;get screen attribute
MOV AX,0600h ;scroll active page
INT 10h
RET
;-----------------------------------------------------------------------------
;Direct Cursor Addressing
; DX row, col

Locate: MOV AH,2 ;request move cursor
XOR BH,BH ;page #0
INT 10h
RET
;-----------------------------------------------------------------------------
;Insert String Directly in the Video Buffer
; SI string address DX row, col
; AtrByte holds color, foreground and background

InsertAsmString:
PUSH ES
CALL CalcVidOffset ;calc offset into video buffer
MOV DI,AX ;offset was returned in AX
CALL SetVidAddr ;set to monochrome or graphics
MOV ES,AX ;video buffer address into ES
MOV AX,80
MOV DH,AtrByte ;get the attribute byte
IsrtLoop: MOV DL,BYTE PTR[SI]
CMP DL,0
JE InsertAsmStringExit ;exit if end of string
CMP DL,0FEh ;end of line marker?
JNE IsrtLoop2
SHL AX,1 ;skip remaining positions on
ADD DI,AX ; this line
MOV AX,80 ;and reset char count
JMP SHORT NextByte

IsrtLoop2: CMP DL,31 ;control character?
JA IsrtWord ;no, use the character
CMP DL,1 ;if character 1
JZ Skip80 ;skip next 80 print positions
XOR DH,DH ;zero attribute byte
SUB AX,DX
SHL DX,1 ;skip number of print
ADD DI,DX ;positions = ASCII value
MOV DH,AtrByte ;restore attribute byte
JMP SHORT NextByte

Skip80: ADD DI,0A0H ;skip next 80 positions
JMP SHORT NextByte

IsrtWord: MOV ES:WORD PTR[DI],DX ;move char and attr to crt buf
ADD DI,2 ;point to next crt buf loc
DEC AX
NextByte: ADD SI,1 ;point to next string byte
JMP SHORT IsrtLoop ;move another word

InsertAsmStringExit:
POP ES
RET
;-----------------------------------------------------------------------------
;Set Video Address

SetVidAddr: CALL GetMode ;get crt mode
CMP AL,7 ;is it monochrome
JNE ItsGraphics
MOV AX,MonoSegAddr ;monochrome buffer seg addr
RET

ItsGraphics: MOV AX,GraphSegAddr ;graphics buffer seg address
RET
;-----------------------------------------------------------------------------
;Calculate Video Address

CalcVidOffset: MOV AX,160 ;number of bytes in row
MUL DH ;row * 160
SHL DL,1 ;col * 2
XOR DH,DH ;byte to word
ADD AX,DX ;(row *160)+(col*2)
MOV DI,AX ;set offset in DI
RET
;-----------------------------------------------------------------------------
;Get Video Mode.
;Returns CRT mode in AL and the number of character cols in AH

GetMode: MOV AX,0F00h
INT 10h
XOR AH,AH ;remove cols
RET
;-----------------------------------------------------------------------------
CODE ENDS
END