EXTENDED BASIC

Developer(s): Robert Newman, Jack Dohany
Date: 198x
Type: Program
Platform(s): TS 2068

Adds nine new commands to our standard basic, which significantly enhance the 2068’s sound and animation facilities.

All of the new commands have the form *abc (that is, an asterisk followed by 3 small letters). Some of the commands must also be followed by parameters (a fancy word for numbers that specify some sort of measurement, like length or size).

  • *zap (makes a sound)
  • *nse l (gives a white-noise; l = length = 1-255)
  • *brk 0 (disables the BREAK key)
  • *brk 1 (re-enables it)

New Graphics Commands

  • *scr p,i (changes paper and ink colors without erasing screen)
  • *use n,s (defines number (1-255) of graphic characters, and size of memory to be reserved for holding them)
  • *def c,w,h (defines the width and height of a graphics character. c = character number (1-255) w = pixel width (1-256) h = pixel height (1-176))
  • *get c,x,y (gets a character from the screen)
  • *put (c,x,y puts a character on the screen)
  • *clr c,x,y (erases a character at the specified position, or it can be used to clear an area of the screen)

Appears on

Capital Area Timex Sinclair User Groupโ€™s Library Tape.

Gallery

EXTENDED BASIC

Source Code

    1 REM EXTENDED BASIC \* R. NEWMAN
    2 LET ersp=PEEK 23613+256*PEEK 23614: POKE ersp,206: POKE ersp+1,249: GO TO 8
    3 CLEAR 63899: BORDER 0: PAPER 0: INK 7: CLS : PRINT AT 10,0;"LOADING 1636-BYTE EXTENDED BASIC"'"CODE AT 63899": LOAD ""CODE : GO TO 2
    4 REM SAVE
    5 CLEAR : CLS : PRINT AT 10,0;"MAKING TWO-PART BACKUP": SAVE "EB" LINE 3: BEEP .01,25: SAVE "EBCODE"CODE 63899,1636
    6 CLS : PRINT "REWIND and PLAY to VERIFY": VERIFY "": PRINT "BASIC OK": VERIFY ""CODE : PRINT "CODE OK"
    7 GO TO 1
    8 CLS : INPUT "MAKE BACKUP COPY? (y/ent)";q$: IF q$="y" THEN GO TO 5
   10 CLS :*zap: PRINT "EXTENDED BASIC by Robert Newman"'"is now activated."
   20 BORDER 0:*scr 0,7
   22 PRINT ''"This BASIC program is mostly a"'"tutorial of EXTENDED BASIC."''"By listing and studying the"'"program, you'll see how to use"'"Extended Basic in your own"'"programs." 
   24 GO SUB 9000
   26 CLS : PRINT "  **EXTENDED BASIC TUTORIAL**"
   30 PRINT '"I will now show how the NINE (9)"'"new commands of EXTENDED BASIC"'"can be used. When this program"'"stops, please LIST or LLIST it"'"and study it."
   40*nse 100: GO SUB 8000
   50 PAUSE 200:*zap: PRINT '"ALL of the new commands have the"'"form *abc (That is, an asterisk"'"followed by 3 small letters)."
   60 PRINT '"SOME of the commands must also"'"be followed by PARAMETERS"'"(a fancy word for numbers that"'"specify some sort of measure-"'"ment, like length or size)." 
   70 GO SUB 9000
  100 PRINT '"Let's start with some easy ones.": PAUSE 100: PRINT ''"*zap  (gives this sound:)"
  110 FOR j=1 TO 5:*zap: PAUSE 20: NEXT j
  120 PAUSE 50
  130 PRINT ''"*nse l  gives a white-noise."'"     (l = length = 1-255.)"
  160 FOR j=1 TO 5:*nse 200: PAUSE 10: NEXT j
  170 PAUSE 50
  180 PRINT ''"*brk 0   disables the BREAK key"
  190 PRINT '"*brk 1    re-enables it."
  200 PRINT '"Try pressing BREAK before the"'"counter reaches 500."
  210*brk 0
  220 PAUSE 50: FOR j=1 TO 500: PRINT AT 17,8;"*";j;"*": IF INKEY$=CHR$ 13 THEN GO TO 230
  225 NEXT j
  230*brk 1
  240 PRINT ''"BREAK is now re-enabled."
  250 GO SUB 9000
  300 PRINT "NEW GRAPHICS COMMANDS:"''"*scr p,i   changes paper and ink"'"colors without erasing screen."
  350 PRINT ''"press a key to change colors."
  360 FOR j=0 TO 6
  370 PAUSE 60
  380*scr j,9
  390 NEXT j
  395*scr 0,7
  400 GO SUB 9000
  405 LET m$="MORE NEW GRAPHICS COMMANDS:"
  410 PRINT m$
  420 PRINT '"*use n,s  defines <n>umber (1-"'"255) of graphic characters,"'"and <s>ize of memory to be"'"reserved for holding them."
  430 PRINT '"NOTE: *use n,s is used BEFORE"'"commands *def, *get, or *put."
  435 PRINT '"If *use is not used, *use 8,256"'"is assumed."
  440 PRINT '"NOTE: *use will lower ramtop,"'"if necessary, to allocate space"'"for graphics characters."
  450 GO SUB 9000
  460 PRINT m$
  470 PRINT '"*def c,w,h   defines the <w>idth"'"and <h>eight of a graphics"'"<c>haracter."''"c = character number (1-255)"'"w = pixel width (1-256)"'"h = pixel height (1-176)"
  480 PRINT '"You cannot change the size of a"'"character, once it is defined."
  490 PRINT '"SO: you can have up to 255"'"graphics characters, any of"'"which may range in size from"'"a single dot, to the whole"'"screen."
  500 PRINT '"Memory limitations must be taken"'"into account, naturally."
  510 GO SUB 9000
  600 PRINT m$
  610 PRINT '"*get c,x,y   gets a character"'"from the screen."''"*put c,x,y   puts a character on the screen."
  620 PRINT '"c = character number (1-255)"''"x and y are the pixel co-"'"ordinates of the TOP LEFT of a"'"box on the screen from which"'"the character will be gotten,"'"or to which it will be put."
  630 PRINT '"x = X co-ordinate (0-255)"'"y = Y co-ordinate (0-175)"
  635 GO SUB 9000
  640 PRINT AT 15,0;"Press key to demonstrate *put "
  641*use 1,256
  642*def 1,256,8:*get 1,0,55
  650 PAUSE 0
  660 PRINT "The above line has been *got as a 256x8 pixel graphic character"'"and it can now be moved across"'"the screen one pixel at a time."
  662 PRINT "NOTE:*put prints with wrap-over!"
  670 FOR j=1 TO 255:*put 1,j,55: NEXT j
  680*zap
  700 GO SUB 9000
  710 PRINT m$''"*clr c,x,y   erases a character"'"at the specified position, or"'"it can be used to clear an area"'"of the screen."
  720 PRINT '"That's all the new commands."''"There's a complete list on"'"the next page."
  730 GO SUB 9000
  740 PRINT "LIST OF EXTENDED BASIC COMMANDS:"
  750 PRINT '"*zap";TAB 11;"Laser sound"'"*nse l";TAB 11;"White noise/length"
  755 PRINT "*brk 0/1   BREAK key off/on"
  760 PRINT "*scr p,i   Changes paper,ink"
  765 PRINT '"*use n,s   Defines number of"'TAB 11;"characters & size of"'TAB 11;"their reserved memory"
  766 PRINT '"*def c,w,h Defines width and"'TAB 11;"height of a character"
  767 PRINT "*get c,x,y Gets a character"'TAB 11;"from screen"
  768 PRINT "*put c,x,y Puts a character"'TAB 11;"on the screen"
  769 PRINT "*clr c,x,y Clears an area of"'TAB 11;"screen corresponding"'TAB 11;"to a character's size"
  770 GO SUB 9000
  772 PRINT "EXTENDED BASIC PARAMETERS"
  774 PRINT '"l = length (1-255);255=1 second"
  775 PRINT '"p = paper color (0-7)"'"i = ink color (0-9)"
  776 PRINT '"n = number of characters (1-255)"'"s = size of memory (number of"'"bytes) reserved for characters"
  777 PRINT '"c = character number (1-255 but"'"less than n)"
  778 PRINT '"w = width (1-256) of a character"'"h = height (1-176)"" """
  779 PRINT '"x,y = screen position"'"x = 0(left) to 255 (right)"'"y = 0(bottom) to 175(top)"
  780 GO SUB 9000
  840 PRINT "Finally, a short demo using"'"Extended Basic to move graphics"'"around the screen."
  850 PRINT "First, *get is used to copy the"'"graphic characters:"
  855 REM characters in next line are graphics characters
  860 PRINT 
  861 PRINT " \f\g  \j\k  \a\b  \c\d \e"
  862 PRINT " \h\i  \l\m"
  870*use 5,200:*def 1,22,15:*def 2,22,15:*def 3,22,8:*def 4,15,8:*def 5,4,11
  880*get 1,3,127:*get 2,35,127:*get 3,68,127:*get 4,104,127:*get 5,132,127
  890 DIM x(5): DIM a(5)
  900 FOR j=1 TO 5
  910 LET x(j)=0
  920 LET a(j)=INT (1+RND*4)
  930 NEXT j
  940 GO SUB 9000
  950 PRINT "I'LL BET ON NUMER 2!"
  960 FOR j=1 TO 58
  970 FOR k=1 TO 5
  980*put 1,x(k),k*25
  990 NEXT k
 1000 FOR k=1 TO 5:*put 2,x(k),k*25
 1010 LET x(k)=x(k)+a(k)
 1020 NEXT k
 1030 NEXT j
 1040*zap: CLS 
 1050 FOR j=1 TO 2
 1060 FOR k=0 TO 237 STEP 3
 1070*put 3,k,150: NEXT k
 1080 FOR k=237 TO 0 STEP -3
 1090*put 3,k,150: NEXT k
 1100 NEXT j
 1110*put 4,150,10:*zap:*nse 40
 1120 FOR j=0 TO 24
 1130*put 3,j*6,150:*put 5,154,30+5*j
 1140*put 3,j*6+3,150
 1150 NEXT j
 1160*nse 150:*clr 3,147,150
 1200 CLS 
 1205*brk 0
 1210 PLOT 68,28: DRAW 100,100,4156
 1216 LET ink=0: FOR i=1 TO 100: LET ink=7-ink: LET pap=7-ink:*scr pap,ink: NEXT i:*scr 0,7
 1220 LET x=38: LET y=158
 1225*use 1,4000
 1230*def 1,144,144
 1240*get 1,x,y
 1310 FOR i=y-15 TO y+15:*put 1,x,i: NEXT i
 1320*brk 1
 1330 IF INKEY$="" THEN GO TO 1330
 1340 CLS : PRINT "  ***USING EXTENDED BASIC***"
 1350 PRINT '"You can delete lines 10-9999"'"of this program. You need to"'"keep only lines 1-6, and the"'"1636 bytes of machine code (MC)"'"starting at location 16389."
 1360 PRINT '"Line 1 ""activates"" the MC."
 1370 PRINT '"""CLEAR"" will de-activate the MC."'"In order to enter or edit BASIC"'"lines containing EXTENDED BASIC"'"commands, the MC MUST be"'"activated."
 1380 PRINT '"You can check whether the MC is"'"activated by trying *zap as an"'"immediate command."
 1390 PAUSE 100:*zap
 1400 PRINT "If it works, all's well. If not,"'"you must activate the MC with a"'"""GO TO 1"" command."
 1410 GO SUB 9000
 1420 CLS : PRINT "Note that all of the EXTENDED"'"BASIC commands are an asterisk"'"(*) and 3 LOWER-CASE letters."'"Any required parameters are"'"separated from the command by"'"a space, and from each other"'"by a comma."
 1430 PRINT '"MORE ABOUT THE *use n,s COMMAND:"'"n (1-255) is the maximum number"'"of graphics characters (sprites)"'"that you will have."
 1440 PRINT "For example, if n=7 then you can"'"define characters 1 to 7, but"'"not number 8."
 1450 PRINT '"s is the size of memory (number"'"of bytes) you need for ALL your"'"sprites. This takes some prior"'"planning, as described on the"'"next page."
 1460 GO SUB 9000
 1470 CLS : PRINT "The size of each individual"'"character is calculated as"'"follows: divide width by 8,"'"add 1 for any remainder, and"'"multiply by height."
 1480 PRINT '"For example, sprite #5 (defined"'"by *def 5,83,42) would require"'"462 bytes." 
 1490 PRINT '"You would have to calculate the"'"sizes of all sprites in your"'"plan, and add them all up, to"'"get the s parameter for the"'"*use command."
 1492 PRINT '"It does no harm to make s too"'"big. If it's too small, you will"'"get an out-of-nemory error"'"report when your program runs."
 1495 GO SUB 9000
 1500 PRINT ''"MORE ABOUT *get/*put c,x,y:"'"x and y refer to the TOP LEFT"'"of a character, and to the"'"BOTTOM LEFT of the screen."
 1510 PRINT '"For example: *put 7,27,19 puts"'"the TOP LEFT CORNER of sprite #7on the screen 28 dots from the"'"left screen border, and 20 dots"'"from the bottom border."
 1520 PRINT '"(If the character should be too"'"big to fit, it'll wrap around.)"
 1530 PRINT '"Thus, x and y say WHERE on the"'"screen (counted from bottom"'"left) to put the top left corner"'"of a sprite."
 1540 GO SUB 9000
 1550 PRINT "Need more help?"'"Call Jack, (415) 321-7684, or"'"find a copy of YOUR COMPUTER"'"magazine,Vol.4 No.9 P.141"
 1560 PRINT '"This program was written for the"'"SPECTRUM by Robert Newman, and"'"was modified for the 2068 by"'"Jack Dohany. This is a"'"copyrighted public-domain prog"'"-ram and may not be used for"'"commercial purposes without"'"permission of original author"'"and publisher."
 1570 GO SUB 9000
 1580 PRINT "TECHNICAL NOTES:"''"Extended Basic's machine code"'"resides above RAMTOP, from"'"loc 63900 to 65367 (1467 bytes)."''"The code is accessed from BASIC"'"by means of the BASIC System"'"Variable ERR SP at loc 23613/4."''"BASIC line 2 puts the entry"'"address of the Extended Basic MC"'"into this two-byte system"'"variable."
 1582 PRINT '"When the BASIC systax checker"'"encounters a syntax error (such"'"as ""*""!),it jumps to the"'"address held in ERR SP...and"'"from then on, Extended Basic"'"MC is IN CONTROL of syntax"'"checking." 
 1584 GO SUB 9000
 1590 PRINT "Syntax checking is done when"'"you enter or edit a line, and"'"when you enter an immediate"'"command (such as *zap), AND"'"when a program is running."
 1592 PRINT ''"During program execution, EB not"'"only says that its syntax is"'"NOT an error after all...but"'"procedes to interpret the systax"'"that it encounters."''"And that, roughly, is how we"'"extend BASIC to include new"'"commands. It ain't easy, and it"'"must be done in machine code..."'"but it CAN be done, and"''"THE SKY'S THE LIMIT!"
 1900 STOP 
 2000 PRINT AT 10,0;CODE INKEY$;"   ";: GO TO 2000
 8000 RESTORE 8050
 8010 FOR j=0 TO 103
 8020 READ n
 8030 POKE USR "a"+j,n
 8040 NEXT j
 8050 DATA 192,64,19,63,84,247,92,8,12,16,32,240,168,188,232,64
 8060 DATA 1,1,7,15,31,63,248,240,0,0,192,224,240,248,62,30
 8070 DATA 2,1,2,4,2,1,0,0
 8080 DATA 0,0,0,0,193,33,31,30,0,0,192,128,130,94,123,179
 8090 DATA 31,60,48,96,64,128,128,0,248,184,24,6,4,4,1,0
 8100 DATA 0,0,1,3,65,175,31,31,64,224,128,172,222,123,184,188
 8110 DATA 31,12,4,4,2,2,1,0,124,8,16,16,32,32,64,0
 8120 RETURN 
 9000 PRINT #1;AT 0,0;"COPY? (y=yes, ENT= next page.)"
 9010 IF INKEY$="" THEN GO TO 9010
 9020 IF INKEY$="y" OR INKEY$="Y" THEN COPY : GO TO 9000
 9030 CLS : RETURN 
Scroll to Top