Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous stats / credits / FMV fixes #1803

Merged
merged 5 commits into from
Nov 2, 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
3 changes: 3 additions & 0 deletions docs/tr2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
- added a fly cheat key (#1642)
- added an items cheat key (#1641)
- added a level skip cheat key (#1640)
- added the ability to skip end credits with the action and escape keys (#1800)
- added the ability to skip FMVs with the action key (#1650)
- changed the inputs backend from DirectX to SDL (#1695)
- improved controller support to match TR1X
- changed the number of custom layouts to 3
Expand Down Expand Up @@ -49,6 +51,7 @@
- fixed the ammo counter being hidden while a demo plays in NG+ (#1559)
- fixed the game crashing in large rooms with z-buffer disabled (#1761, regression from 0.2)
- fixed the game hanging if exited during the level stats, credits, or final stats (#1585)
- fixed the console not being drawn during credits (#1802)
- fixed grenades launched at too slow speeds (#1760, regression from 0.3)

## [0.5](https://github.com/LostArtefacts/TRX/compare/afaf12a...tr2-0.5) - 2024-10-08
Expand Down
20 changes: 10 additions & 10 deletions docs/tr2/progress.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions docs/tr2/progress.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3984,7 +3984,7 @@ typedef enum {
0x0044C9C0 0x000A + void __cdecl Random_SeedDraw(int32_t seed);
0x0044C9D0 0x0044 -R void __cdecl GetValidLevelsList(REQUEST_INFO *req);
0x0044CA20 0x004C -R void __cdecl GetSavedGamesList(REQUEST_INFO *req);
0x0044CA70 0x0233 -R void __cdecl DisplayCredits(void);
0x0044CA70 0x0233 +R void __cdecl DisplayCredits(void);
0x0044CCB0 0x0165 *R BOOL __cdecl S_FrontEndCheck(void);
0x0044CE20 0x0114 -R int32_t __cdecl S_SaveGame(const void *save_data, uint32_t save_size, int32_t slot_num);
0x0044CF40 0x0096 -R int32_t __cdecl S_LoadGame(void *save_data, uint32_t save_size, int32_t slot_num);
Expand Down Expand Up @@ -4057,7 +4057,7 @@ typedef enum {
0x00451C90 0x0051 -R void __cdecl S_SetupBelowWater(BOOL underwater);
0x00451CF0 0x0021 -R void __cdecl S_SetupAboveWater(BOOL underwater);
0x00451D20 0x00B1 -R void __cdecl S_AnimateTextures(int32_t ticks);
0x00451DE0 0x0105 *R void __cdecl S_DisplayPicture(const char *file_name, BOOL is_title);
0x00451DE0 0x0105 +R void __cdecl S_DisplayPicture(const char *file_name, BOOL is_title);
0x00451EF0 0x007E -R void __cdecl S_SyncPictureBufferPalette(void);
0x00451F70 0x001C *R void __cdecl S_DontDisplayPicture(void);
0x00451F80 0x000D -R void __cdecl ScreenDump(void);
Expand Down Expand Up @@ -4784,3 +4784,4 @@ typedef enum {
0x0051A004 - char *g_GameBuf_MemPtr;
0x0051A008 - size_t g_GameBuf_MemUsed;
0x0051A00C - size_t g_GameBuf_MemFree;
0x0051B608 - RGB_888 g_PicturePalette[256]
84 changes: 80 additions & 4 deletions src/tr2/decomp/decomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2783,13 +2783,13 @@ void __cdecl S_Wait(int32_t frames, const BOOL input_check)
{
if (input_check) {
while (frames > 0) {
if (g_Input.any) {
break;
}
Shell_ProcessEvents();
Input_Update();
Shell_ProcessInput();

if (!g_Input.any) {
break;
}
int32_t passed;
do {
passed = Sync();
Expand All @@ -2806,7 +2806,7 @@ void __cdecl S_Wait(int32_t frames, const BOOL input_check)
Shell_ProcessEvents();
Input_Update();
Shell_ProcessInput();
if (input_check && g_Input.any) {
if (input_check && g_InputDB.any) {
break;
}

Expand All @@ -2833,3 +2833,79 @@ BOOL __cdecl S_InitialiseSystem(void)
CalculateWibbleTable();
return 1;
}

void __cdecl S_DisplayPicture(const char *const file_name, const BOOL is_title)
{
char *compressed_data = NULL;
size_t compressed_data_size = 0;
if (!File_Load(file_name, &compressed_data, &compressed_data_size)) {
return;
}

if (!is_title) {
GameBuf_Reset();
}

const size_t width = 640;
const size_t height = 480;
uint8_t *pixels = GameBuf_Alloc(width * height, GBUF_LOAD_PICTURE_BUFFER);
DecompPCX(
(uint8_t *)compressed_data, compressed_data_size, pixels,
g_PicturePalette);
Memory_FreePointer(&compressed_data);
if (g_SavedAppSettings.render_mode == RM_SOFTWARE) {
WinVidCopyBitmapToBuffer(g_PictureBufferSurface, pixels);
} else {
BGND_Make640x480(pixels, g_PicturePalette);
}
if (!is_title) {
CopyBitmapPalette(
g_PicturePalette, pixels, width * height, g_GamePalette8);
}
GameBuf_Free(width * height);
}

void __cdecl DisplayCredits(void)
{
S_FadeToBlack();
S_UnloadLevelFile();
if (!Level_Initialise(0, 0)) {
return;
}

RGB_888 old_palette[256];
memcpy(old_palette, g_GamePalette8, sizeof(old_palette));
memset(g_GamePalette8, 0, sizeof(g_GamePalette8));

Music_Play(MX_SKIDOO_THEME, false);

for (int32_t i = 0; i < 9; i++) {
char file_name[60];
sprintf(file_name, "data/credit0%d.pcx", i + 1);
g_IsVidModeLock = 1;
FadeToPal(0, g_GamePalette8);

S_DisplayPicture(file_name, false);

S_InitialisePolyList(0);
S_CopyBufferToScreen();
Console_Draw();
Text_Draw();
S_OutputPolyList();
S_DumpScreen();
FadeToPal(30, g_GamePalette8);

S_Wait(450, true);

S_FadeToBlack();
S_DontDisplayPicture();
if (g_IsGameToExit) {
break;
}
}

memcpy(g_GamePalette8, old_palette, sizeof(g_GamePalette8));
S_Wait(300, true);
FadeToPal(30, g_GamePalette8);
g_IsVidModeLock = 0;
}
2 changes: 2 additions & 0 deletions src/tr2/decomp/decomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,5 @@ void __cdecl S_LoadSettings(void);
void __cdecl S_SaveSettings(void);
void __cdecl S_Wait(int32_t frames, BOOL input_check);
BOOL __cdecl S_InitialiseSystem(void);
void __cdecl S_DisplayPicture(const char *file_name, BOOL is_title);
void __cdecl DisplayCredits(void);
2 changes: 1 addition & 1 deletion src/tr2/decomp/fmv.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ void __cdecl WinPlayFMV(const char *const file_name, const bool is_playback)

Input_Update();
Shell_ProcessInput();
if (g_InputDB.option) {
if (g_InputDB.menu_back || g_InputDB.menu_confirm) {
Video_Stop(video);
break;
}
Expand Down
25 changes: 10 additions & 15 deletions src/tr2/decomp/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,6 @@ int32_t __cdecl LevelStats(const int32_t level_num)
Overlay_HideGameInfo();
S_CopyScreenToBuffer();

while (g_Input.menu_confirm) {
Shell_ProcessEvents();
Input_Update();
Shell_ProcessInput();
}

while (true) {
S_InitialisePolyList(0);
S_CopyBufferToScreen();
Expand All @@ -337,6 +331,10 @@ int32_t __cdecl LevelStats(const int32_t level_num)
break;
}

if (g_InputDB.menu_back || g_InputDB.menu_confirm) {
break;
}

if (g_GF_OverrideDir != (GAME_FLOW_DIR)-1) {
break;
}
Expand All @@ -346,10 +344,6 @@ int32_t __cdecl LevelStats(const int32_t level_num)
Text_Draw();
S_OutputPolyList();
S_DumpScreen();

if (g_InputDB.menu_confirm) {
break;
}
}

Requester_Shutdown(&g_StatsRequester);
Expand All @@ -374,7 +368,8 @@ int32_t __cdecl GameStats(const int32_t level_num)
start->statistics.medipacks = g_SaveGame.statistics.medipacks;

Overlay_HideGameInfo();
while (g_Input.menu_confirm) {

while (g_Input.any) {
Shell_ProcessEvents();
Input_Update();
Shell_ProcessInput();
Expand All @@ -392,6 +387,10 @@ int32_t __cdecl GameStats(const int32_t level_num)
break;
}

if (g_InputDB.menu_back || g_InputDB.menu_confirm) {
break;
}

if (g_GF_OverrideDir != (GAME_FLOW_DIR)-1) {
break;
}
Expand All @@ -401,10 +400,6 @@ int32_t __cdecl GameStats(const int32_t level_num)
Text_Draw();
S_OutputPolyList();
S_DumpScreen();

if (g_InputDB.menu_confirm) {
break;
}
}

Requester_Shutdown(&g_StatsRequester);
Expand Down
6 changes: 5 additions & 1 deletion src/tr2/game/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,13 @@ void Input_Update(void)
M_UpdateFromBackend(
&g_Input, &g_Input_Controller, g_Config.input.controller_layout);

g_Input.menu_up |= g_Input.forward;
g_Input.menu_down |= g_Input.back;
g_Input.menu_left |= g_Input.left;
g_Input.menu_right |= g_Input.right;
g_Input.menu_back |= g_Input.option;
g_Input.option &= g_Camera.type != CAM_CINEMATIC;
g_Input.roll |= g_Input.forward && g_Input.back;
g_Input.menu_back |= g_Input.option;
if (g_Input.left && g_Input.right) {
g_Input.left = 0;
g_Input.right = 0;
Expand Down
3 changes: 2 additions & 1 deletion src/tr2/game/shell/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,15 @@ void __cdecl Shell_Main(void)
TempVideoAdjust(1, 1.0);

g_IsVidModeLock = 1;

S_DisplayPicture("data\\legal.pcx", 0);
S_InitialisePolyList(0);
S_CopyBufferToScreen();
S_OutputPolyList();
S_DumpScreen();
Shell_ProcessEvents();
FadeToPal(30, g_GamePalette8);
S_Wait(180, 1);
S_Wait(180, true);
S_FadeToBlack();
S_DontDisplayPicture();
g_IsVidModeLock = 0;
Expand Down
2 changes: 0 additions & 2 deletions src/tr2/global/funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@
#define S_FadeToBlack ((void __cdecl (*)(void))0x0044C3A0)
#define GetValidLevelsList ((void __cdecl (*)(REQUEST_INFO *req))0x0044C9D0)
#define GetSavedGamesList ((void __cdecl (*)(REQUEST_INFO *req))0x0044CA20)
#define DisplayCredits ((void __cdecl (*)(void))0x0044CA70)
#define S_FrontEndCheck ((BOOL __cdecl (*)(void))0x0044CCB0)
#define S_SaveGame ((int32_t __cdecl (*)(const void *save_data, uint32_t save_size, int32_t slot_num))0x0044CE20)
#define S_LoadGame ((int32_t __cdecl (*)(void *save_data, uint32_t save_size, int32_t slot_num))0x0044CF40)
Expand All @@ -231,7 +230,6 @@
#define S_SetupBelowWater ((void __cdecl (*)(BOOL underwater))0x00451C90)
#define S_SetupAboveWater ((void __cdecl (*)(BOOL underwater))0x00451CF0)
#define S_AnimateTextures ((void __cdecl (*)(int32_t ticks))0x00451D20)
#define S_DisplayPicture ((void __cdecl (*)(const char *file_name, BOOL is_title))0x00451DE0)
#define S_SyncPictureBufferPalette ((void __cdecl (*)(void))0x00451EF0)
#define S_DontDisplayPicture ((void __cdecl (*)(void))0x00451F70)
#define ScreenDump ((void __cdecl (*)(void))0x00451F80)
Expand Down
1 change: 1 addition & 0 deletions src/tr2/global/vars_decomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@
#define g_DetailText (*(TEXTSTRING *(*)[5])0x0051A2D8)
#define g_SoundText (*(TEXTSTRING *(*)[4])0x0051A2F0)
#define g_WaterPalette (*(RGB_888(*)[256])0x0051B308)
#define g_PicturePalette (*(RGB_888(*)[256])0x0051B608)
#define g_PhdWinRect (*(RECT*)0x0051B918)
#define g_HiRes (*(int32_t*)0x0051B928)
#define g_AnimTextureRanges (*(int16_t **)0x0051B92C)
Expand Down
2 changes: 2 additions & 0 deletions src/tr2/inject_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ static void M_DecompGeneral(const bool enable)
INJECT(enable, 0x00454C50, TitleSequence);
INJECT(enable, 0x004550C0, S_SaveSettings);
INJECT(enable, 0x00455140, S_LoadSettings);
INJECT(enable, 0x00451DE0, S_DisplayPicture);
INJECT(enable, 0x0044CA70, DisplayCredits);
}

static void M_DecompFMV(const bool enable)
Expand Down