CAT2String

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Post Reply
User avatar
cha05e90
Dizzy
Posts: 66
Joined: Sun Nov 19, 2017 7:02 pm

CAT2String

Post by cha05e90 »

Hi folks!

By pure chance I found this very interesting and informative web page: http://www.users.globalnet.co.uk/~jg27p ... ntents.htm

While scanning through the hints, tips and magic of (often) ZX BASIC mircales I stumbled across this little gem for the ZX Spectrum +3: CAT2String.BAS

Code: Select all

   2 DEF FN p(a)=PEEK a+256*PEEK (a+1)
  20 LET k1=0: LET k2=0: FOR a=0 TO 0: NEXT a
  21 DIM s$(200): POKE FN p(23631)+5,129: POKE FN p(23631)+6,15:
     LET k1=FN p(23643): CAT : LET k2=FN p(23643):
     POKE FN p(23631)+5,244: POKE FN p(23631)+6,9:
     FOR a=k1 TO k2-1: LET s$(a-k1+1)=CHR$ PEEK a: NEXT a:
     PRINT s$(TO a-k1)
  22 PAUSE 0: RANDOMIZE USR 5808: GO TO 21
It seems that this is done by (more or less) pure ZX BASIC. Is there any chance to adapt this for ZX Microdrive usage (48k/128k + ZX Interface 1) or is that something that works only with +3 systems?

I must admit I'm not really a pro when it comes to CHANNELS and STREAMS (and the corresponding system variable areas)...
48K/+/+/+/+128K/Vega/Next&80/81&88
User avatar
cha05e90
Dizzy
Posts: 66
Joined: Sun Nov 19, 2017 7:02 pm

Re: CAT2String

Post by cha05e90 »

I had some spare time last night ... :-) and rumbled through the sys vars section of the ZX Spectrum manuals and clicked through the Richards Online ROM disassembly (https://skoolkid.github.io/rom/).

To my own surprise this channel redirection pokery works well with a standard 48K and 128K ZX Spectrum plus ZX Interface 1 when replacing the original "CAT" with "CAT x" (x = ZX Microdrive no.). Sometimes it's nice to see that the original ROM is still in place (and charge).
48K/+/+/+/+128K/Vega/Next&80/81&88
Post Reply