mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-10-17 08:25:43 +00:00
Support USE_CPU_EMUL_SERVICES in SDL/video driver. Only trigger ethernet
interrupt in one_tick() if no pthreads at all are used, i.e. ether_dummy is effective in that case. Otherwise, don't trigger ethernet again if pthreads are available (and ether_unix) and cpu emul services are active.
This commit is contained in:
parent
e616062d6d
commit
fe99211e75
@ -101,10 +101,14 @@ static uint8 *the_buffer_copy = NULL; // Copy of Mac frame buffer (for refres
|
|||||||
static uint32 the_buffer_size; // Size of allocated the_buffer
|
static uint32 the_buffer_size; // Size of allocated the_buffer
|
||||||
|
|
||||||
static bool redraw_thread_active = false; // Flag: Redraw thread installed
|
static bool redraw_thread_active = false; // Flag: Redraw thread installed
|
||||||
|
#ifndef USE_CPU_EMUL_SERVICES
|
||||||
static volatile bool redraw_thread_cancel; // Flag: Cancel Redraw thread
|
static volatile bool redraw_thread_cancel; // Flag: Cancel Redraw thread
|
||||||
static SDL_Thread *redraw_thread = NULL; // Redraw thread
|
static SDL_Thread *redraw_thread = NULL; // Redraw thread
|
||||||
|
#ifdef SHEEPSHAVER
|
||||||
static volatile bool thread_stop_req = false;
|
static volatile bool thread_stop_req = false;
|
||||||
static volatile bool thread_stop_ack = false; // Acknowledge for thread_stop_req
|
static volatile bool thread_stop_ack = false; // Acknowledge for thread_stop_req
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_VOSF
|
#ifdef ENABLE_VOSF
|
||||||
static bool use_vosf = false; // Flag: VOSF enabled
|
static bool use_vosf = false; // Flag: VOSF enabled
|
||||||
@ -1006,12 +1010,16 @@ bool SDL_monitor_desc::video_open(void)
|
|||||||
LOCK_FRAME_BUFFER;
|
LOCK_FRAME_BUFFER;
|
||||||
|
|
||||||
// Start redraw/input thread
|
// Start redraw/input thread
|
||||||
|
#ifndef USE_CPU_EMUL_SERVICES
|
||||||
redraw_thread_cancel = false;
|
redraw_thread_cancel = false;
|
||||||
redraw_thread_active = ((redraw_thread = SDL_CreateThread(redraw_func, NULL)) != NULL);
|
redraw_thread_active = ((redraw_thread = SDL_CreateThread(redraw_func, NULL)) != NULL);
|
||||||
if (!redraw_thread_active) {
|
if (!redraw_thread_active) {
|
||||||
printf("FATAL: cannot create redraw thread\n");
|
printf("FATAL: cannot create redraw thread\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
redraw_thread_active = true;
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1228,10 +1236,12 @@ void SDL_monitor_desc::video_close(void)
|
|||||||
D(bug("video_close()\n"));
|
D(bug("video_close()\n"));
|
||||||
|
|
||||||
// Stop redraw thread
|
// Stop redraw thread
|
||||||
|
#ifndef USE_CPU_EMUL_SERVICES
|
||||||
if (redraw_thread_active) {
|
if (redraw_thread_active) {
|
||||||
redraw_thread_cancel = true;
|
redraw_thread_cancel = true;
|
||||||
SDL_WaitThread(redraw_thread, NULL);
|
SDL_WaitThread(redraw_thread, NULL);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
redraw_thread_active = false;
|
redraw_thread_active = false;
|
||||||
|
|
||||||
// Unlock frame buffer
|
// Unlock frame buffer
|
||||||
@ -2035,9 +2045,45 @@ static void VideoRefreshInit(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void do_video_refresh(void)
|
||||||
|
{
|
||||||
|
// Handle SDL events
|
||||||
|
handle_events();
|
||||||
|
|
||||||
|
// Update display
|
||||||
|
video_refresh();
|
||||||
|
|
||||||
|
#ifdef SHEEPSHAVER
|
||||||
|
// Set new cursor image if it was changed
|
||||||
|
if (cursor_changed && sdl_cursor) {
|
||||||
|
cursor_changed = false;
|
||||||
|
SDL_FreeCursor(sdl_cursor);
|
||||||
|
sdl_cursor = SDL_CreateCursor(MacCursor + 4, MacCursor + 36, 16, 16, MacCursor[2], MacCursor[3]);
|
||||||
|
if (sdl_cursor)
|
||||||
|
SDL_SetCursor(sdl_cursor);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Set new palette if it was changed
|
||||||
|
handle_palette_changes();
|
||||||
|
}
|
||||||
|
|
||||||
|
// This function is called on non-threaded platforms from a timer interrupt
|
||||||
|
void VideoRefresh(void)
|
||||||
|
{
|
||||||
|
// We need to check redraw_thread_active to inhibit refreshed during
|
||||||
|
// mode changes on non-threaded platforms
|
||||||
|
if (!redraw_thread_active)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Process pending events and update display
|
||||||
|
do_video_refresh();
|
||||||
|
}
|
||||||
|
|
||||||
const int VIDEO_REFRESH_HZ = 60;
|
const int VIDEO_REFRESH_HZ = 60;
|
||||||
const int VIDEO_REFRESH_DELAY = 1000000 / VIDEO_REFRESH_HZ;
|
const int VIDEO_REFRESH_DELAY = 1000000 / VIDEO_REFRESH_HZ;
|
||||||
|
|
||||||
|
#ifndef USE_CPU_EMUL_SERVICES
|
||||||
static int redraw_func(void *arg)
|
static int redraw_func(void *arg)
|
||||||
{
|
{
|
||||||
uint64 start = GetTicks_usec();
|
uint64 start = GetTicks_usec();
|
||||||
@ -2063,28 +2109,12 @@ static int redraw_func(void *arg)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Handle SDL events
|
// Process pending events and update display
|
||||||
handle_events();
|
do_video_refresh();
|
||||||
|
|
||||||
// Refresh display
|
|
||||||
video_refresh();
|
|
||||||
|
|
||||||
#ifdef SHEEPSHAVER
|
|
||||||
// Set new cursor image if it was changed
|
|
||||||
if (cursor_changed && sdl_cursor) {
|
|
||||||
cursor_changed = false;
|
|
||||||
SDL_FreeCursor(sdl_cursor);
|
|
||||||
sdl_cursor = SDL_CreateCursor(MacCursor + 4, MacCursor + 36, 16, 16, MacCursor[2], MacCursor[3]);
|
|
||||||
if (sdl_cursor)
|
|
||||||
SDL_SetCursor(sdl_cursor);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Set new palette if it was changed
|
|
||||||
handle_palette_changes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 end = GetTicks_usec();
|
uint64 end = GetTicks_usec();
|
||||||
D(bug("%lld refreshes in %lld usec = %f refreshes/sec\n", ticks, end - start, ticks * 1000000.0 / (end - start)));
|
D(bug("%lld refreshes in %lld usec = %f refreshes/sec\n", ticks, end - start, ticks * 1000000.0 / (end - start)));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -1131,9 +1131,13 @@ static void one_tick(...)
|
|||||||
one_second();
|
one_second();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(USE_PTHREADS_SERVICES) && !defined(USE_SDL_VIDEO)
|
#ifndef USE_PTHREADS_SERVICES
|
||||||
// No threads available, perform video refresh and networking from here
|
// Threads not used to trigger interrupts, perform video refresh from here
|
||||||
VideoRefresh();
|
VideoRefresh();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_PTHREADS
|
||||||
|
// No threads available, perform networking from here
|
||||||
SetInterruptFlag(INTFLAG_ETHER);
|
SetInterruptFlag(INTFLAG_ETHER);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user