This will set up the colour registers for the PLOT/DRAWTO
graphic mode commands, and the PRINT #6; commands in text modes. They
are directly linked with COLOR. There are five colour registers (0-4)
accessible through this command, but other registers can be called
using POKE statements. Each register is set at a particular colour,
called a default colour. These can be changed using SETCOLOR R, C, I
where R= colour register, C= colour, and I= intensity (brightness).
This can be put directly into memory by POKE (location), 16*C+I. A
table follows giving all the relevant details.
In graphic modes. SE. will colour a point. Which one
depends on the mode called. For more detail it is best to consult a
Returns the sign of a number. It will return -1 for
a negative number, 1 for a positive number, and 0 if the value is 0.
This opens a sound channel in the form, SO. C, N, D,
V, where C=channel (0-3), N=a note between 0 and 255, D=distortion
(0-15), V=volume (0-15). Experimentation with this will demonstrate
all the effects. By using FOR/ NEXT loops and N or V other, more
intricate, effects can be obtained.
10 FOR N=0
TO 255 STEP 5: FOR V=15 TO 0 STEP -1: SO.0,N,10,V: NEXT V: NEXT N
Returns the square root of any positive number. Due
to the nature of the floating point ROM, some roots may work out to
decimal places, eg. 2.9999 instead of 3. To get round this just
multiply by 10, add 1, divide by 10, and take the integer. If the
answer will have decimal places, you will need to use 100, 1000, etc.
to work out the correct solution.
Used to determine the condition of a file opened for
input only. XIO is a safer and better form. It will store the error
number in the variable. See DOS 2 manual for an example
Example: 10 STATUS # 1, VARIABLE
Used with FOR/NEXT loops to increment or decrement
the loops by more or less than the default value of 1. See FOR and
Example: 10 FOR V=15 TO 0 STEP -1:
SO.0,10,10,V: NEXT V
This will read the position of the designated
joystick. The four sticks can be PEEKed directly from locations
STICK(0): GOTO 10 : REM To find the number returned for each handle
This will read the trigger of the joystick. They can
be directly PEEKed from locations 644-647. As for PTRIG, 0=pressed, 1=
Example: IF STRIG(0)=1 THEN ? "NO"
This is used in the deferred mode to return a
program to direct mode without closing files or sound. It will display
"STOPPED AT LINE xxx". The program can be restarted with
CONT. When stopped, you can print current variable or string values
for program testing.
This will change a number into a string. It is
similar to defining a string, but you can change a variable to a
string, whereas you cannot define a string from a variable. Mainly
used to do computations on strings.
Example: A$=STR$(100): REM *** Means A$=100
Linked with IF. When the IF part of the conditional
statement is true the THEN part is carried out
Linked with FOR/NEXT to give the limit of the
variable. See FOR and NEXT.
Normally an error during the running of a program
will stop and transfer it to direct mode. This can be tedious, as the
program will have to be restarted each time. TRAP, with
a line number, will send the program to this line number to give an
indication of what has occurred. The program can then be automatically
restarted by GOTO [the routine that caused the error]. TRAP must be
reset each time by TRAP to a line that does not exist in the program
(normally 40000 - an illegal line outside the computers range). This
is useful in debugging a program, but comes into its own when you need
to stop stupid user responses that would cause a crash. In the
following example, if the input is not a number, the user will be told
this and given another chance to enter a response, instead of seeing
ERROR 8. Try entering your name to the program instead of a number,
then delete line 10 and do the same again.
10 TRAP 100
20 INPUT A
30 ?"O.K.": END
100 ? "INPUT A NUMBER": TRAP 40000: GOTO 10
entry to a machine language (ML) program starting at the memory
location stated. Normally it will return a value to the variable in
the command, but most times this is not required. Several numbers,
variables, or strings can be included in the brackets. These will be
used by the ML program and are held on the program stack until needed,
i.e. moving memory from one location to another. If the program is
held in a string, the USR function can go to the current address of
this string (it can be anywhere in memory) by using the
10 Z=USR(1536, ADR(A$), ADR(B$))
This is the
opposite of STR$. It will return the value of string number so that
string computations can be performed.
A=SQR(VAL(A$)): ? A
This is for general I/O operations and is handy for such things as
reading a disk directory without recourse to DOS. It comes in the form
XIO COMMAND, #n, n1, n2, file, where n is the device number, n1 and n2
are control bytes, mostly set at 0, and file is the filename to be
operated on. For the fill function, it will be "S:" for
screen and the device will be #6. A list of command numbers is given
A new column by Mark Hutchinson begins shortly