From d8b928178cc74f462014432b470daa3c57ceaac7 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Wed, 21 May 2014 17:43:19 +0300 Subject: [PATCH] 2810b2 --- cia.cpp | 68 ++++++++++++++++++++++++------------ debug.cpp | 6 ++-- disk.cpp | 62 ++++++++++++++++---------------- drawing.cpp | 19 ++++++++-- od-win32/win32.cpp | 11 ++---- od-win32/win32.h | 4 +-- od-win32/win32gui.cpp | 12 +++---- od-win32/winuaechangelog.txt | 21 +++++++++++ 8 files changed, 129 insertions(+), 74 deletions(-) diff --git a/cia.cpp b/cia.cpp index 6c55a595..2fbf5c39 100644 --- a/cia.cpp +++ b/cia.cpp @@ -105,39 +105,47 @@ static void setclr (unsigned int *p, unsigned int val) } } +/* delay interrupt after current CIA register access if + * interrupt would have triggered mid access + */ static int cia_interrupt_disabled; - -static bool access_last_eclock(void) -{ - if (!currprefs.cpu_cycle_exact) - return false; - return true; -} +static int cia_interrupt_delay; static void ICR (uae_u32 data) { INTREQ_0 (0x8000 | data); } + static void ICRA (uae_u32 data) { - if (cia_interrupt_disabled & 1) { - event2_newevent_xx (-1, 4 * CYCLE_UNIT, data, ICRA); + ciaaicr |= 0x40; +#if 1 + if (currprefs.cpu_cycle_exact && !(ciaaicr & 0x20) && (cia_interrupt_disabled & 1)) { + cia_interrupt_delay |= 1; +#if CIAB_DEBUG_IRQ + write_log(_T("ciab interrupt disabled ICR=%02X PC=%x\n"), ciabicr, M68K_GETPC); +#endif return; } - ICR (data); - ciaaicr |= 0x40; +#endif + ciaaicr |= 0x20; + ICR (0x0008); } + static void ICRB (uae_u32 data) { - if (cia_interrupt_disabled & 2) { + ciabicr |= 0x40; +#if 1 + if (currprefs.cpu_cycle_exact && !(ciabicr & 0x20) && (cia_interrupt_disabled & 2)) { + cia_interrupt_delay |= 2; #if CIAB_DEBUG_IRQ write_log(_T("ciab interrupt disabled ICR=%02X PC=%x\n"), ciabicr, M68K_GETPC); #endif - event2_newevent_xx (-1, 4 * CYCLE_UNIT, data, ICRB); return; } - ICR (data); - ciabicr |= 0x40; +#endif + ciabicr |= 0x20; + ICR (0x2000); } static void RethinkICRA (void) @@ -149,7 +157,7 @@ static void RethinkICRA (void) if (!(ciaaicr & 0x80)) { ciaaicr |= 0x80; if (currprefs.cpu_cycle_exact) { - event2_newevent_xx (-1, DIV10 + 2 * CYCLE_UNIT + CYCLE_UNIT / 2, 0x0008, ICRA); + event2_newevent_xx (-1, DIV10 + 2 * CYCLE_UNIT + CYCLE_UNIT / 2, 0, ICRA); } else { ICRA (0x0008); } @@ -166,9 +174,9 @@ static void RethinkICRB (void) if (!(ciabicr & 0x80)) { ciabicr |= 0x80; if (currprefs.cpu_cycle_exact) { - event2_newevent_xx (-1, DIV10 + 2 * CYCLE_UNIT + CYCLE_UNIT / 2, 0x2000, ICRB); + event2_newevent_xx (-1, DIV10 + 2 * CYCLE_UNIT + CYCLE_UNIT / 2, 0, ICRB); } else { - ICRB (0x2000); + ICRB (0); } } } @@ -177,9 +185,9 @@ static void RethinkICRB (void) void rethink_cias (void) { if (ciaaicr & 0x40) - ICRA (0x0008); + ICRA (0); if (ciabicr & 0x40) - ICRB (0x2000); + ICRB (0); } /* Figure out how many CIA timer cycles have passed for each timer since the @@ -1029,7 +1037,7 @@ static uae_u8 ReadCIAA (unsigned int addr) #endif return ciaasdr; case 13: - tmp = ciaaicr & ~0x40; + tmp = ciaaicr & ~(0x40 | 0x20); ciaaicr = 0; return tmp; case 14: @@ -1151,7 +1159,7 @@ static uae_u8 ReadCIAB (unsigned int addr) if (ciabicr & (0x80 | 0x40)) write_log (_T("CIAB IRQ cleared PC=%x\n"), M68K_GETPC); #endif - tmp = ciabicr & ~0x40; + tmp = ciabicr & ~(0x40 | 0x20); ciabicr = 0; return tmp; case 14: @@ -1645,8 +1653,24 @@ static void cia_wait_post (int cianummask, uae_u32 value) do_cycles (c); if (currprefs.cpu_cycle_exact) { cia_interrupt_disabled &= ~cianummask; + if ((cia_interrupt_delay & cianummask) & 1) { + cia_interrupt_delay &= ~1; + ICR(0x0008); + } + if ((cia_interrupt_delay & cianummask) & 2) { + cia_interrupt_delay &= ~2; + ICR(0x2000); + } } } + if (!currprefs.cpu_cycle_exact && cia_interrupt_delay) { + int v = cia_interrupt_delay; + cia_interrupt_delay = 0; + if (v & 1) + ICR(0x0008); + if (v & 2) + ICR(0x2000); + } } static bool iscia(uaecptr addr) diff --git a/debug.cpp b/debug.cpp index dd3d89a3..71222109 100644 --- a/debug.cpp +++ b/debug.cpp @@ -1095,6 +1095,7 @@ void debug_draw_cycles (uae_u8 *buf, int bpp, int line, int width, int height, u putpixel (buf, bpp, dx + 3, 0); } +#define HEATMAP_COUNT 50 static struct memory_heatmap *heatmap; struct memory_heatmap { @@ -1108,11 +1109,10 @@ static void memwatch_heatmap (uaecptr addr, int rwi, int size) static void record_dma_heatmap (uaecptr addr, int type) { - if (currprefs.address_space_24 || !heatmap) + if (addr >= 0x01000000 || !heatmap) return; struct memory_heatmap *hp = &heatmap[addr / 2]; - if (hp->type != type) - hp->cnt = 0; + hp->cnt = HEATMAP_COUNT; hp->type = type; } diff --git a/disk.cpp b/disk.cpp index ac01d7c3..f9cf51b6 100644 --- a/disk.cpp +++ b/disk.cpp @@ -99,8 +99,8 @@ static uae_u8 writebuffer[544 * MAX_SECTORS]; #define DISK_WORDSYNC 2 #define DISK_REVOLUTION 4 /* 8,16,32,64 */ -#define DSKREADY_UP_TIME 20 -#define DSKREADY_DOWN_TIME 50 +#define DSKREADY_UP_TIME 18 +#define DSKREADY_DOWN_TIME 45 #define DSKDMA_OFF 0 #define DSKDMA_INIT 1 @@ -985,7 +985,7 @@ static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const TCHAR gui_disk_image_change (dnum, fname, drv->wrprot); if (!drv->motoroff) { - drv->dskready_up_time = DSKREADY_UP_TIME; + drv->dskready_up_time = DSKREADY_UP_TIME * 312 + (uaerand() & 511); drv->dskready_down_time = 0; } @@ -1295,8 +1295,7 @@ static void drive_step (drive * drv, int step_direction) if (!drive_empty (drv)) drv->dskchange = 0; if (drv->steplimit && get_cycles() - drv->steplimitcycle < MIN_STEPLIMIT_CYCLE) { - if (disk_debug_logging > 1) - write_log (_T(" step ignored drive %d, %d\n"), + write_log (_T(" step ignored drive %d, %d\n"), drv - floppy, (get_cycles() - drv->steplimitcycle) / CYCLE_UNIT); return; } @@ -1370,7 +1369,7 @@ static void motordelay_func (uae_u32 v) static void drive_motor (drive * drv, bool off) { if (drv->motoroff && !off) { - drv->dskready_up_time = DSKREADY_UP_TIME; + drv->dskready_up_time = DSKREADY_UP_TIME * 312 + (uaerand() & 511); rand_shifter (drv); #ifdef DRIVESOUND if (isfloppysound (drv)) @@ -1381,7 +1380,7 @@ static void drive_motor (drive * drv, bool off) } if (!drv->motoroff && off) { drv->drive_id_scnt = 0; /* Reset id shift reg counter */ - drv->dskready_down_time = DSKREADY_DOWN_TIME; + drv->dskready_down_time = DSKREADY_DOWN_TIME * 312 + (uaerand() & 511); #ifdef DRIVESOUND driveclick_motor (drv - floppy, 0); #endif @@ -2501,7 +2500,7 @@ static void setdskchangetime (drive *drv, int dsktime) void DISK_reinsert (int num) { drive_eject (&floppy[num]); - setdskchangetime (&floppy[num], 100); + setdskchangetime (&floppy[num], 2 * 50 * 312); } int disk_setwriteprotect (struct uae_prefs *p, int num, const TCHAR *name, bool writeprotected) @@ -2642,9 +2641,9 @@ static void disk_insert_2 (int num, const TCHAR *name, bool forced, bool forcedw * called from DISK_check_change() after 2 second delay * this makes sure that all programs detect disk change correctly */ - setdskchangetime (drv, 100); + setdskchangetime (drv, 2 * 50 * 312); } else { - setdskchangetime (drv, 1); + setdskchangetime (drv, 1 * 312); } } @@ -2691,24 +2690,6 @@ void DISK_vsync (void) drive *drv = floppy + i; if (drv->dskchange_time == 0 && _tcscmp (currprefs.floppyslots[i].df, changed_prefs.floppyslots[i].df)) disk_insert (i, changed_prefs.floppyslots[i].df, changed_prefs.floppyslots[i].forcedwriteprotect); - if (drv->dskready_down_time > 0) - drv->dskready_down_time--; - /* emulate drive motor turn on time */ - if (drv->dskready_up_time > 0 && !drive_empty (drv)) { - drv->dskready_up_time--; - if (drv->dskready_up_time == 0 && !drv->motoroff) - drv->dskready = true; - } - /* delay until new disk image is inserted */ - if (drv->dskchange_time > 0) { - drv->dskchange_time--; - if (drv->dskchange_time == 0) { - drive_insert (drv, &currprefs, i, drv->newname, false, drv->newnamewriteprotected); - if (disk_debug_logging > 0) - write_log (_T("delayed insert, drive %d, image '%s'\n"), i, drv->newname); - update_drive_gui (i, false); - } - } } } @@ -3332,8 +3313,8 @@ static void disk_doupdate_read (drive * drv, int floppybits) static void disk_dma_debugmsg (void) { - write_log (_T("LEN=%04X (%d) SYNC=%04X PT=%08X ADKCON=%04X PC=%08X\n"), - dsklength, dsklength, (adkcon & 0x400) ? dsksync : 0xffff, dskpt, adkcon, M68K_GETPC); + write_log (_T("LEN=%04X (%d) SYNC=%04X PT=%08X ADKCON=%04X INTREQ=%04X PC=%08X\n"), + dsklength, dsklength, (adkcon & 0x400) ? dsksync : 0xffff, dskpt, adkcon, intreq, M68K_GETPC); } /* this is very unoptimized. DSKBYTR is used very rarely, so it should not matter. */ @@ -3422,6 +3403,27 @@ void DISK_hsync (void) drv->steplimit--; if (drv->revolution_check) drv->revolution_check--; + + if (drv->dskready_down_time > 0) + drv->dskready_down_time--; + /* emulate drive motor turn on time */ + if (drv->dskready_up_time > 0 && !drive_empty (drv)) { + drv->dskready_up_time--; + if (drv->dskready_up_time == 0 && !drv->motoroff) + drv->dskready = true; + } + /* delay until new disk image is inserted */ + if (drv->dskchange_time > 0) { + drv->dskchange_time--; + if (drv->dskchange_time == 0) { + drive_insert (drv, &currprefs, dr, drv->newname, false, drv->newnamewriteprotected); + if (disk_debug_logging > 0) + write_log (_T("delayed insert, drive %d, image '%s'\n"), dr, drv->newname); + update_drive_gui (dr, false); + } + } + + } if (indexdecay) indexdecay--; diff --git a/drawing.cpp b/drawing.cpp index 7e374480..5263a41f 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -1780,6 +1780,13 @@ static void decode_ham (int pix, int stoppos, bool blank) } } +static void decode_ham_border(int pix, int stoppos, bool blank) +{ + int todraw_amiga = res_shift_from_window (stoppos - pix); + while (todraw_amiga-- > 0) + ham_linebuf[ham_decode_pixel++] = 0; +} + static void gen_pfield_tables (void) { int i; @@ -2367,6 +2374,12 @@ static void do_color_changes (line_draw_func worker_border, line_draw_func worke } } + +STATIC_INLINE bool have_color_changes(struct draw_info *di) +{ + return (di->nr_color_changes == 0 || (di->nr_color_changes == 1 && curr_color_changes[di->first_color_change].regno == -1)); +} + enum double_how { dh_buf, dh_line, @@ -2451,13 +2464,13 @@ static void pfield_draw_line (struct vidbuffer *vb, int lineno, int gfx_ypos, in sprites. */ if (dp_for_drawing->ham_seen) { init_ham_decoding (); - if (dip_for_drawing->nr_color_changes == 0) { + if (!have_color_changes(dip_for_drawing)) { /* The easy case: need to do HAM decoding only once for the * full line. */ decode_ham (visible_left_border, visible_right_border, false); } else /* Argh. */ { int ohposblank = hposblank; - do_color_changes (dummy_worker, decode_ham, lineno); + do_color_changes (decode_ham_border, decode_ham, lineno); hposblank = ohposblank; // reset colors to state before above do_color_changes() adjust_drawing_colors (dp_for_drawing->ctable, (dp_for_drawing->ham_seen || bplehb) ? -1 : 0); @@ -2520,7 +2533,7 @@ static void pfield_draw_line (struct vidbuffer *vb, int lineno, int gfx_ypos, in } #endif - if (!dosprites && (dip_for_drawing->nr_color_changes == 0 || (dip_for_drawing->nr_color_changes == 1 && curr_color_changes[dip_for_drawing->first_color_change].regno == -1))) { + if (!dosprites && have_color_changes(dip_for_drawing)) { if (dp_for_drawing->plfleft < -1) { // blanked border line int tmp = hposblank; diff --git a/od-win32/win32.cpp b/od-win32/win32.cpp index 9c734856..1d89fe73 100644 --- a/od-win32/win32.cpp +++ b/od-win32/win32.cpp @@ -1323,15 +1323,10 @@ static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam, int myy = (amigawin_rect.bottom - amigawin_rect.top) / 2; mx = mx - mxx; my = my - myy; - if (abs(mx) < windowmouse_max_w && abs(my) < windowmouse_max_h) { - //write_log (_T("%d:%dx%d\n"), dinput_winmouse(), mx, my); - setmousestate (dinput_winmouse (), 0, mx, 0); - setmousestate (dinput_winmouse (), 1, my, 0); - } else { - ;//write_log (_T("!!! %d:%dx%d\n"), dinput_winmouse(), mx, my); - } + setmousestate (dinput_winmouse (), 0, mx, 0); + setmousestate (dinput_winmouse (), 1, my, 0); } - } else if (isfocus () < 0 && (istablet || currprefs.input_tablet >= TABLET_MOUSEHACK)) { + } else if (isfocus () < 0 && (istablet || currprefs.input_tablet >= TABLET_MOUSEHACK)) { setmousestate (0, 0, mx, 1); setmousestate (0, 1, my, 1); } diff --git a/od-win32/win32.h b/od-win32/win32.h index a0db59d6..749e33d3 100644 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -19,11 +19,11 @@ #define LANG_DLL 1 #if WINUAEPUBLICBETA -#define WINUAEBETA _T("1") +#define WINUAEBETA _T("2") #else #define WINUAEBETA _T("") #endif -#define WINUAEDATE MAKEBD(2014, 5, 14) +#define WINUAEDATE MAKEBD(2014, 5, 21) #define WINUAEEXTRA _T("") //#define WINUAEEXTRA _T("AmiKit Preview") //#define WINUAEEXTRA _T("Amiga Forever Edition") diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index fffaf7e2..d9aad4cf 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -11542,25 +11542,25 @@ static INT_PTR CALLBACK FloppyDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARA break; case IDC_EJECT0: case IDC_EJECT0Q: - SetDlgItemText (hDlg, IDC_DF0TEXT, _T("")); - SetDlgItemText (hDlg, IDC_DF0TEXTQ, _T("")); + SendDlgItemMessage (hDlg, IDC_DF0TEXT, CB_SETCURSEL, -1, 0); + SendDlgItemMessage (hDlg, IDC_DF0TEXTQ, CB_SETCURSEL, -1, 0); ejectfloppy (0); addfloppytype (hDlg, 0); break; case IDC_EJECT1: case IDC_EJECT1Q: - SetDlgItemText (hDlg, IDC_DF1TEXT, _T("")); - SetDlgItemText (hDlg, IDC_DF1TEXTQ, _T("")); + SendDlgItemMessage (hDlg, IDC_DF1TEXT, CB_SETCURSEL, -1, 0); + SendDlgItemMessage (hDlg, IDC_DF1TEXTQ, CB_SETCURSEL, -1, 0); ejectfloppy (1); addfloppytype (hDlg, 1); break; case IDC_EJECT2: - SetDlgItemText (hDlg, IDC_DF2TEXT, _T("")); + SendDlgItemMessage (hDlg, IDC_DF2TEXT, CB_SETCURSEL, -1, 0); ejectfloppy (2); addfloppytype (hDlg, 2); break; case IDC_EJECT3: - SetDlgItemText (hDlg, IDC_DF3TEXT, _T("")); + SendDlgItemMessage (hDlg, IDC_DF3TEXT, CB_SETCURSEL, -1, 0); ejectfloppy (3); addfloppytype (hDlg, 3); break; diff --git a/od-win32/winuaechangelog.txt b/od-win32/winuaechangelog.txt index f3bbaa15..740c3776 100644 --- a/od-win32/winuaechangelog.txt +++ b/od-win32/winuaechangelog.txt @@ -9,8 +9,29 @@ 1 -> E (ABC) : 0,1FE,70,70,70,70,.. (C) 1 -> F (ABCD): 0,1FE,70,70,74,70,70,70,74,70,70,70,74,.. (CCCA) +Things that may happen in 2015: + +- Minium Windows version will be Windows 7. +- CPU must be SSE 2 capable. +- DirectDraw support will be removed. +- and more + - restore only single input target to default. +Beta 2: + +- Quickstart GUI disk eject button was unreliable. +- HAM mode right border in some situations (Uridium 2 title screeen in some filter modes), also restored + proper operation (got broken long time ago) of original "fast mode" if HAM scanline does not have any + color register changes. +- CIA update (which I forgot to mention in b1 changelog) improved, was not fully compatible if CPU was faster + than 68000 , do not trigger CIA interrupt while CPU is accessing any CIA register (not 100% confirmed but + seems to be true), this also made b1 CPU mode switching unreliable. +- Reduced diskready (motor rotating at full speed) activation time by small amount, fixes Critical Mass / Parallax. +- Disk inserted (if replacing existing disk) and disk ready bit setting time is now more "random", now delay time + counts scanlines, previously it counted vblanks (=disk was always inserted at vblank) +- Removed 270b16 Windows 8.1 mouse bug workaround, bug seems to be fixed. + Beta 1: - Audio DMA CPU wait hack (that tries to prevent missing samples if program has CPU timed audio DMA wait) -- 2.47.3