Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Challenge: Find the use of rectangles
signed int __thiscall InitMenuHandler(tag_message *msg)
{
signed int result; // eax@26
int v2; // ST48_4@29
int v3; // [sp+Ch] [bp-24h]@27
signed int v5; // [sp+1Ch] [bp-14h]@40
signed int v6; // [sp+20h] [bp-10h]@4
signed int v7; // [sp+24h] [bp-Ch]@1
int highID; // [sp+2Ch] [bp-4h]@32
signed int highIDa; // [sp+2Ch] [bp-4h]@40
v7 = 0;
PollSound();
if ( BYTE1(msg->inputTypeBitmask) & 2 )
{
if ( msg->xCoordOrKeycode == 12 || msg->xCoordOrKeycode == 14 )
{
v6 = -1;
switch ( msg->yCoordOrFieldID )
{
case 101:
v6 = 0; // new game
break;
case 102:
v6 = 1; // load game
break;
case 103: // high scores
v6 = 2;
break;
case 104: // credits
v6 = 3;
break;
case 105: // quit
v6 = 4;
break;
default:
break;
}
if ( v6 >= 0 )
NormalDialog(gEventText[v6 + 116], 4, -1, -1, -1, 0, -1, 0, -1, 0);
}
}
else
{
switch ( msg->eventCode )
{
case INPUT_KEYDOWN_EVENT_CODE:
switch ( msg->xCoordOrKeycode )
{
case '1':
gpWindowManager->buttonPressedCode = 101;
v7 = 1;
break;
case '&':
gpWindowManager->buttonPressedCode = 102;
v7 = 1;
break;
case '.':
gpWindowManager->buttonPressedCode = 104;
v7 = 1;
break;
case '#':
gpWindowManager->buttonPressedCode = 103;
v7 = 1;
break;
case '\x10':
gpWindowManager->buttonPressedCode = 105;
v7 = 1;
break;
default:
goto LABEL_54;
}
break;
case INPUT_GUI_MESSAGE_CODE:
if ( msg->yCoordOrFieldID < 101 || msg->yCoordOrFieldID > 107 )
return 0;
v3 = msg->xCoordOrKeycode;
if ( v3 == 12 )
{
if ( msg->yCoordOrFieldID != 107 )
{
v2 = msg->yCoordOrFieldID - 101;
msg->eventCode = 512;
msg->yCoordOrFieldID = v2 + 11;
msg->xCoordOrKeycode = 4;
msg->payload = (void *)(4 * v2 + 3);
heroWindow::BroadcastMessage(gpInitWin, msg);
heroWindow::DrawWindow(gpInitWin, 0, v2 + 11, v2 + 11);
heroWindowManager::UpdateScreenRegion(
gpWindowManager,
(unsigned __int16)IMHotSpots[4 * v2],
(unsigned __int16)word_50CFEA[4 * v2],
(unsigned __int16)word_50CFEC[4 * v2],
(unsigned __int16)word_50CFEE[4 * v2]);
}
}
else if ( v3 == 13 )
{
if ( msg->yCoordOrFieldID == 107 )
{
PlaySmacker(38);
resourceManager::GetBackdrop(gpResourceManager, "heroes.icn", gpWindowManager->screenBuffer, 1);
heroWindow::DrawWindow(gpInitWin, 0);
heroWindowManager::UpdateScreenRegion(gpWindowManager, 0, 0, 0x280u, 480);
soundManager::PlayAmbientMusic(gpSoundManager, 42, 0, -1);
}
else
{
gpWindowManager->buttonPressedCode = msg->yCoordOrFieldID;
for ( highID = 11; highID <= 15; ++highID )
{
msg->eventCode = 512;
msg->yCoordOrFieldID = highID;
msg->xCoordOrKeycode = 4;
msg->payload = (void *)(4 * highID - 44);
heroWindow::BroadcastMessage(gpInitWin, msg);
}
heroWindow::DrawWindow(gpInitWin, 0, 11, 15);
heroWindowManager::UpdateScreenRegion(gpWindowManager, 0, 105, 0x235u, 375);
v7 = 1;
}
}
break;
case INPUT_MOUSEMOVE_EVENT_CODE:
v5 = -1;
for ( highIDa = 0; highIDa < 5; ++highIDa )
{
if ( (unsigned __int16)IMHotSpots[4 * highIDa] <= msg->altXCoord
&& (unsigned __int16)word_50CFEA[4 * highIDa] <= msg->altYCoord
&& (unsigned __int16)IMHotSpots[4 * highIDa] + (unsigned __int16)word_50CFEC[4 * highIDa] > msg->altXCoord
&& (unsigned __int16)word_50CFEE[4 * highIDa] + (unsigned __int16)word_50CFEA[4 * highIDa] > msg->altYCoord )
v5 = highIDa;
}
if ( v5 != lastIMHoverID )
{
if ( lastIMHoverID != -1 )
{
msg->eventCode = 512;
msg->yCoordOrFieldID = lastIMHoverID + 11;
msg->xCoordOrKeycode = 4;
msg->payload = (void *)(4 * lastIMHoverID + 1);
heroWindow::BroadcastMessage(gpInitWin, msg);
heroWindow::DrawWindow(gpInitWin, 0, lastIMHoverID + 11, lastIMHoverID + 11);
heroWindowManager::UpdateScreenRegion(
gpWindowManager,
(unsigned __int16)IMHotSpots[4 * lastIMHoverID],
(unsigned __int16)word_50CFEA[4 * lastIMHoverID],
(unsigned __int16)word_50CFEC[4 * lastIMHoverID],
(unsigned __int16)word_50CFEE[4 * lastIMHoverID]);
}
if ( v5 != -1 )
{
msg->eventCode = 512;
msg->yCoordOrFieldID = v5 + 11;
msg->xCoordOrKeycode = 4;
msg->payload = (void *)(4 * v5 + 2);
heroWindow::BroadcastMessage(gpInitWin, msg);
heroWindow::DrawWindow(gpInitWin, 0, v5 + 11, v5 + 11);
heroWindowManager::UpdateScreenRegion(
gpWindowManager,
(unsigned __int16)IMHotSpots[4 * v5],
(unsigned __int16)word_50CFEA[4 * v5],
(unsigned __int16)word_50CFEC[4 * v5],
(unsigned __int16)word_50CFEE[4 * v5]);
}
lastIMHoverID = v5;
}
break;
}
}
LABEL_54:
if ( v7 || giMenuCommand != -1 )
{
msg->eventCode = 512;
msg->yCoordOrFieldID = 10;
msg->xCoordOrKeycode = msg->yCoordOrFieldID;
result = 2;
}
else
{
CheckShingleUpdate();
result = 1;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment