Skip to content

Commit

Permalink
tr2: port S_UnloadLevelFile
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Nov 18, 2024
1 parent b2b385c commit d8f1737
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 11 deletions.
16 changes: 8 additions & 8 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.
4 changes: 2 additions & 2 deletions docs/tr2/progress.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3965,7 +3965,7 @@ typedef enum {
0x0044B180 0x00E0 @R BOOL __cdecl SelectDrive(void);
0x0044B260 0x024A + bool __cdecl Level_Load(const char *file_name, int32_t level_num);
0x0044B4B0 0x0018 +R BOOL __cdecl S_LoadLevelFile(LPCTSTR file_name, int32_t level_num, GAMEFLOW_LEVEL_TYPE level_type);
0x0044B4D0 0x002A -R void __cdecl S_UnloadLevelFile(void);
0x0044B4D0 0x002A +R void __cdecl S_UnloadLevelFile(void);
0x0044B500 0x0014 +R void __cdecl S_AdjustTexelCoordinates(void);
0x0044B520 0x00C4 -R BOOL __cdecl S_ReloadLevelGraphics(BOOL reload_palettes, BOOL reload_tex_pages);
0x0044B5F0 0x00C6 + BOOL __cdecl GF_ReadStringTable(DWORD count, char **string_table, char **string_buf, LPDWORD buf_size, HANDLE handle);
Expand Down Expand Up @@ -4345,7 +4345,7 @@ typedef enum {
0x004BF3DC - int32_t g_LsDivider;
0x004BF3E0 - PHD_VBUF g_PhdVBuf[1500];
0x004CAF60 - void *g_XBuffer; // no-dereferencing
0x004D6AE0 - uint8_t *g_TexturePageBuffer8[32];
0x004D6AE0 - uint8_t *g_TexturePageBuffer8[32]; // MAX_TEXTURE_PAGES
0x004D6B60 - float g_FltWinRight;
0x004D6B68 - XYZ_32 g_LsVectorView;
0x004D6B78 - float g_WibbleTable[32];
Expand Down
1 change: 1 addition & 0 deletions src/tr2/decomp/decomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,4 @@ void __cdecl AdjustTextureUVs(bool reset_uv_add);
void __cdecl S_AdjustTexelCoordinates(void);
BOOL __cdecl S_LoadLevelFile(
const char *file_name, int32_t level_num, GAMEFLOW_LEVEL_TYPE level_type);
void __cdecl S_UnloadLevelFile(void);
10 changes: 10 additions & 0 deletions src/tr2/decomp/decomp2.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,3 +553,13 @@ BOOL __cdecl S_LoadLevelFile(
S_UnloadLevelFile();
return Level_Load(file_name, level_num);
}

void __cdecl S_UnloadLevelFile(void)
{
if (g_SavedAppSettings.render_mode == RM_HARDWARE) {
HWR_FreeTexturePages();
}
strcpy(g_LevelFileName, "");
memset(g_TexturePageBuffer8, 0, sizeof(uint8_t *) * MAX_TEXTURE_PAGES);
g_TextureInfoCount = 0;
}
1 change: 0 additions & 1 deletion src/tr2/global/funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@
#define GiantYeti_Control ((void __cdecl (*)(int16_t item_num))0x00443050)
#define Yeti_Control ((void __cdecl (*)(int16_t item_num))0x00443350)
#define ReadFileSync ((BOOL __cdecl (*)(HANDLE handle, LPVOID lpBuffer, DWORD nBytesToRead, LPDWORD lpnBytesRead, LPOVERLAPPED lpOverlapped))0x004498D0)
#define S_UnloadLevelFile ((void __cdecl (*)(void))0x0044B4D0)
#define S_ReloadLevelGraphics ((BOOL __cdecl (*)(BOOL reload_palettes, BOOL reload_tex_pages))0x0044B520)
#define GetValidLevelsList ((void __cdecl (*)(REQUEST_INFO *req))0x0044C9D0)
#define CalculateWibbleTable ((void __cdecl (*)(void))0x0044D780)
Expand Down
1 change: 1 addition & 0 deletions src/tr2/inject_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ static void M_DecompGeneral(const bool enable)
INJECT(enable, 0x004498C0, DecodeErrorMessage);
INJECT(enable, 0x00449E50, AdjustTextureUVs);
INJECT(enable, 0x0044B4B0, S_LoadLevelFile);
INJECT(enable, 0x0044B4D0, S_UnloadLevelFile);
INJECT(enable, 0x0044B500, S_AdjustTexelCoordinates);
INJECT(enable, 0x0044C1D0, S_FindColor);
INJECT(enable, 0x0044C200, S_DrawScreenLine);
Expand Down

0 comments on commit d8f1737

Please sign in to comment.