Add some directories to environment

This commit is contained in:
Jesse Talavera-Greenberg 2023-03-07 09:21:43 -05:00
parent 65f753b84d
commit 1e715272b6
2 changed files with 21 additions and 1 deletions

View File

@ -5,6 +5,8 @@
#ifndef MELONDS_DS_ENVIRONMENT_HPP
#define MELONDS_DS_ENVIRONMENT_HPP
#include <string>
namespace retro {
/// For use by other parts of the core
bool environment(unsigned cmd, void *data);
@ -12,6 +14,9 @@ namespace retro {
void log(enum retro_log_level level, const char *fmt, ...);
bool supports_bitmasks();
const std::string& base_directory();
const std::string& save_directory();
}
#endif //MELONDS_DS_ENVIRONMENT_HPP

View File

@ -1,9 +1,24 @@
#include <libretro.h>
#include "environment.hpp"
#include "libretro.hpp"
PUBLIC_SYMBOL void retro_init(void) {
namespace retro {
static std::string _base_directory;
static std::string _save_directory;
}
PUBLIC_SYMBOL void retro_init(void) {
const char *dir = nullptr;
srand(time(nullptr));
if (retro::environment(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &dir) && dir)
retro::_base_directory = dir;
if (retro::environment(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY, &dir) && dir)
retro::_save_directory = dir;
}
PUBLIC_SYMBOL void retro_deinit(void) {