diff --git a/JoeyLib-Formats.md b/JoeyLib-Formats.md new file mode 100644 index 0000000..0ce695a --- /dev/null +++ b/JoeyLib-Formats.md @@ -0,0 +1,52 @@ +#### STA - Static Images +Static images are created either by JoeyLib applications or the `imgconvert` tool. Static images are 320x200 pixels with a 16 color 4-bit RGB palette. The on-disk format is the same as the in-memory format. STA files begin with a three byte signature ("STA") and a single byte version number followed by palette and then image data. + +```c +typedef struct { + byte b : 4; + byte g : 4; + byte r : 4; + byte reserved : 4; +} jlColorT; + +typedef struct { + byte l : 4; + byte r : 4; +} jlPixelPairT; + +typedef struct { + char id[3]; + byte version; + jlColorT palette[16]; // 4 bits reserved, 4 bits red, 4 green, 4 blue + jlPixelPairT pixels[32000]; // 320x200, 4 bits per pixel +} jlStaT; +``` + +#### VEC - Vector Images +Vector images begin life as a text file specifying the operations needed to draw them. The text file is processed by the `vecdraw` utility into an efficient byte stream that can be used by JoeyLib. The supported operations in the text format are: +``` +C - Specify Drawing Color +E - Erase the Display +D ... - Draw a Pixel +L ... - Draw a Line +B ... - Draw a Hollow Box +S ... - Draw a Solid Box +F ... - Flood Fill over Single Color +T ... - Flood Fill To Color +P ... - Set Palette Color +R - Reset Palette to Default +``` +One command can be entered per line and lines can be up to 1024 characters long. + +Commands followed by "..." can have additional sets of parameters added to repeat the operation without the need to specify another command line. + +After processing, the byte stream is stored as a three byte header ("VEC") followed by a single byte version number, an unsigned integer length of the data to follow, and then the data itself. +```c +typedef struct { + char id[3]; + byte version; + unsigned int length; + byte *data; +} jlVecT; +``` +**NOTE:** At the moment, all X coordinates range from 0 to 255 and are scaled up to 0-319 when drawn. While this saves space in the byte stream, it may make things ugly. If it's too bad, it will be changed. \ No newline at end of file