Skip to content

# Game structs

> Typed views of game structs in guest RAM.

> Generated by the engine build; do not edit.

> Layouts come from the decompilation, which builds a byte-identical PSX binary. Pointer fields are uint32_t guest vaddrs; resolve them with `api->guest()`. The `_Static_assert`s at the end pin every size and offset, so a layout change fails the mod's compile.

## `Vector3D`

`sizeof == 0xc`. The layout is pinned, so drift fails the mod's compile rather than a player's session.

    typedef struct Vector3D {
      int x, y, z;
    } Vector3D;

## `Vector3D8`

`sizeof == 0x3`. The layout is pinned, so drift fails the mod's compile rather than a player's session.

    typedef struct Vector3D8 {
      uint8_t x, y, z;
    } Vector3D8;

## `SHORTMATRIX`

`sizeof == 0x14`. The layout is pinned, so drift fails the mod's compile rather than a player's session.

    typedef struct SHORTMATRIX {
      short m[3][3]; /**< 3x3 rotation matrix. */
      short _pad;    /**< padding. */
    } SHORTMATRIX;

## `AnimationState`

`sizeof == 0x7`. The layout is pinned, so drift fails the mod's compile rather than a player's session.

    typedef struct AnimationState {
      /** @brief Which animation is currently playing. */
      uint8_t m_Animation;

      /** @brief Which animation you're interpolating to. */
      uint8_t m_NextAnimation;

      /** @brief The current frame. */
      uint8_t m_Frame;

      /** @brief The next frame which you're interpolating to. */
      uint8_t m_NextFrame;

      /** @brief The progress of the current frame used for interpolation. */
      uint8_t m_FrameProgress;

      /** @brief The amount of progress to make per frame. */
      uint8_t m_PerFrameProgress;

      /** @brief Flags that are set by the animation system. */
      uint8_t m_AnimationFlags;
    } AnimationState;

## `Moby`

`sizeof == 0x58`. The layout is pinned, so drift fails the mod's compile rather than a player's session.

Field | Offset
--- | ---
`m_Props` | `0x0`
`m_Position` | `0xc`
`m_DamageFlags` | `0x18`
`m_RotationMatrix` | `0x20`
`m_CollisionRegion` | `0x34`
`m_Class` | `0x36`
`m_AnimationState` | `0x3c`
`m_Rotation` | `0x44`
`m_State` | `0x48`
`m_SectorIndex` | `0x4a`
`m_RenderRadius` | `0x50`
`m_WasDrawn` | `0x51`
`m_UpdateDistance` | `0x52`

    typedef struct Moby {
      /** @brief Specifies the properties of the moby, which is class specific. */
      uint32_t m_Props; /**< Guest pointer: `void *`. */

      /** @brief The next moby in the collision chain that this Moby is a part of. */
      uint32_t m_CollisionChainNext; /**< Guest pointer: `struct Moby *`. */

      /** @brief This Moby's active collision group (Which is part of it's model). */
      uint32_t m_CollisionGroup; /**< Guest pointer: `void *`. */

      /** @brief The Moby's position. */
      Vector3D m_Position;

      /** @brief The damage that has been applied to the Moby. */
      int m_DamageFlags; // TODO: Enum?

      /** @brief The distance of the shadow from the Moby, equal to the floor. */
      int m_ShadowDistance;

      /** @brief The Moby's rotation matrix. */
      SHORTMATRIX m_RotationMatrix;

      /** @brief The collision region that the Moby is in. */
      short m_CollisionRegion;

      /** @brief The Moby's class, which specifies which kind of Moby it is. */
      short m_Class;

      /** @brief The distance of the moby to the floor. */
      short m_FloorDistance;

      /** @brief Flag used to determine if the Moby has already dropped it's drop. */
      uint8_t m_DroppedFlag;

      /** @brief The range of the Moby's current collision. */
      uint8_t m_CollisionRange;

      /** @brief The Moby's current animation state. */
      AnimationState m_AnimationState;

      /** @brief The Pod that this Moby is a part of. */
      uint8_t m_Pod;

      /** @brief The Moby's rotation. */
      Vector3D8 m_Rotation;

      /** @brief Offsets the sorting depth of the entire Moby. */
      char m_DepthOffset;

      /** @brief The Moby's current state, often used in Moby code. */
      uint8_t m_State;

      /** @brief The Moby's substate, less often used in Moby code. */
      uint8_t m_Substate;

      /** @brief Sector the Moby is located in, for culling purposes. */
      uint8_t m_SectorIndex;

      union {
        struct {
          /** @brief Stores the render distance of the Moby. */
          uint8_t m_Distance : 7;

          /** @brief And the renderer to be used. */
          uint8_t m_ShinyRenderer : 1;
        } flags;
        uint8_t raw;
      } m_Renderer;

      // We have to define it like this, we can't use
      // a bitfield because there's no 24 bit integer
      // type and the compiler aligns it to the
      // integer size used

      // Used for the specular color, which is 6 bits per channel (each value is
      // divided by 2)

      // For metal it's straight forward, 8 bits per channel

      uint8_t m_SpecularMetalColor[3];

      // Stores the type when shinyRenderer is enabled
      // If Shiny renderer: 0 = Specular 1/2 = metal (2 being rotated)
      // If shaded: color index
      uint8_t m_SpecularMetalType;

      /** @brief Radius of the Moby for clipping purposes (>> 2). */
      uint8_t m_RenderRadius;

      // Stores whether the Moby got drawn last frame
      // If it has, the Moby receives more grace during culling
      // Also often used in Moby code, often enemies will not attack when they
      // are off-screen
      uint8_t m_WasDrawn;

      /** @brief The distance at which Mobys get updated (/1024). */
      // Mobys often initialize this to 0xFF
      uint8_t m_UpdateDistance;

      /** @brief Moby class dropped by this Moby. */
      uint8_t m_DropMoby;

      /** @brief Sound channel the moby is occuping. */
      uint8_t m_SoundChannel;

      /** @brief Distance the last sound played was at. */
      uint8_t m_SoundDistance;

      // If dynamically allocated, this contains the index of the Moby that spawned
      // us used for keeping track of which index of the gem bitmask needs to be set
      // Ignored if the moby is not dynamically allocated
      uint8_t m_MobyIndex;

      // Used for resizing the Moby model dynamically, if set to 0 the regular size
      // is used
      uint8_t m_ScaleOverride;
    } Moby;