Fix pause feature

This commit is contained in:
mahoneyt944 2024-08-22 09:36:51 -04:00 committed by GitHub
parent 04af4c8ecb
commit 9234555754
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 45 additions and 46 deletions

View File

@ -334,8 +334,7 @@ static void cpu_pre_run(void)
/* reset the globals */
cpu_vblankreset();
current_frame = 0;
cpu_pause_state = false;
toggle_showgfx = false;
cpu_pause(false);
state_save_dump_registry();
}
@ -469,11 +468,6 @@ static void watchdog_reset(void)
watchdog_counter = 3 * Machine->drv->frames_per_second;
}
WRITE_HANDLER( watchdog_disarm_w )
{
watchdog_counter = -1;
}
WRITE_HANDLER( watchdog_reset_w )
{
watchdog_reset();

View File

@ -95,15 +95,14 @@ void machine_reset(void);
void mame_frame(void);
extern void (*pause_action)(void);
/*************************************
*
* Optional watchdog
*
*************************************/
/* Used to disarm the watchdog while cpu is paused */
WRITE_HANDLER( watchdog_disarm_w );
/* 8-bit watchdog read/write handlers */
WRITE_HANDLER( watchdog_reset_w );
WRITE_HANDLER( watchdog_400_reset_w );

View File

@ -310,11 +310,7 @@ void cpu_set_irq_line(int cpunum, int irqline, int state)
void cpu_set_irq_line_and_vector(int cpunum, int irqline, int state, int vector)
{
INT32 irq_event = (state & 0xff) | ((irqline & 0xff) << 8) | (vector << 16);
int event_index;
if (cpu_pause_state && state == PULSE_LINE) return;
event_index = irq_event_index[cpunum]++;
int event_index = irq_event_index[cpunum]++;
/*LOG(("cpu_set_irq_line(%d,%d,%d,%02x)\n", cpunum, irqline, state, vector));*/

View File

@ -3522,7 +3522,7 @@ void draw_crosshair(int player_number, struct mame_bitmap *bitmap,int x,int y,co
int i;
static int inactive_xy [MAX_PLAYER_COUNT][3];
if (!options.crosshair_enable || cpu_pause_state)
if (!options.crosshair_enable)
{
/* Update frame count */
inactive_xy[player_number-1][2] = cpu_getcurrentframe();

View File

@ -131,7 +131,6 @@ int mame_debug; /* !0 when -debug option is specified */
int bailing; /* set to 1 if the startup is aborted to prevent multiple error messages */
extern int16_t XsoundBuffer[2048];
extern void (*pause_action)(void);
/* the active machine */
static struct RunningMachine active_machine;
@ -512,9 +511,6 @@ void pause_action_start_emulator(void)
/* run the emulation! */
cpu_run();
/* Unpause */
pause_action = 0;
}
void run_machine_core_done(void)
@ -1189,7 +1185,10 @@ void update_video_and_audio(void)
int updatescreen(void)
{
/* update sound */
sound_update();
if (pause_action)
osd_update_silent_stream();
else
sound_update();
/* if we're not skipping this frame, draw the screen */
if (osd_skip_this_frame() == 0)

View File

@ -364,26 +364,21 @@ int16_t get_pointer_delta(int16_t coord, int16_t *prev_coord)
return delta;
}
/* initialized in cpu_pre_run() */
bool cpu_pause_state;
void pause_action_generic(void)
{
updatescreen();
}
/* initialized in cpu_pre_run() */
void cpu_pause(bool pause)
{
int cpunum;
for (cpunum = 0; cpunum < cpu_gettotalcpu(); cpunum++)
if (pause)
pause_action = pause_action_generic;
else /* resume and reset behavior */
{
if (pause)
cpunum_suspend(cpunum, SUSPEND_REASON_DISABLE, 1);
else
cpunum_resume(cpunum, SUSPEND_ANY_REASON);
toggle_showgfx = false;
pause_action = 0;
}
/* disarm watchdog to prevent reset */
if (pause) watchdog_disarm_w(0, 0);
/* update state */
cpu_pause_state = pause;
}
extern UINT8 frameskip_counter;
@ -581,10 +576,8 @@ int osd_update_audio_stream(INT16 *buffer)
int i,j;
if ( Machine->sample_rate !=0 && buffer)
{
if (cpu_pause_state)
memset(samples_buffer, 0, samples_per_frame * (usestereo ? 4 : 2));
else
memcpy(samples_buffer, buffer, samples_per_frame * (usestereo ? 4 : 2));
memcpy(samples_buffer, buffer, samples_per_frame * (usestereo ? 4 : 2));
if (usestereo)
audio_batch_cb(samples_buffer, samples_per_frame);
else
@ -596,8 +589,6 @@ int osd_update_audio_stream(INT16 *buffer)
}
audio_batch_cb(conversion_buffer,samples_per_frame);
}
if (cpu_pause_state)
return samples_per_frame;
/*process next frame */
@ -625,6 +616,26 @@ int osd_update_audio_stream(INT16 *buffer)
}
void osd_update_silent_stream(void)
{
int length = samples_per_frame * (usestereo ? 4 : 2);
if (Machine->sample_rate !=0)
{
if (usestereo)
{
memset(samples_buffer, 0, length);
audio_batch_cb(samples_buffer, samples_per_frame);
}
else
{
memset(conversion_buffer, 0, length * 2);
audio_batch_cb(conversion_buffer,samples_per_frame);
}
}
}
void osd_stop_audio_stream(void)
{
}

View File

@ -330,7 +330,6 @@ void osd_update_video_and_audio(struct mame_display *display);
/*
Pause or resume all active cpus, true->pause, false->resume.
*/
extern bool cpu_pause_state;
extern void cpu_pause(bool pause);
@ -362,6 +361,7 @@ extern void cpu_pause(bool pause);
*/
int osd_start_audio_stream(int stereo);
int osd_update_audio_stream(INT16 *buffer);
void osd_update_silent_stream(void);
void osd_stop_audio_stream(void);
/******************************************************************************

View File

@ -369,7 +369,6 @@ static void frame_convert(struct mame_display *display)
extern bool retro_audio_buff_underrun;
extern bool retro_audio_buff_active;
extern unsigned retro_audio_buff_occupancy;
extern void (*pause_action)(void);
const int frameskip_table[12][12] =
{ { 0,0,0,0,0,0,0,0,0,0,0,0 },

View File

@ -715,7 +715,7 @@ void mixer_update_channel(struct mixer_channel_data *channel, int total_sample_c
if (samples_to_generate <= 0)
return;
if ( channel->is_paused || cpu_pause_state ) return;
if ( channel->is_paused ) return;
/* if we're playing, mix in the data */
if (channel->is_playing)

View File

@ -3388,6 +3388,7 @@ int handle_user_interface(struct mame_bitmap *bitmap)
}
else if(setup_selected)
{
erase_screen(bitmap);
setup_selected = setup_menu(bitmap, setup_selected);
}
@ -3436,7 +3437,7 @@ int handle_user_interface(struct mame_bitmap *bitmap)
if(toggle_showgfx) showcharset(bitmap);
if (!setup_active() && !toggle_showgfx && cpu_pause_state)
if (!setup_active() && !toggle_showgfx && pause_action)
cpu_pause(false);
return 0;