<< Back to contents.

CharPad 2.3 User Manual - Subchrist Software, 2019.

CTM File Format, Version 2.

Used by CharPad 1.7 to record project data.

First comes the header, 20 bytes...

ID_STR [00-02] : 3 bytes : File ID string (ASCII) "CTM".
VERSION [03] : 1 byte : Format version number (2).
COLOURS [04-07] : 4 bytes : Screen colour, Char multi-colour 1, Char multi-colour 2, Char colour.
COLR_METH [08] : 1 byte : Colouring method (0 = Global, 1 = Per-tile, 2 = Per-tile-cell).
MCMODE [09] : 1 byte : Char multi-colour mode flag (1 = Yes).
MAP_WID [10-11] : 2 bytes : Map width (16 bits).
MAP_HEI [12-13] : 2 bytes : Map height (16 bits).
NUM_CHARS [14-15] : 2 bytes : Character image quantity -1 (16 bits).
NUM_TILES [16] : 1 byte : Tile quantity -1.
TILE_SZ [17] : 1 byte : Tile size (1-5).
RESERVED [18-19] : 2 bytes : Unused.

Then comes the data...

CHAR_DATA : NUM_CHARS * 9 bytes. : Character image data (one byte per pixel row, each 9th byte holds a 'material' value).
TILE_DATA : NUM_TILES * TILE_SZ * TILE_SZ bytes * 2 bytes. : Tile data (16 bits per tile cell).
TILE_COLOURS : NUM_TILES bytes. : Tile colour data (one byte per tile, only exists if COLR_METH = 1).
CELL_COLOURS : NUM_TILES * TILE_SIZE * TILE_SIZE bytes. : Tile cell colour data (one byte per tile cell, only exists if COLR_METH = 2).
MAP_DATA : MAP_WID * MAP_HEI bytes. : Map data.

Notes...

16-bit values should always be interpreted as least significant byte first (LSBF).

The data for each character image (CHAR_DATA) consists of eight rows of pixels (one byte per row) starting with the top row, each 9th byte contains a material value (0-15).

The data for each tile (TILE_DATA, CELL_COLOURS) begins with the tile's top-left element and runs left-to-right, top-to-bottom (Z-pattern LRTB).

The data for the map (MAP_DATA) begins with the map's top-left element and runs left-to-right, top-to-bottom (Z-pattern LRTB).

Changes...

This version of the CTM file format enhances the previous version by including support for a 16-bit character count (up to 65536 character images), the tile data is now (necessarily) 16-bit and tile sizes are now variable between 1x1 and 5x5 (square sizes only).

Also added is an attribute byte along with each character image, CharPad 1.7 uses these to store character 'material' values (0-3).

File format limitations...

Max character images : 65536
Max tiles : 256
Max maps : 1
Max tile size : 255 x 255 (square only).
Max map width : 65535
Max map height : 65535

CharPad 1.7 limitations...

Max character images : 6400 (256 x 5 x 5).
Max tiles : 256
Max maps : 1
Max tile size : 5 x 5 (square only).
Max map width : 4096
Max map height : 4096

See also:-

CTM File Format, Version 1.
CTM File Format, Version 3.
CTM File Format, Version 4.
CTM File Format, Version 5.