Files
jak-project/game/main.cpp
T
ManDude 7d5045ab3f PAL & NTSC-J support + updates (#1490)
* PAL dumps files

* alrighty then

* make PAL warning slightly more specific

* PAL patches for `title-obs`

* Update all-types.gc

* PAL patch `beach-obs`

* `process-taskable` PAL patch

* `ambient` PAL patch

* `yakow` PAL patch

* `village-obs` PAL patch

* `sparticle-launcher` patch

* `swamp-obs` PAL patch

* `sequence-a-village1` PAL patch

* typo

* errors

* `powerups` PAL patch

* `ogreboss` PAL patch

* jak 1 v2 encoding

* `load-boundary` PAL patch

* `flying-lurker` PAL patch

* `mayor` PAL patch

* update game encoding to PAL (v2) encoding

* `cam-debug` and `cam-update` PAL patch

* `fisher` PAL patch

* `target` PAL patch

* `target2` PAL patch and fix text compiling

* `target-death` PAL patch

* `target-racer-h` PAL patch

* `logic-target` PAL patch

* `main` PAL patch

* `snow-flutflut-obs` PAL patch

* `rolling-obs` PAL patch

* `gsound` PAL patch

* update refs

* `progress` and `progress-draw` PAL patches

* clang

* wrong.

* complain

* clang

* fix test

* fix blurry jp text

* fix weird interrupt lag from setting window size

* patch more text lines, special handling for credits

* Update FontUtils.cpp

* Add xdelta3 and file patching interface

* add window lock toggle and update settings ver

* better particle hacks

* add PAL support to extractor

* Fix credits

* also NTSC-J support

* make xdelta3 a separate library

* address feedback

Co-authored-by: water <awaterford111445@gmail.com>
2022-06-22 05:16:34 +01:00

130 lines
3.5 KiB
C++

/*!
* @file main.cpp
* Main for the game. Launches the runtime.
*/
#include <string>
#include "runtime.h"
#include "common/versions.h"
#include "common/log/log.h"
#include "common/util/FileUtil.h"
#include "game/discord.h"
#include "common/util/os.h"
// Discord RPC
extern int64_t gStartTime;
/*!
* Set up logging system to log to file.
* @param verbose : should we print debug-level messages to stdout?
*/
void setup_logging(bool verbose) {
lg::set_file(file_util::get_file_path({"log/game.txt"}));
if (verbose) {
lg::set_file_level(lg::level::debug);
lg::set_stdout_level(lg::level::debug);
lg::set_flush_level(lg::level::debug);
} else {
lg::set_file_level(lg::level::debug);
lg::set_stdout_level(lg::level::warn);
lg::set_flush_level(lg::level::warn);
}
lg::initialize();
}
/*!
* Entry point for the game.
*/
int main(int argc, char** argv) {
// Figure out if the CPU has AVX2 to enable higher performance AVX2 versions of functions.
setup_cpu_info();
// If the CPU doesn't have AVX, GOAL code won't work and we exit.
if (!get_cpu_info().has_avx) {
printf("Your CPU does not support AVX, which is required for OpenGOAL.\n");
return -1;
}
// parse arguments
bool verbose = false;
bool disable_avx2 = false;
std::optional<std::filesystem::path> project_path_override = std::nullopt;
for (int i = 1; i < argc; i++) {
if (std::string("-v") == argv[i]) {
verbose = true;
break;
}
if (std::string("-no-avx2") == argv[i]) {
disable_avx2 = true;
}
if (std::string("-proj-path") == argv[i] && i + 1 < argc) {
project_path_override = std::make_optional(std::filesystem::path(argv[i + 1]));
}
}
// set up file paths for resources. This is the full repository when developing, and the data
// directory (a subset of the full repo) in release versions
if (!file_util::setup_project_path(project_path_override)) {
return 1;
}
// set up discord stuff
gStartTime = time(nullptr);
init_discord_rpc();
if (disable_avx2) {
// for debugging the non-avx2 code paths, there's a flag to manually disable.
printf("Note: AVX2 code has been manually disabled.\n");
get_cpu_info().has_avx2 = false;
}
#ifndef __AVX2__
if (get_cpu_info().has_avx2) {
// printf("Note: your CPU supports AVX2, but this build was not compiled with AVX2 support\n");
get_cpu_info().has_avx2 = false;
}
#endif
if (get_cpu_info().has_avx2) {
printf("AVX2 mode enabled\n");
} else {
printf("AVX2 mode disabled\n");
}
setup_logging(verbose);
bool force_debug_next_time = false;
while (true) {
std::vector<std::string> args;
for (int i = 0; i < argc; i++) {
args.push_back(argv[i]);
}
if (force_debug_next_time) {
args.push_back("-boot");
args.push_back("-debug");
force_debug_next_time = false;
}
std::vector<char*> ptrs;
for (auto& str : args) {
ptrs.push_back(str.data());
}
// run the runtime in a loop so we can reset the game and have it restart cleanly
lg::info("OpenGOAL Runtime {}.{}", versions::GOAL_VERSION_MAJOR, versions::GOAL_VERSION_MINOR);
auto exit_status = exec_runtime(ptrs.size(), ptrs.data());
switch (exit_status) {
case RuntimeExitStatus::EXIT:
return 0;
case RuntimeExitStatus::RESTART_RUNTIME:
case RuntimeExitStatus::RUNNING:
break;
case RuntimeExitStatus::RESTART_IN_DEBUG:
force_debug_next_time = true;
break;
}
}
return 0;
}