-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathmain.cpp
More file actions
147 lines (134 loc) · 4.54 KB
/
main.cpp
File metadata and controls
147 lines (134 loc) · 4.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#include "stdafx.h"
#include <Project64-core/AppInit.h>
#include "Multilanguage\LanguageSelector.h"
#include "Settings/UISettings.h"
#include <windows.h>
#include <string>
using namespace std;;
//#include <Project64-core/Plugins/PluginClass.h>
int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /*lpszArgs*/, int /*nWinMode*/)
{
CoInitialize(NULL);
AppInit(&Notify(), CPath(CPath::MODULE_DIRECTORY), __argc, __argv);
CLanguageSelector().Set("English");
WriteTrace(TraceUserInterface, TraceDebug, "Create Main Window");
CMainGui MainWindow(true, stdstr_f("Project64 %s", "SM64AI").c_str()), HiddenWindow(false);
CMainMenu MainMenu(&MainWindow);
CDebuggerUI Debugger;
g_Debugger = &Debugger;
g_Plugins->SetRenderWindows(&MainWindow, &HiddenWindow);
Notify().SetMainWindow(&MainWindow);
WriteTrace(TraceUserInterface, TraceDebug, "Show Main Window");
MainWindow.Show(true);
try
{
string path;
TCHAR dir[MAX_PATH];
GetCurrentDirectory(MAX_PATH, dir);
path = dir;
path = path + "/Super Mario 64 (USA).z64";
CN64System::RunFileImage(path.c_str());
}
catch (...)
{
WriteTrace(TraceUserInterface, TraceError, "Exception caught (File: \"%s\" Line: %d)", __FILE__, __LINE__);
MessageBox(NULL, stdstr_f("Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__).c_str(), "Exception", MB_OK);
}
/*
try
{
CoInitialize(NULL);
AppInit(&Notify(), CPath(CPath::MODULE_DIRECTORY), __argc, __argv);
CLanguageSelector().Set("English");
// if (!g_Lang->IsLanguageLoaded())
// {
// CLanguageSelector().Select();
// }
//Create the main window with Menu
WriteTrace(TraceUserInterface, TraceDebug, "Create Main Window");
CMainGui MainWindow(true, stdstr_f("Project64 %s", "test").c_str()), HiddenWindow(false);
CMainMenu MainMenu(&MainWindow);
CDebuggerUI Debugger;
g_Debugger = &Debugger;
g_Plugins->SetRenderWindows(&MainWindow, &HiddenWindow);
Notify().SetMainWindow(&MainWindow);
// CSupportWindow SupportWindow;
if (g_Settings->LoadStringVal(Cmd_RomFile).length() > 0)
{
MainWindow.Show(true); //Show the main window
//N64 ROM or 64DD Disk
stdstr ext = CPath(g_Settings->LoadStringVal(Cmd_RomFile)).GetExtension();
if (!(_stricmp(ext.c_str(), "ndd") == 0))
{
//File Extension is not *.ndd so it should be a N64 ROM
CN64System::RunFileImage(g_Settings->LoadStringVal(Cmd_RomFile).c_str());
}
else
{
//Ext is *.ndd, so it should be a disk file.
if (CN64System::RunDiskImage(g_Settings->LoadStringVal(Cmd_RomFile).c_str()))
{
stdstr IPLROM = g_Settings->LoadStringVal(File_DiskIPLPath);
if ((IPLROM.length() <= 0) || (!CN64System::RunFileImage(IPLROM.c_str())))
{
CPath FileName;
const char * Filter = "64DD IPL ROM Image (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0";
if (FileName.SelectFile(NULL, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true))
{
CN64System::RunFileImage(FileName);
}
}
}
}
}
else
{
//CN64System::RunFileImage("C:/Users/justi/Desktop/Class files repo/Class-files-repo/C463 AI/Mario64AI/Super Mario 64 (USA).z64");
// SupportWindow.Show(reinterpret_cast<HWND>(MainWindow.GetWindowHandle()));
if (UISettingsLoadBool(RomBrowser_Enabled))
{
WriteTrace(TraceUserInterface, TraceDebug, "Show Rom Browser");
//Display the rom browser
MainWindow.ShowRomList();
MainWindow.Show(true); //Show the main window
MainWindow.HighLightLastRom();
}
else
{
WriteTrace(TraceUserInterface, TraceDebug, "Show Main Window");
MainWindow.Show(true); //Show the main window
}
}
//Process Messages till program is closed
WriteTrace(TraceUserInterface, TraceDebug, "Entering Message Loop");
MainWindow.ProcessAllMessages();
WriteTrace(TraceUserInterface, TraceDebug, "Message Loop Finished");
if (g_BaseSystem)
{
g_BaseSystem->CloseCpu();
delete g_BaseSystem;
g_BaseSystem = NULL;
}
WriteTrace(TraceUserInterface, TraceDebug, "System Closed");
}
catch (...)
{
WriteTrace(TraceUserInterface, TraceError, "Exception caught (File: \"%s\" Line: %d)", __FILE__, __LINE__);
MessageBox(NULL, stdstr_f("Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__).c_str(), "Exception", MB_OK);
}
*/
//Process Messages till program is closed
WriteTrace(TraceUserInterface, TraceDebug, "Entering Message Loop");
MainWindow.ProcessAllMessages();
WriteTrace(TraceUserInterface, TraceDebug, "Message Loop Finished");
if (g_BaseSystem)
{
g_BaseSystem->CloseCpu();
delete g_BaseSystem;
g_BaseSystem = NULL;
}
WriteTrace(TraceUserInterface, TraceDebug, "System Closed");
AppCleanup();
CoUninitialize();
return true;
}