From 1dade12cc7f78d9f5d4737cf5896cf8976f3f85f Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Tue, 1 May 2012 17:02:22 +0300 Subject: [PATCH] 2410b12 --- custom.cpp | 72 +++++--- drawing.cpp | 15 +- events.cpp | 39 +++-- main.cpp | 2 +- od-win32/direct3d.cpp | 4 +- od-win32/hardfile_win32.cpp | 44 +++-- od-win32/resources/resource | 3 + od-win32/resources/winuae.rc | 2 + od-win32/rp.cpp | 4 +- od-win32/sounddep/sound.cpp | 2 +- od-win32/win32.cpp | 25 ++- od-win32/win32.h | 4 +- od-win32/win32gfx.cpp | 160 ++++++++++-------- od-win32/win32gui.cpp | 16 +- od-win32/winuae_msvc10/winuae_msvc.vcxproj | 1 - .../winuae_msvc10/winuae_msvc.vcxproj.filters | 3 - od-win32/winuaechangelog.txt | 12 ++ 17 files changed, 254 insertions(+), 154 deletions(-) diff --git a/custom.cpp b/custom.cpp index 259a3436..7c38035c 100644 --- a/custom.cpp +++ b/custom.cpp @@ -2452,7 +2452,7 @@ static void decide_sprites (int hpos) record_sprite (next_lineno, nr, posns[i], sprdata[nr], sprdatb[nr], sprctl[nr]); /* get left and right sprite edge if brdsprt enabled */ #if AUTOSCALE_SPRITES - if (dmaen (DMA_SPRITE) && (bplcon0 & 1) && (bplcon3 & 0x02) && !(bplcon3 & 0x20)) { + if (dmaen (DMA_SPRITE) && (bplcon0 & 1) && (bplcon3 & 0x02) && !(bplcon3 & 0x20) && nr > 0) { int j, jj; for (j = 0, jj = 0; j < sprite_width; j+= 16, jj++) { int nx = fromspritexdiw (posns[i] + j); @@ -5235,42 +5235,54 @@ static void framewait (void) // fastest possible int max, adjust; + frame_time_t now; - adjust = 0; - curr_time = read_processor_time (); - start = vsync_busywait_end (); - if ((int)curr_time - (int)vsyncwaittime < 0) - curr_time = start; - + curr_time = vsync_busywait_end (); // vsync time vsync_busywait_do (NULL, (bplcon0 & 4) != 0 && !lof_changed && !lof_changing, lof_store != 0); vsync_busywait_start (); - max = vsynctimebase * (1000 + currprefs.m68k_speed_throttle) / 1000; - if ((int)curr_time - (int)vsyncwaittime > 0 && (int)curr_time - (int)vsyncwaittime < vsynctimebase / 2) - adjust = curr_time - vsyncwaittime; - max -= adjust; + now = read_processor_time (); // current time + adjust = (int)now - (int)curr_time; + if (adjust < 0) + adjust = 0; + if (adjust > vsynctimebase / 3) + adjust = vsynctimebase / 3; - vsyncmintime = curr_time; + max = (vsynctimebase - (adjust * 3 / 2)) * (1000 + currprefs.m68k_speed_throttle) / 1000; + vsyncmintime = now; vsyncwaittime = curr_time + vsynctimebase; vsynctimeperline = max / (maxvpos_nom + 1); - vsyncmaxtime = curr_time + max; + vsyncmaxtime = now + max; } else { + int max, adjust; + frame_time_t now; + render_screen (); bool show = show_screen_maybe (false); vsync_busywait_do (&freetime, (bplcon0 & 4) != 0 && !lof_changed && !lof_changing, lof_store != 0); curr_time = read_processor_time (); - vsyncmintime = curr_time; - vsyncwaittime = curr_time + vsynctimebase; - vsyncmaxtime = curr_time + vsynctimebase; - vsynctimeperline = vsynctimebase / (maxvpos_nom + 1); if (!show) { show_screen (); if (extraframewait) sleep_millis_main (extraframewait); } + now = read_processor_time (); + adjust = (int)now - (int)curr_time; + if (adjust < 0) + adjust = 0; + if (adjust > vsynctimebase / 3) + adjust = vsynctimebase / 3; + max = vsynctimebase - (adjust * 3 / 2); + + vsyncmintime = now; + vsyncwaittime = curr_time + vsynctimebase; + + vsynctimeperline = max / 3; + vsyncmaxtime = now + max; + frame_shown = true; } @@ -5813,6 +5825,11 @@ static void hsync_handler_pre (bool onvsync) #endif } +STATIC_INLINE bool is_last_line (void) +{ + return vpos + 1 == maxvpos + lof_store; +} + // this prepares for new line static void hsync_handler_post (bool onvsync) { @@ -5931,12 +5948,13 @@ static void hsync_handler_post (bool onvsync) } #endif if (currprefs.m68k_speed < 0) { - if (vpos + 1 == maxvpos + lof_store) { + if (is_last_line ()) { /* really last line, just run the cpu emulation until whole vsync time has been used */ if (currprefs.m68k_speed_throttle) { vsyncmintime = read_processor_time (); /* end of CPU emulation time */ } else { vsyncmintime = vsyncmaxtime; /* emulate if still time left */ + is_syncline_end = read_processor_time () + vsynctimebase; is_syncline = 1; } } else { @@ -5957,19 +5975,23 @@ static void hsync_handler_post (bool onvsync) linecounter = 0; } } - // extra cpu emulation time if previous 8 lines without extra time. - if (!is_syncline && linecounter >= 8) { - is_syncline = -1; - is_syncline_end = read_processor_time () + vsynctimeperline; - linecounter = 0; + if (!isvsync ()) { + // extra cpu emulation time if previous 10 lines without extra time. + if (!is_syncline && linecounter >= 10) { + is_syncline = -1; + is_syncline_end = read_processor_time () + vsynctimeperline; + linecounter = 0; + } } } + } else { + ;//write_log (L"%d ", vpos); } } } else { if (vpos + 1 < maxvpos + lof_store && (vpos == maxvpos_nom * 1 / 3 || vpos == maxvpos_nom * 2 / 3)) { frame_time_t rpt = read_processor_time (); - vsyncmintime += vsynctimebase / 3; + vsyncmintime += vsynctimeperline; // sleep if more than 2ms "free" time if (!vblank_found_chipset && (int)vsyncmintime - (int)(rpt + vsynctimebase / 10) > 0) { sleep_millis_main (1); @@ -6079,7 +6101,7 @@ static void hsync_handler_post (bool onvsync) if (diw_change > 0) diw_change--; - if (is_syncline > 0 && isvsync_chipset () == -2 && !vsync_rendered && currprefs.gfx_apmode[0].gfx_vflip == 0) { + if (is_last_line () && isvsync_chipset () == -2 && !vsync_rendered && currprefs.gfx_apmode[0].gfx_vflip == 0) { frame_time_t start, end; start = read_processor_time (); /* fastest possible + last line and no vflip wait: render the frame as early as possible */ diff --git a/drawing.cpp b/drawing.cpp index 113c9d49..e083800d 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -384,11 +384,14 @@ int get_custom_limits (int *pw, int *ph, int *pdx, int *pdy) // interlace = only use long frames if (!lof_store) return ret; - last_planes_vpos++; - plflastline_total++; + /* program may have set last visible line as last possible line (CD32 boot screen) */ + if (last_planes_vpos < maxvpos) + last_planes_vpos++; + if (plflastline_total < maxvpos) + plflastline_total++; } - if (!plflastline_total) + if (plflastline_total < 4) plflastline_total = last_planes_vpos; ddffirstword_total = coord_hw_to_window_x (ddffirstword_total * 2 + DIW_DDF_OFFSET); @@ -2939,6 +2942,12 @@ static void clearbuffer (struct vidbuffer *dst) } } +void reset_decision_table (void) +{ + for (int i = 0; i < sizeof linestate / sizeof *linestate; i++) + linestate[i] = LINE_UNDECIDED; +} + void reset_drawing (void) { unsigned int i; diff --git a/events.cpp b/events.cpp index d4fe194e..a587f7ab 100644 --- a/events.cpp +++ b/events.cpp @@ -50,24 +50,27 @@ void do_cycles_slow (unsigned long cycles_to_add) int i; /* Keep only CPU emulation running while waiting for sync point. */ - if (is_syncline > 0) { - int rpt = read_processor_time (); - int v = rpt - vsyncmintime; - int v2 = rpt - is_syncline_end; - if (v > (int)vsynctimebase || v < -((int)vsynctimebase)) { - v = 0; - } - if (v < 0 && v2 < 0 && !vblank_found_chipset) { - pissoff = pissoff_value; - return; - } - is_syncline = 0; - } else if (is_syncline < 0) { - int rpt = read_processor_time (); - int v = rpt - is_syncline_end; - if (v < 0 && !vblank_found_chipset) { - pissoff = pissoff_value; - return; + if (is_syncline) { + if (!vblank_found_chipset) { + if (is_syncline > 0) { + int rpt = read_processor_time (); + int v = rpt - vsyncmintime; + int v2 = rpt - is_syncline_end; + if (v > (int)vsynctimebase || v < -((int)vsynctimebase)) { + v = 0; + } + if (v < 0 && v2 < 0) { + pissoff = pissoff_value; + return; + } + } else if (is_syncline < 0) { + int rpt = read_processor_time (); + int v = rpt - is_syncline_end; + if (v < 0) { + pissoff = pissoff_value; + return; + } + } } is_syncline = 0; } diff --git a/main.cpp b/main.cpp index e885b28b..20274428 100644 --- a/main.cpp +++ b/main.cpp @@ -169,7 +169,7 @@ void fixup_prefs_dimensions (struct uae_prefs *prefs) if (ap->gfx_vsyncmode) { // low latency vsync: no flip only if no-buffer if (ap->gfx_backbuffers >= 1) - ap->gfx_vflip = -1; + ap->gfx_vflip = 1; if (!i && ap->gfx_backbuffers == 2) ap->gfx_vflip = 1; } else { diff --git a/od-win32/direct3d.cpp b/od-win32/direct3d.cpp index acfa043c..b0c66dc6 100644 --- a/od-win32/direct3d.cpp +++ b/od-win32/direct3d.cpp @@ -1673,8 +1673,8 @@ static void setupscenecoords (void) //write_log (_T("%.1fx%.1f %.1fx%.1f %.1fx%.1f\n"), dw, dh, w, h, sw, sh); // ratio between Amiga texture and overlay mask texture - float sw2 = dw * tin_w / window_w - 0.5f; - float sh2 = dh * tin_h / window_h + 0.5f; + float sw2 = dw * tin_w / window_w; + float sh2 = dh * tin_h / window_h; maskmult.x = sw2 * maskmult_x / w; maskmult.y = sh2 * maskmult_y / h; diff --git a/od-win32/hardfile_win32.cpp b/od-win32/hardfile_win32.cpp index d885340e..3cadbecf 100644 --- a/od-win32/hardfile_win32.cpp +++ b/od-win32/hardfile_win32.cpp @@ -1030,17 +1030,23 @@ static int getstorageproperty (PUCHAR outBuf, int returnedLength, struct uae_dri udi->removablemedia = devDesc->RemovableMedia; write_log (_T("device id string: '%s'\n"), udi->device_name); if (ignoreduplicates) { - _stprintf (orgname, _T(":%s"), udi->device_name); - if (isharddrive (orgname) >= 0) { - write_log (_T("duplicate device, ignored\n")); - return 1; - } if (!udi->removablemedia) { write_log (_T("drive letter not removable, ignored\n")); - return 1; + return -2; + } + _stprintf (orgname, _T(":%s"), udi->device_name); + for (i = 0; i < hdf_getnumharddrives (); i++) { + if (!_tcscmp (uae_drives[i].device_name, orgname)) { + if (uae_drives[i].dangerous == -10) { + write_log (_T("replaced old '%s'\n"), uae_drives[i].device_name); + return i; + } + write_log (_T("duplicate device, ignored\n")); + return -2; + } } } - return 0; + return -1; } static BOOL GetDevicePropertyFromName(const TCHAR *DevicePath, DWORD Index, DWORD *index2, uae_u8 *buffer, int ignoreduplicates) @@ -1060,13 +1066,15 @@ static BOOL GetDevicePropertyFromName(const TCHAR *DevicePath, DWORD Index, DWOR BOOL status; ULONG length = 0, returned = 0, returnedLength; BOOL showonly = FALSE; + struct uae_driveinfo tmpudi = { 0 }; + + udi = &tmpudi; + int udiindex = *index2; // // Now we have the device path. Open the device interface // to send Pass Through command - udi = &uae_drives[*index2]; - memset (udi, 0, sizeof (struct uae_driveinfo)); _tcscpy (udi->device_path, DevicePath); write_log (_T("opening device '%s'\n"), udi->device_path); hDevice = CreateFile( @@ -1143,15 +1151,19 @@ static BOOL GetDevicePropertyFromName(const TCHAR *DevicePath, DWORD Index, DWOR } nosp = 1; generatestorageproperty (udi, ignoreduplicates); + udiindex = -1; } else { - int r; nosp = 0; - r = getstorageproperty (outBuf, returnedLength, udi, ignoreduplicates); - if (r) { - ret = r; + udiindex = getstorageproperty (outBuf, returnedLength, udi, ignoreduplicates); + if (udiindex == -2) { + ret = 1; goto end; } } + udi = &uae_drives[udiindex < 0 ? *index2 : udiindex]; + memcpy (udi, &tmpudi, sizeof (struct uae_driveinfo)); + + _tcscpy (orgname, udi->device_name); udi->bytespersector = 512; geom_ok = 1; @@ -1277,7 +1289,7 @@ static BOOL GetDevicePropertyFromName(const TCHAR *DevicePath, DWORD Index, DWOR } amipartfound: _stprintf (udi->device_name, _T(":%s"), orgname); - { + if (udiindex < 0) { int cnt = 1; int off = _tcslen (udi->device_name); while (isharddrive (udi->device_name) >= 0) { @@ -1286,8 +1298,8 @@ amipartfound: udi->device_name[off + 2] = 0; cnt++; } - } - (*index2)++; + (*index2)++; + } end: if (hDevice != INVALID_HANDLE_VALUE) CloseHandle (hDevice); diff --git a/od-win32/resources/resource b/od-win32/resources/resource index cd29145d..465d454e 100644 --- a/od-win32/resources/resource +++ b/od-win32/resources/resource @@ -356,6 +356,9 @@ #define IDS_SCREEN_VSYNC2_AUTOSWITCH 376 #define IDS_SCREEN_VSYNC2 377 #define IDS_SCREEN_VSYNC_NONE 378 +#define IDS_FILTEROVERLAYTYPE_MASKS 379 +#define IDS_STRING380 380 +#define IDS_FILTEROVERLAYTYPE_OVERLAYS 380 #define IDS_QS_MODELS 1000 #define IDS_QS_MODEL_A500 1001 #define IDS_QS_MODEL_A500P 1002 diff --git a/od-win32/resources/winuae.rc b/od-win32/resources/winuae.rc index a9b183d1..af7b3862 100644 --- a/od-win32/resources/winuae.rc +++ b/od-win32/resources/winuae.rc @@ -1707,6 +1707,8 @@ BEGIN IDS_SCREEN_VSYNC2_AUTOSWITCH "Low latency VS, 50/60Hz" IDS_SCREEN_VSYNC2 "Low latency VSync" IDS_SCREEN_VSYNC_NONE "-" + IDS_FILTEROVERLAYTYPE_MASKS "Masks" + IDS_FILTEROVERLAYTYPE_OVERLAYS "Overlays" END STRINGTABLE diff --git a/od-win32/rp.cpp b/od-win32/rp.cpp index bbf6909b..23637607 100644 --- a/od-win32/rp.cpp +++ b/od-win32/rp.cpp @@ -259,7 +259,7 @@ bool port_get_custom (int inputmap_port, TCHAR *out) } } } - write_log (L"********* -> %s\n", out); + write_log (_T("port_get_custom: %s\n"), out); return true; } @@ -345,7 +345,7 @@ int port_insert_custom (int inputmap_port, int devicetype, DWORD flags, const TC } } if (wdnum >= 0) { - write_log (_T("kb=%d (%s) wdnum=%d\n"), j, inputdevicefunc_keyboard.get_friendlyname (j), wdnum); + //write_log (_T("kb=%d (%s) wdnum=%d\n"), j, inputdevicefunc_keyboard.get_friendlyname (j), wdnum); inputdevice_set_gameports_mapping (&changed_prefs, kb + j, wdnum, evtnum, flags, inputmap_port); inputdevice_set_gameports_mapping (&currprefs, kb + j, wdnum, evtnum, flags, inputmap_port); } else { diff --git a/od-win32/sounddep/sound.cpp b/od-win32/sounddep/sound.cpp index 0ba617e2..dfcc933f 100644 --- a/od-win32/sounddep/sound.cpp +++ b/od-win32/sounddep/sound.cpp @@ -250,7 +250,7 @@ static void docorrection (struct sound_dp *s, int sndbuf, double sync, int granu double skipmode, avgskipmode; double avg = s->avg_correct / s->cnt_correct; - skipmode = sync / 10.0; + skipmode = sync / 100.0; avgskipmode = avg / (10000.0 / granulaty); if ((0 || sound_debug) && (tfprev % 10) == 0) { diff --git a/od-win32/win32.cpp b/od-win32/win32.cpp index d4501178..4d2d33f8 100644 --- a/od-win32/win32.cpp +++ b/od-win32/win32.cpp @@ -99,7 +99,7 @@ int log_scsi; int log_net; int log_vsync; int uaelib_debug; -int pissoff_value = 20000 * CYCLE_UNIT; +int pissoff_value = 15000 * CYCLE_UNIT; unsigned int fpucontrol; int extraframewait = 0; @@ -2276,7 +2276,7 @@ void logging_init (void) int wow64 = 0; static int started; static int first; - TCHAR tmp[MAX_DPATH]; + TCHAR tmp[MAX_DPATH], filedate[256]; if (first > 1) { write_log (_T("** RESTART **\n")); @@ -2292,6 +2292,7 @@ void logging_init (void) logging_open (first ? 0 : 1, 0); logging_started = 1; first++; + #ifdef _WIN64 wow64 = 1; #else @@ -2299,13 +2300,29 @@ void logging_init (void) if (fnIsWow64Process) fnIsWow64Process (GetCurrentProcess (), &wow64); #endif + + _tcscpy (filedate, _T("?")); + if (GetModuleFileName (NULL, tmp, sizeof tmp / sizeof (TCHAR))) { + HANDLE h = CreateFile (tmp, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (h != INVALID_HANDLE_VALUE) { + FILETIME ft; + if (GetFileTime (h, &ft, NULL, NULL)) { + SYSTEMTIME st; + if (FileTimeToSystemTime(&ft, &st)) { + _stprintf (filedate, _T("%02d:%02d"), st.wHour, st.wMinute); + } + } + CloseHandle (h); + } + } + write_log (_T("%s (%d.%d %s%s[%d])"), VersionStr, osVersion.dwMajorVersion, osVersion.dwMinorVersion, osVersion.szCSDVersion, _tcslen (osVersion.szCSDVersion) > 0 ? _T(" ") : _T(""), os_winnt_admin); - write_log (_T(" %d-bit %X.%X.%X %d"), + write_log (_T(" %d-bit %X.%X.%X %d %s"), wow64 ? 64 : 32, SystemInfo.wProcessorArchitecture, SystemInfo.wProcessorLevel, SystemInfo.wProcessorRevision, - SystemInfo.dwNumberOfProcessors); + SystemInfo.dwNumberOfProcessors, filedate); write_log (_T("\n(c) 1995-2001 Bernd Schmidt - Core UAE concept and implementation.") _T("\n(c) 1998-2012 Toni Wilen - Win32 port, core code updates.") _T("\n(c) 1996-2001 Brian King - Win32 port, Picasso96 RTG, and GUI.") diff --git a/od-win32/win32.h b/od-win32/win32.h index 78eec3ee..ab75413a 100644 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -19,8 +19,8 @@ #define LANG_DLL 1 //#define WINUAEBETA _T("") -#define WINUAEBETA _T("Beta 11") -#define WINUAEDATE MAKEBD(2012, 4, 27) +#define WINUAEBETA _T("12") +#define WINUAEDATE MAKEBD(2012, 5, 1) #define WINUAEEXTRA _T("") //#define WINUAEEXTRA _T("AmiKit Preview") #define WINUAEREV _T("") diff --git a/od-win32/win32gfx.cpp b/od-win32/win32gfx.cpp index 57dfec44..223d304b 100644 --- a/od-win32/win32gfx.cpp +++ b/od-win32/win32gfx.cpp @@ -147,6 +147,7 @@ static void vsync_sleep (bool preferbusy) if (vsync_busy_wait_mode == 0) { dowait = ap->gfx_vflip || !preferbusy; + //dowait = !preferbusy; } else if (vsync_busy_wait_mode < 0) { dowait = true; } else { @@ -2451,18 +2452,18 @@ static bool waitvblankstate (bool state, int *maxvpos, int *flags) } } -static bool vblank_wait (void) +static int vblank_wait (void) { int vp; for (;;) { int opos = prevvblankpos; if (!getvblankpos (&vp)) - return false; + return -2; if (opos > maxscanline / 2 && vp < maxscanline / 3) - return true; + return vp; if (vp <= 0) - return true; + return vp; vsync_sleep (true); } } @@ -2522,7 +2523,6 @@ static int frame_usage, frame_usage_avg, frame_usage_total; extern int log_vsync; static bool dooddevenskip; static volatile bool vblank_skipeveryother; -static volatile bool vblank_first_time; static bool vblanklaceskip (void) { @@ -2537,105 +2537,135 @@ static bool vblanklaceskip (void) static unsigned int __stdcall vblankthread (void *dummy) { - static bool firstvblankbasewait2; + bool vblank_first_time = false; + bool firstvblankbasewait2; + frame_time_t vblank_prev_time2; + bool doflipped; + while (vblankthread_mode > VBLANKTH_KILL) { struct apmode *ap = picasso_on ? &currprefs.gfx_apmode[1] : &currprefs.gfx_apmode[0]; vblankthread_counter++; - if (vblankthread_mode == VBLANKTH_CALIBRATE) { + int mode = vblankthread_mode; + if (mode == VBLANKTH_CALIBRATE) { // calibrate mode, try to keep CPU power saving inactive SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_LOWEST); while (vblankthread_mode == 0) vblankthread_counter++; SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_HIGHEST); - } else if (vblankthread_mode == VBLANKTH_IDLE) { + } else if (mode == VBLANKTH_IDLE) { // idle mode Sleep (100); - } else if (vblankthread_mode == VBLANKTH_ACTIVE_WAIT) { - sleep_millis (ap->gfx_vflip && currprefs.m68k_speed >= 0 ? 2 : 1); - } else if (vblankthread_mode == VBLANKTH_ACTIVE_START) { + } else if (mode == VBLANKTH_ACTIVE_WAIT) { + sleep_millis (1); + } else if (mode == VBLANKTH_ACTIVE_START) { // do not start until vblank has been passed int vp; - firstvblankbasewait2 = false; getvblankpos (&vp); - if (vp <= 0) { - if (!vblank_first_time) { - // set prevtime now if we are still at vsync to improve timing - vblank_prev_time = read_processor_time (); - vblank_first_time = true; - } + if (vp > maxscanline / 2) { sleep_millis (1); continue; } - if (vp > maxscanline / 2) { + if (!vblank_first_time) { + frame_time_t rpt = read_processor_time (); + if (vp <= 0) { + vblank_prev_time2 = rpt; + } else { + vblank_prev_time2 = rpt - (vblankbasefull * vp / maxscanline) / (vblank_skipeveryother ? 2 : 1 ); + } + vblank_first_time = true; + } + if (vp <= 0) { sleep_millis (1); continue; } + vblank_prev_time = vblank_prev_time2; + vblank_first_time = false; + firstvblankbasewait2 = false; prevvblankpos = 0; + doflipped = false; if (vblank_skipeveryother) // wait for first vblank in skip frame mode (100Hz+) vblankthread_mode = VBLANKTH_ACTIVE_SKIPFRAME; else vblankthread_mode = VBLANKTH_ACTIVE; - } else if (vblankthread_mode == VBLANKTH_ACTIVE_SKIPFRAME) { + } else if (mode == VBLANKTH_ACTIVE_SKIPFRAME) { int vp; sleep_millis (1); getvblankpos (&vp); if (vp >= maxscanline / 2) vblankthread_mode = VBLANKTH_ACTIVE_SKIPFRAME2; - } else if (vblankthread_mode == VBLANKTH_ACTIVE_SKIPFRAME2) { + if (read_processor_time () - vblank_prev_time2 > vblankbasefull * 2) + vblankthread_mode = VBLANKTH_ACTIVE; + } else if (mode == VBLANKTH_ACTIVE_SKIPFRAME2) { int vp; sleep_millis (1); getvblankpos (&vp); - if (vp < maxscanline / 2) + if (vp > 0 && vp < maxscanline / 2) { + prevvblankpos = 0; vblankthread_mode = VBLANKTH_ACTIVE; - } else if (vblankthread_mode == VBLANKTH_ACTIVE) { + } + if (read_processor_time () - vblank_prev_time2 > vblankbasefull * 2) + vblankthread_mode = VBLANKTH_ACTIVE; + } else if (mode == VBLANKTH_ACTIVE) { // busy wait mode frame_time_t t = read_processor_time (); bool donotwait = false; bool end = false; + bool vblank_found_rtg2 = false; + bool vblank_found2 = false; + frame_time_t thread_vblank_time2 = 0; int vs = isvsync_chipset (); // immediate vblank if mismatched frame type if (vs < 0 && vblanklaceskip ()) { - vblank_found = true; + vblank_found2 = true; vblank_found_chipset = true; end = true; - } else if (t - vblank_prev_time > vblankbasewait2) { + } else if (t - vblank_prev_time2 > vblankbasewait2) { int vp = 0; bool vb = false; bool ok; if (firstvblankbasewait2 == false) { firstvblankbasewait2 = true; vblank_getstate (&vb, &vp); - if (!dooddevenskip && ap->gfx_vflip > 0) { - doflipevent (); - } + } + if (!doflipped && !dooddevenskip && ap->gfx_vflip > 0) { + doflipevent (); + doflipped = true; } ok = vblank_getstate (&vb, &vp); if (!ok || vb) { - thread_vblank_time = t; + thread_vblank_time2 = t; if (vs < 0) { vblank_found_chipset = true; if (!ap->gfx_vflip) { show_screen (); } } - vblank_found_rtg = true; - vblank_found = true; + vblank_found_rtg2 = true; + vblank_found2 = true; end = true; } - if (t - vblank_prev_time > vblankbasewait3) + if (t - vblank_prev_time2 > vblankbasewait3) donotwait = true; } - if (t - vblank_prev_time > vblankbasefull * 2) { - thread_vblank_time = t; - vblank_found = true; - vblank_found_rtg = true; + if (!end && t - vblank_prev_time2 > vblankbasefull * 2) { + thread_vblank_time2 = t; + vblank_found2 = true; + vblank_found_rtg2 = true; vblank_found_chipset = true; end = true; } if (end) { + if (!dooddevenskip && ap->gfx_vflip > 0 && !doflipped) { + doflipevent (); + doflipped = true; + } + thread_vblank_time = thread_vblank_time2; + vblank_found_rtg = vblank_found_rtg2; + vblank_found = vblank_found2; vblankthread_mode = VBLANKTH_ACTIVE_WAIT; } else if (!donotwait || ap->gfx_vflip || picasso_on) { - sleep_millis (ap->gfx_vflip && currprefs.m68k_speed >= 0 ? 2 : 1); +// } else if (!donotwait || picasso_on) { + sleep_millis (1); } } else { break; @@ -2645,48 +2675,29 @@ static unsigned int __stdcall vblankthread (void *dummy) return 0; } -#if 0 -static void vsync_notvblank (void) +frame_time_t vsync_busywait_end (void) { + frame_time_t prev; for (;;) { - int vp; - if (!getvblankpos (&vp)) - return; - if (vp > 0) { - //write_log (_T("%d "), vpos); + int v = vblankthread_mode; + if (v != VBLANKTH_ACTIVE_START && v != VBLANKTH_ACTIVE_SKIPFRAME && v != VBLANKTH_ACTIVE_SKIPFRAME2) break; - } - vsync_sleep (true); - } -} -#endif -frame_time_t vsync_busywait_end (void) -{ - while (vblankthread_mode == VBLANKTH_ACTIVE_START || vblankthread_mode == VBLANKTH_ACTIVE_SKIPFRAME || vblankthread_mode == VBLANKTH_ACTIVE_SKIPFRAME2) { sleep_millis_main (1); } + prev = vblank_prev_time; if (!dooddevenskip) { - while (!vblank_found && vblankthread_mode == VBLANKTH_ACTIVE) { - vsync_sleep (currprefs.m68k_speed < 0 && currprefs.m68k_speed_throttle == 0); + while (vblankthread_mode == VBLANKTH_ACTIVE) { + vsync_sleep (currprefs.m68k_speed < 0 || currprefs.m68k_speed_throttle < 0); } } changevblankthreadmode_fast (VBLANKTH_ACTIVE_WAIT); - return thread_vblank_time; + return prev + vblankbasefull; } void vsync_busywait_start (void) { -#if 0 - struct apmode *ap = picasso_on ? &currprefs.gfx_apmode[1] : &currprefs.gfx_apmode[0]; - if (!dooddevenskip) { - vsync_notvblank (); - if (ap->gfx_vflip > 0) { - doflipevent (); - } - } -#endif - vblank_prev_time = thread_vblank_time; - vblank_first_time = false; + if (vblankthread_mode != VBLANKTH_ACTIVE_WAIT) + write_log (L"low latency vsync state mismatch %d\n", vblankthread_mode); changevblankthreadmode_fast (VBLANKTH_ACTIVE_START); } @@ -2768,16 +2779,21 @@ bool vsync_busywait_do (int *freetime, bool lace, bool oddeven) while (!framelost && read_processor_time () - prevtime < vblankbasewait1) { vsync_sleep (false); } - v = vblank_wait (); + int vp = vblank_wait (); + if (vp >= -1) { + vblank_prev_time = read_processor_time (); + if (vp > 0) + vblank_prev_time -= (vblankbasefull * vp / maxscanline) / (vblank_skipeveryother ? 2 : 1 ); + v = true; + } } else { v = true; + vblank_prev_time = read_processor_time (); } framelost = false; - } if (v) { - vblank_prev_time = read_processor_time (); frame_counted++; return true; } @@ -2826,7 +2842,7 @@ double vblank_calibrate (double approx_vblank, bool waitonly) while (rv) { if (rv->width == width && rv->height == height && rv->depth == depth && rv->rate == rate && rv->mode == mode && rv->rtg == picasso_on) { approx_vblank = rv->remembered_rate2; - rval = rv->remembered_rate; + tsum = rval = rv->remembered_rate; maxscanline = rv->maxscanline; maxvpos = rv->maxvpos; lace = rv->lace; @@ -2917,9 +2933,9 @@ double vblank_calibrate (double approx_vblank, bool waitonly) tsum /= total; } -skip: if (waitonly) tsum = approx_vblank; +skip: vblank_skipeveryother = false; getvsyncrate (tsum, &mult); @@ -2936,7 +2952,7 @@ skip: vblankbasefull = (syncbase / tsum2); vblankbasewait1 = (syncbase / tsum2) * 75 / 100; vblankbasewait2 = (syncbase / tsum2) * 55 / 100; - vblankbasewait3 = (syncbase / tsum2) * 99 / 100 - syncbase / 500; // at least 2ms before vblank + vblankbasewait3 = (syncbase / tsum2) * 99 / 100 - syncbase / (250 * (vblank_skipeveryother ? 1 : 2)); // at least 2ms before vblank vblankbaselace = lace; write_log (_T("VSync %s: %.6fHz/%.1f=%.6fHz. MinV=%d MaxV=%d%s Units=%d %.1f%%\n"), waitonly ? _T("remembered") : _T("calibrated"), tsum, div, tsum2, diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index acb59330..de4336af 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -11700,7 +11700,7 @@ static void values_from_inputdlg (HWND hDlg, int inputchange) bool iscustom = false; TCHAR custom[MAX_DPATH]; - if (!_tcscmp (inputdevice_get_eventinfo (INPUTEVENT_SPC_CUSTOM_EVENT)->name, eventnames[input_selected_event])) { + if (eventnames[input_selected_event] && !_tcscmp (inputdevice_get_eventinfo (INPUTEVENT_SPC_CUSTOM_EVENT)->name, eventnames[input_selected_event])) { doinputcustom (hDlg, 1); iscustom = true; } @@ -12998,7 +12998,7 @@ static INT_PTR CALLBACK hw3dDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM LRESULT item; TCHAR tmp[100]; int i; - static int filteroverlaypos; + static int filteroverlaypos = -1; switch (msg) { @@ -13030,8 +13030,16 @@ static INT_PTR CALLBACK hw3dDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM } SendDlgItemMessage (hDlg, IDC_FILTEROVERLAYTYPE, CB_RESETCONTENT, 0, 0L); - SendDlgItemMessage (hDlg, IDC_FILTEROVERLAYTYPE, CB_ADDSTRING, 0, (LPARAM)_T("Overlays")); - SendDlgItemMessage (hDlg, IDC_FILTEROVERLAYTYPE, CB_ADDSTRING, 0, (LPARAM)_T("Masks")); + WIN32GUI_LoadUIString (IDS_FILTEROVERLAYTYPE_OVERLAYS, tmp, sizeof tmp / sizeof (TCHAR)); + SendDlgItemMessage (hDlg, IDC_FILTEROVERLAYTYPE, CB_ADDSTRING, 0, (LPARAM)tmp); + WIN32GUI_LoadUIString (IDS_FILTEROVERLAYTYPE_MASKS, tmp, sizeof tmp / sizeof (TCHAR)); + SendDlgItemMessage (hDlg, IDC_FILTEROVERLAYTYPE, CB_ADDSTRING, 0, (LPARAM)tmp); + if (filteroverlaypos < 0) { + if (!workprefs.gfx_filteroverlay[0]) + filteroverlaypos = 1; + else + filteroverlaypos = 0; + } SendDlgItemMessage (hDlg, IDC_FILTEROVERLAYTYPE, CB_SETCURSEL, filteroverlaypos, 0); enable_for_hw3ddlg (hDlg); diff --git a/od-win32/winuae_msvc10/winuae_msvc.vcxproj b/od-win32/winuae_msvc10/winuae_msvc.vcxproj index 1c8fb9e9..22e4c2dc 100644 --- a/od-win32/winuae_msvc10/winuae_msvc.vcxproj +++ b/od-win32/winuae_msvc10/winuae_msvc.vcxproj @@ -685,7 +685,6 @@ - diff --git a/od-win32/winuae_msvc10/winuae_msvc.vcxproj.filters b/od-win32/winuae_msvc10/winuae_msvc.vcxproj.filters index 34fb1b37..0f75a87b 100644 --- a/od-win32/winuae_msvc10/winuae_msvc.vcxproj.filters +++ b/od-win32/winuae_msvc10/winuae_msvc.vcxproj.filters @@ -609,9 +609,6 @@ - - common - diff --git a/od-win32/winuaechangelog.txt b/od-win32/winuaechangelog.txt index 573f34c0..9691d294 100644 --- a/od-win32/winuaechangelog.txt +++ b/od-win32/winuaechangelog.txt @@ -2,6 +2,18 @@ - restore only single input target to default. - hdd from command line +Beta 12: (RC1) + +- Ignore sprite 0 (normally mouse pointer) when calculating autoscale position and size. +- Custom Input event editor usually crashed. +- CD32 boot screen autoscale improved. +- b10 "show drives that require admin privileges" hide drives that also have drive letter. + Background info: for some strange reason USB memory card adapters have two devices, one (without drive letter) that can't + be accessed without admin privileges and drive letter device that can be accessed. +- Fastest possible CPU + low latency vsync and double frame mode (85Hz+) jitter fixed. +- "Masks" in filter panel is selected by default, "Overlays" is only selected if overlay image is already configured. +- Possible fix for D3D mask alignment errors in some scaling settings. + Beta 11: - Adjusted Fastest Possible timing a bit more.. -- 2.47.3