More JIT work

This commit is contained in:
CocoSimone
2023-01-05 01:20:34 +01:00
parent 64630ea06b
commit 60d0dd2c31
7 changed files with 134 additions and 158 deletions

View File

@@ -13,6 +13,11 @@ using namespace nlohmann;
namespace fs = std::filesystem;
GameList::GameList(const std::string& path) {
Create(path);
}
void GameList::Create(const std::string &path) {
threadDone = false;
if(!path.empty()) {
std::thread searchThread([path, this]() {
std::ifstream gameDbFile("resources/db.json");
@@ -20,6 +25,10 @@ GameList::GameList(const std::string& path) {
std::vector<u8> rom{};
for(const auto& p : fs::recursive_directory_iterator{path}) {
const auto filename = p.path().string();
if(threadDone) {
gamesList.clear();
break;
}
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(filename, std::ios::binary);

View File

@@ -3,13 +3,6 @@
#include <string>
#include <atomic>
enum GameInfoID {
Name_ID,
Region_ID,
Size_ID,
Status_ID
};
struct GameInfo {
std::string name, region, size, status, path;
};
@@ -18,10 +11,11 @@ struct GameList {
GameList(const std::string&);
~GameList() = default;
void Create(const std::string&);
bool RenderWidget(float, std::string&);
[[nodiscard]] std::vector<GameInfo> GetGamesList() const { return gamesList; }
std::atomic_bool threadDone = false;
private:
std::vector<GameInfo> gamesList{}, notMatch{};
std::atomic_bool threadDone = false;
};

View File

@@ -160,6 +160,7 @@ DrawData Window::Present(n64::Core& core) {
void Window::LoadROM(n64::Core& core, const std::string &path) {
if(!path.empty()) {
gameList.threadDone = true;
n64::CartInfo cartInfo = core.LoadROM(path);
std::ifstream gameDbFile("resources/db.json");
json gameDb = json::parse(gameDbFile);
@@ -243,6 +244,7 @@ float Window::Render(n64::Core& core) {
core.rom.clear();
Util::UpdateRPC(Util::Idling);
SDL_SetWindowTitle(window, windowTitle.c_str());
gameList.Create(settings.GetGamesDir());
core.Stop();
}
if (ImGui::MenuItem(core.pause ? "Resume" : "Pause", nullptr, false, core.romLoaded)) {