First Steps: A-Z of Atari Basic part 4

by Mark Hutchinson

 

 

Issue 17

Sep/Oct 85

Next Article >>

<< Prev Article

 

 

SETCOLOR (SE)

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.

SE. 0 POKE 708  CAPITALS
SE. 1 POKE 709  INVERSE CAPITALS
SE. 2  POKE 710 LOWER CASE/WINDOW/BORDER
SE. 3  POKE 711 INVERSE LOWER
SE. 4 POKE 712 BACKGROUND

In graphic modes. SE. will colour a point. Which one depends on the mode called. For more detail it is best to consult a tutorial.

SGN

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.

Example: X=SGN(-10)

SOUND (SO.)

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.

Example: 

10 FOR N=0 TO 255 STEP 5: FOR V=15 TO 0 STEP -1: SO.0,N,10,V: NEXT V: NEXT N

SQR

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.

Example: X=SQR(100)

STATUS (ST.)

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 program

Example: 10 STATUS # 1, VARIABLE

STEP

Used with FOR/NEXT loops to increment or decrement the loops by more or less than the default value of 1. See FOR and NEXT.

Example: 10 FOR V=15 TO 0 STEP -1: SO.0,10,10,V: NEXT V

STICK

This will read the position of the designated joystick. The four sticks can be PEEKed directly from locations 632-635.

Example:

10 ? STICK(0): GOTO 10 : REM To find the number returned for each handle position

STRIG

This will read the trigger of the joystick. They can be directly PEEKed from locations 644-647. As for PTRIG, 0=pressed, 1= not pressed.

Example: IF STRIG(0)=1 THEN ? "NO"

STOP (STO.)

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.

STR$

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

THEN

Linked with IF. When the IF part of the conditional statement is true the THEN part is carried out

TO

Linked with FOR/NEXT to give the limit of the variable. See FOR and NEXT.

TRAP (T.)

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.

Example: 

10 TRAP 100
20 INPUT A
30 ?"O.K.": END
100 ? "INPUT A NUMBER": TRAP 40000: GOTO 10

 

USR

 

This gives 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 ADR function.


Examples

10 X=USR(1536)
10 Y=USR(ADR(A$))
10 Z=USR(1536, ADR(A$), ADR(B$))


VAL

 

This is the opposite of STR$. It will return the value of string number so that string computations can be performed.


Example: 

10 A$=100: A=SQR(VAL(A$)): ? A

 

XIO (X)


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 below.


Examples:

3 OPEN  18 FILL
5 GET RECORD 32 RENAME FILE
7 GET CHARACTERS 33 DELETE FILE
9 PUT RECORD  35 LOCK FILE
11 PUT CHARACTERS 36 UNLOCK FILE
12 CLOSE 37 POINT
13 STATUS 38 NOTE
17 DRAW LINE 254 FORMAT DISK


A new column by Mark Hutchinson begins shortly

top