48K Disk BASIC Preliminary notes Inserting the 48K Disk BASIC program disk and selecting the +3 'Loader' option will enter the +3 into 48K Disk BASIC (48KDB) mode. The 48KDB program is approximately 22K long. It occupies two pages of memory (the rest is used for work space for the CAT program and other things). Unfortunately, therefore, the RAM disk has a capacity of only 26K. The program operates in 4,5,6,3 Extended Paging mode, since this is the only configuration with RAM in the area 00000 to 3FFF, which has a screen, and which doesn't use page 7. This means that (a) The "ROM" program runs in contended RAM, and (b) whenever a program is to be run in +3 mode, some memory swapping should be done. These prove to be minor inconveniences, but no more. (a) means that the beep routine works by calling the ROM3 version, and that the tape SAVE and LOAD routines do not work and are therefore replaced by others. Note: This means that programs which call the tape routines do not work in 48KDB mode. (b) means that some commands have a .7 second delay on starting up and ending - but some routines get away without doing memory swapping. In addition, the page of memory from 8000 to BFFF is contended RAM, whereas in 48K and +3 modes it is not. Other notes: The ZX printer is not supported by 48KDB since the system variables occupy the printer buffer, and also because the space is needed for other routines. The disk motor timer is not practicable to implement, therefore the motor is turned off at the end of each disk command - this can sometimes cause minor delays. The 48KDB program requires system variables, in particular routines which do not move when the memory configuration is changed. These are therefore stored below CHANS starting at 23734 and occupy about 550 bytes (just less than a microdrive channel!). They persist through 48KDB NEW and USR 0 commands, but not through the +3 NEW command. It is possible to re-enter +3 mode; this is done by pressing extended mode V (which is usually LLIST), whereupon the token "UNSPEC" will appear (this is supposed to be short for "Un-Spectrum") (LLIST is now achieved using LIST #3). When that has been done, 48KDB mode may be regained with the command "print usr 23734". These commands may be used in BASIC programs. There is an error in the +3 which causes some centronics printers (notably mine, which was made by Esprit Systems) not to work. The error has the effect that STROBE is usually low, whereas it is supposed to be usually high. On entering 48KDB mode, STROBE is set high, and remains so until +3 mode is entered and an error report has been generated there. Hence all centronics printers (and in particular, mine) should work in 48KDB mode. During RS232 and Centronics communication when in 48KDB mode, the border will turn green. This can be changed by poking 23973 with a new value. Bit 3 is usually set (but by altering bits 3 and 4 you can cause tones to be heard). The 48K mode: There are several changes to the normal 48K ROM (which were originally implemented in an EPROM fitted to a 48K spectrum and have transferred virtually unchanged): - Initialisation (changes to message, colours, PIP, REPPER and RASP) - Character set - Tokens GOTO and GOSUB (without spaces - that's just my preference!) - Various changes where indicated in The Complete Spectrum ROM Disassembly (e.g. printing of character codes 8 and 9; 34th bit of division; extra stack store during STR$ and SCREEN$; handling of -65536 - note that the correction listed is incorrect!) - The error routine contains an EI as well as a halt - The TEST ROOM routine uses RST 8 if there is not enough room (I think I added this for the Interface I, so it is probably no longer necessary). - The LIST command acts like the BBC's, unless immediately followed by a star - so LIST 5 lists only line 5 while LIST,7 lists all lines up to 7; LIST 7, lists line 7 and subsequent lines; LIST 4,9 lists all lines between 4 and 9. No current line cursor is shown, but EDIT will always bring down the first line listed. - There is a BBC-type editing system in addition to the normal one. Holding down extended mode (or symbol-shift) whilst pressing the cursor keys moves a flashing square around the screen; 0 (or delete) copies the character under the square to the cursor (all graphics and inverse characters work - but note that a CHR$ 143 is always chosen in preference to an inverse space). This works at speed REPPER regardless of the length of the input line. This routine requires 8 bytes of system variables which in the EPROM version ocupied the top 8 bytes of memory - that is, the graphic store for graphic U. This is (as yet) unchanged in the +3 version. - There is a tokenizing routine (necessitated by the BBC-edit routine) which tokenizes all upper case words not in quotes. If the very first character in the edit line is a quote, it is ignored, enabling "K" mode to be circumvented in order to type out the keywords. (Unfortunately this feature is occasionally an inconvenience as it's not really intelligent enough. The main problem occurs in REMs). - A non-maskable interrupt routine is added. It waits for a key press, which should be N, space or V. Pressing N causes a NEW operation with RAMTOP set at 24399 - thus most of the memory is preserved whilst the BASIC system is restored. This should be guaranteed to work, unless the "ROM" has been changed. Pressing space causes the same action, if it is obvious that the BASIC system variables are corrupt; otherwise the routine attempts to return to the BASIC environment as it is, with the message "NMI break". In this case the machine stack is not cleared, and the registers are stored in the TSTACK and STRIP areas as follows: 23420 (bit 2) interrupt flag 23422 AF 23424 HL 23426 DE 23428 BC 23430 AF' 23432 HL' 23434 DE' 23436 BC' 23438 IX 23440 IY 23442 SP (points to interrupt return address) Until a CLEAR is executed or another error is reported, issuing a CONTINUE command will attempt to return to the program. Pressing V will result in a beep; you should then enter exactly four hex digits, whereupon a program at that address will be called exactly as if the interrupted program had called it. Any RET will then return control directly to the interrupted program. +3 BASIC Commands All normal BASIC commands remain, except for the modifications mentioned above. The extra commands SPECTRUM and PLAY are not implemented. The disk commands SAVE, LOAD, VERIFY, MERGE, ERASE, MOVE, FORMAT and CAT are all implemented via calls to the +3 ROM (the FORMAT commands which deal with the printer are also implemented. Note that the VERIFY command only works for tape). The former four commands are subject to the .7 second delay when starting and finishing, as described above. Unfortunately this means a 1.4 second delay even when you just want to change the default drive. Long sequences of these commands can be speeded up by putting UNSPEC before and PRINT USR 23734 after the sequence. Extended Commands: The SAVE, LOAD, VERIFY and MERGE commands have been extended to allow transmission of data in Interface 1 RS232 format. These extended commands just use a star in place of the filename; all other syntax is the same - so, for example, SAVE * SCREEN$ transmits the screen via RS232 to another +3 using LOAD * SCREEN$ or to a spectrum using the interface I command LOAD *"b" SCREEN$. The RS232 should be selected and set to the correct baud rate for this to work. The CAT command is extended, so a new command 'CAT *', which has the same syntax as CAT itself, causes not only file names, but also file details to appear on the screen (this command takes longer to operate, as it needs to load the relevant information from each file). This command searches all user areas (see p.146 of the manual); the user areas are listed in order with a heading (such as '10:') for each area except zero. Wildcard characters in filenames are treated similarly to those in +3 commands, but are extended so that stars are allowed in any position and question marks stand for exactly one character even at the end of a name (i.e. they do not match spaces). This CAT command looks for, and prints out at the top of the catalogue, a disk name which may be stored at the start of the last reserved sector (as long as the disk has one or more reserved tracks). This is, of course, non-standard. An example program is supplied ("relabel") to write a name onto a disk. When you call 32000, the program reads the disk details and then (if the disk has a reserved track) inputs a name which it writes in the correct place to be recognised by the CAT routine. The CAT routine uses DOS OPEN DRIVE to examine the disk and so there are certain restrictions on the format. Most disks having 512-byte sectors, 1K blocks and at most 128 files on them should work, however. When using the extended catalogue on the "M:" disk you may notice that some files have "unknown data type" or nonsense attributes; this is because CAT does not do any memory swapping (so it happens immediately) and so some of the files on "M:" are not in the correct position in memory. The COPY (file copying) command has been extended. It can carry out the same functions as before, the only change being that part of the 'CAT *' command is used to search for files (this means that user numbers are not allowed in source file names, but that files in all user areas are copied. Also the extended wildcard characters may be used) - it is used even if only one file is being copied (so you can abbreviate filenames, as long as the abbreviation matches a unique file. For example, on a disk containing "disk", "disk.bin" and "disk.fse", COPY "*.fse" TO "m:this" works, as does COPY "d*k.*" to "m:", but COPY "d*k.*" TO "m:this" produces the error "Destination must be drive" as in +3 mode). These COPY functions are carried out without overwriting BASIC memory, unlike the +3 COPY command, which uses 2048 bytes of memory starting at 60689. In addition to copying files between disks, the COPY command can copy to/from tape, using the "T:" drive specifier. During copying to tape, the name of the tape file (unless specified) will be its disk name with spaces removed, truncated to 10 characters. When copying from tape, either a unique file name or just "T:" must be used for the source name. The latter copies every file which is played in on the tape, until a break in occurs (or another error such as disk full). BASIC memory is used for tape copy; if a file fits in the screen, the screen is used, otherwise RAMTOP is expected to be low enough to fit the file in (it is loaded as high as possible, so that its last byte is at 65535). If RAMTOP is not correct, the error "Ramtop no good" is issued. The COPY command cannot copy from tape to tape. The drive name "R:" is used to denote RS232; files can be copied to and from here (in Interface-1 format). The other forms of the COPY command are not supported.