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

Add /sfx; add console word wrap; import /endlevel, /exit, /title, /tp, /demo #35

Merged
merged 9 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/libtrx/game/console/cmd/end_level.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include "../common.h"

extern CONSOLE_COMMAND g_Console_Cmd_EndLevel;
5 changes: 5 additions & 0 deletions include/libtrx/game/console/cmd/exit_game.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include "../common.h"

extern CONSOLE_COMMAND g_Console_Cmd_ExitGame;
5 changes: 5 additions & 0 deletions include/libtrx/game/console/cmd/exit_to_title.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include "../common.h"

extern CONSOLE_COMMAND g_Console_Cmd_ExitToTitle;
5 changes: 5 additions & 0 deletions include/libtrx/game/console/cmd/play_demo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include "../common.h"

extern CONSOLE_COMMAND g_Console_Cmd_PlayDemo;
5 changes: 5 additions & 0 deletions include/libtrx/game/console/cmd/sfx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include "../common.h"

extern CONSOLE_COMMAND g_Console_Cmd_SFX;
5 changes: 5 additions & 0 deletions include/libtrx/game/console/cmd/teleport.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include "../common.h"

extern CONSOLE_COMMAND g_Console_Cmd_Teleport;
11 changes: 9 additions & 2 deletions include/libtrx/game/console/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@ typedef enum {
CR_BAD_INVOCATION,
} COMMAND_RESULT;

typedef struct __PACKING {
typedef struct {
const struct __PACKING CONSOLE_COMMAND *cmd;
const char *prefix;
COMMAND_RESULT (*proc)(const char *args);
const char *args;
} COMMAND_CONTEXT;

typedef struct __PACKING CONSOLE_COMMAND {
const char *prefix;
COMMAND_RESULT (*proc)(const COMMAND_CONTEXT *ctx);
} CONSOLE_COMMAND;

void Console_Log(const char *fmt, ...);
COMMAND_RESULT Console_Eval(const char *cmdline);
3 changes: 2 additions & 1 deletion include/libtrx/game/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@

#define PHD_ONE 0x10000
#define STEP_L 256
#define WALL_L 1024
#define WALL_L 1024 // 1 << WALL_SHIFT
#define WALL_SHIFT 10
13 changes: 13 additions & 0 deletions include/libtrx/game/game_string.def
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,17 @@ GS_DEFINE(OSD_KILL_ALL_FAIL, "Uh-oh, there are no enemies left to kill...")
GS_DEFINE(OSD_KILL, "Bye-bye!")
GS_DEFINE(OSD_KILL_FAIL, "No enemy nearby...")
GS_DEFINE(OSD_INVALID_OBJECT, "Invalid object")
GS_DEFINE(OSD_INVALID_SAMPLE, "Invalid sound: %d")
GS_DEFINE(OSD_OBJECT_NOT_FOUND, "Object not found")
GS_DEFINE(OSD_SOUND_AVAILABLE_SAMPLES, "Available sounds: %s")
GS_DEFINE(OSD_SOUND_PLAYING_SAMPLE, "Playing sound %d")
GS_DEFINE(OSD_UNKNOWN_COMMAND, "Unknown command: %s")
GS_DEFINE(OSD_COMMAND_BAD_INVOCATION, "Invalid invocation: %s")
GS_DEFINE(OSD_COMMAND_UNAVAILABLE, "This command is not currently available")
GS_DEFINE(OSD_INVALID_ROOM, "Invalid room: %d. Valid rooms are 0-%d")
GS_DEFINE(OSD_POS_SET_POS, "Teleported to position: %.3f %.3f %.3f")
GS_DEFINE(OSD_POS_SET_POS_FAIL, "Failed to teleport to position: %.3f %.3f %.3f")
GS_DEFINE(OSD_POS_SET_ROOM, "Teleported to room: %d")
GS_DEFINE(OSD_POS_SET_ROOM_FAIL, "Failed to teleport to room: %d")
GS_DEFINE(OSD_POS_SET_ITEM, "Teleported to object: %s")
GS_DEFINE(OSD_POS_SET_ITEM_FAIL, "Failed to teleport to object: %s")
5 changes: 5 additions & 0 deletions include/libtrx/game/gameflow/common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include "./types.h"

extern void Gameflow_OverrideCommand(GAMEFLOW_COMMAND action);
24 changes: 24 additions & 0 deletions include/libtrx/game/gameflow/types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include <stdint.h>

typedef enum {
GF_CONTINUE_SEQUENCE,
GF_START_GAME,
GF_START_CINE,
GF_START_FMV,
GF_START_DEMO,
GF_EXIT_TO_TITLE,
GF_LEVEL_COMPLETE,
GF_EXIT_GAME,
GF_START_SAVED_GAME,
GF_RESTART_GAME,
GF_SELECT_GAME,
GF_START_GYM,
GF_STORY_SO_FAR,
} GAMEFLOW_ACTION;

typedef struct GAMEFLOW_COMMAND {
GAMEFLOW_ACTION action;
int32_t param;
} GAMEFLOW_COMMAND;
2 changes: 1 addition & 1 deletion include/libtrx/game/items/common.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "types.h"
#include "./types.h"

#include <stdbool.h>

Expand Down
9 changes: 9 additions & 0 deletions include/libtrx/game/items/enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,13 @@ typedef enum {
IF_INVISIBLE = 0x0100,
IF_KILLED = 0x8000,
} ITEM_FLAG;


typedef enum {
IS_INACTIVE = 0,
IS_ACTIVE = 1,
IS_DEACTIVATED = 2,
IS_INVISIBLE = 3,
} ITEM_STATUS;

// clang-format on
2 changes: 1 addition & 1 deletion include/libtrx/game/items/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

#if TR_VERSION == 1
typedef struct __PACKING CARRIED_ITEM {
Expand Down
14 changes: 8 additions & 6 deletions include/libtrx/game/lara/cheat.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
#include <stdbool.h>
#include <stdint.h>

bool Lara_Cheat_GiveAllKeys(void);
bool Lara_Cheat_GiveAllGuns(void);
bool Lara_Cheat_GiveAllItems(void);
bool Lara_Cheat_EnterFlyMode(void);
bool Lara_Cheat_ExitFlyMode(void);
bool Lara_Cheat_KillEnemy(int16_t item_num);
extern bool Lara_Cheat_GiveAllKeys(void);
extern bool Lara_Cheat_GiveAllGuns(void);
extern bool Lara_Cheat_GiveAllItems(void);
extern bool Lara_Cheat_EnterFlyMode(void);
extern bool Lara_Cheat_ExitFlyMode(void);
extern bool Lara_Cheat_KillEnemy(int16_t item_num);
extern void Lara_Cheat_EndLevel(void);
extern bool Lara_Cheat_Teleport(int32_t x, int32_t y, int32_t z);
3 changes: 3 additions & 0 deletions include/libtrx/game/objects/vars.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
extern const GAME_OBJECT_ID g_EnemyObjects[];
extern const GAME_OBJECT_ID g_AllyObjects[];
extern const GAME_OBJECT_ID g_PickupObjects[];
extern const GAME_OBJECT_ID g_AnimObjects[];
extern const GAME_OBJECT_ID g_NullObjects[];
extern const GAME_OBJECT_ID g_InvObjects[];
8 changes: 8 additions & 0 deletions include/libtrx/game/random.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#include <stdint.h>

extern void Random_SeedControl(int32_t seed);
extern void Random_SeedDraw(int32_t seed);
extern int32_t Random_GetControl(void);
extern int32_t Random_GetDraw(void);
5 changes: 5 additions & 0 deletions include/libtrx/game/rooms.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

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

#include "types.h"

extern int32_t Room_GetTotalCount(void);
ROOM_INFO *Room_Get(int32_t room_num);
4 changes: 4 additions & 0 deletions include/libtrx/game/rooms/const.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once

#define NO_ROOM_NEG (-1)
#define NO_ROOM 255
29 changes: 29 additions & 0 deletions include/libtrx/game/rooms/enum.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once

#if TR_VERSION == 1
typedef enum {
TO_OBJECT = 0,
TO_CAMERA = 1,
TO_SINK = 2,
TO_FLIPMAP = 3,
TO_FLIPON = 4,
TO_FLIPOFF = 5,
TO_TARGET = 6,
TO_FINISH = 7,
TO_CD = 8,
TO_FLIPEFFECT = 9,
TO_SECRET = 10,
} TRIGGER_OBJECT;

typedef enum {
TT_TRIGGER = 0,
TT_PAD = 1,
TT_SWITCH = 2,
TT_KEY = 3,
TT_PICKUP = 4,
TT_HEAVY = 5,
TT_ANTIPAD = 6,
TT_COMBAT = 7,
TT_DUMMY = 8,
} TRIGGER_TYPE;
#endif
171 changes: 171 additions & 0 deletions include/libtrx/game/rooms/types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
#pragma once

#include "../math.h"
#include "./enum.h"

#include <stdbool.h>

#if TR_VERSION == 1
typedef struct {
TRIGGER_OBJECT type;
void *parameter;
} TRIGGER_CMD;

typedef struct {
int16_t camera_num;
uint8_t timer;
uint8_t glide;
bool one_shot;
} TRIGGER_CAMERA_DATA;

typedef struct {
TRIGGER_TYPE type;
int8_t timer;
int16_t mask;
bool one_shot;
int16_t item_index;
int32_t command_count;
TRIGGER_CMD *commands;
} TRIGGER;

typedef struct __PACKING {
int16_t room_num;
XYZ_16 normal;
XYZ_16 vertex[4];
} DOOR_INFO;

#elif TR_VERSION == 2
typedef struct __PACKING {
int16_t room;
int16_t x;
int16_t y;
int16_t z;
XYZ_16 vertex[4];
} DOOR_INFO;
#endif

typedef struct __PACKING {
uint16_t count;
DOOR_INFO door[];
} DOOR_INFOS;

#if TR_VERSION == 1
typedef struct __PACKING {
uint16_t index;
int16_t box;
bool is_death_sector;
TRIGGER *trigger;
struct {
uint8_t pit;
uint8_t sky;
int16_t wall;
} portal_room;
struct {
int16_t height;
int16_t tilt;
} floor, ceiling;
} SECTOR_INFO;

typedef struct LIGHT_INFO {
XYZ_32 pos;
int16_t intensity;
int32_t falloff;
} LIGHT_INFO;

typedef struct MESH_INFO {
XYZ_32 pos;
struct {
int16_t y;
} rot;
uint16_t shade;
uint16_t static_num;
} MESH_INFO;

typedef struct __PACKING {
int16_t *data;
DOOR_INFOS *doors;
SECTOR_INFO *sectors;
LIGHT_INFO *light;
MESH_INFO *mesh;
int32_t x;
int32_t y;
int32_t z;
int32_t min_floor;
int32_t max_ceiling;
int16_t z_size;
int16_t x_size;
int16_t ambient;
int16_t num_lights;
int16_t num_meshes;
int16_t left;
int16_t right;
int16_t top;
int16_t bottom;
int16_t bound_active;
int16_t item_num;
int16_t fx_num;
int16_t flipped_room;
uint16_t flags;
} ROOM_INFO;

#elif TR_VERSION == 2
typedef struct __PACKING {
uint16_t idx;
int16_t box;
uint8_t pit_room;
int8_t floor;
uint8_t sky_room;
int8_t ceiling;
} SECTOR_INFO;

typedef struct __PACKING {
int32_t x;
int32_t y;
int32_t z;
int16_t intensity1;
int16_t intensity2;
int32_t falloff1;
int32_t falloff2;
} LIGHT_INFO;

typedef struct __PACKING {
int32_t x;
int32_t y;
int32_t z;
int16_t y_rot;
int16_t shade1;
int16_t shade2;
int16_t static_num;
} MESH_INFO;

typedef struct __PACKING {
int16_t *data;
DOOR_INFOS *doors;
SECTOR_INFO *sector;
LIGHT_INFO *light;
MESH_INFO *mesh;
XYZ_32 pos;
int32_t min_floor;
int32_t max_ceiling;
int16_t z_size;
int16_t x_size;
int16_t ambient1;
int16_t ambient2;
int16_t light_mode;
int16_t num_lights;
int16_t num_meshes;
int16_t bound_left;
int16_t bound_right;
int16_t bound_top;
int16_t bound_bottom;
uint16_t bound_active;
int16_t test_left;
int16_t test_right;
int16_t test_top;
int16_t test_bottom;
int16_t item_num;
int16_t fx_num;
int16_t flipped_room;
uint16_t flags;
} ROOM_INFO;
#endif
Loading