From: Toni Wilen Date: Fri, 27 Apr 2012 16:52:00 +0000 (+0300) Subject: 2410b11 X-Git-Tag: 2410~4 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=3fa879f3eee514bf379077b782aa5f7e016176ae;p=francis%2Fwinuae.git 2410b11 --- diff --git a/custom.cpp b/custom.cpp index 59dd68db..259a3436 100644 --- a/custom.cpp +++ b/custom.cpp @@ -5946,19 +5946,24 @@ static void hsync_handler_post (bool onvsync) linecounter++; is_syncline = 0; if (!vblank_found_chipset) { - if ((int)vsyncmaxtime - (int)vsyncmintime > 0 && (int)vsyncwaittime - (int)vsyncmintime > 0) { - frame_time_t rpt = read_processor_time (); - /* Extra time left? Do some extra CPU emulation */ - if ((int)vsyncmintime - (int)rpt > 0) { + if ((int)vsyncmaxtime - (int)vsyncmintime > 0) { + if ((int)vsyncwaittime - (int)vsyncmintime > 0) { + frame_time_t rpt = read_processor_time (); + /* Extra time left? Do some extra CPU emulation */ + if ((int)vsyncmintime - (int)rpt > 0) { + is_syncline = 1; + /* limit extra time */ + is_syncline_end = rpt + vsynctimeperline; + 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; } } - // extra cpu emulation time if 10 lines without extra - if (!is_syncline && linecounter > 9) { - is_syncline = -1; - linecounter = 0; - } } } } else { diff --git a/disk.cpp b/disk.cpp index 83b42930..f862e6c2 100644 --- a/disk.cpp +++ b/disk.cpp @@ -18,6 +18,8 @@ int disk_debug_logging = 0; int disk_debug_mode = 0; int disk_debug_track = -1; +#define MFM_VALIDATOR 0 + #include "uae.h" #include "options.h" #include "memory.h" @@ -1305,7 +1307,7 @@ static void mfmcode (uae_u16 * mfm, int words) { uae_u32 lastword = 0; while (words--) { - uae_u32 v = *mfm; + uae_u32 v = (*mfm) & 0x55555555; uae_u32 lv = (lastword << 16) | v; uae_u32 nlv = 0x55555555 & ~lv; uae_u32 mfmbits = (nlv << 1) & (nlv >> 1); @@ -1418,6 +1420,7 @@ static void decode_amigados (drive *drv) int dstmfmoffset = 0; uae_u16 *dstmfmbuf = drv->bigmfmbuf; int len = drv->num_secs * 544 + FLOPPY_GAP_LEN; + int prevbit; trackid *ti = drv->trackdata + tr; memset (dstmfmbuf, 0xaa, len * 2); @@ -1425,9 +1428,10 @@ static void decode_amigados (drive *drv) drv->skipoffset = (FLOPPY_GAP_LEN * 8) / 3 * 2; drv->tracklen = len * 2 * 8; + prevbit = 0; for (sec = 0; sec < drv->num_secs; sec++) { uae_u8 secbuf[544]; - uae_u16 mfmbuf[544]; + uae_u16 mfmbuf[544 + 1]; int i; uae_u32 deven, dodd; uae_u32 hck = 0, dck = 0; @@ -1444,7 +1448,8 @@ static void decode_amigados (drive *drv) read_floppy_data (drv->diskfile, ti, sec * 512, &secbuf[32], 512); - mfmbuf[0] = mfmbuf[1] = 0xaaaa; + mfmbuf[0] = prevbit ? 0x2aaa : 0xaaaa; + mfmbuf[1] = 0xaaaa; mfmbuf[2] = mfmbuf[3] = 0x4489; deven = ((secbuf[4] << 24) | (secbuf[5] << 16) @@ -1491,12 +1496,18 @@ static void decode_amigados (drive *drv) mfmbuf[29] = dodd; mfmbuf[30] = deven >> 16; mfmbuf[31] = deven; - mfmcode (mfmbuf + 4, 544 - 4); + + mfmbuf[544] = 0; + + mfmcode (mfmbuf + 4, 544 - 4 + 1); for (i = 0; i < 544; i++) { dstmfmbuf[dstmfmoffset % len] = mfmbuf[i]; dstmfmoffset++; } + prevbit = mfmbuf[i - 1] & 1; + // so that final word has correct MFM encoding + dstmfmbuf[dstmfmoffset % len] = mfmbuf[i]; } if (disk_debug_logging > 0) @@ -1728,6 +1739,26 @@ static uae_u32 getmfmlong (uae_u16 *mbuf, int shift) return ((getmfmword (mbuf, shift) << 16) | getmfmword (mbuf + 1, shift)) & MFMMASK; } +#if MFM_VALIDATOR +static void check_valid_mfm (uae_u16 *mbuf, int words, int sector) +{ + int prevbit = 0; + for (int i = 0; i < words * 8; i++) { + int wordoffset = i / 8; + uae_u16 w = mbuf[wordoffset]; + uae_u16 wp = mbuf[wordoffset - 1]; + int bitoffset = (7 - (i & 7)) * 2; + int clockbit = w & (1 << (bitoffset + 1)); + int databit = w & (1 << (bitoffset + 0)); + + if ((clockbit && databit) || (clockbit && !databit && prevbit) || (!clockbit && !databit && !prevbit)) { + write_log (L"illegal mfm sector %d data %04x %04x, bit %d:%d\n", sector, wp, w, wordoffset, bitoffset); + } + prevbit = databit; + } +} +#endif + static int decode_buffer (uae_u16 *mbuf, int cyl, int drvsec, int ddhd, int filetype, int *drvsecp, int *sectable, int checkmode) { int i, secwritten = 0; @@ -1773,6 +1804,9 @@ static int decode_buffer (uae_u16 *mbuf, int cyl, int drvsec, int ddhd, int file return 2; continue; } +#if MFM_VALIDATOR + check_valid_mfm (mbuf - 4, 544 - 4 + 1, trackoffs); +#endif chksum = odd ^ even; for (i = 0; i < 4; i++) { odd = getmfmlong (mbuf, shift); @@ -1791,12 +1825,18 @@ static int decode_buffer (uae_u16 *mbuf, int cyl, int drvsec, int ddhd, int file odd = getmfmlong (mbuf, shift); even = getmfmlong (mbuf + 2, shift); mbuf += 4; - if (((odd << 1) | even) != chksum || ((id & 0x00ff0000) >> 16) != cyl * 2 + side) { + if (((odd << 1) | even) != chksum) { write_log (_T("Disk decode: checksum error on sector %d header\n"), trackoffs); if (filetype == ADF_EXT2) return 3; continue; } + if (((id & 0x00ff0000) >> 16) != cyl * 2 + side) { + write_log (_T("Disk decode: mismatched track (%d <> %d) on sector %d header\n"), (id & 0x00ff0000) >> 16, cyl * 2 + side, trackoffs); + if (filetype == ADF_EXT2) + return 3; + continue; + } odd = getmfmlong (mbuf, shift); even = getmfmlong (mbuf + 2, shift); mbuf += 4; @@ -1820,6 +1860,7 @@ static int decode_buffer (uae_u16 *mbuf, int cyl, int drvsec, int ddhd, int file continue; } mbuf += 256; + //write_log (_T("Sector %d ok\n"), trackoffs); sectable[trackoffs] = 1; secwritten++; memcpy (writebuffer + trackoffs * 512, secbuf + 32, 512); @@ -2004,9 +2045,10 @@ static void drive_write_data (drive * drv) if (!longwritemode) ret = drive_write_adf_amigados (drv); if (ret) { + activate_debugger (); write_log (_T("not an amigados track %d (error %d), writing as raw track\n"), drv->cyl * 2 + side, ret); - drive_write_ext2 (drv->bigmfmbuf, drv->diskfile, &drv->trackdata[drv->cyl * 2 + side], - longwritemode ? dsklength2 * 8 : drv->tracklen); +// drive_write_ext2 (drv->bigmfmbuf, drv->diskfile, &drv->trackdata[drv->cyl * 2 + side], +// longwritemode ? dsklength2 * 8 : drv->tracklen); } return; case ADF_IPF: diff --git a/events.cpp b/events.cpp index 696779d0..d4fe194e 100644 --- a/events.cpp +++ b/events.cpp @@ -15,7 +15,7 @@ #include "events.h" unsigned long int event_cycles, nextevent, currcycle; -int is_syncline; +int is_syncline, is_syncline_end; long cycles_to_next_event; long max_cycles_to_next_event; long cycles_to_hsync_event; @@ -50,12 +50,21 @@ void do_cycles_slow (unsigned long cycles_to_add) int i; /* Keep only CPU emulation running while waiting for sync point. */ - if (is_syncline) { + 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; diff --git a/include/events.h b/include/events.h index 0cf4b1a7..333fe133 100644 --- a/include/events.h +++ b/include/events.h @@ -32,7 +32,7 @@ extern void do_cycles_fast (unsigned long cycles_to_add); extern int is_cycle_ce (void); extern unsigned long currcycle, nextevent; -extern int is_syncline; +extern int is_syncline, is_syncline_end; typedef void (*evfunc)(void); typedef void (*evfunc2)(uae_u32); diff --git a/od-win32/cloanto/RetroPlatformIPC.h b/od-win32/cloanto/RetroPlatformIPC.h index 31fad917..0fd25571 100644 --- a/od-win32/cloanto/RetroPlatformIPC.h +++ b/od-win32/cloanto/RetroPlatformIPC.h @@ -8,7 +8,7 @@ : version 2.0 as published by Mozilla Corporation. Authors : os, mcb Created : 2007-08-27 13:55:49 - Updated : 2012-04-20 14:49:00 + Updated : 2012-04-23 12:41:00 Comment : RetroPlatform Player interprocess communication include file *****************************************************************************/ @@ -55,6 +55,7 @@ #define RP_IPC_TO_HOST_INPUTDEVICE (WM_APP + 26) // introduced in RetroPlatform API 3.0 #define RP_IPC_TO_HOST_DEVICECONTENT (WM_APP + 27) // extended in RetroPlatform API 3.0 + // **************************************************************************** // Host-to-Guest Messages // **************************************************************************** @@ -91,7 +92,7 @@ #define RP_FEATURE_FULLSCREEN 0x00000020 // fullscreen display is available #define RP_FEATURE_SCREENCAPTURE 0x00000040 // screen capture functionality is available (see RP_IPC_TO_GUEST_SCREENCAPTURE message) #define RP_FEATURE_PAUSE 0x00000080 // pause functionality is available (see RP_IPC_TO_GUEST_PAUSE message) -#define RP_FEATURE_TURBO 0x00000100 // turbo mode functionality is available (see RP_IPC_TO_GUEST_TURBO message) +#define RP_FEATURE_TURBO_CPU 0x00000100 // turbo CPU functionality is available (see RP_IPC_TO_GUEST_TURBO message) #define RP_FEATURE_VOLUME 0x00000200 // volume adjustment is possible (see RP_IPC_TO_GUEST_VOLUME message) #define RP_FEATURE_STATE 0x00000400 // loading and saving of emulation state is supported (see RP_IPC_TO_GUEST_SAVESTATE/RP_IPC_TO_GUEST_LOADSTATE message) #define RP_FEATURE_SCANLINES 0x00000800 // scan lines video effect is available @@ -106,6 +107,8 @@ #define RP_FEATURE_INPUTDEVICE_ANALOGSTICK 0x00100000 // supports emulation of analog joystick #define RP_FEATURE_INPUTDEVICE_LIGHTPEN 0x00200000 // supports emulation of light pen #define RP_FEATURE_INPUTDEVICE_TABLET 0x00400000 // supports emulation of pen tablet +#define RP_FEATURE_TURBO_FLOPPY 0x00800000 // turbo floppy functionality is available (see RP_IPC_TO_GUEST_TURBO message) +#define RP_FEATURE_TURBO_TAPE 0x01000000 // turbo tape functionality is available (see RP_IPC_TO_GUEST_TURBO message) typedef struct RPScreenMode @@ -475,6 +478,7 @@ typedef struct RPDeviceContent_Legacy #define RPIPCHM_QUERYSCREENMODE RP_IPC_TO_GUEST_QUERYSCREENMODE #define RPIPCHM_GUESTAPIVERSION RP_IPC_TO_GUEST_GUESTAPIVERSION #define RPIPCHM_DEVICECONTENT RP_IPC_TO_GUEST_DEVICECONTENT +#define RP_FEATURE_TURBO RP_FEATURE_TURBO_CPU // End of Legacy Compatibility #endif #endif // __CLOANTO_RETROPLATFORMIPC_H__ diff --git a/od-win32/rp.cpp b/od-win32/rp.cpp index 660e8de5..bbf6909b 100644 --- a/od-win32/rp.cpp +++ b/od-win32/rp.cpp @@ -1118,7 +1118,7 @@ static void sendfeatures (void) DWORD feat; feat = RP_FEATURE_POWERLED | RP_FEATURE_SCREEN1X | RP_FEATURE_FULLSCREEN; - feat |= RP_FEATURE_PAUSE | RP_FEATURE_TURBO | RP_FEATURE_VOLUME | RP_FEATURE_SCREENCAPTURE; + feat |= RP_FEATURE_PAUSE | RP_FEATURE_TURBO_CPU | RP_FEATURE_TURBO_FLOPPY | RP_FEATURE_VOLUME | RP_FEATURE_SCREENCAPTURE; feat |= RP_FEATURE_STATE | RP_FEATURE_SCANLINES | RP_FEATURE_DEVICEREADWRITE; feat |= RP_FEATURE_SCALING_SUBPIXEL | RP_FEATURE_SCALING_STRETCH; if (!WIN32GFX_IsPicassoScreen ()) diff --git a/od-win32/sounddep/sound.cpp b/od-win32/sounddep/sound.cpp index 146aca3b..0ba617e2 100644 --- a/od-win32/sounddep/sound.cpp +++ b/od-win32/sounddep/sound.cpp @@ -131,7 +131,7 @@ struct sound_dp #define ADJUST_SIZE 20 #define EXP 1.9 -#define ADJUST_VSSIZE 10 +#define ADJUST_VSSIZE 12 #define EXPVS 1.6 int sound_debug = 0; @@ -272,9 +272,9 @@ static void docorrection (struct sound_dp *s, int sndbuf, double sync, int granu static double sync_sound (double m) { double skipmode; - if (0 && isvsync ()) { + if (isvsync ()) { - skipmode = pow (m < 0 ? -m : m, EXPVS) / 9; + skipmode = pow (m < 0 ? -m : m, EXPVS) / 2; if (m < 0) skipmode = -skipmode; if (skipmode < -ADJUST_VSSIZE) diff --git a/od-win32/win32.cpp b/od-win32/win32.cpp index 18ff9b5e..d4501178 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 = 8000 * CYCLE_UNIT; +int pissoff_value = 20000 * CYCLE_UNIT; unsigned int fpucontrol; int extraframewait = 0; diff --git a/od-win32/win32.h b/od-win32/win32.h index 6f353922..78eec3ee 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 10") -#define WINUAEDATE MAKEBD(2012, 4, 23) +#define WINUAEBETA _T("Beta 11") +#define WINUAEDATE MAKEBD(2012, 4, 27) #define WINUAEEXTRA _T("") //#define WINUAEEXTRA _T("AmiKit Preview") #define WINUAEREV _T("") diff --git a/od-win32/win32gfx.cpp b/od-win32/win32gfx.cpp index 2dd65ee4..57dfec44 100644 --- a/od-win32/win32gfx.cpp +++ b/od-win32/win32gfx.cpp @@ -2412,16 +2412,31 @@ static bool getvblankpos (int *vp) return true; } -static bool waitvblankstate (bool state, int *maxvpos) +static bool getvblankpos2 (int *vp, int *flags) +{ + if (!getvblankpos (vp)) + return false; + if (*vp > 100 && flags) { + if ((*vp) & 1) + *flags |= 2; + else + *flags |= 1; + } + return true; +} + +static bool waitvblankstate (bool state, int *maxvpos, int *flags) { int vp; + if (flags) + *flags = 0; for (;;) { int omax = maxscanline; - if (!getvblankpos (&vp)) + if (!getvblankpos2 (&vp, flags)) return false; while (omax != maxscanline) { omax = maxscanline; - if (!getvblankpos (&vp)) + if (!getvblankpos2 (&vp, flags)) return false; } if (maxvpos) @@ -2699,7 +2714,7 @@ bool vsync_busywait_do (int *freetime, bool lace, bool oddeven) ti = t - prevtime; if (ti > 2 * vblankbasefull || ti < -2 * vblankbasefull) { changevblankthreadmode_fast (VBLANKTH_ACTIVE_WAIT); - waitvblankstate (false, NULL); + waitvblankstate (false, NULL, NULL); vblank_prev_time = t; thread_vblank_time = t; frame_missed++; @@ -2851,22 +2866,23 @@ double vblank_calibrate (double approx_vblank, bool waitonly) cnt = total; for (cnt = 0; cnt < total; cnt++) { int maxvpos1, maxvpos2; - if (!waitvblankstate (true, NULL)) + int flags1, flags2; + if (!waitvblankstate (true, NULL, NULL)) goto fail; - if (!waitvblankstate (false, NULL)) + if (!waitvblankstate (false, NULL, NULL)) goto fail; - if (!waitvblankstate (true, NULL)) + if (!waitvblankstate (true, NULL, NULL)) goto fail; t1 = read_processor_time (); - if (!waitvblankstate (false, NULL)) + if (!waitvblankstate (false, NULL, NULL)) goto fail; maxscanline = 0; - if (!waitvblankstate (true, &maxvpos1)) + if (!waitvblankstate (true, &maxvpos1, &flags1)) goto fail; - if (!waitvblankstate (false, NULL)) + if (!waitvblankstate (false, NULL, NULL)) goto fail; maxscanline = 0; - if (!waitvblankstate (true, &maxvpos2)) + if (!waitvblankstate (true, &maxvpos2, &flags2)) goto fail; t2 = read_processor_time (); maxvpos = maxvpos1 > maxvpos2 ? maxvpos1 : maxvpos2; @@ -2885,8 +2901,9 @@ double vblank_calibrate (double approx_vblank, bool waitonly) break; } tsum += tval; - if (abs (maxvpos1 - maxvpos2) == 1) + if ((flags1 > 0 && flags1 < 3) && (flags2 > 0 && flags2 < 3) && (flags1 != flags2)) { lace = true; + } } if (cnt >= total) break; diff --git a/od-win32/winuaechangelog.txt b/od-win32/winuaechangelog.txt index 1f6afb3b..573f34c0 100644 --- a/od-win32/winuaechangelog.txt +++ b/od-win32/winuaechangelog.txt @@ -2,6 +2,14 @@ - restore only single input target to default. - hdd from command line +Beta 11: + +- Adjusted Fastest Possible timing a bit more.. +- Better PC interlace screen mode detection. +- Fixed invalid MFM encoding when converting standard adf unencoded data to MFM encoding. (Few incorrect MFM clock bits) Another + "no one cares" fix (since the beginning, does not affect adf data quality), noticed when testing m68k AROS trackdisk.device write support. +- Vsync mode sound sync shouldn't be that aggressive. (b8) + Beta 10: - Partial rewrite of fastest possible CPU low latency vsync detection code. Should fix jitter caused by frame not always