MSX-BASIC programs can be stored in two formats: Tokenized BASIC program or pure ASCII. In both cases loading can be done with LOAD-command when you work with disks.
Pure ASCII files are usually used in order to use MERGE-command or to transfer files between platforms. These files are stored as ASCII with both CR and LF as linefeed. End of file is marked with EOF (=^Z =#1A) while saving, but is not required while loading. When storing file to cassette you need to use SAVE-command. When storing file to disk you need to use SAVE-command with parameter ",A"
Typical extensions used on disk: .BAS or .TXT
Saving as Tokenized BASIC is recommended because this way programs fit to smaller space and are faster to load. When using disk you can use SAVE-command. When using cassette, you need to use [CSAVE]-command.
Tokenized BASIC programs are stored as direct memory dump of BASIC program. There is only 1 byte header that is always #FF (255). The memory addresses of lines are stored, but are not required to be correct as they are calculated again during loading time.
Typical extensions used on disk: .BAS or .LDR
MSX-BASIC binary files
These are files that can be loaded with BLOAD-command or saved with BSAVE-command. In MSX1 only normal RAM between #8000 and #FFFF can be loaded or saved. In MSX2 and up also all of 128K VRAM can be loaded or saved using ",S" parameter. (See also SET PAGE-command)
Most MSX2 and up graphic softwares uses this format also to store pictures and their palette. (DD-Graphics, Phillips Video designer, Graphsaurus etc. etc.)
These files have 7-byte header:
- Byte: #FE (Type of file)
- Word: Begin address of file
- Word: End address of file
- Word: Start address of file (Only important when ",R" parameter is defined with BLOAD-command)
Typical extensions used on disk: .BIN, .SC?, .PL?, .GE5, .PIC
Graphic files created with COPY-command
On MSX2 and up you can save or restore part of VRAM to/from disk by using COPY-command.
These files have 4-byte header:
- Word: Number of X-pixels
- Word: Number of Y-pixels
Graphics are stored after header in native pixel format from left to right and up to down. This means that number of bits/pixel depends of used graphic mode.
Tables created with COPY-command
These files don't have header. The values are stored one at a time in native BASIC format (2 bytes for integers, 4 bytes for singes and 8 bytes for doubles) after each other starting from 0 to last cell defined by DIM. In multidimensional arrays the dimensions are stored after each other from bottom to up, left to right. The format of array is not stored.