home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 211
/
211.d81
/
t.basics
< prev
next >
Wrap
Text File
|
2022-08-26
|
3KB
|
124 lines
u
D R A W I N G B O X E S
by Jeffrey L. Jones
Fast routines aren't exclusively
ML. The Box Demo that comes with this
article shows how you can use BASIC to
draw boxes of any color or size, at
any location on the screen.
But drawing boxes in BASIC is
slow, right? Not if you do it in a
fast way! How does two tenths of a
second grab you? Printing strings in
BASIC is fast -- I mean FAST on a
C-64. The text screen is updated so
fast that most text seems to "appear"
before your eyes. POOF!
My box routine uses two string
variables to make a box. When the
routine is initialized, BA$ becomes a
bar 38 columns across. BD$ is a little
more complicated. It contains the
vertical bar for the box. Since the
cursor will advance right after any
character is printed, the variable
includes a cursor left and a cursor
down after each bar printed.
So how do I make boxes of any and
all sizes using only two strings?
Using the LEFT$ function! I only print
the portion of the box strings that I
need.
LEFT$(string$,integer)
LEFT$ will print only the leftmost
part of a string that you specify. For
instance, if A$="LOADSTAR" and you use
the command:
PRINT LEFT$(A$,4)
you will see
LOAD
Only "LOAD" will be printed because
the LEFT$ function has been told to
pass only the first four characters in
the string.
If the integer specified is of
greater length than the string itself,
the entire string will be printed. If
the integer is zero then a null string
will be returned.
Something else should be
explained:
POKE211,bx:POKE214,by:SYS58732
is a routine I use to move the cursor
to the exact location I need before
printing.
POKE 646,bc
Location 646 is used to either check
or change cursor color.
Here's how to use the routine:
GOSUB 40000 to initialize the routine.
This needs to be done only ONCE to
define the variables. Do this early in
your program while you're declaring
other variables.
To print a box, GOSUB 40040.
But first you must declare the
dimensions and locations of the box.
Here are the variables you will be
using:
BX - leftmost X coordinate
BY - uppermost Y coordinate
EX - rightmost X coordinate
BD - how many rows to enclose in box
(number of rows deep)
RV - if non-zero the box is reversed
BC - color of the box
Naturally no x coordinate can be wider
than the screen. Very large boxes may
cause scrolling.
If you want to print a box inside
a box, there's no need to redefine the
variables. Just GOSUB 40120 to make
the box shrink. To make it grow out,
GOSUB 40100. Since RV is cleared every
time a box is printed, RV must be
updated if being used.
By printing a box in different
colors, you can make it appear to glow
or flash on and off. Run this program
to see a demo of my box-making
technique.
I might mention that the box
routine is significantly sped up if
compiled.
JLJ