← Supporting evidence

Evidence record

snippets/frame-runner.cpp.inc

From Windows Application to Portable Emulation Platform

1,169 bytes

// Public source: https://vccplus-git.brianholman.com/VCCPlus/VCCPlusOSS/src/branch/main/src/core/FrameRunner.cpp
// Selected code lines: 18; selection, not the full current source.
// Original copyright/license notice and selected code follow unchanged.
// SPDX-License-Identifier: GPL-3.0-or-later
VCC::FrameResult VCC::RunFrame(GimeGpu& gpu, int (*execute)(int), std::size_t cycleBudget) {
#if USE_NEWTIMING
    if (!execute) throw std::invalid_argument("Frame execution requires a CPU");
    std::size_t cycles = 0;
    for (;;) {
        if (gpu.FrameFinished()) return {FrameStop::Complete, cycles};
        if (CpuDebugger().IsHalted()) return {FrameStop::Halted, cycles};
        if (cycles >= cycleBudget) return {FrameStop::Budget, cycles};
        const int request = cycleBudget - cycles < 2 ? 1 : 2;
        const auto elapsed = static_cast<long long>(request) - execute(request);
        if (elapsed <= 0)
            return {CpuDebugger().IsHalted() ? FrameStop::Halted : FrameStop::Stalled, cycles};
        cycles += static_cast<std::size_t>(elapsed);
    }
#else
    throw std::logic_error("RunFrame requires the event-based timing engine");
#endif
}

SHA-2567bd46f33627f3dc23d48343d2eaad39ffeec44c8a7558022ed87db2017056f06

A closer look

Open original