TR-DOS for those who know nothing about it. .BIG BRAIN
WARL0CK 02/15/97
I have never written an article in HACKER and to correct this
misunderstanding, I decided to write a series of articles about TR-DOSe. I'll start with
the very basics, i.e. how to call it from BASIC and from machine
codes, etc.
----------------------------------------------------------------
ERROR CODES WHEN CALLING FROM BASICa.
Error codes can be obtained from the TR-DOS variable (23823) or
via the BASICa variable as follows:
LET err=USR 15b19:REM:DOS command
or
RAND0MIZE USR 15b19:REM:DOS command
LETerr=REEK 23823
and now the meanings of the error codes:
0 - no errors
1 - no file
3 - a file with the same name already exists on disk
4 - the directory is full (the number of files is more than 128)
5 - record number overflow
b - no disk
7 - disk error
8 - syntax error
9 - I didn’t find data on this error anywhere
10 - channel is already open
11 - the disk is not formatted
12 - channel not open
----------------------------------------------------------------
FILE HEADER STRUCTURE0...7 8 9 V D E F
XXXXX X XX XX X X X
│ │ │ │ │ │ └ 1 byte - starting track number
│ │ │ │ │ └── 1 byte - starting sector number
│ │ │ │ └──── 1 byte - file length in sectors
│ │ │ └──────── 2 bytes - file length for C0DE and program
│ │ │ part for BASICa, in bytes
│ │ └──────────── 2 bytes - starting address for C0DE or
│ │ full file length for BASICa
│ └────────────── 1 byte - file type
└──────────────────── 8 bytes - file name
----------------------------------------------------------------
STRUCTURE OF SYSTEM CEKT0PA
╔══════════╤════════════════ ════════════════════════════╗
║ OFFSET │ ASSIGNMENT ║█
╠══════════╪═════════════════ ═══════════════════════════╣█
║ 225 │ Byte. Number of the next free sector. ║█
║ │ Afterformatting is zero. ║█
║──────────┼───────────────── ───────────────────────────╢█
║ 22b │ Byte. Number of the next free track. ║█
║ │ After formatting, it is equal to one. ║█
║──────────┼───────────────── ───────────────────────────╢█
║ 227 │ Byte. Floppy disk type: ║█
║ │ 22 - 80 tracks, 2 sides ║█
║ │ 23 - 40 tracks, 2 sides ║█
║ │ 24 - 80 tracks, 1 side ║█
║ │ 25 - 40 tracks, 1 side ║█
║──────────┼───────────────── ───────────────────────────╢█
║ 228 │ Byte. Number of files on disk, including ║█
║ │ and deleted. After formatting it is equal to 0. ║█
║──────────┼───────────────── ───────────────────────────╢█
║ 229,230 │ Word. Number of free sectors. ║█
║ │ After formatting: ║█
║ │ ║█
║ │ 2544 - for 80 track double-sided ║█
║ │ 12b4 - for 80 track single-sided ║█
║ │ and 40 expensive double-sided ║█
║ │ b24 - for 40 track single-sided ║█║──────────┼───────────────── ───────────────────────────╢█
║ 231 │ Byte. Number of sectors on the track. ║█
║ │ If not equal to 1b, then the message is displayed: ║█
║ │ Disk egrog and 23823=11 ║█
║──────────┼────────── ──────────────────────────────────╢█
║ 232,233 │ Two bytes of zeros. But why, I don’t ║█
║ │ I know. ║█
║──────────┼───────────────── ───────────────────────────╢█
║ 234...242│ Nine bytes of spaces (code 32). ║█
║──────────┼───────────────── ───────────────────────────╢█
║ 243 │ One byte equals zero. ║█
║──────────┼───────────────── ───────────────────────────╢█
║ 244 │ Byte. Number of deleted files. After the for- ║█
║ │ matting is zero. ║█
║──────────┼───────────────── ───────────────────────────╢█
║ 245...252│ 8 bytes. Disk name ║█
║──────────┼───────────────── ───────────────────────────╢█
║ 253...255│ 3 bytes of zeros. ║█
╚══════════╧═════════════════ ═══════════════════════════╝█
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
----------------------------------------------------------------TR-DOS INPUT POINTS
0 TR-DOS entry points a lot has been written, but I’ll make up my mind
repeat, because Perhaps someone does not have this information.
#3D00 - entering DOS from BASICa.
#3D03 - calling the TD-DOS command from BASICa.
#ZDOb - communication channel with a disk file-input program.
#ЗDOE - communication channel with a disk file-output program.
#3D13 - execution of the command specified in the C register of the processor.
#3D2F - jump to any DOS address.
At address #3D2F there are two commands: NOP and RET. Using this
entry points can be reached at any TR-DOS ROM address.
LD HL,LAB ; return address
PUSH HL ; put it on the stack
LD HL,address ; address in TR-DOS ROM
PUSH HL; put it on the stack
JP #3D2F ; transition to entry point
LAB.....; continuation of the program
or
LD HL,address ; TR-DOS ROM address
CALL DOS; push the return address onto the stack
..... ; continuation of the program
DOS PUSH HL; put the address in the TR-DOS ROM onto the stack
JP #3D2F ; transition to entry point
The most important entry point is #3D13. Now let's look at
commands that can be used through this entry point.
To call the command you need to enter the necessary data in
registers and use this construction:
LD C,number;team number
CALL #3D13 ;go to entry point
..... ;continuation of the program
══════════╤═════════════════════ ════════════════════════════════
Meaning │Shortcommand description
register C│
══════════╪═════════════════════ ════════════════════════════════
#00 │ Restoring VG-93: the head is retracted to zero
│ track and waits for the INTRQ signal. Waiting is possible
│ interrupt by pressing BREAK.
──────────┼───────────────────── ────────────────────────────────
#01 │ Initializing the drive specified in register A:
│ 00-A
│ 01-B
│ 02-С
│ 03-D
──────────┼───────────────────── ────────────────────────────────
#02 │ Installing the head on the track number specified in
│ register A (0...179).
──────────┼───────────────────── ────────────────────────────────
#03 │ Setting the sector number whose number is specified in
│ register A (1..1b).
──────────┼───────────────────── ────────────────────────────────
#04 │ Setting the address of the buffer specified in the register
│ pair HL. Placed in system variable #5D00.──────────┼───────────────────── ────────────────────────────────
#05 │ Reading a block of sectors. At address HL reads B
│ sectors from track D, the first of which is numbered E.
──────────┼───────────────────── ────────────────────────────────
#0b │ Recording a block of sectors. The parameters are the same as in the co-
│ mande #05.
──────────┼───────────────────── ────────────────────────────────
#07 │ Output the disk directory to channel number A.
──────────┼────────────── ─────────────────── ────────────────────
#08 │ Reading the file header (descriptor) into the system area
│ dark variables. File number in register A (0..127
│ including remote ones).
──────────┼───────────────────── ────────────────────────────────
#09 │ Write the file header to disk. File number in A.
──────────┼───────────────────── ────────────────────────────────
#0A │ Search for a file in a directory by name and type that
│ are given in system variables #5CDD...#5CE5; quantity
│ bytes being checked are entered into variable 23814,
│ usually 9. If the file was found, then its number in the re-
│ hyster C and cells 23838, 23823; if not found then
│ register C=255, 23823=255, 23838 does not change.──────────┼───────────────────── ────────────────────────────────
#0B │ Write a file of type C0DE to disk from the HL address and length
│ DE; the file name and type must be in the system
│ variable. Checking for the presence of a file of the same name does not
│ carried out so that multiple files can be created
│ with the same name and type.
──────────┼───────────────────── ────────────────────────────────
#0С │ Recording a BASIC program. The name is specified in the system
│ belt. Checking for the presence of a file of the same name does not
│ is produced. The variable #5CD1 specifies the number
│ autostart lines. If the type is not B, then the file will be written
│ under the name "boot".
──────────┼───────────────────── ────────────────────────────────
#0E │ Upload or VERIFY files; type and title in the system
│ dark variables. When 23801=0, loading is performed,
│ and at 255 check. To download a BASIC program
│ 23824 should be equal to 0, if 255 then the old program
│ the pamma is erased, but a new one is not loaded. Data in
│ depending on the contents of A, they are specified differently:
│
│ A=0 ;address and length are taken from the catalog│ A=3;address in HL, length DE
│ A=255;address in HL, length from catalog
──────────┼───────────────────── ────────────────────────────────
#12 │ The file whose name and type are specified in the system is erased.
│ dark variables, all files with such
│ name and type, their number in the variable is 23815.
──────────┼───────────────────── ────────────────────────────────
#13 │ Transferring file information (descriptor, 1b bytes) from
│ HL addresses to system variables #5CDD...#5CE5.
──────────┼───────────────────── ────────────────────────────────
#14 │ Transferring a file descriptor from system variables
│ to HL.
──────────┼───────────────────── ────────────────────────────────
#15 │ Checking the track whose number is specified in register D.
│ If bad sectors are found on the track, then
│ system variables will contain the following data:
│ #5DOF error code 7
│ #SСDb number of bad sectors
──────────┼───────────────────── ────────────────────────────────
#1b │ Sets the current disk side to 0.
──────────┼───────────────────── ────────────────────────────────
#17 │Sets the current disk side to 1.
──────────┼───────────────────── ────────────────────────────────
#18 │ Sets variables for the floppy disk type.
══════════╧═════════════════════ ════════════════════════════════
Here are a few examples of using entry point #3D13:
Loader monoblock:
; in the BASIC line behind REM there is something like this procedure:
LD HL,#9С40 ;image download address
LD ВС,#1В05;number of sectors and command code 5
LD DE,(#5CF4) ;number of the next track and sector
CALL 15b35 ;calling the loading procedure
LD DE,#4000 ;screen area address
LD HL,#9С40 ;address where the picture was uploaded
LD ВС,#1В00 ;picture length
LDIR ;transfer picture to screen
LD HL,#7530 ;main block download address
LD VS,#b205;number of sectors and command code 5
LD DE,(#5CF4) ;number of the next track and sector
CALL 15b35 ;calling the loading procedure
JP #7530 ;run loaded program
File loader:
; also in the line after REM there is a small procedure:
LD HL,BL0CK1 ;address of the name and type of the first block
LD С,#13 ;transfer descriptor
CALL 15b35 ;calling the descriptor transfer procedure
LD С,#0А;search for file on disk
CALL 15b35; call search procedure
LD A, C; save the file number in the accumulator
INC C ;if there is no file,
JP Z,LABEL ; then go to message output
LD C,8 ;reading file descriptor
CALL 15b35 ;go to entry point
X0R A ;loading
LD (23801),A ;file
LD A,255;length from catalog address from HL
LD HL,#9С40 ;download address
PUSH HL; remember it
LD С,#0E ;load the first block
CALL 15b35 ;calling the loading procedure
POP HL ;restore address
LD DE,#4000 ;transfer
LD BC,#1В00 ; pictures
LDIR ; into the screen
LD HL,BL0CK2 ;second block name address
LD С,#13 ;file descriptor transfer
CALL 15b35 ;calling the transfer procedure
LD С,#0А ;search for a file on disk
CALL 15b35; call search procedure
LD A, C; save the file number in the accumulator
INC C ;if file not found
JP Z,LABEL ; then go to print message
LD С,#08 ;loading file descriptor
CALL 15b35; transition to TR-DOS
X0R A ;loading
LD (23801),A ; blockLD A,255;address in HL, length from catalog
LD HL,#7530 ;download address
LD С,#0E ;upload file
CALL 15b35 ;calling the loading procedure
JP #7530 ;start main unit
LABEL CALL 3435 ;screen cleaning
LD A,2 ;output channel number
CALL #1b01 ;calling the channel opening procedure
LD DE,TEXT ;DE start of message
LD ВС,BL0CK1-TEХТ;ВС message length
CALL 8252 ;print message
LD A,2 ; red color
0UT (254),A ; curb
DI ;disable interrupts
HALT ; hang up the computer
TEKHT DEFB 22,0,0 ; print coordinates
DEFM "FILE N0T FOUND!"
BL0CK1 DEFM "FILE1 C"
BL0CK1 DEFM "FILE2 C"
Since we're talking about entry points, I'll giveseveral addresses
TR-DOS procedures with addresses for ROM version 5.04T.
══════════════╦═════════════════ ════════════════════════════════
address (HEX) ║ destination
══════════════╬═════════════════ ════════════════════════════════
0000 ║ Complete system restart
──────────────╫───────────────── ────────────────────────────────
0008 ║ RST #08, initialization, top of memory in DE.
──────────────╫───────────────── ────────────────────────────────
0010 ║ RST #10, outputting a character from the accumulator.
──────────────╫───────────────── ────────────────────────────────
0018 ║ RST #18, character strings starting with (HL), ending
║ zero or a symbol greater than 127.
──────────────╫───────────────── ────────────────────────────────
0020 ║ RST #20, procedure call from ROM, address immediately after
║ RST #20, for example:
║
║ RST #20
║ DEFW #ODbV
──────────────╫───────────────── ────────────────────────────────
0028 ║ RST #28, returns the address of the currentchannel
║ taking into account the shift in C.
──────────────╫───────────────── ────────────────────────────────
OObb ║ MAGIC button handler.
──────────────╫───────────────── ────────────────────────────────
01D3 ║ Exit DOS after executing commands #0D-#11
║ entry points 15b35. These are the commands for further
║ TR-DOS extensions.
──────────────╫───────────────── ────────────────────────────────
03b0 ║ TR-DOS version name.
──────────────╫───────────────── ────────────────────────────────
0405 ║ Procedure for executing command #18.
──────────────╫───────────────── ────────────────────────────────
0800 ║ Free memory (#FF).
──────────────╫───────────────── ────────────────────────────────
1003 ║ Text "Interface 1 connected."
──────────────╫────────── ─────────────────── ────────────────────
10A5 ║ System information text for LIST.
──────────────╫───────────────── ────────────────────────────────
115D ║ Print sheet (HL) in decimal form.
──────────────╫───────────────── ────────────────────────────────
1bSC ║ Executing command #08.──────────────╫───────────────── ────────────────────────────────
1bbCh ║ Executing command #09.
──────────────╫───────────────── ────────────────────────────────
1CF0 ║ Execute commands in #0A.
──────────────╫───────────────── ────────────────────────────────
1EЗD ║ Executing command #05.
──────────────╫───────────────── ────────────────────────────────
1EХD ║ Executing command #0b.
──────────────╫───────────────── ────────────────────────────────
1FFD ║ Track formatting
║ in E track number
║ in the system variable #SСEB the address of the table
║ in system variable #5CE8 table address +1
║ in system variable #5CD7 check flag
║ sectors #1FB9 - 0rdinary, #325A - TURB0.
──────────────╫───────────────── ────────────────────────────────
1FEB ║ Executing command #1b.
──────────────╫───────────────── ────────────────────────────────
1FFb ║ Executing command #17.
──────────────╫───────────────── ────────────────────────────────
2739 ║ Executing command #15.──────────────╫───────────────── ────────────────────────────────
27bb ║ Texts of TR-DOS messages.
──────────────╫───────────────── ────────────────────────────────
283С ║ Control goes here from 15b35, definition
║ commands.
──────────────╫───────────────── ────────────────────────────────
288C ║ Table of addresses of commands addressed by register C.
──────────────╫───────────────── ────────────────────────────────
28D8 ║ Executing command #07.
──────────────╫───────────────── ────────────────────────────────
28E0 ║ Executing command #13.
──────────────╫───────────────── ────────────────────────────────
28E3 ║ Executing command #14.
──────────────╫───────────────── ────────────────────────────────
28E5 ║ File descriptor transfer
║ at A=0 from HL to system variables
║ for A<>0 is the opposite.
──────────────╫────────── ─────────────────── ────────────────────
28F2 ║ Executing command #0С.
──────────────╫───────────────── ────────────────────────────────
28FB ║ Execution of command #0B.──────────────╫───────────────── ────────────────────────────────
290F ║ Execute command #0E.
──────────────╫───────────────── ────────────────────────────────
292b ║ Executing command #12.
──────────────╫───────────────── ────────────────────────────────
29В1 ║ Texts of TR-DOS messages.
──────────────╫───────────────── ────────────────────────────────
2A53 ║ Output A to port BC.
──────────────╫───────────────── ────────────────────────────────
2ASb ║ TR-DOS goes here after pressing MAGIC.
──────────────╫───────────────── ────────────────────────────────
ZOFD ║ Keywords TR-DOS.
──────────────╫───────────────── ────────────────────────────────
2FFЗ ║ Keyword address table.
──────────────╫───────────────── ────────────────────────────────
3D00 ║ Entry point. See the beginning of the article.
──────────────╫───────────────── ────────────────────────────────
3D03 ║ Entry point.
──────────────╫────────── ─────────────────── ────────────────────
ZDOb ║ Entry point.
──────────────╫───────────────── ────────────────────────────────ЗDOE ║ Point of entry.
—
3D13 ║ Entry point.
—
3D24 ║ Entry point.
—
3D2F ║ Entry point.
—
3D98 ║ Execution of command #00.
—
3DCB ║ Executing command #01.
—
3E44 ║ Execution of commands ВГ93 from B, given in A.
—
ЗЕбЗ ║ Execution of command #02.
—
3F02 ║ Execution of command #03.
—
ФОб ║ Execution of command #04.
─️
ZEF5 ║ Waiting for execution of the last command ВГ93.─────────────╫───────────────── ────────────────────────────────
ЗFE5 ║ Here is the procedure for receiving a group of bytes
║ from VG93 (INI).
─────────────╫───────────────── ────────────────────────────────
3FCA ║ Block write procedure (0UTI) is located here.
══════════════╩═════════════════ ════════════════════════════════
The easiest and most reliable way to determine the TR-DOS ROM version
this is via command #13:
LD HL,#03b0; in HL we place the address of the TR-DOS version
; (for 5.04T)
LD С,#13;transfer from HL to system variables
; 1b byte
CALL 15b35; transition to TR-DOS
..... ;string comparison procedure
I think this is enough for the first article in HACKER. Well I
I'm finishing. I took most of the information from the book "TR-DOS for
this is via command #13:LD HL,#03b0; in HL we place the address of the TR-DOS version
; (for 5.04T)
LD С,#13;transfer from HL to system variables
; 1b byte
CALL 15b35; transition to TR-DOS
..... ;string comparison procedure
I think this is enough for the first article in HACKER. Well I
I'm finishing. I took most of the information from the book "TR-DOS for
professionals and amateurs" by Yu. Pomortsev.
And here there will probably be a comment from CRAZY ALEXa.
****************************************************************
Hehe... But there will be no comment...
Although, is this already a comment?!
****************************************************************
Share your thoughts about the article