Becker Basic Manual PDF
Becker Basic Manual PDF
Becker Basic Manual PDF
Abacus
A Data Becker Product
For programming applications under GEOS
Abacus!
Copyright Notice
Abacus Software makes this package available for use on a single computer
only. It is unlawful to copy any portion of this software package onto any
medium for any purpose other than backup. It is unlawful to give away or
resell copies of this package. Any unauthorized distribution of this product
deprives the authors of their deserved royalties. For use on multiple
computers, please contact Abacus Software to make such arrangements.
Warranty
Abacus, Inc.
5370 52nd Street
Grand Rapids, MI 49508
ISBN 1-55755-033-6
Table of Contents
Foreword -*v
1. Introduction 1
1.1 BeckerBASIC structure 1
1.1.1 Starting BeckerBasic 3
1.1.2 The Input-System and Testing-System 5
1.1.3 The Run-Only-System 8
1.1.4 TheCONVERTER .9
1.2 Changing command names 12
1.2.1 Setting up the command table 12
1.2.2 Handling command names and numbers 13
1.2.3 Renaming commands 15
1.2.4 Saving and loading command tables 17
1.3 BASIC 2.0 commands 19
1.4 Adding commands & functions 19
1.5 Miscellaneous 20
2. Program development. . 25
2.1 Utilities -25
2.1.1 Programming commands 25
2.1.2 Function keys .27
2.2 Error handling 29
2.2.3 The TRACE commands 33
7. GEOS 129
7.1 Drop-down menus 132
7.1.1 Using the Drop-down Menu Construction Set 134
7.2 Dialogue boxes 135
7.2.1 Using the Dialogue Box Construction Set 136
7.3 Entering and displaying hi-res text 138
li
Abacus Table of Contents
Index 229
in
Foreword BeckerBASIC 64
Foreword
BeckerBASIC is one of the most complicated products ever released for the
C64. The testing process at Data Becker and Abacus was an exhaustive one.
However, it's almost impossible to test any product on every piece of hardware
or software (e.g., disk drive enhancements, operating system extensions,
countless application programs, etc.) available for the C64. This means that
neither the author nor the publishers can be held responsible for support of
programming or application problems (aside from errors within BeckerBASIC
itself, of course).
To give you the complete picture of the program, BeckerBASIC comes with this
thorough, easy to follow manual. I hope that this manual will serve you well.
Martin Hecht
Stuttgart, West Germany
September 20,1987
IV
Abacus 1. Introduction
1. Introduction
You should learn the many commands and functions before you can program
efficiently in BeckerBASIC. That is where this manual comes in. It's not
absolutely necessary that you read the entire book to learn BeckerBASIC.
If you look at the first directory page of your BeckerBASIC distribution diskette
from the GEOS deskTop, you'll see three files named System 1, System 2 and
System 3. These three programs are the three BeckerBASIC interpreters in
VLIR format.
The three interpreters can be accessed directly from the deskTop by double-
clicking the desired icon. You can toggle between the Input- and the Testing-
Systems while a BeckerBASIC program resides in memory without losing the
program.
All three systems can be accessed at any time from the GEOS deskTop. They
are loaded in from the diskette, then GEOS keeps them in memory.
1. Introduction BeckerBASIC 64
Total loading time is between 10 and 15 seconds. Toggling between the Input-
and Testing-Systems takes nine seconds to load and initialize.
All three systems give you 15,800 bytes of free memory. If you stop to think
that GEOS and BeckerBASIC are in memory at the same time, this is a good
amount of memory. There are ways around memory limitations: BeckerBASIC
has overlay capabilities (loading multiple programs from diskette), and if you
avoid high-res graphics, the unused bitmap starting at location 40960 gives you
about 8K of additional memory.
The Input-System: The Input-System works much like the BASIC 2.0
editor—you type in and edit programs in this interpreter. Not all of
BeckerBASIC s commands can be used here. Most of the available commands
are programmer's tools.
The Testing-System: This interpreter lets you test run BeckerBASIC programs.
The Testing-System uses all BeckerBASIC commands, as well as the editing
and programmer's utility commands.
After starting the system, a normal text screen appears with a menu for
controlling the entire operation. This menu is controlled by function keys.
When an error occurs within the program, BeckerBASIC displays the prompt,
"Error in Program! Load Input Interpreter (y/n)?" When you press the <y> key,
BeckerBASIC loads the Input-System and displays the incorrect line number. If
ERRSHOWON is in effect, BeckerBASIC also displays the error in reverse
video. If you press the <n> key, the main menu of the Testing-System reappears.
Pressing <F3> asks for the name of a program you want loaded from diskette
and run. Pressing <F7> or <CTRL><Commodore> returns you to the Input-
System.
Abacus 1. Introduction
BeckerBASIC programs remain in memory when you switch from the Input-
System to the Testing-System and back. <F8> exits BeckerBASIC and returns
you to the deskTop.
When an error occurs, the message "Error in Program! Contact this program's
author" appears on the screen, and BeckerBASIC displays a menu similar to that
displayed from the Testing-System, except you cannot access the Input or
Testing-Systems from the Run-Only system.
The drop-down menus and dialogue boxes require the second hi-res bitmap
starting at memory location 24576. This reduces the amount of available BASIC
memory by eight kilobytes.
You start BeckerBASIC as you would start any GEOS application. Before you
start BeckerBASIC, however, make one or more working copies of the
BeckerBASIC distribution diskette. Use the BACKUP or DISKCOPY program
from the GEOS system diskette to make backup BeckerBASIC diskettes. The
procedure is exactly the same as making a backup of other GEOS applications
(see your GEOS manual for information). When you've finished making backup
copies, put the original diskette in a safe place.
Copy the GEOS deskTop to your backup diskettes. You could also copy over
desk accessories such as the Notepad, but these accessories are inaccessible
from BeckerBASIC.
1. Introduction BeckerBASIC 64
You can now begin your tour through BeckerBASIC. All program sections
mentioned in this chapter are described in detail later on in the book. If you
don't understand what you read here, the later descriptions should clear things
up.
You'll find all BeckerBASIC system files on the first page of the directory on
the GEOS deskTop. Open the BeckerBASIC work diskette by selecting the
open item from the disk menu. The upper row shows icons named System 1,
System 2 and System 3. These are BeckerBASIC's three interpreters. The first
icon is the Input-System, the second icon represents the Testing-System and the
third is the Run-Only system. All these interpreters start when you double-click
the icons.
Look for the BASIC icon named DEMO. This demonstration program is a
BeckerBASIC program, handled as a GEOS application. DEMO displays just a
few of BeckerBASIC's abilities. Start it by double-clicking the icon from the
deskTop.
Most of the BeckerBASIC programs on the system diskette have a BASIC icon.
This icon is generated by the CONVERTER. If you want, you can make your
own icon using the CONVERTER.
The last three programs on the first page of the directory are discussed later in
this book. Chapter 9 describes SPRITE-EDIT, while Chapter 7 tells about
DDM.C.S (the Drop-Down Menu Construction Set) and D.C.S (the Dialogue
Box Construction Set). The second directory page lists different BeckerBASIC
utilities and sample programs.
BeckerBASIC gives you almost 16,000 bytes of free BASIC memory. This is
more than most non-GEOS BASIC extensions offer. When you consider that
you get both GEOS and BeckerBASIC in memory, 16000 bytes is plenty of
memory.
The Input-System is the first interpreter that needs close examination. Double
click the System 1 icon on the GEOS deskTop. The Input-System loads into the
computer.
At the end of the loading procedure, some graphic garbage prints on part of the
deskTop, the screen turns black, and the starting screen of the Input-System
appears.
In most cases, you must enter the Testing-System to test programs, especially
for GEOS hi-res and sound commands. You can test some programs from the
Input-System mode. Start the program by typing RUN and pressing the
<RETURN> key. To load and start a program with one command, type
DRLOADB'^ame" (see Section 5.3).
NOTE: You cannot run programs using GEOS hi-res commands from within the
Input-System.
1. Introduction BeckerBASIC 64
You can start the Input-System directly from Commodore BASIC 2.0 by typing
LOAD"DBL",8,1 and pressing the <RETURN> key. This gives you about
24,000 bytes of BASIC memory for development, as well as 20,000 bytes of
memory unoccupied by GEOS.
The Input-System works the same whether you run it with or without GEOS,
with one exception: If you run the Input-System from BASIC 2.0, you can't
access the Testing-System or the deskTop.
If you use commands the interpreter doesn't understand, the computer stops and
displays the ILLEGAL COMMAND ERROR message. When this happens, you
must switch to the Testing-System to test the program.
You can access the Testing-System from the Input-System in two ways. First,
you can save the program to diskette and type in DESKTOP <RETURN> to
return to the GEOS deskTop. When the deskTop finishes loading, double-click
the System 2 icon to load the Testing-System. The other method is to press the
key combination <CTRLxCommodore>. Pressing these two keys loads the
Testing-System in about nine seconds, while retaining the BeckerBASIC
program you were working on in memory.
NOTE: Make sure that a BeckerBASIC work diskette containing both the Input-
and Testing-System is in the drive when you make this switch, and not just a
diskette on which you store your programs. Otherwise, the computer may crash,
and destroy the program in memory.
Along with the current BASIC program, you also have the complete set of
debugging tools (e.g., TRACE, ERRSHOWON and ONERRORGO—see
Section 2.2), as well as all your variables.
A menu screen appears after the loading procedure which lists four options. The
Testing-System has no options for editing BASIC programs.
Abacus 1. Introduction
To start your BASIC program, press the <F1> key to "Start program." Press the
<F3> key to load a program from diskette and run it. You can end program
name input by pressing the <RETURN> key. Pressing <SHIFT><RETURN>
returns you to the menu screen.
The use of drop-down menus, dialogue boxes and hi-res graphics have been
avoided in the operation of these interpreters for a number of reasons. First, they
take up too much memory, and second, function keys are faster. However, if you
really want to make your programming user-friendly, you can add GEOS
commands to your own programs (see Chapters 7 and 8).
If BeckerBASIC programs have errors, the screen displays the message "Error
in program!" and asks, "Load Input-System? (Y/N)". If you press the <n> key
(no), the system returns to the menu screen of the Testing-System. If you press
the <y> key (yes), the computer returns to the Input-System and displays the
error messages.
If you have the extended error display on using the ERRSHOWON command
(see Section 2.2), the incorrect line is listed, and the error appears in reverse
video.
NOTE: As long as ONERRORGO is active (see Section 2.2), the error handling
follows this route only in the Testing-System.
When you toggle back to the Input-System, you have all variables available. For
example, you can now check the values of individual variables or print out
current variable contents with the PDUMP command (see Section 2.1).
You could do a lot of switching back and forth between the Input- and the
Testing-Systems when in the development phases of a program. This takes time,
but it's something like working with a compiled language. For example, when
you work with a Pascal compiler, you have to enter the text in an editor, load the
compiler and try compiling the program. If the compilation fails, you have to
return to editing mode, fix the program and start over. Since BeckerBASIC's
load times are so brief, this waiting time isn't a problem.
The BeckerBASIC system will help you to learn structured programming: After
about the 15th or 20th error message, you'll learn to be much more careful in
your program development.
1. Introduction BeckerBASIC 64
The last two menu options are self-explanatory. <F7> performs the same
function as <CTRL><Commodore>, returning you to the Input-System.
You have a total of three methods of returning to the Input-System. You can
press the <F7> key or the <CTRLxCommodore> key combination. The latter
is useful for going to the Input-System, fixing the program, and returning to the
Testing-System to retry the program. The third method returns you to the
deskTop. Pressing the <F8> key has the same effect as typing DESKTOP in the
Input-System (see Section 1.5). There are a few exceptions to available
commands in the Testing-System. The Appendices list all BeckerBASIC
commands. Those commands unavailable to the Testing-System and the Run-
Only-System are marked with a number sign, and result in an ILLEGAL
COMMAND ERROR.
The entire program development and testing phases are performed in the Input
and Testing-Systems. The Run-Only-System is of interest when you want to
distribute your own BeckerBASIC programs as GEOS applications. The
CONVERTER routine adds icons and info data to BeckerBASIC programs.
Converted programs access the Run-Only-System when you double-click the
icons from the deskTop.
The Run-Only-System contains almost all the same coding as the Testing-
System. The big difference between the two is in error handling. The only error
you get in the Run-Only-System is the message, "Error in program! Contact this
program's author!11 The error then sends you to the menu screen.
The <F1> key starts a BASIC program already in memory. <F3> automatically
loads and runs the program name you request. <F8> returns you to the deskTop.
You cannot call the Input-System from the Run-Only-System. However, you
can set up an error trap with ONERRORGO (see Chapter 2) for eventually
catching errors. You can put a message in listing your address ("Error in
program: Please write me at the following address—...").
The Run-Only-System should only be copied from the system diskette. Use the
GEOS deskTop to do this. If you can't remember how to copy files, check your
GEOS manual or GEOS Inside and Out from Abacus for instructions.
NOTE: When you wish to edit a program already converted with the
CONVERTER, you must run it through the CONVERTER program after
editing in the Input-System. Also, CONVERTER should be used to convert a
completely tested and debugged program only.
First, the routine asks for the name of the file to be converted and its filetype.
The CONVERTER can handle both programs and data files (never try to start
data files direct from the deskTop). Be sure that the diskette containing the
program you want converted is in the drive.
If the program has not been converted, the CONVERTER mentions this. The
CONVERTER then asks whether you want this file converted to a
BeckerBASIC program or a data file.
1. Introduction BeckerBASIC 64
The CONVERTER then asks for the data you want placed in the Info screen.
You can select the default values by pressing <RETURN> for each entry (if the
program was converted before), or enter new values. NOTE: The year input
must be two digits (e.g., "88").
The CONVERTER asks "Use standard icon (y/n)?" If you respond with
<y><RETURN> (yes), the program assigns the standard BASIC icon to the
program, identifying the code as a BeckerBASIC program. Data files have
BASIC DATA icons.
Before saving the data to diskette, a confirmation prompt appears: "Save data
(y/n)?fl If you respond with <n><RETURN> (no), the data clears and the
CONVERTER restarts. If you wish to convert several programs, answer the next
prompt ("Another program?") <y><RETURN> to restart the CONVERTER.
NOTE: You cannot use commas or semicolons when entering your info text.
However, the info text can be edited later from the Info screen on the deskTop.
Converted BeckerBASIC programs run when you double-click their icons from
the deskTop. The Run-Only-System must be on the same diskette as the
converted BeckerBASIC program.
NOTE: You can replace the END statement at the close of a program with the
DESKTOP command. The program then automatically returns to the GEOS
deskTop, making it look as if it's a real GEOS application. (BeckerBASIC
programs only look like GEOS applications; they don't really run the same as
GEOS applications).
10
Abacus 1. Introduction
The deskTop can be on the same diskette, but it doesn't have to be on the same
diskette. If the deskTop is unavailable, GEOS displays a dialogue box asking for
a diskette containing the deskTop.
One important note when renaming files: GEOS uses a different character
coding from BASIC. The uppercase lettering and the numbers 0 to 9 are
identical to BASIC character codes. However, the lowercase lettering is
different When you rename a BeckerBASIC program from the deskTop, use
uppercase letters only, or else you may not be able to load the file from the
Input-System. The best examples are the BASIC programs stored on the system
diskette. When you display the GEOS deskTop directory, you'll see that all
program names appear in uppercase lettering. However, if you read the directory
(see DIR, Chapter 5), the BeckerBASIC names appear in lowercase lettering.
11
1. Introduction BeckerBASIC 64
The option of renaming commands may seem unusual to you, but it's more than
just a plaything. It allows you to program efficiently.
With over 250 commands, it's hard to find command names that suit every user.
You can change the command names available to you from the Input-System.
Take the TRANSFER command, for example (Section 4.1). Since this is a
frequently used command, maybe the command name would work better for
you as the abbreviation TR. Or you could change the name to MEMSHIFT, or
even MOVE.
You can rename commands to whatever you want. The format (parameter
layout) and function stay as they are.
The entry and output of BASIC lines when editing takes a bit longer than
BASIC 2.0. The large command set in BeckerBASIC causes this drop in speed.
BeckerBASIC uses two command tables. The first table contains the original
command names; the second contains the user-defined new names.
OLDCOMTAB lets you switch to the original command name table, which is in
effect when BeckerBASIC initializes. During program input, OLDCOMTAB
compares all command names with those stored in the original table, and
interprets the commands.
12
Abacus 1. Introduction
As mentioned above, you can toggle back and forth between the two command
tables, either in direct mode or program mode.
Format CT = COMTAB
The original table returns a value of 0 to CT; a new command table gives CT a
value of 1.
Format PHELP NO
13
1. Introduction BeckerBASIC 64
NOTE: When you select the original command table with OLDCOMTAB, the
displayed command names come from this table. However, when the
NEWCOMTAB command is used, the names come from the new table.
A contains the number of the command word listed in BF$. Any string
can go into BF$.
COMNUM does essentially the same thing as PHELP: If the original command
table is active, COMNUM compares BF$ with the stored name, then checks the
new table. If BF$ doesn't match the old or new table, then A is assigned the
value 0. A numerical expression for BF$ results in a TYPE MISMATCH
ERROR.
Examples:
14
Abacus 1. Introduction
COMNAME (251) (Q
BeckerBASIC assigns the command name for BN to the variable NM$. Like
COMNUM, COMNAME accesses either table through OLDCOMTAB or
NEWCOMTAB.
Examples:
RENCOM replaces the command name listed in ON$ (OldName) with the new
name contained in NN$. ON$ is immediately compared with the newly defined
command name, which goes to the second command table.
15
1. Introduction BeckerBASIC 64
There are some rules you must remember when assigning new command names:
The new name must have a minimum of two characters, and a maximum of 15
characters. Going beyond these results in a COMMAND NAME ERROR.
BeckerBASIC provides 3000 bytes for newly defined command names, which
assumes an average name length of 10 characters. When the command table
goes past this 3000 byte limit, the result is a COMMAND NAME ERROR.
You cannot use quotation marks ("), apostrophes ('), or Commodore ASCII
codes higher than 127 in your names (see your C64 manual or Programmer's
Reference Guide for ASCII code information). These characters result in a
COMMAND NAME ERROR.
Using a question mark (?), colon (:), semicolon (;), comma (,) space () or a
number from 0 to 9 at the beginning of a command name also results in a
COMMAND NAME ERROR.
A new command name should not contain part of another command name. For
example, say you had two commands named GOTHERE and GOTHERETOO.
When the interpreter encounters GOTHERETOO, it will treat the command as
GOTHERE. That is, it executes GOTHERE, and interprets TOO as a parameter
or another command. This interpretation only occurs if both the GOTHERE and
GOTHERETOO commands are in the command table.
If the comparison ends without finding a match, an error occurs. At best, the
interpreter could treat the extension of a command name as a parameter, as in
the GOTHERETOO example described above.
As already mentioned, RENCOM checks the old command name against the
new command table. Here's a little trick which allows you to use the original
command name:
16
Abacus 1. Introduction
Examples:
This short routine displays each command name and asks for a new command
name. If you don't want the name changed, press the <RETURN> key.
17
1. Introduction BeckerBASIC 64
NA$ is the name under which the table is or was stored to diskette. This
string can be a maximum of 16 characters in length (a longer name
causes a STRING TOO LONG ERROR).
Example:
Another problem exists when you toggle from the Testing- to the Input-System:
Calling the Input-System loads the command name tables and the program code
from diskette.
If you're working with new names, then the corresponding name table must be
reloaded, so that the system recognizes the command names. BeckerBASIC uses
the TABNAME command to convey the name of the table stored on diskette.
NM$ is the name under which the table is stored on diskette. The name can
have a maximum length of 16 characters.
You can also use this command for loading a name table for a program restart.
Just put the necessary commands into a short program and save this under the
name TABINT on your work diskette:
When you start up the Input-System, type the following in direct mode:
DRLOADB"TABINT"
The program loads and automatically starts, and initializes the command table
NAME (see Section 5.3 for more information).
18
Abacus 1. Introduction
BASIC 2.0 programs run under BeckerBASIC after you convert them to
BeckerBASIC. List the program lines on the screen under BeckerBASIC and
press the <RETURN> key on each line so the line is accepted. This way, you
can set up the new BeckerBASIC coding in BASIC memory.
DB (173) (c)
DF (244) (f)
One note about new commands and functions: The command subroutine should
end with RTS, as you would with any machine language program.
The value of the function should be placed into the floating point accumulator 1.
Corresponding routines are available in the C64 operating system. For example,
a 1-byte value normally found in the Y-register can be placed in the floating
point accumulator by JSR $B3A2, or accessed in a routine with JMP $B3A2.
19
1. Introduction BeckerBASIC 64
1.5 Miscellaneous
The BeckerBASIC LIST command is basically the same as the BASIC 2.0
LIST. The big difference between the original LIST command and the
BeckerBASIC LIST is that the BeckerBASIC LIST can run within a program,
without stopping program execution.
LIST -100 lists from the start of the program up to and including line 100.
NOTE: If you rename the LIST command (e.g., to PROGLIST), and you've
switched to the new command table, don't use the LIST command!! You'll get a
system crash.
Use the new name as soon as you start working with the new command table.
The old table always has LIST on it for your use.
PRLIST has the same purpose as LIST, except that PRLIST sends the output to
a printer.
20
Abacus 1. Introduction
Examples:
This command inserts a pause in a program, to keep messages on the screen for
a period of time.
Format PAUSE SC
The variable SC equals the number of seconds you want the program to wait
SC=1 delays for about one second. Values for SC range from 0 to 255.
The SWAP command swaps variable contents, and lets you avoid creating a
third variable.
The contents of variables VI and V2 are exchanged with each other, as are the
contents of variables Vl$ and V2$. Note that both variables should be of the
same type (floating-point/ floating-point, integer/ integer or string/ string).
SWAPping different variable types results in a TYPE MISMATCH ERROR.
Examples:
21
1. Introduction BeckerBASIC 64
NEW works the same as the BASIC 2.0 command of the same name: It clears
BASIC memory of all program code and variables. BeckerBASICs NEW clears
stack memory, as well as initializing the stack pointer for the REPEAT,
WHILE, LOOP and PROCEDURE commands (see Chapter 6 for more
information).
RESET performs a partial reset of your computer. That is, it and BeckerBASIC
return to start-up status. The video chip, as well as all pointers, (variable pointer,
stack pointer, etc.) are reset Also, all error traps such as ONKEYGO,
ONERRORGO, STOPOFF, etc. are cleared.
A BASIC program deleted with this command can be restored with POLD (see
Section 2.1.1). If GEOS is in memory, it is unaffected.
Format: RESET
DESKTOP returns you to the GEOS deskTop from BeckerBASIC, provided the
deskTop is on the diskette currently in the drive. BeckerBASIC and any
program in memory are erased before die deskTop reloads.
Format DESKTOP
22
Abacus 2. Program development
2. Program development
2.1 Utilities
Here are the commands you'll use most frequently in program development:
FL is the first line number you want given. Values for FL can range from 0
to 63999.
LI is the increment between line numbers. Values for LI can range from 1
to 255.
Here's how it works: After you type in a command and press the <RETURN>
key, the next line number appears on the next line, followed by the cursor. Now
you enter your program text Press the <RETURN> key again to get a new line
number and new program line. This next line will be LI higher than the earlier
line number (e.g., if LI=10, then the line following 200 would be 210, etc.).
Pressing <SHIFT><RETURN> disables auto line numbering.
Example:
PAUTO 100,5 makes the first program line 100, followed by 105,110, etc.
23
2. Program development BeckerBASIC 64
This command renumbers program lines. All branch commands like GOTO and
GOSUB are unchanged, however. The reason is that BeckerBASIC allows you
to jump to labels and calculated line numbers. Changing line numbers is
unnecessary with labels, and calculated line numbers are self-adjusting
(e.g.,GOTO A*2+10).
Why have a RENUMBER command? When you run short of program lines
(e.g., when you want to insert a line between lines 10 and 11), PRENUMBER
can make room between line numbers.
NL is the first new line number of the program or program range being
renumbered. Values for NL can range from 0 to 63999.
LI is the increment between lines (see PAUTO) once they are renumbered.
Values for LI can range from 1 and 255.
If you don't want to renumber the entire program, you can add the additional
parameters to limit the procedure to a selected range of lines.
SL,EL SL is the first line and EL is the last line of the range to be renumbered.
The parameters can be stated in the same way as the LIST command:
SL, SL- or -EL.
Examples:
PRENUMBER 1000,10 numbers the entire program in steps of 10. The first
new line is 1000.
PRENUMBER 100,5,-200 numbers the program from the start to line 200 in
steps of 5. The first new line=100.
24
Abacus 2. Program development
MN$ is the name of the merged program. PMERGE deletes all variables, so
you may want to use DOVERLAYK and DOVERLAYW (see Section
5.3.3), which do not delete variables.
NOTE: To avoid syntax errors in the program, make sure that no lines in the
program being loaded are overwritten by PMERGE. Merged program lines with
smaller line numbers than the current program will usually result in a program
stopping. PMERGE should only be used in direct mode.
PDEL deletes a single line or a series of lines from a program. Like PMERGE,
PDEL deletes all variables:
L1-L4 are the line numbers or the starting and ending line numbers of the
range(s) to be deleted. To delete several lines or a range, you can use -
to connect ranges and commas to separate each range.
NOTE: If you use this command in program mode, do not delete the program
lines preceding or containing this command.
Examples:
PDEL 10-20,30- deletes program lines from 10 to 20, then lines 30 to the end.
25
2. Program development BeckerBASIC 64
POLD restores a BASIC program just deleted with NEW, RESET or PDEL
(variable contents are unrestored).
It's important that you type in this command immediately after typing NEW,
RESET or PDEL. If you type in a new program line, you won't be able to
restore your program. This command works only in direct mode:
Format: POLD
PBCEND changes the top of memory for BASIC programming. The default
value for this top of memory is around 32575. PBCEND is commonly used in
dialogue box and drop-down menu creation (see Chapter 7). GTBCEND retums
the current top of BASIC memory.
PMEM displays the current BASIC memory layout. After you type in PMEM,
the output appears in the format:
PROGRAM: 00000
VARIABLES: 00000
ARRAYS: 00000
BYTES FREE: 00000
The current values appear instead of these zeroes. All values represent bytes.
26
Abacus 2. Program development
PDUMP list the currently defined variables, their names and current values.
Format: PDUMP
Example:
AD 123.45
F% -14562
GT V$=nTEXTn
W -3
BN$ "EXAMPLE"
You can program function keys to print frequently used commands or strings.
PDFKEY assigns a text to a function key. This text can be up to ten characters
long.
TX$ contains a text used by the function key. Strings longer than 10
characters produce a STRING TOO LONG ERROR. Commands can
be abbreviated to three or four characters, so this is not a big
disadvantage.
NOTE: To set up a function key so that it does nothing, you must include
CHR$(0). You can do this either with PDFKEY(NR) = (CHR$(0)) or PDFKEY
(NR)=C).
27
2. Program development BeckerBASIC 64
Format PKEY
PI: RUN
F2: PMEM
F3: PDUMP
F4: LIST
F5: POLD
F6: TRON
F7: TROFF
F8: COLORS
PFKEYON turns the function key setup on, and PFKEYOFF turns the setup off.
Before you use PFKEYOFF for the first time, the function key setup must
already be turned on with PFKEYON. Each function key contains CHR$(0)
when turned off (see the NOTE under the entry for PDFKEY above).
Function key assignments are active in direct mode only. Program mode can use
function keys also, without turning off the setup with PFKEYOFF.
Now when you want to run a BASIC program in memory, just press the <F1>
key.
When you have the ability to turn the function key layout on or off, is a question
of keyboard priority. Since interrupts control the keyboard reading system, the
function key layout set by PDFKEY has highest priority.
28
Abacus 2. Program development
The function key layout turned on by PFKEYON has higher priority than all
other function key settings. Other setups are assigned CHR$(0), so they cannot
execute.
This section describes the commands available in both the Input-System and the
Testing-System for testing programs and handling errors. The TRACE
command is one of these, and can help you understand the workings of a very
complex program.
The BeckerBASIC error handling system operates on three levels: The lowest
level corresponds to the standard BASIC 2.0 error display; when an error
occurs, BASIC displays a message on the screen.
The second level of error handling displays the incorrect syntax in reverse
video. You can turn on this second level of error handling with ERRSHOWON
and off with ERRSHOWOFF.
2) If the incorrect line appears in the last two lines of the screen, the
reverse video display may appear in the wrong area.
3) If you scroll the incorrect line up when listing, the reverse video
display may appear in the correct column, but a line or two too low. If
the error is at the end of a program line, it may be impossible to display
the bad area in reverse video.
29
2. Program development BeckerBASIC 64
These last two items can be bypassed if you remember the following rule: If an
incorrect line isn't in reverse video, then look at the end of the line for the
incorrect command.
The third and most user-friendly level is the ONERRORGO command. It is the
only error tool which can be used in the Run-Only-System. This lets you branch
to a program line, and assign a variaable for holding the error message, as well as
the incorrect line's number.
FN is the variable containing the error number. See Appendix B for a list
of all error messages.
FT$ is the string variable in which the error text is stored. Error texts are
similar to texts normally displayed on the screen (e.g., SYNTAX
ERROR, ILLEGAL QUANTITY ERROR, etc.).
FZ is the variable containing the line number of the incorrect line. An error
in direct mode assigns FZ a value of 0.
ONERRORGO can be placed anywhere within a program, but you can also
define it in direct mode as well. Also, any number of ONERRORGO commands
can exist in a program.
When an error occurs, BeckerBASIC displays the last command executed. Like
ERRSHOWON, ONERRORGO has an off switch - ONERROROFF (026).
30
Abacus 2. Program development
Format RESUMECUR
Format RESUMENEXT
LN is the line to which the program should jump; LN$ is the label of the
LN$ line to which the program should jump. When the third RESUME
command is used without having first run into an error, and without a
program jump (e.g., ONERRORGO), the system displays a RESUME
WITHOUT ONERRORGO ERROR. The RESUME command can
only be used for ending an error handling routine. If you compare
ONERRORGO with GOSUB, then RESUME is comparable to the
RETURN statement.
NOTE: When you encounter an error in direct mode, do not use the RESUME
command.
Error handling with ONERRORGO is complicated, but easy to work with once
you learn its essentials.
When you use only one error handling routine within a program, then the
ONERRORGO command should be at the beginning of the program. This traps
all errors within a program. First you must supply the line number to which the
error should branch, followed by the variable names for the error number, error
text and incorrect line.
31
2. Program development BeckerBASIC 64
Examples:
Errors can be easily identified by their error numbers, as you saw from ER in the
last example. The given error text (ER$ in the last example) can be used to
display user information on the screen.
In most cases, the error handling ends with a program break, since it hardly
makes sense to continue a program that has errors. Then why is there a
RESUME command? This command can be very useful in many cases. Take
RESUMECUR, for example. If a program using disk access finds that either the
disk drive is turned off or that there is no diskette in the drive, you usually get a
DEVICE NOT PRESENT ERROR. ONERROR and RESUMECUR solve these
problems:
5 'DEMO OF ONERRORGO'
10 ONERRORGO 1010,A,B$,C
100 DLOADM "PRG"
1000 'ERROR HANDLING'
1005 'DEVICE NOT PRESENT ERROR'
1010 IF NOT(A=5) THEN POPIF:GOTO 1500:ENDIF
1020 :
1030 SCPRINT;"»TURN DISK DRIVE ON«" :SCPRINT
1040 SCPRINT"»INSERT A DISK, AND«" :SCPRINT"»PRESS A KEY«M
1050 :
1060 KEYDEL:WAITKEYA:'WAIT FOR A KEYPRESS'
1070 :
1080 RESUMECUR:'GO TO INCORRECT LINE'
1090 '...'
1100 '...'
1110 '...'
1500 'OTHER ERRORS HERE'
32
Abacus 2. Program development
TRACE displays the program line number currently executing. This is useful for
testing program flow and getting a better understanding of program structure.
The program being edited can be displayed in any area of the screen. The
beginning of the next command to be executed appears in reverse video. The
<F1> and <F3> keys turn the screen display on or off during program execution.
If you exit a program in normal mode, you must first turn off all TRACE
commands. You have to start the TRACE mode from the beginning of the
program.
BeckerBASIC gets around this disadvantage by splitting the mode into three
commands.
33
2. Program development BeckerBASIC 64
TRACE (032) to
TRACE assigns the necessary parameters to trace mode. You can use as many
TRACE commands as you wish within a program. TRACE should be the last
command in that mode.
LN is the screen line number at which the program line to be traced should
appear. Values for LN range from 1 (topmost line) to 25 (bottom line).
The bottom two lines (lines 24 and 25) do the same as in
ERRSHOWON: If the current line scrolls up during output, the reverse
video could end up one or two lines too low. Therefore, try to stay
away from the last two screen lines.
VW is the value assigned to the delay loop. This loop sets the time delay
between commands. Values for VW can range from 0 to 255. The
longest possible delay occurs when VW=1; the shortest possible delay
results when VW=255. VW=0 turns on single-step mode.
As mentioned above, pressing the <CTRL> key executes the next command in
single-step mode. This also applies to direct mode (when you start a program
with RUN, you must press the <CTRL> key as well as the <RETURN> key).
The remaining functions of all the TRACE modes work in both direct mode and
program mode. NOTE: The current command display is unavailable in direct
mode.
34
Abacus 2. Program development
When reading program lines on the screen, the TRACE routines use the
available command name tables. These tables are in the hi-res graphic bitmap
memory (see Appendix C). When you use hi-res graphics in a program, these
tables are overwritten. Therefore, you should switch into hi-res graphics for
program output after you turn off TRACE (setting AF to zero), and leave the
TRACE mode off. Otherwise, you could get a system error. Besides that, to use
program line output, you should first load the Input-System into the computer,
then toggle over to the Testing-System, so that the name tables load over from
the Input-System.
TRON turns TRACE on. All commands following this (up to the last TRACE
command) run under a time delay.
Format: TRON
Format TROFF
Both the TRON and TROFF commands can be used within a program as many
times as you wish. TROFF has no effect in normal mode.
Examples:
TRACE 5,10 0,1 sets screen line 5 as the output line. A delay value of 100 is
given. This display follows immediately after the TRON command (AF=1).
ZE=1:EM=O:TRACE ZEJEM,0 makes the topmost line the display Une. EM=0
turns on single-step mode. The 0 suppresses the output
35
Abacus 3. Input and Output
The most important input device is the keyboard. BeckerBASIC has numerous
commands for making keyboard input easier and more comfortable.
KEYREPEATON switches on the keyboard repeat function. Note that the cursor
is turned on with the repeat function.
Format- KEYREPEATON
The speed at which the key repeats is adjusted by the CRFREQ command (see
Section 3.4 for more information).
KEYREPEATOFF (034)
Format KEYREPEATOFF
37
3. Input and Output BeckerBASIC 64
The keyboard of the C64 has one key that can be a nuisance, the <STOP> key.
If a user presses this key at the wrong time (e.g., during diskette access), serious
problems could result. BeckerBASIC offers the STOPOFF and STOPON
commands.
Format: STOPOFF
STOPON has the opposite effect of STOPOFF: The <STOP> key is enabled - a
running program can now be stopped by pressing the <STOP> key.
Format: STOPON
The C64 has a keyboard buffer into which up to 10 characters (keypresses) are
stored. The computer reads the keypresses from this buffer. Since the keypresses
register through an interrupt, the buffer may already be full after every keypress.
The buffer may read a previous keypress instead of the input you want it to read,
resulting in an error. The keyboard buffer can be deleted with the KEYDEL
command.
Format KEYDEL
WATTKEYA waits for any keypress. The keyboard buffer is deleted before
reading, so KEYDEL is unnecessary in this case. This command can be used in
connection with GET.
38
Abacus 3. Input and Output
Example:
WAITKEYS waits for a specific keypress, assigned with the ASCII code of the
desired key (see your C64 manual for ASCII codes).
Format WAITKEYS TE
TE is the ASCII code of the desired key. Values for TE can range from 0
to 255. WAITKEY 65 waits for the <A> key.
This command is similar to the BASIC 2.0 GET command: It reads data from
the keyboard. However, it is much more flexible than GET.
LE sets the input length. Values for LE can range from 1 to 255.
K$ limits the amount of input allowed. All keys you want included must be
in K$. For example, if you want only the numbers from 0 to 9 read as
legal input, K$ would equal "0123456789'1. The K$ parameters are
optional; if parameters are included, they must be enclosed in quotation
marks.
KGETV reads data only as a string. Input can be changed to numeric input using
the BASIC 2.0 VAL command.
39
3. Input and Output BeckerBASIC 64
Examples:
Example:
As you can see in the example, the input goes where the cursor is assigned (see
Section 3.4 for more information on cursor commands).
Cursor control is used here for controlling the reading of the string during input.
If you'dprefer to avoid this command, there are alternatives in Section 3.1.2.
40
Abacus 3. Input and Output
KGETV and KBGETV are intended for shorter input. However, there are other
commands in this chapter which can handle input on an entire screen page.
The next two commands can read the <SHIFT>, <CTRL>, <Commodore> keys
and others.
Format: WT = STTEST
WT can also test for the <SHIFT>, <Commodore> and <CTRL> keys. WT can
be assigned the following values to show one or more of these keys pressed:
Example:
WAITST waits for one or more alternate keys to be pressed, then immediately
continues on with the next command in the program.
Format: WAITST GT
41
3. Input and Output BeckerBASIC 64
Example:
When these comands are used in conjunction with the ONKEYGO command
(see below), a whole new set of programming possibilities opens. You can even
jump to a predetermined program routine while editing a program in direct
mode.
LN is the line to which the program should jump on this keypress. Values
for LN range from 0 to 63999. Numbers outside of this range result in
an ILLEGAL QUANTITY ERROR.
Examples:
ONKEYGO 65,5000 branches to line 5000 when the user presses the <A> key.
ONKEYGO ASC(" A"),5000 performs the same function. When you don't know
the ASCII code for a character, you can use the ASC function.
ONKEYGO 137,61000 branches to line 61000 when the user presses the <F2>
key.
42
Abacus 3. Input and Output
Format: RETKEY
To get a better grasp of what happens, here are descriptions of what occurs after
ONKEYGO:
Direct mode: Direct mode branches direct to the given program line and runs the
program code to the next RETKEY command. After RETKEY, the computer
returns to direct mode.
Program mode: The program executes to the end of the current line, the next
line number is stored in a buffer. The program then branches to the line number
specified in the ONKEYGO command. When RETKEY is encountered the line
number in the buffer is used to return to the main program, and executes the
next command in the main program.
There are two options for cancelling an ONKEYGO definition: Either you set a
new definition, or you invoke ONKEYOFF.
Format: ONKEYOFF
The ONKEYGO command should be turned off at the end of a program with
ONKEYOFF. The reason is that the ONKEYGO may accidentally branch to a
program line when in direct mode.
The screen is not an input device, and doesn't directly provide data input. Still,
"screen input" describes the process of displaying keyboard input on the screen,
and BeckerBASIC has numerous commands for this type of programming.
43
3. Input and Output BeckerBASIC 64
To write data easily on the screen, there are many commands. One small
example is the WINPROC procedure at the end of Chapter 6. With this program,
you can define input windows of any size and type on the text screen, store
screen contents in a buffer and restore these contents on the screen.
As long as the data only shows on the screen, it is not very useful.
BeckerBASIC has two commands to transfer screen data into computer memory
or a string variable.
VR$ is the name of the string variable to which the data is assigned.
RO are the row (RO) and column (CO) of the screen position from which
CO the data is read. After command execution, the cursor returns to the
home position of the screen. Values for RO range from 1 to 25, while
values for CO range from 1 to 40.
Examples:
SGETV EG$,10,17,5 puts 10 characters from row 17, column 5 into the variable
EG$.
44
Abacus 3. Input and Output
SA gives the starting address of the memory range into which the data is
stored. Values for SA can range from 0 to 65535.
LE gives the length of the data being read, based upon RO and CO as the
starting point. Values for LE range from 1 to 255.
RO are the row (RO) and column (CO) of the screen position from which
CO the data is read. After command execution, the cursor returns to the
home position of the screen. Values for RO range from 1 to 25, while
values for CO range from 1 to 40.
The hi-res bitmap (40960 to 48960) gives you 8000 bytes. Naturally, you can
only use this range if you aren't using hi-res graphics.
Smaller quantities of data can be stored in the cassette buffer from memory
locations 828 to 1023.
Both areas of memory have the advantage that they lie outside of BASIC
memory, and thus won't disturb that memory.
Examples:
SGETM 41000,22,3,7 reads 22 characters from row 3, column 7 and puts these
characters into memory starting at memory location 41000.
45
3. Input and Output BeckerBASIC 64
SCPRINT is much the same as the BASIC 2.0 PRINT statement. You can
position the text when you add AT to SCPRINT (see below).
A! (048) (c)
AT puts the cursor at a specified screen position. This command can be used
only in connection with the SCPRINT command.
RO RO is the row position and CO is the column position at which the text
CO appears. Values for RO range from 1 to 25, while values for CO range
from 1 to 40. The EXPRESSION follows CO, separated by a
semicolon. The expression between quotation marks appears at the
cursor position marked by RO and CO. You can omit the expression
between quotation marks just to position the cursor without text The
semicolon cannot be omitted.
You may find it easier to set cursor positioning with the CRSET command (see
Section 3.4).
46
Abacus 3. Input and Output
A disadvantage to the PRINT command in BASIC 2.0 is the fact that the
computer changes reverse video to normal video when the end of a PRINT
statement is reached.
If you wish to display longer PRINT statements in reverse video, you must end
each PRINT statement with a semicolon. This makes it much more difficult to
plan screen format. BeckerBASIC solves this problem with the RVSON and
RVSOFF commands.
RVSON turns reverse video on. All output in a SCPRINT command appears in
reverse video. RVSOFF turns the text back to normal mode.
Example:
47
3. Input and Output BeckerBASIC 64
PRPRINT sends any alphanumeric data to the printer, much like the SCPRINT
command. The rules for PRPRINT are identical to those used in SCPRINT and
the BASIC 2.0 PRINT statement
PRCOM sends individual printer codes to the printer. This is especially useful
for sending control codes such as bold, expanded print, etc.
When used within a program line, PRCOM can have as many control codes as
you like, as long as each code is separated from the next by a comma. PRCOM
is the same as the BASIC 2.0 sequence:
C1,C2 is the code normally sent in the form of a CHR$(..) code. PRCOM can
handle individual printable characters. The ASCII code must be
concluded by a <RETURN> (ASCII code 13). PRCOM ASC("A"),13
sends an A.
OPEN 14,4:PRINT#14,...:CLOSE14
Never use any other file commands with a logical file number of 14! This
number was assigned to the printer since it's an unusual logical number.
48
Abacus 3. Input and Output
This section includes commands for clearing and changing the screen, as well as
loading and saving areas of the screen.
PCOLORS states the list of colors available to the user, and their respective
color numbers.
When you have trouble remembering the correct color and number, just enter
PCOLORS and press the <RETURN> key to display the following table:
0 black 8 orange
1 white 9 brown
2 red 10 lt.red
3 turquoise 11 greyl
4 purple 12 grey 2
5 green 13 k.green
6 blue 14 ltblue
7 yellow 15 grey 3
BORDER changes the screen border color. CLBORDER reads the current
border color.
Values for BORDER can theoretically range from 0 to 255, although once you
pass 15, the color numbers just repeat (16=0,17=1, etc.).
49
3. Input and Output BeckerBASIC 64
GROUND changes the screen background color. CLGROUND reads the current
background.
FN represents the background color. Values for FN can range from 0 to 15.
Values for GROUND can theoretically range from 0 to 255, although once you
pass 15, the color numbers repeat (16=0,17=1, etc.).
CLS clears the text screen, and corresponds to the BASIC 2.0 statement PRINT
CHR$(147). The cursor moves to the home position after the screen clears. To
move the cursor to the home position without clearing the screen, use the
CRHOME command (see Section 3.4).
Format CLS
These commands turn the screen on (SCRON) and off (SCROFF) through
software. These don't literally turn the screen power on or off; they blank out
the screen.
50
Abacus 3. Input and Output
NA$ is the name under which the screen is stored. This name can have a
maximum of 16 characters.
SCRDLOAD loads direct into the current screen and overwrites the old screen.
SCRDSAVE is used to save a screen mask setup for later recall.
CRHOME moves the cursor to its home position (the upper left corner of the
screen).
Format CRHOME
CRSET sets the cursor at any location on the screen. CRPOSL (line) and
CRPOSC (column) read the current cursor position.
51
3. Input and Output BeckerBASIC 64
CRCOL changes the cursor color and the text color. CLCURSOR reads the
current cursor color.
CRON turns on the cursor at the current cursor position. This is useful when you
want the user to make an important input. CROFF turns the cursor off again.
CRREPEATON turns on the cursor repeat function, i.e., the repeated movement
of the cursor as you hold down one of the cursor keys (this function is built into
the operating system). This command acts much the same as the
KEYREPEATON command (see Section 3.1.1). CRREPEATOFF turns off
cursor and keyboard repeat
CRFREQ changes the cursor and keyboard reading frequency. That is, it
changes the speed at which the cursor movement and keyboard output occur
(faster or slower).
52
Abacus 3. Input and Output
Format CRFREQNR
NR is the rate at which the system reads the cursor and keyboard. Values
for NR range from 0 to 255. It is best to use values between 25 and
125. Smaller numbers cause faster movement, while larger values slow
the movement
Another effect can be put to good use with BASIC programs that depend on
time: The slower the cursor movement (i.e., the larger the NR value), the faster a
BASIC program executes, in cases of NR values larger than 125.
53
Abacus 4. Memory access
This chapter describes the most important memory commands. The most vital
commands are MYFILL, which fills a memory range with the user's choice of
characters; and TRANSFER, which moves any area of memory to another area
of memory (e.g., the character generator in ROM). See how the original memory
range, the destination and end range can overlap in Section 4.3, using the
VGETM, MGETV and VARADR commands.
The following four commands are intended specifically for handling memory,
from a large range of memory down to a single memory location.
Examples:
55
4. Memory access BeckerBASIC 64
TRANSFER 1025,2023,1024 moves the entire screen one character to the left.
10 AD = 1024+40*(ZE-1) + (SP-1)
20 TRANSFER AD,AD+(LE-1),ZL
This short program takes the contents or the screen at row ZE, column SP and a
length of LE, and puts it at destination range ZL.
MYFILL fills the specified memory range with a given value or character.
Examples:
56
Abacus 4. Memory access
This program displays each character on the screen, 1000 characters at a time.
When you set data into RAM from the screen (e.g., with TRANSFER), a
problem can occur: Screen memory data is in BSC format (Berkeley Softworks
Code - true ASCII), while the strings must be in Commodore ASCII format for
editing.
BSCASCW converts these strings from BSC to ASCII format. When you need
to transfer string data to a memory range on screen, you need to convert it from
ASCII to BSC format The ASCBSCW performs this conversion.
BA BA give the starting address and BE the ending address of the memory
BE range to be converted.
Examples:
BSCASCW 41000,41500 converts the RAM area from 41000 to 41500 from
BSC code to ASCII code.
ASCBSCW 47000,48000 converts the RAM area from 47000 to 48000 from
ASCII to BSC code.
In addition to the BASIC 2.0 POKE and PEEK commands, BeckerBASIC offers
the following memory access commands.
57
4. Memory access BeckerBASIC 64
WT is the value inserted into memory locations AD and AD+1. Values for
WT can range from 0 to 65535. DOKE can be assigned parameters for
machine language programs.
Examples:
DOKE 48000,35000 puts the value 35000 into memory locations 48000 and
48001. After execution, memory location 48000 contains 184 and 48001
contains 136.
DOKE 828,VR(10) puts the contents of the array element VR(10) into locations
828 and 829.
DEEK reads the contents of two consecutive memory locations and gives the
total value as a variable. The first memory location is read as the low byte, while
the second location is read as the high byte.
AD is the starting address of the two memory locations read. Values for AD
range from 0 to 65535.
Examples:
58
Abacus 4. Memory access
Examples:
W = TEEK (56325) reads RAM location 56325 (from the CIA register).
59
4. Memory access ReckerBASIC 64
The memory range from 40969 to 48960 is hi-res memory, an ideal area for
storing data of all kinds (provided you aren't using the hi-res memory for
anything else). These three commands are designed for storing different data.
Format VGETMBA,VR$
BA is the first memory location at which the string data is placed. Values
for BA range from 0 to 65535.
Examples:
VGETM 830,"TEXT" puts the string "TEXT* starting at memory location 830.
MGETV reads the conttents of a memory range into any string variable.
VR$ is the name of the string variable into which the memory contents are
loaded.
LE,BA LE is the length of the memory range, BA is the first memory location
to be placed in the string variable.
60
Abacus 4. Memory access
Examples:
MGETV T$,10,890 reads the contents of locations 890 to 899 into variable T$.
TRANSFER takes the first five characters of the screen starting at memory
location 41500, converts the result from BSC to ASCII code, and puts the result
into the variable EG$.
NOTE: When you move data directly from the screen to RAM (e.g., with
TRANSFER), you should convert the memory area from BSC code into ASCII
code using the BSCASCW command (see Section 4.2).
Aside from easy memory access, there are very few uses for VARADR. One
possibility of this function lies in the buffer storage of larger variable arrays, or
sections of variable arrays. You can compute the first and last array elements
and then move the array with TRANSFER (see Section 4.1).
Examples:
5 DIM A%(55)
10 W1=VARADR(A%(1)):W2=VARADR(A%(52)):'CONVEY ADDRESS
20 W2=W2+1:'ENDADR.+1, AN INTEGER MADE UP OF TWO BYTES'
30 TRANSFER Wl,W2,43000:'TRANSFER CONTENTS'
61
4. Memory access BeckerBASIC 64
This short program transfers the contents of the array elements A%(l)-A%(52)
to memory starting at 43000.
The following program lets you put the values in any integer array:
62
Abacus 5. Disk commands
5. Disk commands
The 1541 disk drive is an extremely versatile storage device. It performs simple
loading and saving, as well as allowing user-created data access.
The most interesting capabilities of the 1541 can only be achieved by complex
programming. And even the simplest tasks, such as deleting a file, involves a bit
of program code.
Please bear the following rules in mind when using BeckerBASIC diskette
commands:
Never use BeckerBASIC diskette commands together with BASIC 2.0 diskette
commands, since conflicts with secondary addresses could occur.
Syntax of command parameters is most important at the disk drive level. This is
vital when you're uncertain about sending commands on the disk channel (see
DSTATUS, Section 5.1).
Three diskette commands can cause trouble when used in conjunction with
GEOS disk management:
63
5. Disk commands BeckerBASIC 64
Here are the diskette commands which you'll use most often.
DER displays a diskette directory on the screen without disturbing the program
in memory.
If you type in DIR without any parameters, the entire directory appears. Pressing
the <STOP> key halts the directory display.
SL$ selects certain parts of the directory for display. DIR "$*=P" displays
program files (PRG) only; DIR "$*=S" displays sequential files (SEQ);
DIR "$*=R" displays relative files (REL); and DIR t!$*=U" displays
user files (USR).
Along with filetypes, you can use the wildcards * and ? for selecting individual
filenames.
The asterisk (*) replaces all characters following it. "$FD*M selects all files
starting with the characters FD. "SDIR*" gives all files starting with DIR (e.g.,
DIRECTORY, DIRTY, etc.).
64
Abacus 5. Disk commands
The question mark (?) can represent any character in a filename. DIR
t!$AD??CF" lists all six-character filenames starting with AD and ending with
CF. The two characters in between can be any letter or number. DIR
"$???TT?FP?r selects all ten-character files containing T as the fourth and fifth
characters, F as the seventh character, P as the eighth character and 1 as the
tenth character.
The asterisk and question mark can be used together. For example, DIR
"$C?T*" reads all files starting with C and containing a T as its third character
(e.g., COT, CAT, CITIES, etc.).
The wildcards can also be used in conjunction with the filetype selection. DIR
"$OUT*=S" selects all sequential files beginning with OUT.
DSENDCOM sends any commands to the disk drive. It is the equivalent of the
BASIC 2.0 OPEN 1,8,15, ftCOMMANDft:CLOSEl.
KN$ contains the disk command. DSENDCOM "S:NAMEM deletes the file
NAME. KN$ is a string up to 40 characters in length. Longer strings
result in a STRING TOO LONG ERROR.
You'll find other commands in this section that are more convenient to use than
DSENDCOM.
FM$ is the name of the string variable in which the error message should be
placed. If you omit FM$, then the message appears on the screen at the
current cursor position. The message appears in the format:
65
5. Disk commands BeckerBASIC 64
If the disk status is okay, then the result is 00,OK,00,00. The obvious signal for
a disk error is the flashing status light on the disk drive. When that occurs, read
the error channel to find out the problem.
KN$ contains the name of the file to be deleted. Additional files can be
added to KN$, each separated by commas. The string within KN$ can
be a maximum of 38 characters. The wildcards * and ? can be used
here, just as in theDIR command. For example, DSCRATCH "N7M*"
deletes all files containing N as the first character and M as the third
character.
KN$ contains the new and current filenames. These filenames can be up to
16 characters long.
Example:
66
Abacus 5. Disk commands
KN$ contains the diskette name and the identification characters (ID). If you
omit ID, an already formatted diskette can be cleared and renamed. A
new, unformatted disk must have an ID assigned to it the first time you
format it. The formatting process takes about 80 seconds.
NOTE: Formatting an already formatted diskette destroys all the data currently
on that diskette.
Examples:
DHEADER ffTEST,TT formats a new diskette and assigns it the name TEST
and the id TT.
DINIT loads the BAM (Block Availability Map) into disk memory. The BAM
shows how data is organized on diskette. Normally the BAM automatically
loads into disk drive memory when you change a diskette.
There are occasions when the disk drive can confuse two diskettes. This happens
when the id characters are the same when you switch from one diskette to
another. If this happens, the disk drive assumes that the newly inserted diskette
is the same diskette as the old one.
When this happens, and you know that the diskette ids are the same, you can
initialize the diskette (load the BAM) with the DINIT command.
Format: DINIT
67
5. Disk commands BeckerBASIC 64
DRESET sets the disk drive into the power-up state, something like resetting the
computer, without the disadvantages.
Format: DRESET
The default address of the disk drive is 8. If you work with two disk drives (the
C64 allows up to 5 disk drives), the addresses must be different from one
another.
The following three commands allow address changes and multiple disk drive
operation.
Format: DADRCHANGE DN
DN is the new disk drive device number. Values for DN can range from 4
to 15. Other values result in an ILLEGAL QUANTITY ERROR.
The disk drive not planned for an address change must be switched off.
68
Abacus 5. Disk commands
DN is the new disk drive device number. Values for DN can range from 4
to 15. Other values result in an ILLEGAL QUANTITY ERROR.
Example:
This example is in two parts. Type the first program in and save it with
DSAVEB"TEST on drive 8. Do not RUN this program.
Clear your memory with NEW, then type in the next program listing. After you
save it, RUN it.
Turn off the disk drive you want kept as device 8. Line 10 changes the device
number of the currently switched on disk drive to 9. Turn on the other drive
(device 8) and press a key (WAITKEYA waits for a keypress). Line 20 loads the
program "TEST1 into memory, overwriting the first program. The program now
in memory saves itself as "TEST1 to device number 9 and the SCPRINT
command displays the current device number (9).
NOTE: You only need to change disk drive addresses once with the extra drive
turned off. From then on, you can change addresses within the program while
the power is on.
The commands described in this section work best with BASIC and machine
language programs. The first topic is the saving and loading of programs,
including machine language. Screen memory, hi-res bitmaps and other data have
their own commands for dealing with data.
69
5. Disk commands BeckerBASIC 64
Disk files can be handled by their filetypes (see Section 5.4.4 below).
PR$ is the name under which the program is saved. PR$ can be a maximum
of 16 characters in length.
Examples:
DCSAVEB "UTILITY" deletes a file named UTILITY from diskette and saves
the program currently in memory to diskette under the name UTILITY.
70
Abacus 5. Disk commands
DSAVEL and DCSAVEL let you save selected program lines to diskette.
DCSAVEL deletes the program of the same name from diskette, then saves the
program lines in memory to diskette under that name.
PR$ is the name under which the BASIC program is saved. PR$ can be up
to 16 characters in length.
Examples:
DCSAVEL !!NAME2tf,125 deletes the old file NAME2 from the diskette and
saves line 125 to diskette as NAME2.
NOTE: If you attempt to DSAVEL a line number larger than the highest
program number, BeckerBASIC returns an ILLEGAL QUANTITY ERROR.
For example, take a program that has lines numbered 10,12,17,20,21 and 49:
71
5. Disk commands BeckerBASIC 64
DSAVEM and DCSAVEM save machine language programs and all kinds of
data to diskette. DCSAVEM deletes a machine language program of the same
name from diskette, then saves the program currently in memory to diskette
under that name.
PR$ is the filename under which the program in memory is saved. PR$ can
be up to 16 characters long.
Examples:
DCSAVEM "MPl",828,850 deletes the file already on diskette under the name
MP1, and saves the memory range from location 828 to location 850 under the
same name.
PR$ is the name of the program on diskette that you want compared to the
program in memory.
72
Abacus 5. Disk commands
Example:
PR$ is the name of the program to be compared with the program currently
in memory.
Examples:
73
5. Disk commands BeckerBASIC 64
DLOADB and DRLOADB loads a BASIC program from diskette into memory.
DRLOADB automatically starts the program after loading it, so you don't have
to type RUN.
PR$ is the name of the file to be loaded from diskette. PR$ can be up to 16
characters in length.
PR$ is the name of the file to be loaded from diskette. PR$ can be a
maximum of 16 characters long.
BA gives the load address of the program. Values for BA range from 0 to
65535.
Examples:
DLOADAM "NAME2" ,42000 loads the program NAME2 into memory starting
at address 42000.
74
Abacus 5. Disk commands
5.3.3 Overlays
When you write larger programs, it may be necessary to break the program up
into smaller programs and load the sections as the program executes. The
biggest problem here is retaining variable contents, since BASIC normally
destroys variables when a new program loads. Overlay commands solve this
problem!
DOVERLAYW lets you load line numbers into a program already in memory.
Identical line numbers in memory are deleted.
What applies to PMERGE also applies to DOVERLAYW: When you use this
command within a program, the program being loaded in cannot have line
numbers smaller than or equal to the number of the current BASIC line (in
which the DOVERLAYW command stands). In such a case, the program may
stop with a SYNTAX ERROR message.
75
5. Disk commands BeckerBASIC 64
PR$ is the name of the program you want loaded. This name is a string up to
16 characters long. NOTE: Strings normally written in the form
VR$="TEXTM must be written as VR$=MTEXTtt+"tt so that the string is
handled correctly in the loading process. The added +lllfensures that the
string is copied into the top of string memory. You can also perform
this in DATA statements: READ VR$: VR$=VR$ +V$+" ".
Example:
HERE'S
AN
EXAMPLE OF
DOVERLAYW.
List the program when it's done running. It will look like this:
NOTE: When you can't arrange the program so that line numbers don't conflict,
then you should use the DLOADPROC command (see Chapter 6). This sets up
procedures independent of programs whose line numbers will not conflict with
the main program.
76
Abacus 5. Disk commands
LDEL has a similar function to the PDEL command (Chapter 2). It deletes
individual lines or sets of lines from a program. Unlike PDEL, variable contents
remain intact.
You can put as many parameters into LDEL as you can fit into a program line.
Example:
10 ...
20 LDEL 50,72-79,100
30 ...
The logical file is an efficient way to handle data of all kinds on diskette. Every
logical file has a name under which it is stored on diskette. Every logical file has
a logical file number. This number easily lets you see whether the file is set for
reading or writing.
This section lists the essential commands needed for logical file access. They
follow the same principles as stated earlier.
77
5. Disk commands BeckerBASIC 64
When you open a file, the filename and logical file number state the necessary
parameters. BeckerBASIC's DGETV and DGETM replace the BASIC 2.0
commands GET* and INPUT# for reading file data. Writing data is performed
by the BASIC 2.0 PRINT# command. All read and write errors are signalled
according to the logical file number.
DCLOSE closes the file and ends the access. If you wish to re-access the file, it
must again be opened by the DOPEN command.
NOTE: You must use the DCLOSE command to close the file; you can't just
leave the file open. Also, remember to use the proper secondary addresses when
closing and opening files with DCLOSE and DOPEN.
The disk drive system allows a maximum of three open files at one time. If you
open a fourth file, a TOO MANY FILES ERROR results. You should also keep
in mind that one relative file is equal to two normal files. If you have a relative
file open, you can only have one sequential file open as well.
DOPEN opens a file of any type for reading or writing. All filetypes have their
own special open commands (more on this below).
LF is the logical file number of the file. Values for LF can range from 1 to
127 (you can theoretically use values higher than 127, but it doesn't
usually make sense for disk access). The logical file number identifies
the file, and has nothing to with the type of file access itself.
78
Abacus 5. Disk commands
S sequential (SEQ)
MF is the mode flag, which states whether the file is open for reading or
writing. You have a choice of two letters for MF:
R Read data
W Write data
One exception exists when opening a relative file with DOPEN: You omit the
mode flag and replace it with the record length in character code form. Another
peculiarity stands in opening sequential files: Using A for MF lets you append
an existing sequential file to an open file.
Examples:
DOPEN 5,"EX5,S,A" opens sequential file EX5 for appending data to the file
previously opened by DOPEN.
79
5. Disk commands BeckerBASIC 64
FILENUM lists the number of files currently open. Checking this occasionally
helps you avoid having more than three files open at a time.
After opening the desired file with the DOPEN command, you can write or read
any data in the file, depending upon which mode is active when the file opens.
The next two commands are used for reading data.
DGETV reads data from any disk file and puts this data into a string variable.
VR$ is the name of the string variable into which the data goes.
LE is the number of characters that should be read from the file. Values for
LE can range from 1 to 255.
DGETV has the advantage over BASIC 2.0' s INPUT# in that it can handle up to
255 characters at a time.
Examples:
DGETV 7,EG$,23 reads 23 characters from logical file 7, and places these
characters into string variable EG$.
DGETM reads data from any disk file, and places this data in any area of
memory.
80
Abacus 5. Disk commands
SA is the address of the first memory location of the data read. Values for
SA range from 0 to 65535.
LE sets the number of bytes to be read from the file. Values for LE range
from 1 to 255.
The use of DGETM instead of DGETV is useful when the data must be
transferred directly to the screen, and variable contents must stay free (see
Chapter 4 for memory access commands).
Examples:
DGETM 2,42000,52 reads 52 characters from logical file 2, and places the data
in the computer starting at memory location 42000.
line 110 reads the data and places it in memory starting at address 48000. Lines
120 to 140 put the data in memory location 48000 and place it in string variables
A$, B$ and C$.
EOF helps you determine the end of the current disk file.
Format: FL = EOF
81
5. Disk commands BeckerBASIC 64
Example:
This short routine reads the data from logical file 3 until it reaches the end of the
file. The file goes into memory starting at memory address 42000 (more on the
REPEAT/UNTIL construct in Chapter 6).
DCLOSE closes a logical file, signalling the computer and disk drive that the
file access is finished.
Format: DCLOSE LF
Example:
This routine reads the data from a sequential file and places it in E$.
DSQOPEN is designed for opening sequential files. The simplest form uses the
logical file number and the corresponding filename.
82
Abacus 5. Disk commands
LF is the desired logical file number. Legal values for LF range from 1 to
127.
• R read data
W write data
Omitting the mode flag defaults the file to read status (R).
A If you try writing to an existing sequential file with new data using the
W mode flag, the error message FILE EXISTS results. You can add to
this file by opening it with the mode flag A. All data sent through
PRINT* is appended to the existing file.
Examples:
DSQOPEN 5,"DATA" opens the sequential file DATA for reading. The logical
file number is 5.
DSQOPEN 1,"DATF,M" opens the improperly closed sequential file DATF for
reading.
83
5. Disk commands BeckerBASIC 64
Fl,... are the names of sequential files added to the new file.
KN$ is the string containing the data about NF, Fl, etc. This string can be up
to 38 characters in length.
Examples:
If you want to add a file to an existing file, you can do the following:
10 DSQCONCAT MZW=F1,F2"
20 DSCRATCH"F1"
30 DRENAME "Fl=ZW"
With the help of these three commands, you can easily handle relative files.
84
Abacus 5. Disk commands
RL is the record length. Relative files are divided into records, and all
records have the same length. This parameter must be given on every
file opening, regardless of whether the file is new or existing. Values
for RL can range between 1 and 254 bytes.
*
NOTE: Once you set a record length on initially opening a file, the record length
cannot be changed. Trying to re-open a file using a different record length
results in a RECORD NOT PRESENT ERROR.
When the input is sent with PRINT#1 and concluded with <RETURN> (e.g.,
PRINT#1,A$), you must allow 1 byte for the CHR$(13) (<RETURN> key)
within each record. A 5O-byte record can only contain 49 characters plus
<RETURN>.
Examples:
Format DRLCLOSE LF
85
5. Disk commands BeckerBASIC 64
Example:
DRLCLOSE 7 closes the relative file assigned logical file number 7. One
similarity between DCLOSE and DRLCLOSE: When a disk error occurs during
the time a file is open, you must close the corresponding file.
All data records in a relative file are accessed by record numbers, with values
from 1 to 65535. T6 access a record (i.e., read from it or write to it), you must
set the computer to the record's position.
RN is the record number you want Values for RN can range from 1 to
65535.
RP allows you to move to a position within the record. Legal values for
this can range from 1 (first byte of the record) to 254 (last byte of the
record).
1) When writing a record, RP must start out set to 1. Data records are sent
from that point in one group through the PRINT* command. When a
position is found that is larger than the last data record of the
corresponding file, the result is a RECORD NOT PRESENT ERROR.
However, the next write access to the record with PRINT* executes
correctly. The message RECORD NOT PRESENT signals that you
have gone past the previous end of the file.
2) A write access to a record fills all data records with lower numbers that
haven't been written to yet with CHR$(255). For example, you define a
new relative file with DRLOPEN 7,"DATA",50. Using DRLRECORD
3,70,l:PRINT#3,RD$ writes to record 70. Records 1 to 69 are written
with CHR$(255), and can be written to later on.
86
Abacus 5. Disk commands
To avoid unnecessary waiting time during file access, if you know the length of
the file, you can move to the last record position and fill in the entire file with
CHR$(255). For instance, a program to fill in a relative file containing 200
records and record length of 72 bytes can look like this:
Now for a complete example of relative file handling using the simple file
handling commands included in BeckerBASIC:
5 'RELFILE MGR.BECKERBAS'
10 LF=1:'LOGICAL FILE NUMBER'
20 DN$="DATA":'FILENAME'
30 RL=20:'RECORD LENGTH'
40 DRLOPEN LF,DN$,RL:'OPEN FILE'
50 :
90 CLS
100 SCPRINT "READ OR WRITE 'RECORD (R/W)?";
110 KBGETV WL$,1,"WR":'SELECT W OR R'
120 GOSUB WL$:'AND CALL SUBROUTINE'
130 :
140 SCPRINT:INPUT "MORE? (Y/N)";W$:'CONTINUE?'
150 IF W$="Y" THEN POPIF:GOTO100:ENDIF
160 DRLCLOSE LF:'NO, CLOSE FILE'
170 END:'END PROGRAM'
180 :
190 :
500 "R":'READ RECORD'
510 SCPRINT:INPUT"RECORD NUMBER";RN
520 DRLRECORD LF,RN,1:'POSITION TO RECORD'
530 DGETV LF,EG$,RL:'READ RECORD'
540 SCPRINT EG$:'DISPLAY ON THE SCREEN'
550 RETURN
560 :
570 :
600 "W":'WRITE RECORD'
610 SCPRINT:INPUT"RECORD NUMBER: ";RN
620 DRLRECORD LF,RN,1:'MOVE TO RECORD'
630 SCPRINT"YOUR INPUT:";
640 KBGETV EG$,RL:'GET DATA FROM KYBD'
650 PRINT#LF,EG$;:'AND SEND IT'
660 RETURN
87
5. Disk commands BeckerBASIC 64
DUSOPEN opens a user file (files containing a USR identifier in their directory
listings).
LF is the desired logical file number. Legal values for LF can range from 1
to 127.
LS is the optional mode flag. If LS is W, then the file opens for writing; if
LS is R, then the file opens for reading. If you omit the mode flag, the
file opens for reading (R).
Examples:
DUSOPEN 3,-NAMl" opens the user file NAM1 for reading data.
DPGOPEN opens program files. This lets you load and edit a program byte for
byte.
LF is the logical file number. Legal values for LF range from 1 to 127.
LS is the optional mode flag. If LS is W, then the file opens for writing; if
LS is R, then the file opens for reading. If you omit the mode flag, the
file opens for reading (R).
88
Abacus 5. Disk commands
Examples:
Diskettes store data in blocks of 256 bytes each. A direct access file allows you
to access (read or write) individual blocks of data. This means that you can
easily create your own data structures based upon program, sequential and
relative files. These commands allow simple manipulation of available files, or
even the directory.
CAUTION: Even though direct access gives great flexibility in disk access,
remember that direct access can also turn little errors into big ones! For
example, one badly written data block can destroy an entire sequential file.
If you want to design your own file structures, you should use a newly formatted
diskette which contains no programs, relative or sequential files. Or at the very
least, use a backup copy of die diskette you want to read from or write to.
DDAOPEN is designed for opening a direct access file. Before describing the
format of this command, you need some general background about the
organization of a direct access file.
All data read from a disk data block is first stored in buffer memory within the
disk drive's memory. From there you read the data with the commands DGETV,
DGETM, etc.
By the same token, data written to a data block is stored in this buffer, then
transferred to diskette using a special command.
89
5. Disk commands BeckerBASIC 64
The disk drive has a total of five buffers available, each identified by the
numbers 0 to 4:
LF is the logical file number. Legal values for LF can range from 1 to 127.
PN is the buffer number, chosen from the list above. Buffer selection has
nothing to do with the later transfer of the file, so you can omit the PN
parameter from DDAOPEN if you don't care which buffer is used.
The number of the buffer selected can be read after using the DDAOPEN
command (e.g., with DGETV LF,P$,1:PN=ASC(P$)). If you give an illegal
number for PN, or the corresponding buffer is being used, the DOS responds
with a NO CHANNEL error.
In most cases, all you need to do is open a direct access file. You can have a
maximum of four of these files open at a time. Watch out for opening different
filetypes at once (SEQ, PRG, etc.). You can have a maximum of two relative
files open at a time. If you overstep the maximum allowable number of files,
you'll get a TOO MANY FILES ERROR error messages.
Examples:
DDAOPEN 5,3 sets up a direct access file with a logical file number of 5 in disk
buffer 3.
90
Abacus 5. Disk commands
DDAREADBL reads the desired track and sector (data block) from diskette into
the direct access file's buffer.
LF is the logical file number. Legal values for LF can range from 1 to 127.
TR,SC are the track (TR) and sector (SC) of the desired data block. Use the
values for track and sector in the table below:
TRACK SECTOR
0 - 17 00 - 20
18 - 24 00 - 18
25 - 30 00 - 17
31 - 35 00 - 16
Examples:
DDAREADBL 3,18,0 loads the data block at track 18, sector 0 (the first
directory block) into the buffer.
After the data block loads into the buffer, you can read the data with the resident
commands (DGETV, DGETM, etc.). In addition, you can set a buffer pointer to
a memory location within the buffer, for reading or writing the data.
91
5. Disk commands BeckerBASIC 64
DDAPOINT sets the buffer pointer to a memory location within the buffer.
LF is the logical file number. Legal values for LF can range from 1 to 127.
PS is the desired position at which the pointer should be set Legal values
for PS can range from 0 (the first byte of the buffer) to 255 (the last
byte of the buffer).
Examples:
DDAPOINT 3,27 positions the pointer to the 28th byte of memory assigned by
logical file number 3.
DDAPOINT 7,255 puts the pointer on the last byte of the buffer controlled by
logical file number 7.
LF is the logical file number. Legal values for LF can range from 1 to 127.
TR,SC are the track (TR) and sector (SC) of the desired data block. Use the
values for track and sector in the table below:
TRACK SECTOR
0 - 17 00 -- 20
18 - 24 00 -- 18
25 - 30 00 -- 17
31 - 35 00 -- 16
92
Abacus 5. Disk commands
NOTE: To store the current data block, you can send it to diskette with PRINT*.
Examples:
DDAWRTTEBL 2,1,0 writes the contents of the buffer assigned logical file
number 2 to the data block starting at track 1, sector 0.
Normally, you name a diskette once-when you format a diskette. The program
above lets you change the name of your diskette, without any loss of data,
anytime you want. NOTE: Type this program in carefully.
Now that you know the essentials of direct access and data control,
BeckerBASIC has two DOS commands which allocate and free up diskette
memory.
DDABLALLOC allocates data in a specific track and sector on the BAM (Block
Availability Map). DDABLFREE frees memory in a specific track and sector.
93
5. Disk commands BeckerBASIC 64
TR,SC are the track (TR) and sector (SC) of the desired data block. Use the
values for track and sector in the table below:
TRACK SECTOR
0 - 17 00 -- 20
18 - 24 00 -- 18
25 - 30 00 -- 17
31 - 35 00 -- 16
Examples:
DDABLALLOC 12,19 allocates the data block at track 12, sector 19 in the
BAM.
The following command sequence below lets you isolate the track and sector
number of the next available data block from the error message. The error
message is stored in the variable DS$ for later retrieval (e.g., with DSTATUS
DS$):
If no free data block exists (i.e., there is no next available block), TR and SC are
both set to zero.
94
Abacus 5. Disk commands
The 1541 disk drive has its own disk operating system (DOS); which means it
can perform its disk operations without the computer's support. In addition to
the DOS, which is stored in ROM, there are two kilobytes of RAM allocated for
working memory and buffer memory. The following commands let you read
disk drive memory (both RAM and ROM), write to disk drive RAM, and
execute your own machine language programs from within disk drive RAM.
AD is the memory address whose contents are placed in the variable VL.
Values for AD can range from 0 to 65535.
Example:
LE,BA are the address of the first memory location to be read and the length of
the data being read, computed from BA. Values for BA range from 0 to
65535; values for LE range from 0 to 255.
Example:
95
5. Disk commands BeckerBASIC 64
DMYREADV K$,16,1936 reads the name of the disk currently in the drive and
places it in the variable K$. Characters following the filename are filled in with
<SHIFT><SPACE>. This can be used to check if the correct diskette is
currently in the drive.
LE,B A are the address of the first memory location to be read and the length of
the data being read, computed from BA. Values for BA range from 0 to
65535; values for LE range from 0 to 255.
Example:
DMYREADM 42000,37,725 reads the last error message sent by the disk drive
from address 725 to 761 (error message buffer memory) and places this segment
in the computer's memory starting at memory location 42000.
BA BA is the address and WT is the value placed into the address. Values
WT for WT range from 0 to 255; values for ba range from 0 to 65535
(NOTE: Not all values for BA are effective, see your C64
Programmer's Reference Guide, or The Anatomy of the 1541 Disk
Drive from Abacus for memory locations).
96
Abacus 5. Disk commands
Example:
FA is the address at which the data is written in disk memory. Values for
FA range from 0 to 65535.
SD$ is the string to be sent to disk memory. Values for SD$ range from 1 to
34 characters. Strings longer than 34 characters result in a STRING
TOO LONG ERROR.
Example:
FA is the address of disk memory at which the data starts. Values for FA
range from 0 to 65535.
RAJJB are the starting address of computer memory of the data sent to disk
memory (RA) and the length of the data (LE) starting at RA. Values for
RA range from 0 to 65535. Values for LE range from 1 to 34.
97
5. Disk commands BeckerBASIC 64
Example:
When you want to execute machine language commands stored in disk memory
or on diskette, you can start these from the computer using the following
commands.
Format DMYEXEC SA
SA is the starting address of the machine program set for execution. Values
for SA can range from 0 to 65535.
Example:
DMYEXEC 49597 branches to disk memory and deletes the command string
buffer in the disk drive.
DDABLEXEC loads the contents of the given data block into the predetermined
direct access file disk memory (see Section 5.5). The contents are then executed
as a machine language program. Like DMYEXEC, the machine language
program must be concluded with an RTS (Return from Subroutine).
LF is the logical file number set in DDAOPEN (see Section 5.5). Legal
values for LF can range from 1 to 127.
98
Abacus 5. Disk commands
TR,SC are the track (TR) and sector (SC) of the desired data block. Use the
values in the table below for track and sector
TRACK SECTOR
0-17 00 -- 20
18 - 24 00 -- 18
25 -30 00 -- 17
31 -35 00 -- 16
Example:
DDABLEXEC 3,14,19 loads the machine language program at track 14, sector
9 to the data buffer assigned logical file number 3, and starts the program.
99
Abacus 6. Structured programming
6. Structured programming
Most large BASIC programs are unreadable. That is, their listings are difficult to
read for style or program flow. This chapter discusses the structured
programming commands of BeckerBASIC.
With the exception of SELECT/ENDSEL, this chapter lists six preset constructs
for simpler nested loop programming. For an introduction to nesting, here's an
example written in BASIC 2.0.
10 FOR Zl=l TO 10
20 FOR Z2 =1 TO 10
30 FOR Z3=l TO 10
40 ; ...
50 ; ...
60 : NEXT Z3
70 : NEXT Z2
80 NEXT Zl
This routine consists of three nested FOR/NEXT loops. The innermost loop
executes lines 30 to 60. The second nested level runs lines 20 to 70, and the
topmost level from line 10 to 80.
As you can see from the above example, the program becomes much more
readable when you indent each loop level. The colons at the beginning of lines
20 to 70 are necessary so the interpreter ignores the spaces following them.
101
6. Structured programming BeckerBASIC 64
6.1 Comments
BeckerBASIC has two extended versions of the BASIC 2.0 REM command.
These versions use the apostrophe (') and quotation mark (").
You must place commentary between the' or". There must be a colon before or
after the commentary. Also, you cannot mix the two characters as comment
markers (" and', or' and").
The major advantage of these comment markers over REM is the flexibility of
comments: You can place comments between commands, instead of at the end
of a command line, or on a separate line.
Examples:
102
Abacus 6. Structured programming
Throughout the BeckerBASIC program disk you'll find most of the comments
typed in between apostrophes. The quotation mark can be used as a comment
marker, but it is also used for defining labels. The jump commands GOTO,
GOSUB, etc. only function in BASIC 2.0 through the use of constants (e.g.,
GOTO 100, GOSUB 350). Commands like GOTO 2*A+B or GOTO
"OUTPUT1 don't run in BASIC 2.0. The first of these two (GOTO 2*A+B)
handles the branch to a calculated line number. The second (GOTO
"OUTPUT") looks for a label. Both these items are executable in BeckerBASIC
thanks to the GOTO, GOSUB, RUN, RESTORE and ON commands.
Note that RESTORE also sets positions for DATA lines. While the DATA
pointer of BASIC 2.0 moves only to the first DATA statement, BeckerBASIC
lets you position the DATA pointer to any DATA statement, and any section of
a program. This allows the use of calculated line numbers and labels (e.g.,
RESTORE 12+A or RESTORE "BLOCK").
Calculated line numbers may use any mathematical expressions. You can even
use GOTO SIN(A) or GOSUB SQR(COS(B)). The only limit is that you stay
within the legal values (from 0 to 63999). If you go beyond these values, the
computer returns an ILLEGAL QUANTITY ERROR (values lower than 0) or a
SYNTAX ERROR (values higher than 63999). Results containing decimal
numbers automatically round off to integers (BeckerBASIC removes the
decimal places).
103
6. Structured programming BeckerBASIC 64
3) A colon separates the label from the rest of the program line.
Examples:
5 'LABEL DEMO'
10 A=10*B+7:GOSUB "OUTPUT"
50 PRINT"THIS IS THE MAIN PROGRAM, AND SHOULD APPEAR AFTER THE";
60 PRINT"OUTPUT SUBROUTINE.":PRINT" "
70 END
100 "OUTPUT":PRINT"THIS IS THE ";CHR$(34);"OUTPUT";CHR$(34);
110 PRINT"SUBROUTINE AND SHOULD APPEAR FIRST. A=";A:PRINT:RETURN
5 'RESTORE DEMO'
10 A$(1)="BLOCK1":A$(2)="BLOCK2":A$(3)="BLOCK3"
20 INPUT"PLEASE SELECT A BLOCK NUMBER (1-3) AND PRESS <RETURN>";BN
30 RESTORE A$(BN):'MOVE TO DESIRED BLOCK'
40 :
50 READ DA$
60 PRINT DA$
1000 "BLOCK1":DATA "DOG"
1010 DATA
1100 "BLOCK2":DATA "CAT"
1110 DATA
1200 "BLOCK3":DATA "MOUSE"
1210 DATA
104
Abacus 6. Structured programming
IF (110) (c)
THEN (111) (c)
ELSE (112) (c)
ENDIF (113) (c)
If the condition following the IF is fulfilled, the program executes the THEN. If
the condition is unfulfilled at IF, the program looks for the ELSE and executes
the section stated at ELSE. When ELSE is omitted, the program continues after
the ENDIF.
As you can see from the format, the IF/THEN/ELSE/ENDIF can be used over
several program lines.
There are a few points to keep in mind when working with the BeckerBASIC
version of IF/THEN:
2) A colon must precede the ELSE nad ENDIF instructions, unless one of
these instructions is at the beginning of a program line.
105
6. Structured programming BeckerBASIC 64
If the interpreter finds an ELSE of ENDIF without a corresponding IF, the result
is an ELSE/ENDIF WITHOUT IF ERROR. A THEN without an IF returns a
SYNTAX ERROR.
Examples:
If the condition is fulfilled, then the string W$ appears on the screen, otherwise
the variable W$ becomes a null string.
This can improve the readability of a program (note the GOSUB in line 110).
Format: VT=LEVELIF
VT can have values ranging from 0 (no nesting) to 255 (maximum nesting
depth).
106
Abacus 6. Structured programming
You can exit a loop level at any time using the POPIF command. POPIF simply
resets the pointer to the next nesting level up. Before or after POPIF, there must
be a loop jump (e.g., a GOTO).
Format: POPIF
Format: 10 SELECT AW
20 CASE Wl, ...:
30 CASE W2, W3, ...:
40 ...
50 OTHER ...
60 ENDSEL
If one of the compared values goes over AW, the program executes the line
following the highest CASE command. If the interpreter finds a new CASE, the
program looks for ENDSEL before it continues on. If no CASE value matches
AW, the command(s) listed following OTHER executes.
107
6. Structured programming BeckerBASIC 64
NOTE: CASE, OTHER and ENDSEL must be found by the interpreter at the
beginning of a program line. Indentation and leading colons are not allowed.
Examples:
5 A=1:INPUT"NUMBER";CW
10 SELECT A*CW+7
20 CASE 2,4,7/9,117:GOSUB"SUBROUTINEl"
30 CASE 1,18,22:GOSUB"SUBROUTINE2"
40 OTHER GOSUB"SUBROUTINE3"
50 ENDSEL
60 END
70 "SUBROUTINE1":PRINT"THIS IS SUBROUTINE!":RETURN
80 "SUBROUTINE2":PRINT"THIS IS SUBROUTINE2":RETURN
90 "SUBROUTINE3":PRINT"THIS IS SUBROUTINE3":RETURN
The result of the equation A*CW+7 moves the program to the different
subroutines. A result of 2,4,7,9 or 117 branches to SUBROUTINE 1. A result of
1,18 or 22 branches to SUBROUTINES Any other result branches to
SUBROUTINE3.
5 INPUT"NUMBER";WB
10 SELECT WB
20 CASE 1,3,5:A=1
30 CASE 2,4,6:A=2
40 ENDSEL
50 PRINT"A= ";A
108
Abacus 6. Structured programming
As you can see, this version is much harder to follow than the CASE/SELECT
version. SELECT may not necessarily be the most useful construct when
working with multiple conditions.
10 INPUT"NUMBER";KN
20 :
30 SELECT KN
40 CASE 1:WT$="SUNDAY"
50 CASE 2:WT$="MONDAY"
60 CASE 3:WT$="TUESDAY"
70 CASE 4:WT$="WEDNESDAY"
80 CASE 5:WT$="THURSDAY"
90 CASE 6:WT$="FRIDAY"
100 CASE 7:WT$="SATURDAY"
110 OTHER SCPRINT"BAD NUMBER. TRY AGAIN.11
120 ENDSEL
130 SCPRINT" "WT$
This routine reads the number you input and puts the weekday into the variable
WT$.
109
6. Structured programming BeckerBASIC 64
BeckerBASIC offers three loop types in addition to the BASIC 2.0 FOR/NEXT
loop: WHILE/DO/ENDDO, REPEAT/UNTIL and LOOP/LPEXITIF/
ENDLOOP. All three types differ from each other in the time at which
conditions execute. WHILE takes control at the beginning of the loop; REPEAT
waits until the end of the loop. LOOP works at any point in the loop.
A WHILE loop performs its task as long as a condition remains true and the
commands within the loop do not change (a FOR/NEXT construction runs only
once in any case).
When the program encounters an ENDDO, it checks the current loop condition
between WHILE and DO. If this is still true, the commands between WHILE
and DO continue execution. On false conditions, the program continues at the
point following ENDDO.
If the WHILE condition is false after the first run, the program continues
immediately after ENDDO.
110
Abacus 6. Structured programming
WHILE/ENDDO loops can be nested up to 15 levels. Once nesting goes past the
fifteenth level, the interpreter responds with an OUT OF MEMORY ERROR.
Example:
10 INPUT"NUMBER (0-50)";AZ
20 ZP=0
30 WHILE NOT(ZP=AZ) DO
40 SCPRINT 2AZP:ZP=ZP+1
50 ENDDO
This routine displays exponents of 2 from 2*0 to 2M9. The WHILE loop runs
until AZ equals to ZP.
Format: VT = LEVELWHL
You can exit any loop level at any time with the POPWHL command. Directly
after POPWHL, GOTO can be used to exit the loop. POPWHL clears the
WHILE stack of the currently stored loop value.
Format: POPWHL
Unlike the WHILE/ENDDO command, the REPEAT/UNTIL loop tests for the
end of the loop. REPEAT/UNTIL always executes at least once.
Ill
6. Structured programming BeckerBASIC 64
Format: 10 REPEAT . . .
20 ...
30 UNTIL [CONDITION]
The program commands found in between REPEAT and UNTIL execute until
the condition following UNTIL is true. As soon as this condition is met, the
program continues after the UNTIL. REPEAT and UNTIL can be placed on
different lines of the program.
Example:
100 REPEAT
110 . B=0
120 REPEAT
130 : C=0
140 : REPEAT
150 : D=0
160 : REPEAT
170 : E=0
180 : REPEAT
190 : SCPRINT A+B+C+D+E
200 : E=E+1
210 : UNTIL E=l
220 : D=D+1
230 : UNTIL D=2
240 : C=C+1
250 : UNTIL E=3
260 : B=B+1
270 : UNTIL B=4
280 A=A+1
290 UNTIL A=5
112
Abacus 6. Structured programming
Format: VT = LEVELREP
You can exit a REPEAT/UNTIL loop at any time using the POPREP command.
Directly after POPREP, GOTO can be used to exit the loop. POPREP clears the
REPEAT stack of the currently stored loop value.
LOOP/ENDLOOP lets you set up common types of loops. The branch can be
designated at any time, which makes LOOP/ENDLOOP extremely flexible, and
useful when no other loop type will do the job.
Format: 10 LOOP .. .
20 ...
30 [LPEXITIF ... 'CONDITION']
40 ...
50 ENDLOOP
The program data between the LOOP and ENDLOOP executes until the
condition following LPEXITIF is fulfilled.
113
6. Structured programming BeckerBASIC 64
Example:
10 LOOP
20 INPUT"STRING:n;ZK$
30 LPEXITIF ZK$="ENDn
40 SCPRINT "LENGTH:H;LEN(ZK$)
50 ENDLOOP
60 ...
This example lists the number of characters you type in at the prompt. You
could have done this with an IF/THEN/POPIF/ENDIF sequence, but this
program code performs the same job with a little more elegant style.
Format VT = LEVELLP
POPLP lets you exit a loop at any time. Like the other POP commands, POPLP
takes the stored value from the LOOP stack. Once the loop exits, you must
branch with another command, like GOTO.
6.5 Procedures
114
Abacus 6. Structured programming
Labels are a basic method of getting into a procedure (see Section 6.2).
The limits of extra variable ranges mean more work in some respects. The
procedure may require one or more variable values from the program calling it
(this is almost always the case), so you have to add these variables to the
procedure.
This means that you have to pick and choose which variable the procedure needs
from the main program. As you'll see from the descriptions below, these
definitions are simpler than they might sound here.
Every procedure definition begins with the PROCEDURE command and ends
with PROCEND. Both commands must appear at the beginning of a program
line.
The name of the procedure follows the PROCEDURE command. You can give
it any name you wish. The only stipulations are that you place the procedure
name in quotation marks, and that the procedure name occupies less than a
program line in length.
The variables follow the name, each separated by commas and all variables
placed in parentheses.
Next comes the procedure itself - the commands you want executed by the
procedure.
115
6. Structured programming BeckerBASIC 64
100 PROCEDURE...(HEADER)
110 ...
120 ... (PROCEDURE COMMANDS)
130 ...
140 PROCEND (END MARKER)
Procedures are called using the CALL command. If a procedure doesn't exist,
the computer responds with an UNDEFINED PROCEDURE ERROR.
"NAME" can be any string. It is the name of the procedure you want
called.
Variables within the PROCEDURE list can be broken into two categories,
separated by semicolons. The contents of the variables to the left of the
semicolon are received from the CALL. The variables to the right contain the
values to be returned.
In CALL'S list the values to the left of the semicolon are the values to be passed
to the procedure; the right hand variables will contain the values to return.
This procedure takes an input LE characters long from column CL and row RW,
and places it in the variable EG$. A CALL for this procedure can look like this:
116
Abacus 6. Structured programming
CALL "TEST",(10,2,17;W$)
A string 17 characters long is taken from column 2, row 10. This is placed in the
variable W$ in the main program.
NOTE: The variables set for access by CALL must be defined BEFORE the first
procedure call. Even if you just assign values of zero, that will work fine.
There are some things about variable arrays and array elements to keep in mind.
These explanations are for parameter passing to a procedure only, not for the
return to the main program:
2) Larger numbers of arrays present problems. Here the first and last
element of the desired array range, separated by a minus sign (-), must
be given. If, for example, you want elements 7 through 19 of the array
FT passed, then the code would look like this:
CALL "NAME",(FT(7)-FT(19),...)
The example below gives all 28 elements of the string array AG$:
117
6. Structured programming BeckerBASIC 64
CALL "NAME",(AG$(0)-AG$(27),...)
PROCEDURE "NAME",(DA(12),..■)
PROCEDURE "NAME",(SR$(27),...)
PROCEDURE "NAME",(DM,FL%(DM),...)
This assigns the integer array FL% a size of variable DM. When the procedure
is called by the command CALL "NAME",(9,DW%(0)-DW%(9),...), FL% is
assigned ten elements and is filled with the elements of the array DW%(..).
Naturally, you can assign the array larger dimensions than needed; the rest of
the'array fills with null elements.
BeckerBASIC uses only two controlling factors in array passing, type control
and length control. Type control requires only that you make sure that arrays are
of the same type when setting them up for passing. In other words, putting real
into integer and vice versa is illegal. This results in a PROCEDURE-
PARAMETER ERROR.
The length control simply compares the array lengths, making sure that the one
has sufficient room to take on the other. Dimension control is impossible. One
thing you can do here is convert multidimensional arrays to smaller dimensions,
and vice versa.
Example:
118
Abacus 6. Structured programming
The two-dimensional array W(..,..) transfers its contents into the single-
dimensional array FA(...). You can also do the reverse:
10 CALL "NAME",(FA(15),...)
The first line of the note about passing arrays also applies to passing arrays from
procedure to the main program. The procedure return to the main program is
almost the same, with one exception: All arrays and simple variables returned
must be predefined before the passing takes place. After CALL and the
semicolon you give the first element of the array whose values you want passed
(default is element 0). See the example below.
10 DIM TC$(15),ZN%(25):AK=0
20...
100 CALL "NAME",(12*4+CG,3,TC$(9)-TC$(11);AK,ZN%(6))
NOTE: The term 12*4+CG had to be predefined before CALL (e.g., with
CG=0). The string array AM$ is dimensioned with a size of HV. The variable
returned is given to the real variable AK by the integer variable Z%. This is
handled as a simple variable. The element of the integer array D% must be
converted into an integer array (ZN%; this fills in the seventh element).
Remember: The variable AK and the array ZN% must be defined / dimensioned
before the procedure call (see program line 10 above):
10 DV(2,0)=7:DV(l,2)=138
100 CALL"NAME",(DV(0,0)-DV(2,2);)
110 ...
120 PROCEDURE "NAME",(MB(8);)
119
6. Structured programming BeckerBASIC 64
Remember: The semicolon in the variable list must be given, even if no values
appear to the right of the semicolon.
Procedures can be nested like loops. Nesting means in this case that a procedure
can be called from within another procedure during execution of that procedure.
This is particularly interesting when you want to create a self-calling, or
recursive procedure.
You can have a maximum nesting level of 15. If you go past this level, the
computer responds with an OUT OF MEMORY ERROR.
NOTE: On every procedure call, a new area of variable memory must be set
aside, so nesting procedures can make great demands on the memory. Keep this
in mind when writing recursive procedures. If, for example, you have defined
three real variables within a procedure, and you plan on making procedures self-
calling down to the seventh level, necessary variable memory for three variables
is 147 bytes.
Format: VT = LEVELPROC
POPPROC lets you exit a procedure before it's done executing. POPPROC
clears the variable range of the procedure in BASIC memory and retains the last
called procedure from the procedure stack. A jump command lets you go to any
point in the program.
Format: POPPROC
The formats of the following three commands are the same as those in Section
5.3.3 (Overlays). Procedures can also be loaded, saved, etc. without loss of data.
120
Abacus 6. Structured programming
NA$ is the name of the procedure to be saved. This string can be a maximum
length of 16 characters (the disk drive cannot handle longer names).
Although you can save procedures with DSAVEL (see Section 5.3.1),
DSAVEPROC is easier to use.
Example:
All procedures containing the same line numbers as the running program can be
easily loaded into the running program. Once it happens, you cannot edit the
two programs in memory; but you can remove the procedure with the
DELPROC command.
Example:
121
6. Structured programming BeckerBASIC 64
NA$ is the name of the procedure you wish deleted. To delete individual
program sections instead, use the PDEL (with variable loss; see Section
2.1.1) or LDEL (no variable loss; see Section 5.3.3).
Example:
If you want to use a procedure in an extreme case during editing, use the
following:
The solution to this problem lies in the memory range from 40960 to 48960
(free RAM).
However, the nesting principle holds true here, i.e., before you can deactivate a
window part way down the nesting levels, the last active window(s) must be
closed as well.
122
Abacus 6. Structured programming
The program at the end of this section is on your distribution diskette under the
name WINPROC. It contains a total of five procedures:
If you no longer need the window, you can close the window you opened with
the WINCLOSE procedure (program lines 1320-1490).
The WINDEL procedure (program lines 1530-1610) prepares the screen area for
data input by clearing the area. WININPUT (program lines 1760-2100) lets you
enter any data into the window. The cursor can be moved anywhere in the
window with the cursor keys. The other key functions (colors, for example) are
also accessible. WININPUT treats the window area as a miniature "screen."
Remember: The input array must be dimensioned in the main program BEFORE
the procedure executes.
123
6. Structured programming BeckerBASIC 64
The WINPRINT procedure (program lines 1650-1720) writes the data in a one-
dimensional string array (one array per window line) to a window. The
parameters applying to WINDEL, WININPUT and WINPRINT also apply to
WINOPEN.
You now have a general background of window techniques. There are other
procedures in this program, though. You can, for example, remove the border
from a window, or move different windows around the screen.
10 'WINPROC
100 'DELETE THESE LINES AFTER APPENDING TO ANOTHER PROGRAM'
110 :
115 CLS:LETTERON:CRCOL 1
120 SCPRINT AT 3,1;"THIS PROGRAM CANNOT START ON ITS OWN!"
130 SCPRINT AT 6,1;"IT IS INTENDED TO BE INTEGRATED"
140 SCPRINT AT 7,1;"WITH OTHER PROGRAMS YOU"
150 SCPRINT AT 8,1;"HAVE WRITTEN."
160 SCPRINT AT 17,6;"PLEASE PRESS A KEY."
165 WAITKEYA:END
170 :
180 :
190 :
1000 'WINDOW PROCEDURE'
1010 '(C) 1987 BY MARTIN HECHT'
1020 :
1030 'SAVED TO DISKETTE UNDER THE NAME WINPROC
1040 :
1050 :
1060 :
1070 PROCEDURE "WINOPEN",(WZ,WS,ZL,SL;)
1080 :
1090 WA=TEEK(45535):'CURRENT NUMBER OF WINDOWS'
1100 IF WA=5 THEN SCPRINT "TOO MANY WINDOWS!":POPIF:PROCEND
1110 ELSE WA=WA+1:POKE 45535,WA
1120 ENDIF
1130 :
1140 'SCREEN MEMORY BUFFER'
1150 IF WA=1 THEN BA=45505
1160 ELSE BA=DEEK(45535-WA*2+2)
124
Abacus 6. Structured programming
1170 ENDIF
1180 BD=PEEK(648)*256
1190 FOR AZ=WZ TO WZ+SL-1
1200 ZW=BD+(AZ-l)*40:TRANSFER ZW+WS-1,ZW+WS+ZL-2,BA-(ZL-1):BA=BA-ZL
1210 NEXT AZ
1220 :
1230 'PARAMETER STORAGE'
1240 DOKE 45535-WA*2,BA:'STARTING ADDRESS OF SCREEN BUFFER MEMORY'
1250 POKE 45525-WA,WZ:POKE 45520-WA,WS:'WINDOW STARTING POSITION'
1260 POKE 45515-WA,SL:POKE 45510-WA,ZL:'COLUMN /LINE LENGTHS'
1270 :
1280 PROCEND
1290 :
1300 :
1310 :
1320 PROCEDURE "WINCLOSE", (;)
1330 :
1340 WA=TEEK(45535):'CURRENT NUMBER OF WINDOWS'
1350 IF WA=0 THEN POPIF:PROCEND:ENDIF
1360 :
1370 'GET PARAMETERS'
1380 BA=DEEK(45535-WA*2):'BUFFER STARTING ADDRESS'
1390 WZ=TEEK(45525-WA):WS=TEEK(45520-WA):'WINDOW STARTING POS.'
1400 SL=TEEK(45515-WA):ZL=TEEK(45510-WA):'COLUMN / LINE LENGTH'
1410 :
1420 'RESTORE SCREEN AREA'
1430 BD=PEEK(648)*256:BA=BA+SL*ZL
1440 FOR AZ=WZ TO WZ+SL-1
1450 TRANSFER BA-(ZL-1),BA,BD+(AZ-1)*40+WS-l:BA=BA-ZL
1460 NEXT AZ
1470 :
1480 WA=WA-1:POKE 45535,WA:'NUMBER OF OPEN WINDOWS'
1490 PROCEND
1500 :
1510 :
1520 :
1530 PROCEDURE "WINDEL",(WZ,WS,ZL,SL;)
1540 :
1550 'CLEAR SCREEN AREA'
1560 BD=PEEK(648)*256
1570 FOR AZ=WZ TO WZ+SL-1
1580 ZW=BD+(AZ-l)*40:MYFILL ZW+WS-1,ZW+WS+ZL-2, 32
1590 NEXT AZ
1600 :
1610 PROCEND
1620 :
1630 :
1640 :
125
6. Structured programming BeckerBASIC 64
2070 NEXT AZ
2080 :
2090 "WEND":POPLP
2100 PROCEND
126
Abacus 6. Structured programming
By changing the parameters in line 110, you can make your window any size,
and enter any data in your window.
127
Abacus 7. GEOS
7. GEOS
GEOS operates in hi-res mode on the Commodore 64. The bitmap for GEOS
lies between memory locations 40960 and 48960. This memory range uses the
hi-res commands discussed in Chapter 8.
GEOS and hi-res commands can be used together. Both programming areas
have some similarities, but these two subjects require two separate chapters.
This chapter describes the creation of dialogue boxes and drop-down menus.
There is one thing you should remember when working with GEOS from
BeckerBASIC: All tables and strings sent to GEOS must end with 0 (CHR$(0)).
Not doing this can lead to a system error. Also note that the commands and
functions listed in this chapter are not accessible in the Input System. You will
have to switch to the Testing System with <CTRLxCommodore> to test your
program.
Since GEOS uses a different text coding from BASIC, you must convert any
text from Commodore ASCII to GEOS ASCII with the ASCGEOSW command
(see Section 7.3). By the same token, any text transferred from GEOS to
BeckerBASIC must be converted by the GEOSASCW command.
Not everything can be produced by the GEOS commands, even though it might
seem as if you can program some things at first glance. This can occur because
of memory layout, or for other technical reasons.
With the help of a few programming tricks, you can simulate such important
GEOS functions as drop-down menus and dialogue boxes from BASIC. In both
cases, command control is given to GEOS then returned to BeckerBASIC.
129
7GEOS BeckerBASIC64
Drop-down menus and dialogue boxes present another problem. These both
need the second hi-res bitmap range starting at memory location 24576. This
area of memory needs to be protected. Use the PBCEND command to do this.
This reduces the available BASIC memory by almost eight kilobytes.
Both dialogue boxes and drop-down menus are best used with programs that
load other programs through overlay commands from diskette (see Section 5.3).
IMPORTANT: Before you use any GEOS commands, you must call the
GEOSON (or HRON) command. Otherwise, the result will be a system error.
Hi-res graphic drawing is impossible without these commands (the picture is
drawn first, then the graphic screen switches on).
The same rule applies to going from hi-res mode to the normal text screen. If
you want a text screen command (e.g., SCPRINT), you must switch off the hi
res screen with GEOSOFF (or HROFF). Again, failure to do this leads to a
system crash.
Remember these rules, you'll save yourself a lot of time, trouble and system
errors.
Once hi-res graphics are active, you'll want to clear the graphic bitmap. The
HRDEL command performs this function.
Format: HRDEL
130
Abacus 7.GEOS
These three commands handle colors in the hi-res bitmap. HRGDCOL sets the
background color, HRPTCOL sets the point color and HRGTCOL returns the
current hi-res colors.
Fl is the color code you wish assigned to the unset points of the graphic.
Values for F2 range from 0 to 15 (see the PCOLOR command, Section
3.3).
F2 is the color code you wish assigned to the set points of the graphic.
Values for F2 range from 0 to 15 (see the PCOLOR command, Section
3.3).
CD sets the color status you want CD=0 returns the current point color;
CD=1 returns the current background color.
The border color can be changed with the BORDER command (see Section 3.3).
Remember that HRON can be used instead of GEOSON to produce the same
result. See Chapter 8 for more commands in hi-res mode.
131
7. GEOS BeckerBASIC 64
GEOS puts its drop-down menu data into a table in memory. BeckerBASIC uses
this table. This code table can be created using the BeckerBASIC Drop-down
Menu Construction Set.
GEOS text appears in the menu in proportional type, so initially you may not get
the menu spacing correct If you make a mistake, tell the program N when it
asks if you want the menu saved.
The program then allows you to correct your data. When you finish editing your
data, the drop-down menu sample appears on the screen again. You can repeat
this procedure as often as you wish. When the menu is finished, and your
parameters are entered, the table is saved to disk under any name you wish for
later recall. The commands you require for recall are DLOADM (load a menu
table from diskette, see Chapter 5) and PDMENU described below.
PDMENU activates (displays) a drop-down menu and allows access using the
mouse pointer. The only additional parameter needed is an address.
Format PDMENU AD
AD is the starting address of the code table +95. If the table address starts
at location 24000, AD must contain the value 24095. The menu then
appears on the screen for easy selection. As soon as you click a menu
option, the option blinks and die menu closes (the hi-res screen restores
the area where the menu had been).
132
Abacus 7.GEOS
A sub-menu will appear below this menu item (a set of selections connected
with the menu item) for further selection. When you click on an item from a
sub-menu, both the sub-menu and the menu disappear, and the program
continues.
MENUCODE (271) (0
This function returns the code of the menu or sub-menu item you clicked.
CD returns the number of either the clicked main menu item or the number
of the corresponding sub-menu item. Values for CD range from 0 to
10. CD=0 gives you the number of the clicked menu item in MC.
CD=1 returns the number of the sub-menu item.
The program can react to this data. Here is how the data reacts to menus, using
the ON GOSUB command:
Line 100 reads the menu. If you click the first menu item, the program branches
to line 1000, where it checks for the sub-menu item selected. If you select the
second menu item, the program jumps to line 2000, where the sub-menu item
routine branches, and so on.
133
7. GEOS BeckerBASIC 64
This program is on the distribution diskette under the name DDM.C.S, and can
be opened by double-clicking its icon from the deskTop. After the program
starts, it asks you where you want the data table placed.
Shorter menus can be easily stored in the cassette buffer (memory locations 828-
1023). Longer menus should be placed in the memory range starting at memory
location 24000 (directly under the second hi-res bitmap).
The next data requested is that of the main menu. First, you must determine the
number of menu items (1-10), then decide whether the menu should be
displayed horizontally or vertically. Next, the construction set needs the hi-res
position of the menu. Finally, the text for each item is requested.
Once you've entered this data, the program asks whether or not you wish to
create sub-menus. If so, you must enter the data for every menu requested.
When all data is ready, press any key to see your drop-down menu on the
screen.
Click on a menu item to end the display. The construction set asks if you like
the menu. If so, you must enter the name under which you want the code table
stored on diskette. If you answer the question with N, the program doesn't save
the data to diskette, but reserves it in memory for the moment.
When the program ends, after the data table is stored on diskette, the screen
displays a message on how to load and start your drop-down menu.
Try entering this data into the construction set program. Enter each value at the
prompt and press the <RETURN> key (don't type in the commas):
24200,5,0,80,60,218,73,GEOS,FILE,VIEW,DISK,SPECIAL,
N,Y,5,1,109,73,154,144,OPEN,DUPLICATE,RENAME,INFO,PRINT,
N,Y, 6,1,158, 73, 200,158,OPEN,CLOSE,RENAME,COPY,VALIDATE,FORMAT,N
This creates a familiar menu, the GEOS deskTop menu. To keep it simple, you
are asked above to enter the data for the second and fourth sub-menus only. If
you save this table to diskettee under the name PDMEX, you'd retrieve it in a
program as follows:
134
Abacus 7. GEOS
20 DLOADM "PDMEX"
30 PDMENU 24200+95
AD is the memory address of the dialogue box's code table. As a rule, this
table is small enough to be stored in the cassette buffer (memory
locations 828 to 1023).
EG is the memory location at which the dialogue box text input is stored.
In most cases, dialogue boxes need some sort of button to allow the user to exit.
When you define several buttons (e.g., YES and NO), DIALCODE reads the
button the user clicked. This code corresponds to the code assigned to the
button:
1 OK button
2 CANCEL button
3 YES button
4 NO button
5 OPEN button
6 DISK button
14 Click anywhere on the screen
135
7. GEOS BeckerBASIC 64
Code 14 reads a click anywhere on the screen. This is functional only when
installed from the Dialogue Box Construction Set. You might want to add
information about Code 14 in the GEOS INFO screen.
The Dialogue Box Construction Set is on your distribution diskette under the
name D.C.S. Double-click this program's icon from the deskTop.
The program first asks for the desired starting address of the code table. The
cassette buffer area starting at location 828 is ideal for this purpose. Next, the
program asks whether you want the standard dialogue box. The standard box is
the one you see for file operations (e.g., rename). If you don't want the
standard box, you'll need to supply the coordinates of the upper left and lower
right corners of the dialogue box. The next parameter requested is the desired
fill pattern for the box shadow. A fill pattern of 0 casts no shadow.
After this general data, parameters get more detailed. The order of the parameter
codes isn't as crucial here as with the Drop-down Menu Construction Set, but
you can't just throw these codes in at random. Furthermore, you must enter
these codes as individual input routines.
The upper area of the screen displays a table of the available codes. For
example, if you want an OK button, you type a 1 and press the <RETURN> key.
The program then asks the position at which you want the button placed from
the left (X-coordinate) and top (Y-coordinate) of the dialogue box.
After entering this input, you can assign the next code or codes. All these codes
are placed in the table as you go along.
Text output within the dialogue box is made possible through code 11. Again,
the program asks for the spacing from the left and top of the dialogue box. The
find request is for the text you want.
Code 13 enables data input Here the program asks for the starting position of
the input line from the left and top of the dialogue box. Then you are asked for
the maximum length of the input.
136
Abacus 7.GEOS
NOTE: When a dialogue box asks for input, the DIALOGBOX command must
contain the address at which the data should be placed (e.g., DIALOGBOX
850,828: The computer puts the data at memory location 828). From this
location you must use the GEOSASCW command to convert text to ASCII text
format (see Section 7.3). Finally, the data must move to a string variable using
MGETV (see Chapter 4).
The Construction Set always puts the data at memory location 828. Text input
requires a table starting address higher than 828.
Select code 0 to end the input procedure. Now press a key to see your dialogue
box. When you're done looking at it, click on a button to exit NOTE: If you
haven't put in any buttons before looking at this test display, you can't get out of
the display. Power down and start over.
The program then asks if the dialogue box looks okay. Type y or n and press the
<RETURN> key. Select y if you want to save the data; the program asks for the
name under which you want the table saved. Select n to start over.
This program has the disadvantage that you can't edit one code at a time. That
is, you have to start over if you want to change the dialogue box parameters.
Here's a practical example of using this Construction Set: Enter the first value at
the first prompt, press the <RETURN> key, then enter the rest of the values in
the same manner (don't type in the commas):
828,N,10,10,270,90,1,1,1,20,2,10,10,3,19,10,4,1,55,5,10,55,6,19,55,
11, 8,35,PLEASE CLICK ON A BUTTON-ANY BUTTON.,0
Tell the program you want to see this dialogue box, and watch the result that
appears: A box with six buttons and a line of text appears. Save this to diskette
under the name DBEX and exit the Construction Set. Then type in, save and run
this program to put your new dialogue box to use:
137
7. GEOS BeckerBASIC 64
BeckerBASIC has four commands for text input and output in hi-res mode.
HRPRINT displays text; HRGET is the high-resolution equivalent of INPUT;
ASCGEOSW and GEOSASCW convert ASCII text into GEOS format and
GEOS text into ASCII format respectively.
HRPRINT writes text to a specific position on the hi-res graphic screen. You
can use different typestyles (e.g., italics or bold) with this text
X,Y are the X-coordinate and the Y-coordinate of the hi-res pixel where the
text begins. Values for X range from 0 to 319. Values for Y range from
0 to 199.
TX$ is the string containing text to be displayed. The text in TX$ can be up
to 255 bytes long, and must end with a null (CHR$(0)).
138
Abacus 7.GEOS
CHR$(13) moves the text cursor to the start of the next line of text
following a carriage return.
The different typestyles can be used in combination (e.g., bold italic text). Not
all combinations give good-looking results.
Examples:
10 GEOSON
15 HRDEL
20 T$=CHR$(10) :HRPRINT 20, 20, IIG"+T$+"E"+T$+"OII+T$+IIS"+CHR$ (0)
30 WAITKEYA
40 GEOSOFF
The above program displays the word GEOS one letter under the next.
139
7. GEOS BeckerBASIC 64
10 GEOSON
12 HRDEL
14 HRGDCOL 15
15 HRPTCOL 0
20 TX$=CHR$(14)+CHR$(26)+"AN EXAMPLE"+CHR$(27)+CHR$(0)
25 HRPRINT 10,90,TX$
30 WAITKEYA
40 GEOSOFF
GEOS uses a different ASCII from Commodore BASIC. This means that every
text you use must be converted to GEOS ASCII using the ASCGEOSW
command.
GEOSASCW has the opposite effect Data must be converted from GEOS
format to normal BASIC format.
Text contained within a string can be handled directly with both commands.
You can use the following routine for this:
10 W=VARADR(TX$):WL=PEEK(W+l):WH=PEEK(W+2)
20 AD=WL+256*WH:AE=AD+PEEK(W)-1
30 ASCGEOSW AD,AE
140
Abacus 7. GEOS
VARADR conveys the address of the variable TX$. The current memory
position of the contents of TX$ goes into AD and the ending address of TX$
goes into AE.
HRGET reads data input in hi-res mode. A vertical blinking "text cursor"
appears.
X,Y are the X-coordinate and the Y-coordinate of the upper left corner at
which the text should be read. Values for X range from 0 to 319.
Values for Y range from 0 to 199.
GT$ is the variable for the text input GT$ must fulfill two conditions: The
input length for GT$ must be defined beforehand, and the string must
end with a null (CHR$(0)). For example, GT$=" "+CHR$(0) sets an
allowable input length of five characters. You can use spaces or other
characters instead of periods; these just set the input length. If you
prefer other characters, the text in GT$ must be converted to GEOS
text format by ASCGEOSW.
When you define GT$ as described above, the text cursor appears in the hi-res
graphic at the end of the reading position. To move it to the left, you must press
one of the cursor keys (all the cursor keys move the cursor left). Characters
erase to the left of the cursor as you move the cursor left. To make the cursor
appear at the beginning of the reading position, define GT$ as follows:
GT$=CHR$(0)+" "
Press the <RETURN> key to end the hi-res input. The text entered is in GEOS
text format in GT$. The text must be converted to normal BASIC text format
with GEOSASCW, and the CHR$(0) end marker removed (this can be done
with GT$=LEFT$(GT$,LEN(GT$)-1)).
Examples:
10 GEOSON
12 HRDEL
15 GT$=" "+CHR$(0)
141
7.GEOS BeckerBASIC64
20 HRGET 100,50,GT$
30 VGETM 828,GT$:GEOSASCW 828,828+LEN(GT$)
40 MGETV GT$,LEN(GT$)-1,828
50 WAITKEYA
60 GEOSOFF
Line 10 defines GT$ to ten characters and gets input from the hi-res position
100/50. VGETM puts the text at memory location 828, where GEOSASCW
converts the text to ASCII format. MGETV gets data from the variable GT$,
and removes the end marker (CHR$(0)).
10 AB$="EXAMPLEn+CHR$(0)
20 HRGET 200,50/AB$
30 VGETM 828,AB$:GEOSASCW 828,828+LEN(AB$)
40 MGETV AB$,LEN(AB$)-1,828
The major difference between this and the other example is that the text
EXAMPLE is the given text
142
Abacus 8. High-resolution graphics
8. High-resolution graphics
These commands are designed for efficient programming. Besides that, many
commands can be simulated using a combination of hi-res instructions. Since
BeckerBASIC commands optimize time wherever possible, speed is almost
never a problem.
BeckerBASIC supports many GEOS specialties. For example, you can draw a
filled rectangle with HRBOX, using one of the 45 GEOS fill patterns and 256
different combinations of line patterns. If you prefer, HRSTRING allows you to
combine drawing commands into one string for fast execution.
You may want to review the descriptions of GEOS commands (see Chapter 7)
before reading this chapter. You'll find a number of commands there that deal
with data input and output while using GEOS's hi-res screen.
NOTE: that the commands and functions listed in this chapter are not accessible
in the Input System. You wil have to switch to the Testing System with
<CTRL>+<SHIFT> to test your program.
BeckerBASIC uses the first bitmap of GEOS for hi-res mode. This bitmap lies
in memory locations 40960 to 48960. GEOS commands and hi-res commands
can be used in parallel. Bitmap I lies outside of BASIC memory, so the two
won't interfere with each other.
143
8. High-resolution graphics BeckerBASIC 64
HRON enables the hi-res graphic screen, and is identical to the GEOSON
command in Chapter 7. HROFF disables the hi-res graphic screen.
HRGTON tells the user which mode is currently active. If HRGTON returns 0,
the text screen is on; if HRGTON equals 1, hi-res mode is on.
NOTE: Before you use a hi-res command, you must use a HRON command
first Failure to do so leads to a system crash, since you can't do hi-res pictures
without hi-res mode. The same goes for the opposite direction: you can't use a
standard text screen command without turning hi-res mode off with HROFF.
Remember these rules whenever you work with hi-res graphics.
Format HRDEL
HRGDCOL sets the background color of the hi-res screen. HRPTCOL sets the
current point color of the hi-res graphic. HRGTCOL returns the current hi-res
colors.
Fl is the color code of the unset pixels. Values for Fl can range from 0 to
15.
F2 is the color code of the set pixels. Values for F2 can range from 0 to 15.
144
Abacus 8. High-resolution graphics
FB is the current color read. GD=0 returns the current foreground pixel
color; CD=1 returns the current background color.
HRPLOT lets you access any one of the 64,000 pixels. HRTESTP tells whether
the pixel is set or unset.
XK are the X- and Y-coordinates of the desired pixel. Values for XK range
YK from 0 to 319. Values for YK range from 0 to 199. Values outside
these ranges result in an ILLEGAL QUANTITY ERROR.
ZM states whether the pixel is set (ZM=0) or unset (ZM=l). The default
value for ZM is 0.
CD is the pixel status. If CD equals 1, the pixel is set; otherwise the value
for CD is 0.
145
8. High-resolution graphics BeckerBASIC 64
Examples:
X1,Y1 are the coordinates of the first point in the line. Values for XI range
from 0 to 319; values for Yl range from 0 to 199.
X2,Y2 are the coordinates of the last point of the line. Values for x2 range
from 0 to 319. Values for Y2 range from 0 to 199. Values outside these
ranges result in an ILLEGAL QUANTITY ERROR.
Example:
HRHLINE draws horizontal lines on the hi-res screen. HRVLINE draws vertical
lines. These commands execute much faster than HRLINE. You can draw lines
in up to 256 patterns with both commands.
146
Abacus & High-resolution graphics
ZM is the drawing mode. Values for ZM can range from 0 to 255. You can
figure out your line pattern by converting the number into an 8-bit
binary number. For example, ZM=170 would be 10101010 in binary
notation. Every set bit of the pattern corresponds to a 1, and every unset
bit is a 0.170 gives a dotted line as a pattern.
Examples:
HRVLINE 130,25,130,180,0 deletes any vertical line that might have been in
the same position.
HRFRAME draws a rectangular frame of any size on the screen. This command
uses the same drawing patterns as HRHLINE and HRVLINE.
X1,Y1 are the coordinates of the upper left corner of the frame. Values for XI
range from 0 to 319. Values for Yl range from 0 to 199.
X2,Y2 are the coordinates of the lower right corner of the frame. Values for
X2 range from 0 to 319. Values for Y2 range from 0 to 199.
147
8. High-resolution graphics BeckerBASIC 64
ZM is the drawing mode. Values for ZM can range from 0 to 255. You can
figure out your frame pattern by converting the number into an 8-bit
binary number. For example, ZM=170 would be 10101010 in binary
notation. Every set bit of the pattern corresponds to a 1, and every unset
bit corresponds to a 0.
Example:
HRBOX draws a filled rectangle of any size. You have 45 fill patterns available.
X1,Y1 are the coordinates of the upper left corner of the box.Values for XI
range from 0 to 319. Values for Yl range from 0 to 199.
X2,Y2 are the coordinates of the lower right corner of the box.Values for X2
range from 0 to 319. Values for Y2 range from 0 to 199.
FM is the fill pattern. Values for FM can theoretically range from 0 to 255,
but the useful values are up to 44. FM=1 produces a completely filled
box, while FM=0 deletes the box area.
100 HRON
110 FOR FM=0 TO 44
120 HRBOX 0, 0,319,199,FMrHRPRINT 10,100,"PATTERN #M+CHR$(0)
148
Abacus 8. High-resolution graphics
122 Q$=STR$(FM)
123 HRPRINT 90,100,Q$+CHR$(0)
125 HRPRINT 10,140,"PRESS A KEY FOR NEXT PATTERN"+CHR$(0):WAITKEYA
130 NEXT FM
140 HROFF
Example:
HRINV inverts the hi-res graphic display, i.e., set pixels become unset and unset
pixels become set
Format HRINV
HRSTRING lets you place a series of commands into a single string. This
speeds up execution time and saves memory.
KM$ is the string containing the codes required for the hi-res commands.
KM$ can be up to 255 bytes in length. The codes for KM$ are as
follows:
01 sets the intended graphic cursor at a certain point, using the coordinate
setXlow/Xhigh/Y.
02 draws a line between any two points. The coordinates of both ends of
the line are set using the coordinate set Xlow/Xhigh/Y (the first
pixel of the line is set by code 01).
149
8. High-resolution graphics BeckerBASIC 64
03 draws a filled rectangle. The upper left coordinates of the rectangle are
set by code 01. The lower left coordinates are set after code 03 using
the coordinate set Xlow/Xhigh/Y.
07 draws a rectangular frame. The coordinates of the upper left corner are
set by code 01, while the coordinates of the lower right corner directly
follow 07 using the coordinate set Xlow/Xhigh/ Y.
08 places the graphic cursor to the right by the coordinates stated in the
form Low/High.
10 HRON
20 HRDEL
30 'GRAPHIC CURSOR AT 10/10'
40 T1$=CHR$(1)+CHR$(10)+CHR$(0)+CHR$(10)
50 'DRAW A LINE FROM 10/10 TO 280/180'
60 T2$=CHR$(2)+CHR$(24)+CHR$(l)+CHR$(180)
70 HRSTRING T1$+T2$+CHR$(0)
80 WAITKEYA
90 HROFF
This program draws a line from coordinates 10,10 to coordinates 280,180. Press
a key to end the program.
90 HRON
95 HRDEL
100 'SET GRAPHIC CURSOR TO 25/40'
110 T1$=CHR$(1)+CHR$(25)+CHR$(0)+CHR$(40)
120 'SET DRAWING PATTERN 17'
130 T2$=CHR$(05)+CHR$(17)
140 'DRAW BOX, 2ND COORDINATE 100/100'
150 T3$=CHR$(03)+CHR$(100)+CHR$(00)+CHR$(100)
155 WAITKEYA
150
Abacus 8. High-resolution graphics
160 T4$=CHR$(1)+CHR$(40)+CHR$(0)+CHR$(70)
170 'MOVE GRAPHIC CURSOR DOWN AND RIGHT'
180 'SET DRAWING PATTERN 9'
190 T5$=CHR$(05)+CHR$(09)
200 'DRAW BOX, 2ND COORDINATE 120/145'
210 T6$=CHR$(03)+CHR$(120)+CHR$(00)+CHR$(145)
220 HRSTRING Tl$+T2$+T3$+T4$+T5$+T6$+CHR$(0)
230 WAITKEYA
240 HROFF
This program produces two overlapping rectangles with different fill patterns.
As already mentioned, HRSTRING saves time since the commands are read as
machine language instead of interpreted BASIC.
When you have a number of these graphic strings in a program, it may help if
you place these in a sequential or relative file. The DGETV command lets you
easily read this data into the computer (see Chapter 5 for more on DGETV).
Loading and saving hi-res graphics can be done with DLOADM and DSAVEM
(see Section 5.3). These commands LET you load or save parts of graphic
screens. The next two commands access entire graphic screens.
NA$ is the name assigned to the screen being saved or loaded. This name
can be up to 16 characters long.
Examples:
HRDSAVE "HIRES" saves the hi-res bitmap under the name HIRES.
151
8. High-resolution graphics BeckerBASIC 64
HRDLOAD "HIRDAT1 loads the graphic file HIRDAT into graphic memory.
NOTE: BeckerBASIC saves hi-res graphics so that they load into memory byte-
for-byte, without formatting or compression. Remember this when loading
BeckerBASIC graphics into other graphic programs, or when loading other
graphics into BeckerBASIC.
152
Abacus 9. Sprite commands
9. Sprite commands
The Commodore 64 allows up to eight sprites on the screen at once. The main
purpose of freely movable graphic objects is in game programming, although
sprites can be used effectively in other applications. For example, you can use
sprites to create a title screen, just as in the DEMO program on your
BeckerB ASIC distribution diskette.
Now for some fundamental information about sprites. Like normal characters
which are defined in groups of pixels, sprites are also made up of pixels. Sprites
have horizontal resolutions of 24 pixels and vertical resolutions of 21 pixels.
A pixel is set (on) or unset (off) according to the bytes setting up the sprite
matrix. Every 24-pixel line takes up three bytes, while the 21 columns use up 63
bytes. You have a total of 63 values to control to make up the sprite's shape.
The best method of drawing a sprite design is with a sprite editor. This lets you
see the sprite magnified, so you can control its shape easily. You'll find a sprite
editor at the end of this chapter in Section 9.6. Once you design the sprite, the
data must be fed into memory. You can put this data in most areas of memory.
2) The memory segment must be in the same 16K memory block as the
screen. This means that you shouldn't place the data in active BASIC
memory or any other area used heavily by the computer and the
program.
MBDESIGN (Section 9.1) puts sprite data into memory - as long as this sprite
data exists in a string. It's fairly easy to convert sprite data to a string; it saves
memory and you can actually store this data in integer arrays or variables. The
sprite editor at the end of the chapter converts data into strings, so they can be
easily read by MBDESIGN.
153
9. Sprite commands BeckerBASIC 64
You must state the location in memory you want the sprite data. This is done
with the command MBBLOCK. This allows you to quickly switch between two
blocks of sprite data.
BL is the number of the desired memory block. You compute this block of
memory with the formula BL = STARTING_ADDRESS/64. Values
for BL range from 0 to 1023. Naturally, not all of these block numbers
are useful; avoid active BASIC memory and zeropage memory.
You must make sure that the sprite data is in the same 16K memory range for
the sprite design as the active screen memory. That is, if you put the sprite
design data in the first memory segment, the active screen should be in the first
memory segment The following table lists practical values for BL (the
corresponding starting memory addresses are in parentheses):
As you can see, available screen memory is very small. The normal text screen
starting at 1024 has enough room for three sprites at a time. Memory segment II
(hi-res) is a little bigger; here you can fit eight sprite matrices.
154
Abacus 9. Sprite commands
NOTE: Sprite blocks 552 and 553 already have the data for the GEOS mouse
pointer and the GEOS text cursor. Don't change these when you use GEOS
commands that requires these two sprites. You can change the appearance of
these sprites, however.
The sprite editor in Section 9.6 places the data into the variable MT$. This data
can immediately be used with MBDESIGN BL, MT$. The matrix can be read
into memory with MT$=MBDATA(BL). Both commands work in conjunction
with the sprite editor. For example, if you include a GOSUB
"MATDEF/S":MBDESIGN 13,MT$ in a program containing the sprite editor,
MT$ defines a sprite matrix and places it in memory block 13.
Format MBCLR BL
BL is the number of the data block. Values for this block can range from 0
to 1023 (see MBDESIGN above).
Example:
Format MBINV BL
BL is the number of the data block. Values for this block can range from 0
to 1023 (see MBDESIGN above).
155
9. Sprite commands BeckerBASIC 64
Example:
MBINV 558 inverts data block 558. The inversion "exchanges" the background
color and the foreground color.
B1,B2 are blocks of memory. Values for Bl and B2 can range from 0 to 1023
(see also MBDESIGN).
MBMOVE copies the data block Bl into block B2. MBCHANGE swaps the
contents of block B1 and block B2.
Examples:
MBMOVE 13,14 copies the contents of data block 13 into block 14.
These three commands allow you to compare sprite data blocks with each other.
B 1,B2 are blocks of memory. Values for B1 and B2 can range from 0 to 1023
(see also MBDESIGN).
156
Abacus 9. Sprite commands
Data blocks Bl and B2 are compared with each other using a logical AND
(MBAND), logical OR (MBOR) or logical EXCLUSIVE OR (MBEOR). The
result of this comparison appears in Bl.
Examples:
MBAND 554,13 compares blocks 554 and 13 for logical AND. The result is in
data block 554.
MBOR 555,556:MBEOR 555,557 compares block 555 and 556 for logical OR,
then compares block 555 with block 557 for an EXCLUSIVE OR.
Logical comparisons let you manipulate data blocks quickly to achieve some
interesting effects. Try these out with a few sprite matrices.
MBBLOCK arranges all eight sprites into one data block. MBGTBLK reads the
current assignments for the individual sprites.
BL is the data block number containing the sprite data. See MBDESIGN
for further information on BL.
Examples:
MBBLOCK 1,5,13 assigns sprite 5 to data block 13. The corresponding data
pointer moves to normal screen memory (starting at location 1024).
157
9. Sprite commands BeckerBASIC 64
Sprites have two modes: The single-color and multicolor modes. Multicolor
mode offers you a total of three colors for your sprites.
Sprite matrices interpret their setups by bits. The three bit combinations are 10,
01 and 11, and when a sprite is assigned multicolor mode, these combinations
have their own colors (the combination 00 equals the background color).
MBMODE lets you set the color mode for each sprite. MBGTMOD returns the
current color mode for every sprite.
NM is the color mode for the desired sprite. If NM=0, the sprite is in single-
color mode; NM=1 means that the sprite is in multicolor mode.
Example:
MBSETCOL sets the desired color of a sprite. MBGTCOL reads the current
color code for individual sprites.
158
Abacus 9. Sprite commands
Example:
MBEXCOL sets the additional colors for the bit combinations 01 and 11 in
multicolor mode. MBGTEXCL reads the current additional colors.
Fl is the color code for bit combination 01. Values for Fl range from 0 to
15 (see PCOLORS, Chapter 3).
F2 is the color code for bit combination 11. Values for F2 range from 0 to
15 (see PCOLORS, Chapter 3).
FN,ZN set the color code (FN) according to the value in ZN. If ZN=1, FN is
the code for the first additional color. If ZN=2, FN is the code for the
second additional color.
Example:
When two or more sprites appear at the same place on the screen, these sprites
must be assigned priorities. Priority states which sprite passes in front of another
when two or more overlap.
159
9. Sprite commands BeckerBASIC 64
Also, it must be established whether a sprite can pass in front of or behind the
other sprite. The first case (sprite/sprite priority) states that sprites with higher
numbers pass in front of sprites with lower numbers. Therefore, if sprites 2 and
7 cross, sprite 2 passes behind sprite 7.
You cannot directly alter these priorities, but you can change them indirectly
using MBBLOCK to switch sprite matrices. This automatically swaps priority.
NR is the number of the desired sprite. Values for NR can range from 1 to
8.
Example:
160
Abacus 9. Sprite commands
MD is the control for sprite size. If MD=0, then the sprite appears in normal
size. When MD=1, the sprite's size doubles. MBXSIZE expands the
sprite horizontally; MBYSIZE expands the sprite vertically.
Example:
MBGTXSZ returns the horizontal sprite size code, MBGTYSZ returns the
vertical sprite size code.
XD XD and YD are the size codes. When XD equals 0, the horizontal size
YD is normal. When YD equals 0, the vertical size is normal. If either size
is expanded, YD or XD return values of 1.
Example:
10 SELECT MBGTYSZ(3)
20 CASE 0:MBYSIZE 3,1:'DOUBLE SIZE'
30 CASE 1:MBYSIZE 3,0:'NORMAL SIZE'
40 ENDSEL
This routine sets the size of sprite 3 according to selection (see Chapter 6 for
information on the SELECT/ENDSEL commands).
161
9. Sprite commands BeckerBASIC 64
like normal screen displays, sprites operate on a coordinate system which lets
you put a sprite anywhere on the screen. The sprite coordinate system is so
accurate that you can put sprites literally anywhere on the visible screen. This
means that you can place a sprite so it's only partially visible (off one edge of
the border).
The coordinate system originates at the upper left corner of the screen. The X-
coordinate (horizontal position) has 512 possible values (0-512); the Y-
coordinate (vertical position) has 256 possible values (0-255). The visible screen
area for sprites lies between coordinates 24/50 (upper left corner), 344/50 (upper
right corner), 344/250 (lower right corner) and 24/250 (lower left corner).
XK is the horizontal coordinate at which the upper left comer of the sprite
should appear - whether that corner is visible or not. Values for XK
range fromO to 511.
YK is the vertical coordinate at which the upper left corner of the sprite
should appear - whether that corner is visible or not. Values for YK
range from 0 to 255.
Examples:
162
Abacus 9. Sprite commands
Examples:
This short program moves a very primitive sprite across the screen. The step
value SP sets the speed of the sprite movement A value of 1 results in a fairly
slow movement, while a value of 5 moves the sprite very quickly across the
screen.
You can fine-tune the speed using a blank FOR/NEXT loop (e.g., FOR 1=1 TO
25:NEXT I). See Chapter 6 for information about loop construction, particularly
FOR/NEXT loops.
163
9. Sprite commands BeckerBASIC 64
A combination of MBSETPOS and loops will be enough for most users, since
this command is very flexible when compared to the normal C64 sprite
commands.
The MBON command turns the corresponding sprite on. The MBGTON
command tells whether a sprite is on or off.
MD is the status number of the desired sprite. If MD=1, the sprite is visible
on the screen. If MD=0, the sprite is inactive.
Example:
164
Abacus 9. Sprite commands
Example:
NA$ is the filename under which the data is loaded/saved. This filename can
be up to 16 characters long.
NOTE: When you save or load several data blocks at once, use the DS AVEM or
DLOADM commands (see Section 5.3) since these commands can handle any
memory size.
Example:
MBDLOAD "SPRBL",553 loads this same sprite data into memory block 553.
165
9. Sprite commands BeckerBASIC 64
The following functions operate in conjunction with the commands used for
checking sprite priority. Collisions occur in the visible screen area between
sprites. These collisions set the appropriate sprite matrix bits to 1.
NOTE: The VIC collision register is designed so that reading the register clears
the register. The functions below store the codes in variable memory for later
reading.
Example:
A=MBCHECKS(7) tells whether sprite 7 collided with one of the other seven
sprites. If so, A=l; otherwise A=0.
Format: MD = MBCHECKALLS
166
Abacus 9. Sprite commands
Sprite number: 12 3 4 5 6 7 8
Value: 1 2 4 8 16 32 64 128
The total value of MD is the sum of the individual values. If, for example,
sprites 2,3 and 5 collide, MD returns 22.
Examples:
This command looks for a collision between a certain sprite and a screen
character or hi-res graphic.
Example:
Similar to sprite/sprite collision reading, except that all sprites are checked for
background collision.
Format: MD = MBCHECKALLG
167
9. Sprite commands BeckerBASIC 64
Sprite number: 12 3 4 5 6 7 8
Value: 1 2 4 8 16 32 64 128
The total value of MD is the sum of the individual values. If, for example,
sprites 2,3 and 5 collide, MD returns 22.
Examples:
MD=32 means that sprite 6 has hit either a character or part of a hi-res graphic.
MD=26 signals that sprites 2,4 and S have collided with the background.
This command clears both VIC registers for sprite/sprite and sprite/background
collisions. Use this command at the beginning of a program so false readings
left from previous programs are not encountered.
Format MBDELCOLL
To start the editor you need the instruction GOTO "MATDEF/S". You can now
use your cursor keys to move around an enlarged 21 x 24 matrix. Press the <F1>
key to set a pixel; press the <F3> key to erase a pixel. Press <F7> to accept the
completed matrix, or <F8> rejects the matrix. Accepted sprites load into the
variable MT$.
168
Abacus 9. Sprite commands
After you define the sprite matrix, the editor allows you to load stored sprite
matrices into memory for editing, or clear the matrix to use new sprites. Load
the matrix into MT$ (using MBDATA, for example) and call the editor with
GOTO "MATDAR/S".
You can change the position of the editor's matrix area by changing the value of
the variable SW. This variable always contains the upper left corner of the
editor.
To move the editor to the center of the screen, for example, you need to set SW
toPEEK(648)*256+88 (see lines 1080,1250 and 1580).
The branches in the editor use labels, so you can change line numbers (with
PRENUMBER, see Section 2.1.1) for merging. The structured design of the
routine allows easy addition of new functions (e.g., mirroring the matrix).
169
9. Sprite commands BeckerBASIC 64
1130 : AW=AW/2
1140 : IF AW=INT(AW) THEN PW=46:ELSE PW=160:ENDIF
1150 : POKE SW+Zl/3*40+Z2*8+7-Z3,PW:AW=INT(AW)
1160 : NEXT Z3
1170 : NEXT Z2
1180 NEXT Zl
1190 GOTO "MATDEFINP/S":'MATRIX INPUT CONTROL'
1200 :
1210 :
1220 "MATDEF/S":'DEFINE MATRIX'
1230 :
1240 'DRAW PATTERN ARRAY'
1250 CLS:SW=PEEK(648)*256
1260 FOR Zl=0 TO 20
1270 : HV=SW+Z1*4O:MYFILL HV,HV+23,46
1280 NEXT Zl
1290 :
1300 "MATDEFINP/S":'INPUT CONTROL'
1310 H=SW-PEEK(648)*256:PZ=INT(H/40)+l:PS=H-(PZ-
1)*40+1:'STARTPOSITION'
1320 ZE=PZ:SP=PS:'CURSOR IN STARTPOSITION'
1330 "MATINPUT/S":CRSET ZE,SP:CRON:WAITKEYA:GET EG$:CROFF
1340 SELECT ASC(EG$):'CURRENT INPUT'
1350 CASE 29:'CURSOR RIGHT'
1360 "CR":IF NOT(SP=PS+23) THEN SP=SP+1
1370 ELSE IF NOT(ZE=PZ+20) THEN SP=PS:ZE=ZE+1:ENDIF
1375 ENDIF
1380 CASE 157:'CURSOR LEFT'
1390 IF NOT(SP=PS) THEN SP=SP-1
1400 ELSE IF NOT(ZE=PZ) THEN SP=PS+23:ZE=ZE-1:ENDIF
1410 ENDIF
1420 CASE 17:'CURSOR DOWN'
1430 IF NOT(ZE=PZ+20) THEN ZE=ZE+1:ENDIF
1440 CASE 145:'CURSOR UP'
1450 IF NOT(ZE=PZ) THEN ZE=ZE-1:ENDIF
1460 CASE 133:'F1=SET PIXEL'
1470 POKE PEEK(648)*256+40*(ZE-1)+SP-1,160:GOTO "CR"
1480 CASE 134:'F3=DELETE PIXEL'
1490 POKE PEEK(648)*256+40*(ZE-1)+SP-1,46:GOTO "CR"
1500 CASE 136:'F7=ACCEPT MATRIX'
1510 GOTO "UEBERNAHME/S"
1520 CASE 140:'F8=CANCEL'
1530 GOTO "ENDE"
1540 ENDSEL
1550 GOTO "MATINPUT/S"
1560 :
1570 "UEBERNAHME/S":'ACCEPT MATRIX'
1580 SW=PEEK(648)*256:AW=0:MT$=""
170
Abacus 9. Sprite commands
171
Abacus 10. Sound commands
In many cases, you'll only need a few commands to program sound effects. You
can take the programs on the next few pages and re-use them in other programs
as procedures (see Chapter 6).
Each section of this chapter examines a different aspect of the sound chip.
Section 10.1 takes you through the basics of making single notes. Section 10.2
shows you how to turn notes on and off. The last two sections demonstrate
synchronization, filters and ring modulation.
NOTE: that the commands and functions listed in this chapter are not accessible
in the Input System. You wil have to switch to the Testing System with
<CTRLxCommodore> to test your program.
The C64 sound chip (the SID chip) has a total of three tone generators, which
produce three voices.
The SDCLEAR command initializes (resets) the sound chip. This command can
be used at the beginning or end of a program to reset all sound registers to their
normal states.
Format: SDCLEAR
173
10. Sound commands BeckerBASIC 64
SDVOLUME (149) (£
The SDVOLUME command sets the volume for all three voices.
Format: SDVOLUME VL
FR is the frequency of the note. Values for FR range from 0 to 3848. You
can include decimals after a decimal point for fine tuning of up to 1/17
Hertz).
Example:
174
Abacus 10. Sound commands
NT$ contains the characters indicating the note you want played, as well as
the desired octave. This sequence reads NOTEOCTAVE. NOTE names
use normal letter names from A to G. Values for OCTAVE range from
0 to 7. The SDNOTE command translates the note and octave into the
equivalent frequency.
10 RESTORE:SDCLEAR:SDVOLUME 15
15 NR=1:'VOICE'
20 SDWAVEON NR,1:SDENVELOPE NR,0,0,15,0:SDVOICEON NR
25 LOOP
30 READ NT$:LPEXITIF NT$="DONE"
35 SDNOTE NR,NT$:FOR 1=1 TO 200:NEXT I
40 ENDLOOP
45 SDVOICEOFF NR:END
50 :
100 DATA C0,C#0,D0,D#0,E0,F0,F#0,G0,G#0,A0,A#0,B0
110 DATA Cl,C#l,Dl,D#l,El,Fl,F#l,Gl,G#l,Al,A#l,Bl
120 DATA C2,C#2,D2,D#2,E2,F2,F#2,G2,G#2,A2,A#2,B2
130 DATA C3,C#3,D3,D#3,E3,F3,F#3,G3,G#3,A3,A#3,B3
140 DATA C4,C#4,D4/D#4,E4,F4,F#4,G4,G#4,A4,A#4,B4
150 DATA C5,C#5,D5,D#5,E5,F5,F#5,65,6#5,A5,A#5,B5
160 DATA C6,C#6,D6,D#6,E6,F6,F#6,66,6#6,A6,A#6,B6
170 DATA C7,C#7,D7,D#7,E7,F7,F#7,67,6#7,A7,A#7
180 DATA DONE
This program plays the complete SID range on voice 1, and contains a complete
list of the notes and octaves accessible to the SID chip (look at the DATA
statements). Please note that the scale stops at the top A#, since that is the
highest note of the SID chip's range.
175
10. Sound commands BeckerBASIC 64
WF is the identifier for the desired waveform. You have four waveforms
available:
1 triangle
2 sawtooth
3 pulse
4 noise
Examples:
This command gives you the power to create a software envelope which controls
the attack (start), decay (dying out), sustain (hold) and release (end) of a note.
A controls the attack (starting) phase of a note. Values for A range from 0
to 15 (maximum volume).
176
Abacus 10. Sound commands
D controls the decay phase of a note, when the sound dies out. Values for
D range from 0 to 15.
S controls the sustain phase of a note (when a note is held). Values for S
range from 0 to 15. S determines its parameter based upon the attack
phase maximum of 15, instead of basing itself on time. If, for example,
S=15, the volume reaches its maximum during the attack phase. A
value of 0 for S means that the tone holds until the decay phase begins.
The increments from S are linear. That is, if S=7, the volume drops to
about half the value of the attack phase.
R controls the release (ending) phase of a note. Values for R range from 0
to 15.
The table below contains the individual values for time (sc=seconds,
ms=milliseconds) and parameters:
0 2 ms 6 ms
1 8 ms 24 ms
2 16 ms 48 ms
3 24 ms 72 ms
4 36 ms 114 ms
5 56 ms 168 ms
6 68 ms 204 ms
7 80 ms 240 ms
8 100 ms 300 ms
9 250 ms 750 ms
10 500 ms 1.5 sc
11 800 ms 2.4 sc
12 1 sc 3 sc
13 3 sc 9 sc
14 5 sc 15 sc
15 8 sc 24 sc
177
10. Sound commands BeckerBASIC 64
These commands let you enable or disable any one of the voices at any time.
VC is the number of the desired voice. Values for VC can range from 1 to
3. The desired voice is audible only if parameters such as volume,
waveform, etc. are set before turning the voice on. The frequency of a
tone can be changed while the voice is on.
When you set up an envelope with the SDENVELOPE command (see above),
SDVOICEON uses that envelope for its sound parameters. The attack executes,
then the decay and sustain phases run. The release phase actually holds the tone
until the SDVOICEOFF command disables the voice. As long as the voice is on,
the tone continues (see below for a concrete example). You can use PAUSE to
sustain notes for certain periods of time (see Chapter 3). SDVOICEON
2:PAUSE4:SDVOICEOFF 2 turns on voice 2 for exactly 4 seconds. You can
fine-tune this timing by using a FOR/NEXT loop instead (e.g., FOR 1=1 TO
100:NEXTI).
Examples:
The example below sounds a standard signal tone that you might use for audible
errors, etc.
1000 NR=1:'VOICE'
1005 SDCLEAR:'INITIALIZATION':SDVOLUME 15:'VOL'
1010 SDFREQUENCY NR,500:'500 HERTZ FREQUENCY'
1015 SDWAVEON NR,1:'TRIANGLE WAVE'
1020 SDENVELOPE NR,0,0,15,0:'ENVELOPE'
1025 SDVOICEON NR:'VOICE ON':PAUSE 3
1030 SDVOICEOFF NR:'VOICE OFF'
1035 END
1100 NR=1:'VOICE'
1105 SDCLEAR:' INITIALIZATION':SDVOLUME 15":'VOL'
1110 SDFREQUENCY NR,3250:'3250 HERTZ FREQUENCY'
1115 SDWAVEON NR,4:'NOISE WAVE'
178
Abacus 10. Sound commands
1200 'FLUTE'
1203 CLS:SCPRINT AT 7,17;"FLUTE "
1205 NR=1:'VOICE'
1210 SDCLEAR:'INITIALIZATION':SDVOLUME 15:'VOL'
1215 SDFREQUENCY NR,600:'600 HERTZ FREQUENCY'
1220 SDWAVEON NR,1:'TRIANGLE WAVE'
1225 SDENVELOPE NR,8,5,15,8:'ENVELOPE'
1226 SCPRINT AT 10,10; "PLEASE PRESS A KEY.11
1230 SDVOICEON NR:'VOICE ON':WAITKEYA:'WAIT FOR KEYPRESS'
1235 SDVOICEOFF NR:'VOICE OFF'
1300 'OBOE'
1303 CLS:SCPRINT AT 7,17;"OBOE M
1305 NR=1:'VOICE'
1310 SDCLEAR:'INITIALIZATION':SDVOLUME 15:'VOL'
1315 SDFREQUENCY NR,450:'450 HERTZ FREQUENCY'
1320 SDWAVEON NR,3,6.11:'PULSE WAVE, WIDTH 6.11%'
1325 SDENVELOPE NR,4,9,15,8:'ENVELOPE'
1326 SCPRINT AT 10,7;"PLEASE PRESS A KEY TO END."
1330 SDVOICEON NR:'VOICE ON':WAITKEYA:'WAIT FOR KEYPRESS'
1335 SDVOICEOFF NR:'VOICE OFF'
1340 END
10.3 Filters
The sound chip can alter voice qualities using a filter. This filter is like the tone
control on your stereo system. One common filter affects all three voices, but
you can state which voices are filtered and which voices come through
"straight."
This command sets up the filter parameters. The numbers below set the
operating mode and resonance of the filter.
179
10. Sound commands BeckerBASIC 64
FA sets the filter operating mode. FA=1 sets up a high-pass filter, affecting
only the frequencies above the frequency FQ. FA=2 sets up a low-pass
filter, which affects frequencies below the frequency FQ. FA=3
activates a bandpass filter, which affects frequencies in the area of FQ.
FA=4 enables parallel switching of high-pass and low-pass filters,
called a notchfilter.
RS sets the resonance of the filter. Values for RS range from 0 to 15. This
parameter adds richness to the frequencies in the area of FQ. RS=0
causes minimal resonance, while RS=15 results in maximum
resonance.
VC is the number of the tone generator. Values for VC can range from 1 to
4 (!). Voice 4 represents the audio input
Like all other SID parameters, you can turn filtering on or off at any time.
Examples:
2000 NR=1:'VOICE'
2005 SDCLEAR:'INITIALIZATION'rSDVOLUME 15:'VOL'
2010 SDFREQUENCY NR,500:'500 HERTZ FREQUENCY'
2015 SDWAVEON NR,4:'NOISE WAVE'
180
Abacus 10. Sound commands
2100 NR=1:'VOICE'
2105 SDCLEAR:'INITIALIZATION'rSDVOLUME 15:'VOL'
2110 SDFREQUENCY NR,450:'450 HERTZ FREQUENCY'
2115 SDWAVEON NR,2:'SAWTOOTH WAVE'
2120 SDENVELOPE NR,0,9,0,0:'ENVELOPE'
2125 'FILTER:NOTCH, 2000 HZ FREQUENCY, RESONANCE 15'
2130 SDFILTER 4,2000,15:SDVCFTON NR:'VOICE INTO FILTER'
2135 SDVOICEON NR:PAUSE 1
2140 SDVOICEOFF NR:SDVCFTOFF NR
2145 END
VC is the number of the voice set for synchronization. The voice used for
synchronizing VC is hardware-set. VC=1 means that voice 1 is
synchronized with voice 3; VC=2 synchronizes voice 1 with voice 2;
and VC=3 synchronizes voice 2 with voice 3.
181
10. Sound commands BeckerBASIC 64
VC is the number of the voice to be combined with a second voice for ring
modulation. VC=1 creates ring modulation between voices 1 and 3;
VC=2 creates ring modulation between voices 2 and 1; VC=3 creates
ring modulation between voices 3 and 2.
Example:
NOTE: Waveforms must be set to triangle wave before you can get an audible
ring modulation.
Synchronized or ring modulated voices are normally audible. If you use voice 3,
you can make it "inaudible" with SDVOICE3OFF. (Because of hardware
design, this option exists only for the third voice).
182
Abacus 10. Sound commands
Examples:
Both examples make siren noises using BeckerBASIC SID chip commands in
different ways.
3000 'SYNCHRONIZATION'
3005 N1=1:N2=3:'VOICES'
3010 SDCLEARrSDVOLUME 15
3015 SDENVELOPE Nl,0,0,15,0:'ENVELOPE'
3020 SDWAVEON Nl,3,40:'PULSE WAVE':SDSYNCHRON Nl
3025 SDWAVEON N2,2:'SAWTOOTH WAVE':SDVOICE3OFF
3030 SDFREQUENCY N2,150:'150 HZ FREQUENCY'
3035 SDVOICEON Nl:SDVOICEON N2
3040 FOR 1=100 TO 2000 STEP 3
3045 SDFREQUENCY Nl,I
3050 NEXT I
3055 SDCLEAR:END
183
Abacus Appendix A
This book allows space after the original name for your own defined command
names. This table is intended to help you quickly find information about
BeckerBASIC commands.
The far right column of the table is the page reference for each command or
function. When you want to find a command, the procedure is as follows: Find
the command number on the screen using COMNUM, then look up the
command number in the table.
185
Appendix A BeckerBASIC 64
Commands
# 004 LIST 20
* 006 TRON 35
* 007 PAUSE 21
* 008 DESKTOP 22
# 009 PAUTO 23
# 010 PRENUMBER 24
# Oil POLD 26
# 012 PMERGE 25
# 013 PDEL 25
♦ 014 PBCEND 26
# 015 PMEM 26
# 016 PDFKEY 27
# 017 PKEY 28
# 018 PCOLORS 49
186
Abacus Appendix A
# 019 PHELP 13
# 020 NEWCOMTAB 12
# 021 OLDCOMTAB 12
# 022 RENCOM 15
# 023 DSCOMTAB 17
# 024 DLCOMTAB 17
* 025 ONERRORGO 30
♦ 026 ONERROROFF 30
* 027 RESUMECUR 30
* 028 RESUMENEXT 31
* 029 RESUME 31
* 030 ERRSHOWON 29
* 031 ERRSHOWOFF 29
* 032 TRACE 34
♦ 033 KEYREPEATON 37
* 034 KEYREPEATOFF 37
* 035 STOPON 38
* 036 STOPOF 38
* 037 WAITKEYA 38
187
BeckerBASIC 64
Appendix A
* 038 WATTKEYS 39
* 039 KGETV 39
♦ 040 KBGETV 40
* 041 ONKEYGO 42
* 042 RETKEY 43
* 043 SGETV 44
♦ 044 SGETM 44
* 045 DGETV 80
* 046 DGETM 80
* 047 SCPRINT 46
* 048 AT 46
* 049 RVSON 47
* 050 RVSOFF 47
BORDER 49
* 051
GROUND 50
♦ 052
* 053 CLS 50
* 054 SCRON 50
SCROFF 50
* 055
SCRDSAVE 51
* 056
188
Abacus Appendix A
* 057 SCRDLOAD 51
* 058 CRHOME 51
* 059 CRSET 51
* 060 CRCOL 52
* 061 CRON 52
* 062 CRREPEATON 52
* 063 CRREPEATOFF 52
* 064 CRFREQ 52
* 065 TRANSFER 55
* 066 DOKE 58
* 067 MYFILL 56
* 068 MGETV 60
* 069 ASCBSCW 57
* 070 BSCASCW 57
* 071 SWAP 21
♦ 072 DIR 64
* 073 DSTATUS 65
* 074 DSENDCOM 65
* 075 DHEADER 67
189
Appendix A BeckerBASIC 64
* 076 DDSflT 67
* 077 DRESET 68
* 078 DRENAME 66
♦ 079 DSCRATCH 66
* 080 DOPEN 78
* 081 DCLOSE 82
* 082 DSAVEB 70
* 083 DSAVEM 72
* 084 DCSAVEB 70
* 085 DCSAVEM 72
* 086 DVERIFYB 72
* 087 DVERIFYM 73
* 088 DLOADB 74
* 089 DLOADM 74
* 090 DLOADAM 74
* 091 DRLOADB 74
* 092 DOVERLAYK 75
* 093 DOVERLAYW 75
* 094 DSQOPEN 82
190
Abacus Appendix A
* 095 DSOCONCAT 84
* 096 DRLOPEN 84
* 097 DRLRECORD 86
* 098 DUSOPEN 88
* 099 DDAOPEN 89
* 100 DDAPOINT 92
* 101 DDAREADBL 91
* 102 DDAWRITEBL 92
* 103 DDABLALLOC 93
* 104 DDABLFREE 93
* 105 DDABLEXEC 98
♦ 106 DMYPOKE 96
* 107 DMYWRTTEM 97
* 108 DMYWRTTEV 97
* 109 DMYEXEC 98
* 110 IF 105
191
Appendix A BeckerBASIC 64
* 115 DO 110
* 132 LDEL 77
192
Abacus Appendix A
* 133 LETTERON 47
♦ 134 LETTEROFF 47
* 135 LOCKON 47
* 136 LOCKOFF 47
193
Appendix A BeckerBASIC 64
SDRINGMODOFF 182
163
SDVOICE3ON 182
164
SDVOICE3OFF 182
165
ONKEYOFF 43
* 166
TROFF 35
* 167
CROFF 52
♦ 168
MBPRIOR 160
* 169
PRLIST 20
* 170
194
Appendix A
Abacus
♦ 171 PRPRINT 48
* 172 PRCOM 48
* 173 DB 19
* 174 ON 103
RESET 22
* 175
* 176 KEYDEL 38
NEW 22
* 177
WAITST 41
* 178
* 179 PFKEYON 28
* 180 PFKEYOFF 28
* 181 VGETM 60
195
Appendix A BeckerBASIC 64
♦ 194 DADRCHANGE 68
* 195 DKDEVNB 68
* 196 DPGOPEN 88
* 197 DSAVEL 71
* 198 DCSAVEL 71
* 199 DVERIFYAM 73
* 200 DRLCLOSE 85
* 201 DMYREADM 96
♦ 202 DMYREADV 95
PDUMP 27
♦ 203
POPREP 113
* 204
POPWHL 111
* 205
POPPROC 120
* 206
POPLP 114
* 207
POPIF 107
♦ 208
196
Abacus Appendix A
# 209 TABNAME 18
197
Appendix A BeckerBASIC64
198
Abacus Appendix A
Functions
# 231 COMNUM 14
* 232 STTEST 41
* 233 CRPOSL 51
* 234 CRPOSC 51
♦ 235 DEEK 58
* 236 TEEK 59
* 237 VARADR 61
* 238 EOF 81
* 239 DMYPEEK 95
* 244 DF 19
* 245 CLGROUND 50
* 246 CLBORDER 49
♦ 247 CLCURSOR 52
199
Appendix A BeckerBASIC 64
* 249 GTBCEND 26
# 250 COMTAB 13
* 251 COMNAME 15
* 252 FILENUM 80
* 253 DDEVADR 68
MBGTON 164
* 261
LEVELLP 114
* 267
200
Abacus Appendix A
201
Abacus Appendix B
The following table lists the commands and functions alphabetically. The
command or function name is followed by its number. C and F indicate whether
if it a command or function. The last number on the line is the page number
where the command or function is located.
AT (048) (C) 46
CLS (053) (Q 50
203
Appendix B BeckerBASIC 64
CRFREQ (064) (Q 52
CROFF (168) (Q 52
CRREPEATON (062) (Q 52
DB (173) (C) 19
DDABLALLOC (103) (Q 93
DDABLEXEC (105) (Q 98
204
Abacus Appendix B
DDAPOINT (100) (Q 92
DDAWRITEBL (102) (Q 92
DF (244) (F) 19
DGETV (045) (Q 80
DINIT (076) (Q 67
DIR (072) (Q 64
205
Appendix B BeckerBASIC 64
DMYREADM (201) (Q 96
DOKE (066) (Q 58
DRLCLOSE (200) (Q 85
206
Abacus Appendix B
DSCRATCH (079) (Q 66
DSQCONCAT (095) (Q 84
DSQOPEN (094) (Q 82
DSTATUS (073) (O 65
DVERIFYAM (199) (Q 73
DVERIFYM (087) (O 73
207
Appendix B BeckerBASIC 64
ERRSHOWOFF (031) (Q 29
GROUND (052) (Q 50
208
Abacus Appendix B
IF (110) (Q 105
KBGETV (040) (Q 40
209
Appendix B BeckerBASIC 64
LETTEROFF (134) (Q 47
LIST (004) (O 20
LOCKON (135) (Q 47
210
Abacus Appendix B
211
Appendix B BeckerBASIC 64
MGETV (068) (Q 60
MYFILL (067) (Q 56
NEWCOMTAB (020) (Q 12
212
Abacus Appendix B
ON (174) (Q 103
ONERROROFF (026) (Q 30
ONKEYOFF (166) (O 43
PAUTO (009) (Q 23
PFKEYON (179) (Q 28
PKEY (017) (Q 28
213
Appendix B BeckerBASIC 64
PMEM (015) (Q 26
EMERGE (012) (Q 25
POLD (Oil) (Q 26
PRCOM (172) (Q 48
PRENUMBER (010) (Q 24
PRPRINt (171) (Q 48
RENCOM (022) (Q 15
RESET (175) (Q 22
214
Abacus Appendix B
RVSOFF (050) (Q 47
215
Appendix B BeckerBASIC 64
STOPOFF (036) (Q 38
216
Abacus Appendix B
TRACE (032) (Q 34
TRON (006) (Q 35
217
Abacus Appendix C
This table contains the complete set of BeckerBASIC error messages. The error
messages coincide with the ONERRORGO command (see Section 2.2).
08 MISSING FILENAME
11 SYNTAX
13 OUT OF DATA
14 ILLEGAL QUANTITY
15 OVERFLOW
• 16 OUT OF MEMORY
17 UNDEF'D STATEMENT
18 BAD SUBSCRIPT
19 REDIM'D ARRAY
20 DIVISION BY ZERO
21 ILLEGAL DIRECT
22 TYPE MISMATCH
26 CAN'T CONTINUE
27 UNDEF'D FUNCTION
28 VERIFY
29 LOAD
30 BREAK
31 REMARK
219
Appendix C BeckerBASIC 64
220
Abacus Appendix D
This memory map will help you when you want to make your own changes to
BeckerBASIC or GEOS. In conjunction with this, you should refer to the
BeckerBASIC memory access commands (see Chapter 4). This allows access to
ROM lying in RAM, where the gross majority of GEOS routines lie.
You can find a C64 operating system memory map, as well as the BASIC
interpreter layout, in your C64 Programmer's Reference Guide and Anatomy of
the C64 from Abacus.
221
Appendix D BeckerBASIC 64
222
Abacus Appendix E
Let's assume that you want to save a list of names on your disk. For our sample
program we'll need a drop-down menu.
Let's run the DDM.C.S program on the disk. First it will want to know where
the table needed by the menu will be stored in memory. Enter 24200. Next it
will ask for how many item will appear on the menu bar. Enter 2. Now, will it
be a horizontal menu or vertical? Enter 0 for horizontal. Next enter 0 then 0 for
the upper left corner of the menu. Enter 7 9 and 13 for the lower right corner.
When creating menus, it is best to enter height in multiples of 14, starting with
0. such as 0,13,27,41 and so on.
Now you need to enter the text to appear on the menu. Enter FILE. And enter
DATA.
Next, we'll create the sub-menus. It now asks if a sub-menu should be created
for FILE. Answer Y. Now enter 2 for the number of items. Enter 1 for vertical
menu. Enter 0,13, 59, and 41 as the location coordinates. Now enter the text
for items on the sub-menu. Type CREATE /LOAD and QUIT. To create the
second sub-menu, enter the following text at the appropriate prompts: Y (for yes,
you want a sub-menu for data), 2 (number of items), 1 (vertical), 20,13, 64,
41 (coordinates), ENTER, READ (names of the sub-menus).
Once you have created your menu, the program will wait for a keypress then
display it. Click on a sub-menu item to continue. After you click, it will ask if
the menu is acceptable. If you answer Y, it will ask for a name to save it under.
If you answer N, you will be able to go through and reenter your data. Answer Y
now to save the menu. Enter the name ADDRMENU.
You have now just created the table for your menu. To use it in our program, we
will load it into memory with DLOADM"ADDRMENU".
223
Appendix £ BeckerBASIC 64
Now let's create a dialogue box. Load and run D. c. S off the BeckerBASIC
disk. Now enter 828 for the address where the table will be loaded into
memory. Enter N so you can create your own size of dialogue box. Enter the
coordinates 60 and 50 for the upper-left corner. Now enter 260 and 150 for
the lower-right corner. Next enter 0 for no shadow.
To add a button to the dialogue box, enter the number for the desired button. For
our example we only want the CANCEL button so enter 2. Now the program
wants to know how far over the button should be placed. Enter the number in
bytes (divide actual pixels by 8, i.e., you want the button over 16 pixels so you
would enter 2). Enter 2 now. Enter 70 for the number of pixels down from the
top. You have just added a CANCEL button to the dialogue box.
To add text, enter 11. Do this now. Next enter the coordinates of were the text
should be placed. Enter 16 and 14. Enter the text Please enter
filename. at the prompt Now add an input prompt so the use can enter text
using the dialogue box. Type 13 for an input prompt Enter the coordinates of
the prompt as 16 and 35. Next enter the number of characters that will be
allowed to be entered. Type 14.
Our dialogue box is now complete. You can enter 33 to see if the data for the
buttons was entered correctly. Enter 0 and the dialogue box will be displayed.
Before you display a dialogue box, make sure you added a button or you will
not be able to return from the dialogue box. Click on the button to exit. If
everything is okay, then enter Y to save the table. Enter ADDRDIAL as the name
of the table.
With both the drop-down menu and the dialogue box tables saved, we are ready
to enter our program. This program has a little of nearly everything. The
following explains the program ADDRSAMPLE (on the BeckerBASIC disk)
section by section. It will show some of BeckerBASICs highlights in action.
The first section is labeled "SETUP". The first line sets up the error routine used
for editing and debugging the program as it was written. When an error is
encountered, it does the following: jumps to the line number after the
ONERRORGO statement, places the error number in EN, places the error text in
EN$, and places in EL the line number where the error occurred.
224
Abacus Appendix E
The next line sets the end of memory for your BeckerBASIC program. Since we
want to protect our menu starting at location 24200, we set the end of BASIC to
24199. CLR resets variables and pointers.
GEOS is turned on next The program sets up the arrays for the screen text and
the address data. Then it loads the menu and dialogue tables into memory. Next
it defines the strings that are to be placed on the screen. Finally it jumps to the
routine that creates the screen.
The section labeled "MENU" first displays the drop-down menu. Then it defines
where it should jump to when a menu item is selected. The labels that it jumps
to correspond to the names of the items on the menu.
"DRAWSCREEN" first clears the screen. It then draws a box filled with the
background pattern. Now it draws a smaller black box. Next it draws a black
box for a shadow, then a white box overlapping the black box. A frame is then
added.
The next three lines draws a wide, narrow box that will be used to display
information.
The last group of lines prints the screen title in bold, italic and reversed type and
the field descriptions in bold type.
"CREATE/LOAD" uses a dialogue box to enter the name of the data file. First it
assigns N$ the default filename. Then N$ is stored into memory at 880. Next it's
converted from ASCII to GEOS text. The dialogue box is called with the
following line and the text inputted is to be placed at memory location 880.
Since we placed the contents of N$ there, it will be displayed at the input
prompt The next line checks to see if the CANCEL button was selected. If it
was the program flow returns to "MENU". The entered text is converted from
GEOS back to ASCII. N$ is filled with the contents of 880 through 893. The
REPEAT UNTIL loop looks for the end of the text in N$ so the extra characters
can be stripped out If the first character in N$ is CHR$(0) then there is no text
and it returns back to "MENU". Next N$ is stripped of the extra characters. A
sequential file is then created under the name N$. The program then checks to
see if a file under that name exists. If it does exist than it is checked to see if
data can be appended to it If it cannot append data then an error occurs and is
displayed in the info box we created on die screen. Before it jumps back to the
"MENU" loop, a flag is set to indicate that a file exists to be used.
225
Appendix E BeckerBASIC 64
The "ENTER" routine permits data to be added to the sequential file. First it
checks to see of a file has been cleared. If it was not cleared, it prints "NO
FILE" in the info box. If it has, it continues and opens the file. The HRBOX
command clears what data might be on the screen. The FOR-NEXT loop sets
the entry variables to blanks and allows up to 15 characters to be entered. The
next FOR-NEXT loop allows the user to enter the data and does the necessary
conversions. Also it strips the entries of any extra text Next it asks if the entry
was okay. If it was not, then it allows you to make corrections on the text
already entered. Once the text entered is satisfactory, the program then saves the
data to disk. It then asks you if you want to enter more data.
The next section is "READ". This routine checks to see if the file has been
okayed then opens the file. Next it INPUTs the data in the D$ array and displays
each record until the EOF.
'ERRORS' uses the "INFOBOX" routine to display any errors that might occur.
Once the program is thoroughly debugged, you may want to take this section out
along with the ONERRORGO command.
If you want to RUN this program from the GEOS deskTop, first replace the
END statement in the last line with DESKTOP. When you QUIT the program, it
will return to the deskTop.
The next thing you will need to do is to run the CONVERTER program. This
program converts your program so that it is accessible from the deskTop. You
can add a creation date and design your own icon. More information on the
CONVERTER program is in Section 1.1.4.
226
Abacus Appendix F
Abacus grants to you a royalty-free right to copy and distribute the "Run-Only
System" of BeckerBASIC provided that you:
(b) leave the Run-Only System unchanged and named "SYSTEM 3"
upon the disk
227
Appendix G BeckerBASIC 64
Section 1.4 (page 19) described the DB and DF commands which allow the
machine language programmer to add a command or function to BeckerBASIC.
Here are two BeckerBASIC programs demonstrating each of these function
from BASIC.
DB:
The above sequence, which prints the A character on the screen when the DB in
line 40 executes, is the equivalent of the marine language program:
LDA #$41
JSR $FFD2
RTS
DF:
The above program, which returns a value of 1 when the SCPRINT DF executes
in line 40, is the equivalent of the machine language program:
LDY#$01
JMP$B3A2
228
Abacus Index
background color 50
BAM (Block Availability Map) 67
BASIC 2.0 commands 19
BASIC extension 1
BASIC icon 4
BeckerBASIC
distribution 9
exit 3
interpreters 1
program errors 2
starting 3
structure 1
system files 4
bold 139
BORDER 49
border color 49
branch structures 105
BSCASCW 57
buttons 135
229
Index BeckerBASIC 64
command table 12
loading 17
saving 17
commands 1, 5
comments 102
Commodore key 41
COMNAME 15
COMNUM 14
COMTAB 13
CONVERTER 1
CONVERTER program 4
copy sprite block 156
CRCOL 52
CRFREQ 52
CRHOME 51
CROFF 52
CRON 52
CRPOSC 51
CRPOSL 51
CRREPEATOFF 52
CRREPEATON 52
CRSET 51
CTRL key 41
CTRL/Commodore keys 2
cursor
color 52
control 51
position 51
DADRCHANGE 68
DATA 153
data input 37
data output 46
DB 19
DOLOSE 78,82
DCSAVEB 70
DCSAVEL 71
DCSAVEM 72
DDABLALLOC 93
DDABLEXEC 98
230
Abacus Index
DDABLFREE 93
DDAOPEN 89
DDAPOINT 92
DDAREADBL 91
DDAWRITEBL 92
DDEVADR 68
DEEK 58
delete files 66
DELPROC 122
DEMO program 4,11
deskTop 1,6,22
DF 19
DGETM 78,80
DGETV 78,80
DHEADER 63,67
DIALCODE 135
DIALOGBOX 135
Dialogue Box Construction Set 4
operation 136
dialogue boxes 3,129,135
DINIT 67
DIR 64
direct diskette access 89
disabling hi-res screen 144
disabling sprites 164
disabling voices 176
disk
addresses 68
commands 63
memory access 95
operating system (DOS) 95
status (DSTATUS) 65
directory 64
DKDEVNB 68
DLCOMTAB 17
DLOADAM 74
DLOADB 5,74
DLOADM 74,151
DLOADPROC 121
DMYEXEC 98
231
Index BeckerBASIC64
DMYPEEK 95
DMYPOKE 96
DMYREADM 96
DMYREADV 95
DMYWRTTEM 97
DMYWRTTEV 97
DO 101,110
DOKE 58
DOPEN 78
DOVERLAYK 75
DOVERLAYW 75
DPGOPEN 88
drawing in hi-res
filled rectangle 148
frame 147
horizontal line 146
line 146
vertical line 146
DRENAME 64,66
DRESET 68
DRLCLOSE 85
DRLOADB 5,74
DRLOPEN 84
DRLRECORD 86
Drop-Down Menu Construction Set 4,132
operation 134
drop-down menus 3,129,132
DSAVEB 5,70
DSAVEL 71
DSAVEM 72,151
DSAVEPROC 121
DSCOMTAB 17
DSCRATCH 66
DSENDCOM 63,65
DSQCONCAT 84
DSQOPEN 82
DSTATUS 63,65
DUSOPEN 88
DVERIFYAM 73
232
Abacus Index
DVERIFYB 72
DVERIFYM 73
editing 2
ELSE 105
enabling hi-res screen 144
enabling voices 176
ENDDO 101,110
ENDIF 105
ENDLOOP 101,113
ENDSEL 101,107
EOF 81
Error
display 2,29
handling 2,29
messages 6,7,8,16,90
ERRSHOWOFF 8,29
ERRSHOWON 2, 6,7,8,29
executing machine language programs 98
FDLENUM 80
Fill memory range 56
Filters 179
FOR 101
format diskette 63
format diskettes 67
function keys
assignment 27
layout 27
functions 1
233
Index BeckerBASIC 64
GOTO 19,103
GROUND 50
GTBCEND 26
hi-res 5
background color 131,144
commands 5,129
graphic control 130
graphic string 149
graphics 7,143
input 141
mode 129
plot 145
point color 131,144
screen clear 130
text display 138
text entry 138
HRBOX 148
HRDEL 130,144
HRDLOAD 151
HRDSAVE 151
HRFRAME 147
HRGDCOL 131,144
HRGET 138,141
HRGTCOL 131,144
HRGTON 144
HRHLINE 146
HRINV 149
HRLINE 146
HROFF 130,144
HRON 130,144
HRPLOT 145
HRPRINT 138
HRPTCOL 131,144
HRSTRING 149
HRTESTP 145
HRVLINE 146
icon editor 10
icons 1
234
Abacus Index
IF 19,101,105
initializing graphics 143
INPUT 138
INPUT* 78
Input-System 1
loading 6
interpreters 5
invert hi-res graphic display 149
invert sprite data block 1SS
italics 139
KBGETV 40
keyboard input 37
KEYDEL 38
KEYREPEATOFF 37
KEYREPEATON 37
KGETV 39
labels 103
language extensions iv
LDEL 77
LETTEROFF 47
LETTERON 47
LEVELIF 106
LEVELLP 114
LEVELPROC 120
LEVELREP 113
LEVELWHL 111
LIST 19,20
loading
command tables 17
hi-res graphics 1S1
programs 5
LOCKOFF 47
LOCKON 47
logical files 77
LOOP 101,113
loop structures 110
LOOP/LPEXTTIF/ENDLOOP 101
LPEXTITF 101,113
235
Index BeckcrBASIC64
MBALLOFF 164
MBAND 156
MBBLOCK 154,157
MBCHANGE 156
MBCHECKALLG 167
MBCHECKALLS 166
MBCHECKG 167
MBCHECKS 166
MBCLR 155
MBDATA 154
MBDELCOLL 168
MBDESIGN 153,154
MBDLOAD 165
MBDSAVE 165
MBEOR 156
MBEXCOL 159
MBGTBLK 157
MBGTCOL 158
MBGTEXCL 159
MBGTMOD 158
MBGTON 164
MBGTPR 160
MBGTXSZ 161
MBGTYSZ 161
MBINV 155
MBMODE 158
MBMOVE 156
MBOFF 164
MBON 164
MBOR 156
MBPRIOR 160
MBRXPOS 163
MBRYPOS 163
MBSETCOL 158
MBSETPOS 162
MBXSEE 160
MBYSEE 160
memory
access 55,57
exchange 60
236
Abacus Index
memory
fill 56
reading contents 60
transfer 55
MENUCODE 133
MGETV 55,60
multicolor bit combinations 159
MYHLL 55,56
OLDCOMTAB 12
ON 19,103
ONERRORGO 6,7,8,30
ONERROROFF 30
ONKEYGO 42
ONKEYOFF 43
opening
direct access files 89
files 78
program files 88
user files 88
OTHER 107
outlined text 139
PAUSE 21
PAUTO 23
PBCEND 26
PCOLORS 49
PDEL 25
PDFKEY 27
PDMENU 132
PDUMP 5,27
PFKEYOFF 28
PFKEYON 28
PHELP 13
Piracy 9
237
Index BeckerBASIC 64
PKEY 28
PMEM 26
PMERGE 25
POKE 153
POLD 26
POPIF 107
POPLP 114
POPPROC 120
POPREP 113
POPWHL 111
PRCOM 48
PRENUMBER 5,24
PRINT* 78
printer codes 48
printer output 48
PRLIST 20
PROCEDURE 115
procedures 114
PROCEND 115
program distribution 3
program files 64
programmer's tools 2
proportional type 132,138
PRPRINT 48
RAM 60
reading
disk bytes 95
memory 58
sprite data 154
track and sector 91
relative file commands 84
relative files 64
REM 102
renaming disk files 64, 66
renaming commands 12,16
RENCOM 15
REPEAT 101,111
REPEAT/UNTIL 101
RESET 22
238
Abacus Index
saving
command tables 17
hi-res graphics 151
programs 5,70
SAVE with replace 70
SCPRINT 46
SCRDLOAD 51
SCRDSAVE 51
screen input 43
screen output 46
SCROFF 50
SCRON 50
SDCLEAR 173
SDENVELOPE 176
SDFDLTER 179
SDFREQUENCY 174
SDNOTE 174
SDRINGMODOFF 182
SDRINGMODON 182
SDSYNCHROFF 181
SDSYNCHRON 181
SDVCFTOFF 180
SDVCFTON 180
SDVOICE3OFF 182
SDVOICE3ON 182
239
Index BeckerBASIC 64
SDVOICEOFF 178
SDVOICEON 178
SDVOLUME 174
SDWAVEOFF 175
SDWAVEON 175
SELECT 101,107
SELECT/ENDSEL 101
sending disk commands 65
sequential file commands 82
sequential files 64
SGETM 44
SGETV 44
SHIFT key 41
software envelope 176
sound commands 5,173
sound generation 173
SPRITE-EDIT program 4,168
sprite 153
collisions 166
commands 153
coordinates 162
data block comparison 156
disabling 164
editor 153,168
enabling 164
expansion 160
loading data blocks 165
moving 162
positioning 162
priority 160
saving data blocks 165
swapping blocks 156
STOP key 38
STOPOFF 38
STOPON 38
structured programming 101
STTEST 41
sub-menus *34
SWAP 21
swap sprite block 156
240
Abacus Index
Synchronization 181
TABNAME 18
TEEK 59
Testing-System 1
function keys 2
menu 2
text color 52
text conversion 140
THEN 19,105
TRACE 6,29,34
TRANSFER 55
TROFF 8,35
TRON 8,35
typestyles
bold 139
italics 139
outline , 139
reversed 139
underlining 139
validate 63
VARADR 55,61
variable address 61
verifying programs 70
VGETM 55,60
VLIR files 1
voices
disabling 176
enabling 176
WATTKEYA 38
WAITKEYS 39
WATTST 41
WHILE 101,110
WHILE/DO/ENDDO 101
wildcards 64
241
Index BeckerBASIC 64
242
Selected Abacus 11H Products for Commodore computer
SpeedTerm
Terminal Software
for both the C-128 and C-64
SpeedTerm-128
• Commodore 128
• 1541/MSD or 1571 disk drive
• 40- or 80-column monitor
PowerPlan-64
Spreadsheet and Graphics package
fortheC-64
Abacus Inc.
Suggested retail price: 5370 52nd Street SE
C-64 version $39.95 Grand Rapids, Ml 49508
Phone (616) 698-0330
Commodore W, ConmxaJore 1
Selected Abacus HI Products for Commodore .computers
BASIC
Complete BASIC compilers
and development systems Make your BASIC programs
fortheC-64orC-128
COBOL
for the C-64 or the C-128
COBOL-128:
Commodore 128 with 1541 or 1571 disk drive
(supports 40- or 80-column monitor)
Super C
C language development package
fortheC-64orC-128
gets(buffer,40,STDIO);
putc(CR,STDIO);
The fast compiler (maximum of 53K object code) creates
files which the linker turns into a ready-to-run machine )while(strcmp(buffer,"read\n");
language program. Super Cs linker combines up to
seven separately compiled modules into one executable putsC\nnames:n, STDIO);
program. gets(buffer,40,STDIO);
putc(CR,STDIO);
readset(buffer,charrami);
The I/O library includes many of the standard functions,
including print £ and fprintf, with libraries for
math functions and graphics. The runtime library may
be called from machine language or included as a BASIC
lookalike program.
Super C Features:
Abacus Inc.
Suggested retail price:
5370 52nd Street SE
C-64 version $59.95 Grand Rapids, Ml 49508
C-128 version $59.95 Phone (616) 698-0330
Selected AbacusHH! Products for Commodore computers
Super Pascal
Pascal language development package
fortheC-64orC-128
Super Pascal is a complete program development system
for the Commodore 64 or Commodore 128. Super
Pascal is so capable that hundreds of schools are using it
to teach Pascal programming to their students. But
Pascal is more than just a learning language. Super
Pascal features language extensions for serious system
level programming.
Super Pascal 128 contains all the features found in our IF NO_DEF THEN STOP (TITLE_ND);
IF FOR_GET THEN TEST_FOR_SAVE
popular C-64 version while taking advantage of the C-
END
128's 40/80 column modes; it's high-resolution graphics
ELSE
package runs in 80. columns and makes some truly BEGIN
remarkable artwork possible. IF NOT (INPUT* IN LETTER) THEN
STOP (ILL TITLE);
READ (TITLE);
Another "extra" qf Super Pascal 128 is its RAM disk,
IF FOR_GET THEN TEST_FOR_SAVE;
which allows for ultra-fast loading/compiling, and
NOT_DEF:-FALSE;COMMON *:=TITLE
supports 1571 Burst mode. END
END;
A detailed introduction is laid out for the novice-beginning with how to load the
GEOS operating system...how to create a backup...how to alter the preference
manager...how to format disks...learn geoWrite and geoPalnt in detail...use geoPaint
for designing floor plans or drawing electronic diagrams. Easy-to-understand
examples, diagrams and glossary are included to enflghten the beginner. To receive your copy of OEOS Inslda and
Out and/or QEOS Tricks 4 Tips, call now
7776 advanced user will find more detailed Information on GEOS's internals and for the name of the dealer or bookstore near
useful tricks and tips. Add a constant display dock-includes assembly and BASIC you. Or order directly using your Visa, MC or
listing...complete listing of our FlteMaster utility (converts your programs to GEOS Amex card. Add $4.00 per order for shipping
format with an icon editor) with a line by line explanation...create a single-step and handling. Foreign orders add $10.00 per
simulator for observing memory and the various system registers...learn about book. Call or write today for your free catalog.
windows and how to use them to your advantage...understand GEOS file structure. Dealer inquires welcome—2000 nationwide.
If you're just getting started with GEOS or getting to the point of wanting to add your Order both today I
own applications, then QEOS Inalda and Out will help you on your way. $19.95
Abacus!
m ■ You Cm Count On is
Continuing the tradition established by our famous C-64 reference library, GEOS
Tricks « Tips Is a collection of helpful techniques for anyone who uses GEOS with
their Commodore. It's easy to understand without talking down to the reader, and 5370 52nd Street SE
detailed in the applications of the routines. Includes a font editor to create up to 64 Grand Rapids, Ml 49508
point text and a machine language monitor. A perfect companion volume to OEOS
AisMfc and Out. Available Second Quarter. $19.95 Phone (616) 698-0330
GEOS, geoWrite, geoPalnt are tradenames of Berkeley Softworto.
Introducing BeckerBASIC. If you already hires programming needs. Creat boxes, plot
know BASIC, you can now write your own points, and draw lines.
GEOS applications in BASIC, easily. 18 additional commands are dedicated to
BeckerBASIC gives you the power of creating sound. Set ring modulation, change
over 270 new commands and functions. the filter, alter the waveform and set the
Over 20 commands to make envelope.
your programming easier. For example, Over 35 commands let you create and
TRACE, RENUMBER, DUMP, DIR, etc. animate sprites with ease. Load and save
Packed with over 50 commands for easy sprites directly. Alter their size, change their
disk access. Load and save blocks of positions and check for collisions. Use the
memory or selected lines of your program. sprite editor to create sprites and icons.
You can even PEEK and POKE into your Use the Pulldown Menu Construction Set
disk drive's memory. and Dialog Box Construction Set to aid in
10 commands can be used for easier the creation of you own applications
cursor control. Turn the cursor on and off. Royalty-free distribution of your
Set how quickly it flashes. Position it at any BeckerBASIC applications.
location on the screen. Now anyone can create applications in
20 commands are available for all your BASIC to run with GEOS. Only $49.95
Call today or mail the coupon for your free catabg covering
our complete line of software and books for the Commodore B If your Commodore dealer doesn't carry Abacus products, then have
64 and 128. Or ask for the location of the dealer nearest ; him order them for you. Or you can order direct using the following
order blank or by catling—1-800-451-4319
you. You can order direct by phone using your VISA, ]
American Express or MasterCard or detatch and mail your j Product Prte
BockerBASIC for the Commodore 64 $49.95
completed coupon. Dealer inquiries welcome—over 2400 |.
In USA add S-1.00 for S & H per order. Foreign add $12.00 per Hem.
nationwide. II Michigan residents include 4% sales lax __
ToUl amount ancloMd (US funda)
Abacus HUBS
Payment: ( ) MasterCard { ) VISA ( ) American Enpress
( ) Money Order { ) Check
Card No &p,
Nama
PRIZE LIST
To enter:
Return this entry form and your 51/4" diskette.the BeckerBASIC
Entries must be received by midnight, August
31,1988, to be eligible. To win, you must comply with the
competition rules. (Over)
* Write your entries using BeckerBASIC to run under GEOS.Entrki mull be submitted
on a diskette.
* You can submit multiple enlrles provided that all entries fit on a single diskette.
* Entries must be accompanied by the official entry form you'll find Inside the
BeckerBASIC package. Xerox or reproductions of the entry form are not acceptable.
* Winners will be notified by mail, and must claim their prize within 30 days or an
alternate winner will be selected. Prizes won by a minor will be awarded to the winner's
parent or legal guardian. For a list of the winners, send a stamped, self-addressed
envelope to Abacus Software.
* All federal, ftlale, provincial, and local taxes will be the rcspomihllily of the prize
winner. Winners may be required to execute an affidavit of eligibility and release.
* Entrants grant Abacus Software, without limitation the right lo use their names,
likeness, and competition entry for any advertising and/promotion purpose.or marketing
ENTRY FORM
Name
Address
REGISTRATION CARD
705
Reeistraoon#
1 7 R **} 1 A
— • ° ' -*- * Proeram r ime: Product ID
Name
Address
City State Zip
Purchase Information:
Dealer
Address
Citv Slate Zip.
Return this registration card to obtain a non-copy protected backup of the above
program for a handling charge of $10.00. A check, money order, or credit
card number must accompany this request. Purchase orders are not acceptable.
Abacus HUBS
Software You Can Count On
Abacus i
If ni
ti !!
5370 52nd Street SE • Grand Rapids, Ml 49508
ISBN 1-55755-033-b