Skip to content

Commit

Permalink
ignore antiflicker when framerate is below 50
Browse files Browse the repository at this point in the history
  • Loading branch information
skyfloogle committed Jun 16, 2024
1 parent b2889ae commit 8fc1ae5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/vb_dsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ typedef struct {
HWORD V810_RControll(bool reset);

void video_init(void);
void video_render(int alt_buf);
void video_render(int alt_buf, bool on_time);
void video_flush(bool left_for_both);
void video_quit(void);

Expand Down
12 changes: 11 additions & 1 deletion source/3ds/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ int main(void) {
int qwe;
int frame = 0;
int err = 0;
bool on_time = false;
PrintConsole main_console;
#if DEBUGLEVEL == 0
PrintConsole debug_console;
Expand Down Expand Up @@ -135,9 +136,15 @@ int main(void) {
guiUpdate(osTickCounterRead(&frameTickCounter), osTickCounterRead(&drcTickCounter));

if (tVIPREG.DPCTRL & 0x0002) {
video_render(alt_buf);
video_render(alt_buf, on_time);
on_time = true;
} else if (on_time) {
if (tVBOpt.ANTIFLICKER) video_flush(false);
on_time = false;
}
C3D_FrameEnd(0);
} else {
on_time = false;
}
if (tVIPREG.XPCTRL & 0x0002) {
if (tDSPCACHE.DDSPDataState[alt_buf] != GPU_CLEAR) {
Expand All @@ -149,9 +156,12 @@ int main(void) {
} else {
// no game graphics, draw menu if possible
if (C3D_FrameBegin(C3D_FRAME_NONBLOCK)) {
// refresh top screen for antiflicker
if (tVBOpt.ANTIFLICKER && on_time) video_flush(false);
guiUpdate(osTickCounterRead(&frameTickCounter), osTickCounterRead(&drcTickCounter));
C3D_FrameEnd(0);
}
on_time = false;
}

// if hold, turn off fast forward, as it'll be turned back on while reading input
Expand Down
6 changes: 3 additions & 3 deletions source/3ds/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ void video_init(void) {

static int g_alt_buf = 0;

void video_render(int alt_buf) {
if (tVBOpt.ANTIFLICKER) video_flush(false);
void video_render(int alt_buf, bool on_time) {
if (tVBOpt.ANTIFLICKER && on_time) video_flush(false);
g_alt_buf = alt_buf;
if (tDSPCACHE.ColumnTableInvalid)
processColumnTable();
Expand Down Expand Up @@ -276,7 +276,7 @@ void video_render(int alt_buf) {
}

C3D_BlendingColor(0x80808080);
if (tVBOpt.ANTIFLICKER) C3D_AlphaBlend(GPU_BLEND_ADD, 0, GPU_CONSTANT_ALPHA, GPU_ONE_MINUS_CONSTANT_ALPHA, 0, 0);
if (tVBOpt.ANTIFLICKER && on_time) C3D_AlphaBlend(GPU_BLEND_ADD, 0, GPU_CONSTANT_ALPHA, GPU_ONE_MINUS_CONSTANT_ALPHA, 0, 0);
video_flush(false);
C3D_ColorLogicOp(GPU_LOGICOP_COPY);
}
Expand Down
2 changes: 1 addition & 1 deletion source/common/vb_gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ int emulation_lstate(int state) {

clearCache();
C3D_FrameBegin(0);
video_render((tVIPREG.tFrameBuffer) % 2);
video_render((tVIPREG.tFrameBuffer) % 2, false);
C3D_FrameEnd(0);

guiop = AKILL;
Expand Down

0 comments on commit 8fc1ae5

Please sign in to comment.