| Summary | ROM | Disasm | Roots |
The SAM BASIC is a modern, fully structured programming language compatible with the ZX BASIC and BETA BASIC. The system of the SAM BASIC can manage the whole basic 512KB RAM (every 16KB memory page) and fill it with programs, procedures, functions, variables, arrays, screens, system extensions, DOS and ramdisks (bigger ramdisks can be open in the extra 4MB RAM). Every part of the memory (per 1KB) could be protected from being overwritten. Programs can read allocation table and respect marked memory layout. 600 bytes of system variables serve for a wide range of commands and peripherals (soundchip, graphics modes and colour palette, disk and tape I/O, mouse, joystick, printer, light-pen, net, key- and char-sets). The SAM BASIC has also a full range of mathematical functions and provides hex and binary conversions.
The MasterBASIC (MB) expansion brings speed improvements, more comfortable program editing and tracing, an interrupt-driven video, sound capabilities and much more.
SAM BASIC Commands
- procedures: DEF PROC, END PROC, LOCAL and DEFAULT variables, REF (parameter passing); MB: EXIT PROC
- conditions: WHILE, UNTIL, ON (case equivalent), 'long' IF, ELSE IF, ELSE, END IF, 'short' IF - THEN - ELSE
- conditions with loops: DO, LOOP, DO WHILE, DO UNTIL, LOOP WHILE, LOOP UNTIL, LOOP IF, EXIT IF, FOR - TO - STEP - NEXT; MB: EXIT DO, EXIT FOR
- data and strings manipulations: READ, DATA, ITEM, RESTORE, RANDOMIZE, RND, DIM, READ LINE (omit quotes), TRUNC$ (truncate spaces), LENGTH, INSTR$, STR$, VAL, VAL$, CODE, CHR$, INKEY$, GET; MB: EDIT, SORT (ABS, INVERSE - case sensitive and reverse order switches), DELETE, INARRAY, USING$, SVAL$, NVAL, SHIFT$, EQU
- labels: LABEL name, GOTO, GOSUB
- memory handling: PEEK, DPEEK, POKE, DPOKE (num,var,string), MEM$ (a TO b), OPEN, FREE, RAMTOP, CLEAR, CLOSE
- graphics: MODE, SCREEN, OPEN SCREEN, CLOSE SCREEN, DISPLAY, PALETTE, PALETTE pos,a,b LINE n, PEN, PAPER, BORDER, CSIZE, PLOT, DRAW, DRAW x,y,angle, DRAW TO, CIRCLE, BRIGHT, FLASH, INVERSE, OVER, POINT, BLOCK, FATPIX, SCREEN$, FILL, GRAB, PUT, XOS, YOS, XRG, YRG (axis offset and range), ROLL, SCROLL, WINDOW, RECORD TO string, RECORD STOP, BLITZ; MB: COPY SCREEN a TO b, ALTER DISPLAY a TO b LINE n, SCRAD
- sound: BEEP, SOUND, ZAP, POW, ZOOM, BOOM; MB: buffer, RECORD SOUND, CLEAR SOUND, BLITZ SOUND
- program and system administration: PAUSE, STOP, ON ERROR, CONTINUE, POP (discard return address), KEYIN (allows program to self-modify, converts a string into a form of program line), SVAR, USR, CALL, IN, OUT, AUTO (start,step), RENUM (a TO b LINE f STEP s), LIST FORMAT (0-2) - structured listing; MB: editor and printer buffer, JOIN, split (/), REF - search, ALTER TO - replace, LINE (delay,STEP,OFF) - program tracing, LPRINT CLEAR, TIME, TICS, HIDE TO - system integrated hidden procedures, SAVE MODE, FSTAT, ALTER DEVICE drive TO drive, DIR$, INP$, LOCN
SAM BASIC in Numbers
- covers all memory area of 528 KBytes, programs up to 470 Kbytes long
- up to 65279 lines in any one program, up to 16127 bytes and 127 individual statements per line
- strings up to 65520 characters long, arrays can fill all available memory
- up to 65535 items in one dimension of data array
- names of numerical variables up to 32 characters long
- names of strings and arrays up to 10 character long
- names of user-defined functions up to 32 characters long
Some complex programs were written in the SAM BASIC, e.g. the SAM Adventure System (SAS) or the 3D Graphics Engine.