From a58f14b9a8ff812a9773d364a79555b528da28da Mon Sep 17 00:00:00 2001 From: Floogle <18466542+skyfloogle@users.noreply.github.com> Date: Sun, 24 Nov 2024 18:55:16 +0100 Subject: [PATCH] add VIP overclock toggle and reorganize options --- include/vb_set.h | 1 + source/3ds/drc_core.c | 2 ++ source/3ds/gui_hard.c | 55 +++++++++++++++++++++------------------- source/common/v810_cpu.c | 7 ++++- source/common/vb_set.c | 4 +++ 5 files changed, 42 insertions(+), 27 deletions(-) diff --git a/include/vb_set.h b/include/vb_set.h index aa3762f..025930e 100644 --- a/include/vb_set.h +++ b/include/vb_set.h @@ -114,6 +114,7 @@ typedef struct VB_OPT { bool MODIFIED; // Do we need to ask for save? bool INPUTS; // Input display bool ANTIFLICKER; + bool VIP_OVERCLOCK; } VB_OPT; void setCustomMappingDefaults(void); diff --git a/source/3ds/drc_core.c b/source/3ds/drc_core.c index 75d3117..ef2abea 100644 --- a/source/3ds/drc_core.c +++ b/source/3ds/drc_core.c @@ -1880,6 +1880,8 @@ void drc_dumpDebugInfo(int code) { fprintf(f, "Cache start: %p\n", cache_start); fprintf(f, "Cache pos: %p\n", cache_pos); + fprintf(f, "VIP overclock: %d\n", tVBOpt.VIP_OVERCLOCK); + replay_save("debug_replay.bin"); fclose(f); diff --git a/source/3ds/gui_hard.c b/source/3ds/gui_hard.c index f6cf07d..8693043 100644 --- a/source/3ds/gui_hard.c +++ b/source/3ds/gui_hard.c @@ -360,8 +360,8 @@ static Button options_buttons[] = { {.str="Sound", .x=16, .y=80, .w=96-8, .h=48, .show_toggle=true, .toggle_text_on=&text_on, .toggle_text_off=&text_off}, #define OPTIONS_FF 3 {.str="Fastforward", .x=112-2, .y=80, .w=96+4, .h=48, .show_toggle=true, .toggle_text_on=&text_toggle, .toggle_text_off=&text_hold}, - #define OPTIONS_DEV 4 - {.str="Dev\nsettings", .x=208+8, .y=80, .w=96-8, .h=48}, + #define OPTIONS_PERF 4 + {.str="Perf.\nsettings", .x=208+8, .y=80, .w=96-8, .h=48}, #define OPTIONS_SAVE_GLOBAL 5 {.str="Save\n(Global)", .x=16, .y=144, .w=96-8, .h=48}, #define OPTIONS_SAVE_GAME 6 @@ -400,18 +400,18 @@ static Button colour_filter_buttons[] = { {.str="Gray", .x=16, .y=128, .w=48, .h=32}, }; -static void vblink(bool backtomain); +static void vblink(void); static Button vblink_buttons[] = {}; static void dev_options(int initial_button); static Button dev_options_buttons[] = { - #define DEV_PERF 0 - {.str="Perf. info", .x=16, .y=16, .w=288, .h=48, .show_toggle=true, .toggle_text_on=&text_on, .toggle_text_off=&text_off}, - #define DEV_VBLINK 1 - {.str="VBLink", .x=16, .y=80, .w=288, .h=48}, - #define DEV_N3DS 2 + #define PERF_BAR 0 + {.str="Status bar", .x=16, .y=16, .w=288, .h=48, .show_toggle=true, .toggle_text_on=&text_on, .toggle_text_off=&text_off}, + #define PERF_VIP 1 + {.str="Overclock VIP", .x=16, .y=80, .w=288, .h=48, .show_toggle=true, .toggle_text_on=&text_on, .toggle_text_off=&text_off}, + #define PERF_N3DS 2 {.str="N3DS speedup", .x=16, .y=80+64, .w=288, .h=48, .show_toggle=true, .toggle_text_on=&text_on, .toggle_text_off=&text_off}, - #define DEV_BACK 3 + #define PERF_BACK 3 {.str="Back", .x=0, .y=208, .w=48, .h=32}, }; @@ -497,7 +497,7 @@ static void first_menu(int initial_button) { draw_logo(); if (hidKeysDown() & KEY_Y) loop = false; LOOP_END(first_menu_buttons); - if (hidKeysDown() & KEY_Y) return vblink(true); + if (hidKeysDown() & KEY_Y) return vblink(); guiop = 0; switch (button) { case MAIN_MENU_LOAD_ROM: @@ -518,7 +518,7 @@ static void game_menu(int initial_button) { LOOP_BEGIN(game_menu_buttons, initial_button); if (hidKeysDown() & KEY_Y) loop = false; LOOP_END(game_menu_buttons); - if (hidKeysDown() & KEY_Y) return vblink(true); + if (hidKeysDown() & KEY_Y) return vblink(); switch (button) { case MAIN_MENU_LOAD_ROM: // Load ROM guiop = AKILL | VBRESET; @@ -1412,7 +1412,7 @@ static bool vblink_transfer() { return vblink_progress == 100; } -static void vblink(bool backtomain) { +static void vblink(void) { bool loaded = false; char str[100]; C2D_Text text; @@ -1447,35 +1447,38 @@ static void vblink(bool backtomain) { if (success) { // success return; - } else return vblink(backtomain); + } else return vblink(); } else { vblink_close(); - return backtomain ? main_menu(game_running ? MAIN_MENU_RESUME : MAIN_MENU_LOAD_ROM) : dev_options(DEV_VBLINK); + return main_menu(game_running ? MAIN_MENU_RESUME : MAIN_MENU_LOAD_ROM); } } static void dev_options(int initial_button) { bool new_3ds = false; APT_CheckNew3DS(&new_3ds); - dev_options_buttons[DEV_N3DS].hidden = !new_3ds; - dev_options_buttons[DEV_PERF].toggle = tVBOpt.PERF_INFO; - dev_options_buttons[DEV_N3DS].toggle = tVBOpt.N3DS_SPEEDUP; + dev_options_buttons[PERF_N3DS].hidden = !new_3ds; + dev_options_buttons[PERF_BAR].toggle = tVBOpt.PERF_INFO; + dev_options_buttons[PERF_VIP].toggle = tVBOpt.VIP_OVERCLOCK; + dev_options_buttons[PERF_N3DS].toggle = tVBOpt.N3DS_SPEEDUP; LOOP_BEGIN(dev_options_buttons, initial_button); LOOP_END(dev_options_buttons); switch (button) { - case DEV_PERF: + case PERF_BAR: tVBOpt.PERF_INFO = !tVBOpt.PERF_INFO; tVBOpt.MODIFIED = true; - return dev_options(DEV_PERF); - case DEV_VBLINK: - return vblink(false); - case DEV_N3DS: + return dev_options(PERF_BAR); + case PERF_VIP: + tVBOpt.VIP_OVERCLOCK = !tVBOpt.VIP_OVERCLOCK; + tVBOpt.MODIFIED = true; + return dev_options(PERF_VIP); + case PERF_N3DS: tVBOpt.N3DS_SPEEDUP = !tVBOpt.N3DS_SPEEDUP; tVBOpt.MODIFIED = true; osSetSpeedupEnable(tVBOpt.N3DS_SPEEDUP); - return dev_options(DEV_N3DS); - case DEV_BACK: - return options(OPTIONS_DEV); + return dev_options(PERF_N3DS); + case PERF_BACK: + return options(OPTIONS_PERF); } } @@ -1556,7 +1559,7 @@ static void options(int initial_button) { case OPTIONS_SOUND: // Sound tVBOpt.SOUND = !tVBOpt.SOUND; return options(OPTIONS_SOUND); - case OPTIONS_DEV: // Developer settings + case OPTIONS_PERF: // Developer settings return dev_options(0); case OPTIONS_CONTROLS: // About return controls(0); diff --git a/source/common/v810_cpu.c b/source/common/v810_cpu.c index 84aecb7..4f84d05 100644 --- a/source/common/v810_cpu.c +++ b/source/common/v810_cpu.c @@ -418,7 +418,12 @@ int serviceDisplayInt(unsigned int cycles, WORD PC) { interrupts |= TIMEERR; } else { tVIPREG.drawing = true; - tVIPREG.frametime = videoProcessingTime(); + if (!tVBOpt.VIP_OVERCLOCK) { + tVIPREG.frametime = videoProcessingTime(); + } else { + // pre-0.9.7 behaviour + tVIPREG.frametime = 137216; + } tVIPREG.tFrameBuffer++; if ((tVIPREG.tFrameBuffer < 1) || (tVIPREG.tFrameBuffer > 2)) tVIPREG.tFrameBuffer = 1; tVIPREG.XPSTTS = XPEN | (tVIPREG.tFrameBuffer<<2) | SBOUT; diff --git a/source/common/vb_set.c b/source/common/vb_set.c index 224aa8b..873974e 100644 --- a/source/common/vb_set.c +++ b/source/common/vb_set.c @@ -127,6 +127,7 @@ void setDefaults(void) { tVBOpt.MODIFIED = false; tVBOpt.INPUTS = false; tVBOpt.ANTIFLICKER = false; + tVBOpt.VIP_OVERCLOCK = false; strcpy(tVBOpt.HOME_PATH, "sdmc:/red-viper"); // Default keys @@ -181,6 +182,8 @@ static int handler(void* user, const char* section, const char* name, strcpy(pconfig->ROM_PATH, value); } else if (MATCH("vbopt", "n3ds_speedup")) { pconfig->N3DS_SPEEDUP = atoi(value); + } else if (MATCH("vbopt", "vip_overclock")) { + pconfig->VIP_OVERCLOCK = atoi(value); } else if (MATCH("vbopt", "homepath")) { strncpy(pconfig->HOME_PATH, value, sizeof(pconfig->HOME_PATH)); pconfig->HOME_PATH[sizeof(pconfig->HOME_PATH)-1] = 0; @@ -372,6 +375,7 @@ void writeOptionsFile(FILE* f, bool global) { fprintf(f, "antiflicker=%d\n", tVBOpt.ANTIFLICKER); fprintf(f, "perfinfo=%d\n", tVBOpt.PERF_INFO); fprintf(f, "n3ds_speedup=%d\n", tVBOpt.N3DS_SPEEDUP); + fprintf(f, "vip_overclock=%d\n", tVBOpt.VIP_OVERCLOCK); if (global) { fprintf(f, "lastrom=%s\n", tVBOpt.ROM_PATH); fprintf(f, "homepath=%s\n", tVBOpt.HOME_PATH);