<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://sciwiki.sierrahelp.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Rainer+De+Temple</id>
	<title>SCI Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://sciwiki.sierrahelp.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Rainer+De+Temple"/>
	<link rel="alternate" type="text/html" href="http://sciwiki.sierrahelp.com/index.php/Special:Contributions/Rainer_De_Temple"/>
	<updated>2026-10-17T19:08:53Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.9</generator>
	<entry>
		<id>http://sciwiki.sierrahelp.com/index.php?title=Picture_Resource&amp;diff=15237</id>
		<title>Picture Resource</title>
		<link rel="alternate" type="text/html" href="http://sciwiki.sierrahelp.com/index.php?title=Picture_Resource&amp;diff=15237"/>
		<updated>2020-10-15T02:19:35Z</updated>

		<summary type="html">&lt;p&gt;Rainer De Temple: formatting&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div align=&amp;quot;center&amp;quot; style=&amp;quot;font-size: 22pt&amp;quot;&amp;gt;&amp;#039;&amp;#039;&amp;#039;The SCI Picture Resource&amp;#039;&amp;#039;&amp;#039;&amp;lt;/div&amp;gt;&amp;amp;nbsp;&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;amp;nbsp;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;br /&amp;gt; Description ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Place holder for the SCI Picture Resource&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Format/Specifications ==&lt;br /&gt;
&lt;br /&gt;
The picture resource is a vector image format defined by unsigned bytes in the file.&lt;br /&gt;
&lt;br /&gt;
A Picture Resource File always begins with a two-byte header identifier of 0x8100, followed by the first drawing instruction.&lt;br /&gt;
&lt;br /&gt;
Below is a summary of each drawing instruction:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
! Number &lt;br /&gt;
! Hex&lt;br /&gt;
! Parameters&lt;br /&gt;
! Description&lt;br /&gt;
! Example&lt;br /&gt;
|- &lt;br /&gt;
| 0&lt;br /&gt;
| 0xF0&lt;br /&gt;
| 0x## (1 byte)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Set Visual Color &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Sets the visual color index to the value specified&lt;br /&gt;
| &amp;lt;code&amp;gt;F0 0C&amp;lt;/code&amp;gt;  Sets the visual palette index to 0x0C (color 12, bright red)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 0xF1&lt;br /&gt;
| &lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Disable Visual &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Disables drawing on visual canvas&lt;br /&gt;
| &amp;lt;code&amp;gt;F1&amp;lt;/code&amp;gt; Disable visual drawing&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 0xF2&lt;br /&gt;
| 0x## (lower 4-bits only)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Set Priority Color &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Sets the priority color index to the value specified&lt;br /&gt;
| &amp;lt;code&amp;gt;F0 05&amp;lt;/code&amp;gt;  Sets the priority color to 0x05 (color 5, Magenta)&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| 0xF3&lt;br /&gt;
| &lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Disable Priority &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Disables drawing on priority canvas&lt;br /&gt;
| &amp;lt;code&amp;gt;F3&amp;lt;/code&amp;gt; Disable priority drawing&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| 0xF4&lt;br /&gt;
|&lt;br /&gt;
(0x##) Pattern number if flag set&lt;br /&gt;
&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
(0x##) Pattern number if flag set&amp;lt;br&amp;gt;&lt;br /&gt;
0xXY offset ([[wikipedia:Signed number representations#Signed magnitude representation|signed]] 4 bit words)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Short Relative Patterns &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots patterns from the coordinates specified to the offset coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F4 10 22 AC D9&amp;lt;/code&amp;gt; Plot current pattern type at coordinates 0x122,0x0AC(290,172) and then (-5,-1) at (285,171)&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| 0xF5&lt;br /&gt;
|&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
0xYY Offset for Y using [[wikipedia:Signed number representations#Signed magnitude representation|sign-magnitude]]&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX Offset for X using [[wikipedia:Signed number representations#Two&amp;#039;s complement|2&amp;#039;s Compliment]]&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Medium Relative Lines &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots short lines from starting coordinates, to offset coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 85 FB&amp;lt;/code&amp;gt; Draw a line starting at 0x122,0x0AC(290,172) to offset 0xFB,0x85(-5,-5) at (285,167)&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| 0xF6&lt;br /&gt;
|&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
0xXY Upper 4-bits for next X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for next X and Y coordinates&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Long Lines &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots lines from starting coordinates, to next coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 00 05 0F&amp;lt;/code&amp;gt; Draw a line starting at 0x122,0x0AC(290,172) to 0x005,0x00F(5,14)&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| 0xF7&lt;br /&gt;
|&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
0xXY offset ([[wikipedia:Signed number representations#Signed magnitude representation|signed]] 4 bit words)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Short Relative Lines &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots lines from starting coordinates, to next coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 00 5D&amp;lt;/code&amp;gt; Draw a line starting at 0x122,0x0AC(290,172) to offset 0x5,0xD(5,-5) at (295, 167)&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| 0xF8&lt;br /&gt;
|&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
0xXY offset ([[wikipedia:Signed number representations#Signed magnitude representation|signed]] 4 bit words)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Flood fill &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots lines from starting coordinates, to next coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 00 5D&amp;lt;/code&amp;gt; Draw a line starting at 0x122,0x0AC(290,172) to offset 0x5,0xD(5,-5) at (295, 167)&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| 0xF9&lt;br /&gt;
|&lt;br /&gt;
0x## &amp;lt;br&amp;gt;&lt;br /&gt;
Bit 4 - Use Solid/Pattern Flag&amp;lt;br&amp;gt;&lt;br /&gt;
Bit 5 - Use Circle/Rectangle&amp;lt;br&amp;gt;&lt;br /&gt;
Bits 0-3 - Pattern Size (0-7)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Set Pattern &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Sets Pattern style flags and Pattern size.&lt;br /&gt;
| &amp;lt;code&amp;gt;F9 23&amp;lt;/code&amp;gt; Sets pattern brush to size 3 and type to random pattern.&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| 0xFA&lt;br /&gt;
|&lt;br /&gt;
(0x##) Pattern number if use pattern flag set&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
0xXY Upper 4-bits for next X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for next X and Y coordinates&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Long Patterns &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots a pattern using the set flags, size and number to coordinates specified. Command is repeated until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;FA 10 22 AC&amp;lt;/code&amp;gt; Plot a pattern at coordinates 0x122,0x0AC(290,172)&lt;br /&gt;
|-&lt;br /&gt;
| 11&lt;br /&gt;
| 0xFB&lt;br /&gt;
| 0x## (lower 4-bits only)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Set Control Color &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Sets the control color index to the value specified&lt;br /&gt;
| &amp;lt;code&amp;gt;FB 02&amp;lt;/code&amp;gt;  Sets the control color to 0x02 (color 2, Green)&lt;br /&gt;
|-&lt;br /&gt;
| 12&lt;br /&gt;
| 0xFC&lt;br /&gt;
| &lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Disable Control &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Disables drawing on control canvas&lt;br /&gt;
| &amp;lt;code&amp;gt;FC&amp;lt;/code&amp;gt; Disable control drawing&lt;br /&gt;
|-&lt;br /&gt;
| 13&lt;br /&gt;
| 0xFD&lt;br /&gt;
|&lt;br /&gt;
(0x##) Pattern number if use pattern flag set&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
(0x##) Pattern number if flag set&amp;lt;br&amp;gt;&lt;br /&gt;
0xYY Offset for Y using [[wikipedia:Signed number representations#Signed magnitude representation|sign-magnitude]]&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX Offset for X using [[wikipedia:Signed number representations#Two&amp;#039;s complement|2&amp;#039;s Compliment]]&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Medium Relative Patterns &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots short lines from starting coordinates, to offset coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 85 FB&amp;lt;/code&amp;gt; Plot a pattern starting at 0x122,0x0AC(290,172) then to offset 0xFB,0x85(-5,-5) at (285,167)&lt;br /&gt;
|-&lt;br /&gt;
| 14&lt;br /&gt;
| 0xFE&lt;br /&gt;
|&lt;br /&gt;
0x## Extended Command Number&lt;br /&gt;
&lt;br /&gt;
(0x00) Set palette Entry&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## Palette Index(across all 4 palettes)&amp;lt;br&amp;gt;&lt;br /&gt;
0xXY Set first color to X and second to Y&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x01) Set Entire Palette&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## Palette Number&amp;lt;br&amp;gt;&lt;br /&gt;
0xXY Set first color to X and second to Y (for 40 iterations)&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x02) Set Mono0 Set Monochrome Palette&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## Palette Number&amp;lt;br&amp;gt;&lt;br /&gt;
0xXY Set first color to X and second to Y (for 40 iterations)&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x03) Set Mono1 Set Visual (using monochrome palette)&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## Color&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x04) Set Mono2 Disable Visual&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
(0x05) Set Mono3 Set direct Visual (without going through the mono palette) &lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## Color&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x06) Set Mono4 Disable direct Visual&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
(0x07) Embed Cel (bitmap) (SCI01 Onwards Only)&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0xXY Upper 4-bits for X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0x## 0x## Size of the data to follow in bytes (little endian)&amp;lt;br&amp;gt;&lt;br /&gt;
0x## (for size amount of bytes) Refer to [[SCI_Specifications:_Chapter_3_-_The_Graphics_subsystem#Image_Cell|View documentation]] for Cel format&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x08) Set Priority Bands (SCI01 Onwards Only)&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## Y locations for priority bands (14 num)??&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Command extensions &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Execute the extended command specified. Note these differ for SCI1.1 (VGA).&lt;br /&gt;
| &amp;lt;code&amp;gt;FE 00 10 22&amp;lt;/code&amp;gt;Set palette entry 16 in palette 1 to 0x22 (2,2)&lt;br /&gt;
|-&lt;br /&gt;
| 15&lt;br /&gt;
| 0xFF&lt;br /&gt;
| &lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Picture End &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Signals the end of the picture commands.&lt;br /&gt;
| &amp;lt;code&amp;gt;FF&amp;lt;/code&amp;gt; End of Drawing Commands.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Short, Medium, Long? === &lt;br /&gt;
&lt;br /&gt;
The different types is likely to help in reducing file size for the pictures. You can see that a &amp;quot;Long&amp;quot; line uses 6 bytes, however a Medium uses 5 bytes, and a short 4 bytes. There is a trade-off on line length - for example a &amp;quot;Short&amp;quot; line can only be up to 7 pixels long. This could be automatically determined by the picture editor software. &lt;br /&gt;
An image with 100 short lines would only be 400 bytes on disk, whereas using long lines is 50% larger at 600 bytes. When you&amp;#039;re designing a game to be shipped on 720k disks, every byte counts.&lt;br /&gt;
&lt;br /&gt;
=== Palette ===&lt;br /&gt;
&lt;br /&gt;
Each drawing can contain up to 4 palettes of 40 colors. Each entry in the palette consists of a first and second color. Where both are the same value the color appears solid. When the values are different then the color is &amp;quot;dithered&amp;quot; between those two colors.&lt;br /&gt;
&lt;br /&gt;
The default palette (ie palette 1) is set as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;INSERT IMAGE HERE &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
In hexadecimal format:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;Code:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;&lt;br /&gt;
std::array&amp;lt;std::pair&amp;lt;uint8_t,uint8_t&amp;gt;, 40&amp;gt; default_palette =&lt;br /&gt;
{{&lt;br /&gt;
     {0x0,0x0}, {0x1,0x1}, {0x2,0x2}, {0x3,0x3}, {0x4,0x4}, {0x5,0x5}, {0x6,0x6}, {0x7,0x7},&lt;br /&gt;
     {0x8,0x8}, {0x9,0x9}, {0xa,0xa}, {0xb,0xb}, {0xc,0xc}, {0xd,0xd}, {0xe,0xe}, {0x8,0x8},&lt;br /&gt;
     {0x8,0x8}, {0x0,0x1}, {0x0,0x2}, {0x0,0x3}, {0x0,0x4}, {0x0,0x5}, {0x0,0x6}, {0x8,0x8},&lt;br /&gt;
     {0x8,0x8}, {0xf,0x9}, {0xf,0xa}, {0xf,0xb}, {0xf,0xc}, {0xf,0xd}, {0xf,0xe}, {0xf,0xf},&lt;br /&gt;
     {0x0,0x8}, {0x9,0x1}, {0x2,0xa}, {0x3,0xb}, {0x4,0xc}, {0x5,0xd}, {0x6,0xe}, {0x8,0x8}&lt;br /&gt;
}};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The default palette is duplicated across all 4 palettes at the start of a picture.&lt;br /&gt;
&lt;br /&gt;
=== Line and Flood-fill algorithms ===&lt;br /&gt;
&lt;br /&gt;
Typically, the [[wikipedia:Bresenham&amp;#039;s line algorithm|Bresenham line-algorithm]] is used for line drawing. &lt;br /&gt;
&lt;br /&gt;
Below is an example of what the routine might look like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;Code:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;&lt;br /&gt;
void dither_line(int x0, int y0, int x1, int y1, std::pair&amp;lt;uint8_t, uint8_t&amp;gt; col, uint8_t priority, uint8_t control, uint8_t draw_enable)&lt;br /&gt;
{&lt;br /&gt;
    int dx =  std::abs(x1-x0);&lt;br /&gt;
    int sx = x0&amp;lt;x1 ? 1 : -1;&lt;br /&gt;
    int dy = -std::abs(y1-y0);&lt;br /&gt;
    int sy = y0&amp;lt;y1 ? 1 : -1;&lt;br /&gt;
    int err = dx+dy;  &lt;br /&gt;
    while(true)&lt;br /&gt;
    {&lt;br /&gt;
        uint8_t line_col = ((x0 + y0) % 2) ? col.first : col.second;&lt;br /&gt;
        if (draw_enable &amp;amp; DRAW_ENABLE_VISUAL) plot_pixel(x0, y0, visual_pixels, line_col);&lt;br /&gt;
        if (draw_enable &amp;amp; DRAW_ENABLE_PRIORITY) plot_pixel(x0, y0, priority_pixels, priority);&lt;br /&gt;
        if (draw_enable &amp;amp; DRAW_ENABLE_CONTROL) plot_pixel(x0, y0, control_pixels, control);&lt;br /&gt;
        if (x0==x1 &amp;amp;&amp;amp; y0==y1) break;&lt;br /&gt;
        int e2 = 2*err;&lt;br /&gt;
        if (e2 &amp;gt;= dy) &lt;br /&gt;
        {&lt;br /&gt;
            err += dy;&lt;br /&gt;
            x0 += sx;&lt;br /&gt;
        }&lt;br /&gt;
        if (e2 &amp;lt;= dx) &lt;br /&gt;
        {&lt;br /&gt;
            err += dx;&lt;br /&gt;
            y0 += sy;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similarly, a basic 4-way recursive [[wikipedia:Flood fill|flood fill]] algorithm is used for the fill function.&lt;br /&gt;
&lt;br /&gt;
An example of how the flood fill procedure may work:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;Code:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;&lt;br /&gt;
void dither_fill(int x, int y, std::pair&amp;lt;uint8_t, uint8_t&amp;gt; col, uint8_t priority, uint8_t control, uint8_t draw_enable)&lt;br /&gt;
{&lt;br /&gt;
    int legal_color = 0xf;&lt;br /&gt;
    static std::array&amp;lt;uint8_t, 320*200&amp;gt; bound_pixels; // a temporary working area&lt;br /&gt;
    if (draw_enable &amp;amp; DRAW_ENABLE_VISUAL) { bound_pixels = visual_pixels; legal_color = 0xf;}&lt;br /&gt;
    else if (draw_enable &amp;amp; DRAW_ENABLE_PRIORITY) { bound_pixels = priority_pixels; legal_color = 0;}&lt;br /&gt;
    else if (draw_enable &amp;amp; DRAW_ENABLE_CONTROL) { bound_pixels = control_pixels; legal_color = 0;}&lt;br /&gt;
    else return; // no draw flags set&lt;br /&gt;
&lt;br /&gt;
    if (x&amp;lt;0 || x&amp;gt;319 || y&amp;lt;0 || y&amp;gt;189) return; // don&amp;#039;t fill outside canvas&lt;br /&gt;
&lt;br /&gt;
    if (bound_pixels[x + (y * 320)] != legal_color) return; // don&amp;#039;t fill non-white/black areas&lt;br /&gt;
    &lt;br /&gt;
    // plot the pixel&lt;br /&gt;
    if (draw_enable &amp;amp; DRAW_ENABLE_VISUAL)   plot_pixel(x, y, visual_pixels, ((x + y) % 2) ? col.first : col.second);&lt;br /&gt;
    if (draw_enable &amp;amp; DRAW_ENABLE_PRIORITY) plot_pixel(x, y, priority_pixels, priority);&lt;br /&gt;
    if (draw_enable &amp;amp; DRAW_ENABLE_CONTROL)  plot_pixel(x, y, control_pixels, control);&lt;br /&gt;
    &lt;br /&gt;
    // recursively call for neighbours&lt;br /&gt;
    dither_fill(x, y+1, col, priority, control, draw_enable);&lt;br /&gt;
    dither_fill(x, y-1, col, priority, control, draw_enable);&lt;br /&gt;
    dither_fill(x-1, y, col, priority, control, draw_enable);&lt;br /&gt;
    dither_fill(x+1, y, col, priority, control, draw_enable);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{note|The recursive fill above may not work on larger fill areas and cause a stack overflow. A better way to to keep an organised list (ie a queue) of points to fill, popping them off the list as each is filled.}}&lt;br /&gt;
&lt;br /&gt;
=== Dithering ===&lt;br /&gt;
One of the identifying qualities of an SCI EGA Picture is it&amp;#039;s dithering. This is done by alternating between color 1 and color 2 from the palette.&lt;br /&gt;
&lt;br /&gt;
A practical way (easy to understand) to do this is using the following formula:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
if ((x + y) % 2) color = col.first&lt;br /&gt;
else color = col.second&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or (for older computers):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
if ((x + y) &amp;amp; 1) color = col.first &lt;br /&gt;
else color = col.second&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
Pictures keep two flags for whether to draw a circle or square, and solid or random pattern (spray-paint style).&lt;br /&gt;
&lt;br /&gt;
;USE_RECTANGLE_FLAG : 0x10 (bit 4)&lt;br /&gt;
;USE_PATTERN_FLAG : 0x20 (bit 5)&lt;br /&gt;
&lt;br /&gt;
At the start of a picture these flags are both set to zero (ie use circles, and use solids).&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; INSERT PATTERN TYPES IMAGE HERE &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
There are 120 different styles of &amp;quot;random&amp;quot; pattern available. &lt;br /&gt;
&lt;br /&gt;
A texture bitmap is sampled from different offsets to generate each style.&lt;br /&gt;
The texture is defined as a 256-bit array:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
0x20, 0x94, 0x02, 0x24, 0x90, 0x82, 0xa4, 0xa2,&lt;br /&gt;
0x82, 0x09, 0x0a, 0x22, 0x12, 0x10, 0x42, 0x14,&lt;br /&gt;
0x91, 0x4a, 0x91, 0x11, 0x08, 0x12, 0x25, 0x10,&lt;br /&gt;
0x22, 0xa8, 0x14, 0x24, 0x00, 0x50, 0x24, 0x04&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Pattern number is an index to the following table, which in turn is an offset into the texture defined above.&lt;br /&gt;
&amp;lt;pre&amp;gt;    &lt;br /&gt;
0x00, 0x18, 0x30, 0xc4, 0xdc, 0x65, 0xeb, 0x48,&lt;br /&gt;
0x60, 0xbd, 0x89, 0x04, 0x0a, 0xf4, 0x7d, 0x6d,&lt;br /&gt;
0x85, 0xb0, 0x8e, 0x95, 0x1f, 0x22, 0x0d, 0xdf,&lt;br /&gt;
0x2a, 0x78, 0xd5, 0x73, 0x1c, 0xb4, 0x40, 0xa1,&lt;br /&gt;
0xb9, 0x3c, 0xca, 0x58, 0x92, 0x34, 0xcc, 0xce,&lt;br /&gt;
0xd7, 0x42, 0x90, 0x0f, 0x8b, 0x7f, 0x32, 0xed,&lt;br /&gt;
0x5c, 0x9d, 0xc8, 0x99, 0xad, 0x4e, 0x56, 0xa6,&lt;br /&gt;
0xf7, 0x68, 0xb7, 0x25, 0x82, 0x37, 0x3a, 0x51,&lt;br /&gt;
0x69, 0x26, 0x38, 0x52, 0x9e, 0x9a, 0x4f, 0xa7,&lt;br /&gt;
0x43, 0x10, 0x80, 0xee, 0x3d, 0x59, 0x35, 0xcf,&lt;br /&gt;
0x79, 0x74, 0xb5, 0xa2, 0xb1, 0x96, 0x23, 0xe0,&lt;br /&gt;
0xbe, 0x05, 0xf5, 0x6e, 0x19, 0xc5, 0x66, 0x49,&lt;br /&gt;
0xf0, 0xd1, 0x54, 0xa9, 0x70, 0x4b, 0xa4, 0xe2,&lt;br /&gt;
0xe6, 0xe5, 0xab, 0xe4, 0xd2, 0xaa, 0x4c, 0xe3,&lt;br /&gt;
0x06, 0x6f, 0xc6, 0x4a, 0x75, 0xa3, 0x97, 0xe1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the pattern size forces the sample point past the length of the texture, then it wraps back around to zero. With modern computers the texture could be repeated twice to avoid having to write code to wrap around (SCUMMVM does this).&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;br /&amp;gt; Versions ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
===&amp;lt;br /&amp;gt; PIC ===&lt;br /&gt;
&lt;br /&gt;
* Used with [[SCI0]] games [[#note|*]]&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;br /&amp;gt; P16 ===&lt;br /&gt;
&lt;br /&gt;
* &lt;br /&gt;
&lt;br /&gt;
===&amp;lt;br /&amp;gt; P56 ===&lt;br /&gt;
&lt;br /&gt;
* &lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;br /&amp;gt; References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Also See ==&lt;br /&gt;
&lt;br /&gt;
* [[SCI Specifications: Chapter 1 - Introduction#PIC]]&lt;br /&gt;
* [[SCI Specifications: Chapter 1 - Introduction#P16]]&lt;br /&gt;
* [[SCI Specifications: Chapter 1 - Introduction#P56]]&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
[[Category:SCI Resources]]&lt;/div&gt;</summary>
		<author><name>Rainer De Temple</name></author>
	</entry>
	<entry>
		<id>http://sciwiki.sierrahelp.com/index.php?title=Picture_Resource&amp;diff=15236</id>
		<title>Picture Resource</title>
		<link rel="alternate" type="text/html" href="http://sciwiki.sierrahelp.com/index.php?title=Picture_Resource&amp;diff=15236"/>
		<updated>2020-10-15T02:18:38Z</updated>

		<summary type="html">&lt;p&gt;Rainer De Temple: recursive fill doesn&amp;#039;t work for large areas.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div align=&amp;quot;center&amp;quot; style=&amp;quot;font-size: 22pt&amp;quot;&amp;gt;&amp;#039;&amp;#039;&amp;#039;The SCI Picture Resource&amp;#039;&amp;#039;&amp;#039;&amp;lt;/div&amp;gt;&amp;amp;nbsp;&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;amp;nbsp;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;br /&amp;gt; Description ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Place holder for the SCI Picture Resource&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Format/Specifications ==&lt;br /&gt;
&lt;br /&gt;
The picture resource is a vector image format defined by unsigned bytes in the file.&lt;br /&gt;
&lt;br /&gt;
A Picture Resource File always begins with a two-byte header identifier of 0x8100, followed by the first drawing instruction.&lt;br /&gt;
&lt;br /&gt;
Below is a summary of each drawing instruction:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
! Number &lt;br /&gt;
! Hex&lt;br /&gt;
! Parameters&lt;br /&gt;
! Description&lt;br /&gt;
! Example&lt;br /&gt;
|- &lt;br /&gt;
| 0&lt;br /&gt;
| 0xF0&lt;br /&gt;
| 0x## (1 byte)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Set Visual Color &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Sets the visual color index to the value specified&lt;br /&gt;
| &amp;lt;code&amp;gt;F0 0C&amp;lt;/code&amp;gt;  Sets the visual palette index to 0x0C (color 12, bright red)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 0xF1&lt;br /&gt;
| &lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Disable Visual &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Disables drawing on visual canvas&lt;br /&gt;
| &amp;lt;code&amp;gt;F1&amp;lt;/code&amp;gt; Disable visual drawing&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 0xF2&lt;br /&gt;
| 0x## (lower 4-bits only)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Set Priority Color &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Sets the priority color index to the value specified&lt;br /&gt;
| &amp;lt;code&amp;gt;F0 05&amp;lt;/code&amp;gt;  Sets the priority color to 0x05 (color 5, Magenta)&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| 0xF3&lt;br /&gt;
| &lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Disable Priority &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Disables drawing on priority canvas&lt;br /&gt;
| &amp;lt;code&amp;gt;F3&amp;lt;/code&amp;gt; Disable priority drawing&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| 0xF4&lt;br /&gt;
|&lt;br /&gt;
(0x##) Pattern number if flag set&lt;br /&gt;
&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
(0x##) Pattern number if flag set&amp;lt;br&amp;gt;&lt;br /&gt;
0xXY offset ([[wikipedia:Signed number representations#Signed magnitude representation|signed]] 4 bit words)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Short Relative Patterns &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots patterns from the coordinates specified to the offset coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F4 10 22 AC D9&amp;lt;/code&amp;gt; Plot current pattern type at coordinates 0x122,0x0AC(290,172) and then (-5,-1) at (285,171)&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| 0xF5&lt;br /&gt;
|&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
0xYY Offset for Y using [[wikipedia:Signed number representations#Signed magnitude representation|sign-magnitude]]&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX Offset for X using [[wikipedia:Signed number representations#Two&amp;#039;s complement|2&amp;#039;s Compliment]]&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Medium Relative Lines &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots short lines from starting coordinates, to offset coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 85 FB&amp;lt;/code&amp;gt; Draw a line starting at 0x122,0x0AC(290,172) to offset 0xFB,0x85(-5,-5) at (285,167)&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| 0xF6&lt;br /&gt;
|&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
0xXY Upper 4-bits for next X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for next X and Y coordinates&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Long Lines &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots lines from starting coordinates, to next coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 00 05 0F&amp;lt;/code&amp;gt; Draw a line starting at 0x122,0x0AC(290,172) to 0x005,0x00F(5,14)&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| 0xF7&lt;br /&gt;
|&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
0xXY offset ([[wikipedia:Signed number representations#Signed magnitude representation|signed]] 4 bit words)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Short Relative Lines &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots lines from starting coordinates, to next coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 00 5D&amp;lt;/code&amp;gt; Draw a line starting at 0x122,0x0AC(290,172) to offset 0x5,0xD(5,-5) at (295, 167)&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| 0xF8&lt;br /&gt;
|&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
0xXY offset ([[wikipedia:Signed number representations#Signed magnitude representation|signed]] 4 bit words)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Flood fill &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots lines from starting coordinates, to next coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 00 5D&amp;lt;/code&amp;gt; Draw a line starting at 0x122,0x0AC(290,172) to offset 0x5,0xD(5,-5) at (295, 167)&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| 0xF9&lt;br /&gt;
|&lt;br /&gt;
0x## &amp;lt;br&amp;gt;&lt;br /&gt;
Bit 4 - Use Solid/Pattern Flag&amp;lt;br&amp;gt;&lt;br /&gt;
Bit 5 - Use Circle/Rectangle&amp;lt;br&amp;gt;&lt;br /&gt;
Bits 0-3 - Pattern Size (0-7)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Set Pattern &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Sets Pattern style flags and Pattern size.&lt;br /&gt;
| &amp;lt;code&amp;gt;F9 23&amp;lt;/code&amp;gt; Sets pattern brush to size 3 and type to random pattern.&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| 0xFA&lt;br /&gt;
|&lt;br /&gt;
(0x##) Pattern number if use pattern flag set&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
0xXY Upper 4-bits for next X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for next X and Y coordinates&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Long Patterns &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots a pattern using the set flags, size and number to coordinates specified. Command is repeated until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;FA 10 22 AC&amp;lt;/code&amp;gt; Plot a pattern at coordinates 0x122,0x0AC(290,172)&lt;br /&gt;
|-&lt;br /&gt;
| 11&lt;br /&gt;
| 0xFB&lt;br /&gt;
| 0x## (lower 4-bits only)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Set Control Color &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Sets the control color index to the value specified&lt;br /&gt;
| &amp;lt;code&amp;gt;FB 02&amp;lt;/code&amp;gt;  Sets the control color to 0x02 (color 2, Green)&lt;br /&gt;
|-&lt;br /&gt;
| 12&lt;br /&gt;
| 0xFC&lt;br /&gt;
| &lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Disable Control &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Disables drawing on control canvas&lt;br /&gt;
| &amp;lt;code&amp;gt;FC&amp;lt;/code&amp;gt; Disable control drawing&lt;br /&gt;
|-&lt;br /&gt;
| 13&lt;br /&gt;
| 0xFD&lt;br /&gt;
|&lt;br /&gt;
(0x##) Pattern number if use pattern flag set&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
(0x##) Pattern number if flag set&amp;lt;br&amp;gt;&lt;br /&gt;
0xYY Offset for Y using [[wikipedia:Signed number representations#Signed magnitude representation|sign-magnitude]]&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX Offset for X using [[wikipedia:Signed number representations#Two&amp;#039;s complement|2&amp;#039;s Compliment]]&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Medium Relative Patterns &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots short lines from starting coordinates, to offset coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 85 FB&amp;lt;/code&amp;gt; Plot a pattern starting at 0x122,0x0AC(290,172) then to offset 0xFB,0x85(-5,-5) at (285,167)&lt;br /&gt;
|-&lt;br /&gt;
| 14&lt;br /&gt;
| 0xFE&lt;br /&gt;
|&lt;br /&gt;
0x## Extended Command Number&lt;br /&gt;
&lt;br /&gt;
(0x00) Set palette Entry&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## Palette Index(across all 4 palettes)&amp;lt;br&amp;gt;&lt;br /&gt;
0xXY Set first color to X and second to Y&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x01) Set Entire Palette&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## Palette Number&amp;lt;br&amp;gt;&lt;br /&gt;
0xXY Set first color to X and second to Y (for 40 iterations)&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x02) Set Mono0 Set Monochrome Palette&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## Palette Number&amp;lt;br&amp;gt;&lt;br /&gt;
0xXY Set first color to X and second to Y (for 40 iterations)&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x03) Set Mono1 Set Visual (using monochrome palette)&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## Color&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x04) Set Mono2 Disable Visual&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
(0x05) Set Mono3 Set direct Visual (without going through the mono palette) &lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## Color&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x06) Set Mono4 Disable direct Visual&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
(0x07) Embed Cel (bitmap) (SCI01 Onwards Only)&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0xXY Upper 4-bits for X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0x## 0x## Size of the data to follow in bytes (little endian)&amp;lt;br&amp;gt;&lt;br /&gt;
0x## (for size amount of bytes) Refer to [[SCI_Specifications:_Chapter_3_-_The_Graphics_subsystem#Image_Cell|View documentation]] for Cel format&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x08) Set Priority Bands (SCI01 Onwards Only)&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## Y locations for priority bands (14 num)??&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Command extensions &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Execute the extended command specified. Note these differ for SCI1.1 (VGA).&lt;br /&gt;
| &amp;lt;code&amp;gt;FE 00 10 22&amp;lt;/code&amp;gt;Set palette entry 16 in palette 1 to 0x22 (2,2)&lt;br /&gt;
|-&lt;br /&gt;
| 15&lt;br /&gt;
| 0xFF&lt;br /&gt;
| &lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Picture End &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Signals the end of the picture commands.&lt;br /&gt;
| &amp;lt;code&amp;gt;FF&amp;lt;/code&amp;gt; End of Drawing Commands.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Short, Medium, Long? === &lt;br /&gt;
&lt;br /&gt;
The different types is likely to help in reducing file size for the pictures. You can see that a &amp;quot;Long&amp;quot; line uses 6 bytes, however a Medium uses 5 bytes, and a short 4 bytes. There is a trade-off on line length - for example a &amp;quot;Short&amp;quot; line can only be up to 7 pixels long. This could be automatically determined by the picture editor software. &lt;br /&gt;
An image with 100 short lines would only be 400 bytes on disk, whereas using long lines is 50% larger at 600 bytes. When you&amp;#039;re designing a game to be shipped on 720k disks, every byte counts.&lt;br /&gt;
&lt;br /&gt;
=== Palette ===&lt;br /&gt;
&lt;br /&gt;
Each drawing can contain up to 4 palettes of 40 colors. Each entry in the palette consists of a first and second color. Where both are the same value the color appears solid. When the values are different then the color is &amp;quot;dithered&amp;quot; between those two colors.&lt;br /&gt;
&lt;br /&gt;
The default palette (ie palette 1) is set as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;INSERT IMAGE HERE &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
In hexadecimal format:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;Code:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;&lt;br /&gt;
std::array&amp;lt;std::pair&amp;lt;uint8_t,uint8_t&amp;gt;, 40&amp;gt; default_palette =&lt;br /&gt;
{{&lt;br /&gt;
     {0x0,0x0}, {0x1,0x1}, {0x2,0x2}, {0x3,0x3}, {0x4,0x4}, {0x5,0x5}, {0x6,0x6}, {0x7,0x7},&lt;br /&gt;
     {0x8,0x8}, {0x9,0x9}, {0xa,0xa}, {0xb,0xb}, {0xc,0xc}, {0xd,0xd}, {0xe,0xe}, {0x8,0x8},&lt;br /&gt;
     {0x8,0x8}, {0x0,0x1}, {0x0,0x2}, {0x0,0x3}, {0x0,0x4}, {0x0,0x5}, {0x0,0x6}, {0x8,0x8},&lt;br /&gt;
     {0x8,0x8}, {0xf,0x9}, {0xf,0xa}, {0xf,0xb}, {0xf,0xc}, {0xf,0xd}, {0xf,0xe}, {0xf,0xf},&lt;br /&gt;
     {0x0,0x8}, {0x9,0x1}, {0x2,0xa}, {0x3,0xb}, {0x4,0xc}, {0x5,0xd}, {0x6,0xe}, {0x8,0x8}&lt;br /&gt;
}};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The default palette is duplicated across all 4 palettes at the start of a picture.&lt;br /&gt;
&lt;br /&gt;
=== Line and Flood-fill algorithms ===&lt;br /&gt;
&lt;br /&gt;
Typically, the [[wikipedia:Bresenham&amp;#039;s line algorithm|Bresenham line-algorithm]] is used for line drawing. &lt;br /&gt;
&lt;br /&gt;
Below is an example of what the routine might look like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;Code:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;&lt;br /&gt;
void dither_line(int x0, int y0, int x1, int y1, std::pair&amp;lt;uint8_t, uint8_t&amp;gt; col, uint8_t priority, uint8_t control, uint8_t draw_enable)&lt;br /&gt;
{&lt;br /&gt;
    int dx =  std::abs(x1-x0);&lt;br /&gt;
    int sx = x0&amp;lt;x1 ? 1 : -1;&lt;br /&gt;
    int dy = -std::abs(y1-y0);&lt;br /&gt;
    int sy = y0&amp;lt;y1 ? 1 : -1;&lt;br /&gt;
    int err = dx+dy;  &lt;br /&gt;
    while(true)&lt;br /&gt;
    {&lt;br /&gt;
        uint8_t line_col = ((x0 + y0) % 2) ? col.first : col.second;&lt;br /&gt;
        if (draw_enable &amp;amp; DRAW_ENABLE_VISUAL) plot_pixel(x0, y0, visual_pixels, line_col);&lt;br /&gt;
        if (draw_enable &amp;amp; DRAW_ENABLE_PRIORITY) plot_pixel(x0, y0, priority_pixels, priority);&lt;br /&gt;
        if (draw_enable &amp;amp; DRAW_ENABLE_CONTROL) plot_pixel(x0, y0, control_pixels, control);&lt;br /&gt;
        if (x0==x1 &amp;amp;&amp;amp; y0==y1) break;&lt;br /&gt;
        int e2 = 2*err;&lt;br /&gt;
        if (e2 &amp;gt;= dy) &lt;br /&gt;
        {&lt;br /&gt;
            err += dy;&lt;br /&gt;
            x0 += sx;&lt;br /&gt;
        }&lt;br /&gt;
        if (e2 &amp;lt;= dx) &lt;br /&gt;
        {&lt;br /&gt;
            err += dx;&lt;br /&gt;
            y0 += sy;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similarly, a basic 4-way recursive [[wikipedia:Flood fill|flood fill]] algorithm is used for the fill function.&lt;br /&gt;
&lt;br /&gt;
An example of how the flood fill procedure may work:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;Code:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;&lt;br /&gt;
void dither_fill(int x, int y, std::pair&amp;lt;uint8_t, uint8_t&amp;gt; col, uint8_t priority, uint8_t control, uint8_t draw_enable)&lt;br /&gt;
{&lt;br /&gt;
    int legal_color = 0xf;&lt;br /&gt;
    static std::array&amp;lt;uint8_t, 320*200&amp;gt; bound_pixels; // a temporary working area&lt;br /&gt;
    if (draw_enable &amp;amp; DRAW_ENABLE_VISUAL) { bound_pixels = visual_pixels; legal_color = 0xf;}&lt;br /&gt;
    else if (draw_enable &amp;amp; DRAW_ENABLE_PRIORITY) { bound_pixels = priority_pixels; legal_color = 0;}&lt;br /&gt;
    else if (draw_enable &amp;amp; DRAW_ENABLE_CONTROL) { bound_pixels = control_pixels; legal_color = 0;}&lt;br /&gt;
    else return; // no draw flags set&lt;br /&gt;
&lt;br /&gt;
    if (x&amp;lt;0 || x&amp;gt;319 || y&amp;lt;0 || y&amp;gt;189) return; // don&amp;#039;t fill outside canvas&lt;br /&gt;
&lt;br /&gt;
    if (bound_pixels[x + (y * 320)] != legal_color) return; // don&amp;#039;t fill non-white/black areas&lt;br /&gt;
    &lt;br /&gt;
    // plot the pixel&lt;br /&gt;
    if (draw_enable &amp;amp; DRAW_ENABLE_VISUAL)   plot_pixel(x, y, visual_pixels, ((x + y) % 2) ? col.first : col.second);&lt;br /&gt;
    if (draw_enable &amp;amp; DRAW_ENABLE_PRIORITY) plot_pixel(x, y, priority_pixels, priority);&lt;br /&gt;
    if (draw_enable &amp;amp; DRAW_ENABLE_CONTROL)  plot_pixel(x, y, control_pixels, control);&lt;br /&gt;
    &lt;br /&gt;
    // recursively call for neighbours&lt;br /&gt;
    dither_fill(x, y+1, col, priority, control, draw_enable);&lt;br /&gt;
    dither_fill(x, y-1, col, priority, control, draw_enable);&lt;br /&gt;
    dither_fill(x-1, y, col, priority, control, draw_enable);&lt;br /&gt;
    dither_fill(x+1, y, col, priority, control, draw_enable);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{note|The recursive fill above may not work on larger fill areas and cause a stack overflow. A better way to to keep an organised list (ie a queue) of points to fill, popping them off the list as each is filled.}}&lt;br /&gt;
&lt;br /&gt;
=== Dithering ===&lt;br /&gt;
One of the identifying qualities of an SCI EGA Picture is it&amp;#039;s dithering. This is done by alternating between color 1 and color 2 from the palette.&lt;br /&gt;
&lt;br /&gt;
A practical way (easy to understand) to do this is using the following formula:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
if ((x + y) % 2) color = col.first&lt;br /&gt;
else color = col.second&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
or (for older computers)&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
if ((x + y) &amp;amp; 1) color = col.first &lt;br /&gt;
else color = col.second&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
Pictures keep two flags for whether to draw a circle or square, and solid or random pattern (spray-paint style).&lt;br /&gt;
&lt;br /&gt;
;USE_RECTANGLE_FLAG : 0x10 (bit 4)&lt;br /&gt;
;USE_PATTERN_FLAG : 0x20 (bit 5)&lt;br /&gt;
&lt;br /&gt;
At the start of a picture these flags are both set to zero (ie use circles, and use solids).&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; INSERT PATTERN TYPES IMAGE HERE &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
There are 120 different styles of &amp;quot;random&amp;quot; pattern available. &lt;br /&gt;
&lt;br /&gt;
A texture bitmap is sampled from different offsets to generate each style.&lt;br /&gt;
The texture is defined as a 256-bit array:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
0x20, 0x94, 0x02, 0x24, 0x90, 0x82, 0xa4, 0xa2,&lt;br /&gt;
0x82, 0x09, 0x0a, 0x22, 0x12, 0x10, 0x42, 0x14,&lt;br /&gt;
0x91, 0x4a, 0x91, 0x11, 0x08, 0x12, 0x25, 0x10,&lt;br /&gt;
0x22, 0xa8, 0x14, 0x24, 0x00, 0x50, 0x24, 0x04&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Pattern number is an index to the following table, which in turn is an offset into the texture defined above.&lt;br /&gt;
&amp;lt;pre&amp;gt;    &lt;br /&gt;
0x00, 0x18, 0x30, 0xc4, 0xdc, 0x65, 0xeb, 0x48,&lt;br /&gt;
0x60, 0xbd, 0x89, 0x04, 0x0a, 0xf4, 0x7d, 0x6d,&lt;br /&gt;
0x85, 0xb0, 0x8e, 0x95, 0x1f, 0x22, 0x0d, 0xdf,&lt;br /&gt;
0x2a, 0x78, 0xd5, 0x73, 0x1c, 0xb4, 0x40, 0xa1,&lt;br /&gt;
0xb9, 0x3c, 0xca, 0x58, 0x92, 0x34, 0xcc, 0xce,&lt;br /&gt;
0xd7, 0x42, 0x90, 0x0f, 0x8b, 0x7f, 0x32, 0xed,&lt;br /&gt;
0x5c, 0x9d, 0xc8, 0x99, 0xad, 0x4e, 0x56, 0xa6,&lt;br /&gt;
0xf7, 0x68, 0xb7, 0x25, 0x82, 0x37, 0x3a, 0x51,&lt;br /&gt;
0x69, 0x26, 0x38, 0x52, 0x9e, 0x9a, 0x4f, 0xa7,&lt;br /&gt;
0x43, 0x10, 0x80, 0xee, 0x3d, 0x59, 0x35, 0xcf,&lt;br /&gt;
0x79, 0x74, 0xb5, 0xa2, 0xb1, 0x96, 0x23, 0xe0,&lt;br /&gt;
0xbe, 0x05, 0xf5, 0x6e, 0x19, 0xc5, 0x66, 0x49,&lt;br /&gt;
0xf0, 0xd1, 0x54, 0xa9, 0x70, 0x4b, 0xa4, 0xe2,&lt;br /&gt;
0xe6, 0xe5, 0xab, 0xe4, 0xd2, 0xaa, 0x4c, 0xe3,&lt;br /&gt;
0x06, 0x6f, 0xc6, 0x4a, 0x75, 0xa3, 0x97, 0xe1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the pattern size forces the sample point past the length of the texture, then it wraps back around to zero. With modern computers the texture could be repeated twice to avoid having to write code to wrap around (SCUMMVM does this).&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;br /&amp;gt; Versions ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
===&amp;lt;br /&amp;gt; PIC ===&lt;br /&gt;
&lt;br /&gt;
* Used with [[SCI0]] games [[#note|*]]&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;br /&amp;gt; P16 ===&lt;br /&gt;
&lt;br /&gt;
* &lt;br /&gt;
&lt;br /&gt;
===&amp;lt;br /&amp;gt; P56 ===&lt;br /&gt;
&lt;br /&gt;
* &lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;br /&amp;gt; References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Also See ==&lt;br /&gt;
&lt;br /&gt;
* [[SCI Specifications: Chapter 1 - Introduction#PIC]]&lt;br /&gt;
* [[SCI Specifications: Chapter 1 - Introduction#P16]]&lt;br /&gt;
* [[SCI Specifications: Chapter 1 - Introduction#P56]]&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
[[Category:SCI Resources]]&lt;/div&gt;</summary>
		<author><name>Rainer De Temple</name></author>
	</entry>
	<entry>
		<id>http://sciwiki.sierrahelp.com/index.php?title=Picture_Resource&amp;diff=15212</id>
		<title>Picture Resource</title>
		<link rel="alternate" type="text/html" href="http://sciwiki.sierrahelp.com/index.php?title=Picture_Resource&amp;diff=15212"/>
		<updated>2020-09-21T22:57:06Z</updated>

		<summary type="html">&lt;p&gt;Rainer De Temple: updated monochrome commands&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div align=&amp;quot;center&amp;quot; style=&amp;quot;font-size: 22pt&amp;quot;&amp;gt;&amp;#039;&amp;#039;&amp;#039;The SCI Picture Resource&amp;#039;&amp;#039;&amp;#039;&amp;lt;/div&amp;gt;&amp;amp;nbsp;&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;amp;nbsp;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;br /&amp;gt; Description ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Place holder for the SCI Picture Resource&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Format/Specifications ==&lt;br /&gt;
&lt;br /&gt;
The picture resource is a vector image format defined by unsigned bytes in the file.&lt;br /&gt;
&lt;br /&gt;
A Picture Resource File always begins with a two-byte header identifier of 0x8100, followed by the first drawing instruction.&lt;br /&gt;
&lt;br /&gt;
Below is a summary of each drawing instruction:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
! Number &lt;br /&gt;
! Hex&lt;br /&gt;
! Parameters&lt;br /&gt;
! Description&lt;br /&gt;
! Example&lt;br /&gt;
|- &lt;br /&gt;
| 0&lt;br /&gt;
| 0xF0&lt;br /&gt;
| 0x## (1 byte)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Set Visual Color &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Sets the visual color index to the value specified&lt;br /&gt;
| &amp;lt;code&amp;gt;F0 0C&amp;lt;/code&amp;gt;  Sets the visual palette index to 0x0C (color 12, bright red)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 0xF1&lt;br /&gt;
| &lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Disable Visual &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Disables drawing on visual canvas&lt;br /&gt;
| &amp;lt;code&amp;gt;F1&amp;lt;/code&amp;gt; Disable visual drawing&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 0xF2&lt;br /&gt;
| 0x## (lower 4-bits only)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Set Priority Color &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Sets the priority color index to the value specified&lt;br /&gt;
| &amp;lt;code&amp;gt;F0 05&amp;lt;/code&amp;gt;  Sets the priority color to 0x05 (color 5, Magenta)&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| 0xF3&lt;br /&gt;
| &lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Disable Priority &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Disables drawing on priority canvas&lt;br /&gt;
| &amp;lt;code&amp;gt;F3&amp;lt;/code&amp;gt; Disable priority drawing&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| 0xF4&lt;br /&gt;
|&lt;br /&gt;
(0x##) Pattern number if flag set&lt;br /&gt;
&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
(0x##) Pattern number if flag set&amp;lt;br&amp;gt;&lt;br /&gt;
0xXY offset ([[wikipedia:Signed number representations#Signed magnitude representation|signed]] 4 bit words)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Short Relative Patterns &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots patterns from the coordinates specified to the offset coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F4 10 22 AC D9&amp;lt;/code&amp;gt; Plot current pattern type at coordinates 0x122,0x0AC(290,172) and then (-5,-1) at (285,171)&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| 0xF5&lt;br /&gt;
|&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
0xYY Offset for Y using [[wikipedia:Signed number representations#Signed magnitude representation|sign-magnitude]]&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX Offset for X using [[wikipedia:Signed number representations#Two&amp;#039;s complement|2&amp;#039;s Compliment]]&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Medium Relative Lines &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots short lines from starting coordinates, to offset coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 85 FB&amp;lt;/code&amp;gt; Draw a line starting at 0x122,0x0AC(290,172) to offset 0xFB,0x85(-5,-5) at (285,167)&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| 0xF6&lt;br /&gt;
|&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
0xXY Upper 4-bits for next X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for next X and Y coordinates&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Long Lines &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots lines from starting coordinates, to next coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 00 05 0F&amp;lt;/code&amp;gt; Draw a line starting at 0x122,0x0AC(290,172) to 0x005,0x00F(5,14)&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| 0xF7&lt;br /&gt;
|&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
0xXY offset ([[wikipedia:Signed number representations#Signed magnitude representation|signed]] 4 bit words)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Short Relative Lines &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots lines from starting coordinates, to next coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 00 5D&amp;lt;/code&amp;gt; Draw a line starting at 0x122,0x0AC(290,172) to offset 0x5,0xD(5,-5) at (295, 167)&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| 0xF8&lt;br /&gt;
|&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
0xXY offset ([[wikipedia:Signed number representations#Signed magnitude representation|signed]] 4 bit words)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Flood fill &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots lines from starting coordinates, to next coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 00 5D&amp;lt;/code&amp;gt; Draw a line starting at 0x122,0x0AC(290,172) to offset 0x5,0xD(5,-5) at (295, 167)&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| 0xF9&lt;br /&gt;
|&lt;br /&gt;
0x## &amp;lt;br&amp;gt;&lt;br /&gt;
Bit 4 - Use Solid/Pattern Flag&amp;lt;br&amp;gt;&lt;br /&gt;
Bit 5 - Use Circle/Rectangle&amp;lt;br&amp;gt;&lt;br /&gt;
Bits 0-3 - Pattern Size (0-7)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Set Pattern &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Sets Pattern style flags and Pattern size.&lt;br /&gt;
| &amp;lt;code&amp;gt;F9 23&amp;lt;/code&amp;gt; Sets pattern brush to size 3 and type to random pattern.&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| 0xFA&lt;br /&gt;
|&lt;br /&gt;
(0x##) Pattern number if use pattern flag set&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
0xXY Upper 4-bits for next X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for next X and Y coordinates&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Long Patterns &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots a pattern using the set flags, size and number to coordinates specified. Command is repeated until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;FA 10 22 AC&amp;lt;/code&amp;gt; Plot a pattern at coordinates 0x122,0x0AC(290,172)&lt;br /&gt;
|-&lt;br /&gt;
| 11&lt;br /&gt;
| 0xFB&lt;br /&gt;
| 0x## (lower 4-bits only)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Set Control Color &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Sets the control color index to the value specified&lt;br /&gt;
| &amp;lt;code&amp;gt;FB 02&amp;lt;/code&amp;gt;  Sets the control color to 0x02 (color 2, Green)&lt;br /&gt;
|-&lt;br /&gt;
| 12&lt;br /&gt;
| 0xFC&lt;br /&gt;
| &lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Disable Control &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Disables drawing on control canvas&lt;br /&gt;
| &amp;lt;code&amp;gt;FC&amp;lt;/code&amp;gt; Disable control drawing&lt;br /&gt;
|-&lt;br /&gt;
| 13&lt;br /&gt;
| 0xFD&lt;br /&gt;
|&lt;br /&gt;
(0x##) Pattern number if use pattern flag set&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
(0x##) Pattern number if flag set&amp;lt;br&amp;gt;&lt;br /&gt;
0xYY Offset for Y using [[wikipedia:Signed number representations#Signed magnitude representation|sign-magnitude]]&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX Offset for X using [[wikipedia:Signed number representations#Two&amp;#039;s complement|2&amp;#039;s Compliment]]&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Medium Relative Patterns &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots short lines from starting coordinates, to offset coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 85 FB&amp;lt;/code&amp;gt; Plot a pattern starting at 0x122,0x0AC(290,172) then to offset 0xFB,0x85(-5,-5) at (285,167)&lt;br /&gt;
|-&lt;br /&gt;
| 14&lt;br /&gt;
| 0xFE&lt;br /&gt;
|&lt;br /&gt;
0x## Extended Command Number&lt;br /&gt;
&lt;br /&gt;
(0x00) Set palette Entry&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## Palette Index(across all 4 palettes)&amp;lt;br&amp;gt;&lt;br /&gt;
0xXY Set first color to X and second to Y&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x01) Set Entire Palette&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## Palette Number&amp;lt;br&amp;gt;&lt;br /&gt;
0xXY Set first color to X and second to Y (for 40 iterations)&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x02) Set Mono0 Set Monochrome Palette&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## Palette Number&amp;lt;br&amp;gt;&lt;br /&gt;
0xXY Set first color to X and second to Y (for 40 iterations)&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x03) Set Mono1 Set Visual (using monochrome palette)&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## Color&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x04) Set Mono2 Disable Visual&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
(0x05) Set Mono3 Set direct Visual (without going through the mono palette) &lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## Color&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x06) Set Mono4 Disable direct Visual&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
(0x07) Embed Cel (bitmap) (SCI01 Onwards Only)&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0xXY Upper 4-bits for X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0x## 0x## Size of the data to follow in bytes (little endian)&amp;lt;br&amp;gt;&lt;br /&gt;
0x## (for size amount of bytes) Refer to [[SCI_Specifications:_Chapter_3_-_The_Graphics_subsystem#Image_Cell|View documentation]] for Cel format&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x08) Set Priority Bands (SCI01 Onwards Only)&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## Y locations for priority bands (14 num)??&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Command extensions &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Execute the extended command specified. Note these differ for SCI1.1 (VGA).&lt;br /&gt;
| &amp;lt;code&amp;gt;FE 00 10 22&amp;lt;/code&amp;gt;Set palette entry 16 in palette 1 to 0x22 (2,2)&lt;br /&gt;
|-&lt;br /&gt;
| 15&lt;br /&gt;
| 0xFF&lt;br /&gt;
| &lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Picture End &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Signals the end of the picture commands.&lt;br /&gt;
| &amp;lt;code&amp;gt;FF&amp;lt;/code&amp;gt; End of Drawing Commands.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Short, Medium, Long? === &lt;br /&gt;
&lt;br /&gt;
The different types is likely to help in reducing file size for the pictures. You can see that a &amp;quot;Long&amp;quot; line uses 6 bytes, however a Medium uses 5 bytes, and a short 4 bytes. There is a trade-off on line length - for example a &amp;quot;Short&amp;quot; line can only be up to 7 pixels long. This could be automatically determined by the picture editor software. &lt;br /&gt;
An image with 100 short lines would only be 400 bytes on disk, whereas using long lines is 50% larger at 600 bytes. When you&amp;#039;re designing a game to be shipped on 720k disks, every byte counts.&lt;br /&gt;
&lt;br /&gt;
=== Palette ===&lt;br /&gt;
&lt;br /&gt;
Each drawing can contain up to 4 palettes of 40 colors. Each entry in the palette consists of a first and second color. Where both are the same value the color appears solid. When the values are different then the color is &amp;quot;dithered&amp;quot; between those two colors.&lt;br /&gt;
&lt;br /&gt;
The default palette (ie palette 1) is set as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;INSERT IMAGE HERE &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
In hexadecimal format:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;Code:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;&lt;br /&gt;
std::array&amp;lt;std::pair&amp;lt;uint8_t,uint8_t&amp;gt;, 40&amp;gt; default_palette =&lt;br /&gt;
{{&lt;br /&gt;
     {0x0,0x0}, {0x1,0x1}, {0x2,0x2}, {0x3,0x3}, {0x4,0x4}, {0x5,0x5}, {0x6,0x6}, {0x7,0x7},&lt;br /&gt;
     {0x8,0x8}, {0x9,0x9}, {0xa,0xa}, {0xb,0xb}, {0xc,0xc}, {0xd,0xd}, {0xe,0xe}, {0x8,0x8},&lt;br /&gt;
     {0x8,0x8}, {0x0,0x1}, {0x0,0x2}, {0x0,0x3}, {0x0,0x4}, {0x0,0x5}, {0x0,0x6}, {0x8,0x8},&lt;br /&gt;
     {0x8,0x8}, {0xf,0x9}, {0xf,0xa}, {0xf,0xb}, {0xf,0xc}, {0xf,0xd}, {0xf,0xe}, {0xf,0xf},&lt;br /&gt;
     {0x0,0x8}, {0x9,0x1}, {0x2,0xa}, {0x3,0xb}, {0x4,0xc}, {0x5,0xd}, {0x6,0xe}, {0x8,0x8}&lt;br /&gt;
}};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The default palette is duplicated across all 4 palettes at the start of a picture.&lt;br /&gt;
&lt;br /&gt;
=== Line and Flood-fill algorithms ===&lt;br /&gt;
&lt;br /&gt;
Typically, the [[wikipedia:Bresenham&amp;#039;s line algorithm|Bresenham line-algorithm]] is used for line drawing. &lt;br /&gt;
&lt;br /&gt;
Below is an example of what the routine might look like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;Code:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;&lt;br /&gt;
void dither_line(int x0, int y0, int x1, int y1, std::pair&amp;lt;uint8_t, uint8_t&amp;gt; col, uint8_t priority, uint8_t control, uint8_t draw_enable)&lt;br /&gt;
{&lt;br /&gt;
    int dx =  std::abs(x1-x0);&lt;br /&gt;
    int sx = x0&amp;lt;x1 ? 1 : -1;&lt;br /&gt;
    int dy = -std::abs(y1-y0);&lt;br /&gt;
    int sy = y0&amp;lt;y1 ? 1 : -1;&lt;br /&gt;
    int err = dx+dy;  &lt;br /&gt;
    while(true)&lt;br /&gt;
    {&lt;br /&gt;
        uint8_t line_col = ((x0 + y0) % 2) ? col.first : col.second;&lt;br /&gt;
        if (draw_enable &amp;amp; DRAW_ENABLE_VISUAL) plot_pixel(x0, y0, visual_pixels, line_col);&lt;br /&gt;
        if (draw_enable &amp;amp; DRAW_ENABLE_PRIORITY) plot_pixel(x0, y0, priority_pixels, priority);&lt;br /&gt;
        if (draw_enable &amp;amp; DRAW_ENABLE_CONTROL) plot_pixel(x0, y0, control_pixels, control);&lt;br /&gt;
        if (x0==x1 &amp;amp;&amp;amp; y0==y1) break;&lt;br /&gt;
        int e2 = 2*err;&lt;br /&gt;
        if (e2 &amp;gt;= dy) &lt;br /&gt;
        {&lt;br /&gt;
            err += dy;&lt;br /&gt;
            x0 += sx;&lt;br /&gt;
        }&lt;br /&gt;
        if (e2 &amp;lt;= dx) &lt;br /&gt;
        {&lt;br /&gt;
            err += dx;&lt;br /&gt;
            y0 += sy;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similarly, a basic 4-way recursive [[wikipedia:Flood fill|flood fill]] algorithm is used for the fill function.&lt;br /&gt;
&lt;br /&gt;
An example of how the flood fill procedure may work:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;Code:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;&lt;br /&gt;
void dither_fill(int x, int y, std::pair&amp;lt;uint8_t, uint8_t&amp;gt; col, uint8_t priority, uint8_t control, uint8_t draw_enable)&lt;br /&gt;
{&lt;br /&gt;
    int legal_color = 0xf;&lt;br /&gt;
    static std::array&amp;lt;uint8_t, 320*200&amp;gt; bound_pixels; // a temporary working area&lt;br /&gt;
    if (draw_enable &amp;amp; DRAW_ENABLE_VISUAL) { bound_pixels = visual_pixels; legal_color = 0xf;}&lt;br /&gt;
    else if (draw_enable &amp;amp; DRAW_ENABLE_PRIORITY) { bound_pixels = priority_pixels; legal_color = 0;}&lt;br /&gt;
    else if (draw_enable &amp;amp; DRAW_ENABLE_CONTROL) { bound_pixels = control_pixels; legal_color = 0;}&lt;br /&gt;
    else return; // no draw flags set&lt;br /&gt;
&lt;br /&gt;
    if (x&amp;lt;0 || x&amp;gt;319 || y&amp;lt;0 || y&amp;gt;189) return; // don&amp;#039;t fill outside canvas&lt;br /&gt;
&lt;br /&gt;
    if (bound_pixels[x + (y * 320)] != legal_color) return; // don&amp;#039;t fill non-white/black areas&lt;br /&gt;
    &lt;br /&gt;
    // plot the pixel&lt;br /&gt;
    if (draw_enable &amp;amp; DRAW_ENABLE_VISUAL)   plot_pixel(x, y, visual_pixels, ((x + y) % 2) ? col.first : col.second);&lt;br /&gt;
    if (draw_enable &amp;amp; DRAW_ENABLE_PRIORITY) plot_pixel(x, y, priority_pixels, priority);&lt;br /&gt;
    if (draw_enable &amp;amp; DRAW_ENABLE_CONTROL)  plot_pixel(x, y, control_pixels, control);&lt;br /&gt;
    &lt;br /&gt;
    // recursively call for neighbours&lt;br /&gt;
    dither_fill(x, y+1, col, priority, control, draw_enable);&lt;br /&gt;
    dither_fill(x, y-1, col, priority, control, draw_enable);&lt;br /&gt;
    dither_fill(x-1, y, col, priority, control, draw_enable);&lt;br /&gt;
    dither_fill(x+1, y, col, priority, control, draw_enable);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Dithering ===&lt;br /&gt;
One of the identifying qualities of an SCI EGA Picture is it&amp;#039;s dithering. This is done by alternating between color 1 and color 2 from the palette.&lt;br /&gt;
&lt;br /&gt;
A practical way to do this is using the following formula:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
if ((x + y) % 2) == 1) color = col.first&lt;br /&gt;
else color = col.second&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
Pictures keep two flags for whether to draw a circle or square, and solid or random pattern (spray-paint style).&lt;br /&gt;
&lt;br /&gt;
;USE_RECTANGLE_FLAG : 0x10 (bit 4)&lt;br /&gt;
;USE_PATTERN_FLAG : 0x20 (bit 5)&lt;br /&gt;
&lt;br /&gt;
At the start of a picture these flags are both set to zero (ie use circles, and use solids).&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; INSERT PATTERN TYPES IMAGE HERE &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
There are 120 different styles of &amp;quot;random&amp;quot; pattern available. &lt;br /&gt;
&lt;br /&gt;
A texture bitmap is sampled from different offsets to generate each style.&lt;br /&gt;
The texture is defined as a 256-bit array:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
0x20, 0x94, 0x02, 0x24, 0x90, 0x82, 0xa4, 0xa2,&lt;br /&gt;
0x82, 0x09, 0x0a, 0x22, 0x12, 0x10, 0x42, 0x14,&lt;br /&gt;
0x91, 0x4a, 0x91, 0x11, 0x08, 0x12, 0x25, 0x10,&lt;br /&gt;
0x22, 0xa8, 0x14, 0x24, 0x00, 0x50, 0x24, 0x04&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Pattern number is an index to the following table, which in turn is an offset into the texture defined above.&lt;br /&gt;
&amp;lt;pre&amp;gt;    &lt;br /&gt;
0x00, 0x18, 0x30, 0xc4, 0xdc, 0x65, 0xeb, 0x48,&lt;br /&gt;
0x60, 0xbd, 0x89, 0x04, 0x0a, 0xf4, 0x7d, 0x6d,&lt;br /&gt;
0x85, 0xb0, 0x8e, 0x95, 0x1f, 0x22, 0x0d, 0xdf,&lt;br /&gt;
0x2a, 0x78, 0xd5, 0x73, 0x1c, 0xb4, 0x40, 0xa1,&lt;br /&gt;
0xb9, 0x3c, 0xca, 0x58, 0x92, 0x34, 0xcc, 0xce,&lt;br /&gt;
0xd7, 0x42, 0x90, 0x0f, 0x8b, 0x7f, 0x32, 0xed,&lt;br /&gt;
0x5c, 0x9d, 0xc8, 0x99, 0xad, 0x4e, 0x56, 0xa6,&lt;br /&gt;
0xf7, 0x68, 0xb7, 0x25, 0x82, 0x37, 0x3a, 0x51,&lt;br /&gt;
0x69, 0x26, 0x38, 0x52, 0x9e, 0x9a, 0x4f, 0xa7,&lt;br /&gt;
0x43, 0x10, 0x80, 0xee, 0x3d, 0x59, 0x35, 0xcf,&lt;br /&gt;
0x79, 0x74, 0xb5, 0xa2, 0xb1, 0x96, 0x23, 0xe0,&lt;br /&gt;
0xbe, 0x05, 0xf5, 0x6e, 0x19, 0xc5, 0x66, 0x49,&lt;br /&gt;
0xf0, 0xd1, 0x54, 0xa9, 0x70, 0x4b, 0xa4, 0xe2,&lt;br /&gt;
0xe6, 0xe5, 0xab, 0xe4, 0xd2, 0xaa, 0x4c, 0xe3,&lt;br /&gt;
0x06, 0x6f, 0xc6, 0x4a, 0x75, 0xa3, 0x97, 0xe1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the pattern size forces the sample point past the length of the texture, then it wraps back around to zero. With modern computers the texture could be repeated twice to avoid having to write code to wrap around (SCUMMVM does this).&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;br /&amp;gt; Versions ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
===&amp;lt;br /&amp;gt; PIC ===&lt;br /&gt;
&lt;br /&gt;
* Used with [[SCI0]] games [[#note|*]]&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;br /&amp;gt; P16 ===&lt;br /&gt;
&lt;br /&gt;
* &lt;br /&gt;
&lt;br /&gt;
===&amp;lt;br /&amp;gt; P56 ===&lt;br /&gt;
&lt;br /&gt;
* &lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;br /&amp;gt; References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Also See ==&lt;br /&gt;
&lt;br /&gt;
* [[SCI Specifications: Chapter 1 - Introduction#PIC]]&lt;br /&gt;
* [[SCI Specifications: Chapter 1 - Introduction#P16]]&lt;br /&gt;
* [[SCI Specifications: Chapter 1 - Introduction#P56]]&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
[[Category:SCI Resources]]&lt;/div&gt;</summary>
		<author><name>Rainer De Temple</name></author>
	</entry>
	<entry>
		<id>http://sciwiki.sierrahelp.com/index.php?title=Rainer_De_Temple&amp;diff=15211</id>
		<title>Rainer De Temple</title>
		<link rel="alternate" type="text/html" href="http://sciwiki.sierrahelp.com/index.php?title=Rainer_De_Temple&amp;diff=15211"/>
		<updated>2020-09-21T07:11:42Z</updated>

		<summary type="html">&lt;p&gt;Rainer De Temple: updated my status :)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ProfileStub}}&lt;br /&gt;
{{DesignerInfobox&lt;br /&gt;
| Portrait = [[Image:RainerdeDeTemple.png|150px]]&lt;br /&gt;
| Name = Rainer De Temple&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;br /&amp;gt; A.K.A. ==&lt;br /&gt;
&lt;br /&gt;
* cosmicr&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;br /&amp;gt; About ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
AGI Tragic and SCI collaborator. Working on a SCI Game, hopefully to be released in the next decade or so hahaha.&lt;br /&gt;
&lt;br /&gt;
I used to be a fairly active member of the AGI/SCI community back in the day (about 15 years ago). I was the original creator of the AGI Wiki back then. I was a part of the community as far back as 1997 when Peter Kelly was the main contributor to AGI and SCI wasn&amp;#039;t even on the table!&lt;br /&gt;
&lt;br /&gt;
Lately I have had a renewed interest in all things Sierra and have dusted off the code for my SCI game in development.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;br /&amp;gt; Home Page ==&lt;br /&gt;
&lt;br /&gt;
* &lt;br /&gt;
&lt;br /&gt;
==&amp;lt;br /&amp;gt; Games by Rainer De Temple ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot; &amp;lt;!-- width=&amp;quot;800&amp;quot; --&amp;gt;&lt;br /&gt;
! width=&amp;quot;350&amp;quot; | Title !! width=&amp;quot;30&amp;quot; | Year !! width=&amp;quot;450&amp;quot; | Credits&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| [[agiw:AGI Piano|AGI Piano]] || align=&amp;quot;center&amp;quot; | [[1998]] || Designer&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| [[agiw:Escape Quest Demo|Escape Quest Demo]] || align=&amp;quot;center&amp;quot; | [[1998|1998/09/21]] || Designer&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| [[agiw:Moon Patrol|Moon Patrol]] || align=&amp;quot;center&amp;quot; | &amp;lt;!-- [[]] --&amp;gt; || Designer&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| [[agiw:Pharaoh Quest Demo|Pharaoh Quest Demo]] || align=&amp;quot;center&amp;quot; | [[2007|2007/12]] || Designer&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| [[agiw:Renegade|Renegade]] || align=&amp;quot;center&amp;quot; | &amp;lt;!-- [[]] --&amp;gt; || Designer&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unfortunately, all of these games are abandoned. I was quite ambitious 20 years ago. &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Renegade&amp;#039;&amp;#039;&amp;#039; is still on the table however, but I have moved my development to SCI from AGI. I still have the original game design document and are working from that.&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;br /&amp;gt; Contributions by Rainer De Temple ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot; &amp;lt;!-- width=&amp;quot;800&amp;quot; --&amp;gt;&lt;br /&gt;
! width=&amp;quot;350&amp;quot; | Title !! width=&amp;quot;30&amp;quot; | Year !! width=&amp;quot;450&amp;quot; | Credits&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| GameNameHere || align=&amp;quot;center&amp;quot; | YearHere || CreditsHere&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;br /&amp;gt; Tools by Rainer De Temple ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot; &amp;lt;!-- width=&amp;quot;800&amp;quot; --&amp;gt;&lt;br /&gt;
! width=&amp;quot;350&amp;quot; | Title !! width=&amp;quot;30&amp;quot; | Year !! width=&amp;quot;450&amp;quot; | Credits&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| [[agiw:Logic Wizard|Logic Wizard]] || align=&amp;quot;center&amp;quot; | [[1998|1998/08/19]] || Developer&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;br /&amp;gt; References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;br /&amp;gt; See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[:Category:Releases by Rainer De Temple|Releases by Rainer De Temple]]&lt;br /&gt;
* [[:Category:Contributions by Rainer De Temple|Contributions by Rainer De Temple]]&lt;br /&gt;
* [[agiw:Category:Software Developed by Rainer De Temple|Software Developed by Rainer De Temple]]&lt;br /&gt;
* [[agiw:Fan AGI Release List|Fan AGI Release List]]&lt;br /&gt;
* [[:Category:Fan Releases|Fan Releases]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Designers]]&lt;br /&gt;
[[Category:Software Developers]]&lt;/div&gt;</summary>
		<author><name>Rainer De Temple</name></author>
	</entry>
	<entry>
		<id>http://sciwiki.sierrahelp.com/index.php?title=Picture_Resource&amp;diff=15210</id>
		<title>Picture Resource</title>
		<link rel="alternate" type="text/html" href="http://sciwiki.sierrahelp.com/index.php?title=Picture_Resource&amp;diff=15210"/>
		<updated>2020-09-21T05:35:21Z</updated>

		<summary type="html">&lt;p&gt;Rainer De Temple: more pattern info.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div align=&amp;quot;center&amp;quot; style=&amp;quot;font-size: 22pt&amp;quot;&amp;gt;&amp;#039;&amp;#039;&amp;#039;The SCI Picture Resource&amp;#039;&amp;#039;&amp;#039;&amp;lt;/div&amp;gt;&amp;amp;nbsp;&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;amp;nbsp;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;br /&amp;gt; Description ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Place holder for the SCI Picture Resource&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Format/Specifications ==&lt;br /&gt;
&lt;br /&gt;
The picture resource is a vector image format defined by unsigned bytes in the file.&lt;br /&gt;
&lt;br /&gt;
A Picture Resource File always begins with a two-byte header identifier of 0x8100, followed by the first drawing instruction.&lt;br /&gt;
&lt;br /&gt;
Below is a summary of each drawing instruction:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
! Number &lt;br /&gt;
! Hex&lt;br /&gt;
! Parameters&lt;br /&gt;
! Description&lt;br /&gt;
! Example&lt;br /&gt;
|- &lt;br /&gt;
| 0&lt;br /&gt;
| 0xF0&lt;br /&gt;
| 0x## (1 byte)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Set Visual Color &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Sets the visual color index to the value specified&lt;br /&gt;
| &amp;lt;code&amp;gt;F0 0C&amp;lt;/code&amp;gt;  Sets the visual palette index to 0x0C (color 12, bright red)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 0xF1&lt;br /&gt;
| &lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Disable Visual &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Disables drawing on visual canvas&lt;br /&gt;
| &amp;lt;code&amp;gt;F1&amp;lt;/code&amp;gt; Disable visual drawing&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 0xF2&lt;br /&gt;
| 0x## (lower 4-bits only)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Set Priority Color &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Sets the priority color index to the value specified&lt;br /&gt;
| &amp;lt;code&amp;gt;F0 05&amp;lt;/code&amp;gt;  Sets the priority color to 0x05 (color 5, Magenta)&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| 0xF3&lt;br /&gt;
| &lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Disable Priority &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Disables drawing on priority canvas&lt;br /&gt;
| &amp;lt;code&amp;gt;F3&amp;lt;/code&amp;gt; Disable priority drawing&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| 0xF4&lt;br /&gt;
|&lt;br /&gt;
(0x##) Pattern number if flag set&lt;br /&gt;
&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
(0x##) Pattern number if flag set&amp;lt;br&amp;gt;&lt;br /&gt;
0xXY offset ([[wikipedia:Signed number representations#Signed magnitude representation|signed]] 4 bit words)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Short Relative Patterns &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots patterns from the coordinates specified to the offset coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F4 10 22 AC D9&amp;lt;/code&amp;gt; Plot current pattern type at coordinates 0x122,0x0AC(290,172) and then (-5,-1) at (285,171)&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| 0xF5&lt;br /&gt;
|&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
0xYY Offset for Y using [[wikipedia:Signed number representations#Signed magnitude representation|sign-magnitude]]&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX Offset for X using [[wikipedia:Signed number representations#Two&amp;#039;s complement|2&amp;#039;s Compliment]]&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Medium Relative Lines &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots short lines from starting coordinates, to offset coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 85 FB&amp;lt;/code&amp;gt; Draw a line starting at 0x122,0x0AC(290,172) to offset 0xFB,0x85(-5,-5) at (285,167)&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| 0xF6&lt;br /&gt;
|&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
0xXY Upper 4-bits for next X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for next X and Y coordinates&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Long Lines &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots lines from starting coordinates, to next coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 00 05 0F&amp;lt;/code&amp;gt; Draw a line starting at 0x122,0x0AC(290,172) to 0x005,0x00F(5,14)&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| 0xF7&lt;br /&gt;
|&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
0xXY offset ([[wikipedia:Signed number representations#Signed magnitude representation|signed]] 4 bit words)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Short Relative Lines &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots lines from starting coordinates, to next coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 00 5D&amp;lt;/code&amp;gt; Draw a line starting at 0x122,0x0AC(290,172) to offset 0x5,0xD(5,-5) at (295, 167)&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| 0xF8&lt;br /&gt;
|&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
0xXY offset ([[wikipedia:Signed number representations#Signed magnitude representation|signed]] 4 bit words)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Flood fill &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots lines from starting coordinates, to next coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 00 5D&amp;lt;/code&amp;gt; Draw a line starting at 0x122,0x0AC(290,172) to offset 0x5,0xD(5,-5) at (295, 167)&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| 0xF9&lt;br /&gt;
|&lt;br /&gt;
0x## &amp;lt;br&amp;gt;&lt;br /&gt;
Bit 4 - Use Solid/Pattern Flag&amp;lt;br&amp;gt;&lt;br /&gt;
Bit 5 - Use Circle/Rectangle&amp;lt;br&amp;gt;&lt;br /&gt;
Bits 0-3 - Pattern Size (0-7)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Set Pattern &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Sets Pattern style flags and Pattern size.&lt;br /&gt;
| &amp;lt;code&amp;gt;F9 23&amp;lt;/code&amp;gt; Sets pattern brush to size 3 and type to random pattern.&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| 0xFA&lt;br /&gt;
|&lt;br /&gt;
(0x##) Pattern number if use pattern flag set&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
0xXY Upper 4-bits for next X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for next X and Y coordinates&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Long Patterns &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots a pattern using the set flags, size and number to coordinates specified. Command is repeated until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;FA 10 22 AC&amp;lt;/code&amp;gt; Plot a pattern at coordinates 0x122,0x0AC(290,172)&lt;br /&gt;
|-&lt;br /&gt;
| 11&lt;br /&gt;
| 0xFB&lt;br /&gt;
| 0x## (lower 4-bits only)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Set Control Color &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Sets the control color index to the value specified&lt;br /&gt;
| &amp;lt;code&amp;gt;FB 02&amp;lt;/code&amp;gt;  Sets the control color to 0x02 (color 2, Green)&lt;br /&gt;
|-&lt;br /&gt;
| 12&lt;br /&gt;
| 0xFC&lt;br /&gt;
| &lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Disable Control &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Disables drawing on control canvas&lt;br /&gt;
| &amp;lt;code&amp;gt;FC&amp;lt;/code&amp;gt; Disable control drawing&lt;br /&gt;
|-&lt;br /&gt;
| 13&lt;br /&gt;
| 0xFD&lt;br /&gt;
|&lt;br /&gt;
(0x##) Pattern number if use pattern flag set&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
(0x##) Pattern number if flag set&amp;lt;br&amp;gt;&lt;br /&gt;
0xYY Offset for Y using [[wikipedia:Signed number representations#Signed magnitude representation|sign-magnitude]]&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX Offset for X using [[wikipedia:Signed number representations#Two&amp;#039;s complement|2&amp;#039;s Compliment]]&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Medium Relative Patterns &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots short lines from starting coordinates, to offset coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 85 FB&amp;lt;/code&amp;gt; Plot a pattern starting at 0x122,0x0AC(290,172) then to offset 0xFB,0x85(-5,-5) at (285,167)&lt;br /&gt;
|-&lt;br /&gt;
| 14&lt;br /&gt;
| 0xFE&lt;br /&gt;
|&lt;br /&gt;
0x## Extended Command Number&lt;br /&gt;
&lt;br /&gt;
(0x00) Set palette Entry&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## Palette Index(across all 4 palettes)&amp;lt;br&amp;gt;&lt;br /&gt;
0xXY Set first color to X and second to Y&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x01) Set Entire Palette&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## Palette Number&amp;lt;br&amp;gt;&lt;br /&gt;
0xXY Set first color to X and second to Y (for 40 iterations)&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x02) Set Mono0?? (possible set a palette to monochrome?)&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## First parameter&amp;lt;br&amp;gt;&lt;br /&gt;
0xXY Next parameter(for 40 iterations)&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x03) Set Mono1?? &lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## First parameter&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x04) Set Mono2?? &lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;No Parameters&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x05) Set Mono3?? &lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## First parameter&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x06) Set Mono4?? &lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;No Parameters&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x07) Embed Cel (bitmap) (SCI01 Onwards Only)&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0xXY Upper 4-bits for X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0x## 0x## Size of the data to follow in bytes (little endian)&amp;lt;br&amp;gt;&lt;br /&gt;
0x## (for size amount of bytes) Refer to [[SCI_Specifications:_Chapter_3_-_The_Graphics_subsystem#Image_Cell|View documentation]] for Cel format&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x08) Set Priority Bands (SCI01 Onwards Only)&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## Y locations for priority bands (14 num)??&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Command extensions &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Execute the extended command specified. Note these differ for SCI1.1 (VGA).&lt;br /&gt;
| &amp;lt;code&amp;gt;FE 00 10 22&amp;lt;/code&amp;gt;Set palette entry 16 in palette 1 to 0x22 (2,2)&lt;br /&gt;
|-&lt;br /&gt;
| 15&lt;br /&gt;
| 0xFF&lt;br /&gt;
| &lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Picture End &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Signals the end of the picture commands.&lt;br /&gt;
| &amp;lt;code&amp;gt;FF&amp;lt;/code&amp;gt; End of Drawing Commands.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Short, Medium, Long? === &lt;br /&gt;
&lt;br /&gt;
The different types is likely to help in reducing file size for the pictures. You can see that a &amp;quot;Long&amp;quot; line uses 6 bytes, however a Medium uses 5 bytes, and a short 4 bytes. There is a trade-off on line length - for example a &amp;quot;Short&amp;quot; line can only be up to 7 pixels long. This could be automatically determined by the picture editor software. &lt;br /&gt;
An image with 100 short lines would only be 400 bytes on disk, whereas using long lines is 50% larger at 600 bytes. When you&amp;#039;re designing a game to be shipped on 720k disks, every byte counts.&lt;br /&gt;
&lt;br /&gt;
=== Palette ===&lt;br /&gt;
&lt;br /&gt;
Each drawing can contain up to 4 palettes of 40 colors. Each entry in the palette consists of a first and second color. Where both are the same value the color appears solid. When the values are different then the color is &amp;quot;dithered&amp;quot; between those two colors.&lt;br /&gt;
&lt;br /&gt;
The default palette (ie palette 1) is set as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;INSERT IMAGE HERE &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
In hexadecimal format:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;Code:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;&lt;br /&gt;
std::array&amp;lt;std::pair&amp;lt;uint8_t,uint8_t&amp;gt;, 40&amp;gt; default_palette =&lt;br /&gt;
{{&lt;br /&gt;
     {0x0,0x0}, {0x1,0x1}, {0x2,0x2}, {0x3,0x3}, {0x4,0x4}, {0x5,0x5}, {0x6,0x6}, {0x7,0x7},&lt;br /&gt;
     {0x8,0x8}, {0x9,0x9}, {0xa,0xa}, {0xb,0xb}, {0xc,0xc}, {0xd,0xd}, {0xe,0xe}, {0x8,0x8},&lt;br /&gt;
     {0x8,0x8}, {0x0,0x1}, {0x0,0x2}, {0x0,0x3}, {0x0,0x4}, {0x0,0x5}, {0x0,0x6}, {0x8,0x8},&lt;br /&gt;
     {0x8,0x8}, {0xf,0x9}, {0xf,0xa}, {0xf,0xb}, {0xf,0xc}, {0xf,0xd}, {0xf,0xe}, {0xf,0xf},&lt;br /&gt;
     {0x0,0x8}, {0x9,0x1}, {0x2,0xa}, {0x3,0xb}, {0x4,0xc}, {0x5,0xd}, {0x6,0xe}, {0x8,0x8}&lt;br /&gt;
}};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The default palette is duplicated across all 4 palettes at the start of a picture.&lt;br /&gt;
&lt;br /&gt;
=== Line and Flood-fill algorithms ===&lt;br /&gt;
&lt;br /&gt;
Typically, the [[wikipedia:Bresenham&amp;#039;s line algorithm|Bresenham line-algorithm]] is used for line drawing. &lt;br /&gt;
&lt;br /&gt;
Below is an example of what the routine might look like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;Code:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;&lt;br /&gt;
void dither_line(int x0, int y0, int x1, int y1, std::pair&amp;lt;uint8_t, uint8_t&amp;gt; col, uint8_t priority, uint8_t control, uint8_t draw_enable)&lt;br /&gt;
{&lt;br /&gt;
    int dx =  std::abs(x1-x0);&lt;br /&gt;
    int sx = x0&amp;lt;x1 ? 1 : -1;&lt;br /&gt;
    int dy = -std::abs(y1-y0);&lt;br /&gt;
    int sy = y0&amp;lt;y1 ? 1 : -1;&lt;br /&gt;
    int err = dx+dy;  &lt;br /&gt;
    while(true)&lt;br /&gt;
    {&lt;br /&gt;
        uint8_t line_col = ((x0 + y0) % 2) ? col.first : col.second;&lt;br /&gt;
        if (draw_enable &amp;amp; DRAW_ENABLE_VISUAL) plot_pixel(x0, y0, visual_pixels, line_col);&lt;br /&gt;
        if (draw_enable &amp;amp; DRAW_ENABLE_PRIORITY) plot_pixel(x0, y0, priority_pixels, priority);&lt;br /&gt;
        if (draw_enable &amp;amp; DRAW_ENABLE_CONTROL) plot_pixel(x0, y0, control_pixels, control);&lt;br /&gt;
        if (x0==x1 &amp;amp;&amp;amp; y0==y1) break;&lt;br /&gt;
        int e2 = 2*err;&lt;br /&gt;
        if (e2 &amp;gt;= dy) &lt;br /&gt;
        {&lt;br /&gt;
            err += dy;&lt;br /&gt;
            x0 += sx;&lt;br /&gt;
        }&lt;br /&gt;
        if (e2 &amp;lt;= dx) &lt;br /&gt;
        {&lt;br /&gt;
            err += dx;&lt;br /&gt;
            y0 += sy;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similarly, a basic 4-way recursive [[wikipedia:Flood fill|flood fill]] algorithm is used for the fill function.&lt;br /&gt;
&lt;br /&gt;
An example of how the flood fill procedure may work:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;Code:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;&lt;br /&gt;
void dither_fill(int x, int y, std::pair&amp;lt;uint8_t, uint8_t&amp;gt; col, uint8_t priority, uint8_t control, uint8_t draw_enable)&lt;br /&gt;
{&lt;br /&gt;
    int legal_color = 0xf;&lt;br /&gt;
    static std::array&amp;lt;uint8_t, 320*200&amp;gt; bound_pixels; // a temporary working area&lt;br /&gt;
    if (draw_enable &amp;amp; DRAW_ENABLE_VISUAL) { bound_pixels = visual_pixels; legal_color = 0xf;}&lt;br /&gt;
    else if (draw_enable &amp;amp; DRAW_ENABLE_PRIORITY) { bound_pixels = priority_pixels; legal_color = 0;}&lt;br /&gt;
    else if (draw_enable &amp;amp; DRAW_ENABLE_CONTROL) { bound_pixels = control_pixels; legal_color = 0;}&lt;br /&gt;
    else return; // no draw flags set&lt;br /&gt;
&lt;br /&gt;
    if (x&amp;lt;0 || x&amp;gt;319 || y&amp;lt;0 || y&amp;gt;189) return; // don&amp;#039;t fill outside canvas&lt;br /&gt;
&lt;br /&gt;
    if (bound_pixels[x + (y * 320)] != legal_color) return; // don&amp;#039;t fill non-white/black areas&lt;br /&gt;
    &lt;br /&gt;
    // plot the pixel&lt;br /&gt;
    if (draw_enable &amp;amp; DRAW_ENABLE_VISUAL)   plot_pixel(x, y, visual_pixels, ((x + y) % 2) ? col.first : col.second);&lt;br /&gt;
    if (draw_enable &amp;amp; DRAW_ENABLE_PRIORITY) plot_pixel(x, y, priority_pixels, priority);&lt;br /&gt;
    if (draw_enable &amp;amp; DRAW_ENABLE_CONTROL)  plot_pixel(x, y, control_pixels, control);&lt;br /&gt;
    &lt;br /&gt;
    // recursively call for neighbours&lt;br /&gt;
    dither_fill(x, y+1, col, priority, control, draw_enable);&lt;br /&gt;
    dither_fill(x, y-1, col, priority, control, draw_enable);&lt;br /&gt;
    dither_fill(x-1, y, col, priority, control, draw_enable);&lt;br /&gt;
    dither_fill(x+1, y, col, priority, control, draw_enable);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Dithering ===&lt;br /&gt;
One of the identifying qualities of an SCI EGA Picture is it&amp;#039;s dithering. This is done by alternating between color 1 and color 2 from the palette.&lt;br /&gt;
&lt;br /&gt;
A practical way to do this is using the following formula:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
if ((x + y) % 2) == 1) color = col.first&lt;br /&gt;
else color = col.second&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
Pictures keep two flags for whether to draw a circle or square, and solid or random pattern (spray-paint style).&lt;br /&gt;
&lt;br /&gt;
;USE_RECTANGLE_FLAG : 0x10 (bit 4)&lt;br /&gt;
;USE_PATTERN_FLAG : 0x20 (bit 5)&lt;br /&gt;
&lt;br /&gt;
At the start of a picture these flags are both set to zero (ie use circles, and use solids).&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; INSERT PATTERN TYPES IMAGE HERE &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
There are 120 different styles of &amp;quot;random&amp;quot; pattern available. &lt;br /&gt;
&lt;br /&gt;
A texture bitmap is sampled from different offsets to generate each style.&lt;br /&gt;
The texture is defined as a 256-bit array:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
0x20, 0x94, 0x02, 0x24, 0x90, 0x82, 0xa4, 0xa2,&lt;br /&gt;
0x82, 0x09, 0x0a, 0x22, 0x12, 0x10, 0x42, 0x14,&lt;br /&gt;
0x91, 0x4a, 0x91, 0x11, 0x08, 0x12, 0x25, 0x10,&lt;br /&gt;
0x22, 0xa8, 0x14, 0x24, 0x00, 0x50, 0x24, 0x04&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Pattern number is an index to the following table, which in turn is an offset into the texture defined above.&lt;br /&gt;
&amp;lt;pre&amp;gt;    &lt;br /&gt;
0x00, 0x18, 0x30, 0xc4, 0xdc, 0x65, 0xeb, 0x48,&lt;br /&gt;
0x60, 0xbd, 0x89, 0x04, 0x0a, 0xf4, 0x7d, 0x6d,&lt;br /&gt;
0x85, 0xb0, 0x8e, 0x95, 0x1f, 0x22, 0x0d, 0xdf,&lt;br /&gt;
0x2a, 0x78, 0xd5, 0x73, 0x1c, 0xb4, 0x40, 0xa1,&lt;br /&gt;
0xb9, 0x3c, 0xca, 0x58, 0x92, 0x34, 0xcc, 0xce,&lt;br /&gt;
0xd7, 0x42, 0x90, 0x0f, 0x8b, 0x7f, 0x32, 0xed,&lt;br /&gt;
0x5c, 0x9d, 0xc8, 0x99, 0xad, 0x4e, 0x56, 0xa6,&lt;br /&gt;
0xf7, 0x68, 0xb7, 0x25, 0x82, 0x37, 0x3a, 0x51,&lt;br /&gt;
0x69, 0x26, 0x38, 0x52, 0x9e, 0x9a, 0x4f, 0xa7,&lt;br /&gt;
0x43, 0x10, 0x80, 0xee, 0x3d, 0x59, 0x35, 0xcf,&lt;br /&gt;
0x79, 0x74, 0xb5, 0xa2, 0xb1, 0x96, 0x23, 0xe0,&lt;br /&gt;
0xbe, 0x05, 0xf5, 0x6e, 0x19, 0xc5, 0x66, 0x49,&lt;br /&gt;
0xf0, 0xd1, 0x54, 0xa9, 0x70, 0x4b, 0xa4, 0xe2,&lt;br /&gt;
0xe6, 0xe5, 0xab, 0xe4, 0xd2, 0xaa, 0x4c, 0xe3,&lt;br /&gt;
0x06, 0x6f, 0xc6, 0x4a, 0x75, 0xa3, 0x97, 0xe1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the pattern size forces the sample point past the length of the texture, then it wraps back around to zero. With modern computers the texture could be repeated twice to avoid having to write code to wrap around (SCUMMVM does this).&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;br /&amp;gt; Versions ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
===&amp;lt;br /&amp;gt; PIC ===&lt;br /&gt;
&lt;br /&gt;
* Used with [[SCI0]] games [[#note|*]]&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;br /&amp;gt; P16 ===&lt;br /&gt;
&lt;br /&gt;
* &lt;br /&gt;
&lt;br /&gt;
===&amp;lt;br /&amp;gt; P56 ===&lt;br /&gt;
&lt;br /&gt;
* &lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;br /&amp;gt; References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Also See ==&lt;br /&gt;
&lt;br /&gt;
* [[SCI Specifications: Chapter 1 - Introduction#PIC]]&lt;br /&gt;
* [[SCI Specifications: Chapter 1 - Introduction#P16]]&lt;br /&gt;
* [[SCI Specifications: Chapter 1 - Introduction#P56]]&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
[[Category:SCI Resources]]&lt;/div&gt;</summary>
		<author><name>Rainer De Temple</name></author>
	</entry>
	<entry>
		<id>http://sciwiki.sierrahelp.com/index.php?title=Picture_Resource&amp;diff=15209</id>
		<title>Picture Resource</title>
		<link rel="alternate" type="text/html" href="http://sciwiki.sierrahelp.com/index.php?title=Picture_Resource&amp;diff=15209"/>
		<updated>2020-09-21T05:19:50Z</updated>

		<summary type="html">&lt;p&gt;Rainer De Temple: Fixed a couple of errors and finished SCI0 commands.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div align=&amp;quot;center&amp;quot; style=&amp;quot;font-size: 22pt&amp;quot;&amp;gt;&amp;#039;&amp;#039;&amp;#039;The SCI Picture Resource&amp;#039;&amp;#039;&amp;#039;&amp;lt;/div&amp;gt;&amp;amp;nbsp;&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;amp;nbsp;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;br /&amp;gt; Description ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Place holder for the SCI Picture Resource&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Format/Specifications ==&lt;br /&gt;
&lt;br /&gt;
The picture resource is a vector image format defined by unsigned bytes in the file.&lt;br /&gt;
&lt;br /&gt;
A Picture Resource File always begins with a two-byte header identifier of 0x8100, followed by the first drawing instruction.&lt;br /&gt;
&lt;br /&gt;
Below is a summary of each drawing instruction:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
! Number &lt;br /&gt;
! Hex&lt;br /&gt;
! Parameters&lt;br /&gt;
! Description&lt;br /&gt;
! Example&lt;br /&gt;
|- &lt;br /&gt;
| 0&lt;br /&gt;
| 0xF0&lt;br /&gt;
| 0x## (1 byte)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Set Visual Color &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Sets the visual color index to the value specified&lt;br /&gt;
| &amp;lt;code&amp;gt;F0 0C&amp;lt;/code&amp;gt;  Sets the visual palette index to 0x0C (color 12, bright red)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 0xF1&lt;br /&gt;
| &lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Disable Visual &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Disables drawing on visual canvas&lt;br /&gt;
| &amp;lt;code&amp;gt;F1&amp;lt;/code&amp;gt; Disable visual drawing&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 0xF2&lt;br /&gt;
| 0x## (lower 4-bits only)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Set Priority Color &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Sets the priority color index to the value specified&lt;br /&gt;
| &amp;lt;code&amp;gt;F0 05&amp;lt;/code&amp;gt;  Sets the priority color to 0x05 (color 5, Magenta)&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| 0xF3&lt;br /&gt;
| &lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Disable Priority &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Disables drawing on priority canvas&lt;br /&gt;
| &amp;lt;code&amp;gt;F3&amp;lt;/code&amp;gt; Disable priority drawing&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| 0xF4&lt;br /&gt;
|&lt;br /&gt;
(0x##) Pattern number if flag set&lt;br /&gt;
&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
(0x##) Pattern number if flag set&amp;lt;br&amp;gt;&lt;br /&gt;
0xXY offset ([[wikipedia:Signed number representations#Signed magnitude representation|signed]] 4 bit words)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Short Relative Patterns &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots patterns from the coordinates specified to the offset coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F4 10 22 AC D9&amp;lt;/code&amp;gt; Plot current pattern type at coordinates 0x122,0x0AC(290,172) and then (-5,-1) at (285,171)&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| 0xF5&lt;br /&gt;
|&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
0xYY Offset for Y using [[wikipedia:Signed number representations#Signed magnitude representation|sign-magnitude]]&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX Offset for X using [[wikipedia:Signed number representations#Two&amp;#039;s complement|2&amp;#039;s Compliment]]&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Medium Relative Lines &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots short lines from starting coordinates, to offset coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 85 FB&amp;lt;/code&amp;gt; Draw a line starting at 0x122,0x0AC(290,172) to offset 0xFB,0x85(-5,-5) at (285,167)&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| 0xF6&lt;br /&gt;
|&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
0xXY Upper 4-bits for next X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for next X and Y coordinates&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Long Lines &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots lines from starting coordinates, to next coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 00 05 0F&amp;lt;/code&amp;gt; Draw a line starting at 0x122,0x0AC(290,172) to 0x005,0x00F(5,14)&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| 0xF7&lt;br /&gt;
|&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
0xXY offset ([[wikipedia:Signed number representations#Signed magnitude representation|signed]] 4 bit words)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Short Relative Lines &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots lines from starting coordinates, to next coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 00 5D&amp;lt;/code&amp;gt; Draw a line starting at 0x122,0x0AC(290,172) to offset 0x5,0xD(5,-5) at (295, 167)&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| 0xF8&lt;br /&gt;
|&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
0xXY offset ([[wikipedia:Signed number representations#Signed magnitude representation|signed]] 4 bit words)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Flood fill &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots lines from starting coordinates, to next coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 00 5D&amp;lt;/code&amp;gt; Draw a line starting at 0x122,0x0AC(290,172) to offset 0x5,0xD(5,-5) at (295, 167)&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| 0xF9&lt;br /&gt;
|&lt;br /&gt;
0x## &amp;lt;br&amp;gt;&lt;br /&gt;
Bit 4 - Use Solid/Pattern Flag&amp;lt;br&amp;gt;&lt;br /&gt;
Bit 5 - Use Circle/Rectangle&amp;lt;br&amp;gt;&lt;br /&gt;
Bits 0-3 - Pattern Size (0-7)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Set Pattern &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Sets Pattern style flags and Pattern size.&lt;br /&gt;
| &amp;lt;code&amp;gt;F9 23&amp;lt;/code&amp;gt; Sets pattern brush to size 3 and type to random pattern.&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| 0xFA&lt;br /&gt;
|&lt;br /&gt;
(0x##) Pattern number if use pattern flag set&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
0xXY Upper 4-bits for next X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for next X and Y coordinates&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Long Patterns &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots a pattern using the set flags, size and number to coordinates specified. Command is repeated until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;FA 10 22 AC&amp;lt;/code&amp;gt; Plot a pattern at coordinates 0x122,0x0AC(290,172)&lt;br /&gt;
|-&lt;br /&gt;
| 11&lt;br /&gt;
| 0xFB&lt;br /&gt;
| 0x## (lower 4-bits only)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Set Control Color &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Sets the control color index to the value specified&lt;br /&gt;
| &amp;lt;code&amp;gt;FB 02&amp;lt;/code&amp;gt;  Sets the control color to 0x02 (color 2, Green)&lt;br /&gt;
|-&lt;br /&gt;
| 12&lt;br /&gt;
| 0xFC&lt;br /&gt;
| &lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Disable Control &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Disables drawing on control canvas&lt;br /&gt;
| &amp;lt;code&amp;gt;FC&amp;lt;/code&amp;gt; Disable control drawing&lt;br /&gt;
|-&lt;br /&gt;
| 13&lt;br /&gt;
| 0xFD&lt;br /&gt;
|&lt;br /&gt;
(0x##) Pattern number if use pattern flag set&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
(0x##) Pattern number if flag set&amp;lt;br&amp;gt;&lt;br /&gt;
0xYY Offset for Y using [[wikipedia:Signed number representations#Signed magnitude representation|sign-magnitude]]&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX Offset for X using [[wikipedia:Signed number representations#Two&amp;#039;s complement|2&amp;#039;s Compliment]]&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Medium Relative Patterns &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots short lines from starting coordinates, to offset coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 85 FB&amp;lt;/code&amp;gt; Plot a pattern starting at 0x122,0x0AC(290,172) then to offset 0xFB,0x85(-5,-5) at (285,167)&lt;br /&gt;
|-&lt;br /&gt;
| 14&lt;br /&gt;
| 0xFE&lt;br /&gt;
|&lt;br /&gt;
0x## Extended Command Number&lt;br /&gt;
&lt;br /&gt;
(0x00) Set palette Entry&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## Palette Index(across all 4 palettes)&amp;lt;br&amp;gt;&lt;br /&gt;
0xXY Set first color to X and second to Y&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x01) Set Entire Palette&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## Palette Number&amp;lt;br&amp;gt;&lt;br /&gt;
0xXY Set first color to X and second to Y (for 40 iterations)&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x02) Set Mono0?? (possible set a palette to monochrome?)&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## First parameter&amp;lt;br&amp;gt;&lt;br /&gt;
0xXY Next parameter(for 40 iterations)&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x03) Set Mono1?? &lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## First parameter&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x04) Set Mono2?? &lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;No Parameters&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x05) Set Mono3?? &lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## First parameter&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x06) Set Mono4?? &lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;No Parameters&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x07) Embed Cel (bitmap) (SCI01 Onwards Only)&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0xXY Upper 4-bits for X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0x## 0x## Size of the data to follow in bytes (little endian)&amp;lt;br&amp;gt;&lt;br /&gt;
0x## (for size amount of bytes) Refer to [[SCI_Specifications:_Chapter_3_-_The_Graphics_subsystem#Image_Cell|View documentation]] for Cel format&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x08) Set Priority Bands (SCI01 Onwards Only)&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## Y locations for priority bands (14 num)??&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Command extensions &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Execute the extended command specified. Note these differ for SCI1.1 (VGA).&lt;br /&gt;
| &amp;lt;code&amp;gt;FE 00 10 22&amp;lt;/code&amp;gt;Set palette entry 16 in palette 1 to 0x22 (2,2)&lt;br /&gt;
|-&lt;br /&gt;
| 15&lt;br /&gt;
| 0xFF&lt;br /&gt;
| &lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Picture End &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Signals the end of the picture commands.&lt;br /&gt;
| &amp;lt;code&amp;gt;FF&amp;lt;/code&amp;gt; End of Drawing Commands.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Short, Medium, Long? === &lt;br /&gt;
&lt;br /&gt;
The different types is likely to help in reducing file size for the pictures. You can see that a &amp;quot;Long&amp;quot; line uses 6 bytes, however a Medium uses 5 bytes, and a short 4 bytes. There is a trade-off on line length - for example a &amp;quot;Short&amp;quot; line can only be up to 7 pixels long. This could be automatically determined by the picture editor software. &lt;br /&gt;
An image with 100 short lines would only be 400 bytes on disk, whereas using long lines is 50% larger at 600 bytes. When you&amp;#039;re designing a game to be shipped on 720k disks, every byte counts.&lt;br /&gt;
&lt;br /&gt;
=== Palette ===&lt;br /&gt;
&lt;br /&gt;
Each drawing can contain up to 4 palettes of 40 colors. Each entry in the palette consists of a first and second color. Where both are the same value the color appears solid. When the values are different then the color is &amp;quot;dithered&amp;quot; between those two colors.&lt;br /&gt;
&lt;br /&gt;
The default palette (ie palette 1) is set as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;INSERT IMAGE HERE &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
In hexadecimal format:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;Code:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;&lt;br /&gt;
std::array&amp;lt;std::pair&amp;lt;uint8_t,uint8_t&amp;gt;, 40&amp;gt; default_palette =&lt;br /&gt;
{{&lt;br /&gt;
     {0x0,0x0}, {0x1,0x1}, {0x2,0x2}, {0x3,0x3}, {0x4,0x4}, {0x5,0x5}, {0x6,0x6}, {0x7,0x7},&lt;br /&gt;
     {0x8,0x8}, {0x9,0x9}, {0xa,0xa}, {0xb,0xb}, {0xc,0xc}, {0xd,0xd}, {0xe,0xe}, {0x8,0x8},&lt;br /&gt;
     {0x8,0x8}, {0x0,0x1}, {0x0,0x2}, {0x0,0x3}, {0x0,0x4}, {0x0,0x5}, {0x0,0x6}, {0x8,0x8},&lt;br /&gt;
     {0x8,0x8}, {0xf,0x9}, {0xf,0xa}, {0xf,0xb}, {0xf,0xc}, {0xf,0xd}, {0xf,0xe}, {0xf,0xf},&lt;br /&gt;
     {0x0,0x8}, {0x9,0x1}, {0x2,0xa}, {0x3,0xb}, {0x4,0xc}, {0x5,0xd}, {0x6,0xe}, {0x8,0x8}&lt;br /&gt;
}};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The default palette is duplicated across all 4 palettes at the start of a picture.&lt;br /&gt;
&lt;br /&gt;
=== Line and Flood-fill algorithms ===&lt;br /&gt;
&lt;br /&gt;
Typically, the [[wikipedia:Bresenham&amp;#039;s line algorithm|Bresenham line-algorithm]] is used for line drawing. &lt;br /&gt;
&lt;br /&gt;
Below is an example of what the routine might look like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;Code:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;&lt;br /&gt;
void dither_line(int x0, int y0, int x1, int y1, std::pair&amp;lt;uint8_t, uint8_t&amp;gt; col, uint8_t priority, uint8_t control, uint8_t draw_enable)&lt;br /&gt;
{&lt;br /&gt;
    int dx =  std::abs(x1-x0);&lt;br /&gt;
    int sx = x0&amp;lt;x1 ? 1 : -1;&lt;br /&gt;
    int dy = -std::abs(y1-y0);&lt;br /&gt;
    int sy = y0&amp;lt;y1 ? 1 : -1;&lt;br /&gt;
    int err = dx+dy;  &lt;br /&gt;
    while(true)&lt;br /&gt;
    {&lt;br /&gt;
        uint8_t line_col = ((x0 + y0) % 2) ? col.first : col.second;&lt;br /&gt;
        if (draw_enable &amp;amp; DRAW_ENABLE_VISUAL) plot_pixel(x0, y0, visual_pixels, line_col);&lt;br /&gt;
        if (draw_enable &amp;amp; DRAW_ENABLE_PRIORITY) plot_pixel(x0, y0, priority_pixels, priority);&lt;br /&gt;
        if (draw_enable &amp;amp; DRAW_ENABLE_CONTROL) plot_pixel(x0, y0, control_pixels, control);&lt;br /&gt;
        if (x0==x1 &amp;amp;&amp;amp; y0==y1) break;&lt;br /&gt;
        int e2 = 2*err;&lt;br /&gt;
        if (e2 &amp;gt;= dy) &lt;br /&gt;
        {&lt;br /&gt;
            err += dy;&lt;br /&gt;
            x0 += sx;&lt;br /&gt;
        }&lt;br /&gt;
        if (e2 &amp;lt;= dx) &lt;br /&gt;
        {&lt;br /&gt;
            err += dx;&lt;br /&gt;
            y0 += sy;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similarly, a basic 4-way recursive [[wikipedia:Flood fill|flood fill]] algorithm is used for the fill function.&lt;br /&gt;
&lt;br /&gt;
An example of how the flood fill procedure may work:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;Code:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;&lt;br /&gt;
void dither_fill(int x, int y, std::pair&amp;lt;uint8_t, uint8_t&amp;gt; col, uint8_t priority, uint8_t control, uint8_t draw_enable)&lt;br /&gt;
{&lt;br /&gt;
    int legal_color = 0xf;&lt;br /&gt;
    static std::array&amp;lt;uint8_t, 320*200&amp;gt; bound_pixels; // a temporary working area&lt;br /&gt;
    if (draw_enable &amp;amp; DRAW_ENABLE_VISUAL) { bound_pixels = visual_pixels; legal_color = 0xf;}&lt;br /&gt;
    else if (draw_enable &amp;amp; DRAW_ENABLE_PRIORITY) { bound_pixels = priority_pixels; legal_color = 0;}&lt;br /&gt;
    else if (draw_enable &amp;amp; DRAW_ENABLE_CONTROL) { bound_pixels = control_pixels; legal_color = 0;}&lt;br /&gt;
    else return; // no draw flags set&lt;br /&gt;
&lt;br /&gt;
    if (x&amp;lt;0 || x&amp;gt;319 || y&amp;lt;0 || y&amp;gt;189) return; // don&amp;#039;t fill outside canvas&lt;br /&gt;
&lt;br /&gt;
    if (bound_pixels[x + (y * 320)] != legal_color) return; // don&amp;#039;t fill non-white/black areas&lt;br /&gt;
    &lt;br /&gt;
    // plot the pixel&lt;br /&gt;
    if (draw_enable &amp;amp; DRAW_ENABLE_VISUAL)   plot_pixel(x, y, visual_pixels, ((x + y) % 2) ? col.first : col.second);&lt;br /&gt;
    if (draw_enable &amp;amp; DRAW_ENABLE_PRIORITY) plot_pixel(x, y, priority_pixels, priority);&lt;br /&gt;
    if (draw_enable &amp;amp; DRAW_ENABLE_CONTROL)  plot_pixel(x, y, control_pixels, control);&lt;br /&gt;
    &lt;br /&gt;
    // recursively call for neighbours&lt;br /&gt;
    dither_fill(x, y+1, col, priority, control, draw_enable);&lt;br /&gt;
    dither_fill(x, y-1, col, priority, control, draw_enable);&lt;br /&gt;
    dither_fill(x-1, y, col, priority, control, draw_enable);&lt;br /&gt;
    dither_fill(x+1, y, col, priority, control, draw_enable);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Dithering ===&lt;br /&gt;
One of the identifying qualities of an SCI EGA Picture is it&amp;#039;s dithering. This is done by alternating between color 1 and color 2 from the palette.&lt;br /&gt;
&lt;br /&gt;
A practical way to do this is using the following formula:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
if ((x + y) % 2) == 1) color = col.first&lt;br /&gt;
else color = col.second&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
Pictures keep two flags for whether to draw a circle or square, and solid or random pattern (spray-paint style).&lt;br /&gt;
&lt;br /&gt;
;USE_RECTANGLE_FLAG : 0x10 (bit 4)&lt;br /&gt;
;USE_PATTERN_FLAG : 0x20 (bit 5)&lt;br /&gt;
&lt;br /&gt;
At the start of a picture these flags are both set to zero (ie use circles, and use solids).&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; INSERT PATTERN TYPES IMAGE HERE &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
There are 120 different styles of &amp;quot;random&amp;quot; pattern available. &lt;br /&gt;
&lt;br /&gt;
A texture bitmap is sampled from different offsets to generate each style.&lt;br /&gt;
The texture is defined as a 256-bit array:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
0x20, 0x94, 0x02, 0x24, 0x90, 0x82, 0xa4, 0xa2,&lt;br /&gt;
0x82, 0x09, 0x0a, 0x22, 0x12, 0x10, 0x42, 0x14,&lt;br /&gt;
0x91, 0x4a, 0x91, 0x11, 0x08, 0x12, 0x25, 0x10,&lt;br /&gt;
0x22, 0xa8, 0x14, 0x24, 0x00, 0x50, 0x24, 0x04&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Pattern number is an index to the following table, which in turn is an offset into the texture defined above.&lt;br /&gt;
&amp;lt;pre&amp;gt;    &lt;br /&gt;
0x00, 0x18, 0x30, 0xc4, 0xdc, 0x65, 0xeb, 0x48,&lt;br /&gt;
0x60, 0xbd, 0x89, 0x04, 0x0a, 0xf4, 0x7d, 0x6d,&lt;br /&gt;
0x85, 0xb0, 0x8e, 0x95, 0x1f, 0x22, 0x0d, 0xdf,&lt;br /&gt;
0x2a, 0x78, 0xd5, 0x73, 0x1c, 0xb4, 0x40, 0xa1,&lt;br /&gt;
0xb9, 0x3c, 0xca, 0x58, 0x92, 0x34, 0xcc, 0xce,&lt;br /&gt;
0xd7, 0x42, 0x90, 0x0f, 0x8b, 0x7f, 0x32, 0xed,&lt;br /&gt;
0x5c, 0x9d, 0xc8, 0x99, 0xad, 0x4e, 0x56, 0xa6,&lt;br /&gt;
0xf7, 0x68, 0xb7, 0x25, 0x82, 0x37, 0x3a, 0x51,&lt;br /&gt;
0x69, 0x26, 0x38, 0x52, 0x9e, 0x9a, 0x4f, 0xa7,&lt;br /&gt;
0x43, 0x10, 0x80, 0xee, 0x3d, 0x59, 0x35, 0xcf,&lt;br /&gt;
0x79, 0x74, 0xb5, 0xa2, 0xb1, 0x96, 0x23, 0xe0,&lt;br /&gt;
0xbe, 0x05, 0xf5, 0x6e, 0x19, 0xc5, 0x66, 0x49,&lt;br /&gt;
0xf0, 0xd1, 0x54, 0xa9, 0x70, 0x4b, 0xa4, 0xe2,&lt;br /&gt;
0xe6, 0xe5, 0xab, 0xe4, 0xd2, 0xaa, 0x4c, 0xe3,&lt;br /&gt;
0x06, 0x6f, 0xc6, 0x4a, 0x75, 0xa3, 0x97, 0xe1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the pattern size forces the sample point past the length of the texture, then it wraps back around to zero.&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;br /&amp;gt; Versions ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
===&amp;lt;br /&amp;gt; PIC ===&lt;br /&gt;
&lt;br /&gt;
* Used with [[SCI0]] games [[#note|*]]&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;br /&amp;gt; P16 ===&lt;br /&gt;
&lt;br /&gt;
* &lt;br /&gt;
&lt;br /&gt;
===&amp;lt;br /&amp;gt; P56 ===&lt;br /&gt;
&lt;br /&gt;
* &lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;br /&amp;gt; References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Also See ==&lt;br /&gt;
&lt;br /&gt;
* [[SCI Specifications: Chapter 1 - Introduction#PIC]]&lt;br /&gt;
* [[SCI Specifications: Chapter 1 - Introduction#P16]]&lt;br /&gt;
* [[SCI Specifications: Chapter 1 - Introduction#P56]]&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
[[Category:SCI Resources]]&lt;/div&gt;</summary>
		<author><name>Rainer De Temple</name></author>
	</entry>
	<entry>
		<id>http://sciwiki.sierrahelp.com/index.php?title=Picture_Resource&amp;diff=15208</id>
		<title>Picture Resource</title>
		<link rel="alternate" type="text/html" href="http://sciwiki.sierrahelp.com/index.php?title=Picture_Resource&amp;diff=15208"/>
		<updated>2020-09-18T06:39:29Z</updated>

		<summary type="html">&lt;p&gt;Rainer De Temple: Added format specification and notes for SCI0 Picture Drawing - needs a bit more work&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div align=&amp;quot;center&amp;quot; style=&amp;quot;font-size: 22pt&amp;quot;&amp;gt;&amp;#039;&amp;#039;&amp;#039;The SCI Picture Resource&amp;#039;&amp;#039;&amp;#039;&amp;lt;/div&amp;gt;&amp;amp;nbsp;&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;amp;nbsp;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;br /&amp;gt; Description ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Place holder for the SCI Picture Resource&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Format/Specifications ==&lt;br /&gt;
&lt;br /&gt;
The picture resource is a vector image format defined by unsigned bytes in the file.&lt;br /&gt;
&lt;br /&gt;
A Picture Resource File always begins with a two-byte header identifier of 0x8100, followed by the first drawing instruction.&lt;br /&gt;
&lt;br /&gt;
Below is a summary of each drawing instruction:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
! Number &lt;br /&gt;
! Hex&lt;br /&gt;
! Parameters&lt;br /&gt;
! Description&lt;br /&gt;
! Example&lt;br /&gt;
|- &lt;br /&gt;
| 0&lt;br /&gt;
| 0xF0&lt;br /&gt;
| 0x## (1 byte)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Set Visual Color &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Sets the visual color index to the value specified&lt;br /&gt;
| &amp;lt;code&amp;gt;F0 0C&amp;lt;/code&amp;gt;  Sets the visual palette index to 0x0C (color 12, bright red)&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 0xF1&lt;br /&gt;
| &lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Disable Visual &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Disables drawing on visual canvas&lt;br /&gt;
| &amp;lt;code&amp;gt;F1&amp;lt;/code&amp;gt; Disable visual drawing&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 0xF2&lt;br /&gt;
| 0x## (lower 4-bits only)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Set Priority Color &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Sets the priority color index to the value specified&lt;br /&gt;
| &amp;lt;code&amp;gt;F0 05&amp;lt;/code&amp;gt;  Sets the priority color to 0x05 (color 5, Magenta)&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| 0xF3&lt;br /&gt;
| &lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Disable Priority &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Disables drawing on priority canvas&lt;br /&gt;
| &amp;lt;code&amp;gt;F3&amp;lt;/code&amp;gt; Disable priority drawing&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| 0xF4&lt;br /&gt;
|&lt;br /&gt;
(0x##) Pattern number if flag set&lt;br /&gt;
&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
(0x##) Pattern number if flag set&amp;lt;br&amp;gt;&lt;br /&gt;
0xXY offset ([[wikipedia:Signed number representations#Signed magnitude representation|signed]] 4 bit words)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Short Relative Patterns &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots patterns from the coordinates specified to the offset coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F4 10 22 AC D9&amp;lt;/code&amp;gt; Plot current pattern type at coordinates 0x122,0x0AC(290,172) and then (-5,-1) at (285,171)&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| 0xF5&lt;br /&gt;
|&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
0xYY Offset for Y using [[wikipedia:Signed number representations#Signed magnitude representation|sign-magnitude]]&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX Offset for X using [[wikipedia:Signed number representations#Two&amp;#039;s complement|2&amp;#039;s Compliment]]&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Medium Relative Lines &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots short lines from starting coordinates, to offset coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 85 FB&amp;lt;/code&amp;gt; Draw a line starting at 0x122,0x0AC(290,172) to offset 0xFB,0x85(-5,-5) at (285,167)&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| 0xF6&lt;br /&gt;
|&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
0xXY Upper 4-bits for next X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for next X and Y coordinates&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Long Lines &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots lines from starting coordinates, to next coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 00 05 0F&amp;lt;/code&amp;gt; Draw a line starting at 0x122,0x0AC(290,172) to 0x005,0x00F(5,14)&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| 0xF7&lt;br /&gt;
|&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
0xXY offset ([[wikipedia:Signed number representations#Signed magnitude representation|signed]] 4 bit words)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Short Relative Lines &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots lines from starting coordinates, to next coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 00 5D&amp;lt;/code&amp;gt; Draw a line starting at 0x122,0x0AC(290,172) to offset 0x5,0xD(5,-5) at (295, 167)&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| 0xF8&lt;br /&gt;
|&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
0xXY offset ([[wikipedia:Signed number representations#Signed magnitude representation|signed]] 4 bit words)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Flood fill &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots lines from starting coordinates, to next coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 00 5D&amp;lt;/code&amp;gt; Draw a line starting at 0x122,0x0AC(290,172) to offset 0x5,0xD(5,-5) at (295, 167)&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| 0xF9&lt;br /&gt;
|&lt;br /&gt;
0x## &amp;lt;br&amp;gt;&lt;br /&gt;
Bit 4 - Use Solid/Pattern Flag&amp;lt;br&amp;gt;&lt;br /&gt;
Bit 5 - Use Circle/Rectangle&amp;lt;br&amp;gt;&lt;br /&gt;
Bits 0-3 - Pattern Size (0-7)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Set Pattern &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Sets Pattern style flags and Pattern size.&lt;br /&gt;
| &amp;lt;code&amp;gt;F9 23&amp;lt;/code&amp;gt; Sets pattern brush to size 3 and type to random pattern.&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| 0xFA&lt;br /&gt;
|&lt;br /&gt;
(0x##) Pattern number if use pattern flag set&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
0xXY Upper 4-bits for next X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for next X and Y coordinates&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Long Patterns &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots a pattern using the set flags, size and number to coordinates specified. Command is repeated until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;FA 10 22 AC&amp;lt;/code&amp;gt; Plot a pattern at coordinates 0x122,0x0AC(290,172)&lt;br /&gt;
|-&lt;br /&gt;
| 11&lt;br /&gt;
| 0xFB&lt;br /&gt;
| 0x## (lower 4-bits only)&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Set Control Color &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Sets the control color index to the value specified&lt;br /&gt;
| &amp;lt;code&amp;gt;FB 02&amp;lt;/code&amp;gt;  Sets the control color to 0x02 (color 2, Green)&lt;br /&gt;
|-&lt;br /&gt;
| 12&lt;br /&gt;
| 0xFC&lt;br /&gt;
| &lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Disable Control &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Disables drawing on control canvas&lt;br /&gt;
| &amp;lt;code&amp;gt;FC&amp;lt;/code&amp;gt; Disable control drawing&lt;br /&gt;
|-&lt;br /&gt;
| 13&lt;br /&gt;
| 0xFD&lt;br /&gt;
|&lt;br /&gt;
(0x##) Pattern number if use pattern flag set&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
0xXY Upper 4-bits for starting X and Y coordinates&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX 0xYY Lower 8 bits for starting X and Y coordinates&lt;br /&gt;
&lt;br /&gt;
(0x##) Pattern number if flag set&amp;lt;br&amp;gt;&lt;br /&gt;
0xYY Offset for Y using [[wikipedia:Signed number representations#Signed magnitude representation|sign-magnitude]]&amp;lt;br&amp;gt;&lt;br /&gt;
0xXX Offset for X using [[wikipedia:Signed number representations#Two&amp;#039;s complement|2&amp;#039;s Compliment]]&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Medium Relative Patterns &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Plots short lines from starting coordinates, to offset coordinates until next command.&lt;br /&gt;
| &amp;lt;code&amp;gt;F5 10 22 AC 85 FB&amp;lt;/code&amp;gt; Plot a pattern starting at 0x122,0x0AC(290,172) then to offset 0xFB,0x85(-5,-5) at (285,167)&lt;br /&gt;
|-&lt;br /&gt;
| 14&lt;br /&gt;
| 0xFE&lt;br /&gt;
|&lt;br /&gt;
0x## Palette Command Number&lt;br /&gt;
&lt;br /&gt;
(0x00) Set palette Entry&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## Palette Index(across all 4 palettes)&amp;lt;br&amp;gt;&lt;br /&gt;
0xXY Set first color to X and second to Y&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
(0x01) Set Entire Palette&lt;br /&gt;
&amp;lt;blockquote class=&amp;quot;offset&amp;quot;&amp;gt;0x## Palette Number&amp;lt;br&amp;gt;&lt;br /&gt;
0xXY Set first color to X and second to Y (for 40 iterations)&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
TODO: SCI1 commands differ&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039; Palette Command &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
Execute the palette command specified. Note: for SCI1 pictures, this command extends the number of commands to include drawing a bitmap.&lt;br /&gt;
| &amp;lt;code&amp;gt;FE 00 10 22&amp;lt;/code&amp;gt;Set palette entry 16 in palette 1 to 0x22 (2,2)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Short, Medium, Long? === &lt;br /&gt;
&lt;br /&gt;
The different types is likely to help in reducing file size for the pictures. You can see that a &amp;quot;Long&amp;quot; line uses 6 bytes, however a Medium uses 5 bytes, and a short 4 bytes. There is a trade-off on line length - for example a &amp;quot;Short&amp;quot; line can only be up to 7 pixels long. This could be automatically determined by the picture editor software. &lt;br /&gt;
An image with 100 short lines would only be 400 bytes on disk, whereas using long lines is 50% larger at 600 bytes. When you&amp;#039;re designing a game to be shipped on 720k disks, every byte counts.&lt;br /&gt;
&lt;br /&gt;
=== Palette ===&lt;br /&gt;
&lt;br /&gt;
Each drawing can contain up to 4 palettes of 40 colors. Each entry in the palette consists of a first and second color. Where both are the same value the color appears solid. When the values are different then the color is &amp;quot;dithered&amp;quot; between those two colors.&lt;br /&gt;
&lt;br /&gt;
The default palette (ie palette 1) is set as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;INSERT IMAGE HERE &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
In hexadecimal format:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;Code:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;&lt;br /&gt;
std::array&amp;lt;std::pair&amp;lt;uint8_t,uint8_t&amp;gt;, 40&amp;gt; default_palette =&lt;br /&gt;
{{&lt;br /&gt;
     {0x0,0x0}, {0x1,0x1}, {0x2,0x2}, {0x3,0x3}, {0x4,0x4}, {0x5,0x5}, {0x6,0x6}, {0x7,0x7},&lt;br /&gt;
     {0x8,0x8}, {0x9,0x9}, {0xa,0xa}, {0xb,0xb}, {0xc,0xc}, {0xd,0xd}, {0xe,0xe}, {0x8,0x8},&lt;br /&gt;
     {0x8,0x8}, {0x0,0x1}, {0x0,0x2}, {0x0,0x3}, {0x0,0x4}, {0x0,0x5}, {0x0,0x6}, {0x8,0x8},&lt;br /&gt;
     {0x8,0x8}, {0xf,0x9}, {0xf,0xa}, {0xf,0xb}, {0xf,0xc}, {0xf,0xd}, {0xf,0xe}, {0xf,0xf},&lt;br /&gt;
     {0x0,0x8}, {0x9,0x1}, {0x2,0xa}, {0x3,0xb}, {0x4,0xc}, {0x5,0xd}, {0x6,0xe}, {0x8,0x8}&lt;br /&gt;
}};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The default palette is duplicated across all 4 palettes at the start of a picture.&lt;br /&gt;
&lt;br /&gt;
=== Line and Flood-fill algorithms ===&lt;br /&gt;
&lt;br /&gt;
Typically, the [[wikipedia:Bresenham&amp;#039;s line algorithm|Bresenham line-algorithm]] is used for line drawing. &lt;br /&gt;
&lt;br /&gt;
Below is an example of what the routine might look like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;Code:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;&lt;br /&gt;
void dither_line(int x0, int y0, int x1, int y1, std::pair&amp;lt;uint8_t, uint8_t&amp;gt; col, uint8_t priority, uint8_t control, uint8_t draw_enable)&lt;br /&gt;
{&lt;br /&gt;
    int dx =  std::abs(x1-x0);&lt;br /&gt;
    int sx = x0&amp;lt;x1 ? 1 : -1;&lt;br /&gt;
    int dy = -std::abs(y1-y0);&lt;br /&gt;
    int sy = y0&amp;lt;y1 ? 1 : -1;&lt;br /&gt;
    int err = dx+dy;  &lt;br /&gt;
    while(true)&lt;br /&gt;
    {&lt;br /&gt;
        uint8_t line_col = ((x0 + y0) % 2) ? col.first : col.second;&lt;br /&gt;
        if (draw_enable &amp;amp; DRAW_ENABLE_VISUAL) plot_pixel(x0, y0, visual_pixels, line_col);&lt;br /&gt;
        if (draw_enable &amp;amp; DRAW_ENABLE_PRIORITY) plot_pixel(x0, y0, priority_pixels, priority);&lt;br /&gt;
        if (draw_enable &amp;amp; DRAW_ENABLE_CONTROL) plot_pixel(x0, y0, control_pixels, control);&lt;br /&gt;
        if (x0==x1 &amp;amp;&amp;amp; y0==y1) break;&lt;br /&gt;
        int e2 = 2*err;&lt;br /&gt;
        if (e2 &amp;gt;= dy) &lt;br /&gt;
        {&lt;br /&gt;
            err += dy;&lt;br /&gt;
            x0 += sx;&lt;br /&gt;
        }&lt;br /&gt;
        if (e2 &amp;lt;= dx) &lt;br /&gt;
        {&lt;br /&gt;
            err += dx;&lt;br /&gt;
            y0 += sy;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similarly, a basic 4-way recursive [[wikipedia:Flood fill|flood fill]] algorithm is used for the fill function.&lt;br /&gt;
&lt;br /&gt;
An example of how the flood fill procedure may work:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;CodeBlockHeader&amp;quot;&amp;gt;Code:&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; class=&amp;quot;cs&amp;quot;&amp;gt;&lt;br /&gt;
void dither_fill(int x, int y, std::pair&amp;lt;uint8_t, uint8_t&amp;gt; col, uint8_t priority, uint8_t control, uint8_t draw_enable)&lt;br /&gt;
{&lt;br /&gt;
    int legal_color = 0xf;&lt;br /&gt;
    static std::array&amp;lt;uint8_t, 320*200&amp;gt; bound_pixels; // a temporary working area&lt;br /&gt;
    if (draw_enable &amp;amp; DRAW_ENABLE_VISUAL) { bound_pixels = visual_pixels; legal_color = 0xf;}&lt;br /&gt;
    else if (draw_enable &amp;amp; DRAW_ENABLE_PRIORITY) { bound_pixels = priority_pixels; legal_color = 0;}&lt;br /&gt;
    else if (draw_enable &amp;amp; DRAW_ENABLE_CONTROL) { bound_pixels = control_pixels; legal_color = 0;}&lt;br /&gt;
    else return; // no draw flags set&lt;br /&gt;
&lt;br /&gt;
    if (x&amp;lt;0 || x&amp;gt;319 || y&amp;lt;0 || y&amp;gt;189) return; // don&amp;#039;t fill outside canvas&lt;br /&gt;
&lt;br /&gt;
    if (bound_pixels[x + (y * 320)] != legal_color) return; // don&amp;#039;t fill non-white/black areas&lt;br /&gt;
    &lt;br /&gt;
    // plot the pixel&lt;br /&gt;
    if (draw_enable &amp;amp; DRAW_ENABLE_VISUAL)   plot_pixel(x, y, visual_pixels, ((x + y) % 2) ? col.first : col.second);&lt;br /&gt;
    if (draw_enable &amp;amp; DRAW_ENABLE_PRIORITY) plot_pixel(x, y, priority_pixels, priority);&lt;br /&gt;
    if (draw_enable &amp;amp; DRAW_ENABLE_CONTROL)  plot_pixel(x, y, control_pixels, control);&lt;br /&gt;
    &lt;br /&gt;
    // recursively call for neighbours&lt;br /&gt;
    dither_fill(x, y+1, col, priority, control, draw_enable);&lt;br /&gt;
    dither_fill(x, y-1, col, priority, control, draw_enable);&lt;br /&gt;
    dither_fill(x-1, y, col, priority, control, draw_enable);&lt;br /&gt;
    dither_fill(x+1, y, col, priority, control, draw_enable);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Dithering ===&lt;br /&gt;
One of the identifying qualities of an SCI EGA Picture is it&amp;#039;s dithering. This is done by alternating between color 1 and color 2 from the palette.&lt;br /&gt;
&lt;br /&gt;
A practical way to do this is using the following formula:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
if ((x + y) % 2) == 1) color = col.first&lt;br /&gt;
else color = col.second&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
Pictures keep two flags for whether to draw a circle or square, and solid or random pattern (spray-paint style).&lt;br /&gt;
&lt;br /&gt;
;USE_RECTANGLE_FLAG : 0x10 (bit 4)&lt;br /&gt;
;USE_PATTERN_FLAG : 0x20 (bit 5)&lt;br /&gt;
&lt;br /&gt;
At the start of a picture these flags are both set to zero (ie use circles, and use solids).&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039; INSERT PATTERN TYPES IMAGE HERE &amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
There are 120 different styles of &amp;quot;random&amp;quot; pattern available. &lt;br /&gt;
&lt;br /&gt;
A texture bitmap is sampled from different offsets to generate each style.&lt;br /&gt;
The texture is defined as a 256-bit array:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
0x20, 0x94, 0x02, 0x24, 0x90, 0x82, 0xa4, 0xa2,&lt;br /&gt;
0x82, 0x09, 0x0a, 0x22, 0x12, 0x10, 0x42, 0x14,&lt;br /&gt;
0x91, 0x4a, 0x91, 0x11, 0x08, 0x12, 0x25, 0x10,&lt;br /&gt;
0x22, 0xa8, 0x14, 0x24, 0x00, 0x50, 0x24, 0x04&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Pattern number is an index to the following table, which in turn is an offset into the texture defined above.&lt;br /&gt;
&amp;lt;pre&amp;gt;    &lt;br /&gt;
0x00, 0x18, 0x30, 0xc4, 0xdc, 0x65, 0xeb, 0x48,&lt;br /&gt;
0x60, 0xbd, 0x89, 0x04, 0x0a, 0xf4, 0x7d, 0x6d,&lt;br /&gt;
0x85, 0xb0, 0x8e, 0x95, 0x1f, 0x22, 0x0d, 0xdf,&lt;br /&gt;
0x2a, 0x78, 0xd5, 0x73, 0x1c, 0xb4, 0x40, 0xa1,&lt;br /&gt;
0xb9, 0x3c, 0xca, 0x58, 0x92, 0x34, 0xcc, 0xce,&lt;br /&gt;
0xd7, 0x42, 0x90, 0x0f, 0x8b, 0x7f, 0x32, 0xed,&lt;br /&gt;
0x5c, 0x9d, 0xc8, 0x99, 0xad, 0x4e, 0x56, 0xa6,&lt;br /&gt;
0xf7, 0x68, 0xb7, 0x25, 0x82, 0x37, 0x3a, 0x51,&lt;br /&gt;
0x69, 0x26, 0x38, 0x52, 0x9e, 0x9a, 0x4f, 0xa7,&lt;br /&gt;
0x43, 0x10, 0x80, 0xee, 0x3d, 0x59, 0x35, 0xcf,&lt;br /&gt;
0x79, 0x74, 0xb5, 0xa2, 0xb1, 0x96, 0x23, 0xe0,&lt;br /&gt;
0xbe, 0x05, 0xf5, 0x6e, 0x19, 0xc5, 0x66, 0x49,&lt;br /&gt;
0xf0, 0xd1, 0x54, 0xa9, 0x70, 0x4b, 0xa4, 0xe2,&lt;br /&gt;
0xe6, 0xe5, 0xab, 0xe4, 0xd2, 0xaa, 0x4c, 0xe3,&lt;br /&gt;
0x06, 0x6f, 0xc6, 0x4a, 0x75, 0xa3, 0x97, 0xe1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the pattern size forces the sample point past the length of the texture, then it wraps back around to zero.&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;br /&amp;gt; Versions ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
===&amp;lt;br /&amp;gt; PIC ===&lt;br /&gt;
&lt;br /&gt;
* Used with [[SCI0]] games [[#note|*]]&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;br /&amp;gt; P16 ===&lt;br /&gt;
&lt;br /&gt;
* &lt;br /&gt;
&lt;br /&gt;
===&amp;lt;br /&amp;gt; P56 ===&lt;br /&gt;
&lt;br /&gt;
* &lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;br /&amp;gt; References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Also See ==&lt;br /&gt;
&lt;br /&gt;
* [[SCI Specifications: Chapter 1 - Introduction#PIC]]&lt;br /&gt;
* [[SCI Specifications: Chapter 1 - Introduction#P16]]&lt;br /&gt;
* [[SCI Specifications: Chapter 1 - Introduction#P56]]&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
[[Category:SCI Resources]]&lt;/div&gt;</summary>
		<author><name>Rainer De Temple</name></author>
	</entry>
	<entry>
		<id>http://sciwiki.sierrahelp.com/index.php?title=SCI_Specifications:_Chapter_3_-_The_Graphics_subsystem&amp;diff=15207</id>
		<title>SCI Specifications: Chapter 3 - The Graphics subsystem</title>
		<link rel="alternate" type="text/html" href="http://sciwiki.sierrahelp.com/index.php?title=SCI_Specifications:_Chapter_3_-_The_Graphics_subsystem&amp;diff=15207"/>
		<updated>2020-09-16T11:50:27Z</updated>

		<summary type="html">&lt;p&gt;Rainer De Temple: /* The SCI0 and SCI01 pic resource */ fixed some errors and cleaned up a little&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==General stuff==&lt;br /&gt;
The graphics in SCI are generated using four resource types:&lt;br /&gt;
&lt;br /&gt;
* Pic resources for background pictures&lt;br /&gt;
* View resources for images&lt;br /&gt;
* Font resources for drawing text&lt;br /&gt;
* Cursor resources for displaying the mouse pointer&lt;br /&gt;
&lt;br /&gt;
Those resources are drawn on three distinct maps:&lt;br /&gt;
&lt;br /&gt;
* The visual map, used for displaying the actual pictures the player sees&lt;br /&gt;
* The priority map, which keeps information about how the depth of the screen&lt;br /&gt;
* The control map, which contains special information&lt;br /&gt;
&lt;br /&gt;
==SCI Ports==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Lars Skovlund&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Version 1.0, 6. July 1999&lt;br /&gt;
&lt;br /&gt;
Note that the observations made in this document are generally based on SCI version 0.000.572 (the one that comes with LSL3), but should be valid even for SCI01 and SCI1, as well. I know already about some differences in the port system from SCI0 to SCI1, but I feel we should have an interpreter running for SCI0 before dealing with SCI1.&lt;br /&gt;
&lt;br /&gt;
This article discusses a key data structure in SCI graphics handling; this data structure is called a port, and it is involved in most graphics-related operations. The port is basically a graphics state record, storing things like pen color, current font, cursor position etc. Each port also has an origin and a size. The actual port data structure has remained absolutely unchanged from SCI0 up to the latest versions of SCI1.&lt;br /&gt;
&lt;br /&gt;
The port can be viewed as a rectangle in which things are drawn. Every drawing operation (even KDrawPic) is executed relative to the origin coordinates of the current port (depending on the kernel function, other parameters in the port structure are used as well), such that coordinate (0, 0) in the &amp;quot;picture window&amp;quot; (such a thing really exists in SCI!) is not the top of the screen, but rather the leftmost point underneath the menu bar. The coordinate set (0,0) is called the local coordinates, and its physical position on the screen, (0, 10), is called the global coordinates. Kernel calls exist to ease conversion between the two coordinate systems, but they are, it appears, meant for event handlers to use, and not generally usable (I think they take a pointer to an Event object as a parameter).&lt;br /&gt;
&lt;br /&gt;
At least three ports are created and managed automatically by the SCI interpreter. These are the &amp;quot;window manager&amp;quot; port, the menu port, and the picture port (which is actually a window, see later). The latter two should be fairly easy to understand. The menu bar is drawn in the menu port, and the current room is drawn in the picture port. What may be less obvious is that the window manager port is an &amp;quot;invisible&amp;quot; port, on which the window backgrounds are drawn, although the windows have a port themselves. If you are familiar with Windows™ programming, the term &amp;quot;client rectangle&amp;quot; may ring a bell here - SCI draws the window backgrounds, using values in the window manager port, while the window&amp;#039;s own port controls what is drawn inside it. The window manager port covers the same bounding rectangle as the picture window, but it is transparent so it doesn&amp;#039;t mess up the graphics.&lt;br /&gt;
&lt;br /&gt;
I feel compelled to mention windows for a bit here, not in depth - they are the subject of a later article - but just to mention that the structure used to manage windows is just an extension of the port structure. Whenever an SCI system call needs a pointer to a port structure, a pointer to a window structure will do. This implicates that the SysWindow class (which implements windows) has no &amp;quot;port&amp;quot; property. Instead, its &amp;quot;window&amp;quot; property points to the extended port/window structure which can safely be passed to KSetPort. Not surprisingly, many of KNewWindow&amp;#039;s arguments end up in the port part of the window structure.&lt;br /&gt;
&lt;br /&gt;
An SCI program can&amp;#039;t directly instantiate a port. If a program wants to access a specific part of the screen using ports, it has to instantiate a transparent window. In fact, SCI creates the picture window using RNewWindow, the same function that the kernel call KNewWindow ends up calling, asking for an untitled window with a transparent background - but more on that in a later article.&lt;br /&gt;
&lt;br /&gt;
It must be stressed that ports are purely internal structures. Although a program can select different ports to draw in, the data structures themselves are absolutely off-limits to SCI code. KNewWindow fills a port structure with user-supplied data, but there is no way of changing that data, short of dis- posing the window and instantiating it again. The structure is frequently changed by SCI itself, though.&lt;br /&gt;
&lt;br /&gt;
Only two kernel calls deal directly with ports:&lt;br /&gt;
&lt;br /&gt;
KGetPort (see [[SCI_Specifications:_Chapter_5_(cont.)_-_Kernel_functions#Kernel_function_0x14:_GetPort.28.29|the Section called Kernel function 0x14: GetPort() in Chapter 5]])&amp;lt;br&amp;gt;&lt;br /&gt;
KSetPort (see [[SCI_Specifications:_Chapter_5_(cont.)_-_Kernel_functions#Kernel_function_0x15:_SetPort.28.29|the Section called Kernel function 0x15: SetPort() in Chapter 5]])&lt;br /&gt;
&lt;br /&gt;
These two functions are often used in pairs (also internally), like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;var temp;&lt;br /&gt;
&lt;br /&gt;
temp=KGetPort();  /* Save the old port */&lt;br /&gt;
KSetPort(...);      /* Activate some other port */&lt;br /&gt;
..                            /* Draw some stuff */&lt;br /&gt;
KSetPort(temp);    /* Reactivate the old port */&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==The Cursor resource==&lt;br /&gt;
&lt;br /&gt;
This resource stores a simple bitmap describing the shape and texture of the mouse pointer. All information stored herein is little endian in byte order.&lt;br /&gt;
&lt;br /&gt;
0x00 - 0x01&lt;br /&gt;
&lt;br /&gt;
:: X coordinate of the mouse cursor hot spot as a 16 bit integer. This variable is not used in SCI0. &lt;br /&gt;
&lt;br /&gt;
0x02 - 0x03&lt;br /&gt;
&lt;br /&gt;
:: Y coordinate of the mouse cursor hot spot as a 16 bit integer. Only 0x03 is used in SCI0; here, if set, the hot spot is at (8,8), if not set, it is located at (0,0). &lt;br /&gt;
&lt;br /&gt;
0x04 - 0x23&lt;br /&gt;
&lt;br /&gt;
:: This is a list of 16 unsigned 16 bit integers constituting bitmasks for the mouse cursor&amp;#039;s transparency map, with the MSB representing the leftmost pixel. &lt;br /&gt;
&lt;br /&gt;
0x24 - 0x43&lt;br /&gt;
&lt;br /&gt;
:: This is another list of 16 unsigned 16 bit integers. Each of them represents another bitmask, determining whether the mouse cursor pixel should be drawn in black (not set) or white (set). &lt;br /&gt;
&lt;br /&gt;
To determine whether or not to draw a pixel, and, if it is to be drawn, in which color it should be drawn in, the corresponding bits of both bitmask lists mentioned above have to be examined. In the table below, A represents a bit from the first list, and B the corresponding bit from the lower list.&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
===Color mapping for the SCI0 mouse pointer===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; width=&amp;quot;150&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;center&amp;quot; width=&amp;quot;25&amp;quot; | AB&lt;br /&gt;
! width=&amp;quot;120&amp;quot; | Result&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;25&amp;quot; | 00&lt;br /&gt;
| width=&amp;quot;120&amp;quot; | Transparent&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;25&amp;quot; | 01&lt;br /&gt;
| width=&amp;quot;120&amp;quot; | Transparent&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;25&amp;quot; | 10&lt;br /&gt;
| width=&amp;quot;120&amp;quot; | 0x00 (Black)&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;25&amp;quot; | 11&lt;br /&gt;
| width=&amp;quot;120&amp;quot; | 0x0f (White)&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
===Color mapping for the SCI1 mouse pointer===&lt;br /&gt;
&lt;br /&gt;
Since this method of doing things wastes one combination, the table was changed for SCI01 and SCI1:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; width=&amp;quot;150&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;center&amp;quot; width=&amp;quot;25&amp;quot; | AB&lt;br /&gt;
! width=&amp;quot;120&amp;quot; | Result&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;25&amp;quot; | 00&lt;br /&gt;
| width=&amp;quot;120&amp;quot; | Transparent&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;25&amp;quot; | 01&lt;br /&gt;
| width=&amp;quot;120&amp;quot; | 0x0f (White)&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;25&amp;quot; | 10&lt;br /&gt;
| width=&amp;quot;120&amp;quot; | 0x00 (Black)&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;25&amp;quot; | 11&lt;br /&gt;
| width=&amp;quot;120&amp;quot; | 0x07 (Light Gray)&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
==The SCI0 View Resource==&lt;br /&gt;
&lt;br /&gt;
In SCI0, Views are collections of images or sprites. Each View resource contains a number of groups, which, in turn, contain one or more images. Usually, those groups contain a number of consecutive animation frames. It appears to be customary to store related animations or images in a single frame. For example, the basic movements of all protagonists (four or eight animation cycles (depending on the game)) are stored inside of a single View resource. Please note that the byte order of the following data is always little endian.&lt;br /&gt;
&lt;br /&gt;
===The View Resource===&lt;br /&gt;
&lt;br /&gt;
0x00 - 0x01&lt;br /&gt;
&lt;br /&gt;
:: The number of image groups available. &lt;br /&gt;
&lt;br /&gt;
0x02 - 0x03&lt;br /&gt;
&lt;br /&gt;
:: A bitmask containing the &amp;#039;mirrored&amp;#039; flag for each of the groups, with the LSB containing the &amp;#039;mirrored&amp;#039; flag for group 0. &lt;br /&gt;
&lt;br /&gt;
0x04 - 0x07&lt;br /&gt;
&lt;br /&gt;
:: - unknown - &lt;br /&gt;
&lt;br /&gt;
0x08...&lt;br /&gt;
&lt;br /&gt;
:: A list of indices pointing to the start of the cell list for each image group. The number of entries is equal to the number of cells as described in 0x00 - &lt;br /&gt;
&lt;br /&gt;
0x01. &lt;br /&gt;
&lt;br /&gt;
===Cell List===&lt;br /&gt;
&lt;br /&gt;
0x00 - 0x01&lt;br /&gt;
&lt;br /&gt;
:: The number of image cells available for this group.&lt;br /&gt;
&lt;br /&gt;
0x02 - 0x03&lt;br /&gt;
&lt;br /&gt;
:: - unknown -&lt;br /&gt;
&lt;br /&gt;
0x04...&lt;br /&gt;
&lt;br /&gt;
:: A list of 16 bit pointers indexing the start of the image cell structure for each image cell. The pointers are relative to the beginning of the resource data. &lt;br /&gt;
&lt;br /&gt;
===Image Cell===&lt;br /&gt;
&lt;br /&gt;
0x00 - 0x01&lt;br /&gt;
&lt;br /&gt;
:: The horizontal (X) size of the image.&lt;br /&gt;
&lt;br /&gt;
0x02 - 0x03&lt;br /&gt;
&lt;br /&gt;
:: The vertical (Y) size of the image.&lt;br /&gt;
&lt;br /&gt;
0x04&lt;br /&gt;
&lt;br /&gt;
:: The x placement modifier. This signed value determines the number of pixels a view cell is moved to the right before it is drawn.&lt;br /&gt;
&lt;br /&gt;
0x05&lt;br /&gt;
&lt;br /&gt;
:: The y placement modifier. This signed value determines the number of pixels a view cell is moved downwards before it is drawn.&lt;br /&gt;
&lt;br /&gt;
0x06&lt;br /&gt;
&lt;br /&gt;
:: The color key, i.e. the color number used for transparency in this cell.&lt;br /&gt;
&lt;br /&gt;
0x07...&lt;br /&gt;
&lt;br /&gt;
:: A list of combined color/repeat count entries. Each byte contains a color entry (low nibble) and a repeat count (high nibble). If the color is equal to the color key from index 0x06, then no drawing should be performed, although [repeat] pixels still need to be skipped. It is not known whether this list is terminated; the FreeSCI drawing algorithm stops drawing as soon as the rectangle defined in the first two cell entries has been filled.&lt;br /&gt;
&lt;br /&gt;
==The SCI font resource==&lt;br /&gt;
&lt;br /&gt;
SCI font resources remained unchanged during the SCI revisions and were still used in SCI32. Their format is relatively straightforward and completely sufficient for any 8 or even 16 bit character table:&lt;br /&gt;
&amp;lt;div id=&amp;quot;AEN2349&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Table 3-1. The SCI font resource data structure&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; width=&amp;quot;760&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! width=&amp;quot;85&amp;quot; align=&amp;quot;center&amp;quot; | Offset&lt;br /&gt;
! width=&amp;quot;235&amp;quot; | Type&lt;br /&gt;
! width=&amp;quot;440&amp;quot; | Meaning&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;85&amp;quot; align=&amp;quot;center&amp;quot; | 0&lt;br /&gt;
| width=&amp;quot;235&amp;quot; | 16 bit integer, little endian encoding&lt;br /&gt;
| width=&amp;quot;440&amp;quot; | Always zero (?)&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;85&amp;quot; align=&amp;quot;center&amp;quot; | 2&lt;br /&gt;
| width=&amp;quot;235&amp;quot; | 16 bit integer, little endian encoding&lt;br /&gt;
| width=&amp;quot;440&amp;quot; | NUMCHAR: Number of characters&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;85&amp;quot; align=&amp;quot;center&amp;quot; | 4&lt;br /&gt;
| width=&amp;quot;235&amp;quot; | 16 bit integer, little endian encoding&lt;br /&gt;
| width=&amp;quot;440&amp;quot; | HEIGHT: Number of pixel lines per text line&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;85&amp;quot; align=&amp;quot;center&amp;quot; | 6 + NR * 2&lt;br /&gt;
| width=&amp;quot;235&amp;quot; | 16 bit integer, little endian encoding&lt;br /&gt;
| width=&amp;quot;440&amp;quot; | Absolute offset of the character #NR, where 0 &amp;amp;lt;= NR &amp;amp;lt; NUMCHAR&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
 HEIGHT does not affect the height of a character, though- it only tells the interpreter how far to move downwards when displaying a line of text. The characters referenced to starting at offset 6 are encoded as follows:&lt;br /&gt;
&amp;lt;div id=&amp;quot;AEN2375&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Table 3-2. The SCI font resource character data structure&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; width=&amp;quot;760&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! width=&amp;quot;85&amp;quot; align=&amp;quot;center&amp;quot; | Offset&lt;br /&gt;
! width=&amp;quot;235&amp;quot; | Type&lt;br /&gt;
! width=&amp;quot;440&amp;quot; | Meaning&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;85&amp;quot; align=&amp;quot;center&amp;quot; | 0&lt;br /&gt;
| width=&amp;quot;235&amp;quot; | unsigned 8 bit integer&lt;br /&gt;
| width=&amp;quot;440&amp;quot; | character &amp;lt;span style=&amp;quot;color: red; text-decoration: line-through;&amp;quot;&amp;gt;HEIGHT&amp;lt;/span&amp;gt; WIDTH&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;85&amp;quot; align=&amp;quot;center&amp;quot; | 1&lt;br /&gt;
| width=&amp;quot;235&amp;quot; | unsigned 8 bit integer&lt;br /&gt;
| width=&amp;quot;440&amp;quot; | character &amp;lt;span style=&amp;quot;color: red; text-decoration: line-through;&amp;quot;&amp;gt;WIDTH&amp;lt;/span&amp;gt; HEIGHT&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;85&amp;quot; align=&amp;quot;center&amp;quot; | 2...&lt;br /&gt;
| width=&amp;quot;235&amp;quot; | bitmask, size HEIGHT * round_up(WIDTH / 8)&lt;br /&gt;
| width=&amp;quot;440&amp;quot; | Bitmask for the character&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The bitmap consists of HEIGHT lines of n bytes, where n equals the number of bytes required for storing WIDTH bits. Data is stored with the MSB first, in little-endian encoding (first byte describes the 8 leftmost pixels), where a pixel is drawn iff the bit it corresponds to is set.&lt;br /&gt;
&lt;br /&gt;
==The SCI0 and SCI01 pic resource==&lt;br /&gt;
&lt;br /&gt;
;See also: [[Picture Resource]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The pic (background picture) resource format used in SCI0 is rather complex in comparison to the other graphical resource formats. It is best described as a sequence of drawing operations on a set of four 320x200 canvases, three of which are later used in the game (visual, priority, and control), and one of which is used during the drawing process for auxiliary purposes&amp;lt;ref group=Note&amp;gt;Due to the vector graphics nature of these drawing operations, they are inherently more scaleable than pixmaps.&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note hereIn order to describe the process, we will first need to define a set of operations we base them on:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;FUNCTION peek_input(): Byte; /* returns the byte pointed to by the input pointer */&lt;br /&gt;
FUNCTION get_input(): Byte; /* works like peek_input(), but also increminates the &lt;br /&gt;
                            ** input pointer  */&lt;br /&gt;
FUNCTION skip_input(x): Byte; /* skips x input bytes */&amp;lt;/pre&amp;gt;&lt;br /&gt;
      &lt;br /&gt;
&lt;br /&gt;
Using these pre-defined functions, we will now define additional helper functions used for reading specifically encoded data tuples:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;FUNCTION GetAbsCoordinates(): (Integer, Integer)&lt;br /&gt;
VAR&lt;br /&gt;
    x, y, coordinate_prefix : Integer;&lt;br /&gt;
BEGIN&lt;br /&gt;
    coordinate_prefix := get_input();&lt;br /&gt;
    x := get_input();&lt;br /&gt;
    y := get_input();&lt;br /&gt;
    x |= (coordinate_prefix &amp;amp; 0xf0) &amp;lt;&amp;lt; 4;&lt;br /&gt;
    y |= (coordinate_prefix &amp;amp; 0x0f) &amp;lt;&amp;lt; 8;&lt;br /&gt;
&lt;br /&gt;
    RETURN (x,y)&lt;br /&gt;
END&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
FUNCTION GetRelCoordinates(x : Integer, y: Integer): (Integer, Integer)&lt;br /&gt;
VAR&lt;br /&gt;
    input : Integer;&lt;br /&gt;
BEGIN&lt;br /&gt;
    input := get_input();&lt;br /&gt;
&lt;br /&gt;
    &amp;#039;&amp;#039;The below code for x is inaccurate. The left-most bit is used to indicate sign, so before doing the bitshift it is necessary to remove the left-most bit&amp;#039;&amp;#039;&lt;br /&gt;
    IF (input &amp;amp; 0x80) THEN&lt;br /&gt;
            x -= (input &amp;gt;&amp;gt; 4) &amp;amp; 0x7; /* remove left-most (sign) bit */&lt;br /&gt;
    ELSE&lt;br /&gt;
        x += (input &amp;gt;&amp;gt; 4);&lt;br /&gt;
    FI&lt;br /&gt;
&lt;br /&gt;
    IF (input &amp;amp; 0x08) THEN&lt;br /&gt;
        y -= (input &amp;amp; 0x7);&lt;br /&gt;
    ELSE&lt;br /&gt;
        y += (input &amp;amp; 0x7);&lt;br /&gt;
    FI&lt;br /&gt;
&lt;br /&gt;
    RETURN (x,y)&lt;br /&gt;
END&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We also need some data types based on EGACOLOR and PRIORITY, which can be thought of as integers:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;TYPE Palette = ARRAY[0..39] of EGACOLOR[0..1]&lt;br /&gt;
TYPE Priority_Table = ARRAY[0..39] of PRIORITY&lt;br /&gt;
&lt;br /&gt;
Palette default_palette =&lt;br /&gt;
     &amp;lt;(0,0), (1,1), (2,2), (3,3), (4,4), (5,5), (6,6), (7,7),&lt;br /&gt;
      (8,8), (9,9), (a,a), (b,b), (c,c), (d,d), (e,e), (8,8),&lt;br /&gt;
      (8,8), (0,1), (0,2), (0,3), (0,4), (0,5), (0,6), (8,8),&lt;br /&gt;
      (8,8), (f,9), (f,a), (f,b), (f,c), (f,d), (f,e), (f,f),&lt;br /&gt;
      (0,8), (9,1), (2,a), (3,b), (4,c), (5,d), (6,e), (8,8)&amp;gt;;&lt;br /&gt;
&lt;br /&gt;
#define DRAW_ENABLE_VISUAL   1&lt;br /&gt;
#define DRAW_ENABLE_PRIORITY 2&lt;br /&gt;
#define DRAW_ENABLE_CONTROL  4&lt;br /&gt;
&lt;br /&gt;
#define PATTERN_FLAG_RECTANGLE 0x10&lt;br /&gt;
#define PATTERN_FLAG_USE_PATTERN 0x20&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And now for the actual algorithm:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;FUNCTION DrawPic (cumulative, fill_in_black : Boolean; default_palette: Integer; visual_map, priority_map, control_map, aux_map : Map): Map^4&lt;br /&gt;
VAR&lt;br /&gt;
    palette : Array [0..3] of Palette;&lt;br /&gt;
    drawenable, priority, control, col1, col2, pattern_nr, pattern_code : Integer;&lt;br /&gt;
BEGIN&lt;br /&gt;
    palette := (default_palette × 4);&lt;br /&gt;
    drawenable := DRAW_ENABLE_VISUAL | DRAW_ENABLE_PRIORITY&lt;br /&gt;
    control := priority := 0;&lt;br /&gt;
    col1 := col2 := 0;&lt;br /&gt;
    pattern_nr := 0;&lt;br /&gt;
    pattern_code := 0;&lt;br /&gt;
&lt;br /&gt;
    IF (!cumulative) THEN BEGIN&lt;br /&gt;
        visual_map := (0xf × 320 × 200);&lt;br /&gt;
        map control := map priority := map aux := (0 × 320 × 200);&lt;br /&gt;
    END&lt;br /&gt;
&lt;br /&gt;
    FOREVER DO BEGIN&lt;br /&gt;
&lt;br /&gt;
        opcode := get_input();&lt;br /&gt;
&lt;br /&gt;
        COND opcode:&lt;br /&gt;
            0xf0 → /* PIC_OP_SET_COLOR */&lt;br /&gt;
                code := get_input();&lt;br /&gt;
                (col1, col2) := palette[default_palette + (code / 40)][code % 40];&lt;br /&gt;
                drawenable |= DRAW_ENABLE_VISUAL;&lt;br /&gt;
&lt;br /&gt;
            0xf1 → /* PIC_OP_DISABLE_VISUAL */&lt;br /&gt;
                drawenable &amp;amp;= ~DRAW_ENABLE_VISUAL;&lt;br /&gt;
&lt;br /&gt;
            0xf2 → /* PIC_OP_SET_PRIORITY */&lt;br /&gt;
                code := get_input();&lt;br /&gt;
                priority := code &amp;amp; 0xf;&lt;br /&gt;
                drawenable |= DRAW_ENABLE_PRIORITY;&lt;br /&gt;
&lt;br /&gt;
            0xf3 → /* PIC_OP_DISABLE_PRIORITY */&lt;br /&gt;
                drawenable &amp;amp;= ~DRAW_ENABLE_PRIORITY;&lt;br /&gt;
&lt;br /&gt;
            0xf4 → /* PIC_OP_RELATIVE_PATTERNS */&lt;br /&gt;
                IF (pattern_code &amp;amp; PATTERN_FLAG_USE_PATTERN) THEN&lt;br /&gt;
                    pattern_nr := (get_input() &amp;gt;&amp;gt; 1) &amp;amp; 0x7f&lt;br /&gt;
                FI&lt;br /&gt;
&lt;br /&gt;
                (x,y) := GetAbsCoordinates();&lt;br /&gt;
&lt;br /&gt;
                DrawPattern(x, y, col1, col2, priority, control, drawenable,&lt;br /&gt;
                         pattern_code &amp;amp; PATTERN_FLAG_USE_PATTERN,&lt;br /&gt;
                         pattern_size, pattern_nr, pattern_code &amp;amp; PATTERN_FLAG_RECTANGLE);&lt;br /&gt;
&lt;br /&gt;
                WHILE (peek_input() &amp;lt; 0xf0) DO BEGIN&lt;br /&gt;
                    IF (pattern_code &amp;amp; PATTERN_FLAG_USE_PATTERN) THEN&lt;br /&gt;
                        pattern_nr := (get_input() &amp;gt;&amp;gt; 1) &amp;amp; 0x7f&lt;br /&gt;
                    FI&lt;br /&gt;
                    (x,y) =  GetRelCoordinates(x,y);&lt;br /&gt;
                    DrawPattern(x, y, col1, col2, priority, control, drawenable,&lt;br /&gt;
                             pattern_code &amp;amp; PATTERN_FLAG_USE_PATTERN,&lt;br /&gt;
                             pattern_size, pattern_nr, pattern_code &amp;amp; PATTERN_FLAG_RECTANGLE);&lt;br /&gt;
                END&lt;br /&gt;
&lt;br /&gt;
            0xf5 → /* PIC_OP_RELATIVE_MEDIUM_LINES */&lt;br /&gt;
                (oldx, oldy) := GetAbsCoordinates();&lt;br /&gt;
                WHILE (peek_input() &amp;lt; 0xf0) DO BEGIN&lt;br /&gt;
                    temp := get_input();&lt;br /&gt;
                    IF (temp &amp;amp; 0x80) THEN&lt;br /&gt;
                        y := oldy - (temp &amp;amp; 0x7f)&lt;br /&gt;
                    ELSE&lt;br /&gt;
                        y := oldy + temp&lt;br /&gt;
                    FI&lt;br /&gt;
                    x = oldx + get_input();&lt;br /&gt;
                     DitherLine(oldx, oldy, x, y, col1, col2, priority, control, drawenable);&lt;br /&gt;
                    (oldx, oldy) := (x, y);&lt;br /&gt;
                END&lt;br /&gt;
&lt;br /&gt;
            0xf6 → /* PIC_OP_RELATIVE_LONG_LINES */&lt;br /&gt;
                (oldx, oldy) :=  GetAbsCoordinates()&lt;br /&gt;
                WHILE (peek_input() &amp;lt; 0xf0) DO BEGIN&lt;br /&gt;
                    (x, y) := GetAbsCoordinates();&lt;br /&gt;
                    DitherLine(oldx, oldy, x, y, col1, col2, priority, control, drawenable);&lt;br /&gt;
                    (oldx, oldy) := (x, y);&lt;br /&gt;
                END&lt;br /&gt;
&lt;br /&gt;
            0xf7 → /* PIC_OP_RELATIVE_SHORT_LINES */&lt;br /&gt;
                (oldx, oldy) =  GetAbsCoordinates()&lt;br /&gt;
                WHILE (peek_input() &amp;lt; 0xf0) DO BEGIN&lt;br /&gt;
                    (x, y) := GetRelCoordinates(oldx, oldy);&lt;br /&gt;
                    DitherLine(oldx, oldy, x, y, col1, col2, priority, control, drawenable);&lt;br /&gt;
                    (oldx, oldy) := (x, y);&lt;br /&gt;
                END&lt;br /&gt;
&lt;br /&gt;
            0xf8 → /* PIC_OP_FILL */&lt;br /&gt;
                IF (fill_in_black) THEN&lt;br /&gt;
                    (oldc1, oldc2) := (c1, c2);&lt;br /&gt;
                FI&lt;br /&gt;
&lt;br /&gt;
                WHILE (peek_input() &amp;lt; 0xf0) DO BEGIN&lt;br /&gt;
                    (x, y) := GetAbsCoordinates();&lt;br /&gt;
                    DitherFill(x, y, col1, col2, priority, control, drawenable);&lt;br /&gt;
                END&lt;br /&gt;
&lt;br /&gt;
                IF (fill_in_black) THEN&lt;br /&gt;
                    (c1, c2) := (oldc1, oldc2);&lt;br /&gt;
                FI&lt;br /&gt;
&lt;br /&gt;
            0xf9 → /* PIC_OP_SET_PATTERN */&lt;br /&gt;
                pattern_code := get_input() &amp;amp; 0x37;&lt;br /&gt;
                pattern_size := pattern_code &amp;amp; 0x7;&lt;br /&gt;
&lt;br /&gt;
            0xfa → /* PIC_OP_ABSOLUTE_PATTERNS */&lt;br /&gt;
                WHILE (peek_input() &amp;lt; 0xf0) DO&lt;br /&gt;
                    IF (pattern_code &amp;amp; PATTERN_FLAG_USE_PATTERN)&lt;br /&gt;
                        pattern_nr := (get_input() &amp;gt;&amp;gt; 1) &amp;amp; 0x7f&lt;br /&gt;
                    FI&lt;br /&gt;
                    (x, y) := GetAbsCoordinates();&lt;br /&gt;
                    DrawPattern(x, y, col1, col2, priority, control, drawenable,&lt;br /&gt;
                             pattern_code &amp;amp; PATTERN_FLAG_USE_PATTERN,&lt;br /&gt;
                             pattern_size, pattern_nr, pattern_code &amp;amp; PATTERN_FLAG_RECTANGLE);&lt;br /&gt;
                    END&lt;br /&gt;
&lt;br /&gt;
            0xfb → /* PIC_OP_SET_CONTROL */&lt;br /&gt;
                control := get_input() &amp;amp; 0x0f;&lt;br /&gt;
                drawenable |= DRAW_ENABLE_CONTROL;&lt;br /&gt;
&lt;br /&gt;
            0xfc → /* PIC_OP_DISABLE_CONTROL */&lt;br /&gt;
                drawenable &amp;amp;= ~DRAW_ENABLE_CONTROL;&lt;br /&gt;
&lt;br /&gt;
            0xfd → /* PIC_OP_RELATIVE_MEDIUM_PATTERNS */&lt;br /&gt;
                IF (pattern_code &amp;amp; PATTERN_FLAG_USE_PATTERN) THEN&lt;br /&gt;
                    pattern_nr := (get_input() &amp;gt;&amp;gt; 1) &amp;amp; 0x7f;&lt;br /&gt;
                FI&lt;br /&gt;
&lt;br /&gt;
                (oldx, oldy) := GetAbsCoordinates();&lt;br /&gt;
&lt;br /&gt;
                DrawPattern(x, y, col1, col2, priority, control, drawenable,&lt;br /&gt;
                         pattern_code &amp;amp; PATTERN_FLAG_USE_PATTERN,&lt;br /&gt;
                         pattern_size, pattern_nr, pattern_code &amp;amp; PATTERN_FLAG_RECTANGLE);&lt;br /&gt;
&lt;br /&gt;
                WHILE (peek_input() &amp;lt; 0xf0) DO BEGIN&lt;br /&gt;
                    IF (pattern_code &amp;amp; PATTERN_FLAG_USE_PATTERN) THEN&lt;br /&gt;
                        pattern_nr := (get_input() &amp;gt;&amp;gt; 1) &amp;amp; 0x7f;&lt;br /&gt;
                    FI&lt;br /&gt;
            &lt;br /&gt;
                    temp := get_input();&lt;br /&gt;
                    IF (temp &amp;amp; 0x80)&lt;br /&gt;
                        y := oldy - (temp &amp;amp; 0x7f)&lt;br /&gt;
                    ELSE&lt;br /&gt;
                        y := oldy + temp&lt;br /&gt;
                    FI&lt;br /&gt;
                    x := oldx + get_input();&lt;br /&gt;
                    DrawPattern(x, y, col1, col2, priority, control, drawenable,&lt;br /&gt;
                             pattern_code &amp;amp; PATTERN_FLAG_USE_PATTERN,&lt;br /&gt;
                             pattern_size, pattern_nr, pattern_code &amp;amp; PATTERN_FLAG_RECTANGLE);&lt;br /&gt;
                END&lt;br /&gt;
&lt;br /&gt;
            0xfd → /* PIC_OP_OPX */&lt;br /&gt;
                COND get_input():&lt;br /&gt;
                    0x00 → /* PIC_OPX_SET_PALETTE_ENTRY */&lt;br /&gt;
                        WHILE peek_input() &amp;lt; 0xf0 DO BEGIN&lt;br /&gt;
                            index := get_input();&lt;br /&gt;
                            color := get_input();&lt;br /&gt;
                            palette[index / 40][color % 40] := color;&lt;br /&gt;
                        END&lt;br /&gt;
&lt;br /&gt;
                    0x01 → /* PIC_OPX_SET_PALETTE */&lt;br /&gt;
                        palette_number := get_input();&lt;br /&gt;
                        FOR i := 0 TO 39 DO&lt;br /&gt;
                            palette[palette_number][i] := get_input();&lt;br /&gt;
                        OD&lt;br /&gt;
&lt;br /&gt;
                    0x02 → /* PIC_OPX_MONO0 */&lt;br /&gt;
                        skip_input(41);&lt;br /&gt;
&lt;br /&gt;
                    0x03 → /* PIC_OPX_MONO1 */&lt;br /&gt;
                        skip_input(1);&lt;br /&gt;
&lt;br /&gt;
                    0x04 → /* PIC_OPX_MONO2 */&lt;br /&gt;
                    0x05 → /* PIC_OPX_MONO3 */&lt;br /&gt;
                        skip_input(1);&lt;br /&gt;
&lt;br /&gt;
                    0x06 → /* PIC_OPX_MONO4 */&lt;br /&gt;
                    0x07 → /* PIC_OPX_EMBEDDED_VIEW */ /* SCI01 operation */&lt;br /&gt;
                    0x08 → /* PIC_OPX_SET_PRIORITY_TABLE */ /* SCI01 operation */&lt;br /&gt;
&lt;br /&gt;
            0xff → return (visual, control, priority, aux);&lt;br /&gt;
        END OF COND&lt;br /&gt;
      END&lt;br /&gt;
END&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;This algorithm uses three auxiliary algorithms, DrawPattern, DitherLine, and DitherFill, which are sketched below. All of these functions are supposed to take the four maps as implicit parameters.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;PROCEDURE DrawPattern(x, y, col1, col2, priority, control, drawenable : Integer;  solid : Boolean ;  pattern_size, pattern_nr : Integer; rectangle : Boolean)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alters (x,y) so that 0 &amp;lt;= (x - pattern_size), 319 &amp;gt;= (x + pattern_size), 189 &amp;gt;= (y + pattern_size) and 0 &amp;lt;= (y - pattern_size), then draws a rectangle or a circle filled with col1, col2, priority, control, as determined by drawenable.&lt;br /&gt;
&lt;br /&gt;
If rectangle is not set, it will draw a rectangle, otherwise a circle of size pattern_size. pattern_nr is used to specify the start index in the random bit table (256 random bits)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;PROCEDURE DitherLine(x, y, xend, yend, color1, color2, priority, control, drawenable : Integer)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Draws a dithered line between (x, y+10) and (xend, yend+10). If the appropriate drawenable flags&lt;br /&gt;
are set, it draws &amp;#039;priority&amp;#039; to the priority map, &amp;#039;control&amp;#039; to the control map, and &amp;#039;color1&amp;#039; and &amp;#039;color2&amp;#039;&lt;br /&gt;
(alternating) to the visual map. The auxiliary map is bitwise-or&amp;#039;d with the drawenable flag while this is&lt;br /&gt;
done.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;PROCEDURE DitherFill(x, y, col0, col1, priority, control, drawenable : Integer)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fills all layers for which drawenable is set with the appropriate content. Diagonal filling is not allowed. Boundaries are determined as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;x&amp;lt;0, x&amp;gt;319, y&amp;lt;10, y&amp;gt;199 are hard boundaries. We now determine the &amp;#039;boundary map&amp;#039; bound_map and the allowed color legal_color. If bound_map[coordinates] = legal_color, then the pixel may be filled.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;IF (drawenable &amp;amp; DRAW_ENABLE_VISUAL)&lt;br /&gt;
    bound_map = visual;&lt;br /&gt;
    legal_color = 0xf;&lt;br /&gt;
ELSIF (drawenable &amp;amp; DRAW_ENABLE_PRIORITY)&lt;br /&gt;
    bound_map = priority;&lt;br /&gt;
    legal_color = 0;&lt;br /&gt;
ELSIF (drawenable &amp;amp; DRAW_ENABLE_CONTROL)&lt;br /&gt;
    bound_map = control;&lt;br /&gt;
    legal_color = 0;&lt;br /&gt;
ELSE&lt;br /&gt;
    return;&lt;br /&gt;
FI&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Windows, Dialogs and Controls==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;by Lars Skovlund&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Version 1.0, 7. July 1999&lt;br /&gt;
&lt;br /&gt;
I am going to start by mentioning the menus. It has nothing to do with the material I deal with in this essay. They use different kernel calls, and such things as port management are handled internally by the kernel routines. The SCI program just sets up a menu structure using the kernel calls. Since they are irrelevant to the subject of this essay, I will not spend more time on them.&lt;br /&gt;
&lt;br /&gt;
The Rect structure is important (also to ports) since it is the basis for passing a screen position to the interpreter. It looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;typedef struct&lt;br /&gt;
{&lt;br /&gt;
  short top, left, bottom, right;&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It will be seen from this that rectangle coordinates in SCI are not normally represented in the usual (x,y,width,height) fashion. So pay close attention to this structure! Also, it is not passed as a pointer, but rather as the four values in order. This is particularly true of SCI objects, where the property names nsTop etc. actually form a Rect structure which can be used directly by the interpreter.&lt;br /&gt;
&lt;br /&gt;
Windows are created using the KNewWindow kernel function. Each window has six attributes which are passed from the script to the kernel function:&lt;br /&gt;
&lt;br /&gt;
Bounding rectangle&amp;lt;br&amp;gt;&lt;br /&gt;
Title&amp;lt;br&amp;gt;&lt;br /&gt;
Type&amp;lt;br&amp;gt;&lt;br /&gt;
Priority&amp;lt;br&amp;gt;&lt;br /&gt;
Foreground color&amp;lt;br&amp;gt;&lt;br /&gt;
Background color&lt;br /&gt;
&lt;br /&gt;
Of these, the type and priority are the most interesting, because they decide the appearance of the window. The type is a bit field:&lt;br /&gt;
&lt;br /&gt;
bit 0 - transparency&amp;lt;br&amp;gt;&lt;br /&gt;
bit 1 - window does _not_ have a frame&amp;lt;br&amp;gt;&lt;br /&gt;
bit 2 - the window has a title&amp;lt;br&amp;gt;&lt;br /&gt;
bit 3-6 - unused&amp;lt;br&amp;gt;&lt;br /&gt;
bit 7 - see below&lt;br /&gt;
&lt;br /&gt;
Bit 0 specifies a transparent window. KNewWindow does not save the image behind the created window - it stays on the screen until the pic is redrawn, so windows with this style definitely can&amp;#039;t be used as message boxes. It does have some special uses, though. If this bit is not set, KNewWindow draws a rectangle in the specified background color using the bounding rectangle coordinates (using the WM port). When this bit is set,&lt;br /&gt;
&lt;br /&gt;
Bit 1 specifies a window without a frame. The frame is the black shading you can see in the corner of a message box.&lt;br /&gt;
&lt;br /&gt;
Bit 2 tells KNewWindow to draw a grey title bar with a title printed in white. In the version I have used for this essay, it is not possible to change the title bar colors. Note that the bounding rectangle is always specified as if the window had no title bar. If this bit is set, ten pixels are reserved above the coordinates specified. Although this bit is set, the Title parameter may still be NULL. If this is the case, an empty title bar is drawn.&lt;br /&gt;
&lt;br /&gt;
Bit 7 has a special meaning; it is used only in window type 0x81, and is not tested in any other way. When this style is chosen, KNewWindow does not draw anything at all. It is the caller&amp;#039;s responsibility to draw a window frame on the WM port. CB1 uses this style for its ornate windows, and draws the frame manually.&lt;br /&gt;
&lt;br /&gt;
The picture window which I mentioned in the last article is created using style 3 (that is, TRANSPARENT | NOFRAME). The normal message box styles used in LSL3 are 0 and 4.&lt;br /&gt;
&lt;br /&gt;
I have not been able to investigate the priority property yet, so the fol- lowing is based on suppositions. It is only used when drawing transparent windows. In this case, if priority is not -1 (which means not used), the window is drawn onto the priority map (with the specified priority value) as well as the screen.&lt;br /&gt;
&lt;br /&gt;
There is a class called SysWindow which is just a simple wrapper around the following two kernel calls. Try breaking on SysWindow::open, then type c to inspect the current object. You can change all the parameters to KNewWindow (the Rect is split in its fields, to nsTop, nsLeft etc.)&lt;br /&gt;
&lt;br /&gt;
To create a window structure, use KNewWindow (see [[SCI_Specifications:_Chapter_5_(cont.)_-_Kernel_functions#Kernel_function_0x13:_NewWindow.28Rect.2C_HeapPtr.2C_word.2C_word.2C_word.2C_word.29|the Section called Kernel function 0x13: NewWindow(Rect, HeapPtr, word, word, word, word) in Chapter 5]]); to remove it again, apply KDisposeWindow (see [[SCI_Specifications:_Chapter_5_(cont.)_-_Kernel_functions#Kernel_function_0x16:_DisposeWindow.28HeapPtr_Window.29|the Section called Kernel function 0x16: DisposeWindow(HeapPtr Window) in Chapter 5]]) on it.&lt;br /&gt;
&lt;br /&gt;
So how do we put stuff inside these windows? That question is a little complicated to answer, because it is really a shared effort between the interpreter and the object hierarchy, and this is one case where the interpreter actually interacts with the objects itself. I will start by explaining the classes involved.&lt;br /&gt;
&lt;br /&gt;
All control types are descendants of a common class (I do not know its name, since it appears to have an invalid name property). Among other things, this common class contains a type number and a state. The type number is the only thing that distinguishes the control types from each other inside the interpreter - if a wrong type is set, the interpreter might try to change a non-existent property.&lt;br /&gt;
&lt;br /&gt;
The type numbers are laid out as follows:&lt;br /&gt;
&lt;br /&gt;
# - Button control&lt;br /&gt;
# - Text control&lt;br /&gt;
# - Edit control&lt;br /&gt;
# - Icon control&lt;br /&gt;
# - not used&lt;br /&gt;
# - Selector control (as in the Save and Restore boxes)&lt;br /&gt;
&lt;br /&gt;
The gauge &amp;quot;controls&amp;quot; are not really controls. I don&amp;#039;t know how they work (yet).&lt;br /&gt;
&lt;br /&gt;
Each control also has a state value. These are laid out as follows:&lt;br /&gt;
&lt;br /&gt;
: bit 0 - selectable. If this bit is set, the control can be selected using the Tab key. Except for the text and icon controls, all controls are selectable.&amp;lt;br&amp;gt;&lt;br /&gt;
: bit 1 - unknown. Always set, except for the text and icon controls&amp;lt;br&amp;gt;&lt;br /&gt;
: bit 2 - disabled. When this bit is set, a button is grayed out. No other control types are affected.&amp;lt;br&amp;gt;&lt;br /&gt;
: bit 3 - selected. When this bit is set, a frame is drawn around the control.&lt;br /&gt;
&lt;br /&gt;
Note that state 3 is by far the most common. With that explained, I&amp;#039;ll move on to the kernel functions. There are three functions associated with controls - KDrawControl (see [[SCI_Specifications:_Chapter_5_(cont.)_-_Kernel_functions#Kernel_function_0x17:_DrawControl.28HeapPtr.29|the Section called Kernel function 0x17: DrawControl(HeapPtr) in Chapter 5]]), KHiliteControl (see [[SCI_Specifications:_Chapter_5_(cont.)_-_Kernel_functions#Kernel_function_0x18:_HiliteControl.28HeapPtr.29|the Section called Kernel function 0x18: HiliteControl(HeapPtr) in Chapter 5]]) and KEditControl (see [[SCI_Specifications:_Chapter_5_(cont.)_-_Kernel_functions#Kernel_function_0x19:_EditControl.28HeapPtr.29|the Section called Kernel function 0x19: EditControl(HeapPtr) in Chapter 5]]). Note that there is a KOnControl kernel call which is entirely unrelated to window management.&lt;br /&gt;
&lt;br /&gt;
The dialogs are implemented using not one, but two classes - Dialog and Window. While the Window class maintains the window (It is derived from SysWindow), the Dialog class is just a list of controls. It is derived from the List class, but has extended functionality to tell its members to redraw etc. There is a special function, located in script 255, which allows scripts to push information about the dialog on the stack instead of creating the Dialog object manually.&lt;br /&gt;
&lt;br /&gt;
:: &amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;Note&amp;#039;&amp;#039;&amp;#039; that the internal debugger uses the same window calls as the SCI script. That is why the screen messes up if you step through drawing code - the debugger has activated the Debug window port, and &amp;quot;forgets&amp;quot; to switch back while stepping across instructions. Thus, all graphics commands are redirected to the debug window port. Not a pretty sight.&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
==Pictures and movement control==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;By Lars Skovlund&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Version 1.0, 24. July 1999&lt;br /&gt;
&lt;br /&gt;
A pic in SCI consists of three layers (called maps - they are unrelated to the map resources found in SCI1 games). The visual map, used for the picture which appears on the user&amp;#039;s screen. The priority map which tells the interpreter which things go in front of which in the three-dimensional room. Without the priority map, a room would just be a flat, painted surface. The control map decides where game characters (called actors) can walk and where special events occur. These special events are triggered by a game character walking on a particular spot. Where the visual map is almost always very complex and using dithered fills etc., the latter two consist of large areas of solid color.&lt;br /&gt;
&lt;br /&gt;
Many functions which need to access these maps do so by using a bit-field. The bits are laid out as follows (but don&amp;#039;t set more than one at a time!)&lt;br /&gt;
&lt;br /&gt;
bit 0 - Visual&amp;lt;br&amp;gt;&lt;br /&gt;
bit 1 - Priority&amp;lt;br&amp;gt;&lt;br /&gt;
bit 2 - Control&lt;br /&gt;
&lt;br /&gt;
It is important to understand that, although being represented as colors on the screen, a priority/control &amp;quot;color&amp;quot; should be considered a number. The colors map to values according to the standard EGA color values.&lt;br /&gt;
&lt;br /&gt;
Every animated object in SCI has a priority. As the object moves, its pri- ority changes according to the so-called priority bands, explained next (it is, however, possible for a script to lock the priority of a view). The picture window is divided vertically into 16 priority bands. The priority of an animated object is determined by the position of its &amp;quot;base rectangle&amp;quot; in one of these bands. Things are drawn in order of ascending priority, so objects with priority 15 are guaranteed to be in front of everything else. The default priority mapping gives priority 0 a fairly large space, the 42 topmost rows (including the menu bar which AFAIK is 10) in the picture. All other priority bands have the same size. A script can choose to alter this mapping, specifying the amount of space to assign to priority 0, and the number of the last row to include in the mapping calculation.&lt;br /&gt;
&lt;br /&gt;
In most rooms, it is desirable to limit actor movement, confining the actor to a specific part of the screen. In other cases, special events are triggered by movement into a specific screen area. On some occasions, even room switches are implemented using control polygons. While the meaning of priorities is determined by the kernel, the meaning of control values is entirely up to the script. It is more or less a standard, however, that actors can&amp;#039;t walk on white control areas.&lt;br /&gt;
&lt;br /&gt;
As the control map is not consulted by the interpreter itself (except in a few cases), scripts need a way to do so. That way is called OnControl, and it is a kernel call. Supplied with a point or a rectangle, it returns a bit mask containing the control values of all the pixels in the desired region. If a specific control value is encountered, it is used as a bit number, and that bit is set in the output mask.&lt;br /&gt;
&lt;br /&gt;
This bit mask system is also used in another place, namely the illegalBits selector of the Act (actor) class. The illegalBits selector determines in which areas the actor may not walk.&lt;br /&gt;
&lt;br /&gt;
The OnControl() system call is explained in [[SCI_Specifications:_Chapter_5_(cont.)_-_Kernel_functions#Kernel_function_0x52:_OnControl.28word.2C_Point_.7C_Rect.29|the Section called Kernel function 0x52: OnControl(word, Point | Rect) in Chapter 5]].&lt;br /&gt;
&lt;br /&gt;
;Notes&lt;br /&gt;
&amp;lt;references group=Note/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;float: left&amp;quot;&amp;gt;[[SCI Specifications: Chapter_2_-_Resource_files|&amp;amp;lt; Previous: Chapter 2 - Resource files]]&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;float: right&amp;quot;&amp;gt;[[SCI Specifications: Chapter_4_-_The_Sound_subsystem|Next: Chapter 4 - The Sound subsystem &amp;amp;gt;]]&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
[[Category:SCI Documentation]]&lt;br /&gt;
[[Category:Sierra Creative Interpreter Specifications]]&lt;br /&gt;
[[Category:SCI Resources]]&lt;br /&gt;
[[Category:Control Areas]]&lt;/div&gt;</summary>
		<author><name>Rainer De Temple</name></author>
	</entry>
	<entry>
		<id>http://sciwiki.sierrahelp.com/index.php?title=Main_Page&amp;diff=15206</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://sciwiki.sierrahelp.com/index.php?title=Main_Page&amp;diff=15206"/>
		<updated>2020-09-16T11:05:14Z</updated>

		<summary type="html">&lt;p&gt;Rainer De Temple: Added link to getting started, reworded how to contribute and fixed broken links&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
===Welcome to the SCI Programmers Wiki.===&lt;br /&gt;
&lt;br /&gt;
A Wiki for the SCI Programming Community. SCI is the game engine created by [[Jeff Stephenson]] for [[Sierra On-Line]], which was used between the years of 1989 to 1997. It superseded Sierra&amp;#039;s earlier AGI engine. It was used to create such games as &amp;#039;&amp;#039;[[King&amp;#039;s Quest IV]]&amp;#039;&amp;#039; to VII, &amp;#039;&amp;#039;[[Space Quest III]]&amp;#039;&amp;#039; to &amp;#039;&amp;#039;[[Space Quest 6|6]]&amp;#039;&amp;#039;, &amp;#039;&amp;#039;[[Quest for Glory I]]&amp;#039;&amp;#039; to &amp;#039;&amp;#039;[[Quest for Glory IV|IV]]&amp;#039;&amp;#039; and &amp;#039;&amp;#039;[[Gabriel Knight I]]&amp;#039;&amp;#039; and &amp;#039;&amp;#039;[[Beast Within: A Gabriel Knight Mystery, The|II]]&amp;#039;&amp;#039;. With the availability of such tools as [[SCI Studio|Brian Provinciano&amp;#039;s SCI Studio 3]] and [[SCI Companion|Phil Fortier&amp;#039;s SCI Companion]], you can create your own games based on the same engine that Sierra used. This Wiki is a knowledgebase and collection of resources for those working with SCI. Additional help can always be found on the [[SCIPF:|SCI Programming Community Message Board]]. For help with Sierra&amp;#039;s games, see [[SHP:|The Sierra Help Pages]].&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;br /&amp;gt; News ===&lt;br /&gt;
&lt;br /&gt;
{| width=&amp;quot;100%&amp;quot; cellspacing=&amp;quot;20&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border: 1px solid #C9AE56; background-color: #FFFBED&amp;quot; width=&amp;quot;50%&amp;quot; valign=&amp;quot;top&amp;quot; | &amp;lt;div style=&amp;quot;padding: .4em .9em .9em&amp;quot;&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Feb 07, 2016&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* There is a new version of [[Phil Fortier|Phil Fortier&amp;#039;s]] [[SCI Companion]]. SCI Companion v3 supports development of games from [[Sierra_Release_List#SCI0_.28early.29 | SCI0]] to [[Sierra_Release_List#SCI1.1 | SCI1.1]]. Besides VGA graphics you will now be able to add digital sound effects and lip synced speech to your SCI games.&lt;br /&gt;
&lt;br /&gt;
* [[NSIS Publisher]], SCI Companion&amp;#039;s first plugin has been released. NSIS Publisher allows you to publish your SCI Companion project using the [http://nsis.sourceforge.net/Main_Page Null Soft Install System (NSIS)] and can automatically compile a DOSBox installer for distribution of your game.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;March, 2016&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* [[SEQTool]], another SCI Companion plugin is under development. This tool is based on [[Kawa|Kawa&amp;#039;s]] [[SeqMaker]], a command line program. With SEQTool you can edit existing [[SEQ Resource|SEQ files]] (used for cut scenes in SCI1 and later Sierra games), create new ones from your own 320px x 200px paletted 8-bit color images, import animated GIFs to SEQ or export frames from SEQ files to individual image files.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;br /&amp;gt; Getting started ===&lt;br /&gt;
&lt;br /&gt;
New here? Visit the [[Getting Started]] page for information about how to create new SCI games, or understand the Tools behind editing them.&lt;br /&gt;
&lt;br /&gt;
Please also take the time to visit the [[Community Portal]], which contains useful links for SCI and the SCI Wiki. &lt;br /&gt;
&lt;br /&gt;
If you are interested in contributing to the Wiki see [[#How to Contribute|How to Contribute]] below.&amp;lt;!--&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;Didn&amp;#039;t find what you were looking for? Try [[Request article|requesting an article]].&amp;lt;/div&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;br /&amp;gt; Links ===&lt;br /&gt;
&lt;br /&gt;
Links for additional help and resources for help for your SCI needs.&lt;br /&gt;
&lt;br /&gt;
[http://sciprogramming.com SCI Programming.com] &amp;amp;nbsp; - &amp;amp;nbsp; http://sciprogramming.com&lt;br /&gt;
: [http://sciprogramming.com/community/ SCI Programming.com message boards] &amp;amp;nbsp; - &amp;amp;nbsp; http://sciprogramming.com/community/&lt;br /&gt;
: [http://sciprogramming.com/scitools.php SCI Tools on SCI Programming.com] &amp;amp;nbsp; - &amp;amp;nbsp; http://sciprogramming.com/scitools.php&lt;br /&gt;
: [http://sciprogramming.com/fangames.php SCI fan games] &amp;amp;nbsp; - &amp;amp;nbsp; http://sciprogramming.com/fangames.php&lt;br /&gt;
[[scicomp:|SCI Companion]]&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scicompdoc:|SCI Companion Documentation]]&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;!-- [http://www.mtnphil.com/Games/SCIComp.html SCI Companion] &amp;amp;nbsp; - &amp;amp;nbsp; http://www.mtnphil.com/Games/SCIComp.html&amp;lt;br&amp;gt; --&amp;gt;&lt;br /&gt;
[http://scistudio.sourceforge.net/ SCI Studio on SourceForge] &amp;amp;nbsp; - &amp;amp;nbsp; http://scistudio.sourceforge.net/&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- [http://www.sci.sierrahelp.com/Tools/SCITools.html SCI Tools on the Sierra Help Pages] &amp;amp;nbsp; - &amp;amp;nbsp; http://www.sci.sierrahelp.com/Tools/SCITools.html&amp;lt;br&amp;gt; --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;br /&amp;gt; How to Contribute ===&lt;br /&gt;
&lt;br /&gt;
No registration is required to view this Wiki. Anyone can view the various topics and guides on the SCI Wiki. However, to add or edit pages, you must be [[Special:Userlogin|logged in]]. If you are not registered, you may request an account editing privileges. &lt;br /&gt;
&lt;br /&gt;
Contact Collector on the [[SCIPF:|SCI Programming Community Message Board]] or [[shp:forums|The Sierra Help Pages Forums]] if you wish to contribute. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
==== Notes for Editors: ====&lt;br /&gt;
&lt;br /&gt;
Please familiarize yourself with [[Help:Contents | MediaWiki formatting]] before adding or editing pages. See the [[Notes_for_Editors|Notes for Editors]] page for SCI Wiki standards and news.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Wiki Help]]&lt;/div&gt;</summary>
		<author><name>Rainer De Temple</name></author>
	</entry>
	<entry>
		<id>http://sciwiki.sierrahelp.com/index.php?title=Getting_Started_With_SCI_Development&amp;diff=15205</id>
		<title>Getting Started With SCI Development</title>
		<link rel="alternate" type="text/html" href="http://sciwiki.sierrahelp.com/index.php?title=Getting_Started_With_SCI_Development&amp;diff=15205"/>
		<updated>2020-09-16T10:55:14Z</updated>

		<summary type="html">&lt;p&gt;Rainer De Temple: initial creation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page serves as an introduction to SCI Programming.  Programming for Sierra&amp;#039;s Creative Interpreter can be divided into two main sections. &lt;br /&gt;
&lt;br /&gt;
;Creating SCI Games: for those who want to learn and create new games using the interpreter.&lt;br /&gt;
&lt;br /&gt;
;Programming SCI Tools: for those who want to learn more about the Interpreter itself and want to create new tools for editing games.&lt;br /&gt;
&lt;br /&gt;
== Quick Start ==&lt;br /&gt;
&lt;br /&gt;
# Download [http://scicompanion.com/ SCI Companion], and install.&lt;br /&gt;
# Open your favourite SCI game by browsing to it&amp;#039;s &amp;quot;resource.map&amp;quot; file in SCI Companion.&lt;br /&gt;
# Using the resource explorer, double click to view the game&amp;#039;s pictures, views, and sounds, etc.&lt;br /&gt;
# Create a new game using the built in Template.&lt;br /&gt;
&lt;br /&gt;
== Play SCI Releases ==&lt;br /&gt;
&lt;br /&gt;
For a list of all &amp;quot;fan-made&amp;quot; games refer to the [[:Category:All_SCI_Releases|All SCI Releases]] Category. &lt;br /&gt;
Many of these can be downloaded from the [http://sciprogramming.com SCI Programming.com] website.&lt;br /&gt;
&lt;br /&gt;
== Creating SCI Games ==&lt;br /&gt;
&lt;br /&gt;
Two main editors are available for creating new SCI Games. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin: auto;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| style=&amp;quot;width: 50%&amp;quot;|{{SCISoftwareInfobox&lt;br /&gt;
| Software = SCI Studio&lt;br /&gt;
| image = [[Image:SCIStudio3SS.png|320px]]&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;SCI Studio Screenshot&amp;#039;&amp;#039;&lt;br /&gt;
| Version = 3&lt;br /&gt;
| ReleaseDate = [[2003]]&lt;br /&gt;
| Company = {{BriProTool}}&lt;br /&gt;
| Published = {{Published}}&lt;br /&gt;
| Developers =  {{BrianProvincianoFanToolDev}}&lt;br /&gt;
| ProgLanguage = {{C++}}&lt;br /&gt;
| OpenSource = {{Open}}&lt;br /&gt;
| Source = {{SourceSW}}&lt;br /&gt;
| License = &lt;br /&gt;
| Platform = {{WinTool}}&lt;br /&gt;
| Type = {{SCIIDE}}&lt;br /&gt;
| Localization = {{EnglishTool}}&lt;br /&gt;
| Website = [[wayback:20061113153514/http://www.bripro.com/scistudio/index.php|http://www.bripro.com/scistudio/]] (web archive)&lt;br /&gt;
}}&lt;br /&gt;
| style=&amp;quot;width: 50%&amp;quot;|{{SCISoftwareInfobox&lt;br /&gt;
| Software = SCI Companion&lt;br /&gt;
| image = [[Image:SCICompanion3SS.png|320px]]&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;SCI Companion 3 Screenshot&amp;#039;&amp;#039;&lt;br /&gt;
| Version = 3.0.1.7&lt;br /&gt;
| ReleaseDate = [[2016|Feb 07, 2016]]&lt;br /&gt;
| Company = IceFall Games&lt;br /&gt;
| Published = {{Published}}&lt;br /&gt;
| Developers = {{PhilFortierToolDev}}&lt;br /&gt;
| ProgLanguage = {{C++}}&lt;br /&gt;
| OpenSource = {{Open}}&lt;br /&gt;
| Source = {{SourceSW}}&lt;br /&gt;
| License = &amp;lt;!-- {{GPL2}} --&amp;gt;&lt;br /&gt;
| Platform = {{WinTool}}&lt;br /&gt;
| Type = {{IDE}}&lt;br /&gt;
| Localization = {{EnglishTool}}&lt;br /&gt;
| Website = [http://scicompanion.com/ scicompanion.com/]&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For more SCI Integrated Development Environments, refer to [[:Category:SCI_Integrated_Development_Environments|SCI Integrated Development Environments]]&lt;br /&gt;
&lt;br /&gt;
=== Choosing a SCI Version ===&lt;br /&gt;
&lt;br /&gt;
There are several versions of SCI, ranging from early game types such as King&amp;#039;s Quest 4, Leisure Suit Larry 2, and Police Quest 2, all the way up to Kings Quest 7, Phantasmagoria, and Gabriel Knight.&lt;br /&gt;
&lt;br /&gt;
Typically, the earlier versions SCI0 are better supported. Continued development and research can be found on the SCI Message Board. For all versions, refer to [[ToDo/Sierra Game Versions|Sierra Game Versions]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|- &lt;br /&gt;
| SCI0 &lt;br /&gt;
| EGA 16 Color Graphics, text parser &lt;br /&gt;
| eg: Space Quest 3&lt;br /&gt;
|- &lt;br /&gt;
| SCI01 &lt;br /&gt;
| EGA 16 Color Graphics, text parser/mouse &lt;br /&gt;
| eg: Quest for Glory 2&lt;br /&gt;
|- &lt;br /&gt;
| SCI1 &lt;br /&gt;
| EGA/VGA 256 Graphics, mouse &lt;br /&gt;
| eg: Police Quest 3&lt;br /&gt;
|- &lt;br /&gt;
| SCI1.1 &lt;br /&gt;
| VGA Graphics, mouse &lt;br /&gt;
| eg: Quest for Glory 3&lt;br /&gt;
|- &lt;br /&gt;
| SCI2 &lt;br /&gt;
| SVGA Graphics &lt;br /&gt;
| eg: Space Quest 6&lt;br /&gt;
|}&lt;br /&gt;
{{note|Presently Template Games for SCI0 and SCI1.1 are available.}}&lt;br /&gt;
&lt;br /&gt;
=== [[SCI Studio]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:SCIStudio3SS1.png]]&lt;br /&gt;
&lt;br /&gt;
This is the tool originally created off the back of the efforts of many to &amp;quot;reverse engineer&amp;quot; the SCI format. Although now superseded by SCI Companion, SCI Studio still has many useful tools for editing SCI Resources.&lt;br /&gt;
&lt;br /&gt;
==== Tutorials ====&lt;br /&gt;
&lt;br /&gt;
{{note|The tutorials for SCI Studio are based upon the older &amp;quot;SCI Studio&amp;quot; Script, which has been since superseded by &amp;quot;Sierra Script&amp;quot;. Please refer to the [[scicompdoc:|SCI Companion Documentation]] for more information.}}&lt;br /&gt;
; [[SCI Studio Tutorial 1|Brian Provinciano&amp;#039;s SCI Studio Tutorial 1]]&lt;br /&gt;
:A great place to start for first time users.&lt;br /&gt;
:Takes you through your first game, including how to edit views, pictures, scripts, fonts and vocabulary. Moves on to how to handle player input, create rooms, doors, and inventory items. &lt;br /&gt;
&lt;br /&gt;
; [[SCI Studio Tutorial 2|Brian Provinciano&amp;#039;s SCI Studio Tutorial 2]]&lt;br /&gt;
:A continuation on Tutorial 1, expanding on player input, NPC&amp;#039;s (non-player characters), and customizing the graphical interface.&lt;br /&gt;
&lt;br /&gt;
For more tutorials, refer to [[SCI Tutorials]]&lt;br /&gt;
&lt;br /&gt;
=== [[SCI Companion]] ===&lt;br /&gt;
&lt;br /&gt;
[[Image:SCICompanion3bSS.png]]&lt;br /&gt;
&lt;br /&gt;
SCI Companion is the successor to SCI Studio. It introduces full support for SCI1 (and above) as well as many other features, including a better scripting language, &amp;quot;Sierra Script&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Tutorials ====&lt;br /&gt;
&lt;br /&gt;
A lot of the above SCI Studio tutorials also apply to SCI Companion, as it is compatible with both. However it is recommended you &amp;#039;&amp;#039;convert&amp;#039;&amp;#039; your script format to the superior and easier to use Sierra Script.  The differences are documented in the SCI Companion Documentation [http://scicompanion.com/Documentation/Compiler/differences.html Differences from SCI Studio syntax].&lt;br /&gt;
&lt;br /&gt;
; [[A Basic Tutorial for SCI1.1|A Basic Tutorial for SCI1.1 by Phil Fortier]]&lt;br /&gt;
:This tutorial can also be found on the [http://scicompanion.com/Documentation/sci11_tutorial.html SCI Companion] website. Covers creating your first room, objects, props, inventory, scoring, and adding more rooms.&lt;br /&gt;
&lt;br /&gt;
For more tutorials, refer to [[SCI Tutorials]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Programming SCI Tools ==&lt;br /&gt;
&lt;br /&gt;
An SCI game runs on a Virtual [[wikipedia:Stack Machine|Stack Machine]](wikipedia link). Game Resources are stored in a proprietary archive format, or individually in the game folder as a patch file. &lt;br /&gt;
&lt;br /&gt;
The following information is available on the specifications of SCI.&lt;br /&gt;
&lt;br /&gt;
; [[Official SCI Documentation]]&lt;br /&gt;
: Sierra&amp;#039;s Official Documentation for SCI.&lt;br /&gt;
&lt;br /&gt;
; [[SCI Specifications]]&lt;br /&gt;
: Originally sourced from the now defunct FreeSCI project. Documents the SCI systems and resource formats.&lt;br /&gt;
&lt;br /&gt;
For more documentation refer to [[SCI Documentation]].&lt;br /&gt;
&lt;br /&gt;
== Getting Help ==&lt;br /&gt;
&lt;br /&gt;
The [[Community Portal]] has links to external sources and information about the Wiki. &lt;br /&gt;
&lt;br /&gt;
It also contains a link to the [http://sciprogramming.com/community/ SCI Messageboard] - where you will find other SCI programmers and announcements of new games and software.&lt;/div&gt;</summary>
		<author><name>Rainer De Temple</name></author>
	</entry>
	<entry>
		<id>http://sciwiki.sierrahelp.com/index.php?title=SCI_Tutorials&amp;diff=15204</id>
		<title>SCI Tutorials</title>
		<link rel="alternate" type="text/html" href="http://sciwiki.sierrahelp.com/index.php?title=SCI_Tutorials&amp;diff=15204"/>
		<updated>2020-09-16T06:47:51Z</updated>

		<summary type="html">&lt;p&gt;Rainer De Temple: tidy up, clarification on some things&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;These are the tutorials that we currently have available. They cover a beginner&amp;#039;s getting started level to more advanced topics. &lt;br /&gt;
&lt;br /&gt;
== SCI Tutorials ==&lt;br /&gt;
&lt;br /&gt;
{{note|These tutorials are based upon the older &amp;quot;SCI Studio&amp;quot; Script, which has been since superseded by &amp;quot;Sierra Script&amp;quot;. Please refer to the [[scicompdoc:|SCI Companion Documentation]] for more information.}}&lt;br /&gt;
* [[SCI Studio Tutorial 1|Brian Provinciano&amp;#039;s SCI Studio Tutorial 1]]&lt;br /&gt;
* [[SCI Studio Tutorial 2|Brian Provinciano&amp;#039;s SCI Studio Tutorial 2]]&lt;br /&gt;
* [[Advanced SCI Tutorials|Phil Fortier&amp;#039;s Advanced SCI Tutorials]]&lt;br /&gt;
* [[SCI Point and Click Tutorial|Cloudee1&amp;#039;s SCI Point and Click Tutorial]]&lt;br /&gt;
* [[Adding Sound Support|Brandon Blume&amp;#039;s Adding Sound Support]]&lt;br /&gt;
&lt;br /&gt;
== SCI Companion Tutorials ==&lt;br /&gt;
&lt;br /&gt;
* [[A Basic Tutorial for SCI1.1|A Basic Tutorial for SCI1.1 by Phil Fortier]]&lt;br /&gt;
&lt;br /&gt;
== SCI Documentation == &lt;br /&gt;
&lt;br /&gt;
* [[Official SCI Documentation|Sierra&amp;#039;s Official SCI Documentation]]&lt;br /&gt;
* [http://scicompanion.com/Documentation/index.html SCI Companion Documentation]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- &amp;lt;span style=&amp;quot;float: right&amp;quot;&amp;gt;[[SCI_Studio_Tutorial 1|Next: Brian Provinciano&amp;#039;s SCI Studio Tutorial 1 &amp;amp;gt;]]&amp;lt;/span&amp;gt; --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Rainer De Temple</name></author>
	</entry>
	<entry>
		<id>http://sciwiki.sierrahelp.com/index.php?title=Fan_Release_List&amp;diff=15176</id>
		<title>Fan Release List</title>
		<link rel="alternate" type="text/html" href="http://sciwiki.sierrahelp.com/index.php?title=Fan_Release_List&amp;diff=15176"/>
		<updated>2020-09-09T01:30:41Z</updated>

		<summary type="html">&lt;p&gt;Rainer De Temple: fixed missing redirect&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Fan SCI Release List]]&lt;/div&gt;</summary>
		<author><name>Rainer De Temple</name></author>
	</entry>
	<entry>
		<id>http://sciwiki.sierrahelp.com/index.php?title=SCI_Studio_Tutorial_2&amp;diff=15175</id>
		<title>SCI Studio Tutorial 2</title>
		<link rel="alternate" type="text/html" href="http://sciwiki.sierrahelp.com/index.php?title=SCI_Studio_Tutorial_2&amp;diff=15175"/>
		<updated>2020-09-09T01:24:12Z</updated>

		<summary type="html">&lt;p&gt;Rainer De Temple: added note about using older script language&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;[[Image:SCI_Studio_Tutorial_Title.gif|align=&amp;quot;center&amp;quot;|Making a Game With SCI Studio ]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;Category&amp;quot;&amp;gt;Volume II&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;By Brian Provinciano&amp;lt;br /&amp;gt;&lt;br /&gt;
Updated March 2nd, 2003&amp;#039;&amp;#039;&amp;#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{note|This tutorial is based upon the older &amp;quot;SCI Studio&amp;quot; Script, which has been since superseded by &amp;quot;Sierra Script&amp;quot;. Please refer to the [[scicompdoc:|SCI Companion Documentation]] for more information.}}&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
There&amp;#039;s so much SCI can do! Much more than could be covered in one tutorial. If the first tutorial covered it all, many would be overwhelmed. Expanding on the first one, this tutorial shows you how to expand your template game to include some more of Sierra&amp;#039;s standard game features. They can be done in any order you like.&lt;br /&gt;
&lt;br /&gt;
==Table of Contents==&lt;br /&gt;
&lt;br /&gt;
===Player Input===&lt;br /&gt;
&lt;br /&gt;
* [[Global Said() Statements|Chapter 1 - Global Said() Statements]]&lt;br /&gt;
** Teaches you how to create said statements which are parsed in every room.&lt;br /&gt;
* [[WordFail, syntaxFail and pragmaFail|Chapter 2 - Oh, yeah? Well, &amp;quot;%s&amp;quot; this!]]&lt;br /&gt;
** Teaches you how to make the parser more intelligent so it will print more than just &amp;quot;I don&amp;#039;t understand the word &amp;amp;lt;&amp;amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Actors===&lt;br /&gt;
&lt;br /&gt;
* [[Actor Paths|Chapter 3 - Making Actors Move Along Paths]]&lt;br /&gt;
** Teaches you how to make actors, such as ego, move along specified paths.&lt;br /&gt;
* [[Actor Event Triggers|Chapter 4 - Moving Actors and Triggering Events]]&lt;br /&gt;
** Teaches you how to move actors, and trigger events as they reach their destination&amp;lt;br /&amp;gt; (prerequisite: &amp;#039;&amp;#039;Making Actors Move Along Paths&amp;#039;&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
===Views/Props===&lt;br /&gt;
&lt;br /&gt;
* [[Actor Paths with Over Views/Props|Chapter 5 - Allowing Actors to Walk Through/Over Views/Props]]&lt;br /&gt;
** Teaches you how to make views and props background objects without actually making them part of the background.&lt;br /&gt;
&lt;br /&gt;
===Doors===&lt;br /&gt;
&lt;br /&gt;
* [[Checking a Door&amp;#039;s State|Chapter 6 - Checking a Door&amp;#039;s State]]&lt;br /&gt;
** Teaches you how to check if a door is open, closed, opening, locked, etc.&lt;br /&gt;
&lt;br /&gt;
===User Interface===&lt;br /&gt;
&lt;br /&gt;
* [[Custom Buttons|Chapter 7 - Creating Custom Buttons]]&lt;br /&gt;
** Teaches you how to create custom buttons from views.&lt;br /&gt;
* [[Custom Windows|Chapter 8 - Creating Custom Windows]]&lt;br /&gt;
** Teaches you how to create custom window frames from views.&lt;br /&gt;
* [[Custom_Slider_Controls|Chapter 9 - Creating Custom Slider Controls]]&lt;br /&gt;
** Teaches you how to create custom slider controls from views.&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;float: left&amp;quot;&amp;gt;[[SCI_Studio_Tutorial 1|&amp;amp;lt; Previous: Brian Provinciano&amp;#039;s SCI Studio Tutorial 1]]&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;float: right&amp;quot;&amp;gt;[[Global Said() Statements|Next: Chapter 1 - Global Said() Statements &amp;amp;gt;]]&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Rainer De Temple</name></author>
	</entry>
	<entry>
		<id>http://sciwiki.sierrahelp.com/index.php?title=SCI_Studio_Tutorial_1&amp;diff=15174</id>
		<title>SCI Studio Tutorial 1</title>
		<link rel="alternate" type="text/html" href="http://sciwiki.sierrahelp.com/index.php?title=SCI_Studio_Tutorial_1&amp;diff=15174"/>
		<updated>2020-09-09T01:22:08Z</updated>

		<summary type="html">&lt;p&gt;Rainer De Temple: added note about using older script language&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;[[Image:SCI_Studio_Tutorial_Title.gif|Making a Game With SCI Studio ]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;Category&amp;quot;&amp;gt;Volume I&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;By Brian Provinciano&amp;lt;br /&amp;gt;&lt;br /&gt;
Updated March 5th, 2003&amp;#039;&amp;#039;&amp;#039;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{note|This tutorial is based upon the older &amp;quot;SCI Studio&amp;quot; Script, which has been since superseded by &amp;quot;Sierra Script&amp;quot;. Please refer to the [[scicompdoc:|SCI Companion Documentation]] for more information.}}&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Have you ever wanted to make an adventure game like Sierra&amp;#039;s King&amp;#039;s Quest, Space Quest, Police Quest, Leisure Suit Larry or Quest for Glory? Well, now you can! With [[SCI Studio]], you can create games using the exact same engine Sierra used!&lt;br /&gt;
&lt;br /&gt;
Since 1988, Sierra has been using the SCI game engine to create countless outstanding games. Through the great efforts of many fans, the SCI game engine has been reverse engineered. With this acquired knowledge, SCI Studio was written, giving you the ability make complete games using Sierra&amp;#039;s original SCI game engine!&lt;br /&gt;
&lt;br /&gt;
====Making The Game====&lt;br /&gt;
&lt;br /&gt;
So you want to make an SCI game, do you? Well this is the place to start! This tutorial will tell you everything you need to know about making an SCI game. It takes you step by step through the whole process of creating a simple game. From managing the game&amp;#039;s files, to creating the graphics, to scripting, it will teach you every aspect of making a adventure game with SCI Studio.&lt;br /&gt;
&lt;br /&gt;
To make an SCI game, you should have some prior programming experience. This tutorial will assume that you have a general grasp in computer programming. You need not be an expert, but should have an idea of how programming generally works (variables, if, else, while, statements, etc.). You should also be familiar with at least one object oriented programming language such as C++, Java or Delphi. This is simply a suggestion, as I have been emailed by many users who had absolutely no prior programming experience, but with this tutorial, were able to create some quite impressive games.&lt;br /&gt;
&lt;br /&gt;
Making an SCI game is not very hard. You essentially just need to draw backgrounds, the characters and animation, and script what should happen when the user enters certain commands, such as &amp;amp;quot;open door&amp;amp;quot;, or &amp;amp;quot;look tree&amp;amp;quot;.&lt;br /&gt;
&lt;br /&gt;
SCI games all begin in SCI Studio...&lt;br /&gt;
&lt;br /&gt;
====Getting Started====&lt;br /&gt;
&lt;br /&gt;
This tutorial takes you through every step of making an SCI game. It is highly recommended that you follow it from beginning to end and don&amp;#039;t skip any steps. If you go through it step by step, you WILL be able to make a complete SCI game when finished. Just remember to follow it&amp;#039;s order, not skip anything, and if you get stumped on something, read it over and over until you understand it.&lt;br /&gt;
&lt;br /&gt;
There are five main sections:&lt;br /&gt;
&lt;br /&gt;
* The &amp;#039;&amp;#039;&amp;#039;Getting Started&amp;#039;&amp;#039;&amp;#039; section gets you familiar with SCI, and starting a new game. &lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;The Basics&amp;#039;&amp;#039;&amp;#039; section teaches you how to edit the graphics and game vocabulary. &lt;br /&gt;
* The &amp;#039;&amp;#039;&amp;#039;Getting Technical &amp;#039;&amp;#039;&amp;#039;section gives you a general overview of theSCI language and syntax. For those of you who know Lisp, or at least one object oriented programming language such as C++, Java or Delphi, you should have no trouble understanding this section. If, however, you have no prior experience, you may find it hard to understand. If you have trouble, just read it over once in it&amp;#039;s entirety and then continue on to the next section. After finishing the Scripting The Game section, you should understand it a lot better. Go back to it, and read it again. You should be set!&lt;br /&gt;
* The &amp;#039;&amp;#039;&amp;#039;Scripting The Game&amp;#039;&amp;#039;&amp;#039; section takes you through every step of making your first game, &amp;amp;quot;Tutorial Quest&amp;amp;quot;! It discusses what you need to do and explains everything you need to know as it arises.&lt;br /&gt;
* The &amp;#039;&amp;#039;&amp;#039;Conclusion&amp;#039;&amp;#039;&amp;#039; section concludes the tutorial giving you information on additional resources to expand your knowledge and get more help on programming SCI games.&lt;br /&gt;
&lt;br /&gt;
Finally, when finished this tutorial, you click on the Volume II link, which will take you to many more tutorials which teach how to do specific tasks such as creating custom buttons and other more advanced topics.&lt;br /&gt;
&lt;br /&gt;
Best of luck!&lt;br /&gt;
&lt;br /&gt;
==Table of Contents==&lt;br /&gt;
&lt;br /&gt;
====Getting Started====&lt;br /&gt;
&lt;br /&gt;
: [[SCI_Studio_Tutorial_Chapter_1_-_An_Introduction_To_SCI_Resources|Chapter &amp;amp;nbsp;&amp;amp;nbsp;1 - An Introduction To SCI Resources]]&lt;br /&gt;
: [[SCI_Studio_Tutorial_Chapter_2_-_Creating_The_Game|Chapter &amp;amp;nbsp;&amp;amp;nbsp;2 - Creating The Game]]&lt;br /&gt;
&lt;br /&gt;
====The Basics====&lt;br /&gt;
&lt;br /&gt;
: [[SCI_Studio_Tutorial_Chapter_3_-_Editing_Views|Chapter &amp;amp;nbsp;&amp;amp;nbsp;3 - Editing Views]]&lt;br /&gt;
: [[SCI_Studio_Tutorial_Chapter_4_-_Editing_Cursors|Chapter &amp;amp;nbsp;&amp;amp;nbsp;4 - Editing Cursors]]&lt;br /&gt;
: [[SCI_Studio_Tutorial_Chapter_5_-_Editing_Fonts|Chapter &amp;amp;nbsp;&amp;amp;nbsp;5 - Editing Fonts]]&lt;br /&gt;
: [[SCI_Studio_Tutorial_Chapter_6_-_Editing_Pics|Chapter &amp;amp;nbsp;&amp;amp;nbsp;6 - Editing Pics]]&lt;br /&gt;
: [[SCI_Studio_Tutorial_Chapter_7_-_Editing_The_Vocabulary|Chapter &amp;amp;nbsp;&amp;amp;nbsp;7 - Editing The Vocabulary]]&lt;br /&gt;
&lt;br /&gt;
====Getting Technical====&lt;br /&gt;
&lt;br /&gt;
: [[SCI_Studio_Tutorial_Chapter_8_-_An_Introduction_To_Scripts|Chapter &amp;amp;nbsp;&amp;amp;nbsp;8 - An Introduction To Scripts]]&lt;br /&gt;
: [[SCI_Studio_Tutorial_Chapter_9_-_Elements_of_a_Script|Chapter &amp;amp;nbsp;&amp;amp;nbsp;9 - Elements of a Script]]&lt;br /&gt;
: [[SCI_Studio_Tutorial_Chapter_10_-_Getting_Familiar_With_Objects|Chapter 10 - Getting Familiar With Objects]]&lt;br /&gt;
: [[SCI_Studio_Tutorial_Chapter_11_-_Variables|Chapter 11 - Variables]]&lt;br /&gt;
: [[SCI_Studio_Tutorial_Chapter_12_-_Methods_and_Procedures|Chapter 12 - Methods and Procedures]]&lt;br /&gt;
: [[SCI_Studio_Tutorial_Chapter_13_-_Conditional_and_Looping_Statements|Chapter 13 - Conditional and Looping Statements]]&lt;br /&gt;
&lt;br /&gt;
====Scripting The Game====&lt;br /&gt;
&lt;br /&gt;
: [[SCI_Studio_Tutorial_Chapter_14_-_Making_The_Title_Screen|Chapter 14 - Making The Title Screen]]&lt;br /&gt;
: [[SCI_Studio_Tutorial_Chapter_15_-_Programming_The_First_Room|Chapter 15 - Programming The First Room]]&lt;br /&gt;
: [[SCI_Studio_Tutorial_Chapter_16_-_Handling_The_Player&amp;#039;s_&amp;amp;quot;Said&amp;amp;quot;_Input|Chapter 16 - Handling The Player&amp;#039;s &amp;amp;quot;Said&amp;amp;quot; Input]]&lt;br /&gt;
: [[SCI_Studio_Tutorial_Chapter_17_-_Creating_and_Using_Props|Chapter 17 - Creating and Using Props]]&lt;br /&gt;
: [[SCI_Studio_Tutorial_Chapter_18_-_Handling_The_Inventory|Chapter 18 - Handling The Inventory]]&lt;br /&gt;
: [[SCI_Studio_Tutorial_Chapter_19_-_Creating_and_Using_Actors|Chapter 19 - Creating and Using Actors]]&lt;br /&gt;
: [[SCI_Studio_Tutorial_Chapter_20_-_Making_An_Additional_Room|Chapter 20 - Making An Additional Room]]&lt;br /&gt;
: [[SCI_Studio_Tutorial_Chapter_21_-_Creating_and_Using_Doors|Chapter 21 - Creating and Using Doors]]&lt;br /&gt;
: [[SCI_Studio_Tutorial_Chapter_22_-_Handling_The_Player&amp;#039;s_Score|Chapter 22 - Handling The Player&amp;#039;s Score]]&lt;br /&gt;
: [[SCI_Studio_Tutorial_Chapter_23_-_Using_The_Death_Handler|Chapter 23 - Using The Death Handler]]&lt;br /&gt;
: [[SCI_Studio_Tutorial_Chapter_24_-_Using_The_Print_Procedures|Chapter 24 - Using The Print Procedures]]&lt;br /&gt;
: [[SCI_Studio_Tutorial_Chapter_25_-_Customizing_The_Menubar|Chapter 25 - Customizing The Menubar]]&lt;br /&gt;
&lt;br /&gt;
====Conclusion====&lt;br /&gt;
&lt;br /&gt;
: [[SCI_Studio_Tutorial_Chapter_26_-_Game_Maintenance|Chapter 26 - Game Maintenance]]&lt;br /&gt;
&amp;lt;!--: [[SCI_Studio_Tutorial_Chapter_27_-_Additional_Resources|Chapter 27 - Additional Resources]]--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;float: left&amp;quot;&amp;gt;[[SCI_Tutorials|&amp;amp;lt; Back to Tutorials Index]]&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;float: right&amp;quot;&amp;gt;[[SCI_Studio_Tutorial_Chapter_1_-_An_Introduction_To_SCI_Resources|Next: Chapter 1 - An Introduction To SCI Resources &amp;amp;gt;]]&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>Rainer De Temple</name></author>
	</entry>
	<entry>
		<id>http://sciwiki.sierrahelp.com/index.php?title=Template:Note&amp;diff=15173</id>
		<title>Template:Note</title>
		<link rel="alternate" type="text/html" href="http://sciwiki.sierrahelp.com/index.php?title=Template:Note&amp;diff=15173"/>
		<updated>2020-09-09T01:18:02Z</updated>

		<summary type="html">&lt;p&gt;Rainer De Temple: Created page with &amp;quot;&amp;lt;noinclude&amp;gt; == Usage == {{Note|Example Text}} Please review the source for this page and copy the above text. &amp;lt;/noinclude&amp;gt;  &amp;lt;includeonly&amp;gt; {| class=&amp;quot;wikitable&amp;quot;  style=&amp;quot; width=&amp;quot;...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&lt;br /&gt;
== Usage ==&lt;br /&gt;
{{Note|Example Text}}&lt;br /&gt;
Please review the source for this page and copy the above text.&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;includeonly&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;  style=&amp;quot; width=&amp;quot;100%&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border: 1px solid #a3caff; background-color: #eaf3ff;&amp;quot; cellspacing=&amp;quot;0&amp;quot; |&amp;#039;&amp;#039;&amp;#039;NOTE:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;{{{1}}}&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rainer De Temple</name></author>
	</entry>
	<entry>
		<id>http://sciwiki.sierrahelp.com/index.php?title=Main_Page&amp;diff=15172</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="http://sciwiki.sierrahelp.com/index.php?title=Main_Page&amp;diff=15172"/>
		<updated>2020-09-09T00:27:29Z</updated>

		<summary type="html">&lt;p&gt;Rainer De Temple: Notes for editors was repeated&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
===Welcome to the SCI Programmers Wiki.===&lt;br /&gt;
&lt;br /&gt;
A Wiki for the SCI Programming Community. SCI is the game engine created by [[Jeff Stephenson]] for [[Sierra On-Line]], which was used between the years of 1989 to 1997. It superseded Sierra&amp;#039;s earlier AGI engine. It was used to create such games as &amp;#039;&amp;#039;[[King&amp;#039;s Quest IV]]&amp;#039;&amp;#039; to VII, &amp;#039;&amp;#039;[[Space Quest III]]&amp;#039;&amp;#039; to &amp;#039;&amp;#039;[[Space Quest 6|6]]&amp;#039;&amp;#039;, &amp;#039;&amp;#039;[[Quest for Glory I]]&amp;#039;&amp;#039; to &amp;#039;&amp;#039;[[Quest for Glory IV|IV]]&amp;#039;&amp;#039; and &amp;#039;&amp;#039;[[Gabriel Knight I]]&amp;#039;&amp;#039; and &amp;#039;&amp;#039;[[Beast Within: A Gabriel Knight Mystery, The|II]]&amp;#039;&amp;#039;. With the availability of such tools as [[SCI Studio|Brian Provinciano&amp;#039;s SCI Studio 3]] and [[SCI Companion|Phil Fortier&amp;#039;s SCI Companion]], you can create your own games based on the same engine that Sierra used. This Wiki is a knowledgebase and collection of resources for those working with SCI. Additional help can always be found on the [[SCIPF:|SCI Programming Community Message Board]]. For help with Sierra&amp;#039;s games, see [[SHP:|The Sierra Help Pages]].&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;br /&amp;gt; News ===&lt;br /&gt;
&lt;br /&gt;
{| width=&amp;quot;100%&amp;quot; cellspacing=&amp;quot;20&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border: 1px solid #C9AE56; background-color: #FFFBED&amp;quot; width=&amp;quot;50%&amp;quot; valign=&amp;quot;top&amp;quot; | &amp;lt;div style=&amp;quot;padding: .4em .9em .9em&amp;quot;&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Feb 07, 2016&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* There is a new version of [[Phil Fortier|Phil Fortier&amp;#039;s]] [[SCI Companion]]. SCI Companion v3 supports development of games from [[Sierra_Release_List#SCI0_.28early.29 | SCI0]] to [[Sierra_Release_List#SCI1.1 | SCI1.1]]. Besides VGA graphics you will now be able to add digital sound effects and lip synced speech to your SCI games.&lt;br /&gt;
&lt;br /&gt;
* [[NSIS Publisher]], SCI Companion&amp;#039;s first plugin has been released. NSIS Publisher allows you to publish your SCI Companion project using the [http://nsis.sourceforge.net/Main_Page Null Soft Install System (NSIS)] and can automatically compile a DOSBox installer for distribution of your game.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;March, 2016&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
* [[SEQTool]], another SCI Companion plugin is under development. This tool is based on [[Kawa|Kawa&amp;#039;s]] [[SeqMaker]], a command line program. With SEQTool you can edit existing [[SEQ Resource|SEQ files]] (used for cut scenes in SCI1 and later Sierra games), create new ones from your own 320px x 200px paletted 8-bit color images, import animated GIFs to SEQ or export frames from SEQ files to individual image files.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;br /&amp;gt; Getting started ===&lt;br /&gt;
&lt;br /&gt;
New here? Please take the time to visit the [[Community Portal]], which contains useful links for SCI and the SCI Wiki. If you are not registered, you may request an account editing privileges. Contact Collector on the [[SCIPF:|SCI Programming Community Message Board]] or [[SHPF:index.php|The Sierra Help Pages Forums]] if you wish to contribute. See [[#How to Contribute|How to Contribute]] below after you have received an account. &amp;lt;!--&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;Didn&amp;#039;t find what you were looking for? Try [[Request article|requesting an article]].&amp;lt;/div&amp;gt;--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;br /&amp;gt; Links ===&lt;br /&gt;
&lt;br /&gt;
Links for additional help and resources for help for your SCI needs.&lt;br /&gt;
&lt;br /&gt;
[http://sciprogramming.com SCI Programming.com] &amp;amp;nbsp; - &amp;amp;nbsp; http://sciprogramming.com&lt;br /&gt;
: [http://sciprogramming.com/community/ SCI Programming.com message boards] &amp;amp;nbsp; - &amp;amp;nbsp; http://sciprogramming.com/community/&lt;br /&gt;
: [http://sciprogramming.com/scitools.php SCI Tools on SCI Programming.com] &amp;amp;nbsp; - &amp;amp;nbsp; http://sciprogramming.com/scitools.php&lt;br /&gt;
: [http://sciprogramming.com/fangames.php SCI fan games] &amp;amp;nbsp; - &amp;amp;nbsp; http://sciprogramming.com/fangames.php&lt;br /&gt;
[[scicomp:|SCI Companion]]&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scicompdoc:|SCI Companion Documentation]]&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;!-- [http://www.mtnphil.com/Games/SCIComp.html SCI Companion] &amp;amp;nbsp; - &amp;amp;nbsp; http://www.mtnphil.com/Games/SCIComp.html&amp;lt;br&amp;gt; --&amp;gt;&lt;br /&gt;
[http://scistudio.sourceforge.net/ SCI Studio on SourceForge] &amp;amp;nbsp; - &amp;amp;nbsp; http://scistudio.sourceforge.net/&amp;lt;br&amp;gt;&lt;br /&gt;
[http://www.sci.sierrahelp.com/Tools/SCITools.html SCI Tools on the Sierra Help Pages] &amp;amp;nbsp; - &amp;amp;nbsp; http://www.sci.sierrahelp.com/Tools/SCITools.html&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;br /&amp;gt; How to Contribute ===&lt;br /&gt;
&lt;br /&gt;
No registration is required to use this Wiki. Anyone can view the various topics and guides on the SCI Wiki. However, to add or edit pages, you must be [[Special:Userlogin|logged in]]. If you are not registered, you may request an account editing privileges. Contact Collector on the [[SCIPF:|SCI Programming Community Message Board]] or [[shp:forums|The Sierra Help Pages Forums]] if you wish to contribute. &lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
No registration is required to use this Wiki, however, you must request an account to view, add or edit pages. Contact Collector on the [[SCIPF:|SCI Programming Community Message Board]] or [[shp:forums|sThe Sierra Help Pages Forums]] * [[shp:forums|The Sierra Help Pages Forums]] if you wish to access.--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
==== Notes for Editors: ====&lt;br /&gt;
&lt;br /&gt;
Please familiarize yourself with [[Help:Contents | MediaWiki formatting]] before adding or editing pages. See the [[Notes_for_Editors|Notes for Editors]] page for SCI Wiki standards and news.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Wiki Help]]&lt;/div&gt;</summary>
		<author><name>Rainer De Temple</name></author>
	</entry>
</feed>