port HWR_DrawPolyList

This commit is contained in:
Marcin Kurczewski 2024-07-15 17:51:33 +02:00
parent 78b252e9fe
commit ff4e9d59e0
No known key found for this signature in database
GPG Key ID: CC65E6FD28CAE42A
6 changed files with 67 additions and 10 deletions

View File

@ -69,10 +69,10 @@
</g>
<g transform="translate(0 116)">
<text x="0" y="7.50">Tomb2.exe progress according to the physical function order:</text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">43.51% (530)</tspan> · <tspan class="known">54.02% (658)</tspan> · <tspan class="todo">0% (0)</tspan> · <tspan class="unused">2.46% (30)</tspan></tspan></text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">43.60% (531)</tspan> · <tspan class="known">53.94% (657)</tspan> · <tspan class="todo">0% (0)</tspan> · <tspan class="unused">2.46% (30)</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="325.05" height="6" x="0" y="0" class="decompiled"/>
<rect width="403.55" height="6" x="325.05" y="0" class="known"/>
<rect width="325.66" height="6" x="0" y="0" class="decompiled"/>
<rect width="402.94" height="6" x="325.66" y="0" class="known"/>
<rect width="18.40" height="6" x="728.60" y="0" class="unused"/>
</g>
<g transform="translate(0 31)">
@ -1091,7 +1091,7 @@
<rect width="12" height="12" x="180" y="300" class="decompiled"><title>void __cdecl HWR_EnableColorKey(bool state);</title></rect>
<rect width="12" height="12" x="195" y="300" class="decompiled"><title>void __cdecl HWR_EnableZBuffer(bool z_write_enable, bool z_enable);</title></rect>
<rect width="12" height="12" x="210" y="300" class="decompiled"><title>void __cdecl HWR_BeginScene(void);</title></rect>
<rect width="12" height="12" x="225" y="300" class="known"><title>void __cdecl HWR_DrawPolyList(void);</title></rect>
<rect width="12" height="12" x="225" y="300" class="decompiled"><title>void __cdecl HWR_DrawPolyList(void);</title></rect>
<rect width="12" height="12" x="240" y="300" class="known"><title>void __cdecl HWR_LoadTexturePages(int32_t pages_count, void *pages_buf, RGB_888 *palette);</title></rect>
<rect width="12" height="12" x="255" y="300" class="known"><title>void __cdecl HWR_FreeTexturePages(void);</title></rect>
<rect width="12" height="12" x="270" y="300" class="known"><title>void __cdecl HWR_GetPageHandles(void);</title></rect>
@ -1298,10 +1298,10 @@
</g>
<g transform="translate(0 546)">
<text x="0" y="7.50">Tomb2.exe progress according to the function sizes:</text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">39.80%</tspan> · <tspan class="known">59.87%</tspan> · <tspan class="todo">0%</tspan> · <tspan class="unused">0.33%</tspan></tspan></text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">39.91%</tspan> · <tspan class="known">59.77%</tspan> · <tspan class="todo">0%</tspan> · <tspan class="unused">0.33%</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="297.32" height="6" x="0" y="0" class="decompiled"/>
<rect width="447.24" height="6" x="297.32" y="0" class="known"/>
<rect width="298.11" height="6" x="0" y="0" class="decompiled"/>
<rect width="446.44" height="6" x="298.11" y="0" class="known"/>
<rect width="2.44" height="6" x="744.56" y="0" class="unused"/>
</g>
<g transform="translate(0 31)">
@ -1564,7 +1564,7 @@
<rect width="15.04" height="13.84" x="484.80" y="59.39" class="known"><title>int32_t __cdecl Misc_Move3DPosTo3DPos(PHD_3DPOS *src_pos, PHD_3DPOS *dest_pos, int32_t velocity, PHD_ANGLE ang_add);</title></rect>
<rect width="15" height="13.84" x="502.85" y="59.39" class="decompiled"><title>const int16_t *__cdecl Output_CalcVerticeLight(const int16_t *obj_ptr);</title></rect>
<rect width="15" height="13.84" x="520.84" y="59.39" class="decompiled"><title>int32_t __cdecl Lara_TestHangJumpUp(ITEM_INFO *item, COLL_INFO *coll);</title></rect>
<rect width="14.95" height="13.84" x="538.84" y="59.39" class="known"><title>void __cdecl HWR_DrawPolyList(void);</title></rect>
<rect width="14.95" height="13.84" x="538.84" y="59.39" class="decompiled"><title>void __cdecl HWR_DrawPolyList(void);</title></rect>
<rect width="14.80" height="13.84" x="556.78" y="59.39" class="known"><title>void __cdecl Boat_Animation(ITEM_INFO *boat, int32_t collide);</title></rect>
<rect width="14.80" height="13.84" x="574.58" y="59.39" class="known"><title>void __cdecl draw_flare(void);</title></rect>
<rect width="14.75" height="13.84" x="592.38" y="59.39" class="known"><title>int32_t __cdecl Room_GetWaterHeight(int32_t x, int32_t y, int32_t z, int16_t room_num);</title></rect>

Before

Width:  |  Height:  |  Size: 360 KiB

After

Width:  |  Height:  |  Size: 360 KiB

View File

@ -3203,7 +3203,7 @@ typedef struct {
0x0044D200 0x004A +R void __cdecl HWR_EnableColorKey(bool state);
0x0044D250 0x0082 +R void __cdecl HWR_EnableZBuffer(bool z_write_enable, bool z_enable);
0x0044D2E0 0x0016 +R void __cdecl HWR_BeginScene(void);
0x0044D310 0x016C -R void __cdecl HWR_DrawPolyList(void);
0x0044D310 0x016C +R void __cdecl HWR_DrawPolyList(void);
0x0044D490 0x008E -R void __cdecl HWR_LoadTexturePages(int32_t pages_count, void *pages_buf, RGB_888 *palette);
0x0044D520 0x004A -R void __cdecl HWR_FreeTexturePages(void);
0x0044D570 0x0035 -R void __cdecl HWR_GetPageHandles(void);

View File

@ -158,3 +158,59 @@ void __cdecl HWR_BeginScene(void)
WaitPrimaryBufferFlip();
g_D3DDev->lpVtbl->BeginScene(g_D3DDev);
}
void __cdecl HWR_DrawPolyList(void)
{
HWR_EnableZBuffer(false, true);
for (int32_t i = 0; i < g_SurfaceCount; i++) {
uint16_t *buf_ptr = (uint16_t *)g_SortBuffer[i]._0;
uint16_t poly_type = *buf_ptr++;
uint16_t tex_page =
(poly_type == POLY_HWR_GTMAP || poly_type == POLY_HWR_WGTMAP)
? *buf_ptr++
: 0;
uint16_t vtx_count = *buf_ptr++;
D3DTLVERTEX *vtx_ptr = *(D3DTLVERTEX **)buf_ptr;
switch (poly_type) {
// triangle fan (texture)
case POLY_HWR_GTMAP:
// triangle fan (texture + colorkey)
case POLY_HWR_WGTMAP:
HWR_TexSource(g_HWR_PageHandles[tex_page]);
HWR_EnableColorKey(poly_type == POLY_HWR_WGTMAP);
HWR_DrawPrimitive(D3DPT_TRIANGLEFAN, vtx_ptr, vtx_count, true);
break;
// triangle fan (color)
case POLY_HWR_GOURAUD:
HWR_TexSource(0);
HWR_EnableColorKey(false);
HWR_DrawPrimitive(D3DPT_TRIANGLEFAN, vtx_ptr, vtx_count, true);
break;
// line strip (color)
case POLY_HWR_LINE:
HWR_TexSource(0);
HWR_EnableColorKey(false);
HWR_DrawPrimitive(D3DPT_LINESTRIP, vtx_ptr, vtx_count, true);
break;
// triangle fan (color + semitransparent)
case POLY_HWR_TRANS: {
DWORD alpha_state;
HWR_TexSource(0);
g_D3DDev->lpVtbl->GetRenderState(
g_D3DDev, g_AlphaBlendEnabler, &alpha_state);
g_D3DDev->lpVtbl->SetRenderState(
g_D3DDev, g_AlphaBlendEnabler, TRUE);
HWR_DrawPrimitive(D3DPT_TRIANGLEFAN, vtx_ptr, vtx_count, true);
g_D3DDev->lpVtbl->SetRenderState(
g_D3DDev, g_AlphaBlendEnabler, alpha_state);
break;
}
}
}
}

View File

@ -18,3 +18,4 @@ void __cdecl HWR_TexSource(HWR_TEXTURE_HANDLE tex_source);
void __cdecl HWR_EnableColorKey(bool state);
void __cdecl HWR_EnableZBuffer(bool z_write_enable, bool z_enable);
void __cdecl HWR_BeginScene(void);
void __cdecl HWR_DrawPolyList(void);

View File

@ -512,7 +512,6 @@
#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)
#define HWR_DrawPolyList ((void __cdecl (*)(void))0x0044D310)
#define HWR_LoadTexturePages ((void __cdecl (*)(int32_t pages_count, void *pages_buf, RGB_888 *palette))0x0044D490)
#define HWR_FreeTexturePages ((void __cdecl (*)(void))0x0044D520)
#define HWR_GetPageHandles ((void __cdecl (*)(void))0x0044D570)

View File

@ -180,6 +180,7 @@ static void Inject_HWR(bool enable)
INJECT(enable, 0x0044D200, HWR_EnableColorKey);
INJECT(enable, 0x0044D250, HWR_EnableZBuffer);
INJECT(enable, 0x0044D2E0, HWR_BeginScene);
INJECT(enable, 0x0044D310, HWR_DrawPolyList);
}
static void Inject_Background(const bool enable)