Displaying Text and Graphics / 9
KILLBUFF
Deallocate Get/Put buffer
tax:
RUN GFX2("KILLBUFF",group, buffer)
Deallocates the indicated Get/Put buffer. You select group and
buffer numbers when you define a buffer or when you load or
get a window image. For more information on Get/Put buffers,
see DEFBUFF, PUT, GET, and GPLOAD.
Parameters:
group The group number of the buffer you want to
deallocate, in the range 1-199. Buffer Group
Numbers 0 and
200-255
are reserved for OS-9
system use.
buffer
The number of the buffer to deallocate, in the
range
1-255.
Examples:
RUN GFX2("KILLBUFF",1,5)
Sample Program:
This procedure draws a figure on a window screen, loads it
into a buffer, then repeatedly places it in new locations on the
screen. Each new PUT erases the previous image.
PROCEDURE putdown
ODIM X,Y,T,J:INTEGER
ORUN GFX2("CUROFF")
ORUN GFX2("CLEAR")
ORUN GFX2("ELLIPSE",320,96,12,4)
ORUN GFX2C"CIRCLE",320,90,5)
ORUN GFX2("COLOR",1)
ORUN GFX2C"FILL",320,96)
ORUN GFX2("COLOR",3)
nRUN GFX2("FILL",320,90)
ORUN GFX2("BAR",305,100,335,104)
pRUN GFX2("GET",1,1,288,85,50,23)
ORUN GFX2("GET",1 ,2,1 ,1 ,50,23)
pRUN GFX2("PUT",1,2,288,85)
9-101
BASIC09 .Reference
OJ =1 0
pFOR T=20 TO 559 STEP 6
OJ=J+2
ORUN GFX2C"PUT", 1 , 1 ,T, J)
ONEXT T
ORUN GFX2C"KILLHUFF",1 ,1 )
ORUN GFX2C"CURON")
REND
9-102
Displaying Text and Graphics / 9
LINE
Draw a line
Syntax:
RUN GFX2([path,]"LINE"[,xcorl,ycorl],xcor2,
ycorz
Function:
Draws a line in one of the following ways:
· From the current draw pointer to the specified X- and Ycoordinates.
· From the specified beginning X- and Y-coordinates to
the specified ending X- and Y-coordinates.
Parameters:
path The
route to the window in which you want to
draw a line.
xcorl,ycorl The optional beginning X- and Y-coordinates
for the line.
xcor2,ycor2 The ending X- and Y-coordinates for the line.
Examples:
RUN GFX2("LINE",192,128)
RUN GFX2("LINE",0,0,192,128)
Sample Program:
This procedure draws a sine wave of vertical lines across a
window.
PROCEDURE waves
pDIM A,X,Y,Z:INTEGER
OCALC=0 _
DA=100
ORUN GFX2("CLEAR")
' ORUN GFX2("COLOR",3,2)
OFOR X=0 TO 638 STEP 1
OCALC=CALC+.05
OY=A-SIN (CALC) * 1 5
OZ=Y+25
9-103
BASIC09 Reference
ORUN GFX2C"LINE",X,Y,X,Z)
ONEXT X
pEND
9-104
Displaying Text and Graphics l 9
LOGIC
Perform logic function
Syntax:
RUN GFX2("LOGIC","function")
Function:
Causes BASIC09 to perform the specified logic function on all data bits used by subsequent drawing functions.
Once set, the logic function remains in effect until you turn
LOGIC off.
Parameters:
function
can be one of the following logical functions:
OFF
AND -
OR -
XOR -
RUN GFX2C"LOGIC","AND")
RUN GFX2C"LOGIC","XOR")
no logic
performs AND logic
performs OR logic
performs XOR logic
Sample Program:
This procedure uses LOGIC to draw a horizontal bar across a
background of multicolored vertical bars. Using XOR logic, the
procedure causes the horizontal bar to change the color of each
vertical bar.
PROCEDURE logic
pDIM A,Z,T,X,Y,COLOR:INTEGER
RUN GFX2C"LOGIC","OFF")
RUN GFX2C"CLEAR")
pCOLOR=0
OFOR T=0 TO 619 STEP 20
COLOR=COLOR+1
RUN GFX2C"COLOR",COLOR
RUN GFX2C"HAR",T,0,T+20,190)
pNEXT T
RUN GFX2C"COLOR",3,2)
RUN GFX2C"LOGIC","XOR")
9-105
BASIC09 Reference
(FOR T=1 TO 1 0
ORUN GFX2C"BAR",0,80,639,112)
ONEXT T
ORUN GFX2C"LOGIC","OFF")
OEND
9-106
Displaying Text and Graphics l 9
OWSET
Establish an overlay window
Syntax:
RUN GFX2([path,]"OWSET",save switch,xpos,
ypos,xsizeysize,foreground,background)
Function:
Creates an overlay window on a previously existing
device window. Reconfigures the current device window paths
to use a new area of the screen as the current device window.
Parameters:
path
The route to the window in which you want to
set an overlay.
save switch
Either 0 or 1. A value of 0 tells BASIC09 not
to save the overlaid area. A value of 1 tells
BASIC09 to save the overlaid area and restore
it when the new window closes.
xpos The character column in which to start the
new window (upper left corner).
ypos The character row in. which to start the new
window (upper left corner).
xsize
The width of the new window in characters.
ysize The depth of the new window in rows.
foreground
The foreground color of the new window.
background
The background color of the new window.
Examples:
RUN GFX2("OWSET",00,44,10,32,8,00,06)
Sample Program:
This procedure creates six progressively smaller overlay windows, labeling each. It then waits for you to press a key, after
which it erases all the windows and leaves the original window
intact.
9-107
BASIC09 Reference
PROCEDURE overwin
ODIM X,Y,X1 ,Y1 ,T,J,H,L,PLACE:INTEGER
pD I M RESPONSE : STR I NG 1 1 J
oX=0 \Y=0
pX1 =80 \Y1 =24
OPLACE-33
OFOR T=1 TO 6
OIF T=2 OR T=6 THEN
pH = 3
DELSE H=2
DENDIF
ORUN GFX2C"OWSET",1 ,X,Y,X1 ,Y1 ,H,T)
OX-X+6 \Y=Y+2
OX1 =X1 -1 2 \Y1 =Y1 -4
pFOR J=1 TO 5
OPRINT TAHCPLACE); "Overlay Screen "; T
ONEXT J
OPLACE=PLACE-6
ONEXT T
OPRINT "Press A Key...";
OGET x1,RESPONSE
OFOR T=1 TO 6
ORUN GFX2C"OWEND")
ONEXT T
REND
9-108
Displaying Text and Graphics / 9
PALETTE
Set color for palette registers
Syntax:
RUN GFX2([path,]"PALETTE",register,color)
Function:
Sets palette colors. Lets you install any of the Color
Computer's 64 colors in the palette for use with text and
graphics.
Parameters:
path The route to the window where you want to
change palette colors.
register The number of the register in which you want
to install a new color.
color The code of the new color you want to install.
/- Examples:
RUN GFX2("PALETTE",13,32)
Sample Program:
This procedure draws a series of bars and circles, then repeatedly changes their colors using PALETTE.
PROCEDURE palette
DIM T,K,J,X,Y,COLOR:INTEGER
OD I M RESPONSE : STR I NG t 1 l
ORUN GFX2("COLOR",3,2,2)
OCOLOR=0
ORUN GFX2("CLEAR")
ORUN GFX2("CUROFF")
OFOR Y=0 TO 23 STEP 3
ORUN GFX2("COLOR",COLOR)
ORUN GFX2("HAR",0,Y,639,Y+3)
OCOLOR-COLOR+1
OIF COLOR=2 THEN
OCOLOR=COLOR+ 1
OEND I F
ONEXT Y
OFOR Y=164 TO 185 STEP 3
9-109
BASIC09 Reference
ORUN GFX2C"COLOR",COLOR)
ORUN GFX2C"BAR",0,Y,639,Y+3)
pCOLOR=COLOR+ 1
(NEXT Y
OCOLOR=0
OFOR K=45 TO 1 70 STEP 48
FOR T=1 0 0 TO 580 STEP 1 0 0
pRUN GFX2C"COLOR",3)
ORUN GFX2C"CIRCLE",T,K,30)
ORUN GFX2C"COLOR",COLOR)
pRUN GFX2C"FILL",T,K)
OCOLOR=COLOR+1
OIF COLOR=2 THEN
OCOLOR=COLOR+1
REND I F
ONEXT T
ONEXT K
pREPEAT
OX=RNDC63)
OREPEAT
OY=RNDC16)+1
OUNTIL Y<>2
ORUN GFX2C"PALETTE",Y,X)
ORUN INKEYCRESPONSE)
OUNTIL RESPONSE>""
ORUN GFX2C"DEFCOL")
ORUN GFX2C"CURON")
REND
9-110
Displaying Text and Graphics / 9
PATTERN
Select pattern buffer
Syntax:
RUN GFX2E[path,]"PATTERN",group, buffer)
Function:
Selects the contents of a preloaded Get/Put buffer as
a pattern for graphics functions. Although PATTERN can use
a buffer of any size, it uses a specific number of bytes, depending on the screen format in use:
Color Pattern Bits
Mode Array Size Per Pel
02 4 bytes x 8 bytes = 32 bytes 1
04 8 bytes x 8 bytes = 64 bytes 2
16 16 bytes x 8 bytes = 128 bytes 4
The pattern array is a 32 x 8 pel representation of graphics
memory. It takes the current color mode into consideration to
define the number of bits per pel and pels per byte. If the
buffer is larger than the number of bytes required, PATTERN
ignores the extra bytes. BASIC09 uses the selected pattern
with all draw commands until you change the pattern or turn
off the pattern function by specifying a group and buffer number of 0.
Parameters:
path The route to the window in which you want to
use a new graphics pattern.
group The group number of the buffer you want to
use for a graphics pattern.
buffer
The buffer number that you want to use for a
graphics pattern. _
Examples:
RUN GFX2C"PATTERN",1,3)
9-111
BASIC09 Reference
Sample Program:
This procedure loads the current window data at location 0,0
into a buffer to use as a draw pattern. It then draws a circle and
fills the circle with the pattern in the buffer.
PROCEDURE pattern
pDIM X,Y,T:INTEGER
ORUN GFX2C"GET",1 ,1 ,0,0,5,5)
ORUN GFX2C"COLOR",4)
ORUN GFX2C"CLEAR")
ORUN GFX2C"CIRCLE",320,96,100)
ORUN GFX2C"FILL",320,96)
ORUN GFX2C"PATTERN",1 ,1 )
ORUN GFX2C"COLOR",3)
ORUN GFX2C"FILL",320,96)
ORUN GFX2C"PATTERN",0,0)
REND
9-112
Displaying Text and Graphics / 9
POINT
Mark a point
Syntax:
RUN GFX2([path,]"POINT"[,xcorycor])
Function:
Sets the pixel at the current draw pointer position
or at the specified coordinates to the current foreground color.
If you do not specify coordinates, POINT sets the pixel at the
draw pointer.
Parameters:
path The route to the window in which you want to
turn on the specified pixels.
xcorycor Optional coordinates for the POINT function.
The X-coordinates are in the range 0-639. The
Y-coordinates are in the range 0-191.
Examples:
RUN GFX2C"POINT")
RUN GFX2C"PO I NT",192, 1 28)
Sample Program:
This procedure uses POINT to produce a swirl design on a window screen.
PROCEDURE point
CHASE 0
ODIM XC20),YC20):INTEGER
pDIM T,R,J,K:INTEGER
DJ = 0
OK = 0
pRUN GFX2C"CUROFF")
ORUN GFX2C"CLEAR")
pFOR T=1 TO 288 STEP 3
pJ=J+1
OFOR R=0 TO 11
pXCR)=INTCT*SINC30*R+K))+320
OYCR)=INTCJ*COSC30*R+K))+96
pRUN GFX2C"POINT",XCR),YCR))
9-113
BASIC09 Reference
pK=K+1
ONEXT R
pNEXT T
ORUN GFX2C"CURON")
FIEND
9-114
Displaying Text and Graphics / 9
PRO P SW
Proportional space switch
Syntax:
RUN GFX2([path,]"PROPSW",",switch")
Function:
Enables or disables the automatic proportional spacing of characters on graphic screens.
Parameters:
path
The route to the window in which you want to
use proportional character spacing.
switch
Either OFF to turn proportional spacing off, or
ON to turn proportional spacing on. The
default setting of the switch is OFF.
Examples:
RUN GFX2("PROPSW","ON")
Sample Program:
This procedure produces a demonstration of the BASIC09 proportional spacing function.
PROCEDURE proport
ODIM LINE:STRING
pDIM LETTER:STRINGf1]
ODIM T,J,K,FLAG:INTEGER
ORUN GFX2("CLEAR")
OFLAG=1
pFOR T=1 TO 1 2
pREAD LINE
pFOR J=1 TO LEN(LINE)
OLETTER=MID$(LINE,J,1) _
OIF LETTER<>"!" AND LETTER<>"V" THEN
OPRINT LETTER;
OENDIF
OIF LETTER="!" THEN
pFLAG=FLAG* -1
OIF FLAG>O THEN
ORUN GFX2("PROPSW","OFF")
9-115
BASIC09 Reference
ELSE
ORUN GFX2C"PROPSW","ON")
pENDI F
REND I F
OIF LETTER="*" THEN
OPRINT CHR$C34);
OEND I F
pNEXT J
OPRINT
ONEXT T
OPRINT \ PRINT
REND
ODATA "This is a demonstration of"
ODATA "!Proportional Spacing! using"
ODATA "HASIC09's GFX2 module."
ODATA
sell
ODATA "!The quick brown fox jumped. . . !"
ODATA "The quick brown fox jumped..."
ODATA
1811
ODATA "Use the command"
ODATA "!RUN GFX2C#PROPSWx,xON#)!"
ODATA "to turn proportional spacing on."
ODATA "Use !RUN GFX2C#PROPSWx,#OFF#)!"
ODATA "to turn proportional spacing off"
9-116
Displaying Text and Graphics / 9
PUT
Put a saved data block on the window
tax:
RUN GFX2([path,]"PUT",group,buffer,
xcorycor)
Function:
Places the image in the specified Get/Put buffer on
the window. PUT requires only the group and buffer numbers
and the window coordinates for the upper left corner of the
image. The GET function saves the dimensions of the block in
the buffer. PUT automatically handles window format
conversion.
Parameters:
path The route to the window where you want to
place a pre-saved image.
group The group number of the buffer in which to
save the window data.
buffer
The buffer number in which to save the win
dow data.
xcorycor The X- and Y-coordinates of the upper left cor
ner of the window position. The X-coordinates
are in the range 0-639. The Y-coordinates are
in the range 0-191.
Examples:
RUN GFX2C"PUT",1,5,100,50)
9-117
BASIC09 Reference
Sample Program:
This procedure draws a character, loads it into a buffer, then ,,.·~,,
repeatedly replaces the character to the window screen using
PUT. Each new image erases the previous image, giving an
impression of animation.
PROCEDURE putdown
[]DIM X,Y,T,J:INTEGER
[]RUN GFX2C"CUROFF")
[]RUN GFX2C"CLEAR")
[]RUN GFX2C"ELLIPSE",320,96,12,4)
[]RUN GFX2C"CIRCLE",320,90,5)
[]RUN GFX2C"COLOR",1 )
[]RUN GFX2C"FILL",320,96)
[]RUN GFX2C"COLOR",3)
[]RUN GFX2C"FILL",320,90)
[]RUN GFX2C"BAR",305,100,335,104)
[]RUN GFX2C"GET",1,1,288,85,50,23)
[]RUN GFX2C"GET",1 ,2,1 ,1 ,50,23)
[]RUN GFX2C"PUT",1,2,288,85)
[]J =1 0,
[]FOR T=20 TO 559 STEP 6
[]J=J+2
[]RUN GFX2C"PUT", 1 , 1 ,T,J)
[]NEXT T
[]RUN GFX2C"KILLHUFF",1 ,1 )
[]RUN GFX2C"CURON")
[]END
9-118
Displaying Text and Graphics / 9
PUTGC
Put graphics cursor
Syntax:
RUN GFX2([path,]"PUTGC",xcorycor)
Function: Places and displays the graphics cursor at the specified location. Use screen relative coordinates for this function,
not window relative coordinates. The horizontal range is
0-639.
The vertical range is
0-191.
Parameters:
path The route to the window where you want to
display a graphics cursor.
xcorycor The screen coordinates for the cursor location.
The X coordinates are in the range
0-639.
The
Y coordinates are in the range
0-191.
Examples:
RUN GFX2C"PUTGC",100,5)
Sample Program:
This procedure displays the available graphic cursors stored in
group 202. Before this procedure can work, you must merge the
Stdptrs file in the SYS directory of your system disk with the
window you are using. For instance, if your system diskette is in
Drive /D0, merge Stdptrs with Window 1, by typing:
merge /d0/sy5/5tdptrs > /w1 ENTER
PROCEDURE viewcur
DDIM T,Z:INTEGER
DRUN GFX2C"CLEAR")
DFOR T=1 TO 7
DRUN GFX2C"GCSET",202,T)
DRUN GFX2C"PUTGC",320,96)
OFOR Z=1 TO 6000
DNEXT Z
DNEXT T
DRUN GFX2C"GCSET",0,0)
DEND
9-119
BASIC09 Reference
REVON
Reverse video on
REVOFF
Reverse video off
Syntax: RUN GFX2([path,]"REVON")
RUN GFX2([pat,hj"REVOFF")
Function: Enables or disables reverse video characters. Once
set, reverse video remains in effect until you execute the
reverse video off function.
Parameters:
path The route to the window in which you want to
display reverse characters.
Examples:
RUN GFX2("REVON")
RUN GFX2("REVOFF")
9-120
Displaying Text and Graphics / 9
SCALE SW
Enable/disable scaling
Syntax:
RUN GFX2([path, ]"SCALE
Sw","s yvi tch")
Function:
Enables or disables scaling when drawing on variously formatted windows. Scaling in windows is normally on.
If scaling is off, coordinates are relative to the window origin
coordinates. Scaling does not affect text.
Parameters:
path
The route to the window where you want to
turn scaling off or on.
switch
Either OFF (disable scaling) or ON (enable
scaling).
.. , Examples:
RUN GFX2("SCALESW","OFF")
Sample Program:
This procedure runs a routine of drawing a design in overlay
windows twice. The routine runs once with scaling off and once
with scaling on. After the first routine pauses, press the space
bar to see the second demonstration.
PROCEDURE Scale
ODIM X,Y,X1 ,Y1 ,T,H,J,R,W,Z: INTEGER
pDIM RESPONSE:STRING[1]
ORUN GFX2("CLEAR")
OFOR J=1 TO 2
DI F J=1 THEN
ORUN GFX2("SCALESW","OFF") -
DELSE
ORUN GFX2("SCALESW","ON")
OENDI F
OX=0 \Y=0 \X1 =80 \Y1 =24
OFOR T=1 TO 4
OIF T=2 OR T=6 THEN
OH = 3
9-121
BASIC09 Reference
OELSE H=2
OEND I F
ORUN GFX2C"OWSET",1 ,X,Y,X1 ,Y1 ,H,T)
OFOR R=1 TO 35
OW=40*S I NCR)+1 70
OZ=25*COSCR)+45
ORUN GFX2C"CIRCLE",W,Z,30)
ONEXT R
OX=X+G \Y=Y+2 \X1 =X1 -1 2 \Y1 =Y1 -4
ONEXT T
OPRINT "Press A Key
OGET #1 ,RESPONSE
OFOR T=1 TO 4
ORUN GFX2C"OWEND")
ONEXT T
ONEXT J
REND
9-122
Displaying Text and Graphics / 9
SELECT
Select next window
Syntax:
RUN GFX2([path,"SELECT")
Function:
SELECT causes a window to display if the procedure is operating in the active window. If the procedure is not
in the active window, the newly selected window displays
when you press
CLEAR
. If you do not specify a path, BASIC09
selects the device using the standard input, standard output,
and standard error paths, Paths 0, 1, and 2.
Parameters:
path The path to the window to select.
Examples:
RUN GFX2("SELECT")
RUN GFX2(1,"SELECT")
RUN GFX2(PATH,"SELECT")
Sample Program:
From /TERM, this procedure temporarily opens a path to
Window 3, creates the window format, and uses SELECT to display the new window. It draws a design, then returns to the
/TERM screen and closes the path.
PROCEDURE design
pDIM PATH,T,Y:INTEGER
OOPEN #PATH,"/W3":WRITE
pRUN GFX2(PATH,"DWSET",5,0,0,80,24,3,2,2)
pRUN GFX2(PATH,"SELECT") _
Fly= 1
pFOR T=1 TO 200 STEP 3
Ely =Y+1
ORUN GFX2(PATH,"ELLIPSE",320,96,T,Y)
ONEXT T
pRUN GFX2(PATH,"COLOR",1,2)
OFOR T=200 TO 1 STEP -6
ORUN GFX2(PATH,"ELLIPSE",320,96,T,Y)
9-123
BASIC09 Reference
OIF INTCT/3)=T/3 THEN
pY=Y#1
pEND I F
ONEXT T~'
ORUN GFX2(1,"SELECT")
ORUN GFX2CPATH,"DWEND")
OCLOSE #PATH
OEND
9-124
Displaying Text and Graphics / 9
SETDPTR
Set draw pointer
Syntax: RUN GFX2([path,]"SETDPTR",xcorycor)
Function: Places the draw pointer at the specified coordinates.
The draw pointer selects the beginning point of the next
graphics draw function (such as CIRCLE, LINE, BOX, and so
on), if you do not supply other coordinates.
Parameters:
path
xcor,ycor
Examples:
The route to the screen where you want to set
the draw pointer.
The screen coordinates for the draw pointer
location. The X-coordinates are in the range
0-639. The Y-coordinates are in the range 0191.
RUN GFX2("SETDPTR",100,5)
Sample Program:
This procedure uses coordinates from a DATA statement for setting the draw pointer to create a series of star shapes.
PROCEDURE star
pDIM X,Y,T,J:INTEGER
OPRINT CHR$(12)
OFOR J=1 TO 1 0
DREAD X,Y
ORUN GFX2("SETDPTR",X+J,Y+J+J)
OFOR T=1 TO S
DREAD X , Y
ORUN GFX2("LINE",X+J,Y+J+J)
ONEXT T
ONEXT J
ODATA 320,46,440,146,200,84,440,84,200,146,320,46
REND
9-125
BASIC09 Reference
UNDLNONUnderline characters on
UNDLNOFF
Underline characters off
Syntax:
RUN GFX2([path,]"UNDLNON")
RUN GFX2([path,]"UNDLNOFF")
Function:
Enables or disables character underline. After you
execute UNDLNON, all characters displayed are underlined
until you execute UNDLNOFF. The default is UNDLNOFF.
Parameters:
path The route to the window where you want to
use underline characters.
Examples:
RUN GFX2("UNDLNON"-)
RUN GFX2("UNDLNOFF")
9-126