2016-01-27 09:11:59 +00:00
|
|
|
#include "stdafx.h"
|
2022-09-21 05:16:07 +00:00
|
|
|
|
2021-02-28 21:32:50 +00:00
|
|
|
#include "Settings/UISettings.h"
|
2022-09-21 05:16:07 +00:00
|
|
|
#include "UserInterface/WelcomeScreen.h"
|
|
|
|
#include <Project64-core/AppInit.h>
|
2016-01-27 09:11:59 +00:00
|
|
|
|
|
|
|
int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /*lpszArgs*/, int /*nWinMode*/)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2021-04-12 11:35:39 +00:00
|
|
|
CoInitialize(nullptr);
|
2016-01-28 09:37:44 +00:00
|
|
|
AppInit(&Notify(), CPath(CPath::MODULE_DIRECTORY), __argc, __argv);
|
2016-01-27 09:11:59 +00:00
|
|
|
if (!g_Lang->IsLanguageLoaded())
|
|
|
|
{
|
2020-08-04 12:58:40 +00:00
|
|
|
WelcomeScreen().DoModal();
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
|
2021-03-03 07:05:17 +00:00
|
|
|
// Create the main window with menu
|
2022-09-21 05:16:07 +00:00
|
|
|
|
2021-03-03 07:05:17 +00:00
|
|
|
WriteTrace(TraceUserInterface, TraceDebug, "Create main window");
|
2017-06-18 23:08:35 +00:00
|
|
|
CMainGui MainWindow(true, stdstr_f("Project64 %s", VER_FILE_VERSION_STR).c_str()), HiddenWindow(false);
|
2016-01-27 09:11:59 +00:00
|
|
|
CMainMenu MainMenu(&MainWindow);
|
2018-01-10 07:05:57 +00:00
|
|
|
CDebuggerUI Debugger;
|
|
|
|
g_Debugger = &Debugger;
|
2016-01-27 09:11:59 +00:00
|
|
|
g_Plugins->SetRenderWindows(&MainWindow, &HiddenWindow);
|
|
|
|
Notify().SetMainWindow(&MainWindow);
|
2019-08-22 11:16:58 +00:00
|
|
|
bool isROMLoaded = false;
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2021-09-03 05:11:04 +00:00
|
|
|
if (CDebuggerUI::HaveDebugger())
|
|
|
|
{
|
|
|
|
Debugger.StartAutorunScripts();
|
|
|
|
}
|
|
|
|
|
2019-08-22 11:16:58 +00:00
|
|
|
if (g_Settings->LoadStringVal(Cmd_RomFile).length() > 0 && g_Settings->LoadStringVal(Cmd_ComboDiskFile).length() > 0)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2021-03-03 07:05:17 +00:00
|
|
|
// Handle combo loading (N64 ROM and 64DD Disk)
|
2019-08-22 11:16:58 +00:00
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
MainWindow.Show(true);
|
2019-08-22 11:16:58 +00:00
|
|
|
|
|
|
|
stdstr extcombo = CPath(g_Settings->LoadStringVal(Cmd_ComboDiskFile)).GetExtension();
|
|
|
|
stdstr ext = CPath(g_Settings->LoadStringVal(Cmd_RomFile)).GetExtension();
|
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
if (g_Settings->LoadStringVal(Cmd_ComboDiskFile).length() > 0 && ((_stricmp(extcombo.c_str(), "ndd") == 0) || (_stricmp(extcombo.c_str(), "d64") == 0)))
|
2019-08-22 11:16:58 +00:00
|
|
|
{
|
|
|
|
if ((!(_stricmp(ext.c_str(), "ndd") == 0)) && (!(_stricmp(ext.c_str(), "d64") == 0)))
|
|
|
|
{
|
2021-03-03 07:05:17 +00:00
|
|
|
// Cmd_ComboDiskFile must be a 64DD disk image
|
|
|
|
// Cmd_RomFile must be an N64 ROM image
|
2019-08-22 11:16:58 +00:00
|
|
|
isROMLoaded = CN64System::RunDiskComboImage(g_Settings->LoadStringVal(Cmd_RomFile).c_str(), g_Settings->LoadStringVal(Cmd_ComboDiskFile).c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (g_Settings->LoadStringVal(Cmd_RomFile).length() > 0)
|
|
|
|
{
|
2021-03-03 07:05:17 +00:00
|
|
|
// Handle single game (N64 ROM or 64DD Disk)
|
2019-08-22 11:16:58 +00:00
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
MainWindow.Show(true);
|
2019-08-22 11:16:58 +00:00
|
|
|
|
2016-05-22 12:55:23 +00:00
|
|
|
stdstr ext = CPath(g_Settings->LoadStringVal(Cmd_RomFile)).GetExtension();
|
2019-08-11 16:13:52 +00:00
|
|
|
if ((!(_stricmp(ext.c_str(), "ndd") == 0)) && (!(_stricmp(ext.c_str(), "d64") == 0)))
|
2016-05-22 12:55:23 +00:00
|
|
|
{
|
2021-03-03 07:05:17 +00:00
|
|
|
// File extension is not *.ndd/*.d64 so it should be an N64 ROM
|
2019-08-22 11:16:58 +00:00
|
|
|
isROMLoaded = CN64System::RunFileImage(g_Settings->LoadStringVal(Cmd_RomFile).c_str());
|
2016-05-22 12:55:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-03-03 07:22:41 +00:00
|
|
|
// File extension is *.ndd/*.d64, so it should be an N64 disk image
|
2019-08-22 11:16:58 +00:00
|
|
|
isROMLoaded = CN64System::RunDiskImage(g_Settings->LoadStringVal(Cmd_RomFile).c_str());
|
2016-05-22 12:55:23 +00:00
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
2019-08-22 11:16:58 +00:00
|
|
|
|
|
|
|
if (!isROMLoaded)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2020-10-22 02:11:19 +00:00
|
|
|
CSupportWindow(MainWindow.Support()).Show((HWND)MainWindow.GetWindowHandle(), true);
|
2016-04-13 07:34:19 +00:00
|
|
|
if (UISettingsLoadBool(RomBrowser_Enabled))
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2021-03-03 07:05:17 +00:00
|
|
|
WriteTrace(TraceUserInterface, TraceDebug, "Show ROM browser");
|
2016-01-27 09:11:59 +00:00
|
|
|
MainWindow.ShowRomList();
|
2020-10-22 02:11:19 +00:00
|
|
|
MainWindow.Show(true);
|
2016-01-27 09:11:59 +00:00
|
|
|
MainWindow.HighLightLastRom();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-03-03 07:05:17 +00:00
|
|
|
WriteTrace(TraceUserInterface, TraceDebug, "Show main window");
|
2020-10-22 02:11:19 +00:00
|
|
|
MainWindow.Show(true);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-03 07:05:17 +00:00
|
|
|
WriteTrace(TraceUserInterface, TraceDebug, "Entering message loop");
|
2016-01-27 09:11:59 +00:00
|
|
|
MainWindow.ProcessAllMessages();
|
2021-03-03 07:05:17 +00:00
|
|
|
WriteTrace(TraceUserInterface, TraceDebug, "Message loop finished");
|
2016-01-27 09:11:59 +00:00
|
|
|
|
|
|
|
if (g_BaseSystem)
|
|
|
|
{
|
|
|
|
g_BaseSystem->CloseCpu();
|
|
|
|
delete g_BaseSystem;
|
2021-04-12 11:35:39 +00:00
|
|
|
g_BaseSystem = nullptr;
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
2021-03-03 07:05:17 +00:00
|
|
|
WriteTrace(TraceUserInterface, TraceDebug, "System closed");
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
WriteTrace(TraceUserInterface, TraceError, "Exception caught (File: \"%s\" Line: %d)", __FILE__, __LINE__);
|
2021-04-12 11:35:39 +00:00
|
|
|
MessageBox(nullptr, stdstr_f("Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__).ToUTF16().c_str(), L"Exception", MB_OK);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
AppCleanup();
|
|
|
|
CoUninitialize();
|
|
|
|
return true;
|
2021-03-03 07:05:17 +00:00
|
|
|
}
|