<?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=Merlix</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=Merlix"/>
	<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php/Special:Contributions/Merlix"/>
	<updated>2026-09-27T17:35:50Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.5</generator>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=SGA&amp;diff=15018</id>
		<title>SGA</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=SGA&amp;diff=15018"/>
		<updated>2014-03-10T23:02:39Z</updated>

		<summary type="html">&lt;p&gt;Merlix: /* File Format */&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;
Chunks are word aligned. Chunk header is 12-bytes&lt;br /&gt;
&lt;br /&gt;
 byte 0     chunk type &lt;br /&gt;
 byte 1     Stream&lt;br /&gt;
 bytes 2-3  payload length &lt;br /&gt;
 bytes 4-7  time indicator&lt;br /&gt;
  non 32x&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;
  32x&lt;br /&gt;
   byte 8     palette start (usually 1)&lt;br /&gt;
   byte 9     palette update size (0 if use existing palette)&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 and Make My Video: INXS but with 3 palettes)&lt;br /&gt;
* 0xC6: compressed video&lt;br /&gt;
* 0xC7: 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;
* 0xE7: compressed video (Used in Make My Video: INXS)&lt;br /&gt;
* 0xE8: compressed video (Used in Ground Zero Texas)&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, 0xC7, 0xC8 ==&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>Merlix</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Talk:SGA&amp;diff=14377</id>
		<title>Talk:SGA</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Talk:SGA&amp;diff=14377"/>
		<updated>2013-03-03T23:11:11Z</updated>

		<summary type="html">&lt;p&gt;Merlix: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===32x File Format===&lt;br /&gt;
&lt;br /&gt;
I disassembled the nt.bin and subload.bin, looks like most of the decoding is done on the 68k side, rather than the sh2 (32x) side.&lt;br /&gt;
&lt;br /&gt;
I will document my curiosities here, for others to read.&lt;br /&gt;
&lt;br /&gt;
==Special Values in decoding==&lt;br /&gt;
If the y tile size is 11 then special values are 01 and 03, otherwise its 04 and 02. Havent found where its used yet. But those values pop up all over the compressed data.&lt;br /&gt;
&lt;br /&gt;
 LAB_0289:&lt;br /&gt;
  move	#$0003,d3		;6390: 363C0003&lt;br /&gt;
  move	#$0001,d4		;6394: 383C0001&lt;br /&gt;
  cmpi.b	#$11,EXT_000D		;6398: 0C390011002018FF&lt;br /&gt;
  beq.s	LAB_028A		;63A0: 6708&lt;br /&gt;
  move	#$0002,d3		;63A2: 363C0002&lt;br /&gt;
  move	#$0004,d4		;63A6: 383C0004&lt;br /&gt;
 LAB_028A:&lt;br /&gt;
  rts				;63AA: 4E75&lt;br /&gt;
&lt;br /&gt;
==Possible code book setup==&lt;br /&gt;
I think this code here is setting up a code book, whats interesting that it seeks to a specific location. Plus there is a specific code book size.&lt;br /&gt;
&lt;br /&gt;
 adda.l	#$00003004,a0		;6010: D1FC00003004&lt;br /&gt;
 movea.l	EXT_016B.w,a1		;6016: 2278AA66&lt;br /&gt;
 adda.l	#$00003020,a1		;601A: D3FC00003020&lt;br /&gt;
 move	#$1800,d0		;6020: 303C1800&lt;br /&gt;
 bsr	LAB_0281		;6024: 610001EC&lt;/div&gt;</summary>
		<author><name>Merlix</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Talk:SGA&amp;diff=14376</id>
		<title>Talk:SGA</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Talk:SGA&amp;diff=14376"/>
		<updated>2013-03-03T22:57:42Z</updated>

		<summary type="html">&lt;p&gt;Merlix: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===32x File Format===&lt;br /&gt;
&lt;br /&gt;
I disassembled the nt.bin and subload.bin, looks like most of the decoding is done on the 68k side, rather than the sh2 (32x) side.&lt;br /&gt;
&lt;br /&gt;
I will document my curiosities here, for others to read.&lt;br /&gt;
&lt;br /&gt;
==Special Values in decoding==&lt;br /&gt;
If the y tile size is 11 then special values are 01 and 03, otherwise its 04 and 02. Havent found where its used yet. But those values pop up all over the compressed data.&lt;br /&gt;
&lt;br /&gt;
 LAB_0289:&lt;br /&gt;
  move	#$0003,d3		;6390: 363C0003&lt;br /&gt;
  move	#$0001,d4		;6394: 383C0001&lt;br /&gt;
  cmpi.b	#$11,EXT_000D		;6398: 0C390011002018FF&lt;br /&gt;
  beq.s	LAB_028A		;63A0: 6708&lt;br /&gt;
  move	#$0002,d3		;63A2: 363C0002&lt;br /&gt;
  move	#$0004,d4		;63A6: 383C0004&lt;br /&gt;
 LAB_028A:&lt;br /&gt;
  rts				;63AA: 4E75&lt;/div&gt;</summary>
		<author><name>Merlix</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=Talk:SGA&amp;diff=14375</id>
		<title>Talk:SGA</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=Talk:SGA&amp;diff=14375"/>
		<updated>2013-03-03T22:57:19Z</updated>

		<summary type="html">&lt;p&gt;Merlix: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===32x File Format===&lt;br /&gt;
&lt;br /&gt;
I disassembled the nt.bin and subload.bin, looks like most of the decoding is done on the 68k side, rather than the sh2 (32x) side.&lt;br /&gt;
&lt;br /&gt;
I will document my curiosities here, for others to read.&lt;br /&gt;
&lt;br /&gt;
==Special Values in decoding==&lt;br /&gt;
If the y tile size is 11 then special values are 01 and 03, otherwise its 04 and 02. Havent found where its used yet. But those values pop up all over the compressed data.&lt;br /&gt;
&lt;br /&gt;
 LAB_0289:&lt;br /&gt;
  move	#$0003,d3		;6390: 363C0003&lt;br /&gt;
  move	#$0001,d4		;6394: 383C0001&lt;br /&gt;
  cmpi.b	#$11,EXT_000D		;6398: 0C390011002018FF&lt;br /&gt;
  beq.s	LAB_028A		;63A0: 6708&lt;br /&gt;
  move	#$0002,d3		;63A2: 363C0002&lt;br /&gt;
  move	#$0004,d4		;63A6: 383C0004&lt;br /&gt;
 LAB_028A:&lt;br /&gt;
  rts				;63AA: 4E75&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Merlix</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=SGA&amp;diff=13397</id>
		<title>SGA</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=SGA&amp;diff=13397"/>
		<updated>2011-04-02T05:25:29Z</updated>

		<summary type="html">&lt;p&gt;Merlix: Added a few more chunk types&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;
Chunks are word aligned. 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 and Make My Video: INXS but with 3 palettes)&lt;br /&gt;
* 0xC6: compressed video&lt;br /&gt;
* 0xC7: 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;
* 0xE7: compressed video (Used in Make My Video: INXS)&lt;br /&gt;
* 0xE8: compressed video (Used in Ground Zero Texas)&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, 0xC7, 0xC8 ==&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>Merlix</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=SGA&amp;diff=9446</id>
		<title>SGA</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=SGA&amp;diff=9446"/>
		<updated>2008-02-09T00:58:54Z</updated>

		<summary type="html">&lt;p&gt;Merlix: Fixed Header Info and a Typo&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;
&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>Merlix</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=SGA&amp;diff=8333</id>
		<title>SGA</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=SGA&amp;diff=8333"/>
		<updated>2007-08-28T02:53:54Z</updated>

		<summary type="html">&lt;p&gt;Merlix: &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 rather common file format for games on the Sega CD console system. Early version used uncompressed frames, newer version use a simple LZ compression scheme, whilst that last 32x version uses 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;
Due to using CD storage each chunk is stored using 2048 byte sectors.&lt;br /&gt;
The data payload is the first 2046 bytes, with the last 2 being an integer specifying how much of the chunk is left. One item to be aware of is if the value is zero then to skip the next sector and check the next one. (I'm presuming this has something to do with padding the CD for faster loading?)&lt;br /&gt;
&lt;br /&gt;
A SGA doesnt 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 0xC6 ==&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 an 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;
&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>Merlix</name></author>
	</entry>
	<entry>
		<id>https://wiki.multimedia.cx/index.php?title=SGA&amp;diff=8332</id>
		<title>SGA</title>
		<link rel="alternate" type="text/html" href="https://wiki.multimedia.cx/index.php?title=SGA&amp;diff=8332"/>
		<updated>2007-08-28T02:52:15Z</updated>

		<summary type="html">&lt;p&gt;Merlix: &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 rather common file format for games on the Sega CD console system. Early version used uncompressed frames, newer version use a simple LZ compression scheme, whilst that last 32x version uses 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;
Due to using CD storage each chunk is stored using 2048 byte sectors.&lt;br /&gt;
The data payload is the first 2046 bytes, with the last 2 being an integer specifying how much of the chunk is left. One item to be aware of is if the value is zero then to skip the next sector and check the next one. (I'm presuming this has something to do with padding the CD for faster loading?)&lt;br /&gt;
&lt;br /&gt;
A SGA doesnt 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 0xC6 ==&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 an 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;
&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>Merlix</name></author>
	</entry>
</feed>