From b9981bee8c7ab60cc4ad514c22ab0de99ebe9160 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sun, 2 Nov 2008 14:14:26 +0200 Subject: [PATCH] imported winuaesrc1530b7.zip --- a2091.c | 2 +- cia.c | 111 +++++++++++++++++++---------------- custom.c | 18 +++--- hardfile.c | 40 ++++++++++++- include/cia.h | 4 +- main.c | 2 + memory.c | 12 ++-- od-win32/direct3d.c | 16 ++--- od-win32/picasso96_win.c | 15 +++-- od-win32/win32.h | 4 +- od-win32/win32gfx.c | 2 +- od-win32/win32gui.c | 8 ++- od-win32/winuaechangelog.txt | 18 ++++++ scsi.c | 2 +- 14 files changed, 165 insertions(+), 89 deletions(-) diff --git a/a2091.c b/a2091.c index cf7ce78b..eed6ad59 100755 --- a/a2091.c +++ b/a2091.c @@ -1305,7 +1305,7 @@ void a2091_init (void) roms[2] = 53; roms[3] = 56; roms[4] = -1; - //roms[0] = 56; + roms[0] = 53; rombankswitcher = 0; rombank = 0; diff --git a/cia.c b/cia.c index 98ceaa83..bb8d5100 100755 --- a/cia.c +++ b/cia.c @@ -35,6 +35,7 @@ #include "keyboard.h" #include "uae.h" #include "amax.h" +#include "ersatz.h" //#define CIAA_DEBUG_R //#define CIAA_DEBUG_W @@ -68,10 +69,6 @@ static int div10; static int kbstate, kback, ciaasdr_unread; static unsigned int sleepyhead; -#ifdef TOD_HACK -static int tod_hack, tod_hack_delay; -#endif - static uae_u8 serbits; static int warned = 10; @@ -335,6 +332,54 @@ STATIC_INLINE void ciaa_checkalarm (int inc) } } + +#ifdef TOD_HACK +static uae_u64 tod_hack_tv, tod_hack_tod, tod_hack_tod_last; +static void tod_hack_reset (void) +{ + struct timeval tv; + gettimeofday (&tv, NULL); + tod_hack_tv = (uae_u64)tv.tv_sec * 1000000 + tv.tv_usec; + tod_hack_tod = ciaatod; + tod_hack_tod_last = tod_hack_tod; +} +#endif + +static void do_tod_hack (int dotod) +{ + struct timeval tv; + static int oldrate; + uae_u64 t, rate; + int docount = 0; + + if (currprefs.cs_ciaatod == 0) + rate = vblank_hz; + else if (currprefs.cs_ciaatod == 1) + rate = 50; + else + rate = 60; + if (rate != oldrate || ciaatod != tod_hack_tod_last) { + tod_hack_reset (); + oldrate = rate; + docount = 1; + write_log ("TOD HACK reset %d\n", rate); + } + if (!dotod && currprefs.cs_ciaatod == 0) + return; + gettimeofday (&tv, NULL); + t = (uae_u64)tv.tv_sec * 1000000 + tv.tv_usec; + if (t - tod_hack_tv >= 1000000 / rate) { + tod_hack_tv += 1000000 / rate; + docount = 1; + } + if (docount) { + ciaatod++; + ciaatod &= 0x00ffffff; + tod_hack_tod_last = ciaatod; + ciaa_checkalarm (0); + } +} + static int resetwarning_phase, resetwarning_timer; static void setcode (uae_u8 keycode) @@ -400,14 +445,17 @@ static void resetwarning_check (void) } } -void CIA_hsync_handler (void) +void CIA_hsync_handler (int dotod) { - if (ciabtodon) { + if (ciabtodon && dotod) { ciabtod++; ciabtod &= 0xFFFFFF; ciab_checkalarm (1); } + if (currprefs.tod_hack && ciaatodon) + do_tod_hack (dotod); + if (resetwarning_phase) { resetwarning_check (); while (keys_available ()) @@ -456,23 +504,11 @@ void CIA_hsync_handler (void) if (ciaasdr_unread == 3) ciaaicr |= 8; if (ciaasdr_unread < 3) - ciaasdr_unread = 0; /* give up on this key event after unread for a long time */ + ciaasdr_unread = 0; /* give up on this key event after unread for a long time */ } } } -#ifdef TOD_HACK -static void tod_hack_reset (void) -{ - struct timeval tv; - uae_u32 rate = currprefs.ntscmode ? 60 : 50; - gettimeofday (&tv, NULL); - tod_hack = (uae_u32)(((uae_u64)tv.tv_sec) * rate + tv.tv_usec / (1000000 / rate)); - tod_hack -= ciaatod; - tod_hack_delay = 10 * 50; -} -#endif - static int led_times; static unsigned long led_on, led_cycle; @@ -507,36 +543,14 @@ static void led_vsync (void) led_cycle = get_cycles (); } -void CIA_vsync_handler (void) +void CIA_vsync_handler (int dotod) { led_vsync (); #ifdef TOD_HACK - if (currprefs.tod_hack && ciaatodon) { - struct timeval tv; - uae_u32 t, nt, rate = currprefs.ntscmode ? 60 : 50; - - if (tod_hack_delay > 0) { - tod_hack_delay--; - if (tod_hack_delay == 0) { - tod_hack_reset (); - tod_hack_delay = 0; - write_log ("TOD_HACK re-initialized CIATOD=%06X\n", ciaatod); - } - } - if (tod_hack_delay == 0) { - gettimeofday (&tv, NULL); - t = (uae_u32)(((uae_u64)tv.tv_sec) * rate + tv.tv_usec / (1000000 / rate)); - nt = t - tod_hack; - if ((nt < ciaatod && ciaatod - nt < 10) || nt == ciaatod) - return; /* try not to count backwards */ - ciaatod = nt; - ciaatod &= 0xffffff; - ciaa_checkalarm (0); - return; - } - } + if (currprefs.tod_hack) + return; #endif - if (ciaatodon) { + if (ciaatodon && dotod) { ciaatod++; ciaatod &= 0xFFFFFF; ciaa_checkalarm (1); @@ -884,10 +898,6 @@ static void WriteCIAA (uae_u16 addr,uae_u8 val) ciaatod = (ciaatod & ~0xff) | val; ciaatodon = 1; ciaa_checkalarm (0); -#ifdef TOD_HACK - if (currprefs.tod_hack) - tod_hack_reset (); -#endif } break; case 9: @@ -1090,7 +1100,8 @@ void CIA_inprec_prepare (void) void CIA_reset (void) { #ifdef TOD_HACK - tod_hack = 0; + tod_hack_tv = 0; + tod_hack_tod = 0; if (currprefs.tod_hack) tod_hack_reset (); #endif diff --git a/custom.c b/custom.c index 02fd41bd..b658bea5 100755 --- a/custom.c +++ b/custom.c @@ -2503,8 +2503,12 @@ void init_hz (void) hzc = 1; if (beamcon0 & 0x80) hack_vpos = -1; + if (beamcon0 != new_beamcon0) + write_log ("BEAMCON0 %04x -> %04x\n", beamcon0, new_beamcon0); beamcon0 = new_beamcon0; - isntsc = beamcon0 & 0x20 ? 0 : 1; + isntsc = (beamcon0 & 0x20) ? 0 : 1; + if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS)) + isntsc = currprefs.ntscmode ? 1 : 0; if (hack_vpos > 0) { if (maxvpos == hack_vpos) return; @@ -3027,7 +3031,7 @@ static void BEAMCON0 (uae_u16 v) if (v != new_beamcon0) { new_beamcon0 = v; if (v & ~0x20) - write_log ("warning: %04X written to BEAMCON0\n", v); + write_log ("warning: %04X written to BEAMCON0 PC=%08X\n", v, M68K_GETPC); } } } @@ -4609,9 +4613,9 @@ static void copper_check (int n) } } -static void CIA_vsync_prehandler (void) +static void CIA_vsync_prehandler (int dotod) { - CIA_vsync_handler (); + CIA_vsync_handler (dotod); #if 0 if (input_recording > 0) { inprec_rstart(INPREC_CIAVSYNC); @@ -4702,12 +4706,12 @@ static void hsync_handler (void) eventtab[ev_hsync].evtime += get_cycles () - eventtab[ev_hsync].oldcycles; eventtab[ev_hsync].oldcycles = get_cycles (); - CIA_hsync_handler (); + CIA_hsync_handler (!(bplcon0 & 2) || ((bplcon0 & 2) && currprefs.genlock)); if (currprefs.cs_ciaatod > 0) { static int cia_hsync; cia_hsync -= 256; if (cia_hsync <= 0) { - CIA_vsync_prehandler (); + CIA_vsync_prehandler (1); cia_hsync += ((MAXVPOS_PAL * MAXHPOS_PAL * 50 * 256) / (maxhpos * (currprefs.cs_ciaatod == 2 ? 60 : 50))); } } @@ -4767,7 +4771,7 @@ static void hsync_handler (void) #endif vsync_counter++; if (currprefs.cs_ciaatod == 0) - CIA_vsync_prehandler (); + CIA_vsync_prehandler (!(bplcon0 & 2) || ((bplcon0 & 2) && currprefs.genlock)); } DISK_hsync (maxhpos); diff --git a/hardfile.c b/hardfile.c index cb22d0b9..80d0a2b5 100755 --- a/hardfile.c +++ b/hardfile.c @@ -39,6 +39,8 @@ #define hf_log write_log #undef hf_log2 #define hf_log2 write_log +#undef hf_log3 +#define hf_log3 write_log #undef scsi_log #define scsi_log write_log #endif @@ -559,7 +561,7 @@ int scsi_emulate(struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, uae_u8 offset *= hfd->blocksize; len = rl (cmdbuf + 7 - 2) & 0xffff; len *= hfd->blocksize; - if (checkbounds(hfd, offset, len)) + if (checkbounds (hfd, offset, len)) scsi_len = (uae_u32)cmd_readx (hfd, scsi_data, offset, len); break; case 0x2a: /* WRITE (10) */ @@ -569,9 +571,35 @@ int scsi_emulate(struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, uae_u8 offset *= hfd->blocksize; len = rl (cmdbuf + 7 - 2) & 0xffff; len *= hfd->blocksize; - if (checkbounds(hfd, offset, len)) + if (checkbounds (hfd, offset, len)) scsi_len = (uae_u32)cmd_writex (hfd, scsi_data, offset, len); break; +#if 0 + case 0x2f: /* VERIFY */ + { + int bytchk = cmdbuf[1] & 2; + if (nodisk (hfd)) + goto nodisk; + offset = rl (cmdbuf + 2); + offset *= hfd->blocksize; + len = rl (cmdbuf + 7 - 2) & 0xffff; + len *= hfd->blocksize; + if (checkbounds (hfd, offset, len)) { + uae_u8 *vb = xmalloc (hfd->blocksize); + while (len > 0) { + int len = cmd_readx (hfd, vb, offset, hfd->blocksize); + if (bytchk) { + if (memcmp (vb, scsi_data, hfd->blocksize)) + goto miscompare; + scsi_data += hfd->blocksize; + } + offset += hfd->blocksize; + } + xfree (vb); + } + } + break; +#endif case 0x35: /* SYNCRONIZE CACHE (10) */ if (nodisk (hfd)) goto nodisk; @@ -624,6 +652,14 @@ err: s[12] = 0x24; /* ILLEGAL FIELD IN CDB */ ls = 12; break; +miscompare: + lr = -1; + status = 2; /* CHECK CONDITION */ + s[0] = 0x70; + s[2] = 5; /* ILLEGAL REQUEST */ + s[12] = 0x1d; /* MISCOMPARE DURING VERIFY OPERATION */ + ls = 12; + break; } *data_len = scsi_len; *reply_len = lr; diff --git a/include/cia.h b/include/cia.h index dd61df70..b76d5888 100755 --- a/include/cia.h +++ b/include/cia.h @@ -7,8 +7,8 @@ */ extern void CIA_reset (void); -extern void CIA_vsync_handler (void); -extern void CIA_hsync_handler (void); +extern void CIA_vsync_handler (int); +extern void CIA_hsync_handler (int); extern void CIA_handler (void); extern void diskindex_handler (void); diff --git a/main.c b/main.c index 4dafce19..6496946d 100755 --- a/main.c +++ b/main.c @@ -398,6 +398,8 @@ void fixup_prefs (struct uae_prefs *p) #endif if (p->maprom && !p->address_space_24) p->maprom = 0x0f000000; + if (p->tod_hack && p->cs_ciaatod == 0) + p->cs_ciaatod = p->ntscmode ? 2 : 1; target_fixup_options (p); } diff --git a/memory.c b/memory.c index cee76cf7..23d46859 100755 --- a/memory.c +++ b/memory.c @@ -317,23 +317,23 @@ static struct romdata roms[] = { { "Freezer: HRTMon v2.30 (built-in)", 0, 0, 0, 0, "HRTMON\0", 0, 63, 0, 0, ROMTYPE_HRTMON, 0, 1, NULL, 0xffffffff, 0, 0, 0, 0, 0, "HRTMon" }, - { "A590/A2091 SCSI boot ROM", 0, 0, 6, 0, "A590\0A2091\0", 16384, 53, 0, 0, ROMTYPE_A2091BOOT, 0, 0, NULL, + { "A590/A2091 SCSI boot ROM", 6, 0, 6, 0, "A590\0A2091\0", 16384, 53, 0, 0, ROMTYPE_A2091BOOT, 0, 0, NULL, 0x8396cf4e, 0x5E03BC61,0x8C862ABE,0x7BF79723,0xB4EEF4D2,0x1859A0F2 }, ALTROM(53, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, 0xb0b8cf24,0xfcf40175,0x05f4d441,0x814b45d5,0x59c19eab,0x43816b30) ALTROM(53, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, 0x2e77bbff,0x8a098845,0x068f32cf,0xa4d34a27,0x8cd290f6,0x1d35a52c) - { "A590/A2091 SCSI boot ROM", 0, 0, 6, 6, "A590\0A2091\0", 16384, 54, 0, 0, ROMTYPE_A2091BOOT, 0, 0, NULL, + { "A590/A2091 SCSI boot ROM", 6, 6, 6, 6, "A590\0A2091\0", 16384, 54, 0, 0, ROMTYPE_A2091BOOT, 0, 0, NULL, 0x33e00a7a, 0x739BB828,0xE874F064,0x9360F59D,0x26B5ED3F,0xBC99BB66 }, ALTROM(54, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, 0xe536bbb2,0xfd7f8a6d,0xa18c1b02,0xd07eb990,0xc2467a24,0x183ede12) ALTROM(54, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, 0xc0871d25,0xe155f18a,0xbb90cf82,0x0589c15e,0x70559d3b,0x6b391af8) - { "A590/A2091 SCSI boot ROM", 0, 0, 7, 0, "A590\0A2091\0", 16384, 55, 0, 0, ROMTYPE_A2091BOOT, 0, 0, NULL, + { "A590/A2091 SCSI boot ROM", 7, 0, 7, 0, "A590\0A2091\0", 16384, 55, 0, 0, ROMTYPE_A2091BOOT, 0, 0, NULL, 0x714a97a2, 0xE50F01BA,0xF2899892,0x85547863,0x72A82C33,0x3C91276E }, ALTROM(55, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, 0xa9ccffed,0x149f5bd5,0x2e2d2990,0x4e3de483,0xb9ad7724,0x48e9278e) ALTROM(55, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, 0x2942747a,0xdbd7648e,0x79c75333,0x7ff3e4f4,0x91de224b,0xf05e6bb6) - { "A590/A2091 SCSI Guru boot ROM", 0, 0, 6, 14, "A590\0A2091\0", 32768, 56, 0, 0, ROMTYPE_A2091BOOT, 0, 0, NULL, + { "A590/A2091 SCSI Guru boot ROM", 6, 14, 6, 14, "A590\0A2091\0", 32768, 56, 0, 0, ROMTYPE_A2091BOOT, 0, 0, NULL, 0x04e52f93, 0x6DA21B6F,0x5E8F8837,0xD64507CD,0x8A4D5CDC,0xAC4F426B }, - { "A4091 SCSI boot ROM", 0, 0, 40, 9, "A4091\0", 32768, 57, 0, 0, ROMTYPE_A4091BOOT, 0, 0, NULL, + { "A4091 SCSI boot ROM", 40, 9, 40, 9, "A4091\0", 32768, 57, 0, 0, ROMTYPE_A4091BOOT, 0, 0, NULL, 0x00000000, 0, 0, 0, 0, 0 }, - { "A4091 SCSI boot ROM", 0, 0, 40, 13, "A4091\0", 32768, 58, 0, 0, ROMTYPE_A4091BOOT, 0, 0, NULL, + { "A4091 SCSI boot ROM", 40, 13, 40, 13, "A4091\0", 32768, 58, 0, 0, ROMTYPE_A4091BOOT, 0, 0, NULL, 0x54cb9e85, 0x3CE66919,0xF6FD6797,0x4923A12D,0x91B730F1,0xFFB4A7BA }, { "Arcadia OnePlay 2.11", 0, 0, 0, 0, "ARCADIA\0", 0, 49, 0, 0, ROMTYPE_ARCADIABIOS, 0, 0 }, diff --git a/od-win32/direct3d.c b/od-win32/direct3d.c index 00eb0cb4..3a8d5d5e 100755 --- a/od-win32/direct3d.c +++ b/od-win32/direct3d.c @@ -818,8 +818,10 @@ static void createscanlines (int force) osl2 = currprefs.gfx_filter_scanlineratio; sl4 = currprefs.gfx_filter_scanlines * 16 / 100; sl42 = currprefs.gfx_filter_scanlinelevel * 16 / 100; - if (sl4 > 15) sl4 = 15; - if (sl42 > 15) sl42 = 15; + if (sl4 > 15) + sl4 = 15; + if (sl42 > 15) + sl42 = 15; l1 = currprefs.gfx_filter_scanlineratio & 15; l2 = currprefs.gfx_filter_scanlineratio >> 4; @@ -829,11 +831,11 @@ static void createscanlines (int force) return; } sld = (uae_u8*)locked.pBits; - for (y = 0; y < window_h; y++) - memset (sld + y * locked.Pitch, 0, window_w * 2); - for (y = 1; y < window_h; y += l1 + l2) { - for (yy = 0; yy < l2 && y + yy < window_h; yy++) { - for (x = 0; x < window_w; x++) { + for (y = 0; y < required_sl_texture_h; y++) + memset (sld + y * locked.Pitch, 0, required_sl_texture_w * 2); + for (y = 1; y < required_sl_texture_h; y += l1 + l2) { + for (yy = 0; yy < l2 && y + yy < required_sl_texture_h; yy++) { + for (x = 0; x < required_sl_texture_w; x++) { /* 16-bit, A4R4G4B4 */ uae_u8 sll = sl42; p = &sld[(y + yy) * locked.Pitch + (x * 2)]; diff --git a/od-win32/picasso96_win.c b/od-win32/picasso96_win.c index 3e67f122..040ea4b0 100755 --- a/od-win32/picasso96_win.c +++ b/od-win32/picasso96_win.c @@ -130,6 +130,7 @@ static uae_u32 cursorrgb[4], cursorrgbn[4]; static int reloadcursor, cursorvisible, cursordeactivate; static uaecptr boardinfo; static int interrupt_enabled; +int p96vblank; static uaecptr uaegfx_resname, uaegfx_resid, @@ -3272,18 +3273,16 @@ void picasso_handle_hsync (void) void init_hz_p96 (void) { - int rate; - p96syncrate = maxvpos * vblank_hz; if (currprefs.win32_rtgvblankrate < 0) - rate = DirectDraw_CurrentRefreshRate (); + p96vblank = DirectDraw_CurrentRefreshRate (); else if (currprefs.win32_rtgvblankrate == 0) - rate = abs (currprefs.gfx_refreshrate); + p96vblank = vblank_hz; else - rate = currprefs.win32_rtgvblankrate; - if (rate <= 0) - rate = 60; - p96syncrate /= rate; + p96vblank = currprefs.win32_rtgvblankrate; + if (p96vblank <= 0) + p96vblank = 60; + p96syncrate /= p96vblank; } /* NOTE: Watch for those planeptrs of 0x00000000 and 0xFFFFFFFF for all zero / all one bitmaps !!!! */ diff --git a/od-win32/win32.h b/od-win32/win32.h index 0aa29d88..49abe4be 100755 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -17,8 +17,8 @@ #define WINUAEPUBLICBETA 1 -#define WINUAEBETA "6" -#define WINUAEDATE MAKEBD(2008, 10, 26) +#define WINUAEBETA "7" +#define WINUAEDATE MAKEBD(2008, 11, 2) #define WINUAEEXTRA "" #define WINUAEREV "" diff --git a/od-win32/win32gfx.c b/od-win32/win32gfx.c index 3779d9d3..60d18814 100755 --- a/od-win32/win32gfx.c +++ b/od-win32/win32gfx.c @@ -1028,7 +1028,7 @@ int check_prefs_changed_gfx (void) c |= currprefs.gfx_filter_saturation != changed_prefs.gfx_filter_saturation ? (1|8) : 0; c |= currprefs.gfx_filter_gamma != changed_prefs.gfx_filter_gamma ? (1|8) : 0; //c |= currprefs.gfx_filter_ != changed_prefs.gfx_filter_ ? (1|8) : 0; - + c |= currprefs.gfx_resolution != changed_prefs.gfx_resolution ? (2 | 8) : 0; c |= currprefs.gfx_linedbl != changed_prefs.gfx_linedbl ? (2 | 8) : 0; c |= currprefs.gfx_lores_mode != changed_prefs.gfx_lores_mode ? (2 | 8) : 0; diff --git a/od-win32/win32gui.c b/od-win32/win32gui.c index 55a2daf7..1012fa11 100755 --- a/od-win32/win32gui.c +++ b/od-win32/win32gui.c @@ -11825,7 +11825,7 @@ void gui_led (int led, int on) tt = dfx[led - 1]; tt[0] = 0; if (strlen (p + j) > 0) - sprintf (tt, "%s (CRC=%08X)", p + j, gui_data.crc32[led - 1]); + sprintf (tt, "%s [CRC=%08X]", p + j, gui_data.crc32[led - 1]); } else if (led == 0) { pos = 3; ptr = strcpy (drive_text + pos * 16, "Power"); @@ -11836,9 +11836,13 @@ void gui_led (int led, int on) pos = 5; ptr = strcpy (drive_text + pos * 16, "CD"); } else if (led == 7) { + extern int p96vblank; pos = 2; ptr = drive_text + pos * 16; - sprintf (ptr, "FPS: %.1f", (double)(gui_data.fps / 10.0)); + if (picasso_on) + sprintf (ptr, "%d [%.1f]", p96vblank, (double)(gui_data.fps / 10.0)); + else + sprintf (ptr, "FPS: %.1f", (double)(gui_data.fps / 10.0)); if (pause_emulation) strcpy (ptr, "PAUSED"); } else if (led == 8) { diff --git a/od-win32/winuaechangelog.txt b/od-win32/winuaechangelog.txt index 6dc9bfdf..f44a0bb3 100755 --- a/od-win32/winuaechangelog.txt +++ b/od-win32/winuaechangelog.txt @@ -1,4 +1,22 @@ +Beta 7: + +- fixed D3D scanline missing right edge +- OCS NTSC chipset always used PAL rates +- windowed RTG mode FPS counter shows both RTG and chipset refresh + rates " [