mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-08 23:25:40 +12:00
[APT/CFG/Kernel] Smash Bros stuff
This commit is contained in:
parent
327b071efd
commit
1078253f6c
5 changed files with 32 additions and 9 deletions
|
@ -235,4 +235,6 @@ public:
|
||||||
u8* getDSPMem() { return dspRam; }
|
u8* getDSPMem() { return dspRam; }
|
||||||
u8* getDSPDataMem() { return &dspRam[DSP_DATA_MEMORY_OFFSET]; }
|
u8* getDSPDataMem() { return &dspRam[DSP_DATA_MEMORY_OFFSET]; }
|
||||||
u8* getDSPCodeMem() { return &dspRam[DSP_CODE_MEMORY_OFFSET]; }
|
u8* getDSPCodeMem() { return &dspRam[DSP_CODE_MEMORY_OFFSET]; }
|
||||||
|
|
||||||
|
u32 getUsedUserMem() { return usedUserMemory; }
|
||||||
};
|
};
|
|
@ -8,6 +8,10 @@
|
||||||
// Yay, more circular dependencies
|
// Yay, more circular dependencies
|
||||||
class Kernel;
|
class Kernel;
|
||||||
|
|
||||||
|
enum class ConsoleModel : u32 {
|
||||||
|
Old3DS, New3DS
|
||||||
|
};
|
||||||
|
|
||||||
class APTService {
|
class APTService {
|
||||||
Handle handle = KernelHandles::APT;
|
Handle handle = KernelHandles::APT;
|
||||||
Memory& mem;
|
Memory& mem;
|
||||||
|
@ -17,6 +21,8 @@ class APTService {
|
||||||
std::optional<Handle> notificationEvent = std::nullopt;
|
std::optional<Handle> notificationEvent = std::nullopt;
|
||||||
std::optional<Handle> resumeEvent = std::nullopt;
|
std::optional<Handle> resumeEvent = std::nullopt;
|
||||||
|
|
||||||
|
ConsoleModel model = ConsoleModel::Old3DS;
|
||||||
|
|
||||||
MAKE_LOG_FUNCTION(log, aptLogger)
|
MAKE_LOG_FUNCTION(log, aptLogger)
|
||||||
|
|
||||||
// Service commands
|
// Service commands
|
||||||
|
@ -34,6 +40,7 @@ class APTService {
|
||||||
void replySleepQuery(u32 messagePointer);
|
void replySleepQuery(u32 messagePointer);
|
||||||
void setApplicationCpuTimeLimit(u32 messagePointer);
|
void setApplicationCpuTimeLimit(u32 messagePointer);
|
||||||
void setScreencapPostPermission(u32 messagePointer);
|
void setScreencapPostPermission(u32 messagePointer);
|
||||||
|
void theSmashBrosFunction(u32 messagePointer);
|
||||||
|
|
||||||
// Percentage of the syscore available to the application, between 5% and 89%
|
// Percentage of the syscore available to the application, between 5% and 89%
|
||||||
u32 cpuTimeLimit;
|
u32 cpuTimeLimit;
|
||||||
|
|
|
@ -194,6 +194,13 @@ void Kernel::getProcessInfo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
// According to 3DBrew: Amount of private (code, data, heap) memory used by the process + total supervisor-mode
|
||||||
|
// stack size + page-rounded size of the external handle table
|
||||||
|
case 2:
|
||||||
|
regs[1] = mem.getUsedUserMem();
|
||||||
|
regs[2] = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
case 20: // Returns 0x20000000 - <linear memory base vaddr for process>
|
case 20: // Returns 0x20000000 - <linear memory base vaddr for process>
|
||||||
regs[1] = PhysicalAddrs::FCRAM - mem.getLinearHeapVaddr();
|
regs[1] = PhysicalAddrs::FCRAM - mem.getLinearHeapVaddr();
|
||||||
regs[2] = 0;
|
regs[2] = 0;
|
||||||
|
|
|
@ -16,14 +16,8 @@ namespace APTCommands {
|
||||||
GetApplicationCpuTimeLimit = 0x00500040,
|
GetApplicationCpuTimeLimit = 0x00500040,
|
||||||
SetScreencapPostPermission = 0x00550040,
|
SetScreencapPostPermission = 0x00550040,
|
||||||
CheckNew3DSApp = 0x01010000,
|
CheckNew3DSApp = 0x01010000,
|
||||||
CheckNew3DS = 0x01020000
|
CheckNew3DS = 0x01020000,
|
||||||
};
|
TheSmashBrosFunction = 0x01030000
|
||||||
}
|
|
||||||
|
|
||||||
namespace Model {
|
|
||||||
enum : u8 {
|
|
||||||
Old3DS = 0,
|
|
||||||
New3DS = 1
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +55,7 @@ void APTService::handleSyncRequest(u32 messagePointer) {
|
||||||
case APTCommands::ReplySleepQuery: replySleepQuery(messagePointer); break;
|
case APTCommands::ReplySleepQuery: replySleepQuery(messagePointer); break;
|
||||||
case APTCommands::SetApplicationCpuTimeLimit: setApplicationCpuTimeLimit(messagePointer); break;
|
case APTCommands::SetApplicationCpuTimeLimit: setApplicationCpuTimeLimit(messagePointer); break;
|
||||||
case APTCommands::SetScreencapPostPermission: setScreencapPostPermission(messagePointer); break;
|
case APTCommands::SetScreencapPostPermission: setScreencapPostPermission(messagePointer); break;
|
||||||
|
case APTCommands::TheSmashBrosFunction: theSmashBrosFunction(messagePointer); break;
|
||||||
default: Helpers::panic("APT service requested. Command: %08X\n", command);
|
default: Helpers::panic("APT service requested. Command: %08X\n", command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +74,7 @@ void APTService::appletUtility(u32 messagePointer) {
|
||||||
void APTService::checkNew3DS(u32 messagePointer) {
|
void APTService::checkNew3DS(u32 messagePointer) {
|
||||||
log("APT::CheckNew3DS\n");
|
log("APT::CheckNew3DS\n");
|
||||||
mem.write32(messagePointer + 4, Result::Success);
|
mem.write32(messagePointer + 4, Result::Success);
|
||||||
mem.write8(messagePointer + 8, Model::Old3DS); // u8, Status (0 = Old 3DS, 1 = New 3DS)
|
mem.write8(messagePointer + 8, (model == ConsoleModel::New3DS) ? 1 : 0); // u8, Status (0 = Old 3DS, 1 = New 3DS)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Figure out the slight way this differs from APT::CheckNew3DS
|
// TODO: Figure out the slight way this differs from APT::CheckNew3DS
|
||||||
|
@ -193,4 +188,13 @@ void APTService::getSharedFont(u32 messagePointer) {
|
||||||
mem.write32(messagePointer + 4, Result::Success);
|
mem.write32(messagePointer + 4, Result::Success);
|
||||||
mem.write32(messagePointer + 8, fontVaddr);
|
mem.write32(messagePointer + 8, fontVaddr);
|
||||||
mem.write32(messagePointer + 16, KernelHandles::FontSharedMemHandle);
|
mem.write32(messagePointer + 16, KernelHandles::FontSharedMemHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This function is entirely undocumented. We know Smash Bros uses it and that it normally writes 2 to cmdreply[2] on New 3DS
|
||||||
|
// And that writing 1 stops it from accessing the ir:USER service for New 3DS HID use
|
||||||
|
void APTService::theSmashBrosFunction(u32 messagePointer) {
|
||||||
|
log("APT: Called the elusive Smash Bros function\n");
|
||||||
|
|
||||||
|
mem.write32(messagePointer + 4, Result::Success);
|
||||||
|
mem.write32(messagePointer + 8, (model == ConsoleModel::New3DS) ? 2 : 1);
|
||||||
}
|
}
|
|
@ -87,6 +87,9 @@ void CFGService::getConfigInfoBlk2(u32 messagePointer) {
|
||||||
} else if (size == 4 && blockID == 0xB0003) { // Coordinates (latidude and longtitude) as s16
|
} else if (size == 4 && blockID == 0xB0003) { // Coordinates (latidude and longtitude) as s16
|
||||||
mem.write16(output, 0); // Latitude
|
mem.write16(output, 0); // Latitude
|
||||||
mem.write16(output + 2, 0); // Longtitude
|
mem.write16(output + 2, 0); // Longtitude
|
||||||
|
} else if (size == 2 && blockID == 0xA0001) { // Birthday
|
||||||
|
mem.write8(output, 5); // Month (May)
|
||||||
|
mem.write8(output + 1, 5); // Day (Fifth)
|
||||||
} else if (size == 8 && blockID == 0x30001) { // User time offset
|
} else if (size == 8 && blockID == 0x30001) { // User time offset
|
||||||
printf("Read from user time offset field in NAND. TODO: What is this\n");
|
printf("Read from user time offset field in NAND. TODO: What is this\n");
|
||||||
mem.write64(output, 0);
|
mem.write64(output, 0);
|
||||||
|
|
Loading…
Add table
Reference in a new issue