mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-04-28 20:58:07 +03:00
tr1: add /debug command
This commit is contained in:
parent
9fb746bacf
commit
d5fc558fd0
10 changed files with 86 additions and 2 deletions
|
@ -16,6 +16,7 @@
|
|||
- added a `/cut` (alias: `/cutscene`) console command for playing cutscenes
|
||||
- added a `/gym` (alias: `/home`) console command for playing Lara's Home
|
||||
- added a `/music` console command that plays a specific music track
|
||||
- added a `/debug` console command that shows all triggers in pink
|
||||
- added a console log when using the `/demo` command
|
||||
- ⚠️ changed the game data to use a separate strings file for text information, removing it from the game flow file
|
||||
- ⚠️ changed the game flow file internal structure
|
||||
|
|
|
@ -49,6 +49,10 @@ Currently supported commands:
|
|||
`/wireframe off`
|
||||
Enables or disables the wireframe mode. Enter the debugging realm!
|
||||
|
||||
- `/debug on`
|
||||
`/debug off`
|
||||
Enables or disables the debug mode. Draws all room triggers.
|
||||
|
||||
- `/endlevel`
|
||||
`/nextlevel`
|
||||
Ends the current level. Ideal for speedruns.
|
||||
|
|
|
@ -97,6 +97,7 @@ CFG_INT32(g_Config, window.height, -1)
|
|||
CFG_INT32(g_Config, rendering.fps, 30)
|
||||
CFG_INT32(g_Config, rendering.texture_filter, GFX_TF_BILINEAR)
|
||||
CFG_INT32(g_Config, rendering.fbo_filter, GFX_TF_NN)
|
||||
CFG_BOOL(g_Config, rendering.enable_debug, false)
|
||||
CFG_BOOL(g_Config, rendering.enable_wireframe, false)
|
||||
CFG_DOUBLE(g_Config, rendering.wireframe_width, 2.5)
|
||||
CFG_BOOL(g_Config, rendering.enable_perspective_filter, true)
|
||||
|
|
|
@ -201,6 +201,7 @@ typedef struct {
|
|||
bool enable_perspective_filter;
|
||||
GFX_TEXTURE_FILTER texture_filter;
|
||||
GFX_TEXTURE_FILTER fbo_filter;
|
||||
bool enable_debug;
|
||||
bool enable_wireframe;
|
||||
double wireframe_width;
|
||||
bool enable_vsync;
|
||||
|
|
|
@ -13,6 +13,7 @@ static COMMAND_TO_OPTION_MAP m_CommandToOptionMap[] = {
|
|||
{ "cheats", &g_Config.gameplay.enable_cheats },
|
||||
{ "vsync", &g_Config.rendering.enable_vsync },
|
||||
{ "wireframe", &g_Config.rendering.enable_wireframe },
|
||||
{ "debug", &g_Config.rendering.enable_debug },
|
||||
{ "fps", &g_Config.rendering.fps },
|
||||
{ nullptr, nullptr },
|
||||
};
|
||||
|
@ -34,4 +35,4 @@ static COMMAND_RESULT M_Entrypoint(const COMMAND_CONTEXT *const ctx)
|
|||
return CR_FAILURE;
|
||||
}
|
||||
|
||||
REGISTER_CONSOLE_COMMAND("braid|cheats|fps|vsync|wireframe", M_Entrypoint)
|
||||
REGISTER_CONSOLE_COMMAND("braid|cheats|vsync|wireframe|debug|fps", M_Entrypoint)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "game/clock.h"
|
||||
#include "game/overlay.h"
|
||||
#include "game/random.h"
|
||||
#include "game/room.h"
|
||||
#include "game/shell.h"
|
||||
#include "game/viewport.h"
|
||||
#include "global/const.h"
|
||||
|
@ -645,6 +646,70 @@ void Output_DrawRoom(const ROOM_MESH *const mesh)
|
|||
M_DrawRoomSprites(mesh);
|
||||
}
|
||||
|
||||
void Output_DrawRoomTriggers(const ROOM *const r)
|
||||
{
|
||||
#define DRAW_TRI(a, b, c, color) \
|
||||
do { \
|
||||
S_Output_DrawFlatTriangle(a, b, c, color); \
|
||||
S_Output_DrawFlatTriangle(c, b, a, color); \
|
||||
} while (0)
|
||||
#define DRAW_QUAD(a, b, c, d, color) \
|
||||
do { \
|
||||
DRAW_TRI(a, b, d, color); \
|
||||
DRAW_TRI(b, c, d, color); \
|
||||
} while (0)
|
||||
|
||||
const RGBA_8888 color = { .r = 255, .g = 0, .b = 255, .a = 128 };
|
||||
const XZ_16 offsets[4] = { { 0, 0 }, { 0, 1 }, { 1, 1 }, { 1, 0 } };
|
||||
|
||||
m_IsWaterEffect = false;
|
||||
m_IsShadeEffect = false;
|
||||
S_Output_DisableTextureMode();
|
||||
S_Output_DisableDepthWrites();
|
||||
S_Output_SetBlendingMode(GFX_BLEND_MODE_NORMAL);
|
||||
for (int32_t z = 0; z < r->size.z; z++) {
|
||||
for (int32_t x = 0; x < r->size.x; x++) {
|
||||
const SECTOR *sector = &r->sectors[z + x * r->size.z];
|
||||
if (sector->trigger == nullptr) {
|
||||
continue;
|
||||
}
|
||||
PHD_VBUF vns[4];
|
||||
for (int32_t i = 0; i < 4; i++) {
|
||||
XYZ_16 vertex_pos = {
|
||||
.x = (x + offsets[i].x) * WALL_L,
|
||||
.z = (z + offsets[i].z) * WALL_L,
|
||||
};
|
||||
XYZ_32 world_pos = {
|
||||
.x = r->pos.x + x * WALL_L + offsets[i].x * (WALL_L - 1),
|
||||
.z = r->pos.z + z * WALL_L + offsets[i].z * (WALL_L - 1),
|
||||
.y = r->pos.y,
|
||||
};
|
||||
|
||||
int16_t room_num = r - g_RoomInfo;
|
||||
sector = Room_GetSector(
|
||||
world_pos.x, world_pos.y, world_pos.z, &room_num);
|
||||
vertex_pos.y =
|
||||
Room_GetHeight(
|
||||
sector, world_pos.x, world_pos.y, world_pos.z)
|
||||
+ (m_IsWaterEffect ? -16 : -2);
|
||||
|
||||
M_CalcVertex(&vns[i], vertex_pos);
|
||||
vns[i].g = HIGH_LIGHT;
|
||||
vns[i].zv -=
|
||||
(double)((1 << W2V_SHIFT) / 2); // reduce z fighting
|
||||
}
|
||||
|
||||
DRAW_QUAD(&vns[0], &vns[1], &vns[2], &vns[3], color);
|
||||
}
|
||||
}
|
||||
|
||||
S_Output_SetBlendingMode(GFX_BLEND_MODE_OFF);
|
||||
S_Output_EnableDepthWrites();
|
||||
|
||||
#undef DRAW_TRI
|
||||
#undef DRAW_QUAD
|
||||
}
|
||||
|
||||
void Output_DrawShadow(
|
||||
const int16_t size, const BOUNDS_16 *const bounds, const ITEM *const item)
|
||||
{
|
||||
|
|
|
@ -38,6 +38,7 @@ bool Output_IsSkyboxEnabled(void);
|
|||
void Output_DrawSkybox(const OBJECT_MESH *mesh);
|
||||
|
||||
void Output_DrawRoom(const ROOM_MESH *mesh);
|
||||
void Output_DrawRoomTriggers(const ROOM *room);
|
||||
void Output_DrawShadow(int16_t size, const BOUNDS_16 *bounds, const ITEM *item);
|
||||
void Output_DrawLightningSegment(
|
||||
int32_t x1, int32_t y1, int32_t z1, int32_t x2, int32_t y2, int32_t z2,
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "global/types.h"
|
||||
#include "global/vars.h"
|
||||
|
||||
#include <libtrx/config.h>
|
||||
#include <libtrx/game/matrix.h>
|
||||
#include <libtrx/log.h>
|
||||
|
||||
|
@ -315,6 +316,9 @@ void Room_DrawSingleRoom(int16_t room_num)
|
|||
Effect_Draw(i);
|
||||
}
|
||||
|
||||
if (g_Config.rendering.enable_debug) {
|
||||
Output_DrawRoomTriggers(r);
|
||||
}
|
||||
Matrix_Pop();
|
||||
|
||||
r->bound_left = Viewport_GetMaxX();
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
#include <libtrx/config.h>
|
||||
#include <libtrx/debug.h>
|
||||
#include <libtrx/gfx/context.h>
|
||||
#include <libtrx/log.h>
|
||||
|
||||
#include <string.h>
|
||||
|
@ -423,6 +422,11 @@ void S_Output_DisableTextureMode(void)
|
|||
GFX_3D_Renderer_SetTexturingEnabled(m_Renderer3D, m_IsTextureMode);
|
||||
}
|
||||
|
||||
void S_Output_SetBlendingMode(const GFX_BLEND_MODE blend_mode)
|
||||
{
|
||||
GFX_3D_Renderer_SetBlendingMode(m_Renderer3D, blend_mode);
|
||||
}
|
||||
|
||||
void S_Output_EnableDepthWrites(void)
|
||||
{
|
||||
GFX_3D_Renderer_SetDepthWritesEnabled(m_Renderer3D, true);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "global/types.h"
|
||||
|
||||
#include <libtrx/engine/image.h>
|
||||
#include <libtrx/gfx/context.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
@ -11,6 +12,7 @@ void S_Output_Shutdown(void);
|
|||
|
||||
void S_Output_EnableTextureMode(void);
|
||||
void S_Output_DisableTextureMode(void);
|
||||
void S_Output_SetBlendingMode(GFX_BLEND_MODE blend_mode);
|
||||
void S_Output_EnableDepthWrites(void);
|
||||
void S_Output_DisableDepthWrites(void);
|
||||
void S_Output_EnableDepthTest(void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue