cardfile file format


microsoft applications note
cardfile file format

the cardfile file format is as follows:

byte #    description

0 - 2    "signature bytes --- always ""mgc"" (4d 47 43) "   
3 - 4    number of cards in file
                       
beyond the first five bytes are the index lines --- the
information about the top line of each"card. the first
index entry begins at byte #5 in the file, and successive
entries begin 34 bytes after the beginning of the last index
entry (the second entry at byte #39, the third entry at byte
#6d, etc.). the format for each index line entry is as
follows:

0 - 5    null bytes, reserved for future use (should all be 00)
6 - 9    absolute position of card data in file    
a        flag byte (00)
b - 32    index line text
33        null byte ; indicates end of index entry

after the last index entry, each card's data is stored.
card data will be in one of four general formats: graphic
and text, text only, graphic only, and blank. blank cards
consist of four null bytes; the other card formats are
below:
                       
graphic    text        graphic
& text    only        only
0 - 1    0 - 1#    0 - 1    length of graphic bitmap. #
2 - 3 *        2 - 3    width of graphic. *
4 - 5    *        4 - 5     height of graphic. *
6 - 7    *        6 - 7     x-coordinate of graphic. *
8 - 9    *        8 - 9     y-coordinate of graphic. *
a - x    *        a - x     bitmap of graphic. *   
x+1 - x+2    2 - 3 x+1 - x+2#length of text entry. #   
x+3 - y     4 - z    *    text. *    
                       
x = 9 + length of bitmap
# - bytes are null if no bitmap/text
y = x + 2 + length of text entry    
* - bytes don't exist if no bitmap/text   
z = 3 + length of text entry    
                       
the first byte of any card's data entry is pointed to by
bytes 6-9 in the index entry. note that no null byte is
used to indicate the end of the card's data entry; the next
card's data entry immediately follows the last byte of the
previous entry, which will be null only if the previous card
has no text (null length of text entry).
           
all numbers in this document, including those in the
descriptive text, should be interpreted as hexadecimal
numerals. all data pointers and count bytes in the file are
unsigned binary/hexadecimal integers in least- to most
significant format. all text in the file is saved in low
ascii format. in the text section of a card's data, <cr> is
always followed by <lf>.