From: Toni Wilen Date: Fri, 23 Apr 2010 14:03:09 +0000 (+0300) Subject: 2100b24 X-Git-Tag: 2100~2 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=3f3a908c0ca8a36f7ce00e8a36cd7ffe7a58dd10;p=francis%2Fwinuae.git 2100b24 --- diff --git a/blkdev_cdimage.cpp b/blkdev_cdimage.cpp index 090d32d7..8336f3fb 100644 --- a/blkdev_cdimage.cpp +++ b/blkdev_cdimage.cpp @@ -450,16 +450,21 @@ static void *cdda_play_func (void *v) } } - bufon[bufnum] = 1; - if (volume != cdda_volume || volume_main != currprefs.sound_volume) { - int vol; - volume = cdda_volume; - volume_main = currprefs.sound_volume; - vol = (100 - volume_main) * volume / 100; - if (vol >= 0xffff) - vol = 0xffff; - waveOutSetVolume (cdda_wavehandle, vol | (vol << 16)); + volume = cdda_volume; + volume_main = currprefs.sound_volume; + int vol_mult = (100 - volume_main) * volume / 100; + if (vol_mult) + vol_mult++; + if (vol_mult >= 65536) + vol_mult = 65536; + uae_s16 *p = (uae_s16*)(px[bufnum]); + for (i = 0; i < num_sectors * 2352 / 4; i++) { + p[i * 2 + 0] = p[i * 2 + 0] * vol_mult / 65536; + p[i * 2 + 1] = p[i * 2 + 1] * vol_mult / 65536; } + + + bufon[bufnum] = 1; mmr = waveOutWrite (cdda_wavehandle, &whdr[bufnum], sizeof (WAVEHDR)); if (mmr != MMSYSERR_NOERROR) { write_log (L"CDDA: waveOutWrite %d\n", mmr); diff --git a/cfgfile.cpp b/cfgfile.cpp index 46840a62..8e3e7ab9 100644 --- a/cfgfile.cpp +++ b/cfgfile.cpp @@ -214,7 +214,7 @@ TCHAR *cfgfile_subst_path (const TCHAR *path, const TCHAR *subst, const TCHAR *f /* @@@ use strcasecmp for some targets. */ if (_tcslen (path) > 0 && _tcsncmp (file, path, _tcslen (path)) == 0) { int l; - TCHAR *p = xmalloc (TCHAR, _tcslen (file) + _tcslen (subst) + 2); + TCHAR *p2, *p = xmalloc (TCHAR, _tcslen (file) + _tcslen (subst) + 2); _tcscpy (p, subst); l = _tcslen (p); while (l > 0 && p[l - 1] == '/') @@ -222,10 +222,13 @@ TCHAR *cfgfile_subst_path (const TCHAR *path, const TCHAR *subst, const TCHAR *f l = _tcslen (path); while (file[l] == '/') l++; - _tcscat (p, L"/"); _tcscat (p, file + l); - return p; + _tcscat (p, L"/"); + _tcscat (p, file + l); + p2 = target_expand_environment (p); + xfree (p); + return p2; } - return my_strdup (file); + return target_expand_environment (file); } static int isdefault (const TCHAR *s) @@ -918,6 +921,18 @@ int cfgfile_string (const TCHAR *option, const TCHAR *value, const TCHAR *name, return 1; } +int cfgfile_path (const TCHAR *option, const TCHAR *value, const TCHAR *name, TCHAR *location, int maxsz) +{ + if (!cfgfile_string (option, value, name, location, maxsz)) + return 0; + TCHAR *s = target_expand_environment (location); + _tcsncpy (location, s, maxsz - 1); + location[maxsz - 1] = 0; + xfree (s); + return 1; +} + + static int getintval (TCHAR **p, int *result, int delim) { TCHAR *value = *p; @@ -1002,9 +1017,9 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) *tmpp = '\0'; if (_tcscmp (section, TARGET_NAME) == 0) { /* We special case the various path options here. */ - if (cfgfile_string (option, value, L"rom_path", p->path_rom, sizeof p->path_rom / sizeof (TCHAR)) - || cfgfile_string (option, value, L"floppy_path", p->path_floppy, sizeof p->path_floppy / sizeof (TCHAR)) - || cfgfile_string (option, value, L"hardfile_path", p->path_hardfile, sizeof p->path_hardfile / sizeof (TCHAR))) + if (cfgfile_path (option, value, L"rom_path", p->path_rom, sizeof p->path_rom / sizeof (TCHAR)) + || cfgfile_path (option, value, L"floppy_path", p->path_floppy, sizeof p->path_floppy / sizeof (TCHAR)) + || cfgfile_path (option, value, L"hardfile_path", p->path_hardfile, sizeof p->path_hardfile / sizeof (TCHAR))) return 1; return target_parse_option (p, option, value); } @@ -1012,7 +1027,7 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) } for (i = 0; i < MAX_SPARE_DRIVES; i++) { _stprintf (tmpbuf, L"diskimage%d", i); - if (cfgfile_string (option, value, tmpbuf, p->dfxlist[i], sizeof p->dfxlist[i] / sizeof (TCHAR))) { + if (cfgfile_path (option, value, tmpbuf, p->dfxlist[i], sizeof p->dfxlist[i] / sizeof (TCHAR))) { #if 0 if (i < 4 && !p->df[i][0]) _tcscpy (p->df[i], p->dfxlist[i]); @@ -1021,7 +1036,7 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) } } - if (cfgfile_string (option, value, L"cdimage0", p->cdimagefile, sizeof p->cdimagefile / sizeof (TCHAR))) + if (cfgfile_path (option, value, L"cdimage0", p->cdimagefile, sizeof p->cdimagefile / sizeof (TCHAR))) return 1; if (cfgfile_intval (option, value, L"sound_frequency", &p->sound_freq, 1)) { @@ -1086,10 +1101,10 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) || cfgfile_intval (option, value, L"override_dga_address", &p->override_dga_address, 1)) return 1; - if (cfgfile_string (option, value, L"floppy0soundext", p->dfxclickexternal[0], sizeof p->dfxclickexternal[0] / sizeof (TCHAR)) - || cfgfile_string (option, value, L"floppy1soundext", p->dfxclickexternal[1], sizeof p->dfxclickexternal[1] / sizeof (TCHAR)) - || cfgfile_string (option, value, L"floppy2soundext", p->dfxclickexternal[2], sizeof p->dfxclickexternal[2] / sizeof (TCHAR)) - || cfgfile_string (option, value, L"floppy3soundext", p->dfxclickexternal[3], sizeof p->dfxclickexternal[3] / sizeof (TCHAR)) + if (cfgfile_path (option, value, L"floppy0soundext", p->dfxclickexternal[0], sizeof p->dfxclickexternal[0] / sizeof (TCHAR)) + || cfgfile_path (option, value, L"floppy1soundext", p->dfxclickexternal[1], sizeof p->dfxclickexternal[1] / sizeof (TCHAR)) + || cfgfile_path (option, value, L"floppy2soundext", p->dfxclickexternal[2], sizeof p->dfxclickexternal[2] / sizeof (TCHAR)) + || cfgfile_path (option, value, L"floppy3soundext", p->dfxclickexternal[3], sizeof p->dfxclickexternal[3] / sizeof (TCHAR)) || cfgfile_string (option, value, L"gfx_display_name", p->gfx_display_name, sizeof p->gfx_display_name / sizeof (TCHAR)) || cfgfile_string (option, value, L"config_info", p->info, sizeof p->info / sizeof (TCHAR)) || cfgfile_string (option, value, L"config_description", p->description, sizeof p->description / sizeof (TCHAR))) @@ -1303,7 +1318,7 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) if (cfgfile_strval (option, value, L"joyport3mode", &p->jports[3].mode, joyportmodes, 0)) return 1; - if (cfgfile_string (option, value, L"statefile", tmpbuf, sizeof (tmpbuf) / sizeof (TCHAR))) { + if (cfgfile_path (option, value, L"statefile", tmpbuf, sizeof (tmpbuf) / sizeof (TCHAR))) { _tcscpy (savestate_fname, tmpbuf); if (zfile_exists (savestate_fname)) { savestate_state = STATE_DORESTORE; @@ -1698,11 +1713,11 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, TCHAR *option, TCHAR *va || cfgfile_strval (option, value, L"comp_flushmode", &p->comp_hardflush, flushmode, 0)) return 1; - if (cfgfile_string (option, value, L"kickstart_rom_file", p->romfile, sizeof p->romfile / sizeof (TCHAR)) - || cfgfile_string (option, value, L"kickstart_ext_rom_file", p->romextfile, sizeof p->romextfile / sizeof (TCHAR)) - || cfgfile_string (option, value, L"amax_rom_file", p->amaxromfile, sizeof p->amaxromfile / sizeof (TCHAR)) - || cfgfile_string (option, value, L"flash_file", p->flashfile, sizeof p->flashfile / sizeof (TCHAR)) - || cfgfile_string (option, value, L"cart_file", p->cartfile, sizeof p->cartfile / sizeof (TCHAR)) + if (cfgfile_path (option, value, L"kickstart_rom_file", p->romfile, sizeof p->romfile / sizeof (TCHAR)) + || cfgfile_path (option, value, L"kickstart_ext_rom_file", p->romextfile, sizeof p->romextfile / sizeof (TCHAR)) + || cfgfile_path (option, value, L"amax_rom_file", p->amaxromfile, sizeof p->amaxromfile / sizeof (TCHAR)) + || cfgfile_path (option, value, L"flash_file", p->flashfile, sizeof p->flashfile / sizeof (TCHAR)) + || cfgfile_path (option, value, L"cart_file", p->cartfile, sizeof p->cartfile / sizeof (TCHAR)) || cfgfile_string (option, value, L"pci_devices", p->pci_devices, sizeof p->pci_devices / sizeof (TCHAR)) || cfgfile_string (option, value, L"ghostscript_parameters", p->ghostscript_parameters, sizeof p->ghostscript_parameters / sizeof (TCHAR))) return 1; @@ -1730,7 +1745,7 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, TCHAR *option, TCHAR *va for (i = 0; i < 4; i++) { _stprintf (tmpbuf, L"floppy%d", i); - if (cfgfile_string (option, value, tmpbuf, p->df[i], sizeof p->df[i] / sizeof (TCHAR))) + if (cfgfile_path (option, value, tmpbuf, p->df[i], sizeof p->df[i] / sizeof (TCHAR))) return 1; } @@ -2015,9 +2030,9 @@ int cfgfile_parse_option (struct uae_prefs *p, TCHAR *option, TCHAR *value, int return 1; if (!_tcscmp (option, L"config_host")) return 1; - if (cfgfile_string (option, value, L"config_hardware_path", p->config_hardware_path, sizeof p->config_hardware_path / sizeof (TCHAR))) + if (cfgfile_path (option, value, L"config_hardware_path", p->config_hardware_path, sizeof p->config_hardware_path / sizeof (TCHAR))) return 1; - if (cfgfile_string (option, value, L"config_host_path", p->config_host_path, sizeof p->config_host_path / sizeof (TCHAR))) + if (cfgfile_path (option, value, L"config_host_path", p->config_host_path, sizeof p->config_host_path / sizeof (TCHAR))) return 1; if (type == 0 || (type & CONFIG_TYPE_HARDWARE)) { if (cfgfile_parse_hardware (p, option, value)) @@ -2270,8 +2285,8 @@ static int cfgfile_load_2 (struct uae_prefs *p, const TCHAR *filename, int real, cfgfile_parse_separated_line (p, line1b, line2b, askedtype); } else { cfgfile_string (line1b, line2b, L"config_description", p->description, sizeof p->description / sizeof (TCHAR)); - cfgfile_string (line1b, line2b, L"config_hardware_path", p->config_hardware_path, sizeof p->config_hardware_path / sizeof (TCHAR)); - cfgfile_string (line1b, line2b, L"config_host_path", p->config_host_path, sizeof p->config_host_path / sizeof (TCHAR)); + cfgfile_path (line1b, line2b, L"config_hardware_path", p->config_hardware_path, sizeof p->config_hardware_path / sizeof (TCHAR)); + cfgfile_path (line1b, line2b, L"config_host_path", p->config_host_path, sizeof p->config_host_path / sizeof (TCHAR)); } } } @@ -2611,6 +2626,14 @@ static void parse_cpu_specs (struct uae_prefs *p, const TCHAR *spec) } } +static void cmdpath (TCHAR *dst, const TCHAR *src, int maxsz) +{ + TCHAR *s = target_expand_environment (src); + _tcsncpy (dst, s, maxsz); + dst[maxsz] = 0; + xfree (s); +} + /* Returns the number of args used up (0 or 1). */ int parse_cmdline_option (struct uae_prefs *p, TCHAR c, const TCHAR *arg) { @@ -2632,12 +2655,12 @@ int parse_cmdline_option (struct uae_prefs *p, TCHAR c, const TCHAR *arg) switch (c) { case 'h': usage (); exit (0); - case '0': _tcsncpy (p->df[0], arg, 255); p->df[0][255] = 0; break; - case '1': _tcsncpy (p->df[1], arg, 255); p->df[1][255] = 0; break; - case '2': _tcsncpy (p->df[2], arg, 255); p->df[2][255] = 0; break; - case '3': _tcsncpy (p->df[3], arg, 255); p->df[3][255] = 0; break; - case 'r': _tcsncpy (p->romfile, arg, 255); p->romfile[255] = 0; break; - case 'K': _tcsncpy (p->romextfile, arg, 255); p->romextfile[255] = 0; break; + case '0': cmdpath (p->df[0], arg, 255); break; + case '1': cmdpath (p->df[1], arg, 255); break; + case '2': cmdpath (p->df[2], arg, 255); break; + case '3': cmdpath (p->df[3], arg, 255); break; + case 'r': cmdpath (p->romfile, arg, 255); break; + case 'K': cmdpath (p->romextfile, arg, 255); break; case 'p': _tcsncpy (p->prtname, arg, 255); p->prtname[255] = 0; break; /* case 'I': _tcsncpy (p->sername, arg, 255); p->sername[255] = 0; currprefs.use_serial = 1; break; */ case 'm': case 'M': parse_filesys_spec (p, c == 'M', arg); break; diff --git a/include/options.h b/include/options.h index 795dd13d..d5a0e9b3 100644 --- a/include/options.h +++ b/include/options.h @@ -427,6 +427,7 @@ extern int cfgfile_strval (const TCHAR *option, const TCHAR *value, const TCHAR extern int cfgfile_string (const TCHAR *option, const TCHAR *value, const TCHAR *name, TCHAR *location, int maxsz); extern TCHAR *cfgfile_subst_path (const TCHAR *path, const TCHAR *subst, const TCHAR *file); +extern TCHAR *target_expand_environment (const TCHAR *path); extern int target_parse_option (struct uae_prefs *, TCHAR *option, TCHAR *value); extern void target_save_options (struct zfile*, struct uae_prefs *); extern void target_default_options (struct uae_prefs *, int type); diff --git a/main.cpp b/main.cpp index 48d18262..5a733a65 100644 --- a/main.cpp +++ b/main.cpp @@ -498,6 +498,13 @@ static TCHAR *parsetext (const TCHAR *s) return my_strdup (s); } } +static TCHAR *parsetextpath (const TCHAR *s) +{ + TCHAR *s2 = parsetext (s); + TCHAR *s3 = target_expand_environment (s2); + xfree (s2); + return s3; +} static void parse_cmdline (int argc, TCHAR **argv) { @@ -505,7 +512,7 @@ static void parse_cmdline (int argc, TCHAR **argv) for (i = 1; i < argc; i++) { if (!_tcsncmp (argv[i], L"-diskswapper=", 13)) { - TCHAR *txt = parsetext (argv[i] + 13); + TCHAR *txt = parsetextpath (argv[i] + 13); parse_diskswapper (txt); xfree (txt); } else if (_tcsncmp (argv[i], L"-cfgparam=", 10) == 0) { @@ -514,12 +521,12 @@ static void parse_cmdline (int argc, TCHAR **argv) if (i + 1 < argc) i++; } else if (_tcsncmp (argv[i], L"-config=", 8) == 0) { - TCHAR *txt = parsetext (argv[i] + 8); + TCHAR *txt = parsetextpath (argv[i] + 8); currprefs.mountitems = 0; target_cfgfile_load (&currprefs, txt, -1, 0); xfree (txt); } else if (_tcsncmp (argv[i], L"-statefile=", 11) == 0) { - TCHAR *txt = parsetext (argv[i] + 11); + TCHAR *txt = parsetextpath (argv[i] + 11); savestate_state = STATE_DORESTORE; _tcscpy (savestate_fname, txt); xfree (txt); @@ -528,8 +535,10 @@ static void parse_cmdline (int argc, TCHAR **argv) if (i + 1 == argc) { write_log (L"Missing argument for '-f' option.\n"); } else { + TCHAR *txt = parsetextpath (argv[++i]); currprefs.mountitems = 0; - target_cfgfile_load (&currprefs, argv[++i], -1, 0); + target_cfgfile_load (&currprefs, txt, -1, 0); + xfree (txt); } } else if (_tcscmp (argv[i], L"-s") == 0) { if (i + 1 == argc) @@ -540,7 +549,7 @@ static void parse_cmdline (int argc, TCHAR **argv) usage (); exit (0); } else if (_tcsncmp (argv[i], L"-cdimage=", 9) == 0) { - TCHAR *txt = parsetext (argv[i] + 9); + TCHAR *txt = parsetextpath (argv[i] + 9); cfgfile_parse_option (&currprefs, L"cdimage0", txt, 0); xfree (txt); } else { diff --git a/od-win32/blkdev_win32_ioctl.cpp b/od-win32/blkdev_win32_ioctl.cpp index 87706eeb..f1bf993c 100644 --- a/od-win32/blkdev_win32_ioctl.cpp +++ b/od-win32/blkdev_win32_ioctl.cpp @@ -373,17 +373,21 @@ static void *cdda_play (void *v) } } reseterrormode (unitnum); + + volume = ciw->cdda_volume; + volume_main = currprefs.sound_volume; + int vol_mult = (100 - volume_main) * volume / 100; + if (vol_mult) + vol_mult++; + if (vol_mult >= 65536) + vol_mult = 65536; + uae_s16 *p = (uae_s16*)(px[bufnum]); + for (i = 0; i < num_sectors * 2352 / 4; i++) { + p[i * 2 + 0] = p[i * 2 + 0] * vol_mult / 65536; + p[i * 2 + 1] = p[i * 2 + 1] * vol_mult / 65536; + } bufon[bufnum] = 1; - if (volume != ciw->cdda_volume || volume_main != currprefs.sound_volume) { - int vol; - volume = ciw->cdda_volume; - volume_main = currprefs.sound_volume; - vol = (100 - volume_main) * volume / 100; - if (vol >= 0xffff) - vol = 0xffff; - waveOutSetVolume (ciw->cdda_wavehandle, vol | (vol << 16)); - } mmr = waveOutWrite (ciw->cdda_wavehandle, &whdr[bufnum], sizeof (WAVEHDR)); if (mmr != MMSYSERR_NOERROR) { write_log (L"CDDA: waveOutWrite %d\n", mmr); diff --git a/od-win32/win32.cpp b/od-win32/win32.cpp index 8924ccd4..d578640c 100644 --- a/od-win32/win32.cpp +++ b/od-win32/win32.cpp @@ -2587,6 +2587,18 @@ static int fetchpri (int pri, int defpri) return defpri; } +TCHAR *target_expand_environment (const TCHAR *path) +{ + if (!path) + return NULL; + int len = ExpandEnvironmentStrings (path, NULL, 0); + if (len <= 0) + return my_strdup (path); + TCHAR *s = xmalloc (TCHAR, len + 1); + ExpandEnvironmentStrings (path, s, len); + return s; +} + static const TCHAR *obsolete[] = { L"killwinkeys", L"sound_force_primary", L"iconified_highpriority", L"sound_sync", L"sound_tweak", L"directx6", L"sound_style", @@ -4109,7 +4121,7 @@ static int parseargs (const TCHAR *arg, const TCHAR *np, const TCHAR *np2) return 2; } if (!_tcscmp (arg, L"-datapath")) { - _tcscpy(start_path_data, np); + ExpandEnvironmentStrings (np, start_path_data, sizeof start_path_data / sizeof (TCHAR)); start_data = -1; return 2; } diff --git a/od-win32/win32.h b/od-win32/win32.h index ca29cf01..8b673978 100644 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -18,9 +18,9 @@ #define WINUAEPUBLICBETA 0 #define LANG_DLL 1 -#define WINUAEBETA L"23" -#define WINUAEDATE MAKEBD(2010, 4, 20) -#define WINUAEEXTRA L"RC1" +#define WINUAEBETA L"24" +#define WINUAEDATE MAKEBD(2010, 4, 23) +#define WINUAEEXTRA L"RC2" #define WINUAEREV L"" #define IHF_WINDOWHIDDEN 6