<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multimedia.cx/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Sasuke</id>
	<title>MultimediaWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multimedia.cx/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Sasuke"/>
	<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php/Special:Contributions/Sasuke"/>
	<updated>2026-09-27T17:35:51Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.5</generator>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=SGA&amp;diff=12896</id>
		<title>SGA</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=SGA&amp;diff=12896"/>
		<updated>2010-08-13T02:33:24Z</updated>

		<summary type="html">&lt;p&gt;Sasuke: /* File Format */  Tiny bit of info for audio chunk.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: SGA&lt;br /&gt;
* Samples: [http://samples.mplayerhq.hu/game-formats/segacd/sga/ http://samples.mplayerhq.hu/game-formats/segacd/sga/]&lt;br /&gt;
&lt;br /&gt;
SGA is a multimedia file format commonly used for games on the [[Sega CD]] console system. Early versions of the format store uncompressed video frames. Newer versions use a simple [[LZ]] compression scheme. The final version of the format, used on Sega 32X/CD games use a yet to be determined compression method.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
All multi-byte numbers in a SGA file are big-endian.&lt;br /&gt;
&lt;br /&gt;
Due to using CD storage each chunk is stored using 2048 byte sectors.&lt;br /&gt;
The first sector in the file contains 2048 bytes of data, each subsequent sectors contain a 2 byte header specifying how much of the chunk is left followed by 2046 bytes of data. One item to be aware of is if the value of the header is zero then to skip the next 2046 bytes and check the next header. (I'm presuming this has something to do with padding the CD for faster loading?)&lt;br /&gt;
&lt;br /&gt;
An SGA file does not contain a global header, but has headers for each chunk. Each chunk can contain video or audio. &lt;br /&gt;
Chunk header is 12-bytes&lt;br /&gt;
&lt;br /&gt;
 byte 0     chunk type&lt;br /&gt;
 byte 1     unknown (Presumed to be the stream number)&lt;br /&gt;
 bytes 2-3  payload length &lt;br /&gt;
 bytes 4-7  unknown (time indicator)&lt;br /&gt;
 byte 8     column start (can be ignored since we are not drawing on a 320x224 screen) &lt;br /&gt;
 byte 9     row start (again can be ignored)&lt;br /&gt;
 byte 10    column size&lt;br /&gt;
 byte 11    row size&lt;br /&gt;
 bytes 12.. chunk payload&lt;br /&gt;
&lt;br /&gt;
Bytes 4-5 are presumed to be part of the chunk preamble since the payload length specifies the length of the chunk.&lt;br /&gt;
&lt;br /&gt;
When reading an audio chunk, bytes 8 and 9 represent the frequency counter value of the audio (For the PCM chip on the Sega CD). Bytes 11 and 12 are unknown (Usually 0x01 and 0x00 in Sewer Shark).&lt;br /&gt;
&lt;br /&gt;
== Chunk Types ==&lt;br /&gt;
Some observed chunk types are:&lt;br /&gt;
&lt;br /&gt;
* 0x81: compressed video (Night Trap 32x uses this)&lt;br /&gt;
* 0xC1: uncompressed video (used in Night Trap)&lt;br /&gt;
* 0xC6: compressed video&lt;br /&gt;
* 0xC8: compressed video (used in Sewer Shark)&lt;br /&gt;
* 0xCD: video, perhaps followed by audio&lt;br /&gt;
* 0xCB: video, perhaps in files that are video only&lt;br /&gt;
* 0xA1: audio, sign/magnitude 8-bit PCM&lt;br /&gt;
&lt;br /&gt;
== Uncompressed Video 0xC1 ==&lt;br /&gt;
Genesis Video uses 4-bit(16 color) pixels and upto 4 palettes&lt;br /&gt;
&lt;br /&gt;
Video is made up of tiles. (column * 4 * row * 8) (each byte has 2 pixels)&lt;br /&gt;
Then palette data follows (if there is only 24 bytes then only one palette is used, otherwise there is 4 palettes)&lt;br /&gt;
A palette map follows for videos that use 4 palettes.&lt;br /&gt;
&lt;br /&gt;
== Palette Data ==&lt;br /&gt;
Palettes are stored in an unusual format. As the genesis normally uses either RGB or BGR stored in nibbles (even though only the top 3 bits are used).&lt;br /&gt;
&lt;br /&gt;
bitmap={1,2,4}&lt;br /&gt;
&lt;br /&gt;
 For bit=0 to 2&lt;br /&gt;
    for color=0 to 15&lt;br /&gt;
        red[color]+=Top Most Bit of Data *bitmap[bit]&lt;br /&gt;
    next&lt;br /&gt;
 next&lt;br /&gt;
&lt;br /&gt;
Repeat for green and blue.&lt;br /&gt;
&lt;br /&gt;
== Palette Map ==&lt;br /&gt;
Reading 2 bits for each tile, determines which of the 4 palettes to use.&lt;br /&gt;
&lt;br /&gt;
 For Row=0 to RowMax&lt;br /&gt;
    For Col=0 to ColMax&lt;br /&gt;
        PalMap[Row*ColMax+Col]=Top 2 Bits of data&lt;br /&gt;
    Next&lt;br /&gt;
 Next&lt;br /&gt;
&lt;br /&gt;
When Drawing the Tile you would select the palette based upon Map.        &lt;br /&gt;
&lt;br /&gt;
== Compressed Video 0xC6 ==&lt;br /&gt;
Chunks in this format consist of several 34 byte LZSS blocks. Each block contains a one word (2 bytes) tag of compression flags followed by 16 words of data.&lt;br /&gt;
&lt;br /&gt;
The tag is read in bits, starting with the most significant (left most) bit. For each bit set to 0, there is an uncompressed word literal. For each bit set to 1, the following word is a displacement/length reference in the following format:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;LLLD DDDD DDDD DDDD&lt;br /&gt;
&lt;br /&gt;
L = Amount of words to copy (amount of bytes to copy * 2)&lt;br /&gt;
D = Displacement&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This may be calculated as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;for count = 0 to top 3 bits of LZ word * 2&lt;br /&gt;
   data[current + count] = data[current + count - last 13 bits of LZ word]&lt;br /&gt;
next&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the displacement, unlike the copy amount, is based on &amp;lt;em&amp;gt;bytes&amp;lt;/em&amp;gt;, not words. Also, the displacement does not have to be word aligned.&lt;br /&gt;
&lt;br /&gt;
After the entire tag is read, the next flag block is read, and the process continues. The sequence ends when an reference word's top three bits are all zeros.&lt;br /&gt;
&lt;br /&gt;
== Games Using SGA ==&lt;br /&gt;
* [http://www.mobygames.com/game/sega-cd/double-switch Double Switch]&lt;br /&gt;
&lt;br /&gt;
[[Category:Game Formats]]&lt;/div&gt;</summary>
		<author><name>Sasuke</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=SGA&amp;diff=12895</id>
		<title>SGA</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=SGA&amp;diff=12895"/>
		<updated>2010-08-13T02:22:41Z</updated>

		<summary type="html">&lt;p&gt;Sasuke: /* File Format */  Added info about audio and fixed some typos, etc.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: SGA&lt;br /&gt;
* Samples: [http://samples.mplayerhq.hu/game-formats/segacd/sga/ http://samples.mplayerhq.hu/game-formats/segacd/sga/]&lt;br /&gt;
&lt;br /&gt;
SGA is a multimedia file format commonly used for games on the [[Sega CD]] console system. Early versions of the format store uncompressed video frames. Newer versions use a simple [[LZ]] compression scheme. The final version of the format, used on Sega 32X/CD games use a yet to be determined compression method.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
All multi-byte numbers in a SGA file are big-endian.&lt;br /&gt;
&lt;br /&gt;
Due to using CD storage each chunk is stored using 2048 byte sectors.&lt;br /&gt;
The first sector in the file contains 2048 bytes of data, each subsequent sectors contain a 2 byte header specifying how much of the chunk is left followed by 2046 bytes of data. One item to be aware of is if the value of the header is zero then to skip the next 2046 bytes and check the next header. (I'm presuming this has something to do with padding the CD for faster loading?)&lt;br /&gt;
&lt;br /&gt;
An SGA file does not contain a global header, but has headers for each chunk. Each chunk can contain video or audio. &lt;br /&gt;
Chunk header is 12-bytes&lt;br /&gt;
&lt;br /&gt;
 byte 0     chunk type&lt;br /&gt;
 byte 1     unknown (Presumed to be the stream number)&lt;br /&gt;
 bytes 2-3  payload length &lt;br /&gt;
 bytes 4-7  unknown (time indicator)&lt;br /&gt;
 byte 8     column start (can be ignored since we are not drawing on a 320x224 screen) &lt;br /&gt;
 byte 9     row start (again can be ignored)&lt;br /&gt;
 byte 10    column size&lt;br /&gt;
 byte 11    row size&lt;br /&gt;
 bytes 12.. chunk payload&lt;br /&gt;
&lt;br /&gt;
Bytes 4-5 are presumed to be part of the chunk preamble since the payload length specifies the length of the chunk.&lt;br /&gt;
&lt;br /&gt;
When reading an audio chunk, bytes 8 and 9 represent the frequency counter value of the audio (For the PCM chip on the Sega CD). Bytes 11 and 12 are unknown.&lt;br /&gt;
&lt;br /&gt;
== Chunk Types ==&lt;br /&gt;
Some observed chunk types are:&lt;br /&gt;
&lt;br /&gt;
* 0x81: compressed video (Night Trap 32x uses this)&lt;br /&gt;
* 0xC1: uncompressed video (used in Night Trap)&lt;br /&gt;
* 0xC6: compressed video&lt;br /&gt;
* 0xC8: compressed video (used in Sewer Shark)&lt;br /&gt;
* 0xCD: video, perhaps followed by audio&lt;br /&gt;
* 0xCB: video, perhaps in files that are video only&lt;br /&gt;
* 0xA1: audio, sign/magnitude 8-bit PCM&lt;br /&gt;
&lt;br /&gt;
== Uncompressed Video 0xC1 ==&lt;br /&gt;
Genesis Video uses 4-bit(16 color) pixels and upto 4 palettes&lt;br /&gt;
&lt;br /&gt;
Video is made up of tiles. (column * 4 * row * 8) (each byte has 2 pixels)&lt;br /&gt;
Then palette data follows (if there is only 24 bytes then only one palette is used, otherwise there is 4 palettes)&lt;br /&gt;
A palette map follows for videos that use 4 palettes.&lt;br /&gt;
&lt;br /&gt;
== Palette Data ==&lt;br /&gt;
Palettes are stored in an unusual format. As the genesis normally uses either RGB or BGR stored in nibbles (even though only the top 3 bits are used).&lt;br /&gt;
&lt;br /&gt;
bitmap={1,2,4}&lt;br /&gt;
&lt;br /&gt;
 For bit=0 to 2&lt;br /&gt;
    for color=0 to 15&lt;br /&gt;
        red[color]+=Top Most Bit of Data *bitmap[bit]&lt;br /&gt;
    next&lt;br /&gt;
 next&lt;br /&gt;
&lt;br /&gt;
Repeat for green and blue.&lt;br /&gt;
&lt;br /&gt;
== Palette Map ==&lt;br /&gt;
Reading 2 bits for each tile, determines which of the 4 palettes to use.&lt;br /&gt;
&lt;br /&gt;
 For Row=0 to RowMax&lt;br /&gt;
    For Col=0 to ColMax&lt;br /&gt;
        PalMap[Row*ColMax+Col]=Top 2 Bits of data&lt;br /&gt;
    Next&lt;br /&gt;
 Next&lt;br /&gt;
&lt;br /&gt;
When Drawing the Tile you would select the palette based upon Map.        &lt;br /&gt;
&lt;br /&gt;
== Compressed Video 0xC6 ==&lt;br /&gt;
Chunks in this format consist of several 34 byte LZSS blocks. Each block contains a one word (2 bytes) tag of compression flags followed by 16 words of data.&lt;br /&gt;
&lt;br /&gt;
The tag is read in bits, starting with the most significant (left most) bit. For each bit set to 0, there is an uncompressed word literal. For each bit set to 1, the following word is a displacement/length reference in the following format:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;LLLD DDDD DDDD DDDD&lt;br /&gt;
&lt;br /&gt;
L = Amount of words to copy (amount of bytes to copy * 2)&lt;br /&gt;
D = Displacement&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This may be calculated as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;for count = 0 to top 3 bits of LZ word * 2&lt;br /&gt;
   data[current + count] = data[current + count - last 13 bits of LZ word]&lt;br /&gt;
next&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the displacement, unlike the copy amount, is based on &amp;lt;em&amp;gt;bytes&amp;lt;/em&amp;gt;, not words. Also, the displacement does not have to be word aligned.&lt;br /&gt;
&lt;br /&gt;
After the entire tag is read, the next flag block is read, and the process continues. The sequence ends when an reference word's top three bits are all zeros.&lt;br /&gt;
&lt;br /&gt;
== Games Using SGA ==&lt;br /&gt;
* [http://www.mobygames.com/game/sega-cd/double-switch Double Switch]&lt;br /&gt;
&lt;br /&gt;
[[Category:Game Formats]]&lt;/div&gt;</summary>
		<author><name>Sasuke</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=SGA&amp;diff=12894</id>
		<title>SGA</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=SGA&amp;diff=12894"/>
		<updated>2010-08-12T22:40:18Z</updated>

		<summary type="html">&lt;p&gt;Sasuke: /* Compressed Video 0xC6 */  Polished the SGA compressed chunk section.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: SGA&lt;br /&gt;
* Samples: [http://samples.mplayerhq.hu/game-formats/segacd/sga/ http://samples.mplayerhq.hu/game-formats/segacd/sga/]&lt;br /&gt;
&lt;br /&gt;
SGA is a multimedia file format commonly used for games on the [[Sega CD]] console system. Early versions of the format store uncompressed video frames. Newer versions use a simple [[LZ]] compression scheme. The final version of the format, used on Sega 32X/CD games use a yet to be determined compression method.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
All multi-byte numbers in a SGA file are big-endian.&lt;br /&gt;
&lt;br /&gt;
Due to using CD storage each chunk is stored using 2048 byte sectors.&lt;br /&gt;
The first sector on the disc contains 2048 bytes of data, each subsiquent sectors contain a 2 byte header specifying how much of the chunk is left followed by 2046 bytes of data. One item to be aware of is if the value of the header is zero then to skip the next 2046 bytes and check the next header. (I'm presuming this has something to do with padding the CD for faster loading?)&lt;br /&gt;
&lt;br /&gt;
An SGA file does not contain a global header, but has headers for each chunk. Each chunk can contain video or audio. &lt;br /&gt;
Chunk header is 12-bytes&lt;br /&gt;
&lt;br /&gt;
 byte 0     chunk type&lt;br /&gt;
 byte 1     unknown (always 0)&lt;br /&gt;
 bytes 2-3  payload length &lt;br /&gt;
 bytes 4-7  unknown (time indicator)&lt;br /&gt;
 byte 8     column start (can be ignored since we are not drawing on a 320x224 screen) &lt;br /&gt;
 byte 9     row start (again can be ignored)&lt;br /&gt;
 byte 10    column size&lt;br /&gt;
 byte 11    row size&lt;br /&gt;
 bytes 12.. chunk payload&lt;br /&gt;
&lt;br /&gt;
Bytes 4-5 are presumed to be part of the chunk preamble since the payload length specifies the length of the chunk.&lt;br /&gt;
&lt;br /&gt;
== Chunk Types ==&lt;br /&gt;
Some observed chunk types are:&lt;br /&gt;
&lt;br /&gt;
* 0x81: compressed video (Night Trap 32x uses this)&lt;br /&gt;
* 0xC1: uncompressed video (used in Night Trap)&lt;br /&gt;
* 0xC6: compressed video&lt;br /&gt;
* 0xC8: compressed video (used in Sewer Shark)&lt;br /&gt;
* 0xCD: video, perhaps followed by audio&lt;br /&gt;
* 0xCB: video, perhaps in files that are video only&lt;br /&gt;
* 0xA1: audio, sign/magnitude 8-bit PCM&lt;br /&gt;
&lt;br /&gt;
== Uncompressed Video 0xC1 ==&lt;br /&gt;
Genesis Video uses 4-bit(16 color) pixels and upto 4 palettes&lt;br /&gt;
&lt;br /&gt;
Video is made up of tiles. (column * 4 * row * 8) (each byte has 2 pixels)&lt;br /&gt;
Then palette data follows (if there is only 24 bytes then only one palette is used, otherwise there is 4 palettes)&lt;br /&gt;
A palette map follows for videos that use 4 palettes.&lt;br /&gt;
&lt;br /&gt;
== Palette Data ==&lt;br /&gt;
Palettes are stored in an unusual format. As the genesis normally uses either RGB or BGR stored in nibbles (even though only the top 3 bits are used).&lt;br /&gt;
&lt;br /&gt;
bitmap={1,2,4}&lt;br /&gt;
&lt;br /&gt;
 For bit=0 to 2&lt;br /&gt;
    for color=0 to 15&lt;br /&gt;
        red[color]+=Top Most Bit of Data *bitmap[bit]&lt;br /&gt;
    next&lt;br /&gt;
 next&lt;br /&gt;
&lt;br /&gt;
Repeat for green and blue.&lt;br /&gt;
&lt;br /&gt;
== Palette Map ==&lt;br /&gt;
Reading 2 bits for each tile, determines which of the 4 palettes to use.&lt;br /&gt;
&lt;br /&gt;
 For Row=0 to RowMax&lt;br /&gt;
    For Col=0 to ColMax&lt;br /&gt;
        PalMap[Row*ColMax+Col]=Top 2 Bits of data&lt;br /&gt;
    Next&lt;br /&gt;
 Next&lt;br /&gt;
&lt;br /&gt;
When Drawing the Tile you would select the palette based upon Map.        &lt;br /&gt;
&lt;br /&gt;
== Compressed Video 0xC6 ==&lt;br /&gt;
Chunks in this format consist of several 34 byte LZSS blocks. Each block contains a one word (2 bytes) tag of compression flags followed by 16 words of data.&lt;br /&gt;
&lt;br /&gt;
The tag is read in bits, starting with the most significant (left most) bit. For each bit set to 0, there is an uncompressed word literal. For each bit set to 1, the following word is a displacement/length reference in the following format:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;LLLD DDDD DDDD DDDD&lt;br /&gt;
&lt;br /&gt;
L = Amount of words to copy (amount of bytes to copy * 2)&lt;br /&gt;
D = Displacement&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This may be calculated as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;for count = 0 to top 3 bits of LZ word * 2&lt;br /&gt;
   data[current + count] = data[current + count - last 13 bits of LZ word]&lt;br /&gt;
next&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the displacement, unlike the copy amount, is based on &amp;lt;em&amp;gt;bytes&amp;lt;/em&amp;gt;, not words. Also, the displacement does not have to be word aligned.&lt;br /&gt;
&lt;br /&gt;
After the entire tag is read, the next flag block is read, and the process continues. The sequence ends when an reference word's top three bits are all zeros.&lt;br /&gt;
&lt;br /&gt;
== Games Using SGA ==&lt;br /&gt;
* [http://www.mobygames.com/game/sega-cd/double-switch Double Switch]&lt;br /&gt;
&lt;br /&gt;
[[Category:Game Formats]]&lt;/div&gt;</summary>
		<author><name>Sasuke</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=SGA&amp;diff=12887</id>
		<title>SGA</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=SGA&amp;diff=12887"/>
		<updated>2010-08-02T05:21:39Z</updated>

		<summary type="html">&lt;p&gt;Sasuke: /* Chunk Types */  Added capitalization and Sewer Shark&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: SGA&lt;br /&gt;
* Samples: [http://samples.mplayerhq.hu/game-formats/segacd/sga/ http://samples.mplayerhq.hu/game-formats/segacd/sga/]&lt;br /&gt;
&lt;br /&gt;
SGA is a multimedia file format commonly used for games on the [[Sega CD]] console system. Early versions of the format store uncompressed video frames. Newer versions use a simple [[LZ]] compression scheme. The final version of the format, used on Sega 32X/CD games use a yet to be determined compression method.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
All multi-byte numbers in a SGA file are big-endian.&lt;br /&gt;
&lt;br /&gt;
Due to using CD storage each chunk is stored using 2048 byte sectors.&lt;br /&gt;
The first sector on the disc contains 2048 bytes of data, each subsiquent sectors contain a 2 byte header specifying how much of the chunk is left followed by 2046 bytes of data. One item to be aware of is if the value of the header is zero then to skip the next 2046 bytes and check the next header. (I'm presuming this has something to do with padding the CD for faster loading?)&lt;br /&gt;
&lt;br /&gt;
An SGA file does not contain a global header, but has headers for each chunk. Each chunk can contain video or audio. &lt;br /&gt;
Chunk header is 12-bytes&lt;br /&gt;
&lt;br /&gt;
 byte 0     chunk type&lt;br /&gt;
 byte 1     unknown (always 0)&lt;br /&gt;
 bytes 2-3  payload length &lt;br /&gt;
 bytes 4-7  unknown (time indicator)&lt;br /&gt;
 byte 8     column start (can be ignored since we are not drawing on a 320x224 screen) &lt;br /&gt;
 byte 9     row start (again can be ignored)&lt;br /&gt;
 byte 10    column size&lt;br /&gt;
 byte 11    row size&lt;br /&gt;
 bytes 12.. chunk payload&lt;br /&gt;
&lt;br /&gt;
Bytes 4-5 are presumed to be part of the chunk preamble since the payload length specifies the length of the chunk.&lt;br /&gt;
&lt;br /&gt;
== Chunk Types ==&lt;br /&gt;
Some observed chunk types are:&lt;br /&gt;
&lt;br /&gt;
* 0x81: compressed video (Night Trap 32x uses this)&lt;br /&gt;
* 0xC1: uncompressed video (used in Night Trap)&lt;br /&gt;
* 0xC6: compressed video&lt;br /&gt;
* 0xC8: compressed video (used in Sewer Shark)&lt;br /&gt;
* 0xCD: video, perhaps followed by audio&lt;br /&gt;
* 0xCB: video, perhaps in files that are video only&lt;br /&gt;
* 0xA1: audio, sign/magnitude 8-bit PCM&lt;br /&gt;
&lt;br /&gt;
== Uncompressed Video 0xC1 ==&lt;br /&gt;
Genesis Video uses 4-bit(16 color) pixels and upto 4 palettes&lt;br /&gt;
&lt;br /&gt;
Video is made up of tiles. (column * 4 * row * 8) (each byte has 2 pixels)&lt;br /&gt;
Then palette data follows (if there is only 24 bytes then only one palette is used, otherwise there is 4 palettes)&lt;br /&gt;
A palette map follows for videos that use 4 palettes.&lt;br /&gt;
&lt;br /&gt;
== Palette Data ==&lt;br /&gt;
Palettes are stored in an unusual format. As the genesis normally uses either RGB or BGR stored in nibbles (even though only the top 3 bits are used).&lt;br /&gt;
&lt;br /&gt;
bitmap={1,2,4}&lt;br /&gt;
&lt;br /&gt;
 For bit=0 to 2&lt;br /&gt;
    for color=0 to 15&lt;br /&gt;
        red[color]+=Top Most Bit of Data *bitmap[bit]&lt;br /&gt;
    next&lt;br /&gt;
 next&lt;br /&gt;
&lt;br /&gt;
Repeat for green and blue.&lt;br /&gt;
&lt;br /&gt;
== Palette Map ==&lt;br /&gt;
Reading 2 bits for each tile, determines which of the 4 palettes to use.&lt;br /&gt;
&lt;br /&gt;
 For Row=0 to RowMax&lt;br /&gt;
    For Col=0 to ColMax&lt;br /&gt;
        PalMap[Row*ColMax+Col]=Top 2 Bits of data&lt;br /&gt;
    Next&lt;br /&gt;
 Next&lt;br /&gt;
&lt;br /&gt;
When Drawing the Tile you would select the palette based upon Map.        &lt;br /&gt;
&lt;br /&gt;
== Compressed Video 0xC6 ==&lt;br /&gt;
Chunks in this format consist of several 34 byte blocks. Each block contains one word (2 bytes) of compression flags followed by 16 words of data.&lt;br /&gt;
&lt;br /&gt;
The flag word is read in bits, starting with the most significant bit. If the bit is 0, the next word being read in the data stream is uncompressed. If the bit is one, the next word is an LZ command in the following format:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;CCCD DDDD DDDD DDDD&lt;br /&gt;
&lt;br /&gt;
C = Amount of words to copy&lt;br /&gt;
D = Displacement&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This may be calculated as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;for count = 0 to top 3 bits of LZ word * 2&lt;br /&gt;
   data[current + count] = data[current + count - last 13 bits of LZ word]&lt;br /&gt;
next&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the displacement, unlike the copy ammount, is based on &amp;lt;em&amp;gt;bytes&amp;lt;/em&amp;gt;, not words. Also, the displacement does not have to be word aligned.&lt;br /&gt;
&lt;br /&gt;
After all sixteen bits of flags are read, the next block is read, and the process continues. The sequence ends when an LZ word's top three bits are all zeros.&lt;br /&gt;
&lt;br /&gt;
== Games Using SGA ==&lt;br /&gt;
* [http://www.mobygames.com/game/sega-cd/double-switch Double Switch]&lt;br /&gt;
&lt;br /&gt;
[[Category:Game Formats]]&lt;/div&gt;</summary>
		<author><name>Sasuke</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=SGA&amp;diff=12886</id>
		<title>SGA</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=SGA&amp;diff=12886"/>
		<updated>2010-08-02T05:20:06Z</updated>

		<summary type="html">&lt;p&gt;Sasuke: /* Compressed Video 0xC6 */ More info&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: SGA&lt;br /&gt;
* Samples: [http://samples.mplayerhq.hu/game-formats/segacd/sga/ http://samples.mplayerhq.hu/game-formats/segacd/sga/]&lt;br /&gt;
&lt;br /&gt;
SGA is a multimedia file format commonly used for games on the [[Sega CD]] console system. Early versions of the format store uncompressed video frames. Newer versions use a simple [[LZ]] compression scheme. The final version of the format, used on Sega 32X/CD games use a yet to be determined compression method.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
All multi-byte numbers in a SGA file are big-endian.&lt;br /&gt;
&lt;br /&gt;
Due to using CD storage each chunk is stored using 2048 byte sectors.&lt;br /&gt;
The first sector on the disc contains 2048 bytes of data, each subsiquent sectors contain a 2 byte header specifying how much of the chunk is left followed by 2046 bytes of data. One item to be aware of is if the value of the header is zero then to skip the next 2046 bytes and check the next header. (I'm presuming this has something to do with padding the CD for faster loading?)&lt;br /&gt;
&lt;br /&gt;
An SGA file does not contain a global header, but has headers for each chunk. Each chunk can contain video or audio. &lt;br /&gt;
Chunk header is 12-bytes&lt;br /&gt;
&lt;br /&gt;
 byte 0     chunk type&lt;br /&gt;
 byte 1     unknown (always 0)&lt;br /&gt;
 bytes 2-3  payload length &lt;br /&gt;
 bytes 4-7  unknown (time indicator)&lt;br /&gt;
 byte 8     column start (can be ignored since we are not drawing on a 320x224 screen) &lt;br /&gt;
 byte 9     row start (again can be ignored)&lt;br /&gt;
 byte 10    column size&lt;br /&gt;
 byte 11    row size&lt;br /&gt;
 bytes 12.. chunk payload&lt;br /&gt;
&lt;br /&gt;
Bytes 4-5 are presumed to be part of the chunk preamble since the payload length specifies the length of the chunk.&lt;br /&gt;
&lt;br /&gt;
== Chunk Types ==&lt;br /&gt;
Some observed chunk types are:&lt;br /&gt;
&lt;br /&gt;
* 0x81: compressed video (night trap 32x uses this)&lt;br /&gt;
* 0xC1: uncompressed video (used in night trap)&lt;br /&gt;
* 0xC6: compressed video&lt;br /&gt;
* 0xCD: video, perhaps followed by audio&lt;br /&gt;
* 0xCB: video, perhaps in files that are video only&lt;br /&gt;
* 0xA1: audio, sign/magnitude 8-bit PCM&lt;br /&gt;
&lt;br /&gt;
== Uncompressed Video 0xC1 ==&lt;br /&gt;
Genesis Video uses 4-bit(16 color) pixels and upto 4 palettes&lt;br /&gt;
&lt;br /&gt;
Video is made up of tiles. (column * 4 * row * 8) (each byte has 2 pixels)&lt;br /&gt;
Then palette data follows (if there is only 24 bytes then only one palette is used, otherwise there is 4 palettes)&lt;br /&gt;
A palette map follows for videos that use 4 palettes.&lt;br /&gt;
&lt;br /&gt;
== Palette Data ==&lt;br /&gt;
Palettes are stored in an unusual format. As the genesis normally uses either RGB or BGR stored in nibbles (even though only the top 3 bits are used).&lt;br /&gt;
&lt;br /&gt;
bitmap={1,2,4}&lt;br /&gt;
&lt;br /&gt;
 For bit=0 to 2&lt;br /&gt;
    for color=0 to 15&lt;br /&gt;
        red[color]+=Top Most Bit of Data *bitmap[bit]&lt;br /&gt;
    next&lt;br /&gt;
 next&lt;br /&gt;
&lt;br /&gt;
Repeat for green and blue.&lt;br /&gt;
&lt;br /&gt;
== Palette Map ==&lt;br /&gt;
Reading 2 bits for each tile, determines which of the 4 palettes to use.&lt;br /&gt;
&lt;br /&gt;
 For Row=0 to RowMax&lt;br /&gt;
    For Col=0 to ColMax&lt;br /&gt;
        PalMap[Row*ColMax+Col]=Top 2 Bits of data&lt;br /&gt;
    Next&lt;br /&gt;
 Next&lt;br /&gt;
&lt;br /&gt;
When Drawing the Tile you would select the palette based upon Map.        &lt;br /&gt;
&lt;br /&gt;
== Compressed Video 0xC6 ==&lt;br /&gt;
Chunks in this format consist of several 34 byte blocks. Each block contains one word (2 bytes) of compression flags followed by 16 words of data.&lt;br /&gt;
&lt;br /&gt;
The flag word is read in bits, starting with the most significant bit. If the bit is 0, the next word being read in the data stream is uncompressed. If the bit is one, the next word is an LZ command in the following format:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;CCCD DDDD DDDD DDDD&lt;br /&gt;
&lt;br /&gt;
C = Amount of words to copy&lt;br /&gt;
D = Displacement&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This may be calculated as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;for count = 0 to top 3 bits of LZ word * 2&lt;br /&gt;
   data[current + count] = data[current + count - last 13 bits of LZ word]&lt;br /&gt;
next&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the displacement, unlike the copy ammount, is based on &amp;lt;em&amp;gt;bytes&amp;lt;/em&amp;gt;, not words. Also, the displacement does not have to be word aligned.&lt;br /&gt;
&lt;br /&gt;
After all sixteen bits of flags are read, the next block is read, and the process continues. The sequence ends when an LZ word's top three bits are all zeros.&lt;br /&gt;
&lt;br /&gt;
== Games Using SGA ==&lt;br /&gt;
* [http://www.mobygames.com/game/sega-cd/double-switch Double Switch]&lt;br /&gt;
&lt;br /&gt;
[[Category:Game Formats]]&lt;/div&gt;</summary>
		<author><name>Sasuke</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=SGA&amp;diff=12885</id>
		<title>SGA</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=SGA&amp;diff=12885"/>
		<updated>2010-08-02T05:03:16Z</updated>

		<summary type="html">&lt;p&gt;Sasuke: /* Compressed Video 0xC6 */  Added info on the compressed stream.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* Extension: SGA&lt;br /&gt;
* Samples: [http://samples.mplayerhq.hu/game-formats/segacd/sga/ http://samples.mplayerhq.hu/game-formats/segacd/sga/]&lt;br /&gt;
&lt;br /&gt;
SGA is a multimedia file format commonly used for games on the [[Sega CD]] console system. Early versions of the format store uncompressed video frames. Newer versions use a simple [[LZ]] compression scheme. The final version of the format, used on Sega 32X/CD games use a yet to be determined compression method.&lt;br /&gt;
&lt;br /&gt;
== File Format ==&lt;br /&gt;
All multi-byte numbers in a SGA file are big-endian.&lt;br /&gt;
&lt;br /&gt;
Due to using CD storage each chunk is stored using 2048 byte sectors.&lt;br /&gt;
The first sector on the disc contains 2048 bytes of data, each subsiquent sectors contain a 2 byte header specifying how much of the chunk is left followed by 2046 bytes of data. One item to be aware of is if the value of the header is zero then to skip the next 2046 bytes and check the next header. (I'm presuming this has something to do with padding the CD for faster loading?)&lt;br /&gt;
&lt;br /&gt;
An SGA file does not contain a global header, but has headers for each chunk. Each chunk can contain video or audio. &lt;br /&gt;
Chunk header is 12-bytes&lt;br /&gt;
&lt;br /&gt;
 byte 0     chunk type&lt;br /&gt;
 byte 1     unknown (always 0)&lt;br /&gt;
 bytes 2-3  payload length &lt;br /&gt;
 bytes 4-7  unknown (time indicator)&lt;br /&gt;
 byte 8     column start (can be ignored since we are not drawing on a 320x224 screen) &lt;br /&gt;
 byte 9     row start (again can be ignored)&lt;br /&gt;
 byte 10    column size&lt;br /&gt;
 byte 11    row size&lt;br /&gt;
 bytes 12.. chunk payload&lt;br /&gt;
&lt;br /&gt;
Bytes 4-5 are presumed to be part of the chunk preamble since the payload length specifies the length of the chunk.&lt;br /&gt;
&lt;br /&gt;
== Chunk Types ==&lt;br /&gt;
Some observed chunk types are:&lt;br /&gt;
&lt;br /&gt;
* 0x81: compressed video (night trap 32x uses this)&lt;br /&gt;
* 0xC1: uncompressed video (used in night trap)&lt;br /&gt;
* 0xC6: compressed video&lt;br /&gt;
* 0xCD: video, perhaps followed by audio&lt;br /&gt;
* 0xCB: video, perhaps in files that are video only&lt;br /&gt;
* 0xA1: audio, sign/magnitude 8-bit PCM&lt;br /&gt;
&lt;br /&gt;
== Uncompressed Video 0xC1 ==&lt;br /&gt;
Genesis Video uses 4-bit(16 color) pixels and upto 4 palettes&lt;br /&gt;
&lt;br /&gt;
Video is made up of tiles. (column * 4 * row * 8) (each byte has 2 pixels)&lt;br /&gt;
Then palette data follows (if there is only 24 bytes then only one palette is used, otherwise there is 4 palettes)&lt;br /&gt;
A palette map follows for videos that use 4 palettes.&lt;br /&gt;
&lt;br /&gt;
== Palette Data ==&lt;br /&gt;
Palettes are stored in an unusual format. As the genesis normally uses either RGB or BGR stored in nibbles (even though only the top 3 bits are used).&lt;br /&gt;
&lt;br /&gt;
bitmap={1,2,4}&lt;br /&gt;
&lt;br /&gt;
 For bit=0 to 2&lt;br /&gt;
    for color=0 to 15&lt;br /&gt;
        red[color]+=Top Most Bit of Data *bitmap[bit]&lt;br /&gt;
    next&lt;br /&gt;
 next&lt;br /&gt;
&lt;br /&gt;
Repeat for green and blue.&lt;br /&gt;
&lt;br /&gt;
== Palette Map ==&lt;br /&gt;
Reading 2 bits for each tile, determines which of the 4 palettes to use.&lt;br /&gt;
&lt;br /&gt;
 For Row=0 to RowMax&lt;br /&gt;
    For Col=0 to ColMax&lt;br /&gt;
        PalMap[Row*ColMax+Col]=Top 2 Bits of data&lt;br /&gt;
    Next&lt;br /&gt;
 Next&lt;br /&gt;
&lt;br /&gt;
When Drawing the Tile you would select the palette based upon Map.        &lt;br /&gt;
&lt;br /&gt;
== Compressed Video 0xC6 ==&lt;br /&gt;
Chunks in this format consist of several 34 byte blocks. Each block contains one word (2 bytes) of compression flags followed by 16 words of data.&lt;br /&gt;
&lt;br /&gt;
The flag word is read in bits, starting with the most significant bit. If the bit is 0, the next word being read in the data stream is uncompressed. If the bit is one, the next word is an LZ command in the following format:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;CCCD DDDD DDDD DDDD&lt;br /&gt;
&lt;br /&gt;
C = Amount of words to copy&lt;br /&gt;
D = Displacement&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the displacement does &amp;lt;em&amp;gt;not&amp;lt;/em&amp;gt; have to be word aligned.&lt;br /&gt;
&lt;br /&gt;
After all sixteen bits of flags are read, the next block is read, and the process continues. The sequence ends when an LZ word's top three bits are all zeros.&lt;br /&gt;
&lt;br /&gt;
== Games Using SGA ==&lt;br /&gt;
* [http://www.mobygames.com/game/sega-cd/double-switch Double Switch]&lt;br /&gt;
&lt;br /&gt;
[[Category:Game Formats]]&lt;/div&gt;</summary>
		<author><name>Sasuke</name></author>
	</entry>
</feed>