home *** CD-ROM | disk | FTP | other *** search
- ;*****************************************************************************
- ;
- ; Name : DrawBox.ASM
- ;
- ; Revised : 09/02/90 03:24pm
- ;
- ; Purpose : - Draws a box on the display screen of a size and in a format
- ; defined by the user.
- ;
- ; - This routine should be DECLAREd in your program as an
- ; external SUB routine, via the QuickBASIC statement -
- ;
- ;DECLARE SUB DrawBox(Ulr%, Ulc%, Lrr%, Lrc%, BAttrib%, BType%, WAttrib%, Shadow%)
- ;
- ; Parameters : - In this case, there will be 8 parameters, any or all of may be
- ; either pre-defined INTEGER VARIABLES, IMMEDIATE INTEGER VALUES,
- ; or CONSTs.
- ; - These parameters are defined as follows :
- ;
- ; Ulr = Upper Left Row # for Box
- ; Ulc = Upper Left Column # for Box
- ; Lrr = Lower Right Row # for Box
- ; Lrc = Lower Right Column # for Box
- ; BAttrib = Color attribute for box, as per the table below
- ; BType = which type of Box to draw -
- ; 1 = Straight Single Line Box
- ; 2 = Straight Double Line Box
- ; 3 = Single HLine Box, Double VLine Box
- ; 4 = Double HLine Box, Single VLine Box
- ; 5 = Solid Line box (100% dots)
- ; 6 = Solid Line box (75% dots)
- ; 7 = Solid Line box (50% dots)
- ; 8 = Solid Line box (25% dots)
- ; WAttrib = Color to first clear the window area to - if this
- ; parm = 0, then the area will NOT be cleared prior to
- ; use (you can clear to black using attrib = 7)
- ; Shadow = If this parm = 0 then NO shadow box will be drawn
- ; around the box; otherwise, a shadow box will be drawn.
- ;
- ; Returns : None - also, this routine does NO ERROR CHECKING for the
- ; parm values you pass, so be careful.
- ;
- ; COLOR VALUES TO USE
- ;
- ; Color Foreground Value Background Value
- ;
- ; BLACK 0 0
- ; BLUE 1 16
- ; GREEN 2 32
- ; CYAN 3 48
- ; RED 4 64
- ; MAGENTA 5 80
- ; YELLOW 6 96
- ; WHITE 7 112
- ;
- ; To get INTENSE foreground color, add 8 to foreground value.
- ; To get BLINKING attribute, add 128 to the total combined color value.
- ;
- ;=============================================================================
-
- .MODEL MEDIUM, BASIC
- .CODE
-
- DrawBox proc ULR:word, ULC:word, LRR:word, LRC:word, BATTRIB:word, BOXTYPE:word, WATTRIB:word, SHADOW:word
- LOCAL VLine:WORD, HLine:WORD, UlcChar:WORD, UrcChar:WORD, LlcChar:WORD, LrcChar:WORD, ULRow:word ,ULCol:word ,LRRow:word ,LRCol:word
-
- mov VLine,179 ; If invalid value is in BOXTYPE,
- mov HLine,196 ; assume we will use straight,
- mov UlcChar,218 ; single line box
- mov UrcChar,191
- mov LlcChar,192
- mov LrcChar,217
-
- mov BX,BOXTYPE
- mov AX,[BX]
- cmp AX,1 ; Should we draw a single line box?
- jne Not_Type_One_Box ; No - check next possibility
- jmp Draw_The_Box
-
- Not_Type_One_Box:
-
- cmp AX,2 ; Should we draw a double line box?
- jne Not_Type_Two_Box ; No - check the next possibility
- mov VLine,186
- mov HLine,205
- mov UlcChar,201
- mov UrcChar,187
- mov LlcChar,200
- mov LrcChar,188
- jmp Draw_The_Box
-
- Not_Type_Two_Box:
-
- cmp AX,3 ; Should we draw single HLine, Double VLine Box?
- jne Not_Type_Three_Box ; No - Check the last possibility
- mov VLine,186
- mov HLine,196
- mov UlcChar,214
- mov UrcChar,183
- mov LlcChar,211
- mov LrcChar,189
- jmp Draw_The_Box
-
- Not_Type_Three_Box:
-
- cmp AX,4 ; Should we draw a double HLine, Single VLine Box?
- jne Not_Type_Four_Box ; No - try next type
- mov VLine, 179
- mov HLine, 205
- mov UlcChar, 213
- mov UrcChar, 184
- mov LlcChar, 212
- mov LrcChar, 190
- jmp Draw_The_Box
-
- Not_Type_Four_Box:
-
- cmp AX,5 ; Should we draw a solid box (100% dots)
- jne Not_Type_Five_Box ; No - try next type
- mov VLine, 219
- mov HLine, 219
- mov UlcChar, 219
- mov UrcChar, 219
- mov LlcChar, 219
- mov LrcChar, 219
- jmp short Draw_The_Box
-
- Not_Type_Five_Box:
-
- cmp AX,6 ; Should we draw solid box, 3/4 dots?
- jne Not_Type_Six_Box ; No - try next type
- mov HLine, 178
- mov VLine, 178
- mov UlcChar, 178
- mov UrcChar, 178
- mov LlcChar, 178
- mov LrcChar, 178
- jmp short Draw_The_Box
-
- Not_Type_Six_Box:
-
- cmp AX,7 ; Should we draw solid box, 1/2 dots on?
- jne Not_Type_Seven_Box ; No - try next type
- mov HLine, 177
- mov VLine, 177
- mov UlcChar, 177
- mov UrcChar, 177
- mov LlcChar, 177
- mov LrcChar, 177
- jmp short Draw_The_Box
-
- Not_Type_Seven_Box:
-
- cmp AX, 8 ; Should we draw solid box, 1/4 dots?
- jne Draw_The_Box ; If not, use default = single line box
- mov VLine, 176
- mov HLine, 176
- mov UlcChar, 176
- mov UrcChar, 176
- mov LlcChar, 176
- mov LrcChar, 176
-
- Draw_The_Box:
-
- mov BX,ULC ; Put address of the ULC value into BX
- mov CX,[BX] ; Put actual ULC value into CL
- mov ULCol,CX
- dec CX ; Adjust for BASIC screen definitions
- shl CX,1 ; Remember there are 2 bytes / position
-
- mov BX,ULR ; Put address of the ULR value into BX
- mov AX,[BX] ; Put the ULR value into AX
- mov ULRow,AX
- dec AX ; Adjust for BASIC screen definitions
- mov DX,160 ; Multiply by # bytes per row
- mul DL
- add AX,CX ; Here,AX = total offset to start of box
- mov SI,CX ; CX = column displacement only
-
- mov BX,LRC ; Repeat proc for Lower left corner
- mov CX,[BX]
- mov LRCol,CX
- dec CX
- shl CX,1
- sub CX,SI
- shr CX,1
- push CX
-
- mov SI,AX ; Here, SI = total offset to box start
- mov BX,LRR
- mov AX,[BX]
- mov LRRow,AX
- dec AX
- mov DX,160
- mul DL
- dec AX
- push AX
-
- mov BX,WATTRIB
- mov AX,[BX]
- mov BH,AL ; Put Window Attrib value into BH for scroll
- cmp AX,0
- je NoClearFirst
-
- push CX
- mov DX,LRCol
- dec DX
- mov AX,LRRow
- dec AX
- mov DH,AL ; DH:DL = LRR:LRC
- mov CX,ULCol
- dec CL
- mov AX,ULRow
- dec AL
- mov CH,AL ; CH:CL = ULR:ULC
- mov AX,0700h ; Prepare for scroll down entire window
- int 10h
-
- pop CX
-
- NoClearFirst:
-
- mov BX,BATTRIB
- mov AX,[BX] ; Now the color attrib is in AL
-
- mov DX,0B800h ; Address of Video RAM memory
- mov ES,DX
- mov DI,SI
-
- push AX
- mov AX,HLine
- mov DL,AL ; Load box drawing chars
- mov AX, VLine
- mov DH,AL
- mov AX,UlcChar
- mov BH,AL
- mov AX,UrcChar
- mov BL,AL
- pop AX
-
- pop SI
- push SI
- cmp SI,DI
- jne STEP_ONE
- mov BH,DL
- mov BL,DL
-
- Step_One:
-
- mov SI,DI
- mov ES:[SI],BH
- jmp short Step_Three
-
- Step_Two:
-
- mov ES:[SI],DL
-
- Step_Three:
-
- inc SI
- cmp AL,0
- je Step_Four
- mov ES:[SI],AL
-
- Step_Four:
-
- inc SI
- loop Step_Two
- mov ES:[SI],BL
- inc SI
- cmp AL,0
- je Step_Five
- mov ES:[SI],AL
-
- Step_Five:
-
- pop BX
- pop CX
- cmp SI,BX
- jge DrawBox_Exit
-
- Step_Six:
-
- add DI,160
- mov SI,DI
- cmp SI,BX
- jge Step_Ten
-
- Step_Seven:
-
- mov ES:[SI],DH
- inc SI
- cmp AL,0
- je Step_Eight
- mov ES:[SI],AL
-
- Step_Eight:
-
- dec SI
- add SI,CX
- add SI,CX
- mov ES:[SI],DH
- inc SI
- cmp AL,0
- je Step_Nine
- mov ES:[SI],AL
-
- Step_Nine:
-
- jmp short Step_Six
-
- Step_Ten:
- push AX
- mov AX,LlcChar
- mov BH,AL
- mov AX,LrcChar
- mov BL,AL
- pop AX
-
- Step_Eleven:
-
- push BX
- push CX
- jmp short Step_One
-
- DrawBox_Exit:
-
- mov BX,SHADOW
- mov AX,[BX]
- cmp AX,0
- je LeaveDrawBox
-
- mov CX,ULCol ; Put COLUMN value into CX (do NOT adjust, since we want 1 column to the right)
- shl CX,1 ; and for 2 bytes per position
-
- mov AX,LRRow ; Put ROW value into AX
- mov DX,160
- mul DL ; Multiply AX by # bytes per ROW
- add AX,CX ; and add in the COLUMN offset
-
- mov SI,AX ; SI = screen position to start at, but
- inc SI ; add 1 to skip over char to attrib.
-
- mov CX,LRCol
- mov AX,ULCol
- sub CX,AX ; CX = length of row to change
- mov AL,08 ; AL now has the color attribute
- inc CX
- inc CX
-
- mov DX,0B800h ; Put address of Video RAM into DX, and from there,
- mov ES,DX ; into ES register
-
- ChangeDBottom:
-
- mov ES:[SI],AL ; Put new color attrib onto screen
- inc SI
- inc SI ; Skip over char to next attrib byte
- loop ChangeDBottom
-
- mov AX,LRCol
- mov DL,AL
- mov AX,ULRow
- mov DH,AL ; Row and Column are in DH:DL
- mov CX,LRRow
- sub CX,AX
- inc CX
-
- DoShadowDEdge:
-
- mov AH,02
- xor BH,BH
- int 10h ; SetCursorPosition in BIOS
-
- mov AH,08
- int 10h ; Read Char W/attribute at cursor
-
- mov BL,08 ; Put color attribute into BL
- mov AH,09
- push CX
- mov CX,01
- int 10h
-
- inc DL
- mov AH,02
- xor BH,BH
- int 10h ; SetCursorPosition in BIOS
-
- mov AH,08
- int 10h ; Read Char W/attribute at cursor
- mov BL,08
- mov AH,09
- int 10h
-
- pop CX
- dec DL
- inc DH
- loop DoShadowDEdge
-
- LeaveDrawBox:
-
- ret
-
- DrawBox ENDP
-
- END
-
- ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++