mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-17 19:21:30 +12:00
Cleanup, fix RomFS reads (todo: revisit), add CFG::GetConfigInfoBlk2
This commit is contained in:
parent
1ddba7737f
commit
156a89ba75
7 changed files with 35 additions and 6 deletions
|
@ -30,7 +30,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 MemoryRead64(u32 vaddr) override {
|
u64 MemoryRead64(u32 vaddr) override {
|
||||||
return u64(MemoryRead32(vaddr)) | u64(MemoryRead32(vaddr + 4)) << 32;
|
return mem.read64(vaddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryWrite8(u32 vaddr, u8 value) override {
|
void MemoryWrite8(u32 vaddr, u8 value) override {
|
||||||
|
@ -162,6 +162,7 @@ public:
|
||||||
|
|
||||||
void runFrame() {
|
void runFrame() {
|
||||||
env.ticksLeft = 268111856 / 60;
|
env.ticksLeft = 268111856 / 60;
|
||||||
|
|
||||||
const auto exitReason = jit->Run();
|
const auto exitReason = jit->Run();
|
||||||
if (static_cast<u32>(exitReason) != 0) [[unlikely]] {
|
if (static_cast<u32>(exitReason) != 0) [[unlikely]] {
|
||||||
Helpers::panic("Exit reason: %d\nPC: %08X", static_cast<u32>(exitReason), getReg(15));
|
Helpers::panic("Exit reason: %d\nPC: %08X", static_cast<u32>(exitReason), getReg(15));
|
||||||
|
|
|
@ -71,7 +71,7 @@ public:
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool seek(std::int64_t offset, int origin = 0) {
|
bool seek(std::int64_t offset, int origin = SEEK_SET) {
|
||||||
if (!isOpen() || fseeko(handle, offset, origin) != 0)
|
if (!isOpen() || fseeko(handle, offset, origin) != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,9 @@ class CFGService {
|
||||||
Memory& mem;
|
Memory& mem;
|
||||||
MAKE_LOG_FUNCTION(log, cfgLogger)
|
MAKE_LOG_FUNCTION(log, cfgLogger)
|
||||||
|
|
||||||
|
// Service functions
|
||||||
|
void getConfigInfoBlk2(u32 messagePointer);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CFGService(Memory& mem) : mem(mem) {}
|
CFGService(Memory& mem) : mem(mem) {}
|
||||||
void reset();
|
void reset();
|
||||||
|
|
|
@ -63,4 +63,10 @@ public:
|
||||||
DSPService(Memory& mem) : mem(mem) {}
|
DSPService(Memory& mem) : mem(mem) {}
|
||||||
void reset();
|
void reset();
|
||||||
void handleSyncRequest(u32 messagePointer);
|
void handleSyncRequest(u32 messagePointer);
|
||||||
|
|
||||||
|
enum class SoundOutputMode : u8 {
|
||||||
|
Mono = 0,
|
||||||
|
Stereo = 1,
|
||||||
|
Surround = 2
|
||||||
|
};
|
||||||
};
|
};
|
|
@ -42,7 +42,7 @@ std::optional<u32> SelfNCCHArchive::readFile(FileSession* file, u64 offset, u32
|
||||||
}
|
}
|
||||||
|
|
||||||
IOFile& ioFile = mem.CXIFile;
|
IOFile& ioFile = mem.CXIFile;
|
||||||
if (!ioFile.seek(cxi->fileOffset + romFSOffset + offset)) {
|
if (!ioFile.seek(cxi->fileOffset + romFSOffset + offset + 0x1000)) {
|
||||||
Helpers::panic("Failed to seek while reading from RomFS");
|
Helpers::panic("Failed to seek while reading from RomFS");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ void Kernel::switchThread(int newThreadIndex) {
|
||||||
auto& oldThread = threads[currentThreadIndex];
|
auto& oldThread = threads[currentThreadIndex];
|
||||||
auto& newThread = threads[newThreadIndex];
|
auto& newThread = threads[newThreadIndex];
|
||||||
newThread.status = ThreadStatus::Running;
|
newThread.status = ThreadStatus::Running;
|
||||||
|
printf("Switching from thread %d to %d\n", currentThreadIndex, newThreadIndex);
|
||||||
|
|
||||||
// Bail early if the new thread is actually the old thread
|
// Bail early if the new thread is actually the old thread
|
||||||
if (currentThreadIndex == newThreadIndex) [[unlikely]] {
|
if (currentThreadIndex == newThreadIndex) [[unlikely]] {
|
||||||
|
@ -136,8 +137,8 @@ void Kernel::createThread() {
|
||||||
u32 initialSP = regs[3] & ~7; // SP is force-aligned to 8 bytes
|
u32 initialSP = regs[3] & ~7; // SP is force-aligned to 8 bytes
|
||||||
s32 id = static_cast<s32>(regs[4]);
|
s32 id = static_cast<s32>(regs[4]);
|
||||||
|
|
||||||
logSVC("CreateThread(entry = %08X, stacktop = %08X, priority = %X, processor ID = %d)\n", entrypoint,
|
logSVC("CreateThread(entry = %08X, stacktop = %08X, arg = %X, priority = %X, processor ID = %d)\n", entrypoint,
|
||||||
initialSP, priority, id);
|
initialSP, arg, priority, id);
|
||||||
|
|
||||||
if (priority > 0x3F) [[unlikely]] {
|
if (priority > 0x3F) [[unlikely]] {
|
||||||
Helpers::panic("Created thread with bad priority value %X", priority);
|
Helpers::panic("Created thread with bad priority value %X", priority);
|
||||||
|
@ -157,7 +158,6 @@ void Kernel::sleepThreadOnArbiter(u32 waitingAddress) {
|
||||||
switchToNextThread();
|
switchToNextThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Kernel::getThreadID() {
|
void Kernel::getThreadID() {
|
||||||
Handle handle = regs[1];
|
Handle handle = regs[1];
|
||||||
logSVC("GetThreadID(handle = %X)\n", handle);
|
logSVC("GetThreadID(handle = %X)\n", handle);
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
#include "services/cfg.hpp"
|
#include "services/cfg.hpp"
|
||||||
|
#include "services/dsp.hpp"
|
||||||
|
|
||||||
namespace CFGCommands {
|
namespace CFGCommands {
|
||||||
enum : u32 {
|
enum : u32 {
|
||||||
|
GetConfigInfoBlk2 = 0x00010082
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +18,23 @@ void CFGService::reset() {}
|
||||||
void CFGService::handleSyncRequest(u32 messagePointer) {
|
void CFGService::handleSyncRequest(u32 messagePointer) {
|
||||||
const u32 command = mem.read32(messagePointer);
|
const u32 command = mem.read32(messagePointer);
|
||||||
switch (command) {
|
switch (command) {
|
||||||
|
case CFGCommands::GetConfigInfoBlk2: getConfigInfoBlk2(messagePointer); break;
|
||||||
default: Helpers::panic("CFG service requested. Command: %08X\n", command);
|
default: Helpers::panic("CFG service requested. Command: %08X\n", command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CFGService::getConfigInfoBlk2(u32 messagePointer) {
|
||||||
|
u32 size = mem.read32(messagePointer + 4);
|
||||||
|
u32 blockID = mem.read32(messagePointer + 8);
|
||||||
|
u32 output = mem.read32(messagePointer + 16); // Pointer to write the output data to
|
||||||
|
log("CFG::GetConfigInfoBlk2 (size = %X, block ID = %X, output pointer = %08X\n", size, blockID, output);
|
||||||
|
|
||||||
|
// Implement checking the sound output mode
|
||||||
|
if (size == 1 && blockID == 0x70001) {
|
||||||
|
mem.write8(output, (u8) DSPService::SoundOutputMode::Stereo);
|
||||||
|
} else {
|
||||||
|
Helpers::panic("Unhandled GetConfigInfoBlk2 configuration");
|
||||||
|
}
|
||||||
|
|
||||||
|
mem.write32(messagePointer + 4, Result::Success);
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue