HOME

TheInfoList



OR:

Color BASIC is the implementation of
Microsoft BASIC Microsoft BASIC is the foundation software product of the Microsoft company and evolved into a line of BASIC interpreters and compiler(s) adapted for many different microcomputers. It first appeared in 1975 as Altair BASIC, which was the first v ...
that is included in the
ROM Rom, or ROM may refer to: Biomechanics and medicine * Risk of mortality, a medical classification to estimate the likelihood of death for a patient * Rupture of membranes, a term used during pregnancy to describe a rupture of the amniotic sac * ...
of the Tandy/Radio Shack
TRS-80 Color Computer The RadioShack TRS-80 Color Computer, later marketed as the Tandy Color Computer, is a series of home computers developed and sold by Tandy Corporation. Despite sharing a name with the earlier TRS-80, the Color Computer is a completely different ...
s manufactured between 1980 and 1991.
BASIC Basic or BASIC may refer to: Science and technology * BASIC, a computer programming language * Basic (chemistry), having the properties of a base * Basic access authentication, in HTTP Entertainment * Basic (film), ''Basic'' (film), a 2003 film ...
(Beginner's All-purpose Symbolic Instruction Code) is a high level language with simple syntax that makes it easy to write simple programs. Color BASIC is interpreted, that is, decoded as it is run.


Background

The nucleus of Color BASIC was Microsoft BASIC-69 which Tandy licensed from Microsoft. Color BASIC 1.0 was released with the original 4k TRS-80 Color Computer in 1980. It resides on 8k bytes of ROM, and is responsible for all 'housekeeping' duties on the system. This includes hardware initialization,
memory management Memory management (also dynamic memory management, dynamic storage allocation, or dynamic memory allocation) is a form of Resource management (computing), resource management applied to computer memory. The essential requirement of memory manag ...
,
interrupt In digital computers, an interrupt (sometimes referred to as a trap) is a request for the processor to ''interrupt'' currently executing code (when permitted), so that the event can be processed in a timely manner. If the request is accepted ...
processing, etc. Like most implementations of BASIC, each line of code starts with a line number and consists of one or more statements with
variables Variable may refer to: Computer science * Variable (computer science), a symbolic name associated with a value and whose associated value may be changed Mathematics * Variable (mathematics), a symbol that represents a quantity in a mathemat ...
and operators. 16k of memory is required for the next level of BASIC,
Extended Color BASIC Extended Color Basic is an update to the Color BASIC interpreter for the Radio Shack/Tandy TRS-80 Color Computer series, and is the default Basic interpreter for the Color Computer 2. The Color Computer Basic implementations are somewhat different ...
("ECB"). Extended BASIC is required for the
floppy disk controller A floppy-disk controller (FDC) is a hardware component that directs and controls reading from and writing to a computer's floppy disk drive (FDD). It has evolved from a discrete set of components on one or more circuit boards to a special-purpo ...
, which then gives you Disk Extended Color BASIC ("DECB"). Emulators of the Color Computers running this interpreter and the others are available for modern computers, some of which require a "snapshot" file of the physical machine.MESS


Variables

Color BASIC understands one type of numeric variable and
string String or strings may refer to: *String (structure), a long flexible structure made from threads twisted together, which is used to tie, bind, or hang other objects Arts, entertainment, and media Films * ''Strings'' (1991 film), a Canadian anim ...
variables. Variable names in Color BASIC have the first two characters significant. The first character of the variable name must be a letter. The second can be either a letter or number. String variables are indicated by adding a dollar sign ($) after the variable name.


Examples

A=5 A$="THIS IS A STRING" K7=10 BB$="HELLO!" ZZ=1.54 Numeric variables have only one type, a binary floating point implementation. Each numeric variable uses 5 bytes of memory and can be in the range from -1E+38 up to 1E+37. Unlike most implementations of Microsoft BASIC, Color BASIC requires the user to reserve space for string variables via the CLEAR statement. Multidimensional
arrays An array is a systematic arrangement of similar objects, usually in rows and columns. Things called an array include: {{TOC right Music * In twelve-tone and serial composition, the presentation of simultaneous twelve-tone sets such that the ...
are also supported with both numeric and string variables. In the case of an array, the element address is enclosed with a parenthesis: A(1)=1 A$(1)="BOOKS" Multiple dimensions are separated by commas A(1,3)=4 A$(2,2)="XYZ123"


Operators and Symbols

Color BASIC provides several operators for both mathematic and, to a lesser extent, string operations. :+ can be used to
concatenate In formal language theory and computer programming, string concatenation is the operation of joining character strings end-to-end. For example, the concatenation of "snow" and "ball" is "snowball". In certain formalizations of concatenati ...
strings or for mathematical addition :- is used for subtraction :* is used for multiplication :/ is used for division Parenthesis ( ) are used to override mathematical order of operation :AND is used for logical 'and' operations :OR is used for logical 'or' operations :NOT is used for logical 'not' operations For testing, the following operators are used: := is equal to :> is greater than :< is less than :>= is greater than or equal to (also => is acceptable) :<= is less than or equal to (also =< is acceptable) :<> is not equal to (also >< is acceptable) Other symbols used in BASIC: :" " indicates string data is a constant (static) :: separates multiple commands on a single program line :A semicolon, when encountered in a PRINT function, will cause the output to remain on the same line :A comma, when encountered in a PRINT function, will tab to the next column


Key

''num'' indicates a numeric expression is required. This can be a fixed number, a variable, or other operation or function that returns a numeric quantity. ''str'' indicates a string expression is required. This can be a static string value (in quotes), a string variable, or other function or expression that returns a string of characters. ''device number'' indicates a device. By default, device 0 (screen and keyboard) is assumed. In Color BASIC, device #-1 (cassette) and #-2 (printer) are available to the programmer.


Edit mode

If you make a mistake typing in a line, you can either retype it from scratch (or DEL it).. or you can EDIT it. When in EDIT mode, you get a reprint of the line, and a second copy that you SPACEbar across chars. You cannot use arrow keys. backspace takes you left, but does not actually erase it in the buffer. 'i' puts you in insert mode. pressing return gets you out of it. 'c' changes one char, 'd' deletes one char. 'x' takes you to end of line, allowing you to e'x'tend it. 'l' redraws the line. 's' searches for the next instance of a character. For the 's', 'c' and 'd' commands you can also enter a number (#) before pressing any of them which will: 's' - search for the # instance of the character, 'c' - allow you to change # of characters, 'd' - delete # amount characters.


Functions

;ABS(''num''): returns the
absolute value In mathematics, the absolute value or modulus of a real number x, is the non-negative value without regard to its sign. Namely, , x, =x if x is a positive number, and , x, =-x if x is negative (in which case negating x makes -x positive), ...
of ''num'' ;ASC(''str''): returns the
ASCII ASCII ( ), an acronym for American Standard Code for Information Interchange, is a character encoding standard for representing a particular set of 95 (English language focused) printable character, printable and 33 control character, control c ...
code of the first character in ''str'' ;CHR$(''num''): returns a single string character with the ASCII code ''num'' ;EOF(''device number''): returns 0 if the file has data, or -1 if at the end of the file ;INKEY$: returns a character if a key on the keyboard has been pressed, or null if nothing is pressed ;INT(''num''): returns the
integer An integer is the number zero (0), a positive natural number (1, 2, 3, ...), or the negation of a positive natural number (−1, −2, −3, ...). The negations or additive inverses of the positive natural numbers are referred to as negative in ...
portion of ''num'' ;INSTR(''startpos,search str,target str''): searches for the first string, in the target str. startpos is optional. ;JOYSTK(''num''): returns the position of the joystick axis (0-3) with a value from 0 to 63 ;LEFT$(''str'',''num''): returns the first ("left") ''num'' characters of string ''str'' ;LEN(''str''): returns the length (in characters) of string ''str'' ;MEM: returns the available free memory in bytes ;MID$(''str'',''start num'',''length num''): returns a sub-string of string ''str'' beginning at position ''start num'' and ''length num'' characters long. Can also reassign by adding ="newvalue" ;
PEEK Polyether ether ketone (PEEK) is a beige coloured organic thermoplastic polymer in the polyaryletherketone (PAEK) family, used in engineering applications. It was invented in November 1978 and brought to market in the early 1980s by part of I ...
(''num'')
: returns the value of the memory location ''num'' (0-65535) ;POINT(''x num,y num''): returns the color of the
semigraphics Text-based semigraphics, pseudographics, or character graphics is a primitive method used in early text mode video hardware to emulate raster graphics without having to implement the logic for such a display mode. There are two different ways ...
dot at position ''x numm'' (0-63) and ''y num'' (0-31) ;RIGHT$(''str'',''position num''): returns the end ("right") portion of string ''str'' beginning at character ''position num'' ;RND(''number''): returns a random number (integer) between 1 and ''num'' ;SGN(''num''): returns the sign of a number ''num'', 1 if positive, -1 if negative, 0 if 0 ;SIN(''num''): returns the sine of ''num'' in radians ;STR$(''num''): returns a string of the number ''num'' ;USR(''num''): calls a
machine language In computer programming, machine code is computer code consisting of machine language instructions, which are used to control a computer's central processing unit (CPU). For conventional binary computers, machine code is the binaryOn nonb ...
subroutine In computer programming, a function (also procedure, method, subroutine, routine, or subprogram) is a callable unit of software logic that has a well-defined interface and behavior and can be invoked multiple times. Callable units provide a ...
whose address is stored in memory locations 275 and 276. ''num'' is passed to the routine, and a return value is assigned when the routine is done


Commands

;AUDIO
OFF Off or OFF may refer to: Art and entertainment * ''Off'' (video game), a video game by Mortis Ghost. *Sven Väth, German DJ and singer who uses the pseudonym OFF * ''Off'' (album), by Ciwan Haco, 2006 * ''Off!'' (album), by Off! * Off!, an Ameri ...
/code>: Connects or disconnects cassette audio from the TV sound ;CLEAR ''variable space'' ''highest memory location''/code>: reserves memory for string variables, and optionally, a machine language program ;CLOAD ''name''"/code>: loads BASIC program from cassette. If no name is specified, the next program is loaded ;CLOADM ''name''"/code>: loads machine language program from cassette. If no name is specified, the next program is loaded ;CLOSE 'device number''/code>: closes a device (in Color BASIC this can only be #-1, the cassette) ;CLS(''num''): clears the screen. An optional color ''num'' (0-8) can be specified ;CONT: continues a program after pressing BREAK or a STOP statement ;CSAVE ''name''"/code>: saves a BASIC program to cassette with optional name ;DATA ''var,var,var...'': stores data in a BASIC program for retrieval with the READ command ;DIM ''variable''(''dimension'' ''dimension 2'',.../code>: dimensions an array and reserves memory space for it ;END: indicates the end of a BASIC program ;EXEC: 'memory address''executes the machine language program at ''memory address''. If none specified, the execute address of the program loaded off tape is used ;INPUT 'device number'' ;''variable'' ''variable 2'', ''variable n''/code>: Waits for input from ''device number''. If not specified, device 0 (keyboard) is assumed. An optional prompt can be printed on the screen for the input statement ;LIST 'starting line''- 'ending line''/code>: lists line(s) of your program. Either start or end can be omitted, or if both are omitted, the entire program will be listed ;LLIST 'starting line''- 'ending line''/code>: works like LIST, but outputs to the printer ;MOTOR
OFF Off or OFF may refer to: Art and entertainment * ''Off'' (video game), a video game by Mortis Ghost. *Sven Väth, German DJ and singer who uses the pseudonym OFF * ''Off'' (album), by Ciwan Haco, 2006 * ''Off!'' (album), by Off! * Off!, an Ameri ...
/code>: turns the cassette motor on or off ;NEW: erases contents of memory (program and variable) ;ON GOSUB ''line 1'', ''line 2'', ... ''line n'': evaluates expression ''num'' and calls the ''num''th subroutine listed ;ON (''num'') GOTO ''line 1'', ''line 2'', ... ''line n'': evaluates expression ''num'' and jumps to the ''num''th line listed ;OPEN " O,''device number'' "''filename''"/code>: opens a device for communication ;
POKE Poke may refer to: Arts, entertainment, and media * Poke (Ender's Game), Poke (''Ender's Game''), a fictional character * Poke (game), a two-player card game * Poke, a fictional bar owner in the television series ''Treme (season 2), Treme'' * The ...
''memory address'', ''data''
: writes ''data'' (0-255) into ''memory address'' (0-65535) ;PRINT ''device number'',''expression'': prints data to device specified. If omitted, #0 (screen) is assumed ;PRINT @ ''expression'': works like PRINT, but prints at the location specified (0-511) ;READ ''variable'' ''variable'',.../code>: reads the next variable(s) from the BASIC program embedded with DATA statements ;RENUM NewStart ''num,'' OldStart ''num,'' Increment ''num'': renumbers each line (optional Oldstart ) (with optional NewStart) of the program : at multiples of (optional ''num).'': If all options are omitted, the list will use 10 for increment. : With a program with 10 lines, with 10 separation. 10,20,30,40,50,60,70,80,90,100: renum 100, 40, 2. This will renumber, Starting at line number 40. It will change all line number following and including 40 by 2. lines now 10,20,30,100,102,104,106,108,110, 112 ;RESET(''x,y''): sets the semigraphics pixel at location x (0-63) and y (0-31) to black ;RESTORE: resets the READ pointer back to the first DATA statement ;RETURN: returns from a subroutine ;RUN ''num'': runs the BASIC program, optionally, at the line number specified ;SET(''x,y,color''): sets the semigraphics pixel at location x (0-63) y (0-31) to color (0-8) ;SKIPF ''filename''"/code>: skips over BASIC programs on tape until the program name specified is found ;SOUND ''tone'',''duration'': sounds a tone with frequency (1-255) and duration (1-255) ;STOP: causes the program to stop executing ;TAB(''column''): tabs to the column specified (used with PRINT) ;VAL(''str''): returns the numeric value of a string that contains a number in string form


Control flow

;
GOSUB Basic or BASIC may refer to: Science and technology * BASIC, a computer programming language * Basic (chemistry), having the properties of a base * Basic access authentication, in HTTP Entertainment * Basic (film), ''Basic'' (film), a 2003 film ...
'
: calls the subroutine at the line number specified ; GOTO ': jumps to the program's line number specified ;IF ' THEN ' LSE '/code>: performs conditional test. If the test is true THEN commands are executed, otherwise (ELSE) other commands are executed. If the no ELSE is specified, and the test is false, the next line of the program will be run
FOR For or FOR may refer to: English language *For, a preposition *For, a complementizer *For, a grammatical conjunction Science and technology * Fornax, a constellation * for loop, a programming language statement * Frame of reference, in physics * ...
' = ' TO ' TEP ' ... NEXT ''(num)'' : creates a loop where the numeric variable ''(num)'' runs from start number to end number in increments of number (STEP). If step is omitted, 1 is assumed


Error Messages

;/0:
division by zero In mathematics, division by zero, division (mathematics), division where the divisor (denominator) is 0, zero, is a unique and problematic special case. Using fraction notation, the general example can be written as \tfrac a0, where a is the di ...
;AO: file specified is already open ;BS: bad subscript. subscript is out of DIM range ;CN: can't continue (see CONT command) ;DD: attempt to redimension an array ;DN: invalid device number ;DS: direct statement error (program has no line numbers) ;FC: illegal function call: function contains a value that is out of range ;FD: bad file data: attempt to read a number into a string value, etc. ;FM: bad file mode, attempt to INPUT data to a file open for OUTPUT, etc. ;ID: illegal direct: the specified command can only be run in a program ;IE: input past end of file. See EOF ;IO:
input/output In computing, input/output (I/O, i/o, or informally io or IO) is the communication between an information processing system, such as a computer, and the outside world, such as another computer system, peripherals, or a human operator. Inputs a ...
error ;LS: long string: strings can only have 255 characters ;NF: NEXT without FOR ;NO: file not open ;OD: out of data: attempt to read beyond the last DATA in the program ;OM: out of memory ;OS: out of string space: see CLEAR ;OV: overflow: the number is out of range ;RG: RETURN without GOSUB ;SN: syntax error ;ST: string operation too complex ;TM: type mismatch (A$=3, A="CAT") ;UL: attempt to GOTO or GOSUB to a line that doesn't exist


Documented ROM subroutines

There are a few subroutines available for machine language programs in the Color BASIC ROM that are available for general purpose programming. ;POLCAT: address A000 polls keyboard for a character ;CHROUT: address A002 outputs a character to screen or device ;CSRDON: address
A004 National Route A004 is a four-lane highway connecting National Route 1 (Argentina), National Route 1 (mostly known as the "Buenos Aires-La Plata highway") at km marker 31 with the Juan María Gutiérrez Roundabout in Greater Buenos Aires. The road ...
starts cassette and prepares for reading ;BLKIN: address A006 reads a block from cassette ;BLKOUT: address A008 writes a block to cassette ;JOYIN: address A00A reads joystick values


References

;Notes *''Getting Started With Color BASIC'', 1980, Tandy Corporation. Publication #8749266 *
Color Computer Disk System (Tandy)
', 1981, Tandy Corporation. Publication #8749470-BCo *
Getting Started With Extended Color BASIC
', 1984, Tandy Corporation. Publication #811013700A *
Color Computer 3 Extended Basic (Tandy)
', 1986, Tandy Corporation. Publication #81101910A {{DEFAULTSORT:Color Basic TRS-80 Color Computer Discontinued Microsoft BASICs BASIC programming language family Microsoft programming languages