Personal Computer News


Oric Atmos Basic

Categories: Review: Software

 
Published in Personal Computer News #053

Atmos Basic | A | ABS | AND | ASC | ATN | AUTO | C | CALL | CHAR | CHR$ | CIRCLE | CLEAR | CLOAD | CLS | CONT | COS | CSAVE | CURMOV | CURSET | D | DATA | DEEK | DEF | DIM | DOKE | DRAW | E | EDIT | ELSE | END | EXP | EXPLODE | Next Week

Atmos Basic

Here we analyse all the keywords of Atmos Basic from range A to E. These keywords are, in fact, identical to the Oric-1's, but changes have been finely wrought in the depths of the ROM, and some commands work differently.

A

ABS
ABS returns the absolute value of an expression. This is the result without its sign. It is used whenever the size of a quantity is required, regardless of its sign, typically when comparing two numbers to determine how close they are to each other.

AND
AND may be used to link two conditions, e.g. IF T>100 AND T<200 THEN PRINT "Within range"

Here both parts have to be true for the condition to be true. It may also be used as a binary operation, comparing the binary digits in the numbers it is joining. For each corresponding pair of bits it returns a 1 if, and only if, both bits equal one. This shows the similarity between the two uses of AND. To the Atmos there is no difference since it stores the value True as binary 1s and False as Binary 0s.

ASC
ASC converts the first character in a string expression to its ASCII code. Characters on the Atmos are stored by means of one byte codes in the range 32 to 127 according to the ASCII convention. Character codes below 32 are control characters used for clearing the screen, moving the cursor, toggling keyclicks on and off, and so on. In parallel with the standard ASCII character set the Atmos holds an alternate set of Prestel-style graphics characters. These are accessible in LORES1 mode, or by giving the appropriate CHAR command in high resolution.

ATN
The ATN function returns the value of the angle (in radians) whose tangent is given by an expression. It can be used to find the angle of slopes, given horizontal and vertical measurements.

It is the only inverse trigonometric function in Oric Basic.

AUTO
An optional keyword which may be appended to the CSAVE command, to cause the program to be stored on cassette in such a way that it will RUN automatically once loaded by CLOAD. A non-zero value in memory location #0063 indicates this.

C

CALL
CALL transfers program control to a specified machine code subroutine. The routine exists when a 6502 RTS instruction is found. The Atmos manual lists useful ROM routines and addresses in Appendix 9.

CHAR
The CHAR instruction is used to place a character on the high resolution screen at the current cursor position. The code of the character has to be specified together with parameters showing whether foreground, background or inverse is required, and whether standard or alternate characters should be displayed. For example: CHAR 65,0,1 displays 'A' in foreground colour.

CHR$
The CHR$ function returns a single character from its ASCII code. The function is particularly useful for producing characters outside the normal printed character set. When a code in the range 128 to 151 is printed, it is interpreted as an attribute character: its highest bit is first removed and it then specifies a display attribute such as a foreground or background colour.

For example PRINT CHR$(129);"BULL"

displays BULL in red foreground colour.

CHR$ may also be used to LPRINT instructions to send special characters to the printer.

With the Oric MCP-40 Printer many such control codes may, of course, be used to alter character size or give graphical commands.

CIRCLE
CIRCLE draws a circle of specified radius centred on the current position on the high resolution screen. Since the pixels in the high resolution screen are not symmetrical, the circles actually appear as ovals. This is inherent to the Atmos, and not a bug. The PATTERN instruction can be used to vary the layout of the lines with which circles are drawn.

CLEAR
CLEAR sets the value of all numeric variables to zero and all character variables to null. RUN also has this effect.

CLOAD
Used to load a file from cassette tape. The Atmos has a much more powerful version of this command than its predecessor, allowing appending and verifying of files. The append facility requires a ",J" clause and causes a program file from cassette to be joined to the end of the program currently in memory. However, the modules are not merged - the line numbers in the program on tape must be higher than those in the current program. The verify option requires a ",v" clause and enables the user to check whether a file has been CSAVED correctly.

A report on the number of verify errors detected appears on the screen after the operation.

Improvements have been made on the level of messages given when CLOAD is executing.

Whenever a file is encountered on tape, its name is shown at the top of the screen, together with a B or C label - B indicates a Basic program while C stands for a machine code file.

The proven Tangerine cassette interface standard continues its reign on the Atmos: a fast mode (2400 bauds) is the default while slow mode (300 bauds) can be invoked by ",s" at the end of the command.

Program or file names can be up to seventeen characters long and can include special characters as well as alphanumerics.

The 'Load Aborted' message may appear in the middle of a CLOAD: this usually means that the volume level on the cassette recorder is too low. In contrast, lines of "UUU..." in a listing after CLOAD has been executed usually indicates too high a setting. Often the volume level for successful loading is very sensitive in fast mode.

CLS
CLS clears the screen in any resolution mode. It does not affect the PAPER and INK colours, but other serial attributes are cleared out. Note that CTRL-L has the same effect in immediate mode.

CONT
Restarts the execution of a program after it has been stopped. CONT can be used effectively in program debugging. A program may be interrupted by CTRL-C, values of significant variables can be examined using PRINT in immediate mode, and then CONT can restart the program.

COS
COS (a) is a trigonometric function whcih returns the cosine of an angle whose value in radians is given by 'a'. Together with SIN, the function may be used to express graphical points in terms of polar coordinates i.e. x = r cos a and y = r sin a. This means the the geometry of circular shapes can be easily displayed in high-resolution displays, as shown in the example program.

CSAVE
Used to store a program or memory block as a file on cassette tape. To save a program, the CSAVE keyword is followed by the program name, with an optional ",AUTO" if it is to run automatically once loaded, and a ",S" if slow saving mode is to be employed. A memory block is saved by naming it and specifying its start and end addresses in the CSAVE command. Low- or high-resolution pictures may be stored by this method, since the data and attributes of a display lie in the same contiguous file.

When AUTO is used it causes a non-zero value to be placed in memory location #0063 as an indicator. The filename is held in a block starting at address #0035, and byte #0067 indicates fast (=0) or slow (=1).

CURMOV
CURMOV X,Y,F moves the cursor on the high resultion screen relative to its current position by X on the x-axis and Y on the y-axis. F stands for the FB code and produces an effect according to:

F = 0 background
F = 1 foreground
F = 2 inverse
F = 3 null

If the cursor is moved out of the range 0 to 239 on the x-axis or 0 to 199 on the y-axis then this gives an 'Illegal Quantity Error'.

CURSET
CURSET is a companion to CURMOV and has a similar format. However instead of being a relative cursor move it sets the cursor to an absolute position (X,Y) on the screen. When the high resolution instruction is executed the cursor is automatically set to (0,0). Clearly many high resolution programs do not require drawing to start at this point, so CURSET is used to initially position the cursor. Subsequently the instruction is used whenever an absolute cursor setting is needed. Typically this is when characters are to be displayed using CHAR, or new parts of the display to be drawn. In the example program CURSET moves the cursor prior to drawing a circle centred on a given point.

D

DATA
As in all dialects of Basic, DATA is always used in conjunction with the READ instruction, to define constants to be assigned to data names in the READ. However Atmos Basic is very flexible in this area. Constants may be numeric (including hexadecimal and E format) or string.

String constants need not be enclosed in quotes unless they contain required leading spaces. Without quotes, leading spaces are ignored but trailing spaces are not. If there is a null item in a DATA instruction, i.e. two commas together, then the respective variable will be set to zero if it is numeric or null if it is a string.

The Atmos maintains a pointer showing the next data item to be read: this is set to the beginning of the first DATA instruction when a program is RUN and also by the RESTORE instruction. If a program attempts to READ more data items than are available then an 'Out of data' error occurs.

DATA is not very economical in its use of memory, data thus occurring both in the program area and the data area of memory, but it is convenient. Commonly it is found in programs to initialise arrays or to list values to redefine characters.

DEEK
DEEK returns the value of the double-length integer in the pair of bytes starting at a specified address. The first byte of the pair is considered to hold the low-order half of the integer and the second byte has the high-order half. Thus if byte 1 holds n1 and byte 2 holds n2 then the DEEK function gives the value (N2*256)+N1. DEEK may be used to examine system variables which often span two bytes. For example, PRINT DEEK(156) reveals where the data area of memory starts.

DEF
The DEF instruction has no directly noticeable effect - it simply defines. It has two uses defining numeric functions and defining the start of a machine-code routine. DEF FN V(W) = x defines a numeric function of the name FNv, with argument w. The expression x should contain w. The argument cannot be omitted, and there can be only one. The expression can contain data-names other than the argument but this is not recommended.

DEF USR can define the starting address in memory of a machine code subroutine which will be called by the USR function.

Whenever an expression occurs frequently in a program and it is based upon the value of one argument, it can be replaced by a function. A common use of DEF FN is for the generation of random numbers, since these are often required between one and a given integer. For example, to get a random number between 1 and 100 define the function as:

DEF FN R(N)=INT(RND(1)*N)+1

DIM
As usual the DIM instruction allocates space in memory for arrays. These may have any valid name, real or integer or character. There is a maximum of 255 dimensions for an array, and the size of dimensions is limited only by the amount of memory available. Subscripts may start at 0. Arrays need not be dimensioned providing they do not have more than 11 elements.

String arrays have strings rather than just individual characters as their elements, and these strings need not be the same length. Once the size of an array has been set by a DIM statement it may not be redefined - otherwise the 'Redimensioned array error' results. Arrays are stored in memory in an area immediately following that used for single values. An undimensioned array always has eleven slots allocated for it in memory so this useful omission can be wasteful on space.

DOKE
The DOKE instruction places a two-byte integer in the pair of bytes starting at a given address. The high order half of the integer is put in the second byte and the low order half in the first. Thus DOKE is the reverse of DEEK, and correspondingly can be useful for altering system variables. For example a Basic program may be LIST-protected by:

DOKE #001B,#F42D

Once this has been entered the Atmos will always clear its memory when a program ends - an excellent way of protecting a program from curious users.

DRAW
DRAW X,Y,F draws a line from the current cursor position on the screen to a position X further away on the x-axis and Y further away on the y-axis, with an FB code of F. X and Y are thus relative coordinates. If the instruction attempts to draw a line outside the x range 0-239 or the y range 0-199, an 'Illegal Quantity Error' is flagged. The PATTERN instruction can be used to give a different layout to the lines drawn.

E

EDIT
The Oric-1 manual was never too sure whether this command existed or not - the first provisional manual included it, but wrongly explained its use, while the final manual omitted it! Perhaps Oric realised that their editing commands left a lot to be desired.

In fact, EDIT is used to bring a copy of a program line to the cursor position, prior to editing. To subsequently alter a line the cursor movement keys are used to position the cursor on the appropriate characters, and these are then sent to the Atmos's input buffer by CTRL-A. Alternatively, new characters can be typed in. Once the line has been correctly typed, RETURN enters it into the program memory area. CTRL-X can be used to cancel a line, while DEL can be used to delete individual characters. Inserting new characters into a line is messy but possible.

ELSE
The ELSE keyword provides an optional clause in the IF instruction. The problems found in using concurrent IF-THEN-ELSE instructions on the Oric-1 have been eradicated on the Atmos.

END
The instruction causes a Basic program to stop. It is identical to STOP except that it does not cause the Atmos to display a message showing at which line the program halted.

EXP
EXP(X) returns the value ex where e is the Napierian constant or exponential. The function LN is complementary to EXP, and the two can be used as log and antilog. For example, if you want to find the fifth root of a number N then EXP (LN(N)/5) will give the right result.

EXPLODE
Produces a predefined sound of an explosion. For several repeated explosions a WAIT instruction must be included between them, otherwise a continuous noise results.

Next Week

We continue our look at the Atmos and Oric-1 machines with further keyword descriptions and a glimpse of Oric peripherals.

Contributor: Bob Maunder
Cover and inside photos: Monica Curtain

Bob Maunder

Atmos Basic | A | ABS | AND | ASC | ATN | AUTO | C | CALL | CHAR | CHR$ | CIRCLE | CLEAR | CLOAD | CLS | CONT | COS | CSAVE | CURMOV | CURSET | D | DATA | DEEK | DEF | DIM | DOKE | DRAW | E | EDIT | ELSE | END | EXP | EXPLODE | Next Week