Difference between revisions of "Sonic Heroes/EXE Editing"
From Sonic Retro
(→Material Opcodes) |
(→Known Offsets) |
||
Line 323: | Line 323: | ||
|00<br>01<br>00<br>01<br>01<br>05<br>06<br>00<br>02<br>02 | |00<br>01<br>00<br>01<br>01<br>05<br>06<br>00<br>02<br>02 | ||
|Main HUD interface | |Main HUD interface | ||
+ | | | ||
+ | |- | ||
+ | |0006C369<br>0006C372<br>0006C37B<br>0006C384 | ||
+ | |0046C369<br>0046C372<br>0046C37B<br>0046C384 | ||
+ | |Source Blend<br>Destination Blend<br>Culling<br>Fog | ||
+ | |05<br>02<br>01<br>00 | ||
+ | |Checkpoint Rays | ||
+ | | | ||
+ | |- | ||
+ | |000720A1<br>000720AA<br>000720B3 | ||
+ | |004720A1<br>004720AA<br>004720B3 | ||
+ | |Source Blend<br>Destination Blend<br>Culling | ||
+ | |05<br>02<br>01 | ||
+ | |Flower Rays | ||
| | | | ||
|- | |- | ||
Line 337: | Line 351: | ||
|05<br>06<br>03<br>02 | |05<br>06<br>03<br>02 | ||
|Popped Item Balloon | |Popped Item Balloon | ||
+ | | | ||
+ | |- | ||
+ | |0007C04C<br>0007C055<br>0007C05E | ||
+ | |0047C04C<br>0047C055<br>0047C05E | ||
+ | |Source Blend<br>Destination Blend<br>Culling | ||
+ | |02<br>02<br>00 | ||
+ | |Lasers | ||
| | | | ||
|- | |- |
Revision as of 04:45, 14 February 2017
SCHG: Sonic Heroes |
---|
Main Article |
Mechanic Editing |
DOL Editing |
Model Editing |
Collision Format Model Format |
Level Editing |
Camera Editing |
Particle Editing |
Particle Editing |
Sound Editing |
Music List |
SCHG How-Tos |
Custom Object Material Effect Tutorial |
The main EXE of the PC game is Tsonic_win.exe. The EXE is little endian. The pointer key is 0x400000; to find where a pointer points to, you must subtract that from its value.
Contents
Start/End Positions
Start Positions
List of single player start positions begins at 0x3C2FC8. Each level array has the first 4 bytes setting the level number at the first byte and five 0x1C entries for the four teams and Super Hard (although the Super Hard entry seems to be ignored, it uses Team Sonic's instead). Note that the level IDs used are not the same ones as the level and object lists, they are the ones used in RAM, for example Seaside Hill is 02
Start position entry:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Offset | Type | Description |
---|---|---|
0x00 | Float | X Position |
0x04 | Float | Y Position |
0x08 | Float | Z Position |
0x0C | Word | Pitch (direction) |
0x14 | Byte | Mode 00: Normal 01: Running 02: Rail |
0x18 | Word | Hold time Time spent running |
Ending Positions
List of ending positions begins at 0x3C45B8. These are the places where each team does their victory animation and the results are displayed, after the mission is finished. Each level array has the first 4 bytes setting the level number at the first byte and five 0x14 entries for the four teams and Super Hard. This section has data for single player and multiplayer modes.
End position entry:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Offset | Type | Description |
---|---|---|
0x00 | Float | X Position |
0x04 | Float | Y Position |
0x08 | Float | Z Position |
0x0C | Word | Camera pitch Angle from which the characters are seen |
0x0E | Word | ? (Always FF FF) |
0x10 | Long | Null |
Multiplayer Positions
List of multiplayer start positions begins at 0x3C5E18, after the ending positions. This section has data for the Team Battles and each multiplayer level. The entries are the same as single player start positions, but only have two position entries instead of 5, for the first and second players.
List of multiplayer "bragging" positions begins at 0x3C6380, after the multiplayer start positions. These are the positions where each team makes a comment to the other one, before the multiplayer match starts. This section only has data for each multiplayer level, not the Team Battles. The entries follow the same format as single player ending positions, with five entries.
Splines (incomplete)
Splines set path data for autoloops, rails and probably other path data. The arrays for each level are located in various different places in the EXE. What is known is that each level has a list of pointers. Each pointer points to a spline header, which is defined below. Each spline header points to its list of vertices.
A search reveals there are apparently 62 autoloops and 1075 rails in the entire game. It's possible that some paths are made of multiple splines though.
Grand Metropolis pointer list starts at 0x4B5B60. There are 12 pointers in it. It's not known what points to this list yet. The headers for the splines themselves are just before this pointer list.
Header entry:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Offset | Type | Description |
---|---|---|
0x00 | Word | Always 01 00 |
0x02 | Word | Number of vertices |
0x04 | Float | Total length of spline |
0x08 | Pointer (Long) | Pointer to first vertex of spline |
0x0C | Pointer (Long) | Type of spline 0x433970 (Autoloop) 0x4343F0 (Rail) |
Point entry:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Offset | Type | Description |
---|---|---|
0x00 | Long | Unknown flags (speed?) |
0x04 | Float | Distance to next point Last one is 0 |
0x08 | Float | X Position |
0x0C | Float | Y Position |
0x10 | Float | Z Position |
Material Functions
Material Opcodes
A number of code sections contain additional materials/graphic codes rendered via Renderware engine that provides special effects to an object such as Espio's invisibility.
Function entry:
Regular Material function:
6A 00 6A 00
Offset | Type | Description |
---|---|---|
0x00 and 0x02 | Byte | Always 6A |
0x01 | Byte | Material value |
0x03 | Byte | Material function type |
4 Byte Material function:
68 00000000
Offset | Type | Description |
---|---|---|
0x00 | Byte | Always 68 |
0x01 | 4 Bytes | Material value |
A list of material types are implemented in the EXE.
Material type parameters | Alternative Material type parameters | Hexadecimal type | Description | Parameters | Call Address | Alternative Call Address | Example(s) | Notes |
---|---|---|---|---|---|---|---|---|
01 | Byte | Null | 00 (values upon this will crash the game) | 0024C9B0 (EXE) 0064C9B0 (RAM) |
6A 00 6A 01 | |||
06 | Byte | Z-buffer testing | 00 = Disabled 01 = Enabled |
0024C9B0 (EXE) 0064C9B0 (RAM) |
6A 00 6A 06 | |||
07 | Byte | Shading | 00 = rwSHADEMODEFLAT 01 = rwSHADEMODEGOURAUD |
0024C9B0 (EXE) 0064C9B0 (RAM) |
6A 02 6A 07 | |||
08 | Byte | Z-buffer writing | 00 = Disabled 01 = Enabled |
0024C9B0 (EXE) 0064C9B0 (RAM) |
6A 01 6A 08 | |||
09 | Byte | Texture filtering | 01 = rwFILTERNEAREST 02 = rwFILTERLINEAR 03 = rwFILTERMIPNEAREST 04 = rwFILTERMIPLINEAR 05 = rwFILTERLINEARMIPNEAREST 06 = rwFILTERLINEARMIPLINEAR |
0024C9B0 (EXE) 0064C9B0 (RAM) |
6A 02 6A 09 | |||
0A & 0B | 13 & 14 | Byte | Source Blend Destination Blend |
01 = rwBLENDZERO 02 = rwBLENDONE 03 = rwBLENDSRCCOLOR 04 = rwBLENDINVSRCCOLOR 05 = rwBLENDSRCALPHA 06 = rwBLENDINVSRCALPHA 07 = rwBLENDDESTALPHA 08 = rwBLENDINVDESTALPHA 09 = rwBLENDDESTCOLOR 0A = rwBLENDINVDESTCOLOR 0B = rwBLENDSRCALPHASAT |
0024C9B0 (EXE) 0064C9B0 (RAM) |
00247980 (EXE) 00647980 (RAM) |
6A 05 6A 0A 6A 06 6A 0B 6A 05 6A 13 6A 06 6A 14 |
Models that are completely opaque will not be able to use the intended alpha blending. To make models use different alpha blending modes, change the byte in offset 0x248B1C from 74 to EB. |
0C | 1B | Byte | Vertex Alpha Enabling | 00 = Disabled 01 = Enabled |
0024C9B0 (EXE) 0064C9B0 (RAM) |
00247980 (EXE) 00647980 (RAM) |
6A 01 6A 0C | |
0E | Byte | Fog | 00 = Disabled 01 = Enabled |
0024C9B0 (EXE) 0064C9B0 (RAM) |
6A 00 6A 0E | |||
14 | 16 | Byte | Cull Mode | 01 = None 02 = Back 03 = Front |
0024C9B0 (EXE) 0064C9B0 (RAM) |
00247980 (EXE) 00647980 (RAM) |
6A 02 6A 14 6A 02 6A 16 |
|
18 | Byte | Alpha Testing Reference | 4 Byte Range: 00000000-FF000000 | 00247980 (EXE) 00647980 (RAM) |
68 C8000000 6A 18 | |||
19 | Byte | Alpha Testing | 01 = rwALPHATESTFUNCTIONNEVER 02 = rwALPHATESTFUNCTIONLESS 03 = rwALPHATESTFUNCTIONEQUAL 04 = rwALPHATESTFUNCTIONLESSEQUAL 05 = rwALPHATESTFUNCTIONGREATER 06 = rwALPHATESTFUNCTIONNOTEQUAL 07 = rwALPHATESTFUNCTIONGREATEREQUAL 08 = rwALPHATESTFUNCTIONALWAYS |
00247980 (EXE) 00647980 (RAM) |
6A 08 6A 19 | |||
AB000000 | 4 Bytes | Blend Equation | 01 = Add 02 = Subtract 03 = Reverse Subtract 04 = Min 05 = Max |
00247980 (EXE) 00647980 (RAM) |
6A 01 68 AB000000 |
Known Offsets
A list shows offsets for special material effects that were discovered in the EXE.
Offsets | RAM Offsets | Materials | Default Parameter Values | Applies on | Notes |
---|---|---|---|---|---|
0001BA94 0001BA9E 0001BAA9 0001BAB3 0001BACC 0001BAD5 0001BAD9 0001BAE3 |
0041BA94 0041BA9E 0041BAA9 0041BAB3 0041BACC 0041BAD5 0041BAD9 0041BAE3 |
Z-testing Z-writing Fog Enabling Culling Source Blend #1 Destination Blend #1 Source Blend #2 Destination Blend #2 |
00 00 00 01 02 06 05 02 |
Warp Effects | |
0001E0A1 0001E0AD 0001E0B6 0001E0BF 0001E0C8 0001E0D1 0001E0DA 0001E0E3 0001E0EC 0001E0F8 |
0041E0A1 0041E0AD 0041E0B6 0041E0BF 0041E0C8 0041E0D1 0041E0DA 0041E0E3 0041E0EC 0041E0F8 |
Z-testing Z-writing Fog Enabling Culling Vertex Alpha Enabling Source Blend Destination Blend Null Material Shade Mode Texture Filtering |
00 01 00 01 01 05 06 00 02 02 |
Main HUD interface | |
0006C369 0006C372 0006C37B 0006C384 |
0046C369 0046C372 0046C37B 0046C384 |
Source Blend Destination Blend Culling Fog |
05 02 01 00 |
Checkpoint Rays | |
000720A1 000720AA 000720B3 |
004720A1 004720AA 004720B3 |
Source Blend Destination Blend Culling |
05 02 01 |
Flower Rays | |
00076404 0007640D 00076416 |
00476404 0047640D 00476416 |
Source Blend Destination Blend Culling |
02 06 01 |
Hint Ring Question Mark | |
00078361 0007836A 00078373 0007838B |
00478361 0047836A 00478373 0047838B |
Source Blend Destination Blend Culling #1 Culling #2 |
05 06 03 02 |
Popped Item Balloon | |
0007C04C 0007C055 0007C05E |
0047C04C 0047C055 0047C05E |
Source Blend Destination Blend Culling |
02 02 00 |
Lasers | |
0008AC09 0008AC12 0008AC1B |
0048AC09 0048AC12 0048AC1B |
Source Blend Destination Blend Culling |
05 02 01 |
Fading Target Switch | |
000FEE13 000FEE1C 000FEE25 |
004FEE13 004FEE1C 004FEE25 |
Source Blend Destination Blend Culling |
02 02 01 |
Mystic Mansion Lights | |
00103401 00103409 00103412 |
00503401 00503409 00503412 |
Source Blend Destination Blend Culling |
02 02 01 |
Teleporter Switch Glowing Symbols | |
00107BE4 00107BED 00107BF6 |
00507BE4 00507BED 00507BF6 |
Source Blend Destination Blend Culling |
05 02 01 |
Thunder lightening with skulls | |
001D2B99 001D2BA2 001D2BAE 001D2BB7 001D2BC0 |
005D2B99 005D2BA2 005D2BAE 005D2BB7 005D2BC0 |
Source Blend Destination Blend Culling Vertex Alpha Enabling Fog Enabling |
05 02 02 01 00 |
Espio's Invisibility | |
006387B4 006387BD 006387C6 006387CF |
006387B4 006387BD 006387C6 006387CF |
Source Blend Destination Blend Culling Fog Enabling |
05 02 01 00 |
Light Streak Effects | |
002396AD 002396B6 002396BF 002396CB 002396D4 002396DD |
006396AD 006396B6 006396BF 006396CB 006396D4 006396DD |
Source Blend Destination Blend Culling Null Material Vertex Alpha Enabling Fog Enabling |
05 02 01 00 01 00 |
Character Trail Effects |
Material Flags
Somewhat like BSPs with identifiers stored in .ONE files, objects have their own material flags stored in the code. Objects that use material flags provide a rendering effect through the main rendering code sections when applied to an object after it appears. Examples of objects that use material flags are Energy paths and HEXAeco Signboards. Note that not all objects use material flags separately for each model loaded in the level.
Flag offset pointer entry:
00 72 00 00 00
Offset | Type | Description |
---|---|---|
0x00 | Byte | Pointer flag |
0x01 | 4 bytes | Always 72 00 00 00 |
Flag entry:
00 00 00 00 00 00 00 00 00
Offset | Type | Description |
---|---|---|
0x01 | Byte | Flag |
0x00 | Long | Null |
A list of identifier flags for objects are the following pointer and regular bytes:
Flag pointer:
Flag | Identifier | Description | Notes |
---|---|---|---|
54 | ?? | Invisible geometry | Usually used if the object set has individual material flags stored somewhere in the EXE and RAM. |
58 | DN | Sky model material | |
5C | O | Reflective material | |
60 | OS | Reflective floor material | |
64 | ON | Regular material | |
68 | ONS | Regular floor material | |
6C | ONW | Regular material without culling | |
70 | ONWS | Regular floor material without culling | |
74 | P | Alpha testing with reflective material | |
78 | PS | Alpha testing with reflective floor material | |
7C | PN | Alpha testing material | |
80 | PNS | Alpha testing floor material | |
84 | PNW | Alpha testing material without culling | |
88 | PNWS | Alpha testing floor material without culling | |
8C | DA | Alpha sky material | |
90 | AF | Alpha reflective material | |
94 | AFS | Alpha reflective floor material | |
98 | AFN | Alpha material | |
9C | AFNS | Alpha floor material | |
A0 | K | Additive alpha material | |
A4 | KW | Additive alpha material without culling | |
A8 | A | Alpha reflective material | |
AC | AS | Alpha reflective floor material | |
B0 | AN | Alpha material | |
B4 | ANS | Alpha floor material |
Individual flag ids:
Flag | Identifier | Description | Notes |
---|---|---|---|
00 | ?? | Invisible geometry | Usually used if the object set has individual material flags stored somewhere in the EXE and RAM. |
01 | DN | Sky model material | |
02 | O | Reflective material | |
03 | OS | Reflective floor material | |
04 | ON | Regular material | |
05 | ONS | Regular floor material | |
06 | ONW | Regular material without culling | |
07 | ONWS | Regular floor material without culling | |
08 | P | Alpha testing with reflective material | |
09 | PS | Alpha testing with reflective floor material | |
0A | PN | Alpha testing material | |
0B | PNS | Alpha testing floor material | |
0C | PNW | Alpha testing material without culling | |
0D | PNWS | Alpha testing floor material without culling | |
0E | DA | Alpha sky material | |
0F | AF | Alpha reflective material | |
10 | AFS | Alpha reflective floor material | |
11 | AFN | Alpha material | |
12 | AFNS | Alpha floor material | |
13 | K | Additive alpha material | |
14 | KW | Additive alpha material without culling | |
15 | A | Alpha reflective material | |
16 | AS | Alpha reflective floor material | |
17 | AN | Alpha material | |
18 | ANS | Alpha floor material |
Known Offsets
A list below shows offsets found in the EXE for certain parts of the codes that apply material flags to objects.
Object | Offset(s) | RAM Offsets | Default byte values | Flag Type(s) | Notes |
---|---|---|---|---|---|
Barrier | 001822CF | 005822CF | A4 | Pointer | |
Energy Path Objects | 00173279 0017330B 0017399A |
00573279 0057330B 0057399A |
A0 A0 A4 |
Pointer | |
Grand Metropolis Cloud | 001769FD | 005769FD | 0E | Byte Opcode | |
Hang Castle Clouds | 000F77A5 | 004F77A5 | A4 | Pointer | |
HEXAeco Signboard | 004B446C 004B4484 004B449C |
008B446C 008B4484 008B449C |
04 14 14 |
Byte ID | |
Mystic Mansion Pocket Dimension Bubbles | 00104EEA | 00504EEA | A4 | Pointer | |
Rail Canyon Rails | 000D5A4A 000D5B39 |
004D5A4A 004D5B39 |
A0 | Pointer | |
Seaside Hill Flag | 0049547C | 0009547C | 7C | Pointer |