Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added fast-forward functionality #21 #178

Merged
merged 1 commit into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Source/Config/ConfigOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ bool gFogEnabled = false; // Enable fog
bool gMemoryAccessOptimisation = false; // Enable the memory access optimisation
bool gCheatsEnabled = true; // Enable cheat codes
u32 gControllerIndex = 0; // Which controller config to set
bool gFastForward = false;

DaedalusConfig g_DaedalusConfig;
1 change: 1 addition & 0 deletions Source/Config/ConfigOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ extern bool gVideoRateMatch;
extern bool gFogEnabled;
extern bool gMemoryAccessOptimisation;
extern bool gCheatsEnabled;
extern bool gFastForward;
//ToDo: Needs moving to Graphics plugin config
extern bool gCleanSceneEnabled;
extern u32 gCheckTextureHashFrequency;
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/CPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,8 @@ void CPU_HANDLE_COUNT_INTERRUPT()

gVerticalInterrupts++;

FramerateLimiter_Limit();
if(!gFastForward)
FramerateLimiter_Limit();
#ifdef DAEDALUS_W32
if (gAudioPlugin != nullptr)
gAudioPlugin->Update(false);
Expand Down
2 changes: 1 addition & 1 deletion Source/HLEAudio/AudioBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void CAudioBuffer::AddSamples( const Sample * samples, u32 num_samples, u32 freq
if( write_ptr >= mBufferEnd )
write_ptr = mBufferBegin;

while( write_ptr == read_ptr )
while( write_ptr == read_ptr && !gFastForward)
{
// The buffer is full - spin until the read pointer advances.
// Note - spends a lot of time here if program is running
Expand Down
46 changes: 42 additions & 4 deletions Source/SysVita/UI/InGameMenuScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,37 @@
#include "SysVita/UI/Menu.h"

static uint64_t tmr1;
static uint32_t oldpad;
bool pause_emu = false;
ButtonSce selectBtn {false, 0, 500000, SCE_CTRL_SELECT};

int update_button(ButtonSce* btn, const SceCtrlData* pad, uint32_t ticks)
{
if ((pad->buttons & btn->btn) && !btn->down){
btn->down = true;
btn->downTime = ticks;
return BUTTON_SHORT_HOLD;
} else if (!(pad->buttons & btn->btn) && btn->down){
btn->down = false;
uint32_t deltaTime = ticks - btn->downTime;
if(deltaTime > btn->longPressTime){
return BUTTON_LONG_RELEASED;
}
else {
return BUTTON_SHORT_RELEASED;
}
} else if ((pad->buttons & btn->btn) && btn->down){
uint32_t deltaTime = ticks - btn->downTime;
if(deltaTime > btn->longPressTime){
return BUTTON_LONG_HOLD;
}
else {
return BUTTON_SHORT_HOLD;
}
}
else {
return BUTTON_NEUTRAL;
}
}

void DrawInGameMenu() {
DrawInGameMenuBar();
Expand All @@ -53,12 +82,21 @@ void DrawInGameMenu() {
show_menubar = !gHideMenubar;
}

// Handling emulation pause
// Handling select button (menu pause and fast-forward)
SceCtrlData pad;
sceCtrlPeekBufferPositive(0, &pad, 1);
if ((pad.buttons & SCE_CTRL_SELECT) && (!(oldpad & SCE_CTRL_SELECT))) {
int statusSelectBtn = update_button(&selectBtn, &pad, sceKernelGetProcessTimeWide());
if(statusSelectBtn == BUTTON_SHORT_RELEASED){
pause_emu = !pause_emu;
EnableMenuButtons(pause_emu);
} else if(statusSelectBtn == BUTTON_LONG_HOLD){
if(!gFastForward && !pause_emu){
gFastForward = true;
vglWaitVblankStart(GL_FALSE);
}
}
else if(statusSelectBtn == BUTTON_LONG_RELEASED){
gFastForward = false;
vglWaitVblankStart(gUseVSync);
}
oldpad = pad.buttons;
}
18 changes: 18 additions & 0 deletions Source/SysVita/UI/Menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,15 @@ enum {
MEM_DOWNLOAD
};

// Button status types
enum {
BUTTON_SHORT_HOLD,
BUTTON_SHORT_RELEASED,
BUTTON_LONG_HOLD,
BUTTON_LONG_RELEASED,
BUTTON_NEUTRAL
};

struct Download {
void (*post_func)();
char url[256];
Expand Down Expand Up @@ -277,6 +286,13 @@ struct Overlay {
Overlay *next;
};

struct ButtonSce {
bool down;
uint32_t downTime;
uint32_t longPressTime;
const SceCtrlButtons btn;
};

extern Dialog cur_dialog;
extern Alert cur_alert;
extern Download cur_download;
Expand Down Expand Up @@ -349,3 +365,5 @@ void extract_file(char *file, char *dir);
int download_file(char *url, char *file, char *msg, float int_total_bytes, bool has_temp_file);

void dummy_func();

int update_button(ButtonSce* btn, const SceCtrlData* pad, uint32_t ticks);