Example TR-DOS Basic file
Jump to navigation
Jump to search
This is an example TR-DOS BASIC file an encoded on disk. the file listing is below.
Basic file listing
10 DIM a$(10,5) 20 DIM b(2,3) 30 FOR a=1 TO 10 40 LET a$(a,3)="x" 50 LET a$(a,4)="y" 60 LET a$(a,5)="z" 70 NEXT a 80 LET x=10 90 LET r$="test string" 100 RANDOMISE USR 15619: REM : SAVE "basic" LINE 300 110 RANDOMISE USR 15619: REM : SAVE "code" CODE 30000,2000 120 RANDOMISE USR 15619: REM : SAVE "cdata" DATA a$() 130 RANDOMISE USR 15619: REM : SAVE "ndata" DATA b() 140 REM RANDOMISE USR 15619: REM : FORMAT "testdisk"
TR-DOS Directory entry
The Raw dirent is as follows:
62 61 73 69 63 20 20 20 42 EF 01 68 01 02 00 01 basic B..h....
Offset (dec) | Offest (hex) | Bytes | Content | Description |
---|---|---|---|---|
0-7 | 00-07 | 62 61 73 69 63 20 20 20 | "basic " | Filename |
8 | 08 | 43 | "B" (Basic) | File type |
9-10 | 09-0A | EF 01 | 495 bytes (0x01EF) | File size including variables area EXCLUDING the area at the end containing the line number. |
11-12 | 0a-0b | 68 01 | 360 bytes (0x0168) | Pointer to the start of the variables area in the file. |
13 | 0C | 08 | 8 sectors long | Number of sectors the file uses |
14 | 0D | 02 | Start sector 2 | Sector the file starts from (Note, sectors number from 0 regardless of the actual disk layout) |
15 | 0E | 01 | Start logical track 1 | Logical Track the file starts from. (Note, the tracks are encoded as CH, so for DS drives, track 0=C0H0, 1=C0H1, 2=C1H0, ect) |
Encoding on disk
Most of the file is the same as with any other basic program saved to a media. The variables in this case start at 0168 and the basic file ends at 01EF
0000 00 0A 17 00 20 E9 61 24 28 31 30 0E 00 00 0A 00 .... .a$(10..... 0010 00 2C 35 0E 00 00 05 00 00 29 0D 00 14 15 00 20 .,5......)..... 0020 E9 62 28 32 0E 00 00 02 00 00 2C 33 0E 00 00 03 .b(2......,3.... 0030 00 00 29 0D 00 1E 15 00 20 EB 61 3D 31 0E 00 00 ..)..... .a=1... 0040 01 00 00 CC 31 30 0E 00 00 0A 00 00 0D 00 28 14 ....10........(. 0050 00 20 F1 61 24 28 61 2C 33 0E 00 00 03 00 00 29 . .a$(a,3......) 0060 3D 22 78 22 0D 00 32 14 00 20 F1 61 24 28 61 2C ="x"..2.. .a$(a, 0070 34 0E 00 00 04 00 00 29 3D 22 79 22 0D 00 3C 13 4......)="y"..<. 0080 00 F1 61 24 28 61 2C 35 0E 00 00 05 00 00 29 3D ..a$(a,5......)= 0090 22 7A 22 0D 00 46 03 00 F3 61 0D 00 50 0C 00 F1 "z"..F...a..P... 00A0 78 3D 31 30 0E 00 00 0A 00 00 0D 00 5A 12 00 F1 x=10........Z... 00B0 72 24 3D 22 74 65 73 74 20 73 74 72 69 6E 67 22 r$="test string" 00C0 0D 00 64 1E 00 F9 C0 31 35 36 31 39 0E 00 00 03 ..d....15619.... 00D0 3D 00 3A EA 3A F8 22 62 61 73 69 63 22 20 CA 33 =.:.:."basic" .3 00E0 30 30 0D 00 6E 23 00 F9 C0 31 35 36 31 39 0E 00 00..n#...15619.. 00F0 00 03 3D 00 3A EA 3A F8 22 63 6F 64 65 22 AF 33 ..=.:.:."code".3 0100 30 30 30 30 2C 32 30 30 30 0D 00 78 1E 00 F9 C0 ,2000..x.... 0110 31 35 36 31 39 0E 00 00 03 3D 00 3A EA 3A F8 22 15619....=.:.:." 0120 63 64 61 74 61 22 E4 61 24 28 29 0D 00 82 1D 00 cdata".a$()..... 0130 F9 C0 31 35 36 31 39 0E 00 00 03 3D 00 3A EA 3A ..15619....=.:.: 0140 F8 22 6E 64 61 74 61 22 E4 62 28 29 0D 00 8C 17 ."ndata".b().... 0150 00 EA F9 C0 31 35 36 31 39 3A EA 3A D0 22 74 65 ....15619:.:."te 0160 73 74 64 69 73 6B 22 0D stdisk".
0x0168 is where the variable start....
0160 C1 37 00 02 0A 00 05 00 .7...... 0170 20 20 78 79 7A 20 20 78 79 7A 20 20 78 79 7A 20 xyz xyz xyz 0180 20 78 79 7A 20 20 78 79 7A 20 20 78 79 7A 20 20 xyz xyz xyz 0190 78 79 7A 20 20 78 79 7A 20 20 78 79 7A 20 20 78 xyz xyz xyz x 01A0 79 7A 82 23 00 02 02 00 03 00 00 00 00 00 00 00 yz.#............ 01B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 01C0 00 00 00 00 00 00 00 00 E1 00 00 0B 00 00 00 00 ................ 01D0 0A 00 00 00 00 01 00 00 1E 00 02 78 00 00 0A 00 ...........x.... 01E0 00 52 0B 00 74 65 73 74 20 73 74 72 69 6E 67 .R..test string
01EF is where the extra data starts.
01EF 80 . 01F0 AA 2C 01 20 13 5F 05 00 00 00 13 5F 05 00 00 00 .,. ._....._.... ^^^^^ Start line (012C = line 300)