Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implemented MainMenu::BeginStartup #99

Merged
merged 14 commits into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/implemented.csv
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ DebugPrint
DebugPrint2
FileSystem::OpenPath
FileSystem::WriteDataToFile
MainMenu::BeginStartup
MidiDevice::MidiDevice
MidiDevice::~MidiDevice
MidiOutput::MidiOutput
Expand Down
130 changes: 65 additions & 65 deletions config/mapping.csv

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions config/stubbed.csv
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ StageMenu::OnDrawRetryMenu
AsciiManager::DrawPopupsWithHwVertexProcessing
AsciiManager::DrawPopupsWithoutHwVertexProcessing
GameWindow::Render
MainMenu::LoadTitleAnm
MidiDevice::Close
MidiTimer::StopTimer
MidiOutput::ClearTracks
Expand All @@ -27,6 +28,7 @@ Supervisor::CreateBackBuffer
Supervisor::SetupDInput
Supervisor::TickTimer
Supervisor::ReleasePbg3
Supervisor::PlayAudio
GameManager::RegisterChain
GameManager::CutChain
Ending::RegisterChain
Expand Down
1 change: 1 addition & 0 deletions scripts/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def configure(build_type):
"Supervisor",
"GameErrorContext",
"GameWindow",
"MainMenu",
"MidiOutput",
"SoundPlayer",
"Stage",
Expand Down
52 changes: 52 additions & 0 deletions src/MainMenu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include <D3DX8.h>
#include <windows.h>

#include "MainMenu.hpp"
#include "Supervisor.hpp"

#pragma optimize("s", on)
#pragma var_order(time, i, vector3Ptr)
ZunResult MainMenu::BeginStartup()
{
D3DXVECTOR3 vector3Ptr; // we have to add Ptr,
// because otherwise it gets 0.7% less on decomp.me for some reason
DWORD time;
int i;

if (LoadTitleAnm(this) != ZUN_SUCCESS)
{
g_Supervisor.curState = SUPERVISOR_STATE_EXITSUCCESS;
return ZUN_ERROR;
}
if (g_Supervisor.startupTimeBeforeMenuMusic > 0)
{
time = timeGetTime();
while ((time - g_Supervisor.startupTimeBeforeMenuMusic >= 0) &&
(3000 > time - g_Supervisor.startupTimeBeforeMenuMusic))
{
time = timeGetTime();
}
g_Supervisor.startupTimeBeforeMenuMusic = 0;
g_Supervisor.PlayAudio("bgm/th06_01.mid");
}
for (i = 0; i < 122; i++)
{
this->vm[i].pendingInterrupt = 1;
this->vm[i].flags |= AnmVmFlags_3;
if ((g_Supervisor.cfg.opts & (1 << GCOS_USE_D3D_HW_TEXTURE_BLENDING)) == 0)
{
this->vm[i].color = 0xff000000;
}
else
{
this->vm[i].color = 0xffffffff;
}
vector3Ptr.x = 0.0;
vector3Ptr.y = 0.0;
vector3Ptr.z = 0.0;
this->vm[i].pos2 = vector3Ptr;
}
this->gameState = STATE_PRE_INPUT;
return ZUN_SUCCESS;
}
#pragma optimize("", on)
61 changes: 61 additions & 0 deletions src/MainMenu.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,69 @@
#pragma once

#include <D3D8.h>

#include "AnmVm.hpp"
#include "Chain.hpp"
#include "ZunResult.hpp"
#include "inttypes.hpp"

enum GameState
{
STATE_STARTUP,
STATE_PRE_INPUT,
STATE_MAIN_MENU,
STATE_OPTIONS,
STATE_QUIT,
STATE_KEYCONFIG,
STATE_DIFFICULTY_LOAD,
STATE_DIFFICULTY_SELECT,
STATE_CHARACTER_LOAD,
STATE_CHARACTER_SELECT,
STATE_SCORE,
STATE_SHOT_SELECT,
STATE_REPLAY_LOAD,
STATE_REPLAY_ANIM,
STATE_REPLAY_UNLOAD,
STATE_REPLAY_SELECT,
STATE_MUSIC_ROOM,
};

struct MainMenu
{
ZunResult BeginStartup();
static ZunResult LoadTitleAnm(MainMenu *menu);
static ZunResult RegisterChain(u32 is_demo);

AnmVm vm[122];
i32 cursor;
i8 padding[0x40];
u32 unk_81e4;
i32 chosenReplay;
i32 replayFilesNum;
GameState gameState;
i32 stateTimer;
i32 idleFrames;
f32 unk_81fc;
D3DCOLOR maybeMenuTextColor;
D3DCOLOR color2;
D3DCOLOR color1;
u32 unk_820c;
u32 isActive;
u32 wasActive;
i8 padding2[4];
i16 controlMapping[9];
i8 padding3[6];
ChainElem *chainCalc;
ChainElem *chainDraw;
char replayFilePaths[60][512];
char replayFileName[60][8];
i8 replayFileData[60][0x50];
i8 *currentReplay;
i32 *unk_10ee0;
f32 *unk_10ee4;
i8 padding4[64];
u32 unk_10f28;
u32 unk_10f2c;
u32 time_related;
};
C_ASSERT(sizeof(MainMenu) == 0x10f34);
2 changes: 2 additions & 0 deletions src/Supervisor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ struct Supervisor
static ZunResult DeletedCallback(Supervisor *s);
static void DrawFpsCounter();

void PlayAudio(char *path);

static void CreateBackBuffer();

static ZunResult SetupDInput(Supervisor *s);
Expand Down
Loading