static int p96hsync_counter, full_refresh;
static smp_comm_pipe *render_pipe;
+static volatile int render_thread_state;
static CRITICAL_SECTION render_cs;
#define PICASSO_STATE_SETDISPLAY 1
static void *render_thread(void *v)
{
+ render_thread_state = 1;
for (;;) {
int idx = read_comm_pipe_int_blocking(render_pipe);
if (idx == -1)
break;
- lockrtg();
- picasso_flushpixels(idx, gfxmem_banks[idx]->start + natmem_offset, picasso96_state.XYOffset - gfxmem_banks[idx]->start);
- unlockrtg();
+ if (picasso_on && picasso_requested_on) {
+ lockrtg();
+ picasso_flushpixels(idx, gfxmem_banks[idx]->start + natmem_offset, picasso96_state.XYOffset - gfxmem_banks[idx]->start);
+ unlockrtg();
+ }
}
+ render_thread_state = -1;
return 0;
}
void picasso_reset (void)
{
- if (!render_pipe && currprefs.rtg_multithread) {
- InitializeCriticalSection(&render_cs);
- render_pipe = xmalloc(smp_comm_pipe, 1);
- init_comm_pipe(render_pipe, 10, 1);
- uae_start_thread(_T("rtg"), render_thread, NULL, NULL);
+ if (currprefs.rtg_multithread) {
+ if (!render_pipe) {
+ InitializeCriticalSection(&render_cs);
+ render_pipe = xmalloc(smp_comm_pipe, 1);
+ init_comm_pipe(render_pipe, 10, 1);
+ }
+ if (render_thread_state <= 0) {
+ render_thread_state = 0;
+ uae_start_thread(_T("rtg"), render_thread, NULL, NULL);
+ }
}
rtg_index = -1;
return 0;
}
+void picasso_free(void)
+{
+ if (currprefs.rtg_multithread && render_thread_state > 0) {
+ write_comm_pipe_int(render_pipe, -1, 0);
+ while (render_thread_state >= 0) {
+ Sleep(10);
+ }
+ render_thread_state = 0;
+ }
+}
+
void restore_p96_finish (void)
{
init_alloc (NULL, 0);
extern bool picasso_is_vram_dirty (int index, uaecptr addr, int size);
extern void picasso_statusline (uae_u8 *dst);
extern void picasso_invalidate (int x, int y, int w, int h);
+extern void picasso_free(void);
/* This structure describes the UAE-side framebuffer for the Picasso
* screen. */