SCS-Draw saves images in image library files with extension DRW. DRW is a container format for images in the DMP raster image format. An Image Library can contain up to 5000 images, each with a name up to 20 characters long, separated into pages of 20 images per page.
An SCS-Draw Image Library can be identified by the signature "DMP Image Library" at 0xC0. Doug Mahugh developed the DMP format in the fall of 1984 as an image format for dot matrix printers. ("DMP" stands for "Dot Matrix Printer" or "Doug Mahugh's Program".) Doug wrote a program called DMP in SBASIC to print .DMP images, but decided that he needed to program in Z80 Assembly language for performance, and so that the program could reside entirely within the Z80's 64 KB RAM limit. This led him to develop a full drawing program that displayed images on screen using Kaypro graphics. The new program was renamed Draw, and the image library file extension changed to DRW.
The DRW format consists of a Library Header, a Page Header for each page, and an Image Header for each image. The byte order for numeric fields is little-endian.
The library header is 128 bytes and begins at 0x80. (The first 128 bytes of a DRW file is garbage which should be ignored.)
Offset | Size | Description |
---|---|---|
0x00 | 2B | Library size in sectors |
0x02 | 2B | Image count |
0x04 | 2B | Page count |
0x06 | 58B | Reserved for future use (null) |
0x40 | 20B | Signature ("DMP Image Library", terminated with 3 nulls) |
0x54 | 24B | Reserved for future use (null) |
0x6C | 20B | Library name (0x20 padded) |
The page header is 512 bytes. There will always be at least one page header, the first of which is located at 0x100. The page headers are a doubly linked list, storing the starting address of the previous and next page header so that SCS-Draw can iterate between pages. This eliminates the need to reserve space in the Library Header for a table with addresses for up to 250 page headers, but prevents SCS-Draw from jumping to a specific page. (The "Save/Select Image" menu only allows navigating to the next or previous page, which could be inconvenient in an Image Library with hundreds of images.)
Offset | Size | Description |
---|---|---|
0x00 | 2B | Starting sector of next page (null if this is the last page) |
0x02 | 2B | Starting sector of previous page (null if this is the first page) |
0x04 | 2B | Image count for this page |
0x06 | 14B | Reserved for future use (null) |
0x14 | 40B | Table with starting 16-bit sector number for each of 20 images |
0x3C | 52B | Reserved for future use (null) |
0x70 | 400B | Table with 20-character names for each of 20 images (0x20 padded) |
The image header is 640 bytes. It contains the starting address of up to 56 "rows" of pixel data, which can be 128, 256, or 384 bytes in length. The maximum image size is 362x336, or 121 632 pixels.
Offset | Size | Description |
---|---|---|
0x00 | 2B | Image width in dots |
0x02 | 2B | Image height in rows |
0x04 | 124B | Reserved for future use (null) |
0x80 | 112B | Table with starting 16-bit sector number for each row |
0xC0 | 400B | Reserved for future use (null) |
DMP is a 1-bit (monochrome) bitmapped image format. Draw uses a single printer driver with a printhead height of 6 dots, and matches the DMP format to also store only 6 dots per byte in order to keep the code simpler by not having to remap the image to the capabilities of each printer (some dot matrix printers use only 6 or 7 dots per byte in order to use 1 or 2 bits for other purposes). The trade-off is that printing is a bit slower on printers that can use all 8 dots per byte - for example, an image that is 48 pixels tall requires 8 passes of the printhead instead of 6.
Pixel data is organized into "rows" of 1 to 3 consecutive 128-byte sectors. The last 6 bytes in each sector are unused, so a row is composed of 128 bytes if the image is 1-122 pixels wide, 256 bytes if 123-244 pixels wide, and 384 bytes if 245-362 pixels wide. The highest- and lowest-order bit in each byte is not used (set to 0), and the remaining 6 bits represent a column of horizontal pixels going downwards. The pixel format for each 6-pixel column is depicted below, with decimal values for each bit.
°️°️°️°️°️°️°️°️ 01111110 º️°️º️º️º️º️º️º️º️°️ª️ °️°️ 64°️°️°️ª️ °️°️ 32°️°️°️°️°️ª️ °️°️ 16°️°️°️°️°️°️°️ª️ °️°️ 8°️°️°️°️°️°️°️°️°️ª️ °️°️ 4°️°️°️°️°️°️°️°️°️°️°️ª️ °️°️ 2°️°️°️°️°️°️°️°️°️°️°️°️°️ª️ º️°️°️ª️