home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 248
/
248.d81
/
t.dotbasic
< prev
next >
Wrap
Text File
|
2022-08-26
|
9KB
|
383 lines
u
DotBASIC Plus
The Tutorial
by Dave Moorman
DotBASIC Plus (DB+) is a new and
exciting way to put pizzazz in your
programs. This tutorial series will
walk through a number of program
ideas, explaining the various
DBCommands along the way.
You do not need to be a programmer
-- however some familiarity with BASIC
2.0 (the built-in language on the
C-64) will help. We will start from
scratch. Yep -- "Hello, World" will be
our first project. From there, we will
explore doing custom screens, event
regions, mouse controls, and a host of
other features.
With DB+, you do not have to know
any Machine Language. You don't even
need to know much about bloading and
using ML modules. Most everything you
will need is built into the language.
You will need a copy of the
DotBASIC Plus disk and at least one
disk drive. The system works best if
you have two or more drives. The DB+
disk should be put in your secondary
drive, and your formatted Work Disk in
the primary drive. I use drive 8 for
my Work, drive 9 for my Utilties, and
drive 10 for the DB+ disk. Your
situation may vary. I also work in
VICE, the Versatile Commodore
Emulator, on a Pentium 400 Windows 98
machine. Even on the shiny new
equipment, I am woefully behind the
cutting edge!
You will want to copy DB+ to a new
disk. Single 1541 users will need to
delete the text files (t.*) to have
room for your work. Just be sure to
copy your program to another disk when
the project is completed.
SEMI-OBLIGATORY
HELLO WORLD PROGRAM
So you are ready to go? Format
your work disk, make sure all disks
are in the proper drives. We will use
the "variables" db for your DB+ disk
drive and dw for the Work disk drive.
Ready? Here we go!
LOAD"B.DOTBASIC",db
and
RUN
You will see a menu of all working
drives labeled "Dot Disk." Choose the
drive your DB+ disk is in. The next
menu is "Work Dsk." Choose the drive
your Work disk is in. You will be
asked to confirm both choices. If you
need to change, press <N>, then press
<Y> to try again.
You are now prompted to input the
program name. We will call this
program "hello". Type in:
hello
and press <RETURN>.
After some very quick flashes,
the screen gets a blue background,
blue border, and white text
characters. If you look at the
directory,
LOAD"$",dw
and
LIST
you will see
B.HELLO
MOUSE2.1 7K 1000
HELLO.DML
HELLO.DBS
B.HELLO is the boot program, the
one you will load and run to start
your program. MOUSE2.1 7K 1000
provides many of the commands you
will use. HELLO.DML is the ML program
that interprets commands from DB+ and
makes them work.
And HELLO.DBS is your DB+
program. This is the place where you
will be working.
If you loaded the directory and
listed it, now LOAD"HELLO.DBS",dw .
Either way, RUN it. Now LIST the
program:
5 d=peek(186): dd=56*256: mm=16*256
10 rem begin list
20 rem.endlist
30 sysdd
40 .tx,1: print"<clr>";:
.bg,6:.br,14
59998 .of
59999 end
60000 gosub60008: n$=n$+".dbs"
60001 d=peek(186): sys14339
60002 open1,d,15,"s0:"+n$: close1
60003 saven$,d:end
60008 n$="hello"
60009 return
Line 5 sets up important variables.
Lines 10 through 20 are used to add
commands to your DB+ program. Line 30
starts DB+.
Line 40 uses three DB+ commands.
.TX,color
sets the Text color. Add 128 to
the color value to reverse the
text.
.BG sets the Background color.
.BR sets the Border color.
On line 59998 we have another
DotCommand:
.OF
which turns off DB+ and returns your
computer to it's normal default
state. The SYS14339 in line 60001
does the same thing.
You will note that lines 60000 on
contain our LOADSTAR "scratch and
save" routine. With DB+, all you ever
need to do to save your program is
GOTO60000
And press <RETURN>.
Impressed? Confused? Don't worry.
We will now write "Hello"!
100 PRINT"Hello, World"
102 .DO
104 .MA
106 .UN L2% or PEEK(198)
108 PRINT"<clr>";
110 POKE 198,0
(You will notice that throughout this
tutorial, I will use upper case
characters for commands, and lower/
upper case for text in strings.
"<clr>" is <Shift-Home>.)
Actually, the printing of "Hello
World" is just plain BASIC 2.0. The
DB+ improvement comes with lines 102
- 106.
.DO begins a Do-Loop. If you have
worked with any language other than
BASIC 2.0, you know what a Do-Loop is
all about. We will explain in a
moment.
.MA is "Mouse Ask," which puts all
the current conditions of the mouse in
various variables. One of those
variables is L2%, which is 0 until the
left mouse button is clicked. (This
goes for the joystick fire button as
well.)
.UN is short for UNtil, and the
program will loop back to the .DO
until either l2% or PEEK(198) are not
0. So when you click the left mouse
button, fire button, or press any key,
the program falls through the UNtil.
Otherwise, this code just waits for
something to happen.
The Do-Loop is perfect for many
mouse-driven activities and we will
use it a lot. We can put everything on
just one line:
102 .do:.ma:.un l2% or
peek(198):poke198,0
So GOTO60000 then RUN your
program! Always GOTO60000 before
RUNning your program! That way, if DB+
is still active in the background, it
will be stopped.
You can do all sorts of things
with this. For example, a FOR-NEXT
loop will add some color and fun:
100 for x=0to15:.tx,x:print"Hello,
World":next
Change line 102 to
102 .do:.ma
then add:
103 .bg,cx%and15
104 .br,cy%and15
Now your mouse/joystick will
control the color of the background
and border. CX% gives the text cell
x-coordinate (after .MA happens), and
CY% is the y-coordinate. You will find
this feature extremely valuable!
Check out the DB+ Docs for all the
values returned by .MA. Think of the
POWER!
------------------
INFINITE COMMANDS
I have lost track of how many
commands are available in DB+; the
list just keeps growing. However,
except for the ones you used above,
you will have to "include" the
commands in the program.
With your disks still in the
drives, reset your computer, then load
and run B.DOTBASIC. Choose the drives
you are using (as before). This time,
for the program name, input:
hello2
Now for the fun. To include
commands, add this line to your
program:
11 rem.text,.box,.keymw
Save the program (good old GOTO
60000), then load and run B.DEV from
your DB+ disk. If DEV stops, it means
you included a non-existant command,
forgot the REM, or put a space before
the dots.
Let's look at the three commands.
.TEXT,X,Y,W,STRING
This command prints the string at
X,Y -- and word wraps it to fit in W
width. It doesn't get much easier than
that!
.BOX,X,Y,W,H,SC,CO
This draws a box on the screen
with the upper left corner at X,Y, a
width of W, and a Height of H. SC
stands for Screen Code -- usually 32
for a blank screen or 160 for reversed
spaces. CO is COlor, of course. If you
use 255 for SC, the area is painted
with CO. Add 16 to CO to draw a frame
around the box.
.KEYMW
Key/Mouse Wait replaces the
Do-Loop we mentioned above. The
program stops and waits for either a
mouse click or a key press. The mouse
variables hold the mouse's current
information. I% will contain the ASCII
number of the key pressed (0 if none).
We are going to draw a box on the
screen and fill it with text. First
the box:
100 .box,5,5,30,07,32,1+16
This box has its upper left corner
at column 5, row 5, is 30 columns wide
and 7 rows high (or deep). The screen
code is 32 -- a space, with a color of
1 -- white. The +16 puts a frame
around the box.
Now we need some text to put in
the box.
110 t$="This is a wonderful test of
this remarkable system. "
111 t$=t$+"Nothing can possibly go
wrong with this test."
T$ now holds this long text. Lets
set the text color to yellow, and the
border and background to black.
112 .tx,7:.br,0:.bg,0
We are now ready to print the text
with .TEXT. Note that the X,Y
locations are one more than the box's
X,Y, and the width is two less than
that of the box.
120 .text,6,6,28,t$
And watch how tidy this is:
130 .k