Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
types: import many types
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Sep 21, 2024
1 parent 52fe1f6 commit 99c5dd4
Show file tree
Hide file tree
Showing 30 changed files with 1,667 additions and 211 deletions.
46 changes: 46 additions & 0 deletions include/libtrx/game/anims.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#pragma once

#include "math.h"

typedef struct __PACKING {
int16_t goal_anim_state;
int16_t num_ranges;
int16_t range_idx;
} ANIM_CHANGE;

typedef struct __PACKING {
int16_t start_frame;
int16_t end_frame;
int16_t link_anim_num;
int16_t link_frame_num;
} ANIM_RANGE;

#if TR_VERSION == 1
typedef struct __PACKING {
BOUNDS_16 bounds;
XYZ_16 offset;
int16_t nmeshes;
int32_t *mesh_rots;
} FRAME_INFO;
#endif

typedef struct __PACKING {
#if TR_VERSION == 1
FRAME_INFO *frame_ptr;
uint32_t frame_ofs;
#elif TR_VERSION == 2
int16_t *frame_ptr;
#endif
int16_t interpolation;
int16_t current_anim_state;
int32_t velocity;
int32_t acceleration;
int16_t frame_base;
int16_t frame_end;
int16_t jump_anim_num;
int16_t jump_frame_num;
int16_t num_changes;
int16_t change_idx;
int16_t num_commands;
int16_t command_idx;
} ANIM;
14 changes: 5 additions & 9 deletions include/libtrx/game/collision.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "math.h"

#if TR_VERSION == 1
typedef struct COLL_INFO {
typedef struct __PACKING {
int32_t mid_floor;
int32_t mid_ceiling;
int32_t mid_type;
Expand Down Expand Up @@ -37,16 +37,13 @@ typedef struct COLL_INFO {
} COLL_INFO;

#elif TR_VERSION == 2
typedef struct __unaligned
{
typedef struct __PACKING {
int32_t floor;
int32_t ceiling;
int32_t type;
}
COLL_SIDE;
} COLL_SIDE;

typedef struct __unaligned
{
typedef struct __PACKING {
COLL_SIDE side_mid;
COLL_SIDE side_front;
COLL_SIDE side_left;
Expand Down Expand Up @@ -77,6 +74,5 @@ typedef struct __unaligned
uint16_t hit_ceiling: 1; // 0x20 32
uint16_t pad: 10;
// clang-format on
}
COLL_INFO;
} COLL_INFO;
#endif
4 changes: 3 additions & 1 deletion include/libtrx/game/console/common.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "../types.h"

#include <stdbool.h>

typedef enum {
Expand All @@ -9,7 +11,7 @@ typedef enum {
CR_BAD_INVOCATION,
} COMMAND_RESULT;

typedef struct {
typedef struct __PACKING {
const char *prefix;
COMMAND_RESULT (*proc)(const char *args);
} CONSOLE_COMMAND;
Expand Down
25 changes: 25 additions & 0 deletions include/libtrx/game/creature.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
#pragma once

#include "items.h"
#include "lot.h"
#include "math.h"

#include <stdint.h>

typedef enum {
MOOD_BORED = 0,
MOOD_ATTACK = 1,
MOOD_ESCAPE = 2,
MOOD_STALK = 3,
} MOOD_TYPE;

typedef struct __PACKING {
int16_t head_rotation;
int16_t neck_rotation;
int16_t maximum_turn;
uint16_t flags;
int16_t item_num;
MOOD_TYPE mood;
LOT_INFO lot;
XYZ_32 target;
#if TR_VERSION == 2
ITEM_INFO *enemy;
#endif
} CREATURE_INFO;

bool Creature_IsEnemy(const ITEM_INFO *item);
4 changes: 4 additions & 0 deletions include/libtrx/game/effects.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once

#include "effects/exploding_death.h"
#include "effects/types.h"
6 changes: 6 additions & 0 deletions include/libtrx/game/effects/exploding_death.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

#include <stdint.h>

int32_t Effect_ExplodingDeath(
int16_t item_num, int32_t mesh_bits, int16_t damage);
35 changes: 35 additions & 0 deletions include/libtrx/game/effects/types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#pragma once

#include "../math.h"
#include "../objects/ids.h"
#include "../types.h"

typedef struct __PACKING {
XYZ_32 pos;
XYZ_16 rot;
int16_t room_num;
#if TR_VERSION == 1
GAME_OBJECT_ID object_id;
#else
int16_t object_id;
#endif
#if TR_VERSION == 1
int16_t next_draw;
#endif
int16_t next_free;
int16_t next_active;
int16_t speed;
int16_t fall_speed;
int16_t frame_num;
int16_t counter;
int16_t shade;

#if TR_VERSION == 1
struct __PACKING {
struct __PACKING {
XYZ_32 pos;
XYZ_16 rot;
} result, prev;
} interp;
#endif
} FX_INFO;
103 changes: 4 additions & 99 deletions include/libtrx/game/items.h
Original file line number Diff line number Diff line change
@@ -1,101 +1,6 @@
#pragma once

#include "math.h"
#include "objects/ids.h"

#include <stdbool.h>
#include <stdint.h>

#define NO_ITEM (-1)

#pragma pack(push, 1)

#if TR_VERSION == 1
typedef enum {
DS_CARRIED = 0,
DS_FALLING = 1,
DS_DROPPED = 2,
DS_COLLECTED = 3,
} DROP_STATUS;

typedef struct CARRIED_ITEM {
GAME_OBJECT_ID object_id;
int16_t spawn_num;
XYZ_32 pos;
XYZ_16 rot;
int16_t room_num;
int16_t fall_speed;
DROP_STATUS status;
struct CARRIED_ITEM *next_item;
} CARRIED_ITEM;
#endif

typedef struct {
int32_t floor;
uint32_t touch_bits;
uint32_t mesh_bits;
#if TR_VERSION == 1
GAME_OBJECT_ID object_id;
#elif TR_VERSION == 2
int16_t object_id;
#endif
int16_t current_anim_state;
int16_t goal_anim_state;
int16_t required_anim_state;
int16_t anim_num;
int16_t frame_num;
int16_t room_num;
int16_t next_item;
int16_t next_active;
int16_t speed;
int16_t fall_speed;
int16_t hit_points;
int16_t box_num;
int16_t timer;
uint16_t flags;

#if TR_VERSION == 1
int16_t shade;
void *data;
void *priv;
CARRIED_ITEM *carried_item;
#elif TR_VERSION == 2
int16_t shade1;
int16_t shade2;
int16_t carried_item;
void *data;
#endif

XYZ_32 pos;
XYZ_16 rot;

uint16_t active : 1; // 0x0001
uint16_t status : 2; // 0x0002…0x0004
uint16_t gravity : 1; // 0x0008
uint16_t hit_status : 1; // 0x0010
uint16_t collidable : 1; // 0x0020
uint16_t looked_at : 1; // 0x0040
#if TR_VERSION == 1
uint16_t pad : 9; // 0x0080…0x8000
#elif TR_VERSION == 2
uint16_t dynamic_light : 1; // 0x0080
uint16_t killed : 1; // 0x0100
uint16_t pad : 7; // 0x0200…0x8000
#endif

#if TR_VERSION == 1
struct {
struct {
XYZ_32 pos;
XYZ_16 rot;
} result, prev;
} interp;
#endif
} ITEM_INFO;

#pragma pack(pop)

ITEM_INFO *Item_Get(int16_t num);
int32_t Item_GetTotalCount(void);
int32_t Item_GetDistance(const ITEM_INFO *item, const XYZ_32 *target);
void Item_TakeDamage(ITEM_INFO *item, int16_t damage, bool hit_status);
#include "items/common.h"
#include "items/const.h"
#include "items/enum.h"
#include "items/types.h"
10 changes: 10 additions & 0 deletions include/libtrx/game/items/common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

#include "types.h"

#include <stdbool.h>

ITEM_INFO *Item_Get(int16_t num);
int32_t Item_GetTotalCount(void);
int32_t Item_GetDistance(const ITEM_INFO *item, const XYZ_32 *target);
void Item_TakeDamage(ITEM_INFO *item, int16_t damage, bool hit_status);
3 changes: 3 additions & 0 deletions include/libtrx/game/items/const.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

#define NO_ITEM (-1)
20 changes: 20 additions & 0 deletions include/libtrx/game/items/enum.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

#if TR_VERSION == 1
typedef enum {
DS_CARRIED = 0,
DS_FALLING = 1,
DS_DROPPED = 2,
DS_COLLECTED = 3,
} DROP_STATUS;
#endif

// clang-format off
typedef enum {
IF_ONE_SHOT = 0x0100,
IF_CODE_BITS = 0x3E00,
IF_REVERSE = 0x4000,
IF_INVISIBLE = 0x0100,
IF_KILLED = 0x8000,
} ITEM_FLAG;
// clang-format on
Loading

0 comments on commit 99c5dd4

Please sign in to comment.