Skip to content

Commit

Permalink
draw immediately to reduce judder
Browse files Browse the repository at this point in the history
  • Loading branch information
skyfloogle committed Apr 2, 2024
1 parent dd6f2b9 commit ea6f6ae
Showing 1 changed file with 24 additions and 29 deletions.
53 changes: 24 additions & 29 deletions source/3ds/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,41 +118,14 @@ int main() {
lag_frames = 0;
}

// if hold, turn off fast forward, as it'll be turned back on while reading input
if (!tVBOpt.FF_TOGGLE) tVBOpt.FASTFORWARD = false;

// read inputs once per frame
HWORD inputs = V810_RControll();
tHReg.SLB =(BYTE)(inputs&0xFF);
tHReg.SHB =(BYTE)((inputs>>8)&0xFF);

replay_update(inputs);

float last_drc_time = osTickCounterRead(&drcTickCounter);

#if DEBUGLEVEL == 0
consoleSelect(&debug_console);
#endif
osTickCounterStart(&drcTickCounter);
err = drc_run();
osTickCounterUpdate(&drcTickCounter);
if (err) {
showError(err);
do {
hidScanInput();
gspWaitForVBlank();
} while (aptMainLoop() && !hidKeysDown());
goto exit;
}

// Display a frame, only after the right number of 'skips'
if(tVIPREG.tFrame == tVIPREG.FRMCYC) {
int alt_buf = (tVIPREG.tFrameBuffer) % 2;
// pass C3D_FRAME_NONBLOCK to enable frameskip, 0 to disable
// it's only needed for 1 second in the mario clash intro afaik
// so just bite the bullet and do the frameskip, rather that than slowdown
if (C3D_FrameBegin(C3D_FRAME_NONBLOCK)) {
guiUpdate(osTickCounterRead(&frameTickCounter), last_drc_time);
guiUpdate(osTickCounterRead(&frameTickCounter), osTickCounterRead(&drcTickCounter));

if (tVIPREG.DPCTRL & 0x0002) {
video_render(alt_buf);
Expand All @@ -169,11 +142,33 @@ int main() {
} else {
// no game graphics, draw menu if possible
if (C3D_FrameBegin(C3D_FRAME_NONBLOCK)) {
guiUpdate(osTickCounterRead(&frameTickCounter), last_drc_time);
guiUpdate(osTickCounterRead(&frameTickCounter), osTickCounterRead(&drcTickCounter));
C3D_FrameEnd(0);
}
}

// if hold, turn off fast forward, as it'll be turned back on while reading input
if (!tVBOpt.FF_TOGGLE) tVBOpt.FASTFORWARD = false;

// read inputs once per frame
HWORD inputs = V810_RControll();
tHReg.SLB =(BYTE)(inputs&0xFF);
tHReg.SHB =(BYTE)((inputs>>8)&0xFF);

replay_update(inputs);

osTickCounterStart(&drcTickCounter);
err = drc_run();
osTickCounterUpdate(&drcTickCounter);
if (err) {
showError(err);
do {
hidScanInput();
gspWaitForVBlank();
} while (aptMainLoop() && !hidKeysDown());
goto exit;
}

// Increment frame
frame++;

Expand Down

0 comments on commit ea6f6ae

Please sign in to comment.