home *** CD-ROM | disk | FTP | other *** search
- ;void draw_box(hrz_char,vrt_char,top_x,top_y,width,depth,color);
- ; unsigned char hrz_char,vrt_char,top_x,top_y,width,depth,color;
-
- EXTRN _memory_model:byte
- EXTRN _error_code:byte
- EXTRN _video_buffer:word
- EXTRN _snow_protect:byte
-
- _TEXT SEGMENT BYTE PUBLIC 'CODE'
- ASSUME CS:_TEXT
- PUBLIC _draw_box
- _draw_box proc near
- jmp short D1
- WriteIt PROC ;procedures writes char,
- push dx ; takes care of snow problem
- push bx ;save DX and BX
- cld ;set direction flag
- cmp _snow_protect,0 ;protect against snow?
- jle C1 ;jump ahead if not
- mov dx,3dah ;status byte address
- mov bx,ax ;store AX contents
- A1: in al,dx ;get status byte
- test al,1 ;test bit
- jnz A1 ;loop till 0
- cli ;disable interrupts
- B1: in al,dx ;get status byte
- test al,1 ;test bit
- jz B1 ;loop till 1
- mov ax,bx ;restore AX contents
- C1: stosw ;write the character
- dec di ;pull ptr back
- dec di ;again
- pop bx ;restore BX
- pop dx ;restore DX and return
- ret
- WriteIt endp
- D1: push bp ;
- mov bp,sp ;set up stack frame
- push di ;
- mov _error_code,1 ;1 = row out of range
- cmp _memory_model,0 ;near or far?
- jle begin ;jump if near
- inc bp ;else add 2 to BP
- inc bp ;
- begin: mov al,[bp+4] ;horz double or single?
- mov dh,205 ;assume double line
- cmp al,'D' ;double line?
- je E1 ;jump ahead if so
- cmp al,'d' ;double line?
- je E1 ;jump ahead if so
- mov dh,196 ;else single line
- E1: mov al,[bp+6] ;vert double or single?
- mov dl,186 ;assume double line
- cmp al,'D' ;double line?
- je G1 ;jump ahead if so
- cmp al,'d' ;double line?
- je G1 ;jump ahead if so
- mov dl,179 ;else single line
- cmp dh,196 ;horizontal single?
- jne F1 ;jump ahead if not
- mov ax,0DaBFh ;top sngl vert, sngl horz
- mov bx,0c0d9h ;bot sngl vert, sngl horz
- jmp short I1 ;registers set
- F1: mov ax,0d5b8h ;top sngl vert, dbl horz
- mov bx,0d4beh ;bot sngl vert, dbl horz
- jmp short I1 ;registers set
- G1: cmp dh,196 ;horizontal single?
- jne H1 ;jump ahead if not
- mov ax,0d6b7h ;top dbl vert, sngl horz
- mov bx,0d3bdh ;bot dbl vert, sngl horz
- jmp short I1 ;registers set
- H1: mov ax,0c9bbh ;top dbl vert, dbl horz
- mov bx,0c8bch ;bot dbl vert, dbl horz
- I1: mov [bp+4],ax ;save top corners
- mov [bp+6],bx ;save bottom corners
- mov ax,_video_buffer ;get ptr to videobuffer
- mov es,ax ;move to ES
- sub ax,ax ;
- mov al,[bp+10] ;row to AX
- dec ax ;count from 0
- cmp ax,24 ;in range?
- jbe J1 ;jump ahead if so
- jmp O1 ;else quit routine
- J1: inc _error_code ;2 = column out of range
- mov cl,160 ;bytes in a row
- mul cl ;times rows
- sub cx,cx ;
- mov cl,[bp+8] ;column to CX
- dec cx ;count from 0
- cmp cx,79 ;in range?
- jna K1 ;jump ahead if OK
- jmp O1 ;else quit
- K1: inc _error_code ;3 = width out of range
- shl cx,1 ;double for attributes
- add ax,cx ;buffer offset
- mov di,ax ;ES:DI pts to offset
- sub bx,bx ;
- mov bl,[bp+12] ;width to BX
- dec bx ;count from 0
- dec bx ;ready for test
- cmp bx,78 ;out of range?
- ja O1 ;quit if so
- inc _error_code ;4 = depth out of range
- inc bx ;readjust after test
- shl bx,1 ;double for attributes
- mov ah,[bp+16] ;attribute to AH
- mov al,[bp+5] ;topleft corner to AL
- call WriteIt ;write the character
- add di,bx ;add offset to scrn ptr
- mov al,[bp+4] ;topright corner to AL
- call WriteIt ;write the character
- sub di,bx ;sub offset from scrn ptr
- sub cx,cx ;
- mov cl,[bp+14] ;get box depth
- dec cx ;minus 2
- dec cx ; for corners
- cmp cx,23 ;test length
- ja O1 ;quit if out of range
- mov _error_code,0 ;else no error
- push di ;save initial position
- add di,160 ;forward screen ptr
- jcxz M1 ;jump if no chr to write
- mov al,dl ;vertical char to AL
- L1: call WriteIt ;write the character
- add di,bx ;add offset to scrn ptr
- call WriteIt ;write the character
- sub di,bx ;sub offset from scrn ptr
- add di,160 ;forward screen ptr
- loop L1 ;on to next vert chars
- M1: mov al,[bp+7] ;bottomleft corner to AL
- call WriteIt ;write the character
- mov al,[bp+6] ;bottomright corner to AL
- add di,bx ;add offset to scrn ptr
- call WriteIt ;write the character
- sub di,bx ;sub offset from scrn ptr
- mov bx,di ;save bottom left pos
- pop di ;restore top left pos
- mov al,dh ;horizontal char to AL
- sub cx,cx ;
- mov cl,[bp+12] ;get width
- dec cx ;minus 2
- dec cx ; for corners
- jcxz O1 ;quit if no chrs to print
- inc di ;forward scrn ptr
- inc di ; to 1st position on top
- N1: call WriteIt ;write the character
- inc di ;forward base ptr
- inc di ;...again
- inc bx ;forward scrn ptr
- inc bx ; for bottom line
- xchg di,bx ;get ready to write
- call WriteIt ;write the character
- xchg di,bx ;restore scrn ptr
- loop N1 ;go do next char
- O1: sti ;reenable interrupts
- pop di ;
- pop bp ;
- cmp _memory_model,0 ;quit
- jle quit ;
- db 0CBh ;RET far
- quit: ret ;RET near
- _draw_box endp
- _TEXT ENDS
- END