Page 1 of 1

Re: BASIC: Find out if an Interface 1 is attached.

Posted: Sat Sep 21, 2019 6:03 am
by jpnz
There are some more suggestions from J.G. Hartson

His machine code approach is pretty versatile, and uses hook code 0x31 to initialize the IF1

It also traps for the non existence of the IF1 and will trigger a clean return to BASIC in either instance

There are other interfaces (Disciple and Plus D) that mirror the IF1 hook codes

Pretending I hadn't read what Seven.FFF had said about magic numbers(!),
you can potentially determine what interface (and version) has responded to hook code 0x31 by inspecting register pairs once control has returned to your own code...

For example, with an IF1 Version 2

de will be set at 0x0700 - the UNPAGE location that leaves the shadow ROM
hl will be set at 0x1e98 - the HOOK-31 location

With an IF1 Version 1, de will still be 0x0700, but hl will be set at a different location of 0x19a8 for HOOK-31

Re: BASIC: Find out if an Interface 1 is attached.

Posted: Mon Sep 23, 2019 10:08 am
by cha05e90
Wow, it doesn't seem that easy to retrieve that information from your Speccy..:-)

I'm still trying to make a test with pure Sinclair BASIC - maybe something from all your suggestions can be used. If that's really impossible, I'll give this or that method using some assembler a try - but that will be the last resort.

Thanks for all your suggestions and tips!

Re: BASIC: Find out if an Interface 1 is attached.

Posted: Mon Sep 23, 2019 11:37 am
by spider
It is surprising to realise there's not a very easy IF PEEK xyz <> abc , or something similar like IF PEEK xyz = abc etc

Logic would say there should be, I can see it moves things about a bit, trouble is the contents of what has moved is variable anyway in its nature and content.

I don't *think* the following will be useful but...

23653-23654 STACKEND:
This system variable contains the address of where the spare part of memory starts. From reading this we can gain an idea of how much memory we have left by subtracting it from RAMtop
Try: PRINT PEEK 23730 + 256*PEEK 23731 - PEEK 23653 - 256*PEEK 23654 , with both an IF one connected *and* without it connected.

EDIT... No the above usually on a reset returns 41532 regardless and CLEAR is going to make that jump about. Hmm. There might be something similar that can be used. Have you looked at all the system variables in the Speccy Manual ?

RAMTOP is at 23730-23731

I don't (think) FLAGS at 23611 is going to be any help.

That's about as much erm 'sane' thoughts as I can put into this.

Re: BASIC: Find out if an Interface 1 is attached.

Posted: Wed Sep 25, 2019 8:55 am
by cha05e90
jpnz wrote: Sat Sep 21, 2019 6:03 am There are some more suggestions from J.G. Hartson
I tested Jonathan's rather short Sinclair BASIC variant - indeed a test in the system variable area:

Code: Select all

10 CLOSE#0:LET inf1=(PEEK 23734<>244)
20 IF inf1 THEN PRINT "ZX Interface 1 detected."
If I put that in the beginning of the BASIC program it seems rather reliable in detecting an attached ZX Interface 1. I tried it with some emulators and with my real ZX Spectrum 48K/128K and it works. So'll stick with that for the moment!