Drawing and Events updates from WinUAE

This commit is contained in:
Dimitris Panokostas 2020-08-17 18:56:05 +02:00
parent 447d875976
commit b901d298ad
3 changed files with 74 additions and 14 deletions

View file

@ -3126,7 +3126,13 @@ static void pfield_draw_line (struct vidbuffer *vb, int lineno, int gfx_ypos, in
have_color_changes = is_color_changes(dip_for_drawing); have_color_changes = is_color_changes(dip_for_drawing);
sprite_smaller_than_64_inuse = false; sprite_smaller_than_64_inuse = false;
xlinebuffer = row_map[gfx_ypos], dh = dh_buf; dh = dh_line;
xlinebuffer = vidinfo->drawbuffer.linemem;
if (xlinebuffer == 0 && do_double
&& (border == 0 || have_color_changes))
xlinebuffer = vidinfo->drawbuffer.emergmem, dh = dh_emerg;
if (xlinebuffer == 0)
xlinebuffer = row_map[gfx_ypos], dh = dh_buf;
xlinebuffer -= linetoscr_x_adjust_pixbytes; xlinebuffer -= linetoscr_x_adjust_pixbytes;
//xlinebuffer_genlock = row_map_genlock[gfx_ypos] - linetoscr_x_adjust_pixels; //xlinebuffer_genlock = row_map_genlock[gfx_ypos] - linetoscr_x_adjust_pixels;
@ -3606,8 +3612,19 @@ void putpixel(uae_u8 *buf, uae_u8 *genlockbuf, int bpp, int x, xcolnr c8, int op
case 4: case 4:
{ {
int i; int i;
uae_u32 *p = (uae_u32*)buf + x; if (1 || opaq || currprefs.gf[0].gfx_filter == 0) {
*p = c8; uae_u32 *p = (uae_u32*)buf + x;
*p = c8;
} else {
for (i = 0; i < 4; i++) {
int v1 = buf[i + bpp * x];
int v2 = (c8 >> (i * 8)) & 255;
v1 = (v1 * 2 + v2 * 3) / 5;
if (v1 > 255)
v1 = 255;
buf[i + bpp * x] = v1;
}
}
break; break;
} }
} }
@ -4219,7 +4236,7 @@ void reset_drawing(void)
{ {
struct amigadisplay* ad = &adisplays; struct amigadisplay* ad = &adisplays;
struct vidbuf_description* vidinfo = &ad->gfxvidinfo; struct vidbuf_description* vidinfo = &ad->gfxvidinfo;
max_diwstop = 0; max_diwstop = 0;
lores_reset (); lores_reset ();

View file

@ -12,6 +12,7 @@
#include "sysdeps.h" #include "sysdeps.h"
#include "options.h" #include "options.h"
#include "events.h"
#include "memory.h" #include "memory.h"
#include "newcpu.h" #include "newcpu.h"
#include "xwin.h" #include "xwin.h"
@ -51,6 +52,8 @@ void events_schedule(void)
nextevent = currcycle + mintime; nextevent = currcycle + mintime;
} }
extern void vsync_event_done(void);
static bool event_check_vsync(void) static bool event_check_vsync(void)
{ {
/* Keep only CPU emulation running while waiting for sync point. */ /* Keep only CPU emulation running while waiting for sync point. */
@ -66,6 +69,16 @@ static bool event_check_vsync(void)
} }
// wait for vblank // wait for vblank
audio_finish_pull(); audio_finish_pull();
int done = vsync_isdone(NULL);
if (!done)
{
if (currprefs.cachesize)
pissoff = pissoff_value;
else
pissoff = pissoff_nojit_value;
return true;
}
vsync_event_done();
} }
else if (is_syncline == -10) { else if (is_syncline == -10) {
@ -110,20 +123,24 @@ static bool event_check_vsync(void)
void do_cycles_cpu_fastest(uae_u32 cycles_to_add) void do_cycles_cpu_fastest(uae_u32 cycles_to_add)
{ {
if ((pissoff -= cycles_to_add) > 0) if (!currprefs.cpu_thread) {
return; if ((pissoff -= cycles_to_add) >= 0)
cycles_to_add = -pissoff;
pissoff = 0;
if (is_syncline)
{
if (event_check_vsync())
return; return;
cycles_to_add = -pissoff;
pissoff = 0;
} else {
pissoff = 0x40000000;
} }
while ((nextevent - currcycle) <= cycles_to_add) while ((nextevent - currcycle) <= cycles_to_add)
{ {
if (is_syncline)
{
if (event_check_vsync())
return;
}
cycles_to_add -= (nextevent - currcycle); cycles_to_add -= (nextevent - currcycle);
currcycle = nextevent; currcycle = nextevent;
@ -131,7 +148,10 @@ void do_cycles_cpu_fastest(uae_u32 cycles_to_add)
{ {
if (i.active && i.evtime == currcycle) if (i.active && i.evtime == currcycle)
{ {
(*i.handler)(); if (i.handler == nullptr)
i.active = false;
else
(*i.handler)();
} }
} }
events_schedule(); events_schedule();
@ -207,6 +227,7 @@ void MISC_handler(void)
if (mintime != ~0UL) if (mintime != ~0UL)
{ {
eventtab[ev_misc].active = true; eventtab[ev_misc].active = true;
eventtab[ev_misc].oldcycles = ct;
eventtab[ev_misc].evtime = ct + mintime; eventtab[ev_misc].evtime = ct + mintime;
events_schedule(); events_schedule();
} }
@ -247,3 +268,17 @@ void event2_newevent_xx(int no, evt t, uae_u32 data, evfunc2 func)
eventtab2[no].data = data; eventtab2[no].data = data;
MISC_handler(); MISC_handler();
} }
void event2_newevent_x_replace(evt t, uae_u32 data, evfunc2 func)
{
for (int i = 0; i < ev2_max; i++) {
if (eventtab2[i].active && eventtab2[i].handler == func) {
eventtab2[i].active = false;
}
}
if (((int)t) <= 0) {
func(data);
return;
}
event2_newevent_xx(-1, t * CYCLE_UNIT, data, func);
}

View file

@ -1754,7 +1754,9 @@ static int save_thumb(char* path)
return ret; return ret;
} }
#ifdef USE_DISPMANX
static int currVSyncRate = 0; static int currVSyncRate = 0;
#endif
bool vsync_switchmode(int hz) bool vsync_switchmode(int hz)
{ {
static struct PicassoResolution* oldmode; static struct PicassoResolution* oldmode;
@ -1873,6 +1875,12 @@ bool vsync_switchmode(int hz)
#endif #endif
} }
int vsync_isdone(frame_time_t* dt)
{
if (isvsync() == 0)
return -1;
}
bool target_graphics_buffer_update() bool target_graphics_buffer_update()
{ {
auto rate_changed = false; auto rate_changed = false;