예제 #1
0
 // Emulates until the next video frame has to be drawn. Returns the hit address.
 public int AdvanceFrame(Joypad joypad = Joypad.None)
 {
     CurrentJoypad = joypad;
     RunFor(SamplesPerFrame - BufferSamples);
     CurrentJoypad = Joypad.None;
     return(Libgambatte.gambatte_gethitinterruptaddress(Handle));
 }
예제 #2
0
    // Emulates 'runsamples' number of samples, or until a video frame has to be drawn. (1 sample = 2 cpu cycles)
    public int RunFor(int runsamples)
    {
        int videoFrameDoneSampleCount = Libgambatte.gambatte_runfor(Handle, VideoBuffer, 160, AudioBuffer, ref runsamples);
        int outsamples = videoFrameDoneSampleCount >= 0 ? BufferSamples + videoFrameDoneSampleCount : BufferSamples + runsamples;

        BufferSamples   += runsamples;
        BufferSamples   -= outsamples;
        EmulatedSamples += (ulong)outsamples;

        if (Scene != null)
        {
            Scene.OnAudioReady(outsamples);
            // returns a positive value if a video frame needs to be drawn.
            if (videoFrameDoneSampleCount >= 0)
            {
                Scene.Begin();
                Scene.Render();
                Scene.End();
            }
        }

        return(Libgambatte.gambatte_gethitinterruptaddress(Handle));
    }