New DB
This commit is contained in:
7132
resources/db.json
Normal file
7132
resources/db.json
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -40,41 +40,7 @@ GameList::GameList(const std::string& path) {
|
||||
std::for_each(std::execution::par_unseq, begin(recursive_directory_iterator{path}), end(recursive_directory_iterator{path}), [&](const auto& p) {
|
||||
if(p.path().extension() == ".n64" || p.path().extension() == ".z64" || p.path().extension() == ".v64" ||
|
||||
p.path().extension() == ".N64" || p.path().extension() == ".Z64" || p.path().extension() == ".V64") {
|
||||
std::ifstream file(p.path().string(), std::ios::binary);
|
||||
file.unsetf(std::ios::skipws);
|
||||
|
||||
if(!file.is_open()) {
|
||||
util::panic("Unable to open {}!", path);
|
||||
}
|
||||
|
||||
file.seekg(0, std::ios::end);
|
||||
auto size = file.tellg();
|
||||
auto sizeAdjusted = util::NextPow2(size);
|
||||
file.seekg(0, std::ios::beg);
|
||||
|
||||
std::vector<u8> cart{};
|
||||
|
||||
std::fill(cart.begin(), cart.end(), 0);
|
||||
cart.resize(sizeAdjusted);
|
||||
cart.insert(cart.begin(), std::istream_iterator<u8>(file), std::istream_iterator<u8>());
|
||||
|
||||
file.close();
|
||||
|
||||
u32 crc, dummy;
|
||||
util::SwapN64Rom(sizeAdjusted, cart.data(), crc, dummy);
|
||||
|
||||
u8 countryCode = 0;
|
||||
countryCode = cart[0x3D];
|
||||
|
||||
std::ifstream gameDbFile("resources/game_db.json");
|
||||
json gameDb = json::parse(gameDbFile);
|
||||
auto entry = gameDb[fmt::format("{:08x}", crc)]["name"];
|
||||
|
||||
if(!entry.empty()) {
|
||||
gamesList.push_back({entry.get<std::string>(), CountryCodeToStr(countryCode), fmt::format("{:.2f} MiB", float(size) / 1024 / 1024), p.path().string()});
|
||||
} else {
|
||||
gamesList.push_back({p.path().stem().string(), CountryCodeToStr(countryCode), fmt::format("{:.2f} MiB", float(size) / 1024 / 1024), p.path().string()});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <Core.hpp>
|
||||
#include <Audio.hpp>
|
||||
#include <SDL.h>
|
||||
#include <iostream>
|
||||
|
||||
VkInstance instance{};
|
||||
|
||||
@@ -157,16 +158,28 @@ ImDrawData* Window::Present(n64::Core& core) {
|
||||
void Window::LoadROM(n64::Core& core, const std::string &path) {
|
||||
if(!path.empty()) {
|
||||
n64::CartInfo cartInfo = core.LoadROM(path);
|
||||
std::ifstream gameDbFile("resources/game_db.json");
|
||||
std::ifstream gameDbFile("resources/db.json");
|
||||
json gameDb = json::parse(gameDbFile);
|
||||
auto entry = gameDb[fmt::format("{:08x}", cartInfo.crc)]["name"];
|
||||
|
||||
if(!entry.empty()) {
|
||||
gameName = entry.get<std::string>();
|
||||
} else {
|
||||
for(const auto& item : gameDb["titles"]) {
|
||||
auto temp = item["part"]["dataarea"];
|
||||
std::cout << temp << "\n";
|
||||
//if(!crc.empty()) {
|
||||
// if(crc.get<std::string>() == fmt::format("{:08x}", cartInfo.crc)) {
|
||||
// auto desc = item["description"];
|
||||
// if(desc.empty()) {
|
||||
// gameName = desc.get<std::string>();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
};
|
||||
|
||||
if(gameName.empty()) {
|
||||
gameName = std::filesystem::path(path).stem().string();
|
||||
}
|
||||
|
||||
std::cout << gameName << "\n";
|
||||
|
||||
util::UpdateRPC(util::Playing, gameName);
|
||||
windowTitle = "Gadolinium - " + gameName;
|
||||
shadowWindowTitle = windowTitle;
|
||||
|
||||
Reference in New Issue
Block a user