Objects

From Terranigma Wiki
Revision as of 16:58, 22 February 2016 by Nethraz (talk | contribs) (Added information about double linked list)
Jump to navigation Jump to search

The game uses objects to store runtime information about sprites and scripts, e.g. size and position of a sprite, or the current script address. Each object has a handle in range 0x1000...0x1F80, in steps of 0x40, allowing for a maximum of 63 objects. Object data is stored in chunks of 0x1000 bytes at various places in RAM. Objects are created by declaration in the Map Object Header or by script command.

Object Data

Offsets must be added to the object handle to get the memory address.

Table at 7E1000
Offset Size Description
7E0000 2 X Position (signed)
7E0002 2 Y Position (signed)
7E0004 2 Flags
7E0006 2 Flags2
7E0008 2 Flags3
7E000A 3 Script Pointer, also used for reentry
7E000E 2 Reentry Delay in frames
7E0012 1 Bank for bounds data (used with ptr at 7F000A)
7E0016 2 Elevation level (sprites on different levels can't hit each other)
7E002C 2 Previous Object in List
7E002E 2 Next Object in List
Table at 7F1000
Offset Size Description
7F000A 2 Pointer to Bounding Rect Table [ROM], used with bank at 7E0012
Bounding Rect Table
Offset Size Description
0 4 Map Collision Rect
4 4 Attack Collision Rect
8 4 Defense Collision Rect
Rect
Offset 0 1 2 3
Value Left Width Top Height

Values are signed 8 bit pixel coordinates, relative to the object's X and Y position.

7F0018 2 Movement dx
7F001A 2 Movement dy
Table at 7F2000
Offset Size Description
7F1022 2 Fighting Data Ptr [ROM], Bank: 8D
7F102A 2 Current HP

Double Linked List

Objects are organized in a double linked list. The list defines, among other things, the order in which scripts run.

Double Linked List
Offset Description
0DFA First entry
0DFC Last entry
object[2C] Predecessor
object[2E] Successor