diff --git a/Source/engine.cpp b/Source/engine.cpp index 83fef3a9b..9fabba3cd 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -172,7 +172,7 @@ void __fastcall CelDecDatLightOnly(char *pDecodeTo, char *pRLEBytes, int frame_c if ((v8 & 0x80u) != 0) /* check sign */ break; v9 = v7 - v8; - CelDecDatLightEntry(v8, a3, v5, v4); + CelDecDatLightEntry(v8, a3, &v5, &v4); v7 = v9; if (!v9) goto LABEL_9; @@ -188,52 +188,14 @@ void __fastcall CelDecDatLightOnly(char *pDecodeTo, char *pRLEBytes, int frame_c } // 69BEF8: using guessed type int light_table_index; -void __fastcall CelDecDatLightEntry(unsigned char shift, char *LightIndex, char *&pDecodeTo, char *&pRLEBytes) +void __fastcall CelDecDatLightEntry(unsigned char n, char *LightIndex, char **pDecodeTo, char **pRLEBytes) { - char v5; // cf - unsigned char v6; // cl - char v7; // cl - int v8; // eax - char v9; // ch - int tmp; // eax - char v11; // ch - char v12; // ch - unsigned char a1; - - v5 = shift & 1; - v6 = shift >> 1; - if (v5) { - a1 = *pRLEBytes; - *pDecodeTo = LightIndex[a1]; - ++pRLEBytes; - ++pDecodeTo; - } - v5 = v6 & 1; - v7 = v6 >> 1; - if (v5) { - a1 = *pRLEBytes; - *pDecodeTo = LightIndex[a1]; - a1 = pRLEBytes[1]; - pDecodeTo[1] = LightIndex[a1]; - pRLEBytes += 2; - pDecodeTo += 2; - } - for (; v7; --v7) { - v8 = *(_DWORD *)pRLEBytes; - pRLEBytes += 4; - a1 = v8; - v9 = LightIndex[a1]; - a1 = BYTE1(v8); - tmp = __ROR4__(v8, 16); - *pDecodeTo = v9; - v11 = LightIndex[a1]; - a1 = tmp; - pDecodeTo[1] = v11; - v12 = LightIndex[a1]; - a1 = BYTE1(tmp); - pDecodeTo[2] = v12; - pDecodeTo[3] = LightIndex[a1]; - pDecodeTo += 4; + int i; + + for (i = 0; i < n; i++) { + **pDecodeTo = LightIndex[**pRLEBytes]; + (*pRLEBytes)++; + (*pDecodeTo)++; } } @@ -690,7 +652,7 @@ void __fastcall Cel2DecDatLightOnly(char *pDecodeTo, char *pRLEBytes, int frame_ v7 -= v8; if (v5 < (char *)gpBufEnd) { v9 = v7; - Cel2DecDatLightEntry(v8, a3, v5, v4); + Cel2DecDatLightEntry(v8, a3, &v5, &v4); v7 = v9; } else { v4 += v8; @@ -705,52 +667,14 @@ void __fastcall Cel2DecDatLightOnly(char *pDecodeTo, char *pRLEBytes, int frame_ // 69BEF8: using guessed type int light_table_index; // 69CF0C: using guessed type int gpBufEnd; -void __fastcall Cel2DecDatLightEntry(unsigned char shift, char *LightIndex, char *&pDecodeTo, char *&pRLEBytes) +void __fastcall Cel2DecDatLightEntry(unsigned char n, char *LightIndex, char **pDecodeTo, char **pRLEBytes) { - char v5; // cf - unsigned char v6; // cl - char v7; // cl - int v8; // eax - char v9; // ch - int tmp; // eax - char v11; // ch - char v12; // ch - unsigned char a1; - - v5 = shift & 1; - v6 = shift >> 1; - if (v5) { - a1 = *pRLEBytes; - *pDecodeTo = LightIndex[a1]; - ++pRLEBytes; - ++pDecodeTo; - } - v5 = v6 & 1; - v7 = v6 >> 1; - if (v5) { - a1 = *pRLEBytes; - *pDecodeTo = LightIndex[a1]; - a1 = pRLEBytes[1]; - pDecodeTo[1] = LightIndex[a1]; - pRLEBytes += 2; - pDecodeTo += 2; - } - for (; v7; --v7) { - v8 = *(_DWORD *)pRLEBytes; - pRLEBytes += 4; - a1 = v8; - v9 = LightIndex[a1]; - a1 = BYTE1(v8); - tmp = __ROR4__(v8, 16); - *pDecodeTo = v9; - v11 = LightIndex[a1]; - a1 = tmp; - pDecodeTo[1] = v11; - v12 = LightIndex[a1]; - a1 = BYTE1(tmp); - pDecodeTo[2] = v12; - pDecodeTo[3] = LightIndex[a1]; - pDecodeTo += 4; + int i; + + for (i = 0; i < n; i++) { + **pDecodeTo = LightIndex[**pRLEBytes]; + (*pRLEBytes)++; + (*pDecodeTo)++; } } diff --git a/Source/engine.h b/Source/engine.h index 659e81e89..6ca590f89 100644 --- a/Source/engine.h +++ b/Source/engine.h @@ -20,7 +20,7 @@ void __fastcall CelDecDatOnly(char *pBuff, char *pCelBuff, int frame, int frame_ void __fastcall CelDrawHdrOnly(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int always_0, int direction); void __fastcall CelDecodeHdrOnly(char *pBuff, char *pCelBuff, int frame, int frame_width, int always_0, int direction); void __fastcall CelDecDatLightOnly(char *pDecodeTo, char *pRLEBytes, int frame_content_size, int frame_width); -void __fastcall CelDecDatLightEntry(unsigned char shift, char *LightIndex, char *&pDecodeTo, char *&pRLEBytes); /* __usercall a1@ a2@ a3@ a4@ */ +void __fastcall CelDecDatLightEntry(unsigned char n, char *LightIndex, char **pDecodeTo, char **pRLEBytes); /* __usercall a1@ a2@ a3@ a4@ */ void __fastcall CelDecDatLightTrans(char *pDecodeTo, char *pRLEBytes, int frame_content_size, int frame_width); void __fastcall CelDecodeLightOnly(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width); void __fastcall CelDecodeHdrLightOnly(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int always_0, int direction); @@ -30,7 +30,7 @@ void __fastcall Cel2DecDatOnly(char *pDecodeTo, char *pRLEBytes, int frame_conte void __fastcall Cel2DrawHdrOnly(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int a6, int direction); void __fastcall Cel2DecodeHdrOnly(char *pBuff, char *pCelBuff, int frame, int frame_width, int a5, int direction); void __fastcall Cel2DecDatLightOnly(char *pDecodeTo, char *pRLEBytes, int frame_content_size, int frame_width); -void __fastcall Cel2DecDatLightEntry(unsigned char shift, char *LightIndex, char *&pDecodeTo, char *&pRLEBytes); /* __usercall a1@ a2@ a3@ a4@ */ +void __fastcall Cel2DecDatLightEntry(unsigned char n, char *LightIndex, char **pDecodeTo, char **pRLEBytes); /* __usercall a1@ a2@ a3@ a4@ */ void __fastcall Cel2DecDatLightTrans(char *pDecodeTo, char *pRLEBytes, int frame_content_size, int frame_width); void __fastcall Cel2DecodeHdrLight(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int a6, int direction); void __fastcall Cel2DecodeLightTrans(char *dst_buf, char *pCelBuff, int frame, int frame_width, int a5, int direction); diff --git a/types.h b/types.h index 8001610a4..ec2a04e16 100644 --- a/types.h +++ b/types.h @@ -82,11 +82,7 @@ extern "C" { #include "Source/dx.h" #include "Source/effects.h" #include "Source/encrypt.h" -#ifdef __cplusplus -} #include "Source/engine.h" -extern "C" { -#endif #include "Source/error.h" #include "Source/fault.h" #include "Source/gamemenu.h"