Keywords and Tokens

This is an exhaustive list of keywords and instructions in Tomy BASIC, including undocumented keywords (discovered by mistake and poking around :-). Many, many thanks are due to James Host, the Wizard Kludgefinder, for patiently compiling much of this list and the entire list of token values during his forays through the Tomy OS. Also grateful acknowledgement made to Dave Brain, who made some new discoveries on his unit. Updates and corrections are gratefully accepted. Last modify 26 January 2009.

Back to "Programming the Tomy Tutor" | Back to the main page

Tutti BASIC.
Two keywords at work in Tutti.

All tokens have byte values of hex $80 or higher.

Several things become apparent when examining the inner workings of Tomy BASIC. Many tokens seem grouped by function; $BA-$BD, logical operators; $BE-$C5, binary operators; $9C-$AA (except RUN, $A9), program output and screen display; $CB-$DC, function calls. There are several large gaps in the keyword table; $DD-$FB (except $E7, see below) is unoccupied, but TAB and # occupy $FC and $FD. There is also a gap between $AB-$AF (except $AD, see below).

There is a significant number of "crash" tokens that when inserted into memory cause the system to lock up when LISTed (and presumably don't execute either). These tokens are $99, $9F, $AD, $B9 and $E7. Avoid!


Direct Mode Only

Attempting to enter these statements in as program lines results in an ERR 14. Keywords with * are supported in Tutti.

Curiously, some direct mode keywords have tokens, which may indicate Tomy once considered allowing such instructions to be programmatically executable, and some keywords that you may think should be direct-only, like TRACE, can be used in a program as well (see that section).

Keyword Token Description
AUTO a,b none Initiates automatic line numbering. Arguments a and b are optional; a specifies starting number and b the increment. Defaults to 100 and 10, respectively.
CLRSTP a,b $8F Clears a breakpoint from lines a and b.
CONT none Standard BASIC.
LIST a-b none Standard BASIC; a and b are optional.
LLIST a-b none Same as LIST, but sends to the printer. If you have one, that is, or are using the printer interface.
LOAD file none Loads a file from tape. file must be a literal (can't be a variable).
MENU* none Exits to the Tomy menu.
NEW* none Clears the current program. In reality, completely resets the BASIC interpreter (as if you'd exited by typing MENU and selected BASIC again).
RENUM a,b none Renumbers previously entered lines. Arguments a and b are optional; a specifies starting number and b the increment. Defaults to 100 and 10, respectively.
RUN a $A9 Standard BASIC; a is optional.
SAVE file none Saves a file to tape. file must be a literal (can't be a variable).
STOP a,b $8E Sets a breakpoint at lines a and b; execution is continued with CONT. Parameters are not optional in direct mode.
VERIFY file none Checks the integrity of tape file file. file must be a literal (can't be a variable).

Program and Direct Mode

Keywords with * are supported in Tutti.

Keyword Token Description
ABS(a) $CB Standard BASIC.
AND, OR, XOR, NOT $BB, $BA, $BC, $BD Standard BASIC. Work as both logical and bitmask operators, though this behaviour is not documented.
ASC(a$) $DC Standard BASIC.
ATN(a) $CC Standard BASIC. a must be in radians.
CHR$(a) $D6 Standard BASIC, but undocumented.
CLS* $A0 Clears the screen. No arguments.
COLOR(a,b,c) $A1 Sets the colour screen elements. a is the character set, usually 0; b is the foreground colour and c is the background colour.
COS(a) $CD Standard BASIC. a must be in radians.
DATA, READ $93, $97 Standard BASIC. You may specify multiple variables to READ.
DEF fun(lambda)=expression $89 Allows function definition. Example: DEF MINE(A)=1+A
DIM v(a[,b...]) $8A Standard BASIC.
END, STOP $8B, $8E Standard BASIC.
EXP(a) $CE Raises e to the ath power.
FOR, TO, STEP, NEXT $8C, $B1, $B2, $96 Standard BASIC.
GCELL(a,b,c) $A5 Get a screen cell into a variable. a is the vertical coordinate (1-24), b is the horizontal (1-32), and c is the name of the variable to save it to.
GOSUB, RETURN $87, $88 Standard BASIC. Computed GOSUBs are not allowed.
GOTO $86 Standard BASIC. Computed GOTOs are not allowed.
IF, THEN, ELSE $84, $B0, $81 Standard BASIC. THEN and ELSE may only be followed by line numbers, not statements. There is no colon between THEN and ELSE. Example: IF Q=1 THEN 200 ELSE 300 Computed THENs and ELSEs are not allowed.
INPUT b$:a $92 Standard BASIC. The prompt and the variable are separated by a colon instead of a semicolon or comma. BASIC whines with an error 16 if you do a type mismatch (the equivalent of the 64's ?REDO FROM START complaint).
INT(a) $CF Standard BASIC.
JKEY1, JKEY2 $A7, $A8 Undocumented.
KEY(a,b) $A6 Reads the joystick and keyboard. a is 0 for the keyboard, 1 for stick #1, and 2 for stick #2; b is the name of the variable to store the ASCII value (for keyboard) or stick value (for joystick) in. For the joystick: bit 0 (1) is right, bit 1 (2) is up, bit 2 (4) is left, bit 3 (8) is down, bit 4 (16) is select-right fire button, and bit 5 (32) is select-left fire button, and combinations of them (SL+left+up = 32+4+2 = 38) are valid.
LEN(a$) $D5 Standard BASIC.
LET $8D Standard BASIC. LET is not required.
LPRINT $9C Identical to PRINT, but sends to the printer which was never manufactured, or to your own printer if you're using the printer interface.
MCELL(a,b$) $A3 Loads a bit pattern into a programmable character (128-159 are available for use, but actually any valid byte is acceptable). The bit pattern is constructed identically to the TI's CALL CHAR statement, basically eight hex bytes corresponding to the bit pattern. Example from the manual:
00000000 00
01100110 66
11111111 FF
11111111 FF
11111111 FF
01111110 7E 
00111100 3C
00011000 18
So, MCELL(128, "0066FFFFFF7E3C18") turns character 128 into a heart. MCELL can be used to manipulate most VDP memory locations below VDP $0800. See the Memory Map and the SCELL command.
ON, GOTO, GOSUB $9B, $86, $87 Standard BASIC.
PRINT $9C Standard BASIC. Similar to the TI, single colons (:) embedded in a PRINT statement, like PRINT "X":"Y", insert carriage returns.
RANDOMIZE $95 Re-seeds the random number generator, presumably off the internal clock or some other "independent" source.
REM $9A Standard BASIC.
RESTORE a $94 Standard BASIC; optional parameter a sets READ pointer to that line.
RND $D7 Returns a random number between 0 and 1. Unlike many BASICs, RND takes no arguments.
SCELL(a,b,c,d) $A4 Puts a character at a screen position. a is the vertical coordinate (1-24), b is the horizontal coordinate (1-32), c is the character number (32-159 officially, but actually any valid byte; this is actually based on MCELL number and not the real offset into the character set) and n is the number of times to print that character.

SCELL( ) is the only BASIC command that allows direct access to all of VDP RAM since it has no bounds-checking. Refer to the Tomy Memory Map, and also the MCELL command.

SCREEN(a)* $A2 Sets the background colour to colour a (1-16).
SEG$(a$,b,c) $D8 Takes a substring of string a$. Undocumented; the manual incorrectly lists this keyword as MID$.
SGN(a) $D1 Standard BASIC.
SIN(a) $D2 Causes your computer to lust madly and ravenously after tender young ... ahem. Standard BASIC. a must be in radians.
SOUND(a,b,c,d,e) $AA Plays a single-voice tone of frequency b for a clock cycles at amplitude c. Optional parameters d and e specify frequency for voices 2 and 3.
STR$(a) $DB Standard BASIC, but undocumented.
SQR(a) $D3 Standard BASIC.
TAB(a) $FC Standard BASIC, but undocumented.
TRACE $90 Enables BASIC trace mode. Dave mentions this and UNTRACE *do* work in a program.
UNTRACE $91 Disables BASIC trace mode.
VAL(a$) $DA Standard BASIC.

Symbols

In token order.

Symbol Token Description
:: $82 Multiple statement separator.
! $83 Davey suggests, perhaps a tail REM (a la the apostrophe in Microsoft BASIC). Undocumented.
, $B3 Parameter separator.
; $B4 Concatenator and newline suppressor for PRINT and LPRINT.
: $B5 Inserts new lines in PRINT and LPRINT statements; parameter separator in INPUT.
) ( $B6, $B7 Arithmetic precedence operators; also used to denote argument lists for functions. Unlike the C64, where the leading ( is considered a part of the function tokens that require it, ( is a separate token in Tomy BASIC.
& $B8 On Davey's unit, this works as a string concatenation operator, just like the 99/4A. Undocumented.
=, <, > $BE, $BF, $C0 Logical comparison operators; = is also the assignment operator. Compound tokens >=, =>, <=, =< and <> also possible with regular BASIC semantics.
+, -, *, /, ^ $C1, $C2, $C3, $C4, $C5 Arithmetic operators. + is also the string concatenator. Standard BASIC.
# $FD Unknown. Undocumented. May be a remnant of never-finished input/output routines (compare with INPUT# on the 99/4A and C64). Dave experimented and found that PRINT #0 prints to the screen; PRINT #1 (all the way up to 255, what dedication!) gives a ERR19 (see the Errors page); INPUT #0 gives ERR20 (ibid.); INPUT#1 (through 255?) seems to be keyboard. RESTORE# on any device number gives ERR19 again, and OPEN# and CLOSE# don't work.

Housekeeping Tokens

These tokens are used internally by Tomy BASIC for delimiters and indicators, do not actually appear in LISTings, and cannot be entered directly.

Token Description
$C7 Indicates literal string in quotes to follow. The LIST routine prints a quote, and gets the length of the string from the byte immediately following. The string is printed, and then a trailing quote.
$C8 Indicates literal string without quotes to follow (i.e. variables, token-less keywords). The length is also in the byte immediately following the token.
$C9 Indicates 16-bit integer to follow, in high-byte/low-byte standard 9995 word format.


Back to the top | Back to "Programming The Tomy Tutor"