Star Fox:Material Data

From Data Crystal
Revision as of 17:26, 15 February 2020 by SpyderTL (talk | contribs) (Added texture offset table address)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Material Data
Game Star Fox
Start Address 0x010000
End Address 0x017FFF
# of Entries unknown
Entry Length unknown
Total Length 32,768 bytes (0x8000)
Back to the ROM map


Offset  Size    Description
------- ----    -----------
 0x00   1       Material Value
 0x01   1       Material Type

Material Data

Each object has a "base" material address, and each face in the model for that object has a material offset. Each material entry is 2 bytes, has a material type and a material value. Materials can either be textured, shaded by distance and face direction, dynamically shaded, or statically colored. Statically colored materials actually contain two color palette values, and the surface is rendered using a checkerboard pattern, alternating between the two colors. Materials can also be animated by jumping to a separate material table that contains a list of standard materials to be rendered in sequence.

Distance Shaded

Distance shaded materials have a material type of 0x00 to 0x0A, and the material value always matches the material type. These 10 colors are shifted by the game engine based on both the direction of the face in relation to a light source, and the distance of the object from the camera.

Dynamically Shaded

Dynamically shaded materials have a material type of 0x3E, and can be altered by the game engine. For instance, when the player dies, the screen fades to a dark red shade by shifting all of the colors in the dynamic color lookup table at address 0x18B8A.

Statically Colored

Statically colored materials have a material type of 0x3F. The material value contains two colors -- the high 4-bits and the low 4-bits. These colors are rendered on the screen in an alternating checkerboard pattern for a dithering effect that allows more than the standard 16 colors to be displayed. The game engine chooses which palette (day, night, space) to use when rendering these colors to the screen.

Textured Materials

Material Type Texture Width Texture Height Effect
0x40 32 32 Flip Horizontal
0x41 64 64 Flip Horizontal
0x42 8 8 Flip Horizontal
0x43 64 16 Flip Horizontal
0x44 32 8 Flip Horizontal
0x45 32 8
0x46 64 64
0x47 16 8
0x48 32 32
0x49 64 64 Polar Mapped 45 Degrees
0x4a 64 64 Polar Mapped -45 Degrees

Texture Coordinates

The texture coordinates can be found by using the least significant 7 bits of the material value field as an index to the Texture Offset table (0x18918). The texture offset table contains 128 entries of 3-byte addresses. Each entry points to the address of the top left pixel of a texture.

Since each pixel in a texture is 1-byte long, the x/y coordinates can be easily found by subtracting the address of the texture data (0x90000) from the address in the texture offset table, and dividing the result value by 256. However, the address stored in the texture offset table is the RAM address (0x128000), so it must be converted to the ROM address in order to correctly calculate the offset, since the texture data is larger than one page.

The most significant bit of the texture value field selects between texture 1 and texture 2.

Animated Materials

If the high bit of the material type is set, then this material is animated. The low nibble (4-bits) of the material type is combined with the material value to find the 12-bit offset of the animated material in the animated material table, starting at address 0x18000.

Offset  Size    Description
------- ----    -----------
 0x00   1       Frame Count
 0x01   Count*2 Frames

Each frame in the animation has the same format as the normal materials in the material table (i.e. Material Type and Material Value).