commit 38a12651a90d779da86e95350cc812fb37d5e4ff
Author: Jon Bell <j.to.the.bell@gmail.com>
AuthorDate: Sun Aug 28 18:43:10 2022 -0600
Commit: Jon Bell <j.to.the.bell@gmail.com>
CommitDate: Sun Aug 28 18:43:10 2022 -0600
Set cart dir on load in libretro
should allow basic multicart to work
---
platform/libretro/libretro.cpp | 11 +++++++----
platform/libretro/libretrohost.cpp | 10 ++++++++--
platform/libretro/{setInput.h => libretrohosthelpers.h} | 4 ++++
3 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/platform/libretro/libretro.cpp b/platform/libretro/libretro.cpp
index 1a90a60..6c76f0c 100644
--- a/platform/libretro/libretro.cpp
+++ b/platform/libretro/libretro.cpp
@@ -11,7 +11,7 @@
#include "../../source/hostVmShared.h"
#include "../../source/nibblehelpers.h"
#include "../../source/filehelpers.h"
-#include "setInput.h"
+#include "libretrohosthelpers.h"
//since this is a C api, we need to mark all these as extern
@@ -231,12 +231,9 @@ EXPORT void retro_run()
int16_t pointY = input_state_cb(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y);
if (pressed) {
- printf("raw: %d, %d\n", pointX, pointY);
picoMouseX = pointX * 64 / 32768 + 64;
picoMouseY = pointY * 64 / 32768 + 64;
mouseBtnState = 1;
- //printf("adjusted: %d, %d : %d\n", picoMouseX, picoMouseY, pressed);
- //
}
}
@@ -461,6 +458,12 @@ EXPORT void retro_cheat_set(unsigned index, bool enabled, const char *code)
EXPORT bool retro_load_game(struct retro_game_info const *info)
{
+ auto containingDir = getDirectory(info->path);
+
+ if (containingDir.length() > 0) {
+ setCartDirectory(containingDir);
+ }
+
_vm->QueueCartChange(info->path);
return true;
}
diff --git a/platform/libretro/libretrohost.cpp b/platform/libretro/libretrohost.cpp
index 1833f3c..3a0dd6e 100644
--- a/platform/libretro/libretrohost.cpp
+++ b/platform/libretro/libretrohost.cpp
@@ -9,7 +9,7 @@
#include <iostream>
using namespace std;
-#include "setInput.h"
+#include "libretrohosthelpers.h"
#include "../../source/host.h"
#include "../../source/hostVmShared.h"
#include "../../source/nibblehelpers.h"
@@ -24,6 +24,8 @@ static int16_t stubMouseX;
static int16_t stubMouseY;
static uint8_t stubMouseBtns;
+std::string _currentCartDirectory;
+
void setInputState(uint8_t kDown, uint8_t kHeld, int16_t mouseX, int16_t mouseY, uint8_t mouseBtns) {
stubCurrKDown = kDown;
stubCurrKHeld = kHeld;
@@ -32,6 +34,10 @@ void setInputState(uint8_t kDown, uint8_t kHeld, int16_t mouseX, int16_t mouseY,
stubMouseBtns = mouseBtns;
}
+void setCartDirectory(std::string dir) {
+ _currentCartDirectory = dir;
+}
+
Host::Host() { }
@@ -111,7 +117,7 @@ std::string Host::customBiosLua() {
}
std::string Host::getCartDirectory() {
- return "carts";
+ return _currentCartDirectory;
}
void Host::overrideLogFilePrefix(const char* newPrefix) {
diff --git a/platform/libretro/setInput.h b/platform/libretro/libretrohosthelpers.h
similarity index 67%
rename from platform/libretro/setInput.h
rename to platform/libretro/libretrohosthelpers.h
index d9ad8a2..e898bf3 100644
--- a/platform/libretro/setInput.h
+++ b/platform/libretro/libretrohosthelpers.h
@@ -1,6 +1,10 @@
+#include <string.h>
+
void setInputState(
uint8_t kDown,
uint8_t kHeld,
int16_t mouseX,
int16_t mouseY,
uint8_t mouseBtnState);
+
+void setCartDirectory(std::string dir);
\ No newline at end of file