From 6a4f55fa77aae25b01927e10dc0b2f710f1a12fd Mon Sep 17 00:00:00 2001 From: Dimitris Panokostas Date: Thu, 7 Feb 2019 23:38:38 +0100 Subject: [PATCH] Implemented Emulation Pause handling - Fixes #414 --- src/filesys.cpp | 17 +++++++++++++++++ src/include/inputdevice.h | 4 ++++ src/inputdevice.cpp | 33 ++++++++++++++++++++++++++++++--- 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/src/filesys.cpp b/src/filesys.cpp index b95abe26..f09166a8 100644 --- a/src/filesys.cpp +++ b/src/filesys.cpp @@ -1467,6 +1467,23 @@ int filesys_eject (int nr) } static uae_u32 heartbeat; +static int heartbeat_count, heartbeat_count_cont; +static int heartbeat_task; + +bool filesys_heartbeat(void) +{ + return heartbeat_count_cont > 0; +} + +// This uses filesystem process to reduce resource usage +void setsystime(void) +{ + if (!currprefs.tod_hack || !rtarea_bank.baseaddr) + return; + heartbeat = get_long_host(rtarea_bank.baseaddr + RTAREA_HEARTBEAT); + heartbeat_task = 1; + heartbeat_count = 10; +} static uae_u32 REGPARAM2 debugger_helper(TrapContext *ctx) { diff --git a/src/include/inputdevice.h b/src/include/inputdevice.h index c8516085..6728fa56 100644 --- a/src/include/inputdevice.h +++ b/src/include/inputdevice.h @@ -282,6 +282,8 @@ extern void inputdevice_acquire (int allmode); extern void inputdevice_unacquire (void); extern void inputdevice_unacquire(bool emulationactive, int inputmask); +extern void pausemode(int mode); + extern void inputdevice_add_inputcode(int code, int state, const TCHAR *); extern void inputdevice_handle_inputcode (void); @@ -289,6 +291,8 @@ extern void inputdevice_tablet_strobe (void); extern uae_u64 input_getqualifiers (void); +extern void setsystime(void); + #define JSEM_MODE_DEFAULT 0 #define JSEM_MODE_WHEELMOUSE 1 #define JSEM_MODE_MOUSE 2 diff --git a/src/inputdevice.cpp b/src/inputdevice.cpp index fcdd79c4..9ad4e579 100644 --- a/src/inputdevice.cpp +++ b/src/inputdevice.cpp @@ -97,6 +97,8 @@ static const int *joyinputs[MAX_JPORTS]; static int input_acquired; +static int autopause; + static int handle_input_event (int nr, int state, int max, int autofire); static struct inputdevice_functions idev[IDTYPE_MAX]; @@ -2642,9 +2644,6 @@ static bool inputdevice_handle_inputcode2(int code, int state, const TCHAR *s) // screenshot(1, 1); // } // break; - case AKS_TOGGLEWINDOWEDFULLSCREEN: - toggle_fullscreen(); - break; #ifdef ACTION_REPLAY case AKS_FREEZEBUTTON: action_replay_freeze(); @@ -2702,6 +2701,14 @@ static bool inputdevice_handle_inputcode2(int code, int state, const TCHAR *s) case AKS_EFLOPPY3: disk_eject(3); break; + case AKS_PAUSE: + pausemode(newstate > 0 ? 1 : newstate); + break; + case AKS_SINGLESTEP: + if (pause_emulation) + pausemode(0); + autopause = 1; + break; case AKS_VOLDOWN: sound_volume(newstate <= 0 ? -1 : 1); break; @@ -2717,6 +2724,9 @@ static bool inputdevice_handle_inputcode2(int code, int state, const TCHAR *s) case AKS_HARDRESET: uae_reset(1, 1); break; + case AKS_TOGGLEWINDOWEDFULLSCREEN: + toggle_fullscreen(); + break; case AKS_MOUSEMAP_PORT0_LEFT: (changed_prefs.jports[0].mousemap) ^= 1 << 0; inputdevice_updateconfig(&changed_prefs, &currprefs); @@ -3071,6 +3081,13 @@ static void inputdevice_checkconfig (void) void inputdevice_vsync (void) { + if (autopause > 0 && pause_emulation == 0) { + autopause--; + if (!autopause) { + pausemode(1); + } + } + input_frame++; mouseupdate (0, true); @@ -6115,6 +6132,16 @@ int getmousestate (int joy) return mice[joy].enabled; } +void pausemode(int mode) +{ + if (mode < 0) + pause_emulation = pause_emulation ? 0 : 9; + else + pause_emulation = mode; + set_config_changed(); + setsystime(); +} + int jsem_isjoy (int port, const struct uae_prefs *p) { int v = JSEM_DECODEVAL (port, p);