mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-06 22:25:41 +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 {
|
||||
return u64(MemoryRead32(vaddr)) | u64(MemoryRead32(vaddr + 4)) << 32;
|
||||
return mem.read64(vaddr);
|
||||
}
|
||||
|
||||
void MemoryWrite8(u32 vaddr, u8 value) override {
|
||||
|
@ -162,6 +162,7 @@ public:
|
|||
|
||||
void runFrame() {
|
||||
env.ticksLeft = 268111856 / 60;
|
||||
|
||||
const auto exitReason = jit->Run();
|
||||
if (static_cast<u32>(exitReason) != 0) [[unlikely]] {
|
||||
Helpers::panic("Exit reason: %d\nPC: %08X", static_cast<u32>(exitReason), getReg(15));
|
||||
|
|
|
@ -71,7 +71,7 @@ public:
|
|||
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)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -8,6 +8,9 @@ class CFGService {
|
|||
Memory& mem;
|
||||
MAKE_LOG_FUNCTION(log, cfgLogger)
|
||||
|
||||
// Service functions
|
||||
void getConfigInfoBlk2(u32 messagePointer);
|
||||
|
||||
public:
|
||||
CFGService(Memory& mem) : mem(mem) {}
|
||||
void reset();
|
||||
|
|
|
@ -63,4 +63,10 @@ public:
|
|||
DSPService(Memory& mem) : mem(mem) {}
|
||||
void reset();
|
||||
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;
|
||||
if (!ioFile.seek(cxi->fileOffset + romFSOffset + offset)) {
|
||||
if (!ioFile.seek(cxi->fileOffset + romFSOffset + offset + 0x1000)) {
|
||||
Helpers::panic("Failed to seek while reading from RomFS");
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ void Kernel::switchThread(int newThreadIndex) {
|
|||
auto& oldThread = threads[currentThreadIndex];
|
||||
auto& newThread = threads[newThreadIndex];
|
||||
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
|
||||
if (currentThreadIndex == newThreadIndex) [[unlikely]] {
|
||||
|
@ -136,8 +137,8 @@ void Kernel::createThread() {
|
|||
u32 initialSP = regs[3] & ~7; // SP is force-aligned to 8 bytes
|
||||
s32 id = static_cast<s32>(regs[4]);
|
||||
|
||||
logSVC("CreateThread(entry = %08X, stacktop = %08X, priority = %X, processor ID = %d)\n", entrypoint,
|
||||
initialSP, priority, id);
|
||||
logSVC("CreateThread(entry = %08X, stacktop = %08X, arg = %X, priority = %X, processor ID = %d)\n", entrypoint,
|
||||
initialSP, arg, priority, id);
|
||||
|
||||
if (priority > 0x3F) [[unlikely]] {
|
||||
Helpers::panic("Created thread with bad priority value %X", priority);
|
||||
|
@ -157,7 +158,6 @@ void Kernel::sleepThreadOnArbiter(u32 waitingAddress) {
|
|||
switchToNextThread();
|
||||
}
|
||||
|
||||
|
||||
void Kernel::getThreadID() {
|
||||
Handle handle = regs[1];
|
||||
logSVC("GetThreadID(handle = %X)\n", handle);
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#include "services/cfg.hpp"
|
||||
#include "services/dsp.hpp"
|
||||
|
||||
namespace CFGCommands {
|
||||
enum : u32 {
|
||||
GetConfigInfoBlk2 = 0x00010082
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -16,6 +18,23 @@ void CFGService::reset() {}
|
|||
void CFGService::handleSyncRequest(u32 messagePointer) {
|
||||
const u32 command = mem.read32(messagePointer);
|
||||
switch (command) {
|
||||
case CFGCommands::GetConfigInfoBlk2: getConfigInfoBlk2(messagePointer); break;
|
||||
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
Reference in a new issue