From: Toni Wilen Date: Sun, 14 Mar 2010 13:44:14 +0000 (+0200) Subject: 2100b17 X-Git-Tag: 2100~11 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=2ad9ae413b880832802552bc9cc32d8a3085b05c;p=francis%2Fwinuae.git 2100b17 --- diff --git a/audio.cpp b/audio.cpp index 0604c788..518f2399 100644 --- a/audio.cpp +++ b/audio.cpp @@ -1374,7 +1374,6 @@ void set_audio (void) int sep, delay; int ch; - ch = sound_prefs_changed (); if (ch >= 0) close_sound (); diff --git a/cdtv.cpp b/cdtv.cpp index 59a65a82..b76886c6 100644 --- a/cdtv.cpp +++ b/cdtv.cpp @@ -252,6 +252,7 @@ static int play_cdtrack (uae_u8 *p) int index_start = p[2]; int track_end = p[3]; int index_end = p[4]; + int start_found, end_found; uae_u32 start, end; int i, j; @@ -259,18 +260,31 @@ static int play_cdtrack (uae_u8 *p) i -= 2; i /= 11; end = last_cd_position; + start_found = end_found = 0; for (j = 0; j < i; j++) { uae_u8 *s = cdrom_toc + 4 + j * 11; - if (track_start == s[3]) + if (track_start == s[3]) { + start_found++; start = (s[8] << 16) | (s[9] << 8) | s[10]; - if (track_end == s[3]) + } + if (track_end == s[3]) { end = (s[8] << 16) | (s[9] << 8) | s[10]; + end_found++; + } + } + if (start_found == 0) { + cdaudiostop (); + cd_error = 1; + activate_stch = 1; + write_log (L"PLAY CD AUDIO: illegal start track %d\n", track_start); + return 0; } play_end = msf2lsn (end); play_start = msf2lsn (start); #ifdef CDTV_DEBUG write_log (L"PLAY CD AUDIO from %d-%d, %06X (%d) to %06X (%d)\n", - track_start, track_end, start, msf2lsn (start), end, msf2lsn (end)); + track_start, track_end, + start, msf2lsn (start), end, msf2lsn (end)); #endif play_state = 1; play_state_cmd = 1; diff --git a/custom.cpp b/custom.cpp index 5548ba61..ff9a2303 100644 --- a/custom.cpp +++ b/custom.cpp @@ -1655,7 +1655,7 @@ STATIC_INLINE void update_fetch (int until, int fm) int ddfstop_to_test; - if (nodraw() || plf_state == plf_end) + if (nodraw () || plf_state == plf_end) return; /* We need an explicit test against HARD_DDF_STOP here to guard against @@ -3358,7 +3358,7 @@ STATIC_INLINE int use_eventmode (uae_u16 v) { if (!currprefs.cpu_cycle_exact) return 0; - if (currprefs.cpu_cycle_exact && currprefs.cpu_model == 68000) + if (currprefs.cpu_cycle_exact && currprefs.cpu_model <= 68020) return 1; if (v & 0x8000) return 1; @@ -5299,7 +5299,7 @@ static void hsync_handler (void) last_custom_value1 = 0xffff; // refresh slots should set this to 0xffff - if (!nocustom()) { + if (!nocustom ()) { if (!currprefs.blitter_cycle_exact && bltstate != BLT_done && dmaen (DMA_BITPLANE) && diwstate == DIW_waiting_stop) { blitter_slowdown (thisline_decision.plfleft, thisline_decision.plfright - (16 << fetchmode), cycle_diagram_total_cycles[fetchmode][GET_RES_AGNUS (bplcon0)][GET_PLANES_LIMIT (bplcon0)], @@ -5623,7 +5623,7 @@ void customreset (int hardreset) CLXCON (0); setup_fmodes (0); sprite_width = GET_SPRITEWIDTH (fmode); - new_beamcon0 = currprefs.ntscmode ? 0x00 : 0x20; + beamcon0 = new_beamcon0 = currprefs.ntscmode ? 0x00 : 0x20; } gayle_reset (hardreset); diff --git a/drawing.cpp b/drawing.cpp index e0659744..4b860ee2 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -2301,20 +2301,30 @@ static void init_drawing_frame (void) if (FRAMES_UNTIL_RES_SWITCH > 0 && frame_res_old == frame_res * 2 + frame_res_lace) { frame_res_cnt--; if (frame_res_cnt == 0) { + int ar = currprefs.gfx_autoresolution; int m = frame_res * 2 + frame_res_lace; struct wh *dst = currprefs.gfx_afullscreen ? &changed_prefs.gfx_size_fs : &changed_prefs.gfx_size_win; while (m < 4) { struct wh *src = currprefs.gfx_afullscreen ? &currprefs.gfx_size_fs_xtra[m] : &currprefs.gfx_size_win_xtra[m]; - if ((src->width > 0 && src->height > 0) || (currprefs.gfx_autoresolution && currprefs.gfx_filter > 0)) { - changed_prefs.gfx_resolution = (m & 2) == 0 ? 0 : 1; - changed_prefs.gfx_linedbl = (m & 1) == 0 ? 0 : 1; - if (currprefs.gfx_autoresolution) { - changed_prefs.gfx_filter_horiz_zoom_mult = 1000 >> changed_prefs.gfx_resolution; - changed_prefs.gfx_filter_vert_zoom_mult = (changed_prefs.gfx_linedbl + 1) * 500; - } else { - *dst = *src; + if ((src->width > 0 && src->height > 0) || (ar && currprefs.gfx_filter > 0)) { + int nr = (m & 2) == 0 ? 0 : 1; + int nl = (m & 1) == 0 ? 0 : 1; + if (changed_prefs.gfx_resolution != nr || changed_prefs.gfx_linedbl != nl) { + changed_prefs.gfx_resolution = nr; + changed_prefs.gfx_linedbl = nl; + write_log (L"RES -> %d LINE -> %d\n", nr, nl); + config_changed = 1; + if (ar) { + changed_prefs.gfx_filter_horiz_zoom_mult = (nr + 1) * 500; + changed_prefs.gfx_filter_vert_zoom_mult = (nl + 1) * 500; + } + } + if (src->width > 0 && src->height > 0) { + if (memcmp (dst, src, sizeof *dst)) { + *dst = *src; + config_changed = 1; + } } - config_changed = 1; break; } m++; @@ -2907,7 +2917,14 @@ void vsync_handle_redraw (int long_frame, int lof_changed) count_frame (); check_picasso (); - if (check_prefs_changed_gfx ()) { + int changed = check_prefs_changed_gfx (); + if (changed > 0) { + reset_drawing (); + init_row_map (); + init_aspect_maps (); + notice_screen_contents_lost (); + notice_new_xcolors (); + } else if (changed < 0) { reset_drawing (); init_row_map (); init_aspect_maps (); @@ -2921,6 +2938,8 @@ void vsync_handle_redraw (int long_frame, int lof_changed) if (framecnt == 0) init_drawing_frame (); + else if (currprefs.cpu_cycle_exact) + init_hardware_for_drawing_frame (); } else { if (currprefs.gfx_afullscreen && currprefs.gfx_avsync) flush_screen (0, 0); /* vsync mode */ diff --git a/driveclick.cpp b/driveclick.cpp index 76bdae66..a1e37090 100644 --- a/driveclick.cpp +++ b/driveclick.cpp @@ -450,6 +450,8 @@ void driveclick_check_prefs (void) { int i; + if (!config_changed) + return; driveclick_fdrawcmd_vsync (); if (driveclick_active ()) dr_audio_activate (); diff --git a/gencpu.cpp b/gencpu.cpp index 28fb2618..00f3c727 100644 --- a/gencpu.cpp +++ b/gencpu.cpp @@ -2110,8 +2110,10 @@ static void gen_opcode (unsigned long int opcode) } else { int old_brace_level = n_braces; if (next_cpu_level < 0) - next_cpu_level = 0; + next_cpu_level = 0; printf ("\tuae_u16 newsr; uae_u32 newpc;\n"); + if (using_ce020) // need some delay so that interrupts have time to clear if previous ins was move to INTREQ + printf ("\tdo_cycles_ce (6 * CYCLE_UNIT);\n"); printf ("\tfor (;;) {\n"); genamode (Aipi, "7", sz_word, "sr", 1, 0, 0); genamode (Aipi, "7", sz_long, "pc", 1, 0, 0); @@ -2135,6 +2137,7 @@ static void gen_opcode (unsigned long int opcode) printf ("\t\texception3 (0x%04X, m68k_getpc (), newpc);\n", opcode); printf ("\telse\n"); printf ("\t\tm68k_setpc (newpc);\n"); + printf ("\tipl_fetch ();\n"); need_endlabel = 1; } /* PC is set and prefetch filled. */ diff --git a/include/fsdb.h b/include/fsdb.h index 87bbf163..60e7e50e 100644 --- a/include/fsdb.h +++ b/include/fsdb.h @@ -122,6 +122,7 @@ extern TCHAR *fsdb_create_unique_nname (a_inode *base, const TCHAR *); struct my_opendir_s; struct my_openfile_s; +extern struct my_opendir_s *my_opendir (const TCHAR*, const TCHAR*); extern struct my_opendir_s *my_opendir (const TCHAR*); extern void my_closedir (struct my_opendir_s*); extern int my_readdir (struct my_opendir_s*, TCHAR*); diff --git a/include/inputdevice.h b/include/inputdevice.h index 10bb7062..ad2b22ce 100644 --- a/include/inputdevice.h +++ b/include/inputdevice.h @@ -117,6 +117,7 @@ extern int handle_input_event (int nr, int state, int max, int autofire); extern void inputdevice_do_keyboard (int code, int state); extern int inputdevice_iskeymapped (int keyboard, int scancode); extern int inputdevice_synccapslock (int, int*); +extern void inputdevice_testrecord (int type, int num, int wtype, int wnum, int state); extern uae_u16 potgo_value; extern uae_u16 POTGOR (void); diff --git a/include/keyboard.h b/include/keyboard.h index 8e1e346a..f5ca1a9d 100644 --- a/include/keyboard.h +++ b/include/keyboard.h @@ -129,7 +129,7 @@ #define KBLED_CAPSLOCK 2 #define KBLED_SCROLLLOCK 4 -enum aks { AKS_ENTERGUI = 0x200, AKS_SCREENSHOT, AKS_FREEZEBUTTON, +enum aks { AKS_ENTERGUI = 0x200, AKS_SCREENSHOT_FILE, AKS_SCREENSHOT_CLIPBOARD, AKS_FREEZEBUTTON, AKS_FLOPPY0, AKS_FLOPPY1, AKS_FLOPPY2, AKS_FLOPPY3, AKS_EFLOPPY0, AKS_EFLOPPY1, AKS_EFLOPPY2, AKS_EFLOPPY3, AKS_TOGGLEFULLSCREEN, AKS_ENTERDEBUGGER, AKS_IRQ7, diff --git a/inputdevice.cpp b/inputdevice.cpp index a2fdd6bb..4f13f66b 100644 --- a/inputdevice.cpp +++ b/inputdevice.cpp @@ -2203,9 +2203,12 @@ void inputdevice_handle_inputcode (void) case AKS_ENTERGUI: gui_display (-1); break; - case AKS_SCREENSHOT: + case AKS_SCREENSHOT_FILE: screenshot (1, 1); break; + case AKS_SCREENSHOT_CLIPBOARD: + screenshot (0, 1); + break; #ifdef ACTION_REPLAY case AKS_FREEZEBUTTON: action_replay_freeze (); @@ -4310,9 +4313,14 @@ void inputdevice_unacquire (void) idev[IDTYPE_KEYBOARD].unacquire (i); } -static void testrecord (int type, int num, int wtype, int wnum, int state) +void inputdevice_testrecord (int type, int num, int wtype, int wnum, int state) { TCHAR tmp[2000]; + + if (wnum < 0) { + testmode = -1; + return; + } tmp[0] = 0; wnum += idev[type].get_widget_first (num, wtype); idev[type].get_widget_type (num, wnum, tmp, NULL); @@ -4330,6 +4338,10 @@ int inputdevice_testread (TCHAR *name) idev[IDTYPE_KEYBOARD].read (); idev[IDTYPE_JOYSTICK].read (); idev[IDTYPE_MOUSE].read (); + if (testmode != 1) { + testmode = 0; + return 1; + } testmode = 0; return 0; } @@ -4427,7 +4439,7 @@ void setmousebuttonstateall (int mouse, uae_u32 buttonbits, uae_u32 buttonmask) void setmousebuttonstate (int mouse, int button, int state) { if (testmode) { - testrecord (IDTYPE_MOUSE, mouse, IDEV_WIDGET_BUTTON, button, state); + inputdevice_testrecord (IDTYPE_MOUSE, mouse, IDEV_WIDGET_BUTTON, button, state); return; } setbuttonstateall (&mice[mouse], &mice2[mouse], button, state); @@ -4444,7 +4456,7 @@ void setjoystickstate (int joy, int axis, int state, int max) int i, v1, v2; if (testmode) { - testrecord (IDTYPE_JOYSTICK, joy, IDEV_WIDGET_AXIS, axis, state); + inputdevice_testrecord (IDTYPE_JOYSTICK, joy, IDEV_WIDGET_AXIS, axis, state); return; } v1 = state; @@ -4481,7 +4493,7 @@ void setmousestate (int mouse, int axis, int data, int isabs) static double fract[MAX_INPUT_DEVICES][MAX_INPUT_DEVICE_EVENTS]; if (testmode) { - testrecord (IDTYPE_MOUSE, mouse, IDEV_WIDGET_AXIS, axis, data); + inputdevice_testrecord (IDTYPE_MOUSE, mouse, IDEV_WIDGET_AXIS, axis, data); return; } if (!mice[mouse].enabled) { diff --git a/inputevents.def b/inputevents.def index 48d575ae..29d58baf 100644 --- a/inputevents.def +++ b/inputevents.def @@ -299,7 +299,8 @@ DEFEVENT(KEY_7F,L"Keycode 0x7F",AM_K,0,0,0x7f) /* special */ DEFEVENT(SPC_ENTERGUI,L"Enter GUI",AM_K,0,0,AKS_ENTERGUI) -DEFEVENT(SPC_SCREENSHOT,L"Screenshot",AM_K,0,0,AKS_SCREENSHOT) +DEFEVENT(SPC_SCREENSHOT,L"Screenshot (file)",AM_K,0,0,AKS_SCREENSHOT_FILE) +DEFEVENT(SPC_SCREENSHOT_CLIPBOARD,L"Screenshot (clipboard)",AM_K,0,0,AKS_SCREENSHOT_CLIPBOARD) DEFEVENT(SPC_FREEZEBUTTON,L"Activate Cartridge",AM_K,0,0,AKS_FREEZEBUTTON) DEFEVENT(SPC_FLOPPY0,L"Change disk in DF0:",AM_K,0,0,AKS_FLOPPY0) DEFEVENT(SPC_FLOPPY1,L"Change disk in DF1:",AM_K,0,0,AKS_FLOPPY1) diff --git a/newcpu.cpp b/newcpu.cpp index 961ec468..a46e34f1 100644 --- a/newcpu.cpp +++ b/newcpu.cpp @@ -3103,7 +3103,7 @@ static void m68k_run_2ce (void) struct regstruct *r = ®s; int tmpcycles = MAX68020CYCLES; - regs.ipl = regs.ipl_pin; + ipl_fetch (); for (;;) { uae_u32 opcode = get_word_ce020_prefetch (0); (*cpufunctbl[opcode])(opcode); diff --git a/od-win32/dinput.cpp b/od-win32/dinput.cpp index d257c9b6..9b52b64b 100644 --- a/od-win32/dinput.cpp +++ b/od-win32/dinput.cpp @@ -2172,7 +2172,8 @@ static void read_kb (void) continue; di_keycodes[i][scancode] = pressed; if (istest) { - inputdevice_do_keyboard (scancode, pressed); + int q = di_keycodes[i][DIK_LMENU] && di_keycodes[i][DIK_RMENU]; + inputdevice_testrecord (IDTYPE_KEYBOARD, i, IDEV_WIDGET_BUTTON, q ? -1 : scancode, pressed); } else { if (stopoutput == 0) my_kbd_handler (i, scancode, pressed); diff --git a/od-win32/direct3d.cpp b/od-win32/direct3d.cpp index 5d3aa33e..cc07b44c 100644 --- a/od-win32/direct3d.cpp +++ b/od-win32/direct3d.cpp @@ -1035,6 +1035,7 @@ static void setupscenecoords (void) dh = dr.bottom - dr.top; w = sr.right - sr.left; h = sr.bottom - sr.top; + //write_log (L"%.1fx%.1f %.1fx%.1f\n", dw, dh, w, h); MatrixOrthoOffCenterLH (&m_matProj, 0, w, 0, h, 0.0f, 1.0f); @@ -1623,7 +1624,9 @@ static void D3D_render22 (void) return; setupscenecoords (); + hr = d3ddev->Clear (0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, d3ddebug ? 0x80 : 0, 0), 0, 0); + if (FAILED (hr = d3ddev->BeginScene ())) { write_log (L"%s: BeginScene: %s\n", D3DHEAD, D3D_ErrorString (hr)); return; @@ -1833,6 +1836,24 @@ void D3D_unlocktexture (void) locked = 0; } +void D3D_flushtexture (int miny, int maxy) +{ + if (miny >= 0 && maxy >= 0) { + RECT r; + maxy++; + r.left = 0; + r.right = twidth; + r.top = miny <= 0 ? 0 : miny; + r.bottom = maxy <= theight ? maxy : theight; + if (r.top <= r.bottom) { + HRESULT hr = texture->AddDirtyRect (&r); + if (FAILED (hr)) + write_log (L"%s: AddDirtyRect(): %s\n", D3DHEAD, D3D_ErrorString (hr)); + //write_log (L"%d %d\n", r.top, r.bottom); + } + } +} + uae_u8 *D3D_locktexture (int *pitch) { D3DLOCKED_RECT lock; @@ -1845,7 +1866,7 @@ uae_u8 *D3D_locktexture (int *pitch) lock.pBits = NULL; lock.Pitch = 0; - hr = texture->LockRect (0, &lock, NULL, 0); + hr = texture->LockRect (0, &lock, NULL, D3DLOCK_NO_DIRTY_UPDATE); if (FAILED (hr)) { write_log (L"%s: LockRect failed: %s\n", D3DHEAD, D3D_ErrorString (hr)); return NULL; diff --git a/od-win32/direct3d.h b/od-win32/direct3d.h index dc1af060..ce55ceb5 100644 --- a/od-win32/direct3d.h +++ b/od-win32/direct3d.h @@ -6,6 +6,7 @@ extern void D3D_refresh (void); extern void D3D_flip (void); extern uae_u8 *D3D_locktexture(int*); extern void D3D_unlocktexture(void); +extern void D3D_flushtexture (int miny, int maxy); extern void D3D_guimode (int guion); extern HDC D3D_getDC(HDC hdc); extern int D3D_isenabled (void); diff --git a/od-win32/fsdb_mywin32.cpp b/od-win32/fsdb_mywin32.cpp index 1e67e55c..5d647a86 100644 --- a/od-win32/fsdb_mywin32.cpp +++ b/od-win32/fsdb_mywin32.cpp @@ -107,12 +107,17 @@ struct my_opendir_s { }; struct my_opendir_s *my_opendir (const TCHAR *name) +{ + return my_opendir (name, L"*.*"); +} +struct my_opendir_s *my_opendir (const TCHAR *name, const TCHAR *mask) { struct my_opendir_s *mod; TCHAR tmp[MAX_DPATH]; _tcscpy (tmp, name); - _tcscat (tmp, L"\\*.*"); + _tcscat (tmp, L"\\"); + _tcscat (tmp, mask); mod = xmalloc (struct my_opendir_s, 1); if (!mod) return NULL; @@ -181,7 +186,7 @@ unsigned int my_write (struct my_openfile_s *mos, void *b, unsigned int size) return written; } -static DWORD GetFileAttributesSafe(const TCHAR *name) +static DWORD GetFileAttributesSafe (const TCHAR *name) { DWORD attr, last; diff --git a/od-win32/uaeunp/uaeunp.vcxproj b/od-win32/uaeunp/uaeunp.vcxproj index e9554e88..4c762b53 100644 --- a/od-win32/uaeunp/uaeunp.vcxproj +++ b/od-win32/uaeunp/uaeunp.vcxproj @@ -71,14 +71,13 @@ MaxSpeed true ..\..\include;..\..;..\;..\resources;..\osdep;..\sounddep;..\..\prowizard\include;..\tun;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;WIN32_IE=0x0700;WIN32;CINTERFACE;COBJMACROS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;WIN32_IE=0x0700;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreaded true Level3 ProgramDatabase - CompileAsC zlibstat.lib;wininet.lib;%(AdditionalDependencies) diff --git a/od-win32/win32.h b/od-win32/win32.h index 9710d1e6..8a052a76 100644 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -18,8 +18,8 @@ #define WINUAEPUBLICBETA 1 #define LANG_DLL 1 -#define WINUAEBETA L"16" -#define WINUAEDATE MAKEBD(2010, 3, 10) +#define WINUAEBETA L"17" +#define WINUAEDATE MAKEBD(2010, 3, 14) #define WINUAEEXTRA L"" #define WINUAEREV L"" diff --git a/od-win32/win32_scaler.cpp b/od-win32/win32_scaler.cpp index 921c55aa..74894331 100644 --- a/od-win32/win32_scaler.cpp +++ b/od-win32/win32_scaler.cpp @@ -730,7 +730,7 @@ void S2X_render (void) end: if (d3d) { - D3D_unlocktexture (); + ;//D3D_unlocktexture (); unlock in win32gfx.c } else { unlocksurface (tempsurf); diff --git a/od-win32/win32gfx.cpp b/od-win32/win32gfx.cpp index 2e3fbadc..8c32a8e5 100644 --- a/od-win32/win32gfx.cpp +++ b/od-win32/win32gfx.cpp @@ -782,25 +782,52 @@ int WIN32GFX_AdjustScreenmode (struct MultiDisplay *md, int *pwidth, int *pheigh return index; } -void flush_line (int lineno) -{ +static int flushymin, flushymax; +#define FLUSH_DIFF 50 +static void flushit (int lineno) +{ + if (!currprefs.gfx_api) + return; + if (flushymin > lineno) { + if (flushymin - lineno > FLUSH_DIFF && flushymax != 0) { + D3D_flushtexture (flushymin, flushymax); + flushymin = currentmode->amiga_height; + flushymax = 0; + } else { + flushymin = lineno; + } + } + if (flushymax < lineno) { + if (lineno - flushymax > FLUSH_DIFF && flushymax != 0) { + D3D_flushtexture (flushymin, flushymax); + flushymin = currentmode->amiga_height; + flushymax = 0; + } else { + flushymax = lineno; + } + } } -void flush_block (int a, int b) +void flush_line (int lineno) { + flushit (lineno); +} +void flush_block (int first, int last) +{ + flushit (first); + flushit (last); } void flush_screen (int a, int b) { if (dx_islost ()) return; + flushymin = 0; + flushymax = currentmode->amiga_height; if (currentmode->flags & DM_D3D) { - if ((currentmode->flags & DM_SWSCALE) && usedfilter->type != UAE_FILTER_NULL) - S2X_render (); D3D_flip (); - return; #ifdef GFXFILTER } else if (currentmode->flags & DM_SWSCALE) { S2X_render (); @@ -829,6 +856,8 @@ int lockscr (void) int ret = 0; if (!isscreen ()) return ret; + flushymin = currentmode->amiga_height; + flushymax = 0; ret = 1; if (currentmode->flags & DM_D3D) { #ifdef D3D @@ -855,8 +884,9 @@ void unlockscr (void) { if (currentmode->flags & DM_D3D) { if ((currentmode->flags & DM_SWSCALE) && usedfilter->type != UAE_FILTER_NULL) - return; + S2X_render (); #ifdef D3D + D3D_flushtexture (flushymin, flushymax); D3D_unlocktexture (); #endif } else if (currentmode->flags & DM_SWSCALE) { @@ -1002,6 +1032,10 @@ uae_u8 *gfx_lock_picasso (void) void gfx_unlock_picasso (void) { if (currprefs.gfx_api) { + if (p96_double_buffer_needs_flushing) { + D3D_flushtexture (p96_double_buffer_first, p96_double_buffer_last); + p96_double_buffer_needs_flushing = 0; + } D3D_unlocktexture (); D3D_flip (); } else { @@ -1252,6 +1286,7 @@ int check_prefs_changed_gfx (void) 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; c |= currprefs.gfx_scandoubler != changed_prefs.gfx_scandoubler ? (2 | 8) : 0; c |= currprefs.gfx_display != changed_prefs.gfx_display ? (2|4|8) : 0; @@ -1309,10 +1344,11 @@ int check_prefs_changed_gfx (void) currprefs.gfx_filter_autoscale = changed_prefs.gfx_filter_autoscale; //currprefs.gfx_filter_ = changed_prefs.gfx_filter_; - currprefs.gfx_lores_mode = changed_prefs.gfx_lores_mode; - currprefs.gfx_scandoubler = changed_prefs.gfx_scandoubler; currprefs.gfx_resolution = changed_prefs.gfx_resolution; currprefs.gfx_linedbl = changed_prefs.gfx_linedbl; + + currprefs.gfx_lores_mode = changed_prefs.gfx_lores_mode; + currprefs.gfx_scandoubler = changed_prefs.gfx_scandoubler; currprefs.gfx_display = changed_prefs.gfx_display; _tcscpy (currprefs.gfx_display_name, changed_prefs.gfx_display_name); currprefs.gfx_blackerthanblack = changed_prefs.gfx_blackerthanblack; @@ -1347,7 +1383,14 @@ int check_prefs_changed_gfx (void) inputdevice_acquire (TRUE); return 1; } - +#if 0 + if (currprefs.gfx_resolution != changed_prefs.gfx_resolution || + currprefs.gfx_linedbl != changed_prefs.gfx_linedbl) { + currprefs.gfx_resolution = changed_prefs.gfx_resolution; + currprefs.gfx_linedbl = changed_prefs.gfx_linedbl; + return -1; + } +#endif if (currprefs.chipset_refreshrate != changed_prefs.chipset_refreshrate) { currprefs.chipset_refreshrate = changed_prefs.chipset_refreshrate; init_hz (); diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index 1c2798fb..35efa1f0 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -524,6 +524,7 @@ struct favitems }; #define MAXFAVORITES 30 +#define MAXFAVORITESPACE 99 static void writefavoritepaths (int num, struct favitems *fitem) { int i, idx; @@ -657,7 +658,7 @@ static void addeditmenu (HMENU menu, struct favitems *fitem) InsertMenuItem (menu, -1, TRUE, &mii); } -static int popupmenu (HWND hwnd, struct favitems *items) +static int popupmenu (HWND hwnd, struct favitems *items, int morefiles) { int i, item, got; HMENU menu; @@ -667,13 +668,13 @@ static int popupmenu (HWND hwnd, struct favitems *items) got = 0; i = 0; while (items[i].type) { - if (items[i].type == 2) { + if (items[i].type >= 2) { MENUITEMINFO mii = { 0 }; mii.cbSize = sizeof mii; mii.fMask = MIIM_STRING | MIIM_ID; mii.fType = MFT_STRING; mii.fState = MFS_ENABLED; - mii.wID = 1 + i; + mii.wID = items[i].type == 2 ? 1 + i : 990 - 3 + items[i].type; mii.dwTypeData = items[i].value; mii.cch = _tcslen (mii.dwTypeData); InsertMenuItem (menu, -1, TRUE, &mii); @@ -681,10 +682,21 @@ static int popupmenu (HWND hwnd, struct favitems *items) } i++; } + if (morefiles < 0) { + MENUITEMINFO mii = { 0 }; + mii.cbSize = sizeof mii; + mii.fMask = MIIM_STRING | MIIM_ID; + mii.fType = MFT_STRING; + mii.fState = MFS_ENABLED; + mii.wID = 999; + mii.dwTypeData = L"[Directory scan]"; + mii.cch = _tcslen (mii.dwTypeData); + InsertMenuItem (menu, -1, TRUE, &mii); + got = 1; + } if (got) { MENUITEMINFO mii = { 0 }; mii.cbSize = sizeof mii; - mii.fMask = MIIM_FTYPE; mii.fType = MFT_SEPARATOR; mii.fState = MFS_ENABLED; @@ -713,13 +725,117 @@ static int popupmenu (HWND hwnd, struct favitems *items) DestroyMenu (menu); return item; } + +static void favitemsort (struct favitems *fitem, int start, int end) +{ + for (int i = start; i < end; i++) { + for (int j = i + 1; j < end; j++) { + if (_tcscmp (fitem[i].value, fitem[j].value) > 0) { + struct favitems tmp; + memcpy (&tmp, &fitem[i], sizeof tmp); + memcpy (&fitem[i], &fitem[j], sizeof tmp); + memcpy (&fitem[j], &tmp, sizeof tmp); + } + } + } +} + +static int getdeepfavdiskimage (TCHAR *imgpath, struct favitems *fitem, int idx) +{ + TCHAR path[MAX_DPATH], mask[MAX_DPATH]; + TCHAR *p; + struct my_opendir_s *myd = NULL; + int previdx = idx; + + if (!imgpath[0]) + return idx; + _tcscpy (path, imgpath); + mask[0] = 0; + for (;;) { + p = _tcsrchr (path, '\\'); + if (!p) + p = _tcsrchr (path, '/'); + if (!p) + break; + if (!mask[0]) + _tcscpy (mask, p + 1); + p[0] = 0; + if (my_existsdir (path)) + break; + } + static TCHAR notallowed[] = L"[]()_-#!{}=.,"; + for (int i = 0; i < _tcslen (notallowed); i++) { + for (;;) { + p = _tcsrchr (mask, notallowed[i]); + if (!p) + break; + if (p - mask < 6) + break; + p[0] = 0; + } + } + while (mask[_tcslen (mask) - 1] == ' ') + mask[_tcslen (mask) - 1] = 0; + _tcscat (mask, L"*.*"); + myd = my_opendir (path, mask); + int cnt = 0; + while (cnt < 30) { + TCHAR tmp[MAX_DPATH], tmp2[MAX_DPATH]; + if (!my_readdir (myd, tmp)) + break; + _tcscpy (tmp2, path); + _tcscat (tmp2, L"\\"); + _tcscat (tmp2, tmp); + fitem[idx].value = my_strdup (tmp2); + fitem[idx].path = NULL; + fitem[idx].type = 2; + idx++; + cnt++; + } + my_closedir (myd); + favitemsort (fitem, previdx, idx); + fitem[idx].type = 0; + return idx; +} + +static int getfavdiskimage (TCHAR *imgpath, struct favitems *fitem, int idx) +{ + int i; + TCHAR name[MAX_DPATH]; + + _tcscpy (name, imgpath); + int previdx = idx; + for (;;) { + if (!disk_prevnext_name (name, 1)) + break; + for (i = previdx; i < idx; i++) { + if (!_tcsicmp (fitem[i].value, name)) + break; + } + if (i < idx) + break; + fitem[idx].value = my_strdup (name); + fitem[idx].path = NULL; + fitem[idx].type = 2; + idx++; + if (!_tcscmp (name, imgpath)) + break; + } + favitemsort (fitem, previdx, idx); + fitem[idx].type = 0; + return idx; +} + static TCHAR *favoritepopup (HWND hwnd, int drive) { UAEREG *fkey; int idx, idx2; - struct favitems fitem[MAXFAVORITES + 1]; - int ret, i, j, num; + struct favitems fitem[MAXFAVORITESPACE + 1]; + int ret, i, num; + int srcdrive, dstdrive; + int morefiles = 0; + srcdrive = dstdrive = drive; for (;;) { fkey = regcreatetree (NULL, L"FavoritePaths"); if (fkey == NULL) @@ -760,63 +876,50 @@ static TCHAR *favoritepopup (HWND hwnd, int drive) idx++; } regclosetree (fkey); - for (i = 0; i < idx; i++) { - for (j = i + 1; j < idx; j++) { - if (_tcscmp (fitem[i].value, fitem[j].value) > 0) { - struct favitems tmp; - memcpy (&tmp, &fitem[i], sizeof tmp); - memcpy (&fitem[i], &fitem[j], sizeof tmp); - memcpy (&fitem[j], &tmp, sizeof tmp); - } - } - } + favitemsort (fitem, 0, idx); fitem[idx].type = 0; - if (drive >= 0) { - TCHAR name[MAX_DPATH]; - _tcscpy (name, currprefs.df[drive]); - int previdx = idx; - for (;;) { - if (!disk_prevnext_name (name, 1)) - break; - for (i = previdx; i < idx; i++) { - if (!_tcsicmp (fitem[i].value, name)) - break; + if (srcdrive >= 0 && srcdrive <= 4) { + if (!morefiles) { + for (i = 0; i < 4; i++) { + if (workprefs.df[i][0] && srcdrive != i) { + TCHAR tmp[100]; + _stprintf (tmp, L"[DF%c:]", i + '0'); + fitem[idx].value = my_strdup (tmp); + fitem[idx].path = my_strdup (workprefs.df[i]); + fitem[idx].type = 3 + i; + idx++; + fitem[idx].type = 0; + } } - if (i < idx) - break; - fitem[idx].value = my_strdup (name); - fitem[idx].path = NULL; - fitem[idx].type = 2; - idx++; - if (!_tcscmp (name, currprefs.df[drive])) - break; } - for (i = previdx; i < idx; i++) { - for (j = i + 1; j < idx; j++) { - if (_tcscmp (fitem[i].value, fitem[j].value) > 0) { - struct favitems tmp; - memcpy (&tmp, &fitem[i], sizeof tmp); - memcpy (&fitem[i], &fitem[j], sizeof tmp); - memcpy (&fitem[j], &tmp, sizeof tmp); - } + if (workprefs.df[srcdrive][0]) { + if (morefiles > 0) { + idx = getdeepfavdiskimage (workprefs.df[srcdrive], fitem, idx); + } else { + idx = getfavdiskimage (workprefs.df[srcdrive], fitem, idx); + morefiles = -1; } } - fitem[idx].type = 0; } - ret = popupmenu (hwnd, fitem); + ret = popupmenu (hwnd, fitem, morefiles); if (ret == 0) break; if (ret <= idx) { if (fitem[ret - 1].type == 2) { - _tcscpy (workprefs.df[drive], fitem[ret - 1].value); + _tcscpy (workprefs.df[dstdrive], fitem[ret - 1].value); + disk_insert (dstdrive, workprefs.df[dstdrive]); ret = 0; } break; } - if (ret == 1000) { + if (ret >= 990 && ret <= 993) { + srcdrive = ret - 990; + } else if (ret == 999) { + morefiles = 1; + } else if (ret == 1000) { if (!addfavoritepath (hwnd, idx, fitem)) { ret = 0; break; @@ -1597,7 +1700,7 @@ static void gui_to_prefs (void) static int iscd (int n) { - if (quickstart_cd && n == 1) + if (quickstart_cd && n == 1 && currentpage == QUICKSTART_ID) return 1; return 0; } @@ -4575,8 +4678,12 @@ static INT_PTR CALLBACK QuickstartDlgProc (HWND hDlg, UINT msg, WPARAM wParam, L break; case WM_CONTEXTMENU: + if (recursive > 0) + break; + recursive++; diskselectmenu (hDlg, wParam); setfloppytexts (hDlg, true); + recursive--; break; case WM_COMMAND: @@ -8824,7 +8931,7 @@ static void addfloppyhistory_2 (HWND hDlg, int n, int f_text) int i, j; TCHAR *s, *text; UAEREG *fkey; - int nn, type; + int nn, type, curidx; if (f_text < 0) return; @@ -8838,10 +8945,11 @@ static void addfloppyhistory_2 (HWND hDlg, int n, int f_text) type = HISTORY_FLOPPY; text = workprefs.df[n]; } + SendDlgItemMessage (hDlg, f_text, WM_SETTEXT, 0, (LPARAM)text); fkey = read_disk_history (type); if (fkey == NULL) return; - SendDlgItemMessage (hDlg, f_text, WM_SETTEXT, 0, (LPARAM)text); + curidx = -1; i = 0; while (s = DISK_history_get (i, type)) { TCHAR tmpname[MAX_DPATH], tmppath[MAX_DPATH], *p, *p2; @@ -8871,13 +8979,13 @@ static void addfloppyhistory_2 (HWND hDlg, int n, int f_text) } if (f_text >= 0) SendDlgItemMessage (hDlg, f_text, CB_ADDSTRING, 0, (LPARAM)tmpname); - if (!_tcscmp (text, s)) { - if (f_text >= 0) - SendDlgItemMessage (hDlg, f_text, CB_SETCURSEL, i - 1, 0); - } + if (!_tcscmp (text, s)) + curidx = i - 1; if (nn <= 0) break; } + if (f_text >= 0 && curidx >= 0) + SendDlgItemMessage (hDlg, f_text, CB_SETCURSEL, curidx, 0); regclosetree (fkey); } @@ -9151,7 +9259,7 @@ static int diskselectmenu (HWND hDlg, WPARAM wParam) break; } if (num >= 0) { - TCHAR *s = favoritepopup (hDlg, num); + TCHAR *s = favoritepopup (hDlg, iscd (num) ? -1 : num); if (s) { int num = id == IDC_DF0QQ ? 0 : 1; TCHAR tmp[MAX_DPATH]; @@ -10614,9 +10722,8 @@ static void input_copy (HWND hDlg) TCHAR buf[2000]; inputdevice_acquire (1); for (;;) { - focus = 1; - inputdevice_testread (buf); - focus = 0; + if (inputdevice_testread (buf)) + break; Sleep (100); } inputdevice_unacquire (); diff --git a/savestate.cpp b/savestate.cpp index f6f9dc4e..60784bcd 100644 --- a/savestate.cpp +++ b/savestate.cpp @@ -604,6 +604,7 @@ void savestate_restore_finish (void) savestate_file = 0; savestate_state = 0; restore_cpu_finish (); + init_hz (); } /* 1=compressed,2=not compressed,3=ram dump,4=audio dump */