diff options
| author | MegaMech <MegaMech@users.noreply.github.com> | 2025-02-07 22:24:00 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-07 22:24:00 -0700 |
| commit | 008d527ed5bae64e18eff59310bd18d698d4c016 (patch) | |
| tree | ac1d62f7ea28ad5ba81ca9640b6f490c3442ef55 /src/port/GameExtractor.cpp | |
| parent | 7fe705227028ef136317fbc9eceafd8bd366e6a2 (diff) | |
Torch Static Compile (#187)
* Fix freecam rotation smoothing
* Configure freecam controller
* Fix cont z button and impl freecam on/off events
* Add torch static comp
* Fixed cmake
* Copied yamls
---------
Co-authored-by: KiritoDv <kiritodev01@gmail.com>
Diffstat (limited to 'src/port/GameExtractor.cpp')
| -rw-r--r-- | src/port/GameExtractor.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/port/GameExtractor.cpp b/src/port/GameExtractor.cpp new file mode 100644 index 000000000..4a222c681 --- /dev/null +++ b/src/port/GameExtractor.cpp @@ -0,0 +1,56 @@ +#include "GameExtractor.h" +#include <unordered_map> + +#include <fstream> + +#include "Context.h" +#include "spdlog/spdlog.h" +#include "portable-file-dialogs.h" +#include <port/Engine.h> + +std::unordered_map<std::string, std::string> mGameList = { + { "579c48e211ae952530ffc8738709f078d5dd215e", "Mario Kart 64 (US)" }, +}; + +bool GameExtractor::SelectGameFromUI() { +#if !defined(__IOS__) || !defined(__ANDROID__) || !defined(__SWITCH__) + auto selection = pfd::open_file("Select a file", ".", { "N64 Roms", "*.z64" }).result(); + + if (selection.empty()) { + return false; + } + + this->mGamePath = selection[0]; +#else + this->mGamePath = Ship::Context::GetPathRelativeToAppDirectory("baserom.us.z64"); +#endif + + std::ifstream file(this->mGamePath, std::ios::binary); + this->mGameData = std::vector<uint8_t>( std::istreambuf_iterator( file ), {} ); + file.close(); + return true; +} + +std::optional<std::string> GameExtractor::ValidateChecksum() const { + const auto rom = new N64::Cartridge(this->mGameData); + rom->Initialize(); + auto hash = rom->GetHash(); + + if (mGameList.find(hash) == mGameList.end()) { + return std::nullopt; + } + + return mGameList[hash]; +} + +bool GameExtractor::GenerateOTR() const { + Companion::Instance = new Companion(this->mGameData, ArchiveType::O2R, false); + + try { + Companion::Instance->Init(ExportType::Binary); + } catch (const std::exception& e) { + return false; + } + + return true; +} |
