Your Spectrum
Issue 8, October 1984 - YS MegaBasic
Home Contents KwikPik

A number of the features of YS MegaBasic v.1 differ from the descriptions of them in this article.
Also, the Window Demo Program listing at the bottom of the first page has several errors in it
(I've included a corrected one at the end of the article).

The YS MegaBasic manual is on the Spot's Pourri page.


C O V E R   S T O R Y
MegaBasic logo
M E G A B A S I C
Announcing ... the ultimate software sensation - Mike Leaman's MegaBasic - a completely new concept in Spectrum programming. Discover the delights of QL-style windows, sprites galore, stunning sound effects, single letter entry, named procedures ... and much, much more!!
YS MegaBasic is a machine code program which dramatically enhances the capabilities of the 48K Spectrum. Mike Leaman's long-time labour of love leaves the user with about 22K of usable memory, while at the same time providing the kind of features you'd expect to find on a computer five times the price - windows, different character sizes and fonts, procedures, as well as stack of new commands. Not only that, the program was written specifically to iron out the Speccy horror number one... the non- standard keyword entry system.
Overall, YS MegaBasic is a unique way of upgrading the Spectrum - and one which doesn't involve paying out huge sums of money for expensive pieces of hardware. Fancy a trip to new worlds of Spectrum versatility? Then read on!

KEYBOARD MAGIC

Just take a look at the way the keyboard operates under YS MegaBasic. The keys now work as they would on a 'normal' computer, that is they only give single ASCII characters; now, all commands
and functions have to be typed in letter by letter. This will allow the YS MegaBasic owner to use all the new commands easily and, of course, any user new to the Spectrum will no longer have to convert to Sinclair Research's idiosyncratic keyword system.
In the land of YS MegaBasic, the Space key is used as a new Shift key and that's how you squeeze all the new functions out of the keyboard. Just one single key stroke, for example, will RUN the current program in memory or LOAD and RUN the next program on tape!
Lo and behold, the Spectrum is now provided with user-defined keys. The top row (keys '1' to '0') can be programmed to produce a string of up to 255 characters. What's more, the usual 'hack' method of editing on the Speccy has been replaced by a slick sequence that's more reminiscent of the BBC Micro. The method used involves the use of a second cursor which can be moved around the screen independently of the usual input cursor. Text can be copied from the second cursor to the input cursor by just a
single keystroke.
The standard Spectrum screen divides up into two parts ... YS MegaBasic employs three! There's a section for inputting commands and displaying error messages, another for program output, and finally an area for automatic listings. The size and position of these screen areas are completely user-definable, and the same area can even by used for two (or all three) functions.

SCREEN DREAMS

YS MegaBasic has done amazing things to the Spectrum's screen output facilities. Now, it offers no less than three different sizes of character:
1. 64 columns by 24 lines Here, even though the width of each character is halved, the characters still remain quite clear - even on a standard TV set. This size of character is ideal for applications like word processing.
2. 32 columns by 24 lines This is the normal size used by the standard Spectrum.
3. 32 columns by 12 lines Now you can
This listing as printed in the magazine has several errors in it; see the end of the article for a corrected version.
WINDOW DEMO PROGRAM
5 Set up the initial colours

40 Stops the screen being corrupted by the 'OK' message.

60 Sets the position and dimension of each window.

80-110 Print the text up on the screen in different colours (pretty standard Basic this!).
   5 BORDER 0: INK 9
  10 DISPLAY_3,64,18,0,0," DOUBLE HEIGHT ";
  20 DISPLAY_2,32,8,0,16," NORMAL SIZE   ";
  30 DISPLAY_1,32,8,32,16,"  64 COLUMNS   ";
  40 GO TO 40
  50 @DISPLAY_M|XS|YS|X|Y|A$
  60 WINDOW_Y,X,YS,XS
  70 MODE_M:FONT_0
  80 FOR A=0 TO 7: IF A=4 THEN FONT_1
  90 PAPER A
 100 PRINT A$;
 110 NEXT A
 120 RETURN
	
10-30 The procedures used to define the text in each of the three windows - each procedure calls line 50 to define the 'display' subroutine.

50 Defines the 'display' subroutine.

70 Selects the required character size and the standard character set.

120 Returns from the subroutine.

C O V E R   S T O R Y
WINDOW DEMO
The input part of the screen - whatever you type comes up in this window. It's also the area used for editing; to edit a line you simply type EDIT_10, for example, and the line will be printed up so that you can edit it BBC micro-style. Window Demo 1 Once you've typed in a section of program, if you press the Enter key again the program lines will be LISTed to this area of the screen.

When you type RUN (or execute a direct command) the program's output will be displayed in this window.
The screen format for the input/output of YS MegaBasic. Note that, although the screen layout is set originally for three windows carrying out the tasks illustrated above, under software control the window's size and purpose can be changed.
YS MEGABASIC COMMANDS
COMMAND COMMENT
AUTO Causes the computer to automatically produce line numbers
BACKUP Copies tape files
CHANGE Manipulates the attributes file
CLW Clears the current window on-screen
CURRENT Changes the window used for screen output
DELETE Erases a block of YS MegaBasic program lines
DOWN Prints a string down the screen
EDIT Displays a program line for editing
EXAMINE Displays headers of tape files
FADE Produces special effects on-screen
FONT Selects the character set used for printing
FX Handles miscellaneous functions of YS MegaBasic
INVERT Changes INK to PAPER and vice versa
KEY Creates user-defined keys
MODE Changes the current character size
MON Jumps to front panel
PAN Scrolls a window to the left or right, pixel by pixel
PLAY Produces complex sound effects
RESTART YS MegaBasic's equivalent to ON ERROR GO TO
SPEED Used in conjunction with TRON to reduce the speed of program execution
SWAP Swaps one attribute for another
TROFF Turns 'trace' mechanism off
TRON Turns 'trace' mechanism on
VDU YS MegaBasic's equivalent to PRINT CHR$
WINDOW Defines the size and location of the current window on-screen
A brief explanation of the 25 new commands in YS MegaBasic - commands that should have been there in the first place?
enter any normal Basic command, each one being spelt out letter by letter. All commands can be entered into programs, and both new and standard commands can be mixed up together on the same line. The only difference between the two is that if a new command requires parameters, then an underline character must be placed between the
produce characters which are twice the normal height.
And another bonus ... when you're using options 2 and 3, it's also possible to select between two different character sets; in effect, this gives you five different ways of displaying characters on the Spectrum screen.
Ever thought you'd have a QL-like windowing system on the Speccy? Well, courtesy of YS MegaBasic, there's now a way of keeping the display confined to a particular area of the screen. The size and location of windows is totally user-definable, and different character sizes can also be mixed within the same window. The user can even switch between several different windows at any time; in fact, the total number of active windows is only really limited by the amount of memory available. Each window can be cleared or inverted individually, and scrolled up, down, left or right.

SMASH SPRITES

Now, for the first time ever, the Spectrum incorporates its own sprite routine. All

Although it might not make too much sense to you just yet, the listing on the left creates the display shown on the screen. You'll notice that, as well as producing three windows, the windows each contain multicoloured text in three character sizes: double height, normal height and that used for 64-columns. Look closely and you'll see that the double height and 'standard' size text comes in two different fonts.
Window Demo 2
you do is define the direction you want the sprite to move in and then send it on its way; once started, the sprite continues of its own accord. You can also define what happens when the sprite hits another graphic object ... it can either stop or keep moving.
A Speccy sprite is defined by bytes in memory - just as with a user-defined graphic - and each byte represents a horizontal line of eight pixels. Each sprite can be any multiple of eight pixels wide and any number of pixels deep. In addition, each square of eight by eight pixels can have its own attribute - so sprites can be multi-coloured!
With YS MegaBasic, your MegaSpectrum will automatically provide you with 10 sprites - although there are ways of getting more. Remember though, the speed at which your YS MegaBasic program runs is dependent on the size and number of sprites that you're using. The more sprites there are, and the larger their size, the slower your program will run.
Since defining sprites is a very complicated process, a 'sprite designer' program is supplied free with every copy of YS MegaBasic. The program allows you first to define the sprites on the screen, and encode them into memory as bytes. You can then save these bytes as CODE which can be loaded into your own programs.

MEGA COMMANDS

A whole bundle of new commands will fly to your fingertips - thanks to YS MegaBasic. For instance, there's ones to handle the windows and different character sizes - such as MODE, CURRENT, WINDOW and CLW. And commands are provided which make it easier to write programs - such as TRON, TROFF, AUTO, SPEED and DELETE. These are all entered into your MegaSpectrum just as you would

C O V E R   S T O R Y
command word and the start of the argument. For example, the command to print an 'A' character on the screen using the keyword 'VDU' would be VDU_65.
Although the existing keyboard system is non-standard and usually more of a hindrance than a help, it does actually have some advantage too. For example, when entering the command PRINT, it's quicker to stab the 'P' key than to press all five individual letters of the word. Well, the good news is that with YS Mega Basic, it's still possible to abbreviate some commands and functions (a list of minimum abbreviations can be seen as a separate table). You'll notice that the commands are input by way of a full stop, but the abbreviations are expanded out to their full form when they're displayed as a screen listing. Any word not included in the table cannot be abbreviated and has to be typed out in full.

CUSTOMISING POWER

Another neat little bonus is that it's possible to customise YS MegaBasic to suit your own particular needs - simply by adding named subroutines. The system is similar to procedures in other Basics, except you can't use local variables. Parameters can be passed to the subroutines just as normal and a subroutine is terminated by a Basic RETURN instruction. You activate it by entering its name, together with any parameters required. The word 'Proc' is not required. The named subroutine really does become just like another Basic command. For example:

10 @CHARA_Z
20 FOR A=Z TO 255
30 VDU_A
40 NEXT A
50 RETURN

The program example given shows how a named subroutine is defined. You activate it by entering 'CHARA_165', which results in the characters from 165 up to 255 being displayed on-screen. Subroutines can be called from anywhere in a YS MegaBasic program ... they can even call themselves. Thus, lines such as 'IF A$="TOKENS" THEN CHARA_165' are valid!

EXAM RESULTS

A small front-panel program is hidden in the depths of YS MegaBasic ... small and self-contained, and written in machine code (of course). It allows us to examine the internal workings of the MegaSpectrum, enabling the user to examine and alter memory and registers, execute machine code programs, set break-points, and move and fill blocks of memory. The program works with hexadecimal numbers only and you can activate it at any time by just pressing the Space bar and the 'F' key together. It can also be activated from within a program, by execution of the command MON.

FEATURES OF MEGABASIC

A. We've added all the commands Sinclair Research left on the drawing board!


C. ... essential if you're into word processing or you want to get down to business on the Spectrum.


E. If you've envied the BBC Micro's character set, all you need is YS MegaBasic.


G. Again, memory is the limiting factor, but with skillful programmingg you should be able to squeeze a few more on-screen.


I. The keyboard now acts as a 'proper' typewriter - there are no keywords, all must be spelled out. (Abbreviations are, of course, accepted!)
ZX BASIC SPECIFICATIONS
A. NUMBER OF COMMANDS
50 75
B. AMOUNT OF USER RAM AVAILABLE
41K 22K
C. MAXIMUM NUMBER OF SCREEN COLUMNS
32 64
D. NUMBER OF CHARACTER SIZES
1 3
E. NUMBER OF CHARACTER SETS
1 2
F. NUMBER OF WINDOWS
N/A 6
G. NUMBER OF SPRITES
N/A 10
H. SOUND
The BEEP command + more
I. KEYBOARD ENTRY SYSTEM
Keyword entry through a double shift system Now standard
J. LANGUAGE EXTENSION
N/A YES
B. You've less room in memory to play with - but look what you've got instead! Anyway, when was the last time you wrote a 22K program,?


D. Now you've got double height, standard size and half-width characters.


F. You can get six windows comfortably on-screen - even more if you've room left in memory.


H. As well as BEEP, you can also string together single channel pure notes and play around with white noise.


J. Defining procedures are permitted, allowing the language to be extended in YS MegaBasic.

YS MEGABASIC COMMAND ABBREVIATIONS

A.TTRGOS.UBPE.EK
BE.EPG.OTOPL.OT
B.INI.NKEY$P.OINT
BO.RDERINP.UTPR.INT
BR.IGHTINV.ERSERA.NDOMIZE
CH.R$L.ENRE.AD
CI.RCLELI.NERES.TORE
CLE.ARLL.ISTRET.URN
CL.OSE#LP.RINTR.ND
C.ODELO.ADSA.VE
CON.TINUEME.RGES.CREEN$
DA.TAM.OVEST.R$
D.EFFNNE.XTT.AB
DR.AWN.OTTH.EN
ER.ASEOP.EN#U.SR
E.XPOV.ERV.AL$
FL.ASHPA.PERVE.RIFY
F.ORMATPAU.SE
Introducing 'proper' keyboard entry on the Spectrum1 YS MegaBasic may at first seem to slow things down somewhat To combat this, YS MegaBasic allows 53 commands to be entered in a 'shorthand' format.

AND NEXT?

From next issue on, author Mike Leaman will be presenting a series of tutorials to help you along with YS MegaBasic - the software key to a new dimension of Spectrum computing. DON'T MISS IT!!
MegaBasic logo

YOU CANNOT BE SERIOUS ...

64-COLUMN TEXT?
THREE CHARACTER SIZES?
QL-STYLE WINDOWS?
TWO CHARACTER FONTS?
SPRITES GALORE?
SINGLE LETTER ENTRY?
NAMED PROCEDURES?

... ON A SPECTRUM!!??

 
Yes, it's all possible - once you've upgraded to a MegaSpectrum! Next month, you'll discover just how to lay your hands on your own copy of YS MegaBasic ... the inexpensive miracle on cassette. If you want to transform your Spectrum beyond your wildest dreams, hang on to this copy of YS (especially the YS MegaBasic token) and all will be revealed next month. See you there!

WINDOW DEMO PROGRAM - corrected version
   5 BORDER 0: INK 9
  10 DISPLAY_3,64,18,0,0,"         DOUBLE HEIGHT          "
  20 DISPLAY_2,32,8,0,16,"  NORMAL SIZE   "
  30 DISPLAY_1,32,8,32,16,"          64 COLUMNS            "
  40 GO TO 40
  50 @DISPLAY_M,XS,YS,X,Y,A$
  60 WINDOW_Y,X,YS,XS
  70 MODE_M:FONT_0
  80 FOR A=0 TO 7: IF A=4 THEN FONT_1
  90 PAPER A
 100 PRINT A$;
 110 NEXT A
 120 ENDPROC_DISPLAY

Home Contents KwikPik