And again about TR-DOSe. .BIG BRAIN
WARL0CK 1b.02.97
It's me again with my second article about TR-DOS. Today I
I’ll tell you about TR-DOS system variables (although when executing
different commands the same variables have different
meaning) etc.
----------------------------------------------------------------
TR-DOS SYSTEM VARIABLES.
NOTE: All numbers are in decimal notation.
ANOTHER NOTE: the values in square brackets are for
initializing TR-DOS with a disk in the drive, via | without disk |
while working.
═══════╦════════════════════════ ════════════════════════════════
address ║ destination
═══════╬════════════════════════ ════════════════════════════════
23734 ║ 15 bytes channel area CHANS──────╫──────────────────────── ───────────────────────────────
23734 ║ 2548.42b4. Channel K
──────╫──────────────────────── ───────────────────────────────
23739 ║ 2548.5572. Channel S
──────╫──────────────────────── ───────────────────────────────
23744 ║ 39b9.5577. Channel R
──────╫──────────────────────── ───────────────────────────────
2374b ║ Byte-201 (RET command code). Apparently it is used
║ to call BASICa functions from TR-DOS.
──────╫──────────────────────── ───────────────────────────────
23752 ║ Byte - operating mode of drive A. [255|128|131]
║
23753 ║ - " - " - " - V.
║
23754 ║ - " - " - " - S.
║
23755 ║ - " - " - " - D.
──────╫──────────────────────── ───────────────────────────────
2375b ║ Number of the sector output by the CAT command [13].
──────╫──────────────────────── ───────────────────────────────
23757 ║ Byte - drive readiness (reg. status VG93) [128.0].──────╫──────────────────────── ───────────────────────────────
23758 ║ Byte, possible write (255)/read (0) flag [0].
──────╫──────────────────────── ───────────────────────────────
23759 ║ 2 bytes - address W0RKSP with M0VE, C0PY, LIST.
──────╫──────────────────────── ───────────────────────────────
237b1 ║ 2 bytes - the autostart line number for SAVE BASIC.
──────╫──────────────────────── ───────────────────────────────
237b4 ║ Byte - number of the erased file with M0VE.
──────╫──────────────────────── ───────────────────────────────
237b5 ║ Byte - sector number of the erased file with M0VE.
──────╫──────────────────────── ───────────────────────────────
237bb ║ Byte - track number of the erased file with M0VE. For for-
║ reset to zero, at the end there will be a number of dematting
║ defective sectors (similarly when checking the co-
║ manda #15). Loading method for command #0E (reg. A).
║ If the command is not executed 255.
──────╫──────────────────────── ───────────────────────────────
237b7 ║ 2 bytes - address. After initialization, it points to
║ counter [23771], after writing C0DE - starting address
║ in memory. When called from BASICa, contains the line number
║ call. When formatting is performed, 237b7 contains
║number of tracks for formatting, 237b8 check flag,
║ if <> 0, then no check is performed.
──────╫──────────────────────── ───────────────────────────────
237b9 ║ 2 bytes - symbol address for interpretation, similarly
║ CH_ADD. After initialization, it points to [238b9].
║ After recording, C0DE contains the length of the recorded file.
║ When formatting 23770=128, if the floppy disk is double-sided
║ no, otherwise only the other side is formatted. For co-
║ commands #0E download address.
──────╫──────────────────────── ───────────────────────────────
23771 ║ 2 bytes - download counter, after file operations
║ contains the length of the downloaded/recorded part of the file.
║ When M0VE contains the current sector and track numbers.
║ With LIST, byte 23771 contains the current output channel.
──────╫──────────────────────── ───────────────────────────────
File descriptor:
23773 ║ 8 bytes - file header
23781 ║ Byte - file type
23782 ║ 2 bytes - start address for C0DE or full length BASIC
23784 ║ 2 bytes - length of the file or program part for BASIC
2378b ║ Byte - file size in sectors
23787 ║ Byte -file starting sector number
23788 ║ Byte - number of the initial track of the file
──────╫──────────────────────── ───────────────────────────────
Parameters for C0PY:
23789 ║ 2 bytes - address
23791 ║ 2 bytes - length
23793 ║ Byte - volume in sectors
23794 ║ Byte - starting sector number
23795 ║ Byte - initial track number
──────╫──────────────────────── ───────────────────────────────
2379b ║ Byte - counter of loaded sectors. After operations
║ download contains the number of the next sector. Use
║ used for writing monoblock bootloaders.
──────╫──────────────────────── ───────────────────────────────
23797 ║ Byte counter of loaded tracks. After operations,
║ track contains the number of the next track.
──────╫──────────────────────── ───────────────────────────────
23798 ║ Byte - disk drive for temporary operation (0-3).[0].
──────╫──────────────────────── ───────────────────────────────
23799 ║ Byte - when returning from TR-DOS (15b1b) it is reset to zero.
──────╫──────────────────────── ───────────────────────────────
23800 ║ Byte drivesource when working with two drives
║ (0-3) [0].
──────╫──────────────────────── ───────────────────────────────
23801 ║ Byte - operation type: 0-L0AD, 255-VERIFY [0]. When working
║ with two disk drives, the receiver's disk drive number (0-3).
──────╫──────────────────────── ───────────────────────────────
23802 ║ Byte - time of movement of the drive head A
23803 ║ - " - " - B
23804 ║ - " - " - C
23805 ║ - " - " - D
║ If 255 then the drive is not initialized, otherwise 8.
──────╫──────────────────────── ───────────────────────────────
2380b ║ Byte - VG93 command. 128 after reading, 1b0 - writing.
──────╫──────────────────────── ───────────────────────────────
23807 ║ Byte - sector number +1, specified for VG93 DOS.
──────╫──────────────────────── ───────────────────────────────
23808 ║ 2 bytes - address of the DOS buffer into which it is loaded
║ sector. Indicates DOS-CHANS; this area is for a while
║ downloads are temporarily shifted by 257 bytes.[0|0|23845]
──────╫──────────────────────── ───────────────────────────────
23810 ║ 2 bytes - the HL register pair is temporarily saved.──────╫──────────────────────── ───────────────────────────────
23812 ║ 2 bytes - register pair DE is temporarily saved.
──────╫──────────────────────── ───────────────────────────────
23814 ║ Byte - the number of bytes to search for
║ file in directory [9].
──────╫──────────────────────── ───────────────────────────────
23815 ║ Byte - result of M0VE: 0-by files, <>0 - o.k.
──────╫──────────────────────── ───────────────────────────────
2381b ║ Byte - the first letter of the file name for M0VE and ERASE.
──────╫──────────────────────── ───────────────────────────────
23820 ║ Byte - sign of I/O buffer allocation: 0 - yes,
║ 255 - no [255].
──────╫──────────────────────── ───────────────────────────────
23821 ║ File byte number when copying with two drives.
──────╫──────────────────────── ───────────────────────────────
23822 ║ Byte - at 254 DOS messages are not displayed on the screen. When
║ 255 - a sign of BASIC operation, others - TR-DOS.
──────╫──────────────────────── ───────────────────────────────
23823 ║ Byte - TR-DOS error code when called from BASICa, as well as
║ file number in the directory when executing command #0A [0].
──────╫──────────────────────── ───────────────────────────────
23824 ║High error byte when calling 15b1b or 15b35. Necessary
║ we need to write 0 [0|255] before reading files.
──────╫──────────────────────── ───────────────────────────────
23825 ║ 2 bytes - address of the TR-DOS command line [238b8].
──────╫──────────────────────── ───────────────────────────────
23827 ║ 2 bytes - address, points to the highest address of the stack,
║ containing the address of the error handling procedure [b5ZbCh].
║ If high byte=170, the RUN "boot" command is executed.
──────╫──────────────────────── ───────────────────────────────
23829 ║ Byte - DOS mode, at 255 the DOS command is executed from
║ BASICa, at 0 - DOS operation.
──────╫──────────────────────── ───────────────────────────────
23830 ║ Byte - a copy of the controller system register (usually
║ drive number + b0) [b0/44].
──────╫──────────────────────── ───────────────────────────────
23831 ║ Byte - sign of DOS initialization: 0 - when entering DOS
║ the splash screen is displayed and the RUN "boot" command is executed,
║ 170 - no (re-entry) [0/170]. At 255 it doesn't work
║ error when reading an incorrect address.
──────╫──────────────────────── ───────────────────────────────
23832 ║ Byte - equals 255 if Interface 1 is connected.──────╫──────────────────────── ───────────────────────────────
23833 ║ Default drive number (0-3) [0].
──────╫──────────────────────── ───────────────────────────────
23834 ║ 2 bytes - address of the return subroutine from TR-DOS [710].
──────╫──────────────────────── ───────────────────────────────
2383b ║ 2 bytes - the current SP value is saved.
──────╫──────────────────────── ───────────────────────────────
23838 ║ Byte - file number in the directory, if found [0].
──────╫──────────────────────── ───────────────────────────────
23840 ║ 3 initial bytes of the last command line.
──────╫──────────────────────── ───────────────────────────────
23843 ║ Byte - memory size for M0VE (in blocks, BkB minimum).
──────╫──────────────────────── ───────────────────────────────
23845 ║ Byte - the beginning of the DOS temporary buffer [255].
──────╫──────────────────────── ───────────────────────────────
2384b ║ 20 bytes - CHANS-DOS channel area K, S, R, P; similar
║ standard.
──────╫──────────────────────── ───────────────────────────────
238bb ║ Byte - separator [128]
──────╫──────────────────────── ───────────────────────────────
238b7 ║ Start of BASIC programs if disk drives have not been opened
║files.
═══════╩════════════════════════ ════════════════════════════════
DISK FILE CONNECTION AREA
If a disk file is open, it is additionally highlighted
next area:
═══════╦════════════════════════ ════════════════════════════════
address ║ destination
═══════╬════════════════════════ ════════════════════════════════
238bb ║ 292 bytes - area of the communication channel with the disk file:
║
238bb ║ 2 bytes - address of the channel writing procedure
238b8 ║ 2 bytes - address of the reading procedure from the channel
23870 ║ 1 byte - channel name "D"
23871 ║ 8 bytes - 253,50,5b,48,3b,1,0,84 (just don’t ask
║ me, I don’t know what it is).
23879 ║ 3 bytes - 27,00,255 - sequential for writing
║ 00,00,00 - sequential for reading
║ 27,00,127 - with random access
23882 ║ 1b byte- file descriptor
23898 ║ 4 bytes - 234,58,211,52 (God knows what it is)
23902 ║ 25 bytes - file communication buffer; contains the current fragment
║ cop
23158 ║ 1 byte - delimiter 128
23159 ║ Start of a BASIC program if one disk file is open
═══════╩════════════════════════ ════════════════════════════════
To open a disk file you need to run the following commands:
10 CLEAR 24999
20 OPEN #4,"NAME",W:REM open a serial file for
records
10 CLEAR 24999
20 OPEN #4,"NAME",R:REM the same, but for reading
10 CLEAR 24999
20 OPEN #4,"NAME",RND:REM open a file with an arbitrary
access
Definitely (!) afterwork close file:
CL0SE #4
----------------------------------------------------------------
AND FINALLY 0 "MAGIC"
"Magic" works using non-maskable interrupts.
Those. When you press this button, the drive controller replaces
The ROM is on the TR-DOS ROM and produces the NMI signal. Processor
stops the running program and goes to the address
#OObb. There is a non-maskable interrupt handler there. In ROM
BASIC made an error and non-maskable interrupts are not there
are used. The "Magic" click handler pushes 42 onto the stack
byte (saves register values), and if the program does not have
stack depth is sufficient, it will not be reset by “Magic”
(for example: DCU, UFO2 and many others, this is especially true
programs written recently). The handler writes to
sectors 10 and 11 of the zero track 512 bytes of the screen. To this area
the system sector is read from the screen and installed there
stack Next, the beginning of free disk space is determined and
all RAM is unloaded, starting fromscreen to a file named "@" and
type C0DE. The address field contains the stack value (SP). After
recording the program is restored in the same way as when running "@"
file. Processing routine "Magic" writes to address 23551
the number is 201 (most likely RET), and in cells 23552 and 23553
22 and 1b, respectively. Some programs via interrupts
check these cells. For example, "48 IRONS" discovering that its
threw off "Magic" and immediately starts formatting the disk.
File recovery procedure (for TR-DOS version 5.04T)
looks like this:
POP AF
EX AF,AF'
POP AF
LD R,A
POP AF
LD I,A
D.I.
LD A,#FF
JP P0,LL2ECC
LD A,#00LL2ECC LD (#5С00),А
POP AF
POP HL
POP DE
POP ВС
EXX
ЕХ AF,AF'
POP IY
POP IX
POP HL
POP DE
POP ВС
LD А,(#5С48)
AND #38
RRCA
RRCA
RRCA
0UT (#FE),А
LD А,(#5В08)
СР #EE
JR NZ,LL2EF7PUSH Sun
LD Sun,#7FFD
LD A,(#SBSC)
0UT (C),A
POP sun
LL2EF7 LD А,(#5С00)
0R A
LD A,#C9
LD (#5C00),A
JR NZ,LL2F03
EI
LL2F03 POP AF
JP #5С00
LD A,(#4011)
0R #3С
0UT (#FF),A
RET
There are many programs that convert "@" files into
ordinary. They use approximately the same procedure
recovery, just a little simpler, for example like this:POP AF
LD R,А
POP AF
LD I,А
ЕХ AF,AF'
POP AF
POP HL
POP DE
POP ВС
EXX
POP IY
POP IX
POP HL
POP IX
POP HL
POP DE
POP ВС
ЕХ AF,AF'
JP P0,LABEL
EI
LABELPOP AF
RET
"Magic" files are launched via G0 Т0 "name" C0DE. If the file is not
starts, then try changing the first letter of the file name to
"$". The point is that the "Magic" procedure cannot determine the mode
interrupts IM2 or IM1, and therefore at boot it checks
the first letter, and if it is "$", then it turns on IM2 interrupts.
This is where I end this article. All that remains is to disassemble
formatting the disk and programming the VG93, more on that in the next
article. Happily!
****************************************************************
Share your thoughts about the article