summaryrefslogtreecommitdiff
path: root/src/yuzu_cmd/yuzu.cpp
diff options
context:
space:
mode:
authorGravatar James Rowe2018-01-11 20:38:17 -0700
committerGravatar James Rowe2018-01-12 19:11:04 -0700
commitf5f28a4f6773e00e0f53454e881fb6d46dfbe6da (patch)
treeb8f7e7afb2a47d1aa2bfe1401c58a7a854496596 /src/yuzu_cmd/yuzu.cpp
parentRemove gpu debugger and get yuzu qt to compile (diff)
downloadyuzu-f5f28a4f6773e00e0f53454e881fb6d46dfbe6da.tar.gz
yuzu-f5f28a4f6773e00e0f53454e881fb6d46dfbe6da.tar.xz
yuzu-f5f28a4f6773e00e0f53454e881fb6d46dfbe6da.zip
Get yuzu sdl to start compiling
Diffstat (limited to 'src/yuzu_cmd/yuzu.cpp')
-rw-r--r--src/yuzu_cmd/yuzu.cpp176
1 files changed, 176 insertions, 0 deletions
diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp
new file mode 100644
index 000000000..5efbf3910
--- /dev/null
+++ b/src/yuzu_cmd/yuzu.cpp
@@ -0,0 +1,176 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <iostream>
6#include <memory>
7#include <string>
8#include <thread>
9
10// This needs to be included before getopt.h because the latter #defines symbols used by it
11#include "common/microprofile.h"
12
13#ifdef _MSC_VER
14#include <getopt.h>
15#else
16#include <getopt.h>
17#include <unistd.h>
18#endif
19
20#ifdef _WIN32
21// windows.h needs to be included before shellapi.h
22#include <windows.h>
23
24#include <shellapi.h>
25#endif
26
27#include "common/logging/backend.h"
28#include "common/logging/filter.h"
29#include "common/logging/log.h"
30#include "common/scm_rev.h"
31#include "common/scope_exit.h"
32#include "common/string_util.h"
33#include "core/core.h"
34#include "core/gdbstub/gdbstub.h"
35#include "core/loader/loader.h"
36#include "core/settings.h"
37#include "yuzu_cmd/config.h"
38#include "yuzu_cmd/emu_window/emu_window_sdl2.h"
39
40
41static void PrintHelp(const char* argv0) {
42 std::cout << "Usage: " << argv0
43 << " [options] <filename>\n"
44 "-g, --gdbport=NUMBER Enable gdb stub on port NUMBER\n"
45 "-h, --help Display this help and exit\n"
46 "-v, --version Output version information and exit\n";
47}
48
49static void PrintVersion() {
50 std::cout << "Citra " << Common::g_scm_branch << " " << Common::g_scm_desc << std::endl;
51}
52
53/// Application entry point
54int main(int argc, char** argv) {
55 Config config;
56 int option_index = 0;
57 bool use_gdbstub = Settings::values.use_gdbstub;
58 u32 gdb_port = static_cast<u32>(Settings::values.gdbstub_port);
59 char* endarg;
60#ifdef _WIN32
61 int argc_w;
62 auto argv_w = CommandLineToArgvW(GetCommandLineW(), &argc_w);
63
64 if (argv_w == nullptr) {
65 LOG_CRITICAL(Frontend, "Failed to get command line arguments");
66 return -1;
67 }
68#endif
69 std::string filepath;
70
71 static struct option long_options[] = {
72 {"gdbport", required_argument, 0, 'g'},
73 {"help", no_argument, 0, 'h'},
74 {"version", no_argument, 0, 'v'},
75 {0, 0, 0, 0},
76 };
77
78 while (optind < argc) {
79 char arg = getopt_long(argc, argv, "g:hv", long_options, &option_index);
80 if (arg != -1) {
81 switch (arg) {
82 case 'g':
83 errno = 0;
84 gdb_port = strtoul(optarg, &endarg, 0);
85 use_gdbstub = true;
86 if (endarg == optarg)
87 errno = EINVAL;
88 if (errno != 0) {
89 perror("--gdbport");
90 exit(1);
91 }
92 break;
93 case 'h':
94 PrintHelp(argv[0]);
95 return 0;
96 case 'v':
97 PrintVersion();
98 return 0;
99 }
100 } else {
101#ifdef _WIN32
102 filepath = Common::UTF16ToUTF8(argv_w[optind]);
103#else
104 filepath = argv[optind];
105#endif
106 optind++;
107 }
108 }
109
110#ifdef _WIN32
111 LocalFree(argv_w);
112#endif
113
114 Log::Filter log_filter(Log::Level::Debug);
115 Log::SetFilter(&log_filter);
116
117 MicroProfileOnThreadCreate("EmuThread");
118 SCOPE_EXIT({ MicroProfileShutdown(); });
119
120 if (filepath.empty()) {
121 LOG_CRITICAL(Frontend, "Failed to load ROM: No ROM specified");
122 return -1;
123 }
124
125 log_filter.ParseFilterString(Settings::values.log_filter);
126
127 // Apply the command line arguments
128 Settings::values.gdbstub_port = gdb_port;
129 Settings::values.use_gdbstub = use_gdbstub;
130 Settings::Apply();
131
132 std::unique_ptr<EmuWindow_SDL2> emu_window{std::make_unique<EmuWindow_SDL2>()};
133
134 Core::System& system{Core::System::GetInstance()};
135
136 SCOPE_EXIT({ system.Shutdown(); });
137
138 const Core::System::ResultStatus load_result{system.Load(emu_window.get(), filepath)};
139
140 switch (load_result) {
141 case Core::System::ResultStatus::ErrorGetLoader:
142 LOG_CRITICAL(Frontend, "Failed to obtain loader for %s!", filepath.c_str());
143 return -1;
144 case Core::System::ResultStatus::ErrorLoader:
145 LOG_CRITICAL(Frontend, "Failed to load ROM!");
146 return -1;
147 case Core::System::ResultStatus::ErrorLoader_ErrorEncrypted:
148 LOG_CRITICAL(Frontend, "The game that you are trying to load must be decrypted before "
149 "being used with Citra. \n\n For more information on dumping and "
150 "decrypting games, please refer to: "
151 "https://citra-emu.org/wiki/dumping-game-cartridges/");
152 return -1;
153 case Core::System::ResultStatus::ErrorLoader_ErrorInvalidFormat:
154 LOG_CRITICAL(Frontend, "Error while loading ROM: The ROM format is not supported.");
155 return -1;
156 case Core::System::ResultStatus::ErrorNotInitialized:
157 LOG_CRITICAL(Frontend, "CPUCore not initialized");
158 return -1;
159 case Core::System::ResultStatus::ErrorSystemMode:
160 LOG_CRITICAL(Frontend, "Failed to determine system mode!");
161 return -1;
162 case Core::System::ResultStatus::ErrorVideoCore:
163 LOG_CRITICAL(Frontend, "VideoCore not initialized");
164 return -1;
165 case Core::System::ResultStatus::Success:
166 break; // Expected case
167 }
168
169 Core::Telemetry().AddField(Telemetry::FieldType::App, "Frontend", "SDL");
170
171 while (emu_window->IsOpen()) {
172 system.RunLoop();
173 }
174
175 return 0;
176}