X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=ginge.git;a=blobdiff_plain;f=loader%2Femu.c;h=5c2412078fcd269c9cf77df88ed7f6023091daf3;hp=3ab4b346e504c8462456551ce05ae929c55be247;hb=db9191ed7ea2e1c190b4445bf3c576b206c88b36;hpb=4d0451847a77d420284c7fb0f50b1f167c1118ee diff --git a/loader/emu.c b/loader/emu.c index 3ab4b34..5c24120 100644 --- a/loader/emu.c +++ b/loader/emu.c @@ -269,21 +269,26 @@ bad_blit: // FIXME: pass real dimensions to blitters static void mlc_flip(void *src, int bpp) { - u32 *srcp = NULL; + static int old_bpp; // only pass pal to host if it's dirty if (bpp <= 8 && mmsp2.dirty_pal) { - srcp = mmsp2.mlc_stl_pallt_d32; + host_video_update_pal(mmsp2.mlc_stl_pallt_d32); mmsp2.dirty_pal = 0; } + if (bpp != old_bpp) { + host_video_change_bpp(bpp); + old_bpp = bpp; + } + switch (bpp) { case 4: - host_video_blit4(src, 320, 240, srcp); + host_video_blit4(src, 320, 240); break; case 8: - host_video_blit8(src, 320, 240, srcp); + host_video_blit8(src, 320, 240); break; case 16: @@ -304,6 +309,8 @@ static void mlc_flip(void *src, int bpp) } \ } +static int fb_sync_thread_paused; + static void *fb_sync_thread(void *arg) { int invalid_fb_addr = 1; @@ -340,6 +347,10 @@ static void *fb_sync_thread(void *arg) sleep(1); continue; } + if (fb_sync_thread_paused) { + ts_add_nsec(ts, 100000000); + continue; + } if (wait_ret != ETIMEDOUT) { clock_gettime(CLOCK_REALTIME, &ts); @@ -370,6 +381,19 @@ static void *fb_sync_thread(void *arg) } } +static void fb_thread_pause(void) +{ + fb_sync_thread_paused = 1; + // wait until it finishes last refresh + // that it might be doing now + usleep(10000); +} + +static void fb_thread_resume(void) +{ + fb_sync_thread_paused = 0; +} + static u32 xread8(u32 a) { iolog("r8 ", a, 0, 8); @@ -1044,6 +1068,7 @@ int emu_do_system(const char *command) static char tmp_path[512]; const char *p2; char *p; + int ret; if (command == NULL) return -1; @@ -1063,6 +1088,11 @@ int emu_do_system(const char *command) free((void *)p2); dbg("system: \"%s\"\n", tmp_path); - return system(tmp_path); + + // the app might want the screen too.. + fb_thread_pause(); + ret = system(tmp_path); + fb_thread_resume(); + return ret; }