Skip to main content

Detection

Sometimes you only need to know which kind of network cartridge is in the machine. Spectranext builds on the same ideas as the classic Spectranet, but adds new features. Your program can ask the hardware a simple question before using Wi‑Fi, HTTPS, or other extras that exist only on Spectranext.

What you get back

A small helper (spectranext_detect) returns a number:

ValueMeaning (plain language)
1Spectranext is present.
0Not Spectranext, but a classic Spectranet interface is there.
-1No compatible cartridge was found.

So you can branch your program: use Spectranext‑only features when you see 1, fall back when you see 0, and show a friendly message when you see -1.

How it works

Spectranext exposes a control register on a fixed I/O port. When you write a bit and read it back, one particular bit appears “flipped” compared with what you wrote—only on Spectranext. The library uses that quirk to recognize the new hardware without disturbing the rest of the system when it isn’t Spectranext.


Examples

The behaviour is the same whether you call the helper from C or write the port yourself in assembly. Pick the tab that matches how you’re building your program.

Include spectranext.h and call spectranext_detect. Link your project against the Spectranet library (for example libspectranet_np) so the routine is available—same family of libraries as other Spectranet networking code.

#include <spectranext.h>

int main(void)
{
int kind = spectranext_detect();

if (kind == 1) {
/* Spectranext: safe to rely on newer features */
} else if (kind == 0) {
/* Classic Spectranet only */
} else {
/* No cartridge (or not recognised) */
}

return 0;
}

The declaration lives in spectranext.h (return values are documented there next to the function).

Summary

  • Use spectranext_detect when you want one call that distinguishes Spectranext, Spectranet, and no hardware, with return codes 1, 0, and -1.
  • From C, include spectranext.h and link the Spectranet family libraries as usual.
  • From assembly, you can mirror the port handshake at $033B or call the library routine for the full behaviour.