ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ TI Emulator! 4/15/1994 v 5.0 written by Edward Swartz ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ This file describes the format of the emulated TI files used in TI Emulator! v5.0. First, the filename of a TI file is practically the same as on the TI, but it has changes to accomodate MS-DOS restrictions. Of the ten characters, the last two will be put into the extension if necessary. Also, several illegal DOS characters -- <>=,;:*?[]()/\!~ -- will be changed by adding 80h to their ASCII values. This may make it difficult to type the filename from DOS... but these ARE TI files. For your convenience, the most common TI filename characters that are illegal in DOS, '-' and '/', will be changed into '­' and '¯'. The '­' character is IBM ASCII 173 and '¯' is code 175. Just type the code on the numeric keypad with the Alt key held down to get these characters. The actual format of the file tries to follow the sectorized format used on the TI. All sectors are 256 bytes long. All files, though, start with a 128-byte record describing the file attributes. These first 128 bytes of a TI Emulator! file are copied directly from the TI's File Descriptor Record (FDR) for that file. Those bytes are, if you want to know: byte 00-09 : Filename. Unused chars are spaces. 10-11 : unused 12 : File Status Flags (the file type) Bits: 0 = program (1) / data (0) (1h) 1 = internal (1) / display (0) (2h) 2 = unused (4h) 3 = write protected (8h) In the TI DSR, this bit write-protects the file. Under TI Emulator!, this is implemented using the DOS write-protect bit. If the bit happens to be set, it will be ignored. 4 = unused (10h) 5 = unused (20h) 6 = unused (40h) 7 = variable (1) / fixed (0) (80h) Putting these together gives these types: >00 = DIS/FIX >01 = PROGRAM >02 = INT/FIX >80 = DIS/VAR >82 = INT/VAR On newer systems, the 10h bit is used in combination with backups. (Like the archive bit in DOS files.) TI Emulator! doesn't use this bit. 13 : Number of records per sector. = 256/Record Length, even for variable files. 14-15 : Number of Sectors Used. In TI byte order. 16 : EOF marker for variable and program files. 17 : Record length (0 in program files) 18-19 : Number of fixed records OR number of sectors used by variable files. In Intel byte-order. 20-27 : unused (date/time in newer systems) 28-255: unused in TI Emulator! v5.0 but really encoded pointers to the sectors used by the file. Then, the sectors in the file follow directly afterward in one contiguous block. A TI Emulator! file should always be (n*256)+128 bytes long, where n is the value in bytes 14-15. Under the TI Device Service Routine (DSR), no records are ever broken over a sector boundary. So, a fixed file with record length of 129 bytes will waste 127 bytes a sector. TI Emulator! follows this standard. (It's wasteful, but it's compatible!) In variable length record files, each record consists of a length byte and the data. A length of zero is legal, and the record is only the zero byte. Up to 255 records may be stored in one sector (all length 0, of course). In a sector, all records directly follow each other except when a record cannot fit in the remaining space in a sector. The byte where the new record would have gone is set to >FF to signify end-of-sector. (It is called the end-of-file marker, but this really only signifies the end of the sector.) To detect end-of-file, a combination of the end-of-sector marker and the record are used. An EOF marker must appear in a sector, so the maximum number of bytes in a sector that can be used in a non-program file is 255. In fixed length record files, only records will be stored in one sector. Less than this number of records may only appear in the last sector. When a new sector is allocated, the first record always starts at byte 0, and others follow contiguously. The longest record length is 255 bytes; however, this doesn't mean that all the bytes in a sector can't be used: a fixed file with a length of 64 characters can have exactly four records in each sector. ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ