TITLE "VIDJ - Vlib 4.1" NAME ('VIDJ') ;================================================================= ; Copyright (C) 1989 by Harold F. Bower. Permission granted to ; Alpha Systems Corp. to distribute with The Libraries, Version 4 ;----------------------------------------------------------------- ; Author : Harold F. Bower ; Date : 4 Mar 89 ; Version : 1.0 ; Module : VIDJ ; Abstract: This module contains the routines DRBOX and ERABOX ; which draw and erase a graphics-bordered box respectively, ; from parameters passed on the stack, GBOX and ERGBOX which ; draw and erase a box from register parameters, and DRFBOX ; and GFBOX which draw a box framed with the solid graphics ; block character from stack and register parameters respect- ; ively. Boxes are drawn complete with space filling. ; Stack Parameters are passed as: ; CALL DRBOX ; ..or ERABOX, or DRFBOX ; DEFB 5,5,10,20 ; Starting Row, Col, Height, Width ; It also contains the routine CHKBOX which checks the ; parameters of a box to a) see if height and width are >= 2 ; and b) result in a box which will not extend beyond edges ; of the screen defined in the ENV. Parameters are in the ; same registers as for a GBOX/GFBOX call. ; Revision: ; 1.1 19 JAN 90 Joe Wright ; VLINE changed to reflect new @GSET0. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; Module Entry Points PUBLIC DRFBOX, DRBOX, ERABOX, GFBOX, GBOX, GERBOX PUBLIC CHKBOX ; ..from VLIB Get.. EXT GOTOXY, VIDOUT, GHBAR, @GHL, @GVL EXT GRXON, GRXOFF, DRFULL, @GSET0 EXT ULEFT, URIGHT, LLEFT, LRIGHT ; ..from Z3LIB Get.. EXT GETCRT ; ..from SYSLIB Get.. EXT COUT .Z80 CSEG ;=============================================================== ; DRFBOX - Draw Graphics Box with Full block character from stack ; Entry: - None. Parameter block address is passed on stack ; Exit : - None. The block is printed ; Uses : - None ; Special Requirements: None ;=============================================================== DRFBOX: EX (SP),HL ; Get addr of parms PUSH DE ; Save regs PUSH BC PUSH AF CALL SETUP ; Get parms CALL GFBOX ; Draw a full box EXIT: POP AF POP BC EX DE,HL POP DE EX (SP),HL ; Swap HL w/ret addr RET ;=============================================================== ; DRBOX - Draw thinly framed graphics box, space filled from stack ; Entry: - None. Paramater block addressed on stack ; Exit : - None. The box is drawn ; Uses : - None ; Special Requirements: None ;=============================================================== DRBOX: EX (SP),HL ; Get parameter addr PUSH DE ; Save regs PUSH BC PUSH AF CALL SETUP ; Get parms CALL GBOX ; Draw the Graphics Box JR EXIT ; ..exit thru common code ;=============================================================== ; ERABOX - Erase a graphics box by overwriting from parms on stack ; Entry: - None. Paramater block addressed on stack ; Exit : - None. The box is drawn ; Uses : - None ; Special Requirements: None ;=============================================================== ERABOX: EX (SP),HL ; Get parm addresses PUSH DE ; Save regs PUSH BC PUSH AF CALL SETUP ; Get parms CALL GERBOX ; ..and erase it JR EXIT ; Exit thru common code ;=============================================================== ; GFBOX - Draw Graphics Box with Full block character from regs ; Entry: B = Width ; C = Height ; H = Starting Row (Top Left corner) ; L = Starting Column (Top Left corner) ; Exit : - None. Registers destroyed and box printed ; Uses : HL,BC,AF ; Special Requirements: None ;=============================================================== GFBOX: CALL CHKBOX ; Check for illegal values RET Z ; ..quit if no good CALL DRWHL ; Start by drawing whole blk horz line DEC C ; Reduce Vertical size by borders DEC C DEC B ; Reduce Horiz size by borders DEC B PUSH BC LOOP: INC H ; Move down to next row PUSH HL ; Save regs PUSH BC CALL GOTOXY ; Position cursor CALL DRFULL ; Draw full block graphics char LD A,' ' ; Fill block w/spaces DRWMD0: CALL COUT ; ..and print DJNZ DRWMD0 ; Loop til done CALL DRFULL ; Draw right border POP BC ; Restore loop regs POP HL DEC C ; Decrease Row count (Height) JR NZ,LOOP ; ..continue till all done POP BC ; ...restore original counters INC B ; Put Col Ctr back to full width INC B INC H ; Move down to bottom border of box ;..fall thru to draw block line.. DRWHL: PUSH HL ; Preserve parms PUSH BC CALL GOTOXY ; Position cursor DRWHL0: CALL DRFULL ; Draw full block graphics char DJNZ DRWHL0 ; ..loop til done JR EXIT0 ; Restore regs and return below ;=============================================================== ; GBOX - Draw thinly framed graphics box, space filled from regs ; Entry: B = Width ; C = Height ; H = Starting Row (Upper left corner) ; L = Starting Column (Upper left corner) ; Exit : - None. Regs destroyed and the box is drawn ; Uses : HL,BC,AF ; Special Requirements: None ;=============================================================== GBOX: CALL CHKBOX ; Check/correct box dimensions RET Z ; ..return if bad parms DEC B ; Shorten width by borders DEC B DEC C ; ..and shorten Height by borders DEC C PUSH DE ; Save this reg pair CALL GOTOXY ; ..and position cursor CALL ULEFT ; Print upperleft corner CALL DRWL ; Draw graphics line CALL URIGHT ; Print upperright corner LOOP0: INC H ; Addr next line CALL GOTOXY ; Position cursor CALL VLINE ; Print left border PUSH BC ; ..save counters LOOP1: LD A,' ' ; Fill inside with spaces CALL COUT DJNZ LOOP1 ; ..looping til done CALL VLINE ; Print right border POP BC ; Restore counts DEC C ; Are we done w/inside? JR NZ,LOOP0 ; ..loop if not INC H ; Go to bottom row CALL GOTOXY ; Position cursor CALL LLEFT ; Print lowerleft corner CALL DRWL ; Draw line CALL LRIGHT ; Print lowerright corner POP DE ; Restore regs RET ;..... ; Draw a Horizontal Graphics line ; Enter: B = Count ; Exit : None DRWL: PUSH HL ; Save regs PUSH BC XOR A ; Signal for thin line LD C,A ; ..and left-to-right direction INC L ; ...compensate for first corner CALL GHBAR ; Draw the line EXIT0: POP BC POP HL RET ;..... ; Draw a Vertical line Graphics char ; Enter: None ; Exit : A=0 If can't do, A<>0 if Ok VLINE: PUSH HL ; Save regs LD HL,@GVL JP @GSET0 ; ..finish in other module ;=============================================================== ; GERBOX - Erase a graphics box by overwriting from parms in regs ; Entry: B = Width ; C = Height ; H = Starting Row (Upper left corner) ; L = Starting Column (Upper left corner) ; Exit : - None. Regs destroyed and the box is drawn ; Uses : HL,BC,AF ; Special Requirements: None ;=============================================================== GERBOX: CALL CHKBOX ; Check box parameters RET Z ; ..quit doing nothing if bad LOOP2: PUSH HL PUSH BC CALL GOTOXY ; Position cursor LD A,' ' ; overwrite with spaces LOOP3: CALL COUT ; ..w/syslib routine DJNZ LOOP3 ; Loop til done POP BC ; Restore regs POP HL INC H ; Go to next row DEC C ; ..and count down JR NZ,LOOP2 ; Loop til done RET ;..... ; Setup routine for this module. Load values to regs SETUP: LD D,(HL) ; Row INC HL LD E,(HL) ; Col INC HL LD C,(HL) ; Height INC HL LD B,(HL) ; Width INC HL EX DE,HL ; Put XY coords in HL, Return adr in DE RET ;=============================================================== ; CHKBOX - Check parameters of graphics box from values in regs ; Entry: B = Width ; C = Height ; H = Starting Row (Upper left corner) ; L = Starting Column (Upper left corner) ; Exit : A <> 0, Zero Flag Clear (NZ) if Valid dimensions returned ; A = 0, Zero Flag Set if Bad dimensions ; Uses : AF (Maybe B,C,H,L if corrections made) ; Special Requirements: None ;=============================================================== CHKBOX: PUSH DE ; Save regs EX DE,HL ; .preserve XY in DE CALL GETCRT ; ..and Get CRT Def'n from ENV EX DE,HL ; CRT addr in DE, XY in HL LD A,B ; Is width Ok? CP 3 JR C,CHKERX ; ..jump if not minimums LD A,L ; Is starting Col > 0? OR A JR NZ,CHKBO0 ; ..jump if Ok INC L ; Else bump to first Col DEC B ; ..and compensate count CHKBO0: LD A,C ; Is height Ok? CP 3 JR C,CHKERX ; ..jump if not minimums LD A,H ; Is starting Row > 0? OR A JR NZ,CHKBO1 ; ..jump if Ok INC H ; Else bump to first Row DEC C ; ..and compensate count CHKBO1: LD A,(DE) ; Get Column count from ENV def'n INC DE ; ..advance to Row SUB L ; Subtract starting Column JR C,CHKERX ; ..error exit if > right margin CP B ; Will Width take box off screen? JR NC,CHKBO2 ; ..jump if not LD B,A ; Else correct to end on R Edge INC B ; ..and fix value CHKBO2: LD A,(DE) ; Get bottom Row number SUB H ; Subtract starting Row JR C,CHKERX ; ..error exit if > bottom row CP C ; Will depth take box off screen? JR NC,CHKBO3 ; ..jump if not LD C,A ; Else correct to bottom on last row INC C ; ..and fix value CHKBO3: DEFB 0F6H ; "OR 0AFH" when combined with XOR A CHKERX: XOR A ; Error when entered here POP DE ; Restore regs RET END