core: Hacky TAS syncing & load pausing

To keep the TAS inputs synced to the game speed even through lag spikes and loading zones, deeper access is required.

First, the `TAS::UpdateThread` has to be executed exactly once per frame. This is done by connecting it to the service method the game calls to pass parameters to the GPU: `Service::VI::QueueBuffer`.

Second, the loading time of new subareas and/or kingdoms (SMO) can vary. To counteract that, the `CPU_BOOST_MODE` can be detected: In the `APM`-interface, the call to enabling/disabling the boost mode can be caught and forwarded to the TASing system, which can pause the script execution if neccessary and enabled in the settings.
This commit is contained in:
MonsterDruide1
2021-06-18 16:32:46 +02:00
parent 3a7b37238b
commit 4297d2fea2
9 changed files with 140 additions and 107 deletions

View File

@ -826,11 +826,11 @@ void GMainWindow::InitializeWidgets() {
});
statusBar()->insertPermanentWidget(0, renderer_status_button);
TASlabel = new QLabel();
TASlabel->setObjectName(QStringLiteral("TASlabel"));
TASlabel->setText(tr("TAS not running"));
TASlabel->setFocusPolicy(Qt::NoFocus);
statusBar()->insertPermanentWidget(0, TASlabel);
tas_label = new QLabel();
tas_label->setObjectName(QStringLiteral("TASlabel"));
tas_label->setText(tr("TAS not running"));
tas_label->setFocusPolicy(Qt::NoFocus);
statusBar()->insertPermanentWidget(0, tas_label);
statusBar()->setVisible(true);
setStyleSheet(QStringLiteral("QStatusBar::item{border: none;}"));
@ -2896,13 +2896,28 @@ void GMainWindow::UpdateWindowTitle(std::string_view title_name, std::string_vie
}
}
static std::string GetTasStateDescription(TasInput::TasState state) {
switch (state) {
case TasInput::TasState::RUNNING:
return "Running";
case TasInput::TasState::RECORDING:
return "Recording";
case TasInput::TasState::STOPPED:
return "Stopped";
default:
return "INVALID STATE";
}
}
void GMainWindow::UpdateStatusBar() {
if (emu_thread == nullptr) {
status_bar_update_timer.stop();
return;
}
TASlabel->setText(tr(input_subsystem->GetTas()->GetStatusDescription().c_str()));
auto [tas_status, current_tas_frame, total_tas_frames] = input_subsystem->GetTas()->GetStatus();
tas_label->setText(tr("%1 TAS %2/%3").arg(tr(GetTasStateDescription(tas_status).c_str())).arg(current_tas_frame).arg(total_tas_frames));
auto& system = Core::System::GetInstance();
auto results = system.GetAndResetPerfStats();
auto& shader_notify = system.GPU().ShaderNotify();