BASin and the 128k

BASin

BASin and the 128k Spectrum

Although BASin's emulation is based upon the more reliable and robust 48k Spectrum, it has extra functionality to provide the enhancements to BASIC that the 128k Spectrums brought.

The sound is enhanced over the simple beeper of the 48k, by using an AY-3-8912 sound chip, which enables the BASIC to produce three channel sound and white noise, with full envelope control.

The extra memory of the 128k Spectrum is available to BASIC via the silicon disc which is a "virtual disk" system providing 64kb of storage space which is almost instant to access. With careful programming and judicious use of the MERGE command, up to 91kb of BASIC program can be stored at any one time.

128k Commands

BASin will allow you to use the extra sound and silicon disc systems by "branching" the emulation out to the 128k +2 rom and AY-3-8912 sound chip as commands are intepreted. The commands given are...

PLAY 
LOAD !
SAVE !
MERGE !
CAT
ERASE

For instruction on how to use these commands, see the following sections of this help file...

The following keyword reference sections may also be useful...

Limitations of the 128k BASIC - UDGs

The extra commands, PLAY and SPECTRUM had to be housed somewhere in the character set - all keywords in BASIC are stored in this manner. The designers decided that in order to accomodate the new commands, the last two User-Defined Graphics ("T" and "U") would be given over to them. This means that some programs, when run in 128k mode, will display these graphics characters incorrectly.

Because of this limitation, BASin will only replace these UDGs with their command-replacements if your program makes use of the silicon disc or PLAY command. This is worth bearing in mind if you would like to use them. As an example, the program "frogger" from the BASin examples, displays correctly when run in a 48k mode...

Frogger in 48k Mode

...and as you can see, all the graphics are accounted for and display well. However, placing a PLAY command anywhere in the game produces a quite drastic and undesireable effect...

Frogger in 128k Mode

...where all the instances of UDGs "T" and "U" have been replaced with "SPECTRUM" and "PLAY". This kind of thing was common in BASIC games designed on the 48k spectrum and run on the 128k without modification.

Limitations of the 128k BASIC - Printing

In order to provide a full 128kb of memory in the later Spectrum models, the designers utilised an ingenious method of "paging" - pages of RAM could be swapped into and out of the upper memory at will.

Also, to provide the extra commands for the silicon disc and AY chip, two ROMs were used, which could be swapped in a similar manner to the RAM pages in upper memory. Of course, when one ROM was paged in it would need to know that it had to page itself back out to allow the main ROM to resume control. This was not possible for the 48k ROM that lived behind the newer 128k ROM - it had to be an exact copy of the original 48k ROM for compatibility reasons, and this ROM had not been designed for paging systems.

This meant that an area of RAM had to be allocated which the 48k ROM, when it had finished the job it was called for, would jump back to. This area contains code that swaps the 128k ROM back in. Because the 128k Spectrum used an RS-232 port to communicate with more advanced printers, it was felt that the printer buffer utilised by the 48k ROM was no longer needed, and as such this area was reclaimed for the paging system and some more system variables which contained information about the silicon disk, amongst other things.

Because BASin allows the user to use the old 48k printer routines, then the use of the commands for it will try to read (and write) to the buffer region maintained by the paging system. The repercussions of this are that if any printing commands (LPRINT, LLIST) are used after a 128k command, at best you will see garbage on your printout, and at worst it may crash the emulated spectrum. If you use the printer commands with silicon disk commands, you may find that the silicon disc becomes corrupted, which may in turn also crash the emulation.

So if you're going to use 128k commands, then please avoid the use of the ZX Printer support.

BASin's 48k/128k program state indicator

To help remind you which computer your program is compatible with, BASin provides a small indicator at the bottom of the editor window. This is updated as you create or edit your program, and appears like this...

The indicator for 48k BASIC mode

As you enter commands into BASin, this indicator will remain in "48k mode" until you enter a 128k command which utilises the enhanced sound (PLAY) or the silicon disc (LOAD !, SAVE !, MERGE !, CAT ! and ERASE !). When BASin detects these, the indicator will change...

The indicator for 128k BASIC mode

...and when this happens you may also notice that any instances of the UDGs "T" and "U" will change to their small-character hexadecimal equivalents.

Removing 128k commands from your program will revert it back to 48k mode.

The Program Information Window will also display compatibility information based on your usage of 128k features.

Note: Snapshots saved by BASin will differ in behaviour if they are 128k hardware-based. See the section on Loading and saving snapshots for more information.