diff --git a/docs/progress.svg b/docs/progress.svg index 224d509..f839c98 100644 --- a/docs/progress.svg +++ b/docs/progress.svg @@ -69,10 +69,10 @@ Tomb2.exe progress according to the physical function order: -38.10% (464) · 59.44% (724) · 0.41% (5) · 2.05% (25) +38.18% (465) · 59.36% (723) · 0.41% (5) · 2.05% (25) - - + + @@ -1010,7 +1010,7 @@ sub_448420 void __cdecl CreateScreenBuffers(void); void __cdecl CreatePrimarySurface(void); -void __cdecl CreateBackBuffer(void); +void __cdecl CreateBackBuffer(void); void __cdecl CreateClipper(void); void __cdecl CreateWindowPalette(void); void __cdecl CreateZBuffer(void); @@ -1299,10 +1299,10 @@ Tomb2.exe progress according to the function sizes: -35.75% · 63.93% · 0% · 0.32% +35.79% · 63.88% · 0% · 0.32% - - + + @@ -1855,7 +1855,7 @@ int16_t __cdecl Room_GetTiltType(FLOOR_INFO *floor, int32_t x, int32_t y, int32_t z); void __cdecl Lara_Col_FastFall(ITEM_INFO *item, COLL_INFO *coll); void __cdecl WarriorSparkleTrail(ITEM_INFO *item); -void __cdecl CreateBackBuffer(void); +void __cdecl CreateBackBuffer(void); bool __cdecl CreateTexturePageSurface(TEXPAGE_DESC *desc); void __cdecl Overlay_DrawAirBar(bool flash_state); void __cdecl AdjustTextureUVs(bool reset_uv_add); diff --git a/docs/progress.txt b/docs/progress.txt index 0a610a2..b6e1374 100644 --- a/docs/progress.txt +++ b/docs/progress.txt @@ -3108,7 +3108,7 @@ typedef enum { 0x00448420 0x0001 -R sub_448420 0x00448430 0x013B +R void __cdecl CreateScreenBuffers(void); 0x00448570 0x0094 +R void __cdecl CreatePrimarySurface(void); -0x00448610 0x0098 -R void __cdecl CreateBackBuffer(void); +0x00448610 0x0098 +R void __cdecl CreateBackBuffer(void); 0x004486B0 0x009D -R void __cdecl CreateClipper(void); 0x00448750 0x00D3 -R void __cdecl CreateWindowPalette(void); 0x00448830 0x00BC -R void __cdecl CreateZBuffer(void); @@ -3719,3 +3719,5 @@ typedef enum { 0x004D9328 - RECT g_GameVidRect; 0x004D9358 - LPDDS g_BackBufferSurface; 0x004D9350 - bool g_GameVid_IsVga; +0x004D9344 - int32_t g_GameVid_BufWidth; +0x004D9348 - int32_t g_GameVid_BufHeight; diff --git a/src/decomp/decomp.c b/src/decomp/decomp.c index 95f26c2..80e2c5d 100644 --- a/src/decomp/decomp.c +++ b/src/decomp/decomp.c @@ -1363,6 +1363,26 @@ void __cdecl CreatePrimarySurface(void) } } +void __cdecl CreateBackBuffer(void) +{ + DDSDESC dsp = { + .dwSize = sizeof(DDSDESC), + .dwFlags = DDSD_WIDTH|DDSD_HEIGHT|DDSD_CAPS, + .dwWidth = g_GameVid_BufWidth, + .dwHeight = g_GameVid_BufHeight, + .ddsCaps = { + .dwCaps = DDSCAPS_3DDEVICE|DDSCAPS_OFFSCREENPLAIN, + }, + }; + if (g_SavedAppSettings.render_mode == RM_HARDWARE) { + dsp.ddsCaps.dwCaps |= DDSCAPS_VIDEOMEMORY; + } + if (FAILED(DDrawSurfaceCreate(&dsp, &g_BackBufferSurface))) { + Shell_ExitSystem("Failed to create back screen buffer"); + } + WinVidClearBuffer(g_BackBufferSurface, 0, 0); +} + void __cdecl UpdateFrame(const bool need_run_message_loop, LPRECT rect) { if (rect == NULL) { diff --git a/src/decomp/decomp.h b/src/decomp/decomp.h index 9fe3366..108c54b 100644 --- a/src/decomp/decomp.h +++ b/src/decomp/decomp.h @@ -70,6 +70,7 @@ void __cdecl CutscenePlayerGen_Initialise(int16_t item_num); int32_t __cdecl Level_Initialise(int32_t level_num, int32_t level_type); void __cdecl CreateScreenBuffers(void); void __cdecl CreatePrimarySurface(void); +void __cdecl CreateBackBuffer(void); void __cdecl UpdateFrame(bool need_run_message_loop, LPRECT rect); void __cdecl RestoreLostBuffers(void); void __cdecl WaitPrimaryBufferFlip(void); diff --git a/src/global/funcs.h b/src/global/funcs.h index e6224b6..304c5e7 100644 --- a/src/global/funcs.h +++ b/src/global/funcs.h @@ -505,7 +505,6 @@ #define TempVideoRemove ((void __cdecl (*)(void))0x004479D0) #define S_FadeInInventory ((void __cdecl (*)(BOOL isFade))0x00447A10) #define S_FadeOutInventory ((void __cdecl (*)(BOOL isFade))0x00447A50) -#define CreateBackBuffer ((void __cdecl (*)(void))0x00448610) #define CreateClipper ((void __cdecl (*)(void))0x004486B0) #define CreateWindowPalette ((void __cdecl (*)(void))0x00448750) #define CreateZBuffer ((void __cdecl (*)(void))0x00448830) diff --git a/src/global/vars.h b/src/global/vars.h index c31e2d4..798647e 100644 --- a/src/global/vars.h +++ b/src/global/vars.h @@ -227,6 +227,8 @@ extern const char *g_TR2XVersion; #define g_GameVidWidth (*(int32_t*)0x004D9338) #define g_GameVidHeight (*(int32_t*)0x004D933C) #define g_GameVidBPP (*(int32_t*)0x004D9340) +#define g_GameVid_BufWidth (*(int32_t*)0x004D9344) +#define g_GameVid_BufHeight (*(int32_t*)0x004D9348) #define g_UVAdd (*(int32_t*)0x004D934C) #define g_GameVid_IsVga (*(bool*)0x004D9350) #define g_GameVid_IsWindowedVGA (*(int8_t*)0x004D9351) diff --git a/src/inject_exec.c b/src/inject_exec.c index 507f06a..785f095 100644 --- a/src/inject_exec.c +++ b/src/inject_exec.c @@ -118,6 +118,7 @@ static void Inject_Decomp(const bool enable) INJECT(enable, 0x0043A280, Level_Initialise); INJECT(enable, 0x00448430, CreateScreenBuffers); INJECT(enable, 0x00448570, CreatePrimarySurface); + INJECT(enable, 0x00448610, CreateBackBuffer); INJECT(enable, 0x00448D30, UpdateFrame); INJECT(enable, 0x00448BF0, RestoreLostBuffers); INJECT(enable, 0x00448E00, WaitPrimaryBufferFlip);