mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-06 06:05:40 +12:00
Add Y2R event delay
This commit is contained in:
parent
29d9ed7224
commit
1c9a3ac3d3
7 changed files with 40 additions and 8 deletions
|
@ -15,6 +15,7 @@
|
||||||
#include "services/service_manager.hpp"
|
#include "services/service_manager.hpp"
|
||||||
|
|
||||||
class CPU;
|
class CPU;
|
||||||
|
struct Scheduler;
|
||||||
|
|
||||||
class Kernel {
|
class Kernel {
|
||||||
std::span<u32, 16> regs;
|
std::span<u32, 16> regs;
|
||||||
|
@ -243,6 +244,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceManager& getServiceManager() { return serviceManager; }
|
ServiceManager& getServiceManager() { return serviceManager; }
|
||||||
|
Scheduler& getScheduler();
|
||||||
|
|
||||||
void sendGPUInterrupt(GPUInterrupt type) { serviceManager.sendGPUInterrupt(type); }
|
void sendGPUInterrupt(GPUInterrupt type) { serviceManager.sendGPUInterrupt(type); }
|
||||||
void clearInstructionCache();
|
void clearInstructionCache();
|
||||||
|
|
|
@ -11,7 +11,8 @@ struct Scheduler {
|
||||||
VBlank = 0, // End of frame event
|
VBlank = 0, // End of frame event
|
||||||
UpdateTimers = 1, // Update kernel timer objects
|
UpdateTimers = 1, // Update kernel timer objects
|
||||||
RunDSP = 2, // Make the emulated DSP run for one audio frame
|
RunDSP = 2, // Make the emulated DSP run for one audio frame
|
||||||
Panic = 3, // Dummy event that is always pending and should never be triggered (Timestamp = UINT64_MAX)
|
SignalY2R = 3, // Signal that a Y2R conversion has finished
|
||||||
|
Panic = 4, // Dummy event that is always pending and should never be triggered (Timestamp = UINT64_MAX)
|
||||||
TotalNumberOfEvents // How many event types do we have in total?
|
TotalNumberOfEvents // How many event types do we have in total?
|
||||||
};
|
};
|
||||||
static constexpr usize totalNumberOfEvents = static_cast<usize>(EventType::TotalNumberOfEvents);
|
static constexpr usize totalNumberOfEvents = static_cast<usize>(EventType::TotalNumberOfEvents);
|
||||||
|
|
|
@ -109,4 +109,5 @@ class ServiceManager {
|
||||||
HIDService& getHID() { return hid; }
|
HIDService& getHID() { return hid; }
|
||||||
NFCService& getNFC() { return nfc; }
|
NFCService& getNFC() { return nfc; }
|
||||||
DSPService& getDSP() { return dsp; }
|
DSPService& getDSP() { return dsp; }
|
||||||
|
Y2RService& getY2R() { return y2r; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -113,8 +113,12 @@ class Y2RService {
|
||||||
void startConversion(u32 messagePointer);
|
void startConversion(u32 messagePointer);
|
||||||
void stopConversion(u32 messagePointer);
|
void stopConversion(u32 messagePointer);
|
||||||
|
|
||||||
public:
|
bool isBusy;
|
||||||
|
|
||||||
|
public:
|
||||||
Y2RService(Memory& mem, Kernel& kernel) : mem(mem), kernel(kernel) {}
|
Y2RService(Memory& mem, Kernel& kernel) : mem(mem), kernel(kernel) {}
|
||||||
void reset();
|
void reset();
|
||||||
void handleSyncRequest(u32 messagePointer);
|
void handleSyncRequest(u32 messagePointer);
|
||||||
|
|
||||||
|
void signalConversionDone();
|
||||||
};
|
};
|
|
@ -399,3 +399,5 @@ std::string Kernel::getProcessName(u32 pid) {
|
||||||
Helpers::panic("Attempted to name non-current process");
|
Helpers::panic("Attempted to name non-current process");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Scheduler& Kernel::getScheduler() { return cpu.getScheduler(); }
|
||||||
|
|
|
@ -61,6 +61,7 @@ void Y2RService::reset() {
|
||||||
inputLineWidth = 420;
|
inputLineWidth = 420;
|
||||||
|
|
||||||
conversionCoefficients.fill(0);
|
conversionCoefficients.fill(0);
|
||||||
|
isBusy = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Y2RService::handleSyncRequest(u32 messagePointer) {
|
void Y2RService::handleSyncRequest(u32 messagePointer) {
|
||||||
|
@ -156,6 +157,11 @@ void Y2RService::setTransferEndInterrupt(u32 messagePointer) {
|
||||||
void Y2RService::stopConversion(u32 messagePointer) {
|
void Y2RService::stopConversion(u32 messagePointer) {
|
||||||
log("Y2R::StopConversion\n");
|
log("Y2R::StopConversion\n");
|
||||||
|
|
||||||
|
if (isBusy) {
|
||||||
|
isBusy = false;
|
||||||
|
kernel.getScheduler().removeEvent(Scheduler::EventType::SignalY2R);
|
||||||
|
}
|
||||||
|
|
||||||
mem.write32(messagePointer, IPC::responseHeader(0x27, 1, 0));
|
mem.write32(messagePointer, IPC::responseHeader(0x27, 1, 0));
|
||||||
mem.write32(messagePointer + 4, Result::Success);
|
mem.write32(messagePointer + 4, Result::Success);
|
||||||
}
|
}
|
||||||
|
@ -167,7 +173,7 @@ void Y2RService::isBusyConversion(u32 messagePointer) {
|
||||||
|
|
||||||
mem.write32(messagePointer, IPC::responseHeader(0x28, 2, 0));
|
mem.write32(messagePointer, IPC::responseHeader(0x28, 2, 0));
|
||||||
mem.write32(messagePointer + 4, Result::Success);
|
mem.write32(messagePointer + 4, Result::Success);
|
||||||
mem.write32(messagePointer + 8, static_cast<u32>(BusyStatus::NotBusy));
|
mem.write32(messagePointer + 8, static_cast<u32>(isBusy ? BusyStatus::Busy : BusyStatus::NotBusy));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Y2RService::setBlockAlignment(u32 messagePointer) {
|
void Y2RService::setBlockAlignment(u32 messagePointer) {
|
||||||
|
@ -434,11 +440,14 @@ void Y2RService::startConversion(u32 messagePointer) {
|
||||||
mem.write32(messagePointer, IPC::responseHeader(0x26, 1, 0));
|
mem.write32(messagePointer, IPC::responseHeader(0x26, 1, 0));
|
||||||
mem.write32(messagePointer + 4, Result::Success);
|
mem.write32(messagePointer + 4, Result::Success);
|
||||||
|
|
||||||
// Make Y2R conversion end instantly.
|
// Schedule Y2R conversion end event.
|
||||||
// Signal the transfer end event if it's been created. TODO: Is this affected by SetTransferEndInterrupt?
|
static constexpr u64 delayTicks = 60'000;
|
||||||
if (transferEndEvent.has_value()) {
|
isBusy = true;
|
||||||
kernel.signalEvent(transferEndEvent.value());
|
|
||||||
}
|
// Remove any potential pending Y2R event and schedule a new one
|
||||||
|
Scheduler& scheduler = kernel.getScheduler();
|
||||||
|
scheduler.removeEvent(Scheduler::EventType::SignalY2R);
|
||||||
|
scheduler.addEvent(Scheduler::EventType::SignalY2R, scheduler.currentTimestamp + delayTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Y2RService::isFinishedSendingYUV(u32 messagePointer) {
|
void Y2RService::isFinishedSendingYUV(u32 messagePointer) {
|
||||||
|
@ -484,4 +493,15 @@ void Y2RService::isFinishedReceiving(u32 messagePointer) {
|
||||||
mem.write32(messagePointer, IPC::responseHeader(0x17, 2, 0));
|
mem.write32(messagePointer, IPC::responseHeader(0x17, 2, 0));
|
||||||
mem.write32(messagePointer + 4, Result::Success);
|
mem.write32(messagePointer + 4, Result::Success);
|
||||||
mem.write32(messagePointer + 8, finished ? 1 : 0);
|
mem.write32(messagePointer + 8, finished ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Y2RService::signalConversionDone() {
|
||||||
|
if (isBusy) {
|
||||||
|
isBusy = false;
|
||||||
|
|
||||||
|
// Signal the transfer end event if it's been created. TODO: Is this affected by SetTransferEndInterrupt?
|
||||||
|
if (transferEndEvent.has_value()) {
|
||||||
|
kernel.signalEvent(transferEndEvent.value());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -169,6 +169,8 @@ void Emulator::pollScheduler() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case Scheduler::EventType::SignalY2R: kernel.getServiceManager().getY2R().signalConversionDone(); break;
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
Helpers::panic("Scheduler: Unimplemented event type received: %d\n", static_cast<int>(eventType));
|
Helpers::panic("Scheduler: Unimplemented event type received: %d\n", static_cast<int>(eventType));
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue