Technical Support Document number 63a 

HX-20 ROM cartridge; file format
--------------------------------

General information 

The HX-20 ROM cartridge can hold up to 31 files. Each file is composed 
of a 32 byte header and a data block. 

The headers for all the files are grouped together at the top of the ROM 
with the data blocks following after the last header. To separate headers 
from data a dummy header block is used; see the table below, which gives 
the composition of the header. 

--------------------------------------------------------------------------- 
| Byte number | Contents of memory locations                              | 
--------------------------------------------------------------------------- 
| 0-7         | file name in ASCII. If byte 0 is hex FF, then this is     |
|             | the dummy header before the file data and the next 31     |
|             | bytes are ignored.  If byte 0 is hex 00, this is an       |    
|             | erased file and the data block is disregarded.            |
| 8-10        | file name extension in ASCII                              | 
|             |                                                           |
| 11-12       | byte 11; 00 - BASIC   program                             |
|             |          01 - BASIC  data                                 |
|             |          02 - machine code program                        |
|             | byte 12; 00 - binary file                                 |     
|             |          FF - ASCII file                                  |
|             |                                                           |
| 13-15       | all zeros                                                 |
|             |                                                           |
| 16-19       | file start address within the ROM in hex; 4 ASCII digits  |
|             |                                                           |
| 20-23       | file end address +1 within the ROM in hex, 4 ASCII digits |
|             |                                                           |
| 24-29       | creation date if required; 6 ASCII characters/digits      |
|             |                                                           |
| 30-31       | unused; can be used for ROM version etc if required       |
|             |                                                           |
--------------------------------------------------------------------------- 

The files themselves follow after the last header and their structures are 
described below. 

BASIC programs and data; ASCII format 

Each character in each line of text (BASIC line numbers included) is 
coded with the corresponding ASCII byte, with the two bytes OD and OA 
hex added at the end of each line of BASIC for carriage return and line 
feed. Obviously data files do not need line numbering and CR/LF.


Technical Support Document number 63a BASIC programs; internal binary format The first byte is hex FF; this is followed by two bytes for the program length (number of bytes in binary). Thereafter, each line of binary is coded as follows; 1)two bytes dummy data (nonzero); 2)two bytes for the line number (binary); 3)the BASIC program line coded as it would be stored in memory; 4)a single byte 00 hex to mark the end of the line. The file is terminated with two bytes 00 hex after the last line. Machine code files; binary format Machine code programs are split up into records of 16 bytes. Each record is coded as follows: -------------------------------------------------------------------------- | Byte numbers | Contents of memory locations | -------------------------------------------------------------------------- | 1 | number of bytes in this record; always 16 (hex 10) | | | except for the last record | | | | | 2,3 | address into which the bytes in this record are to be | | | loaded, coded as a two byte binary number | | | | | 4-15 | the bytes making up the machine code | | | | | 16 | checksum; sum of bytes 1-15 subtracted from zero | | | | -------------------------------------------------------------------------- The last record is coded slightly differently as follows: -------------------------------------------------------------------------- | Byte numbers | Contents of memory locations | -------------------------------------------------------------------------- | 1 | 00 hex | | | | | 2,3 | program entry address, coded as a two byte binary number| | | | | 4-15 | 00 hex | | | | | 16 | checksum, coded as above | | | | --------------------------------------------------------------------------