From 00f48f2782a24d2e2ad514766832ff39bca9247d Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Tue, 3 Apr 2012 17:46:44 +0300 Subject: [PATCH] 2410b3 --- audio.cpp | 18 +- custom.cpp | 25 +- filesys.cpp | 192 ++++--- hardfile.cpp | 2 +- include/gensound.h | 7 +- include/sysdeps.h | 2 + main.cpp | 26 + od-win32/dinput.cpp | 17 +- od-win32/direct3d.cpp | 6 +- od-win32/win32.cpp | 27 +- od-win32/win32.h | 4 +- od-win32/win32_scaler.cpp | 476 +----------------- od-win32/win32gfx.cpp | 77 +-- od-win32/winuae_msvc10/winuae_msvc.vcxproj | 1 + .../winuae_msvc10/winuae_msvc.vcxproj.filters | 3 + od-win32/winuaechangelog.txt | 11 + 16 files changed, 271 insertions(+), 623 deletions(-) diff --git a/audio.cpp b/audio.cpp index 2a62900a..363c0981 100644 --- a/audio.cpp +++ b/audio.cpp @@ -89,8 +89,8 @@ typedef struct { } sinc_queue_t; struct audio_channel_data { - unsigned long adk_mask; - unsigned long evtime; + unsigned int adk_mask; + unsigned int evtime; bool dmaenstore; bool intreq2; bool dr; @@ -226,7 +226,7 @@ void audio_sampleripper (int mode) underline[0] = 0; namesplit (name); _tcscpy (extension, _T("wav")); - _stprintf (filename, _T("%s%s%s%03.3d.%s"), path, name, underline, cnt, extension); + _stprintf (filename, _T("%s%s%s%03d.%s"), path, name, underline, cnt, extension); wavfile = zfile_fopen (filename, _T("wb"), 0); if (wavfile) { int freq = rs->per > 0 ? (currprefs.ntscmode ? 3579545 : 3546895 / rs->per) : 8000; @@ -380,9 +380,6 @@ static int filter (int input, struct filter_state *fs) input = (uae_s16)input; switch (sound_use_filter) { - case FILTER_NONE: - return input; - case FILTER_MODEL_A500: fs->rc1 = a500e_filter1_a0 * input + (1 - a500e_filter1_a0) * fs->rc1 + DENORMAL_OFFSET; fs->rc2 = a500e_filter2_a0 * fs->rc1 + (1-a500e_filter2_a0) * fs->rc2; @@ -405,6 +402,10 @@ static int filter (int input, struct filter_state *fs) led_output = fs->rc4; break; + case FILTER_NONE: + default: + return input; + } if (led_filter_on) @@ -1153,8 +1154,8 @@ static int isirq (int nr) static void setirq (int nr, int which) { - struct audio_channel_data *cdp = audio_channel + nr; #if DEBUG_AUDIO > 0 + struct audio_channel_data *cdp = audio_channel + nr; if (debugchannel (nr) && cdp->wlen > 1) write_log (_T("SETIRQ%d (%d,%d) PC=%08X\n"), nr, which, isirq (nr) ? 1 : 0, M68K_GETPC); #endif @@ -1554,7 +1555,6 @@ void check_prefs_changed_audio (void) void set_audio (void) { - int old_mixed_on = mixed_on; int old_mixed_size = mixed_stereo_size; int sep, delay; int ch; @@ -1766,7 +1766,7 @@ void update_audio (void) if (audio_channel[i].evtime == 0) { audio_state_channel (i, true); if (audio_channel[i].evtime == 0) { - write_log (_T("evtime==0 sound bug channel %d\n")); + write_log (_T("evtime==0 sound bug channel %d\n"), i); audio_channel[i].evtime = MAX_EV; } } diff --git a/custom.cpp b/custom.cpp index bcb9aaad..4e9f1a70 100644 --- a/custom.cpp +++ b/custom.cpp @@ -131,7 +131,7 @@ struct ev eventtab[ev_max]; struct ev2 eventtab2[ev2_max]; int vpos; -static int vpos_count, vpos_count_prev; +static int vpos_count, vpos_count_diff; int lof_store; // real bit in custom registers static int lof_current; // what display device thinks static int lol; @@ -2878,7 +2878,7 @@ void compute_framesync (void) int res = GET_RES_AGNUS (bplcon0); int vres = islace ? 1 : 0; int res2, vres2; - + res2 = currprefs.gfx_resolution; if (doublescan) res2++; @@ -2894,7 +2894,7 @@ void compute_framesync (void) if (vres2 > VRES_QUAD) vres2 = VRES_QUAD; - gfxvidinfo.drawbuffer.inwidth = (((hbstrt > hbstop ? 0 : (maxhpos - (hbstop - hbstrt))) * 2) << res2); + gfxvidinfo.drawbuffer.inwidth = (((hbstrt > hbstop ? 0 : (maxhpos - (hbstop - hbstrt))) * 2) << res2); gfxvidinfo.drawbuffer.extrawidth = 0; gfxvidinfo.drawbuffer.inwidth2 = gfxvidinfo.drawbuffer.inwidth; @@ -2906,7 +2906,7 @@ void compute_framesync (void) gfxvidinfo.drawbuffer.inwidth = AMIGA_WIDTH_MAX << currprefs.gfx_resolution; gfxvidinfo.drawbuffer.extrawidth = 1; gfxvidinfo.drawbuffer.inwidth2 = gfxvidinfo.drawbuffer.inwidth; - gfxvidinfo.drawbuffer.inheight = (maxvpos - minfirstline) << currprefs.gfx_vresolution; + gfxvidinfo.drawbuffer.inheight = (maxvpos_nom - minfirstline + 1) << currprefs.gfx_vresolution; gfxvidinfo.drawbuffer.inheight2 = gfxvidinfo.drawbuffer.inheight; } @@ -2957,8 +2957,10 @@ void init_hz (bool fullinit) double ovblank = vblank_hz; int hzc = 0; - if (fullinit || (vpos_count_prev && abs (vpos_count - vpos_count_prev) <= 1)) - vpos_count = vpos_count_prev = 0; + if (fullinit) + vpos_count = 0; + + vpos_count_diff = vpos_count; doublescan = 0; programmedmode = false; @@ -2966,7 +2968,7 @@ void init_hz (bool fullinit) hzc = 1; if (beamcon0 != new_beamcon0) { write_log (_T("BEAMCON0 %04x -> %04x PC%=%08x\n"), beamcon0, new_beamcon0, M68K_GETPC); - vpos_count = vpos_count_prev = 0; + vpos_count_diff = vpos_count = 0; } beamcon0 = new_beamcon0; isntsc = (beamcon0 & 0x20) ? 0 : 1; @@ -2990,7 +2992,8 @@ void init_hz (bool fullinit) } maxvpos_nom = maxvpos; if (vpos_count > 0) { - // we come here if vpos_count != maxvpos (someone poked VPOSW) + // we come here if vpos_count != maxvpos and beamcon0 didn't change + // (someone poked VPOSW) if (vpos_count < 10) vpos_count = 10; vblank_hz = (isntsc ? 15734 : 15625.0) / vpos_count; @@ -5414,14 +5417,12 @@ static void vsync_handler_post (void) vpos_count = p96refresh_active; vtotal = vpos_count; } - if ((beamcon0 & (0x20 | 0x80)) != (new_beamcon0 & (0x20 | 0x80)) || (vpos_count_prev && (abs (vpos_count - vpos_count_prev) > 1)) || lof_changed) { + if ((beamcon0 & (0x20 | 0x80)) != (new_beamcon0 & (0x20 | 0x80)) || abs (vpos_count - vpos_count_diff) > 1 || lof_changed) { init_hz (); } else if (interlace_changed || changed_chipset_refresh ()) { compute_framesync (); } - vpos_count_prev = vpos_count; - lof_changed = 0; COPJMP (1, 1); @@ -6133,7 +6134,7 @@ void custom_reset (int hardreset) unset_special (~(SPCFLAG_BRK | SPCFLAG_MODE_CHANGE)); vpos = 0; - vpos_count = vpos_count_prev = 0; + vpos_count = vpos_count_diff = 0; inputdevice_reset (); timehack_alive = 0; diff --git a/filesys.cpp b/filesys.cpp index 980b15c4..a94d7c6d 100644 --- a/filesys.cpp +++ b/filesys.cpp @@ -205,10 +205,19 @@ int nr_directory_units (struct uae_prefs *p) return cnt; } +static int is_virtual (int unit_no) +{ + int t = is_hardfile (unit_no); + return t == FILESYS_VIRTUAL || t == FILESYS_CD; +} + int is_hardfile (int unit_no) { - if (mountinfo.ui[unit_no].volname || mountinfo.ui[unit_no].wasisempty || mountinfo.ui[unit_no].unknown_media) + if (mountinfo.ui[unit_no].volname || mountinfo.ui[unit_no].wasisempty || mountinfo.ui[unit_no].unknown_media) { + if (unit_no >= cd_unit_offset && unit_no < cd_unit_offset + cd_unit_number) + return FILESYS_CD; return FILESYS_VIRTUAL; + } if (mountinfo.ui[unit_no].hf.secspertrack == 0) { if (mountinfo.ui[unit_no].hf.flags & 1) return FILESYS_HARDDRIVE; @@ -236,7 +245,7 @@ static void close_filesys_unit (UnitInfo *uip) if (uip->cd_open) { sys_command_close (uip->cddevno); isofs_unmount (uip->cdfs_superblock); - } + } uip->unit_pipe = 0; uip->back_pipe = 0; @@ -477,7 +486,7 @@ static int set_filesys_unit_1 (int nr, iscd = USE_CDFS == 2 && nr >= cd_unit_offset && nr < cd_unit_offset + cd_unit_number; for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) { - if (nr == i || !mountinfo.ui[i].open || mountinfo.ui[i].rootdir == NULL || iscd) + if (nr == i || !mountinfo.ui[i].open || mountinfo.ui[i].rootdir == NULL || is_hardfile (i) == FILESYS_CD) continue; if (rootdir && _tcslen (rootdir) > 0 && !_tcsicmp (mountinfo.ui[i].rootdir, rootdir)) { write_log (_T("directory/hardfile '%s' already added\n"), rootdir); @@ -726,7 +735,7 @@ void free_mountinfo (void) struct hardfiledata *get_hardfile_data (int nr) { UnitInfo *uip = mountinfo.ui; - if (nr < 0 || nr >= MAX_FILESYSTEM_UNITS || uip[nr].open == 0 || is_hardfile (nr) == FILESYS_VIRTUAL) + if (nr < 0 || nr >= MAX_FILESYSTEM_UNITS || uip[nr].open == 0 || is_virtual (nr)) return 0; return &uip[nr].hf; } @@ -1258,7 +1267,7 @@ int filesys_eject (int nr) return 0; if (!ui->open || u == NULL) return 0; - if (is_hardfile (nr) != FILESYS_VIRTUAL) + if (!is_virtual (nr)) return 0; if (!filesys_isvolume (u)) return 0; @@ -1281,14 +1290,14 @@ int filesys_insert (int nr, TCHAR *volume, const TCHAR *rootdir, bool readonly, return 0; if (nr < 0) { for (u = units; u; u = u->next) { - if (is_hardfile (u->unit) == FILESYS_VIRTUAL) { + if (is_virtual (u->unit)) { if (!filesys_isvolume (u) && mountinfo.ui[u->unit].canremove) break; } } if (!u) { for (u = units; u; u = u->next) { - if (is_hardfile (u->unit) == FILESYS_VIRTUAL) { + if (is_virtual (u->unit)) { if (mountinfo.ui[u->unit].canremove) break; } @@ -1307,7 +1316,7 @@ int filesys_insert (int nr, TCHAR *volume, const TCHAR *rootdir, bool readonly, return 0; if (u->reinsertdelay) return -1; - if (is_hardfile (nr) != FILESYS_VIRTUAL) + if (!is_virtual (nr)) return 0; if (filesys_isvolume (u)) { filesys_delayed_change (u, 50, rootdir, volume, readonly, flags); @@ -1441,7 +1450,7 @@ int filesys_media_change (const TCHAR *rootdir, int inserted, struct uaedev_conf return -1; nr = -1; for (u = units; u; u = u->next) { - if (is_hardfile (u->unit) == FILESYS_VIRTUAL) { + if (is_virtual (u->unit)) { ui = &mountinfo.ui[u->unit]; if (ui->rootdir && !memcmp (ui->rootdir, rootdir, _tcslen (rootdir)) && _tcslen (rootdir) + 3 >= _tcslen (ui->rootdir)) { if (filesys_isvolume (u) && inserted) { @@ -2339,6 +2348,34 @@ static Unit *startup_create_unit (UnitInfo *uinfo, int num) return unit; } + +static bool mount_cd (UnitInfo *uinfo, int nr, uae_u32 *ctime, uae_u64 *uniq) +{ + uinfo->cddevno = nr - cd_unit_offset; + if (!sys_command_open (uinfo->cddevno)) { + write_log (_T("Failed attempt to open CD unit %d\n"), uinfo->cddevno); + return false; + } + uinfo->cdfs_superblock = isofs_mount(uinfo->cddevno, uniq); + uinfo->wasisempty = true; + struct isofs_info ii; + if (isofs_mediainfo (uinfo->cdfs_superblock, &ii)) { + xfree (uinfo->volname); + if (ii.media) { + uinfo->wasisempty = false; + if (!ii.unknown_media) { + uinfo->volname = my_strdup (ii.volumename); + if (ctime) + *ctime = ii.creation; + set_highcyl (uinfo, ii.totalblocks); + } + } + uinfo->unknown_media = ii.unknown_media; + } + uinfo->cd_open = true; + return true; +} + #ifdef UAE_FILESYS_THREADS static void *filesys_thread (void *unit_v); #endif @@ -2352,7 +2389,7 @@ static void filesys_start_thread (UnitInfo *ui, int nr) ui->self = 0; } #ifdef UAE_FILESYS_THREADS - if (is_hardfile (nr) == FILESYS_VIRTUAL) { + if (is_virtual (nr)) { ui->unit_pipe = xmalloc (smp_comm_pipe, 1); ui->back_pipe = xmalloc (smp_comm_pipe, 1); init_comm_pipe (ui->unit_pipe, 100, 3); @@ -2360,10 +2397,15 @@ static void filesys_start_thread (UnitInfo *ui, int nr) uae_start_thread (_T("filesys"), filesys_thread, (void *)ui, &ui->tid); } #endif - if (isrestore ()) + if (isrestore ()) { + if (ui->unit_type == UNIT_CDFS) { + mount_cd (ui, nr, NULL, &ui->self->rootnode.uniq_external); + } startup_update_unit (ui->self, ui); + } } + static uae_u32 REGPARAM2 startup_handler (TrapContext *context) { /* Just got the startup packet. It's in A4. DosBase is in A2, @@ -2374,7 +2416,7 @@ static uae_u32 REGPARAM2 startup_handler (TrapContext *context) uaecptr pkt = m68k_dreg (regs, 3); uaecptr arg2 = get_long (pkt + dp_Arg2); uaecptr devnode; - int i; + int nr; TCHAR *devname = bstr1 (get_long (pkt + dp_Arg1) << 2); TCHAR *s; Unit *unit; @@ -2389,50 +2431,32 @@ static uae_u32 REGPARAM2 startup_handler (TrapContext *context) if (s) *s = '\0'; - for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) { + for (nr = 0; nr < MAX_FILESYSTEM_UNITS; nr++) { /* Hardfile volume name? */ - if (!mountinfo.ui[i].open) + if (!mountinfo.ui[nr].open) continue; - if (is_hardfile(i) != FILESYS_VIRTUAL) + if (!is_virtual (nr)) continue; - if (mountinfo.ui[i].startup == arg2) + if (mountinfo.ui[nr].startup == arg2) break; } - if (i == MAX_FILESYSTEM_UNITS) { + if (nr == MAX_FILESYSTEM_UNITS) { write_log (_T("Failed attempt to mount device '%s'\n"), devname); put_long (pkt + dp_Res1, DOS_FALSE); put_long (pkt + dp_Res2, ERROR_DEVICE_NOT_MOUNTED); return 0; } - uinfo = mountinfo.ui + i; - cdays = 3800 + i; + uinfo = mountinfo.ui + nr; + cdays = 3800 + nr; if (uinfo->unit_type == UNIT_CDFS) { ed = ef = 0; - uinfo->cddevno = i - cd_unit_offset; - if (!sys_command_open (uinfo->cddevno)) { - write_log (_T("Failed attempt to open CD unit %d\n"), uinfo->cddevno); + if (!mount_cd (uinfo, nr, &ctime, &uniq)) { put_long (pkt + dp_Res1, DOS_FALSE); put_long (pkt + dp_Res2, ERROR_DEVICE_NOT_MOUNTED); return 0; } - uinfo->cdfs_superblock = isofs_mount(uinfo->cddevno, &uniq); - uinfo->wasisempty = true; - struct isofs_info ii; - if (isofs_mediainfo (uinfo->cdfs_superblock, &ii)) { - xfree (uinfo->volname); - if (ii.media) { - uinfo->wasisempty = false; - if (!ii.unknown_media) { - uinfo->volname = my_strdup (ii.volumename); - ctime = ii.creation; - set_highcyl (uinfo, ii.totalblocks); - } - } - uinfo->unknown_media = ii.unknown_media; - } - uinfo->cd_open = true; } else { ed = my_existsdir (uinfo->rootdir); ef = my_existsfile (uinfo->rootdir); @@ -2446,9 +2470,9 @@ static uae_u32 REGPARAM2 startup_handler (TrapContext *context) if (!uinfo->unit_pipe) { late = 1; - filesys_start_thread (uinfo, i); + filesys_start_thread (uinfo, nr); } - unit = startup_create_unit (uinfo, i); + unit = startup_create_unit (uinfo, nr); unit->volflags = uinfo->volflags; unit->rootnode.uniq_external = uniq; @@ -6826,6 +6850,8 @@ static uae_u8 *restore_aino (UnitInfo *ui, Unit *u, uae_u8 *src) flags = restore_u32 (); if (flags & 1) a->elock = 1; + if (flags & 4) + a->uniq_external = restore_u64 (); /* full Amiga-side path without drive, eg. "C/SetPatch" */ p = restore_string (); /* root (p = volume label) */ @@ -6886,13 +6912,14 @@ static uae_u8 *restore_aino (UnitInfo *ui, Unit *u, uae_u8 *src) static uae_u8 *restore_key (UnitInfo *ui, Unit *u, uae_u8 *src) { - int savedsize, uniq; + int uniq; TCHAR *p, *pn; mode_t openmode; int err; int missing; a_inode *a; Key *k; + uae_u64 savedsize, size, pos; missing = 0; k = xcalloc (Key, 1); @@ -6903,8 +6930,12 @@ static uae_u8 *restore_key (UnitInfo *ui, Unit *u, uae_u8 *src) savedsize = restore_u32 (); uniq = restore_u64 (); p = restore_string (); - restore_u64 (); - restore_u64 (); + pos = restore_u64 (); + size = restore_u64 (); + if (size) { + savedsize = size; + k->file_pos = pos; + } pn = makenativepath (ui, p); openmode = ((k->dosmode & A_FIBF_READ) == 0 ? O_WRONLY : (k->dosmode & A_FIBF_WRITE) == 0 ? O_RDONLY @@ -6921,19 +6952,23 @@ static uae_u8 *restore_key (UnitInfo *ui, Unit *u, uae_u8 *src) write_log (_T("*** FS: Open file '%s' aino id %d != %d\n"), p, uniq, a->uniq); if (!my_existsfile (pn)) { write_log (_T("*** FS: Open file '%s' is missing, creating dummy file!\n"), p); - k->fd = fs_openfile (u, a, openmode | O_CREAT |O_BINARY); - if (k->fd) { - uae_u8 *buf = xcalloc (uae_u8, 10000); - int sp = savedsize; - while (sp) { - int s = sp >= 10000 ? 10000 : sp; - fs_write (k->fd, buf, s); - sp -= s; + if (savedsize < 10 * 1024 * 1024) { + k->fd = fs_openfile (u, a, openmode | O_CREAT |O_BINARY); + if (k->fd) { + uae_u8 *buf = xcalloc (uae_u8, 10000); + uae_u64 sp = savedsize; + while (sp) { + uae_u32 s = sp >= 10000 ? 10000 : sp; + fs_write (k->fd, buf, s); + sp -= s; + } + xfree(buf); + write_log (_T("*** FS: dummy file created\n")); + } else { + write_log (_T("*** FS: Open file '%s', couldn't create dummy file!\n"), p); } - xfree(buf); - write_log (_T("*** FS: dummy file created\n")); } else { - write_log (_T("*** FS: Open file '%s', couldn't create dummy file!\n"), p); + write_log (L"*** FS: Too big, ignored\n"); } } else { k->fd = fs_openfile (u, a, openmode | O_BINARY); @@ -6945,9 +6980,9 @@ static uae_u8 *restore_key (UnitInfo *ui, Unit *u, uae_u8 *src) uae_s64 s; s = fs_fsize64 (k->fd); if (s != savedsize) - write_log (_T("FS: restored file '%s' size changed! orig=%d, now=%d!!\n"), p, savedsize, s); + write_log (_T("FS: restored file '%s' size changed! orig=%I64d, now=%I64d!!\n"), p, savedsize, s); if (k->file_pos > s) { - write_log (_T("FS: restored filepos larger than size of file '%s'!! %d > %d\n"), p, k->file_pos, s); + write_log (_T("FS: restored filepos larger than size of file '%s'!! %I64d > %d\n"), p, k->file_pos, s); k->file_pos = s; } fs_lseek64 (k->fd, k->file_pos, SEEK_SET); @@ -7015,12 +7050,12 @@ static uae_u8 *restore_filesys_virtual (UnitInfo *ui, uae_u8 *src, int num) cnt = restore_u32 (); write_log (_T("FS: restoring %d locks\n"), cnt); while (cnt-- > 0) - src = restore_aino(ui, u, src); + src = restore_aino (ui, u, src); cnt = restore_u32 (); write_log (_T("FS: restoring %d open files\n"), cnt); while (cnt-- > 0) - src = restore_key(ui, u, src); + src = restore_key (ui, u, src); cnt = restore_u32 (); write_log (_T("FS: restoring %d notifications\n"), cnt); @@ -7035,7 +7070,7 @@ static uae_u8 *restore_filesys_virtual (UnitInfo *ui, uae_u8 *src, int num) return src; } -static TCHAR *getfullaname(a_inode *a) +static TCHAR *getfullaname (a_inode *a) { TCHAR *p; int first = 1; @@ -7068,15 +7103,18 @@ static int recurse_aino (UnitInfo *ui, a_inode *a, int cnt, uae_u8 **dstp) //write_log("recurse '%s' '%s' %d %08x\n", a->aname, a->nname, a->uniq, a->parent); if (a->elock || a->shlock || a->uniq == 0) { if (dst) { - TCHAR *fn; - write_log (_T("uniq=%d s=%d e=%d d=%d '%s' '%s'\n"), a->uniq, a->shlock, a->elock, a->dir, a->aname, a->nname); - fn = getfullaname(a); - write_log (_T("->'%s'\n"), fn); + TCHAR *fn = NULL; + write_log (_T("uniq=%d %I64d s=%d e=%d d=%d '%s' '%s'\n"), a->uniq, a->uniq_external, a->shlock, a->elock, a->dir, a->aname, a->nname); + if (a->aname) { + fn = getfullaname (a); + write_log (_T("->'%s'\n"), fn); + } save_u64 (a->uniq); save_u32 (a->locked_children); save_u32 (a->exnext_count); save_u32 (a->shlock); - save_u32 ((a->elock ? 1 : 0) | (a->dir ? 2 : 0)); + save_u32 ((a->elock ? 1 : 0) | (a->dir ? 2 : 0) | 4); + save_u64 (a->uniq_external); save_string (fn); xfree(fn); } @@ -7215,6 +7253,8 @@ uae_u8 *restore_filesys_common (uae_u8 *src) { if (restore_u32 () != 2) return src; + cd_unit_offset = MAX_FILESYSTEM_UNITS; + cd_unit_number = 0; filesys_prepare_reset2 (); filesys_reset2 (); a_uniq = restore_u64 (); @@ -7232,14 +7272,14 @@ uae_u8 *save_filesys (int num, int *len) if (!ui->open) return NULL; /* not initialized yet, do not save */ - if (type == FILESYS_VIRTUAL && (ui->self == NULL || ui->volname == NULL)) + if ((type == FILESYS_VIRTUAL || type == FILESYS_CD) && ui->self == NULL) return NULL; - write_log (_T("FS_FILESYS: '%s' '%s'\n"), ui->devname, ui->volname); + write_log (_T("FS_FILESYS: '%s' '%s'\n"), ui->devname, ui->volname ? ui->volname : _T("")); dstbak = dst = xmalloc (uae_u8, 100000); save_u32 (2); /* version */ save_u32 (ui->devno); save_u16 (type); - if (type == FILESYS_VIRTUAL) + if (type == FILESYS_VIRTUAL || type == FILESYS_CD) save_path (ui->rootdir, SAVESTATE_PATH_VDIR); else if (type == FILESYS_HARDFILE || type == FILESYS_HARDFILE_RDB) save_path (ui->rootdir, SAVESTATE_PATH_HDF); @@ -7254,7 +7294,7 @@ uae_u8 *save_filesys (int num, int *len) save_u8 (ui->readonly); save_u32 (ui->startup); save_u32 (filesys_configdev); - if (type == FILESYS_VIRTUAL) + if (type == FILESYS_VIRTUAL || type == FILESYS_CD) dst = save_filesys_virtual (ui, dst); if (type == FILESYS_HARDFILE || type == FILESYS_HARDFILE_RDB) dst = save_filesys_hardfile (ui, dst); @@ -7275,14 +7315,20 @@ uae_u8 *restore_filesys (uae_u8 *src) return src; devno = restore_u32 (); type = restore_u16 (); - if (type == FILESYS_VIRTUAL) + if (type == FILESYS_VIRTUAL) { rootdir = restore_path (SAVESTATE_PATH_VDIR); - else if (type == FILESYS_HARDFILE || type == FILESYS_HARDFILE_RDB) + } else if (type == FILESYS_CD) { + rootdir = restore_path (SAVESTATE_PATH_VDIR); + if (cd_unit_offset == MAX_FILESYSTEM_UNITS) + cd_unit_offset = devno; + cd_unit_number++; + } else if (type == FILESYS_HARDFILE || type == FILESYS_HARDFILE_RDB) { rootdir = restore_path (SAVESTATE_PATH_HDF); - else if (type == FILESYS_HARDDRIVE) + } else if (type == FILESYS_HARDDRIVE) { rootdir = restore_path (SAVESTATE_PATH_HD); - else + } else { rootdir = restore_path (SAVESTATE_PATH); + } devname = restore_string (); volname = restore_string (); filesysdir = restore_path (SAVESTATE_PATH); @@ -7304,7 +7350,7 @@ uae_u8 *restore_filesys (uae_u8 *src) } ui->devno = devno; ui->startup = startup; - if (type == FILESYS_VIRTUAL) + if (type == FILESYS_VIRTUAL || type == FILESYS_CD) src = restore_filesys_virtual (ui, src, devno); write_log (_T("'%s' restored\n"), rootdir); end: diff --git a/hardfile.cpp b/hardfile.cpp index bd81179e..d9ef11e6 100644 --- a/hardfile.cpp +++ b/hardfile.cpp @@ -1562,7 +1562,7 @@ static uae_u32 REGPARAM2 hardfile_open (TrapContext *context) return 0; } } - if (unit < 1000 || is_hardfile (unit) == FILESYS_VIRTUAL) + if (unit < 1000 || is_hardfile (unit) == FILESYS_VIRTUAL || is_hardfile (unit) == FILESYS_CD) err = 50; /* HFERR_NoBoard */ } else { err = IOERR_BADLENGTH; diff --git a/include/gensound.h b/include/gensound.h index 2d79c2ed..94f211e6 100644 --- a/include/gensound.h +++ b/include/gensound.h @@ -12,7 +12,7 @@ extern int sound_available; extern void (*sample_handler) (void); /* sample_evtime is in normal Amiga cycles; scaled_sample_evtime is in our event cycles. */ -extern float sample_evtime, scaled_sample_evtime; +extern float scaled_sample_evtime; /* Determine if we can produce any sound at all. This can be only a guess; * if unsure, say yes. Any call to init_sound may change the value. */ @@ -22,13 +22,8 @@ extern int init_sound (void); extern void close_sound (void); extern void sample16_handler (void); -extern void sample16i_rh_handler (void); -extern void sample16i_crux_handler (void); extern void sample8_handler (void); extern void sample16s_handler (void); -extern void sample16si_anti_handler (void); extern void sample16ss_handler (void); -extern void sample16si_rh_handler (void); -extern void sample16si_crux_handler (void); extern void sample8s_handler (void); diff --git a/include/sysdeps.h b/include/sysdeps.h index c80de382..c0ce29e5 100644 --- a/include/sysdeps.h +++ b/include/sysdeps.h @@ -231,6 +231,8 @@ typedef uae_u32 uaecptr; extern TCHAR *my_strdup (const TCHAR*s); #endif extern TCHAR *my_strdup_ansi (const char*); +extern void my_trim (TCHAR*); +extern TCHAR *my_strdup_trim (const TCHAR*); extern TCHAR *au (const char*); extern char *ua (const TCHAR*); extern TCHAR *aucp (const char *s, unsigned int cp); diff --git a/main.cpp b/main.cpp index 29fe0e6f..e885b28b 100644 --- a/main.cpp +++ b/main.cpp @@ -102,6 +102,32 @@ uae_u32 uaerandgetseed (void) return randseed; } +void my_trim (TCHAR *s) +{ + int len; + while (_tcscspn (s, _T("\t \r\n")) == 0) + memmove (s, s + 1, (_tcslen (s + 1) + 1) * sizeof TCHAR); + len = _tcslen (s); + while (len > 0 && _tcscspn (s + len - 1, _T("\t \r\n")) == 0) + s[--len] = '\0'; +} + +TCHAR *my_strdup_trim (const TCHAR *s) +{ + TCHAR *out; + int len; + + while (_tcscspn (s, _T("\t \r\n")) == 0) + s++; + len = _tcslen (s); + while (len > 0 && _tcscspn (s + len - 1, _T("\t \r\n")) == 0) + len--; + out = xmalloc (TCHAR, len + 1); + memcpy (out, s, len * sizeof TCHAR); + out[len] = 0; + return out; +} + void discard_prefs (struct uae_prefs *p, int type) { struct strlist **ps = &p->all_lines; diff --git a/od-win32/dinput.cpp b/od-win32/dinput.cpp index 83cf1011..0c5bc4a5 100644 --- a/od-win32/dinput.cpp +++ b/od-win32/dinput.cpp @@ -1497,11 +1497,18 @@ static bool initialize_rawinput (void) first = last = bcaps[i].NotRange.Usage; } for (j = first; j <= last && buttoncnt < MAX_MAPPINGS; j++) { - did->buttonsort[buttoncnt] = j * 2; - did->buttonmappings[buttoncnt] = j; - _stprintf (tmp, _T("Button %d"), j); - did->buttonname[buttoncnt] = my_strdup (tmp); - buttoncnt++; + int k; + for (k = 0; k < buttoncnt; k++) { + if (did->buttonmappings[k] == j) + break; + } + if (k == buttoncnt) { + did->buttonsort[buttoncnt] = j * 2; + did->buttonmappings[buttoncnt] = j; + _stprintf (tmp, _T("Button %d"), j); + did->buttonname[buttoncnt] = my_strdup (tmp); + buttoncnt++; + } } } if (buttoncnt > 0) { diff --git a/od-win32/direct3d.cpp b/od-win32/direct3d.cpp index 09ebdd10..22a822d9 100644 --- a/od-win32/direct3d.cpp +++ b/od-win32/direct3d.cpp @@ -1683,8 +1683,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; - float sh2 = dh * tin_h / window_h; + float sw2 = dw * tin_w / window_w - 0.5f; + float sh2 = dh * tin_h / window_h + 0.5f; maskmult.x = sw2 * maskmult_x / w; maskmult.y = sh2 * maskmult_y / h; @@ -2318,6 +2318,8 @@ bool D3D_alloctexture (int w, int h) tout_w = tin_w * multx; tout_h = tin_h * multx; + changed_prefs.leds_on_screen = currprefs.leds_on_screen = currprefs.leds_on_screen | STATUSLINE_TARGET; + if (!createamigatexture (tin_w, tin_h)) return false; return true; diff --git a/od-win32/win32.cpp b/od-win32/win32.cpp index a3d17356..fc2ef579 100644 --- a/od-win32/win32.cpp +++ b/od-win32/win32.cpp @@ -2813,6 +2813,19 @@ void target_fixup_options (struct uae_prefs *p) p->win32_inactive_pause = p->win32_inactive_nosound = true; nosound = true; } + + /* switch from 32 to 16 or vice versa if mode does not exist */ + struct MultiDisplay *md = getdisplay (p); + int depth = p->color_mode == 5 ? 4 : 2; + for (int i = 0; md->DisplayModes[i].depth >= 0; i++) { + if (md->DisplayModes[i].depth == depth) { + depth = 0; + break; + } + } + if (depth) { + p->color_mode = p->color_mode == 5 ? 2 : 5; + } } void target_default_options (struct uae_prefs *p, int type) @@ -2862,20 +2875,6 @@ void target_default_options (struct uae_prefs *p, int type) WIN32GUI_LoadUIString (IDS_INPUT_CUSTOM, buf, sizeof buf / sizeof (TCHAR)); for (int i = 0; i < GAMEPORT_INPUT_SETTINGS; i++) _stprintf (p->input_config_name[i], buf, i + 1); - - /* switch from 32 to 16 or vice versa if mode does not exist */ - struct MultiDisplay *md = getdisplay (p); - int depth = currprefs.color_mode == 5 ? 4 : 2; - for (int i = 0; md->DisplayModes[i].depth >= 0; i++) { - if (md->DisplayModes[i].depth == depth) { - depth = 0; - break; - } - } - if (depth) { - currprefs.color_mode = currprefs.color_mode == 5 ? 2 : 5; - } - } if (type == 1 || type == 0) { p->win32_uaescsimode = UAESCSI_CDEMU; diff --git a/od-win32/win32.h b/od-win32/win32.h index fb9ff964..4eee3831 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 2") -#define WINUAEDATE MAKEBD(2012, 4, 1) +#define WINUAEBETA _T("Beta 3") +#define WINUAEDATE MAKEBD(2012, 4, 3) #define WINUAEEXTRA _T("") //#define WINUAEEXTRA _T("AmiKit Preview") #define WINUAEREV _T("") diff --git a/od-win32/win32_scaler.cpp b/od-win32/win32_scaler.cpp index e59cd0c3..7f58ce58 100644 --- a/od-win32/win32_scaler.cpp +++ b/od-win32/win32_scaler.cpp @@ -77,75 +77,10 @@ static void getinit (void) } } -static int vblscale (int v) -{ - static int o; - int n, v2, vo; - - if (!isnativevidbuf ()) - return v; - n = (beamcon0 & 0x80) + maxvpos_nom; - if (n != o) - cleartemp = 1; - o = n; - if (beamcon0 & 0x80) - return v; - if (currprefs.ntscmode) - v2 = MAXVPOS_NTSC; - else - v2 = MAXVPOS_PAL; - if (abs (v2 - maxvpos_nom) <= 3) - return v; - vo = v * maxvpos_nom / v2; - if (vo > v + 60) - vo = v + 60; - else if (vo < v - 60) - vo = v - 60; - return vo; -} -static int vblscale2 (int v) -{ - static int o; - int n, vo; - - if (!isnativevidbuf ()) - return v; - n = (beamcon0 & 0x80) + maxvpos_nom; - if (n != o) - cleartemp = 1; - o = n; - if (beamcon0 & 0x80) - return v; - vo = v * maxvpos_nom / MAXVPOS_PAL; - if (vo > v + 60) - vo = v + 60; - else if (vo < v - 60) - vo = v - 60; - return v; -} - -static void fixh (int *ah, int minh) -{ - if (!isnativevidbuf ()) - return; - if (!(beamcon0 & 0x80)) { - int max = (AMIGA_HEIGHT_MAX * scale) << currprefs.gfx_vresolution; - if (*ah > AMIGA_HEIGHT_MAX * 2) - return; - if (minh && max < minh) - max = minh; - if (*ah > max) - *ah = max; - - } -} - static uae_u8 *getfilterrect1 (RECT *sr, RECT *dr, int dst_width, int dst_height, int dst_depth, int aw, int ah, int scale, int temp_width, int temp_height, uae_u8 *dptr, int pitch) { int aws, ahs; - fixh (&ah, dst_height); - aws = aw * scale; ahs = ah * scale; @@ -199,402 +134,12 @@ static void getmanualpos (int *cxp, int *cyp, int *cwp, int *chp) *chp = ch; } -#if 0 - -void getfilterrect2 (RECT *sr, RECT *dr, RECT *zr, int dst_width, int dst_height, int aw, int ah, int scale, int temp_width, int temp_height) -{ - float srcratio, dstratio; - int aws, ahs, ahs2; - int xs, ys; - int v; - int extraw, extrah; - int fpuv; - - int filter_horiz_zoom = currprefs.gfx_filter_horiz_zoom; - int filter_vert_zoom = currprefs.gfx_filter_vert_zoom; - int filter_horiz_zoom_mult = currprefs.gfx_filter_horiz_zoom_mult; - int filter_vert_zoom_mult = currprefs.gfx_filter_vert_zoom_mult; - int filter_horiz_offset = currprefs.gfx_filter_horiz_offset; - int filter_vert_offset = currprefs.gfx_filter_vert_offset; - - if (!usedfilter && !currprefs.gfx_api) { - filter_horiz_zoom = filter_vert_zoom = 0; - filter_horiz_zoom_mult = filter_vert_zoom_mult = 1000; - filter_horiz_offset = filter_vert_offset = 0; - } - - if (screen_is_picasso) { - getrtgfilterrect2 (sr, dr, zr, dst_width, dst_height); - return; - } - - fpux_save (&fpuv); - - fixh (&ah, dst_height); - - getinit (); - ahs2 = vblscale (ah) * scale; - aws = aw * scale; - ahs = ah * scale; - //write_log (_T("%d %d %d\n"), dst_width, temp_width, aws); - extraw = -aws * (filter_horiz_zoom - currprefs.gfx_filteroverlay_overscan * 10) / 2000; - extrah = -ahs * (filter_vert_zoom - currprefs.gfx_filteroverlay_overscan * 10) / 2000; - - SetRect (sr, 0, 0, dst_width, dst_height); - SetRect (zr, 0, 0, 0, 0); - dr->left = (temp_width - aws) / 2; - dr->top = (temp_height - ahs) / 2; - - filteroffsetx = 0; - filteroffsety = 0; - float xmult = filter_horiz_zoom_mult; - float ymult = filter_vert_zoom_mult; - - dr->left -= (dst_width - aws) / 2; - dr->top -= (dst_height - ahs) / 2; - dr->right = dr->left + dst_width; - dr->bottom = dr->top + dst_height; - - srcratio = 4.0 / 3.0; - if (currprefs.gfx_filter_aspect > 0) { - dstratio = (currprefs.gfx_filter_aspect >> 8) * 1.0 / (currprefs.gfx_filter_aspect & 0xff); - } else if (currprefs.gfx_filter_aspect < 0) { - if (isfullscreen () && deskw > 0 && deskh > 0) - dstratio = 1.0 * deskw / deskh; - else - dstratio = 1.0 * dst_width / dst_height; - } else { - dstratio = srcratio; - } - - int scalemode = currprefs.gfx_filter_autoscale; - - if (scalemode == AUTOSCALE_STATIC_AUTO) { - if (0) { - scalemode = AUTOSCALE_STATIC_NOMINAL; - } else { - int w1 = (800 / 2) << currprefs.gfx_resolution; - int w2 = (640 / 2) << currprefs.gfx_resolution; - int h1 = (600 / 2) << currprefs.gfx_vresolution; - int h2 = (400 / 2) << currprefs.gfx_vresolution; - int w = currprefs.gfx_size_win.width; - int h = currprefs.gfx_size_win.height; - if (w <= w1 && h <= h1 && w >= w2 && h >= h2) - scalemode = AUTOSCALE_NONE; - else - scalemode = AUTOSCALE_STATIC_NOMINAL; - } - } - - if (scalemode) { - int cw, ch, cx, cy, cv; - static int oxmult, oymult; - - filterxmult = 1000 / scale; - filterymult = 1000 / scale; - - if (scalemode == AUTOSCALE_STATIC_MAX || scalemode == AUTOSCALE_STATIC_NOMINAL || scalemode == AUTOSCALE_INTEGER) { - cw = AMIGA_WIDTH_MAX << currprefs.gfx_resolution; - ch = AMIGA_HEIGHT_MAX << currprefs.gfx_vresolution; - cx = 0; - cy = 0; - cv = 1; - if (scalemode == AUTOSCALE_STATIC_NOMINAL || scalemode == AUTOSCALE_INTEGER) { - cw -= 40 << currprefs.gfx_resolution; - ch -= 25 << currprefs.gfx_vresolution; - cx = 28 << currprefs.gfx_resolution; - cy = 10 << currprefs.gfx_vresolution; - } - - if (scalemode == AUTOSCALE_INTEGER) { - int maxw = currprefs.gfx_size.width; - int maxh = currprefs.gfx_size.height; - int mult = 1; - - if (currprefs.gfx_xcenter_pos > 0 || currprefs.gfx_xcenter_size > 0) - getmanualpos (&cx, &cy, &cw, &ch); - - if (cw > maxw || ch > maxh) { - while (cw / mult > maxw || ch / mult > maxh) - mult *= 2; - maxw = maxw * mult; - maxh = maxh * mult; - } else { - while (cw * (mult * 2) <= maxw && ch * (mult * 2) <= maxh) - mult *= 2; - maxw = (maxw + mult - 1) / mult; - maxh = (maxh + mult - 1) / mult; - } - //write_log(_T("(%dx%d) (%dx%d) ww=%d hh=%d w=%d h=%d m=%d\n"), cx, cy, cw, ch, currprefs.gfx_size.width, currprefs.gfx_size.height, maxw, maxh, mult); - cx -= (maxw - cw) / 2; - cw = maxw; - cy -= (maxh - ch) / 2; - ch = maxh; - } - - } else if (scalemode == AUTOSCALE_MANUAL) { - - changed_prefs.gfx_filter_horiz_offset = currprefs.gfx_filter_horiz_offset = 0; - changed_prefs.gfx_filter_vert_offset = currprefs.gfx_filter_vert_offset = 0; - filter_horiz_offset = 0; - filter_vert_offset = 0; - - get_custom_topedge (&cx, &cy); - //write_log (_T("%dx%d %dx%d\n"), cx, cy, currprefs.gfx_resolution, currprefs.gfx_vresolution); - - getmanualpos (&cx, &cy, &cw, &ch); - - //write_log (_T("%dx%d %dx%d %dx%d\n"), currprefs.gfx_xcenter_pos, currprefs.gfx_ycenter_pos, cx, cy, cw, ch); - - cv = 1; - - } else { - - cv = get_custom_limits (&cw, &ch, &cx, &cy); - - } - - if (currprefs.gfx_api == 0) { - if (cx < 0) - cx = 0; - if (cy < 0) - cy = 0; - } - - if (cv) { - int diff; - - if (scalemode == AUTOSCALE_CENTER) { - - int ww = cw * scale; - int hh = ch * scale; - SetRect (sr, 0, 0, dst_width, dst_height); - SetRect (zr, 0, 0, 0, 0); - dr->left = dr->top = 0; - dr->right = dr->left + dst_width; - dr->bottom = dr->top + dst_height; - OffsetRect (zr, cx * scale - (dst_width - ww) / 2, cy * scale - (dst_height - hh) / 2); - goto cont; - - } else if (scalemode == AUTOSCALE_RESIZE && isfullscreen () == 0 && !currprefs.gfx_filteroverlay[0]) { - - static int lastresize = 0; - static int lastdelay = 1; - static int ocw, och, ocx, ocy, lcw, lch, lcx, lcy; - int useold = 0; - - lastresize--; - if (lastresize > 0) { - if (cw != lcw || ch != lch || cx != lcx || cy != lcy) - lastresize = 10; - useold = 1; - } else if (lastdelay == 0) { - lastdelay = 2; - useold = 1; - } else if (lastdelay > 0) { - lastdelay--; - useold = 1; - if (lastdelay == 0) { - lastdelay = -1; - useold = 0; - } - } - - lcw = cw; - lch = ch; - lcx = cx; - lcy = cy; - if (useold && !config_changed) { - cw = ocw; - ch = och; - cx = ocx; - cy = ocy; - } else { - ocw = cw; - och = ch; - ocx = cx; - ocy = cy; - lastresize = 10; - lastdelay = 0; - } - double scalex = currprefs.gfx_filter_horiz_zoom_mult > 0 ? 1000.0 / currprefs.gfx_filter_horiz_zoom_mult : 1.0; - double scaley = currprefs.gfx_filter_vert_zoom_mult > 0 ? 1000.0 / currprefs.gfx_filter_vert_zoom_mult : 1.0; - SetRect (sr, 0, 0, cw * scale * scalex, ch * scale * scaley); - dr->left = (temp_width - aws) /2; - dr->top = (temp_height - ahs) / 2; - dr->right = dr->left + cw * scale; - dr->bottom = dr->top + ch * scale; - OffsetRect (zr, cx * scale, cy * scale); - int ww = (dr->right - dr->left) * scalex; - int hh = (dr->bottom - dr->top) * scaley; - if (currprefs.gfx_xcenter_size >= 0) - ww = currprefs.gfx_xcenter_size; - if (currprefs.gfx_ycenter_size >= 0) - hh = currprefs.gfx_ycenter_size; - int oldwinw = currprefs.gfx_size_win.width; - int oldwinh = currprefs.gfx_size_win.width; - changed_prefs.gfx_size_win.width = ww; - changed_prefs.gfx_size_win.height = hh; - fixup_prefs_dimensions (&changed_prefs); - if (oldwinw != changed_prefs.gfx_size_win.width || oldwinh != changed_prefs.gfx_size_win.height) - config_changed = 1; - OffsetRect (zr, -(changed_prefs.gfx_size_win.width - ww + 1) / 2, -(changed_prefs.gfx_size_win.height - hh + 1) / 2); - filteroffsetx = -zr->left / scale; - filteroffsety = -zr->top / scale; - goto end; - } - - dr->left = (temp_width - aws) /2; - dr->top = (temp_height - ahs) / 2; - dr->right = dr->left + dst_width * scale; - dr->bottom = dr->top + dst_height * scale; - - OffsetRect (zr, cx * scale, cy * scale); - - sizeoffset (dr, zr, extraw, extrah); - - dr->right -= (dst_width - cw) * scale; - dr->bottom -= (dst_height - ch) * scale; - - filteroffsetx = -zr->left / scale; - filteroffsety = -zr->top / scale; - - if (currprefs.gfx_filter_keep_aspect || currprefs.gfx_filter_aspect != 0) { - int diffx = dr->right - dr->left; - int diffy = dr->bottom - dr->top; - float xmult = 1.0; - float ymult = 1.0; - - if (currprefs.gfx_filter_keep_aspect) { - if (currprefs.ntscmode) { - dstratio = dstratio * 1.21; - if (currprefs.gfx_filter_keep_aspect == 2 && ispal ()) - dstratio = dstratio * 0.93; - else if (currprefs.gfx_filter_keep_aspect == 1 && !ispal ()) - dstratio = dstratio * 0.98; - } else { - if (currprefs.gfx_filter_keep_aspect == 2 && ispal ()) - dstratio = dstratio * 0.95; - else if (currprefs.gfx_filter_keep_aspect == 1 && !ispal ()) - dstratio = dstratio * 0.95; - } - } - - if (srcratio > dstratio) { - ymult = ymult * srcratio / dstratio; - } else { - xmult = xmult * dstratio / srcratio; - } - - diff = diffx - diffx * xmult; - sizeoffset (dr, zr, diff, 0); - filteroffsetx += diff / 2; - - diff = diffy - diffy * ymult; - sizeoffset (dr, zr, 0, diff); - filteroffsety += diff / 2; - } - - v = filter_horiz_offset; - OffsetRect (zr, (int)(-v * aws / 1000.0), 0); - v = filter_vert_offset; - OffsetRect (zr, 0, (int)(-v * ahs / 1000.0)); - - diff = dr->right - dr->left; - filterxmult = diff * 1000 / (dst_width * scale); - diff = dr->bottom - dr->top; - filterymult = diff * 1000 / (dst_height * scale); - goto end; - } - - } -cont: - if (!filter_horiz_zoom_mult && !filter_vert_zoom_mult) { - - sizeoffset (dr, zr, extraw, extrah); - - if (currprefs.gfx_filter_keep_aspect) { - float xm, ym, m; - - xm = 1.0 * aws / dst_width; - ym = 1.0 * ahs / dst_height; - if (xm < ym) - xm = ym; - else - ym = xm; - xmult = ymult = xm * 1000.0; - - m = (aws * 1.0 / dst_width) / (ahs * 1.0 / dst_height); - dstratio = dstratio * m; - } - - } - - if (currprefs.ntscmode) { - if (currprefs.gfx_filter_keep_aspect == 2 && ispal ()) - dstratio = dstratio * 0.93; - else if (currprefs.gfx_filter_keep_aspect == 1 && !ispal ()) - dstratio = dstratio * 0.98; - } else { - if (currprefs.gfx_filter_keep_aspect == 2 && ispal ()) - dstratio = dstratio * 0.95; - else if (currprefs.gfx_filter_keep_aspect == 1 && !ispal ()) - dstratio = dstratio * 0.95; - } - - if (srcratio > dstratio) { - ymult = ymult * srcratio / dstratio; - } else { - xmult = xmult * dstratio / srcratio; - } - - if (xmult <= 0.01) - xmult = aws * 1000 / dst_width; - else - xmult = xmult + xmult * filter_horiz_zoom / 2000; - if (ymult <= 0.01) - ymult = ahs * 1000 / dst_height; - else - ymult = ymult + ymult * filter_vert_zoom / 2000; - - if (!filter_horiz_zoom_mult && !filter_vert_zoom_mult) { - if (currprefs.ntscmode) { - int v = vblscale2 (ahs); - ymult /= 1.21; - OffsetRect (dr, 0, (v - ahs2) / 2); - } - } - - ymult = vblscale (ymult); - OffsetRect (dr, 0, (ahs2 - ahs) / 2); - - v = filter_horiz_offset; - OffsetRect (zr, (int)(-v * aws / 1000.0), 0); - v = filter_vert_offset; - OffsetRect (zr, 0, (int)(-v * ahs / 1000.0)); - - xs = dst_width - dst_width * xmult / 1000; - ys = dst_height - dst_height * ymult / 1000; - sizeoffset (dr, zr, xs, ys); - - filterxmult = xmult; - filterymult = ymult; - filteroffsetx += (dst_width - aw * 1000 / filterxmult) / 2; - filteroffsety += (dst_height - ah * 1000 / filterymult) / 2; - -end: - fpux_restore (&fpuv); - -} - -#else - extern bool getscalerect (float *mx, float *my, float *sx, float *sy); void getfilterrect2 (RECT *sr, RECT *dr, RECT *zr, int dst_width, int dst_height, int aw, int ah, int scale, int temp_width, int temp_height) { float srcratio, dstratio; - int aws, ahs, ahs2; + int aws, ahs; int xs, ys; int v; int extraw, extrah; @@ -624,10 +169,7 @@ void getfilterrect2 (RECT *sr, RECT *dr, RECT *zr, int dst_width, int dst_height fpux_save (&fpuv); - fixh (&ah, dst_height); - getinit (); - ahs2 = vblscale (ah) * scale; aws = aw * scale; ahs = ah * scale; //write_log (_T("%d %d %d\n"), dst_width, temp_width, aws); @@ -702,15 +244,15 @@ void getfilterrect2 (RECT *sr, RECT *dr, RECT *zr, int dst_width, int dst_height cw = gfxvidinfo.outbuffer->outwidth; ch = gfxvidinfo.outbuffer->outheight; } else { - cw = AMIGA_WIDTH_MAX << currprefs.gfx_resolution; - ch = AMIGA_HEIGHT_MAX << currprefs.gfx_vresolution; + cw = gfxvidinfo.drawbuffer.inwidth; + ch = gfxvidinfo.drawbuffer.inheight; cx = 0; cy = 0; cv = 1; - if (scalemode == AUTOSCALE_STATIC_NOMINAL || scalemode == AUTOSCALE_INTEGER) { - cw -= 50 << currprefs.gfx_resolution; + if (!(beamcon0 & 0x80) && (scalemode == AUTOSCALE_STATIC_NOMINAL || scalemode == AUTOSCALE_INTEGER)) { + cw -= 40 << currprefs.gfx_resolution; ch -= 25 << currprefs.gfx_vresolution; - cx = 18 << currprefs.gfx_resolution; + cx = 28 << currprefs.gfx_resolution; cy = 10 << currprefs.gfx_vresolution; } } @@ -968,15 +510,10 @@ cont: if (!filter_horiz_zoom_mult && !filter_vert_zoom_mult) { if (currprefs.ntscmode) { - int v = vblscale2 (ahs); ymult /= 1.21; - OffsetRect (dr, 0, (v - ahs2) / 2); } } - ymult = vblscale (ymult); - OffsetRect (dr, 0, (ahs2 - ahs) / 2); - v = filter_horiz_offset; OffsetRect (zr, (int)(-v * aws / 1000.0), 0); v = filter_vert_offset; @@ -1001,7 +538,6 @@ end: fpux_restore (&fpuv); } -#endif uae_u8 *getfilterbuffer (int *widthp, int *heightp, int *pitch, int *depth) { diff --git a/od-win32/win32gfx.cpp b/od-win32/win32gfx.cpp index 98df27f3..897abef0 100644 --- a/od-win32/win32gfx.cpp +++ b/od-win32/win32gfx.cpp @@ -615,6 +615,8 @@ static BOOL CALLBACK monitorEnumProc (HMONITOR h, HDC hdc, LPRECT rect, LPARAM d _stprintf (tmp, _T("%s (%d*%d)"), md->monitorname, md->rect.right - md->rect.left, md->rect.bottom - md->rect.top); else _stprintf (tmp, _T("%s (%d*%d) [%d*%d]"), md->monitorname, md->rect.right - md->rect.left, md->rect.bottom - md->rect.top, md->rect.left, md->rect.top); + if (md->primary) + _tcscat (tmp, _T(" *")); xfree (md->fullname); md->fullname = my_strdup (tmp); return TRUE; @@ -631,28 +633,30 @@ void enumeratedisplays (void) DISPLAY_DEVICE add; add.cb = sizeof add; while (EnumDisplayDevices (NULL, adapterindex, &add, 0)) { - int monitorindex = 0; + adapterindex++; if (!(add.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) continue; if (add.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) continue; if (md - Displays >= MAX_DISPLAYS) - return; + break; + + int monitorindex = 0; DISPLAY_DEVICE mdd; mdd.cb = sizeof mdd; while (EnumDisplayDevices (add.DeviceName, monitorindex, &mdd, 0)) { monitorindex++; if (md - Displays >= MAX_DISPLAYS) - return; + break; if (!(mdd.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) continue; if (mdd.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) continue; - md->adaptername = my_strdup (add.DeviceString); + md->adaptername = my_strdup_trim (add.DeviceString); md->adapterid = my_strdup (add.DeviceName); md->adapterkey = my_strdup (add.DeviceID); - md->monitorname = my_strdup (mdd.DeviceString); + md->monitorname = my_strdup_trim (mdd.DeviceString); md->monitorid = my_strdup (mdd.DeviceKey); if (add.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) md->primary = true; @@ -661,10 +665,10 @@ void enumeratedisplays (void) if (md - Displays >= MAX_DISPLAYS) return; if (monitorindex == 0) { - md->adaptername = my_strdup (add.DeviceString); + md->adaptername = my_strdup_trim (add.DeviceString); md->adapterid = my_strdup (add.DeviceName); md->adapterkey = my_strdup (add.DeviceID); - md->monitorname = my_strdup (add.DeviceString); + md->monitorname = my_strdup_trim (add.DeviceString); md->monitorid = my_strdup (add.DeviceKey); md->primary = true; } @@ -674,7 +678,7 @@ void enumeratedisplays (void) void sortdisplays (void) { - struct MultiDisplay *md1; + struct MultiDisplay *md; int i, idx; int w = GetSystemMetrics (SM_CXSCREEN); @@ -688,23 +692,23 @@ void sortdisplays (void) write_log (_T("Desktop: W=%d H=%d B=%d. CXVS=%d CYVS=%d\n"), w, h, b, GetSystemMetrics (SM_CXVIRTUALSCREEN), GetSystemMetrics (SM_CYVIRTUALSCREEN)); - md1 = Displays; - while (md1->monitorname) { - md1->DisplayModes = xmalloc (struct PicassoResolution, MAX_PICASSO_MODES); - md1->DisplayModes[0].depth = -1; + md = Displays; + while (md->monitorname) { + md->DisplayModes = xmalloc (struct PicassoResolution, MAX_PICASSO_MODES); + md->DisplayModes[0].depth = -1; - write_log (_T("%s [%s]\n"), md1->adaptername, md1->monitorname); - write_log (_T("-: %d*%d [%d*%d]\n"), md1->rect.right - md1->rect.left, md1->rect.bottom - md1->rect.top, md1->rect.left, md1->rect.top); + write_log (_T("%s [%s]\n"), md->adaptername, md->adapterid); + write_log (_T("-: %s\n"), md->fullname); for (int mode = 0; mode < 2; mode++) { DEVMODE dm; dm.dmSize = sizeof dm; dm.dmDriverExtra = 0; idx = 0; - while (EnumDisplaySettingsEx (md1->adapterid, idx, &dm, mode ? EDS_RAWMODE : 0)) { + while (EnumDisplaySettingsEx (md->adapterid, idx, &dm, mode ? EDS_RAWMODE : 0)) { int found = 0; int idx2 = 0; - while (md1->DisplayModes[idx2].depth >= 0 && !found) { - struct PicassoResolution *pr = &md1->DisplayModes[idx2]; + while (md->DisplayModes[idx2].depth >= 0 && !found) { + struct PicassoResolution *pr = &md->DisplayModes[idx2]; if (pr->res.width == dm.dmPelsWidth && pr->res.height == dm.dmPelsHeight && pr->depth == dm.dmBitsPerPel / 8) { for (i = 0; pr->refresh[i]; i++) { if (pr->refresh[i] == dm.dmDisplayFrequency) { @@ -722,20 +726,20 @@ void sortdisplays (void) dm.dmPelsWidth, dm.dmPelsHeight, dm.dmBitsPerPel, dm.dmDisplayFrequency, dm.dmFields); #endif if ((dm.dmFields & DM_PELSWIDTH) && (dm.dmFields & DM_PELSHEIGHT) && (dm.dmFields & DM_BITSPERPEL)) { - addmode (md1, &dm, mode); + addmode (md, &dm, mode); } } idx++; } } //dhack(); - sortmodes (md1); - modesList (md1); + sortmodes (md); + modesList (md); i = 0; - while (md1->DisplayModes[i].depth > 0) + while (md->DisplayModes[i].depth > 0) i++; write_log (_T("%d display modes.\n"), i); - md1++; + md++; } } @@ -872,11 +876,9 @@ bool render_screen (void) EnterCriticalSection (&screen_cs); if (currentmode->flags & DM_D3D) { v = D3D_renderframe (); -#ifdef GFXFILTER } else if (currentmode->flags & DM_SWSCALE) { S2X_render (); v = true; -#endif } else if (currentmode->flags & DM_DDRAW) { v = true; } @@ -3154,6 +3156,8 @@ static void allocsoftbuffer (const TCHAR *name, struct vidbuffer *buf, int flags buf->bufmem_allocated = NULL; buf->bufmem_lockable = true; + write_log (_T("Reserved %s temp buffer (%d*%d*%d)\n"), name, width, height, depth); + } else if (flags & DM_SWSCALE) { int w = buf->width_allocated * 2; @@ -3177,6 +3181,8 @@ static int create_windows (void) return set_ddraw (); } +static int oldtex_w, oldtex_h, oldtex_rtg; + static BOOL doInit (void) { int fs_warning = -1; @@ -3317,8 +3323,13 @@ static BOOL doInit (void) if (!screen_is_picasso) { - allocsoftbuffer (_T("draw"), &gfxvidinfo.drawbuffer, currentmode->flags, - 1600, 1280, currentmode->current_depth); + if (currprefs.gfx_api == 0 && currprefs.gfx_filter == 0) { + allocsoftbuffer (_T("draw"), &gfxvidinfo.drawbuffer, currentmode->flags, + currentmode->native_width, currentmode->native_height, currentmode->current_depth); + } else { + allocsoftbuffer (_T("draw"), &gfxvidinfo.drawbuffer, currentmode->flags, + 1600, 1280, currentmode->current_depth); + } if (currprefs.monitoremu) { allocsoftbuffer (_T("monemu"), &gfxvidinfo.tempbuffer, currentmode->flags, currentmode->amiga_width > 1024 ? currentmode->amiga_width : 1024, @@ -3344,6 +3355,8 @@ static BOOL doInit (void) ret = -1; goto oops; } + oldtex_w = oldtex_h = -1; + target_graphics_buffer_update (); } screen_is_initialized = 1; @@ -3372,13 +3385,19 @@ bool target_graphics_buffer_update (void) w = vb->outwidth; h = vb->outheight; } - - write_log (_T("Buffer size (%d*%d)\n"), w, h); + + if (oldtex_w == w && oldtex_h == h && oldtex_rtg == screen_is_picasso) + return true; + oldtex_w = w; + oldtex_h = h; + oldtex_rtg = screen_is_picasso; + + write_log (_T("Buffer size (%d*%d) %s\n"), w, h, screen_is_picasso ? _T("RTG") : _T("Native")); + S2X_free (); if (currentmode->flags & DM_D3D) { D3D_alloctexture (w, h); } - S2X_free (); if (currentmode->flags & DM_SWSCALE) { S2X_init (currentmode->native_width, currentmode->native_height, currentmode->native_depth); } diff --git a/od-win32/winuae_msvc10/winuae_msvc.vcxproj b/od-win32/winuae_msvc10/winuae_msvc.vcxproj index 19d89195..480675ba 100644 --- a/od-win32/winuae_msvc10/winuae_msvc.vcxproj +++ b/od-win32/winuae_msvc10/winuae_msvc.vcxproj @@ -685,6 +685,7 @@ + diff --git a/od-win32/winuae_msvc10/winuae_msvc.vcxproj.filters b/od-win32/winuae_msvc10/winuae_msvc.vcxproj.filters index 0f75a87b..34fb1b37 100644 --- a/od-win32/winuae_msvc10/winuae_msvc.vcxproj.filters +++ b/od-win32/winuae_msvc10/winuae_msvc.vcxproj.filters @@ -609,6 +609,9 @@ + + common + diff --git a/od-win32/winuaechangelog.txt b/od-win32/winuaechangelog.txt index eedccd48..ff0e83a9 100644 --- a/od-win32/winuaechangelog.txt +++ b/od-win32/winuaechangelog.txt @@ -4,6 +4,17 @@ - restore only single input target to default. - hdd from command line +- On screen led status line was drawn using both D3D sprite and directly to bitmap methods in D3D no-filter mode (b2). +- Removed PAL/NTSC vertical scaling hack which is not needed anymore. +- PAL/NTSC vertical scaling added to Fullscreen (TV)/(Max) filter modes. +- Fullscreen (TV)/(Max) also handles programmed modes like real monitor would, positioning and scaling using sync parameters. +- Fake 60Hz (VPOSW poking) did nothing. (2.4) +- DirectDraw + null filter crash fixed when display height was smaller than emulated display height. (b2) +- D3D overlay mask scaling artifact in some resolutions (2.4) +- CDFS CD drive statefile support. +- Ignore duplicate HID button IDs. +- Reduced flicker when refresh rate changes (PAL<>NTSC or other mode changes) + Beta 2: - Filter system partial rewrite again. Do not use static display buffer. Always dynamically reallocate internal buffer if -- 2.47.3