port Output_XGenXG

This commit is contained in:
Marcin Kurczewski 2023-10-30 11:44:42 +01:00
parent c3311a7abc
commit 53eeb75831
No known key found for this signature in database
GPG Key ID: CC65E6FD28CAE42A
8 changed files with 88 additions and 12 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">20.25% (243)</tspan> · <tspan class="known">77.25% (927)</tspan> · <tspan class="todo">0.67% (8)</tspan> · <tspan class="unused">1.83% (22)</tspan></tspan></text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">20.33% (244)</tspan> · <tspan class="known">77.17% (926)</tspan> · <tspan class="todo">0.67% (8)</tspan> · <tspan class="unused">1.83% (22)</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="151.27" height="6" x="0" y="0" class="decompiled"/>
<rect width="577.06" height="6" x="151.27" y="0" class="known"/>
<rect width="151.89" height="6" x="0" y="0" class="decompiled"/>
<rect width="576.44" height="6" x="151.89" y="0" class="known"/>
<rect width="4.98" height="6" x="728.32" y="0" class="todo"/>
<rect width="13.70" height="6" x="733.30" y="0" class="unused"/>
</g>
@ -111,7 +111,7 @@
<rect width="12" height="12" x="465" y="0" class="decompiled"><title>void __cdecl Output_DrawPolyGTMap(const int16_t *obj_ptr);</title></rect>
<rect width="12" height="12" x="480" y="0" class="decompiled"><title>void __cdecl Output_DrawPolyWGTMap(const int16_t *obj_ptr);</title></rect>
<rect width="12" height="12" x="495" y="0" class="decompiled"><title>int32_t __cdecl Output_XGenX(const int16_t *obj_ptr);</title></rect>
<rect width="12" height="12" x="510" y="0" class="known"><title>int32_t __cdecl Output_XGenXG(const int16_t *obj_ptr);</title></rect>
<rect width="12" height="12" x="510" y="0" class="decompiled"><title>int32_t __cdecl Output_XGenXG(const int16_t *obj_ptr);</title></rect>
<rect width="12" height="12" x="525" y="0" class="known"><title>int32_t __cdecl Output_XGenXGUV(const int16_t *obj_ptr);</title></rect>
<rect width="12" height="12" x="540" y="0" class="known"><title>int32_t __cdecl Output_XGen_XGUVPerspFP(const int16_t *obj_ptr);</title></rect>
<rect width="12" height="12" x="555" y="0" class="known"><title>void __cdecl Output_GTMap_Persp32FP(int32_t y0, int32_t y1, uint8_t *tex_page);</title></rect>
@ -1281,10 +1281,10 @@
</g>
<g transform="translate(0 531)">
<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">12.16%</tspan> · <tspan class="known">87.51%</tspan> · <tspan class="todo">0.02%</tspan> · <tspan class="unused">0.31%</tspan></tspan></text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">12.26%</tspan> · <tspan class="known">87.41%</tspan> · <tspan class="todo">0.02%</tspan> · <tspan class="unused">0.31%</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="90.84" height="6" x="0" y="0" class="decompiled"/>
<rect width="653.69" height="6" x="90.84" y="0" class="known"/>
<rect width="91.56" height="6" x="0" y="0" class="decompiled"/>
<rect width="652.97" height="6" x="91.56" y="0" class="known"/>
<rect width="0.13" height="6" x="744.53" y="0" class="todo"/>
<rect width="2.33" height="6" x="744.67" y="0" class="unused"/>
</g>
@ -1571,7 +1571,7 @@
<rect width="13.34" height="13.16" x="701.04" y="58.64" class="decompiled"><title>void __cdecl Lara_State_Stop(struct ITEM_INFO *item, struct COLL_INFO *coll);</title></rect>
<rect width="13.34" height="13.16" x="717.37" y="58.64" class="known"><title>void __cdecl MovableBlock(int16_t item_num);</title></rect>
<rect width="13.29" height="13.16" x="733.71" y="58.64" class="known"><title>void __cdecl Effect_Draw(int16_t fx_num);</title></rect>
<rect width="13.41" height="13" x="462.24" y="74.81" class="known"><title>int32_t __cdecl Output_XGenXG(const int16_t *obj_ptr);</title></rect>
<rect width="13.41" height="13" x="462.24" y="74.81" class="decompiled"><title>int32_t __cdecl Output_XGenXG(const int16_t *obj_ptr);</title></rect>
<rect width="13.36" height="13" x="478.65" y="74.81" class="known"><title>void __cdecl DrawAssaultTimer(void);</title></rect>
<rect width="13.31" height="13" x="495" y="74.81" class="known"><title>int16_t __cdecl StartGame(int32_t levelID, GF_LEVEL_TYPE levelType);</title></rect>
<rect width="13.25" height="13" x="511.31" y="74.81" class="decompiled"><title>void __cdecl Lara_State_Run(struct ITEM_INFO *item, struct COLL_INFO *coll);</title></rect>

Before

Width:  |  Height:  |  Size: 360 KiB

After

Width:  |  Height:  |  Size: 360 KiB

View File

@ -1177,7 +1177,7 @@ typedef enum LARA_MESH {
00402BD0 0000003C + void __cdecl Output_DrawPolyGTMap(const int16_t *obj_ptr);
00402C10 0000003C + void __cdecl Output_DrawPolyWGTMap(const int16_t *obj_ptr);
00402C50 000000D2 + int32_t __cdecl Output_XGenX(const int16_t *obj_ptr);
00402D30 00000146 - int32_t __cdecl Output_XGenXG(const int16_t *obj_ptr);
00402D30 00000146 + int32_t __cdecl Output_XGenXG(const int16_t *obj_ptr);
00402E80 00000219 - int32_t __cdecl Output_XGenXGUV(const int16_t *obj_ptr);
004030A0 00000284 - int32_t __cdecl Output_XGen_XGUVPerspFP(const int16_t *obj_ptr);
00403330 00000FC6 - void __cdecl Output_GTMap_Persp32FP(int32_t y0, int32_t y1, uint8_t *tex_page);

View File

@ -859,7 +859,7 @@ int32_t __cdecl Output_XGenX(const int16_t *obj_ptr)
if (y1 < y2) {
CLAMPG(y_min, y1);
int32_t x_size = x2 - x1;
const int32_t x_size = x2 - x1;
int32_t y_size = y2 - y1;
struct XBUF_X *x_ptr = (struct XBUF_X *)g_XBuffer + y1;
@ -873,7 +873,7 @@ int32_t __cdecl Output_XGenX(const int16_t *obj_ptr)
}
} else if (y2 < y1) {
CLAMPL(y_max, y1);
int32_t x_size = x1 - x2;
const int32_t x_size = x1 - x2;
int32_t y_size = y1 - y2;
struct XBUF_X *x_ptr = (struct XBUF_X *)g_XBuffer + y2;
@ -896,3 +896,71 @@ int32_t __cdecl Output_XGenX(const int16_t *obj_ptr)
g_XGenY2 = y_max;
return 1;
}
int32_t __cdecl Output_XGenXG(const int16_t *obj_ptr)
{
int32_t pt_count = *obj_ptr++;
const struct XGEN_XG *pt2 = (const struct XGEN_XG *)obj_ptr;
const struct XGEN_XG *pt1 = pt2 + (pt_count - 1);
int32_t y_min = pt1->y;
int32_t y_max = pt1->y;
while (pt_count--) {
const int32_t x1 = pt1->x;
const int32_t y1 = pt1->y;
const int32_t g1 = pt1->g;
const int32_t x2 = pt2->x;
const int32_t y2 = pt2->y;
const int32_t g2 = pt2->g;
pt1 = pt2++;
if (y1 < y2) {
CLAMPG(y_min, y1);
const int32_t g_size = g2 - g1;
const int32_t x_size = x2 - x1;
int32_t y_size = y2 - y1;
struct XBUF_XG *xg_ptr = (struct XBUF_XG *)g_XBuffer + y1;
const int32_t x_add = PHD_ONE * x_size / y_size;
const int32_t g_add = PHD_HALF * g_size / y_size;
int32_t x = x1 * PHD_ONE + (PHD_ONE - 1);
int32_t g = g1 * PHD_HALF;
while (y_size--) {
x += x_add;
g += g_add;
xg_ptr->x2 = x;
xg_ptr->g2 = g;
xg_ptr++;
}
} else if (y2 < y1) {
CLAMPL(y_max, y1);
const int32_t g_size = g1 - g2;
const int32_t x_size = x1 - x2;
int32_t y_size = y1 - y2;
struct XBUF_XG *xg_ptr = (struct XBUF_XG *)g_XBuffer + y2;
const int32_t x_add = PHD_ONE * x_size / y_size;
const int32_t g_add = PHD_HALF * g_size / y_size;
int32_t x = x2 * PHD_ONE + 1;
int32_t g = g2 * PHD_HALF;
while (y_size--) {
x += x_add;
g += g_add;
xg_ptr->x1 = x;
xg_ptr->g1 = g;
xg_ptr++;
}
}
}
if (y_min == y_max) {
return 0;
}
g_XGenY1 = y_min;
g_XGenY2 = y_max;
return 1;
}

View File

@ -30,3 +30,4 @@ void __cdecl Output_DrawPolyGouraud(const int16_t *obj_ptr);
void __cdecl Output_DrawPolyGTMap(const int16_t *obj_ptr);
void __cdecl Output_DrawPolyWGTMap(const int16_t *obj_ptr);
int32_t __cdecl Output_XGenX(const int16_t *obj_ptr);
int32_t __cdecl Output_XGenXG(const int16_t *obj_ptr);

View File

@ -1,4 +1,5 @@
#define PHD_ONE 0x10000
#define PHD_HALF 0x100
#define PHD_DEGREE (PHD_ONE / 360) // = 182
#define PHD_360 (PHD_ONE) // = 65536 = 0x10000
#define PHD_180 (PHD_ONE / 2) // = 32768 = 0x8000

View File

@ -6,7 +6,6 @@
// clang-format off
#define Output_InsertInventoryBackground ((void __cdecl (*)(const int16_t *obj_ptr))0x00401D50)
#define Output_XGenXG ((int32_t __cdecl (*)(const int16_t *obj_ptr))0x00402D30)
#define Output_XGenXGUV ((int32_t __cdecl (*)(const int16_t *obj_ptr))0x00402E80)
#define Output_XGen_XGUVPerspFP ((int32_t __cdecl (*)(const int16_t *obj_ptr))0x004030A0)
#define Output_GTMap_Persp32FP ((void __cdecl (*)(int32_t y0, int32_t y1, uint8_t *tex_page))0x00403330)

View File

@ -1530,6 +1530,12 @@ typedef struct XBUF_X {
int32_t x2;
} XBUF_X;
typedef struct XGEN_XG {
int16_t x;
int16_t y;
int16_t g;
} XGEN_XG;
typedef struct XBUF_XG {
int32_t x1;
int32_t g1;

View File

@ -111,6 +111,7 @@ static void Inject_Output(void)
INJECT(1, 0x00402BD0, Output_DrawPolyGTMap);
INJECT(1, 0x00402C10, Output_DrawPolyWGTMap);
INJECT(1, 0x00402C50, Output_XGenX);
INJECT(1, 0x00402D30, Output_XGenXG);
}
static void Inject_Music(void)