port CompPCX

This commit is contained in:
Marcin Kurczewski 2024-03-17 22:31:13 +01:00
parent 2ca82d4caf
commit 2a0af4a9f4
No known key found for this signature in database
GPG Key ID: CC65E6FD28CAE42A
7 changed files with 77 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">30.54% (372)</tspan> · <tspan class="known">67% (816)</tspan> · <tspan class="todo">0.57% (7)</tspan> · <tspan class="unused">1.89% (23)</tspan></tspan></text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">30.62% (373)</tspan> · <tspan class="known">66.91% (815)</tspan> · <tspan class="todo">0.57% (7)</tspan> · <tspan class="unused">1.89% (23)</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="228.15" height="6" x="0" y="0" class="decompiled"/>
<rect width="500.45" height="6" x="228.15" y="0" class="known"/>
<rect width="228.76" height="6" x="0" y="0" class="decompiled"/>
<rect width="499.84" height="6" x="228.76" y="0" class="known"/>
<rect width="4.29" height="6" x="728.60" y="0" class="todo"/>
<rect width="14.11" height="6" x="732.89" y="0" class="unused"/>
</g>
@ -1118,7 +1118,7 @@
<rect width="12" height="12" x="570" y="300" class="todo"><title>sub_44E880</title></rect>
<rect width="12" height="12" x="585" y="300" class="decompiled"><title>void __cdecl Shell_ExitSystem(const char *message);</title></rect>
<rect width="12" height="12" x="600" y="300" class="decompiled"><title>void __cdecl ScreenShotPCX(void);</title></rect>
<rect width="12" height="12" x="615" y="300" class="known"><title>DWORD __cdecl CompPCX(BYTE *bitmap, DWORD width, DWORD height, RGB888 *palette, BYTE **pcx_data);</title></rect>
<rect width="12" height="12" x="615" y="300" class="decompiled"><title>DWORD __cdecl CompPCX(BYTE *bitmap, DWORD width, DWORD height, RGB888 *palette, BYTE **pcx_data);</title></rect>
<rect width="12" height="12" x="630" y="300" class="known"><title>DWORD __cdecl EncodeLinePCX(BYTE *src, DWORD width, BYTE *dst);</title></rect>
<rect width="12" height="12" x="645" y="300" class="known"><title>DWORD __cdecl EncodePutPCX(BYTE value, BYTE num, BYTE *buffer);</title></rect>
<rect width="12" height="12" x="660" y="300" class="known"><title>void __cdecl ScreenShot(LPDDS screen);</title></rect>
@ -1299,10 +1299,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">28.55%</tspan> · <tspan class="known">71.12%</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">28.60%</tspan> · <tspan class="known">71.07%</tspan> · <tspan class="todo">0.02%</tspan> · <tspan class="unused">0.31%</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="213.26" height="6" x="0" y="0" class="decompiled"/>
<rect width="531.30" height="6" x="213.26" y="0" class="known"/>
<rect width="213.64" height="6" x="0" y="0" class="decompiled"/>
<rect width="530.92" height="6" x="213.64" y="0" class="known"/>
<rect width="0.12" height="6" x="744.56" y="0" class="todo"/>
<rect width="2.32" height="6" x="744.68" y="0" class="unused"/>
</g>
@ -1802,7 +1802,7 @@
<rect width="9.10" height="9.08" x="607.45" y="161.72" class="decompiled"><title>void __cdecl Camera_Initialise(void);</title></rect>
<rect width="9.03" height="9.08" x="619.54" y="161.72" class="known"><title>bool __cdecl WinVidGetDisplayAdapters(void);</title></rect>
<rect width="8.96" height="9.08" x="631.57" y="161.72" class="known"><title>void __cdecl ControlWaterSprite(int16_t fx_num);</title></rect>
<rect width="8.96" height="9.08" x="643.53" y="161.72" class="known"><title>DWORD __cdecl CompPCX(BYTE *bitmap, DWORD width, DWORD height, RGB888 *palette, BYTE **pcx_data);</title></rect>
<rect width="8.96" height="9.08" x="643.53" y="161.72" class="decompiled"><title>DWORD __cdecl CompPCX(BYTE *bitmap, DWORD width, DWORD height, RGB888 *palette, BYTE **pcx_data);</title></rect>
<rect width="8.96" height="9.08" x="655.49" y="161.72" class="known"><title>void __cdecl SyncSurfacePalettes(void *src_data, int32_t width, int32_t height, int32_t src_pitch, RGB888 *src_palette, void *dst_data, int32_t dst_pitch, RGB888 *dst_palette, bool preserve_sys_palette);</title></rect>
<rect width="8.89" height="9.08" x="667.45" y="161.72" class="decompiled"><title>int32_t __cdecl Lara_TestEdgeCatch(struct ITEM_INFO *item, struct COLL_INFO *coll, int32_t *edge);</title></rect>
<rect width="8.82" height="9.08" x="679.34" y="161.72" class="known"><title>void __cdecl AddRequesterItem(struct REQUEST_INFO *req, char *text1, uint32_t flags1, char *text2, uint32_t flags2);</title></rect>

Before

Width:  |  Height:  |  Size: 368 KiB

After

Width:  |  Height:  |  Size: 368 KiB

View File

@ -2772,7 +2772,7 @@ typedef enum GAME_OBJECT_ID {
0044E880 00000010 -R sub_44E880
0044E890 0000003C + void __cdecl Shell_ExitSystem(const char *message);
0044E8E0 0000010F +R void __cdecl ScreenShotPCX(void);
0044E9F0 000000AE -R DWORD __cdecl CompPCX(BYTE *bitmap, DWORD width, DWORD height, RGB888 *palette, BYTE **pcx_data);
0044E9F0 000000AE +R DWORD __cdecl CompPCX(BYTE *bitmap, DWORD width, DWORD height, RGB888 *palette, BYTE **pcx_data);
0044EAA0 000000D2 -R DWORD __cdecl EncodeLinePCX(BYTE *src, DWORD width, BYTE *dst);
0044EB80 0000003E -R DWORD __cdecl EncodePutPCX(BYTE value, BYTE num, BYTE *buffer);
0044EBC0 000001F5 *R void __cdecl ScreenShot(LPDDS screen);

View File

@ -155,3 +155,44 @@ void __cdecl ScreenShotPCX(void)
CloseHandle(handle);
GlobalFree(pcx_data);
}
size_t __cdecl CompPCX(
uint8_t *bitmap, int32_t width, int32_t height, RGB888 *palette,
uint8_t **pcx_data)
{
*pcx_data = (uint8_t *)GlobalAlloc(
GMEM_FIXED,
sizeof(PCX_HEADER) + sizeof(RGB888) * 256 + width * height * 2);
if (*pcx_data == NULL) {
return 0;
}
PCX_HEADER *pcx_header = (PCX_HEADER *)*pcx_data;
pcx_header->manufacturer = 10;
pcx_header->version = 5;
pcx_header->rle = 1;
pcx_header->bpp = 8;
pcx_header->planes = 1;
pcx_header->x_min = 0;
pcx_header->y_min = 0;
pcx_header->x_max = width - 1;
pcx_header->y_max = height - 1;
pcx_header->h_dpi = width;
pcx_header->v_dpi = height;
pcx_header->bytes_per_line = width;
uint8_t *pic_data = *pcx_data + sizeof(PCX_HEADER);
for (int y = 0; y < height; y++) {
pic_data += EncodeLinePCX(bitmap, width, pic_data);
bitmap += width;
}
*pic_data++ = 0x0C;
for (int i = 0; i < 256; i++) {
*pic_data++ = palette[i].red;
*pic_data++ = palette[i].green;
*pic_data++ = palette[i].blue;
}
return pic_data - *pcx_data + sizeof(RGB888) * 256;
}

View File

@ -1,5 +1,7 @@
#pragma once
#include "global/types.h"
#include <stdint.h>
#include <windows.h>
@ -10,3 +12,6 @@ int32_t __stdcall WinMain(
const char *__cdecl DecodeErrorMessage(int32_t error_code);
int32_t __cdecl RenderErrorBox(int32_t error_code);
void __cdecl ScreenShotPCX(void);
size_t __cdecl CompPCX(
uint8_t *bitmap, int32_t width, int32_t height, RGB888 *palette,
uint8_t **pcx_data);

View File

@ -677,7 +677,6 @@
#define CalculateWibbleTable ((void __cdecl (*)(void))0x0044D780)
#define WinGameStart ((int32_t __cdecl (*)(void))0x0044E7A0)
#define Shell_Shutdown ((void __cdecl (*)(void))0x0044E820)
#define CompPCX ((DWORD __cdecl (*)(BYTE *bitmap, DWORD width, DWORD height, RGB888 *palette, BYTE **pcx_data))0x0044E9F0)
#define EncodeLinePCX ((DWORD __cdecl (*)(BYTE *src, DWORD width, BYTE *dst))0x0044EAA0)
#define EncodePutPCX ((DWORD __cdecl (*)(BYTE value, BYTE num, BYTE *buffer))0x0044EB80)
#define ScreenShot ((void __cdecl (*)(LPDDS screen))0x0044EBC0)

View File

@ -1842,4 +1842,25 @@ typedef struct XBUF_XGUVP {
float rhw2;
} XBUF_XGUVP;
typedef struct PCX_HEADER {
uint8_t manufacturer;
uint8_t version;
uint8_t rle;
uint8_t bpp;
uint16_t x_min;
uint16_t y_min;
uint16_t x_max;
uint16_t y_max;
uint16_t h_dpi;
uint16_t v_dpi;
RGB888 palette[16];
uint8_t reserved;
uint8_t planes;
uint16_t bytes_per_line;
uint16_t pal_pnterpret;
uint16_t h_res;
uint16_t v_res;
uint8_t reserved_data[54];
} PCX_HEADER;
#pragma pack(pop)

View File

@ -58,6 +58,7 @@ static void Inject_Decomp(void)
INJECT(1, 0x0044E520, WinMain);
INJECT(1, 0x0044E700, GameInit);
INJECT(1, 0x0044E8E0, ScreenShotPCX);
INJECT(1, 0x0044E9F0, CompPCX);
}
static void Inject_Camera(void)