08-31-2019, 06:50 PM
Summary
This post will be a simple summary of what was found in the discord server over this month.
1.) Compression Format
Gex 3 uses raw deflate for compressing files.
If you are using python, then you can use the standard zlib library to uncompress the data.
2.) Font Sheet
The main font used by the game uses a 128x64 I4 texture.
3.) Objects
There are 963 objects in the game. They are defined in the ROM range 0x818C0 to 0x854F0, where each one is associated with an 8 character string ID.
4.) Levels
There are 30 levels in the game.
At ROM offset 0x8013C and RAM address 0x8007F53C is an array of level information structures. Offsets 0x1C & 0x20 define the ROM region
I made a simple javascript level geometry viewer that will let you view the level geometry data. You can also download the levels as 3D models as either glTF or extended OBJ.
You can download it from the github here: https://github.com/hack64-net/rotm/tree/...gex3viewer
This post will be a simple summary of what was found in the discord server over this month.
1.) Compression Format
Gex 3 uses raw deflate for compressing files.
If you are using python, then you can use the standard zlib library to uncompress the data.
Code:
import zlib
def decompress_raw_deflate(compressed_bytes):
return zlib.decompress(compressed_bytes, wbits=-15)
def compress_raw_deflate(bytes):
return zlib.compress(bytes, level=9)[2:] # Remove zlib header.
2.) Font Sheet
The main font used by the game uses a 128x64 I4 texture.
3.) Objects
There are 963 objects in the game. They are defined in the ROM range 0x818C0 to 0x854F0, where each one is associated with an 8 character string ID.
// 0x10 bytes in size
struct ObjectInfo {
/* 0x00 */ char[8] name_id;
/* 0x08 */ u32 rom_offset_to_compressed_data_start;
/* 0x0C */ u32 rom_offset_to_compressed_data_end;
}
struct ObjectInfo {
/* 0x00 */ char[8] name_id;
/* 0x08 */ u32 rom_offset_to_compressed_data_start;
/* 0x0C */ u32 rom_offset_to_compressed_data_end;
}
4.) Levels
There are 30 levels in the game.
Level Names
At ROM offset 0x8013C and RAM address 0x8007F53C is an array of level information structures. Offsets 0x1C & 0x20 define the ROM region
// 0x54 bytes in size
struct LevelInfo {
/* 0x00 */ char* internal_name;
/* 0x04 */ s16 level_title_text_id;
/* 0x06 */ s16 channel_title_1_text_id;
/* 0x08 */ s16 channel_title_2_text_id;
/* 0x0C */ s16 tv_channel_img_id; // Used in hub areas. 0x06 = Snow, 0x05 = Mystery, etc.
/* 0x0E */ s16 mission_1_text_id;
/* 0x10 */ s16 mission_2_text_id;
/* 0x12 */ s16 mission_3_text_id;
/* 0x14 */ s32 unk_14;
/* 0x18 */ s32 unk_18;
/* 0x1C */ u32 rom_offset_to_compressed_level_data_start;
/* 0x20 */ u32 rom_offset_to_compressed_level_data_end;
/* 0x24 */ u32 unk24_rom_offset_to_asm;
/* 0x28 */ u32 unk28_rom_offset_to_asm;
/* 0x2C */ s32* unk2C_ptr;
/* 0x30 */ s32* unk30_ptr;
/* 0x34 */ s32 unk_34;
/* 0x38 */ u32 unk38_rom_offset;
/* 0x3C */ u32 rom_offset_to_channel_ci4_texture;
/* 0x40 */ u32 rom_offset_to_N64WaveTables;
/* 0x44 */ u32 rom_offset_to_N64PtrTablesV2;
/* 0x48 */ u32 unk48_rom_offset;
/* 0x4C */ u32 unk4C_rom_offset_to_compressed_data;
/* 0x50 */ u32 unk50_rom_offset_to_compressed_data;
}
struct LevelInfo {
/* 0x00 */ char* internal_name;
/* 0x04 */ s16 level_title_text_id;
/* 0x06 */ s16 channel_title_1_text_id;
/* 0x08 */ s16 channel_title_2_text_id;
/* 0x0C */ s16 tv_channel_img_id; // Used in hub areas. 0x06 = Snow, 0x05 = Mystery, etc.
/* 0x0E */ s16 mission_1_text_id;
/* 0x10 */ s16 mission_2_text_id;
/* 0x12 */ s16 mission_3_text_id;
/* 0x14 */ s32 unk_14;
/* 0x18 */ s32 unk_18;
/* 0x1C */ u32 rom_offset_to_compressed_level_data_start;
/* 0x20 */ u32 rom_offset_to_compressed_level_data_end;
/* 0x24 */ u32 unk24_rom_offset_to_asm;
/* 0x28 */ u32 unk28_rom_offset_to_asm;
/* 0x2C */ s32* unk2C_ptr;
/* 0x30 */ s32* unk30_ptr;
/* 0x34 */ s32 unk_34;
/* 0x38 */ u32 unk38_rom_offset;
/* 0x3C */ u32 rom_offset_to_channel_ci4_texture;
/* 0x40 */ u32 rom_offset_to_N64WaveTables;
/* 0x44 */ u32 rom_offset_to_N64PtrTablesV2;
/* 0x48 */ u32 unk48_rom_offset;
/* 0x4C */ u32 unk4C_rom_offset_to_compressed_data;
/* 0x50 */ u32 unk50_rom_offset_to_compressed_data;
}
I made a simple javascript level geometry viewer that will let you view the level geometry data. You can also download the levels as 3D models as either glTF or extended OBJ.
You can download it from the github here: https://github.com/hack64-net/rotm/tree/...gex3viewer