What is the "SPECTRUM" keyword on a 128K?

The 128K replaced UDG characters T and U with new commands; PLAY and SPECTRUM (or possibly the other way around.)

The manual (here) makes a quick reference to typing "SPECTRUM" (and data loss?) and then immediately goes into great detail about the PLAY keyword and usage.

Naturally searching for "SPECTRUM" on Google doesn't really narrow things down so I wondered if anyone could tell me what it does and/or point me at some appropriate documentation?
Myke-P

Comments

  • edited October 2015
    It puts the Spectrum into 48k mode by paging in the 48k ROM, changing the printer channel info to address the ZX printer, and disabling the RAM paging. It neglects to clear the ZX printer buffer and reset the associated system variables, so that needs to be done by the user if they're going to use the ZX printer. Any BASIC program in RAM is preserved. Selecting "48 BASIC" from the menu has a similar effect, but this resets RAM so any program in memory is lost. Typing "USR 0" in 128 BASIC has a similar effect but this leaves the paging enabled IIRC.

    The 48k ROM page on the 128k models is not absolutely identical to the original 48k ROM (particularly on the +3), which causes some programs to fail. It's not possible to switch back to 128k mode with the available commands, although routines have been posted on this forum which do allow this.

    That manual page says that RAM disk data is "as good as lost" because paging is disabled and so the RAM disk is no longer accessible although it's still there.
    Post edited by Battle Bunny on
  • Aha. Thanks BB, that's pretty much answered that! :D
    Myke-P
  • The 48k ROM page on the 128k models is not absolutely identical to the original 48k ROM (particularly on the +3), which causes some programs to fail. It's not possible to switch back to 128k mode with the available commands, although routines have been posted on this forum which do allow this.
    The following command will allow +3 and +2A users to go back to +3/+2A BASIC:
    RANDOMIZE USR 23354
    
    As for the older 128K models, i haven't been able to find any similar command.

    Cheers :)
    Author of BertoMenus, soon to become BertoBASIC +3 ;)
    Feel free to help yourself to the Sinclair ZX Spectrum +3 Manual.pdf
  • The +3 also (ab)used the SPECTRUM keyword to add a Spectrum header onto headerless binary files created on other computers.
    COPY "file.com" TO SPECTRUM FORMAT
    
    Comp.Sys.Sinclair Crap Games Competition 2017
    Everyone has a crap game inside them, let yours out!
  • By the way, I forgot to mention that it was actually possible, on the +3/+2A, to go into 48K BASIC with the SPECTRUM command, insert UDGs "T" and "U" into PRINT statements in your program, then return to 128K using the aforementioned "USR 23354" and run the program with all 21 UDGs if need be. :)
    Author of BertoMenus, soon to become BertoBASIC +3 ;)
    Feel free to help yourself to the Sinclair ZX Spectrum +3 Manual.pdf
  • Why would you want to do that?

    If you do a POKE 23611,204 you enable (or disable) a flag that tells PRINT when to print UDG T and U or expand it to SPECTROM and PLAY keywords.

    It's easier to do a POKE 23611,204 and let the BASIC interpreter do the magic, instead of going and return to 48k mode every time you need to print something.
    I was there, too
    An' you know what they said?
    Well, some of it was true!
  • Zup wrote: »
    Why would you want to do that?

    If you do a POKE 23611,204 you enable (or disable) a flag that tells PRINT when to print UDG T and U or expand it to SPECTROM and PLAY keywords.

    It's easier to do a POKE 23611,204 and let the BASIC interpreter do the magic, instead of going and return to 48k mode every time you need to print something.

    I'm sorry if I expressed myself in an unclear way; I didn't mean that you had to go to 48K BASIC in order to print the "T" and "U" UDGS, that is only necessary to put them in your BASIC program. Once that is done, they will work just like any other UDG when run in 128K node. No need for POKEs either.

    I hope this clears it up. :)
    Author of BertoMenus, soon to become BertoBASIC +3 ;)
    Feel free to help yourself to the Sinclair ZX Spectrum +3 Manual.pdf
  • The_Bert wrote: »
    The following command will allow +3 and +2A users to go back to +3/+2A BASIC:
    RANDOMIZE USR 23354
    
    As for the older 128K models, i haven't been able to find any similar command.
    That 23354 (5B3Ah) is ONERR routine (in ZX Printer buffer), that switches back ROM 1. There is similar routine in 128 and +2, but it doesn't return to 128k BASIC mode.

    This might be a hardware difference; it says on the documentation that when outing to memory mapper port 0x7ffd, when bit 5 is set, "memory paging will be disabled and further output to this port will be ignored until the computer is reset". SPECTRUM command does that.

    Apparently this locking mechanism has been removed from the later models, although I haven't seen in docs about that.
  • edited October 2015
    Made some tests that conformed my assumptions: if you run SPECTRUM command, or select 48K BASIC from the start menu, there is no way to get back to the 128K BASIC editor mode, other than reseting the whole machine.

    The routine ONERR is there, on zx128 or +2 it's USR 23325, it just doesn't do much.

    However, it's possible to circumvent this by not using SPECTRUM, but a modified routine instead. I took the SPECTRUM routine from +2 ROM0 disassembly, and here is my modified (+2) version:
    SWAP	EQU	#5B00
    MAIN_4	EQU	#1303
    PRINT_A_1	EQU #10
    ERROR_1	EQU 8
    OVERW_P	EQU #1B72	; #1B53 on Spectrum128
    BANK_M	EQU #5B5C
    
    	ORG	46000
    ; ----------------
    ; Modified SPECTRUM Routine
    ; ----------------
    L1B4A:
    	CALL SWAP	; Additional SWAP because now this is ran when ROM 1 is already active
    
    	CALL OVERW_P        ; Overwrite 'P' channel data to use the ZX Printer.
    	LD	SP,(#5C3D)   ; ERR_SP. Purge the stack.
    	POP  HL           ; Remove error handler address.
    	LD   HL,MAIN_4    ; $1303. The main execution loop within ROM 1.
    	PUSH HL           ;
    	LD	HL,PRINT_A_1+3
    	PUSH HL           ;
    	LD   HL,ERROR_1   ; $0008. The address of the error handler within ROM 1.
    	PUSH HL           ;
    
    	LD	A,0		; Removed BIT 5, the lock bit
    	LD (BANK_M),A   ; $5B5C.
    	JP	SWAP
    
    Now, if you load this in 128K editor mode, and do RANDOMIZE USR 46000 (or whatever ORG you'll use), you should end up to 48K mode. But this time, RANDOMIZE USR 23325 works, and gets you back to the 128K editor!

    Note: the routine to overwrite 'P' channel data is in different address in different roms. I haven't tested yet if it's even necessary to call that routine. And, that ONERR routine is placed in the ZX Printer buffer, so you'll better not use ZX Printer or anything else that may overwrite that.
    Post edited by zPasi on
  • The Spanish 128K lacked the menu of the UK model, so the SPECTRUM command was the intended way for users to switch to 48K BASIC mode on those machines.

    Cheveron informs me that the failure to clear the the print buffer is indeed a bug, fixed in his “Derby Plus” ROM.

    The ROM of the “128Ke” brings back the two UDGs, although SPECTRUM and PLAY can still be used in the editor.
    FUSE: the Free Unix Spectrum Emulator, also for Windows, OS X and more!
    http://fuse-emulator.sourceforge.net/
  • a few here are saying that on earlier machines that the SPECTRUM command caused locking (bit 5) of PAGING. I don't think this happens on any model. The first thing the original version of DTST128 does is a SPECTRUM command with an IM2 routine to type "GOTO 20" just to get the system in USR0 mode! (I guess this was before other ways of getting into USR0 mode were known)
  • Indeed. Part 24 of the +3 manual seems to agree:

    "If a 48K Spectrum game loaded from disk will
    not work, it is possible that by using the SPECTRUM command followed
    by 'OUT 32765,48' (which locks bit 5 in this port), the game might
    then work."
  • zubzub
    edited October 2015
    Oh, I guess that’s why choosing 48K mode using the “SPECTRUM” statement on an English Toastrack or grey +2 fails to prevent “IN 32765” from crashing, and why all of the Ultimate games still fail when you enter 48K mode that way.

    Except... wait a minute.
    Post edited by zub on
    FUSE: the Free Unix Spectrum Emulator, also for Windows, OS X and more!
    http://fuse-emulator.sourceforge.net/
  • BTW, as a courtesy, could people please stop posting blatantly incorrect information of the kind that will cause pretty much any emulator author reading to have a mini-heart–attack, thinking “oh cr*p, that’s not what happens in my emulator!”

    kthxbye
    FUSE: the Free Unix Spectrum Emulator, also for Windows, OS X and more!
    http://fuse-emulator.sourceforge.net/
  • I'm not sure why emulator authors would ever care what BASIC does, they just need to emulate the locking and it'd behave correctly.

    FWIW, 5 minutes playing around in SPUD suggests that the old 128s sets bit 5 (thereby locking the paging hardware) when you select 48 BASIC from the menu or when you issue a SPECTRUM command.

    In contrast, the +2A/+3 seemingly only sets bit 5 when you select 48 BASIC from the menu. The SPECTRUM command instead leaves the paging active in much the same way USR0 mode did.
  • zubzub
    edited October 2015
    AndyC wrote: »
    I'm not sure why emulator authors would ever care what BASIC does, they just need to emulate the locking and it'd behave correctly.
    Which you test, how, exactly?

    When saying that the SPECTRUM command really shouldn’t set the locking bit even on a toastrack, effectively that’s saying that our emulation is incorrect in some way. Given that it is correct, this is most unhelpful. I’m not sure how thoroughly you read the the post making that claim, but it’s best to avoid backing up wild speculation.

    Thanks for explaining about the +2A/+3. I did not know this.
    Post edited by zub on
    FUSE: the Free Unix Spectrum Emulator, also for Windows, OS X and more!
    http://fuse-emulator.sourceforge.net/
  • I don't think anyone was expecting there to be differences. As someone coming from a +2A background, I certainly was confused by the idea it would lock the paging and I suspect, if I was an emulator author, I'd have been just as likely to have a "mini-heart-attack" at your suggestion that it should be locked. Open discussion of things, even when someone's assumptions are just wrong, is always preferable in my mind. I've certainly learnt something, and answered an old mystery of why so many people insisted you needed to use "USR 0" instead of just SPECTRUM, when I've never known there to be an actual difference.
  • I have just tested with the version 4.1 of the +3 ROM and found that this version is not affected. Both the SPECTRUM command and choosing the “48K BASIC” menu entry cause the paging to be locked. The 128K toastrack and grey +2 do the same.

    With the 4.0 +3 ROM, the SPECTRUM command leaves paging unlocked, but the “48K BASIC” menu entry does lock paging. With this version, the status message for SPECTRUM is “OUT 7I, 0:1” instead of the “0 OK, 0:1” that is seen with the 4.0 ROM and with both the 128K toastrack and grey +2.

    I have checked Ian Collier’s +3 bugs list and couldn’t find anything that addressed this particular issue. The “OUT 7I, 0:1” message and the difference in behaviour would seem to imply that this was a bug. I’d wondered if the idea was to allow access to +3 disks from 48K BASIC, but perhaps that is unlikely. If anyone can further shed light on this, I’d be quite grateful!

    I certainly have learnt a lot from this, too! Open discussion is certainly a good thing. :-)

    There was a possibility that we’d have been left with yet another bit of misinformation floating around, though. All I’m really saying it’s quite easy to do a bit of basic fact checking, and that rather than engaging in idle speculation, it is well worth doing this to improve the SNR on the forums.

    AndyC, please do understand that my words were not particularly aimed at your comment, as you very helpfully confirmed what is said in the +3 manual. I hope you can recognise my exasperation: this was more of a case of “oh no, not again” rather than a particularly targeted dig. I’ll admit, I should have walked away for five minutes to cool off instead of just hitting “Post Comment”. The problem I find is that I have done the walk-away-for-five-minutes thing for so much of the nonsense that gets posted on WoSf, that there’s bound to be an occasion, sooner or later, that my frustration gets the better of me. This was that occasion. I’d read your post as passive supporting the conclusion that had been leapt to, and perhaps that was in error. I will say that you clearly could be bothered to do your research. Thank you for this!

    To further explain, I just find it a little exasperating when it feels to me like almost every other post on WoSf is is some wild claim that some has made up without checking. I know there’s not really that bad, but it could be far better. People often don’t go through the few simple steps to check before posting that I expect they would have taken if they were posting before September 1993. I’m afraid I’m not cynical enough to believe that we just have to accept things the way they are, even if everyone else has given up or left already. :)
    FUSE: the Free Unix Spectrum Emulator, also for Windows, OS X and more!
    http://fuse-emulator.sourceforge.net/
  • I think I recall reading in Crash that the "OUT 7I" message is because Amstrad changed what they thought was a spare 0FFh byte in the ROM to make the checksum come out right -- except it turned out the byte was used, as the error number for the RST 8 issued by the SPECTRUM command.

    A little experimentation reveals that the byte in question is at offset 13h in ROM 3. Change it back to 0FFh and the error message reverts to "0 OK". The paging remains unlocked, though.
  • OK, now I'm officially confused. The game to examine is the original Daley Thompson Supertest 128, the non-speedlock one with the "SWITCH" file. This has a "SPECTRUM" command in its loader which, even (and especially as this was the only available speccy at the time) on a toastrack, does not lock paging, although issuing a SPECTRUM command on toastrack, in basic mode, does. What gives here?
  • I think I recall reading in Crash that the "OUT 7I" message is because Amstrad changed what they thought was a spare 0FFh byte in the ROM to make the checksum come out right -- except it turned out the byte was used, as the error number for the RST 8 issued by the SPECTRUM command.

    A little experimentation reveals that the byte in question is at offset 13h in ROM 3. Change it back to 0FFh and the error message reverts to "0 OK". The paging remains unlocked, though.

    Yes, been reading that article today!
    July 1988, No54 Empire Strikes Back cover, Pages 71/72
    Also features Simon Owen multiface stuff.
    I am from that generation, when Pluto was still a planet, and the Earth is round.

    Bomb Munchies on WOS thread
    Bomb Munchies Ver1930 17th Nov 2017 (look for the blue download box ) If you get a time-out message and live in the UK then try after 9pm-3am.
    Send me a PM and I can email it to you too. Kent, UK
  • OK, now I'm officially confused. The game to examine is the original Daley Thompson Supertest 128, the non-speedlock one with the "SWITCH" file. This has a "SPECTRUM" command in its loader which, even (and especially as this was the only available speccy at the time) on a toastrack, does not lock paging, although issuing a SPECTRUM command on toastrack, in basic mode, does. What gives here?

    As far as I can see, when DTST128 is simulating keyboard input, it also patches the 128k paging code in the printer buffer so that it always clears the lock bit before writing the value to the hardware. It replaces the 5 bytes at 5B00h with
      JP 9C67h
      NOP
      NOP
    
    and at 9C67:
      PUSH AF
      PUSH BC
      LD BC, 7FFDh
      LD A,(5B5Ch)
      AND 1Fh     ; Blank out the lock bit!
      LD (5B5Ch),A
      JP 5B05h
    
  • OK, now I'm officially confused. The game to examine is the original Daley Thompson Supertest 128, the non-speedlock one with the "SWITCH" file. This has a "SPECTRUM" command in its loader which, even (and especially as this was the only available speccy at the time) on a toastrack, does not lock paging, although issuing a SPECTRUM command on toastrack, in basic mode, does. What gives here?

    As far as I can see, when DTST128 is simulating keyboard input, it also patches the 128k paging code in the printer buffer so that it always clears the lock bit before writing the value to the hardware. It replaces the 5 bytes at 5B00h with
      JP 9C67h
      NOP
      NOP
    
    and at 9C67:
      PUSH AF
      PUSH BC
      LD BC, 7FFDh
      LD A,(5B5Ch)
      AND 1Fh     ; Blank out the lock bit!
      LD (5B5Ch),A
      JP 5B05h
    
  • ok, smart ;) thanks for sleuthing it.
  • zubzub
    edited October 2015
    MatGubbins wrote: »
    Yes, been reading that article today!
    July 1988, No54 Empire Strikes Back cover, Pages 71/72
    Also features Simon Owen multiface stuff.
    Thanks!

    It’s on archive.org, if anyone’s interested. The part about the OUT 7I bug starts in bottom-right corner of that page, and is titled “Yet More Amstrad Bugs”.
    Post edited by zub on
    FUSE: the Free Unix Spectrum Emulator, also for Windows, OS X and more!
    http://fuse-emulator.sourceforge.net/
  • The_Bert wrote: »
    The 48k ROM page on the 128k models is not absolutely identical to the original 48k ROM (particularly on the +3), which causes some programs to fail. It's not possible to switch back to 128k mode with the available commands, although routines have been posted on this forum which do allow this.
    The following command will allow +3 and +2A users to go back to +3/+2A BASIC:
    RANDOMIZE USR 23354
    
    As for the older 128K models, i haven't been able to find any similar command.

    Cheers :)

    nice for the Basic tricks and tips section

    my old website http://home.hccnet.nl/c.born/ has changed to http://www.cborn.nl/zxfiles/ so just click it and select a file
Sign In or Register to comment.