<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://moddingwiki.shikadi.net/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Zab</id>
	<title>ModdingWiki - User contributions [en-gb]</title>
	<link rel="self" type="application/atom+xml" href="https://moddingwiki.shikadi.net/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Zab"/>
	<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/wiki/Special:Contributions/Zab"/>
	<updated>2026-05-14T06:33:01Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.11</generator>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=RES_Format_(Stellar_7)&amp;diff=3961</id>
		<title>RES Format (Stellar 7)</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=RES_Format_(Stellar_7)&amp;diff=3961"/>
		<updated>2012-04-03T04:04:34Z</updated>

		<summary type="html">&lt;p&gt;Zab: /* BMP: Image */ Added better information about the INF slice guides.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NeedMoreInfo}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;RES format&#039;&#039;&#039; is used by [[Stellar 7]] to store much of the game data. The PC version has 29 files using this format.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
&lt;br /&gt;
It is a binary format containing any number of &#039;&#039;entries&#039;&#039; which themselves can contain other entries. Various items are stored in these files, such as compressed images and palette data, or the mission briefing text. The entries begin with a content type which can be clearly read even with a text editor.&lt;br /&gt;
&lt;br /&gt;
=== Signature ===&lt;br /&gt;
&lt;br /&gt;
There is no known signature, other than carefully reading the file structure and verifying it seems correct (e.g. offsets don&#039;t go past the end of the file.)&lt;br /&gt;
&lt;br /&gt;
=== File entry ===&lt;br /&gt;
&lt;br /&gt;
The file consists of one or more file entries, one after the other.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|char contentType[4]||Content type (see below), not null-terminated&lt;br /&gt;
|-&lt;br /&gt;
|UINT32LE isfolder_length||Length of the data, most significant bit is folder bit&lt;br /&gt;
|-&lt;br /&gt;
|BYTE data[length]||&amp;lt;tt&amp;gt;length&amp;lt;/tt&amp;gt; bytes of data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If the most significant bit in &amp;lt;tt&amp;gt;isfolder_length&amp;lt;/tt&amp;gt; is set, the &amp;lt;tt&amp;gt;data&amp;lt;/tt&amp;gt; is comprised of more file entries in the same format as above, like a subdirectory. None of the game&#039;s data files appear to nest folders more than one level deep. The values can be extracted like this:&lt;br /&gt;
&lt;br /&gt;
  length = isfolder_length &amp;amp; 0x7FFFFFFF&lt;br /&gt;
  if (isfolder_length &amp;amp; 0x80000000) then it is a folder&lt;br /&gt;
&lt;br /&gt;
=== Content types ===&lt;br /&gt;
&lt;br /&gt;
The following values for contentType are known.  Any types that refer to sub-blocks mean &amp;quot;files&amp;quot; in the &amp;quot;subdirectory&amp;quot; as described above.&lt;br /&gt;
&lt;br /&gt;
==== BMP: Image ====&lt;br /&gt;
&lt;br /&gt;
The game supports VGA and earlier modes including EGA and CGA. The main palette information for VGA is located in the file &amp;lt;tt&amp;gt;STELART.RES&amp;lt;/tt&amp;gt; while the EGA/CGA palettes are in &amp;lt;tt&amp;gt;STELARTE.RES&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|INF:||Slice guides for the bitmap. See below.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some BMP: entries contain an INF: tag which appears to be layout guides for the image.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|UINT16LE pair_count||Number of size pairs to read&lt;br /&gt;
|-&lt;br /&gt;
|UINT16LE[2 * pair_count]||Sizes; stored with the width values first followed by the height values.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The sizes correspond to the image data. In &amp;lt;tt&amp;gt;LEVEL1.RES&amp;lt;/tt&amp;gt; there are five size pairs: &lt;br /&gt;
&lt;br /&gt;
 (256,16) (256,16) (256,16) (256,16) (32,27)&lt;br /&gt;
&lt;br /&gt;
These are combined with two images of 8,624 bytes each for a total of 17,248 bytes. If you multiply out these size pairs and add the results they should come up to the same number of bytes, as VGA palettes have a 1:1 pixel-to-byte ratio.&lt;br /&gt;
&lt;br /&gt;
==== FNT: Font ====&lt;br /&gt;
&lt;br /&gt;
There are two FNT: blocks in &amp;lt;tt&amp;gt;STELLAR.RES&amp;lt;/tt&amp;gt;. They are both uncompressed in one of two formats; hints about these formats was found at the [http://code.google.com/p/scummvm-dgds/source/browse/trunk/resources/font.cpp?r=26 ScummVM-DGDS Project]. Over there they are known as &#039;&#039;simple&#039;&#039; and &#039;&#039;complex&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The structure of these fonts are:&lt;br /&gt;
&lt;br /&gt;
===== Simple Font =====&lt;br /&gt;
&lt;br /&gt;
Simple fonts are fixed width.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BYTE width||Width of the font in bits and pixels&lt;br /&gt;
|-&lt;br /&gt;
|BYTE height||Height of the font in bits and pixels&lt;br /&gt;
|-&lt;br /&gt;
|BYTE start||First character code in the font file&lt;br /&gt;
|-&lt;br /&gt;
|BYTE count||Number of characters in the font file&lt;br /&gt;
|-&lt;br /&gt;
|BYTE[height*count]||Font data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Therefore, the file size for a simple font would be:&lt;br /&gt;
&lt;br /&gt;
   4 + (height * count)&lt;br /&gt;
&lt;br /&gt;
Typically, the first character code is 0x20 (32). A font with a full uppercase set has a count of at least 0x40 (64) while a font with an upper/lowercase set has a count of at least 0x60 (96).&lt;br /&gt;
&lt;br /&gt;
To find a particular character, look at the following position in the font data:&lt;br /&gt;
&lt;br /&gt;
   (character_code - start) * height&lt;br /&gt;
&lt;br /&gt;
The simple font included in &amp;lt;tt&amp;gt;STELLAR.RES&amp;lt;/tt&amp;gt; has a size of 8x6 pixels and starts at character 0x20. For character code 0x41 (65, letter A) the position would be (0x41 - 0x20) * 0x6 = 0xC6 (196). The data in this location is:&lt;br /&gt;
&lt;br /&gt;
   0x 7c 82 fe 82 82 00&lt;br /&gt;
&lt;br /&gt;
This font is just a basic raster bitmap using 1 bit-per-pixel:&lt;br /&gt;
&lt;br /&gt;
   .11111..&lt;br /&gt;
   1.....1.&lt;br /&gt;
   1111111.&lt;br /&gt;
   1.....1.&lt;br /&gt;
   1.....1.&lt;br /&gt;
   ........&lt;br /&gt;
&lt;br /&gt;
===== Complex Font =====&lt;br /&gt;
&lt;br /&gt;
Complex fonts have varying widths.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BYTE magic||Magic value 0xff&lt;br /&gt;
|-&lt;br /&gt;
|BYTE width||Maximum width of the font in bits and pixels&lt;br /&gt;
|-&lt;br /&gt;
|BYTE height||Height of the font in bits and pixels&lt;br /&gt;
|-&lt;br /&gt;
|BYTE unknown||&lt;br /&gt;
|-&lt;br /&gt;
|BYTE start||First character code in the font file&lt;br /&gt;
|-&lt;br /&gt;
|BYTE count||Number of characters in the font file&lt;br /&gt;
|-&lt;br /&gt;
|UINT16LE size||Size of the font data&lt;br /&gt;
|-&lt;br /&gt;
|BYTE unknown||Compression algorithm? Seems to be 0x02&lt;br /&gt;
|-&lt;br /&gt;
|UINT32LE uncompressed_size||Size of the uncompressed data&lt;br /&gt;
|-&lt;br /&gt;
|BYTE[font_size-13] data||LZW compressed font data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;size&#039;&#039; and &#039;&#039;uncompressed_size&#039;&#039; appear to match. The uncompressed data contains what appears to be the following layout:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|UINT16LE[count] offsets||Positions for the characters in the data stream&lt;br /&gt;
|-&lt;br /&gt;
|BYTE[count] widths||Bit (or pixel) width for each characters&lt;br /&gt;
|-&lt;br /&gt;
|BYTE[uncompressed_size - (3*count)] data||Character data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The complex font in &amp;lt;tt&amp;gt;STELLAR.RES&amp;lt;/tt&amp;gt; appears to have only two characters with widths greater than eight requiring two bytes to be read for each glyph row rather than one. These characters are 0x42 (*) and 0x64 (@).&lt;br /&gt;
&lt;br /&gt;
==== PAL: Palette ====&lt;br /&gt;
&lt;br /&gt;
The PAL: block contains palette data.  It has sub-blocks for different palette types:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|VGA:||[[VGA Palette]] (three byte, 0-63)&lt;br /&gt;
|-&lt;br /&gt;
|EGA:||&lt;br /&gt;
|-&lt;br /&gt;
|CGA:||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== SCR: Fullscreen image ====&lt;br /&gt;
&lt;br /&gt;
Fullscreen images are 320x200 pixels; 32,000 bytes for EGA and 64,000 bytes for VGA.&lt;br /&gt;
&lt;br /&gt;
The VGA files are split into two 32,000 byte &amp;quot;planes&amp;quot; using two pixels per byte. The second plane contains the more significant bits. If the starting bytes of the first plane are 0xFD 0xFF and the second plane are 0x99 0x88 then the first four horizontal pixels are palette entries 0x9F 0x9D 0x8F 0x8F.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BIN:||32000 byte (16-colour EGA / Least significant VGA bits)&lt;br /&gt;
|-&lt;br /&gt;
|VGA:||32000 byte (Most significant VGA bits)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== VER: Version ====&lt;br /&gt;
&lt;br /&gt;
Null terminated version string (e.g. &amp;quot;3.37&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
==== SSM: Sounds and music ====&lt;br /&gt;
&lt;br /&gt;
The SSM: block seems to contain media data in most cases. It has sub-blocks for different media types:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|SNG:||Song?  Seems to be 8-bit unsigned 11025Hz PCM data with an unknown header&lt;br /&gt;
|-&lt;br /&gt;
|SNG:||Song - also can contain raw MIDI data (theme song is in this format)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The file &amp;lt;tt&amp;gt;STELLAR.RES&amp;lt;/tt&amp;gt; contains three SSM: entries; two of them contain SNG: blocks while the third has entries for various sound cards, most likely a version of the theme song in a format suitable for that device.  The content type tags for these are as follows:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|STD:||?&lt;br /&gt;
|-&lt;br /&gt;
|TAN:||Tandy&lt;br /&gt;
|-&lt;br /&gt;
|M32:||Roland?&lt;br /&gt;
|-&lt;br /&gt;
|ADL:||AdLib&lt;br /&gt;
|-&lt;br /&gt;
|SBL:||Sound Blaster&lt;br /&gt;
|-&lt;br /&gt;
|001:||?&lt;br /&gt;
|-&lt;br /&gt;
|002:||?&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Compression ==&lt;br /&gt;
&lt;br /&gt;
Some file entries are compressed using the [[LZW compression|LZW algorithm]]. The entries which are compressed cannot be identified by the 4-byte content type alone, and it is suspected that certain types are always compressed. Those entries that are compressed are in the following layout:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BYTE unknown||Compression algorithm?  Always seems to be 0x02&lt;br /&gt;
|-&lt;br /&gt;
|UINT32LE decompressedSize||Size of data after decompression&lt;br /&gt;
|-&lt;br /&gt;
|BYTE data[]||LZW-compressed data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following content types never seem to be compressed:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|VQT:||&lt;br /&gt;
|-&lt;br /&gt;
|FNT:||&lt;br /&gt;
|-&lt;br /&gt;
|ARR:||&lt;br /&gt;
|-&lt;br /&gt;
|PAG:||&lt;br /&gt;
|-&lt;br /&gt;
|VGA:|| Only if contained within a &#039;&#039;&#039;PAL:&#039;&#039;&#039; folder entry. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The LZW algorithm uses a dynamic bit length, from 9 bits to 12 bits.  Data is split into bytes in little-endian order.  The first codeword is 257, with code 256 reserved to indicate a dictionary reset.&lt;br /&gt;
&lt;br /&gt;
When the dictionary is reset, some bytes in the input data are discarded.  Why this happens is currently unknown.  The number of bytes discarded seems to vary depending on the number of bytes read (perhaps it is aligning to a DWORD boundary?)&lt;br /&gt;
&lt;br /&gt;
There is some [http://code.google.com/p/scummvm-dgds/source/browse/trunk/compression.cpp sample decompression code] for similar games which seems to (mostly) work.&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This file format was reverse engineered by [[User:Malvineous|Malvineous]], with some subformats identified by [[User:Zab|Zab]].  Hints about the compression algorithm were obtained from the ScummVM project.  If you find this information helpful in a project you&#039;re working on, please give credit where credit is due.  (A link back to this wiki would be nice too!)&lt;br /&gt;
&lt;br /&gt;
[[Category:Stellar 7]]&lt;br /&gt;
[[Category:File Formats]]&lt;br /&gt;
[[Category:Group Files]]&lt;br /&gt;
[[Category:Group Files with embedded FAT]]&lt;/div&gt;</summary>
		<author><name>Zab</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=RES_Format_(Stellar_7)&amp;diff=3960</id>
		<title>RES Format (Stellar 7)</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=RES_Format_(Stellar_7)&amp;diff=3960"/>
		<updated>2012-04-03T02:04:24Z</updated>

		<summary type="html">&lt;p&gt;Zab: /* Complex Font */ The shifted byte may have been a bug with the decompression implementation.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NeedMoreInfo}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;RES format&#039;&#039;&#039; is used by [[Stellar 7]] to store much of the game data. The PC version has 29 files using this format.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
&lt;br /&gt;
It is a binary format containing any number of &#039;&#039;entries&#039;&#039; which themselves can contain other entries. Various items are stored in these files, such as compressed images and palette data, or the mission briefing text. The entries begin with a content type which can be clearly read even with a text editor.&lt;br /&gt;
&lt;br /&gt;
=== Signature ===&lt;br /&gt;
&lt;br /&gt;
There is no known signature, other than carefully reading the file structure and verifying it seems correct (e.g. offsets don&#039;t go past the end of the file.)&lt;br /&gt;
&lt;br /&gt;
=== File entry ===&lt;br /&gt;
&lt;br /&gt;
The file consists of one or more file entries, one after the other.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|char contentType[4]||Content type (see below), not null-terminated&lt;br /&gt;
|-&lt;br /&gt;
|UINT32LE isfolder_length||Length of the data, most significant bit is folder bit&lt;br /&gt;
|-&lt;br /&gt;
|BYTE data[length]||&amp;lt;tt&amp;gt;length&amp;lt;/tt&amp;gt; bytes of data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If the most significant bit in &amp;lt;tt&amp;gt;isfolder_length&amp;lt;/tt&amp;gt; is set, the &amp;lt;tt&amp;gt;data&amp;lt;/tt&amp;gt; is comprised of more file entries in the same format as above, like a subdirectory. None of the game&#039;s data files appear to nest folders more than one level deep. The values can be extracted like this:&lt;br /&gt;
&lt;br /&gt;
  length = isfolder_length &amp;amp; 0x7FFFFFFF&lt;br /&gt;
  if (isfolder_length &amp;amp; 0x80000000) then it is a folder&lt;br /&gt;
&lt;br /&gt;
=== Content types ===&lt;br /&gt;
&lt;br /&gt;
The following values for contentType are known.  Any types that refer to sub-blocks mean &amp;quot;files&amp;quot; in the &amp;quot;subdirectory&amp;quot; as described above.&lt;br /&gt;
&lt;br /&gt;
==== BMP: Image ====&lt;br /&gt;
&lt;br /&gt;
The game supports VGA and earlier modes including EGA and CGA. The main palette information for VGA is located in the file &amp;lt;tt&amp;gt;STELART.RES&amp;lt;/tt&amp;gt; while the EGA/CGA palettes are in &amp;lt;tt&amp;gt;STELARTE.RES&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|INF:||Possibly a way to slice up the bitmap. See below.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some BMP: entries contain an INF: tag which appears to be layout guides for the image. The blocks start with a UINT16LE number specifying 1/4th the number of remaining bytes in the entry. These bytes look like they contain pairs of UINT16LE numbers which correspond somewhat to coordinates in the image.&lt;br /&gt;
&lt;br /&gt;
==== FNT: Font ====&lt;br /&gt;
&lt;br /&gt;
There are two FNT: blocks in &amp;lt;tt&amp;gt;STELLAR.RES&amp;lt;/tt&amp;gt;. They are both uncompressed in one of two formats; hints about these formats was found at the [http://code.google.com/p/scummvm-dgds/source/browse/trunk/resources/font.cpp?r=26 ScummVM-DGDS Project]. Over there they are known as &#039;&#039;simple&#039;&#039; and &#039;&#039;complex&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The structure of these fonts are:&lt;br /&gt;
&lt;br /&gt;
===== Simple Font =====&lt;br /&gt;
&lt;br /&gt;
Simple fonts are fixed width.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BYTE width||Width of the font in bits and pixels&lt;br /&gt;
|-&lt;br /&gt;
|BYTE height||Height of the font in bits and pixels&lt;br /&gt;
|-&lt;br /&gt;
|BYTE start||First character code in the font file&lt;br /&gt;
|-&lt;br /&gt;
|BYTE count||Number of characters in the font file&lt;br /&gt;
|-&lt;br /&gt;
|BYTE[height*count]||Font data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Therefore, the file size for a simple font would be:&lt;br /&gt;
&lt;br /&gt;
   4 + (height * count)&lt;br /&gt;
&lt;br /&gt;
Typically, the first character code is 0x20 (32). A font with a full uppercase set has a count of at least 0x40 (64) while a font with an upper/lowercase set has a count of at least 0x60 (96).&lt;br /&gt;
&lt;br /&gt;
To find a particular character, look at the following position in the font data:&lt;br /&gt;
&lt;br /&gt;
   (character_code - start) * height&lt;br /&gt;
&lt;br /&gt;
The simple font included in &amp;lt;tt&amp;gt;STELLAR.RES&amp;lt;/tt&amp;gt; has a size of 8x6 pixels and starts at character 0x20. For character code 0x41 (65, letter A) the position would be (0x41 - 0x20) * 0x6 = 0xC6 (196). The data in this location is:&lt;br /&gt;
&lt;br /&gt;
   0x 7c 82 fe 82 82 00&lt;br /&gt;
&lt;br /&gt;
This font is just a basic raster bitmap using 1 bit-per-pixel:&lt;br /&gt;
&lt;br /&gt;
   .11111..&lt;br /&gt;
   1.....1.&lt;br /&gt;
   1111111.&lt;br /&gt;
   1.....1.&lt;br /&gt;
   1.....1.&lt;br /&gt;
   ........&lt;br /&gt;
&lt;br /&gt;
===== Complex Font =====&lt;br /&gt;
&lt;br /&gt;
Complex fonts have varying widths.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BYTE magic||Magic value 0xff&lt;br /&gt;
|-&lt;br /&gt;
|BYTE width||Maximum width of the font in bits and pixels&lt;br /&gt;
|-&lt;br /&gt;
|BYTE height||Height of the font in bits and pixels&lt;br /&gt;
|-&lt;br /&gt;
|BYTE unknown||&lt;br /&gt;
|-&lt;br /&gt;
|BYTE start||First character code in the font file&lt;br /&gt;
|-&lt;br /&gt;
|BYTE count||Number of characters in the font file&lt;br /&gt;
|-&lt;br /&gt;
|UINT16LE size||Size of the font data&lt;br /&gt;
|-&lt;br /&gt;
|BYTE unknown||Compression algorithm? Seems to be 0x02&lt;br /&gt;
|-&lt;br /&gt;
|UINT32LE uncompressed_size||Size of the uncompressed data&lt;br /&gt;
|-&lt;br /&gt;
|BYTE[font_size-13] data||LZW compressed font data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;size&#039;&#039; and &#039;&#039;uncompressed_size&#039;&#039; appear to match. The uncompressed data contains what appears to be the following layout:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|UINT16LE[count] offsets||Positions for the characters in the data stream&lt;br /&gt;
|-&lt;br /&gt;
|BYTE[count] widths||Bit (or pixel) width for each characters&lt;br /&gt;
|-&lt;br /&gt;
|BYTE[uncompressed_size - (3*count)] data||Character data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The complex font in &amp;lt;tt&amp;gt;STELLAR.RES&amp;lt;/tt&amp;gt; appears to have only two characters with widths greater than eight requiring two bytes to be read for each glyph row rather than one. These characters are 0x42 (*) and 0x64 (@).&lt;br /&gt;
&lt;br /&gt;
==== PAL: Palette ====&lt;br /&gt;
&lt;br /&gt;
The PAL: block contains palette data.  It has sub-blocks for different palette types:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|VGA:||[[VGA Palette]] (three byte, 0-63)&lt;br /&gt;
|-&lt;br /&gt;
|EGA:||&lt;br /&gt;
|-&lt;br /&gt;
|CGA:||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== SCR: Fullscreen image ====&lt;br /&gt;
&lt;br /&gt;
Fullscreen images are 320x200 pixels; 32,000 bytes for EGA and 64,000 bytes for VGA.&lt;br /&gt;
&lt;br /&gt;
The VGA files are split into two 32,000 byte &amp;quot;planes&amp;quot; using two pixels per byte. The second plane contains the more significant bits. If the starting bytes of the first plane are 0xFD 0xFF and the second plane are 0x99 0x88 then the first four horizontal pixels are palette entries 0x9F 0x9D 0x8F 0x8F.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BIN:||32000 byte (16-colour EGA / Least significant VGA bits)&lt;br /&gt;
|-&lt;br /&gt;
|VGA:||32000 byte (Most significant VGA bits)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== VER: Version ====&lt;br /&gt;
&lt;br /&gt;
Null terminated version string (e.g. &amp;quot;3.37&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
==== SSM: Sounds and music ====&lt;br /&gt;
&lt;br /&gt;
The SSM: block seems to contain media data in most cases. It has sub-blocks for different media types:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|SNG:||Song?  Seems to be 8-bit unsigned 11025Hz PCM data with an unknown header&lt;br /&gt;
|-&lt;br /&gt;
|SNG:||Song - also can contain raw MIDI data (theme song is in this format)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The file &amp;lt;tt&amp;gt;STELLAR.RES&amp;lt;/tt&amp;gt; contains three SSM: entries; two of them contain SNG: blocks while the third has entries for various sound cards, most likely a version of the theme song in a format suitable for that device.  The content type tags for these are as follows:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|STD:||?&lt;br /&gt;
|-&lt;br /&gt;
|TAN:||Tandy&lt;br /&gt;
|-&lt;br /&gt;
|M32:||Roland?&lt;br /&gt;
|-&lt;br /&gt;
|ADL:||AdLib&lt;br /&gt;
|-&lt;br /&gt;
|SBL:||Sound Blaster&lt;br /&gt;
|-&lt;br /&gt;
|001:||?&lt;br /&gt;
|-&lt;br /&gt;
|002:||?&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Compression ==&lt;br /&gt;
&lt;br /&gt;
Some file entries are compressed using the [[LZW compression|LZW algorithm]]. The entries which are compressed cannot be identified by the 4-byte content type alone, and it is suspected that certain types are always compressed. Those entries that are compressed are in the following layout:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BYTE unknown||Compression algorithm?  Always seems to be 0x02&lt;br /&gt;
|-&lt;br /&gt;
|UINT32LE decompressedSize||Size of data after decompression&lt;br /&gt;
|-&lt;br /&gt;
|BYTE data[]||LZW-compressed data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following content types never seem to be compressed:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|VQT:||&lt;br /&gt;
|-&lt;br /&gt;
|FNT:||&lt;br /&gt;
|-&lt;br /&gt;
|ARR:||&lt;br /&gt;
|-&lt;br /&gt;
|PAG:||&lt;br /&gt;
|-&lt;br /&gt;
|VGA:|| Only if contained within a &#039;&#039;&#039;PAL:&#039;&#039;&#039; folder entry. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The LZW algorithm uses a dynamic bit length, from 9 bits to 12 bits.  Data is split into bytes in little-endian order.  The first codeword is 257, with code 256 reserved to indicate a dictionary reset.&lt;br /&gt;
&lt;br /&gt;
When the dictionary is reset, some bytes in the input data are discarded.  Why this happens is currently unknown.  The number of bytes discarded seems to vary depending on the number of bytes read (perhaps it is aligning to a DWORD boundary?)&lt;br /&gt;
&lt;br /&gt;
There is some [http://code.google.com/p/scummvm-dgds/source/browse/trunk/compression.cpp sample decompression code] for similar games which seems to (mostly) work.&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This file format was reverse engineered by [[User:Malvineous|Malvineous]], with some subformats identified by [[User:Zab|Zab]].  Hints about the compression algorithm were obtained from the ScummVM project.  If you find this information helpful in a project you&#039;re working on, please give credit where credit is due.  (A link back to this wiki would be nice too!)&lt;br /&gt;
&lt;br /&gt;
[[Category:Stellar 7]]&lt;br /&gt;
[[Category:File Formats]]&lt;br /&gt;
[[Category:Group Files]]&lt;br /&gt;
[[Category:Group Files with embedded FAT]]&lt;/div&gt;</summary>
		<author><name>Zab</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=RES_Format_(Stellar_7)&amp;diff=3955</id>
		<title>RES Format (Stellar 7)</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=RES_Format_(Stellar_7)&amp;diff=3955"/>
		<updated>2012-03-28T09:47:38Z</updated>

		<summary type="html">&lt;p&gt;Zab: /* Complex Font */ Added some remaining info on the complex font. I have some more work to do on why the uncompressed font appears to be shifted a byte.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NeedMoreInfo}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;RES format&#039;&#039;&#039; is used by [[Stellar 7]] to store much of the game data. The PC version has 29 files using this format.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
&lt;br /&gt;
It is a binary format containing any number of &#039;&#039;entries&#039;&#039; which themselves can contain other entries. Various items are stored in these files, such as compressed images and palette data, or the mission briefing text. The entries begin with a content type which can be clearly read even with a text editor.&lt;br /&gt;
&lt;br /&gt;
=== Signature ===&lt;br /&gt;
&lt;br /&gt;
There is no known signature, other than carefully reading the file structure and verifying it seems correct (e.g. offsets don&#039;t go past the end of the file.)&lt;br /&gt;
&lt;br /&gt;
=== File entry ===&lt;br /&gt;
&lt;br /&gt;
The file consists of one or more file entries, one after the other.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|char contentType[4]||Content type (see below), not null-terminated&lt;br /&gt;
|-&lt;br /&gt;
|UINT32LE isfolder_length||Length of the data, most significant bit is folder bit&lt;br /&gt;
|-&lt;br /&gt;
|BYTE data[length]||&amp;lt;tt&amp;gt;length&amp;lt;/tt&amp;gt; bytes of data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If the most significant bit in &amp;lt;tt&amp;gt;isfolder_length&amp;lt;/tt&amp;gt; is set, the &amp;lt;tt&amp;gt;data&amp;lt;/tt&amp;gt; is comprised of more file entries in the same format as above, like a subdirectory. None of the game&#039;s data files appear to nest folders more than one level deep. The values can be extracted like this:&lt;br /&gt;
&lt;br /&gt;
  length = isfolder_length &amp;amp; 0x7FFFFFFF&lt;br /&gt;
  if (isfolder_length &amp;amp; 0x80000000) then it is a folder&lt;br /&gt;
&lt;br /&gt;
=== Content types ===&lt;br /&gt;
&lt;br /&gt;
The following values for contentType are known.  Any types that refer to sub-blocks mean &amp;quot;files&amp;quot; in the &amp;quot;subdirectory&amp;quot; as described above.&lt;br /&gt;
&lt;br /&gt;
==== BMP: Image ====&lt;br /&gt;
&lt;br /&gt;
The game supports VGA and earlier modes including EGA and CGA. The main palette information for VGA is located in the file &amp;lt;tt&amp;gt;STELART.RES&amp;lt;/tt&amp;gt; while the EGA/CGA palettes are in &amp;lt;tt&amp;gt;STELARTE.RES&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|INF:||Possibly a way to slice up the bitmap. See below.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some BMP: entries contain an INF: tag which appears to be layout guides for the image. The blocks start with a UINT16LE number specifying 1/4th the number of remaining bytes in the entry. These bytes look like they contain pairs of UINT16LE numbers which correspond somewhat to coordinates in the image.&lt;br /&gt;
&lt;br /&gt;
==== FNT: Font ====&lt;br /&gt;
&lt;br /&gt;
There are two FNT: blocks in &amp;lt;tt&amp;gt;STELLAR.RES&amp;lt;/tt&amp;gt;. They are both uncompressed in one of two formats; hints about these formats was found at the [http://code.google.com/p/scummvm-dgds/source/browse/trunk/resources/font.cpp?r=26 ScummVM-DGDS Project]. Over there they are known as &#039;&#039;simple&#039;&#039; and &#039;&#039;complex&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The structure of these fonts are:&lt;br /&gt;
&lt;br /&gt;
===== Simple Font =====&lt;br /&gt;
&lt;br /&gt;
Simple fonts are fixed width.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BYTE width||Width of the font in bits and pixels&lt;br /&gt;
|-&lt;br /&gt;
|BYTE height||Height of the font in bits and pixels&lt;br /&gt;
|-&lt;br /&gt;
|BYTE start||First character code in the font file&lt;br /&gt;
|-&lt;br /&gt;
|BYTE count||Number of characters in the font file&lt;br /&gt;
|-&lt;br /&gt;
|BYTE[height*count]||Font data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Therefore, the file size for a simple font would be:&lt;br /&gt;
&lt;br /&gt;
   4 + (height * count)&lt;br /&gt;
&lt;br /&gt;
Typically, the first character code is 0x20 (32). A font with a full uppercase set has a count of at least 0x40 (64) while a font with an upper/lowercase set has a count of at least 0x60 (96).&lt;br /&gt;
&lt;br /&gt;
To find a particular character, look at the following position in the font data:&lt;br /&gt;
&lt;br /&gt;
   (character_code - start) * height&lt;br /&gt;
&lt;br /&gt;
The simple font included in &amp;lt;tt&amp;gt;STELLAR.RES&amp;lt;/tt&amp;gt; has a size of 8x6 pixels and starts at character 0x20. For character code 0x41 (65, letter A) the position would be (0x41 - 0x20) * 0x6 = 0xC6 (196). The data in this location is:&lt;br /&gt;
&lt;br /&gt;
   0x 7c 82 fe 82 82 00&lt;br /&gt;
&lt;br /&gt;
This font is just a basic raster bitmap using 1 bit-per-pixel:&lt;br /&gt;
&lt;br /&gt;
   .11111..&lt;br /&gt;
   1.....1.&lt;br /&gt;
   1111111.&lt;br /&gt;
   1.....1.&lt;br /&gt;
   1.....1.&lt;br /&gt;
   ........&lt;br /&gt;
&lt;br /&gt;
===== Complex Font =====&lt;br /&gt;
&lt;br /&gt;
Complex fonts have varying widths.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BYTE magic||Magic value 0xff&lt;br /&gt;
|-&lt;br /&gt;
|BYTE width||Maximum width of the font in bits and pixels&lt;br /&gt;
|-&lt;br /&gt;
|BYTE height||Height of the font in bits and pixels&lt;br /&gt;
|-&lt;br /&gt;
|BYTE unknown||&lt;br /&gt;
|-&lt;br /&gt;
|BYTE start||First character code in the font file&lt;br /&gt;
|-&lt;br /&gt;
|BYTE count||Number of characters in the font file&lt;br /&gt;
|-&lt;br /&gt;
|UINT16LE size||Size of the font data&lt;br /&gt;
|-&lt;br /&gt;
|BYTE unknown||Compression algorithm? Seems to be 0x02&lt;br /&gt;
|-&lt;br /&gt;
|UINT32LE uncompressed_size||Size of the uncompressed data&lt;br /&gt;
|-&lt;br /&gt;
|BYTE[font_size-13] data||LZW compressed font data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;size&#039;&#039; and &#039;&#039;uncompressed_size&#039;&#039; appear to match. The uncompressed data contains what appears to be the following layout:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|UINT16LE[count] offsets||Positions for the characters in the data stream&lt;br /&gt;
|-&lt;br /&gt;
|BYTE[count] widths||Bit (or pixel) width for each characters&lt;br /&gt;
|-&lt;br /&gt;
|BYTE[uncompressed_size - (3*count)] data||Character data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The complex font in &amp;lt;tt&amp;gt;STELLAR.RES&amp;lt;/tt&amp;gt; appears to be missing the first byte, which would be 0x00 to coincide with the offsets to follow. The last may be redundant. Only two characters have widths greater than 8 requiring two bytes to be read for each glyph row rather than one. These characters are 0x42 (*) and 0x64 (@).&lt;br /&gt;
&lt;br /&gt;
==== PAL: Palette ====&lt;br /&gt;
&lt;br /&gt;
The PAL: block contains palette data.  It has sub-blocks for different palette types:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|VGA:||[[VGA Palette]] (three byte, 0-63)&lt;br /&gt;
|-&lt;br /&gt;
|EGA:||&lt;br /&gt;
|-&lt;br /&gt;
|CGA:||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== SCR: Fullscreen image ====&lt;br /&gt;
&lt;br /&gt;
Fullscreen images are 320x200 pixels; 32,000 bytes for EGA and 64,000 bytes for VGA.&lt;br /&gt;
&lt;br /&gt;
The VGA files are split into two 32,000 byte &amp;quot;planes&amp;quot; using two pixels per byte. The second plane contains the more significant bits. If the starting bytes of the first plane are 0xFD 0xFF and the second plane are 0x99 0x88 then the first four horizontal pixels are palette entries 0x9F 0x9D 0x8F 0x8F.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BIN:||32000 byte (16-colour EGA / Least significant VGA bits)&lt;br /&gt;
|-&lt;br /&gt;
|VGA:||32000 byte (Most significant VGA bits)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== VER: Version ====&lt;br /&gt;
&lt;br /&gt;
Null terminated version string (e.g. &amp;quot;3.37&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
==== SSM: Sounds and music ====&lt;br /&gt;
&lt;br /&gt;
The SSM: block seems to contain media data in most cases. It has sub-blocks for different media types:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|SNG:||Song?  Seems to be 8-bit unsigned 11025Hz PCM data with an unknown header&lt;br /&gt;
|-&lt;br /&gt;
|SNG:||Song - also can contain raw MIDI data (theme song is in this format)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The file &amp;lt;tt&amp;gt;STELLAR.RES&amp;lt;/tt&amp;gt; contains three SSM: entries; two of them contain SNG: blocks while the third has entries for various sound cards, most likely a version of the theme song in a format suitable for that device.  The content type tags for these are as follows:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|STD:||?&lt;br /&gt;
|-&lt;br /&gt;
|TAN:||Tandy&lt;br /&gt;
|-&lt;br /&gt;
|M32:||Roland?&lt;br /&gt;
|-&lt;br /&gt;
|ADL:||AdLib&lt;br /&gt;
|-&lt;br /&gt;
|SBL:||Sound Blaster&lt;br /&gt;
|-&lt;br /&gt;
|001:||?&lt;br /&gt;
|-&lt;br /&gt;
|002:||?&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Compression ==&lt;br /&gt;
&lt;br /&gt;
Some file entries are compressed using the [[LZW compression|LZW algorithm]]. The entries which are compressed cannot be identified by the 4-byte content type alone, and it is suspected that certain types are always compressed. Those entries that are compressed are in the following layout:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BYTE unknown||Compression algorithm?  Always seems to be 0x02&lt;br /&gt;
|-&lt;br /&gt;
|UINT32LE decompressedSize||Size of data after decompression&lt;br /&gt;
|-&lt;br /&gt;
|BYTE data[]||LZW-compressed data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following content types never seem to be compressed:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|VQT:||&lt;br /&gt;
|-&lt;br /&gt;
|FNT:||&lt;br /&gt;
|-&lt;br /&gt;
|ARR:||&lt;br /&gt;
|-&lt;br /&gt;
|PAG:||&lt;br /&gt;
|-&lt;br /&gt;
|VGA:|| Only if contained within a &#039;&#039;&#039;PAL:&#039;&#039;&#039; folder entry. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The LZW algorithm uses a dynamic bit length, from 9 bits to 12 bits.  Data is split into bytes in little-endian order.  The first codeword is 257, with code 256 reserved to indicate a dictionary reset.&lt;br /&gt;
&lt;br /&gt;
When the dictionary is reset, some bytes in the input data are discarded.  Why this happens is currently unknown.  The number of bytes discarded seems to vary depending on the number of bytes read (perhaps it is aligning to a DWORD boundary?)&lt;br /&gt;
&lt;br /&gt;
There is some [http://code.google.com/p/scummvm-dgds/source/browse/trunk/compression.cpp sample decompression code] for similar games which seems to (mostly) work.&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This file format was reverse engineered by [[User:Malvineous|Malvineous]], with some subformats identified by [[User:Zab|Zab]].  Hints about the compression algorithm were obtained from the ScummVM project.  If you find this information helpful in a project you&#039;re working on, please give credit where credit is due.  (A link back to this wiki would be nice too!)&lt;br /&gt;
&lt;br /&gt;
[[Category:Stellar 7]]&lt;br /&gt;
[[Category:File Formats]]&lt;br /&gt;
[[Category:Group Files]]&lt;br /&gt;
[[Category:Group Files with embedded FAT]]&lt;/div&gt;</summary>
		<author><name>Zab</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=RES_Format_(Stellar_7)&amp;diff=3954</id>
		<title>RES Format (Stellar 7)</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=RES_Format_(Stellar_7)&amp;diff=3954"/>
		<updated>2012-03-28T03:17:02Z</updated>

		<summary type="html">&lt;p&gt;Zab: /* Simple Font */ small wording&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NeedMoreInfo}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;RES format&#039;&#039;&#039; is used by [[Stellar 7]] to store much of the game data. The PC version has 29 files using this format.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
&lt;br /&gt;
It is a binary format containing any number of &#039;&#039;entries&#039;&#039; which themselves can contain other entries. Various items are stored in these files, such as compressed images and palette data, or the mission briefing text. The entries begin with a content type which can be clearly read even with a text editor.&lt;br /&gt;
&lt;br /&gt;
=== Signature ===&lt;br /&gt;
&lt;br /&gt;
There is no known signature, other than carefully reading the file structure and verifying it seems correct (e.g. offsets don&#039;t go past the end of the file.)&lt;br /&gt;
&lt;br /&gt;
=== File entry ===&lt;br /&gt;
&lt;br /&gt;
The file consists of one or more file entries, one after the other.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|char contentType[4]||Content type (see below), not null-terminated&lt;br /&gt;
|-&lt;br /&gt;
|UINT32LE isfolder_length||Length of the data, most significant bit is folder bit&lt;br /&gt;
|-&lt;br /&gt;
|BYTE data[length]||&amp;lt;tt&amp;gt;length&amp;lt;/tt&amp;gt; bytes of data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If the most significant bit in &amp;lt;tt&amp;gt;isfolder_length&amp;lt;/tt&amp;gt; is set, the &amp;lt;tt&amp;gt;data&amp;lt;/tt&amp;gt; is comprised of more file entries in the same format as above, like a subdirectory. None of the game&#039;s data files appear to nest folders more than one level deep. The values can be extracted like this:&lt;br /&gt;
&lt;br /&gt;
  length = isfolder_length &amp;amp; 0x7FFFFFFF&lt;br /&gt;
  if (isfolder_length &amp;amp; 0x80000000) then it is a folder&lt;br /&gt;
&lt;br /&gt;
=== Content types ===&lt;br /&gt;
&lt;br /&gt;
The following values for contentType are known.  Any types that refer to sub-blocks mean &amp;quot;files&amp;quot; in the &amp;quot;subdirectory&amp;quot; as described above.&lt;br /&gt;
&lt;br /&gt;
==== BMP: Image ====&lt;br /&gt;
&lt;br /&gt;
The game supports VGA and earlier modes including EGA and CGA. The main palette information for VGA is located in the file &amp;lt;tt&amp;gt;STELART.RES&amp;lt;/tt&amp;gt; while the EGA/CGA palettes are in &amp;lt;tt&amp;gt;STELARTE.RES&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|INF:||Possibly a way to slice up the bitmap. See below.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some BMP: entries contain an INF: tag which appears to be layout guides for the image. The blocks start with a UINT16LE number specifying 1/4th the number of remaining bytes in the entry. These bytes look like they contain pairs of UINT16LE numbers which correspond somewhat to coordinates in the image.&lt;br /&gt;
&lt;br /&gt;
==== FNT: Font ====&lt;br /&gt;
&lt;br /&gt;
There are two FNT: blocks in &amp;lt;tt&amp;gt;STELLAR.RES&amp;lt;/tt&amp;gt;. They are both uncompressed in one of two formats; hints about these formats was found at the [http://code.google.com/p/scummvm-dgds/source/browse/trunk/resources/font.cpp?r=26 ScummVM-DGDS Project]. Over there they are known as &#039;&#039;simple&#039;&#039; and &#039;&#039;complex&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The structure of these fonts are:&lt;br /&gt;
&lt;br /&gt;
===== Simple Font =====&lt;br /&gt;
&lt;br /&gt;
Simple fonts are fixed width.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BYTE width||Width of the font in bits and pixels&lt;br /&gt;
|-&lt;br /&gt;
|BYTE height||Height of the font in bits and pixels&lt;br /&gt;
|-&lt;br /&gt;
|BYTE start||First character code in the font file&lt;br /&gt;
|-&lt;br /&gt;
|BYTE count||Number of characters in the font file&lt;br /&gt;
|-&lt;br /&gt;
|BYTE[height*count]||Font data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Therefore, the file size for a simple font would be:&lt;br /&gt;
&lt;br /&gt;
   4 + (height * count)&lt;br /&gt;
&lt;br /&gt;
Typically, the first character code is 0x20 (32). A font with a full uppercase set has a count of at least 0x40 (64) while a font with an upper/lowercase set has a count of at least 0x60 (96).&lt;br /&gt;
&lt;br /&gt;
To find a particular character, look at the following position in the font data:&lt;br /&gt;
&lt;br /&gt;
   (character_code - start) * height&lt;br /&gt;
&lt;br /&gt;
The simple font included in &amp;lt;tt&amp;gt;STELLAR.RES&amp;lt;/tt&amp;gt; has a size of 8x6 pixels and starts at character 0x20. For character code 0x41 (65, letter A) the position would be (0x41 - 0x20) * 0x6 = 0xC6 (196). The data in this location is:&lt;br /&gt;
&lt;br /&gt;
   0x 7c 82 fe 82 82 00&lt;br /&gt;
&lt;br /&gt;
This font is just a basic raster bitmap using 1 bit-per-pixel:&lt;br /&gt;
&lt;br /&gt;
   .11111..&lt;br /&gt;
   1.....1.&lt;br /&gt;
   1111111.&lt;br /&gt;
   1.....1.&lt;br /&gt;
   1.....1.&lt;br /&gt;
   ........&lt;br /&gt;
&lt;br /&gt;
===== Complex Font =====&lt;br /&gt;
&lt;br /&gt;
Complex fonts have varying widths, though the limit seems to be 8.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BYTE magic||Magic value 0xff&lt;br /&gt;
|-&lt;br /&gt;
|BYTE width||Width of the font in bits and pixels&lt;br /&gt;
|-&lt;br /&gt;
|BYTE height||Height of the font in bits and pixels&lt;br /&gt;
|-&lt;br /&gt;
|BYTE unknown||&lt;br /&gt;
|-&lt;br /&gt;
|BYTE start||First character code in the font file&lt;br /&gt;
|-&lt;br /&gt;
|BYTE count||Number of characters in the font file&lt;br /&gt;
|-&lt;br /&gt;
|UINT16LE size||Size of the font data&lt;br /&gt;
|-&lt;br /&gt;
|BYTE unknown||Compression algorithm? Seems to be 0x02&lt;br /&gt;
|-&lt;br /&gt;
|UINT32LE uncompressed_size||Size of the uncompressed data&lt;br /&gt;
|-&lt;br /&gt;
|BYTE[font_size-13] data||LZW compressed font data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;size&#039;&#039; and &#039;&#039;uncompressed_size&#039;&#039; appear to match.&lt;br /&gt;
&lt;br /&gt;
The uncompressed data contains what appears to be the following layout:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|UINT16LE[count] offsets||Positions for the characters in the data stream&lt;br /&gt;
|-&lt;br /&gt;
|BYTE[count] widths||Sizes for the characters&lt;br /&gt;
|-&lt;br /&gt;
|BYTE[uncompressed_size - (3*count)] data||Character data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== PAL: Palette ====&lt;br /&gt;
&lt;br /&gt;
The PAL: block contains palette data.  It has sub-blocks for different palette types:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|VGA:||[[VGA Palette]] (three byte, 0-63)&lt;br /&gt;
|-&lt;br /&gt;
|EGA:||&lt;br /&gt;
|-&lt;br /&gt;
|CGA:||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== SCR: Fullscreen image ====&lt;br /&gt;
&lt;br /&gt;
Fullscreen images are 320x200 pixels; 32,000 bytes for EGA and 64,000 bytes for VGA.&lt;br /&gt;
&lt;br /&gt;
The VGA files are split into two 32,000 byte &amp;quot;planes&amp;quot; using two pixels per byte. The second plane contains the more significant bits. If the starting bytes of the first plane are 0xFD 0xFF and the second plane are 0x99 0x88 then the first four horizontal pixels are palette entries 0x9F 0x9D 0x8F 0x8F.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BIN:||32000 byte (16-colour EGA / Least significant VGA bits)&lt;br /&gt;
|-&lt;br /&gt;
|VGA:||32000 byte (Most significant VGA bits)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== VER: Version ====&lt;br /&gt;
&lt;br /&gt;
Null terminated version string (e.g. &amp;quot;3.37&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
==== SSM: Sounds and music ====&lt;br /&gt;
&lt;br /&gt;
The SSM: block seems to contain media data in most cases. It has sub-blocks for different media types:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|SNG:||Song?  Seems to be 8-bit unsigned 11025Hz PCM data with an unknown header&lt;br /&gt;
|-&lt;br /&gt;
|SNG:||Song - also can contain raw MIDI data (theme song is in this format)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The file &amp;lt;tt&amp;gt;STELLAR.RES&amp;lt;/tt&amp;gt; contains three SSM: entries; two of them contain SNG: blocks while the third has entries for various sound cards, most likely a version of the theme song in a format suitable for that device.  The content type tags for these are as follows:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|STD:||?&lt;br /&gt;
|-&lt;br /&gt;
|TAN:||Tandy&lt;br /&gt;
|-&lt;br /&gt;
|M32:||Roland?&lt;br /&gt;
|-&lt;br /&gt;
|ADL:||AdLib&lt;br /&gt;
|-&lt;br /&gt;
|SBL:||Sound Blaster&lt;br /&gt;
|-&lt;br /&gt;
|001:||?&lt;br /&gt;
|-&lt;br /&gt;
|002:||?&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Compression ==&lt;br /&gt;
&lt;br /&gt;
Some file entries are compressed using the [[LZW compression|LZW algorithm]]. The entries which are compressed cannot be identified by the 4-byte content type alone, and it is suspected that certain types are always compressed. Those entries that are compressed are in the following layout:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BYTE unknown||Compression algorithm?  Always seems to be 0x02&lt;br /&gt;
|-&lt;br /&gt;
|UINT32LE decompressedSize||Size of data after decompression&lt;br /&gt;
|-&lt;br /&gt;
|BYTE data[]||LZW-compressed data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following content types never seem to be compressed:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|VQT:||&lt;br /&gt;
|-&lt;br /&gt;
|FNT:||&lt;br /&gt;
|-&lt;br /&gt;
|ARR:||&lt;br /&gt;
|-&lt;br /&gt;
|PAG:||&lt;br /&gt;
|-&lt;br /&gt;
|VGA:|| Only if contained within a &#039;&#039;&#039;PAL:&#039;&#039;&#039; folder entry. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The LZW algorithm uses a dynamic bit length, from 9 bits to 12 bits.  Data is split into bytes in little-endian order.  The first codeword is 257, with code 256 reserved to indicate a dictionary reset.&lt;br /&gt;
&lt;br /&gt;
When the dictionary is reset, some bytes in the input data are discarded.  Why this happens is currently unknown.  The number of bytes discarded seems to vary depending on the number of bytes read (perhaps it is aligning to a DWORD boundary?)&lt;br /&gt;
&lt;br /&gt;
There is some [http://code.google.com/p/scummvm-dgds/source/browse/trunk/compression.cpp sample decompression code] for similar games which seems to (mostly) work.&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This file format was reverse engineered by [[User:Malvineous|Malvineous]], with some subformats identified by [[User:Zab|Zab]].  Hints about the compression algorithm were obtained from the ScummVM project.  If you find this information helpful in a project you&#039;re working on, please give credit where credit is due.  (A link back to this wiki would be nice too!)&lt;br /&gt;
&lt;br /&gt;
[[Category:Stellar 7]]&lt;br /&gt;
[[Category:File Formats]]&lt;br /&gt;
[[Category:Group Files]]&lt;br /&gt;
[[Category:Group Files with embedded FAT]]&lt;/div&gt;</summary>
		<author><name>Zab</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=RES_Format_(Stellar_7)&amp;diff=3953</id>
		<title>RES Format (Stellar 7)</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=RES_Format_(Stellar_7)&amp;diff=3953"/>
		<updated>2012-03-28T03:15:27Z</updated>

		<summary type="html">&lt;p&gt;Zab: /* Simple Font */ Added a bit more on interpreting the simple fonts. Probably needs it&amp;#039;s own Dynamix font format page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NeedMoreInfo}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;RES format&#039;&#039;&#039; is used by [[Stellar 7]] to store much of the game data. The PC version has 29 files using this format.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
&lt;br /&gt;
It is a binary format containing any number of &#039;&#039;entries&#039;&#039; which themselves can contain other entries. Various items are stored in these files, such as compressed images and palette data, or the mission briefing text. The entries begin with a content type which can be clearly read even with a text editor.&lt;br /&gt;
&lt;br /&gt;
=== Signature ===&lt;br /&gt;
&lt;br /&gt;
There is no known signature, other than carefully reading the file structure and verifying it seems correct (e.g. offsets don&#039;t go past the end of the file.)&lt;br /&gt;
&lt;br /&gt;
=== File entry ===&lt;br /&gt;
&lt;br /&gt;
The file consists of one or more file entries, one after the other.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|char contentType[4]||Content type (see below), not null-terminated&lt;br /&gt;
|-&lt;br /&gt;
|UINT32LE isfolder_length||Length of the data, most significant bit is folder bit&lt;br /&gt;
|-&lt;br /&gt;
|BYTE data[length]||&amp;lt;tt&amp;gt;length&amp;lt;/tt&amp;gt; bytes of data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If the most significant bit in &amp;lt;tt&amp;gt;isfolder_length&amp;lt;/tt&amp;gt; is set, the &amp;lt;tt&amp;gt;data&amp;lt;/tt&amp;gt; is comprised of more file entries in the same format as above, like a subdirectory. None of the game&#039;s data files appear to nest folders more than one level deep. The values can be extracted like this:&lt;br /&gt;
&lt;br /&gt;
  length = isfolder_length &amp;amp; 0x7FFFFFFF&lt;br /&gt;
  if (isfolder_length &amp;amp; 0x80000000) then it is a folder&lt;br /&gt;
&lt;br /&gt;
=== Content types ===&lt;br /&gt;
&lt;br /&gt;
The following values for contentType are known.  Any types that refer to sub-blocks mean &amp;quot;files&amp;quot; in the &amp;quot;subdirectory&amp;quot; as described above.&lt;br /&gt;
&lt;br /&gt;
==== BMP: Image ====&lt;br /&gt;
&lt;br /&gt;
The game supports VGA and earlier modes including EGA and CGA. The main palette information for VGA is located in the file &amp;lt;tt&amp;gt;STELART.RES&amp;lt;/tt&amp;gt; while the EGA/CGA palettes are in &amp;lt;tt&amp;gt;STELARTE.RES&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|INF:||Possibly a way to slice up the bitmap. See below.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some BMP: entries contain an INF: tag which appears to be layout guides for the image. The blocks start with a UINT16LE number specifying 1/4th the number of remaining bytes in the entry. These bytes look like they contain pairs of UINT16LE numbers which correspond somewhat to coordinates in the image.&lt;br /&gt;
&lt;br /&gt;
==== FNT: Font ====&lt;br /&gt;
&lt;br /&gt;
There are two FNT: blocks in &amp;lt;tt&amp;gt;STELLAR.RES&amp;lt;/tt&amp;gt;. They are both uncompressed in one of two formats; hints about these formats was found at the [http://code.google.com/p/scummvm-dgds/source/browse/trunk/resources/font.cpp?r=26 ScummVM-DGDS Project]. Over there they are known as &#039;&#039;simple&#039;&#039; and &#039;&#039;complex&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The structure of these fonts are:&lt;br /&gt;
&lt;br /&gt;
===== Simple Font =====&lt;br /&gt;
&lt;br /&gt;
Simple fonts are fixed width.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BYTE width||Width of the font in bits and pixels&lt;br /&gt;
|-&lt;br /&gt;
|BYTE height||Height of the font in bits and pixels&lt;br /&gt;
|-&lt;br /&gt;
|BYTE start||First character code in the font file&lt;br /&gt;
|-&lt;br /&gt;
|BYTE count||Number of characters in the font file&lt;br /&gt;
|-&lt;br /&gt;
|BYTE[height*count]||Font data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Therefore, the file size for a simple font would be:&lt;br /&gt;
&lt;br /&gt;
   4 + (height * count)&lt;br /&gt;
&lt;br /&gt;
Typically, the first character code is 0x20 (32). A font with a full uppercase set has a count of at least 0x40 (64) while a font with an upper/lowercase set has a count of at least 0x60 (96).&lt;br /&gt;
&lt;br /&gt;
To find a character in the font data, look at the following position in the font data:&lt;br /&gt;
&lt;br /&gt;
   (character_code - start) * height&lt;br /&gt;
&lt;br /&gt;
The simple font included in &amp;lt;tt&amp;gt;STELLAR.RES&amp;lt;/tt&amp;gt; has a size of 8x6 pixels and starts at character 0x20. For character code 0x41 (65, letter A) the position would be (0x41 - 0x20) * 0x6 = 0xC6 (196). The data in this location is:&lt;br /&gt;
&lt;br /&gt;
   0x 7c 82 fe 82 82 00&lt;br /&gt;
&lt;br /&gt;
This font is just a basic raster bitmap using 1 bit-per-pixel:&lt;br /&gt;
&lt;br /&gt;
   .11111..&lt;br /&gt;
   1.....1.&lt;br /&gt;
   1111111.&lt;br /&gt;
   1.....1.&lt;br /&gt;
   1.....1.&lt;br /&gt;
   ........&lt;br /&gt;
&lt;br /&gt;
===== Complex Font =====&lt;br /&gt;
&lt;br /&gt;
Complex fonts have varying widths, though the limit seems to be 8.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BYTE magic||Magic value 0xff&lt;br /&gt;
|-&lt;br /&gt;
|BYTE width||Width of the font in bits and pixels&lt;br /&gt;
|-&lt;br /&gt;
|BYTE height||Height of the font in bits and pixels&lt;br /&gt;
|-&lt;br /&gt;
|BYTE unknown||&lt;br /&gt;
|-&lt;br /&gt;
|BYTE start||First character code in the font file&lt;br /&gt;
|-&lt;br /&gt;
|BYTE count||Number of characters in the font file&lt;br /&gt;
|-&lt;br /&gt;
|UINT16LE size||Size of the font data&lt;br /&gt;
|-&lt;br /&gt;
|BYTE unknown||Compression algorithm? Seems to be 0x02&lt;br /&gt;
|-&lt;br /&gt;
|UINT32LE uncompressed_size||Size of the uncompressed data&lt;br /&gt;
|-&lt;br /&gt;
|BYTE[font_size-13] data||LZW compressed font data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;size&#039;&#039; and &#039;&#039;uncompressed_size&#039;&#039; appear to match.&lt;br /&gt;
&lt;br /&gt;
The uncompressed data contains what appears to be the following layout:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|UINT16LE[count] offsets||Positions for the characters in the data stream&lt;br /&gt;
|-&lt;br /&gt;
|BYTE[count] widths||Sizes for the characters&lt;br /&gt;
|-&lt;br /&gt;
|BYTE[uncompressed_size - (3*count)] data||Character data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== PAL: Palette ====&lt;br /&gt;
&lt;br /&gt;
The PAL: block contains palette data.  It has sub-blocks for different palette types:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|VGA:||[[VGA Palette]] (three byte, 0-63)&lt;br /&gt;
|-&lt;br /&gt;
|EGA:||&lt;br /&gt;
|-&lt;br /&gt;
|CGA:||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== SCR: Fullscreen image ====&lt;br /&gt;
&lt;br /&gt;
Fullscreen images are 320x200 pixels; 32,000 bytes for EGA and 64,000 bytes for VGA.&lt;br /&gt;
&lt;br /&gt;
The VGA files are split into two 32,000 byte &amp;quot;planes&amp;quot; using two pixels per byte. The second plane contains the more significant bits. If the starting bytes of the first plane are 0xFD 0xFF and the second plane are 0x99 0x88 then the first four horizontal pixels are palette entries 0x9F 0x9D 0x8F 0x8F.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BIN:||32000 byte (16-colour EGA / Least significant VGA bits)&lt;br /&gt;
|-&lt;br /&gt;
|VGA:||32000 byte (Most significant VGA bits)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== VER: Version ====&lt;br /&gt;
&lt;br /&gt;
Null terminated version string (e.g. &amp;quot;3.37&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
==== SSM: Sounds and music ====&lt;br /&gt;
&lt;br /&gt;
The SSM: block seems to contain media data in most cases. It has sub-blocks for different media types:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|SNG:||Song?  Seems to be 8-bit unsigned 11025Hz PCM data with an unknown header&lt;br /&gt;
|-&lt;br /&gt;
|SNG:||Song - also can contain raw MIDI data (theme song is in this format)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The file &amp;lt;tt&amp;gt;STELLAR.RES&amp;lt;/tt&amp;gt; contains three SSM: entries; two of them contain SNG: blocks while the third has entries for various sound cards, most likely a version of the theme song in a format suitable for that device.  The content type tags for these are as follows:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|STD:||?&lt;br /&gt;
|-&lt;br /&gt;
|TAN:||Tandy&lt;br /&gt;
|-&lt;br /&gt;
|M32:||Roland?&lt;br /&gt;
|-&lt;br /&gt;
|ADL:||AdLib&lt;br /&gt;
|-&lt;br /&gt;
|SBL:||Sound Blaster&lt;br /&gt;
|-&lt;br /&gt;
|001:||?&lt;br /&gt;
|-&lt;br /&gt;
|002:||?&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Compression ==&lt;br /&gt;
&lt;br /&gt;
Some file entries are compressed using the [[LZW compression|LZW algorithm]]. The entries which are compressed cannot be identified by the 4-byte content type alone, and it is suspected that certain types are always compressed. Those entries that are compressed are in the following layout:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BYTE unknown||Compression algorithm?  Always seems to be 0x02&lt;br /&gt;
|-&lt;br /&gt;
|UINT32LE decompressedSize||Size of data after decompression&lt;br /&gt;
|-&lt;br /&gt;
|BYTE data[]||LZW-compressed data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following content types never seem to be compressed:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|VQT:||&lt;br /&gt;
|-&lt;br /&gt;
|FNT:||&lt;br /&gt;
|-&lt;br /&gt;
|ARR:||&lt;br /&gt;
|-&lt;br /&gt;
|PAG:||&lt;br /&gt;
|-&lt;br /&gt;
|VGA:|| Only if contained within a &#039;&#039;&#039;PAL:&#039;&#039;&#039; folder entry. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The LZW algorithm uses a dynamic bit length, from 9 bits to 12 bits.  Data is split into bytes in little-endian order.  The first codeword is 257, with code 256 reserved to indicate a dictionary reset.&lt;br /&gt;
&lt;br /&gt;
When the dictionary is reset, some bytes in the input data are discarded.  Why this happens is currently unknown.  The number of bytes discarded seems to vary depending on the number of bytes read (perhaps it is aligning to a DWORD boundary?)&lt;br /&gt;
&lt;br /&gt;
There is some [http://code.google.com/p/scummvm-dgds/source/browse/trunk/compression.cpp sample decompression code] for similar games which seems to (mostly) work.&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This file format was reverse engineered by [[User:Malvineous|Malvineous]], with some subformats identified by [[User:Zab|Zab]].  Hints about the compression algorithm were obtained from the ScummVM project.  If you find this information helpful in a project you&#039;re working on, please give credit where credit is due.  (A link back to this wiki would be nice too!)&lt;br /&gt;
&lt;br /&gt;
[[Category:Stellar 7]]&lt;br /&gt;
[[Category:File Formats]]&lt;br /&gt;
[[Category:Group Files]]&lt;br /&gt;
[[Category:Group Files with embedded FAT]]&lt;/div&gt;</summary>
		<author><name>Zab</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=RES_Format_(Stellar_7)&amp;diff=3952</id>
		<title>RES Format (Stellar 7)</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=RES_Format_(Stellar_7)&amp;diff=3952"/>
		<updated>2012-03-27T14:14:21Z</updated>

		<summary type="html">&lt;p&gt;Zab: /* Content types */ Added some font info (thanks to scummvm-dgds), still working on visual representation.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NeedMoreInfo}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;RES format&#039;&#039;&#039; is used by [[Stellar 7]] to store much of the game data. The PC version has 29 files using this format.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
&lt;br /&gt;
It is a binary format containing any number of &#039;&#039;entries&#039;&#039; which themselves can contain other entries. Various items are stored in these files, such as compressed images and palette data, or the mission briefing text. The entries begin with a content type which can be clearly read even with a text editor.&lt;br /&gt;
&lt;br /&gt;
=== Signature ===&lt;br /&gt;
&lt;br /&gt;
There is no known signature, other than carefully reading the file structure and verifying it seems correct (e.g. offsets don&#039;t go past the end of the file.)&lt;br /&gt;
&lt;br /&gt;
=== File entry ===&lt;br /&gt;
&lt;br /&gt;
The file consists of one or more file entries, one after the other.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|char contentType[4]||Content type (see below), not null-terminated&lt;br /&gt;
|-&lt;br /&gt;
|UINT32LE isfolder_length||Length of the data, most significant bit is folder bit&lt;br /&gt;
|-&lt;br /&gt;
|BYTE data[length]||&amp;lt;tt&amp;gt;length&amp;lt;/tt&amp;gt; bytes of data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If the most significant bit in &amp;lt;tt&amp;gt;isfolder_length&amp;lt;/tt&amp;gt; is set, the &amp;lt;tt&amp;gt;data&amp;lt;/tt&amp;gt; is comprised of more file entries in the same format as above, like a subdirectory. None of the game&#039;s data files appear to nest folders more than one level deep. The values can be extracted like this:&lt;br /&gt;
&lt;br /&gt;
  length = isfolder_length &amp;amp; 0x7FFFFFFF&lt;br /&gt;
  if (isfolder_length &amp;amp; 0x80000000) then it is a folder&lt;br /&gt;
&lt;br /&gt;
=== Content types ===&lt;br /&gt;
&lt;br /&gt;
The following values for contentType are known.  Any types that refer to sub-blocks mean &amp;quot;files&amp;quot; in the &amp;quot;subdirectory&amp;quot; as described above.&lt;br /&gt;
&lt;br /&gt;
==== BMP: Image ====&lt;br /&gt;
&lt;br /&gt;
The game supports VGA and earlier modes including EGA and CGA. The main palette information for VGA is located in the file &amp;lt;tt&amp;gt;STELART.RES&amp;lt;/tt&amp;gt; while the EGA/CGA palettes are in &amp;lt;tt&amp;gt;STELARTE.RES&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|INF:||Possibly a way to slice up the bitmap. See below.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some BMP: entries contain an INF: tag which appears to be layout guides for the image. The blocks start with a UINT16LE number specifying 1/4th the number of remaining bytes in the entry. These bytes look like they contain pairs of UINT16LE numbers which correspond somewhat to coordinates in the image.&lt;br /&gt;
&lt;br /&gt;
==== FNT: Font ====&lt;br /&gt;
&lt;br /&gt;
There are two FNT: blocks in &amp;lt;tt&amp;gt;STELLAR.RES&amp;lt;/tt&amp;gt;. They are both uncompressed in one of two formats; hints about these formats was found at the [http://code.google.com/p/scummvm-dgds/source/browse/trunk/resources/font.cpp?r=26 ScummVM-DGDS Project]. Over there they are known as &#039;&#039;simple&#039;&#039; and &#039;&#039;complex&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The structure of these fonts are:&lt;br /&gt;
&lt;br /&gt;
===== Simple Font =====&lt;br /&gt;
&lt;br /&gt;
Simple fonts are fixed width.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BYTE width||Width of the font in bits and pixels&lt;br /&gt;
|-&lt;br /&gt;
|BYTE height||Height of the font in bits and pixels&lt;br /&gt;
|-&lt;br /&gt;
|BYTE start||First character code in the font file&lt;br /&gt;
|-&lt;br /&gt;
|BYTE count||Number of characters in the font file&lt;br /&gt;
|-&lt;br /&gt;
|BYTE[height*count]||Font data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Therefore, the file size for a simple font would be:&lt;br /&gt;
&lt;br /&gt;
   4 + (height * count)&lt;br /&gt;
&lt;br /&gt;
Typically, the first character code is 0x20 (32). A font with a full uppercase set has a count of at least 0x40 (64) while a font with an upper/lowercase set has a count of at least 0x60 (96).&lt;br /&gt;
&lt;br /&gt;
The font data is a raster bitmap with 1 bit-per-pixel.&lt;br /&gt;
&lt;br /&gt;
===== Complex Font =====&lt;br /&gt;
&lt;br /&gt;
Complex fonts have varying widths, though the limit seems to be 8.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BYTE magic||Magic value 0xff&lt;br /&gt;
|-&lt;br /&gt;
|BYTE width||Width of the font in bits and pixels&lt;br /&gt;
|-&lt;br /&gt;
|BYTE height||Height of the font in bits and pixels&lt;br /&gt;
|-&lt;br /&gt;
|BYTE unknown||&lt;br /&gt;
|-&lt;br /&gt;
|BYTE start||First character code in the font file&lt;br /&gt;
|-&lt;br /&gt;
|BYTE count||Number of characters in the font file&lt;br /&gt;
|-&lt;br /&gt;
|UINT16LE size||Size of the font data&lt;br /&gt;
|-&lt;br /&gt;
|BYTE unknown||Compression algorithm? Seems to be 0x02&lt;br /&gt;
|-&lt;br /&gt;
|UINT32LE uncompressed_size||Size of the uncompressed data&lt;br /&gt;
|-&lt;br /&gt;
|BYTE[font_size-13] data||LZW compressed font data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;size&#039;&#039; and &#039;&#039;uncompressed_size&#039;&#039; appear to match.&lt;br /&gt;
&lt;br /&gt;
The uncompressed data contains what appears to be the following layout:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|UINT16LE[count] offsets||Positions for the characters in the data stream&lt;br /&gt;
|-&lt;br /&gt;
|BYTE[count] widths||Sizes for the characters&lt;br /&gt;
|-&lt;br /&gt;
|BYTE[uncompressed_size - (3*count)] data||Character data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== PAL: Palette ====&lt;br /&gt;
&lt;br /&gt;
The PAL: block contains palette data.  It has sub-blocks for different palette types:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|VGA:||[[VGA Palette]] (three byte, 0-63)&lt;br /&gt;
|-&lt;br /&gt;
|EGA:||&lt;br /&gt;
|-&lt;br /&gt;
|CGA:||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== SCR: Fullscreen image ====&lt;br /&gt;
&lt;br /&gt;
Fullscreen images are 320x200 pixels; 32,000 bytes for EGA and 64,000 bytes for VGA.&lt;br /&gt;
&lt;br /&gt;
The VGA files are split into two 32,000 byte &amp;quot;planes&amp;quot; using two pixels per byte. The second plane contains the more significant bits. If the starting bytes of the first plane are 0xFD 0xFF and the second plane are 0x99 0x88 then the first four horizontal pixels are palette entries 0x9F 0x9D 0x8F 0x8F.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BIN:||32000 byte (16-colour EGA / Least significant VGA bits)&lt;br /&gt;
|-&lt;br /&gt;
|VGA:||32000 byte (Most significant VGA bits)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== VER: Version ====&lt;br /&gt;
&lt;br /&gt;
Null terminated version string (e.g. &amp;quot;3.37&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
==== SSM: Sounds and music ====&lt;br /&gt;
&lt;br /&gt;
The SSM: block seems to contain media data in most cases. It has sub-blocks for different media types:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|SNG:||Song?  Seems to be 8-bit unsigned 11025Hz PCM data with an unknown header&lt;br /&gt;
|-&lt;br /&gt;
|SNG:||Song - also can contain raw MIDI data (theme song is in this format)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The file &amp;lt;tt&amp;gt;STELLAR.RES&amp;lt;/tt&amp;gt; contains three SSM: entries; two of them contain SNG: blocks while the third has entries for various sound cards, most likely a version of the theme song in a format suitable for that device.  The content type tags for these are as follows:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|STD:||?&lt;br /&gt;
|-&lt;br /&gt;
|TAN:||Tandy&lt;br /&gt;
|-&lt;br /&gt;
|M32:||Roland?&lt;br /&gt;
|-&lt;br /&gt;
|ADL:||AdLib&lt;br /&gt;
|-&lt;br /&gt;
|SBL:||Sound Blaster&lt;br /&gt;
|-&lt;br /&gt;
|001:||?&lt;br /&gt;
|-&lt;br /&gt;
|002:||?&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Compression ==&lt;br /&gt;
&lt;br /&gt;
Some file entries are compressed using the [[LZW compression|LZW algorithm]]. The entries which are compressed cannot be identified by the 4-byte content type alone, and it is suspected that certain types are always compressed. Those entries that are compressed are in the following layout:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BYTE unknown||Compression algorithm?  Always seems to be 0x02&lt;br /&gt;
|-&lt;br /&gt;
|UINT32LE decompressedSize||Size of data after decompression&lt;br /&gt;
|-&lt;br /&gt;
|BYTE data[]||LZW-compressed data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following content types never seem to be compressed:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|VQT:||&lt;br /&gt;
|-&lt;br /&gt;
|FNT:||&lt;br /&gt;
|-&lt;br /&gt;
|ARR:||&lt;br /&gt;
|-&lt;br /&gt;
|PAG:||&lt;br /&gt;
|-&lt;br /&gt;
|VGA:|| Only if contained within a &#039;&#039;&#039;PAL:&#039;&#039;&#039; folder entry. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The LZW algorithm uses a dynamic bit length, from 9 bits to 12 bits.  Data is split into bytes in little-endian order.  The first codeword is 257, with code 256 reserved to indicate a dictionary reset.&lt;br /&gt;
&lt;br /&gt;
When the dictionary is reset, some bytes in the input data are discarded.  Why this happens is currently unknown.  The number of bytes discarded seems to vary depending on the number of bytes read (perhaps it is aligning to a DWORD boundary?)&lt;br /&gt;
&lt;br /&gt;
There is some [http://code.google.com/p/scummvm-dgds/source/browse/trunk/compression.cpp sample decompression code] for similar games which seems to (mostly) work.&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This file format was reverse engineered by [[User:Malvineous|Malvineous]], with some subformats identified by [[User:Zab|Zab]].  Hints about the compression algorithm were obtained from the ScummVM project.  If you find this information helpful in a project you&#039;re working on, please give credit where credit is due.  (A link back to this wiki would be nice too!)&lt;br /&gt;
&lt;br /&gt;
[[Category:Stellar 7]]&lt;br /&gt;
[[Category:File Formats]]&lt;br /&gt;
[[Category:Group Files]]&lt;br /&gt;
[[Category:Group Files with embedded FAT]]&lt;/div&gt;</summary>
		<author><name>Zab</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=RES_Format_(Stellar_7)&amp;diff=3951</id>
		<title>RES Format (Stellar 7)</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=RES_Format_(Stellar_7)&amp;diff=3951"/>
		<updated>2012-03-27T09:06:43Z</updated>

		<summary type="html">&lt;p&gt;Zab: /* File entry */ Observation about folders&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NeedMoreInfo}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;RES format&#039;&#039;&#039; is used by [[Stellar 7]] to store much of the game data. The PC version has 29 files using this format.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
&lt;br /&gt;
It is a binary format containing any number of &#039;&#039;entries&#039;&#039; which themselves can contain other entries. Various items are stored in these files, such as compressed images and palette data, or the mission briefing text. The entries begin with a content type which can be clearly read even with a text editor.&lt;br /&gt;
&lt;br /&gt;
=== Signature ===&lt;br /&gt;
&lt;br /&gt;
There is no known signature, other than carefully reading the file structure and verifying it seems correct (e.g. offsets don&#039;t go past the end of the file.)&lt;br /&gt;
&lt;br /&gt;
=== File entry ===&lt;br /&gt;
&lt;br /&gt;
The file consists of one or more file entries, one after the other.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|char contentType[4]||Content type (see below), not null-terminated&lt;br /&gt;
|-&lt;br /&gt;
|UINT32LE isfolder_length||Length of the data, most significant bit is folder bit&lt;br /&gt;
|-&lt;br /&gt;
|BYTE data[length]||&amp;lt;tt&amp;gt;length&amp;lt;/tt&amp;gt; bytes of data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If the most significant bit in &amp;lt;tt&amp;gt;isfolder_length&amp;lt;/tt&amp;gt; is set, the &amp;lt;tt&amp;gt;data&amp;lt;/tt&amp;gt; is comprised of more file entries in the same format as above, like a subdirectory. None of the game&#039;s data files appear to nest folders more than one level deep. The values can be extracted like this:&lt;br /&gt;
&lt;br /&gt;
  length = isfolder_length &amp;amp; 0x7FFFFFFF&lt;br /&gt;
  if (isfolder_length &amp;amp; 0x80000000) then it is a folder&lt;br /&gt;
&lt;br /&gt;
=== Content types ===&lt;br /&gt;
&lt;br /&gt;
The following values for contentType are known.  Any types that refer to sub-blocks mean &amp;quot;files&amp;quot; in the &amp;quot;subdirectory&amp;quot; as described above.&lt;br /&gt;
&lt;br /&gt;
==== BMP: Image ====&lt;br /&gt;
&lt;br /&gt;
The game supports VGA and earlier modes including EGA and CGA. The main palette information for VGA is located in the file &amp;lt;tt&amp;gt;STELART.RES&amp;lt;/tt&amp;gt; while the EGA/CGA palettes are in &amp;lt;tt&amp;gt;STELARTE.RES&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|INF:||Possibly a way to slice up the bitmap. See below.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some BMP: entries contain an INF: tag which appears to be layout guides for the image. The blocks start with a UINT16LE number specifying 1/4th the number of remaining bytes in the entry. These bytes look like they contain pairs of UINT16LE numbers which correspond somewhat to coordinates in the image.&lt;br /&gt;
&lt;br /&gt;
==== PAL: Palette ====&lt;br /&gt;
&lt;br /&gt;
The PAL: block contains palette data.  It has sub-blocks for different palette types:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|VGA:||[[VGA Palette]] (three byte, 0-63)&lt;br /&gt;
|-&lt;br /&gt;
|EGA:||&lt;br /&gt;
|-&lt;br /&gt;
|CGA:||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== SCR: Fullscreen image ====&lt;br /&gt;
&lt;br /&gt;
Fullscreen images are 320x200 pixels; 32,000 bytes for EGA and 64,000 bytes for VGA.&lt;br /&gt;
&lt;br /&gt;
The VGA files are split into two 32,000 byte &amp;quot;planes&amp;quot; using two pixels per byte. The second plane contains the more significant bits. If the starting bytes of the first plane are 0xFD 0xFF and the second plane are 0x99 0x88 then the first four horizontal pixels are palette entries 0x9F 0x9D 0x8F 0x8F.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BIN:||32000 byte (16-colour EGA / Least significant VGA bits)&lt;br /&gt;
|-&lt;br /&gt;
|VGA:||32000 byte (Most significant VGA bits)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== VER: Version ====&lt;br /&gt;
&lt;br /&gt;
Null terminated version string (e.g. &amp;quot;3.37&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
==== SSM: Sounds and music ====&lt;br /&gt;
&lt;br /&gt;
The SSM: block seems to contain media data in most cases. It has sub-blocks for different media types:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|SNG:||Song?  Seems to be 8-bit unsigned 11025Hz PCM data with an unknown header&lt;br /&gt;
|-&lt;br /&gt;
|SNG:||Song - also can contain raw MIDI data (theme song is in this format)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The file &amp;lt;tt&amp;gt;STELLAR.RES&amp;lt;/tt&amp;gt; contains three SSM: entries; two of them contain SNG: blocks while the third has entries for various sound cards, most likely a version of the theme song in a format suitable for that device.  The content type tags for these are as follows:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|STD:||?&lt;br /&gt;
|-&lt;br /&gt;
|TAN:||Tandy&lt;br /&gt;
|-&lt;br /&gt;
|M32:||Roland?&lt;br /&gt;
|-&lt;br /&gt;
|ADL:||AdLib&lt;br /&gt;
|-&lt;br /&gt;
|SBL:||Sound Blaster&lt;br /&gt;
|-&lt;br /&gt;
|001:||?&lt;br /&gt;
|-&lt;br /&gt;
|002:||?&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Compression ==&lt;br /&gt;
&lt;br /&gt;
Some file entries are compressed using the [[LZW compression|LZW algorithm]]. The entries which are compressed cannot be identified by the 4-byte content type alone, and it is suspected that certain types are always compressed. Those entries that are compressed are in the following layout:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BYTE unknown||Compression algorithm?  Always seems to be 0x02&lt;br /&gt;
|-&lt;br /&gt;
|UINT32LE decompressedSize||Size of data after decompression&lt;br /&gt;
|-&lt;br /&gt;
|BYTE data[]||LZW-compressed data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following content types never seem to be compressed:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|VQT:||&lt;br /&gt;
|-&lt;br /&gt;
|FNT:||&lt;br /&gt;
|-&lt;br /&gt;
|ARR:||&lt;br /&gt;
|-&lt;br /&gt;
|PAG:||&lt;br /&gt;
|-&lt;br /&gt;
|VGA:|| Only if contained within a &#039;&#039;&#039;PAL:&#039;&#039;&#039; folder entry. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The LZW algorithm uses a dynamic bit length, from 9 bits to 12 bits.  Data is split into bytes in little-endian order.  The first codeword is 257, with code 256 reserved to indicate a dictionary reset.&lt;br /&gt;
&lt;br /&gt;
When the dictionary is reset, some bytes in the input data are discarded.  Why this happens is currently unknown.  The number of bytes discarded seems to vary depending on the number of bytes read (perhaps it is aligning to a DWORD boundary?)&lt;br /&gt;
&lt;br /&gt;
There is some [http://code.google.com/p/scummvm-dgds/source/browse/trunk/compression.cpp sample decompression code] for similar games which seems to (mostly) work.&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This file format was reverse engineered by [[User:Malvineous|Malvineous]], with some subformats identified by [[User:Zab|Zab]].  Hints about the compression algorithm were obtained from the ScummVM project.  If you find this information helpful in a project you&#039;re working on, please give credit where credit is due.  (A link back to this wiki would be nice too!)&lt;br /&gt;
&lt;br /&gt;
[[Category:Stellar 7]]&lt;br /&gt;
[[Category:File Formats]]&lt;br /&gt;
[[Category:Group Files]]&lt;br /&gt;
[[Category:Group Files with embedded FAT]]&lt;/div&gt;</summary>
		<author><name>Zab</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Talk:RES_Format_(Stellar_7)&amp;diff=3950</id>
		<title>Talk:RES Format (Stellar 7)</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Talk:RES_Format_(Stellar_7)&amp;diff=3950"/>
		<updated>2012-03-27T08:42:44Z</updated>

		<summary type="html">&lt;p&gt;Zab: /* Compression */ Added file links for LZW help&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Compression ==&lt;br /&gt;
I was able to get an LZW decompressor working beautifully up until some time after code reset 0x100 is encountered. I&#039;m using [http://cibyl.googlecode.com/svn/sarien-cibyl/trunk/src/core/lzw.c this source] with some compatibility fixes. I&#039;m wondering how much is known about discarding bytes. Using LEVEL1.RES for example, the third compressed block has a code reset about 2/3rds of the way through the finished product. I can finish the decoding if I eat three bytes but the remaining image starts becoming corrupted. The eaten bytes don&#039;t look useless either; even the remaining 8 bits in the buffer produce what looks like the next palette number in the output. Any thoughts? [[User:Zab|Zab]] 18:31, 3 March 2012 (GMT)&lt;br /&gt;
&lt;br /&gt;
: I don&#039;t know much about LZW decompression, but in my limited experience there are a bunch of different things that can happen.  If 0x100 is a reset sequence, it may not reset the entire dictionary.  Upon a reset, the length of the codeword may or may not be restored to its initial length (i.e. if it starts at 9-bits and grows to 12-bits, upon reset it may go back to 9-bits or stay at 12-bits.)  There are other things I can&#039;t think of right now too.  If you can find an already decompressed file and then compare that byte by byte to the compressed data as it is being decompressed, you will know at exactly which byte it goes wrong, and what byte it should have been instead, which could provide some hints. -- [[User:Malvineous|Malvineous]] 13:16, 6 March 2012 (GMT)&lt;br /&gt;
&lt;br /&gt;
:: I&#039;ve pounded my head on this plenty. I won&#039;t say I&#039;ve given up but I&#039;m going to put this up in case anyone can help out. Here is [https://gist.github.com/2213872 the decompression code] and [http://www.mediafire.com/?712b70p1u2svaf4,a8v2xwf2g5k7y5y two compressed files], both working and non-working with a decompressed size of 32,000 bytes. Any assistance is appreciated. [[User:Zab|Zab]] 08:42, 27 March 2012 (GMT)&lt;/div&gt;</summary>
		<author><name>Zab</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=RES_Format_(Stellar_7)&amp;diff=3931</id>
		<title>RES Format (Stellar 7)</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=RES_Format_(Stellar_7)&amp;diff=3931"/>
		<updated>2012-03-06T13:55:16Z</updated>

		<summary type="html">&lt;p&gt;Zab: /* BMP: Image */ Added INF: stuff&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NeedMoreInfo}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;RES format&#039;&#039;&#039; is used by [[Stellar 7]] to store much of the game data. The PC version has 29 files using this format.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
&lt;br /&gt;
It is a binary format containing any number of &#039;&#039;entries&#039;&#039; which themselves can contain other entries. Various items are stored in these files, such as compressed images and palette data, or the mission briefing text. The entries begin with a content type which can be clearly read even with a text editor.&lt;br /&gt;
&lt;br /&gt;
=== Signature ===&lt;br /&gt;
&lt;br /&gt;
There is no known signature, other than carefully reading the file structure and verifying it seems correct (e.g. offsets don&#039;t go past the end of the file.)&lt;br /&gt;
&lt;br /&gt;
=== File entry ===&lt;br /&gt;
&lt;br /&gt;
The file consists of one or more file entries, one after the other.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|char contentType[4]||Content type (see below), not null-terminated&lt;br /&gt;
|-&lt;br /&gt;
|UINT32LE isfolder_length||Length of the data, most significant bit is folder bit&lt;br /&gt;
|-&lt;br /&gt;
|BYTE data[length]||&amp;lt;tt&amp;gt;length&amp;lt;/tt&amp;gt; bytes of data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If the most significant bit in &amp;lt;tt&amp;gt;isfolder_length&amp;lt;/tt&amp;gt; is set, the &amp;lt;tt&amp;gt;data&amp;lt;/tt&amp;gt; is comprised of more file entries in the same format as above (sort of like a subdirectory.)  The values can be extracted like this:&lt;br /&gt;
&lt;br /&gt;
  length = isfolder_length &amp;amp; 0x7FFFFFFF&lt;br /&gt;
  if (isfolder_length &amp;amp; 0x80000000) then it is a folder&lt;br /&gt;
&lt;br /&gt;
=== Content types ===&lt;br /&gt;
&lt;br /&gt;
The following values for contentType are known.  Any types that refer to sub-blocks mean &amp;quot;files&amp;quot; in the &amp;quot;subdirectory&amp;quot; as described above.&lt;br /&gt;
&lt;br /&gt;
==== BMP: Image ====&lt;br /&gt;
&lt;br /&gt;
The game supports VGA and earlier modes including EGA and CGA. The main palette information for VGA is located in the file &amp;lt;tt&amp;gt;STELART.RES&amp;lt;/tt&amp;gt; while the EGA/CGA palettes are in &amp;lt;tt&amp;gt;STELARTE.RES&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|INF:||Possibly a way to slice up the bitmap. See below.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some BMP: entries contain an INF: tag which appears to be layout guides for the image. The blocks start with a UINT16LE number specifying 1/4th the number of remaining bytes in the entry. These bytes look like they contain pairs of UINT16LE numbers which correspond somewhat to coordinates in the image.&lt;br /&gt;
&lt;br /&gt;
==== PAL: Palette ====&lt;br /&gt;
&lt;br /&gt;
The PAL: block contains palette data.  It has sub-blocks for different palette types:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|VGA:||[[VGA Palette]] (three byte, 0-63)&lt;br /&gt;
|-&lt;br /&gt;
|EGA:||&lt;br /&gt;
|-&lt;br /&gt;
|CGA:||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== SCR: Fullscreen image ====&lt;br /&gt;
&lt;br /&gt;
Fullscreen images are 320x200 pixels; 32,000 bytes for EGA and 64,000 bytes for VGA.&lt;br /&gt;
&lt;br /&gt;
The VGA files are split into two 32,000 byte &amp;quot;planes&amp;quot; using two pixels per byte. The second plane contains the more significant bits. If the starting bytes of the first plane are 0xFD 0xFF and the second plane are 0x99 0x88 then the first four horizontal pixels are palette entries 0x9F 0x9D 0x8F 0x8F.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BIN:||32000 byte (16-colour EGA / Least significant VGA bits)&lt;br /&gt;
|-&lt;br /&gt;
|VGA:||32000 byte (Most significant VGA bits)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== VER: Version ====&lt;br /&gt;
&lt;br /&gt;
Null terminated version string (e.g. &amp;quot;3.37&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
==== SSM: Sounds and music ====&lt;br /&gt;
&lt;br /&gt;
The SSM: block seems to contain media data in most cases. It has sub-blocks for different media types:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|SNG:||Song?  Seems to be 8-bit unsigned 11025Hz PCM data with an unknown header&lt;br /&gt;
|-&lt;br /&gt;
|SNG:||Song - also can contain raw MIDI data (theme song is in this format)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The file &amp;lt;tt&amp;gt;STELLAR.RES&amp;lt;/tt&amp;gt; contains three SSM: entries; two of them contain SNG: blocks while the third has entries for various sound cards, most likely a version of the theme song in a format suitable for that device.  The content type tags for these are as follows:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|STD:||?&lt;br /&gt;
|-&lt;br /&gt;
|TAN:||Tandy&lt;br /&gt;
|-&lt;br /&gt;
|M32:||Roland?&lt;br /&gt;
|-&lt;br /&gt;
|ADL:||AdLib&lt;br /&gt;
|-&lt;br /&gt;
|SBL:||Sound Blaster&lt;br /&gt;
|-&lt;br /&gt;
|001:||?&lt;br /&gt;
|-&lt;br /&gt;
|002:||?&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Compression ==&lt;br /&gt;
&lt;br /&gt;
Some file entries are compressed using the [[LZW compression|LZW algorithm]]. The entries which are compressed cannot be identified by the 4-byte content type alone, and it is suspected that certain types are always compressed. Those entries that are compressed are in the following layout:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BYTE unknown||Compression algorithm?  Always seems to be 0x02&lt;br /&gt;
|-&lt;br /&gt;
|UINT32LE decompressedSize||Size of data after decompression&lt;br /&gt;
|-&lt;br /&gt;
|BYTE data[]||LZW-compressed data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following content types never seem to be compressed:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|VQT:||&lt;br /&gt;
|-&lt;br /&gt;
|FNT:||&lt;br /&gt;
|-&lt;br /&gt;
|ARR:||&lt;br /&gt;
|-&lt;br /&gt;
|PAG:||&lt;br /&gt;
|-&lt;br /&gt;
|VGA:|| Only if contained within a &#039;&#039;&#039;PAL:&#039;&#039;&#039; folder entry. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The LZW algorithm uses a dynamic bit length, from 9 bits to 12 bits.  Data is split into bytes in little-endian order.  The first codeword is 257, with code 256 reserved to indicate a dictionary reset.&lt;br /&gt;
&lt;br /&gt;
When the dictionary is reset, some bytes in the input data are discarded.  Why this happens is currently unknown.  The number of bytes discarded seems to vary depending on the number of bytes read (perhaps it is aligning to a DWORD boundary?)&lt;br /&gt;
&lt;br /&gt;
There is some [http://code.google.com/p/scummvm-dgds/source/browse/trunk/compression.cpp sample decompression code] for similar games which seems to (mostly) work.&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This file format was reverse engineered by [[User:Malvineous|Malvineous]], with some subformats identified by [[User:Zab|Zab]].  Hints about the compression algorithm were obtained from the ScummVM project.  If you find this information helpful in a project you&#039;re working on, please give credit where credit is due.  (A link back to this wiki would be nice too!)&lt;br /&gt;
&lt;br /&gt;
[[Category:Stellar 7]]&lt;br /&gt;
[[Category:File Formats]]&lt;br /&gt;
[[Category:Group Files]]&lt;br /&gt;
[[Category:Group Files with embedded FAT]]&lt;/div&gt;</summary>
		<author><name>Zab</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Stellar_7&amp;diff=3929</id>
		<title>Stellar 7</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Stellar_7&amp;diff=3929"/>
		<updated>2012-03-06T11:23:23Z</updated>

		<summary type="html">&lt;p&gt;Zab: added some stuff about the executable and restructured.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{GamePage}}&lt;br /&gt;
{{NoModdingInfo}}&lt;br /&gt;
&lt;br /&gt;
Stellar 7 was released in the 1980s for various platforms ending with a PC version in 1990.&lt;br /&gt;
&lt;br /&gt;
== File formats ==&lt;br /&gt;
&lt;br /&gt;
This section lists the file formats used in the game.&lt;br /&gt;
&lt;br /&gt;
* [[RES Format (Stellar 7)|RES Format]] - group files storing most of the game data&lt;br /&gt;
&lt;br /&gt;
== Files ==&lt;br /&gt;
&lt;br /&gt;
The PC version appears to have been compiled with a Microsoft C compiler. Much of the data is stored in bundled .RES files but a decent amount is also hard-coded in the packed executable. Some of the data in the external files is also compressed using an [[LZW compression|LZW algorithm]].&lt;br /&gt;
&lt;br /&gt;
=== Executable ===&lt;br /&gt;
&lt;br /&gt;
The PC executable is compressed using [[LZEXE]] version 0x91. [http://www.shikadi.net/files/unlzexe.c Here] is some sample code which appears to successfully decompress it.&lt;br /&gt;
&lt;br /&gt;
=== RES game data ===&lt;br /&gt;
&lt;br /&gt;
There are 29 files in the PC version using the RES format.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Filename!!Description&lt;br /&gt;
|-&lt;br /&gt;
|STELLAR.RES||Video/Audio (drivers?), probably the game intro song, what looks like fonts, and others.&lt;br /&gt;
|-&lt;br /&gt;
|COCKPIT.RES||Cockpit graphics and sound effects, mission briefing text, and others.&lt;br /&gt;
|-&lt;br /&gt;
|DRAXON.RES||A single SNG: media entry.&lt;br /&gt;
|-&lt;br /&gt;
|VOICE.RES||Contains some SNG: media entries.&lt;br /&gt;
|-&lt;br /&gt;
|LEVEL&#039;&#039;#&#039;&#039;.RES||There are seven level files where &#039;&#039;#&#039;&#039; is 1-7. These files contain background images in VGA and EGA/CGA, a sound entry, and what appears to be a table of level data.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The rest of the files come in two versions, a VGA version and an EGA/CGA version. The easy-to-spot difference between them is the EGA files have a letter E after them. The files are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Filename!!Description&lt;br /&gt;
|-&lt;br /&gt;
|STELART.RES / STELARTE.RES|| Art files with palette info necessary to parse images from anywhere else.&lt;br /&gt;
|-&lt;br /&gt;
|SCENE&#039;&#039;x&#039;&#039;.RES / SCENE&#039;&#039;x&#039;&#039;E.RES||Sixteen &amp;quot;scene&amp;quot; files, eight each where &#039;&#039;x&#039;&#039; is one of A, B1, B2, B3, B5, C, D, or E.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Other Files ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;RESOURCE.CFG&amp;lt;/tt&amp;gt; contains the current configuration set by &amp;lt;tt&amp;gt;INSTALL.COM&amp;lt;/tt&amp;gt;.  The first byte is the selected video mode (monochrome CGA up to 256-colour VGA) and the second byte is the selected sound card.&lt;br /&gt;
&lt;br /&gt;
[[Category:Sierra]]&lt;br /&gt;
[[Category:3D]]&lt;br /&gt;
[[Category:First-Person Shooter]]&lt;/div&gt;</summary>
		<author><name>Zab</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Stellar_7&amp;diff=3925</id>
		<title>Stellar 7</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Stellar_7&amp;diff=3925"/>
		<updated>2012-03-06T06:37:36Z</updated>

		<summary type="html">&lt;p&gt;Zab: oops linkfix&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{GamePage}}&lt;br /&gt;
{{NoModdingInfo}}&lt;br /&gt;
&lt;br /&gt;
Stellar 7 was released in the 1980s for various platforms ending with a PC version in 1990.&lt;br /&gt;
&lt;br /&gt;
The PC version appears to have been compiled with a Microsoft C compiler. Much of the data is stored in bundled .RES files but a decent amount is also hard-coded in the compressed executable. Some of the data in the external files is also compressed using an [[LZW compression|LZW algorithm]].&lt;br /&gt;
&lt;br /&gt;
== File formats ==&lt;br /&gt;
&lt;br /&gt;
This section lists the file formats used in the game.&lt;br /&gt;
&lt;br /&gt;
* [[RES Format (Stellar 7)|RES Format]] - group files storing most of the game data&lt;br /&gt;
&lt;br /&gt;
There are 29 files in the PC version using the RES format.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Filename!!Description&lt;br /&gt;
|-&lt;br /&gt;
|STELLAR.RES||Video/Audio (drivers?), probably the game intro song, what looks like fonts, and others.&lt;br /&gt;
|-&lt;br /&gt;
|COCKPIT.RES||Cockpit graphics and sound effects, mission briefing text, and others.&lt;br /&gt;
|-&lt;br /&gt;
|DRAXON.RES||A single SNG: media entry.&lt;br /&gt;
|-&lt;br /&gt;
|VOICE.RES||Contains some SNG: media entries.&lt;br /&gt;
|-&lt;br /&gt;
|LEVEL&#039;&#039;#&#039;&#039;.RES||There are seven level files where &#039;&#039;#&#039;&#039; is 1-7. These files contain background images in VGA and EGA/CGA, a sound entry, and what appears to be a table of level data.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The rest of the files come in two versions, a VGA version and an EGA/CGA version. The easy-to-spot difference between them is the EGA files have a letter E after them. The files are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Filename!!Description&lt;br /&gt;
|-&lt;br /&gt;
|STELART.RES / STELARTE.RES|| Art files with palette info necessary to parse images from anywhere else.&lt;br /&gt;
|-&lt;br /&gt;
|SCENE&#039;&#039;x&#039;&#039;.RES / SCENE&#039;&#039;x&#039;&#039;E.RES||Sixteen &amp;quot;scene&amp;quot; files, eight each where &#039;&#039;x&#039;&#039; is one of A, B1, B2, B3, B5, C, D, or E.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Other Files ==&lt;br /&gt;
&lt;br /&gt;
The file &#039;&#039;RESOURCE.CFG&#039;&#039; is referenced by the executable, though it is unclear how it is being used.&lt;br /&gt;
&lt;br /&gt;
[[Category:Sierra]]&lt;br /&gt;
[[Category:3D]]&lt;br /&gt;
[[Category:First-Person Shooter]]&lt;/div&gt;</summary>
		<author><name>Zab</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Stellar_7&amp;diff=3924</id>
		<title>Stellar 7</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Stellar_7&amp;diff=3924"/>
		<updated>2012-03-06T05:38:44Z</updated>

		<summary type="html">&lt;p&gt;Zab: Added files block from the format article and some other text&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{GamePage}}&lt;br /&gt;
{{NoModdingInfo}}&lt;br /&gt;
&lt;br /&gt;
Stellar 7 was released in the 1980s for various platforms ending with a PC version in 1990.&lt;br /&gt;
&lt;br /&gt;
The PC version appears to have been compiled with a Microsoft C compiler. Much of the data is stored in bundled .RES files but a decent amount is also hard-coded in the compressed executable. Some of the data in the external files is also compressed using a variant of [[LZW]].&lt;br /&gt;
&lt;br /&gt;
== File formats ==&lt;br /&gt;
&lt;br /&gt;
This section lists the file formats used in the game.&lt;br /&gt;
&lt;br /&gt;
* [[RES Format (Stellar 7)|RES Format]] - group files storing most of the game data&lt;br /&gt;
&lt;br /&gt;
There are 29 files in the PC version using the RES format.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Filename!!Description&lt;br /&gt;
|-&lt;br /&gt;
|STELLAR.RES||Video/Audio (drivers?), probably the game intro song, what looks like fonts, and others.&lt;br /&gt;
|-&lt;br /&gt;
|COCKPIT.RES||Cockpit graphics and sound effects, mission briefing text, and others.&lt;br /&gt;
|-&lt;br /&gt;
|DRAXON.RES||A single SNG: media entry.&lt;br /&gt;
|-&lt;br /&gt;
|VOICE.RES||Contains some SNG: media entries.&lt;br /&gt;
|-&lt;br /&gt;
|LEVEL&#039;&#039;#&#039;&#039;.RES||There are seven level files where &#039;&#039;#&#039;&#039; is 1-7. These files contain background images in VGA and EGA/CGA, a sound entry, and what appears to be a table of level data.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The rest of the files come in two versions, a VGA version and an EGA/CGA version. The easy-to-spot difference between them is the EGA files have a letter E after them. The files are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Filename!!Description&lt;br /&gt;
|-&lt;br /&gt;
|STELART.RES / STELARTE.RES|| Art files with palette info necessary to parse images from anywhere else.&lt;br /&gt;
|-&lt;br /&gt;
|SCENE&#039;&#039;x&#039;&#039;.RES / SCENE&#039;&#039;x&#039;&#039;E.RES||Sixteen &amp;quot;scene&amp;quot; files, eight each where &#039;&#039;x&#039;&#039; is one of A, B1, B2, B3, B5, C, D, or E.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Other Files ==&lt;br /&gt;
&lt;br /&gt;
The file &#039;&#039;RESOURCE.CFG&#039;&#039; is referenced by the executable, though it is unclear how it is being used.&lt;br /&gt;
&lt;br /&gt;
[[Category:Sierra]]&lt;br /&gt;
[[Category:3D]]&lt;br /&gt;
[[Category:First-Person Shooter]]&lt;/div&gt;</summary>
		<author><name>Zab</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=RES_Format_(Stellar_7)&amp;diff=3923</id>
		<title>RES Format (Stellar 7)</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=RES_Format_(Stellar_7)&amp;diff=3923"/>
		<updated>2012-03-06T05:35:46Z</updated>

		<summary type="html">&lt;p&gt;Zab: Moving files to Stellar 7&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NeedMoreInfo}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;RES format&#039;&#039;&#039; is used by [[Stellar 7]] to store much of the game data. The PC version has 29 files using this format.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
&lt;br /&gt;
It is a binary format containing any number of &#039;&#039;entries&#039;&#039; which themselves can contain other entries. Various items are stored in these files, such as compressed images and palette data, or the mission briefing text. The entries begin with a content type which can be clearly read even with a text editor.&lt;br /&gt;
&lt;br /&gt;
=== Signature ===&lt;br /&gt;
&lt;br /&gt;
There is no known signature, other than carefully reading the file structure and verifying it seems correct (e.g. offsets don&#039;t go past the end of the file.)&lt;br /&gt;
&lt;br /&gt;
=== File entry ===&lt;br /&gt;
&lt;br /&gt;
The file consists of one or more file entries, one after the other.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|char contentType[4]||Content type (see below), not null-terminated&lt;br /&gt;
|-&lt;br /&gt;
|UINT32LE isfolder_length||Length of the data, most significant bit is folder bit&lt;br /&gt;
|-&lt;br /&gt;
|BYTE data[length]||&amp;lt;tt&amp;gt;length&amp;lt;/tt&amp;gt; bytes of data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If the most significant bit in &amp;lt;tt&amp;gt;isfolder_length&amp;lt;/tt&amp;gt; is set, the &amp;lt;tt&amp;gt;data&amp;lt;/tt&amp;gt; is comprised of more file entries in the same format as above (sort of like a subdirectory.)  The values can be extracted like this:&lt;br /&gt;
&lt;br /&gt;
  length = isfolder_length &amp;amp; 0x7FFFFFFF&lt;br /&gt;
  if (isfolder_length &amp;amp; 0x80000000) then it is a folder&lt;br /&gt;
&lt;br /&gt;
=== Content types ===&lt;br /&gt;
&lt;br /&gt;
The following values for contentType are known.  Any types that refer to sub-blocks mean &amp;quot;files&amp;quot; in the &amp;quot;subdirectory&amp;quot; as described above.&lt;br /&gt;
&lt;br /&gt;
==== BMP: Image ====&lt;br /&gt;
&lt;br /&gt;
The game supports VGA and earlier modes including EGA and CGA. The main palette information for VGA is located in the file &#039;&#039;STELART.RES&#039;&#039; while the EGA/CGA palettes are in &#039;&#039;STELARTE.RES&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
==== PAL: Palette ====&lt;br /&gt;
&lt;br /&gt;
The PAL: block contains palette data.  It has sub-blocks for different palette types:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|VGA:||[[VGA Palette]] (three byte, 0-63)&lt;br /&gt;
|-&lt;br /&gt;
|EGA:||&lt;br /&gt;
|-&lt;br /&gt;
|CGA:||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== SCR: Fullscreen image ====&lt;br /&gt;
&lt;br /&gt;
Fullscreen images are 320x200 pixels; 32,000 bytes for EGA and 64,000 bytes for VGA.&lt;br /&gt;
&lt;br /&gt;
The VGA files are split into two 32,000 byte &amp;quot;planes&amp;quot; using two pixels per byte. The second plane contains the more significant bits. If the starting bytes of the first plane are 0xFD 0xFF and the second plane are 0x99 0x88 then the first four horizontal pixels are palette entries 0x9F 0x9D 0x8F 0x8F.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BIN:||32000 byte (16-colour EGA / Least significant VGA bits)&lt;br /&gt;
|-&lt;br /&gt;
|VGA:||32000 byte (Most significant VGA bits)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== VER: Version ====&lt;br /&gt;
&lt;br /&gt;
Null terminated version string (e.g. &amp;quot;3.37&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
==== SSM: Sounds and music ====&lt;br /&gt;
&lt;br /&gt;
The SSM: block seems to contain media data in most cases. It has sub-blocks for different media types:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|SNG:||Song?  Seems to be 8-bit unsigned 11025Hz PCM data with an unknown header&lt;br /&gt;
|-&lt;br /&gt;
|SNG:||Song - also can contain raw MIDI data (theme song is in this format)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The file &amp;lt;tt&amp;gt;STELLAR.RES&amp;lt;/tt&amp;gt; contains three SSM: entries; two of them contain SNG: blocks while the third has entries for various sound cards, most likely a version of the theme song in a format suitable for that device.  The content type tags for these are as follows:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|STD:||?&lt;br /&gt;
|-&lt;br /&gt;
|TAN:||Tandy&lt;br /&gt;
|-&lt;br /&gt;
|M32:||Roland?&lt;br /&gt;
|-&lt;br /&gt;
|ADL:||AdLib&lt;br /&gt;
|-&lt;br /&gt;
|SBL:||Sound Blaster&lt;br /&gt;
|-&lt;br /&gt;
|001:||?&lt;br /&gt;
|-&lt;br /&gt;
|002:||?&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Compression ==&lt;br /&gt;
&lt;br /&gt;
Some file entries are compressed using the [[LZW compression|LZW algorithm]]. The entries which are compressed cannot be identified by the 4-byte content type alone, and it is suspected that certain types are always compressed. Those entries that are compressed are in the following layout:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BYTE unknown||Compression algorithm?  Always seems to be 0x02&lt;br /&gt;
|-&lt;br /&gt;
|UINT32LE decompressedSize||Size of data after decompression&lt;br /&gt;
|-&lt;br /&gt;
|BYTE data[]||LZW-compressed data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following content types never seem to be compressed:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|VQT:||&lt;br /&gt;
|-&lt;br /&gt;
|FNT:||&lt;br /&gt;
|-&lt;br /&gt;
|ARR:||&lt;br /&gt;
|-&lt;br /&gt;
|PAG:||&lt;br /&gt;
|-&lt;br /&gt;
|VGA:|| Only if contained within a &#039;&#039;&#039;PAL:&#039;&#039;&#039; folder entry. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The LZW algorithm uses a dynamic bit length, from 9 bits to 12 bits.  Data is split into bytes in little-endian order.  The first codeword is 257, with code 256 reserved to indicate a dictionary reset.&lt;br /&gt;
&lt;br /&gt;
When the dictionary is reset, some bytes in the input data are discarded.  Why this happens is currently unknown.  The number of bytes discarded seems to vary depending on the number of bytes read (perhaps it is aligning to a DWORD boundary?)&lt;br /&gt;
&lt;br /&gt;
There is some [http://code.google.com/p/scummvm-dgds/source/browse/trunk/compression.cpp sample decompression code] for similar games which seems to (mostly) work.&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This file format was reverse engineered by [[User:Malvineous|Malvineous]], with some subformats identified by [[User:Zab|Zab]].  Hints about the compression algorithm were obtained from the ScummVM project.  If you find this information helpful in a project you&#039;re working on, please give credit where credit is due.  (A link back to this wiki would be nice too!)&lt;br /&gt;
&lt;br /&gt;
[[Category:Stellar 7]]&lt;br /&gt;
[[Category:File Formats]]&lt;br /&gt;
[[Category:Group Files]]&lt;br /&gt;
[[Category:Group Files with embedded FAT]]&lt;/div&gt;</summary>
		<author><name>Zab</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Talk:RES_Format_(Stellar_7)&amp;diff=3922</id>
		<title>Talk:RES Format (Stellar 7)</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Talk:RES_Format_(Stellar_7)&amp;diff=3922"/>
		<updated>2012-03-03T18:31:39Z</updated>

		<summary type="html">&lt;p&gt;Zab: Starting LZW discussion&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Compression ==&lt;br /&gt;
I was able to get an LZW decompressor working beautifully up until some time after code reset 0x100 is encountered. I&#039;m using [http://cibyl.googlecode.com/svn/sarien-cibyl/trunk/src/core/lzw.c this source] with some compatibility fixes. I&#039;m wondering how much is known about discarding bytes. Using LEVEL1.RES for example, the third compressed block has a code reset about 2/3rds of the way through the finished product. I can finish the decoding if I eat three bytes but the remaining image starts becoming corrupted. The eaten bytes don&#039;t look useless either; even the remaining 8 bits in the buffer produce what looks like the next palette number in the output. Any thoughts? [[User:Zab|Zab]] 18:31, 3 March 2012 (GMT)&lt;/div&gt;</summary>
		<author><name>Zab</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=RES_Format_(Stellar_7)&amp;diff=3919</id>
		<title>RES Format (Stellar 7)</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=RES_Format_(Stellar_7)&amp;diff=3919"/>
		<updated>2012-03-02T20:45:47Z</updated>

		<summary type="html">&lt;p&gt;Zab: Added a bunch of stuff. Will be working more on it.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NeedMoreInfo}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;RES format&#039;&#039;&#039; is used by [[Stellar 7]] to store much of the game data. The PC version has 29 files using this format.&lt;br /&gt;
&lt;br /&gt;
== Files ==&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Filename!!Description&lt;br /&gt;
|-&lt;br /&gt;
|STELLAR.RES||Video/Audio (drivers?), probably the game intro song, what looks like fonts, and others.&lt;br /&gt;
|-&lt;br /&gt;
|COCKPIT.RES||Cockpit graphics and sound effects, mission briefing text, and others.&lt;br /&gt;
|-&lt;br /&gt;
|DRAXON.RES||A single SNG: media entry.&lt;br /&gt;
|-&lt;br /&gt;
|VOICE.RES||Contains some SNG: media entries.&lt;br /&gt;
|-&lt;br /&gt;
|LEVEL&#039;&#039;#&#039;&#039;.RES||There are seven level files where &#039;&#039;#&#039;&#039; is 1-7. These files contain background images in VGA and EGA/CGA, a sound entry, and what appears to be a table of level data.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The rest of the files come in two versions, a VGA version and an EGA/CGA version. The easy-to-spot difference between them is the EGA files have a letter E after them. The files are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Filename!!Description&lt;br /&gt;
|-&lt;br /&gt;
|STELART.RES / STELARTE.RES|| Art files with palette info necessary to parse images from anywhere else.&lt;br /&gt;
|-&lt;br /&gt;
|SCENE&#039;&#039;x&#039;&#039;.RES / SCENE&#039;&#039;x&#039;&#039;E.RES||Sixteen &amp;quot;scene&amp;quot; files, eight each where &#039;&#039;x&#039;&#039; is one of A, B1, B2, B3, B5, C, D, or E.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
&lt;br /&gt;
It is a binary format containing any number of &#039;&#039;entries&#039;&#039; which themselves can contain other entries. Various items are stored in these files, such as compressed images and palette data, or the mission briefing text. The entries begin with a content type which can be clearly read even with a text editor:&lt;br /&gt;
&lt;br /&gt;
[[Image:stellar_7_res_sample.png]]&lt;br /&gt;
&lt;br /&gt;
=== Signature ===&lt;br /&gt;
&lt;br /&gt;
There is no known signature, other than carefully reading the file structure and verifying it seems correct (e.g. offsets don&#039;t go past the end of the file.)&lt;br /&gt;
&lt;br /&gt;
=== File entry ===&lt;br /&gt;
&lt;br /&gt;
The file consists of one or more file entries, one after the other.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|char contentType[4]||Content type (see below), not null-terminated&lt;br /&gt;
|-&lt;br /&gt;
|UINT32LE isfolder_length||Length of the data, MSB is folder bit&lt;br /&gt;
|-&lt;br /&gt;
|BYTE data[length]||&amp;lt;tt&amp;gt;length&amp;lt;/tt&amp;gt; bytes of data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If the most significant bit in &amp;lt;tt&amp;gt;isfolder_length&amp;lt;/tt&amp;gt; is set, the &amp;lt;tt&amp;gt;data&amp;lt;/tt&amp;gt; is comprised of more file entries in the same format as above (sort of like a subdirectory.)  The values can be extracted like this:&lt;br /&gt;
&lt;br /&gt;
  length = isfolder_length &amp;amp; 0x7FFFFFFF&lt;br /&gt;
  if (isfolder_length &amp;amp; 0x80000000) then it is a folder&lt;br /&gt;
&lt;br /&gt;
=== Content types ===&lt;br /&gt;
&lt;br /&gt;
The following values for contentType are known.  Any types that refer to sub-blocks mean &amp;quot;files&amp;quot; in the &amp;quot;subdirectory&amp;quot; as described above.&lt;br /&gt;
&lt;br /&gt;
==== BMP: Image ====&lt;br /&gt;
&lt;br /&gt;
The game supports VGA and earlier modes including EGA and CGA. The main palette information for VGA is located in the file &#039;&#039;STELART.RES&#039;&#039; while the EGA/CGA palettes are in &#039;&#039;STELARTE.RES&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
==== PAL: Palette ====&lt;br /&gt;
&lt;br /&gt;
The PAL: block contains palette data.  It has sub-blocks for different palette types:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|VGA:||[[VGA Palette]] (three byte, 0-63)&lt;br /&gt;
|-&lt;br /&gt;
|EGA:||&lt;br /&gt;
|-&lt;br /&gt;
|CGA:||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== SCR: Fullscreen image ====&lt;br /&gt;
&lt;br /&gt;
Fullscreen images are 320x200 pixels; 32,000 bytes for EGA and 64,000 bytes for VGA.&lt;br /&gt;
&lt;br /&gt;
The VGA files are split into two 32,000 byte &amp;quot;planes&amp;quot; using two pixels per byte. The second plane contains the more significant bits. If the starting bytes of the first plane are 0xFD 0xFF and the second plane are 0x99 0x88 then the first four horizontal pixels are palette entries 0x9F 0x9D 0x8F 0x8F.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BIN:||32000 byte (16-colour EGA / Least significant VGA bits)&lt;br /&gt;
|-&lt;br /&gt;
|VGA:||32000 byte (Most significant VGA bits)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== VER: Version ====&lt;br /&gt;
&lt;br /&gt;
Null terminated version string (e.g. &amp;quot;3.37&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
==== SSM: Sounds and music ====&lt;br /&gt;
&lt;br /&gt;
The SSM: block seems to contain media data in most cases. It has sub-blocks for different media types:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|SNG:||Song?  Seems to be 8-bit unsigned 11025Hz PCM data with an unknown header&lt;br /&gt;
|-&lt;br /&gt;
|SNG:||Song - also can contain raw MIDI data (theme song is in this format)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The file &#039;&#039;STELLAR.RES&#039;&#039; contains three SSM: entries; two of them contain SNG: blocks while the third has entries for what looks like various sound cards (possibly drivers). The content type tags for these are as follows:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!contentType!!Description&lt;br /&gt;
|-&lt;br /&gt;
|STD:||?&lt;br /&gt;
|-&lt;br /&gt;
|TAN:||Tandy&lt;br /&gt;
|-&lt;br /&gt;
|M32:||Roland?&lt;br /&gt;
|-&lt;br /&gt;
|ADL:||AdLib&lt;br /&gt;
|-&lt;br /&gt;
|SBL:||Sound Blaster&lt;br /&gt;
|-&lt;br /&gt;
|001:||?&lt;br /&gt;
|-&lt;br /&gt;
|002:||?&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Compression ==&lt;br /&gt;
&lt;br /&gt;
Some file entries are compressed using an [[LZW algorithm]]. The entries which are compressed cannot be identified by the 4-byte content type alone, and it is suspected that certain types are always compressed. Those entries that are compressed are in the following layout:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|BYTE unknown||Compression algorithm?  Always seems to be 0x02&lt;br /&gt;
|-&lt;br /&gt;
|UINT32LE decompressedSize||Size of data after decompression&lt;br /&gt;
|-&lt;br /&gt;
|BYTE data[]||LZW-compressed data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The following content types never seem to be compressed:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|VQT:||&lt;br /&gt;
|-&lt;br /&gt;
|FNT:||&lt;br /&gt;
|-&lt;br /&gt;
|ARR:||&lt;br /&gt;
|-&lt;br /&gt;
|PAG:||&lt;br /&gt;
|-&lt;br /&gt;
|VGA:|| Only if contained within a &#039;&#039;&#039;PAL:&#039;&#039;&#039; folder entry. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The LZW algorithm uses a dynamic bit length, from 9 bits to 12 bits.  Data is split into bytes in little-endian order.  The first codeword is 257, with code 256 reserved to indicate a dictionary reset.&lt;br /&gt;
&lt;br /&gt;
When the dictionary is reset, some bytes in the input data are discarded.  Why this happens is currently unknown.  The number of bytes discarded seems to vary depending on the number of bytes read (perhaps it is aligning to a DWORD boundary?)&lt;br /&gt;
&lt;br /&gt;
There is some [http://code.google.com/p/scummvm-dgds/source/browse/trunk/compression.cpp sample decompression code] for similar games which seems to (mostly) work.&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This file format was reverse engineered by [[User:Malvineous|Malvineous]].  Hints about the compression algorithm were obtained from the ScummVM project.  If you find this information helpful in a project you&#039;re working on, please give credit where credit is due.  (A link back to this wiki would be nice too!)&lt;br /&gt;
&lt;br /&gt;
[[Category:Stellar 7]]&lt;br /&gt;
[[Category:File Formats]]&lt;br /&gt;
[[Category:Group Files]]&lt;br /&gt;
[[Category:Group Files with embedded FAT]]&lt;/div&gt;</summary>
		<author><name>Zab</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=User:Zab&amp;diff=3917</id>
		<title>User:Zab</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=User:Zab&amp;diff=3917"/>
		<updated>2012-02-29T15:16:22Z</updated>

		<summary type="html">&lt;p&gt;Zab: Fix link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I currently enjoy binary stuff in c++, and I have done hours of work on [[Stellar 7]]. I&#039;ve gotten much help from this wiki so this is where I want to share my work.&lt;/div&gt;</summary>
		<author><name>Zab</name></author>
	</entry>
</feed>