Skip to content

Commit

Permalink
Merge branch 'master' into AnmManager-DrawEndingRect
Browse files Browse the repository at this point in the history
  • Loading branch information
sere3925sere authored Nov 15, 2024
2 parents 17785f9 + 15ef0ac commit 4814726
Show file tree
Hide file tree
Showing 19 changed files with 2,222 additions and 767 deletions.
5 changes: 5 additions & 0 deletions config/globals.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
_g_BulletTypeInfos, 0x0046a6e8
_g_DifficultyWeightsList, 0x0046bca4
_g_DefaultMagic, 0x0046bdf4
_g_TextureFormatD3D8Mapping, 0x0046c220
_g_StageFiles, 0x004760e0
Expand Down Expand Up @@ -63,7 +64,11 @@ _g_CharacterPowerBulletDataMarisaBRank7,0x004781f8
_g_CharacterPowerBulletDataMarisaBRank8,0x004782b0
_g_CharacterPowerBulletDataMarisaBRank9,0x00478368
_g_CharacterPowerDataMarisaB, 0x00478468
_g_AlphabetList, 0x004784d4
_g_CharacterList, 0x004784d8
_g_SpellcardsWeightsList, 0x004784f0
_g_RightAlignedDifficultyList, 0x00478504
_g_ShortCharacterList2, 0x00478518
_g_SoundBufferIdxVol, 0x00478528
_g_SFXList, 0x00478628
_g_LastJoystickInput, 0x00478690
Expand Down
14 changes: 14 additions & 0 deletions config/implemented.csv
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ th06::Controller::EnumGameControllersCb
th06::EclManager::CallEclSub
th06::EclManager::Load
th06::EclManager::RunEcl
th06::EclManager::Unload
th06::Ending::Ending
th06::Ending::RegisterChain
th06::Ending::AddedCallback
Expand Down Expand Up @@ -259,16 +260,28 @@ th06::MidiTimer::~MidiTimer
th06::MidiTimer::StopTimer
th06::MidiTimer::DefaultTimerCallback
th06::ResultScreen::OnUpdate
th06::ResultScreen::OnDraw
th06::ResultScreen::LinkScore
th06::ResultScreen::FreeScore
th06::ResultScreen::FreeAllScores
th06::ResultScreen::ReleaseScoreDat
th06::ResultScreen::LinkScoreEx
th06::ResultScreen::RegisterChain
th06::ResultScreen::ResultScreen
th06::ResultScreen::DrawFinalStats
th06::ResultScreen::MoveCursor
th06::ResultScreen::OpenScore
th06::ResultScreen::HandleResultKeyboard
th06::ResultScreen::HandleReplaySaveKeyboard
th06::ResultScreen::MoveCursorHorizontally
th06::ResultScreen::CheckConfirmButton
th06::ResultScreen::WriteScore
th06::ResultScreen::ParseCatk
th06::ResultScreen::ParseClrd
th06::ResultScreen::ParsePscr
th06::ResultScreen::AddedCallback
th06::ResultScreen::DeletedCallback
th06::ResultScreen::GetHighScore
th06::Stage::RegisterChain
th06::Stage::CutChain
th06::Stage::AddedCallback
Expand All @@ -294,6 +307,7 @@ th06::TextHelper::TryAllocateBuffer
th06::TextHelper::GetFormatInfo
th06::TextHelper::InvertAlpha
th06::TextHelper::CopyTextToSurface
th06::TextHelper::ReleaseTextBuffer
th06::Supervisor::AddedCallback
th06::Supervisor::DeletedCallback
th06::Supervisor::ReleasePbg3
Expand Down
14 changes: 7 additions & 7 deletions config/mapping.csv
Original file line number Diff line number Diff line change
Expand Up @@ -344,16 +344,16 @@ th06::ReplayManager::SaveReplay,0x42ab30,0x5a9,default,,void,char*,char*
th06::ResultScreen::OpenScore,0x42b0d9,0x1a7,default,,ScoreDat*,char*
th06::ResultScreen::GetHighScore,0x42b280,0x126,default,,u32,ScoreDat*,ScoreListNode*,u32,u32
th06::ResultScreen::LinkScore,0x42b3a6,0x91,default,,i32,ScoreListNode*,Hscr*
th06::ZunFreeArray,0x42b437,0x2f,__stdcall,,void,void*
th06::ResultScreen::FreeAllScores,0x42b437,0x2f,default,,void,ScoreListNode*
th06::ResultScreen::ParseCatk,0x42b466,0x9c,default,,ZunResult,ScoreDat*,Catk*
th06::ResultScreen::ParseClrd,0x42b502,0x15c,default,,ZunResult,ScoreDat*,Clrd*
th06::ResultScreen::ParsePscr,0x42b65e,0x17e,default,,ZunResult,ScoreDat*,Pscr*
th06::ResultScreen::ReleaseScoreDat,0x42b7dc,0x2d,default,,void,ScoreDat*
th06::WriteScore,0x42b809,0x424,__stdcall,,void,ResultScreen*
th06::ResultScreen::LinkScoreEx,0x42bc2d,0x2e,__thiscall,,void,ResultScreen*,Hscr*,i32,i32
th06::ResultScreen::WriteScore,0x42b809,0x424,default,,void,ResultScreen*
th06::ResultScreen::LinkScoreEx,0x42bc2d,0x2e,__thiscall,,i32,ResultScreen*,Hscr*,i32,i32
th06::ResultScreen::FreeScore,0x42bc5b,0x2a,__thiscall,,void,ResultScreen*,i32,i32
th06::ResultScreen::HandleResultKeyboard,0x42bc85,0x64f,__thiscall,,void,ResultScreen*
th06::ResultScreen::HandleReplaySaveKeyboard,0x42c2d4,0xdd0,__thiscall,,void,ResultScreen*
th06::ResultScreen::HandleResultKeyboard,0x42bc85,0x64f,__thiscall,,i32,ResultScreen*
th06::ResultScreen::HandleReplaySaveKeyboard,0x42c2d4,0xdd0,__thiscall,,i32,ResultScreen*
th06::ResultScreen::MoveCursor,0x42d0a4,0xeb,default,,void,ResultScreen*,i32
th06::ResultScreen::MoveCursorHorizontally,0x42d18f,0x103,default,,i32,ResultScreen*,i32
th06::ResultScreen::CheckConfirmButton,0x42d292,0xc8,__thiscall,,ZunResult,ResultScreen*
Expand Down Expand Up @@ -1067,8 +1067,8 @@ _memcpy,0x45cc90,0x2a0,__cdecl,,void*,void*,void*,u32
_memmove,0x45cfd0,0x2a0,__cdecl,,void*,void*,void*,u32
_fprintf,0x45d30d,0x54,__cdecl,varargs,i32,_iobuf*,char*
FUN_0045d361,0x45d361,0xa,unknown,,u8
__aulldiv,0x45d370,0x68,unknown,,u8,u32,u32,u32,u32
__allmul,0x45d3e0,0x34,unknown,,u8,u32,u32,u32,u32
__aulldiv,0x45d370,0x68,unknown,,ulonglong,ulonglong,ulonglong
__allmul,0x45d3e0,0x34,unknown,,longlong,longlong,longlong
strdate,0x45d414,0x70,__stdcall,,char*,char*
_strcpy,0x45d490,0x8a,__cdecl,,char*,char*,char*
_strcat,0x45d4a0,0x65,__cdecl,,char*,char*,char*
Expand Down
9 changes: 0 additions & 9 deletions config/stubbed.csv
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
th06::EclManager::Unload
th06::MidiOutput::OnTimerElapsed
th06::MidiOutput::ParseFile
th06::ResultScreen::OnDraw
th06::ResultScreen::LinkScoreEx
th06::ResultScreen::DeletedCallback
th06::ResultScreen::HandleResultKeyboard
th06::ResultScreen::HandleReplaySaveKeyboard
th06::ResultScreen::GetHighScore
th06::MusicRoom::RegisterChain
th06::ResultScreen::ReleaseScoreDat
th06::MainMenu::SelectRelated
th06::TextHelper::ReleaseTextBuffer
th06::Pbg3Archive::Pbg3Archive
20 changes: 15 additions & 5 deletions src/EclManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,14 +714,14 @@ ZunResult EclManager::RunEcl(Enemy *enemy)
}
if (local_70->nameCsum != (u8)csum)
{
local_70->unk_3e = 0;
local_70->numSuccess = 0;
local_70->numAttempts = 0;
local_70->nameCsum = csum;
}
local_70->captureScore = g_EnemyManager.spellcardInfo.captureScore;
if (local_70->numSuccess < 9999)
if (local_70->numAttempts < 9999)
{
local_70->numSuccess++;
local_70->numAttempts++;
}
}
break;
Expand All @@ -745,7 +745,7 @@ ZunResult EclManager::RunEcl(Enemy *enemy)
g_GameManager.score += scoreIncrease;
if (!g_GameManager.isInReplay)
{
local_80->unk_3e++;
local_80->numSuccess++;
// What. the. fuck?
// memmove(&local_80->nameCsum, &local_80->characterShotType, 4);
for (local_84 = 4; 0 < local_84; local_84 = local_84 + -1)
Expand All @@ -754,7 +754,7 @@ ZunResult EclManager::RunEcl(Enemy *enemy)
}
local_80->characterShotType = g_GameManager.CharacterShotType();
}
g_GameManager.unk_28++;
g_GameManager.spellcardsCaptured++;
}
}
g_EnemyManager.spellcardInfo.isActive = 0;
Expand Down Expand Up @@ -1021,4 +1021,14 @@ ZunResult EclManager::RunEcl(Enemy *enemy)
}
}
}

void EclManager::Unload()
{
if (eclFile != NULL)
{
free(eclFile);
}
eclFile = NULL;
return;
}
}; // namespace th06
5 changes: 3 additions & 2 deletions src/GameErrorContext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ class GameErrorContext
{
}

void RstContext()
void ResetContext()
{
m_BufferEnd = m_Buffer;
m_Buffer[0] = '\0';
m_BufferEnd[0] = '\0';
// TODO: check if it should be m_Buffer[0] above.
}

void Flush();
Expand Down
6 changes: 3 additions & 3 deletions src/GameManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ ZunResult GameManager::AddedCallback(GameManager *mgr)
catk->base.magic = (u32) "CATK";
catk->base.unkLen = sizeof(Catk);
catk->base.th6kLen = sizeof(Catk);
catk->base.version = 0x10;
catk->base.version = TH6K_VERSION;
catk->idx = i;
catk->numAttempts = 0;
catk->numSuccess = 0;
catk->unk_3e = 0;
}
scoredat = ResultScreen::OpenScore("score.dat");
g_GameManager.highScore =
Expand All @@ -215,7 +215,7 @@ ZunResult GameManager::AddedCallback(GameManager *mgr)
mgr->maxRank = g_DifficultyInfo[g_GameManager.difficulty].maxRank;
mgr->deaths = 0;
mgr->bombsUsed = 0;
mgr->unk_28 = 0;
mgr->spellcardsCaptured = 0;
}
else
{
Expand Down
12 changes: 6 additions & 6 deletions src/GameManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ struct GameManager
i32 grazeInStage;
i32 grazeInTotal;
u32 isInReplay;
u32 deaths;
u32 bombsUsed;
u32 unk_28;
i32 deaths;
i32 bombsUsed;
i32 spellcardsCaptured;
i8 isTimeStopped;
Catk catk[CATK_NUM_CAPTURES];
Clrd clrd[CLRD_NUM_CHARACTERS];
Expand All @@ -98,7 +98,7 @@ struct GameManager
i8 unk_1812;
i8 unk_1813;
u16 pointItemsCollectedInStage;
i16 pointItemsCollected;
u16 pointItemsCollected;
u8 numRetries;
i8 powerItemCountForScore;
i8 livesRemaining;
Expand All @@ -109,7 +109,7 @@ struct GameManager
u8 isInGameMenu;
u8 isInRetryMenu;
u8 isInMenu;
i8 isGameCompleted;
u8 isGameCompleted;
u8 isInPracticeMode;
u8 demoMode;
i8 unk_1825;
Expand All @@ -128,7 +128,7 @@ struct GameManager
D3DXVECTOR2 playerMovementAreaSize;
f32 cameraDistance;
D3DXVECTOR3 stageCameraFacingDir;
u32 counat;
i32 counat;
i32 rank;
i32 maxRank;
i32 minRank;
Expand Down
2 changes: 1 addition & 1 deletion src/Gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ void Gui::DrawGameScene()
g_Supervisor.d3dDevice->SetViewport(&g_Supervisor.viewport);
vm = &this->impl->vms[6];
if (((g_Supervisor.cfg.opts >> GCOS_DISPLAY_MINIMUM_GRAPHICS) & 1) == 0 &&
(vm->currentInstruction != NULL || g_Supervisor.unk198 != 0 || g_Supervisor.cfg.IsUnknown()))
(vm->currentInstruction != NULL || g_Supervisor.unk198 != 0 || g_Supervisor.IsUnknown()))
{
for (yPos = 0.0f; yPos < 464.0f; yPos += 32.0f)
{
Expand Down
14 changes: 8 additions & 6 deletions src/GuiImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@ ZunResult GuiImpl::RunMsg()
return ZUN_ERROR;
case MSG_OPCODE_PORTRAITANMSCRIPT:
args = &this->msg.currentInstr->args;
g_AnmManager->SetAndExecuteScriptIdx(&this->msg.portraits[args->portraitAnmScript.portraitIdx],
ANM_SCRIPT_FACE_START + args->portraitAnmScript.anmScriptIdx +
(args->portraitAnmScript.portraitIdx == 0 ? 0 : 2));
g_AnmManager->SetAndExecuteScriptIdx(
&this->msg.portraits[args->portraitAnmScript.portraitIdx],
args->portraitAnmScript.anmScriptIdx +
(args->portraitAnmScript.portraitIdx == 0 ? ANM_SCRIPT_FACE_START : ANM_SCRIPT_FACE_START + 2));
break;
case MSG_OPCODE_PORTRAITANMSPRITE:
args = &this->msg.currentInstr->args;
g_AnmManager->SetActiveSprite(&this->msg.portraits[args->portraitAnmScript.portraitIdx],
ANM_SCRIPT_FACE_START + args->portraitAnmScript.anmScriptIdx +
(args->portraitAnmScript.portraitIdx == 0 ? 0 : 8));
g_AnmManager->SetActiveSprite(
&this->msg.portraits[args->portraitAnmScript.portraitIdx],
args->portraitAnmScript.anmScriptIdx +
(args->portraitAnmScript.portraitIdx == 0 ? ANM_SCRIPT_FACE_START : ANM_SCRIPT_FACE_START + 8));
break;
case MSG_OPCODE_TEXTDIALOGUE:
args = &this->msg.currentInstr->args;
Expand Down
37 changes: 12 additions & 25 deletions src/MainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1763,47 +1763,34 @@ ZunBool MainMenu::WeirdSecondInputCheck()
#pragma optimize("", on)

#pragma optimize("s", on)
#pragma var_order(stageNum, color, charShotType, selectedStage, textPos, local_28, stage)
#pragma var_order(stageNum, color, charShotType, selectedStage, textPos)
ZunResult MainMenu::ChoosePracticeLevel()
{
if (this->gameState == STATE_PRACTICE_LVL_SELECT)
{
i32 local_28;
D3DXVECTOR3 textPos(320.0, 200.0, 0.0);
if (this->stateTimer < 30)
{
local_28 = this->stateTimer * 0xFF / 30;
}
else
{
local_28 = 0xff;
}

i32 color = local_28;
u32 color = (this->stateTimer < 30) ? this->stateTimer * 0xFF / 30 : 0xff;
i32 charShotType = (g_GameManager.character << 1) + g_GameManager.shotType;
i32 stage;
if (g_GameManager.clrd[charShotType].difficultyClearedWithoutRetries[g_GameManager.difficulty] > 6)
{
stage = 6;
}
else
{
stage = g_GameManager.clrd[charShotType].difficultyClearedWithoutRetries[g_GameManager.difficulty];
}
i32 selectedStage = stage;
if (g_GameManager.difficulty == EASY && stage == 6)
i32 selectedStage =
(g_GameManager.clrd[charShotType].difficultyClearedWithoutRetries[g_GameManager.difficulty] > 6)
? 6
: g_GameManager.clrd[charShotType].difficultyClearedWithoutRetries[g_GameManager.difficulty];

if (g_GameManager.difficulty == EASY && selectedStage == 6)
{
selectedStage = 5;
}
for (i32 stageNum = 0; stageNum < selectedStage; stageNum++)

i32 stageNum;
for (stageNum = 0; stageNum < selectedStage; stageNum++)
{
if (stageNum == this->cursor)
{
g_AsciiManager.color = color << 0x18 | 0x00C0F0F0;
}
else
{
g_AsciiManager.color = (color >> 1) << 0x18 | 0x00C0F0F0;
g_AsciiManager.color = (color >> 1) << 0x18 | 0x0080C0C0;
}
g_AsciiManager.AddFormatText(&textPos, "STAGE %d %.9d", stageNum + 1,
g_GameManager.pscr[charShotType][stageNum][g_GameManager.difficulty].score);
Expand Down
2 changes: 1 addition & 1 deletion src/ReplayManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ZunResult ReplayManager::ValidateReplayData(ReplayData *data, i32 fileSize)
return ZUN_ERROR;
}

if (decryptedData->version != 0x102)
if (decryptedData->version != GAME_VERSION)
{
return ZUN_ERROR;
}
Expand Down
Loading

0 comments on commit 4814726

Please sign in to comment.