Skip to content

Instantly share code, notes, and snippets.

@RCL
Last active December 11, 2024 06:28
Show Gist options
  • Save RCL/5af73d4605524800d381d224f133a092 to your computer and use it in GitHub Desktop.
Save RCL/5af73d4605524800d381d224f133a092 to your computer and use it in GitHub Desktop.
TR-DOS (Beta disk interface) BASIC interop

TR-DOS BASIC interop

General format

RANDOMIZE USR 15619: REM: <BASIC token>

Most popular invocations

These should cover 80% of the software if not more:

RANDOMIZE USR 15619: REM: LOAD "foo"
RANDOMIZE USR 15619: REM: LOAD "foo" CODE [Address]

Extra 5-10% for covering:

RANDOMIZE USR 15619: REM: SAVE "foo"

Other

These are other BASIC instructions (re)used in TR-DOS. They are very likely to be only encountered in a productivity or utility software, which would be of limited use nowadays. Most are runnable via RANDOMIZE USR 15619: REM: construct unless stated otherwise (only one - NEW - is not runnable).

CAT - quick listing, two files per line
LIST - detailed listing the disk (like ls -la), one file per line, length and sectors shown
ERASE "Name" - delete file
MERGE "Name" - merging BASIC code
VERIFY "Name" - verifying a file (BASIC only? not sure)
MOVE - disk defragmentation
FORMAT "$NAME" - formatting the floppy
COPY "NewName","OldName" CODE – copying files within one floppy
COPY s "Name" – copying between the floppies a single drive
COPY "A:Name","B:Name" – copying Name file from B: drive to A:
COPY "B:*","A:*" – copying all files from A: to B:
NEW "NewName","OldName" – renaming (only works in the DOS prompt, not via RANDOMIZE USR)
GO TO "$Name" – starting a "magic file" (a memory dump file) with IM2.
PEEK "Name" address,sectorN – reading sectorN sector from the file Name to address in memory 
        (sectorN starts with 1 and ends with the number that is returned in CAT for that file)
POKE "Name" address,sectorN – writing sectornN from the memory to file 
        (sectorN starts with 1 and ends with the number that is returned in CAT for that file)
OPEN #N,"Name",W – opens a sequential file Name for writing with a channel number (N should be from 4 to 15)
OPEN #N,"Name",R – same but for reading
PRINT #N;"TEXT" – printing text into the channel N (e.g. into the aforementioned opened file). 
INPUT #N;T$ – reading text from the channel (file)
OPEN #N, "Name",RND,record_length - opens a disk file with a random access (R/W)
PRINT #N;record_number,Т$ – printing Т$ variable into the random access file
INPUT #N;(record_number),Т$ – reading T$ variable from the random access file
CLOSE #N – closes the file (a must).

Source: https://www.ss-20.ru/index.php?action=downloads;sa=downfile&id=3824 (PDF file, a scan of a 1994 book by Inforcom, a defunct Russian ZX Spectrum publisher)

Memory impact

TR-DOS moves BASIC and system vars by <= 128 bytes.

Without TR-DOS:

print peek 23635: print peek 23636

returns 203/92 = 23755

and after calling for example

randomize usr 15619: rem: list
print peek 23635: print peek 23636

returns 59/93 = 23867

(Source: https://spectrumcomputing.co.uk/forums/viewtopic.php?t=8554)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment