Skip to content

Commit

Permalink
late mess_update push
Browse files Browse the repository at this point in the history
- decompiled mess_update, but it's unstable
- also partially decompiled mess_display, commented
  • Loading branch information
DCxDemo committed Aug 4, 2022
1 parent 30d92d2 commit 478a362
Show file tree
Hide file tree
Showing 9 changed files with 246 additions and 72 deletions.
15 changes: 15 additions & 0 deletions th2patch/hawk2/color.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "stdafx.h"
#include "color.h"

ColorRGB Color_Black() { ColorRGB c = { 0,0,0 }; return c; }
ColorRGB Color_DarkGray() { ColorRGB c = { 0x40, 0x40,0x40 }; return c; }
ColorRGB Color_Gray() { ColorRGB c = { 0x80,0x80,0x80 }; return c; }
ColorRGB Color_LightGray() { ColorRGB c = { 0xC0,0xC0,0xC0 }; return c; }
ColorRGB Color_White() { ColorRGB c = { 0xFF,0xFF,0xFF }; return c; }

ColorRGB Color_Red() { ColorRGB c = { 0xFF,0,0 }; return c; }
ColorRGB Color_Green() { ColorRGB c = { 0,0xFF,0 }; return c; }
ColorRGB Color_Blue() { ColorRGB c = { 0,0,0xFF }; return c; }
ColorRGB Color_Magenta() { ColorRGB c = { 0xFF,0,0xFF }; return c; }
ColorRGB Color_Cyan() { ColorRGB c = { 0,0xFF,0xFF }; return c; }
ColorRGB Color_Yellow() { ColorRGB c = { 0xFF,0xFF,0 }; return c; }
30 changes: 15 additions & 15 deletions th2patch/hawk2/color.h
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
#pragma once

struct ColorRGB
typedef struct
{
char R;
char G;
char B;
};
} ColorRGB;

struct ColorRGBA
typedef struct
{
char R;
char G;
char B;
char A;
};
} ColorRGBA;

ColorRGB Color_Black() { ColorRGB c = {0,0,0}; return c; }
ColorRGB Color_DarkGray() { ColorRGB c = {0x40,0x40,0x40}; return c; }
ColorRGB Color_Gray() { ColorRGB c = {0x80,0x80,0x80}; return c; }
ColorRGB Color_LightGray() { ColorRGB c = {0xC0,0xC0,0xC0}; return c; }
ColorRGB Color_White() { ColorRGB c = {0xFF,0xFF,0xFF}; return c; }
ColorRGB Color_Black();
ColorRGB Color_DarkGray();
ColorRGB Color_Gray();
ColorRGB Color_LightGray();
ColorRGB Color_White();

ColorRGB Color_Red() { ColorRGB c = {0xFF,0,0}; return c; }
ColorRGB Color_Green() { ColorRGB c = {0,0xFF,0}; return c; }
ColorRGB Color_Blue() { ColorRGB c = {0,0,0xFF}; return c; }
ColorRGB Color__Magenta() { ColorRGB c = {0xFF,0,0xFF}; return c; }
ColorRGB Color_Cyan() { ColorRGB c = {0,0xFF,0xFF}; return c; }
ColorRGB Color_Yellow() { ColorRGB c = {0xFF,0xFF,0}; return c; }
ColorRGB Color_Red();
ColorRGB Color_Green();
ColorRGB Color_Blue();
ColorRGB Color_Magenta();
ColorRGB Color_Cyan();
ColorRGB Color_Yellow();
1 change: 1 addition & 0 deletions th2patch/hawk2/hawk2.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="Checksum.cpp" />
<ClCompile Include="color.cpp" />
<ClCompile Include="thawk2\Pad.cpp" />
<ClCompile Include="thawk2\Career.cpp" />
<ClCompile Include="thawk2\CClass.cpp" />
Expand Down
3 changes: 3 additions & 0 deletions th2patch/hawk2/hawk2.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@
<ClCompile Include="thawk2\Pad.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="color.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="hawk2.def">
Expand Down
47 changes: 12 additions & 35 deletions th2patch/hawk2/hawk2_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,26 @@ void PlaySpecialSound()
//SFX_PlayX(0xA2, 0x500);
}

//this should be moved to mess.h
struct MsgType
{
short duration;
short unknown;
short startSize;
short endSize;
ColorRGB startColor;
ColorRGB endColor;

short unk1;
short unk2;

short size1;
short size2;
short size3;
short size4;

short shouldGoEpileptic;
short shouldDisco;
short shouldFadeout;
};

//this should be moved to mess.h
struct SMessageProg
{
MsgType m1;
MsgType m2;
MsgType m3;
MsgType m4;
MsgType m5;
SMessageProg m1;
SMessageProg m2;
SMessageProg m3;
SMessageProg m4;
SMessageProg m5;
};

SMessage mess;
SMessageProg ms;

void SetupMessage(MsgType &message, int d, int ss, int es, ColorRGB sc, ColorRGB ec)
void SetupMessage(SMessageProg &message, int d, int ss, int es, ColorRGB sc, ColorRGB ec)
{
message.duration = d;
message.startSize = ss;
message.endSize = es;
message.startColor = sc;
message.endColor = ec;
message.Duration = d;
message.StartScale = ss;
message.EndScale = es;
message.StartColor = sc;
message.EndColor = ec;
}

SMessageProg DefaultMessage()
Expand All @@ -75,5 +52,5 @@ void LoadMessageProg()

void DrawMessage(char* msgText)
{
Mess_Message(msgText, &ms, 1, 0, -24);
Mess_Message(msgText, &ms.m1, 1, 0, -24);
}
2 changes: 2 additions & 0 deletions th2patch/hawk2/patchStuff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,8 @@ HookFunc hookList[HOOK_LIST_SIZE] = {
{ 0x004b5da6 , Mess_Remove },
{ 0x004b5db2 , Mess_Remove },

{ 0x00469fd7 , Mess_Update }, //in Game_Logic

//{ 0x473680, CreateMessage }
};

Expand Down
2 changes: 1 addition & 1 deletion th2patch/hawk2/thawk2/Career.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ char* AwardGoalGapMessage = (char*)0x55ca44;
char* AwardLevelPickupMessage = (char*)0x55c994;
char* AwardTrickGapMessage = (char*)0x55c9b4;

void* Messprog_Goal = (void*)0x531d68;
SMessageProg* Messprog_Goal = (SMessageProg*)0x531d68;


// goal gap logic
Expand Down
162 changes: 154 additions & 8 deletions th2patch/hawk2/thawk2/Mess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ void* GMessFont = (void*)0x567600;
eTextJustify* Mess_Justify = (eTextJustify*)0x567604;
SMessColor* Mess_Color = (SMessColor*)0x567614;
int* Mess_Scale = (int*)0x567630;
bool GMessFontExists = (bool*)0x56776c;
char* GMessFontFilename = (char*)0x56774c;
bool* GMessFontExists = (bool*)0x56776c;
SMessage** pMessages = (SMessage**)0x567770;




// Sets default Mess text color
void Mess_SetRGB(int r, int g, int b, bool semitrans)
{
Expand All @@ -36,19 +39,22 @@ void Mess_SetRGB(SMessColor* color)


//sets scale
void Mess_SetScale(int scale) {
void Mess_SetScale(int scale)
{
*Mess_Scale = scale << 4;
}


//gets scale
int Mess_GetScale() {
int Mess_GetScale()
{
return *Mess_Scale >> 4;
}


//sets text justify
void Mess_SetTextJustify(eTextJustify justify) {
void Mess_SetTextJustify(eTextJustify justify)
{
*Mess_Justify = justify;
}

Expand Down Expand Up @@ -78,7 +84,7 @@ void Mess_DeleteAll()
{
printf("Mess_DeleteAll()\r\n");

if (*pMessages == NULL) return;
if (!*pMessages) return;

SMessage* curr = *pMessages;
SMessage* next = (*pMessages)->pNext;
Expand Down Expand Up @@ -114,7 +120,7 @@ SMessage* CreateMessage()


//creates new message entry
void Mess_Message(char* pText, void* pProg, bool recenter, short xOffset, short yOffset)
void Mess_Message(char* pText, SMessageProg* pProg, bool recenter, short xOffset, short yOffset)
{
SMessage* pMess = CreateMessage();

Expand Down Expand Up @@ -149,11 +155,15 @@ void Mess_Remove(SMessage* pMess)
Mess_DeleteMessage(curr);
}

void Mess_SetCurrentFont()
void Mess_SetCurrentFont(void* pFont)
{
printf("Mess_SetCurrentFont is no longer used.\r\n");
}

void Mess_SetCurrentFont(char* fontName)
{
printf("Mess_SetCurrentFont is no longer used.\r\n");
}

void __fastcall Font_Draw_Wrap(void* _this, void* _edx, int x, int y, char* pMessage, int Angle)
{
Expand All @@ -173,4 +183,140 @@ void Mess_DrawPanelText(int x, int y, char* pMessage, int Angle)
printf("Mess_DrawText(): %s\r\n", pMessage);

Mess_DrawText(x, y, pMessage, Angle);
}
}

//unloads mess font
void Mess_UnloadFont()
{
printf("Mess_UnloadFont()\r\n");

if (!*GMessFontExists) return;

printf("unloading: %s\r\n", GMessFontFilename);

//FontManager::UnloadFont(GMessFontFilename);
*GMessFontExists = false;
}

//new func, encapsulated from Mess_Update
void Mess_UpdateOne(SMessage* pMess)
{
if (pMess->T < pMess->pProg->Duration)
{
pMess->T++;
pMess->T_total++;
}
else
{
if (!pMess->pProg->NextOff)
{
Mess_DeleteMessage(pMess);
}
else if (pMess->pProg->NextOff != 0x7f)
{
pMess->T = 0;
pMess->pProg += pMess->pProg->NextOff & 0xFF;
pMess->T_total++;
}
else
{
printf("ever happens? %08x\r\n", pMess->pProg->NextOff);
}
}
}

//updates message queue, called every frame in Game_Logic
void Mess_Update()
{
if (!*pMessages) return;

SMessage* curr = *pMessages;
SMessage* next = curr->pNext;

while (true)
{
Mess_UpdateOne(curr);
if (!next) return;

curr = next;
next = next->pNext;
}
}



/*
void Mess_Display()
{
if (!*pMessages) return;
SMessage* curr = *pMessages;
SMessage* next = curr->pNext;
int i = 0;
do {
if (!curr->recenter) i++;
curr = curr->pNext;
} while (curr);
int local_c = i * 0x10 + -0x10;
curr = *pMessages;
do {
SMessageProg* pProg = curr->pProg;
//this is weird, check the condition
if (pProg->FlashDuration == 0 || curr->T / pProg->FlashDuration & 1)
{
//set mess params using interpolated prog values
Mess_SetTextJustify(pProg->Justify);
int scale = pProg->StartScale + (pProg->EndScale - pProg->StartScale) * curr->T / pProg->Duration;
_Sort = _Sort & 0xffff0000 | scale;
Mess_SetScale(scale);
int r = pProg->StartColor.R + (pProg->EndColor.R - pProg->StartColor.R) * curr->T / pProg->Duration;
int g = pProg->StartColor.G + (pProg->EndColor.G - pProg->StartColor.G) * curr->T / pProg->Duration;
int b = pProg->StartColor.B + (pProg->EndColor.B - pProg->StartColor.B) * curr->T / pProg->Duration;
Mess_SetRGB(r, g, b, 0);
//what, sets random red tint based on xblanks?
if (pProg->ColorCycle)
{
Mess_SetRGB(((uint3)((ulonglong)Xblanks / 20 >> 8) & 0xffff00) << 8 | (uint)(ushort)((char)((ulonglong)Xblanks % 20) * 12), 100, 100, 0);
}
//this one calculates the line to show the message on
int local_8 = curr->yOffset + pProg->StartY + (pProg->EndY - pProg->StartY) * curr->T / curr->Duration;
//and maybe shifts it up
if (curr->recenter)
{
local_8 += local_c;
local_c -= 0x20;
}
//time to draw the message using all of the above
Mess_DrawPanelText((int)curr->xOffset +
(int)(short)pProg->StartX +
(int)(((int)(short)pProg->EndX - (int)(short)pProg->StartX) * curr->T) /
(int)uVar5, local_8, curr->pText,
(int)(((uint)pProg->EndAngle - (uint)pProg->StartAngle) * curr->T) /
(int)uVar5 + pProg->StartAngle);
}
//move to next message
next = curr->pNext;
curr = next;
}
while (next);
}
*/
Loading

0 comments on commit 478a362

Please sign in to comment.