Store program ID and expose it in Lua ()

This commit is contained in:
wheremyfoodat 2024-02-22 14:26:31 +00:00 committed by GitHub
parent 7b580ac80e
commit 6279ed699a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 66 additions and 22 deletions

View file

@ -132,6 +132,7 @@ class Emulator {
ServiceManager& getServiceManager() { return kernel.getServiceManager(); }
LuaManager& getLua() { return lua; }
Scheduler& getScheduler() { return scheduler; }
Memory& getMemory() { return memory; }
RendererType getRendererType() const { return config.rendererType; }
Renderer* getRenderer() { return gpu.getRenderer(); }

View file

@ -36,6 +36,7 @@ struct NCCH {
};
u64 partitionIndex = 0;
u64 programID = 0;
u64 fileOffset = 0;
bool isNew3DS = false;

View file

@ -2,7 +2,6 @@
#include <string>
#include "helpers.hpp"
#include "memory.hpp"
// The kinds of events that can cause a Lua call.
// Frame: Call program on frame end
@ -11,6 +10,8 @@ enum class LuaEvent {
Frame,
};
class Emulator;
#ifdef PANDA3DS_ENABLE_LUA
extern "C" {
#include <lauxlib.h>
@ -30,9 +31,9 @@ class LuaManager {
public:
// For Lua we must have some global pointers to our emulator objects to use them in script code via thunks. See the thunks in lua.cpp as an
// example
static Memory* g_memory;
static Emulator* g_emulator;
LuaManager(Memory& mem) { g_memory = &mem; }
LuaManager(Emulator& emulator) { g_emulator = &emulator; }
void close();
void initialize();
@ -51,7 +52,7 @@ class LuaManager {
#else // Lua not enabled, Lua manager does nothing
class LuaManager {
public:
LuaManager(Memory& mem) {}
LuaManager(Emulator& emulator) {}
void close() {}
void initialize() {}

View file

@ -275,6 +275,8 @@ private:
// File handle for reading the loaded ncch
IOFile CXIFile;
std::optional<u64> getProgramID();
u8* getDSPMem() { return dspRam; }
u8* getDSPDataMem() { return &dspRam[DSP_DATA_MEMORY_OFFSET]; }
u8* getDSPCodeMem() { return &dspRam[DSP_CODE_MEMORY_OFFSET]; }