.RDT (Resident Evil) - pmandin/reevengi-tools GitHub Wiki
The .RDT file format is used to stored the description of a room in Resident Evil on Playstation or PC. It should contain the camera position (to correctly display 3D objects), the background images and sprites used to draw the scene, description of when to change camera, position of enemies when entering room, and so on...
On Sega Saturn version, this file is compressed.
The values are stored in Little-Endian order.
The file is always named roomSXXC.rdt. 'S' is the game status/stage. 'XX' is the location number. 'C' is the character 0 for Chris, 1 for Jill.
A RDT file starts with this header, to store count for different objects.
typedef struct { char unknown0; char num_cameras; /* Number of cameras of the room */ char num_sound_banks; /* Number of sound banks, stored at offset 18 ? */ char unknown1[3]; unsigned short unknown2[3]; /* An array of 3 elements of unknown structure, defined below */ rdt_header_part_t unknown3[3]; } rdt_header_t; typedef struct { long unknown_pos_x; /* Unknown 3D position */ long unknown_pos_y; long unknown_pos_z; unsigned long unknown0[2]; } rdt_header_part_t;
Following the header, we have an array of 19 absolute offsets to various objects in the file.
Offset 0: Camera switches Offset 1: Collision Boundaries for 3D Models (*.SCA) Offset 2: items? obstacles? Offset 3: TMD/TIM; points to 2 offsets which are: offset to a TMD file, and offset to a TIM file Offset 4: unknown Offset 5: unknown Offset 6: Initialization Script(s) (*.SCD) Offset 7: Execution Script(s) (*.SCD) Offset 8: Event scripts (*.EVT) Offset 9: skeleton Offset 10: skeleton animation steps Offset 11: unknown Offset 12: unknown Offset 13: animation for current room. Offset 14: points to an offset, to an unknown structure Offset 15: points to an offset, which holds an offset to a TIM file Offset 16: offset to a RAW image? Offset 17: offset to a VAB file Offset 18: offset to sound bank(s) Offset 19: unknown
At absolute offset 0x94 in a file, you'll find an array of 'num_cameras' items with this structure:
typedef struct { long masks_offset; /* Offset to image mask definition */ long tim_masks_offset; /* Offset to TIM file that contains image masks, if not zero */ long camera_from_x; /* Position of the camera */ long camera_from_y; long camera_from_z; long camera_to_x; /* Where the camera is looking to */ long camera_to_y; long camera_to_z; long unknown1[3]; } rdt_camera_t;
The masks_offset is an offset to an extra structure, which has following header:
typedef struct { unsigned short count_offsets; /* Number of global offsets, or 0xffff for none */ unsigned short unknown; } rdt_masks_t;
Then you have 'rdt_mask_offset_t' items, which have a 8-byte length. Summing all 'count' fields should equal the 'count_masks' of the rdt_masks_t structure.
typedef struct { unsigned short count; /* Number of masks, with which to use this structure */ unsigned short unknown; unsigned short dst_x; /* Destination position on background image/screen, to be added */ unsigned short dst_y; } rdt_mask_offset_t;
And then you have 'rdt_[rect|square]_mask_t' items, which have either 12-byte (rectangular mask) or 8-byte length (square mask). The length is 12 if byte 7 (rdt_square_mask_t.size field) is zero, and 8 otherwise. The 'depth' value is the Z distance of the mask from the camera (low value=near, high value=far).
typedef struct { unsigned char src_x; /* Source position in horr/usa/objspr/ospSSRRC.pak image file */ unsigned char src_y; unsigned char dst_x; /* Destination position on background image/screen */ unsigned char dst_y; unsigned short depth; /* Distance/16 from camera */ unsigned short zero; unsigned short width, height; /* Dimensions of mask */ } rdt_rect_mask_t;
At offset 0, you'll find the list of camera switches for the current room. The list end with the first 4 bytes are 0xffffffff (i.e for cam0 and cam1 values).
typedef struct { unsigned short to; /* Camera number to switch to */ unsigned short from; /* Camera number to switch from */ short x1,y1; /* Zone the player must enter to switch camera */ short x2,y2; short x3,y3; short x4,y4; } rdt_camera_switch_t;
If the 'to' value = 9, then it is a boundary, else it is a camera switch.
This is an array of N structures of the following format, used by script instruction OM_SET (0x1f).
typedef struct { unsigned long tmd_offset; unsigned long tim_offset; } rdt_offset2_t;
This is the initialization script for the room. It starts with an unsigned short giving the length of the script in bytes. Then follows the script, in bytecode-style.
Byte | Instruction | Length | Description |
---|---|---|---|
0x00 | Nop | 2 | |
0x01 | If | 2 |
typedef struct { unsigned char opcode; /* 0x01 */ unsigned char block_length; } script_if_t;This structure is followed by one or several conditions for the if (condition) instruction. Any condition evaluated to false will end the if () block. |
0x02 | Else | 2 | Follows: byte with ELSE block length. Note: it's either If/Endif, or If/Else; there is no If/Else/Endif sequence. |
0x03 | End If | 2 | |
0x04 | BIT_TEST | 4 |
Bit test
typedef struct { unsigned char opcode; /* 0x04 */ unsigned char object; unsigned char param; /* Bits 7-5: Longword index in object, see array following */ /* Bits 4-0: Bit number to test */ unsigned char op; /* Operation */ /* 0x00:test bit is 0 */ /* 0x01:test bit is 1 */ } script_bit_test_t; |
0x05 | BIT_OP | 4 |
Bit operation
typedef struct { unsigned char opcode; /* 0x05 */ unsigned char object; /* Number of object to operate on, see array following */ unsigned char param; /* Bits 7-5: Longword index in object */ /* Bits 4-0: Bit number to clear/set/change is (31-this field value) */ unsigned char op; /* Operation */ /* 0x00:clear bit */ /* 0x01:set bit */ /* 0x02:change bit */ } script_bit_op_t; |
0x06 | OBJ06_TEST | 4 |
Compare values
typedef struct { unsigned char opcode; /* 0x06 */ unsigned char src; /* Index in some object for source value */ /* 0x00:Current stage */ /* 0x01:Current room */ /* 0x02:Current camera */ /* 0x03:Stage and room */ /* 0x04:Previous/next camera */ /* 0x05:? */ /* 0x06:? */ /* 0x07:? Used in instruction 0x1a */ /* 0x08:? Used in instruction 0x1c */ /* 0x09:Flags for current camera */ unsigned char func; /* Compare function */ /* 0x00:EQ */ /* 0x01:LT */ /* 0x02:LE */ /* 0x03:GT */ /* 0x04:GE */ /* 0x05:NE */ char param; /* Raw value to compare against */ } script_obj06_test_t; |
0x07 | OBJ07_TEST | 6 |
Compare values
typedef struct { unsigned char opcode; /* 0x07 */ unsigned char dummy; unsigned char src; /* Word index in some object for source value */ /* (not the same object as instruction 0x06) */ unsigned char func; /* Compare function */ /* 0x00:EQ */ /* 0x01:LT */ /* 0x02:LE */ /* 0x03:GT */ /* 0x04:GE */ /* 0x05:NE */ short param; /* Raw value to compare against */ } script_obj07_test_t; |
0x08 | OBJ06_SET | 4 |
Set value in object used for instruction 0x06
typedef struct { unsigned char opcode; /* 0x08 */ unsigned char src; /* Index in some object, see instruction 0x06 */ char value; /* New value */ unsigned char dummy; } script_obj06_set_t; |
0x09 | CUT_SET | 2 | Switch to prev/next camera, set it as current camera |
0x0a | CUT_SET | 2 | Switch to current camera, set it as prev/next camera |
0x0b | ? | 4 | |
0x0c | DOOR_SET | 26 |
TODO: find where next_camera is stored
typedef struct { unsigned char opcode; /* 0x0c */ unsigned char id; short x,y,w,h; unsigned char anim; /* Door animation, i.e. index in array of door filenames (see below) */ unsigned char unknown0[4]; unsigned char next_stage_and_room; /* bits 7,6,5: stage, 4,3,2,1,0: room */ short next_x,next_y,next_z; short next_dir; unsigned char unknown2[2]; } script_door_set_t; /* Files are located in item_m1 directory */ const char *doorfiles[]={ "door00.dor", "door01.dor", "door02.dor", "door03.dor", "door04.dor", "door05.dor", "door06.dor", "door07.dor", "door08.dor", "door09.dor", "door10.dor", "door11.dor", "door12.dor", "door13.dor", "door14.dor", "mon.dor", "ele03.dor", "ele01.dor", "ele01a.dor", "ele01b.dor", "ele02.dor", "ele04.dor", "kai01.dor", "kai03.dor", "kai02.dor", "kai04.dor", "lad01.dor", "lad02.dor", "door00k.dor", "door01k.dor", "door03k.dor", "door05k.dor", "door06k.dor", "door15.dor" };Note: if stage=0, we must keep current stage, else switch stage. |
0x0d | ITEM_SET | 18 |
Pickable items, objects, obstacles
typedef struct { unsigned char opcode; /* 0x0d */ unsigned char id; short x,y,w,h; unsigned char type; /* 0x02: message, obstacle? */ /* 0x07: trigger,event,movable object? */ /* 0x08: box */ /* 0x09: pickable object, trigger? */ /* 0x10: typewriter */ unsigned char unknown[7]; } script_item_set_t; |
0x0e | Nop | 2 | |
0x0f | ? | 8 |
typedef struct { unsigned char opcode; /* 0x0f */ unsigned char bitmask; unsigned short unknown[3]; } script_inst0f_t; |
Byte | Instruction | Length | Description |
---|---|---|---|
0x10 | OBJ10_TEST | 2 |
Check if obj10 has value given as parameter
typedef struct { unsigned char opcode; /* 0x10 */ char value; } script_obj10_test_t; |
0x11 | OBJ11_TEST | 2 |
Check if obj11 has value given as parameter
typedef struct { unsigned char opcode; /* 0x11 */ char value; } script_obj11_test_t; |
0x12 | Item 0x12 | 10 |
Typewriter? Stairs?
typedef struct { unsigned char opcode; /* 0x12 */ unsigned char id; unsigned char unknown0[2]; short unknown1[3]; } script_inst12_t; |
0x13 | Item 0x13 | 4 |
typedef struct { unsigned char opcode; /* 0x13 */ unsigned char id; unsigned char unknown0[2]; } script_inst13_t; |
0x14 | ? | 4 |
typedef struct { unsigned char opcode; /* 0x14 */ unsigned char dummy; unsigned char param1; unsigned char param2; } script_inst14_t; |
0x15 | ? | 2 | |
0x16 | ? | 2 | Volume set? |
0x17 | ? | 10 | |
0x18 | ITEM_MODEL_SET | 26 |
typedef struct { unsigned char opcode; /* 0x18 */ unsigned char id; unsigned char unknown[24]; } script_item_model_set_t; |
0x19 | OBJ19_SET | 4 |
Set value in obj19
typedef struct { unsigned char opcode; /* 0x09 */ unsigned char src; /* Index in some object */ char value; /* New value */ unsigned char dummy; } script_obj19_set_t; |
0x1a | ? | 2 | |
0x1b | EM_SET | 22 |
Entity (enemy, other character)
typedef struct { unsigned char opcode; /* 0x1b */ unsigned char model; unsigned char unknown0[4]; /* unknown0[1]=0xff for other character, else enemy */ long x,y,z; short dir; unsigned short unknown1; } script_em_set_t; |
0x1c | ? | 6 |
typedef struct { unsigned char opcode; /* 0x1c */ unsigned char unknown0; unsigned short unknown1[2]; } script_inst1c_t; |
0x1d | ? | 2 | |
0x1e | ? | 4 |
typedef struct { unsigned char opcode; /* 0x1e */ unsigned char unknown0; unsigned short unknown1; } script_inst1e_t; |
0x1f | OM_SET | 28 |
Movable (crate, statue) or animated (lid) objects?
typedef struct { unsigned char opcode; /* 0x1f */ unsigned char id; /* Bits 5-0: Index in array stored at offset 2 of RDT file */ unsigned char type; /* 0x11: safe lid ? */ unsigned char unknown[25]; } script_om_set_t; |
Byte | Instruction | Length | Description |
---|---|---|---|
0x20 | ? | 14 |
Change player position and direction?
typedef struct { unsigned char opcode; /* 0x20 */ unsigned char dummy; short dir_x,dir_y,dir_z; short pos_x,pos_y,pos_z; } script_inst20_t; |
0x21 | ? | 14 | |
0x22 | ? | 4 | |
0x23 | ? | 2 |
typedef struct { unsigned char opcode; /* 0x23 */ unsigned char flag; } script_inst23_t; |
0x24 | ? | 4 | |
0x25 | ? | 4 | |
0x27 | ? | 2 | |
0x28 | ? | 4,6 or 8 | |
0x29 | ? | 2 | Select sound bank? |
0x2a | ? | 12 | |
0x2b | ? | 4 | |
0x2c | ? | 2 | |
0x2d | ? | 4 | |
0x2f | ? | 4 |
Byte | Instruction | Length | Description |
---|---|---|---|
0x30 | ? | 12 | |
0x31 | ? | 4 | |
0x32 | ? | 4 | |
0x33 | ? | 2 or 4 | |
0x34 | ? | 8 | |
0x35 | ? | 4 | |
0x36 | ? | 4 | |
0x37 | ? | 4 | |
0x38 | ? | 4 | |
0x39 | ? | 2 | |
0x3a | ? | 4 | |
0x3b | ? | 6 | |
0x3c | ? | 6 | |
0x3d | ? | 12 | |
0x3e | ? | 2 | |
0x3f | ? | 6 |
Byte | Instruction | Length | Description |
---|---|---|---|
0x40 | ? | 16 | |
0x41 | ? | 4 | |
0x42 | ? | 4 | |
0x43 | ? | 4 | |
0x44 | ? | 2 | |
0x45 | ? | 2 | |
0x46 | ? | 2+12*n+2*m (was 44) | |
0x47 | ? | 14 | |
0x48 | ? | 2 | |
0x49 | ? | 2 | |
0x4a | ? | 2 | |
0x4b | ? | 2 | |
0x4c | ? | 4 |
Set value in OBJ06 ?
typedef struct { unsigned char opcode; /* 0x4c */ unsigned char unknown[3]; } script_inst4c_t; |
0x4d | ? | 2 | |
0x4e | ? | 4 | |
0x4f | ? | 2 | |
0x50 | ? | 2 |
Object number | Description |
---|---|
0 | ? |
1 | ? |
2 | ? |
3 | ? |
4 | ? |
5 | Game status Bit 23:Player character (0:Chris, 1:Jill, or vice versa). |
6 | ? |
7 | ? |
8 | ? |
9 | ? |
This script is run regularly to update stuff in current room. It follows same structure as the one at offset 6.
This structure starts with a NULL terminated list of 'unsigned long', which are offsets relative to start of this object. These offsets store also some bytecodes, different than those above.
Byte | Instruction | Length | Description |
---|---|---|---|
0xf6 | ? | 1 | Init some stuff related to instruction 0xf7 |
0xf7 | ? | 1 | |
0xf8 | ? | 1 | Init some stuff related to instruction 0xf8 |
0xf9 | ? | 1 or 3 | |
0xfa | For | 4 |
typedef struct { unsigned char opcode; /* 0xfa */ unsigned char dummy; unsigned short count; } event_for_t;Initialize a for loop. |
0xfb | Next | 1 | |
0xfc | Set_Inst | variable |
typedef struct { unsigned char opcode; /* 0xfc */ unsigned char block_length; unsigned char bytecode_inst[]; } event_set_inst_t;Initialize bytecode instruction to execute later. |
0xfd | Exec_inst | 1 | Execute bytecode instruction previously set with 0xfc instruction. |
0xfe | Sleep, process next event | 1 | |
0xff | Disable event | 1 |
See File/Section 0 of .EMD
See File/Section 1 of .EMD