Your Spectrum
YS MegaBasic manual - The New Commands
Home YS MegaBasic Contents

THE NEW COMMANDS

You'll find here a brief description of every new command in YS MegaBasic. A single letter is used to represent a numeric expression and a single letter followed by a dollar sign ($) represents a string expression. Check the given page for a full explanation of the syntax offered.
AUTO_a,b This command causes the MegaSpectrum to produce a line number every time the user presses Enter in immediate mode. To stop the computer producing line numbers, press the equals ('=') key in Extended mode and then press Enter.
BACKUP (WARNING: this command destroys any program already in memory.)
'BACKUP' is used to copy tape files. When you execute the 'BACKUP' command you'll get the "Start tape " message on-screen and, as soon as the MegaSpectrum detects a signal from the EAR socket, it'll display the "OK searching " message and load the next file from tape (the file type doesn't matter). Once the file has loaded you'll get the "Start tape, then press any key " message; when you're ready to save the file back to tape, press a key and the file will be re-saved. That done, the MegaSpectrum will ask if you want another copy - press the 'Y' key if you do (and the 'N' key if you don't), and the MegaSpectrum will search for the next file on tape. You can break out of this command while the MegaSpectrum is saving or loading in the normal way, but do note that if a file is longer than about 20K, the system may crash. Always execute the NEW command after 'BACKUP' has been executed.
BRANCH_n This instruction causes a subroutine to be called at the end of every program line. The subroutine is terminated by 'ENDPROC_'.
BROFF Enter the 'BROFF' command and you'll find that the Break key has been disabled. Note that the Break key will still function during input or output operations.
BRON Use this to re-enable the Break key after you've used the 'BROFF' command.
24

CALL_a(,n,n...) This calls a machine code routine at address 'a'. The address may be followed by a number of numeric expressions. Each of the expressions is evaluated and the result pushed onto the machine stack, the last expression will be the stack's top value. The machine code routine removes all values from the stack and should be terminated by a Z80 'RET' instruction.
CHANGE_a,b This command is used to manipulate the attributes file, where 'a' represents the mask and 'b' the data. The mask is negated with each attribute byte; the data is then ORed with each attribute byte.
CLW_(n),h Use this instruction to clear windows. If two numbers are supplied, then the first is that of the window to be cleared; where only one number is supplied then the current window is used.
CURRENT_n This makes window 'n' the 'current' window - that is, all subsequent PRINT statements will now use this window.
DEFG_a$,n... The 'DEFG_' command allows you to define a user- defined graphic, where a$ shows which graphic is to be defined and up to eight numbers (n,n,etc) represent the required binary pattern.
DELETE_a,b You'd use this command to delete a block of program lines, where 'a' is the first line number of the block and 'b' the last. If the value of 'a' is greater than 'b' then the error message "B Integer out of range" is displayed on-screen.
DOKE_a,b This command represents a two-byte POKE that's equivalent to:
POKE a,b-256*INT(b/256)
POKE a+1,INT(b/256)
DOWN_y,x,a$ This instruction prints a string downwards in the current window. If a string goes off the bottom of a window then it wraps around to the top.
EDIT_n Use this to display line 'n' in the input line and activate the line-editor.
ENDPROC_n This defines the end of a procedure. The name of the procedure (n) can be tagged on to the end of the command.
25

EXAMINE This command displays the type, name, length and start of any files found on tape. To escape from it, use the Break key in the normal way.
FADE_n This decrements each byte in the attributes file unless it's already equal to 'n'. The process is repeated until all bytes have achieved that value.
FONT_n This instruction selects the current character set. It has no effect in Mode 1 (which uses its own special character set).
FX_n,m This controls the on-screen operation of the YS MegaBasic system.
GET_0,a,y,x,d,w Use this command to copy an area of the screen into memory.
INVERT This instruction inverts the whole screen, changing INK to PAPER and PAPER to INK.
KEY_n,a$ Use this command to define a user defined key, where 'n' is the number of the key to be defined and 'a$' is the string of characters to be assigned to the key.
MODE_(n),a This is used to select the size of the characters for screen output. An optional number can be used to select the required window (see 'CLW_').
MON Use this to call up the front-panel display. It allows the user to alter and examine the memory and registers of the Z80. To return to YS MegaBasic, press the Space bar.
MTASK_n The command which allows a YS MegaBasic program to be executed from two different places at once, offering in effect a simple form of multi-tasking.
PAN_n,m Enables the user to scroll the current window sideways pixel by pixel; this command only scrolls the display file - the attributes are left alone.
PANW_m This is very much like 'PAN_' but this time the contents of the window wrap around.
PCLEAR This instruction clears the PROCedures / REPEAT-UNTIL stack and should be executed at the beginning of every program involving the use of procedures or 'REPEAT-UNTIL' loops.
26

PLAY_n,l,s,d,f A command used to produce sound effects. Those wanting to produce tunes will find the conventional BEEP command more suitable.
POP_n This instruction causes a value (n) from the PROCedure / REPEAT-UNTIL stack to be removed. If the command is executed when the stack is already empty, you'll get a "PROC stack underflow" error message displayed on-screen.
PRINTER_n Use this to send output to a peripheral other than the screen - for example, a printer.
PUSH_n,m This command pushes a value on to the PROCedure / REPEAT-UNTIL stack. If the stack's full, you'll get a "PROC stack overflow" error message on-screen.
PUT_f,a,y,x,d,w This puts an area of memory on to the screen; it's the opposite of the 'GET_' command.
REPEAT The 'REPEAT' command defines the beginning of a REPEAT-UNTIL loop. If the PROCedure / REPEAT-UNTIL stack is full, a "PROC stack overflow" error message flashes up on-screen.
RESTART_n This is the YS MegaBasic equivalent of the more common 'ON ERROR GOTO' command you'll find in other Basics. 'RESTART_' will not trap errors concerning Interface 1 or new YS MegaBasic errors.
RESTART_OFF Use this to make the MegaSpectrum act as normal when an error occurs.
SCROLL_n,m This command scrolls the current window up or down, pixel by pixel.
SCROLLW_m Like 'SCROLL_' but here the contents of the window are wrapped around.
SOFF This turns off the interrupt sound generator (ISG).
SON This turns on the interrupt sound generator (ISG).
SPEED_n This command controls the speed of program execution when the trace function is active (see 'TRON').
SPRINT_x,y,a,b,c$ A command that prints strings on the screen using characters whose size can be pre-defined by the user.
27

SPROFF_n,m Use this instruction to turn off sprite operation.
SPRON_n,m Use this command to turn on sprite operation.
SPUT_a,x,y,b,c,w,d Like 'PUT_', with this instruction you can display an area of memory on the screen. Here though, the result is magnified by factors 'b' and 'c' in the x and y directions respectively.
SREP_n This instruction indicates if the interrupt sound generator (ISG) should repeat the sounds in the sound buffer.
STIPPLE_n This command defines the stipple pattern to be used for Mode 4 printing.
SWAP_n,m Use this to manipulate the attributes file; one attribute (m) is swapped for another (n).
TRON Use 'TRON' to turn the trace function on. After the command has been executed the current line number is displayed in the bottom left-hand corner of the screen.
TROFF The command that turns the trace function off.
UNTIL_a This command is used to mark the end of a 'REPEAT-UNTIL' loop.
VDU_a(,a...) This is directly equivalent to the command 'PRINT CHR$ a'; 'a' may be repeated so that you can print more than one character at a time.
WINDOW_y,x,d,w This command defines the size and position of the current window.
28