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

Add Frame Advance #8939

Merged
merged 6 commits into from
Aug 30, 2016
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
45 changes: 23 additions & 22 deletions Common/KeyMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,34 +218,34 @@ static const DefMappingStruct defaultPadMap[] = {
{CTRL_RIGHT , JOYSTICK_AXIS_HAT_X, +1},
{CTRL_UP , JOYSTICK_AXIS_HAT_Y, -1},
{CTRL_DOWN , JOYSTICK_AXIS_HAT_Y, +1},
{CTRL_START , NKCODE_BUTTON_START},
{CTRL_START , NKCODE_BUTTON_START},
{CTRL_SELECT , NKCODE_BUTTON_SELECT},
{CTRL_LTRIGGER , NKCODE_BUTTON_L1},
{CTRL_RTRIGGER , NKCODE_BUTTON_R1},
{VIRTKEY_UNTHROTTLE , NKCODE_BUTTON_R2},
{CTRL_LTRIGGER , NKCODE_BUTTON_L1},
{CTRL_RTRIGGER , NKCODE_BUTTON_R1},
{VIRTKEY_UNTHROTTLE , NKCODE_BUTTON_R2},
{VIRTKEY_PAUSE , NKCODE_BUTTON_THUMBR},
{VIRTKEY_SPEED_TOGGLE, NKCODE_BUTTON_L2},
{VIRTKEY_AXIS_X_MIN, JOYSTICK_AXIS_X, -1},
{VIRTKEY_AXIS_X_MAX, JOYSTICK_AXIS_X, +1},
{VIRTKEY_AXIS_Y_MIN, JOYSTICK_AXIS_Y, +1},
{VIRTKEY_AXIS_Y_MAX, JOYSTICK_AXIS_Y, -1},
{VIRTKEY_SPEED_TOGGLE, NKCODE_BUTTON_L2},
{VIRTKEY_AXIS_X_MIN, JOYSTICK_AXIS_X, -1},
{VIRTKEY_AXIS_X_MAX, JOYSTICK_AXIS_X, +1},
{VIRTKEY_AXIS_Y_MIN, JOYSTICK_AXIS_Y, +1},
{VIRTKEY_AXIS_Y_MAX, JOYSTICK_AXIS_Y, -1},
#else
{CTRL_CROSS , NKCODE_BUTTON_2},
{CTRL_CIRCLE , NKCODE_BUTTON_3},
{CTRL_SQUARE , NKCODE_BUTTON_4},
{CTRL_TRIANGLE , NKCODE_BUTTON_1},
{CTRL_CROSS , NKCODE_BUTTON_2},
{CTRL_CIRCLE , NKCODE_BUTTON_3},
{CTRL_SQUARE , NKCODE_BUTTON_4},
{CTRL_TRIANGLE , NKCODE_BUTTON_1},
{CTRL_UP , NKCODE_DPAD_UP},
{CTRL_RIGHT , NKCODE_DPAD_RIGHT},
{CTRL_DOWN , NKCODE_DPAD_DOWN},
{CTRL_LEFT , NKCODE_DPAD_LEFT},
{CTRL_START , NKCODE_BUTTON_10},
{CTRL_SELECT , NKCODE_BUTTON_9},
{CTRL_LTRIGGER , NKCODE_BUTTON_7},
{CTRL_RTRIGGER , NKCODE_BUTTON_8},
{VIRTKEY_AXIS_X_MIN, JOYSTICK_AXIS_X, -1},
{VIRTKEY_AXIS_X_MAX, JOYSTICK_AXIS_X, +1},
{VIRTKEY_AXIS_Y_MIN, JOYSTICK_AXIS_Y, +1},
{VIRTKEY_AXIS_Y_MAX, JOYSTICK_AXIS_Y, -1},
{CTRL_SELECT , NKCODE_BUTTON_9},
{CTRL_LTRIGGER , NKCODE_BUTTON_7},
{CTRL_RTRIGGER , NKCODE_BUTTON_8},
{VIRTKEY_AXIS_X_MIN, JOYSTICK_AXIS_X, -1},
{VIRTKEY_AXIS_X_MAX, JOYSTICK_AXIS_X, +1},
{VIRTKEY_AXIS_Y_MIN, JOYSTICK_AXIS_Y, +1},
{VIRTKEY_AXIS_Y_MAX, JOYSTICK_AXIS_Y, -1},
#endif
};

Expand Down Expand Up @@ -583,7 +583,7 @@ const KeyMap_IntStrPair key_names[] = {
{NKCODE_NUMPAD_7, "Num7"},
{NKCODE_NUMPAD_8, "Num8"},
{NKCODE_NUMPAD_9, "Num9"},

{NKCODE_LANGUAGE_SWITCH, "Language"},
{NKCODE_MANNER_MODE, "Manner"},
{NKCODE_3D_MODE, "3D Mode"},
Expand All @@ -607,7 +607,7 @@ const KeyMap_IntStrPair key_names[] = {
{NKCODE_EXT_MOUSEWHEEL_UP, "MWheelU"},
{NKCODE_EXT_MOUSEWHEEL_DOWN, "MWheelD"},

{NKCODE_START_QUESTION, "¿"},
{NKCODE_START_QUESTION, "¿"},
{NKCODE_LEFTBRACE, "{"},
{NKCODE_RIGHTBRACE, "}"},
};
Expand Down Expand Up @@ -673,6 +673,7 @@ const KeyMap_IntStrPair psp_button_names[] = {
{VIRTKEY_SPEED_TOGGLE, "SpeedToggle"},
{VIRTKEY_PAUSE, "Pause"},
#ifndef MOBILE_DEVICE
{VIRTKEY_FRAME_ADVANCE, "Frame Advance"},
{VIRTKEY_REWIND, "Rewind"},
#endif
{VIRTKEY_SAVE_STATE, "Save State"},
Expand Down
1 change: 1 addition & 0 deletions Common/KeyMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ enum {
VIRTKEY_ANALOG_LIGHTLY = 0x10011,
VIRTKEY_AXIS_SWAP = 0x10012,
VIRTKEY_DEVMENU = 0x10013,
VIRTKEY_FRAME_ADVANCE = 0x10014,
VIRTKEY_LAST,
VIRTKEY_COUNT = VIRTKEY_LAST - VIRTKEY_FIRST
};
Expand Down
10 changes: 5 additions & 5 deletions Core/HLE/sceCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const u32 CTRL_EMU_RAPIDFIRE_MASK = CTRL_UP | CTRL_DOWN | CTRL_LEFT | CTRL_RIGHT
static void __CtrlUpdateLatch()
{
lock_guard guard(ctrlMutex);

// Copy in the current data to the current buffer.
ctrlBufs[ctrlBuf] = ctrlCurrent;
u32 buttons = ctrlCurrent.buttons;
Expand All @@ -119,7 +119,7 @@ static void __CtrlUpdateLatch()
latch.btnRelease |= ~buttons;
dialogBtnMake |= buttons & changed;
ctrlLatchBufs++;

ctrlOldButtons = buttons;

ctrlBufs[ctrlBuf].frame = (u32) CoreTiming::GetGlobalTimeUs();
Expand Down Expand Up @@ -327,7 +327,7 @@ void __CtrlInit()
void __CtrlDoState(PointerWrap &p)
{
lock_guard guard(ctrlMutex);

auto s = p.Section("sceCtrl", 1, 3);
if (!s)
return;
Expand Down Expand Up @@ -519,7 +519,7 @@ static u32 sceCtrlReadLatch(u32 latchDataPtr)
return __CtrlResetLatch();
}

static const HLEFunction sceCtrl[] =
static const HLEFunction sceCtrl[] =
{
{0X3E65A0EA, nullptr, "sceCtrlInit", '?', "" }, //(int unknown), init with 0
{0X1F4011E6, &WrapU_U<sceCtrlSetSamplingMode>, "sceCtrlSetSamplingMode", 'x', "x" },
Expand All @@ -538,7 +538,7 @@ static const HLEFunction sceCtrl[] =
{0X6841BE1A, nullptr, "sceCtrlSetRapidFire", '?', "" },
{0XA7144800, &WrapI_II<sceCtrlSetIdleCancelThreshold>, "sceCtrlSetIdleCancelThreshold", 'i', "ii"},
{0X687660FA, &WrapI_UU<sceCtrlGetIdleCancelThreshold>, "sceCtrlGetIdleCancelThreshold", 'i', "xx"},
};
};

void Register_sceCtrl()
{
Expand Down
37 changes: 33 additions & 4 deletions UI/EmuScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,26 @@
#include "Windows/MainWindow.h"
#endif

static bool frameStep_;
static int lastNumFlips;

static void __EmuScreenVblank()
{
if (frameStep_ && lastNumFlips != gpuStats.numFlips)
{
frameStep_ = false;
Core_EnableStepping(true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, in EmuScreen this might actually be a better place:

https://github.com/RisingFog/ppsspp/blob/842a29b0aedd2e5db59128f3b25b06d803d27386/UI/EmuScreen.cpp#L980

This will be once per displayed frame though, so importantly:

  • If frameskip is enabled, it will not happen for skipped frames.
  • If the game runs at 30fps, it will be at 30fps.

-[Unknown]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't get it to update the screen properly while frame advancing.

lastNumFlips = gpuStats.numFlips;
}
}

EmuScreen::EmuScreen(const std::string &filename)
: bootPending_(true), gamePath_(filename), invalid_(true), quit_(false), pauseTrigger_(false), saveStatePreviewShownTime_(0.0), saveStatePreview_(nullptr) {
memset(axisState_, 0, sizeof(axisState_));
saveStateSlot_ = SaveState::GetCurrentSlot();
__DisplayListenVblank(__EmuScreenVblank);
frameStep_ = false;
lastNumFlips = gpuStats.numFlips;
}

void EmuScreen::bootGame(const std::string &filename) {
Expand Down Expand Up @@ -174,7 +190,7 @@ void EmuScreen::bootComplete() {
NOTICE_LOG(BOOT, "Loading %s...", PSP_CoreParameter().fileToStart.c_str());
autoLoad();

I18NCategory *sc = GetI18NCategory("Screen");
I18NCategory *sc = GetI18NCategory("Screen");

#ifndef MOBILE_DEVICE
if (g_Config.bFirstRun) {
Expand Down Expand Up @@ -341,7 +357,7 @@ bool EmuScreen::touch(const TouchInput &touch) {
}

void EmuScreen::onVKeyDown(int virtualKeyCode) {
I18NCategory *sc = GetI18NCategory("Screen");
I18NCategory *sc = GetI18NCategory("Screen");

switch (virtualKeyCode) {
case VIRTKEY_UNTHROTTLE:
Expand All @@ -363,6 +379,19 @@ void EmuScreen::onVKeyDown(int virtualKeyCode) {
pauseTrigger_ = true;
break;

case VIRTKEY_FRAME_ADVANCE:
// If game is running, pause emulation immediately. Otherwise, advance a single frame.
if (Core_IsStepping())
{
frameStep_ = true;
Core_EnableStepping(false);
}
else if (!frameStep_)
{
Core_EnableStepping(true);
}
break;

case VIRTKEY_AXIS_SWAP:
KeyMap::SwapAxis();
break;
Expand Down Expand Up @@ -778,7 +807,7 @@ void EmuScreen::update(InputState &input) {
}

float delta_y = tiltInputCurve(normalized_input_y * 2.0 * (g_Config.iTiltSensitivityY)) ;

if (g_Config.bInvertTiltY) {
delta_y *= -1;
}
Expand All @@ -787,7 +816,7 @@ void EmuScreen::update(InputState &input) {
leftstick_x += clamp1(delta_x);
__CtrlSetAnalogX(clamp1(leftstick_x), CTRL_STICK_LEFT);


leftstick_y += clamp1(delta_y);
__CtrlSetAnalogY(clamp1(leftstick_y), CTRL_STICK_LEFT);
}
Expand Down