Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GR8FIND

Finds which slot a GR8NET cartridge is installed in and publishes the primary slot number as the MSX-DOS 2 environment variable GR8SLOT, so batch files can use it.

Why

Nextor's MAPDRV needs the slot the driver lives in:

mapdrv c: 1 1 2-2

That 2-2 is hardcoded to the cartridge sitting in primary slot 2. Move the cartridge to slot 1 and every MAPDRV line in AUTOEXEC.BAT breaks. GR8FIND detects the slot at boot so the batch file no longer has to know it.

Usage

A:\>gr8find
GR8NET in slot 2-0, GR8SLOT=2

The line printed shows the full slot ID of the adapter (P or P-S), and the value stored in GR8SLOT, which is always the primary slot digit 0-3.

In AUTOEXEC.BAT:

gr8find
mapdrv c: 1 1 %GR8SLOT%-2
mapdrv d: 3 1 %GR8SLOT%-2
mapdrv e: 4 1 %GR8SLOT%-2

The -2 stays literal on purpose. Nextor sits in subslot 2 of the GR8NET's expanded slot in mapper modes 8-14, but in other mapper modes the manual puts it elsewhere, so GR8FIND reports where the adapter is and leaves the subslot for the specific service to you.

When no cartridge is found:

A:\>gr8find
GR8NET not found

GR8SLOT is then deleted from the environment rather than left at a stale value, so a following MAPDRV fails loudly instead of mapping the wrong slot.

Requirements

  • MSX-DOS 2 or Nextor. GR8SLOT is set through BDOS _SENV (6Ch), which does not exist in MSX-DOS 1. Only MSX-DOS 2 has been tested.
  • COMMAND2.COM 2.40 or newer to read the variable back. This is the part that catches people out: COMMAND2.COM 2.31 does not expand %VAR%, it just strips the percent signs, so %GR8SLOT%-2 silently becomes GR8SLOT-2. Check with ver. Version 2.44 is known to work.

Setting the variable works on any MSX-DOS 2; only the reading side needs the newer command interpreter.

How detection works

Two methods, in order.

  1. I/O identification ports. Adapters 0-3 are enumerated through ports 5Eh (adapter and register select) and 5Fh (register data). Register 0 answers 'G' when the adapter is active; register 1 then holds its slot ID in RDSLT format, with 00h and FFh meaning "not initialised". This is the method documented in chapter 12.1 of the GR8NET manual and works regardless of the active mapper mode.

  2. ROM signature scan. Fallback if the ports do not answer. Walks primary slots 0-3, and subslots 0-3 for slots flagged as expanded in EXPTBL (FCC1h), looking for the string "GR8NET" at 5FB8h (GR8RSG, chapter 12.2 of the manual). Reads go through the BIOS RDSLT routine at 000Ch, which stays available in MSX-DOS page 0 and handles expanded slots without the page-3 / FFFFh hazards of hand-rolled slot switching.

The original port 5Eh value is restored after enumeration, and the default-adapter bits (5-4) are preserved as the manual requires.

Layout

build.sh                assembles src into dist
src/gr8find.asm         the program
tools/glass-0.6.jar     Glass Z80 assembler
dist/GR8FIND.COM        build output, copy this to the MSX

Building

Needs Java, for the bundled Glass Z80 assembler:

./build.sh

Produces a 423 byte dist/GR8FIND.COM. Copy that to the MSX; nothing else from this repository is needed at runtime.

Tested

Verified on real hardware: a Panasonic FS-A1ST with a GR8NET cartridge.

Verified under openMSX on a Panasonic FS-A1GT with MSX-DOS kernel 2.31:

Case Result
No cartridge present GR8NET not found, GR8SLOT removed from set
Signature ROM in slot 1, not expanded GR8NET in slot 1, GR8SLOT=1
Signature in slot 3-0, expanded slot GR8NET in slot 3-0, GR8SLOT=3
%GR8SLOT%-2 in a batch file, COMMAND2.COM 2.44 expands to 1-2
Same, COMMAND2.COM 2.31 prints GR8SLOT-2, not expanded

openMSX does not emulate the adapter, so the emulator cases exercise the signature scan only; they confirm the I/O port path produces no false positives on a machine without a GR8NET. Both paths are live on the FS-A1ST, and the printed line is the same either way, so it does not say which of the two found the cartridge.

References

About

MSX-DOS 2 tool that detects which slot a GR8NET cartridge is in and exposes it as an environment variable, so AUTOEXEC.BAT no longer hardcodes the slot for Nextor's MAPDRV

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages