mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-06 22:25:41 +12:00
[Kernel] Make File::GetSize panic
This commit is contained in:
parent
deaf7d518c
commit
c16bf5c8aa
3 changed files with 22 additions and 1 deletions
|
@ -120,6 +120,7 @@ private:
|
|||
void handleFileOperation(u32 messagePointer, Handle file);
|
||||
void closeFile(u32 messagePointer, Handle file);
|
||||
void readFile(u32 messagePointer, Handle file);
|
||||
void getFileSize(u32 messagePointer, Handle file);
|
||||
|
||||
public:
|
||||
Kernel(CPU& cpu, Memory& mem, GPU& gpu);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace FileOps {
|
||||
enum : u32 {
|
||||
Read = 0x080200C2,
|
||||
GetSize = 0x08040000,
|
||||
Close = 0x08080000
|
||||
};
|
||||
}
|
||||
|
@ -18,6 +19,7 @@ void Kernel::handleFileOperation(u32 messagePointer, Handle file) {
|
|||
const u32 cmd = mem.read32(messagePointer);
|
||||
switch (cmd) {
|
||||
case FileOps::Close: closeFile(messagePointer, file); break;
|
||||
case FileOps::GetSize: getFileSize(messagePointer, file); break;
|
||||
case FileOps::Read: readFile(messagePointer, file); break;
|
||||
default: Helpers::panic("Unknown file operation: %08X", cmd);
|
||||
}
|
||||
|
@ -62,4 +64,22 @@ void Kernel::readFile(u32 messagePointer, Handle fileHandle) {
|
|||
mem.write32(messagePointer + 4, Result::Success);
|
||||
mem.write32(messagePointer + 8, bytesRead.value());
|
||||
}
|
||||
}
|
||||
|
||||
void Kernel::getFileSize(u32 messagePointer, Handle fileHandle) {
|
||||
logFileIO("Getting size of file %X\n", fileHandle);
|
||||
|
||||
const auto p = getObject(fileHandle, KernelObjectType::File);
|
||||
if (p == nullptr) [[unlikely]] {
|
||||
Helpers::panic("Called GetFileSize on non-existent file");
|
||||
}
|
||||
|
||||
FileSession* file = p->getData<FileSession>();
|
||||
if (!file->isOpen) {
|
||||
Helpers::panic("Tried to get size of closed file");
|
||||
}
|
||||
|
||||
mem.write32(messagePointer + 4, Result::Success);
|
||||
mem.write64(messagePointer + 8, 0); // Size here
|
||||
Helpers::panic("TODO: Implement FileOp::GetSize");
|
||||
}
|
|
@ -9,7 +9,7 @@ int main (int argc, char *argv[]) {
|
|||
|
||||
emu.initGraphicsContext();
|
||||
|
||||
auto romPath = std::filesystem::current_path() / (argc > 1 ? argv[1] : "OoT.3ds");
|
||||
auto romPath = std::filesystem::current_path() / (argc > 1 ? argv[1] : "Pokemon Mystery Dungeon - Gates to Infinity (USA).3ds");
|
||||
if (!emu.loadROM(romPath)) {
|
||||
// For some reason just .c_str() doesn't show the proper path
|
||||
Helpers::panic("Failed to load ROM file: %s", romPath.string().c_str());
|
||||
|
|
Loading…
Add table
Reference in a new issue