From: Toni Wilen Date: Sat, 15 May 2010 10:20:53 +0000 (+0300) Subject: 2200b1 X-Git-Tag: 2200~34 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=dc880b1045134acb0590eac68dd7e518913ad87a;p=francis%2Fwinuae.git 2200b1 --- diff --git a/ar.cpp b/ar.cpp index 67450f97..6895c185 100644 --- a/ar.cpp +++ b/ar.cpp @@ -265,7 +265,7 @@ static void cartridge_exit (void) { #ifdef PICASSO96 if (stored_picasso_on >= 0) - picasso_requested_on = stored_picasso_on; + picasso_requested_on = stored_picasso_on != 0; stored_picasso_on = -1; #endif } diff --git a/audio.cpp b/audio.cpp index 6a3ddb28..844acd9a 100644 --- a/audio.cpp +++ b/audio.cpp @@ -1892,7 +1892,7 @@ void audio_vsync (void) { #if SOUNDSTUFF > 0 int max, min; - int vsync = isfullscreen () > 0 && currprefs.gfx_avsync > 0; + int vsync = isfullscreen () > 0 && currprefs.gfx_avsync; static int lastdir; if (!vsync) { diff --git a/blkdev_cdimage.cpp b/blkdev_cdimage.cpp index 8336f3fb..fb8c83de 100644 --- a/blkdev_cdimage.cpp +++ b/blkdev_cdimage.cpp @@ -740,7 +740,7 @@ static int parse_image (void) if (!img) return 0; - zcue = zfile_fopen (img, L"rb", ZFD_ARCHIVE); + zcue = zfile_fopen (img, L"rb", ZFD_ARCHIVE | ZFD_CD); if (!zcue) return 0; diff --git a/cfgfile.cpp b/cfgfile.cpp index 8e3e7ab9..4525f2bf 100644 --- a/cfgfile.cpp +++ b/cfgfile.cpp @@ -166,7 +166,8 @@ static const TCHAR *maxvert[] = { L"nointerlace", L"interlace", 0 }; static const TCHAR *abspointers[] = { L"none", L"mousehack", L"tablet", 0 }; static const TCHAR *magiccursors[] = { L"both", L"native", L"host", 0 }; static const TCHAR *autoscale[] = { L"none", L"scale", L"resize", 0 }; -static const TCHAR *joyportmodes[] = { NULL, L"mouse", L"djoy", L"ajoy", L"cdtvjoy", L"cd32joy", L"lightpen", 0 }; +static const TCHAR *joyportmodes[] = { L"", L"mouse", L"djoy", L"ajoy", L"cdtvjoy", L"cd32joy", L"lightpen", 0 }; +static const TCHAR *joyaf[] = { L"none", L"pushpull", L"toggle", 0 }; static const TCHAR *epsonprinter[] = { L"none", L"ascii", L"epson_matrix_9pin", L"epson_matrix_24pin", L"epson_matrix_48pin", 0 }; static const TCHAR *aspects[] = { L"none", L"vga", L"tv", 0 }; static const TCHAR *vsyncmodes[] = { L"false", L"true", L"autoswitch", 0 }; @@ -186,7 +187,8 @@ static const TCHAR *obsolete[] = { L"gfx_test_speed", L"gfxlib_replacement", L"enforcer", L"catweasel_io", L"kickstart_key_file", L"fast_copper", L"sound_adjust", L"serial_hardware_dtrdsr", L"gfx_filter_upscale", - L"gfx_correct_aspect", L"gfx_autoscale", + L"gfx_correct_aspect", L"gfx_autoscale", L"parallel_sampler", L"parallel_ascii_emulation", + L"avoid_vid", L"avoid_dga", NULL }; @@ -302,14 +304,18 @@ end: xfree (tmp1); } -void cfgfile_write_bool (struct zfile *f, const TCHAR *option, int b) +void cfgfile_write_bool (struct zfile *f, const TCHAR *option, bool b) { cfg_dowrite (f, option, b ? L"true" : L"false", 0, 0); } -void cfgfile_dwrite_bool (struct zfile *f, const TCHAR *option, int b) +void cfgfile_dwrite_bool (struct zfile *f, const TCHAR *option, bool b) { cfg_dowrite (f, option, b ? L"true" : L"false", 1, 0); } +void cfgfile_dwrite_bool (struct zfile *f, const TCHAR *option, int b) +{ + cfgfile_dwrite_bool (f, option, b != 0); +} void cfgfile_write_str (struct zfile *f, const TCHAR *option, const TCHAR *value) { cfg_dowrite (f, option, value, 0, 0); @@ -319,11 +325,11 @@ void cfgfile_dwrite_str (struct zfile *f, const TCHAR *option, const TCHAR *valu cfg_dowrite (f, option, value, 1, 0); } -void cfgfile_target_write_bool (struct zfile *f, const TCHAR *option, int b) +void cfgfile_target_write_bool (struct zfile *f, const TCHAR *option, bool b) { cfg_dowrite (f, option, b ? L"true" : L"false", 0, 1); } -void cfgfile_target_dwrite_bool (struct zfile *f, const TCHAR *option, int b) +void cfgfile_target_dwrite_bool (struct zfile *f, const TCHAR *option, bool b) { cfg_dowrite (f, option, b ? L"true" : L"false", 1, 1); } @@ -377,6 +383,27 @@ void cfgfile_target_dwrite (struct zfile *f, const TCHAR *option, const TCHAR *f va_end (parms); } +static void cfgfile_write_rom (struct zfile *f, const TCHAR *path, const TCHAR *romfile, const TCHAR *name) +{ + TCHAR *str = cfgfile_subst_path (path, UNEXPANDED, romfile); + cfgfile_write_str (f, name, str); + struct zfile *zf = zfile_fopen (str, L"rb", ZFD_ALL); + if (zf) { + struct romdata *rd = getromdatabyzfile (zf); + if (rd) { + TCHAR name2[MAX_DPATH], str2[MAX_DPATH]; + _tcscpy (name2, name); + _tcscat (name2, L"_id"); + _stprintf (str2, L"%08X,%s", rd->crc32, rd->name); + cfgfile_write_str (f, name2, str2); + } + zfile_fclose (zf); + } + xfree (str); + +} + + static void write_filesys_config (struct uae_prefs *p, const TCHAR *unexpanded, const TCHAR *default_path, struct zfile *f) { @@ -453,7 +480,7 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_write_str (f, L"config_description", p->description); cfgfile_write_bool (f, L"config_hardware", type & CONFIG_TYPE_HARDWARE); - cfgfile_write_bool (f, L"config_host", type & CONFIG_TYPE_HOST); + cfgfile_write_bool (f, L"config_host", !!(type & CONFIG_TYPE_HOST)); if (p->info[0]) cfgfile_write (f, L"config_info", p->info); cfgfile_write (f, L"config_version", L"%d.%d.%d", UAEMAJOR, UAEMINOR, UAESUBREV); @@ -480,14 +507,10 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_write_str (f, L"use_gui", guimode1[p->start_gui]); cfgfile_write_bool (f, L"use_debugger", p->start_debugger); - str = cfgfile_subst_path (p->path_rom, UNEXPANDED, p->romfile); - cfgfile_write_str (f, L"kickstart_rom_file", str); - xfree (str); + cfgfile_write_rom (f, p->path_rom, p->romfile, L"kickstart_rom_file"); + cfgfile_write_rom (f, p->path_rom, p->romextfile, L"kickstart_ext_rom_file"); if (p->romident[0]) cfgfile_dwrite_str (f, L"kickstart_rom", p->romident); - str = cfgfile_subst_path (p->path_rom, UNEXPANDED, p->romextfile); - cfgfile_write_str (f, L"kickstart_ext_rom_file", str); - xfree (str); if (p->romextident[0]) cfgfile_write_str (f, L"kickstart_ext_rom=", p->romextident); str = cfgfile_subst_path (p->path_rom, UNEXPANDED, p->flashfile); @@ -573,17 +596,15 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_write_bool (f, L"comp_midopt", p->comp_midopt); cfgfile_write_bool (f, L"comp_lowopt", p->comp_lowopt); cfgfile_write_bool (f, L"avoid_cmov", p->avoid_cmov); - cfgfile_write_bool (f, L"avoid_dga", p->avoid_dga); - cfgfile_write_bool (f, L"avoid_vid", p->avoid_vid); cfgfile_write (f, L"cachesize", L"%d", p->cachesize); - if (p->override_dga_address) - cfgfile_write (f, L"override_dga_address", L"0x%08x", p->override_dga_address); for (i = 0; i < MAX_JPORTS; i++) { struct jport *jp = &p->jports[i]; int v = jp->id; TCHAR tmp1[MAX_DPATH], tmp2[MAX_DPATH]; - if (v < 0) { + if (v == JPORT_CUSTOM) { + _tcscpy (tmp2, L"custom"); + } else if (v == JPORT_NONE) { _tcscpy (tmp2, L"none"); } else if (v < JSEM_JOYS) { _stprintf (tmp2, L"kbd%d", v + 1); @@ -597,15 +618,17 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) if (i < 2 || jp->id >= 0) { _stprintf (tmp1, L"joyport%d", i); cfgfile_write (f, tmp1, tmp2); + _stprintf (tmp1, L"joyport%dautofire", i); + cfgfile_write (f, tmp1, joyaf[jp->autofire]); if (i < 2 && jp->mode > 0) { _stprintf (tmp1, L"joyport%dmode", i); cfgfile_write (f, tmp1, joyportmodes[jp->mode]); } - if (jp->name) { + if (jp->name[0]) { _stprintf (tmp1, L"joyportfriendlyname%d", i); cfgfile_write (f, tmp1, jp->name); } - if (jp->configname) { + if (jp->configname[0]) { _stprintf (tmp1, L"joyportname%d", i); cfgfile_write (f, tmp1, jp->configname); } @@ -646,7 +669,7 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_write (f, L"gfx_width_fullscreen", L"%d", p->gfx_size_fs.width); cfgfile_write (f, L"gfx_height_fullscreen", L"%d", p->gfx_size_fs.height); cfgfile_write (f, L"gfx_refreshrate", L"%d", p->gfx_refreshrate); - cfgfile_write (f, L"gfx_autoresolution", L"%d", p->gfx_autoresolution); + cfgfile_write_bool (f, L"gfx_autoresolution", p->gfx_autoresolution); cfgfile_write_str (f, L"gfx_vsync", vsyncmodes[p->gfx_avsync]); cfgfile_write_bool (f, L"gfx_vsync_picasso", p->gfx_pvsync); cfgfile_write_bool (f, L"gfx_lores", p->gfx_resolution == 0); @@ -710,7 +733,7 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_dwrite (f, L"gfx_filter_gamma", L"%d", p->gfx_filter_gamma); cfgfile_dwrite (f, L"gfx_filter_blur", L"%d", p->gfx_filter_blur); cfgfile_dwrite (f, L"gfx_filter_noise", L"%d", p->gfx_filter_noise); - cfgfile_dwrite_bool (f, L"gfx_filter_bilinear", p->gfx_filter_bilinear); + cfgfile_dwrite_bool (f, L"gfx_filter_bilinear", p->gfx_filter_bilinear != 0); cfgfile_dwrite_str (f, L"gfx_filter_keep_aspect", aspects[p->gfx_filter_keep_aspect]); cfgfile_dwrite_str (f, L"gfx_filter_autoscale", autoscale[p->gfx_filter_autoscale]); cfgfile_dwrite (f, L"gfx_filter_aspect_ratio", L"%d:%d", @@ -725,8 +748,8 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_write_bool (f, L"immediate_blits", p->immediate_blits); cfgfile_write_bool (f, L"ntsc", p->ntscmode); cfgfile_write_bool (f, L"genlock", p->genlock); - cfgfile_dwrite_bool (f, L"show_leds", p->leds_on_screen & STATUSLINE_CHIPSET); - cfgfile_dwrite_bool (f, L"show_leds_rtg", p->leds_on_screen & STATUSLINE_RTG); + cfgfile_dwrite_bool (f, L"show_leds", !!(p->leds_on_screen & STATUSLINE_CHIPSET)); + cfgfile_dwrite_bool (f, L"show_leds_rtg", !!(p->leds_on_screen & STATUSLINE_RTG)); cfgfile_dwrite (f, L"keyboard_leds", L"numlock:%s,capslock:%s,scrolllock:%s", kbleds[p->keyboard_leds[0]], kbleds[p->keyboard_leds[1]], kbleds[p->keyboard_leds[2]]); if (p->chipset_mask & CSMASK_AGA) @@ -837,8 +860,6 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_write_bool (f, L"filesys_no_fsdb", p->filesys_no_uaefsdb); #endif write_inputdevice_config (p, f); - - /* Don't write gfxlib/gfx_test_speed options. */ } int cfgfile_yesno (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location) @@ -857,6 +878,18 @@ int cfgfile_yesno (const TCHAR *option, const TCHAR *value, const TCHAR *name, i } return 1; } +int cfgfile_yesno (const TCHAR *option, const TCHAR *value, const TCHAR *name, bool *location) +{ + int val; + int ret = cfgfile_yesno (option, value, name, &val); + if (ret == 0) + return 0; + if (ret < 0) + *location = false; + else + *location = val != 0; + return 1; +} int cfgfile_intval (const TCHAR *option, const TCHAR *value, const TCHAR *name, unsigned int *location, int scale) { @@ -912,6 +945,15 @@ int cfgfile_strval (const TCHAR *option, const TCHAR *value, const TCHAR *name, return 1; } +int cfgfile_strboolval (const TCHAR *option, const TCHAR *value, const TCHAR *name, bool *location, const TCHAR *table[], int more) +{ + int locationint; + if (!cfgfile_strval (option, value, name, &locationint, table, more)) + return 0; + *location = locationint != 0; + return 1; +} + int cfgfile_string (const TCHAR *option, const TCHAR *value, const TCHAR *name, TCHAR *location, int maxsz) { if (_tcscmp (option, name) != 0) @@ -932,6 +974,33 @@ int cfgfile_path (const TCHAR *option, const TCHAR *value, const TCHAR *name, TC return 1; } +int cfgfile_rom (const TCHAR *option, const TCHAR *value, const TCHAR *name, TCHAR *location, int maxsz) +{ + TCHAR id[MAX_DPATH]; + if (!cfgfile_string (option, value, name, id, sizeof id / sizeof (TCHAR))) + return 0; + if (zfile_exists (location)) + return 1; + TCHAR *p = _tcschr (id, ','); + if (p) { + TCHAR *endptr, tmp; + *p = 0; + tmp = id[4]; + id[4] = 0; + uae_u32 crc32 = _tcstol (id, &endptr, 16) << 16; + id[4] = tmp; + crc32 |= _tcstol (id + 4, &endptr, 16); + struct romdata *rd = getromdatabycrc (crc32); + if (rd) { + struct romlist *rl = getromlistbyromdata (rd); + if (rl) { + write_log (L"%s: %s -> %s\n", name, location, rl->path); + _tcsncpy (location, rl->path, maxsz); + } + } + } + return 1; +} static int getintval (TCHAR **p, int *result, int delim) { @@ -997,7 +1066,8 @@ static void set_chipset_mask (struct uae_prefs *p, int val) static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) { - int i, v; + int i; + bool vb; TCHAR *section = 0; TCHAR *tmpp; TCHAR tmpbuf[CONFIG_BLEN]; @@ -1063,7 +1133,7 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) || cfgfile_intval (option, value, L"gfx_width_fullscreen", &p->gfx_size_fs.width, 1) || cfgfile_intval (option, value, L"gfx_height_fullscreen", &p->gfx_size_fs.height, 1) || cfgfile_intval (option, value, L"gfx_refreshrate", &p->gfx_refreshrate, 1) - || cfgfile_intval (option, value, L"gfx_autoresolution", &p->gfx_autoresolution, 1) + || cfgfile_yesno (option, value, L"gfx_autoresolution", &p->gfx_autoresolution) || cfgfile_intval (option, value, L"gfx_backbuffers", &p->gfx_backbuffers, 1) || cfgfile_intval (option, value, L"gfx_center_horizontal_position", &p->gfx_xcenter_pos, 1) @@ -1097,8 +1167,7 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) || cfgfile_intval (option, value, L"floppy1sound", &p->dfxclick[1], 1) || cfgfile_intval (option, value, L"floppy2sound", &p->dfxclick[2], 1) || cfgfile_intval (option, value, L"floppy3sound", &p->dfxclick[3], 1) - || cfgfile_intval (option, value, L"floppy_volume", &p->dfxclickvolume, 1) - || cfgfile_intval (option, value, L"override_dga_address", &p->override_dga_address, 1)) + || cfgfile_intval (option, value, L"floppy_volume", &p->dfxclickvolume, 1)) return 1; if (cfgfile_path (option, value, L"floppy0soundext", p->dfxclickexternal[0], sizeof p->dfxclickexternal[0] / sizeof (TCHAR)) @@ -1116,8 +1185,6 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) || cfgfile_yesno (option, value, L"sound_stereo_swap_ahi", &p->sound_stereo_swap_ahi) || cfgfile_yesno (option, value, L"state_replay", &p->statecapture) || cfgfile_yesno (option, value, L"avoid_cmov", &p->avoid_cmov) - || cfgfile_yesno (option, value, L"avoid_dga", &p->avoid_dga) - || cfgfile_yesno (option, value, L"avoid_vid", &p->avoid_vid) || cfgfile_yesno (option, value, L"log_illegal_mem", &p->illegal_mem) || cfgfile_yesno (option, value, L"filesys_no_fsdb", &p->filesys_no_uaefsdb) || cfgfile_yesno (option, value, L"gfx_vsync_picasso", &p->gfx_pvsync) @@ -1135,9 +1202,9 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) || cfgfile_strval (option, value, L"sound_interpol", &p->sound_interpol, interpolmode, 0) || cfgfile_strval (option, value, L"sound_filter", &p->sound_filter, soundfiltermode1, 0) || cfgfile_strval (option, value, L"sound_filter_type", &p->sound_filter_type, soundfiltermode2, 0) - || cfgfile_strval (option, value, L"use_gui", &p->start_gui, guimode1, 1) - || cfgfile_strval (option, value, L"use_gui", &p->start_gui, guimode2, 1) - || cfgfile_strval (option, value, L"use_gui", &p->start_gui, guimode3, 0) + || cfgfile_strboolval (option, value, L"use_gui", &p->start_gui, guimode1, 1) + || cfgfile_strboolval (option, value, L"use_gui", &p->start_gui, guimode2, 1) + || cfgfile_strboolval (option, value, L"use_gui", &p->start_gui, guimode3, 0) || cfgfile_strval (option, value, L"gfx_resolution", &p->gfx_resolution, lorestype1, 0) || cfgfile_strval (option, value, L"gfx_lores", &p->gfx_resolution, lorestype2, 0) || cfgfile_strval (option, value, L"gfx_lores_mode", &p->gfx_lores_mode, loresmode, 0) @@ -1164,18 +1231,18 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) if (_tcscmp (option, L"gfx_vsync") == 0) { - if (cfgfile_strval (option, value, L"gfx_vsync", &p->gfx_avsync, vsyncmodes, 0) >= 0) + if (cfgfile_strboolval (option, value, L"gfx_vsync", &p->gfx_avsync, vsyncmodes, 0) >= 0) return 1; return cfgfile_yesno (option, value, L"gfx_vsync", &p->gfx_avsync); } - if (cfgfile_yesno (option, value, L"show_leds", &v)) { - if (v) + if (cfgfile_yesno (option, value, L"show_leds", &vb)) { + if (vb) p->leds_on_screen |= STATUSLINE_CHIPSET; return 1; } - if (cfgfile_yesno (option, value, L"show_leds_rtg", &v)) { - if (v) + if (cfgfile_yesno (option, value, L"show_leds_rtg", &vb)) { + if (vb) p->leds_on_screen |= STATUSLINE_RTG; return 1; } @@ -1317,6 +1384,14 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) return 1; if (cfgfile_strval (option, value, L"joyport3mode", &p->jports[3].mode, joyportmodes, 0)) return 1; + if (cfgfile_strval (option, value, L"joyport0autofire", &p->jports[0].autofire, joyaf, 0)) + return 1; + if (cfgfile_strval (option, value, L"joyport1autofire", &p->jports[1].autofire, joyaf, 0)) + return 1; + if (cfgfile_strval (option, value, L"joyport2autofire", &p->jports[2].autofire, joyaf, 0)) + return 1; + if (cfgfile_strval (option, value, L"joyport3autofire", &p->jports[3].autofire, joyaf, 0)) + return 1; if (cfgfile_path (option, value, L"statefile", tmpbuf, sizeof (tmpbuf) / sizeof (TCHAR))) { _tcscpy (savestate_fname, tmpbuf); @@ -1497,7 +1572,7 @@ static struct uaedev_config_info *getuci(struct uae_prefs *p) } struct uaedev_config_info *add_filesys_config (struct uae_prefs *p, int index, - TCHAR *devname, TCHAR *volname, TCHAR *rootdir, int readonly, + TCHAR *devname, TCHAR *volname, TCHAR *rootdir, bool readonly, int secspertrack, int surfaces, int reserved, int blocksize, int bootpri, TCHAR *filesysdir, int hdc, int flags) @@ -1587,6 +1662,7 @@ static void parse_addmem (struct uae_prefs *p, TCHAR *buf, int num) static int cfgfile_parse_hardware (struct uae_prefs *p, TCHAR *option, TCHAR *value) { int tmpval, dummyint, i; + bool tmpbool, dummybool; TCHAR *section = 0; TCHAR tmpbuf[CONFIG_BLEN]; @@ -1597,10 +1673,10 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, TCHAR *option, TCHAR *va /* we don't want cycle-exact in 68020/40+JIT modes */ return 1; } - if (cfgfile_yesno (option, value, L"cycle_exact", &tmpval)) { - p->cpu_cycle_exact = p->blitter_cycle_exact = tmpval ? 1 : 0; + if (cfgfile_yesno (option, value, L"cycle_exact", &tmpbool)) { + p->cpu_cycle_exact = p->blitter_cycle_exact = tmpbool; if (p->cpu_model >= 68020 && p->cachesize > 0) - p->cpu_cycle_exact = p->blitter_cycle_exact = 0; + p->cpu_cycle_exact = p->blitter_cycle_exact = false; return 1; } @@ -1610,13 +1686,13 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, TCHAR *option, TCHAR *va } - if (cfgfile_yesno (option, value, L"scsi_a3000", &dummyint)) { - if (dummyint) + if (cfgfile_yesno (option, value, L"scsi_a3000", &dummybool)) { + if (dummybool) p->cs_mbdmac = 1; return 1; } - if (cfgfile_yesno (option, value, L"scsi_a4000t", &dummyint)) { - if (dummyint) + if (cfgfile_yesno (option, value, L"scsi_a4000t", &dummybool)) { + if (dummybool) p->cs_mbdmac = 2; return 1; } @@ -1659,7 +1735,7 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, TCHAR *option, TCHAR *va || cfgfile_yesno (option, value, L"comp_nf", &p->compnf) || cfgfile_yesno (option, value, L"comp_constjump", &p->comp_constjump) || cfgfile_yesno (option, value, L"comp_oldsegv", &p->comp_oldsegv) - || cfgfile_yesno (option, value, L"compforcesettings", &dummyint) + || cfgfile_yesno (option, value, L"compforcesettings", &dummybool) || cfgfile_yesno (option, value, L"compfpu", &p->compfpu) || cfgfile_yesno (option, value, L"fpu_strict", &p->fpu_strict) || cfgfile_yesno (option, value, L"comp_midopt", &p->comp_midopt) @@ -1701,7 +1777,6 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, TCHAR *option, TCHAR *va if (cfgfile_strval (option, value, L"comp_trustbyte", &p->comptrustbyte, compmode, 0) || cfgfile_strval (option, value, L"chipset_compatible", &p->cs_compatible, cscompa, 0) || cfgfile_strval (option, value, L"rtc", &p->cs_rtc, rtctype, 0) - || cfgfile_strval (option, value, L"ksmirror", &p->cs_ksmirror_e0, ksmirrortype, 0) || cfgfile_strval (option, value, L"ciaatod", &p->cs_ciaatod, ciaatodmode, 0) || cfgfile_strval (option, value, L"ide", &p->cs_ide, idemode, 0) || cfgfile_strval (option, value, L"scsi", &p->scsi, scsimode, 0) @@ -1710,11 +1785,13 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, TCHAR *option, TCHAR *va || cfgfile_strval (option, value, L"comp_trustnaddr", &p->comptrustnaddr, compmode, 0) || cfgfile_strval (option, value, L"collision_level", &p->collision_level, collmode, 0) || cfgfile_strval (option, value, L"parallel_matrix_emulation", &p->parallel_matrix_emulation, epsonprinter, 0) - || cfgfile_strval (option, value, L"comp_flushmode", &p->comp_hardflush, flushmode, 0)) + || cfgfile_strboolval (option, value, L"comp_flushmode", &p->comp_hardflush, flushmode, 0)) return 1; 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_rom (option, value, L"kickstart_rom_file_id", p->romfile, sizeof p->romfile / sizeof (TCHAR)) + || cfgfile_rom (option, value, L"kickstart_ext_rom_file_id", 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)) @@ -1878,7 +1955,8 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, TCHAR *option, TCHAR *va if (_tcscmp (option, L"filesystem") == 0 || _tcscmp (option, L"hardfile") == 0) { - int secs, heads, reserved, bs, ro; + int secs, heads, reserved, bs; + bool ro; TCHAR *aname, *root; TCHAR *tmpp = _tcschr (value, ','); TCHAR *str; @@ -1893,11 +1971,11 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, TCHAR *option, TCHAR *va if (_tcscmp (value, L"1") == 0 || strcasecmp (value, L"ro") == 0 || strcasecmp (value, L"readonly") == 0 || strcasecmp (value, L"read-only") == 0) - ro = 1; + ro = true; else if (_tcscmp (value, L"0") == 0 || strcasecmp (value, L"rw") == 0 || strcasecmp (value, L"readwrite") == 0 || strcasecmp (value, L"read-write") == 0) - ro = 0; + ro = false; else goto invalid_fs; secs = 0; heads = 0; reserved = 0; bs = 0; @@ -1931,7 +2009,8 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, TCHAR *option, TCHAR *va if (_tcscmp (option, L"filesystem2") == 0 || _tcscmp (option, L"hardfile2") == 0) { - int secs, heads, reserved, bs, ro, bp, hdcv; + int secs, heads, reserved, bs, bp, hdcv; + bool ro; TCHAR *dname = NULL, *aname = L"", *root = NULL, *fs = NULL, *hdc; TCHAR *tmpp = _tcschr (value, ','); TCHAR *str = NULL; @@ -1942,9 +2021,9 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, TCHAR *option, TCHAR *va *tmpp++ = '\0'; if (strcasecmp (value, L"ro") == 0) - ro = 1; + ro = true; else if (strcasecmp (value, L"rw") == 0) - ro = 0; + ro = false; else goto invalid_fs; secs = 0; heads = 0; reserved = 0; bs = 0; bp = 0; @@ -2240,14 +2319,15 @@ static char *cfg_fgets (char *line, int max, struct zfile *fh) return 0; } -static int cfgfile_load_2 (struct uae_prefs *p, const TCHAR *filename, int real, int *type) +static int cfgfile_load_2 (struct uae_prefs *p, const TCHAR *filename, bool real, int *type) { int i; struct zfile *fh; char linea[CONFIG_BLEN]; TCHAR line[CONFIG_BLEN], line1b[CONFIG_BLEN], line2b[CONFIG_BLEN]; struct strlist *sl; - int type1 = 0, type2 = 0, askedtype = 0; + bool type1 = false, type2 = false; + int askedtype = 0; if (type) { askedtype = *type; @@ -2256,7 +2336,7 @@ static int cfgfile_load_2 (struct uae_prefs *p, const TCHAR *filename, int real, if (real) { p->config_version = 0; config_newfilesystem = 0; - reset_inputdevice_config (p); + //reset_inputdevice_config (p); } fh = zfile_fopen (filename, L"r", ZFD_NORMAL); @@ -2533,7 +2613,7 @@ bad: p->jports[1].id = v1; } -static void parse_filesys_spec (struct uae_prefs *p, int readonly, const TCHAR *spec) +static void parse_filesys_spec (struct uae_prefs *p, bool readonly, const TCHAR *spec) { TCHAR buf[256]; TCHAR *s2; @@ -2667,15 +2747,9 @@ int parse_cmdline_option (struct uae_prefs *p, TCHAR c, const TCHAR *arg) case 'W': parse_hardfile_spec (p, arg); break; case 'S': parse_sound_spec (p, arg); break; case 'R': p->gfx_framerate = _tstoi (arg); break; - case 'x': p->no_xhair = 1; break; case 'i': p->illegal_mem = 1; break; case 'J': parse_joy_spec (p, arg); break; - case 't': p->test_drawing_speed = 1; break; -#ifdef USE_X11_GFX - case 'L': p->x11_use_low_bandwidth = 1; break; - case 'T': p->x11_use_mitshm = 1; break; -#endif case 'w': p->m68k_speed = _tstoi (arg); break; /* case 'g': p->use_gfxlib = 1; break; */ @@ -3214,6 +3288,7 @@ void default_prefs (struct uae_prefs *p, int type) TCHAR zero = 0; struct zfile *f; + reset_inputdevice_config (p); memset (p, 0, sizeof (*p)); _tcscpy (p->description, L"UAE default configuration"); p->config_hardware_path[0] = 0; @@ -3228,7 +3303,6 @@ void default_prefs (struct uae_prefs *p, int type) * to behave identically on all platforms if possible. * (TW says: maybe it is time to update default config..) */ p->illegal_mem = 0; - p->no_xhair = 0; p->use_serial = 0; p->serial_demand = 0; p->serial_hwctsrts = 1; @@ -3274,11 +3348,8 @@ void default_prefs (struct uae_prefs *p, int type) p->fpu_strict = 0; p->cachesize = 0; p->avoid_cmov = 0; - p->avoid_dga = 0; - p->avoid_vid = 0; p->comp_midopt = 0; p->comp_lowopt = 0; - p->override_dga_address = 0; for (i = 0;i < 10; i++) p->optcount[i] = -1; @@ -3314,14 +3385,6 @@ void default_prefs (struct uae_prefs *p, int type) p->gfx_blackerthanblack = 0; p->gfx_backbuffers = 2; - p->x11_use_low_bandwidth = 0; - p->x11_use_mitshm = 0; - p->x11_hide_cursor = 1; - - p->svga_no_linear = 0; - - p->curses_reverse_video = 0; - target_default_options (p, type); p->immediate_blits = 0; @@ -3354,8 +3417,9 @@ void default_prefs (struct uae_prefs *p, int type) p->cs_mbdmac = 0; p->cs_a2091 = 0; p->cs_a4091 = 0; - p->cs_cd32c2p = p->cs_cd32cd = p->cs_cd32nvram = 0; - p->cs_cdtvcd = p->cs_cdtvram = p->cs_cdtvcard = 0; + p->cs_cd32c2p = p->cs_cd32cd = p->cs_cd32nvram = false; + p->cs_cdtvcd = p->cs_cdtvram = false; + p->cs_cdtvcard = 0; p->cs_pcmcia = 0; p->cs_ksmirror_e0 = 1; p->cs_ksmirror_a8 = 0; @@ -3526,16 +3590,16 @@ static void buildin_default_prefs (struct uae_prefs *p) p->gfxmem_size = 0x00000000; p->cs_rtc = 0; - p->cs_a1000ram = 0; + p->cs_a1000ram = false; p->cs_fatgaryrev = -1; p->cs_ramseyrev = -1; p->cs_agnusrev = -1; p->cs_deniserev = -1; p->cs_mbdmac = 0; - p->cs_a2091 = 0; - p->cs_a4091 = 0; - p->cs_cd32c2p = p->cs_cd32cd = p->cs_cd32nvram = 0; - p->cs_cdtvcd = p->cs_cdtvram = p->cs_cdtvcard = 0; + p->cs_a2091 = false; + p->cs_a4091 = false; + p->cs_cd32c2p = p->cs_cd32cd = p->cs_cd32nvram = false; + p->cs_cdtvcd = p->cs_cdtvram = p->cs_cdtvcard = false; p->cs_ide = 0; p->cs_pcmcia = 0; p->cs_ksmirror_e0 = 1; diff --git a/cia.cpp b/cia.cpp index a3728c7e..e31b5f39 100644 --- a/cia.cpp +++ b/cia.cpp @@ -59,7 +59,10 @@ static unsigned long ciaata_passed, ciaatb_passed, ciabta_passed, ciabtb_passed; static unsigned long ciaatod, ciabtod, ciaatol, ciabtol, ciaaalarm, ciabalarm; static int ciaatlatch, ciabtlatch; -static int oldled, oldovl, oldcd32mute, led_changed; +static bool oldled, oldovl, oldcd32mute; +static bool led; +static int led_old_brightness; +static unsigned long led_cycles_on, led_cycles_off, led_cycle; unsigned int ciabpra; @@ -524,37 +527,40 @@ void CIA_hsync_handler (int dotod) } } -static int led_times; -static unsigned long led_on, led_cycle; - - static void calc_led (int old_led) { unsigned long c = get_cycles (); - unsigned long t = c - led_cycle; + unsigned long t = (c - led_cycle) / CYCLE_UNIT; if (old_led) - led_on += t; - led_times++; + led_cycles_on += t; + else + led_cycles_off += t; led_cycle = c; } static void led_vsync (void) { - gui_data.powerled_brightness = gui_data.powerled ? 255 : 0; - calc_led (gui_data.powerled); - if (led_on > 0 && led_times > 2) { - int v = led_on / CYCLE_UNIT * 256 / (maxhpos * maxvpos_nom); - if (v < 0) - v = 0; - if (v > 255) - v = 255; - gui_data.powerled_brightness = v; - } - led_on = 0; - led_times = 0; - if (led_changed) + int v; + + calc_led (led); + if (led_cycles_on && !led_cycles_off) + v = 255; + else if (led_cycles_off && !led_cycles_on) + v = 0; + else + v = led_cycles_on * 255 / led_cycles_off; + if (v < 0) + v = 0; + if (v > 255) + v = 255; + gui_data.powerled_brightness = v; + led_cycles_on = 0; + led_cycles_off = 0; + if (led_old_brightness != gui_data.powerled_brightness) { + gui_data.powerled = gui_data.powerled_brightness > 127; gui_led (LED_POWER, gui_data.powerled); - led_changed = 0; + } + led_old_brightness = gui_data.powerled_brightness; led_cycle = get_cycles (); } @@ -575,15 +581,14 @@ void CIA_vsync_handler (int dotod) static void bfe001_change (void) { uae_u8 v = ciaapra; - int led; + bool led2; v |= ~ciaadra; /* output is high when pin's direction is input */ - led = (v & 2) ? 0 : 1; - if (led != oldled) { - calc_led (oldled); - oldled = led; - gui_data.powerled = led; - led_changed = 1; + led2 = (v & 2) ? 0 : 1; + if (led2 != led) { + calc_led (led); + led = led2; + led_old_brightness = -1; led_filter_audio (); } if (currprefs.cs_ciaoverlay && (v & 1) != oldovl) { @@ -1162,7 +1167,7 @@ void CIA_reset (void) serbits = 0; oldovl = 1; oldcd32mute = 1; - oldled = -1; + oldled = true; resetwarning_phase = resetwarning_timer = 0; if (!savestate_state) { diff --git a/consolehook.cpp b/consolehook.cpp index e503e1cc..8543a76d 100644 --- a/consolehook.cpp +++ b/consolehook.cpp @@ -45,8 +45,8 @@ void consolehook_config (struct uae_prefs *p) p->gfx_size_win.width = 320; p->gfx_size_win.height = 256; p->turbo_emulation = 0; - p->win32_automount_drives = 2; - p->win32_automount_cddrives = 2; + //p->win32_automount_drives = 2; + //p->win32_automount_cddrives = 2; add_filesys_config (p, -1, L"DH0", L"CLIBOOT", L".", 1, 0, 0, 0, 0, 15, NULL, 0, 0); } diff --git a/custom.cpp b/custom.cpp index de6a622e..6e96f0c9 100644 --- a/custom.cpp +++ b/custom.cpp @@ -66,7 +66,7 @@ #define SPRBORDER 0 -STATIC_INLINE int nocustom (void) +STATIC_INLINE bool nocustom (void) { if (picasso_on && currprefs.picasso96_nocustom) return 1; @@ -135,7 +135,9 @@ extern uae_u8* compiled_code; int vpos; static int vpos_count, vpos_count_prev; -static int lof_store, lof_current, lol; +static int lof_store; // real bit in custom registers +static int lof_current; // what display device thinks +static int lol; static int next_lineno, prev_lineno; static enum nln_how nextline_how; static int lof_changed = 0; @@ -256,6 +258,7 @@ enum diw_states static int plffirstline, plflastline; int plffirstline_total, plflastline_total; +static int autoscale_bordercolors; static int plfstrt_start, plfstrt, plfstop; static int sprite_minx, sprite_maxx; static int first_bpl_vpos; @@ -835,7 +838,10 @@ STATIC_INLINE void compute_delay_offset (void) static void record_color_change2 (int hpos, int regno, unsigned long value) { - curr_color_changes[next_color_change].linepos = hpos * 2; + int pos = hpos * 2; + if (regno == 0x1000 + 0x10c) + pos++; // BPLCON4 change needs 1 lores pixel delay + curr_color_changes[next_color_change].linepos = pos; curr_color_changes[next_color_change].regno = regno; curr_color_changes[next_color_change++].value = value; curr_color_changes[next_color_change].regno = -1; @@ -1790,11 +1796,11 @@ static void start_bpl_dma (int hpos, int hstart) if (doflickerfix () && interlace_seen && !scandoubled_line) { int i; for (i = 0; i < 8; i++) { - prevbpl[lof_store][vpos][i] = bplptx[i]; - if (!lof_store && (bplcon0 & 4)) - bplpt[i] = prevbpl[1 - lof_store][vpos][i]; - if (!(bplcon0 & 4) || interlace_seen < 0) - prevbpl[1 - lof_store][vpos][i] = prevbpl[lof_store][vpos][i] = 0; + prevbpl[lof_current][vpos][i] = bplptx[i]; + if (!lof_current && (bplcon0 & 4)) + bplpt[i] = prevbpl[1 - lof_current][vpos][i]; + if (!(bplcon0 & 4) || interlace_seen < 0) + prevbpl[1 - lof_current][vpos][i] = prevbpl[lof_current][vpos][i] = 0; } } @@ -1928,12 +1934,20 @@ static void record_color_change (int hpos, int regno, unsigned long value) } record_color_change2 (hpos, regno, value); - if (regno == 0 && value != 0 && vpos >= 32) { + if (regno == 0 && value != 0 && vpos >= 20) { // autoscale if COLOR00 changes in top or bottom of screen - if (vpos < first_planes_vpos || vpos < plffirstline_total) - plffirstline_total = first_planes_vpos = vpos - 2; - if (vpos > last_planes_vpos || vpos > plflastline_total) - plflastline_total = last_planes_vpos = vpos + 3; + if (vpos >= minfirstline) { + int vpos2 = autoscale_bordercolors ? minfirstline : vpos; + if (first_planes_vpos == 0) + first_planes_vpos = vpos2 - 2; + if (plffirstline_total == maxvpos) + plffirstline_total = vpos2 - 2; + if (vpos2 > last_planes_vpos || vpos2 > plflastline_total) + plflastline_total = last_planes_vpos = vpos2 + 3; + autoscale_bordercolors = 0; + } else { + autoscale_bordercolors++; + } } } @@ -2686,7 +2700,7 @@ void compute_vsynctime (void) updatedisplayarea (); } if (currprefs.produce_sound > 1) - update_sound (fake_vblank_hz, (bplcon0 & 4) ? -1 : lof_current, islinetoggle ()); + update_sound (fake_vblank_hz, (bplcon0 & 4) ? -1 : lof_store, islinetoggle ()); } @@ -2710,7 +2724,7 @@ void init_hz (void) int ovblank = vblank_hz; int hzc = 0; - if (vsync_switchmode (-1, 0) > 0) + if (vsync_switchmode (-1, 0)) currprefs.gfx_avsync = changed_prefs.gfx_avsync = vsync_switchmode (-1, 0); if (!isvsync () && ((currprefs.chipset_refreshrate == 50 && !currprefs.ntscmode) || @@ -2902,8 +2916,8 @@ static uae_u32 REGPARAM2 timehack_helper (TrapContext *context) timehack_alive = 10; gettimeofday (&tv, NULL); - put_long (m68k_areg (regs, 0), tv.tv_sec - (((365 * 8 + 2) * 24) * 60 * 60)); - put_long (m68k_areg (regs, 0) + 4, tv.tv_usec); + x_put_long (m68k_areg (regs, 0), tv.tv_sec - (((365 * 8 + 2) * 24) * 60 * 60)); + x_put_long (m68k_areg (regs, 0) + 4, tv.tv_usec); return 0; #else return 2; @@ -2984,7 +2998,7 @@ STATIC_INLINE uae_u16 VPOSR (void) if (hp + HPOS_OFFSET >= maxhpos) { vp++; - if (vp >= maxvpos + lof_current) + if (vp >= maxvpos + lof_store) vp = 0; } vp = (vp >> 8) & 7; @@ -3004,11 +3018,11 @@ STATIC_INLINE uae_u16 VPOSR (void) if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS)) vp &= 1; - vp = vp | (lof_current ? 0x8000 : 0) | csbit; + vp = vp | (lof_store ? 0x8000 : 0) | csbit; if (currprefs.chipset_mask & CSMASK_ECS_AGNUS) vp |= lol ? 0x80 : 0; #if 0 - if (M68K_GETPC < 0xf00000) + if (M68K_GETPC < 0x00f00000 || M68K_GETPC >= 0x10000000) write_log (L"VPOSR %04x at %08x\n", vp, M68K_GETPC); #endif if (currprefs.cpu_model >= 68020) @@ -3022,9 +3036,9 @@ static void VPOSW (uae_u16 v) if (M68K_GETPC < 0xf00000 || 1) write_log (L"VPOSW %04X PC=%08x\n", v, M68K_GETPC); #endif - if (lof_current != ((v & 0x8000) ? 1 : 0)) { + if (lof_store != ((v & 0x8000) ? 1 : 0)) { lof_changed = 1; - lof_current = (v & 0x8000) ? 1 : 0; + lof_store = (v & 0x8000) ? 1 : 0; } if (currprefs.chipset_mask & CSMASK_ECS_AGNUS) lol = (v & 0x0080) ? 1 : 0; @@ -3057,7 +3071,7 @@ STATIC_INLINE uae_u16 VHPOSR (void) if (hp >= maxhpos) { hp -= maxhpos; vp++; - if (vp >= maxvpos + lof_current) + if (vp >= maxvpos + lof_store) vp = 0; } hp += 1; @@ -3069,7 +3083,7 @@ STATIC_INLINE uae_u16 VHPOSR (void) if (currprefs.cpu_model >= 68020) hsyncdelay (); #if 0 - if (M68K_GETPC < 0xf00000 && (vpos >= maxhpos || vpos <= 1)) + if (M68K_GETPC < 0x00f00000 || M68K_GETPC >= 0x10000000) write_log (L"VPOS %04x %04x at %08x\n", VPOSR (), vp, M68K_GETPC); #endif return vp; @@ -4701,7 +4715,8 @@ STATIC_INLINE void do_sprites_1 (int num, int cycle, int hpos) write_log (L"%d:%d:SPR%d STOP\n", vpos, hpos, num); #endif s->dmastate = 0; -#if 1 +#if 0 + // roots 2.0 flower zoomer bottom part missing if this enabled if (vpos == s->vstop) { spr_arm (num, 0); //return; @@ -4878,6 +4893,7 @@ static void init_hardware_frame (void) ddflastword_total = 0; plflastline_total = 0; plffirstline_total = maxvpos; + autoscale_bordercolors = 0; for (i = 0; i < MAX_SPRITES; i++) spr[i].ptxhpos = MAXHPOS; } @@ -5042,8 +5058,8 @@ static void vsync_handler (void) write_log (L"vblank interrupt not cleared\n"); #endif if (bplcon0 & 4) - lof_current = lof_current ? 0 : 1; - lof_store = lof_current; + lof_store = lof_store ? 0 : 1; + lof_current = lof_store; #ifdef PICASSO96 picasso_handle_vsync (); @@ -5286,6 +5302,12 @@ static void hsync_handler (void) if (islinetoggle ()) lol ^= 1; + if (vpos == equ_vblank_endline + 1 && lof_current != lof_store) { + // argh, line=0 field decision was wrong, someone did + // something stupid and changed LOF + // lof_current = lof_store; + // don't really know what to do here exactly without corrupt display + } maxhpos = maxhpos_short + lol; eventtab[ev_hsync].evtime = get_cycles () + HSYNCTIME; @@ -5328,7 +5350,7 @@ static void hsync_handler (void) vpos_count++; if (vpos >= maxvpos_total) vpos = 0; - if (vpos == maxvpos + lof_current || vpos == maxvpos + lof_current + 1 || vpos_count >= MAXVPOS) { + if (vpos == maxvpos + lof_store || vpos == maxvpos + lof_store + 1 || vpos_count >= MAXVPOS) { // vpos_count >= MAXVPOS just to not crash if VPOSW writes prevent vsync completely if ((bplcon0 & 8) && !lightpen_triggered) { vpos_lpen = vpos - 1; @@ -5378,7 +5400,7 @@ static void hsync_handler (void) strobe = 0x38; else if (vpos < minfirstline) strobe = 0x3a; - else if (vpos + 1 == maxvpos + lof_current) + else if (vpos + 1 == maxvpos + lof_store) strobe = 0x38; else if ((currprefs.chipset_mask & CSMASK_ECS_AGNUS) && lol) strobe = 0x3e; @@ -5411,7 +5433,7 @@ static void hsync_handler (void) } } else { #endif - is_lastline = vpos + 1 == maxvpos + lof_current && currprefs.m68k_speed == -1; + is_lastline = vpos + 1 == maxvpos + lof_store && currprefs.m68k_speed == -1; #ifdef JIT } #endif @@ -5428,8 +5450,8 @@ static void hsync_handler (void) } else if (currprefs.gfx_linedbl && (doublescan <= 0 || interlace_seen > 0)) { lineno *= 2; nextline_how = currprefs.gfx_linedbl == 1 ? nln_doubled : nln_nblack; - if ((bplcon0 & 4) || (interlace_seen > 0 && !lof_store)) { - if (!lof_store) { + if ((bplcon0 & 4) || (interlace_seen > 0 && !lof_current)) { + if (!lof_current) { lineno++; nextline_how = nln_lower; } else { @@ -6341,7 +6363,7 @@ uae_u8 *restore_custom (uae_u8 *src) dsklen = RW; /* 024 DSKLEN */ RW; /* 026 DSKDAT */ RW; /* 028 REFPTR */ - i = RW; lof_current = (i & 0x8000) ? 1 : 0; lol = (i & 0x0080) ? 1 : 0; /* 02A VPOSW */ + i = RW; lof_store = lof_current = (i & 0x8000) ? 1 : 0; lol = (i & 0x0080) ? 1 : 0; /* 02A VPOSW */ RW; /* 02C VHPOSW */ COPCON (RW); /* 02E COPCON */ RW; /* 030 SERDAT* */ @@ -6499,7 +6521,7 @@ uae_u8 *save_custom (int *len, uae_u8 *dstptr, int full) SW (dsklen); /* 024 DSKLEN */ SW (0); /* 026 DSKDAT */ SW (0); /* 028 REFPTR */ - SW ((lof_current ? 0x8001 : 0) | (lol ? 0x0080 : 0));/* 02A VPOSW */ + SW ((lof_store ? 0x8001 : 0) | (lol ? 0x0080 : 0));/* 02A VPOSW */ SW (0); /* 02C VHPOSW */ SW (copcon); /* 02E COPCON */ SW (serper); /* 030 SERDAT * */ @@ -6987,7 +7009,7 @@ int is_cycle_ce (void) #endif -int ispal (void) +bool ispal (void) { if (beamcon0 & 0x80) return currprefs.ntscmode == 0; diff --git a/debug.cpp b/debug.cpp index 02773695..01b7cee1 100644 --- a/debug.cpp +++ b/debug.cpp @@ -2191,12 +2191,13 @@ static uae_u8 *dump_xlate (uae_u32 addr) static void memory_map_dump_2 (int log) { - int i, j, max, im; + bool imold; + int i, j, max; addrbank *a1 = mem_banks[0]; TCHAR txt[256]; - im = currprefs.illegal_mem; - currprefs.illegal_mem = 0; + imold = currprefs.illegal_mem; + currprefs.illegal_mem = false; max = currprefs.address_space_24 ? 256 : 65536; j = 0; for (i = 0; i < max + 1; i++) { @@ -2260,7 +2261,7 @@ static void memory_map_dump_2 (int log) a1 = a2; } } - currprefs.illegal_mem = im; + currprefs.illegal_mem = imold; } void memory_map_dump (void) { diff --git a/disk.cpp b/disk.cpp index 13920bc5..f0eb267b 100644 --- a/disk.cpp +++ b/disk.cpp @@ -143,10 +143,10 @@ typedef struct { trackid writetrackdata[MAX_TRACKS]; int buffered_cyl, buffered_side; int cyl; - int motoroff; + bool motoroff; int motordelay; /* dskrdy needs some clock cycles before it changes after switching off motor */ - int state; - int wrprot; + bool state; + bool wrprot; uae_u16 bigmfmbuf[0x4000 * DDHDMULT]; uae_u16 tracktiming[0x4000 * DDHDMULT]; int multi_revolution; @@ -160,9 +160,9 @@ typedef struct { int dmalen; int num_tracks, write_num_tracks, num_secs; int hard_num_cyls; - int dskchange; + bool dskchange; int dskchange_time; - int dskready; + bool dskready; int dskready_time; int dskready_down_time; int writtento; @@ -634,7 +634,7 @@ static void reset_drive (int i) static void update_drive_gui (int num) { drive *drv = floppy + num; - int writ = dskdmaen == 3 && drv->state && !(selected & (1 << num)); + bool writ = dskdmaen == 3 && drv->state && !(selected & (1 << num)); if (drv->state == gui_data.drive_motor[num] && drv->cyl == gui_data.drive_track[num] @@ -654,7 +654,7 @@ static void update_drive_gui (int num) static void drive_fill_bigbuf (drive * drv,int); -int DISK_validate_filename (const TCHAR *fname, int leave_open, int *wrprot, uae_u32 *crc32, struct zfile **zf) +int DISK_validate_filename (const TCHAR *fname, int leave_open, bool *wrprot, uae_u32 *crc32, struct zfile **zf) { if (zf) *zf = NULL; @@ -775,7 +775,7 @@ TCHAR *DISK_get_saveimagepath (const TCHAR *name) return name1; } -static struct zfile *getwritefile (const TCHAR *name, int *wrprot) +static struct zfile *getwritefile (const TCHAR *name, bool *wrprot) { struct zfile *zf; DISK_validate_filename (DISK_get_saveimagepath (name), 1, wrprot, NULL, &zf); @@ -785,7 +785,7 @@ static struct zfile *getwritefile (const TCHAR *name, int *wrprot) static int iswritefileempty (const TCHAR *name) { struct zfile *zf; - int wrprot; + bool wrprot; uae_char buffer[8]; trackid td[MAX_TRACKS]; int tracks, ddhd, i, ret; @@ -807,7 +807,7 @@ static int iswritefileempty (const TCHAR *name) static int openwritefile (drive *drv, int create) { - int wrprot = 0; + bool wrprot = 0; drv->writediskfile = getwritefile (currprefs.df[drv - &floppy[0]], &wrprot); if (drv->writediskfile) { @@ -826,10 +826,10 @@ static int openwritefile (drive *drv, int create) return drv->writediskfile ? 1 : 0; } -static int diskfile_iswriteprotect (const TCHAR *fname, int *needwritefile, drive_type *drvtype) +static bool diskfile_iswriteprotect (const TCHAR *fname, int *needwritefile, drive_type *drvtype) { struct zfile *zf1, *zf2; - int wrprot1 = 0, wrprot2 = 1; + bool wrprot1 = 0, wrprot2 = 1; uae_char buffer[25]; *needwritefile = 0; @@ -1236,7 +1236,7 @@ static void motordelay_func (uae_u32 v) floppy[v].motordelay = 0; } -static void drive_motor (drive * drv, int off) +static void drive_motor (drive * drv, bool off) { if (drv->motoroff && !off) { drv->dskready_time = DSKREADY_TIME; @@ -2175,7 +2175,8 @@ int disk_setwriteprotect (int num, const TCHAR *name, int protect) { int needwritefile, oldprotect; struct zfile *zf1, *zf2; - int wrprot1, wrprot2, i; + bool wrprot1, wrprot2; + int i; TCHAR *name2; drive_type drvtype; @@ -2230,15 +2231,26 @@ int DISK_history_add (const TCHAR *name, int idx, int type, int donotcheck) if (name[0] == 0) return 0; if (!donotcheck) { - if (!zfile_exists (name)) + if (!zfile_exists (name)) { + for (i = 0; i < MAX_PREVIOUS_FLOPPIES; i++) { + if (!_tcsicmp (dfxhistory[type][i], name)) { + while (i < MAX_PREVIOUS_FLOPPIES - 1) { + _tcscpy (dfxhistory[type][i], dfxhistory[type][i + 1]); + i++; + } + dfxhistory[type][MAX_PREVIOUS_FLOPPIES - 1][0] = 0; + break; + } + } return 0; + } } if (idx >= 0) { if (idx >= MAX_PREVIOUS_FLOPPIES) return 0; dfxhistory[type][idx][0] = 0; for (i = 0; i < MAX_PREVIOUS_FLOPPIES; i++) { - if (!_tcscmp (dfxhistory[type][i], name)) + if (!_tcsicmp (dfxhistory[type][i], name)) return 0; } _tcscpy (dfxhistory[type][idx], name); @@ -3466,7 +3478,7 @@ uae_u8 *restore_disk (int num,uae_u8 *src) drv->buffered_cyl = -1; drv->buffered_side = -1; drv->cyl = restore_u8 (); - drv->dskready = restore_u8 (); + drv->dskready = restore_u8 () != 0; drv->drive_id_scnt = restore_u8 (); drv->mfmpos = restore_u32 (); drv->dskchange = 0; diff --git a/drawing.cpp b/drawing.cpp index 8f34aa86..0016a171 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -69,8 +69,8 @@ static void lores_reset (void) sprite_buffer_res++; } -int aga_mode; /* mirror of chipset_mask & CSMASK_AGA */ -int direct_rgb; +bool aga_mode; /* mirror of chipset_mask & CSMASK_AGA */ +bool direct_rgb; /* The shift factor to apply when converting between Amiga coordinates and window coordinates. Zero if the resolution is the same, positive if window coordinates @@ -214,8 +214,8 @@ static uae_u32 plf_sprite_mask; static int sbasecol[2] = { 16, 16 }; static int brdsprt, brdblank, brdblank_changed; -int picasso_requested_on; -int picasso_on; +bool picasso_requested_on; +bool picasso_on; uae_sem_t gui_sem; int inhibit_frame; @@ -659,10 +659,6 @@ static void pfield_init_linetoscr (void) } } -STATIC_INLINE uae_u8 merge_2pixel8 (uae_u8 p1, uae_u8 p2) -{ - return p1; -} STATIC_INLINE uae_u16 merge_2pixel16 (uae_u16 p1, uae_u16 p2) { uae_u16 v = ((((p1 >> xredcolor_s) & xredcolor_m) + ((p2 >> xredcolor_s) & xredcolor_m)) / 2) << xredcolor_s; @@ -678,29 +674,6 @@ STATIC_INLINE uae_u32 merge_2pixel32 (uae_u32 p1, uae_u32 p2) return v; } -static void fill_line_8 (uae_u8 *buf, unsigned int start, unsigned int stop) -{ - uae_u8 *b = (uae_u8 *)buf; - unsigned int i; - unsigned int rem = 0; - xcolnr col = brdblank ? 0 : colors_for_drawing.acolors[0]; - while (((long)&b[start]) & 3) { - b[start++] = (uae_u8)col; - if (start == stop) - return; - } - if (((long)&b[stop]) & 3) { - rem = ((long)&b[stop]) & 3; - stop -= rem; - } - for (i = start; i < stop; i += 4) { - uae_u32 *b2 = (uae_u32 *)&b[i]; - *b2 = col; - } - while (rem--) - b[stop++] = (uae_u8) col; -} - static void fill_line_16 (uae_u8 *buf, unsigned int start, unsigned int stop) { uae_u16 *b = (uae_u16 *)buf; @@ -736,7 +709,6 @@ static void pfield_do_fill_line (int start, int stop) { xlinecheck(start, stop); switch (gfxvidinfo.pixbytes) { - case 1: fill_line_8 (xlinebuffer, start, stop); break; case 2: fill_line_16 (xlinebuffer, start, stop); break; case 4: fill_line_32 (xlinebuffer, start, stop); break; } @@ -1241,32 +1213,27 @@ static void pfield_do_linetoscr (int start, int stop) if (issprites) { if (res_shift == 0) { switch (gfxvidinfo.pixbytes) { - case 1: src_pixel = linetoscr_8_spr (src_pixel, start, stop); break; case 2: src_pixel = linetoscr_16_spr (src_pixel, start, stop); break; case 4: src_pixel = linetoscr_32_spr (src_pixel, start, stop); break; } } else if (res_shift == 2) { switch (gfxvidinfo.pixbytes) { - case 1: src_pixel = linetoscr_8_stretch2_spr (src_pixel, start, stop); break; case 2: src_pixel = linetoscr_16_stretch2_spr (src_pixel, start, stop); break; case 4: src_pixel = linetoscr_32_stretch2_spr (src_pixel, start, stop); break; } } else if (res_shift == 1) { switch (gfxvidinfo.pixbytes) { - case 1: src_pixel = linetoscr_8_stretch1_spr (src_pixel, start, stop); break; case 2: src_pixel = linetoscr_16_stretch1_spr (src_pixel, start, stop); break; case 4: src_pixel = linetoscr_32_stretch1_spr (src_pixel, start, stop); break; } } else if (res_shift == -1) { if (currprefs.gfx_lores_mode) { switch (gfxvidinfo.pixbytes) { - case 1: src_pixel = linetoscr_8_shrink1f_spr (src_pixel, start, stop); break; case 2: src_pixel = linetoscr_16_shrink1f_spr (src_pixel, start, stop); break; case 4: src_pixel = linetoscr_32_shrink1f_spr (src_pixel, start, stop); break; } } else { switch (gfxvidinfo.pixbytes) { - case 1: src_pixel = linetoscr_8_shrink1_spr (src_pixel, start, stop); break; case 2: src_pixel = linetoscr_16_shrink1_spr (src_pixel, start, stop); break; case 4: src_pixel = linetoscr_32_shrink1_spr (src_pixel, start, stop); break; } @@ -1275,32 +1242,27 @@ static void pfield_do_linetoscr (int start, int stop) } else { if (res_shift == 0) { switch (gfxvidinfo.pixbytes) { - case 1: src_pixel = linetoscr_8 (src_pixel, start, stop); break; case 2: src_pixel = linetoscr_16 (src_pixel, start, stop); break; case 4: src_pixel = linetoscr_32 (src_pixel, start, stop); break; } } else if (res_shift == 2) { switch (gfxvidinfo.pixbytes) { - case 1: src_pixel = linetoscr_8_stretch2 (src_pixel, start, stop); break; case 2: src_pixel = linetoscr_16_stretch2 (src_pixel, start, stop); break; case 4: src_pixel = linetoscr_32_stretch2 (src_pixel, start, stop); break; } } else if (res_shift == 1) { switch (gfxvidinfo.pixbytes) { - case 1: src_pixel = linetoscr_8_stretch1 (src_pixel, start, stop); break; case 2: src_pixel = linetoscr_16_stretch1 (src_pixel, start, stop); break; case 4: src_pixel = linetoscr_32_stretch1 (src_pixel, start, stop); break; } } else if (res_shift == -1) { if (currprefs.gfx_lores_mode) { switch (gfxvidinfo.pixbytes) { - case 1: src_pixel = linetoscr_8_shrink1f (src_pixel, start, stop); break; case 2: src_pixel = linetoscr_16_shrink1f (src_pixel, start, stop); break; case 4: src_pixel = linetoscr_32_shrink1f (src_pixel, start, stop); break; } } else { switch (gfxvidinfo.pixbytes) { - case 1: src_pixel = linetoscr_8_shrink1 (src_pixel, start, stop); break; case 2: src_pixel = linetoscr_16_shrink1 (src_pixel, start, stop); break; case 4: src_pixel = linetoscr_32_shrink1 (src_pixel, start, stop); break; } @@ -1862,7 +1824,7 @@ static void pfield_expand_dp_bplcon (void) #endif } -static int isham (uae_u16 bplcon0) +static bool isham (uae_u16 bplcon0) { int p = GET_PLANES (bplcon0); if (!(bplcon0 & 0x800)) @@ -2296,6 +2258,7 @@ static int frame_res_cnt; static void init_drawing_frame (void) { int i, maxline; +#if 1 static int frame_res_old; if (FRAMES_UNTIL_RES_SWITCH > 0 && frame_res_old == frame_res * 2 + frame_res_lace) { @@ -2345,6 +2308,7 @@ static void init_drawing_frame (void) can_use_lores++; lores_reset (); } +#endif init_hardware_for_drawing_frame (); @@ -2375,9 +2339,7 @@ static void init_drawing_frame (void) first_drawn_line = 32767; first_block_line = last_block_line = NO_BLOCK; - if (currprefs.test_drawing_speed) - frame_redraw_necessary = 1; - else if (frame_redraw_necessary) + if (frame_redraw_necessary) frame_redraw_necessary--; center_image (); @@ -2509,10 +2471,8 @@ void draw_status_line_single (uae_u8 *buf, int bpp, int y, int totalwidth, uae_u side = gui_data.drive_side; } else if (led == LED_POWER) { pos = 3; - //on = gui_data.powerled_brightness > 0; on_rgb = ((gui_data.powerled_brightness * 10 / 16) + 0x33) << 16; - on = gui_data.powerled; - //on_rgb = 0xcc0000; + on = 1; off_rgb = 0x330000; } else if (led == LED_CD) { pos = 5; diff --git a/expansion.cpp b/expansion.cpp index bc06e345..bd8e1896 100644 --- a/expansion.cpp +++ b/expansion.cpp @@ -131,7 +131,8 @@ uaecptr ROM_filesys_resname, ROM_filesys_resid; uaecptr ROM_filesys_diagentry; uaecptr ROM_hardfile_resname, ROM_hardfile_resid; uaecptr ROM_hardfile_init; -int uae_boot_rom, uae_boot_rom_size; /* size = code size only */ +bool uae_boot_rom; +int uae_boot_rom_size; /* size = code size only */ /* ********************************************************** */ diff --git a/filesys.cpp b/filesys.cpp index 69eb53b5..8f561586 100644 --- a/filesys.cpp +++ b/filesys.cpp @@ -112,7 +112,7 @@ static int automountunit = -1; #define DEVNAMES_PER_HDF 32 typedef struct { - int open; + bool open; TCHAR *devname; /* device name, e.g. UAE0: */ uaecptr devname_amiga; uaecptr startup; @@ -121,13 +121,14 @@ typedef struct { TCHAR *rootdir; /* root native directory/hdf. empty drive if invalid path */ struct zvolume *zarchive; TCHAR *rootdirdiff; /* "diff" file/directory */ - int readonly; /* disallow write access? */ + bool readonly; /* disallow write access? */ + bool locked; /* action write protect */ int bootpri; /* boot priority. -128 = no autoboot, -129 = no mount */ int devno; int controller; - int wasisempty; /* if true, this unit was created empty */ - int canremove; /* if true, this unit can be safely ejected and remounted */ - int configureddrive; /* if true, this is drive that was manually configured */ + bool wasisempty; /* if true, this unit was created empty */ + bool canremove; /* if true, this unit can be safely ejected and remounted */ + bool configureddrive; /* if true, this is drive that was manually configured */ struct hardfiledata hf; @@ -252,14 +253,14 @@ int get_filesys_unitconfig (struct uae_prefs *p, int index, struct mountedinfo * } if (my_getvolumeinfo (uci->rootdir) < 0) return -1; - mi->ismedia = 1; + mi->ismedia = true; return FILESYS_VIRTUAL; } else { - ui->hf.readonly = 1; + ui->hf.readonly = true; ui->hf.blocksize = uci->blocksize; if (!hdf_open (&ui->hf, uci->rootdir)) { - mi->ismedia = 0; - mi->ismounted = 1; + mi->ismedia = false; + mi->ismounted = true; if (uci->reserved == 0 && uci->sectors == 0 && uci->surfaces == 0) { if (ui->hf.flags & 1) return FILESYS_HARDDRIVE; @@ -267,7 +268,7 @@ int get_filesys_unitconfig (struct uae_prefs *p, int index, struct mountedinfo * } return -1; } - mi->ismedia = 1; + mi->ismedia = true; if (ui->hf.drive_empty) mi->ismedia = 0; hdf_close (&ui->hf); @@ -276,9 +277,9 @@ int get_filesys_unitconfig (struct uae_prefs *p, int index, struct mountedinfo * if (!ui->controller || (ui->controller && p->cs_ide)) { mi->ismounted = 1; if (uci->ishdf) - mi->ismedia = ui->hf.drive_empty ? 0 : 1; + mi->ismedia = ui->hf.drive_empty ? false : true; else - mi->ismedia = 1; + mi->ismedia = true; } } mi->size = ui->hf.virtsize; @@ -396,7 +397,7 @@ TCHAR *filesys_createvolname (const TCHAR *volname, const TCHAR *rootdir, const return nvol; } -static int set_filesys_volume (const TCHAR *rootdir, int *flags, int *readonly, int *emptydrive, struct zvolume **zvp) +static int set_filesys_volume (const TCHAR *rootdir, int *flags, bool *readonly, bool *emptydrive, struct zvolume **zvp) { *emptydrive = 0; if (my_existsfile (rootdir)) { @@ -425,14 +426,14 @@ static int set_filesys_volume (const TCHAR *rootdir, int *flags, int *readonly, } static int set_filesys_unit_1 (int nr, - TCHAR *devname, TCHAR *volname, const TCHAR *rootdir, int readonly, + TCHAR *devname, TCHAR *volname, const TCHAR *rootdir, bool readonly, int secspertrack, int surfaces, int reserved, - int blocksize, int bootpri, int donotmount, int autoboot, + int blocksize, int bootpri, bool donotmount, bool autoboot, TCHAR *filesysdir, int hdc, int flags) { UnitInfo *ui; int i; - int emptydrive = 0; + bool emptydrive = false; if (hdc) return -1; @@ -477,6 +478,7 @@ static int set_filesys_unit_1 (int nr, ui->volname = 0; ui->hf.readonly = readonly; if (!hdf_open (&ui->hf, rootdir) && !readonly) { + write_log (L"Attempting to open in read-only mode\n"); ui->hf.readonly = readonly = 1; hdf_open (&ui->hf, rootdir); } @@ -532,9 +534,9 @@ err: } static int set_filesys_unit (int nr, - TCHAR *devname, TCHAR *volname, const TCHAR *rootdir, int readonly, + TCHAR *devname, TCHAR *volname, const TCHAR *rootdir, bool readonly, int secspertrack, int surfaces, int reserved, - int blocksize, int bootpri, int donotmount, int autoboot, + int blocksize, int bootpri, bool donotmount, bool autoboot, TCHAR *filesysdir, int hdc, int flags) { int ret; @@ -545,9 +547,9 @@ static int set_filesys_unit (int nr, return ret; } -static int add_filesys_unit (TCHAR *devname, TCHAR *volname, const TCHAR *rootdir, int readonly, +static int add_filesys_unit (TCHAR *devname, TCHAR *volname, const TCHAR *rootdir, bool readonly, int secspertrack, int surfaces, int reserved, - int blocksize, int bootpri, int donotmount, int autoboot, + int blocksize, int bootpri, bool donotmount, bool autoboot, TCHAR *filesysdir, int hdc, int flags) { int ret; @@ -851,45 +853,45 @@ typedef struct _unit { int volflags; uae_u32 lockkey; - int inhibited; - int canremovable; + bool inhibited; + bool canremovable; int mountcount; struct zvolume *zarchive; int reinsertdelay; TCHAR *newvolume; TCHAR *newrootdir; - int newreadonly; + bool newreadonly; int newflags; } Unit; static uae_u32 a_uniq, key_uniq; -typedef uae_u8 *dpacket; -#define PUT_PCK_RES1(p,v) do { do_put_mem_long ((uae_u32 *)((p) + dp_Res1), (v)); } while (0) -#define PUT_PCK_RES2(p,v) do { do_put_mem_long ((uae_u32 *)((p) + dp_Res2), (v)); } while (0) -#define GET_PCK_TYPE(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp_Type)))) -#define GET_PCK_RES1(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp_Res1)))) -#define GET_PCK_RES2(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp_Res2)))) -#define GET_PCK_ARG1(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp_Arg1)))) -#define GET_PCK_ARG2(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp_Arg2)))) -#define GET_PCK_ARG3(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp_Arg3)))) -#define GET_PCK_ARG4(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp_Arg4)))) -#define GET_PCK_ARG5(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp_Arg5)))) - -#define PUT_PCK64_RES0(p,v) do { do_put_mem_long ((uae_u32 *)((p) + dp64_Res0), (v)); } while (0) -#define PUT_PCK64_RES1(p,v) do { do_put_mem_long ((uae_u32 *)((p) + dp64_Res1), (((uae_u64)v) >> 32)); do_put_mem_long ((uae_u32 *)((p) + dp64_Res1 + 4), ((uae_u32)v)); } while (0) -#define PUT_PCK64_RES2(p,v) do { do_put_mem_long ((uae_u32 *)((p) + dp64_Res2), (v)); } while (0) - -#define GET_PCK64_TYPE(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp64_Type)))) -#define GET_PCK64_RES0(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp64_Res0)))) -#define GET_PCK64_RES1(p) ( (((uae_s64)(do_get_mem_long ((uae_u32 *)((p) + dp64_Res1)))) << 32) | (((uae_s64)(do_get_mem_long ((uae_u32 *)((p) + dp64_Res1 + 4)))) << 0) ) -#define GET_PCK64_ARG1(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp64_Arg1)))) -#define GET_PCK64_ARG2(p) ( (((uae_s64)(do_get_mem_long ((uae_u32 *)((p) + dp64_Arg2)))) << 32) | (((uae_s64)(do_get_mem_long ((uae_u32 *)((p) + dp64_Arg2 + 4)))) << 0) ) -#define GET_PCK64_ARG3(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp64_Arg3)))) -#define GET_PCK64_ARG4(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp64_Arg4)))) -#define GET_PCK64_ARG5(p) ( (((uae_s64)(do_get_mem_long ((uae_u32 *)((p) + dp64_Arg5)))) << 32) | (((uae_s64)(do_get_mem_long ((uae_u32 *)((p) + dp64_Arg5 + 4)))) << 0) ) +typedef uaecptr dpacket; +#define PUT_PCK_RES1(p,v) do { x_put_long ((p) + dp_Res1, (v)); } while (0) +#define PUT_PCK_RES2(p,v) do { x_put_long ((p) + dp_Res2, (v)); } while (0) +#define GET_PCK_TYPE(p) ((uae_s32)(x_get_long ((p) + dp_Type))) +#define GET_PCK_RES1(p) ((uae_s32)(x_get_long ((p) + dp_Res1))) +#define GET_PCK_RES2(p) ((uae_s32)(x_get_long ((p) + dp_Res2))) +#define GET_PCK_ARG1(p) ((uae_s32)(x_get_long ((p) + dp_Arg1))) +#define GET_PCK_ARG2(p) ((uae_s32)(x_get_long ((p) + dp_Arg2))) +#define GET_PCK_ARG3(p) ((uae_s32)(x_get_long ((p) + dp_Arg3))) +#define GET_PCK_ARG4(p) ((uae_s32)(x_get_long ((p) + dp_Arg4))) +#define GET_PCK_ARG5(p) ((uae_s32)(x_get_long ((p) + dp_Arg5))) + +#define PUT_PCK64_RES0(p,v) do { x_put_long ((p) + dp64_Res0, (v)); } while (0) +#define PUT_PCK64_RES1(p,v) do { x_put_long ((p) + dp64_Res1, (((uae_u64)v) >> 32)); x_put_long ((p) + dp64_Res1 + 4, ((uae_u32)v)); } while (0) +#define PUT_PCK64_RES2(p,v) do { x_put_long ((p) + dp64_Res2, (v)); } while (0) + +#define GET_PCK64_TYPE(p) ((uae_s32)(x_get_long ((p) + dp64_Type))) +#define GET_PCK64_RES0(p) ((uae_s32)(x_get_long ((p) + dp64_Res0))) +#define GET_PCK64_RES1(p) ( (((uae_s64)(x_get_long ((p) + dp64_Res1))) << 32) | (((uae_s64)(x_get_long ((p) + dp64_Res1 + 4))) << 0) ) +#define GET_PCK64_ARG1(p) ((uae_s32)(x_get_long ((p) + dp64_Arg1))) +#define GET_PCK64_ARG2(p) ( (((uae_s64)(x_get_long ((p) + dp64_Arg2))) << 32) | (((uae_s64)(x_get_long ((p) + dp64_Arg2 + 4))) << 0) ) +#define GET_PCK64_ARG3(p) ((uae_s32)(x_get_long ((p) + dp64_Arg3))) +#define GET_PCK64_ARG4(p) ((uae_s32)(x_get_long ((p) + dp64_Arg4))) +#define GET_PCK64_ARG5(p) ( (((uae_s64)(x_get_long ((p) + dp64_Arg5))) << 32) | (((uae_s64)(x_get_long ((p) + dp64_Arg5 + 4))) << 0) ) static int flush_cache (Unit *unit, int num); @@ -899,7 +901,7 @@ static TCHAR *char1 (uaecptr addr) static TCHAR bufx[1024]; unsigned int i = 0; do { - buf[i] = get_byte (addr); + buf[i] = x_get_byte (addr); addr++; } while (buf[i++] && i < sizeof (buf)); return au_fs_copy (bufx, sizeof (bufx) / sizeof (TCHAR), buf); @@ -910,11 +912,11 @@ static TCHAR *bstr1 (uaecptr addr) static TCHAR bufx[257]; static uae_char buf[257]; int i; - int n = get_byte (addr); + int n = x_get_byte (addr); addr++; for (i = 0; i < n; i++, addr++) - buf[i] = get_byte (addr); + buf[i] = x_get_byte (addr); buf[i] = 0; return au_fs_copy (bufx, sizeof (bufx) / sizeof (TCHAR), buf); } @@ -922,12 +924,12 @@ static TCHAR *bstr1 (uaecptr addr) static TCHAR *bstr (Unit *unit, uaecptr addr) { int i; - int n = get_byte (addr); + int n = x_get_byte (addr); uae_char buf[257]; addr++; for (i = 0; i < n; i++, addr++) - buf[i] = get_byte (addr); + buf[i] = x_get_byte (addr); buf[i] = 0; au_fs_copy (unit->tmpbuf3, sizeof (unit->tmpbuf3) / sizeof (TCHAR), buf); return unit->tmpbuf3; @@ -937,13 +939,13 @@ static TCHAR *bstr_cut (Unit *unit, uaecptr addr) { TCHAR *p = unit->tmpbuf3; int i, colon_seen = 0, off; - int n = get_byte (addr); + int n = x_get_byte (addr); uae_char buf[257]; off = 0; addr++; for (i = 0; i < n; i++, addr++) { - uae_u8 c = get_byte (addr); + uae_u8 c = x_get_byte (addr); buf[i] = c; if (c == '/' || (c == ':' && colon_seen++ == 0)) off = i + 1; @@ -1041,10 +1043,10 @@ static void set_volume_name (Unit *unit) s = ua_fs (unit->ui.volname, -1); namelen = strlen (s); - put_byte (unit->volume + 44, namelen); + x_put_byte (unit->volume + 44, namelen); for (i = 0; i < namelen; i++) - put_byte (unit->volume + 45 + i, s[i]); - put_byte (unit->volume + 45 + namelen, 0); + x_put_byte (unit->volume + 45 + i, s[i]); + x_put_byte (unit->volume + 45 + namelen, 0); xfree (s); unit->rootnode.aname = unit->ui.volname; unit->rootnode.nname = unit->ui.rootdir; @@ -1053,7 +1055,7 @@ static void set_volume_name (Unit *unit) static int filesys_isvolume (Unit *unit) { - return get_byte (unit->volume + 44); + return x_get_byte (unit->volume + 44); } static void clear_exkeys (Unit *unit) @@ -1105,8 +1107,8 @@ int filesys_eject (int nr) u->mountcount++; write_log (L"FILESYS: removed volume '%s'\n", u->ui.volname); flush_cache (u, -1); - put_byte (u->volume + 172 - 32, -2); - uae_Signal (get_long (u->volume + 176 - 32), 1 << 13); + x_put_byte (u->volume + 172 - 32, -2); + uae_Signal (x_get_long (u->volume + 176 - 32), 1 << 13); return 1; } @@ -1127,7 +1129,7 @@ void filesys_vsync (void) } } } -static void filesys_delayed_change (Unit *u, int frames, const TCHAR *rootdir, const TCHAR *volume, int readonly, int flags) +static void filesys_delayed_change (Unit *u, int frames, const TCHAR *rootdir, const TCHAR *volume, bool readonly, int flags) { u->reinsertdelay = 50; u->newflags = flags; @@ -1204,7 +1206,7 @@ int filesys_media_change (const TCHAR *rootdir, int inserted, struct uaedev_conf /* new volume inserted and it was previously mounted? */ if (nr >= 0) { if (!filesys_isvolume (u)) /* not going to mount twice */ - return filesys_insert (nr, volptr, rootdir, -1, -1); + return filesys_insert (nr, volptr, rootdir, false, -1); return 0; } if (inserted < 0) /* -1 = only mount if already exists */ @@ -1249,10 +1251,10 @@ int hardfile_remount (int nr) return 1; } -int filesys_insert (int nr, TCHAR *volume, const TCHAR *rootdir, int readonly, int flags) +int filesys_insert (int nr, TCHAR *volume, const TCHAR *rootdir, bool readonly, int flags) { struct uaedev_config_info *uci; - int emptydrive = 0; + bool emptydrive = false; UnitInfo *ui; Unit *u; @@ -1310,11 +1312,11 @@ int filesys_insert (int nr, TCHAR *volume, const TCHAR *rootdir, int readonly, i ui->volflags = u->volflags = u->ui.volflags = flags; _tcscpy (uci->volname, ui->volname); _tcscpy (uci->rootdir, rootdir); - if (readonly >= 0) + if (flags >= 0) uci->readonly = ui->readonly = u->ui.readonly = readonly; - put_byte (u->volume + 44, 0); - put_byte (u->volume + 172 - 32, 1); - uae_Signal (get_long (u->volume + 176 - 32), 1 << 13); + x_put_byte (u->volume + 44, 0); + x_put_byte (u->volume + 172 - 32, 1); + uae_Signal (x_get_long (u->volume + 176 - 32), 1 << 13); return 100 + nr; } @@ -2120,13 +2122,13 @@ static uae_u32 REGPARAM2 startup_handler (TrapContext *context) /* Just got the startup packet. It's in A4. DosBase is in A2, * our allocated volume structure is in A3, A5 is a pointer to * our port. */ - uaecptr rootnode = get_long (m68k_areg (regs, 2) + 34); - uaecptr dos_info = get_long (rootnode + 24) << 2; + uaecptr rootnode = x_get_long (m68k_areg (regs, 2) + 34); + uaecptr dos_info = x_get_long (rootnode + 24) << 2; uaecptr pkt = m68k_dreg (regs, 3); - uaecptr arg2 = get_long (pkt + dp_Arg2); + uaecptr arg2 = x_get_long (pkt + dp_Arg2); uaecptr devnode; int i; - TCHAR *devname = bstr1 (get_long (pkt + dp_Arg1) << 2); + TCHAR *devname = bstr1 (x_get_long (pkt + dp_Arg1) << 2); TCHAR *s; Unit *unit; UnitInfo *uinfo; @@ -2150,8 +2152,8 @@ static uae_u32 REGPARAM2 startup_handler (TrapContext *context) if (i == MAX_FILESYSTEM_UNITS) { write_log (L"Failed attempt to mount device '%s'\n", devname); - put_long (pkt + dp_Res1, DOS_FALSE); - put_long (pkt + dp_Res2, ERROR_DEVICE_NOT_MOUNTED); + x_put_long (pkt + dp_Res1, DOS_FALSE); + x_put_long (pkt + dp_Res2, ERROR_DEVICE_NOT_MOUNTED); return 0; } uinfo = mountinfo.ui + i; @@ -2161,8 +2163,8 @@ static uae_u32 REGPARAM2 startup_handler (TrapContext *context) if (!uinfo->wasisempty && !ef && !ed) { write_log (L"Failed attempt to mount device '%s'\n", devname); - put_long (pkt + dp_Res1, DOS_FALSE); - put_long (pkt + dp_Res2, ERROR_DEVICE_NOT_MOUNTED); + x_put_long (pkt + dp_Res1, DOS_FALSE); + x_put_long (pkt + dp_Res2, ERROR_DEVICE_NOT_MOUNTED); return 0; } @@ -2179,13 +2181,13 @@ static uae_u32 REGPARAM2 startup_handler (TrapContext *context) unit->ui.volname, unit->volflags, uinfo->wasisempty, ed, ef, unit->ui.rootdir); /* fill in our process in the device node */ - devnode = get_long (pkt + dp_Arg3) << 2; - put_long (devnode + 8, unit->port); + devnode = x_get_long (pkt + dp_Arg3) << 2; + x_put_long (devnode + 8, unit->port); unit->dosbase = m68k_areg (regs, 2); /* make new volume */ unit->volume = m68k_areg (regs, 3) + 32; - put_long (unit->volume + 180 - 32, devnode); + x_put_long (unit->volume + 180 - 32, devnode); #ifdef UAE_FILESYS_THREADS unit->locklist = m68k_areg (regs, 3) + 8; #else @@ -2193,26 +2195,26 @@ static uae_u32 REGPARAM2 startup_handler (TrapContext *context) #endif unit->dummy_message = m68k_areg (regs, 3) + 12; - put_long (unit->dummy_message + 10, 0); + x_put_long (unit->dummy_message + 10, 0); - put_long (unit->volume + 4, 2); /* Type = dt_volume */ - put_long (unit->volume + 12, 0); /* Lock */ - put_long (unit->volume + 16, 3800 + i); /* Creation Date */ - put_long (unit->volume + 20, 0); - put_long (unit->volume + 24, 0); - put_long (unit->volume + 28, 0); /* lock list */ - put_long (unit->volume + 40, (unit->volume + 44) >> 2); /* Name */ + x_put_long (unit->volume + 4, 2); /* Type = dt_volume */ + x_put_long (unit->volume + 12, 0); /* Lock */ + x_put_long (unit->volume + 16, 3800 + i); /* Creation Date */ + x_put_long (unit->volume + 20, 0); + x_put_long (unit->volume + 24, 0); + x_put_long (unit->volume + 28, 0); /* lock list */ + x_put_long (unit->volume + 40, (unit->volume + 44) >> 2); /* Name */ - put_byte (unit->volume + 44, 0); + x_put_byte (unit->volume + 44, 0); if (!uinfo->wasisempty) { set_volume_name (unit); fsdb_clean_dir (&unit->rootnode); } - put_long (unit->volume + 8, unit->port); - put_long (unit->volume + 32, DISK_TYPE); + x_put_long (unit->volume + 8, unit->port); + x_put_long (unit->volume + 32, DISK_TYPE); - put_long (pkt + dp_Res1, DOS_TRUE); + x_put_long (pkt + dp_Res1, DOS_TRUE); return 1 | (late ? 2 : 0); } @@ -2232,15 +2234,15 @@ static void PUT_PCK_RES2 (packet, dos_errno ()); return; } - put_long (info, 0); /* errors */ - put_long (info + 4, unit->unit); /* unit number */ - put_long (info + 8, unit->ui.readonly ? 80 : 82); /* state */ - put_long (info + 12, fsu.fsu_blocks ); /* numblocks */ - put_long (info + 16, fsu.fsu_blocks - fsu.fsu_bavail); /* inuse */ - put_long (info + 20, 1024); /* bytesperblock */ - put_long (info + 24, DISK_TYPE); /* disk type */ - put_long (info + 28, unit->volume >> 2); /* volume node */ - put_long (info + 32, 0); /* inuse */ + x_put_long (info, 0); /* errors */ + x_put_long (info + 4, unit->unit); /* unit number */ + x_put_long (info + 8, unit->ui.readonly || unit->ui.locked ? 80 : 82); /* state */ + x_put_long (info + 12, fsu.fsu_blocks ); /* numblocks */ + x_put_long (info + 16, fsu.fsu_blocks - fsu.fsu_bavail); /* inuse */ + x_put_long (info + 20, 1024); /* bytesperblock */ + x_put_long (info + 24, DISK_TYPE); /* disk type */ + x_put_long (info + 28, unit->volume >> 2); /* volume node */ + x_put_long (info + 32, 0); /* inuse */ PUT_PCK_RES1 (packet, DOS_TRUE); } @@ -2316,10 +2318,10 @@ static void return; } TRACE((L"{ next=0x%lx, mode=%ld, handler=0x%lx, volume=0x%lx, aino %lx ", - get_long (lock) << 2, get_long (lock+8), - get_long (lock+12), get_long (lock+16), - get_long (lock + 4))); - a = lookup_aino (unit, get_long (lock + 4)); + x_get_long (lock) << 2, x_get_long (lock+8), + x_get_long (lock+12), x_get_long (lock+16), + x_get_long (lock + 4))); + a = lookup_aino (unit, x_get_long (lock + 4)); if (a == 0) { TRACE((L"not found!")); } else { @@ -2333,7 +2335,7 @@ static a_inode *find_aino (Unit *unit, uaecptr lock, const TCHAR *name, int *err a_inode *a; if (lock) { - a_inode *olda = lookup_aino (unit, get_long (lock + 4)); + a_inode *olda = lookup_aino (unit, x_get_long (lock + 4)); if (olda == 0) { /* That's the best we can hope to do. */ a = get_aino (unit, &unit->rootnode, name, err); @@ -2357,18 +2359,18 @@ static uaecptr make_lock (Unit *unit, uae_u32 uniq, long mode) /* allocate lock from the list kept by the assembly code */ uaecptr lock; - lock = get_long (unit->locklist); - put_long (unit->locklist, get_long (lock)); + lock = x_get_long (unit->locklist); + x_put_long (unit->locklist, x_get_long (lock)); lock += 4; - put_long (lock + 4, uniq); - put_long (lock + 8, mode); - put_long (lock + 12, unit->port); - put_long (lock + 16, unit->volume >> 2); + x_put_long (lock + 4, uniq); + x_put_long (lock + 8, mode); + x_put_long (lock + 12, unit->port); + x_put_long (lock + 16, unit->volume >> 2); /* prepend to lock chain */ - put_long (lock, get_long (unit->volume + 28)); - put_long (unit->volume + 28, lock >> 2); + x_put_long (lock, x_get_long (unit->volume + 28)); + x_put_long (unit->volume + 28, lock >> 2); DUMPLOCK(unit, lock); return lock; @@ -2386,16 +2388,16 @@ static uaecptr make_lock (Unit *unit, uae_u32 uniq, long mode) static void notify_send (Unit *unit, Notify *n) { uaecptr nr = n->notifyrequest; - int flags = get_long (nr + 12); + int flags = x_get_long (nr + 12); if (flags & NRF_SEND_MESSAGE) { if (!(flags & NRF_WAIT_REPLY) || ((flags & NRF_WAIT_REPLY) && !(flags & NRF_MAGIC))) { uae_NotificationHack (unit->port, nr); } else if (flags & NRF_WAIT_REPLY) { - put_long (nr + 12, get_long (nr + 12) | NRF_MAGIC); + x_put_long (nr + 12, x_get_long (nr + 12) | NRF_MAGIC); } } else if (flags & NRF_SEND_SIGNAL) { - uae_Signal (get_long (nr + 16), 1 << get_byte (nr + 20)); + uae_Signal (x_get_long (nr + 16), 1 << x_get_byte (nr + 20)); } } @@ -2436,8 +2438,8 @@ static void TRACE((L"ACTION_ADD_NOTIFY\n")); - name = my_strdup (char1 (get_long (nr + 4))); - flags = get_long (nr + 12); + name = my_strdup (char1 (x_get_long (nr + 4))); + flags = x_get_long (nr + 12); if (!(flags & (NRF_SEND_MESSAGE | NRF_SEND_SIGNAL))) { PUT_PCK_RES1 (packet, DOS_FALSE); @@ -2447,14 +2449,14 @@ static void #if 0 write_log (L"Notify:\n"); - write_log (L"nr_Name '%s'\n", char1 (get_long (nr + 0))); + write_log (L"nr_Name '%s'\n", char1 (x_get_long (nr + 0))); write_log (L"nr_FullName '%s'\n", name); - write_log (L"nr_UserData %08X\n", get_long (nr + 8)); + write_log (L"nr_UserData %08X\n", x_get_long (nr + 8)); write_log (L"nr_Flags %08X\n", flags); if (flags & NRF_SEND_MESSAGE) { - write_log (L"Message NotifyRequest, port = %08X\n", get_long (nr + 16)); + write_log (L"Message NotifyRequest, port = %08X\n", x_get_long (nr + 16)); } else if (flags & NRF_SEND_SIGNAL) { - write_log (L"Signal NotifyRequest, Task = %08X signal = %d\n", get_long (nr + 16), get_long (nr + 20)); + write_log (L"Signal NotifyRequest, Task = %08X signal = %d\n", x_get_long (nr + 16), x_get_long (nr + 20)); } else { write_log (L"corrupt NotifyRequest\n"); } @@ -2508,13 +2510,13 @@ static void free_lock (Unit *unit, uaecptr lock) if (! lock) return; - if (lock == get_long (unit->volume + 28) << 2) { - put_long (unit->volume + 28, get_long (lock)); + if (lock == x_get_long (unit->volume + 28) << 2) { + x_put_long (unit->volume + 28, x_get_long (lock)); } else { - uaecptr current = get_long (unit->volume + 28); + uaecptr current = x_get_long (unit->volume + 28); uaecptr next = 0; while (current) { - next = get_long (current << 2); + next = x_get_long (current << 2); if (lock == next << 2) break; current = next; @@ -2523,11 +2525,11 @@ static void free_lock (Unit *unit, uaecptr lock) write_log (L"tried to unlock non-existing lock %x\n", lock); return; } - put_long (current << 2, get_long (lock)); + x_put_long (current << 2, x_get_long (lock)); } lock -= 4; - put_long (lock, get_long (unit->locklist)); - put_long (unit->locklist, lock); + x_put_long (lock, x_get_long (unit->locklist)); + x_put_long (unit->locklist, lock); } static void @@ -2572,7 +2574,7 @@ static void action_free_lock (Unit *unit, dpacket packet) TRACE((L"ACTION_FREE_LOCK(0x%lx)\n", lock)); DUMPLOCK(unit, lock); - a = lookup_aino (unit, get_long (lock + 4)); + a = lookup_aino (unit, x_get_long (lock + 4)); if (a == 0) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_OBJECT_NOT_AROUND); @@ -2624,7 +2626,7 @@ static void PUT_PCK_RES1 (packet, 0); return; } - action_dup_lock_2 (unit, packet, get_long (lock + 4)); + action_dup_lock_2 (unit, packet, x_get_long (lock + 4)); } @@ -2800,9 +2802,9 @@ static void entrytype = aino->dir ? 2 : -3; xs = aino->aname; } - put_long (info + 4, entrytype); + x_put_long (info + 4, entrytype); /* AmigaOS docs say these have to contain the same value. */ - put_long (info + 120, entrytype); + x_put_long (info + 120, entrytype); TRACE((L"name=\"%s\"\n", xs)); x2 = x = ua_fs (xs, -1); @@ -2810,26 +2812,26 @@ static void if (n > 106) n = 106; i = 8; - put_byte (info + i, n); i++; + x_put_byte (info + i, n); i++; while (n--) - put_byte (info + i, *x), i++, x++; + x_put_byte (info + i, *x), i++, x++; while (i < 108) - put_byte (info + i, 0), i++; + x_put_byte (info + i, 0), i++; xfree (x2); - put_long (info + 116, fsdb_can ? aino->amigaos_mode : fsdb_mode_supported (aino)); - put_long (info + 124, statbuf.st_size > MAXFILESIZE32 ? MAXFILESIZE32 : statbuf.st_size); + x_put_long (info + 116, fsdb_can ? aino->amigaos_mode : fsdb_mode_supported (aino)); + x_put_long (info + 124, statbuf.st_size > MAXFILESIZE32 ? MAXFILESIZE32 : statbuf.st_size); #ifdef HAVE_ST_BLOCKS - put_long (info + 128, statbuf.st_blocks); + x_put_long (info + 128, statbuf.st_blocks); #else - put_long (info + 128, (statbuf.st_size + 511) / 512); + x_put_long (info + 128, (statbuf.st_size + 511) / 512); #endif get_time (statbuf.st_mtime, &days, &mins, &ticks); - put_long (info + 132, days); - put_long (info + 136, mins); - put_long (info + 140, ticks); + x_put_long (info + 132, days); + x_put_long (info + 136, mins); + x_put_long (info + 140, ticks); if (aino->comment == 0 || !fsdb_can) - put_long (info + 144, 0); + x_put_long (info + 144, 0); else { TRACE((L"comment=\"%s\"\n", aino->comment)); i = 144; @@ -2840,11 +2842,11 @@ static void n = strlen (x); if (n > 78) n = 78; - put_byte (info + i, n); i++; + x_put_byte (info + i, n); i++; while (n--) - put_byte (info + i, *x), i++, x++; + x_put_byte (info + i, *x), i++, x++; while (i < 224) - put_byte (info + i, 0), i++; + x_put_byte (info + i, 0), i++; xfree (x2); } PUT_PCK_RES1 (packet, DOS_TRUE); @@ -2855,7 +2857,7 @@ int get_native_path (uae_u32 lock, TCHAR *out) int i = 0; for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) { if (mountinfo.ui[i].self) { - a_inode *a = lookup_aino (mountinfo.ui[i].self, get_long ((lock << 2) + 4)); + a_inode *a = lookup_aino (mountinfo.ui[i].self, x_get_long ((lock << 2) + 4)); if (a) { _tcscpy (out, a->nname); return 0; @@ -2956,9 +2958,9 @@ static int exalldo (uaecptr exalldata, uae_u32 exalldatasize, uae_u32 type, uaec gid = 0; } - i = get_long (control + 0); + i = x_get_long (control + 0); while (i > 0) { - exp = get_long (exp); /* ed_Next */ + exp = x_get_long (exp); /* ed_Next */ i--; } @@ -2967,41 +2969,41 @@ static int exalldo (uaecptr exalldata, uae_u32 exalldatasize, uae_u32 type, uaec #if EXALL_DEBUG > 0 write_log (L"ID=%d, %d, %08x: '%s'%s\n", - get_long (control + 4), get_long (control + 0), exp, xs, aino->dir ? L" [DIR]" : L""); + x_get_long (control + 4), x_get_long (control + 0), exp, xs, aino->dir ? L" [DIR]" : L""); #endif - put_long (exp, exp + size + size2); /* ed_Next */ + x_put_long (exp, exp + size + size2); /* ed_Next */ if (type >= 1) { - put_long (exp + 4, exp + size2); + x_put_long (exp + 4, exp + size2); for (i = 0; i <= strlen (x); i++) { - put_byte (exp + size2, x[i]); + x_put_byte (exp + size2, x[i]); size2++; } } if (type >= 2) - put_long (exp + 8, entrytype); + x_put_long (exp + 8, entrytype); if (type >= 3) - put_long (exp + 12, statbuf.st_size > MAXFILESIZE32 ? MAXFILESIZE32 : statbuf.st_size); + x_put_long (exp + 12, statbuf.st_size > MAXFILESIZE32 ? MAXFILESIZE32 : statbuf.st_size); if (type >= 4) - put_long (exp + 16, flags); + x_put_long (exp + 16, flags); if (type >= 5) { - put_long (exp + 20, days); - put_long (exp + 24, mins); - put_long (exp + 28, ticks); + x_put_long (exp + 20, days); + x_put_long (exp + 24, mins); + x_put_long (exp + 28, ticks); } if (type >= 6) { - put_long (exp + 32, exp + size2); - put_byte (exp + size2, strlen (comment)); + x_put_long (exp + 32, exp + size2); + x_put_byte (exp + size2, strlen (comment)); for (i = 0; i <= strlen (comment); i++) { - put_byte (exp + size2, comment[i]); + x_put_byte (exp + size2, comment[i]); size2++; } } if (type >= 7) { - put_word (exp + 36, uid); - put_word (exp + 38, gid); + x_put_word (exp + 36, uid); + x_put_word (exp + 38, gid); } - put_long (control + 0, get_long (control + 0) + 1); + x_put_long (control + 0, x_get_long (control + 0) + 1); ret = 1; end: xfree (x); @@ -3018,7 +3020,7 @@ static int action_examine_all_do (Unit *unit, uaecptr lock, ExAllKey *eak, uaecp TCHAR fn[MAX_DPATH]; if (lock != 0) - base = lookup_aino (unit, get_long (lock + 4)); + base = lookup_aino (unit, x_get_long (lock + 4)); if (base == 0) base = &unit->rootnode; for (;;) { @@ -3041,7 +3043,7 @@ static int action_examine_all_do (Unit *unit, uaecptr lock, ExAllKey *eak, uaecp if (!aino) return 0; eak->id = unit->exallid++; - put_long (control + 4, eak->id); + x_put_long (control + 4, eak->id); if (!exalldo (exalldata, exalldatasize, type, control, unit, aino)) { eak->fn = my_strdup (fn); /* no space in exallstruct, save current entry */ break; @@ -3059,7 +3061,7 @@ static int action_examine_all_end (Unit *unit, dpacket packet) if (kickstart_version < 36) return 0; - id = get_long (control + 4); + id = x_get_long (control + 4); eak = getexall (unit, control, id); #if EXALL_DEBUG > 0 write_log (L"EXALL_END ID=%d %x\n", id, eak); @@ -3104,10 +3106,10 @@ static int action_examine_all (Unit *unit, dpacket packet) write_log (L"exall: %08x %08x-%08x %d %d %08x\n", lock, exalldata, exalldata + exalldatasize, exalldatasize, type, control); write_log (L"exall: MatchString %08x, MatchFunc %08x\n", - get_long (control + 8), get_long (control + 12)); + x_get_long (control + 8), x_get_long (control + 12)); #endif - put_long (control + 0, 0); /* eac_Entries */ + x_put_long (control + 0, 0); /* eac_Entries */ /* EXAMINE ALL might use dos.library MatchPatternNoCase() which is >=36 */ if (kickstart_version < 36) @@ -3119,7 +3121,7 @@ static int action_examine_all (Unit *unit, dpacket packet) } PUT_PCK_RES1 (packet, DOS_TRUE); - id = get_long (control + 4); + id = x_get_long (control + 4); if (id == EXALL_END) { write_log (L"FILESYS: EXALL called twice with ERROR_NO_MORE_ENTRIES\n"); goto fail; /* already ended exall() */ @@ -3133,7 +3135,7 @@ static int action_examine_all (Unit *unit, dpacket packet) } if (!action_examine_all_do (unit, lock, eak, exalldata, exalldatasize, type, control)) goto fail; - if (get_long (control + 0) == 0) { + if (x_get_long (control + 0) == 0) { /* uh, no space for first entry.. */ doserr = ERROR_NO_FREE_STORE; goto fail; @@ -3145,7 +3147,7 @@ static int action_examine_all (Unit *unit, dpacket packet) if (!eak) goto fail; if (lock != 0) - base = lookup_aino (unit, get_long (lock + 4)); + base = lookup_aino (unit, x_get_long (lock + 4)); if (base == 0) base = &unit->rootnode; #if EXALL_DEBUG > 0 @@ -3155,10 +3157,10 @@ static int action_examine_all (Unit *unit, dpacket packet) if (!d) goto fail; eak->dirhandle = d; - put_long (control + 4, eak->id); + x_put_long (control + 4, eak->id); if (!action_examine_all_do (unit, lock, eak, exalldata, exalldatasize, type, control)) goto fail; - if (get_long (control + 0) == 0) { + if (x_get_long (control + 0) == 0) { /* uh, no space for first entry.. */ doserr = ERROR_NO_FREE_STORE; goto fail; @@ -3170,18 +3172,18 @@ static int action_examine_all (Unit *unit, dpacket packet) fail: /* Clear last ed_Next. This "list" is quite non-Amiga like.. */ exp = exalldata; - i = get_long (control + 0); + i = x_get_long (control + 0); for (;;) { if (i <= 1) { if (exp) - put_long (exp, 0); + x_put_long (exp, 0); break; } - exp = get_long (exp); /* ed_Next */ + exp = x_get_long (exp); /* ed_Next */ i--; } #if EXALL_DEBUG > 0 - write_log("ok=%d, err=%d, eac_Entries = %d\n", ok, ok ? -1 : doserr, get_long (control + 0)); + write_log("ok=%d, err=%d, eac_Entries = %d\n", ok, ok ? -1 : doserr, x_get_long (control + 0)); #endif if (!ok) { @@ -3195,7 +3197,7 @@ fail: eak->fn = NULL; } if (doserr == ERROR_NO_MORE_ENTRIES) - put_long (control + 4, EXALL_END); + x_put_long (control + 4, EXALL_END); } return 1; } @@ -3205,8 +3207,8 @@ static uae_u32 REGPARAM2 exall_helper (TrapContext *context) int i; Unit *u; uaecptr packet = m68k_areg (regs, 4); - uaecptr control = get_long (packet + dp_Arg5); - uae_u32 id = get_long (control + 4); + uaecptr control = x_get_long (packet + dp_Arg5); + uae_u32 id = x_get_long (control + 4); #if EXALL_DEBUG > 0 write_log (L"FILESYS: EXALL extra round ID=%d\n", id); @@ -3216,7 +3218,7 @@ static uae_u32 REGPARAM2 exall_helper (TrapContext *context) for (u = units; u; u = u->next) { for (i = 0; i < EXALLKEYS; i++) { if (u->exalls[i].id == id && u->exalls[i].control == control) { - action_examine_all (u, get_real_address (packet)); + action_examine_all (u, packet); } } } @@ -3233,15 +3235,15 @@ static void action_examine_object (Unit *unit, dpacket packet) DUMPLOCK(unit, lock); if (lock != 0) - aino = lookup_aino (unit, get_long (lock + 4)); + aino = lookup_aino (unit, x_get_long (lock + 4)); if (aino == 0) aino = &unit->rootnode; get_fileinfo (unit, packet, info, aino); if (aino->dir) { - put_long (info, 0xFFFFFFFF); + x_put_long (info, 0xFFFFFFFF); } else - put_long (info, 0); + x_put_long (info, 0); } /* Read a directory's contents, create a_inodes for each file, and @@ -3323,11 +3325,11 @@ static void action_examine_next (Unit *unit, dpacket packet) DUMPLOCK(unit, lock); if (lock != 0) - aino = lookup_aino (unit, get_long (lock + 4)); + aino = lookup_aino (unit, x_get_long (lock + 4)); if (aino == 0) aino = &unit->rootnode; for(;;) { - uniq = get_long (info); + uniq = x_get_long (info); if (uniq == 0) { write_log (L"ExNext called for a file! (Houston?)\n"); goto no_more_entries; @@ -3345,13 +3347,13 @@ static void action_examine_next (Unit *unit, dpacket packet) } } else { TRACE((L"Looking up ExKey\n")); - ek = lookup_exkey (unit, get_long (info)); + ek = lookup_exkey (unit, x_get_long (info)); } if (ek == 0) { write_log (L"Couldn't find a matching ExKey. Prepare for trouble.\n"); goto no_more_entries; } - put_long (info, ek->uniq); + x_put_long (info, ek->uniq); if (!ek->curr_file || ek->curr_file->mountcount == unit->mountcount) break; ek->curr_file = ek->curr_file->sibling; @@ -3408,14 +3410,14 @@ static void do_find (Unit *unit, dpacket packet, int mode, int create, int fallb return; } if (create != 2) { - if ((((mode & aino->amigaos_mode) & A_FIBF_WRITE) != 0 || unit->ui.readonly) + if ((((mode & aino->amigaos_mode) & A_FIBF_WRITE) != 0 || unit->ui.readonly || unit->ui.locked) && fallback) { mode &= ~A_FIBF_WRITE; } /* Kick 1.3 doesn't check read and write access bits - maybe it would be * simpler just not to do that either. */ - if ((mode & A_FIBF_WRITE) != 0 && unit->ui.readonly) { + if ((mode & A_FIBF_WRITE) != 0 && (unit->ui.readonly || unit->ui.locked)) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED); return; @@ -3476,7 +3478,7 @@ static void do_find (Unit *unit, dpacket packet, int mode, int create, int fallb if (create && isarch) fsdb_set_file_attrs (aino); - put_long (fh + 36, k->uniq); + x_put_long (fh + 36, k->uniq); if (create == 2) { aino->elock = 1; // clear comment if file already existed @@ -3513,7 +3515,7 @@ static void return; } - aino = lookup_aino (unit, get_long (lock + 4)); + aino = lookup_aino (unit, x_get_long (lock + 4)); if (aino == 0) aino = &unit->rootnode; mode = aino->amigaos_mode; /* Use same mode for opened filehandle as existing Lock() */ @@ -3526,7 +3528,7 @@ static void : O_RDWR)); /* the files on CD really can have the write-bit set. */ - if (unit->ui.readonly) + if (unit->ui.readonly || unit->ui.locked) openmode = O_RDONLY; fd = fs_open (unit, aino->nname, openmode | O_BINARY); @@ -3540,7 +3542,7 @@ static void k->fd = fd; k->aino = aino; - put_long (fh + 36, k->uniq); + x_put_long (fh + 36, k->uniq); /* I don't think I need to play with shlock count here, because I'm opening from an existing lock ??? */ @@ -3559,7 +3561,7 @@ static void static void action_find_output (Unit *unit, dpacket packet) { - if (unit->ui.readonly) { + if (unit->ui.readonly || unit->ui.locked) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED); return; @@ -3570,7 +3572,7 @@ static void static void action_find_write (Unit *unit, dpacket packet) { - if (unit->ui.readonly) { + if (unit->ui.readonly || unit->ui.locked) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED); return; @@ -3663,6 +3665,7 @@ static void PUT_PCK_RES1 (packet, actual); k->file_pos += actual; } + flush_dcache (addr, size); } else { uae_u8 *buf; off_t old, filesize; @@ -3691,7 +3694,7 @@ static void int i; PUT_PCK_RES1 (packet, actual); for (i = 0; i < actual; i++) - put_byte (addr + i, buf[i]); + x_put_byte (addr + i, buf[i]); k->file_pos += actual; } xfree (buf); @@ -3718,7 +3721,7 @@ static void gui_flicker_led (LED_HD, unit->unit, 2); TRACE((L"ACTION_WRITE(%s,0x%lx,%ld)\n", k->aino->nname, addr, size)); - if (unit->ui.readonly) { + if (unit->ui.readonly || unit->ui.locked) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED); return; @@ -3740,7 +3743,7 @@ static void } for (i = 0; i < size; i++) - buf[i] = get_byte (addr + i); + buf[i] = x_get_byte (addr + i); actual = fs_write (k->fd, buf, size); xfree (buf); @@ -3823,7 +3826,7 @@ static void TRACE((L"ACTION_SET_PROTECT(0x%lx,\"%s\",0x%lx)\n", lock, bstr (unit, name), mask)); - if (unit->ui.readonly) { + if (unit->ui.readonly || unit->ui.locked) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED); return; @@ -3859,7 +3862,7 @@ static void action_set_comment (Unit * unit, dpacket packet) a_inode *a; int err; - if (unit->ui.readonly) { + if (unit->ui.readonly || unit->ui.locked) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED); return; @@ -3919,7 +3922,7 @@ static void if (!lock1 || !lock2) { PUT_PCK_RES1 (packet, lock1 == lock2 ? DOS_TRUE : DOS_FALSE); } else { - PUT_PCK_RES1 (packet, get_long (lock1 + 4) == get_long (lock2 + 4) ? DOS_TRUE : DOS_FALSE); + PUT_PCK_RES1 (packet, x_get_long (lock1 + 4) == x_get_long (lock2 + 4) ? DOS_TRUE : DOS_FALSE); } } @@ -3948,9 +3951,9 @@ static void } if (type == CHANGE_LOCK) { - uniq = get_long (object + 4); + uniq = x_get_long (object + 4); } else { - Key *k = lookup_key (unit, get_long (object + 36)); + Key *k = lookup_key (unit, x_get_long (object + 36)); if (!k) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_OBJECT_NOT_AROUND); @@ -4034,7 +4037,7 @@ static void PUT_PCK_RES1 (packet, 0); PUT_PCK_RES2 (packet, 0); } else { - action_parent_common (unit, packet, get_long (lock + 4)); + action_parent_common (unit, packet, x_get_long (lock + 4)); } TRACE((L"=%x %d\n", GET_PCK_RES1 (packet), GET_PCK_RES2 (packet))); } @@ -4049,7 +4052,7 @@ static void TRACE((L"ACTION_CREATE_DIR(0x%lx,\"%s\")\n", lock, bstr (unit, name))); - if (unit->ui.readonly) { + if (unit->ui.readonly || unit->ui.locked) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED); return; @@ -4107,9 +4110,9 @@ static void get_fileinfo (unit, packet, info, aino); if (aino->dir) - put_long (info, 0xFFFFFFFF); + x_put_long (info, 0xFFFFFFFF); else - put_long (info, 0); + x_put_long (info, 0); } /* For a nice example of just how contradictory documentation can be, see the @@ -4229,7 +4232,7 @@ static void TRACE((L"ACTION_DELETE_OBJECT(0x%lx,\"%s\")\n", lock, bstr (unit, name))); - if (unit->ui.readonly) { + if (unit->ui.readonly || unit->ui.locked) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED); return; @@ -4291,14 +4294,14 @@ static void TRACE((L"ACTION_SET_DATE(0x%lx,\"%s\")\n", lock, bstr (unit, name))); - if (unit->ui.readonly) { + if (unit->ui.readonly || unit->ui.locked) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED); return; } - ut.actime = ut.modtime = put_time (get_long (date), get_long (date + 4), - get_long (date + 8)); + ut.actime = ut.modtime = put_time (x_get_long (date), x_get_long (date + 4), + x_get_long (date + 8)); a = find_aino (unit, lock, bstr (unit, name), &err); if (err == 0 && utime (a->nname, &ut) == -1) err = dos_errno (); @@ -4327,7 +4330,7 @@ static void TRACE((L"ACTION_RENAME_OBJECT(0x%lx,\"%s\",", lock1, bstr (unit, name1))); TRACE((L"0x%lx,\"%s\")\n", lock2, bstr (unit, name2))); - if (unit->ui.readonly) { + if (unit->ui.readonly || unit->ui.locked) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED); return; @@ -4434,7 +4437,7 @@ static void TRACE((L"ACTION_RENAME_DISK(\"%s\")\n", bstr (unit, name))); - if (unit->ui.readonly) { + if (unit->ui.readonly || unit->ui.locked) { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED); return; @@ -4477,7 +4480,7 @@ static void { PUT_PCK_RES1 (packet, DOS_TRUE); flush_cache (unit, 0); - unit->inhibited = GET_PCK_ARG1 (packet); + unit->inhibited = GET_PCK_ARG1 (packet) != 0; TRACE((L"ACTION_INHIBIT(%d:%d)\n", unit->unit, unit->inhibited)); } @@ -4487,14 +4490,14 @@ static void TRACE((L"ACTION_WRITE_PROTECT()\n")); PUT_PCK_RES1 (packet, DOS_TRUE); if (GET_PCK_ARG1 (packet)) { - if (!(unit->ui.readonly & 2)) { - unit->ui.readonly |= 2; + if (!unit->ui.locked) { + unit->ui.locked = true; unit->lockkey = GET_PCK_ARG2 (packet); } } else { - if (unit->ui.readonly & 2) { + if (unit->ui.locked) { if (unit->lockkey == GET_PCK_ARG2 (packet) || unit->lockkey == 0) { - unit->ui.readonly &= ~2; + unit->ui.locked = false; } else { PUT_PCK_RES1 (packet, DOS_FALSE); PUT_PCK_RES2 (packet, 0); @@ -4699,17 +4702,17 @@ static uae_u32 REGPARAM2 exter_int_helper (TrapContext *context) int cnt = 0; locks = read_comm_pipe_int_blocking (unit->ui.back_pipe); lockend = locks; - while (get_long (lockend) != 0) { - if (get_long (lockend) == lockend) { + while (x_get_long (lockend) != 0) { + if (x_get_long (lockend) == lockend) { write_log (L"filesystem lock queue corrupted!\n"); break; } - lockend = get_long (lockend); + lockend = x_get_long (lockend); cnt++; } TRACE((L"message_lock: %d %x %x %x\n", cnt, locks, lockend, m68k_areg (regs, 3))); - put_long (lockend, get_long (m68k_areg (regs, 3))); - put_long (m68k_areg (regs, 3), locks); + x_put_long (lockend, x_get_long (m68k_areg (regs, 3))); + x_put_long (m68k_areg (regs, 3), locks); } } #else @@ -4891,12 +4894,12 @@ static void *filesys_thread (void *unit_v) uae_set_thread_priority (NULL, 1); for (;;) { - uae_u8 *pck; - uae_u8 *msg; + dpacket pck; + uaecptr msg; uae_u32 morelocks; - pck = (uae_u8 *)read_comm_pipe_pvoid_blocking (ui->unit_pipe); - msg = (uae_u8 *)read_comm_pipe_pvoid_blocking (ui->unit_pipe); + pck = read_comm_pipe_u32_blocking (ui->unit_pipe); + msg = read_comm_pipe_u32_blocking (ui->unit_pipe); morelocks = (uae_u32)read_comm_pipe_int_blocking (ui->unit_pipe); if (ui->reset_state == FS_GO_DOWN) { @@ -4908,14 +4911,14 @@ static void *filesys_thread (void *unit_v) return 0; } - put_long (get_long (morelocks), get_long (ui->self->locklist)); - put_long (ui->self->locklist, morelocks); + x_put_long (x_get_long (morelocks), x_get_long (ui->self->locklist)); + x_put_long (ui->self->locklist, morelocks); if (! handle_packet (ui->self, pck)) { PUT_PCK_RES1 (pck, DOS_FALSE); PUT_PCK_RES2 (pck, ERROR_ACTION_NOT_KNOWN); } /* Mark the packet as processed for the list scan in the assembly code. */ - do_put_mem_long ((uae_u32 *)(msg + 4), -1); + x_put_long (msg + 4, 0xffffffff); /* Acquire the message lock, so that we know we can safely send the * message. */ ui->self->cmds_sent++; @@ -4923,9 +4926,9 @@ static void *filesys_thread (void *unit_v) * happens. */ do_uae_int_requested(); /* Send back the locks. */ - if (get_long (ui->self->locklist) != 0) - write_comm_pipe_int (ui->back_pipe, (int)(get_long (ui->self->locklist)), 0); - put_long (ui->self->locklist, 0); + if (x_get_long (ui->self->locklist) != 0) + write_comm_pipe_int (ui->back_pipe, (int)(x_get_long (ui->self->locklist)), 0); + x_put_long (ui->self->locklist, 0); } return 0; @@ -4938,16 +4941,12 @@ static uae_u32 REGPARAM2 filesys_handler (TrapContext *context) Unit *unit = find_unit (m68k_areg (regs, 5)); uaecptr packet_addr = m68k_dreg (regs, 3); uaecptr message_addr = m68k_areg (regs, 4); - uae_u8 *pck; - uae_u8 *msg; if (! valid_address (packet_addr, 36) || ! valid_address (message_addr, 14)) { write_log (L"FILESYS: Bad address %x/%x passed for packet.\n", packet_addr, message_addr); goto error2; } - pck = get_real_address (packet_addr); - msg = get_real_address (message_addr); - do_put_mem_long ((uae_u32 *)(msg + 4), -1); + x_put_long (message_addr + 4, 0xffffffff); if (!unit || !unit->volume) { write_log (L"FILESYS: was not initialized.\n"); goto error; @@ -4958,26 +4957,26 @@ static uae_u32 REGPARAM2 filesys_handler (TrapContext *context) if (!unit->ui.unit_pipe) goto error; /* Get two more locks and hand them over to the other thread. */ - morelocks = get_long (m68k_areg (regs, 3)); - put_long (m68k_areg (regs, 3), get_long (get_long (morelocks))); - put_long (get_long (morelocks), 0); + morelocks = x_get_long (m68k_areg (regs, 3)); + x_put_long (m68k_areg (regs, 3), x_get_long (x_get_long (morelocks))); + x_put_long (x_get_long (morelocks), 0); /* The packet wasn't processed yet. */ - do_put_mem_long ((uae_u32 *)(msg + 4), 0); - write_comm_pipe_pvoid (unit->ui.unit_pipe, (void *)pck, 0); - write_comm_pipe_pvoid (unit->ui.unit_pipe, (void *)msg, 0); + x_put_long (message_addr + 4, 0); + write_comm_pipe_u32 (unit->ui.unit_pipe, packet_addr, 0); + write_comm_pipe_u32 (unit->ui.unit_pipe, message_addr, 0); write_comm_pipe_int (unit->ui.unit_pipe, (int)morelocks, 1); /* Don't reply yet. */ return 1; } #endif - if (! handle_packet (unit, pck)) { + if (! handle_packet (unit, packet_addr)) { error: - PUT_PCK_RES1 (pck, DOS_FALSE); - PUT_PCK_RES2 (pck, ERROR_ACTION_NOT_KNOWN); + PUT_PCK_RES1 (packet_addr, DOS_FALSE); + PUT_PCK_RES2 (packet_addr, ERROR_ACTION_NOT_KNOWN); } - TRACE((L"reply: %8lx, %ld\n", GET_PCK_RES1 (pck), GET_PCK_RES2 (pck))); + TRACE((L"reply: %8lx, %ld\n", GET_PCK_RES1 (packet_addr), GET_PCK_RES2 (packet_addr))); error2: @@ -5113,14 +5112,14 @@ static uae_u32 REGPARAM2 filesys_diagentry (TrapContext *context) if (ROM_hardfile_resid != 0) { /* Build a struct Resident. This will set up and initialize * the uae.device */ - put_word (resaddr + 0x0, 0x4AFC); - put_long (resaddr + 0x2, resaddr); - put_long (resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */ - put_word (resaddr + 0xA, 0x8101); /* RTF_AUTOINIT|RTF_COLDSTART; Version 1 */ - put_word (resaddr + 0xC, 0x0305); /* NT_DEVICE; pri 05 */ - put_long (resaddr + 0xE, ROM_hardfile_resname); - put_long (resaddr + 0x12, ROM_hardfile_resid); - put_long (resaddr + 0x16, ROM_hardfile_init); /* calls filesys_init */ + x_put_word (resaddr + 0x0, 0x4AFC); + x_put_long (resaddr + 0x2, resaddr); + x_put_long (resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */ + x_put_word (resaddr + 0xA, 0x8101); /* RTF_AUTOINIT|RTF_COLDSTART; Version 1 */ + x_put_word (resaddr + 0xC, 0x0305); /* NT_DEVICE; pri 05 */ + x_put_long (resaddr + 0xE, ROM_hardfile_resname); + x_put_long (resaddr + 0x12, ROM_hardfile_resid); + x_put_long (resaddr + 0x16, ROM_hardfile_init); /* calls filesys_init */ } resaddr += 0x1A; tmp = resaddr; @@ -5148,26 +5147,26 @@ static uae_u32 REGPARAM2 filesys_diagentry (TrapContext *context) /* scan for Residents and return pointer to array of them */ residents = resaddr; while (tmp < residents && tmp > start) { - if (get_word (tmp) == 0x4AFC && - get_long (tmp + 0x2) == tmp) { - put_word (resaddr, 0x227C); /* movea.l #tmp,a1 */ - put_long (resaddr + 2, tmp); - put_word (resaddr + 6, 0x7200); /* moveq.l #0,d1 */ - put_long (resaddr + 8, 0x4EAEFF9A); /* jsr -$66(a6) ; InitResident */ + if (x_get_word (tmp) == 0x4AFC && + x_get_long (tmp + 0x2) == tmp) { + x_put_word (resaddr, 0x227C); /* movea.l #tmp,a1 */ + x_put_long (resaddr + 2, tmp); + x_put_word (resaddr + 6, 0x7200); /* moveq.l #0,d1 */ + x_put_long (resaddr + 8, 0x4EAEFF9A); /* jsr -$66(a6) ; InitResident */ resaddr += 12; - tmp = get_long (tmp + 0x6); + tmp = x_get_long (tmp + 0x6); } else { tmp++; } } /* call setup_exter */ - put_word (resaddr + 0, 0x2079); - put_long (resaddr + 2, rtarea_base + bootrom_header + 4 + 5 * 4); /* move.l RTAREA_BASE+setup_exter,a0 */ - put_word (resaddr + 6, 0xd1fc); - put_long (resaddr + 8, rtarea_base + bootrom_header); /* add.l #RTAREA_BASE+bootrom_header,a0 */ - put_word (resaddr + 12, 0x4e90); /* jsr (a0) */ - put_word (resaddr + 14, 0x7001); /* moveq.l #1,d0 */ - put_word (resaddr + 16, RTS); + x_put_word (resaddr + 0, 0x2079); + x_put_long (resaddr + 2, rtarea_base + bootrom_header + 4 + 5 * 4); /* move.l RTAREA_BASE+setup_exter,a0 */ + x_put_word (resaddr + 6, 0xd1fc); + x_put_long (resaddr + 8, rtarea_base + bootrom_header); /* add.l #RTAREA_BASE+bootrom_header,a0 */ + x_put_word (resaddr + 12, 0x4e90); /* jsr (a0) */ + x_put_word (resaddr + 14, 0x7001); /* moveq.l #1,d0 */ + x_put_word (resaddr + 16, RTS); m68k_areg (regs, 0) = residents; return 1; @@ -5185,7 +5184,7 @@ static uae_u32 REGPARAM2 filesys_dev_bootfilesys (TrapContext *context) { uaecptr devicenode = m68k_areg (regs, 3); uaecptr parmpacket = m68k_areg (regs, 1); - uaecptr fsres = get_long (parmpacket + PP_FSRES); + uaecptr fsres = x_get_long (parmpacket + PP_FSRES); uaecptr fsnode; uae_u32 dostype, dostype2; UnitInfo *uip = mountinfo.ui; @@ -5195,20 +5194,20 @@ static uae_u32 REGPARAM2 filesys_dev_bootfilesys (TrapContext *context) if (type == FILESYS_VIRTUAL) return 0; - dostype = get_long (parmpacket + 80); - fsnode = get_long (fsres + 18); - while (get_long (fsnode)) { - dostype2 = get_long (fsnode + 14); + dostype = x_get_long (parmpacket + 80); + fsnode = x_get_long (fsres + 18); + while (x_get_long (fsnode)) { + dostype2 = x_get_long (fsnode + 14); if (dostype2 == dostype) { int i; - uae_u32 pf = get_long (fsnode + 22); // fse_PatchFlags + uae_u32 pf = x_get_long (fsnode + 22); // fse_PatchFlags for (i = 0; i < 32; i++) { if (pf & (1 << i)) - put_long (devicenode + 4 + i * 4, get_long (fsnode + 22 + 4 + i * 4)); + x_put_long (devicenode + 4 + i * 4, x_get_long (fsnode + 22 + 4 + i * 4)); } return 1; } - fsnode = get_long (fsnode); + fsnode = x_get_long (fsnode); } return 0; } @@ -5246,15 +5245,15 @@ static uae_u32 REGPARAM2 filesys_dev_remember (TrapContext *context) uaecptr parmpacket = m68k_areg (regs, 1); /* copy filesystem loaded from RDB */ - if (get_long (parmpacket + PP_FSPTR)) { + if (x_get_long (parmpacket + PP_FSPTR)) { for (i = 0; i < uip->rdb_filesyssize; i++) - put_byte (get_long (parmpacket + PP_FSPTR) + i, uip->rdb_filesysstore[i]); + x_put_byte (x_get_long (parmpacket + PP_FSPTR) + i, uip->rdb_filesysstore[i]); xfree (uip->rdb_filesysstore); uip->rdb_filesysstore = 0; uip->rdb_filesyssize = 0; } if (m68k_dreg (regs, 3) >= 0) - uip->startup = get_long (devicenode + 28); + uip->startup = x_get_long (devicenode + 28); return devicenode; } @@ -5300,17 +5299,17 @@ static int device_isdup (uaecptr expbase, TCHAR *devname) int len, i; TCHAR dname[256]; - bnode = get_long (expbase + 74); /* expansion.library bootnode list */ - while (get_long (bnode)) { - dnode = get_long (bnode + 16); /* device node */ - name = get_long (dnode + 40) << 2; /* device name BSTR */ - len = get_byte (name); + bnode = x_get_long (expbase + 74); /* expansion.library bootnode list */ + while (x_get_long (bnode)) { + dnode = x_get_long (bnode + 16); /* device node */ + name = x_get_long (dnode + 40) << 2; /* device name BSTR */ + len = x_get_byte (name); for (i = 0; i < len; i++) - dname[i] = get_byte (name + 1 + i); + dname[i] = x_get_byte (name + 1 + i); dname[len] = 0; if (!_tcsicmp (devname, dname)) return 1; - bnode = get_long (bnode); + bnode = x_get_long (bnode); } return 0; } @@ -5339,19 +5338,19 @@ static TCHAR *device_dupfix (uaecptr expbase, TCHAR *devname) static void dump_partinfo (uae_u8 *name, int num, uaecptr pp, int partblock) { TCHAR *s = au ((char*)name); - uae_u32 dostype = get_long (pp + 80); + uae_u32 dostype = x_get_long (pp + 80); uae_u64 size; - size = ((uae_u64)get_long (pp + 20)) * 4 * get_long (pp + 28) * get_long (pp + 36) * (get_long (pp + 56) - get_long (pp + 52) + 1); + size = ((uae_u64)x_get_long (pp + 20)) * 4 * x_get_long (pp + 28) * x_get_long (pp + 36) * (x_get_long (pp + 56) - x_get_long (pp + 52) + 1); write_log (L"RDB: '%s' dostype=%08X. PartBlock=%d\n", s, dostype, partblock); write_log (L"BlockSize: %d, Surfaces: %d, SectorsPerBlock %d\n", - get_long (pp + 20) * 4, get_long (pp + 28), get_long (pp + 32)); + x_get_long (pp + 20) * 4, x_get_long (pp + 28), x_get_long (pp + 32)); write_log (L"SectorsPerTrack: %d, Reserved: %d, LowCyl %d, HighCyl %d, Size %dM\n", - get_long (pp + 36), get_long (pp + 40), get_long (pp + 52), get_long (pp + 56), (uae_u32)(size >> 20)); + x_get_long (pp + 36), x_get_long (pp + 40), x_get_long (pp + 52), x_get_long (pp + 56), (uae_u32)(size >> 20)); write_log (L"Buffers: %d, BufMemType: %08x, MaxTransfer: %08x, BootPri: %d\n", - get_long (pp + 60), get_long (pp + 64), get_long (pp + 68), get_long (pp + 76)); + x_get_long (pp + 60), x_get_long (pp + 64), x_get_long (pp + 68), x_get_long (pp + 76)); xfree (s); } @@ -5465,16 +5464,16 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke buf[37 + buf[36]] = 0; /* zero terminate BSTR */ s = au ((char*)buf + 37); - uip->rdb_devname_amiga[partnum] = ds (device_dupfix (get_long (parmpacket + PP_EXPLIB), s)); + uip->rdb_devname_amiga[partnum] = ds (device_dupfix (x_get_long (parmpacket + PP_EXPLIB), s)); xfree (s); - put_long (parmpacket, uip->rdb_devname_amiga[partnum]); /* name */ - put_long (parmpacket + 4, ROM_hardfile_resname); - put_long (parmpacket + 8, uip->devno); - put_long (parmpacket + 12, 0); /* Device flags */ + x_put_long (parmpacket, uip->rdb_devname_amiga[partnum]); /* name */ + x_put_long (parmpacket + 4, ROM_hardfile_resname); + x_put_long (parmpacket + 8, uip->devno); + x_put_long (parmpacket + 12, 0); /* Device flags */ for (i = 0; i < PP_MAXSIZE; i++) - put_byte (parmpacket + 16 + i, buf[128 + i]); + x_put_byte (parmpacket + 16 + i, buf[128 + i]); dump_partinfo (buf + 37, uip->devno, parmpacket, partblock); - dostype = get_long (parmpacket + 80); + dostype = x_get_long (parmpacket + 80); if (dostype == 0) { write_log (L"RDB: mount failed, dostype=0\n"); @@ -5491,21 +5490,21 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke if (fileblock == -1 || !legalrdbblock (uip, fileblock)) goto error; - fsres = get_long (parmpacket + PP_FSRES); + fsres = x_get_long (parmpacket + PP_FSRES); if (!fsres) { write_log (L"RDB: FileSystem.resource not found, this shouldn't happen!\n"); goto error; } - fsnode = get_long (fsres + 18); - while (get_long (fsnode)) { - if (get_long (fsnode + 14) == dostype) + fsnode = x_get_long (fsres + 18); + while (x_get_long (fsnode)) { + if (x_get_long (fsnode + 14) == dostype) break; - fsnode = get_long (fsnode); + fsnode = x_get_long (fsnode); } oldversion = oldrevision = -1; - if (get_long (fsnode)) { - oldversion = get_word (fsnode + 18); - oldrevision = get_word (fsnode + 20); + if (x_get_long (fsnode)) { + oldversion = x_get_word (fsnode + 18); + oldrevision = x_get_word (fsnode + 20); } else { fsnode = 0; } @@ -5543,8 +5542,8 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke } for (i = 0; i < 140; i++) - put_byte (parmpacket + PP_FSHDSTART + i, buf[32 + i]); - put_long (parmpacket + PP_FSHDSTART, dostype); + x_put_byte (parmpacket + PP_FSHDSTART + i, buf[32 + i]); + x_put_long (parmpacket + PP_FSHDSTART, dostype); /* we found required FSHD block */ fsmem = xmalloc (uae_u8, 262144); lsegblock = rl (buf + 72); @@ -5568,7 +5567,7 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke break; } write_log (L"RDB: Filesystem loaded, %d bytes\n", i * (blocksize - 20)); - put_long (parmpacket + PP_FSSIZE, i * (blocksize - 20)); /* RDB filesystem size hack */ + x_put_long (parmpacket + PP_FSSIZE, i * (blocksize - 20)); /* RDB filesystem size hack */ uip->rdb_filesysstore = fsmem; uip->rdb_filesyssize = i * (blocksize - 20); xfree (buf); @@ -5584,11 +5583,11 @@ static void addfakefilesys (uaecptr parmpacket, uae_u32 dostype) int i; for (i = 0; i < 140; i++) - put_byte (parmpacket + PP_FSHDSTART + i, 0); - put_long (parmpacket + 80, dostype); - put_long (parmpacket + PP_FSHDSTART, dostype); - put_long (parmpacket + PP_FSHDSTART + 8, 0x100 | (dostype == 0x444f5300 ? 0x0 : 0x80)); - put_long (parmpacket + PP_FSHDSTART + 44, 0xffffffff); + x_put_byte (parmpacket + PP_FSHDSTART + i, 0); + x_put_long (parmpacket + 80, dostype); + x_put_long (parmpacket + PP_FSHDSTART, dostype); + x_put_long (parmpacket + PP_FSHDSTART + 8, 0x100 | (dostype == 0x444f5300 ? 0x0 : 0x80)); + x_put_long (parmpacket + PP_FSHDSTART + 44, 0xffffffff); } static int dofakefilesys (UnitInfo *uip, uaecptr parmpacket) @@ -5604,10 +5603,10 @@ static int dofakefilesys (UnitInfo *uip, uaecptr parmpacket) dostype = (buf[0] << 24) | (buf[1] << 16) |(buf[2] << 8) | buf[3]; if (dostype == 0) return FILESYS_HARDFILE; - fsres = get_long (parmpacket + PP_FSRES); - fsnode = get_long (fsres + 18); - while (get_long (fsnode)) { - if (get_long (fsnode + 14) == dostype) { + fsres = x_get_long (parmpacket + PP_FSRES); + fsnode = x_get_long (fsres + 18); + while (x_get_long (fsnode)) { + if (x_get_long (fsnode + 14) == dostype) { if (kickstart_version < 36) { addfakefilesys (parmpacket, dostype); } else if ((dostype & 0xffffff00) != 0x444f5300) { @@ -5615,7 +5614,7 @@ static int dofakefilesys (UnitInfo *uip, uaecptr parmpacket) } return FILESYS_HARDFILE; } - fsnode = get_long (fsnode); + fsnode = x_get_long (fsnode); } tmp[0] = 0; @@ -5654,7 +5653,7 @@ static int dofakefilesys (UnitInfo *uip, uaecptr parmpacket) } zfile_fclose (zf); uip->rdb_filesyssize = size; - put_long (parmpacket + PP_FSSIZE, uip->rdb_filesyssize); + x_put_long (parmpacket + PP_FSSIZE, uip->rdb_filesyssize); addfakefilesys (parmpacket, dostype); write_log (L"HDF: faked RDB filesystem %08X loaded\n", dostype); return FILESYS_HARDFILE; @@ -5663,7 +5662,7 @@ static int dofakefilesys (UnitInfo *uip, uaecptr parmpacket) static void get_new_device (int type, uaecptr parmpacket, TCHAR **devname, uaecptr *devname_amiga, int unit_no) { TCHAR buffer[80]; - uaecptr expbase = get_long (parmpacket + PP_EXPLIB); + uaecptr expbase = x_get_long (parmpacket + PP_EXPLIB); if (*devname == 0 || _tcslen (*devname) == 0) { int un = unit_no; @@ -5705,27 +5704,38 @@ static uae_u32 REGPARAM2 filesys_dev_storeinfo (TrapContext *context) write_log (L"Mounting uaehf.device %d (%d):\n", unit_no, sub_no); get_new_device (type, parmpacket, &uip[unit_no].devname, &uip[unit_no].devname_amiga, unit_no); uip[unit_no].devno = unit_no; - put_long (parmpacket, uip[unit_no].devname_amiga); - put_long (parmpacket + 4, type != FILESYS_VIRTUAL ? ROM_hardfile_resname : fsdevname); - put_long (parmpacket + 8, uip[unit_no].devno); - put_long (parmpacket + 12, 0); /* Device flags */ - put_long (parmpacket + 16, 16); /* Env. size */ - put_long (parmpacket + 20, uip[unit_no].hf.blocksize >> 2); /* longwords per block */ - put_long (parmpacket + 24, 0); /* unused */ - put_long (parmpacket + 28, uip[unit_no].hf.surfaces); /* heads */ - put_long (parmpacket + 32, 1); /* sectors per block */ - put_long (parmpacket + 36, uip[unit_no].hf.secspertrack); /* sectors per track */ - put_long (parmpacket + 40, uip[unit_no].hf.reservedblocks); /* reserved blocks */ - put_long (parmpacket + 44, 0); /* unused */ - put_long (parmpacket + 48, 0); /* interleave */ - put_long (parmpacket + 52, 0); /* lowCyl */ - put_long (parmpacket + 56, uip[unit_no].hf.nrcyls <= 0 ? 0 : uip[unit_no].hf.nrcyls - 1); /* hiCyl */ - put_long (parmpacket + 60, 50); /* Number of buffers */ - put_long (parmpacket + 64, 0); /* Buffer mem type */ - put_long (parmpacket + 68, 0x7FFFFFFF); /* largest transfer */ - put_long (parmpacket + 72, ~1); /* addMask (?) */ - put_long (parmpacket + 76, uip[unit_no].bootpri); /* bootPri */ - put_long (parmpacket + 80, 0x444f5300); /* DOS\0 */ + x_put_long (parmpacket, uip[unit_no].devname_amiga); + x_put_long (parmpacket + 8, uip[unit_no].devno); + x_put_long (parmpacket + 12, 0); /* Device flags */ + x_put_long (parmpacket + 16, 16); /* Env. size */ + x_put_long (parmpacket + 24, 0); /* unused */ + x_put_long (parmpacket + 44, 0); /* unused */ + x_put_long (parmpacket + 48, 0); /* interleave */ + x_put_long (parmpacket + 60, 50); /* Number of buffers */ + x_put_long (parmpacket + 64, 0); /* Buffer mem type */ + x_put_long (parmpacket + 68, 0x7FFFFFFF); /* largest transfer */ + x_put_long (parmpacket + 72, ~1); /* addMask (?) */ + x_put_long (parmpacket + 76, uip[unit_no].bootpri); /* bootPri */ + x_put_long (parmpacket + 80, 0x444f5300); /* DOS\0 */ + if (type == FILESYS_VIRTUAL) { + x_put_long (parmpacket + 4, fsdevname); + x_put_long (parmpacket + 20, 1024 >> 2); /* longwords per block */ + x_put_long (parmpacket + 28, 15); /* heads */ + x_put_long (parmpacket + 32, 1); /* sectors per block */ + x_put_long (parmpacket + 36, 127); /* sectors per track */ + x_put_long (parmpacket + 40, 2); /* reserved blocks */ + x_put_long (parmpacket + 52, 0); /* lowCyl */ + x_put_long (parmpacket + 56, 1); /* hiCyl */ + } else { + x_put_long (parmpacket + 4, ROM_hardfile_resname); + x_put_long (parmpacket + 20, uip[unit_no].hf.blocksize >> 2); /* longwords per block */ + x_put_long (parmpacket + 28, uip[unit_no].hf.surfaces); /* heads */ + x_put_long (parmpacket + 32, 1); /* sectors per block */ + x_put_long (parmpacket + 36, uip[unit_no].hf.secspertrack); /* sectors per track */ + x_put_long (parmpacket + 40, uip[unit_no].hf.reservedblocks); /* reserved blocks */ + x_put_long (parmpacket + 52, 0); /* lowCyl */ + x_put_long (parmpacket + 56, uip[unit_no].hf.nrcyls <= 0 ? 0 : uip[unit_no].hf.nrcyls - 1); /* hiCyl */ + } if (type == FILESYS_HARDFILE) type = dofakefilesys (&uip[unit_no], parmpacket); if (uip[unit_no].bootpri < -127) @@ -5764,7 +5774,7 @@ static uae_u32 REGPARAM2 mousehack_done (TrapContext *context) consolehook_ret (m68k_areg (regs, 1), m68k_areg (regs, 2)); } else if (mode == 102) { uaecptr ret = consolehook_beginio (m68k_areg (regs, 1)); - put_long (m68k_areg (regs, 7) + 4 * 4, ret); + x_put_long (m68k_areg (regs, 7) + 4 * 4, ret); } else { write_log (L"Unknown mousehack hook %d\n", mode); } @@ -6446,7 +6456,8 @@ uae_u8 *restore_filesys (uae_u8 *src) int type, devno; UnitInfo *ui; TCHAR *devname = 0, *volname = 0, *rootdir = 0, *filesysdir = 0; - int bootpri, readonly; + int bootpri; + bool readonly; if (restore_u32 () != 2) return src; @@ -6457,7 +6468,7 @@ uae_u8 *restore_filesys (uae_u8 *src) volname = restore_string (); filesysdir = restore_string (); bootpri = restore_u8 (); - readonly = restore_u8 (); + readonly = restore_u8 () != 0; ui = &mountinfo.ui[devno]; ui->startup = restore_u32 (); filesys_configdev = restore_u32 (); @@ -6468,7 +6479,7 @@ uae_u8 *restore_filesys (uae_u8 *src) } if (set_filesys_unit (devno, devname, volname, rootdir, readonly, ui->hf.secspertrack, ui->hf.surfaces, ui->hf.reservedblocks, ui->hf.blocksize, - bootpri, 0, 1, filesysdir[0] ? filesysdir : NULL, 0, 0) < 0) { + bootpri, false, true, filesysdir[0] ? filesysdir : NULL, 0, 0) < 0) { write_log (L"filesys '%s' failed to restore\n", rootdir); goto end; } diff --git a/fpp.cpp b/fpp.cpp index 94c4f497..82980c99 100644 --- a/fpp.cpp +++ b/fpp.cpp @@ -141,79 +141,6 @@ typedef uae_s64 tointtype; typedef uae_s32 tointtype; #endif -STATIC_INLINE uae_u32 next_ilong_fpu (void) -{ - if (currprefs.mmu_model) - return next_ilong_mmu (); - else if (currprefs.cpu_cycle_exact) - return next_ilong_020ce (); - else - return next_ilong (); -} -STATIC_INLINE uae_u32 next_iword_fpu (void) -{ - if (currprefs.mmu_model) - return next_iword_mmu (); - else if (currprefs.cpu_cycle_exact) - return next_iword_020ce (); - else - return next_iword (); -} -STATIC_INLINE void put_long_fpu (uaecptr addr, uae_u32 v) -{ - if (currprefs.mmu_model) - put_long_mmu (addr, v); - else if (currprefs.cpu_cycle_exact) - put_long_ce020 (addr, v); - else - put_long (addr, v); -} -STATIC_INLINE uae_u32 get_long_fpu (uaecptr addr) -{ - if (currprefs.mmu_model) - return get_long_mmu (addr); - else if (currprefs.cpu_cycle_exact) - return get_long_ce020 (addr); - else - return get_long (addr); -} -STATIC_INLINE void put_word_fpu (uaecptr addr, uae_u32 v) -{ - if (currprefs.mmu_model) - put_word_mmu (addr, v); - else if (currprefs.cpu_cycle_exact) - put_word_ce020 (addr, v); - else - put_word (addr, v); -} -STATIC_INLINE uae_u32 get_word_fpu (uaecptr addr) -{ - if (currprefs.mmu_model) - return get_word_mmu (addr); - else if (currprefs.cpu_cycle_exact) - return get_word_ce020 (addr); - else - return get_word (addr); -} -STATIC_INLINE void put_byte_fpu (uaecptr addr, uae_u32 v) -{ - if (currprefs.mmu_model) - put_byte_mmu (addr, v); - else if (currprefs.cpu_cycle_exact) - put_byte_ce020 (addr, v); - else - put_byte (addr, v); -} -STATIC_INLINE uae_u32 get_byte_fpu (uaecptr addr) -{ - if (currprefs.mmu_model) - return get_byte_mmu (addr); - else if (currprefs.cpu_cycle_exact) - return get_byte_ce020 (addr); - else - return get_byte (addr); -} - static void fpu_op_illg (uae_u32 opcode, int pcoffset) { if ((currprefs.cpu_model == 68060 && (currprefs.fpu_model == 0 || (regs.pcr & 2))) @@ -230,17 +157,17 @@ static void fpu_op_illg (uae_u32 opcode, int pcoffset) } regs.s = 1; m68k_areg (regs, 7) -= 4; - put_long_fpu (m68k_areg (regs, 7), oldpc); + x_put_long (m68k_areg (regs, 7), oldpc); m68k_areg (regs, 7) -= 4; - put_long_fpu (m68k_areg (regs, 7), oldpc); + x_put_long (m68k_areg (regs, 7), oldpc); m68k_areg (regs, 7) -= 2; - put_word_fpu (m68k_areg (regs, 7), 0x4000 + 11 * 4); + x_put_word (m68k_areg (regs, 7), 0x4000 + 11 * 4); m68k_areg (regs, 7) -= 4; - put_long_fpu (m68k_areg (regs, 7), newpc); + x_put_long (m68k_areg (regs, 7), newpc); m68k_areg (regs, 7) -= 2; - put_word_fpu (m68k_areg (regs, 7), regs.sr); + x_put_word (m68k_areg (regs, 7), regs.sr); write_log (L"68040/060 FPU disabled exception PC=%x\n", newpc); - newpc = get_long_fpu (regs.vbr + 11 * 4); + newpc = x_get_long (regs.vbr + 11 * 4); m68k_setpc (newpc); #ifdef JIT set_special (SPCFLAG_END_COMPILE); @@ -507,27 +434,27 @@ STATIC_INLINE int get_fp_value (uae_u32 opcode, uae_u16 extra, fptype *src) ad = m68k_areg (regs, reg); break; case 5: - ad = m68k_areg (regs, reg) + (uae_s32) (uae_s16) next_iword_fpu (); + ad = m68k_areg (regs, reg) + (uae_s32) (uae_s16) x_next_iword (); break; case 6: - ad = get_disp_ea_020 (m68k_areg (regs, reg), next_iword_fpu ()); + ad = x_get_disp_ea_020 (m68k_areg (regs, reg), x_next_iword ()); break; case 7: switch (reg) { case 0: - ad = (uae_s32) (uae_s16) next_iword_fpu (); + ad = (uae_s32) (uae_s16) x_next_iword (); break; case 1: - ad = next_ilong_fpu (); + ad = x_next_ilong (); break; case 2: ad = m68k_getpc (); - ad += (uae_s32) (uae_s16) next_iword_fpu (); + ad += (uae_s32) (uae_s16) x_next_iword (); break; case 3: tmppc = m68k_getpc (); - tmp = next_iword_fpu (); - ad = get_disp_ea_020 (tmppc, tmp); + tmp = x_next_iword (); + ad = x_get_disp_ea_020 (tmppc, tmp); break; case 4: ad = m68k_getpc (); @@ -541,44 +468,44 @@ STATIC_INLINE int get_fp_value (uae_u32 opcode, uae_u16 extra, fptype *src) } switch (size) { case 0: - *src = (fptype) (uae_s32) get_long_fpu (ad); + *src = (fptype) (uae_s32) x_get_long (ad); break; case 1: - *src = to_single (get_long_fpu (ad)); + *src = to_single (x_get_long (ad)); break; case 2:{ uae_u32 wrd1, wrd2, wrd3; - wrd1 = get_long_fpu (ad); + wrd1 = x_get_long (ad); ad += 4; - wrd2 = get_long_fpu (ad); + wrd2 = x_get_long (ad); ad += 4; - wrd3 = get_long_fpu (ad); + wrd3 = x_get_long (ad); *src = to_exten (wrd1, wrd2, wrd3); } break; case 3:{ uae_u32 wrd1, wrd2, wrd3; - wrd1 = get_long_fpu (ad); + wrd1 = x_get_long (ad); ad += 4; - wrd2 = get_long_fpu (ad); + wrd2 = x_get_long (ad); ad += 4; - wrd3 = get_long_fpu (ad); + wrd3 = x_get_long (ad); *src = to_pack (wrd1, wrd2, wrd3); } break; case 4: - *src = (fptype) (uae_s16) get_word_fpu (ad); + *src = (fptype) (uae_s16) x_get_word (ad); break; case 5:{ uae_u32 wrd1, wrd2; - wrd1 = get_long_fpu (ad); + wrd1 = x_get_long (ad); ad += 4; - wrd2 = get_long_fpu (ad); + wrd2 = x_get_long (ad); *src = to_double (wrd1, wrd2); } break; case 6: - *src = (fptype) (uae_s8) get_byte_fpu (ad); + *src = (fptype) (uae_s8) x_get_byte (ad); break; default: return 0; @@ -642,27 +569,27 @@ STATIC_INLINE int put_fp_value (fptype value, uae_u32 opcode, uae_u16 extra) ad = m68k_areg (regs, reg); break; case 5: - ad = m68k_areg (regs, reg) + (uae_s32) (uae_s16) next_iword_fpu (); + ad = m68k_areg (regs, reg) + (uae_s32) (uae_s16) x_next_iword (); break; case 6: - ad = get_disp_ea_020 (m68k_areg (regs, reg), next_iword_fpu ()); + ad = x_get_disp_ea_020 (m68k_areg (regs, reg), x_next_iword ()); break; case 7: switch (reg) { case 0: - ad = (uae_s32) (uae_s16) next_iword_fpu (); + ad = (uae_s32) (uae_s16) x_next_iword (); break; case 1: - ad = next_ilong_fpu (); + ad = x_next_ilong (); break; case 2: ad = m68k_getpc (); - ad += (uae_s32) (uae_s16) next_iword_fpu (); + ad += (uae_s32) (uae_s16) x_next_iword (); break; case 3: tmppc = m68k_getpc (); - tmp = next_iword_fpu (); - ad = get_disp_ea_020 (tmppc, tmp); + tmp = x_next_iword (); + ad = x_get_disp_ea_020 (tmppc, tmp); break; case 4: ad = m68k_getpc (); @@ -674,46 +601,46 @@ STATIC_INLINE int put_fp_value (fptype value, uae_u32 opcode, uae_u16 extra) } switch (size) { case 0: - put_long_fpu (ad, (uae_u32)toint (value, -2147483648.0, 2147483647.0)); + x_put_long (ad, (uae_u32)toint (value, -2147483648.0, 2147483647.0)); break; case 1: - put_long_fpu (ad, from_single (value)); + x_put_long (ad, from_single (value)); break; case 2: { uae_u32 wrd1, wrd2, wrd3; from_exten (value, &wrd1, &wrd2, &wrd3); - put_long_fpu (ad, wrd1); + x_put_long (ad, wrd1); ad += 4; - put_long_fpu (ad, wrd2); + x_put_long (ad, wrd2); ad += 4; - put_long_fpu (ad, wrd3); + x_put_long (ad, wrd3); } break; case 3: { uae_u32 wrd1, wrd2, wrd3; from_pack (value, &wrd1, &wrd2, &wrd3); - put_long_fpu (ad, wrd1); + x_put_long (ad, wrd1); ad += 4; - put_long_fpu (ad, wrd2); + x_put_long (ad, wrd2); ad += 4; - put_long_fpu (ad, wrd3); + x_put_long (ad, wrd3); } break; case 4: - put_word_fpu (ad, (uae_s16) toint (value, -32768.0, 32767.0)); + x_put_word (ad, (uae_s16) toint (value, -32768.0, 32767.0)); break; case 5:{ uae_u32 wrd1, wrd2; from_double (value, &wrd1, &wrd2); - put_long_fpu (ad, wrd1); + x_put_long (ad, wrd1); ad += 4; - put_long_fpu (ad, wrd2); + x_put_long (ad, wrd2); } break; case 6: - put_byte_fpu (ad, (uae_s8)toint (value, -128.0, 127.0)); + x_put_byte (ad, (uae_s8)toint (value, -128.0, 127.0)); break; default: return 0; @@ -744,27 +671,27 @@ STATIC_INLINE int get_fp_ad (uae_u32 opcode, uae_u32 * ad) *ad = m68k_areg (regs, reg); break; case 5: - *ad = m68k_areg (regs, reg) + (uae_s32) (uae_s16) next_iword_fpu (); + *ad = m68k_areg (regs, reg) + (uae_s32) (uae_s16) x_next_iword (); break; case 6: - *ad = get_disp_ea_020 (m68k_areg (regs, reg), next_iword_fpu ()); + *ad = x_get_disp_ea_020 (m68k_areg (regs, reg), x_next_iword ()); break; case 7: switch (reg) { case 0: - *ad = (uae_s32) (uae_s16) next_iword_fpu (); + *ad = (uae_s32) (uae_s16) x_next_iword (); break; case 1: - *ad = next_ilong_fpu (); + *ad = x_next_ilong (); break; case 2: *ad = m68k_getpc (); - *ad += (uae_s32) (uae_s16) next_iword_fpu (); + *ad += (uae_s32) (uae_s16) x_next_iword (); break; case 3: tmppc = m68k_getpc (); - tmp = next_iword_fpu (); - *ad = get_disp_ea_020 (tmppc, tmp); + tmp = x_next_iword (); + *ad = x_get_disp_ea_020 (tmppc, tmp); break; default: return 0; @@ -868,7 +795,7 @@ void fpuop_dbcc (uae_u32 opcode, uae_u16 extra) if (fault_if_no_fpu (opcode, 4)) return; - disp = (uae_s32) (uae_s16) next_iword_fpu (); + disp = (uae_s32) (uae_s16) x_next_iword (); cc = fpp_cond (extra & 0x3f); if (cc == -1) { fpu_op_illg (opcode, 4); @@ -904,7 +831,7 @@ void fpuop_scc (uae_u32 opcode, uae_u16 extra) m68k_setpc (m68k_getpc () - 4); op_illg (opcode); } else - put_byte_fpu (ad, cc ? 0xff : 0x00); + x_put_byte (ad, cc ? 0xff : 0x00); } } @@ -971,47 +898,47 @@ void fpuop_save (uae_u32 opcode) /* 12 byte 68060 IDLE frame. */ if (incr < 0) { ad -= 4; - put_long_fpu (ad, 0x00000000); + x_put_long (ad, 0x00000000); ad -= 4; - put_long_fpu (ad, 0x00000000); + x_put_long (ad, 0x00000000); ad -= 4; - put_long_fpu (ad, 0x00006000); + x_put_long (ad, 0x00006000); } else { - put_long_fpu (ad, 0x00006000); + x_put_long (ad, 0x00006000); ad += 4; - put_long_fpu (ad, 0x00000000); + x_put_long (ad, 0x00000000); ad += 4; - put_long_fpu (ad, 0x00000000); + x_put_long (ad, 0x00000000); ad += 4; } } else if (currprefs.fpu_model == 68040) { /* 4 byte 68040 IDLE frame. */ if (incr < 0) { ad -= 4; - put_long_fpu (ad, fpu_version << 24); + x_put_long (ad, fpu_version << 24); } else { - put_long_fpu (ad, fpu_version << 24); + x_put_long (ad, fpu_version << 24); ad += 4; } } else { /* 68881/68882 */ int idle_size = currprefs.fpu_model == 68882 ? 0x38 : 0x18; if (incr < 0) { ad -= 4; - put_long_fpu (ad, 0x70000000); + x_put_long (ad, 0x70000000); for (i = 0; i < (idle_size - 1) / 4; i++) { ad -= 4; - put_long_fpu (ad, 0x00000000); + x_put_long (ad, 0x00000000); } ad -= 4; - put_long_fpu (ad, (fpu_version << 24) | (idle_size << 16)); + x_put_long (ad, (fpu_version << 24) | (idle_size << 16)); } else { - put_long_fpu (ad, (fpu_version << 24) | (idle_size << 16)); + x_put_long (ad, (fpu_version << 24) | (idle_size << 16)); ad += 4; for (i = 0; i < (idle_size - 1) / 4; i++) { - put_long_fpu (ad, 0x00000000); + x_put_long (ad, 0x00000000); ad += 4; } - put_long_fpu (ad, 0x70000000); + x_put_long (ad, 0x70000000); ad += 4; } } @@ -1043,10 +970,10 @@ void fpuop_restore (uae_u32 opcode) /* all 68060 FPU frames are 12 bytes */ if (incr < 0) { ad -= 4; - d = get_long_fpu (ad); + d = x_get_long (ad); ad -= 8; } else { - d = get_long_fpu (ad); + d = x_get_long (ad); ad += 4; ad += 8; } @@ -1056,7 +983,7 @@ void fpuop_restore (uae_u32 opcode) if (incr < 0) { /* @@@ This may be wrong. */ ad -= 4; - d = get_long_fpu (ad); + d = x_get_long (ad); if ((d & 0xff000000) != 0) { /* Not a NULL frame? */ if ((d & 0x00ff0000) == 0) { /* IDLE */ } else if ((d & 0x00ff0000) == 0x00300000) { /* UNIMP */ @@ -1066,7 +993,7 @@ void fpuop_restore (uae_u32 opcode) } } } else { - d = get_long_fpu (ad); + d = x_get_long (ad); ad += 4; if ((d & 0xff000000) != 0) { /* Not a NULL frame? */ if ((d & 0x00ff0000) == 0) { /* IDLE */ @@ -1080,7 +1007,7 @@ void fpuop_restore (uae_u32 opcode) } else { /* 68881/68882 */ if (incr < 0) { ad -= 4; - d = get_long_fpu (ad); + d = x_get_long (ad); if ((d & 0xff000000) != 0) { if ((d & 0x00ff0000) == 0x00180000) ad -= 6 * 4; @@ -1090,7 +1017,7 @@ void fpuop_restore (uae_u32 opcode) ad -= 45 * 4; } } else { - d = get_long_fpu (ad); + d = x_get_long (ad); ad += 4; if ((d & 0xff000000) != 0) { if ((d & 0x00ff0000) == 0x00180000) @@ -1175,13 +1102,13 @@ void fpuop_arithmetic (uae_u32 opcode, uae_u16 extra) } else if ((opcode & 0x3f) == 0x3c) { if ((extra & 0x2000) == 0) { if (extra & 0x1000) { - regs.fpcr = next_ilong_fpu (); + regs.fpcr = x_next_ilong (); native_set_fpucw (regs.fpcr); } if (extra & 0x0800) - set_fpsr (next_ilong_fpu ()); + set_fpsr (x_next_ilong ()); if (extra & 0x0400) - regs.fpiar = next_ilong_fpu (); + regs.fpiar = x_next_ilong (); } } else if (extra & 0x2000) { /* FMOVEM FPP->memory */ @@ -1203,15 +1130,15 @@ void fpuop_arithmetic (uae_u32 opcode, uae_u16 extra) } ad -= incr; if (extra & 0x1000) { - put_long_fpu (ad, regs.fpcr & 0xffff); + x_put_long (ad, regs.fpcr & 0xffff); ad += 4; } if (extra & 0x0800) { - put_long_fpu (ad, get_fpsr()); + x_put_long (ad, get_fpsr()); ad += 4; } if (extra & 0x0400) { - put_long_fpu (ad, regs.fpiar); + x_put_long (ad, regs.fpiar); ad += 4; } ad -= incr; @@ -1239,16 +1166,16 @@ void fpuop_arithmetic (uae_u32 opcode, uae_u16 extra) ad = ad - incr; } if (extra & 0x1000) { - regs.fpcr = get_long_fpu (ad); + regs.fpcr = x_get_long (ad); native_set_fpucw (regs.fpcr); ad += 4; } if (extra & 0x0800) { - set_fpsr(get_long_fpu (ad)); + set_fpsr(x_get_long (ad)); ad += 4; } if (extra & 0x0400) { - regs.fpiar = get_long_fpu (ad); + regs.fpiar = x_get_long (ad); ad += 4; } if ((opcode & 0x38) == 0x18) @@ -1294,11 +1221,11 @@ void fpuop_arithmetic (uae_u32 opcode, uae_u16 extra) if (list & 0x80) { from_exten (regs.fp[reg], &wrd1, &wrd2, &wrd3); ad -= 4; - put_long_fpu (ad, wrd3); + x_put_long (ad, wrd3); ad -= 4; - put_long_fpu (ad, wrd2); + x_put_long (ad, wrd2); ad -= 4; - put_long_fpu (ad, wrd1); + x_put_long (ad, wrd1); } list <<= 1; } @@ -1307,11 +1234,11 @@ void fpuop_arithmetic (uae_u32 opcode, uae_u16 extra) uae_u32 wrd1, wrd2, wrd3; if (list & 0x80) { from_exten (regs.fp[reg], &wrd1, &wrd2, &wrd3); - put_long_fpu (ad, wrd1); + x_put_long (ad, wrd1); ad += 4; - put_long_fpu (ad, wrd2); + x_put_long (ad, wrd2); ad += 4; - put_long_fpu (ad, wrd3); + x_put_long (ad, wrd3); ad += 4; } list <<= 1; @@ -1351,11 +1278,11 @@ void fpuop_arithmetic (uae_u32 opcode, uae_u16 extra) uae_u32 wrd1, wrd2, wrd3; if (list & 0x80) { ad -= 4; - wrd3 = get_long_fpu (ad); + wrd3 = x_get_long (ad); ad -= 4; - wrd2 = get_long_fpu (ad); + wrd2 = x_get_long (ad); ad -= 4; - wrd1 = get_long_fpu (ad); + wrd1 = x_get_long (ad); regs.fp[reg] = to_exten(wrd1, wrd2, wrd3); } list <<= 1; @@ -1364,11 +1291,11 @@ void fpuop_arithmetic (uae_u32 opcode, uae_u16 extra) for (reg = 0; reg <= 7; reg++) { uae_u32 wrd1, wrd2, wrd3; if (list & 0x80) { - wrd1 = get_long_fpu (ad); + wrd1 = x_get_long (ad); ad += 4; - wrd2 = get_long_fpu (ad); + wrd2 = x_get_long (ad); ad += 4; - wrd3 = get_long_fpu (ad); + wrd3 = x_get_long (ad); ad += 4; regs.fp[reg] = to_exten(wrd1, wrd2, wrd3); } diff --git a/gencpu.cpp b/gencpu.cpp index 72c20150..476d5312 100644 --- a/gencpu.cpp +++ b/gencpu.cpp @@ -221,13 +221,19 @@ static const char *bit_mask (int size) return 0; } +static char *srcl, *dstl; +static char *srcw, *dstw; +static char *srcb, *dstb; +static char *ce020_prefetch_long; +static char *ce020_prefetch_word; + static void gen_nextilong (char *type, char *name, int flags) { int r = m68k_pc_offset; m68k_pc_offset += 4; if (using_ce020) { - printf ("\t%s %s = get_long_ce020_prefetch (%d);\n", type, name, r); + printf ("\t%s %s = %s (%d);\n", type, name, ce020_prefetch_long, r); count_read += 2; } else if (using_ce) { printf ("\t%s %s;\n", type, name); @@ -276,7 +282,7 @@ static const char *gen_nextiword (int flags) m68k_pc_offset += 2; if (using_ce020) { - sprintf (buffer, "get_word_ce020_prefetch (%d)", r); + sprintf (buffer, "%s (%d)", ce020_prefetch_word, r); count_read++; } else if (using_ce) { if (flags & GF_NOREFILL) { @@ -315,7 +321,7 @@ static const char *gen_nextibyte (int flags) m68k_pc_offset += 2; if (using_ce020) { - sprintf (buffer, "(uae_u8)get_word_ce020_prefetch (%d)", r); + sprintf (buffer, "(uae_u8)%s (%d)", ce020_prefetch_word, r); count_read++; } else if (using_ce) { if (flags & GF_NOREFILL) { @@ -625,10 +631,8 @@ static void genamode2 (amodes mode, char *reg, wordsizes size, char *name, int g start_brace (); /* This would ordinarily be done in gen_nextiword, which we bypass. */ insn_n_cycles += 4; - if (using_ce020) - printf ("\t%sa = get_disp_ea_020ce (m68k_areg (regs, %s), next_iword_020ce ());\n", name, reg); - else if (using_mmu) - printf ("\t%sa = get_disp_ea_040mmu (m68k_areg (regs, %s), next_iword_mmu ());\n", name, reg); + if (using_ce020 || using_mmu) + printf ("\t%sa = x_get_disp_ea_020 (m68k_areg (regs, %s), x_next_iword ());\n", name, reg); else printf ("\t%sa = get_disp_ea_020 (m68k_areg (regs, %s), next_iword ());\n", name, reg); } else { @@ -656,10 +660,8 @@ static void genamode2 (amodes mode, char *reg, wordsizes size, char *name, int g /* This would ordinarily be done in gen_nextiword, which we bypass. */ insn_n_cycles += 4; printf ("\ttmppc = m68k_getpc ();\n"); - if (using_ce020) - printf ("\t%sa = get_disp_ea_020ce (tmppc, next_iword_020ce ());\n", name); - else if (using_mmu) - printf ("\t%sa = get_disp_ea_040mmu (tmppc, next_iword_mmu ());\n", name); + if (using_ce020 || using_mmu) + printf ("\t%sa = x_get_disp_ea_020 (tmppc, x_next_iword ());\n", name); else printf ("\t%sa = get_disp_ea_020 (tmppc, next_iword ());\n", name); } else { @@ -763,9 +765,9 @@ static void genamode2 (amodes mode, char *reg, wordsizes size, char *name, int g start_brace (); if (using_ce020) { switch (size) { - case sz_byte: insn_n_cycles += 4; printf ("\tuae_s8 %s = get_byte_ce020 (%sa);\n", name, name); count_read++; break; - case sz_word: insn_n_cycles += 4; printf ("\tuae_s16 %s = get_word_ce020 (%sa);\n", name, name); count_read++; break; - case sz_long: insn_n_cycles += 8; printf ("\tuae_s32 %s = get_long_ce020 (%sa);\n", name, name); count_read += 2; break; + case sz_byte: insn_n_cycles += 4; printf ("\tuae_s8 %s = %s (%sa);\n", name, srcb, name); count_read++; break; + case sz_word: insn_n_cycles += 4; printf ("\tuae_s16 %s = %s (%sa);\n", name, srcw, name); count_read++; break; + case sz_long: insn_n_cycles += 8; printf ("\tuae_s32 %s = %s (%sa);\n", name, srcl, name); count_read += 2; break; default: abort (); } } else if (using_ce) { @@ -910,19 +912,19 @@ static void genastore_2 (char *from, amodes mode, char *reg, wordsizes size, cha if (using_ce020) { switch (size) { case sz_byte: - printf ("\tput_byte_ce020 (%sa, %s);\n", to, from); + printf ("\t%s (%sa, %s);\n", dstb, to, from); count_write++; break; case sz_word: if (cpu_level < 2 && (mode == PC16 || mode == PC8r)) abort (); - printf ("\tput_word_ce020 (%sa, %s);\n", to, from); + printf ("\t%s (%sa, %s);\n", dstw, to, from); count_write++; break; case sz_long: if (cpu_level < 2 && (mode == PC16 || mode == PC8r)) abort (); - printf ("\tput_long_ce020 (%sa, %s);\n", to, from); + printf ("\t%s (%sa, %s);\n", dstl, to, from); count_write += 2; break; default: @@ -1038,18 +1040,10 @@ static void genmovemel (uae_u16 opcode) char getcode[100]; int size = table68k[opcode].size == sz_long ? 4 : 2; - if (using_mmu) { - if (table68k[opcode].size == sz_long) { - strcpy (getcode, "get_long_mmu (srca)"); - } else { - strcpy (getcode, "(uae_s32)(uae_s16)get_word_mmu (srca)"); - } + if (table68k[opcode].size == sz_long) { + sprintf (getcode, "%s (srca)", srcl); } else { - if (table68k[opcode].size == sz_long) { - strcpy (getcode, "get_long (srca)"); - } else { - strcpy (getcode, "(uae_s32)(uae_s16)get_word (srca)"); - } + sprintf (getcode, "(uae_s32)(uae_s16)%s (srca)", srcw); } count_read += table68k[opcode].size == sz_long ? 2 : 1; printf ("\tuae_u16 mask = %s;\n", gen_nextiword (0)); @@ -1100,21 +1094,13 @@ static void genmovemel_ce (uae_u16 opcode) static void genmovemle (uae_u16 opcode) { - char *putcode; + char putcode[100]; int size = table68k[opcode].size == sz_long ? 4 : 2; - if (using_mmu) { - if (table68k[opcode].size == sz_long) { - putcode = "put_long_mmu (srca"; - } else { - putcode = "put_word_mmu (srca"; - } + if (table68k[opcode].size == sz_long) { + sprintf (putcode, "%s (srca", dstl); } else { - if (table68k[opcode].size == sz_long) { - putcode = "put_long (srca"; - } else { - putcode = "put_word (srca"; - } + sprintf (putcode, "%s (srca", dstw); } count_write += table68k[opcode].size == sz_long ? 2 : 1; @@ -1500,19 +1486,29 @@ static int islongimm (struct instr *curi) static void gen_opcode (unsigned long int opcode) { struct instr *curi = table68k + opcode; - char *srcl, *dstl; - char *srcw, *dstw; - char *srcb, *dstb; insn_n_cycles = using_prefetch ? 0 : 4; if (using_ce020) { - srcl = "get_long_ce020"; - dstl = "put_long_ce020"; - srcw = "get_word_ce020"; - dstw = "put_word_ce020"; - srcb = "get_byte_ce020"; - dstb = "put_byte_ce020"; + if (using_ce020 == 2) { + ce020_prefetch_long = "get_long_ce030_prefetch"; + ce020_prefetch_word = "get_word_ce030_prefetch"; + srcl = "get_long_ce030"; + dstl = "put_long_ce030"; + srcw = "get_word_ce030"; + dstw = "put_word_ce030"; + srcb = "get_byte_ce030"; + dstb = "put_byte_ce030"; + } else { + ce020_prefetch_long = "get_long_ce020_prefetch"; + ce020_prefetch_word = "get_word_ce020_prefetch"; + srcl = "get_long_ce020"; + dstl = "put_long_ce020"; + srcw = "get_word_ce020"; + dstw = "put_word_ce020"; + srcb = "get_byte_ce020"; + dstb = "put_byte_ce020"; + } } else if (using_mmu) { srcl = "get_long_mmu"; dstl = "put_long_mmu"; @@ -1636,7 +1632,8 @@ static void gen_opcode (unsigned long int opcode) genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0); genamode (curi->dmode, "dstreg", sz_long, "dst", 1, 0, 0); if (curi->smode == immi) { - c = 4; + c = curi->size == sz_long ? 2 : 4; + c += 4; } else { c = curi->size == sz_long ? 2 : 4; if (islongimm (curi)) @@ -1721,6 +1718,7 @@ static void gen_opcode (unsigned long int opcode) genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0); genamode (curi->dmode, "dstreg", sz_long, "dst", 1, 0, 0); if (curi->smode == immi) { + c = curi->size == sz_long ? 2 : 4; c += 4; } else { c = curi->size == sz_long ? 2 : 4; @@ -2072,6 +2070,8 @@ static void gen_opcode (unsigned long int opcode) break; case i_NOP: fill_prefetch_next (); + if (using_ce020) + printf ("\tdo_cycles_ce (6 * CYCLE_UNIT);\n"); break; case i_STOP: if (using_prefetch) { @@ -2205,7 +2205,11 @@ static void gen_opcode (unsigned long int opcode) } break; case i_RTS: - if (using_ce) + if (using_ce020 == 1) + printf ("\tm68k_do_rts_ce020 ();\n"); + else if (using_ce020 == 2) + printf ("\tm68k_do_rts_ce030 ();\n"); + else if (using_ce) printf ("\tm68k_do_rts_ce ();\n"); else if (using_indirect) printf ("\tm68k_do_rtsi ();\n"); @@ -2301,7 +2305,11 @@ static void gen_opcode (unsigned long int opcode) need_endlabel = 1; } addcycles000 (2); - if (using_ce) { + if (using_ce020 == 1) { + printf ("\tm68k_do_bsr_ce020 (m68k_getpc () + %d, s);\n", m68k_pc_offset); + } else if (using_ce020 == 2) { + printf ("\tm68k_do_bsr_ce030 (m68k_getpc () + %d, s);\n", m68k_pc_offset); + } else if (using_ce) { printf ("\tm68k_do_bsr_ce (m68k_getpc () + %d, s);\n", m68k_pc_offset); } else if (using_indirect) { printf ("\tm68k_do_bsri (m68k_getpc () + %d, s);\n", m68k_pc_offset); @@ -3198,12 +3206,9 @@ static void gen_opcode (unsigned long int opcode) { char *getb, *putb; - if (using_mmu) { - getb = "get_bitfield_040mmu"; - putb = "put_bitfield_040mmu"; - } else if (using_ce020) { - getb = "get_bitfield_020ce"; - putb = "put_bitfield_020ce"; + if (using_mmu || using_ce020) { + getb = "x_get_bitfield"; + putb = "x_put_bitfield"; } else { getb = "get_bitfield"; putb = "put_bitfield"; @@ -3445,7 +3450,7 @@ static void gen_opcode (unsigned long int opcode) break; case i_MMUOP030: printf ("\tuaecptr pc = m68k_getpc ();\n"); - printf ("\tuae_u16 extra = get_word (pc + 2);\n"); + printf ("\tuae_u16 extra = x_get_word (pc + 2);\n"); m68k_pc_offset += 2; sync_m68k_pc (); if (curi->smode == Areg || curi->smode == Dreg) @@ -3811,7 +3816,7 @@ int main (int argc, char **argv) if ((i >= 6 && i < 11) || (i > 12 && i < 20) || (i > 23 && i < 31)) continue; generate_stbl = 1; - if (i == 0 || i == 11 || i == 12 || i == 20 || i == 31) { + if (i == 0 || i == 11 || i == 12 || i == 20 || i == 21 || i == 31) { if (generate_stbl) fprintf (stblfile, "#ifdef CPUEMU_%d\n", postfix); postfix2 = postfix; @@ -3833,18 +3838,27 @@ int main (int argc, char **argv) using_ce = 1; for (rp = 0; rp < nr_cpuop_funcs; rp++) opcode_next_clev[rp] = 0; - } else if (i >= 20 && i < 30) { - cpu_level = 25 - i; + } else if (i == 20) { + cpu_level = 2; using_ce020 = 1; - if (i == 20) + read_counts (); + for (rp = 0; rp < nr_cpuop_funcs; rp++) + opcode_next_clev[rp] = cpu_level; + } else if (i == 21 || i == 22 || i == 23) { + cpu_level = 3 + (23 - i); + using_ce020 = 2; + if (i == 21) { read_counts (); + for (rp = 0; rp < nr_cpuop_funcs; rp++) + opcode_next_clev[rp] = cpu_level; + } } else if (i >= 31 && i < 40) { cpu_level = 4; using_mmu = 1; if (i == 31) read_counts (); for (rp = 0; rp < nr_cpuop_funcs; rp++) - opcode_next_clev[rp] = 4; + opcode_next_clev[rp] = cpu_level; } if (generate_stbl) { diff --git a/genlinetoscr.cpp b/genlinetoscr.cpp index 7c54dd82..8bf90db7 100644 --- a/genlinetoscr.cpp +++ b/genlinetoscr.cpp @@ -478,7 +478,7 @@ int main (int argc, char *argv[]) outln (" */"); outln (""); - for (bpp = DEPTH_8BPP; bpp <= DEPTH_MAX; bpp++) { + for (bpp = DEPTH_16BPP; bpp <= DEPTH_MAX; bpp++) { for (aga = 0; aga <= 1 ; aga++) { if (aga && bpp == DEPTH_8BPP) continue; diff --git a/include/autoconf.h b/include/autoconf.h index ed5dd875..4cb9cb55 100644 --- a/include/autoconf.h +++ b/include/autoconf.h @@ -47,8 +47,8 @@ extern uaecptr need_uae_boot_rom (void); struct mountedinfo { uae_u64 size; - int ismounted; - int ismedia; + bool ismounted; + bool ismedia; int nrcyls; }; @@ -59,12 +59,12 @@ extern int move_filesys_unitconfig (struct uae_prefs *p, int nr, int to); extern TCHAR *validatedevicename (TCHAR *s); extern TCHAR *validatevolumename (TCHAR *s); -int filesys_insert(int nr, TCHAR *volume, const TCHAR *rootdir, int readonly, int flags); -int filesys_eject(int nr); +int filesys_insert (int nr, TCHAR *volume, const TCHAR *rootdir, bool readonly, int flags); +int filesys_eject (int nr); int filesys_media_change (const TCHAR *rootdir, int inserted, struct uaedev_config_info *uci); extern TCHAR *filesys_createvolname (const TCHAR *volname, const TCHAR *rootdir, const TCHAR *def); -extern int target_get_volume_name(struct uaedev_mount_info *mtinf, const TCHAR *volumepath, TCHAR *volumename, int size, int inserted, int fullcheck); +extern int target_get_volume_name (struct uaedev_mount_info *mtinf, const TCHAR *volumepath, TCHAR *volumename, int size, bool inserted, bool fullcheck); extern int sprintf_filesys_unit (TCHAR *buffer, int num); diff --git a/include/cpu_prefetch.h b/include/cpu_prefetch.h index 9c7f8b56..af1add0f 100644 --- a/include/cpu_prefetch.h +++ b/include/cpu_prefetch.h @@ -216,16 +216,16 @@ STATIC_INLINE void put_long_ce020 (uaecptr addr, uae_u32 v) { mem_access_delay_long_write_ce020 (addr, v); } -STATIC_INLINE void put_word_ce020 (uaecptr addr, uae_u16 v) +STATIC_INLINE void put_word_ce020 (uaecptr addr, uae_u32 v) { mem_access_delay_word_write_ce020 (addr, v); } -STATIC_INLINE void put_byte_ce020 (uaecptr addr, uae_u8 v) +STATIC_INLINE void put_byte_ce020 (uaecptr addr, uae_u32 v) { mem_access_delay_byte_write_ce020 (addr, v); } -extern void fill_cache0x0 (uae_u32); +extern void fill_icache020 (uae_u32); STATIC_INLINE uae_u32 get_word_ce020_prefetch (int o) { @@ -238,10 +238,10 @@ STATIC_INLINE uae_u32 get_word_ce020_prefetch (int o) } if (pc == regs.prefetch020addr + 2) { uae_u32 v = regs.prefetch020data & 0xffff; - fill_cache0x0 (pc + 2); + fill_icache020 (pc + 2); return v; } - fill_cache0x0 (pc); + fill_icache020 (pc); } } @@ -265,6 +265,104 @@ STATIC_INLINE uae_u32 next_ilong_020ce (void) m68k_incpc (4); return r; } + +STATIC_INLINE void m68k_do_bsr_ce020 (uaecptr oldpc, uae_s32 offset) +{ + m68k_areg (regs, 7) -= 4; + put_long_ce020 (m68k_areg (regs, 7), oldpc); + m68k_incpc (offset); +} +STATIC_INLINE void m68k_do_rts_ce020 (void) +{ + m68k_setpc (get_long_ce020 (m68k_areg (regs, 7))); + m68k_areg (regs, 7) += 4; +} +#endif + +#ifdef CPUEMU_21 + +extern void fill_icache030 (uae_u32 addr); +extern void write_dcache030 (uaecptr, uae_u32, int); +extern uae_u32 read_dcache030 (uaecptr, int); + +STATIC_INLINE void put_long_ce030 (uaecptr addr, uae_u32 v) +{ + write_dcache030 (addr, v, 2); + mem_access_delay_long_write_ce020 (addr, v); +} +STATIC_INLINE void put_word_ce030 (uaecptr addr, uae_u32 v) +{ + write_dcache030 (addr, v, 1); + mem_access_delay_word_write_ce020 (addr, v); +} +STATIC_INLINE void put_byte_ce030 (uaecptr addr, uae_u32 v) +{ + write_dcache030 (addr, v, 0); + mem_access_delay_byte_write_ce020 (addr, v); +} +STATIC_INLINE uae_u32 get_long_ce030 (uaecptr addr) +{ + return read_dcache030 (addr, 2); +} +STATIC_INLINE uae_u32 get_word_ce030 (uaecptr addr) +{ + return read_dcache030 (addr, 1); +} +STATIC_INLINE uae_u32 get_byte_ce030 (uaecptr addr) +{ + return read_dcache030 (addr, 0); +} + +STATIC_INLINE uae_u32 get_word_ce030_prefetch (int o) +{ + uae_u32 pc = m68k_getpc () + o; + + for (;;) { + if (pc == regs.prefetch020addr) { + uae_u32 v = regs.prefetch020data >> 16; + return v; + } + if (pc == regs.prefetch020addr + 2) { + uae_u32 v = regs.prefetch020data & 0xffff; + fill_icache030 (pc + 2); + return v; + } + fill_icache030 (pc); + } +} + +STATIC_INLINE uae_u32 get_long_ce030_prefetch (int o) +{ + uae_u32 v; + v = get_word_ce030_prefetch (o) << 16; + v |= get_word_ce030_prefetch (o + 2); + return v; +} + +STATIC_INLINE uae_u32 next_iword_030ce (void) +{ + uae_u32 r = get_word_ce030_prefetch (0); + m68k_incpc (2); + return r; +} +STATIC_INLINE uae_u32 next_ilong_030ce (void) +{ + uae_u32 r = get_long_ce030_prefetch (0); + m68k_incpc (4); + return r; +} + +STATIC_INLINE void m68k_do_bsr_ce030 (uaecptr oldpc, uae_s32 offset) +{ + m68k_areg (regs, 7) -= 4; + put_long_ce030 (m68k_areg (regs, 7), oldpc); + m68k_incpc (offset); +} +STATIC_INLINE void m68k_do_rts_ce030 (void) +{ + m68k_setpc (get_long_ce030 (m68k_areg (regs, 7))); + m68k_areg (regs, 7) += 4; +} #endif #ifdef CPUEMU_12 diff --git a/include/custom.h b/include/custom.h index 508c4b5d..a65b12cb 100644 --- a/include/custom.h +++ b/include/custom.h @@ -31,8 +31,8 @@ extern void init_row_map (void); extern void init_hz (void); extern void init_custom (void); -extern int picasso_requested_on; -extern int picasso_on; +extern bool picasso_requested_on; +extern bool picasso_on; extern void set_picasso_hack_rate (int hz); /* Set to 1 to leave out the current frame in average frame time calculation. @@ -207,4 +207,4 @@ struct customhack { void customhack_put (struct customhack *ch, uae_u16 v, int hpos); uae_u16 customhack_get (struct customhack *ch, int hpos); extern void alloc_cycle_ext (int, int); -extern int ispal (void); +extern bool ispal (void); diff --git a/include/disk.h b/include/disk.h index 5f1eae46..8445ea7b 100644 --- a/include/disk.h +++ b/include/disk.h @@ -20,7 +20,7 @@ extern int disk_empty (int num); extern void disk_insert (int num, const TCHAR *name); extern void disk_insert_force (int num, const TCHAR *name); extern void DISK_check_change (void); -extern int DISK_validate_filename (const TCHAR *fname, int leave_open, int *wrprot, uae_u32 *crc32, struct zfile **zf); +extern int DISK_validate_filename (const TCHAR *fname, int leave_open, bool *wrprot, uae_u32 *crc32, struct zfile **zf); extern void DISK_handler (uae_u32); extern void DISK_update (int hpos); extern void DISK_hsync (int hpos); diff --git a/include/drawing.h b/include/drawing.h index a701894a..6ee3d55c 100644 --- a/include/drawing.h +++ b/include/drawing.h @@ -1,8 +1,8 @@ /* - * Data used for communication between custom.c and drawing.c. - * - * Copyright 1996-1998 Bernd Schmidt - */ +* Data used for communication between custom.c and drawing.c. +* +* Copyright 1996-1998 Bernd Schmidt +*/ #define SMART_UPDATE 1 @@ -26,12 +26,12 @@ #define DISPLAY_LEFT_SHIFT 0x40 #else /* According to the HRM, pixel data spends a couple of cycles somewhere in the chips - before it appears on-screen. (TW: display emulation now does this automatically) */ +before it appears on-screen. (TW: display emulation now does this automatically) */ #define DIW_DDF_OFFSET 1 /* this many cycles starting from hpos=0 are visible on right border */ #define HBLANK_OFFSET 9 /* We ignore that many lores pixels at the start of the display. These are - * invisible anyway due to hardware DDF limits. */ +* invisible anyway due to hardware DDF limits. */ #define DISPLAY_LEFT_SHIFT 0x40 #endif @@ -40,46 +40,46 @@ #define max_diwlastword (PIXEL_XPOS(0x1d4 >> 1)) extern int lores_factor, lores_shift, sprite_width, interlace_seen; -extern int aga_mode, direct_rgb; +extern bool aga_mode, direct_rgb; STATIC_INLINE int coord_hw_to_window_x (int x) { - x -= DISPLAY_LEFT_SHIFT; - return x << lores_shift; + x -= DISPLAY_LEFT_SHIFT; + return x << lores_shift; } STATIC_INLINE int coord_window_to_hw_x (int x) { - x >>= lores_shift; - return x + DISPLAY_LEFT_SHIFT; + x >>= lores_shift; + return x + DISPLAY_LEFT_SHIFT; } STATIC_INLINE int coord_diw_to_window_x (int x) { - return (x - DISPLAY_LEFT_SHIFT + DIW_DDF_OFFSET - 1) << lores_shift; + return (x - DISPLAY_LEFT_SHIFT + DIW_DDF_OFFSET - 1) << lores_shift; } STATIC_INLINE int coord_window_to_diw_x (int x) { - x = coord_window_to_hw_x (x); - return x - DIW_DDF_OFFSET; + x = coord_window_to_hw_x (x); + return x - DIW_DDF_OFFSET; } extern int framecnt; /* color values in two formats: 12 (OCS/ECS) or 24 (AGA) bit Amiga RGB (color_regs), - * and the native color value; both for each Amiga hardware color register. - * - * !!! See color_reg_xxx functions below before touching !!! - */ +* and the native color value; both for each Amiga hardware color register. +* +* !!! See color_reg_xxx functions below before touching !!! +*/ struct color_entry { - uae_u16 color_regs_ecs[32]; + uae_u16 color_regs_ecs[32]; #ifndef AGA - xcolnr acolors[32]; + xcolnr acolors[32]; #else - xcolnr acolors[256]; - uae_u32 color_regs_aga[256]; + xcolnr acolors[256]; + uae_u32 color_regs_aga[256]; #endif }; @@ -88,10 +88,10 @@ struct color_entry { /* warning: this is still ugly, but now works with either byte order */ #ifdef WORDS_BIGENDIAN # define CONVERT_RGB(c) \ - ( xbluecolors[((uae_u8*)(&c))[3]] | xgreencolors[((uae_u8*)(&c))[2]] | xredcolors[((uae_u8*)(&c))[1]] ) + ( xbluecolors[((uae_u8*)(&c))[3]] | xgreencolors[((uae_u8*)(&c))[2]] | xredcolors[((uae_u8*)(&c))[1]] ) #else # define CONVERT_RGB(c) \ - ( xbluecolors[((uae_u8*)(&c))[0]] | xgreencolors[((uae_u8*)(&c))[1]] | xredcolors[((uae_u8*)(&c))[2]] ) + ( xbluecolors[((uae_u8*)(&c))[0]] | xgreencolors[((uae_u8*)(&c))[1]] | xredcolors[((uae_u8*)(&c))[2]] ) #endif #else #define CONVERT_RGB(c) 0 @@ -100,68 +100,68 @@ struct color_entry { STATIC_INLINE xcolnr getxcolor (int c) { #ifdef AGA - if (direct_rgb) - return CONVERT_RGB(c); - else + if (direct_rgb) + return CONVERT_RGB(c); + else #endif - return xcolors[c]; + return xcolors[c]; } /* functions for reading, writing, copying and comparing struct color_entry */ STATIC_INLINE int color_reg_get (struct color_entry *ce, int c) { #ifdef AGA - if (aga_mode) - return ce->color_regs_aga[c]; - else + if (aga_mode) + return ce->color_regs_aga[c]; + else #endif - return ce->color_regs_ecs[c]; + return ce->color_regs_ecs[c]; } STATIC_INLINE void color_reg_set (struct color_entry *ce, int c, int v) { #ifdef AGA - if (aga_mode) - ce->color_regs_aga[c] = v; - else + if (aga_mode) + ce->color_regs_aga[c] = v; + else #endif - ce->color_regs_ecs[c] = v; + ce->color_regs_ecs[c] = v; } STATIC_INLINE int color_reg_cmp (struct color_entry *ce1, struct color_entry *ce2) { #ifdef AGA - if (aga_mode) - return memcmp (ce1->color_regs_aga, ce2->color_regs_aga, sizeof (uae_u32) * 256); - else + if (aga_mode) + return memcmp (ce1->color_regs_aga, ce2->color_regs_aga, sizeof (uae_u32) * 256); + else #endif - return memcmp (ce1->color_regs_ecs, ce2->color_regs_ecs, sizeof (uae_u16) * 32); + return memcmp (ce1->color_regs_ecs, ce2->color_regs_ecs, sizeof (uae_u16) * 32); } /* ugly copy hack, is there better solution? */ STATIC_INLINE void color_reg_cpy (struct color_entry *dst, struct color_entry *src) { #ifdef AGA - if (aga_mode) - /* copy acolors and color_regs_aga */ - memcpy (dst->acolors, src->acolors, sizeof(struct color_entry) - sizeof(uae_u16) * 32); - else + if (aga_mode) + /* copy acolors and color_regs_aga */ + memcpy (dst->acolors, src->acolors, sizeof(struct color_entry) - sizeof(uae_u16) * 32); + else #endif - /* copy first 32 acolors and color_regs_ecs */ - memcpy (dst->color_regs_ecs, src->color_regs_ecs, + /* copy first 32 acolors and color_regs_ecs */ + memcpy (dst->color_regs_ecs, src->color_regs_ecs, sizeof(struct color_entry)); } /* - * The idea behind this code is that at some point during each horizontal - * line, we decide how to draw this line. There are many more-or-less - * independent decisions, each of which can be taken at a different horizontal - * position. - * Sprites and color changes are handled specially: There isn't a single decision, - * but a list of structures containing information on how to draw the line. - */ +* The idea behind this code is that at some point during each horizontal +* line, we decide how to draw this line. There are many more-or-less +* independent decisions, each of which can be taken at a different horizontal +* position. +* Sprites and color changes are handled specially: There isn't a single decision, +* but a list of structures containing information on how to draw the line. +*/ struct color_change { - int linepos; - int regno; - unsigned int value; + int linepos; + int regno; + unsigned int value; }; /* 440 rather than 880, since sprites are always lores. */ @@ -174,20 +174,20 @@ struct color_change { #endif /* No divisors for MAX_PIXELS_PER_LINE; we support AGA and may one day - want to use SHRES sprites. */ +want to use SHRES sprites. */ #define MAX_SPR_PIXELS (((MAXVPOS + 1) * 2 + 1) * MAX_PIXELS_PER_LINE) struct sprite_entry { - unsigned short pos; - unsigned short max; - unsigned int first_pixel; - unsigned int has_attached; + unsigned short pos; + unsigned short max; + unsigned int first_pixel; + bool has_attached; }; union sps_union { - uae_u8 bytes[2 * MAX_SPR_PIXELS]; - uae_u32 words[2 * MAX_SPR_PIXELS / 4]; + uae_u8 bytes[2 * MAX_SPR_PIXELS]; + uae_u32 words[2 * MAX_SPR_PIXELS / 4]; }; extern union sps_union spixstate; @@ -214,31 +214,31 @@ extern struct color_change *curr_color_changes, *prev_color_changes; extern struct draw_info *curr_drawinfo, *prev_drawinfo; /* struct decision contains things we save across drawing frames for - * comparison (smart update stuff). */ +* comparison (smart update stuff). */ struct decision { - /* Records the leftmost access of BPL1DAT. */ - int plfleft, plfright, plflinelen; - /* Display window: native coordinates, depend on lores state. */ - int diwfirstword, diwlastword; - int ctable; + /* Records the leftmost access of BPL1DAT. */ + int plfleft, plfright, plflinelen; + /* Display window: native coordinates, depend on lores state. */ + int diwfirstword, diwlastword; + int ctable; - uae_u16 bplcon0, bplcon2; + uae_u16 bplcon0, bplcon2; #ifdef AGA - uae_u16 bplcon3, bplcon4; + uae_u16 bplcon3, bplcon4; #endif - uae_u8 nr_planes; - uae_u8 bplres; - unsigned int ehb_seen; - unsigned int ham_seen; - unsigned int ham_at_start; + uae_u8 nr_planes; + uae_u8 bplres; + bool ehb_seen; + bool ham_seen; + bool ham_at_start; }; /* Anything related to changes in hw registers during the DDF for one - * line. */ +* line. */ struct draw_info { - int first_sprite_entry, last_sprite_entry; - int first_color_change, last_color_change; - int nr_color_changes, nr_sprites; + int first_sprite_entry, last_sprite_entry; + int first_color_change, last_color_change; + int nr_color_changes, nr_sprites; }; extern int next_sprite_entry; @@ -257,16 +257,16 @@ extern void hardware_line_completed (int lineno); /* Determine how to draw a scan line. */ enum nln_how { - /* All lines on a non-doubled display. */ - nln_normal, - /* Non-interlace, doubled display. */ - nln_doubled, - /* Interlace, doubled display, upper line. */ - nln_upper, - /* Interlace, doubled display, lower line. */ - nln_lower, - /* This line normal, next one black. */ - nln_nblack + /* All lines on a non-doubled display. */ + nln_normal, + /* Non-interlace, doubled display. */ + nln_doubled, + /* Interlace, doubled display, upper line. */ + nln_upper, + /* Interlace, doubled display, lower line. */ + nln_lower, + /* This line normal, next one black. */ + nln_nblack }; extern void hsync_record_line_state (int lineno, enum nln_how, int changed); @@ -293,13 +293,13 @@ extern int inhibit_frame; STATIC_INLINE void set_inhibit_frame (int bit) { - inhibit_frame |= 1 << bit; + inhibit_frame |= 1 << bit; } STATIC_INLINE void clear_inhibit_frame (int bit) { - inhibit_frame &= ~(1 << bit); + inhibit_frame &= ~(1 << bit); } STATIC_INLINE void toggle_inhibit_frame (int bit) { - inhibit_frame ^= 1 << bit; + inhibit_frame ^= 1 << bit; } diff --git a/include/epsonprinter.h b/include/epsonprinter.h index 4c51f592..4a70f61a 100644 --- a/include/epsonprinter.h +++ b/include/epsonprinter.h @@ -27,8 +27,10 @@ #if !defined __PRINTER_H #define __PRINTER_H -#include "ft2build.h" +#ifndef WINFONT +s#include "ft2build.h" #include FT_FREETYPE_H +#endif #if defined (WIN32) #include diff --git a/include/gui.h b/include/gui.h index 8bed90c6..ac65ba66 100644 --- a/include/gui.h +++ b/include/gui.h @@ -21,7 +21,7 @@ extern void gui_disk_image_change (int, const TCHAR *); extern unsigned int gui_ledstate; extern void gui_display (int shortcut); -extern int no_gui, quit_to_gui; +extern bool no_gui, quit_to_gui; #define LED_CD_ACTIVE 1 #define LED_CD_ACTIVE2 2 @@ -42,11 +42,11 @@ extern int no_gui, quit_to_gui; struct gui_info { - uae_u8 drive_motor[4]; /* motor on off */ + bool drive_motor[4]; /* motor on off */ uae_u8 drive_track[4]; /* rw-head track */ - uae_u8 drive_writing[4]; /* drive is writing */ - uae_u8 drive_disabled[4]; /* drive is disabled */ - uae_u8 powerled; /* state of power led */ + bool drive_writing[4]; /* drive is writing */ + bool drive_disabled[4]; /* drive is disabled */ + bool powerled; /* state of power led */ uae_u8 powerled_brightness; /* 0 to 255 */ uae_u8 drive_side; /* floppy side */ uae_u8 hd; /* harddrive */ diff --git a/include/inputdevice.h b/include/inputdevice.h index 97879632..e3e12f5f 100644 --- a/include/inputdevice.h +++ b/include/inputdevice.h @@ -34,13 +34,30 @@ extern int pause_emulation; struct uae_input_device_kbr_default { int scancode; - int event; + int evt; + int flags; }; +struct inputevent { + const TCHAR *confname; + const TCHAR *name; + int allow_mask; + int type; + int unit; + int data; +}; + +/* event flags */ +#define ID_FLAG_AUTOFIRE 1 +#define ID_FLAG_TOGGLE 2 +#define ID_FLAG_SAVE_MASK 0xff +#define ID_FLAG_TOGGLED 0x100 + #define IDEV_WIDGET_NONE 0 #define IDEV_WIDGET_BUTTON 1 #define IDEV_WIDGET_AXIS 2 -#define IDEV_WIDGET_KEY 3 +#define IDEV_WIDGET_BUTTONAXIS 3 +#define IDEV_WIDGET_KEY 4 #define IDEV_MAPPED_AUTOFIRE_POSSIBLE 1 #define IDEV_MAPPED_AUTOFIRE_SET 2 @@ -57,10 +74,12 @@ extern int inputdevice_get_mapped_name (int devnum, int num, int *pflags, TCHAR extern void inputdevice_copyconfig (const struct uae_prefs *src, struct uae_prefs *dst); extern void inputdevice_copy_single_config (struct uae_prefs *p, int src, int dst, int devnum); extern void inputdevice_swap_ports (struct uae_prefs *p, int devnum); +extern void inputdevice_swap_compa_ports (struct uae_prefs *p, int portswap); extern void inputdevice_config_change (void); extern int inputdevice_config_change_test (void); extern int inputdevice_get_device_index (int devnum); extern TCHAR *inputdevice_get_device_name (int type, int devnum); +extern TCHAR *inputdevice_get_device_name2 (int devnum); extern TCHAR *inputdevice_get_device_unique_name (int type, int devnum); extern int inputdevice_get_device_status (int devnum); extern void inputdevice_set_device_status (int devnum, int enabled); @@ -70,7 +89,7 @@ extern int inputdevice_get_widget_type (int devnum, int num, TCHAR *name); extern int input_get_default_mouse (struct uae_input_device *uid, int num, int port); extern int input_get_default_lightpen (struct uae_input_device *uid, int num, int port); -extern int input_get_default_joystick (struct uae_input_device *uid, int num, int port, int cd32); +extern int input_get_default_joystick (struct uae_input_device *uid, int num, int port, int mode); extern int input_get_default_joystick_analog (struct uae_input_device *uid, int num, int port); extern int input_get_default_keyboard (int num); @@ -119,6 +138,12 @@ 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 int inputdevice_get_compatibility_input (struct uae_prefs*, int, int*, int**, int**); +extern struct inputevent *inputdevice_get_eventinfo (int evt); +extern void inputdevice_get_eventname (const struct inputevent *ie, TCHAR *out); +extern void inputdevice_compa_prepare_custom (struct uae_prefs *prefs, int index); +extern int intputdevice_compa_get_eventtype (int evt, int **axistable); + extern uae_u16 potgo_value; extern uae_u16 POTGOR (void); @@ -137,7 +162,7 @@ extern void write_inputdevice_config (struct uae_prefs *p, struct zfile *f); extern void read_inputdevice_config (struct uae_prefs *p, TCHAR *option, TCHAR *value); extern void reset_inputdevice_config (struct uae_prefs *pr); extern int inputdevice_joyport_config (struct uae_prefs *p, TCHAR *value, int portnum, int mode, int type); -extern int inputdevice_getjoyportdevice (int jport); +extern int inputdevice_getjoyportdevice (int port, int val); extern void inputdevice_init (void); extern void inputdevice_close (void); @@ -187,7 +212,6 @@ extern void inputdevice_tablet_strobe (void); extern int jsem_isjoy (int port, const struct uae_prefs *p); extern int jsem_ismouse (int port, const struct uae_prefs *p); extern int jsem_iskbdjoy (int port, const struct uae_prefs *p); -extern void do_fake_joystick (int nr, int *fake); extern int inputdevice_uaelib (TCHAR *, TCHAR *); @@ -217,5 +241,8 @@ extern uae_u16 inprec_pu16 (void); extern uae_u32 inprec_pu32 (void); extern int inprec_pstr (TCHAR*); -extern int inputdevice_testread (TCHAR *name); +extern int inputdevice_testread (int*, int*, int*); extern int inputdevice_istest (void); +extern void inputdevice_settest (int); +extern int inputdevice_testread_count (void); + diff --git a/include/keybuf.h b/include/keybuf.h index 410765e5..7f5390f5 100644 --- a/include/keybuf.h +++ b/include/keybuf.h @@ -12,6 +12,5 @@ extern int keys_available (void); extern int record_key (int); extern int record_key_direct (int); extern void keybuf_init (void); -extern void joystick_setting_changed (void); extern int getcapslockstate (void); extern void setcapslockstate (int); diff --git a/include/memory.h b/include/memory.h index fdad6ea0..cdd898e1 100644 --- a/include/memory.h +++ b/include/memory.h @@ -20,7 +20,8 @@ extern void cache_free (uae_u8*); int init_shm (void); void preinit_shm (void); -extern int canbang, candirect; +extern bool canbang; +extern int candirect; #ifdef ADDRESS_SPACE_24BIT #define MEMORY_BANKS 256 @@ -63,10 +64,11 @@ extern uaecptr p96ram_start; extern uaecptr fastmem_start; extern uaecptr a3000lmem_start, a3000hmem_start; -extern int ersatzkickfile; -extern int cloanto_rom, kickstart_rom; +extern bool ersatzkickfile; +extern bool cloanto_rom, kickstart_rom; extern uae_u16 kickstart_version; -extern int uae_boot_rom, uae_boot_rom_size; +extern bool uae_boot_rom; +extern int uae_boot_rom_size; extern uaecptr rtarea_base; extern uae_u8* baseaddr[]; @@ -101,7 +103,7 @@ typedef struct { #define CE_MEMBANK_CHIP 1 #define CE_MEMBANK_CIA 2 #define CE_MEMBANK_FAST16BIT 3 -extern uae_u8 ce_banktype[65536]; +extern uae_u8 ce_banktype[65536], ce_cachable[65536]; extern uae_u8 *filesysory; extern uae_u8 *rtarea; @@ -133,7 +135,6 @@ extern void expamem_next (void); extern uae_u32 gfxmem_start; extern uae_u8 *gfxmemory; extern uae_u32 gfxmem_mask; -extern int address_space_24; extern uae_u16 last_custom_value1; /* Default memory access functions */ diff --git a/include/newcpu.h b/include/newcpu.h index a5eb228e..d9a398bf 100644 --- a/include/newcpu.h +++ b/include/newcpu.h @@ -94,13 +94,22 @@ struct cache020 { uae_u32 data; uae_u32 tag; - uae_u32 valid:1; + bool valid; }; + +#define CACHELINES030 16 +struct cache030 +{ + uae_u32 data[4]; + bool valid[4]; + uae_u32 tag; +}; + #define CACHESETS040 64 struct cache040set { uae_u32 data[4]; - int valid[4]; + bool valid[4]; uae_u32 tag; }; #define CACHELINES040 4 @@ -206,7 +215,10 @@ STATIC_INLINE uaecptr m68k_getpc_p (uae_u8 *p) return (uaecptr)(regs.pc + ((uae_u8*)p - (uae_u8*)regs.pc_oldp)); } -#define m68k_incpc(o) ((regs).pc_p += (o)) +STATIC_INLINE void m68k_incpc (int o) +{ + regs.pc_p += o; +} STATIC_INLINE void m68k_setpc_mmu (uaecptr newpc) { @@ -250,9 +262,18 @@ STATIC_INLINE void m68k_do_bsri (uaecptr oldpc, uae_s32 offset) m68k_incpci (offset); } -#define get_ibyte(o) do_get_mem_byte((uae_u8 *)((regs).pc_p + (o) + 1)) -#define get_iword(o) do_get_mem_word((uae_u16 *)((regs).pc_p + (o))) -#define get_ilong(o) do_get_mem_long((uae_u32 *)((regs).pc_p + (o))) +STATIC_INLINE uae_u32 get_ibyte (int o) +{ + return do_get_mem_byte((uae_u8 *)((regs).pc_p + (o) + 1)); +} +STATIC_INLINE uae_u32 get_iword (int o) +{ + return do_get_mem_word((uae_u16 *)((regs).pc_p + (o))); +} +STATIC_INLINE uae_u32 get_ilong (int o) +{ + return do_get_mem_long((uae_u32 *)((regs).pc_p + (o))); +} #define get_iwordi(o) get_wordi(o) #define get_ilongi(o) get_longi(o) @@ -290,19 +311,26 @@ STATIC_INLINE uae_u32 next_ilongi (void) return r; } +extern uae_u32 (*x_get_byte)(uaecptr addr); +extern uae_u32 (*x_get_word)(uaecptr addr); +extern uae_u32 (*x_get_long)(uaecptr addr); +extern void (*x_put_byte)(uaecptr addr, uae_u32 v); +extern void (*x_put_word)(uaecptr addr, uae_u32 v); +extern void (*x_put_long)(uaecptr addr, uae_u32 v); +extern uae_u32 (*x_next_iword)(void); +extern uae_u32 (*x_next_ilong)(void); + +extern uae_u32 REGPARAM3 x_get_disp_ea_020 (uae_u32 base, uae_u32 dp) REGPARAM; +extern uae_u32 REGPARAM3 x_get_bitfield (uae_u32 src, uae_u32 bdata[2], uae_s32 offset, int width) REGPARAM; +extern void REGPARAM3 x_put_bitfield (uae_u32 dst, uae_u32 bdata[2], uae_u32 val, uae_s32 offset, int width) REGPARAM; + extern void m68k_setstopped (void); extern void m68k_resumestopped (void); extern uae_u32 REGPARAM3 get_disp_ea_020 (uae_u32 base, uae_u32 dp) REGPARAM; -extern uae_u32 REGPARAM3 get_disp_ea_020ce (uae_u32 base, uae_u32 dp) REGPARAM; -extern uae_u32 REGPARAM3 get_disp_ea_040mmu (uae_u32 base, uae_u32 dp) REGPARAM; extern uae_u32 REGPARAM3 get_disp_ea_000 (uae_u32 base, uae_u32 dp) REGPARAM; -extern uae_u32 get_bitfield (uae_u32 src, uae_u32 bdata[2], uae_s32 offset, int width); -extern void put_bitfield (uae_u32 dst, uae_u32 bdata[2], uae_u32 val, uae_s32 offset, int width); -extern uae_u32 get_bitfield_020ce (uae_u32 src, uae_u32 bdata[2], uae_s32 offset, int width); -extern void put_bitfield_020ce (uae_u32 dst, uae_u32 bdata[2], uae_u32 val, uae_s32 offset, int width); -extern uae_u32 get_bitfield_040mmu (uae_u32 src, uae_u32 bdata[2], uae_s32 offset, int width); -extern void put_bitfield_040mmu (uae_u32 dst, uae_u32 bdata[2], uae_u32 val, uae_s32 offset, int width); +extern uae_u32 REGPARAM3 get_bitfield (uae_u32 src, uae_u32 bdata[2], uae_s32 offset, int width) REGPARAM; +extern void REGPARAM3 put_bitfield (uae_u32 dst, uae_u32 bdata[2], uae_u32 val, uae_s32 offset, int width) REGPARAM; extern void m68k_disasm_ea (void *f, uaecptr addr, uaecptr *nextpc, int cnt, uae_u32 *seaddr, uae_u32 *deaddr); extern void m68k_disasm (void *f, uaecptr addr, uaecptr *nextpc, int cnt); @@ -381,12 +409,13 @@ extern const struct cputbl op_smalltbl_12_ff[]; extern cpuop_func *cpufunctbl[65536] ASM_SYM_FOR_FUNC ("cpufunctbl"); #ifdef JIT -extern void flush_icache (uaecptr, int n); +extern void flush_icache (uaecptr, int); extern void compemu_reset (void); -extern int check_prefs_changed_comp (void); +extern bool check_prefs_changed_comp (void); #else #define flush_icache(uaecptr, int) do {} while (0) #endif +extern void flush_dcache (uaecptr, int); extern void flush_mmu (uaecptr, int); extern int movec_illg (int regno); diff --git a/include/options.h b/include/options.h index d5a0e9b3..e0257982 100644 --- a/include/options.h +++ b/include/options.h @@ -1,14 +1,14 @@ - /* - * UAE - The Un*x Amiga Emulator - * - * Stuff - * - * Copyright 1995, 1996 Ed Hanway - * Copyright 1995-2001 Bernd Schmidt - */ +/* +* UAE - The Un*x Amiga Emulator +* +* Stuff +* +* Copyright 1995, 1996 Ed Hanway +* Copyright 1995-2001 Bernd Schmidt +*/ #define UAEMAJOR 2 -#define UAEMINOR 1 +#define UAEMINOR 2 #define UAESUBREV 0 typedef enum { KBD_LANG_US, KBD_LANG_DK, KBD_LANG_DE, KBD_LANG_SE, KBD_LANG_FR, KBD_LANG_IT, KBD_LANG_ES } KbdLang; @@ -16,9 +16,9 @@ typedef enum { KBD_LANG_US, KBD_LANG_DK, KBD_LANG_DE, KBD_LANG_SE, KBD_LANG_FR, extern long int version; struct strlist { - struct strlist *next; - TCHAR *option, *value; - int unknown; + struct strlist *next; + TCHAR *option, *value; + int unknown; }; /* maximum number native input devices supported (single type) */ @@ -27,27 +27,31 @@ struct strlist { #define MAX_INPUT_DEVICE_EVENTS 256 /* 4 different customization settings */ #define MAX_INPUT_SETTINGS 4 +#define GAMEPORT_INPUT_SETTINGS 3 // last slot is for gameport panel mappings #define MAX_INPUT_SUB_EVENT 4 #define MAX_INPUT_SIMULTANEOUS_KEYS 4 struct uae_input_device { - TCHAR *name; - TCHAR *configname; - uae_s16 eventid[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SUB_EVENT]; - TCHAR *custom[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SUB_EVENT]; - uae_u16 flags[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SUB_EVENT]; - uae_s16 extra[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SIMULTANEOUS_KEYS]; - uae_s8 enabled; + TCHAR *name; + TCHAR *configname; + uae_s16 eventid[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SUB_EVENT]; + TCHAR *custom[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SUB_EVENT]; + uae_u16 flags[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SUB_EVENT]; + uae_s16 extra[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SIMULTANEOUS_KEYS]; + uae_s8 enabled; }; #define MAX_JPORTS 4 #define MAX_JPORTNAME 128 struct jport { - int id; - int mode; // 0=def,1=mouse,2=joy,3=anajoy,4=lightpen - TCHAR name[MAX_JPORTNAME]; - TCHAR configname[MAX_JPORTNAME]; + int id; + int mode; // 0=def,1=mouse,2=joy,3=anajoy,4=lightpen + int autofire; + TCHAR name[MAX_JPORTNAME]; + TCHAR configname[MAX_JPORTNAME]; }; +#define JPORT_NONE -1 +#define JPORT_CUSTOM -2 #define MAX_SPARE_DRIVES 20 #define MAX_CUSTOM_MEMORY_ADDRS 2 @@ -61,331 +65,319 @@ struct jport { #define TABLET_REAL 2 struct wh { - int x, y; - int width, height; + int x, y; + int width, height; }; #define MOUNT_CONFIG_SIZE 30 struct uaedev_config_info { - TCHAR devname[MAX_DPATH]; - TCHAR volname[MAX_DPATH]; - TCHAR rootdir[MAX_DPATH]; - int ishdf; - int readonly; - int bootpri; - int autoboot; - int donotmount; - TCHAR filesys[MAX_DPATH]; - int surfaces; - int sectors; - int reserved; - int blocksize; - int configoffset; - int controller; + TCHAR devname[MAX_DPATH]; + TCHAR volname[MAX_DPATH]; + TCHAR rootdir[MAX_DPATH]; + bool ishdf; + bool readonly; + int bootpri; + bool autoboot; + bool donotmount; + TCHAR filesys[MAX_DPATH]; + int surfaces; + int sectors; + int reserved; + int blocksize; + int configoffset; + int controller; }; enum { CP_GENERIC = 1, CP_CDTV, CP_CD32, CP_A500, CP_A500P, CP_A600, CP_A1000, - CP_A1200, CP_A2000, CP_A3000, CP_A3000T, CP_A4000, CP_A4000T }; + CP_A1200, CP_A2000, CP_A3000, CP_A3000T, CP_A4000, CP_A4000T }; #define IDE_A600A1200 1 #define IDE_A4000 2 struct uae_prefs { - struct strlist *all_lines; - - TCHAR description[256]; - TCHAR info[256]; - int config_version; - TCHAR config_hardware_path[MAX_DPATH]; - TCHAR config_host_path[MAX_DPATH]; - - int illegal_mem; - int no_xhair; - int use_serial; - int serial_demand; - int serial_hwctsrts; - int serial_direct; - int parallel_demand; - int parallel_matrix_emulation; - int parallel_postscript_emulation; - int parallel_postscript_detection; - int parallel_autoflush_time; - TCHAR ghostscript_parameters[256]; - int use_gfxlib; - int socket_emu; - - int start_debugger; - int start_gui; - - KbdLang keyboard_lang; - int test_drawing_speed; - - int produce_sound; - int sound_stereo; - int sound_stereo_separation; - int sound_mixed_stereo_delay; - int sound_freq; - int sound_maxbsiz; - int sound_latency; - int sound_interpol; - int sound_filter; - int sound_filter_type; - int sound_volume; - int sound_stereo_swap_paula; - int sound_stereo_swap_ahi; - int sound_auto; - - int comptrustbyte; - int comptrustword; - int comptrustlong; - int comptrustnaddr; - int compnf; - int compfpu; - int comp_midopt; - int comp_lowopt; - int fpu_strict; - - int comp_hardflush; - int comp_constjump; - int comp_oldsegv; - - int cachesize; - int optcount[10]; - - int avoid_cmov; - int avoid_dga; - int avoid_vid; - uae_u32 override_dga_address; - - int gfx_display; - TCHAR gfx_display_name[256]; - int gfx_framerate, gfx_autoframerate; - struct wh gfx_size_win; - struct wh gfx_size_fs; - struct wh gfx_size; - struct wh gfx_size_win_xtra[4]; - struct wh gfx_size_fs_xtra[4]; - int gfx_autoresolution; - int gfx_scandoubler; - int gfx_refreshrate; - int gfx_avsync, gfx_pvsync; - int gfx_resolution; - int gfx_lores_mode; - int gfx_linedbl; - int gfx_afullscreen, gfx_pfullscreen; - int gfx_xcenter, gfx_ycenter; - int gfx_xcenter_pos, gfx_ycenter_pos; - int gfx_xcenter_size, gfx_ycenter_size; - int gfx_max_horizontal, gfx_max_vertical; - int gfx_saturation, gfx_luminance, gfx_contrast, gfx_gamma; - int gfx_blackerthanblack; - int gfx_backbuffers; + struct strlist *all_lines; + + TCHAR description[256]; + TCHAR info[256]; + int config_version; + TCHAR config_hardware_path[MAX_DPATH]; + TCHAR config_host_path[MAX_DPATH]; + + bool illegal_mem; + bool use_serial; + bool serial_demand; + bool serial_hwctsrts; + bool serial_direct; + bool parallel_demand; + int parallel_matrix_emulation; + bool parallel_postscript_emulation; + bool parallel_postscript_detection; + int parallel_autoflush_time; + TCHAR ghostscript_parameters[256]; + bool use_gfxlib; + bool socket_emu; + + bool start_debugger; + bool start_gui; + + KbdLang keyboard_lang; + + int produce_sound; + int sound_stereo; + int sound_stereo_separation; + int sound_mixed_stereo_delay; + int sound_freq; + int sound_maxbsiz; + int sound_latency; + int sound_interpol; + int sound_filter; + int sound_filter_type; + int sound_volume; + bool sound_stereo_swap_paula; + bool sound_stereo_swap_ahi; + bool sound_auto; + + int comptrustbyte; + int comptrustword; + int comptrustlong; + int comptrustnaddr; + bool compnf; + bool compfpu; + bool comp_midopt; + bool comp_lowopt; + bool fpu_strict; + + bool comp_hardflush; + bool comp_constjump; + bool comp_oldsegv; + + int cachesize; + int optcount[10]; + + bool avoid_cmov; + + int gfx_display; + TCHAR gfx_display_name[256]; + int gfx_framerate, gfx_autoframerate; + struct wh gfx_size_win; + struct wh gfx_size_fs; + struct wh gfx_size; + struct wh gfx_size_win_xtra[4]; + struct wh gfx_size_fs_xtra[4]; + bool gfx_autoresolution; + bool gfx_scandoubler; + int gfx_refreshrate; + bool gfx_avsync, gfx_pvsync; + int gfx_resolution; + int gfx_lores_mode; + int gfx_linedbl; + int gfx_afullscreen, gfx_pfullscreen; + int gfx_xcenter, gfx_ycenter; + int gfx_xcenter_pos, gfx_ycenter_pos; + int gfx_xcenter_size, gfx_ycenter_size; + int gfx_max_horizontal, gfx_max_vertical; + int gfx_saturation, gfx_luminance, gfx_contrast, gfx_gamma; + bool gfx_blackerthanblack; + int gfx_backbuffers; int gfx_api; - int color_mode; + int color_mode; - int gfx_filter; - TCHAR gfx_filtershader[MAX_DPATH]; + int gfx_filter; + TCHAR gfx_filtershader[MAX_DPATH]; TCHAR gfx_filtermask[MAX_DPATH]; - int gfx_filter_scanlines; - int gfx_filter_scanlineratio; - int gfx_filter_scanlinelevel; - int gfx_filter_horiz_zoom, gfx_filter_vert_zoom; - int gfx_filter_horiz_zoom_mult, gfx_filter_vert_zoom_mult; - int gfx_filter_horiz_offset, gfx_filter_vert_offset; - int gfx_filter_filtermode; + int gfx_filter_scanlines; + int gfx_filter_scanlineratio; + int gfx_filter_scanlinelevel; + int gfx_filter_horiz_zoom, gfx_filter_vert_zoom; + int gfx_filter_horiz_zoom_mult, gfx_filter_vert_zoom_mult; + int gfx_filter_horiz_offset, gfx_filter_vert_offset; + int gfx_filter_filtermode; int gfx_filter_bilinear; - int gfx_filter_noise, gfx_filter_blur; - int gfx_filter_saturation, gfx_filter_luminance, gfx_filter_contrast, gfx_filter_gamma; - int gfx_filter_keep_aspect, gfx_filter_aspect; - int gfx_filter_autoscale; - - int immediate_blits; - unsigned int chipset_mask; - int ntscmode; - int genlock; - int chipset_refreshrate; - int collision_level; - int leds_on_screen; - int keyboard_leds[3]; - int keyboard_leds_in_use; - int scsi; - int sana2; - int uaeserial; - int catweasel; - int cpu_idle; - int cpu_cycle_exact; - int cpu_clock_multiplier; - int cpu_frequency; - int blitter_cycle_exact; - int floppy_speed; - int floppy_write_length; - int tod_hack; - uae_u32 maprom; - int turbo_emulation; - int headless; - - int cs_compatible; - int cs_ciaatod; - int cs_rtc; - int cs_rtc_adjust; - int cs_rtc_adjust_mode; - int cs_ksmirror_e0; - int cs_ksmirror_a8; - int cs_ciaoverlay; - int cs_cd32cd; - int cs_cd32c2p; - int cs_cd32nvram; - int cs_cdtvcd; - int cs_cdtvram; - int cs_cdtvcard; - int cs_ide; - int cs_pcmcia; - int cs_a1000ram; - int cs_fatgaryrev; - int cs_ramseyrev; - int cs_agnusrev; - int cs_deniserev; - int cs_mbdmac; - int cs_cdtvscsi; - int cs_a2091, cs_a4091; - int cs_df0idhw; - int cs_slowmemisfast; - int cs_resetwarning; - int cs_denisenoehb; - int cs_dipagnus; - int cs_agnusbltbusybug; - - TCHAR df[4][MAX_DPATH]; - TCHAR dfxlist[MAX_SPARE_DRIVES][MAX_DPATH]; - TCHAR romfile[MAX_DPATH]; - TCHAR romident[256]; - TCHAR romextfile[MAX_DPATH]; - TCHAR romextident[256]; - TCHAR flashfile[MAX_DPATH]; - TCHAR cartfile[MAX_DPATH]; - TCHAR cartident[256]; - int cart_internal; - TCHAR pci_devices[256]; - TCHAR prtname[256]; - TCHAR sername[256]; - TCHAR amaxromfile[MAX_DPATH]; - TCHAR a2065name[MAX_DPATH]; + int gfx_filter_noise, gfx_filter_blur; + int gfx_filter_saturation, gfx_filter_luminance, gfx_filter_contrast, gfx_filter_gamma; + int gfx_filter_keep_aspect, gfx_filter_aspect; + int gfx_filter_autoscale; + + bool immediate_blits; + unsigned int chipset_mask; + bool ntscmode; + bool genlock; + int chipset_refreshrate; + int collision_level; + int leds_on_screen; + int keyboard_leds[3]; + bool keyboard_leds_in_use; + int scsi; + bool sana2; + bool uaeserial; + int catweasel; + int cpu_idle; + bool cpu_cycle_exact; + int cpu_clock_multiplier; + int cpu_frequency; + bool blitter_cycle_exact; + int floppy_speed; + int floppy_write_length; + bool tod_hack; + uae_u32 maprom; + int turbo_emulation; + bool headless; + + int cs_compatible; + int cs_ciaatod; + int cs_rtc; + int cs_rtc_adjust; + int cs_rtc_adjust_mode; + bool cs_ksmirror_e0; + bool cs_ksmirror_a8; + bool cs_ciaoverlay; + bool cs_cd32cd; + bool cs_cd32c2p; + bool cs_cd32nvram; + bool cs_cdtvcd; + bool cs_cdtvram; + int cs_cdtvcard; + int cs_ide; + bool cs_pcmcia; + bool cs_a1000ram; + int cs_fatgaryrev; + int cs_ramseyrev; + int cs_agnusrev; + int cs_deniserev; + int cs_mbdmac; + bool cs_cdtvscsi; + bool cs_a2091, cs_a4091; + bool cs_df0idhw; + bool cs_slowmemisfast; + bool cs_resetwarning; + bool cs_denisenoehb; + bool cs_dipagnus; + bool cs_agnusbltbusybug; + + TCHAR df[4][MAX_DPATH]; + TCHAR dfxlist[MAX_SPARE_DRIVES][MAX_DPATH]; + TCHAR romfile[MAX_DPATH]; + TCHAR romident[256]; + TCHAR romextfile[MAX_DPATH]; + TCHAR romextident[256]; + TCHAR flashfile[MAX_DPATH]; + TCHAR cartfile[MAX_DPATH]; + TCHAR cartident[256]; + int cart_internal; + TCHAR pci_devices[256]; + TCHAR prtname[256]; + TCHAR sername[256]; + TCHAR amaxromfile[MAX_DPATH]; + TCHAR a2065name[MAX_DPATH]; TCHAR cdimagefile[MAX_DPATH]; - TCHAR path_floppy[256]; - TCHAR path_hardfile[256]; - TCHAR path_rom[256]; - - int m68k_speed; - int cpu_model; - int mmu_model; - int cpu060_revision; - int fpu_model; - int fpu_revision; - int cpu_compatible; - int address_space_24; - int picasso96_nocustom; - int picasso96_modeflags; - - uae_u32 z3fastmem_size, z3fastmem2_size; - uae_u32 z3fastmem_start; - uae_u32 fastmem_size; - uae_u32 chipmem_size; - uae_u32 bogomem_size; - uae_u32 mbresmem_low_size; - uae_u32 mbresmem_high_size; - uae_u32 gfxmem_size; - uae_u32 custom_memory_addrs[MAX_CUSTOM_MEMORY_ADDRS]; - uae_u32 custom_memory_sizes[MAX_CUSTOM_MEMORY_ADDRS]; - - int kickshifter; - int filesys_no_uaefsdb; - int filesys_custom_uaefsdb; - int mmkeyboard; - int uae_hide; - - int mountitems; - struct uaedev_config_info mountconfig[MOUNT_CONFIG_SIZE]; - - int nr_floppies; - int dfxtype[4]; - int dfxclick[4]; - TCHAR dfxclickexternal[4][256]; - int dfxclickvolume; - - /* Target specific options */ - int x11_use_low_bandwidth; - int x11_use_mitshm; - int x11_use_dgamode; - int x11_hide_cursor; - int svga_no_linear; - - int win32_middle_mouse; - int win32_logfile; - int win32_notaskbarbutton; - int win32_alwaysontop; - int win32_powersavedisabled; - int win32_minimize_inactive; - - int win32_active_priority; - int win32_inactive_priority; - int win32_inactive_pause; - int win32_inactive_nosound; - int win32_iconified_priority; - int win32_iconified_pause; - int win32_iconified_nosound; - - int win32_rtgmatchdepth; - int win32_rtgscaleifsmall; - int win32_rtgallowscaling; - int win32_rtgscaleaspectratio; - int win32_rtgvblankrate; - int win32_borderless; - int win32_ctrl_F11_is_quit; - int win32_automount_removable; - int win32_automount_drives; - int win32_automount_cddrives; - int win32_automount_netdrives; - int win32_automount_removabledrives; - int win32_midioutdev; - int win32_midiindev; - int win32_uaescsimode; - int win32_soundcard; + TCHAR path_floppy[256]; + TCHAR path_hardfile[256]; + TCHAR path_rom[256]; + + int m68k_speed; + int cpu_model; + int mmu_model; + int cpu060_revision; + int fpu_model; + int fpu_revision; + bool cpu_compatible; + bool address_space_24; + bool picasso96_nocustom; + int picasso96_modeflags; + + uae_u32 z3fastmem_size, z3fastmem2_size; + uae_u32 z3fastmem_start; + uae_u32 fastmem_size; + uae_u32 chipmem_size; + uae_u32 bogomem_size; + uae_u32 mbresmem_low_size; + uae_u32 mbresmem_high_size; + uae_u32 gfxmem_size; + uae_u32 custom_memory_addrs[MAX_CUSTOM_MEMORY_ADDRS]; + uae_u32 custom_memory_sizes[MAX_CUSTOM_MEMORY_ADDRS]; + + bool kickshifter; + bool filesys_no_uaefsdb; + bool filesys_custom_uaefsdb; + bool mmkeyboard; + int uae_hide; + + int mountitems; + struct uaedev_config_info mountconfig[MOUNT_CONFIG_SIZE]; + + int nr_floppies; + int dfxtype[4]; + int dfxclick[4]; + TCHAR dfxclickexternal[4][256]; + int dfxclickvolume; + + /* Target specific options */ + + bool win32_middle_mouse; + bool win32_logfile; + bool win32_notaskbarbutton; + bool win32_alwaysontop; + bool win32_powersavedisabled; + bool win32_minimize_inactive; + + int win32_active_priority; + int win32_inactive_priority; + bool win32_inactive_pause; + bool win32_inactive_nosound; + int win32_iconified_priority; + bool win32_iconified_pause; + bool win32_iconified_nosound; + + bool win32_rtgmatchdepth; + bool win32_rtgscaleifsmall; + bool win32_rtgallowscaling; + int win32_rtgscaleaspectratio; + int win32_rtgvblankrate; + bool win32_borderless; + bool win32_ctrl_F11_is_quit; + bool win32_automount_removable; + bool win32_automount_drives; + bool win32_automount_cddrives; + bool win32_automount_netdrives; + bool win32_automount_removabledrives; + int win32_midioutdev; + int win32_midiindev; + int win32_uaescsimode; + int win32_soundcard; int win32_samplersoundcard; - int win32_soundexclusive; - int win32_norecyclebin; - int win32_specialkey; - int win32_guikey; - int win32_kbledmode; - TCHAR win32_commandpathstart[MAX_DPATH]; - TCHAR win32_commandpathend[MAX_DPATH]; - - int curses_reverse_video; - - int statecapture; - int statecapturerate, statecapturebuffersize; - - /* input */ - - TCHAR inputname[256]; - struct jport jports[MAX_JPORTS]; - int input_selected_setting; - int input_joymouse_multiplier; - int input_joymouse_deadzone; - int input_joystick_deadzone; - int input_joymouse_speed; - int input_analog_joystick_mult; - int input_analog_joystick_offset; - int input_autofire_framecnt; - int input_mouse_speed; - int input_tablet; - int input_magic_mouse; - int input_magic_mouse_cursor; - struct uae_input_device joystick_settings[MAX_INPUT_SETTINGS + 1][MAX_INPUT_DEVICES]; - struct uae_input_device mouse_settings[MAX_INPUT_SETTINGS + 1][MAX_INPUT_DEVICES]; - struct uae_input_device keyboard_settings[MAX_INPUT_SETTINGS + 1][MAX_INPUT_DEVICES]; - int dongle; + bool win32_soundexclusive; + bool win32_norecyclebin; + int win32_specialkey; + int win32_guikey; + int win32_kbledmode; + TCHAR win32_commandpathstart[MAX_DPATH]; + TCHAR win32_commandpathend[MAX_DPATH]; + + bool statecapture; + int statecapturerate, statecapturebuffersize; + + /* input */ + + TCHAR inputname[256]; + struct jport jports[MAX_JPORTS]; + int input_selected_setting; + int input_joymouse_multiplier; + int input_joymouse_deadzone; + int input_joystick_deadzone; + int input_joymouse_speed; + int input_analog_joystick_mult; + int input_analog_joystick_offset; + int input_autofire_linecnt; + int input_mouse_speed; + int input_tablet; + bool input_magic_mouse; + int input_magic_mouse_cursor; + struct uae_input_device joystick_settings[MAX_INPUT_SETTINGS][MAX_INPUT_DEVICES]; + struct uae_input_device mouse_settings[MAX_INPUT_SETTINGS][MAX_INPUT_DEVICES]; + struct uae_input_device keyboard_settings[MAX_INPUT_SETTINGS][MAX_INPUT_DEVICES]; + int dongle; }; extern int config_changed; @@ -400,10 +392,10 @@ extern void cfgfile_dwrite (struct zfile *, const TCHAR *option, const TCHAR *fo extern void cfgfile_target_write (struct zfile *, const TCHAR *option, const TCHAR *format,...); extern void cfgfile_target_dwrite (struct zfile *, const TCHAR *option, const TCHAR *format,...); -extern void cfgfile_write_bool (struct zfile *f, const TCHAR *option, int b); -extern void cfgfile_dwrite_bool (struct zfile *f,const TCHAR *option, int b); -extern void cfgfile_target_write_bool (struct zfile *f, const TCHAR *option, int b); -extern void cfgfile_target_dwrite_bool (struct zfile *f, const TCHAR *option, int b); +extern void cfgfile_write_bool (struct zfile *f, const TCHAR *option, bool b); +extern void cfgfile_dwrite_bool (struct zfile *f,const TCHAR *option, bool b); +extern void cfgfile_target_write_bool (struct zfile *f, const TCHAR *option, bool b); +extern void cfgfile_target_dwrite_bool (struct zfile *f, const TCHAR *option, bool b); extern void cfgfile_write_str (struct zfile *f, const TCHAR *option, const TCHAR *value); extern void cfgfile_dwrite_str (struct zfile *f, const TCHAR *option, const TCHAR *value); @@ -412,16 +404,16 @@ extern void cfgfile_target_dwrite_str (struct zfile *f, const TCHAR *option, con extern void cfgfile_backup (const TCHAR *path); extern struct uaedev_config_info *add_filesys_config (struct uae_prefs *p, int index, - TCHAR *devname, TCHAR *volname, TCHAR *rootdir, int readonly, - int secspertrack, int surfaces, int reserved, - int blocksize, int bootpri, TCHAR *filesysdir, int hdc, int flags); + TCHAR *devname, TCHAR *volname, TCHAR *rootdir, bool readonly, + int secspertrack, int surfaces, int reserved, + int blocksize, int bootpri, TCHAR *filesysdir, int hdc, int flags); extern void default_prefs (struct uae_prefs *, int); extern void discard_prefs (struct uae_prefs *, int); int parse_cmdline_option (struct uae_prefs *, TCHAR, const TCHAR *); -extern int cfgfile_yesno (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location); +extern int cfgfile_yesno (const TCHAR *option, const TCHAR *value, const TCHAR *name, bool *location); extern int cfgfile_intval (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, int scale); extern int cfgfile_strval (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, const TCHAR *table[], int more); extern int cfgfile_string (const TCHAR *option, const TCHAR *value, const TCHAR *name, TCHAR *location, int maxsz); diff --git a/include/rommgr.h b/include/rommgr.h index ff7a314d..bd5db1b9 100644 --- a/include/rommgr.h +++ b/include/rommgr.h @@ -62,7 +62,7 @@ extern struct romlist **getarcadiaroms (void); extern struct romdata *getarcadiarombyname (TCHAR *name); extern struct romlist **getromlistbyident (int ver, int rev, int subver, int subrev, TCHAR *model, int all); extern void getromname (struct romdata*, TCHAR*); -extern struct romdata *getromdatabyname (TCHAR*); +extern struct romdata *getromdatabyname (const TCHAR*); extern struct romlist *getromlistbyids (int *ids); extern void romwarning(int *ids); extern struct romlist *getromlistbyromdata (struct romdata *rd); diff --git a/include/uae.h b/include/uae.h index bfb49238..43c92f32 100644 --- a/include/uae.h +++ b/include/uae.h @@ -27,7 +27,7 @@ extern void target_run (void); extern void target_quit (void); extern int quit_program; -extern int console_emulation; +extern bool console_emulation; extern TCHAR warning_buffer[256]; extern TCHAR start_path_data[]; diff --git a/include/xwin.h b/include/xwin.h index 6f780d7d..bdc08f08 100644 --- a/include/xwin.h +++ b/include/xwin.h @@ -25,7 +25,7 @@ extern int isfullscreen (void); extern void toggle_fullscreen (void); extern void toggle_mousegrab (void); extern void desktop_coords (int *dw, int *dh, int *x, int *y, int *w, int *h); -extern int vsync_switchmode (int, int); +extern bool vsync_switchmode (int, int); extern void doflashscreen (void); extern int flashscreen; extern void updatedisplayarea (void); diff --git a/include/zarchive.h b/include/zarchive.h index 8005dab1..309e37bd 100644 --- a/include/zarchive.h +++ b/include/zarchive.h @@ -7,17 +7,19 @@ struct zfile { TCHAR *name; TCHAR *zipname; TCHAR *mode; - FILE *f; - uae_u8 *data; - int dataseek; - uae_s64 size; - uae_s64 seek; + FILE *f; // real file handle if physical file + uae_u8 *data; // unpacked data + int dataseek; // use seek position even if real file + struct zfile *archiveparent; // set if parent is archive and this has not yet been unpacked (datasize < size) + uae_s64 size; // real size + uae_s64 datasize; // available size (not yet unpacked completely?) + uae_s64 seek; // seek position int deleteafterclose; int textmode; struct zfile *next; int zfdmask; struct zfile *parent; - uae_u64 offset; + uae_u64 offset; // byte offset from parent file int opencnt; ZFILEREAD zfileread; ZFILEWRITE zfilewrite; @@ -81,6 +83,7 @@ struct zarchive_info }; #define ArchiveFormat7Zip '7z ' +#define ArchiveFormatXZ 'xz ' #define ArchiveFormatRAR 'rar ' #define ArchiveFormatZIP 'zip ' #define ArchiveFormatLHA 'lha ' @@ -94,6 +97,8 @@ struct zarchive_info #define ArchiveFormatFAT 'FAT ' #define ArchiveFormatTAR 'tar ' +#define PEEK_BYTES 1024 + extern int zfile_is_ignore_ext(const TCHAR *name); extern struct zvolume *zvolume_alloc(struct zfile *z, unsigned int id, void *handle, const TCHAR*); @@ -108,9 +113,11 @@ extern struct zfile *archive_access_plain (struct znode *zn); extern struct zvolume *archive_directory_lha(struct zfile *zf); extern struct zfile *archive_access_lha (struct znode *zn); extern struct zvolume *archive_directory_zip(struct zfile *zf); -extern struct zfile *archive_access_zip (struct znode *zn); +extern struct zfile *archive_access_zip (struct znode *zn, int flags); extern struct zvolume *archive_directory_7z (struct zfile *z); extern struct zfile *archive_access_7z (struct znode *zn); +extern struct zvolume *archive_directory_xz (struct zfile *z); +extern struct zfile *archive_access_xz (struct znode *zn); extern struct zvolume *archive_directory_rar (struct zfile *z); extern struct zfile *archive_access_rar (struct znode *zn); extern struct zvolume *archive_directory_lzx (struct zfile *in_file); @@ -135,6 +142,6 @@ extern void archive_access_scan (struct zfile *zf, zfile_callback zc, void *user extern void archive_access_close (void *handle, unsigned int id); -extern struct zfile *archive_getzfile(struct znode *zn, unsigned int id); +extern struct zfile *archive_getzfile(struct znode *zn, unsigned int id, int flags); extern struct zfile *decompress_zfd (struct zfile*); \ No newline at end of file diff --git a/include/zfile.h b/include/zfile.h index 5ccb9a89..325e134b 100644 --- a/include/zfile.h +++ b/include/zfile.h @@ -74,6 +74,7 @@ extern TCHAR *zfile_geterror (void); #define ZFD_HD 4 //rdb/hdf #define ZFD_UNPACK 8 //gzip,dms #define ZFD_RAWDISK 16 //fdi->adf,ipf->adf etc.. +#define ZFD_CD 32 //cue/iso, cue has priority over iso #define ZFD_DISKHISTORY 0x100 //allow diskhistory (if disk image) #define ZFD_CHECKONLY 0x200 //file exists checkc #define ZFD_NORMAL (ZFD_ARCHIVE|ZFD_UNPACK) diff --git a/inputdevice.cpp b/inputdevice.cpp index 4cedf82b..7db48564 100644 --- a/inputdevice.cpp +++ b/inputdevice.cpp @@ -66,16 +66,6 @@ int inputdevice_logging = 0; #define IE_INVERT 0x80 #define IE_CDTV 0x100 -struct inputevent { - const TCHAR *confname; - const TCHAR *name; - int allow_mask; - int type; - int unit; - int data; -}; - - #define JOYBUTTON_1 0 /* fire/left mousebutton */ #define JOYBUTTON_2 1 /* 2nd/right mousebutton */ #define JOYBUTTON_3 2 /* 3rd/middle mousebutton */ @@ -106,14 +96,8 @@ struct inputevent { #define JOYMOUSE_CDTV 8 -/* event flags */ -#define ID_FLAG_AUTOFIRE 1 -#define ID_FLAG_TOGGLE 2 -#define ID_FLAG_SAVE_MASK 0xff -#define ID_FLAG_TOGGLED 0x100 - #define DEFEVENT(A, B, C, D, E, F) {L#A, B, C, D, E, F }, -struct inputevent events[] = { +static struct inputevent events[] = { {0, 0, AM_K,0,0,0}, #include "inputevents.def" {0, 0, 0, 0, 0, 0} @@ -132,7 +116,19 @@ static struct uae_input_device2 mice2[MAX_INPUT_DEVICES]; static uae_u8 scancodeused[MAX_INPUT_DEVICES][256]; static int input_acquired; -static int testmode; +static int testmode, testmode_read, testmode_toggle; +struct teststore +{ + int testmode_type; + int testmode_num; + int testmode_wtype; + int testmode_wnum; + int testmode_state; +}; +#define TESTMODE_MAX 2 +static int testmode_count; +static struct teststore testmode_data[TESTMODE_MAX]; +static struct teststore testmode_wait[TESTMODE_MAX]; static uae_u8 *inprec_buffer, *inprec_p; static struct zfile *inprec_zf; @@ -398,6 +394,16 @@ static struct uae_input_device *joysticks; static struct uae_input_device *mice; static struct uae_input_device *keyboards; static struct uae_input_device_kbr_default *keyboard_default; +#define KBR_DEFAULT_MAP_NP 0 +#define KBR_DEFAULT_MAP_CK 1 +#define KBR_DEFAULT_MAP_SE 2 +#define KBR_DEFAULT_MAP_CD32_NP 3 +#define KBR_DEFAULT_MAP_CD32_CK 4 +#define KBR_DEFAULT_MAP_CD32_SE 5 +#define KBR_DEFAULT_MAP_XA1 6 +#define KBR_DEFAULT_MAP_XA2 7 +#define KBR_DEFAULT_MAP_ARCADIA 8 +#define KBR_DEFAULT_MAP_ARCADIA_XA 9 static int **keyboard_default_kbmaps; static int mouse_axis[MAX_INPUT_DEVICES][MAX_INPUT_DEVICE_EVENTS]; @@ -433,7 +439,7 @@ static int use_keyboards[MAX_INPUT_DEVICES]; #define INPUT_QUEUE_SIZE 16 struct input_queue_struct { - int event, storedstate, state, max, framecnt, nextframecnt; + int event, storedstate, state, max, linecnt, nextlinecnt; }; static struct input_queue_struct input_queue[INPUT_QUEUE_SIZE]; @@ -459,6 +465,59 @@ static void out_config (struct zfile *f, int id, int num, TCHAR *s1, TCHAR *s2) cfgfile_write_str (f, tmp, s2); } +static bool write_config_head (struct zfile *f, int idnum, int devnum, TCHAR *name, struct uae_input_device *id, struct inputdevice_functions *idf) +{ + TCHAR tmp2[MAX_DPATH]; + + if (idnum == GAMEPORT_INPUT_SETTINGS) { + if (!isdevice (id)) + return false; + if (!id->enabled) + return false; + } + + TCHAR *s = NULL; + if (id->name) + s = id->name; + else if (devnum < idf->get_num ()) + s = idf->get_friendlyname (devnum); + if (s) { + _stprintf (tmp2, L"input.%d.%s.%d.friendlyname", idnum + 1, name, devnum); + cfgfile_write_str (f, tmp2, s); + } + + s = NULL; + if (id->configname) + s = id->configname; + else if (devnum < idf->get_num ()) + s = idf->get_uniquename (devnum); + if (s) { + _stprintf (tmp2, L"input.%d.%s.%d.name", idnum + 1, name, devnum); + cfgfile_write_str (f, tmp2, s); + } + + if (!isdevice (id)) { + _stprintf (tmp2, L"input.%d.%s.%d.empty", idnum + 1, name, devnum); + cfgfile_write_bool (f, tmp2, true); + if (id->enabled) { + _stprintf (tmp2, L"input.%d.%s.%d.disabled", idnum + 1, name, devnum); + cfgfile_write (f, tmp2, L"%d", id->enabled ? 0 : 1); + } + return false; + } + + if (idnum == GAMEPORT_INPUT_SETTINGS) { + _stprintf (tmp2, L"input.%d.%s.%d.custom", idnum + 1, name, devnum); + cfgfile_write_bool (f, tmp2, true); + } else { + _stprintf (tmp2, L"input.%d.%s.%d.empty", idnum + 1, name, devnum); + cfgfile_write_bool (f, tmp2, false); + _stprintf (tmp2, L"input.%d.%s.%d.disabled", idnum + 1, name, devnum); + cfgfile_write (f, tmp2, L"%d", id->enabled ? 0 : 1); + } + return true; +} + static void write_config2 (struct zfile *f, int idnum, int i, int offset, TCHAR *tmp1, struct uae_input_device *id) { TCHAR tmp2[200], tmp3[200], *p; @@ -487,11 +546,11 @@ static void write_config2 (struct zfile *f, int idnum, int i, int offset, TCHAR else if (evt <= 0) _stprintf (p, L"NULL"); else - _stprintf (p, L"%s.%d", events[evt].confname, id->flags[i + offset][j]); + _stprintf (p, L"%s.%d", events[evt].confname, id->flags[i + offset][j] & ID_FLAG_SAVE_MASK); p += _tcslen (p); } if (p > tmp2) { - _stprintf (tmp3, L"input.%d.%s%d", idnum, tmp1, i); + _stprintf (tmp3, L"input.%d.%s%d", idnum + 1, tmp1, i); cfgfile_write_str (f, tmp3, tmp2); } } @@ -500,43 +559,11 @@ static struct inputdevice_functions *getidf (int devnum); static void write_config (struct zfile *f, int idnum, int devnum, TCHAR *name, struct uae_input_device *id, struct uae_input_device2 *id2, struct inputdevice_functions *idf) { - TCHAR tmp1[MAX_DPATH], tmp2[MAX_DPATH], *s; + TCHAR tmp1[MAX_DPATH]; int i; - if (!isdevice (id)) { - _stprintf (tmp2, L"input.%d.%s.%d.empty", idnum, name, devnum); - cfgfile_write_bool (f, tmp2, 1); - if (id->enabled) { - _stprintf (tmp2, L"input.%d.%s.%d.disabled", idnum, name, devnum); - cfgfile_write (f, tmp2, L"%d", id->enabled ? 0 : 1); - } + if (!write_config_head (f, idnum, devnum, name, id, idf)) return; - } - - _stprintf (tmp2, L"input.%d.%s.%d.empty", idnum, name, devnum); - cfgfile_write_bool (f, tmp2, 0); - _stprintf (tmp2, L"input.%d.%s.%d.disabled", idnum, name, devnum); - cfgfile_write (f, tmp2, L"%d", id->enabled ? 0 : 1); - - s = NULL; - if (id->name) - s = id->name; - else if (devnum < idf->get_num ()) - s = idf->get_friendlyname (devnum); - if (s) { - _stprintf (tmp2, L"input.%d.%s.%d.friendlyname", idnum, name, devnum); - cfgfile_write_str (f, tmp2, s); - } - - s = NULL; - if (id->configname) - s = id->configname; - else if (devnum < idf->get_num ()) - s = idf->get_uniquename (devnum); - if (s) { - _stprintf (tmp2, L"input.%d.%s.%d.name", idnum, name, devnum); - cfgfile_write_str (f, tmp2, s); - } _stprintf (tmp1, L"%s.%d.axis.", name, devnum); for (i = 0; i < ID_AXIS_TOTAL; i++) @@ -563,6 +590,10 @@ static void write_kbr_config (struct zfile *f, int idnum, int devnum, struct uae if (!keyboard_default) return; + + if (!write_config_head (f, idnum, devnum, L"keyboard", kbr, idf)) + return; + i = 0; while (i < MAX_INPUT_DEVICE_EVENTS && kbr->extra[i][0] >= 0) { skip = 0; @@ -571,16 +602,16 @@ static void write_kbr_config (struct zfile *f, int idnum, int devnum, struct uae if (keyboard_default[k].scancode == kbr->extra[i][0]) { skip = 1; for (j = 1; j < MAX_INPUT_SUB_EVENT; j++) { - if (kbr->flags[i][j] || kbr->eventid[i][j] > 0) + if ((kbr->flags[i][j] & ID_FLAG_SAVE_MASK) != 0 || kbr->eventid[i][j] > 0) skip = 0; } - if (keyboard_default[k].event != kbr->eventid[i][0] || kbr->flags[i][0] != 0) + if (keyboard_default[k].evt != kbr->eventid[i][0] || keyboard_default[k].flags != (kbr->flags[i][0] & ID_FLAG_SAVE_MASK)) skip = 0; break; } k++; } - if (kbr->eventid[i][0] == 0 && kbr->flags[i][0] == 0 && keyboard_default[k].scancode < 0) + if (kbr->eventid[i][0] == 0 && (kbr->flags[i][0] & ID_FLAG_SAVE_MASK) == 0 && keyboard_default[k].scancode < 0) skip = 1; if (skip) { i++; @@ -604,9 +635,9 @@ static void write_kbr_config (struct zfile *f, int idnum, int devnum, struct uae *p = 0; } if (custom && _tcslen (custom) > 0) - _stprintf (p, L"'%s'.%d", custom, kbr->flags[i][j] & 0xff); + _stprintf (p, L"'%s'.%d", custom, kbr->flags[i][j] & ID_FLAG_SAVE_MASK); else if (evt > 0) - _stprintf (p, L"%s.%d", events[evt].confname, kbr->flags[i][j]); + _stprintf (p, L"%s.%d", events[evt].confname, kbr->flags[i][j] & ID_FLAG_SAVE_MASK); else _tcscat (p, L"NULL"); p += _tcslen(p); @@ -614,7 +645,7 @@ static void write_kbr_config (struct zfile *f, int idnum, int devnum, struct uae _stprintf (tmp3, L"%d", kbr->extra[i][0]); kbrlabel (tmp3); _stprintf (tmp1, L"keyboard.%d.button.%s", devnum, tmp3); - _stprintf (tmp4, L"input.%d.%s", idnum, tmp1); + _stprintf (tmp4, L"input.%d.%s", idnum + 1, tmp1); cfgfile_write_str (f, tmp4, tmp2[0] ? tmp2 : L"NULL"); i++; } @@ -624,7 +655,7 @@ void write_inputdevice_config (struct uae_prefs *p, struct zfile *f) { int i, id; - cfgfile_write (f, L"input.config", L"%d", p->input_selected_setting); + cfgfile_write (f, L"input.config", L"%d", p->input_selected_setting + 1); cfgfile_write (f, L"input.joymouse_speed_analog", L"%d", p->input_joymouse_multiplier); cfgfile_write (f, L"input.joymouse_speed_digital", L"%d", p->input_joymouse_speed); cfgfile_write (f, L"input.joymouse_deadzone", L"%d", p->input_joymouse_deadzone); @@ -632,8 +663,8 @@ void write_inputdevice_config (struct uae_prefs *p, struct zfile *f) cfgfile_write (f, L"input.analog_joystick_multiplier", L"%d", p->input_analog_joystick_mult); cfgfile_write (f, L"input.analog_joystick_offset", L"%d", p->input_analog_joystick_offset); cfgfile_write (f, L"input.mouse_speed", L"%d", p->input_mouse_speed); - cfgfile_write (f, L"input.autofire", L"%d", p->input_autofire_framecnt); - for (id = 1; id <= MAX_INPUT_SETTINGS; id++) { + cfgfile_write (f, L"input.autofire_speed", L"%d", p->input_autofire_linecnt); + for (id = 0; id < MAX_INPUT_SETTINGS; id++) { for (i = 0; i < MAX_INPUT_DEVICES; i++) write_config (f, id, i, L"joystick", &p->joystick_settings[id][i], &joysticks2[i], &idev[IDTYPE_JOYSTICK]); for (i = 0; i < MAX_INPUT_DEVICES; i++) @@ -673,10 +704,81 @@ static TCHAR *getstring (TCHAR **pp) return str; } -void reset_inputdevice_config (struct uae_prefs *pr) +static void reset_inputdevice_settings (struct uae_input_device *uid) +{ + for (int l = 0; l < MAX_INPUT_DEVICE_EVENTS; l++) { + for (int i = 0; i < MAX_INPUT_SUB_EVENT; i++) { + uid->eventid[l][i] = 0; + uid->flags[l][i] = 0; + xfree (uid->custom[l][i]); + uid->custom[l][i] = NULL; + } + } +} +static void reset_inputdevice_slot (struct uae_prefs *prefs, int slot) +{ + for (int m = 0; m < MAX_INPUT_DEVICES; m++) { + reset_inputdevice_settings (&prefs->joystick_settings[slot][m]); + reset_inputdevice_settings (&prefs->mouse_settings[slot][m]); + reset_inputdevice_settings (&prefs->keyboard_settings[slot][m]); + } +} +void reset_inputdevice_config (struct uae_prefs *prefs) { + for (int i = 0; i< MAX_INPUT_SETTINGS; i++) + reset_inputdevice_slot (prefs, i); } + +static void set_kbr_default_event (struct uae_input_device *kbr, struct uae_input_device_kbr_default *trans, int num) +{ + for (int i = 0; trans[i].scancode >= 0; i++) { + if (kbr->extra[num][0] == trans[i].scancode) { + int k; + for (k = 0; k < MAX_INPUT_SUB_EVENT; k++) { + if (kbr->eventid[num][k] == 0) + break; + } + if (k == MAX_INPUT_SUB_EVENT) { + write_log (L"corrupt default keyboard mappings\n"); + return; + } + kbr->eventid[num][k] = trans[i].evt; + kbr->flags[num][k] = trans[i].flags; + break; + } + } +} + +static void set_kbr_default (struct uae_prefs *p, int index) +{ + int i, j; + struct uae_input_device_kbr_default *trans = keyboard_default; + struct uae_input_device *kbr; + struct inputdevice_functions *id = &idev[IDTYPE_KEYBOARD]; + uae_u32 scancode; + + if (!trans) + return; + for (j = 0; j < MAX_INPUT_DEVICES; j++) { + kbr = &p->keyboard_settings[index][j]; + for (i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) { + memset (kbr, 0, sizeof (struct uae_input_device)); + kbr->extra[i][0] = -1; + } + if (j < id->get_num ()) { + if (input_get_default_keyboard (j)) + kbr->enabled = 1; + for (i = 0; i < id->get_widget_num (j); i++) { + id->get_widget_type (j, i, 0, &scancode); + kbr->extra[i][0] = scancode; + set_kbr_default_event (kbr, trans, i); + } + } + } +} + + static void clear_id (struct uae_input_device *id) { #ifndef _DEBUG @@ -701,8 +803,13 @@ void read_inputdevice_config (struct uae_prefs *pr, TCHAR *option, TCHAR *value) option += 6; /* "input." */ p = getstring (&option); - if (!strcasecmp (p, L"config")) - pr->input_selected_setting = _tstol (value); + if (!strcasecmp (p, L"config")) { + pr->input_selected_setting = _tstol (value) - 1; + if (pr->input_selected_setting == -1) + pr->input_selected_setting = GAMEPORT_INPUT_SETTINGS; + if (pr->input_selected_setting < 0 || pr->input_selected_setting > MAX_INPUT_SETTINGS) + pr->input_selected_setting = 0; + } if (!strcasecmp (p, L"joymouse_speed_analog")) pr->input_joymouse_multiplier = _tstol (value); if (!strcasecmp (p, L"joymouse_speed_digital")) @@ -713,8 +820,8 @@ void read_inputdevice_config (struct uae_prefs *pr, TCHAR *option, TCHAR *value) pr->input_joymouse_deadzone = _tstol (value); if (!strcasecmp (p, L"mouse_speed")) pr->input_mouse_speed = _tstol (value); - if (!strcasecmp (p, L"autofire")) - pr->input_autofire_framecnt = _tstol (value); + if (!strcasecmp (p, L"autofire_speed")) + pr->input_autofire_linecnt = _tstol (value); if (!strcasecmp (p, L"analog_joystick_multiplier")) pr->input_analog_joystick_mult = _tstol (value); if (!strcasecmp (p, L"analog_joystick_offset")) @@ -723,6 +830,7 @@ void read_inputdevice_config (struct uae_prefs *pr, TCHAR *option, TCHAR *value) idnum = _tstol (p); if (idnum <= 0 || idnum > MAX_INPUT_SETTINGS) return; + idnum--; if (_tcsncmp (option, L"mouse.", 6) == 0) { p = option + 6; @@ -765,9 +873,24 @@ void read_inputdevice_config (struct uae_prefs *pr, TCHAR *option, TCHAR *value) return; } + if (!_tcscmp (p2, L"custom")) { + int disabled; + p = value; + disabled = getnum (&p); + if (idnum == GAMEPORT_INPUT_SETTINGS) { + clear_id (id); + if (joystick < 0) + set_kbr_default (pr, idnum); + id->enabled = disabled == 0 ? 1 : 0; + } + return; + } + if (!_tcscmp (p2, L"empty")) { clear_id (id); id->enabled = 1; + if (idnum == GAMEPORT_INPUT_SETTINGS) + id->enabled = 0; return; } @@ -776,18 +899,21 @@ void read_inputdevice_config (struct uae_prefs *pr, TCHAR *option, TCHAR *value) p = value; disabled = getnum (&p); id->enabled = disabled == 0 ? 1 : 0; + if (idnum == GAMEPORT_INPUT_SETTINGS) + id->enabled = 0; return; } + if (idnum == GAMEPORT_INPUT_SETTINGS && id->enabled == 0) + return; + if (joystick < 0) { num = getnum (&p); - keynum = 0; - while (id->extra[keynum][0] >= 0) { + for (keynum = 0; keynum < MAX_INPUT_DEVICE_EVENTS; keynum++) { if (id->extra[keynum][0] == num) break; - keynum++; } - if (id->extra[keynum][0] < 0) + if (keynum >= MAX_INPUT_DEVICE_EVENTS) return; } else { button = -1; @@ -1968,6 +2094,16 @@ static uae_u16 handle_joystick_potgor (uae_u16 potgor) static int inputdelay; +void inputdevice_read (void) +{ + do { + handle_msgpump (); + idev[IDTYPE_MOUSE].read (); + idev[IDTYPE_JOYSTICK].read (); + idev[IDTYPE_KEYBOARD].read (); + } while (handle_msgpump ()); +} + void inputdevice_hsync (void) { static int cnt; @@ -1976,17 +2112,28 @@ void inputdevice_hsync (void) #ifdef CATWEASEL catweasel_hsync (); #endif - if ((++cnt & 63) == 63 && handle_msgpump ()) { - idev[IDTYPE_MOUSE].read (); - idev[IDTYPE_JOYSTICK].read (); - idev[IDTYPE_KEYBOARD].read (); + + for (int i = 0; i < INPUT_QUEUE_SIZE; i++) { + struct input_queue_struct *iq = &input_queue[i]; + if (iq->linecnt > 0) { + iq->linecnt--; + if (iq->linecnt == 0) { + if (iq->state) + iq->state = 0; + else + iq->state = iq->storedstate; + handle_input_event (iq->event, iq->state, iq->max, 0); + iq->linecnt = iq->nextlinecnt; + } + } } - if (inputdelay > 0) { + + if ((++cnt & 63) == 63 ) { + inputdevice_read (); + } else if (inputdelay > 0) { inputdelay--; - if (inputdelay == 0) { - idev[IDTYPE_JOYSTICK].read (); - idev[IDTYPE_KEYBOARD].read (); - } + if (inputdelay == 0) + inputdevice_read (); } } @@ -2080,7 +2227,7 @@ static int check_input_queue (int event) return -1; } -static void queue_input_event (int event, int state, int max, int framecnt, int autofire) +static void queue_input_event (int event, int state, int max, int linecnt, int autofire) { struct input_queue_struct *iq; int i = check_input_queue (event); @@ -2089,15 +2236,15 @@ static void queue_input_event (int event, int state, int max, int framecnt, int return; if (state < 0 && i >= 0) { iq = &input_queue[i]; - iq->nextframecnt = -1; - iq->framecnt = -1; + iq->nextlinecnt = -1; + iq->linecnt = -1; iq->event = 0; if (iq->state == 0) handle_input_event (event, 0, 1, 0); } else if (i < 0) { for (i = 0; i < INPUT_QUEUE_SIZE; i++) { iq = &input_queue[i]; - if (iq->framecnt < 0) + if (iq->linecnt < 0) break; } if (i == INPUT_QUEUE_SIZE) { @@ -2107,8 +2254,8 @@ static void queue_input_event (int event, int state, int max, int framecnt, int iq->event = event; iq->state = iq->storedstate = state; iq->max = max; - iq->framecnt = framecnt; - iq->nextframecnt = autofire > 0 ? framecnt : -1; + iq->linecnt = linecnt; + iq->nextlinecnt = autofire > 0 ? linecnt : -1; } } @@ -2361,7 +2508,7 @@ void inputdevice_handle_inputcode (void) case AKS_INPUT_CONFIG_2: case AKS_INPUT_CONFIG_3: case AKS_INPUT_CONFIG_4: - changed_prefs.input_selected_setting = currprefs.input_selected_setting = code - AKS_INPUT_CONFIG_1 + 1; + changed_prefs.input_selected_setting = currprefs.input_selected_setting = code - AKS_INPUT_CONFIG_1; inputdevice_updateconfig (&currprefs); break; case AKS_DISK_PREV0: @@ -2416,10 +2563,10 @@ int handle_input_event (int nr, int state, int max, int autofire) return 0; ie = &events[nr]; if (inputdevice_logging & 1) - write_log (L"'%s' %d %d\n", ie->name, state, max); + write_log (L"'%s' STATE=%d MAX=%d AF=%d\n", ie->name, state, max, autofire); if (autofire) { if (state) - queue_input_event (nr, state, max, currprefs.input_autofire_framecnt, 1); + queue_input_event (nr, state, max, currprefs.input_autofire_linecnt, 1); else queue_input_event (nr, -1, 0, 0, 1); } @@ -2612,7 +2759,7 @@ static void inputdevice_checkconfig (void) currprefs.input_joymouse_deadzone != changed_prefs.input_joymouse_deadzone || currprefs.input_joystick_deadzone != changed_prefs.input_joystick_deadzone || currprefs.input_joymouse_speed != changed_prefs.input_joymouse_speed || - currprefs.input_autofire_framecnt != changed_prefs.input_autofire_framecnt || + currprefs.input_autofire_linecnt != changed_prefs.input_autofire_linecnt || currprefs.input_mouse_speed != changed_prefs.input_mouse_speed) { currprefs.input_selected_setting = changed_prefs.input_selected_setting; @@ -2620,7 +2767,7 @@ static void inputdevice_checkconfig (void) currprefs.input_joymouse_deadzone = changed_prefs.input_joymouse_deadzone; currprefs.input_joystick_deadzone = changed_prefs.input_joystick_deadzone; currprefs.input_joymouse_speed = changed_prefs.input_joymouse_speed; - currprefs.input_autofire_framecnt = changed_prefs.input_autofire_framecnt; + currprefs.input_autofire_linecnt = changed_prefs.input_autofire_linecnt; currprefs.input_mouse_speed = changed_prefs.input_mouse_speed; inputdevice_updateconfig (&currprefs); @@ -2633,31 +2780,12 @@ static void inputdevice_checkconfig (void) void inputdevice_vsync (void) { - struct input_queue_struct *iq; - int i; - if (inputdevice_logging & 32) write_log (L"*\n"); - for (i = 0; i < INPUT_QUEUE_SIZE; i++) { - iq = &input_queue[i]; - if (iq->framecnt > 0) { - iq->framecnt--; - if (iq->framecnt == 0) { - if (iq->state) - iq->state = 0; - else - iq->state = iq->storedstate; - handle_input_event (iq->event, iq->state, iq->max, 0); - iq->framecnt = iq->nextframecnt; - } - } - } - input_frame++; mouseupdate (0, 1); - idev[IDTYPE_MOUSE].read (); - idev[IDTYPE_JOYSTICK].read (); + inputdevice_read (); inputdelay = uaerand () % (maxvpos <= 1 ? 1 : maxvpos - 1); inputdevice_handle_inputcode (); @@ -2747,7 +2875,7 @@ static int switchdevice (struct uae_input_device *id, int num, int button) return 0; if (num == 0 && otherbuttonpressed) newport = newport ? 0 : 1; - if (!currprefs.input_selected_setting) { + if (currprefs.input_selected_setting == GAMEPORT_INPUT_SETTINGS) { if (num == 0 || num == 1) { int om = jsem_ismouse (num, &currprefs); int om1 = jsem_ismouse (0, &currprefs); @@ -2766,7 +2894,7 @@ static int switchdevice (struct uae_input_device *id, int num, int button) return 0; } else { int oldport = getoldport (id); - int i, j, k, evt; + int k, evt; struct inputevent *ie, *ie2; if (flags) @@ -2776,12 +2904,12 @@ static int switchdevice (struct uae_input_device *id, int num, int button) newport++; /* do not switch if switching mouse and any "supermouse" mouse enabled */ if (ismouse) { - for (i = 0; i < MAX_INPUT_SETTINGS + 1; i++) { + for (i = 0; i < MAX_INPUT_SETTINGS; i++) { if (mice[i].enabled && idev[IDTYPE_MOUSE].get_flags (i)) return 0; } } - for (i = 0; i < MAX_INPUT_SETTINGS + 1; i++) { + for (i = 0; i < MAX_INPUT_SETTINGS; i++) { if (getoldport (&joysticks[i]) == newport) joysticks[i].enabled = 0; if (getoldport (&mice[i]) == newport) @@ -3068,7 +3196,7 @@ static void scanevents (struct uae_prefs *p) use_keyboards[i] = 0; if (keyboards[i].enabled && i < idev[IDTYPE_KEYBOARD].get_num()) { j = 0; - while (keyboards[i].extra[j][0] >= 0) { + while (j < MAX_INPUT_DEVICE_EVENTS && keyboards[i].extra[j][0] >= 0) { use_keyboards[i] = 1; for (k = 0; k < MAX_INPUT_SUB_EVENT; k++) { ei = keyboards[i].eventid[j][k]; @@ -3085,60 +3213,163 @@ static void scanevents (struct uae_prefs *p) } } -#ifdef CD32 -static void setcd32 (int joy, int n) +static int axistable[] = { + INPUTEVENT_MOUSE1_HORIZ, INPUTEVENT_MOUSE1_LEFT, INPUTEVENT_MOUSE1_RIGHT, + INPUTEVENT_MOUSE1_VERT, INPUTEVENT_MOUSE1_UP, INPUTEVENT_MOUSE1_DOWN, + INPUTEVENT_MOUSE2_HORIZ, INPUTEVENT_MOUSE2_LEFT, INPUTEVENT_MOUSE2_RIGHT, + INPUTEVENT_MOUSE2_VERT, INPUTEVENT_MOUSE2_UP, INPUTEVENT_MOUSE2_DOWN, + INPUTEVENT_JOY1_HORIZ, INPUTEVENT_JOY1_LEFT, INPUTEVENT_JOY1_RIGHT, + INPUTEVENT_JOY1_VERT, INPUTEVENT_JOY1_UP, INPUTEVENT_JOY1_DOWN, + INPUTEVENT_JOY2_HORIZ, INPUTEVENT_JOY2_LEFT, INPUTEVENT_JOY2_RIGHT, + INPUTEVENT_JOY2_VERT, INPUTEVENT_JOY2_UP, INPUTEVENT_JOY2_DOWN, + INPUTEVENT_LIGHTPEN_HORIZ, INPUTEVENT_LIGHTPEN_LEFT, INPUTEVENT_LIGHTPEN_RIGHT, + INPUTEVENT_LIGHTPEN_VERT, INPUTEVENT_LIGHTPEN_UP, INPUTEVENT_LIGHTPEN_DOWN, + INPUTEVENT_PAR_JOY1_HORIZ, INPUTEVENT_PAR_JOY1_LEFT, INPUTEVENT_PAR_JOY1_RIGHT, + INPUTEVENT_PAR_JOY1_VERT, INPUTEVENT_PAR_JOY1_UP, INPUTEVENT_PAR_JOY1_DOWN, + INPUTEVENT_PAR_JOY2_HORIZ, INPUTEVENT_PAR_JOY2_LEFT, INPUTEVENT_PAR_JOY2_RIGHT, + INPUTEVENT_PAR_JOY2_VERT, INPUTEVENT_PAR_JOY2_UP, INPUTEVENT_PAR_JOY2_DOWN, + INPUTEVENT_MOUSE_CDTV_HORIZ, INPUTEVENT_MOUSE_CDTV_LEFT, INPUTEVENT_MOUSE_CDTV_RIGHT, + INPUTEVENT_MOUSE_CDTV_VERT, INPUTEVENT_MOUSE_CDTV_UP, INPUTEVENT_MOUSE_CDTV_DOWN, + -1 +}; + +int intputdevice_compa_get_eventtype (int evt, int **axistablep) { - joysticks[joy].eventid[ID_BUTTON_OFFSET + 0][0] = n ? INPUTEVENT_JOY2_CD32_RED : INPUTEVENT_JOY1_CD32_RED; - joysticks[joy].eventid[ID_BUTTON_OFFSET + 1][0] = n ? INPUTEVENT_JOY2_CD32_BLUE : INPUTEVENT_JOY1_CD32_BLUE; - joysticks[joy].eventid[ID_BUTTON_OFFSET + 2][0] = n ? INPUTEVENT_JOY2_CD32_GREEN : INPUTEVENT_JOY1_CD32_GREEN; - joysticks[joy].eventid[ID_BUTTON_OFFSET + 3][0] = n ? INPUTEVENT_JOY2_CD32_YELLOW : INPUTEVENT_JOY1_CD32_YELLOW; - joysticks[joy].eventid[ID_BUTTON_OFFSET + 4][0] = n ? INPUTEVENT_JOY2_CD32_RWD : INPUTEVENT_JOY1_CD32_RWD; - joysticks[joy].eventid[ID_BUTTON_OFFSET + 5][0] = n ? INPUTEVENT_JOY2_CD32_FFW : INPUTEVENT_JOY1_CD32_FFW; - joysticks[joy].eventid[ID_BUTTON_OFFSET + 6][0] = n ? INPUTEVENT_JOY2_CD32_PLAY : INPUTEVENT_JOY1_CD32_PLAY; + for (int i = 0; axistable[i] >= 0; i += 3) { + *axistablep = &axistable[i]; + if (axistable[i] == evt) + return IDEV_WIDGET_AXIS; + if (axistable[i + 1] == evt) + return IDEV_WIDGET_BUTTONAXIS; + if (axistable[i + 2] == evt) + return IDEV_WIDGET_BUTTONAXIS; + } + *axistablep = NULL; + return IDEV_WIDGET_BUTTON; } -#endif - -int compatibility_device[MAX_JPORTS]; +static int rem_port1[] = { + INPUTEVENT_MOUSE1_HORIZ, INPUTEVENT_MOUSE1_VERT, + INPUTEVENT_JOY1_HORIZ, INPUTEVENT_JOY1_VERT, + INPUTEVENT_JOY1_HORIZ_POT, INPUTEVENT_JOY1_VERT_POT, + INPUTEVENT_JOY1_FIRE_BUTTON, INPUTEVENT_JOY1_2ND_BUTTON, INPUTEVENT_JOY1_3RD_BUTTON, + INPUTEVENT_JOY1_CD32_RED, INPUTEVENT_JOY1_CD32_BLUE, INPUTEVENT_JOY1_CD32_GREEN, INPUTEVENT_JOY1_CD32_YELLOW, + INPUTEVENT_JOY1_CD32_RWD, INPUTEVENT_JOY1_CD32_FFW, INPUTEVENT_JOY1_CD32_PLAY, + INPUTEVENT_MOUSE_CDTV_HORIZ, INPUTEVENT_MOUSE_CDTV_VERT, + INPUTEVENT_LIGHTPEN_HORIZ, INPUTEVENT_LIGHTPEN_VERT, + -1 +}; +static int rem_port2[] = { + INPUTEVENT_MOUSE2_HORIZ, INPUTEVENT_MOUSE2_VERT, + INPUTEVENT_JOY2_HORIZ, INPUTEVENT_JOY2_VERT, + INPUTEVENT_JOY2_HORIZ_POT, INPUTEVENT_JOY2_VERT_POT, + INPUTEVENT_JOY2_FIRE_BUTTON, INPUTEVENT_JOY2_2ND_BUTTON, INPUTEVENT_JOY2_3RD_BUTTON, + INPUTEVENT_JOY2_CD32_RED, INPUTEVENT_JOY2_CD32_BLUE, INPUTEVENT_JOY2_CD32_GREEN, INPUTEVENT_JOY2_CD32_YELLOW, + INPUTEVENT_JOY2_CD32_RWD, INPUTEVENT_JOY2_CD32_FFW, INPUTEVENT_JOY2_CD32_PLAY, + -1, -1, + -1, -1, + -1 +}; +static int rem_port3[] = { + INPUTEVENT_PAR_JOY1_LEFT, INPUTEVENT_PAR_JOY1_RIGHT, INPUTEVENT_PAR_JOY1_UP, INPUTEVENT_PAR_JOY1_DOWN, + INPUTEVENT_PAR_JOY1_FIRE_BUTTON, + -1 +}; +static int rem_port4[] = { + INPUTEVENT_PAR_JOY2_LEFT, INPUTEVENT_PAR_JOY2_RIGHT, INPUTEVENT_PAR_JOY2_UP, INPUTEVENT_PAR_JOY2_DOWN, + INPUTEVENT_PAR_JOY2_FIRE_BUTTON, + -1 +}; +static int *rem_ports[] = { rem_port1, rem_port2, rem_port3, rem_port4 }; +static int af_port1[] = { + INPUTEVENT_JOY1_FIRE_BUTTON, INPUTEVENT_JOY1_CD32_RED, + -1 +}; +static int af_port2[] = { + INPUTEVENT_JOY2_FIRE_BUTTON, INPUTEVENT_JOY2_CD32_RED, + -1 +}; +static int af_port3[] = { + INPUTEVENT_PAR_JOY1_FIRE_BUTTON, + -1 +}; +static int af_port4[] = { + INPUTEVENT_PAR_JOY2_FIRE_BUTTON, + -1 +}; +static int *af_ports[] = { af_port1, af_port2, af_port3, af_port4 }; static int ip_joy1[] = { - INPUTEVENT_JOY1_UP, INPUTEVENT_JOY1_LEFT, INPUTEVENT_JOY1_RIGHT, INPUTEVENT_JOY1_DOWN, - INPUTEVENT_JOY1_FIRE_BUTTON, INPUTEVENT_JOY1_2ND_BUTTON, INPUTEVENT_JOY1_3RD_BUTTON, + INPUTEVENT_JOY1_LEFT, INPUTEVENT_JOY1_RIGHT, INPUTEVENT_JOY1_UP, INPUTEVENT_JOY1_DOWN, + INPUTEVENT_JOY1_FIRE_BUTTON, INPUTEVENT_JOY1_2ND_BUTTON, -1 }; static int ip_joy2[] = { - INPUTEVENT_JOY2_UP, INPUTEVENT_JOY2_LEFT, INPUTEVENT_JOY2_RIGHT, INPUTEVENT_JOY2_DOWN, - INPUTEVENT_JOY2_FIRE_BUTTON, INPUTEVENT_JOY2_2ND_BUTTON, INPUTEVENT_JOY2_3RD_BUTTON, + INPUTEVENT_JOY2_LEFT, INPUTEVENT_JOY2_RIGHT, INPUTEVENT_JOY2_UP, INPUTEVENT_JOY2_DOWN, + INPUTEVENT_JOY2_FIRE_BUTTON, INPUTEVENT_JOY2_2ND_BUTTON, -1 }; static int ip_joycd321[] = { + INPUTEVENT_JOY1_LEFT, INPUTEVENT_JOY1_RIGHT, INPUTEVENT_JOY1_UP, INPUTEVENT_JOY1_DOWN, INPUTEVENT_JOY1_CD32_RED, INPUTEVENT_JOY1_CD32_BLUE, INPUTEVENT_JOY1_CD32_GREEN, INPUTEVENT_JOY1_CD32_YELLOW, INPUTEVENT_JOY1_CD32_RWD, INPUTEVENT_JOY1_CD32_FFW, INPUTEVENT_JOY1_CD32_PLAY, -1 }; static int ip_joycd322[] = { + INPUTEVENT_JOY2_LEFT, INPUTEVENT_JOY2_RIGHT, INPUTEVENT_JOY2_UP, INPUTEVENT_JOY2_DOWN, INPUTEVENT_JOY2_CD32_RED, INPUTEVENT_JOY2_CD32_BLUE, INPUTEVENT_JOY2_CD32_GREEN, INPUTEVENT_JOY2_CD32_YELLOW, INPUTEVENT_JOY2_CD32_RWD, INPUTEVENT_JOY2_CD32_FFW, INPUTEVENT_JOY2_CD32_PLAY, -1 }; static int ip_parjoy1[] = { - INPUTEVENT_PAR_JOY1_UP, INPUTEVENT_PAR_JOY1_LEFT, INPUTEVENT_PAR_JOY1_RIGHT, INPUTEVENT_PAR_JOY1_DOWN, + INPUTEVENT_PAR_JOY1_LEFT, INPUTEVENT_PAR_JOY1_RIGHT, INPUTEVENT_PAR_JOY1_UP, INPUTEVENT_PAR_JOY1_DOWN, INPUTEVENT_PAR_JOY1_FIRE_BUTTON, -1 }; static int ip_parjoy2[] = { - INPUTEVENT_PAR_JOY2_UP, INPUTEVENT_PAR_JOY2_LEFT, INPUTEVENT_PAR_JOY2_RIGHT, INPUTEVENT_PAR_JOY2_DOWN, + INPUTEVENT_PAR_JOY2_LEFT, INPUTEVENT_PAR_JOY2_RIGHT, INPUTEVENT_PAR_JOY2_UP, INPUTEVENT_PAR_JOY2_DOWN, INPUTEVENT_PAR_JOY2_FIRE_BUTTON, -1 }; static int ip_mouse1[] = { - INPUTEVENT_MOUSE1_UP, INPUTEVENT_MOUSE1_LEFT, INPUTEVENT_MOUSE1_RIGHT, INPUTEVENT_MOUSE1_DOWN, - INPUTEVENT_JOY1_FIRE_BUTTON, INPUTEVENT_JOY1_2ND_BUTTON, INPUTEVENT_JOY1_3RD_BUTTON, + INPUTEVENT_MOUSE1_LEFT, INPUTEVENT_MOUSE1_RIGHT, INPUTEVENT_MOUSE1_UP, INPUTEVENT_MOUSE1_DOWN, + INPUTEVENT_JOY1_FIRE_BUTTON, INPUTEVENT_JOY1_2ND_BUTTON, -1 }; static int ip_mouse2[] = { - INPUTEVENT_MOUSE2_UP, INPUTEVENT_MOUSE2_LEFT, INPUTEVENT_MOUSE2_RIGHT, INPUTEVENT_MOUSE2_DOWN, - INPUTEVENT_JOY2_FIRE_BUTTON, INPUTEVENT_JOY2_2ND_BUTTON, INPUTEVENT_JOY2_3RD_BUTTON, + INPUTEVENT_MOUSE2_LEFT, INPUTEVENT_MOUSE2_RIGHT, INPUTEVENT_MOUSE2_UP, INPUTEVENT_MOUSE2_DOWN, + INPUTEVENT_JOY2_FIRE_BUTTON, INPUTEVENT_JOY2_2ND_BUTTON, + -1 +}; +static int ip_mousecdtv[] = +{ + INPUTEVENT_MOUSE_CDTV_LEFT, INPUTEVENT_MOUSE_CDTV_RIGHT, INPUTEVENT_MOUSE_CDTV_UP, INPUTEVENT_MOUSE_CDTV_DOWN, + INPUTEVENT_JOY1_FIRE_BUTTON, INPUTEVENT_JOY1_2ND_BUTTON, + -1 +}; +static int ip_arcadia[] = { + INPUTEVENT_SPC_ARCADIA_DIAGNOSTICS, INPUTEVENT_SPC_ARCADIA_PLAYER1, INPUTEVENT_SPC_ARCADIA_PLAYER2, + INPUTEVENT_SPC_ARCADIA_COIN1, INPUTEVENT_SPC_ARCADIA_COIN2, + -1 +}; +static int ip_lightpen1[] = { + INPUTEVENT_LIGHTPEN_HORIZ, INPUTEVENT_LIGHTPEN_VERT, INPUTEVENT_JOY1_3RD_BUTTON, + -1 +}; +static int ip_lightpen2[] = { + INPUTEVENT_LIGHTPEN_HORIZ, INPUTEVENT_LIGHTPEN_VERT, INPUTEVENT_JOY2_3RD_BUTTON, + -1 +}; +static int ip_analog1[] = { + INPUTEVENT_JOY1_HORIZ_POT, INPUTEVENT_JOY1_VERT_POT, INPUTEVENT_JOY1_LEFT, INPUTEVENT_JOY1_RIGHT, + -1 +}; +static int ip_analog2[] = { + INPUTEVENT_JOY2_HORIZ_POT, INPUTEVENT_JOY2_VERT_POT, INPUTEVENT_JOY2_LEFT, INPUTEVENT_JOY2_RIGHT, + -1 +}; + +static int ip_arcadiaxa[] = { -1 }; @@ -3176,7 +3407,7 @@ static void checkcompakb (int *kb, int *srcmap) k = 0; while (keyboard_default[k].scancode >= 0) { if (keyboard_default[k].scancode == kb[j]) { - evt = keyboard_default[k].event; + evt = keyboard_default[k].evt; break; } k++; @@ -3198,16 +3429,18 @@ static void setcompakb (int *kb, int *srcmap) int j, k; k = j = 0; while (kb[j] >= 0 && srcmap[k] >= 0) { - struct uae_input_device *uid = &keyboards[0]; while (kb[j] >= 0) { int id = kb[j]; - for (int l = 0; l < MAX_INPUT_DEVICE_EVENTS; l++) { - if (uid->extra[l][0] == id) { - uid->eventid[l][0] = srcmap[k]; - uid->flags[l][0] = 0; - xfree (uid->custom[l][0]); - uid->custom[l][0] = NULL; - break; + for (int m = 0; m < MAX_INPUT_DEVICES; m++) { + struct uae_input_device *uid = &keyboards[m]; + for (int l = 0; l < MAX_INPUT_DEVICE_EVENTS; l++) { + if (uid->extra[l][0] == id) { + uid->eventid[l][0] = srcmap[k]; + uid->flags[l][0] &= ID_FLAG_SAVE_MASK; + xfree (uid->custom[l][0]); + uid->custom[l][0] = NULL; + break; + } } } j++; @@ -3217,251 +3450,500 @@ static void setcompakb (int *kb, int *srcmap) } } -// merge gameport settings with current input configuration -static void compatibility_copy (struct uae_prefs *prefs) +static int joymodes[MAX_JPORTS]; +static int *joyinputs[MAX_JPORTS]; + +int inputdevice_get_compatibility_input (struct uae_prefs *prefs, int index, int *typelist, int **inputlist, int **at) { - int used[MAX_INPUT_DEVICES] = { 0 }; - int i, joy; + if (index >= MAX_JPORTS || joymodes[index] < 0) + return 0; + *typelist = joymodes[index]; + *inputlist = joyinputs[index]; + *at = axistable; + int cnt = 0; + for (int i = 0; joyinputs[index] && joyinputs[index][i] >= 0; i++, cnt++); + return cnt; +} + +static void clearevent (struct uae_input_device *uid, int evt) +{ + for (int i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) { + for (int j = 0; j < MAX_INPUT_SUB_EVENT; j++) { + if (uid->eventid[i][j] == evt) { + uid->eventid[i][j] = 0; + uid->flags[i][j] = 0; + xfree (uid->custom[i][j]); + uid->custom[i][j] = NULL; + } + } + } +} +static void clearkbrevent (struct uae_input_device *uid, int evt) +{ + for (int i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) { + bool found = false; + for (int j = 0; j < MAX_INPUT_SUB_EVENT; j++) { + if (uid->eventid[i][j] == evt) { + uid->eventid[i][j] = 0; + uid->flags[i][j] = 0; + xfree (uid->custom[i][j]); + uid->custom[i][j] = NULL; + if (j == 0) + set_kbr_default_event (uid, keyboard_default, i); + } + } + } +} - for (i = 0; i < 2; i++) { - int mode = prefs->jports[i].mode; - if ((joy = jsem_ismouse (i, prefs)) >= 0) { - switch (mode) - { - case JSEM_MODE_DEFAULT: - case JSEM_MODE_MOUSE: - default: - input_get_default_mouse (mice, joy, i); - break; - case JSEM_MODE_LIGHTPEN: - input_get_default_lightpen (mice, joy, i); +static void resetjport (struct uae_prefs *prefs, int index) +{ + int *p = rem_ports[index]; + while (*p >= 0) { + int evtnum = *p++; + for (int l = 0; l < MAX_INPUT_DEVICES; l++) { + clearevent (&prefs->joystick_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum); + clearevent (&prefs->mouse_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum); + clearkbrevent (&prefs->keyboard_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum); + } + for (int i = 0; axistable[i] >= 0; i += 3) { + if (evtnum == axistable[i] || evtnum == axistable[i + 1] || evtnum == axistable[i + 2]) { + for (int j = 0; j < 3; j++) { + int evtnum2 = axistable[i + j]; + for (int l = 0; l < MAX_INPUT_DEVICES; l++) { + clearevent (&prefs->joystick_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum2); + clearevent (&prefs->mouse_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum2); + clearkbrevent (&prefs->keyboard_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum2); + } + } break; } } } - for (i = 1; i >= 0; i--) { - int mode = prefs->jports[i].mode; - joy = jsem_isjoy (i, prefs); - if (joy >= 0) { - switch (mode) - { - case JSEM_MODE_DEFAULT: - case JSEM_MODE_JOYSTICK: - case JSEM_MODE_JOYSTICK_CD32: - default: - input_get_default_joystick (joysticks, joy, i, (mode == JSEM_MODE_JOYSTICK_CD32 || (mode == JSEM_MODE_DEFAULT && prefs->cs_cd32cd))); - break; - case JSEM_MODE_JOYSTICK_ANALOG: - input_get_default_joystick_analog (joysticks, joy, i); - break; - case JSEM_MODE_MOUSE: - input_get_default_mouse (joysticks, joy, i); +} + +static void remove_compa_config (struct uae_prefs *prefs, int index) +{ + int typelist, *inputlist, *atp; + + if (!inputdevice_get_compatibility_input (prefs, index, &typelist, &inputlist, &atp)) + return; + for (int i = 0; inputlist[i] >= 0; i++) { + int evtnum = inputlist[i]; + + int atpidx = 0; + while (*atp >= 0) { + if (*atp == evtnum) { + atp++; + atpidx = 2; break; - case JSEM_MODE_LIGHTPEN: - input_get_default_lightpen (joysticks, joy, i); + } + if (atp[1] == evtnum || atp[2] == evtnum) { + atpidx = 1; break; } - used[joy] = 1; + atp += 3; + } + while (atpidx >= 0) { + for (int l = 0; l < MAX_INPUT_DEVICES; l++) { + clearevent (&prefs->joystick_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum); + clearevent (&prefs->mouse_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum); + clearkbrevent (&prefs->keyboard_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum); + } + evtnum = *atp++; + atpidx--; } } +} - // replace possible old mappings with default keyboard mapping - checkcompakb (keyboard_default_kbmaps[0], ip_joy2); - checkcompakb (keyboard_default_kbmaps[0], ip_joy1); - checkcompakb (keyboard_default_kbmaps[0], ip_parjoy2); - checkcompakb (keyboard_default_kbmaps[0], ip_parjoy1); - checkcompakb (keyboard_default_kbmaps[0], ip_mouse2); - checkcompakb (keyboard_default_kbmaps[0], ip_mouse1); - checkcompakb (keyboard_default_kbmaps[1], ip_joy2); - checkcompakb (keyboard_default_kbmaps[1], ip_joy1); - checkcompakb (keyboard_default_kbmaps[1], ip_parjoy2); - checkcompakb (keyboard_default_kbmaps[1], ip_parjoy1); - checkcompakb (keyboard_default_kbmaps[1], ip_mouse2); - checkcompakb (keyboard_default_kbmaps[1], ip_mouse1); - checkcompakb (keyboard_default_kbmaps[2], ip_joy2); - checkcompakb (keyboard_default_kbmaps[2], ip_joy1); - checkcompakb (keyboard_default_kbmaps[2], ip_parjoy2); - checkcompakb (keyboard_default_kbmaps[2], ip_parjoy1); - checkcompakb (keyboard_default_kbmaps[2], ip_mouse2); - checkcompakb (keyboard_default_kbmaps[2], ip_mouse1); - checkcompakb (keyboard_default_kbmaps[5], ip_joycd321); - checkcompakb (keyboard_default_kbmaps[5], ip_joycd322); +// prepare port for custom mapping, remove all current Amiga side device mappings +void inputdevice_compa_prepare_custom (struct uae_prefs *prefs, int index) +{ + int mode = prefs->jports[index].mode; + freejport (prefs, index); + resetjport (prefs, index); + if (mode == 0) + mode = index == 0 ? JSEM_MODE_MOUSE : JSEM_MODE_JOYSTICK; + prefs->jports[index].mode = mode; + prefs->jports[index].id = -2; - for (i = 0; i < 2; i++) { - int *kb; - int mode = prefs->jports[i].mode; - for (joy = 0; used[joy]; joy++); - if (JSEM_ISANYKBD (i, prefs)) { - if (JSEM_ISNUMPAD (i, prefs)) - kb = keyboard_default_kbmaps[0]; - else if (JSEM_ISCURSOR (i, prefs)) - kb = keyboard_default_kbmaps[1]; + remove_compa_config (prefs, index); +} + +static void cleardev (struct uae_input_device *uid, int num) +{ + for (int i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) { + for (int j = 0; j < MAX_INPUT_SUB_EVENT; j++) { + uid[num].eventid[i][j] = 0; + } + } +} + +static void setjoyinputs (struct uae_prefs *prefs, int port) +{ + joyinputs[port] = NULL; + switch (joymodes[port]) + { + case JSEM_MODE_JOYSTICK: + if (port >= 2) + joyinputs[port] = port == 3 ? ip_parjoy2 : ip_parjoy1; else - kb = keyboard_default_kbmaps[2]; - switch (mode) - { - case JSEM_MODE_JOYSTICK: - case JSEM_MODE_JOYSTICK_CD32: - case JSEM_MODE_DEFAULT: - setcompakb (kb, i ? ip_joy2 : ip_joy1); - if (mode == JSEM_MODE_JOYSTICK_CD32 || (mode == JSEM_MODE_DEFAULT && prefs->cs_cd32cd)) - setcompakb (keyboard_default_kbmaps[5], i ? ip_joycd322 : ip_joycd321); - break; - case JSEM_MODE_MOUSE: - setcompakb (kb, i ? ip_mouse2 : ip_mouse1); + joyinputs[port] = port == 1 ? ip_joy2 : ip_joy1; + break; + case JSEM_MODE_JOYSTICK_CD32: + joyinputs[port] = port ? ip_joycd322 : ip_joycd321; + break; + case JSEM_MODE_JOYSTICK_ANALOG: + joyinputs[port] = port ? ip_analog2 : ip_analog1; + break; + case JSEM_MODE_MOUSE: + joyinputs[port] = port ? ip_mouse2 : ip_mouse1; + break; + case JSEM_MODE_LIGHTPEN: + joyinputs[port] = port ? ip_lightpen2 : ip_lightpen1; + break; + case JSEM_MODE_MOUSE_CDTV: + joyinputs[port] = ip_mousecdtv; + break; + } +} + +static void enablejoydevice (struct uae_input_device *uid, int evtnum) +{ + for (int i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) { + for (int j = 0; j < MAX_INPUT_SUB_EVENT; j++) { + if (uid->eventid[i][j] == evtnum) { + uid->enabled = 1; + } + } + } +} + +static void setjoydevices (struct uae_prefs *prefs, int port) +{ + for (int i = 0; joyinputs[port] && joyinputs[port][i] >= 0; i++) { + int evtnum = joyinputs[port][i]; + for (int l = 0; l < MAX_INPUT_DEVICES; l++) { + enablejoydevice (&prefs->joystick_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum); + enablejoydevice (&prefs->mouse_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum); + enablejoydevice (&prefs->keyboard_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum); + } + for (int i = 0; axistable[i] >= 0; i += 3) { + if (evtnum == axistable[i] || evtnum == axistable[i + 1] || evtnum == axistable[i + 2]) { + for (int j = 0; j < 3; j++) { + int evtnum2 = axistable[i + j]; + for (int l = 0; l < MAX_INPUT_DEVICES; l++) { + enablejoydevice (&prefs->joystick_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum2); + enablejoydevice (&prefs->mouse_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum2); + enablejoydevice (&prefs->keyboard_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum2); + } + } break; } - used[joy] = 1; } + } - // parport - for (i = 2; i < 4; i++) { - int *kb; - for (joy = 0; used[joy]; joy++); - if (JSEM_ISANYKBD (i, prefs)) { - if (JSEM_ISNUMPAD (i, prefs)) - kb = keyboard_default_kbmaps[0]; - else if (JSEM_ISCURSOR (i, prefs)) - kb = keyboard_default_kbmaps[1]; - else - kb = keyboard_default_kbmaps[2]; - setcompakb (kb, i ? ip_parjoy2 : ip_parjoy1); - used[joy] = 1; +} + +static void setautofire (struct uae_input_device *uid, int port, int af) +{ + int *afp = af_ports[port]; + for (int k = 0; afp[k] >= 0; k++) { + for (int i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) { + for (int j = 0; j < MAX_INPUT_SUB_EVENT; j++) { + if (uid->eventid[i][j] == afp[k]) { + uid->flags[i][j] |= ID_FLAG_AUTOFIRE; + } + } } } } +static void setautofires (struct uae_prefs *prefs, int port, int af) +{ + for (int l = 0; l < MAX_INPUT_DEVICES; l++) { + setautofire (&prefs->joystick_settings[GAMEPORT_INPUT_SETTINGS][l], port, af); + setautofire (&prefs->mouse_settings[GAMEPORT_INPUT_SETTINGS][l], port, af); + setautofire (&prefs->keyboard_settings[GAMEPORT_INPUT_SETTINGS][l], port, af); + } +} -static void compatibility_mode (struct uae_prefs *prefs) +// merge gameport settings with current input configuration +static void compatibility_copy (struct uae_prefs *prefs) { - int joy, i; int used[MAX_INPUT_DEVICES] = { 0 }; + int i, joy; + bool firstmouse = true; - prefs->jports[0].name[0] = prefs->jports[1].name[0] = 0; - prefs->jports[0].configname[0] = prefs->jports[1].configname[0] = 0; - prefs->jports[2].name[0] = prefs->jports[3].name[0] = 0; - prefs->jports[2].configname[0] = prefs->jports[3].configname[0] = 0; - compatibility_device[0] = -1; - compatibility_device[1] = -1; - compatibility_device[2] = -1; - compatibility_device[3] = -1; - for (i = 0; i < MAX_INPUT_DEVICES; i++) { - clear_id (&mice[i]); - clear_id (&joysticks[i]); + for (i = 0; i < MAX_JPORTS; i++) { + joymodes[i] = prefs->jports[i].mode; + joyinputs[i]= NULL; + // remove all mappings from this port, except if custom + if (prefs->jports[i].id != JPORT_CUSTOM) + remove_compa_config (prefs, i); + setjoyinputs (prefs, i); } for (i = 0; i < 2; i++) { - int mode = prefs->jports[i].mode; - if ((joy = jsem_ismouse (i, prefs)) >= 0) { - switch (mode) - { - case JSEM_MODE_DEFAULT: - case JSEM_MODE_MOUSE: - default: - input_get_default_mouse (mice, joy, i); - break; - case JSEM_MODE_LIGHTPEN: - input_get_default_lightpen (mice, joy, i); - break; + if (prefs->jports[i].id >= 0 && joymodes[i] <= 0) { + int mode = prefs->jports[i].mode; + if (jsem_ismouse (i, prefs) >= 0) { + switch (mode) + { + case JSEM_MODE_DEFAULT: + case JSEM_MODE_MOUSE: + default: + joymodes[i] = JSEM_MODE_MOUSE; + joyinputs[i] = i ? ip_mouse2 : ip_mouse1; + break; + case JSEM_MODE_LIGHTPEN: + joymodes[i] = JSEM_MODE_LIGHTPEN; + joyinputs[i] = i ? ip_lightpen2 : ip_lightpen1; + break; + case JSEM_MODE_MOUSE_CDTV: + joymodes[i] = JSEM_MODE_MOUSE_CDTV; + joyinputs[i] = ip_mousecdtv; + break; + } + } else if (jsem_isjoy (i, prefs) >= 0) { + switch (mode) + { + case JSEM_MODE_DEFAULT: + case JSEM_MODE_JOYSTICK: + case JSEM_MODE_JOYSTICK_CD32: + default: + { + int iscd32 = mode == JSEM_MODE_JOYSTICK_CD32 || (mode == JSEM_MODE_DEFAULT && prefs->cs_cd32cd); + joymodes[i] = mode == JSEM_MODE_JOYSTICK_CD32 ? JSEM_MODE_JOYSTICK_CD32 : JSEM_MODE_JOYSTICK; + if (!iscd32) + joyinputs[i] = i ? ip_joy2 : ip_joy1; + else + joyinputs[i] = i ? ip_joycd322 : ip_joycd321; + break; + } + case JSEM_MODE_JOYSTICK_ANALOG: + joymodes[i] = JSEM_MODE_JOYSTICK_ANALOG; + joyinputs[i] = i ? ip_analog2 : ip_analog1; + break; + case JSEM_MODE_MOUSE: + joymodes[i] = JSEM_MODE_MOUSE; + joyinputs[i] = i ? ip_mouse2 : ip_mouse1; + break; + case JSEM_MODE_LIGHTPEN: + joymodes[i] = JSEM_MODE_LIGHTPEN; + joyinputs[i] = i ? ip_lightpen2 : ip_lightpen1; + break; + case JSEM_MODE_MOUSE_CDTV: + joymodes[i] = JSEM_MODE_MOUSE_CDTV; + joyinputs[i] = ip_mousecdtv; + break; + } + } else if (prefs->jports[i].id >= 0) { + prefs->jports[i].mode = joymodes[i] = i ? JSEM_MODE_JOYSTICK : JSEM_MODE_MOUSE; + joyinputs[i] = i ? ip_joy2 : ip_mouse1; } - _tcsncpy (prefs->jports[i].name, idev[IDTYPE_MOUSE].get_friendlyname (joy), MAX_JPORTNAME - 1); - _tcsncpy (prefs->jports[i].configname, idev[IDTYPE_MOUSE].get_uniquename (joy), MAX_JPORTNAME - 1); - mice[joy].enabled = 1; } } - for (i = 1; i >= 0; i--) { - int mode = prefs->jports[i].mode; - joy = jsem_isjoy (i, prefs); - if (joy >= 0) { - switch (mode) - { - case JSEM_MODE_DEFAULT: - case JSEM_MODE_JOYSTICK: - case JSEM_MODE_JOYSTICK_CD32: - default: - input_get_default_joystick (joysticks, joy, i, (mode == JSEM_MODE_JOYSTICK_CD32 || (mode == JSEM_MODE_DEFAULT && prefs->cs_cd32cd))); - break; - case JSEM_MODE_JOYSTICK_ANALOG: - input_get_default_joystick_analog (joysticks, joy, i); - break; - case JSEM_MODE_MOUSE: - input_get_default_mouse (joysticks, joy, i); - break; - case JSEM_MODE_LIGHTPEN: - input_get_default_lightpen (joysticks, joy, i); - break; + + for (i = 2; i < MAX_JPORTS; i++) { + if (prefs->jports[i].id >= 0 && joymodes[i] <= 0) { + int mode = prefs->jports[i].mode; + if (jsem_isjoy (i, prefs) >= 0) { + joymodes[i] = JSEM_MODE_JOYSTICK; + joyinputs[i] = i == 3 ? ip_parjoy2 : ip_parjoy1; + } else if (prefs->jports[i].id >= 0) { + prefs->jports[i].mode = joymodes[i] = JSEM_MODE_JOYSTICK; + joyinputs[i] = i == 3 ? ip_parjoy2 : ip_parjoy1; } - _tcsncpy (prefs->jports[i].name, idev[IDTYPE_JOYSTICK].get_friendlyname (joy), MAX_JPORTNAME - 1); - _tcsncpy (prefs->jports[i].configname, idev[IDTYPE_JOYSTICK].get_uniquename (joy), MAX_JPORTNAME - 1); - joysticks[joy].enabled = 1; - used[joy] = 1; } } - for (i = 2; i < 4; i++) { - joy = jsem_isjoy (i, prefs); - if (joy >= 0) { - input_get_default_joystick (joysticks, joy, i, 0); - _tcsncpy (prefs->jports[i].name, idev[IDTYPE_JOYSTICK].get_friendlyname (joy), MAX_JPORTNAME - 1); - _tcsncpy (prefs->jports[i].configname, idev[IDTYPE_JOYSTICK].get_uniquename (joy), MAX_JPORTNAME - 1); - joysticks[joy].enabled = 1; - used[joy] = 1; + + for (i = 0; i < 2; i++) { + if (prefs->jports[i].id >= 0) { + int mode = prefs->jports[i].mode; + if ((joy = jsem_ismouse (i, prefs)) >= 0) { + cleardev (mice, joy); + switch (mode) + { + case JSEM_MODE_DEFAULT: + case JSEM_MODE_MOUSE: + default: + if (firstmouse) { // map first mouse to each available host mouse device + for (int j = 0; j < MAX_INPUT_DEVICES; j++) + input_get_default_mouse (mice, j, i); + firstmouse = false; + } + input_get_default_mouse (mice, joy, i); + joymodes[i] = JSEM_MODE_MOUSE; + break; + case JSEM_MODE_LIGHTPEN: + input_get_default_lightpen (mice, joy, i); + joymodes[i] = JSEM_MODE_LIGHTPEN; + break; + } + _tcsncpy (prefs->jports[i].name, idev[IDTYPE_MOUSE].get_friendlyname (joy), MAX_JPORTNAME - 1); + _tcsncpy (prefs->jports[i].configname, idev[IDTYPE_MOUSE].get_uniquename (joy), MAX_JPORTNAME - 1); + } } } + for (i = 1; i >= 0; i--) { + if (prefs->jports[i].id >= 0) { + int mode = prefs->jports[i].mode; + joy = jsem_isjoy (i, prefs); + if (joy >= 0) { + cleardev (joysticks, joy); + switch (mode) + { + case JSEM_MODE_DEFAULT: + case JSEM_MODE_JOYSTICK: + case JSEM_MODE_JOYSTICK_CD32: + default: + { + int iscd32 = mode == JSEM_MODE_JOYSTICK_CD32 || (mode == JSEM_MODE_DEFAULT && prefs->cs_cd32cd); + input_get_default_joystick (joysticks, joy, i, iscd32 ? JSEM_MODE_JOYSTICK_CD32 : 0); + joymodes[i] = mode == JSEM_MODE_JOYSTICK_CD32 ? JSEM_MODE_JOYSTICK_CD32 : JSEM_MODE_JOYSTICK; + break; + } + case JSEM_MODE_JOYSTICK_ANALOG: + input_get_default_joystick_analog (joysticks, joy, i); + joymodes[i] = JSEM_MODE_JOYSTICK_ANALOG; + break; + case JSEM_MODE_MOUSE: + input_get_default_mouse (joysticks, joy, i); + joymodes[i] = JSEM_MODE_MOUSE; + break; + case JSEM_MODE_LIGHTPEN: + input_get_default_lightpen (joysticks, joy, i); + joymodes[i] = JSEM_MODE_LIGHTPEN; + break; + case JSEM_MODE_MOUSE_CDTV: + joymodes[i] = JSEM_MODE_MOUSE_CDTV; + input_get_default_joystick (joysticks, joy, i, mode); + break; + + } + _tcsncpy (prefs->jports[i].name, idev[IDTYPE_JOYSTICK].get_friendlyname (joy), MAX_JPORTNAME - 1); + _tcsncpy (prefs->jports[i].configname, idev[IDTYPE_JOYSTICK].get_uniquename (joy), MAX_JPORTNAME - 1); + used[joy] = 1; + } + } + } + + // replace possible old mappings with default keyboard mapping + for (i = KBR_DEFAULT_MAP_NP; i <= KBR_DEFAULT_MAP_SE; i++) { + checkcompakb (keyboard_default_kbmaps[i], ip_joy2); + checkcompakb (keyboard_default_kbmaps[i], ip_joy1); + checkcompakb (keyboard_default_kbmaps[i], ip_parjoy2); + checkcompakb (keyboard_default_kbmaps[i], ip_parjoy1); + checkcompakb (keyboard_default_kbmaps[i], ip_mouse2); + checkcompakb (keyboard_default_kbmaps[i], ip_mouse1); + } + checkcompakb (keyboard_default_kbmaps[5], ip_joycd321); + checkcompakb (keyboard_default_kbmaps[5], ip_joycd322); + for (i = 0; i < 2; i++) { - int mode = prefs->jports[i].mode; - for (joy = 0; used[joy]; joy++); - if (JSEM_ISANYKBD (i, prefs)) { - switch (mode) - { - case JSEM_MODE_JOYSTICK: - case JSEM_MODE_JOYSTICK_CD32: - case JSEM_MODE_DEFAULT: - default: - joysticks[joy].eventid[ID_AXIS_OFFSET + 0][0] = i ? INPUTEVENT_JOY2_HORIZ : INPUTEVENT_JOY1_HORIZ; - joysticks[joy].eventid[ID_AXIS_OFFSET + 1][0] = i ? INPUTEVENT_JOY2_VERT : INPUTEVENT_JOY1_VERT; - joysticks[joy].eventid[ID_BUTTON_OFFSET + 0][0] = i ? INPUTEVENT_JOY2_FIRE_BUTTON : INPUTEVENT_JOY1_FIRE_BUTTON; - joysticks[joy].eventid[ID_BUTTON_OFFSET + 1][0] = i ? INPUTEVENT_JOY2_2ND_BUTTON : INPUTEVENT_JOY1_2ND_BUTTON; - joysticks[joy].eventid[ID_BUTTON_OFFSET + 2][0] = i ? INPUTEVENT_JOY2_3RD_BUTTON : INPUTEVENT_JOY1_3RD_BUTTON; - if (mode == JSEM_MODE_JOYSTICK_CD32 || (mode == JSEM_MODE_DEFAULT && prefs->cs_cd32cd)) - setcd32 (joy, i); - break; - case JSEM_MODE_MOUSE_CDTV: - joysticks[joy].eventid[ID_AXIS_OFFSET + 0][0] = INPUTEVENT_MOUSE_CDTV_HORIZ; - joysticks[joy].eventid[ID_AXIS_OFFSET + 1][0] = INPUTEVENT_MOUSE_CDTV_VERT; - joysticks[joy].eventid[ID_BUTTON_OFFSET + 0][0] = INPUTEVENT_JOY1_FIRE_BUTTON; - joysticks[joy].eventid[ID_BUTTON_OFFSET + 1][0] = INPUTEVENT_JOY1_2ND_BUTTON; - joysticks[joy].eventid[ID_BUTTON_OFFSET + 2][0] = INPUTEVENT_JOY1_3RD_BUTTON; - break; - case JSEM_MODE_MOUSE: - joysticks[joy].eventid[ID_AXIS_OFFSET + 0][0] = i ? INPUTEVENT_MOUSE2_HORIZ : INPUTEVENT_MOUSE1_HORIZ; - joysticks[joy].eventid[ID_AXIS_OFFSET + 1][0] = i ? INPUTEVENT_MOUSE2_VERT : INPUTEVENT_MOUSE1_VERT; - joysticks[joy].eventid[ID_BUTTON_OFFSET + 0][0] = i ? INPUTEVENT_JOY2_FIRE_BUTTON : INPUTEVENT_JOY1_FIRE_BUTTON; - joysticks[joy].eventid[ID_BUTTON_OFFSET + 1][0] = i ? INPUTEVENT_JOY2_2ND_BUTTON : INPUTEVENT_JOY1_2ND_BUTTON; - joysticks[joy].eventid[ID_BUTTON_OFFSET + 2][0] = i ? INPUTEVENT_JOY2_3RD_BUTTON : INPUTEVENT_JOY1_3RD_BUTTON; - break; - case JSEM_MODE_LIGHTPEN: - joysticks[joy].eventid[ID_AXIS_OFFSET + 0][0] = INPUTEVENT_LIGHTPEN_HORIZ; - joysticks[joy].eventid[ID_AXIS_OFFSET + 1][0] = INPUTEVENT_LIGHTPEN_VERT; - joysticks[joy].eventid[ID_BUTTON_OFFSET + 0][0] = i ? INPUTEVENT_JOY2_3RD_BUTTON : INPUTEVENT_JOY1_3RD_BUTTON; - break; + if (prefs->jports[i].id >= 0) { + int *kb = NULL; + int mode = prefs->jports[i].mode; + for (joy = 0; used[joy]; joy++); + if (JSEM_ISANYKBD (i, prefs)) { + int cd32 = mode == JSEM_MODE_JOYSTICK_CD32 || (mode == JSEM_MODE_DEFAULT && prefs->cs_cd32cd); + if (JSEM_ISNUMPAD (i, prefs)) { + if (cd32) + kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_CD32_NP]; + else + kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_NP]; + } else if (JSEM_ISCURSOR (i, prefs)) { + if (cd32) + kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_CD32_CK]; + else + kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_CK]; + } else if (JSEM_ISSOMEWHEREELSE (i, prefs)) { + if (cd32) + kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_CD32_SE]; + else + kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_SE]; + } else if (JSEM_ISXARCADE1 (i, prefs)) { + kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_XA1]; + } else if (JSEM_ISXARCADE2 (i, prefs)) { + kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_XA2]; + } + if (kb) { + switch (mode) + { + case JSEM_MODE_JOYSTICK: + case JSEM_MODE_JOYSTICK_CD32: + case JSEM_MODE_DEFAULT: + if (cd32) { + setcompakb (kb, i ? ip_joycd322 : ip_joycd321); + joymodes[i] = JSEM_MODE_JOYSTICK_CD32; + } else { + setcompakb (kb, i ? ip_joy2 : ip_joy1); + joymodes[i] = JSEM_MODE_JOYSTICK; + } + break; + case JSEM_MODE_MOUSE: + setcompakb (kb, i ? ip_mouse2 : ip_mouse1); + joymodes[i] = JSEM_MODE_MOUSE; + break; + } + used[joy] = 1; + } + } + } + } + if (arcadia_bios) { + setcompakb (keyboard_default_kbmaps[KBR_DEFAULT_MAP_ARCADIA], ip_arcadia); + if (JSEM_ISXARCADE1 (i, prefs) || JSEM_ISXARCADE2 (i, prefs)) + setcompakb (keyboard_default_kbmaps[KBR_DEFAULT_MAP_ARCADIA_XA], ip_arcadiaxa); + } + // parport + for (i = 2; i < MAX_JPORTS; i++) { + if (prefs->jports[i].id >= 0) { + int *kb = NULL; + joy = jsem_isjoy (i, prefs); + if (joy >= 0) { + cleardev (joysticks, joy); + input_get_default_joystick (joysticks, joy, i, 0); + _tcsncpy (prefs->jports[i].name, idev[IDTYPE_MOUSE].get_friendlyname (joy), MAX_JPORTNAME - 1); + _tcsncpy (prefs->jports[i].configname, idev[IDTYPE_MOUSE].get_uniquename (joy), MAX_JPORTNAME - 1); + used[joy] = 1; + joymodes[i] = JSEM_MODE_JOYSTICK; } - joysticks[joy].enabled = -1; - used[joy] = 1; - compatibility_device[i] = joy; } } - for (i = 2; i < 4; i++) { - for (joy = 0; used[joy]; joy++); - if (JSEM_ISANYKBD (i, prefs)) { - joysticks[joy].eventid[ID_AXIS_OFFSET + 0][0] = i == 3 ? INPUTEVENT_PAR_JOY2_HORIZ : INPUTEVENT_PAR_JOY1_HORIZ; - joysticks[joy].eventid[ID_AXIS_OFFSET + 1][0] = i == 3 ? INPUTEVENT_PAR_JOY2_VERT : INPUTEVENT_PAR_JOY1_VERT; - joysticks[joy].eventid[ID_BUTTON_OFFSET + 0][0] = i == 3 ? INPUTEVENT_PAR_JOY2_FIRE_BUTTON : INPUTEVENT_PAR_JOY1_FIRE_BUTTON; - joysticks[joy].enabled = -1; - used[joy] = 1; - compatibility_device[i] = joy; + for (i = 2; i < MAX_JPORTS; i++) { + if (prefs->jports[i].id >= 0) { + int *kb = NULL; + for (joy = 0; used[joy]; joy++); + if (JSEM_ISANYKBD (i, prefs)) { + if (JSEM_ISNUMPAD (i, prefs)) + kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_NP]; + else if (JSEM_ISCURSOR (i, prefs)) + kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_CK]; + else if (JSEM_ISSOMEWHEREELSE (i, prefs)) + kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_SE]; + else if (JSEM_ISXARCADE1 (i, prefs)) + kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_XA1]; + else if (JSEM_ISXARCADE2 (i, prefs)) + kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_XA2]; + if (kb) { + setcompakb (kb, i == 3 ? ip_parjoy2 : ip_parjoy1); + used[joy] = 1; + joymodes[i] = JSEM_MODE_JOYSTICK; + } + } } } + for (i = 0; i < MAX_JPORTS; i++) { + if (prefs->jports[i].autofire) + setautofires (prefs, i, prefs->jports[i].autofire); + } + + for (i = 0; i < MAX_JPORTS; i++) { + setjoyinputs (prefs, i); + setjoydevices (prefs, i); + } } static void matchdevices (struct inputdevice_functions *inf, struct uae_input_device *uid) @@ -3532,14 +4014,14 @@ static void matchdevices (struct inputdevice_functions *inf, struct uae_input_de static void matchdevices_all (struct uae_prefs *prefs) { int i; - for (i = 0; i < MAX_INPUT_SETTINGS + 1; i++) { + for (i = 0; i < MAX_INPUT_SETTINGS; i++) { matchdevices (&idev[IDTYPE_MOUSE], prefs->mouse_settings[i]); matchdevices (&idev[IDTYPE_JOYSTICK], prefs->joystick_settings[i]); matchdevices (&idev[IDTYPE_KEYBOARD], prefs->keyboard_settings[i]); } } -static void inputdevice_updateconfig2 (struct uae_prefs *prefs, int domerge) +static void inputdevice_updateconfig2 (struct uae_prefs *prefs) { int i; @@ -3547,6 +4029,7 @@ static void inputdevice_updateconfig2 (struct uae_prefs *prefs, int domerge) copyjport (&changed_prefs, &currprefs, 1); copyjport (&changed_prefs, &currprefs, 2); copyjport (&changed_prefs, &currprefs, 3); + #ifdef RETROPLATFORM rp_input_change (0); rp_input_change (1); @@ -3573,10 +4056,10 @@ static void inputdevice_updateconfig2 (struct uae_prefs *prefs, int domerge) mouse_deltanoreset[i][2] = 0; mouse_delta[i][2] = 0; } - memset (keybuf, 0, sizeof (keybuf)); + memset (keybuf, 0, sizeof keybuf); for (i = 0; i < INPUT_QUEUE_SIZE; i++) - input_queue[i].framecnt = input_queue[i].nextframecnt = -1; + input_queue[i].linecnt = input_queue[i].nextlinecnt = -1; for (i = 0; i < MAX_INPUT_SUB_EVENT; i++) { sublevdir[0][i] = i; @@ -3589,34 +4072,33 @@ static void inputdevice_updateconfig2 (struct uae_prefs *prefs, int domerge) matchdevices_all (prefs); - memset (joysticks2, 0, sizeof (joysticks2)); - memset (mice2, 0, sizeof (mice2)); - if (prefs->input_selected_setting == 0) - compatibility_mode (prefs); - else if (domerge) - compatibility_copy (prefs); + memset (joysticks2, 0, sizeof joysticks2); + memset (mice2, 0, sizeof mice2); - joystick_setting_changed (); + joysticks = prefs->joystick_settings[GAMEPORT_INPUT_SETTINGS]; + mice = prefs->mouse_settings[GAMEPORT_INPUT_SETTINGS]; + keyboards = prefs->keyboard_settings[GAMEPORT_INPUT_SETTINGS]; + for (i = 0; i < MAX_INPUT_SETTINGS; i++) { + joysticks[i].enabled = 0; + mice[i].enabled = 0; + } + compatibility_copy (prefs); + joysticks = prefs->joystick_settings[prefs->input_selected_setting]; + mice = prefs->mouse_settings[prefs->input_selected_setting]; + keyboards = prefs->keyboard_settings[prefs->input_selected_setting]; scanevents (prefs); config_changed = 1; - -#if 0 -#ifdef CD32 - if (currprefs.input_selected_setting == 0 && currprefs.cs_cd32cd) - cd32_pad_enabled[1] = 1; -#endif -#endif } void inputdevice_mergeconfig (struct uae_prefs *prefs) { - inputdevice_updateconfig2 (prefs, 1); + inputdevice_updateconfig2 (prefs); } void inputdevice_updateconfig (struct uae_prefs *prefs) { - inputdevice_updateconfig2 (prefs, 0); + inputdevice_updateconfig2 (prefs); } @@ -3634,7 +4116,7 @@ void inputdevice_devicechange (struct uae_prefs *prefs) for (i = 0; i < MAX_JPORTS; i++) { jports[i] = NULL; jportskb[i] = -1; - idx = inputdevice_getjoyportdevice (prefs->jports[i].id); + idx = inputdevice_getjoyportdevice (i, prefs->jports[i].id); if (idx >= JSEM_LASTKBD) { struct inputdevice_functions *idf; int devidx; @@ -3678,56 +4160,13 @@ void inputdevice_devicechange (struct uae_prefs *prefs) config_changed = 1; } -static void set_kbr_default (struct uae_prefs *p, int index) -{ - int i, j, k, l; - struct uae_input_device_kbr_default *trans = keyboard_default; - struct uae_input_device *kbr; - struct inputdevice_functions *id = &idev[IDTYPE_KEYBOARD]; - uae_u32 scancode; - - if (!trans) - return; - for (j = 0; j < MAX_INPUT_DEVICES; j++) { - kbr = &p->keyboard_settings[index][j]; - for (i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) { - memset (kbr, 0, sizeof (struct uae_input_device)); - kbr->extra[i][0] = -1; - } - if (j < id->get_num ()) { - if (input_get_default_keyboard (j)) - kbr->enabled = 1; - for (i = 0; i < id->get_widget_num (j); i++) { - id->get_widget_type (j, i, 0, &scancode); - kbr->extra[i][0] = scancode; - l = 0; - while (trans[l].scancode >= 0) { - if (kbr->extra[i][0] == trans[l].scancode) { - for (k = 0; k < MAX_INPUT_SUB_EVENT; k++) { - if (kbr->eventid[i][k] == 0) - break; - } - if (k == MAX_INPUT_SUB_EVENT) { - write_log (L"corrupt default keyboard mappings\n"); - return; - } - kbr->eventid[i][k] = trans[l].event; - if (trans[l].event == INPUTEVENT_KEY_CAPS_LOCK) - kbr->flags[i][k] |= ID_FLAG_TOGGLE; - break; - } - l++; - } - } - } - } -} - +// set default prefs to all input configuration settings void inputdevice_default_prefs (struct uae_prefs *p) { int i, j; inputdevice_init (); + p->input_selected_setting = GAMEPORT_INPUT_SETTINGS; p->input_joymouse_multiplier = 20; p->input_joymouse_deadzone = 33; p->input_joystick_deadzone = 33; @@ -3735,24 +4174,33 @@ void inputdevice_default_prefs (struct uae_prefs *p) p->input_analog_joystick_mult = 15; p->input_analog_joystick_offset = -1; p->input_mouse_speed = 100; - p->input_autofire_framecnt = 10; - for (i = 0; i <= MAX_INPUT_SETTINGS; i++) { - set_kbr_default (p, i); - for (j = 0; j < MAX_INPUT_DEVICES; j++) { - if (input_get_default_mouse (p->mouse_settings[i], j, j & 1)) - p->mouse_settings[i]->enabled = 1; - if (input_get_default_joystick (p->joystick_settings[i], j, j & 1, 0)) - p->joystick_settings[i]->enabled = 1; + p->input_autofire_linecnt = 600; + for (i = 0; i < MAX_INPUT_SETTINGS; i++) { + if (i != GAMEPORT_INPUT_SETTINGS) { + set_kbr_default (p, i); + for (j = 0; j < MAX_INPUT_DEVICES; j++) { + if (input_get_default_mouse (p->mouse_settings[i], j, j & 1)) + p->mouse_settings[i]->enabled = 1; + if (input_get_default_joystick (p->joystick_settings[i], j, j & 1, 0)) + p->joystick_settings[i]->enabled = 1; + } + } else { + if (p->jports[0].id != -2 || p->jports[0].id != -2) { + reset_inputdevice_slot (p, i); + } + set_kbr_default (p, i); } } } +// set default keyboard and keyboard>joystick layouts void inputdevice_setkeytranslation (struct uae_input_device_kbr_default *trans, int **kbmaps) { keyboard_default = trans; keyboard_default_kbmaps = kbmaps; } +// return true if keyboard/scancode pair is mapped int inputdevice_iskeymapped (int keyboard, int scancode) { struct uae_input_device *na = &keyboards[keyboard]; @@ -3794,7 +4242,7 @@ static int inputdevice_translatekeycode_2 (int keyboard, int scancode, int state if (!keyboards || scancode < 0) return handled; j = 0; - while (na->extra[j][0] >= 0) { + while (j < MAX_INPUT_DEVICE_EVENTS && na->extra[j][0] >= 0) { if (na->extra[j][0] == scancode) { for (k = 0; k < MAX_INPUT_SUB_EVENT; k++) {/* send key release events in reverse order */ int autofire = (na->flags[j][sublevdir[state == 0 ? 1 : 0][k]] & ID_FLAG_AUTOFIRE) ? 1 : 0; @@ -3862,6 +4310,7 @@ static void sendmmcodes(int code, int newstate) record_key(((b << 1) | (b >> 7)) & 0xff); } +// main keyboard press/release entry point int inputdevice_translatekeycode (int keyboard, int scancode, int state) { if (inputdevice_translatekeycode_2 (keyboard, scancode, state)) @@ -3909,8 +4358,8 @@ static int get_event_data (const struct inputdevice_functions *id, int devnum, i const struct uae_input_device *uid = get_uid (id, devnum); int type = id->get_widget_type (devnum, num, 0, 0); int i; - if (type == IDEV_WIDGET_BUTTON) { - i = num - id->get_widget_first (devnum, type) + ID_BUTTON_OFFSET; + if (type == IDEV_WIDGET_BUTTON || type == IDEV_WIDGET_BUTTONAXIS) { + i = num - id->get_widget_first (devnum, IDEV_WIDGET_BUTTON) + ID_BUTTON_OFFSET; *eventid = uid->eventid[i][sub]; *flags = uid->flags[i][sub]; *custom = uid->custom[i][sub]; @@ -3936,8 +4385,8 @@ static int put_event_data (const struct inputdevice_functions *id, int devnum, i struct uae_input_device *uid = get_uid (id, devnum); int type = id->get_widget_type (devnum, num, 0, 0); int i; - if (type == IDEV_WIDGET_BUTTON) { - i = num - id->get_widget_first (devnum, type) + ID_BUTTON_OFFSET; + if (type == IDEV_WIDGET_BUTTON || type == IDEV_WIDGET_BUTTONAXIS) { + i = num - id->get_widget_first (devnum, IDEV_WIDGET_BUTTON) + ID_BUTTON_OFFSET; uid->eventid[i][sub] = eventid; uid->flags[i][sub] = flags; xfree (uid->custom[i][sub]); @@ -3978,6 +4427,7 @@ static int is_event_used (const struct inputdevice_functions *id, int devnum, in return 0; } +// device based index from global device index int inputdevice_get_device_index (int devnum) { if (devnum < idev[IDTYPE_JOYSTICK].get_num()) @@ -3990,6 +4440,17 @@ int inputdevice_get_device_index (int devnum) return -1; } +static int getdevnum (int type, int devnum) +{ + if (type == IDTYPE_JOYSTICK) + return devnum; + if (type == IDTYPE_MOUSE) + return idev[IDTYPE_JOYSTICK].get_num() + devnum; + if (type == IDTYPE_KEYBOARD) + return idev[IDTYPE_JOYSTICK].get_num() + idev[IDTYPE_MOUSE].get_num() + devnum; + return -1; +} + static int gettype (int devnum) { if (devnum < idev[IDTYPE_JOYSTICK].get_num()) @@ -4010,6 +4471,11 @@ static struct inputdevice_functions *getidf (int devnum) return &idev[type]; } +struct inputevent *inputdevice_get_eventinfo (int evt) +{ + return &events[evt]; +} + /* returns number of devices of type "type" */ int inputdevice_get_device_total (int type) @@ -4021,6 +4487,11 @@ TCHAR *inputdevice_get_device_name (int type, int devnum) { return idev[type].get_friendlyname (devnum); } +/* returns the name of device */ +TCHAR *inputdevice_get_device_name2 (int devnum) +{ + return getidf (devnum)->get_friendlyname (inputdevice_get_device_index (devnum)); +} /* returns machine readable name of device */ TCHAR *inputdevice_get_device_unique_name (int type, int devnum) { @@ -4030,6 +4501,8 @@ TCHAR *inputdevice_get_device_unique_name (int type, int devnum) int inputdevice_get_device_status (int devnum) { const struct inputdevice_functions *idf = getidf (devnum); + if (idf == NULL) + return -1; struct uae_input_device *uid = get_uid (idf, inputdevice_get_device_index (devnum)); return uid->enabled; } @@ -4038,7 +4511,16 @@ int inputdevice_get_device_status (int devnum) void inputdevice_set_device_status (int devnum, int enabled) { const struct inputdevice_functions *idf = getidf (devnum); - struct uae_input_device *uid = get_uid (idf, inputdevice_get_device_index (devnum)); + int num = inputdevice_get_device_index (devnum); + struct uae_input_device *uid = get_uid (idf, num); + if (enabled) { // disable incompatible devices ("super device" vs "raw device") + for (int i = 0; i < idf->get_num (); i++) { + if (idf->get_flags (i) != idf->get_flags (num)) { + struct uae_input_device *uid2 = get_uid (idf, i); + uid2->enabled = 0; + } + } + } uid->enabled = enabled; } @@ -4049,7 +4531,8 @@ int inputdevice_get_widget_num (int devnum) return idf->get_widget_num (inputdevice_get_device_index (devnum)); } -static void get_ename (const struct inputevent *ie, TCHAR *out) +// return name of event, do not use ie->name directly +void inputdevice_get_eventname (const struct inputevent *ie, TCHAR *out) { if (!out) return; @@ -4077,8 +4560,8 @@ int inputdevice_iterate (int devnum, int num, TCHAR *name, int *af) return 0; } mask = 0; - type = idf->get_widget_type (devindex, num, 0, 0); - if (type == IDEV_WIDGET_BUTTON) { + type = idf->get_widget_type (devindex, num, NULL, NULL); + if (type == IDEV_WIDGET_BUTTON || type == IDEV_WIDGET_BUTTONAXIS) { if (idf == &idev[IDTYPE_JOYSTICK]) { mask |= AM_JOY_BUT; } else { @@ -4110,12 +4593,13 @@ int inputdevice_iterate (int devnum, int num, TCHAR *name, int *af) if (!(ie->allow_mask & mask)) continue; get_event_data (idf, devindex, num, &data, &custom, &flags, 0); - get_ename (ie, name); + inputdevice_get_eventname (ie, name); *af = (flags & ID_FLAG_AUTOFIRE) ? 1 : 0; return 1; } } +// return mapped event from devnum/num/sub int inputdevice_get_mapped_name (int devnum, int num, int *pflags, TCHAR *name, TCHAR *custom, int sub) { const struct inputdevice_functions *idf = getidf (devnum); @@ -4146,10 +4630,11 @@ int inputdevice_get_mapped_name (int devnum, int num, int *pflags, TCHAR *name, flags |= IDEV_MAPPED_AUTOFIRE_POSSIBLE; if (pflags) *pflags = flags; - get_ename (&events[data], name); + inputdevice_get_eventname (&events[data], name); return data; } +// set event name/custom/flags to devnum/num/sub int inputdevice_set_mapping (int devnum, int num, TCHAR *name, TCHAR *custom, int flags, int sub) { const struct inputdevice_functions *idf = getidf (devnum); @@ -4164,7 +4649,7 @@ int inputdevice_set_mapping (int devnum, int num, TCHAR *name, TCHAR *custom, in if (name) { eid = 1; while (events[eid].name) { - get_ename (&events[eid], ename); + inputdevice_get_eventname (&events[eid], ename); if (!_tcscmp(ename, name)) break; eid++; } @@ -4210,6 +4695,7 @@ int inputdevice_config_change_test (void) return v; } +// copy configuration #src to configuration #dst void inputdevice_copyconfig (const struct uae_prefs *src, struct uae_prefs *dst) { int i, j; @@ -4220,11 +4706,13 @@ void inputdevice_copyconfig (const struct uae_prefs *src, struct uae_prefs *dst) dst->input_joystick_deadzone = src->input_joystick_deadzone; dst->input_joymouse_speed = src->input_joymouse_speed; dst->input_mouse_speed = src->input_mouse_speed; - dst->input_autofire_framecnt = src->input_autofire_framecnt; + dst->input_autofire_linecnt = src->input_autofire_linecnt; copyjport (src, dst, 0); copyjport (src, dst, 1); + copyjport (src, dst, 2); + copyjport (src, dst, 3); - for (i = 0; i < MAX_INPUT_SETTINGS + 1; i++) { + for (i = 0; i < MAX_INPUT_SETTINGS; i++) { for (j = 0; j < MAX_INPUT_DEVICES; j++) { memcpy (&dst->joystick_settings[i][j], &src->joystick_settings[i][j], sizeof (struct uae_input_device)); memcpy (&dst->mouse_settings[i][j], &src->mouse_settings[i][j], sizeof (struct uae_input_device)); @@ -4235,6 +4723,63 @@ void inputdevice_copyconfig (const struct uae_prefs *src, struct uae_prefs *dst) inputdevice_updateconfig (dst); } +static void swapjoydevice (struct uae_input_device *uid, int **swaps) +{ + for (int i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) { + for (int j = 0; j < MAX_INPUT_SUB_EVENT; j++) { + bool found = false; + for (int k = 0; k < 2 && !found; k++) { + int evtnum; + for (int kk = 0; (evtnum = swaps[k][kk]) >= 0 && !found; kk++) { + if (uid->eventid[i][j] == evtnum) { + uid->eventid[i][j] = swaps[1 - k][kk]; + found = true; + } else { +#if 1 + for (int jj = 0; axistable[jj] >= 0; jj += 3) { + if (evtnum == axistable[jj] || evtnum == axistable[jj + 1] || evtnum == axistable[jj + 2]) { + for (int ii = 0; ii < 3; ii++) { + if (uid->eventid[i][j] == axistable[jj + ii]) { + int evtnum2 = swaps[1 - k][kk]; + for (int m = 0; axistable[m] >= 0; m += 3) { + if (evtnum2 == axistable[m] || evtnum2 == axistable[m + 1] || evtnum2 == axistable[m + 2]) { + uid->eventid[i][j] = axistable[m + ii]; + found = true; + } + } + } + } + } + } +#endif + } + } + } + } + } +} + +// swap gameports ports, remember to handle customized ports too +void inputdevice_swap_compa_ports (struct uae_prefs *prefs, int portswap) +{ + struct jport tmp; + if ((prefs->jports[portswap].id == JPORT_CUSTOM || prefs->jports[portswap + 1].id == JPORT_CUSTOM)) { + int *swaps[2]; + swaps[0] = rem_ports[portswap]; + swaps[1] = rem_ports[portswap + 1]; + for (int l = 0; l < MAX_INPUT_DEVICES; l++) { + swapjoydevice (&prefs->joystick_settings[GAMEPORT_INPUT_SETTINGS][l], swaps); + swapjoydevice (&prefs->mouse_settings[GAMEPORT_INPUT_SETTINGS][l], swaps); + swapjoydevice (&prefs->keyboard_settings[GAMEPORT_INPUT_SETTINGS][l], swaps); + } + } + memcpy (&tmp, &prefs->jports[portswap], sizeof (struct jport)); + memcpy (&prefs->jports[portswap], &prefs->jports[portswap + 1], sizeof (struct jport)); + memcpy (&prefs->jports[portswap + 1], &tmp, sizeof (struct jport)); + inputdevice_updateconfig (prefs); +} + +// swap device "devnum" ports 0<>1 and 2<>3 void inputdevice_swap_ports (struct uae_prefs *p, int devnum) { const struct inputdevice_functions *idf = getidf (devnum); @@ -4264,6 +4809,7 @@ void inputdevice_swap_ports (struct uae_prefs *p, int devnum) } } +// copy whole configuration #x-slot to another void inputdevice_copy_single_config (struct uae_prefs *p, int src, int dst, int devnum) { if (src == dst) @@ -4282,16 +4828,16 @@ void inputdevice_acquire (int allmode) inputdevice_unacquire (); for (i = 0; i < MAX_INPUT_DEVICES; i++) { - if (use_joysticks[i] || (allmode && !idev[IDTYPE_JOYSTICK].get_flags (i))) + if ((use_joysticks[i] && allmode >= 0) || (allmode && !idev[IDTYPE_JOYSTICK].get_flags (i))) idev[IDTYPE_JOYSTICK].acquire (i, 0); } for (i = 0; i < MAX_INPUT_DEVICES; i++) { - if (use_mice[i] || (allmode && !idev[IDTYPE_MOUSE].get_flags (i))) - idev[IDTYPE_MOUSE].acquire (i, 0); + if ((use_mice[i] && allmode >= 0) || (allmode && !idev[IDTYPE_MOUSE].get_flags (i))) + idev[IDTYPE_MOUSE].acquire (i, allmode < 0); } for (i = 0; i < MAX_INPUT_DEVICES; i++) { - if (use_keyboards[i]) - idev[IDTYPE_KEYBOARD].acquire (i, 0); + if ((use_keyboards[i] && allmode >= 0) || (allmode < 0 && !idev[IDTYPE_KEYBOARD].get_flags (i))) + idev[IDTYPE_KEYBOARD].acquire (i, allmode < 0); } // if (!input_acquired) // write_log (L"input devices acquired (%s)\n", allmode ? "all" : "selected only"); @@ -4315,78 +4861,95 @@ void inputdevice_unacquire (void) 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); - write_log (L"%s: %s %d\n", idev[type].get_friendlyname (num), tmp, state); + if (testmode_count >= TESTMODE_MAX) + return; + if (type == IDTYPE_KEYBOARD) { + if (wnum == 0x100) { + wnum = -1; + } else { + struct uae_input_device *na = &keyboards[num]; + int j = 0; + while (j < MAX_INPUT_DEVICE_EVENTS && na->extra[j][0] >= 0) { + if (na->extra[j][0] == wnum) { + wnum = j; + break; + } + j++; + } + if (j >= MAX_INPUT_DEVICE_EVENTS || na->extra[j][0] < 0) + type = -1; + } + } + // wait until previous event is released before accepting new ones + for (int i = 0; i < TESTMODE_MAX; i++) { + struct teststore *ts2 = &testmode_wait[i]; + if (ts2->testmode_num < 0) + continue; + if (ts2->testmode_num != num || ts2->testmode_type != type || ts2->testmode_wtype != wtype || ts2->testmode_wnum != wnum) + continue; + if (state) + continue; + ts2->testmode_num = -1; + } + if (!state) + return; + + //write_log (L"%d %d %d %d %d\n", type, num, wtype, wnum, state); + struct teststore *ts = &testmode_data[testmode_count]; + ts->testmode_type = type; + ts->testmode_num = num; + ts->testmode_wtype = wtype; + ts->testmode_wnum = wnum; + ts->testmode_state = state; + testmode_count++; } int inputdevice_istest (void) { return testmode; } +void inputdevice_settest (int set) +{ + testmode = set; + testmode_count = 0; + testmode_wait[0].testmode_num = -1; + testmode_wait[1].testmode_num = -1; +} -int inputdevice_testread (TCHAR *name) +int inputdevice_testread_count (void) { - testmode = 1; - idev[IDTYPE_KEYBOARD].read (); - idev[IDTYPE_JOYSTICK].read (); - idev[IDTYPE_MOUSE].read (); + inputdevice_read (); if (testmode != 1) { testmode = 0; - return 1; + return -1; } - testmode = 0; - return 0; + return testmode_count; } -static int ignoreoldinput (int joy) +int inputdevice_testread (int *devnum, int *wtype, int *state) { - if (!use_joysticks[joy]) - return 0; - if (currprefs.input_selected_setting == 0) { - if (jsem_isjoy (0, &currprefs) != joy && jsem_isjoy (1, &currprefs) != joy && - jsem_isjoy (2, &currprefs) != joy && jsem_isjoy (3, &currprefs) != joy) - return 1; + inputdevice_read (); + if (testmode != 1) { + testmode = 0; + return -1; + } + if (testmode_count > 0) { + testmode_count--; + struct teststore *ts = &testmode_data[testmode_count]; + *devnum = getdevnum (ts->testmode_type, ts->testmode_num); + *wtype = idev[ts->testmode_type].get_widget_first (ts->testmode_num, ts->testmode_wtype) + ts->testmode_wnum; + *state = ts->testmode_state; + if (ts->testmode_state) + memcpy (&testmode_wait[testmode_count], ts, sizeof (struct teststore)); + return 1; } return 0; } -void do_fake_joystick (int nr, int *fake) -{ - struct uae_input_device *id1; - struct uae_input_device2 *id2; - int state, i, axis; - - nr = compatibility_device[nr]; - id1 = &joysticks[nr]; - id2 = &joysticks2[nr]; - - axis = 0; - state = fake[1] ? -1 : (fake[2] ? 1 : 0); - for (i = 0; i < MAX_INPUT_SUB_EVENT; i++) - handle_input_event (id1->eventid[ID_AXIS_OFFSET + axis][i], state, 1, - id1->flags[ID_AXIS_OFFSET + axis][i]); - id2->states[axis] = state; - - axis = 1; - state = fake[0] ? -1 : (fake[3] ? 1 : 0); - for (i = 0; i < MAX_INPUT_SUB_EVENT; i++) - handle_input_event (id1->eventid[ID_AXIS_OFFSET + axis][i], state, 1, - id1->flags[ID_AXIS_OFFSET + axis][i]); - id2->states[axis] = state; - - setbuttonstateall (id1, id2, 0, fake[4] ? 1 : 0); - setbuttonstateall (id1, id2, 1, fake[5] ? 1 : 0); - setbuttonstateall (id1, id2, 2, fake[6] ? 1 : 0); -} - /* Call this function when host machine's joystick/joypad/etc button state changes * This function translates button events to Amiga joybutton/joyaxis/keyboard events */ @@ -4399,11 +4962,17 @@ void do_fake_joystick (int nr, int *fake) void setjoybuttonstate (int joy, int button, int state) { + if (testmode) { + inputdevice_testrecord (IDTYPE_JOYSTICK, joy, IDEV_WIDGET_BUTTON, button, state); + return; + } +#if 0 if (ignoreoldinput (joy)) { if (state) switchdevice (&joysticks[joy], button, 1); return; } +#endif setbuttonstateall (&joysticks[joy], &joysticks2[joy], button, state ? 1 : 0); } @@ -4413,8 +4982,10 @@ void setjoybuttonstateall (int joy, uae_u32 buttonbits, uae_u32 buttonmask) { int i; +#if 0 if (ignoreoldinput (joy)) return; +#endif for (i = 0; i < ID_BUTTON_TOTAL; i++) { if (buttonmask & (1 << i)) setbuttonstateall (&joysticks[joy], &joysticks2[joy], i, (buttonbits & (1 << i)) ? 1 : 0); @@ -4467,17 +5038,16 @@ void setjoystickstate (int joy, int axis, int state, int max) v2 = 0; if (v1 == v2) return; - if (!joysticks[joy].enabled || ignoreoldinput(joy)) { + if (!joysticks[joy].enabled) { if (v1) switchdevice (&joysticks[joy], axis * 2 + (v1 < 0 ? 0 : 1), 0); return; } for (i = 0; i < MAX_INPUT_SUB_EVENT; i++) - handle_input_event (id->eventid[ID_AXIS_OFFSET + axis][i], state, max, - id->flags[ID_AXIS_OFFSET + axis][i]); + handle_input_event (id->eventid[ID_AXIS_OFFSET + axis][i], state, max, id->flags[ID_AXIS_OFFSET + axis][i]); id2->states[axis] = state; } -int getjoystickstate(int joy) +int getjoystickstate (int joy) { if (testmode) return 1; @@ -4494,6 +5064,8 @@ void setmousestate (int mouse, int axis, int data, int isabs) if (testmode) { inputdevice_testrecord (IDTYPE_MOUSE, mouse, IDEV_WIDGET_AXIS, axis, data); + // fake "release" event + inputdevice_testrecord (IDTYPE_MOUSE, mouse, IDEV_WIDGET_AXIS, axis, 0); return; } if (!mice[mouse].enabled) { @@ -4661,7 +5233,7 @@ int inputdevice_joyport_config (struct uae_prefs *p, TCHAR *value, int portnum, break; case 0: { - int start = -1, got = 0; + int start = JPORT_NONE, got = 0; TCHAR *pp = 0; if (_tcsncmp (value, L"kbd", 3) == 0) { start = JSEM_KBDLAYOUT; @@ -4677,6 +5249,9 @@ int inputdevice_joyport_config (struct uae_prefs *p, TCHAR *value, int portnum, got = 1; } else if (_tcscmp (value, L"none") == 0) { got = 2; + } else if (_tcscmp (value, L"custom") == 0) { + got = 2; + start = JPORT_CUSTOM; } if (got) { if (pp) { @@ -4704,25 +5279,29 @@ int inputdevice_joyport_config (struct uae_prefs *p, TCHAR *value, int portnum, return 0; } -int inputdevice_getjoyportdevice (int jport) +int inputdevice_getjoyportdevice (int port, int val) { int idx; - if (jport < 0) { + if (val == JPORT_CUSTOM) { + idx = inputdevice_get_device_total (IDTYPE_JOYSTICK) + JSEM_LASTKBD; + if (port < 2) + idx += inputdevice_get_device_total (IDTYPE_MOUSE); + } else if (val < 0) { idx = -1; - } else if (jport >= JSEM_MICE) { - idx = jport - JSEM_MICE; + } else if (val >= JSEM_MICE) { + idx = val - JSEM_MICE; if (idx >= inputdevice_get_device_total (IDTYPE_MOUSE)) idx = 0; else idx += inputdevice_get_device_total (IDTYPE_JOYSTICK); idx += JSEM_LASTKBD; - } else if (jport >= JSEM_JOYS) { - idx = jport - JSEM_JOYS; + } else if (val >= JSEM_JOYS) { + idx = val - JSEM_JOYS; if (idx >= inputdevice_get_device_total (IDTYPE_JOYSTICK)) idx = 0; idx += JSEM_LASTKBD; } else { - idx = jport - JSEM_KBDLAYOUT; + idx = val - JSEM_KBDLAYOUT; } return idx; } diff --git a/inputevents.def b/inputevents.def index 29d58baf..fae09f51 100644 --- a/inputevents.def +++ b/inputevents.def @@ -354,7 +354,7 @@ DEFEVENT(SPC_DISK_NEXT3,L"Next disk image in DF3:",AM_K,0,0,AKS_DISK_NEXT3) DEFEVENT(SPC_INPUT_CONFIG1,L"Select Input Configuration #1",AM_K,0,0,AKS_INPUT_CONFIG_1) DEFEVENT(SPC_INPUT_CONFIG2,L"Select Input Configuration #2",AM_K,0,0,AKS_INPUT_CONFIG_2) DEFEVENT(SPC_INPUT_CONFIG3,L"Select Input Configuration #3",AM_K,0,0,AKS_INPUT_CONFIG_3) -DEFEVENT(SPC_INPUT_CONFIG4,L"Select Input Configuration #4",AM_K,0,0,AKS_INPUT_CONFIG_4) +DEFEVENT(SPC_INPUT_CONFIG4,L"Select GamePorts Input Configuration",AM_K,0,0,AKS_INPUT_CONFIG_4) DEFEVENT(SPC_ARCADIA_DIAGNOSTICS,L"Arcadia diagnostics dip switch",AM_K,0,0,AKS_ARCADIADIAGNOSTICS) DEFEVENT(SPC_ARCADIA_PLAYER1,L"Arcadia player 1",AM_K,0,0,AKS_ARCADIAPLY1) diff --git a/jit/compemu.h b/jit/compemu.h index 74083f03..b15051de 100644 --- a/jit/compemu.h +++ b/jit/compemu.h @@ -518,9 +518,6 @@ extern void empty_optimizer(void); #define comp_get_iword(o) do_get_mem_word((uae_u16 *)(comp_pc_p + (o))) #define comp_get_ilong(o) do_get_mem_long((uae_u32 *)(comp_pc_p + (o))) -/* Preferences handling */ -int check_prefs_changed_comp (void); - struct blockinfo_t; typedef struct dep_t { diff --git a/jit/compemu_raw_x86.cpp b/jit/compemu_raw_x86.cpp index 485b2b4f..007d08a8 100644 --- a/jit/compemu_raw_x86.cpp +++ b/jit/compemu_raw_x86.cpp @@ -1,9 +1,9 @@ /* This should eventually end up in machdep/, but for now, x86 is the - only target, and it's easier this way... */ +only target, and it's easier this way... */ /************************************************************************* - * Some basic information about the the target CPU * - *************************************************************************/ +* Some basic information about the the target CPU * +*************************************************************************/ #define EAX_INDEX 0 #define ECX_INDEX 1 @@ -73,11 +73,11 @@ uae_u8 can_word[]={0,1,2,3,5,6,7,0xff}; uae_u8 call_saved[]={0,0,0,0,1,0,0,0}; /* This *should* be the same as call_saved. But: - - We might not really know which registers are saved, and which aren't, - so we need to preserve some, but don't want to rely on everyone else - also saving those registers - - Special registers (such like the stack pointer) should not be "preserved" - by pushing, even though they are "saved" across function calls +- We might not really know which registers are saved, and which aren't, +so we need to preserve some, but don't want to rely on everyone else +also saving those registers +- Special registers (such like the stack pointer) should not be "preserved" +by pushing, even though they are "saved" across function calls */ uae_u8 need_to_preserve[]={1,1,1,1,0,1,1,1}; @@ -116,24 +116,24 @@ uae_u8 need_to_preserve[]={1,1,1,1,0,1,1,1}; #define CLOBBER_BSF clobber_flags() /************************************************************************* - * Actual encoding of the instructions on the target CPU * - *************************************************************************/ +* Actual encoding of the instructions on the target CPU * +*************************************************************************/ //#include "compemu_optimizer_x86.c" STATIC_INLINE uae_u16 swap16(uae_u16 x) { - return ((x&0xff00)>>8)|((x&0x00ff)<<8); + return ((x&0xff00)>>8)|((x&0x00ff)<<8); } STATIC_INLINE uae_u32 swap32(uae_u32 x) { - return ((x&0xff00)<<8)|((x&0x00ff)<<24)|((x&0xff0000)>>8)|((x&0xff000000)>>24); + return ((x&0xff00)<<8)|((x&0x00ff)<<24)|((x&0xff0000)>>8)|((x&0xff000000)>>24); } STATIC_INLINE int isbyte(uae_s32 x) { - return (x>=-128 && x<=127); + return (x>=-128 && x<=127); } LOWFUNC(NONE,WRITE,1,raw_push_l_r,(R4 r)) @@ -142,13 +142,13 @@ LOWFUNC(NONE,WRITE,1,raw_push_l_r,(R4 r)) } LENDFUNC(NONE,WRITE,1,raw_push_l_r,(R4 r)) -LOWFUNC(NONE,READ,1,raw_pop_l_r,(R4 r)) + LOWFUNC(NONE,READ,1,raw_pop_l_r,(R4 r)) { emit_byte(0x58+r); } LENDFUNC(NONE,READ,1,raw_pop_l_r,(R4 r)) -LOWFUNC(WRITE,NONE,2,raw_bt_l_ri,(R4 r, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_bt_l_ri,(R4 r, IMM i)) { emit_byte(0x0f); emit_byte(0xba); @@ -157,7 +157,7 @@ LOWFUNC(WRITE,NONE,2,raw_bt_l_ri,(R4 r, IMM i)) } LENDFUNC(WRITE,NONE,2,raw_bt_l_ri,(R4 r, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_bt_l_rr,(R4 r, R4 b)) + LOWFUNC(WRITE,NONE,2,raw_bt_l_rr,(R4 r, R4 b)) { emit_byte(0x0f); emit_byte(0xa3); @@ -165,7 +165,7 @@ LOWFUNC(WRITE,NONE,2,raw_bt_l_rr,(R4 r, R4 b)) } LENDFUNC(WRITE,NONE,2,raw_bt_l_rr,(R4 r, R4 b)) -LOWFUNC(WRITE,NONE,2,raw_btc_l_ri,(RW4 r, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_btc_l_ri,(RW4 r, IMM i)) { emit_byte(0x0f); emit_byte(0xba); @@ -174,7 +174,7 @@ LOWFUNC(WRITE,NONE,2,raw_btc_l_ri,(RW4 r, IMM i)) } LENDFUNC(WRITE,NONE,2,raw_btc_l_ri,(RW4 r, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_btc_l_rr,(RW4 r, R4 b)) + LOWFUNC(WRITE,NONE,2,raw_btc_l_rr,(RW4 r, R4 b)) { emit_byte(0x0f); emit_byte(0xbb); @@ -183,7 +183,7 @@ LOWFUNC(WRITE,NONE,2,raw_btc_l_rr,(RW4 r, R4 b)) LENDFUNC(WRITE,NONE,2,raw_btc_l_rr,(RW4 r, R4 b)) -LOWFUNC(WRITE,NONE,2,raw_btr_l_ri,(RW4 r, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_btr_l_ri,(RW4 r, IMM i)) { emit_byte(0x0f); emit_byte(0xba); @@ -192,7 +192,7 @@ LOWFUNC(WRITE,NONE,2,raw_btr_l_ri,(RW4 r, IMM i)) } LENDFUNC(WRITE,NONE,2,raw_btr_l_ri,(RW4 r, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_btr_l_rr,(RW4 r, R4 b)) + LOWFUNC(WRITE,NONE,2,raw_btr_l_rr,(RW4 r, R4 b)) { emit_byte(0x0f); emit_byte(0xb3); @@ -200,7 +200,7 @@ LOWFUNC(WRITE,NONE,2,raw_btr_l_rr,(RW4 r, R4 b)) } LENDFUNC(WRITE,NONE,2,raw_btr_l_rr,(RW4 r, R4 b)) -LOWFUNC(WRITE,NONE,2,raw_bts_l_ri,(RW4 r, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_bts_l_ri,(RW4 r, IMM i)) { emit_byte(0x0f); emit_byte(0xba); @@ -209,7 +209,7 @@ LOWFUNC(WRITE,NONE,2,raw_bts_l_ri,(RW4 r, IMM i)) } LENDFUNC(WRITE,NONE,2,raw_bts_l_ri,(RW4 r, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_bts_l_rr,(RW4 r, R4 b)) + LOWFUNC(WRITE,NONE,2,raw_bts_l_rr,(RW4 r, R4 b)) { emit_byte(0x0f); emit_byte(0xab); @@ -217,1462 +217,1462 @@ LOWFUNC(WRITE,NONE,2,raw_bts_l_rr,(RW4 r, R4 b)) } LENDFUNC(WRITE,NONE,2,raw_bts_l_rr,(RW4 r, R4 b)) -LOWFUNC(WRITE,NONE,2,raw_sub_w_ri,(RW2 d, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_sub_w_ri,(RW2 d, IMM i)) { - emit_byte(0x66); - if (isbyte(i)) { - emit_byte(0x83); - emit_byte(0xe8+d); - emit_byte(i); - } - else { - emit_byte(0x81); - emit_byte(0xe8+d); - emit_word(i); - } + emit_byte(0x66); + if (isbyte(i)) { + emit_byte(0x83); + emit_byte(0xe8+d); + emit_byte(i); + } + else { + emit_byte(0x81); + emit_byte(0xe8+d); + emit_word(i); + } } LENDFUNC(WRITE,NONE,2,raw_sub_w_ri,(RW2 d, IMM i)) -LOWFUNC(NONE,WRITE,2,raw_mov_l_mi,(MEMW d, IMM s)) + LOWFUNC(NONE,WRITE,2,raw_mov_l_mi,(MEMW d, IMM s)) { - emit_byte(0xc7); - emit_byte(0x05); - emit_long(d); - emit_long(s); + emit_byte(0xc7); + emit_byte(0x05); + emit_long(d); + emit_long(s); } LENDFUNC(NONE,WRITE,2,raw_mov_l_mi,(MEMW d, IMM s)) -LOWFUNC(NONE,WRITE,2,raw_mov_w_mi,(MEMW d, IMM s)) + LOWFUNC(NONE,WRITE,2,raw_mov_w_mi,(MEMW d, IMM s)) { - emit_byte(0x66); - emit_byte(0xc7); - emit_byte(0x05); - emit_long(d); - emit_word(s); + emit_byte(0x66); + emit_byte(0xc7); + emit_byte(0x05); + emit_long(d); + emit_word(s); } LENDFUNC(NONE,WRITE,2,raw_mov_w_mi,(MEMW d, IMM s)) -LOWFUNC(NONE,WRITE,2,raw_mov_b_mi,(MEMW d, IMM s)) + LOWFUNC(NONE,WRITE,2,raw_mov_b_mi,(MEMW d, IMM s)) { - emit_byte(0xc6); - emit_byte(0x05); - emit_long(d); - emit_byte(s); + emit_byte(0xc6); + emit_byte(0x05); + emit_long(d); + emit_byte(s); } LENDFUNC(NONE,WRITE,2,raw_mov_b_mi,(MEMW d, IMM s)) -LOWFUNC(WRITE,RMW,2,raw_rol_b_mi,(MEMRW d, IMM i)) + LOWFUNC(WRITE,RMW,2,raw_rol_b_mi,(MEMRW d, IMM i)) { - emit_byte(0xc0); - emit_byte(0x05); - emit_long(d); - emit_byte(i); + emit_byte(0xc0); + emit_byte(0x05); + emit_long(d); + emit_byte(i); } LENDFUNC(WRITE,RMW,2,raw_rol_b_mi,(MEMRW d, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_rol_b_ri,(RW1 r, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_rol_b_ri,(RW1 r, IMM i)) { - emit_byte(0xc0); - emit_byte(0xc0+r); - emit_byte(i); + emit_byte(0xc0); + emit_byte(0xc0+r); + emit_byte(i); } LENDFUNC(WRITE,NONE,2,raw_rol_b_ri,(RW1 r, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_rol_w_ri,(RW2 r, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_rol_w_ri,(RW2 r, IMM i)) { - emit_byte(0x66); - emit_byte(0xc1); - emit_byte(0xc0+r); - emit_byte(i); + emit_byte(0x66); + emit_byte(0xc1); + emit_byte(0xc0+r); + emit_byte(i); } LENDFUNC(WRITE,NONE,2,raw_rol_w_ri,(RW2 r, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_rol_l_ri,(RW4 r, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_rol_l_ri,(RW4 r, IMM i)) { - emit_byte(0xc1); - emit_byte(0xc0+r); - emit_byte(i); + emit_byte(0xc1); + emit_byte(0xc0+r); + emit_byte(i); } LENDFUNC(WRITE,NONE,2,raw_rol_l_ri,(RW4 r, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_rol_l_rr,(RW4 d, R1 r)) + LOWFUNC(WRITE,NONE,2,raw_rol_l_rr,(RW4 d, R1 r)) { - emit_byte(0xd3); - emit_byte(0xc0+d); + emit_byte(0xd3); + emit_byte(0xc0+d); } LENDFUNC(WRITE,NONE,2,raw_rol_l_rr,(RW4 d, R1 r)) -LOWFUNC(WRITE,NONE,2,raw_rol_w_rr,(RW2 d, R1 r)) + LOWFUNC(WRITE,NONE,2,raw_rol_w_rr,(RW2 d, R1 r)) { - emit_byte(0x66); - emit_byte(0xd3); - emit_byte(0xc0+d); + emit_byte(0x66); + emit_byte(0xd3); + emit_byte(0xc0+d); } LENDFUNC(WRITE,NONE,2,raw_rol_w_rr,(RW2 d, R1 r)) -LOWFUNC(WRITE,NONE,2,raw_rol_b_rr,(RW1 d, R1 r)) + LOWFUNC(WRITE,NONE,2,raw_rol_b_rr,(RW1 d, R1 r)) { - emit_byte(0xd2); - emit_byte(0xc0+d); + emit_byte(0xd2); + emit_byte(0xc0+d); } LENDFUNC(WRITE,NONE,2,raw_rol_b_rr,(RW1 d, R1 r)) -LOWFUNC(WRITE,NONE,2,raw_shll_l_rr,(RW4 d, R1 r)) + LOWFUNC(WRITE,NONE,2,raw_shll_l_rr,(RW4 d, R1 r)) { - emit_byte(0xd3); - emit_byte(0xe0+d); + emit_byte(0xd3); + emit_byte(0xe0+d); } LENDFUNC(WRITE,NONE,2,raw_shll_l_rr,(RW4 d, R1 r)) -LOWFUNC(WRITE,NONE,2,raw_shll_w_rr,(RW2 d, R1 r)) + LOWFUNC(WRITE,NONE,2,raw_shll_w_rr,(RW2 d, R1 r)) { - emit_byte(0x66); - emit_byte(0xd3); - emit_byte(0xe0+d); + emit_byte(0x66); + emit_byte(0xd3); + emit_byte(0xe0+d); } LENDFUNC(WRITE,NONE,2,raw_shll_w_rr,(RW2 d, R1 r)) -LOWFUNC(WRITE,NONE,2,raw_shll_b_rr,(RW1 d, R1 r)) + LOWFUNC(WRITE,NONE,2,raw_shll_b_rr,(RW1 d, R1 r)) { - emit_byte(0xd2); - emit_byte(0xe0+d); + emit_byte(0xd2); + emit_byte(0xe0+d); } LENDFUNC(WRITE,NONE,2,raw_shll_b_rr,(RW1 d, R1 r)) -LOWFUNC(WRITE,NONE,2,raw_ror_b_ri,(RW1 r, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_ror_b_ri,(RW1 r, IMM i)) { - emit_byte(0xc0); - emit_byte(0xc8+r); - emit_byte(i); + emit_byte(0xc0); + emit_byte(0xc8+r); + emit_byte(i); } LENDFUNC(WRITE,NONE,2,raw_ror_b_ri,(RW1 r, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_ror_w_ri,(RW2 r, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_ror_w_ri,(RW2 r, IMM i)) { - emit_byte(0x66); - emit_byte(0xc1); - emit_byte(0xc8+r); - emit_byte(i); + emit_byte(0x66); + emit_byte(0xc1); + emit_byte(0xc8+r); + emit_byte(i); } LENDFUNC(WRITE,NONE,2,raw_ror_w_ri,(RW2 r, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_ror_l_ri,(RW4 r, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_ror_l_ri,(RW4 r, IMM i)) { - emit_byte(0xc1); - emit_byte(0xc8+r); - emit_byte(i); + emit_byte(0xc1); + emit_byte(0xc8+r); + emit_byte(i); } LENDFUNC(WRITE,NONE,2,raw_ror_l_ri,(RW4 r, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_ror_l_rr,(RW4 d, R1 r)) + LOWFUNC(WRITE,NONE,2,raw_ror_l_rr,(RW4 d, R1 r)) { - emit_byte(0xd3); - emit_byte(0xc8+d); + emit_byte(0xd3); + emit_byte(0xc8+d); } LENDFUNC(WRITE,NONE,2,raw_ror_l_rr,(RW4 d, R1 r)) -LOWFUNC(WRITE,NONE,2,raw_ror_w_rr,(RW2 d, R1 r)) + LOWFUNC(WRITE,NONE,2,raw_ror_w_rr,(RW2 d, R1 r)) { - emit_byte(0x66); - emit_byte(0xd3); - emit_byte(0xc8+d); + emit_byte(0x66); + emit_byte(0xd3); + emit_byte(0xc8+d); } LENDFUNC(WRITE,NONE,2,raw_ror_w_rr,(RW2 d, R1 r)) -LOWFUNC(WRITE,NONE,2,raw_ror_b_rr,(RW1 d, R1 r)) + LOWFUNC(WRITE,NONE,2,raw_ror_b_rr,(RW1 d, R1 r)) { - emit_byte(0xd2); - emit_byte(0xc8+d); + emit_byte(0xd2); + emit_byte(0xc8+d); } LENDFUNC(WRITE,NONE,2,raw_ror_b_rr,(RW1 d, R1 r)) -LOWFUNC(WRITE,NONE,2,raw_shrl_l_rr,(RW4 d, R1 r)) + LOWFUNC(WRITE,NONE,2,raw_shrl_l_rr,(RW4 d, R1 r)) { - emit_byte(0xd3); - emit_byte(0xe8+d); + emit_byte(0xd3); + emit_byte(0xe8+d); } LENDFUNC(WRITE,NONE,2,raw_shrl_l_rr,(RW4 d, R1 r)) -LOWFUNC(WRITE,NONE,2,raw_shrl_w_rr,(RW2 d, R1 r)) + LOWFUNC(WRITE,NONE,2,raw_shrl_w_rr,(RW2 d, R1 r)) { - emit_byte(0x66); - emit_byte(0xd3); - emit_byte(0xe8+d); + emit_byte(0x66); + emit_byte(0xd3); + emit_byte(0xe8+d); } LENDFUNC(WRITE,NONE,2,raw_shrl_w_rr,(RW2 d, R1 r)) -LOWFUNC(WRITE,NONE,2,raw_shrl_b_rr,(RW1 d, R1 r)) + LOWFUNC(WRITE,NONE,2,raw_shrl_b_rr,(RW1 d, R1 r)) { - emit_byte(0xd2); - emit_byte(0xe8+d); + emit_byte(0xd2); + emit_byte(0xe8+d); } LENDFUNC(WRITE,NONE,2,raw_shrl_b_rr,(RW1 d, R1 r)) -LOWFUNC(WRITE,NONE,2,raw_shra_l_rr,(RW4 d, R1 r)) + LOWFUNC(WRITE,NONE,2,raw_shra_l_rr,(RW4 d, R1 r)) { - emit_byte(0xd3); - emit_byte(0xf8+d); + emit_byte(0xd3); + emit_byte(0xf8+d); } LENDFUNC(WRITE,NONE,2,raw_shra_l_rr,(RW4 d, R1 r)) -LOWFUNC(WRITE,NONE,2,raw_shra_w_rr,(RW2 d, R1 r)) + LOWFUNC(WRITE,NONE,2,raw_shra_w_rr,(RW2 d, R1 r)) { - emit_byte(0x66); - emit_byte(0xd3); - emit_byte(0xf8+d); + emit_byte(0x66); + emit_byte(0xd3); + emit_byte(0xf8+d); } LENDFUNC(WRITE,NONE,2,raw_shra_w_rr,(RW2 d, R1 r)) -LOWFUNC(WRITE,NONE,2,raw_shra_b_rr,(RW1 d, R1 r)) + LOWFUNC(WRITE,NONE,2,raw_shra_b_rr,(RW1 d, R1 r)) { - emit_byte(0xd2); - emit_byte(0xf8+d); + emit_byte(0xd2); + emit_byte(0xf8+d); } LENDFUNC(WRITE,NONE,2,raw_shra_b_rr,(RW1 d, R1 r)) -LOWFUNC(WRITE,NONE,2,raw_shll_l_ri,(RW4 r, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_shll_l_ri,(RW4 r, IMM i)) { - emit_byte(0xc1); - emit_byte(0xe0+r); - emit_byte(i); + emit_byte(0xc1); + emit_byte(0xe0+r); + emit_byte(i); } LENDFUNC(WRITE,NONE,2,raw_shll_l_ri,(RW4 r, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_shll_w_ri,(RW2 r, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_shll_w_ri,(RW2 r, IMM i)) { - emit_byte(0x66); - emit_byte(0xc1); - emit_byte(0xe0+r); - emit_byte(i); + emit_byte(0x66); + emit_byte(0xc1); + emit_byte(0xe0+r); + emit_byte(i); } LENDFUNC(WRITE,NONE,2,raw_shll_w_ri,(RW2 r, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_shll_b_ri,(RW1 r, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_shll_b_ri,(RW1 r, IMM i)) { - emit_byte(0xc0); - emit_byte(0xe0+r); - emit_byte(i); + emit_byte(0xc0); + emit_byte(0xe0+r); + emit_byte(i); } LENDFUNC(WRITE,NONE,2,raw_shll_b_ri,(RW1 r, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_shrl_l_ri,(RW4 r, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_shrl_l_ri,(RW4 r, IMM i)) { - emit_byte(0xc1); - emit_byte(0xe8+r); - emit_byte(i); + emit_byte(0xc1); + emit_byte(0xe8+r); + emit_byte(i); } LENDFUNC(WRITE,NONE,2,raw_shrl_l_ri,(RW4 r, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_shrl_w_ri,(RW2 r, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_shrl_w_ri,(RW2 r, IMM i)) { - emit_byte(0x66); - emit_byte(0xc1); - emit_byte(0xe8+r); - emit_byte(i); + emit_byte(0x66); + emit_byte(0xc1); + emit_byte(0xe8+r); + emit_byte(i); } LENDFUNC(WRITE,NONE,2,raw_shrl_w_ri,(RW2 r, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_shrl_b_ri,(RW1 r, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_shrl_b_ri,(RW1 r, IMM i)) { - emit_byte(0xc0); - emit_byte(0xe8+r); - emit_byte(i); + emit_byte(0xc0); + emit_byte(0xe8+r); + emit_byte(i); } LENDFUNC(WRITE,NONE,2,raw_shrl_b_ri,(RW1 r, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_shra_l_ri,(RW4 r, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_shra_l_ri,(RW4 r, IMM i)) { - emit_byte(0xc1); - emit_byte(0xf8+r); - emit_byte(i); + emit_byte(0xc1); + emit_byte(0xf8+r); + emit_byte(i); } LENDFUNC(WRITE,NONE,2,raw_shra_l_ri,(RW4 r, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_shra_w_ri,(RW2 r, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_shra_w_ri,(RW2 r, IMM i)) { - emit_byte(0x66); - emit_byte(0xc1); - emit_byte(0xf8+r); - emit_byte(i); + emit_byte(0x66); + emit_byte(0xc1); + emit_byte(0xf8+r); + emit_byte(i); } LENDFUNC(WRITE,NONE,2,raw_shra_w_ri,(RW2 r, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_shra_b_ri,(RW1 r, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_shra_b_ri,(RW1 r, IMM i)) { - emit_byte(0xc0); - emit_byte(0xf8+r); - emit_byte(i); + emit_byte(0xc0); + emit_byte(0xf8+r); + emit_byte(i); } LENDFUNC(WRITE,NONE,2,raw_shra_b_ri,(RW1 r, IMM i)) -LOWFUNC(WRITE,NONE,1,raw_sahf,(R2 dummy_ah)) + LOWFUNC(WRITE,NONE,1,raw_sahf,(R2 dummy_ah)) { - emit_byte(0x9e); + emit_byte(0x9e); } LENDFUNC(WRITE,NONE,1,raw_sahf,(R2 dummy_ah)) -LOWFUNC(NONE,NONE,1,raw_cpuid,(R4 dummy_eax)) + LOWFUNC(NONE,NONE,1,raw_cpuid,(R4 dummy_eax)) { - emit_byte(0x0f); - emit_byte(0xa2); + emit_byte(0x0f); + emit_byte(0xa2); } LENDFUNC(NONE,NONE,1,raw_cpuid,(R4 dummy_eax)) -LOWFUNC(READ,NONE,1,raw_lahf,(W2 dummy_ah)) + LOWFUNC(READ,NONE,1,raw_lahf,(W2 dummy_ah)) { - emit_byte(0x9f); + emit_byte(0x9f); } LENDFUNC(READ,NONE,1,raw_lahf,(W2 dummy_ah)) -LOWFUNC(READ,NONE,2,raw_setcc,(W1 d, IMM cc)) + LOWFUNC(READ,NONE,2,raw_setcc,(W1 d, IMM cc)) { - emit_byte(0x0f); - emit_byte(0x90+cc); - emit_byte(0xc0+d); + emit_byte(0x0f); + emit_byte(0x90+cc); + emit_byte(0xc0+d); } LENDFUNC(READ,NONE,2,raw_setcc,(W1 d, IMM cc)) -LOWFUNC(READ,WRITE,2,raw_setcc_m,(MEMW d, IMM cc)) + LOWFUNC(READ,WRITE,2,raw_setcc_m,(MEMW d, IMM cc)) { - emit_byte(0x0f); - emit_byte(0x90+cc); - emit_byte(0x05); - emit_long(d); + emit_byte(0x0f); + emit_byte(0x90+cc); + emit_byte(0x05); + emit_long(d); } LENDFUNC(READ,WRITE,2,raw_setcc_m,(MEMW d, IMM cc)) -LOWFUNC(READ,NONE,3,raw_cmov_b_rr,(RW1 d, R1 s, IMM cc)) + LOWFUNC(READ,NONE,3,raw_cmov_b_rr,(RW1 d, R1 s, IMM cc)) { /* replacement using branch and mov */ int uncc=(cc^1); emit_byte(0x70+uncc); emit_byte(3); /* skip next 2 bytes if not cc=true */ - emit_byte(0x88); - emit_byte(0xc0+8*s+d); + emit_byte(0x88); + emit_byte(0xc0+8*s+d); } LENDFUNC(READ,NONE,3,raw_cmov_b_rr,(RW1 d, R1 s, IMM cc)) -LOWFUNC(READ,NONE,3,raw_cmov_w_rr,(RW2 d, R2 s, IMM cc)) + LOWFUNC(READ,NONE,3,raw_cmov_w_rr,(RW2 d, R2 s, IMM cc)) { - if (have_cmov) { - emit_byte(0x66); - emit_byte(0x0f); - emit_byte(0x40+cc); - emit_byte(0xc0+8*d+s); - } - else { /* replacement using branch and mov */ - int uncc=(cc^1); - emit_byte(0x70+uncc); - emit_byte(3); /* skip next 3 bytes if not cc=true */ - emit_byte(0x66); - emit_byte(0x89); - emit_byte(0xc0+8*s+d); - } + if (have_cmov) { + emit_byte(0x66); + emit_byte(0x0f); + emit_byte(0x40+cc); + emit_byte(0xc0+8*d+s); + } + else { /* replacement using branch and mov */ + int uncc=(cc^1); + emit_byte(0x70+uncc); + emit_byte(3); /* skip next 3 bytes if not cc=true */ + emit_byte(0x66); + emit_byte(0x89); + emit_byte(0xc0+8*s+d); + } } LENDFUNC(READ,NONE,3,raw_cmov_w_rr,(RW2 d, R2 s, IMM cc)) -LOWFUNC(READ,NONE,3,raw_cmov_l_rr,(RW4 d, R4 s, IMM cc)) + LOWFUNC(READ,NONE,3,raw_cmov_l_rr,(RW4 d, R4 s, IMM cc)) { - if (have_cmov) { - emit_byte(0x0f); - emit_byte(0x40+cc); - emit_byte(0xc0+8*d+s); - } - else { /* replacement using branch and mov */ - int uncc=(cc^1); - emit_byte(0x70+uncc); - emit_byte(2); /* skip next 2 bytes if not cc=true */ - emit_byte(0x89); - emit_byte(0xc0+8*s+d); - } + if (have_cmov) { + emit_byte(0x0f); + emit_byte(0x40+cc); + emit_byte(0xc0+8*d+s); + } + else { /* replacement using branch and mov */ + int uncc=(cc^1); + emit_byte(0x70+uncc); + emit_byte(2); /* skip next 2 bytes if not cc=true */ + emit_byte(0x89); + emit_byte(0xc0+8*s+d); + } } LENDFUNC(READ,NONE,3,raw_cmov_l_rr,(RW4 d, R4 s, IMM cc)) -LOWFUNC(WRITE,NONE,2,raw_bsf_l_rr,(W4 d, R4 s)) + LOWFUNC(WRITE,NONE,2,raw_bsf_l_rr,(W4 d, R4 s)) { - emit_byte(0x0f); - emit_byte(0xbc); - emit_byte(0xc0+8*d+s); + emit_byte(0x0f); + emit_byte(0xbc); + emit_byte(0xc0+8*d+s); } LENDFUNC(WRITE,NONE,2,raw_bsf_l_rr,(W4 d, R4 s)) -LOWFUNC(NONE,NONE,2,raw_sign_extend_16_rr,(W4 d, R2 s)) + LOWFUNC(NONE,NONE,2,raw_sign_extend_16_rr,(W4 d, R2 s)) { - emit_byte(0x0f); - emit_byte(0xbf); - emit_byte(0xc0+8*d+s); + emit_byte(0x0f); + emit_byte(0xbf); + emit_byte(0xc0+8*d+s); } LENDFUNC(NONE,NONE,2,raw_sign_extend_16_rr,(W4 d, R2 s)) -LOWFUNC(NONE,NONE,2,raw_sign_extend_8_rr,(W4 d, R1 s)) + LOWFUNC(NONE,NONE,2,raw_sign_extend_8_rr,(W4 d, R1 s)) { - emit_byte(0x0f); - emit_byte(0xbe); - emit_byte(0xc0+8*d+s); + emit_byte(0x0f); + emit_byte(0xbe); + emit_byte(0xc0+8*d+s); } LENDFUNC(NONE,NONE,2,raw_sign_extend_8_rr,(W4 d, R1 s)) -LOWFUNC(NONE,NONE,2,raw_zero_extend_16_rr,(W4 d, R2 s)) + LOWFUNC(NONE,NONE,2,raw_zero_extend_16_rr,(W4 d, R2 s)) { - emit_byte(0x0f); - emit_byte(0xb7); - emit_byte(0xc0+8*d+s); + emit_byte(0x0f); + emit_byte(0xb7); + emit_byte(0xc0+8*d+s); } LENDFUNC(NONE,NONE,2,raw_zero_extend_16_rr,(W4 d, R2 s)) -LOWFUNC(NONE,NONE,2,raw_zero_extend_8_rr,(W4 d, R1 s)) + LOWFUNC(NONE,NONE,2,raw_zero_extend_8_rr,(W4 d, R1 s)) { - emit_byte(0x0f); - emit_byte(0xb6); - emit_byte(0xc0+8*d+s); + emit_byte(0x0f); + emit_byte(0xb6); + emit_byte(0xc0+8*d+s); } LENDFUNC(NONE,NONE,2,raw_zero_extend_8_rr,(W4 d, R1 s)) -LOWFUNC(NONE,NONE,2,raw_imul_32_32,(RW4 d, R4 s)) + LOWFUNC(NONE,NONE,2,raw_imul_32_32,(RW4 d, R4 s)) { - emit_byte(0x0f); - emit_byte(0xaf); - emit_byte(0xc0+8*d+s); + emit_byte(0x0f); + emit_byte(0xaf); + emit_byte(0xc0+8*d+s); } LENDFUNC(NONE,NONE,2,raw_imul_32_32,(RW4 d, R4 s)) -LOWFUNC(NONE,NONE,2,raw_imul_64_32,(RW4 d, RW4 s)) + LOWFUNC(NONE,NONE,2,raw_imul_64_32,(RW4 d, RW4 s)) { #ifdef JIT_DEBUG - if (d!=MUL_NREG1 || s!=MUL_NREG2) { - write_log (L"JIT: Bad register in IMUL: d=%d, s=%d\n",d,s); - abort(); - } + if (d!=MUL_NREG1 || s!=MUL_NREG2) { + write_log (L"JIT: Bad register in IMUL: d=%d, s=%d\n",d,s); + abort(); + } #endif - emit_byte(0xf7); - emit_byte(0xea); + emit_byte(0xf7); + emit_byte(0xea); } LENDFUNC(NONE,NONE,2,raw_imul_64_32,(RW4 d, RW4 s)) -LOWFUNC(NONE,NONE,2,raw_mul_64_32,(RW4 d, RW4 s)) + LOWFUNC(NONE,NONE,2,raw_mul_64_32,(RW4 d, RW4 s)) { #ifdef JIT_DEBUG - if (d!=MUL_NREG1 || s!=MUL_NREG2) { - write_log (L"JIT: Bad register in MUL: d=%d, s=%d\n",d,s); - abort(); - } + if (d!=MUL_NREG1 || s!=MUL_NREG2) { + write_log (L"JIT: Bad register in MUL: d=%d, s=%d\n",d,s); + abort(); + } #endif - emit_byte(0xf7); - emit_byte(0xe2); + emit_byte(0xf7); + emit_byte(0xe2); } LENDFUNC(NONE,NONE,2,raw_mul_64_32,(RW4 d, RW4 s)) -LOWFUNC(NONE,NONE,2,raw_mov_b_rr,(W1 d, R1 s)) + LOWFUNC(NONE,NONE,2,raw_mov_b_rr,(W1 d, R1 s)) { - emit_byte(0x88); - emit_byte(0xc0+8*s+d); + emit_byte(0x88); + emit_byte(0xc0+8*s+d); } LENDFUNC(NONE,NONE,2,raw_mov_b_rr,(W1 d, R1 s)) -LOWFUNC(NONE,NONE,2,raw_mov_w_rr,(W2 d, R2 s)) + LOWFUNC(NONE,NONE,2,raw_mov_w_rr,(W2 d, R2 s)) { - emit_byte(0x66); - emit_byte(0x89); - emit_byte(0xc0+8*s+d); + emit_byte(0x66); + emit_byte(0x89); + emit_byte(0xc0+8*s+d); } LENDFUNC(NONE,NONE,2,raw_mov_w_rr,(W2 d, R2 s)) -LOWFUNC(NONE,READ,3,raw_mov_l_rrm_indexed,(W4 d, R4 baser, R4 index)) + LOWFUNC(NONE,READ,3,raw_mov_l_rrm_indexed,(W4 d, R4 baser, R4 index)) { - emit_byte(0x8b); - if (baser==5) { - emit_byte(0x44+8*d); + emit_byte(0x8b); + if (baser==5) { + emit_byte(0x44+8*d); + emit_byte(8*index+baser); + emit_byte(0); + return; + } + emit_byte(0x04+8*d); emit_byte(8*index+baser); - emit_byte(0); - return; - } - emit_byte(0x04+8*d); - emit_byte(8*index+baser); } LENDFUNC(NONE,READ,3,raw_mov_l_rrm_indexed,(W4 d, R4 baser, R4 index)) -LOWFUNC(NONE,READ,3,raw_mov_w_rrm_indexed,(W2 d, R4 baser, R4 index)) + LOWFUNC(NONE,READ,3,raw_mov_w_rrm_indexed,(W2 d, R4 baser, R4 index)) { - emit_byte(0x66); - emit_byte(0x8b); - if (baser==5) { - emit_byte(0x44+8*d); + emit_byte(0x66); + emit_byte(0x8b); + if (baser==5) { + emit_byte(0x44+8*d); + emit_byte(8*index+baser); + emit_byte(0); + return; + } + emit_byte(0x04+8*d); emit_byte(8*index+baser); - emit_byte(0); - return; - } - emit_byte(0x04+8*d); - emit_byte(8*index+baser); } LENDFUNC(NONE,READ,3,raw_mov_w_rrm_indexed,(W2 d, R4 baser, R4 index)) -LOWFUNC(NONE,READ,3,raw_mov_b_rrm_indexed,(W1 d, R4 baser, R4 index)) + LOWFUNC(NONE,READ,3,raw_mov_b_rrm_indexed,(W1 d, R4 baser, R4 index)) { - emit_byte(0x8a); - if (baser==5) { - emit_byte(0x44+8*d); + emit_byte(0x8a); + if (baser==5) { + emit_byte(0x44+8*d); + emit_byte(8*index+baser); + emit_byte(0); + return; + } + emit_byte(0x04+8*d); emit_byte(8*index+baser); - emit_byte(0); - return; - } - emit_byte(0x04+8*d); - emit_byte(8*index+baser); } LENDFUNC(NONE,READ,3,raw_mov_b_rrm_indexed,(W1 d, R4 baser, R4 index)) -LOWFUNC(NONE,WRITE,3,raw_mov_l_mrr_indexed,(R4 baser, R4 index, R4 s)) + LOWFUNC(NONE,WRITE,3,raw_mov_l_mrr_indexed,(R4 baser, R4 index, R4 s)) { - emit_byte(0x89); - if (baser==5) { - emit_byte(0x44+8*s); + emit_byte(0x89); + if (baser==5) { + emit_byte(0x44+8*s); + emit_byte(8*index+baser); + emit_byte(0); + return; + } + emit_byte(0x04+8*s); emit_byte(8*index+baser); - emit_byte(0); - return; - } - emit_byte(0x04+8*s); - emit_byte(8*index+baser); } LENDFUNC(NONE,WRITE,3,raw_mov_l_mrr_indexed,(R4 baser, R4 index, R4 s)) -LOWFUNC(NONE,WRITE,3,raw_mov_w_mrr_indexed,(R4 baser, R4 index, R2 s)) + LOWFUNC(NONE,WRITE,3,raw_mov_w_mrr_indexed,(R4 baser, R4 index, R2 s)) { - emit_byte(0x66); - emit_byte(0x89); - if (baser==5) { - emit_byte(0x44+8*s); + emit_byte(0x66); + emit_byte(0x89); + if (baser==5) { + emit_byte(0x44+8*s); + emit_byte(8*index+baser); + emit_byte(0); + return; + } + emit_byte(0x04+8*s); emit_byte(8*index+baser); - emit_byte(0); - return; - } - emit_byte(0x04+8*s); - emit_byte(8*index+baser); } LENDFUNC(NONE,WRITE,3,raw_mov_w_mrr_indexed,(R4 baser, R4 index, R2 s)) -LOWFUNC(NONE,WRITE,3,raw_mov_b_mrr_indexed,(R4 baser, R4 index, R1 s)) + LOWFUNC(NONE,WRITE,3,raw_mov_b_mrr_indexed,(R4 baser, R4 index, R1 s)) { - emit_byte(0x88); - if (baser==5) { - emit_byte(0x44+8*s); + emit_byte(0x88); + if (baser==5) { + emit_byte(0x44+8*s); + emit_byte(8*index+baser); + emit_byte(0); + return; + } + emit_byte(0x04+8*s); emit_byte(8*index+baser); - emit_byte(0); - return; - } - emit_byte(0x04+8*s); - emit_byte(8*index+baser); } LENDFUNC(NONE,WRITE,3,raw_mov_b_mrr_indexed,(R4 baser, R4 index, R1 s)) -LOWFUNC(NONE,READ,3,raw_mov_l_rm_indexed,(W4 d, IMM base, R4 index)) + LOWFUNC(NONE,READ,3,raw_mov_l_rm_indexed,(W4 d, IMM base, R4 index)) { - emit_byte(0x8b); - emit_byte(0x04+8*d); - emit_byte(0x85+8*index); - emit_long(base); + emit_byte(0x8b); + emit_byte(0x04+8*d); + emit_byte(0x85+8*index); + emit_long(base); } LENDFUNC(NONE,READ,3,raw_mov_l_rm_indexed,(W4 d, IMM base, R4 index)) -LOWFUNC(NONE,READ,4,raw_cmov_l_rm_indexed,(W4 d, IMM base, R4 index, IMM cond)) + LOWFUNC(NONE,READ,4,raw_cmov_l_rm_indexed,(W4 d, IMM base, R4 index, IMM cond)) { - if (have_cmov) { - emit_byte(0x0f); - emit_byte(0x40+cond); - } - else { /* replacement using branch and mov */ - int uncc=(cond^1); - emit_byte(0x70+uncc); - emit_byte(7); /* skip next 7 bytes if not cc=true */ - emit_byte(0x8b); - } - emit_byte(0x04+8*d); - emit_byte(0x85+8*index); - emit_long(base); + if (have_cmov) { + emit_byte(0x0f); + emit_byte(0x40+cond); + } + else { /* replacement using branch and mov */ + int uncc=(cond^1); + emit_byte(0x70+uncc); + emit_byte(7); /* skip next 7 bytes if not cc=true */ + emit_byte(0x8b); + } + emit_byte(0x04+8*d); + emit_byte(0x85+8*index); + emit_long(base); } LENDFUNC(NONE,READ,4,raw_cmov_l_rm_indexed,(W4 d, IMM base, R4 index, IMM cond)) -LOWFUNC(NONE,READ,3,raw_cmov_l_rm,(W4 d, IMM mem, IMM cond)) + LOWFUNC(NONE,READ,3,raw_cmov_l_rm,(W4 d, IMM mem, IMM cond)) { - if (have_cmov) { - emit_byte(0x0f); - emit_byte(0x40+cond); - emit_byte(0x05+8*d); - emit_long(mem); - } - else { /* replacement using branch and mov */ - int uncc=(cond^1); - emit_byte(0x70+uncc); - emit_byte(6); /* skip next 6 bytes if not cc=true */ - emit_byte(0x8b); - emit_byte(0x05+8*d); - emit_long(mem); - } + if (have_cmov) { + emit_byte(0x0f); + emit_byte(0x40+cond); + emit_byte(0x05+8*d); + emit_long(mem); + } + else { /* replacement using branch and mov */ + int uncc=(cond^1); + emit_byte(0x70+uncc); + emit_byte(6); /* skip next 6 bytes if not cc=true */ + emit_byte(0x8b); + emit_byte(0x05+8*d); + emit_long(mem); + } } LENDFUNC(NONE,READ,3,raw_cmov_l_rm,(W4 d, IMM mem, IMM cond)) -LOWFUNC(NONE,READ,3,raw_mov_l_rR,(W4 d, R4 s, IMM offset)) + LOWFUNC(NONE,READ,3,raw_mov_l_rR,(W4 d, R4 s, IMM offset)) { - emit_byte(0x8b); - emit_byte(0x40+8*d+s); - emit_byte(offset); + emit_byte(0x8b); + emit_byte(0x40+8*d+s); + emit_byte(offset); } LENDFUNC(NONE,READ,3,raw_mov_l_rR,(W4 d, R4 s, IMM offset)) -LOWFUNC(NONE,READ,3,raw_mov_w_rR,(W2 d, R4 s, IMM offset)) + LOWFUNC(NONE,READ,3,raw_mov_w_rR,(W2 d, R4 s, IMM offset)) { - emit_byte(0x66); - emit_byte(0x8b); - emit_byte(0x40+8*d+s); - emit_byte(offset); + emit_byte(0x66); + emit_byte(0x8b); + emit_byte(0x40+8*d+s); + emit_byte(offset); } LENDFUNC(NONE,READ,3,raw_mov_w_rR,(W2 d, R4 s, IMM offset)) -LOWFUNC(NONE,READ,3,raw_mov_b_rR,(W1 d, R4 s, IMM offset)) + LOWFUNC(NONE,READ,3,raw_mov_b_rR,(W1 d, R4 s, IMM offset)) { - emit_byte(0x8a); - emit_byte(0x40+8*d+s); - emit_byte(offset); + emit_byte(0x8a); + emit_byte(0x40+8*d+s); + emit_byte(offset); } LENDFUNC(NONE,READ,3,raw_mov_b_rR,(W1 d, R4 s, IMM offset)) -LOWFUNC(NONE,READ,3,raw_mov_l_brR,(W4 d, R4 s, IMM offset)) + LOWFUNC(NONE,READ,3,raw_mov_l_brR,(W4 d, R4 s, IMM offset)) { - emit_byte(0x8b); - emit_byte(0x80+8*d+s); - emit_long(offset); + emit_byte(0x8b); + emit_byte(0x80+8*d+s); + emit_long(offset); } LENDFUNC(NONE,READ,3,raw_mov_l_brR,(W4 d, R4 s, IMM offset)) -LOWFUNC(NONE,READ,3,raw_mov_w_brR,(W2 d, R4 s, IMM offset)) + LOWFUNC(NONE,READ,3,raw_mov_w_brR,(W2 d, R4 s, IMM offset)) { - emit_byte(0x66); - emit_byte(0x8b); - emit_byte(0x80+8*d+s); - emit_long(offset); + emit_byte(0x66); + emit_byte(0x8b); + emit_byte(0x80+8*d+s); + emit_long(offset); } LENDFUNC(NONE,READ,3,raw_mov_w_brR,(W2 d, R4 s, IMM offset)) -LOWFUNC(NONE,READ,3,raw_mov_b_brR,(W1 d, R4 s, IMM offset)) + LOWFUNC(NONE,READ,3,raw_mov_b_brR,(W1 d, R4 s, IMM offset)) { - emit_byte(0x8a); - emit_byte(0x80+8*d+s); - emit_long(offset); + emit_byte(0x8a); + emit_byte(0x80+8*d+s); + emit_long(offset); } LENDFUNC(NONE,READ,3,raw_mov_b_brR,(W1 d, R4 s, IMM offset)) -LOWFUNC(NONE,WRITE,3,raw_mov_l_Ri,(R4 d, IMM i, IMM offset)) + LOWFUNC(NONE,WRITE,3,raw_mov_l_Ri,(R4 d, IMM i, IMM offset)) { - emit_byte(0xc7); - emit_byte(0x40+d); - emit_byte(offset); - emit_long(i); + emit_byte(0xc7); + emit_byte(0x40+d); + emit_byte(offset); + emit_long(i); } LENDFUNC(NONE,WRITE,3,raw_mov_l_Ri,(R4 d, IMM i, IMM offset)) -LOWFUNC(NONE,WRITE,3,raw_mov_w_Ri,(R4 d, IMM i, IMM offset)) + LOWFUNC(NONE,WRITE,3,raw_mov_w_Ri,(R4 d, IMM i, IMM offset)) { - emit_byte(0x66); - emit_byte(0xc7); - emit_byte(0x40+d); - emit_byte(offset); - emit_word(i); + emit_byte(0x66); + emit_byte(0xc7); + emit_byte(0x40+d); + emit_byte(offset); + emit_word(i); } LENDFUNC(NONE,WRITE,3,raw_mov_w_Ri,(R4 d, IMM i, IMM offset)) -LOWFUNC(NONE,WRITE,3,raw_mov_b_Ri,(R4 d, IMM i, IMM offset)) + LOWFUNC(NONE,WRITE,3,raw_mov_b_Ri,(R4 d, IMM i, IMM offset)) { - emit_byte(0xc6); - emit_byte(0x40+d); - emit_byte(offset); - emit_byte(i); + emit_byte(0xc6); + emit_byte(0x40+d); + emit_byte(offset); + emit_byte(i); } LENDFUNC(NONE,WRITE,3,raw_mov_b_Ri,(R4 d, IMM i, IMM offset)) -LOWFUNC(NONE,WRITE,3,raw_mov_l_Rr,(R4 d, R4 s, IMM offset)) + LOWFUNC(NONE,WRITE,3,raw_mov_l_Rr,(R4 d, R4 s, IMM offset)) { - emit_byte(0x89); - emit_byte(0x40+8*s+d); - emit_byte(offset); + emit_byte(0x89); + emit_byte(0x40+8*s+d); + emit_byte(offset); } LENDFUNC(NONE,WRITE,3,raw_mov_l_Rr,(R4 d, R4 s, IMM offset)) -LOWFUNC(NONE,WRITE,3,raw_mov_w_Rr,(R4 d, R2 s, IMM offset)) + LOWFUNC(NONE,WRITE,3,raw_mov_w_Rr,(R4 d, R2 s, IMM offset)) { - emit_byte(0x66); - emit_byte(0x89); - emit_byte(0x40+8*s+d); - emit_byte(offset); + emit_byte(0x66); + emit_byte(0x89); + emit_byte(0x40+8*s+d); + emit_byte(offset); } LENDFUNC(NONE,WRITE,3,raw_mov_w_Rr,(R4 d, R2 s, IMM offset)) -LOWFUNC(NONE,WRITE,3,raw_mov_b_Rr,(R4 d, R1 s, IMM offset)) + LOWFUNC(NONE,WRITE,3,raw_mov_b_Rr,(R4 d, R1 s, IMM offset)) { - emit_byte(0x88); - emit_byte(0x40+8*s+d); - emit_byte(offset); + emit_byte(0x88); + emit_byte(0x40+8*s+d); + emit_byte(offset); } LENDFUNC(NONE,WRITE,3,raw_mov_b_Rr,(R4 d, R1 s, IMM offset)) -LOWFUNC(NONE,NONE,3,raw_lea_l_brr,(W4 d, R4 s, IMM offset)) + LOWFUNC(NONE,NONE,3,raw_lea_l_brr,(W4 d, R4 s, IMM offset)) { - emit_byte(0x8d); - emit_byte(0x80+8*d+s); - emit_long(offset); + emit_byte(0x8d); + emit_byte(0x80+8*d+s); + emit_long(offset); } LENDFUNC(NONE,NONE,3,raw_lea_l_brr,(W4 d, R4 s, IMM offset)) -LOWFUNC(NONE,NONE,5,raw_lea_l_brr_indexed,(W4 d, R4 s, R4 index, IMM factor, IMM offset)) + LOWFUNC(NONE,NONE,5,raw_lea_l_brr_indexed,(W4 d, R4 s, R4 index, IMM factor, IMM offset)) { - emit_byte(0x8d); - if (!offset) { - if (s!=5) { - emit_byte(0x04+8*d); - emit_byte(0x40*factor+8*index+s); - return; + emit_byte(0x8d); + if (!offset) { + if (s!=5) { + emit_byte(0x04+8*d); + emit_byte(0x40*factor+8*index+s); + return; + } + emit_byte(0x44+8*d); + emit_byte(0x40*factor+8*index+s); + emit_byte(0); + return; } - emit_byte(0x44+8*d); + emit_byte(0x84+8*d); emit_byte(0x40*factor+8*index+s); - emit_byte(0); - return; - } - emit_byte(0x84+8*d); - emit_byte(0x40*factor+8*index+s); - emit_long(offset); + emit_long(offset); } LENDFUNC(NONE,NONE,5,raw_lea_l_brr_indexed,(W4 d, R4 s, R4 index, IMM factor, IMM offset)) -LOWFUNC(NONE,NONE,3,raw_lea_l_rr_indexed,(W4 d, R4 s, R4 index)) + LOWFUNC(NONE,NONE,3,raw_lea_l_rr_indexed,(W4 d, R4 s, R4 index)) { - emit_byte(0x8d); - if (s==5) { - emit_byte(0x44+8*d); + emit_byte(0x8d); + if (s==5) { + emit_byte(0x44+8*d); + emit_byte(8*index+s); + emit_byte(0); + return; + } + emit_byte(0x04+8*d); emit_byte(8*index+s); - emit_byte(0); - return; - } - emit_byte(0x04+8*d); - emit_byte(8*index+s); } LENDFUNC(NONE,NONE,3,raw_lea_l_rr_indexed,(W4 d, R4 s, R4 index)) -LOWFUNC(NONE,WRITE,3,raw_mov_l_bRr,(R4 d, R4 s, IMM offset)) + LOWFUNC(NONE,WRITE,3,raw_mov_l_bRr,(R4 d, R4 s, IMM offset)) { - emit_byte(0x89); - emit_byte(0x80+8*s+d); - emit_long(offset); + emit_byte(0x89); + emit_byte(0x80+8*s+d); + emit_long(offset); } LENDFUNC(NONE,WRITE,3,raw_mov_l_bRr,(R4 d, R4 s, IMM offset)) -LOWFUNC(NONE,WRITE,3,raw_mov_w_bRr,(R4 d, R2 s, IMM offset)) + LOWFUNC(NONE,WRITE,3,raw_mov_w_bRr,(R4 d, R2 s, IMM offset)) { - emit_byte(0x66); - emit_byte(0x89); - emit_byte(0x80+8*s+d); - emit_long(offset); + emit_byte(0x66); + emit_byte(0x89); + emit_byte(0x80+8*s+d); + emit_long(offset); } LENDFUNC(NONE,WRITE,3,raw_mov_w_bRr,(R4 d, R2 s, IMM offset)) -LOWFUNC(NONE,WRITE,3,raw_mov_b_bRr,(R4 d, R1 s, IMM offset)) + LOWFUNC(NONE,WRITE,3,raw_mov_b_bRr,(R4 d, R1 s, IMM offset)) { - emit_byte(0x88); - emit_byte(0x80+8*s+d); - emit_long(offset); + emit_byte(0x88); + emit_byte(0x80+8*s+d); + emit_long(offset); } LENDFUNC(NONE,WRITE,3,raw_mov_b_bRr,(R4 d, R1 s, IMM offset)) -LOWFUNC(NONE,NONE,1,raw_bswap_32,(RW4 r)) + LOWFUNC(NONE,NONE,1,raw_bswap_32,(RW4 r)) { - emit_byte(0x0f); - emit_byte(0xc8+r); + emit_byte(0x0f); + emit_byte(0xc8+r); } LENDFUNC(NONE,NONE,1,raw_bswap_32,(RW4 r)) -LOWFUNC(WRITE,NONE,1,raw_bswap_16,(RW2 r)) + LOWFUNC(WRITE,NONE,1,raw_bswap_16,(RW2 r)) { - emit_byte(0x66); - emit_byte(0xc1); - emit_byte(0xc0+r); - emit_byte(0x08); + emit_byte(0x66); + emit_byte(0xc1); + emit_byte(0xc0+r); + emit_byte(0x08); } LENDFUNC(WRITE,NONE,1,raw_bswap_16,(RW2 r)) -LOWFUNC(NONE,NONE,2,raw_mov_l_rr,(W4 d, R4 s)) + LOWFUNC(NONE,NONE,2,raw_mov_l_rr,(W4 d, R4 s)) { - emit_byte(0x89); - emit_byte(0xc0+8*s+d); + emit_byte(0x89); + emit_byte(0xc0+8*s+d); } LENDFUNC(NONE,NONE,2,raw_mov_l_rr,(W4 d, R4 s)) -LOWFUNC(NONE,WRITE,2,raw_mov_l_mr,(IMM d, R4 s)) + LOWFUNC(NONE,WRITE,2,raw_mov_l_mr,(IMM d, R4 s)) { - emit_byte(0x89); - emit_byte(0x05+8*s); - emit_long(d); + emit_byte(0x89); + emit_byte(0x05+8*s); + emit_long(d); } LENDFUNC(NONE,WRITE,2,raw_mov_l_mr,(IMM d, R4 s)) -LOWFUNC(NONE,READ,2,raw_mov_l_rm,(W4 d, MEMR s)) + LOWFUNC(NONE,READ,2,raw_mov_l_rm,(W4 d, MEMR s)) { - emit_byte(0x8b); - emit_byte(0x05+8*d); - emit_long(s); + emit_byte(0x8b); + emit_byte(0x05+8*d); + emit_long(s); } LENDFUNC(NONE,READ,2,raw_mov_l_rm,(W4 d, MEMR s)) -LOWFUNC(NONE,WRITE,2,raw_mov_w_mr,(IMM d, R2 s)) + LOWFUNC(NONE,WRITE,2,raw_mov_w_mr,(IMM d, R2 s)) { - emit_byte(0x66); - emit_byte(0x89); - emit_byte(0x05+8*s); - emit_long(d); + emit_byte(0x66); + emit_byte(0x89); + emit_byte(0x05+8*s); + emit_long(d); } LENDFUNC(NONE,WRITE,2,raw_mov_w_mr,(IMM d, R2 s)) -LOWFUNC(NONE,READ,2,raw_mov_w_rm,(W2 d, IMM s)) + LOWFUNC(NONE,READ,2,raw_mov_w_rm,(W2 d, IMM s)) { - emit_byte(0x66); - emit_byte(0x8b); - emit_byte(0x05+8*d); - emit_long(s); + emit_byte(0x66); + emit_byte(0x8b); + emit_byte(0x05+8*d); + emit_long(s); } LENDFUNC(NONE,READ,2,raw_mov_w_rm,(W2 d, IMM s)) -LOWFUNC(NONE,WRITE,2,raw_mov_b_mr,(IMM d, R1 s)) + LOWFUNC(NONE,WRITE,2,raw_mov_b_mr,(IMM d, R1 s)) { - emit_byte(0x88); - emit_byte(0x05+8*s); - emit_long(d); + emit_byte(0x88); + emit_byte(0x05+8*s); + emit_long(d); } LENDFUNC(NONE,WRITE,2,raw_mov_b_mr,(IMM d, R1 s)) -LOWFUNC(NONE,READ,2,raw_mov_b_rm,(W1 d, IMM s)) + LOWFUNC(NONE,READ,2,raw_mov_b_rm,(W1 d, IMM s)) { - emit_byte(0x8a); - emit_byte(0x05+8*d); - emit_long(s); + emit_byte(0x8a); + emit_byte(0x05+8*d); + emit_long(s); } LENDFUNC(NONE,READ,2,raw_mov_b_rm,(W1 d, IMM s)) -LOWFUNC(NONE,NONE,2,raw_mov_l_ri,(W4 d, IMM s)) + LOWFUNC(NONE,NONE,2,raw_mov_l_ri,(W4 d, IMM s)) { - emit_byte(0xb8+d); - emit_long(s); + emit_byte(0xb8+d); + emit_long(s); } LENDFUNC(NONE,NONE,2,raw_mov_l_ri,(W4 d, IMM s)) -LOWFUNC(NONE,NONE,2,raw_mov_w_ri,(W2 d, IMM s)) + LOWFUNC(NONE,NONE,2,raw_mov_w_ri,(W2 d, IMM s)) { - emit_byte(0x66); - emit_byte(0xb8+d); - emit_word(s); + emit_byte(0x66); + emit_byte(0xb8+d); + emit_word(s); } LENDFUNC(NONE,NONE,2,raw_mov_w_ri,(W2 d, IMM s)) -LOWFUNC(NONE,NONE,2,raw_mov_b_ri,(W1 d, IMM s)) + LOWFUNC(NONE,NONE,2,raw_mov_b_ri,(W1 d, IMM s)) { - emit_byte(0xb0+d); - emit_byte(s); + emit_byte(0xb0+d); + emit_byte(s); } LENDFUNC(NONE,NONE,2,raw_mov_b_ri,(W1 d, IMM s)) -LOWFUNC(RMW,RMW,2,raw_adc_l_mi,(MEMRW d, IMM s)) + LOWFUNC(RMW,RMW,2,raw_adc_l_mi,(MEMRW d, IMM s)) { - emit_byte(0x81); - emit_byte(0x15); - emit_long(d); - emit_long(s); + emit_byte(0x81); + emit_byte(0x15); + emit_long(d); + emit_long(s); } LENDFUNC(RMW,RMW,2,raw_adc_l_mi,(MEMRW d, IMM s)) -LOWFUNC(WRITE,RMW,2,raw_add_l_mi,(IMM d, IMM s)) + LOWFUNC(WRITE,RMW,2,raw_add_l_mi,(IMM d, IMM s)) { - emit_byte(0x81); - emit_byte(0x05); - emit_long(d); - emit_long(s); + emit_byte(0x81); + emit_byte(0x05); + emit_long(d); + emit_long(s); } LENDFUNC(WRITE,RMW,2,raw_add_l_mi,(IMM d, IMM s)) -LOWFUNC(WRITE,RMW,2,raw_add_w_mi,(IMM d, IMM s)) + LOWFUNC(WRITE,RMW,2,raw_add_w_mi,(IMM d, IMM s)) { - emit_byte(0x66); - emit_byte(0x81); - emit_byte(0x05); - emit_long(d); - emit_word(s); + emit_byte(0x66); + emit_byte(0x81); + emit_byte(0x05); + emit_long(d); + emit_word(s); } LENDFUNC(WRITE,RMW,2,raw_add_w_mi,(IMM d, IMM s)) -LOWFUNC(WRITE,RMW,2,raw_add_b_mi,(IMM d, IMM s)) + LOWFUNC(WRITE,RMW,2,raw_add_b_mi,(IMM d, IMM s)) { - emit_byte(0x80); - emit_byte(0x05); - emit_long(d); - emit_byte(s); + emit_byte(0x80); + emit_byte(0x05); + emit_long(d); + emit_byte(s); } LENDFUNC(WRITE,RMW,2,raw_add_b_mi,(IMM d, IMM s)) -LOWFUNC(WRITE,NONE,2,raw_test_l_ri,(R4 d, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_test_l_ri,(R4 d, IMM i)) { - emit_byte(0xf7); - emit_byte(0xc0+d); - emit_long(i); + emit_byte(0xf7); + emit_byte(0xc0+d); + emit_long(i); } LENDFUNC(WRITE,NONE,2,raw_test_l_ri,(R4 d, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_test_l_rr,(R4 d, R4 s)) + LOWFUNC(WRITE,NONE,2,raw_test_l_rr,(R4 d, R4 s)) { - emit_byte(0x85); - emit_byte(0xc0+8*s+d); + emit_byte(0x85); + emit_byte(0xc0+8*s+d); } LENDFUNC(WRITE,NONE,2,raw_test_l_rr,(R4 d, R4 s)) -LOWFUNC(WRITE,NONE,2,raw_test_w_rr,(R2 d, R2 s)) + LOWFUNC(WRITE,NONE,2,raw_test_w_rr,(R2 d, R2 s)) { - emit_byte(0x66); - emit_byte(0x85); - emit_byte(0xc0+8*s+d); + emit_byte(0x66); + emit_byte(0x85); + emit_byte(0xc0+8*s+d); } LENDFUNC(WRITE,NONE,2,raw_test_w_rr,(R2 d, R2 s)) -LOWFUNC(WRITE,NONE,2,raw_test_b_rr,(R1 d, R1 s)) + LOWFUNC(WRITE,NONE,2,raw_test_b_rr,(R1 d, R1 s)) { - emit_byte(0x84); - emit_byte(0xc0+8*s+d); + emit_byte(0x84); + emit_byte(0xc0+8*s+d); } LENDFUNC(WRITE,NONE,2,raw_test_b_rr,(R1 d, R1 s)) -LOWFUNC(WRITE,NONE,2,raw_and_l_ri,(RW4 d, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_and_l_ri,(RW4 d, IMM i)) { - emit_byte(0x81); - emit_byte(0xe0+d); - emit_long(i); + emit_byte(0x81); + emit_byte(0xe0+d); + emit_long(i); } LENDFUNC(WRITE,NONE,2,raw_and_l_ri,(RW4 d, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_and_w_ri,(RW2 d, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_and_w_ri,(RW2 d, IMM i)) { - emit_byte(0x66); - emit_byte(0x81); - emit_byte(0xe0+d); - emit_word(i); + emit_byte(0x66); + emit_byte(0x81); + emit_byte(0xe0+d); + emit_word(i); } LENDFUNC(WRITE,NONE,2,raw_and_w_ri,(RW2 d, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_and_l,(RW4 d, R4 s)) + LOWFUNC(WRITE,NONE,2,raw_and_l,(RW4 d, R4 s)) { - emit_byte(0x21); - emit_byte(0xc0+8*s+d); + emit_byte(0x21); + emit_byte(0xc0+8*s+d); } LENDFUNC(WRITE,NONE,2,raw_and_l,(RW4 d, R4 s)) -LOWFUNC(WRITE,NONE,2,raw_and_w,(RW2 d, R2 s)) + LOWFUNC(WRITE,NONE,2,raw_and_w,(RW2 d, R2 s)) { - emit_byte(0x66); - emit_byte(0x21); - emit_byte(0xc0+8*s+d); + emit_byte(0x66); + emit_byte(0x21); + emit_byte(0xc0+8*s+d); } LENDFUNC(WRITE,NONE,2,raw_and_w,(RW2 d, R2 s)) -LOWFUNC(WRITE,NONE,2,raw_and_b,(RW1 d, R1 s)) + LOWFUNC(WRITE,NONE,2,raw_and_b,(RW1 d, R1 s)) { - emit_byte(0x20); - emit_byte(0xc0+8*s+d); + emit_byte(0x20); + emit_byte(0xc0+8*s+d); } LENDFUNC(WRITE,NONE,2,raw_and_b,(RW1 d, R1 s)) -LOWFUNC(WRITE,NONE,2,raw_or_l_ri,(RW4 d, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_or_l_ri,(RW4 d, IMM i)) { - emit_byte(0x81); - emit_byte(0xc8+d); - emit_long(i); + emit_byte(0x81); + emit_byte(0xc8+d); + emit_long(i); } LENDFUNC(WRITE,NONE,2,raw_or_l_ri,(RW4 d, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_or_l,(RW4 d, R4 s)) + LOWFUNC(WRITE,NONE,2,raw_or_l,(RW4 d, R4 s)) { - emit_byte(0x09); - emit_byte(0xc0+8*s+d); + emit_byte(0x09); + emit_byte(0xc0+8*s+d); } LENDFUNC(WRITE,NONE,2,raw_or_l,(RW4 d, R4 s)) -LOWFUNC(WRITE,NONE,2,raw_or_w,(RW2 d, R2 s)) + LOWFUNC(WRITE,NONE,2,raw_or_w,(RW2 d, R2 s)) { - emit_byte(0x66); - emit_byte(0x09); - emit_byte(0xc0+8*s+d); + emit_byte(0x66); + emit_byte(0x09); + emit_byte(0xc0+8*s+d); } LENDFUNC(WRITE,NONE,2,raw_or_w,(RW2 d, R2 s)) -LOWFUNC(WRITE,NONE,2,raw_or_b,(RW1 d, R1 s)) + LOWFUNC(WRITE,NONE,2,raw_or_b,(RW1 d, R1 s)) { - emit_byte(0x08); - emit_byte(0xc0+8*s+d); + emit_byte(0x08); + emit_byte(0xc0+8*s+d); } LENDFUNC(WRITE,NONE,2,raw_or_b,(RW1 d, R1 s)) -LOWFUNC(RMW,NONE,2,raw_adc_l,(RW4 d, R4 s)) + LOWFUNC(RMW,NONE,2,raw_adc_l,(RW4 d, R4 s)) { - emit_byte(0x11); - emit_byte(0xc0+8*s+d); + emit_byte(0x11); + emit_byte(0xc0+8*s+d); } LENDFUNC(RMW,NONE,2,raw_adc_l,(RW4 d, R4 s)) -LOWFUNC(RMW,NONE,2,raw_adc_w,(RW2 d, R2 s)) + LOWFUNC(RMW,NONE,2,raw_adc_w,(RW2 d, R2 s)) { - emit_byte(0x66); - emit_byte(0x11); - emit_byte(0xc0+8*s+d); + emit_byte(0x66); + emit_byte(0x11); + emit_byte(0xc0+8*s+d); } LENDFUNC(RMW,NONE,2,raw_adc_w,(RW2 d, R2 s)) -LOWFUNC(RMW,NONE,2,raw_adc_b,(RW1 d, R1 s)) + LOWFUNC(RMW,NONE,2,raw_adc_b,(RW1 d, R1 s)) { - emit_byte(0x10); - emit_byte(0xc0+8*s+d); + emit_byte(0x10); + emit_byte(0xc0+8*s+d); } LENDFUNC(RMW,NONE,2,raw_adc_b,(RW1 d, R1 s)) -LOWFUNC(WRITE,NONE,2,raw_add_l,(RW4 d, R4 s)) + LOWFUNC(WRITE,NONE,2,raw_add_l,(RW4 d, R4 s)) { - emit_byte(0x01); - emit_byte(0xc0+8*s+d); + emit_byte(0x01); + emit_byte(0xc0+8*s+d); } LENDFUNC(WRITE,NONE,2,raw_add_l,(RW4 d, R4 s)) -LOWFUNC(WRITE,NONE,2,raw_add_w,(RW2 d, R2 s)) + LOWFUNC(WRITE,NONE,2,raw_add_w,(RW2 d, R2 s)) { - emit_byte(0x66); - emit_byte(0x01); - emit_byte(0xc0+8*s+d); + emit_byte(0x66); + emit_byte(0x01); + emit_byte(0xc0+8*s+d); } LENDFUNC(WRITE,NONE,2,raw_add_w,(RW2 d, R2 s)) -LOWFUNC(WRITE,NONE,2,raw_add_b,(RW1 d, R1 s)) + LOWFUNC(WRITE,NONE,2,raw_add_b,(RW1 d, R1 s)) { - emit_byte(0x00); - emit_byte(0xc0+8*s+d); + emit_byte(0x00); + emit_byte(0xc0+8*s+d); } LENDFUNC(WRITE,NONE,2,raw_add_b,(RW1 d, R1 s)) -LOWFUNC(WRITE,NONE,2,raw_sub_l_ri,(RW4 d, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_sub_l_ri,(RW4 d, IMM i)) { - if (isbyte(i)) { - emit_byte(0x83); - emit_byte(0xe8+d); - emit_byte(i); - } - else { - emit_byte(0x81); - emit_byte(0xe8+d); - emit_long(i); - } + if (isbyte(i)) { + emit_byte(0x83); + emit_byte(0xe8+d); + emit_byte(i); + } + else { + emit_byte(0x81); + emit_byte(0xe8+d); + emit_long(i); + } } LENDFUNC(WRITE,NONE,2,raw_sub_l_ri,(RW4 d, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_sub_b_ri,(RW1 d, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_sub_b_ri,(RW1 d, IMM i)) { - emit_byte(0x80); - emit_byte(0xe8+d); - emit_byte(i); + emit_byte(0x80); + emit_byte(0xe8+d); + emit_byte(i); } LENDFUNC(WRITE,NONE,2,raw_sub_b_ri,(RW1 d, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_add_l_ri,(RW4 d, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_add_l_ri,(RW4 d, IMM i)) { - if (isbyte(i)) { - emit_byte(0x83); - emit_byte(0xc0+d); - emit_byte(i); - } - else { - emit_byte(0x81); - emit_byte(0xc0+d); - emit_long(i); - } + if (isbyte(i)) { + emit_byte(0x83); + emit_byte(0xc0+d); + emit_byte(i); + } + else { + emit_byte(0x81); + emit_byte(0xc0+d); + emit_long(i); + } } LENDFUNC(WRITE,NONE,2,raw_add_l_ri,(RW4 d, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_add_w_ri,(RW2 d, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_add_w_ri,(RW2 d, IMM i)) { - if (isbyte(i)) { - emit_byte(0x66); - emit_byte(0x83); - emit_byte(0xc0+d); - emit_byte(i); - } - else { - emit_byte(0x66); - emit_byte(0x81); - emit_byte(0xc0+d); - emit_word(i); - } + if (isbyte(i)) { + emit_byte(0x66); + emit_byte(0x83); + emit_byte(0xc0+d); + emit_byte(i); + } + else { + emit_byte(0x66); + emit_byte(0x81); + emit_byte(0xc0+d); + emit_word(i); + } } LENDFUNC(WRITE,NONE,2,raw_add_w_ri,(RW2 d, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_add_b_ri,(RW1 d, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_add_b_ri,(RW1 d, IMM i)) { - emit_byte(0x80); - emit_byte(0xc0+d); - emit_byte(i); + emit_byte(0x80); + emit_byte(0xc0+d); + emit_byte(i); } LENDFUNC(WRITE,NONE,2,raw_add_b_ri,(RW1 d, IMM i)) -LOWFUNC(RMW,NONE,2,raw_sbb_l,(RW4 d, R4 s)) + LOWFUNC(RMW,NONE,2,raw_sbb_l,(RW4 d, R4 s)) { - emit_byte(0x19); - emit_byte(0xc0+8*s+d); + emit_byte(0x19); + emit_byte(0xc0+8*s+d); } LENDFUNC(RMW,NONE,2,raw_sbb_l,(RW4 d, R4 s)) -LOWFUNC(RMW,NONE,2,raw_sbb_w,(RW2 d, R2 s)) + LOWFUNC(RMW,NONE,2,raw_sbb_w,(RW2 d, R2 s)) { - emit_byte(0x66); - emit_byte(0x19); - emit_byte(0xc0+8*s+d); + emit_byte(0x66); + emit_byte(0x19); + emit_byte(0xc0+8*s+d); } LENDFUNC(RMW,NONE,2,raw_sbb_w,(RW2 d, R2 s)) -LOWFUNC(RMW,NONE,2,raw_sbb_b,(RW1 d, R1 s)) + LOWFUNC(RMW,NONE,2,raw_sbb_b,(RW1 d, R1 s)) { - emit_byte(0x18); - emit_byte(0xc0+8*s+d); + emit_byte(0x18); + emit_byte(0xc0+8*s+d); } LENDFUNC(RMW,NONE,2,raw_sbb_b,(RW1 d, R1 s)) -LOWFUNC(WRITE,NONE,2,raw_sub_l,(RW4 d, R4 s)) + LOWFUNC(WRITE,NONE,2,raw_sub_l,(RW4 d, R4 s)) { - emit_byte(0x29); - emit_byte(0xc0+8*s+d); + emit_byte(0x29); + emit_byte(0xc0+8*s+d); } LENDFUNC(WRITE,NONE,2,raw_sub_l,(RW4 d, R4 s)) -LOWFUNC(WRITE,NONE,2,raw_sub_w,(RW2 d, R2 s)) + LOWFUNC(WRITE,NONE,2,raw_sub_w,(RW2 d, R2 s)) { - emit_byte(0x66); - emit_byte(0x29); - emit_byte(0xc0+8*s+d); + emit_byte(0x66); + emit_byte(0x29); + emit_byte(0xc0+8*s+d); } LENDFUNC(WRITE,NONE,2,raw_sub_w,(RW2 d, R2 s)) -LOWFUNC(WRITE,NONE,2,raw_sub_b,(RW1 d, R1 s)) + LOWFUNC(WRITE,NONE,2,raw_sub_b,(RW1 d, R1 s)) { - emit_byte(0x28); - emit_byte(0xc0+8*s+d); + emit_byte(0x28); + emit_byte(0xc0+8*s+d); } LENDFUNC(WRITE,NONE,2,raw_sub_b,(RW1 d, R1 s)) -LOWFUNC(WRITE,NONE,2,raw_cmp_l,(R4 d, R4 s)) + LOWFUNC(WRITE,NONE,2,raw_cmp_l,(R4 d, R4 s)) { - emit_byte(0x39); - emit_byte(0xc0+8*s+d); + emit_byte(0x39); + emit_byte(0xc0+8*s+d); } LENDFUNC(WRITE,NONE,2,raw_cmp_l,(R4 d, R4 s)) -LOWFUNC(WRITE,NONE,2,raw_cmp_l_ri,(R4 r, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_cmp_l_ri,(R4 r, IMM i)) { - emit_byte(0x81); - emit_byte(0xf8+r); - emit_long(i); + emit_byte(0x81); + emit_byte(0xf8+r); + emit_long(i); } LENDFUNC(WRITE,NONE,2,raw_cmp_l_ri,(R4 r, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_cmp_w,(R2 d, R2 s)) + LOWFUNC(WRITE,NONE,2,raw_cmp_w,(R2 d, R2 s)) { - emit_byte(0x66); - emit_byte(0x39); - emit_byte(0xc0+8*s+d); + emit_byte(0x66); + emit_byte(0x39); + emit_byte(0xc0+8*s+d); } LENDFUNC(WRITE,NONE,2,raw_cmp_w,(R2 d, R2 s)) -LOWFUNC(WRITE,NONE,2,raw_cmp_b_ri,(R1 d, IMM i)) + LOWFUNC(WRITE,NONE,2,raw_cmp_b_ri,(R1 d, IMM i)) { - emit_byte(0x80); - emit_byte(0xf8+d); - emit_byte(i); + emit_byte(0x80); + emit_byte(0xf8+d); + emit_byte(i); } LENDFUNC(WRITE,NONE,2,raw_cmp_b_ri,(R1 d, IMM i)) -LOWFUNC(WRITE,NONE,2,raw_cmp_b,(R1 d, R1 s)) + LOWFUNC(WRITE,NONE,2,raw_cmp_b,(R1 d, R1 s)) { - emit_byte(0x38); - emit_byte(0xc0+8*s+d); + emit_byte(0x38); + emit_byte(0xc0+8*s+d); } LENDFUNC(WRITE,NONE,2,raw_cmp_b,(R1 d, R1 s)) -LOWFUNC(WRITE,NONE,2,raw_xor_l,(RW4 d, R4 s)) + LOWFUNC(WRITE,NONE,2,raw_xor_l,(RW4 d, R4 s)) { - emit_byte(0x31); - emit_byte(0xc0+8*s+d); + emit_byte(0x31); + emit_byte(0xc0+8*s+d); } LENDFUNC(WRITE,NONE,2,raw_xor_l,(RW4 d, R4 s)) -LOWFUNC(WRITE,NONE,2,raw_xor_w,(RW2 d, R2 s)) + LOWFUNC(WRITE,NONE,2,raw_xor_w,(RW2 d, R2 s)) { - emit_byte(0x66); - emit_byte(0x31); - emit_byte(0xc0+8*s+d); + emit_byte(0x66); + emit_byte(0x31); + emit_byte(0xc0+8*s+d); } LENDFUNC(WRITE,NONE,2,raw_xor_w,(RW2 d, R2 s)) -LOWFUNC(WRITE,NONE,2,raw_xor_b,(RW1 d, R1 s)) + LOWFUNC(WRITE,NONE,2,raw_xor_b,(RW1 d, R1 s)) { - emit_byte(0x30); - emit_byte(0xc0+8*s+d); + emit_byte(0x30); + emit_byte(0xc0+8*s+d); } LENDFUNC(WRITE,NONE,2,raw_xor_b,(RW1 d, R1 s)) -LOWFUNC(WRITE,RMW,2,raw_sub_l_mi,(MEMRW d, IMM s)) + LOWFUNC(WRITE,RMW,2,raw_sub_l_mi,(MEMRW d, IMM s)) { - emit_byte(0x81); - emit_byte(0x2d); - emit_long(d); - emit_long(s); + emit_byte(0x81); + emit_byte(0x2d); + emit_long(d); + emit_long(s); } LENDFUNC(WRITE,RMW,2,raw_sub_l_mi,(MEMRW d, IMM s)) -LOWFUNC(WRITE,READ,2,raw_cmp_l_mi,(MEMR d, IMM s)) + LOWFUNC(WRITE,READ,2,raw_cmp_l_mi,(MEMR d, IMM s)) { - emit_byte(0x81); - emit_byte(0x3d); - emit_long(d); - emit_long(s); + emit_byte(0x81); + emit_byte(0x3d); + emit_long(d); + emit_long(s); } LENDFUNC(WRITE,READ,2,raw_cmp_l_mi,(MEMR d, IMM s)) -LOWFUNC(NONE,NONE,2,raw_xchg_l_rr,(RW4 r1, RW4 r2)) + LOWFUNC(NONE,NONE,2,raw_xchg_l_rr,(RW4 r1, RW4 r2)) { - emit_byte(0x87); - emit_byte(0xc0+8*r1+r2); + emit_byte(0x87); + emit_byte(0xc0+8*r1+r2); } LENDFUNC(NONE,NONE,2,raw_xchg_l_rr,(RW4 r1, RW4 r2)) -LOWFUNC(READ,WRITE,0,raw_pushfl,(void)) + LOWFUNC(READ,WRITE,0,raw_pushfl,(void)) { - emit_byte(0x9c); + emit_byte(0x9c); } LENDFUNC(READ,WRITE,0,raw_pushfl,(void)) -LOWFUNC(WRITE,READ,0,raw_popfl,(void)) + LOWFUNC(WRITE,READ,0,raw_popfl,(void)) { - emit_byte(0x9d); + emit_byte(0x9d); } LENDFUNC(WRITE,READ,0,raw_popfl,(void)) -/************************************************************************* - * Unoptimizable stuff --- jump * - *************************************************************************/ + /************************************************************************* + * Unoptimizable stuff --- jump * + *************************************************************************/ -STATIC_INLINE void raw_call_r(R4 r) + STATIC_INLINE void raw_call_r(R4 r) { - lopt_emit_all(); - emit_byte(0xff); - emit_byte(0xd0+r); + lopt_emit_all(); + emit_byte(0xff); + emit_byte(0xd0+r); } STATIC_INLINE void raw_jmp_r(R4 r) { - lopt_emit_all(); - emit_byte(0xff); - emit_byte(0xe0+r); + lopt_emit_all(); + emit_byte(0xff); + emit_byte(0xe0+r); } STATIC_INLINE void raw_jmp_m_indexed(uae_u32 base, uae_u32 r, uae_u32 m) { - int sib; + int sib; - switch (m) { + switch (m) { case 1: sib = 0x05; break; case 2: sib = 0x45; break; case 4: sib = 0x85; break; case 8: sib = 0xC5; break; default: abort(); - } - lopt_emit_all(); - emit_byte(0xff); - emit_byte(0x24); - emit_byte(8*r+sib); - emit_long(base); + } + lopt_emit_all(); + emit_byte(0xff); + emit_byte(0x24); + emit_byte(8*r+sib); + emit_long(base); } STATIC_INLINE void raw_jmp_m(uae_u32 base) { - lopt_emit_all(); - emit_byte(0xff); - emit_byte(0x25); - emit_long(base); + lopt_emit_all(); + emit_byte(0xff); + emit_byte(0x25); + emit_long(base); } STATIC_INLINE void raw_call(uae_u32 t) { - lopt_emit_all(); - emit_byte(0xe8); - emit_long(t-(uae_u32)target-4); + lopt_emit_all(); + emit_byte(0xe8); + emit_long(t-(uae_u32)target-4); } STATIC_INLINE void raw_jmp(uae_u32 t) { - lopt_emit_all(); - emit_byte(0xe9); - emit_long(t-(uae_u32)target-4); + lopt_emit_all(); + emit_byte(0xe9); + emit_long(t-(uae_u32)target-4); } STATIC_INLINE void raw_jl(uae_u32 t) { - lopt_emit_all(); - emit_byte(0x0f); - emit_byte(0x8c); - emit_long(t-(uae_u32)target-4); + lopt_emit_all(); + emit_byte(0x0f); + emit_byte(0x8c); + emit_long(t-(uae_u32)target-4); } STATIC_INLINE void raw_jz(uae_u32 t) { - lopt_emit_all(); - emit_byte(0x0f); - emit_byte(0x84); - emit_long(t-(uae_u32)target-4); + lopt_emit_all(); + emit_byte(0x0f); + emit_byte(0x84); + emit_long(t-(uae_u32)target-4); } STATIC_INLINE void raw_jnz(uae_u32 t) { - lopt_emit_all(); - emit_byte(0x0f); - emit_byte(0x85); - emit_long(t-(uae_u32)target-4); + lopt_emit_all(); + emit_byte(0x0f); + emit_byte(0x85); + emit_long(t-(uae_u32)target-4); } STATIC_INLINE void raw_jnz_l_oponly(void) { - lopt_emit_all(); - emit_byte(0x0f); - emit_byte(0x85); + lopt_emit_all(); + emit_byte(0x0f); + emit_byte(0x85); } STATIC_INLINE void raw_jcc_l_oponly(int cc) { - lopt_emit_all(); - emit_byte(0x0f); - emit_byte(0x80+cc); + lopt_emit_all(); + emit_byte(0x0f); + emit_byte(0x80+cc); } STATIC_INLINE void raw_jnz_b_oponly(void) { - lopt_emit_all(); - emit_byte(0x75); + lopt_emit_all(); + emit_byte(0x75); } STATIC_INLINE void raw_jz_b_oponly(void) { - lopt_emit_all(); - emit_byte(0x74); + lopt_emit_all(); + emit_byte(0x74); } STATIC_INLINE void raw_jmp_l_oponly(void) { - lopt_emit_all(); - emit_byte(0xe9); + lopt_emit_all(); + emit_byte(0xe9); } STATIC_INLINE void raw_jmp_b_oponly(void) { - lopt_emit_all(); - emit_byte(0xeb); + lopt_emit_all(); + emit_byte(0xeb); } STATIC_INLINE void raw_ret(void) { - lopt_emit_all(); - emit_byte(0xc3); + lopt_emit_all(); + emit_byte(0xc3); } STATIC_INLINE void raw_nop(void) { - lopt_emit_all(); - emit_byte(0x90); + lopt_emit_all(); + emit_byte(0x90); } /************************************************************************* - * Flag handling, to and fro UAE flag register * - *************************************************************************/ +* Flag handling, to and fro UAE flag register * +*************************************************************************/ #define FLAG_NREG1 0 /* Set to -1 if any register will do */ STATIC_INLINE void raw_flags_to_reg(int r) { - raw_lahf(0); /* Most flags in AH */ - //raw_setcc(r,0); /* V flag in AL */ - raw_setcc_m((uae_u32)live.state[FLAGTMP].mem,0); + raw_lahf(0); /* Most flags in AH */ + //raw_setcc(r,0); /* V flag in AL */ + raw_setcc_m((uae_u32)live.state[FLAGTMP].mem,0); #if 1 /* Let's avoid those nasty partial register stalls */ - //raw_mov_b_mr((uae_u32)live.state[FLAGTMP].mem,r); - raw_mov_b_mr(((uae_u32)live.state[FLAGTMP].mem)+1,r+4); - //live.state[FLAGTMP].status=CLEAN; - live.state[FLAGTMP].status=INMEM; - live.state[FLAGTMP].realreg=-1; - /* We just "evicted" FLAGTMP. */ - if (live.nat[r].nholds!=1) { - /* Huh? */ - abort(); - } - live.nat[r].nholds=0; + //raw_mov_b_mr((uae_u32)live.state[FLAGTMP].mem,r); + raw_mov_b_mr(((uae_u32)live.state[FLAGTMP].mem)+1,r+4); + //live.state[FLAGTMP].status=CLEAN; + live.state[FLAGTMP].status=INMEM; + live.state[FLAGTMP].realreg=-1; + /* We just "evicted" FLAGTMP. */ + if (live.nat[r].nholds!=1) { + /* Huh? */ + abort(); + } + live.nat[r].nholds=0; #endif } #define FLAG_NREG2 0 /* Set to -1 if any register will do */ STATIC_INLINE void raw_reg_to_flags(int r) { - raw_cmp_b_ri(r,-127); /* set V */ - raw_sahf(0); + raw_cmp_b_ri(r,-127); /* set V */ + raw_sahf(0); } /* Apparently, there are enough instructions between flag store and - flag reload to avoid the partial memory stall */ +flag reload to avoid the partial memory stall */ STATIC_INLINE void raw_load_flagreg(uae_u32 target, uae_u32 r) { #if 1 - raw_mov_l_rm(target,(uae_u32)live.state[r].mem); + raw_mov_l_rm(target,(uae_u32)live.state[r].mem); #else - raw_mov_b_rm(target,(uae_u32)live.state[r].mem); - raw_mov_b_rm(target+4,((uae_u32)live.state[r].mem)+1); + raw_mov_b_rm(target,(uae_u32)live.state[r].mem); + raw_mov_b_rm(target+4,((uae_u32)live.state[r].mem)+1); #endif } /* FLAGX is word-sized */ STATIC_INLINE void raw_load_flagx(uae_u32 target, uae_u32 r) { - if (live.nat[target].canword) - raw_mov_w_rm(target,(uae_u32)live.state[r].mem); - else - raw_mov_l_rm(target,(uae_u32)live.state[r].mem); + if (live.nat[target].canword) + raw_mov_w_rm(target,(uae_u32)live.state[r].mem); + else + raw_mov_l_rm(target,(uae_u32)live.state[r].mem); } #define NATIVE_FLAG_Z 0x40 #define NATIVE_CC_EQ 4 STATIC_INLINE void raw_flags_set_zero(int f, int r, int t) { - // FIXME: this is really suboptimal - raw_pushfl(); - raw_pop_l_r(f); - raw_and_l_ri(f,~NATIVE_FLAG_Z); - raw_test_l_rr(r,r); - raw_mov_l_ri(r,0); - raw_mov_l_ri(t,NATIVE_FLAG_Z); - raw_cmov_l_rr(r,t,NATIVE_CC_EQ); - raw_or_l(f,r); - raw_push_l_r(f); - raw_popfl(); + // FIXME: this is really suboptimal + raw_pushfl(); + raw_pop_l_r(f); + raw_and_l_ri(f,~NATIVE_FLAG_Z); + raw_test_l_rr(r,r); + raw_mov_l_ri(r,0); + raw_mov_l_ri(t,NATIVE_FLAG_Z); + raw_cmov_l_rr(r,t,NATIVE_CC_EQ); + raw_or_l(f,r); + raw_push_l_r(f); + raw_popfl(); } STATIC_INLINE void raw_inc_sp(int off) { - raw_add_l_ri(4,off); + raw_add_l_ri(4,off); } /************************************************************************* - * Handling mistaken direct memory access * - *************************************************************************/ +* Handling mistaken direct memory access * +*************************************************************************/ #ifdef NATMEM_OFFSET @@ -1697,604 +1697,601 @@ static uae_u8 *veccode; #define ctxPC (pContext->Eip) #endif -extern int mman_guard_exception (LPEXCEPTION_POINTERS); int EvalException (LPEXCEPTION_POINTERS blah, int n_except) { - PEXCEPTION_RECORD pExceptRecord = NULL; - PCONTEXT pContext = NULL; + PEXCEPTION_RECORD pExceptRecord = NULL; + PCONTEXT pContext = NULL; - uae_u8* i = NULL; - uae_u32 addr = 0; - int r=-1; - int size=4; - int dir=-1; - int len=0; + uae_u8* i = NULL; + uae_u32 addr = 0; + int r=-1; + int size=4; + int dir=-1; + int len=0; - if (n_except == STATUS_GUARD_PAGE_VIOLATION) - return mman_guard_exception (blah); - if (n_except != STATUS_ACCESS_VIOLATION || !canbang) - return EXCEPTION_CONTINUE_SEARCH; + if (n_except != STATUS_ACCESS_VIOLATION || !canbang || currprefs.cachesize == 0) + return EXCEPTION_CONTINUE_SEARCH; - pExceptRecord = blah->ExceptionRecord; - pContext = blah->ContextRecord; + pExceptRecord = blah->ExceptionRecord; + pContext = blah->ContextRecord; - if (pContext) - i = (uae_u8 *)ctxPC; - if (pExceptRecord) - addr = (uae_u32)(pExceptRecord->ExceptionInformation[1]); + if (pContext) + i = (uae_u8 *)ctxPC; + if (pExceptRecord) + addr = (uae_u32)(pExceptRecord->ExceptionInformation[1]); #ifdef JIT_DEBUG - write_log (L"JIT: fault address is 0x%x at 0x%x\n",addr,i); + write_log (L"JIT: fault address is 0x%x at 0x%x\n",addr,i); #endif - if (!canbang || !currprefs.cachesize) - return EXCEPTION_CONTINUE_SEARCH; + if (!canbang || !currprefs.cachesize) + return EXCEPTION_CONTINUE_SEARCH; - if (in_handler) - write_log (L"JIT: Argh --- Am already in a handler. Shouldn't happen!\n"); + if (in_handler) + write_log (L"JIT: Argh --- Am already in a handler. Shouldn't happen!\n"); - if (canbang && i>=compiled_code && i<=current_compile_p) { - if (*i==0x66) { - i++; - size=2; - len++; - } + if (canbang && i>=compiled_code && i<=current_compile_p) { + if (*i==0x66) { + i++; + size=2; + len++; + } - switch(i[0]) { - case 0x8a: - if ((i[1]&0xc0)==0x80) { - r=(i[1]>>3)&7; - dir=SIG_READ; - size=1; - len+=6; - break; - } - break; - case 0x88: - if ((i[1]&0xc0)==0x80) { - r=(i[1]>>3)&7; - dir=SIG_WRITE; - size=1; - len+=6; - break; - } - break; - case 0x8b: - switch(i[1]&0xc0) { - case 0x80: - r=(i[1]>>3)&7; - dir=SIG_READ; - len+=6; - break; - case 0x40: - r=(i[1]>>3)&7; - dir=SIG_READ; - len+=3; - break; - case 0x00: - r=(i[1]>>3)&7; - dir=SIG_READ; - len+=2; - break; - default: - break; - } - break; - case 0x89: - switch(i[1]&0xc0) { - case 0x80: - r=(i[1]>>3)&7; - dir=SIG_WRITE; - len+=6; - break; - case 0x40: - r=(i[1]>>3)&7; - dir=SIG_WRITE; - len+=3; - break; - case 0x00: - r=(i[1]>>3)&7; - dir=SIG_WRITE; - len+=2; - break; + switch(i[0]) { + case 0x8a: + if ((i[1]&0xc0)==0x80) { + r=(i[1]>>3)&7; + dir=SIG_READ; + size=1; + len+=6; + break; + } + break; + case 0x88: + if ((i[1]&0xc0)==0x80) { + r=(i[1]>>3)&7; + dir=SIG_WRITE; + size=1; + len+=6; + break; + } + break; + case 0x8b: + switch(i[1]&0xc0) { + case 0x80: + r=(i[1]>>3)&7; + dir=SIG_READ; + len+=6; + break; + case 0x40: + r=(i[1]>>3)&7; + dir=SIG_READ; + len+=3; + break; + case 0x00: + r=(i[1]>>3)&7; + dir=SIG_READ; + len+=2; + break; + default: + break; + } + break; + case 0x89: + switch(i[1]&0xc0) { + case 0x80: + r=(i[1]>>3)&7; + dir=SIG_WRITE; + len+=6; + break; + case 0x40: + r=(i[1]>>3)&7; + dir=SIG_WRITE; + len+=3; + break; + case 0x00: + r=(i[1]>>3)&7; + dir=SIG_WRITE; + len+=2; + break; + } + break; } - break; } - } - if (r!=-1) { - void* pr=NULL; + if (r!=-1) { + void* pr=NULL; #ifdef JIT_DEBUG - write_log (L"JIT: register was %d, direction was %d, size was %d\n",r,dir,size); + write_log (L"JIT: register was %d, direction was %d, size was %d\n",r,dir,size); #endif - switch(r) { + switch(r) { #if defined(CPU_64_BIT) - case 0: pr=&(pContext->Rax); break; - case 1: pr=&(pContext->Rcx); break; - case 2: pr=&(pContext->Rdx); break; - case 3: pr=&(pContext->Rbx); break; - case 4: pr=(size>1)?NULL:(((uae_u8*)&(pContext->Rax))+1); break; - case 5: pr=(size>1)? - (void*)(&(pContext->Rbp)): - (void*)(((uae_u8*)&(pContext->Rcx))+1); break; - case 6: pr=(size>1)? - (void*)(&(pContext->Rsi)): - (void*)(((uae_u8*)&(pContext->Rdx))+1); break; - case 7: pr=(size>1)? - (void*)(&(pContext->Rdi)): - (void*)(((uae_u8*)&(pContext->Rbx))+1); break; + case 0: pr=&(pContext->Rax); break; + case 1: pr=&(pContext->Rcx); break; + case 2: pr=&(pContext->Rdx); break; + case 3: pr=&(pContext->Rbx); break; + case 4: pr=(size>1)?NULL:(((uae_u8*)&(pContext->Rax))+1); break; + case 5: pr=(size>1)? + (void*)(&(pContext->Rbp)): + (void*)(((uae_u8*)&(pContext->Rcx))+1); break; + case 6: pr=(size>1)? + (void*)(&(pContext->Rsi)): + (void*)(((uae_u8*)&(pContext->Rdx))+1); break; + case 7: pr=(size>1)? + (void*)(&(pContext->Rdi)): + (void*)(((uae_u8*)&(pContext->Rbx))+1); break; #else - case 0: pr=&(pContext->Eax); break; - case 1: pr=&(pContext->Ecx); break; - case 2: pr=&(pContext->Edx); break; - case 3: pr=&(pContext->Ebx); break; - case 4: pr=(size>1)?NULL:(((uae_u8*)&(pContext->Eax))+1); break; - case 5: pr=(size>1)? - (void*)(&(pContext->Ebp)): - (void*)(((uae_u8*)&(pContext->Ecx))+1); break; - case 6: pr=(size>1)? - (void*)(&(pContext->Esi)): - (void*)(((uae_u8*)&(pContext->Edx))+1); break; - case 7: pr=(size>1)? - (void*)(&(pContext->Edi)): - (void*)(((uae_u8*)&(pContext->Ebx))+1); break; + case 0: pr=&(pContext->Eax); break; + case 1: pr=&(pContext->Ecx); break; + case 2: pr=&(pContext->Edx); break; + case 3: pr=&(pContext->Ebx); break; + case 4: pr=(size>1)?NULL:(((uae_u8*)&(pContext->Eax))+1); break; + case 5: pr=(size>1)? + (void*)(&(pContext->Ebp)): + (void*)(((uae_u8*)&(pContext->Ecx))+1); break; + case 6: pr=(size>1)? + (void*)(&(pContext->Esi)): + (void*)(((uae_u8*)&(pContext->Edx))+1); break; + case 7: pr=(size>1)? + (void*)(&(pContext->Edi)): + (void*)(((uae_u8*)&(pContext->Ebx))+1); break; #endif - default: abort(); - } - if (pr) { - blockinfo* bi; + default: abort(); + } + if (pr) { + blockinfo* bi; - if (currprefs.comp_oldsegv) { - addr-=(uae_u32)NATMEM_OFFSET; + if (currprefs.comp_oldsegv) { + addr-=(uae_u32)NATMEM_OFFSET; #ifdef JIT_DEBUG - if ((addr>=0x10000000 && addr<0x40000000) || - (addr>=0x50000000)) { - write_log (L"JIT: Suspicious address 0x%x in SEGV handler.\n",addr); - } + if ((addr>=0x10000000 && addr<0x40000000) || + (addr>=0x50000000)) { + write_log (L"JIT: Suspicious address 0x%x in SEGV handler.\n",addr); + } #endif - if (dir==SIG_READ) { - switch (size) { - case 1: *((uae_u8*)pr)=get_byte (addr); break; - case 2: *((uae_u16*)pr)=swap16(get_word (addr)); break; - case 4: *((uae_u32*)pr)=swap32(get_long (addr)); break; - default: abort(); - } - } - else { /* write */ - switch (size) { - case 1: put_byte (addr,*((uae_u8*)pr)); break; - case 2: put_word (addr,swap16(*((uae_u16*)pr))); break; - case 4: put_long (addr,swap32(*((uae_u32*)pr))); break; - default: abort(); - } - } + if (dir==SIG_READ) { + switch (size) { + case 1: *((uae_u8*)pr)=get_byte (addr); break; + case 2: *((uae_u16*)pr)=swap16(get_word (addr)); break; + case 4: *((uae_u32*)pr)=swap32(get_long (addr)); break; + default: abort(); + } + } + else { /* write */ + switch (size) { + case 1: put_byte (addr,*((uae_u8*)pr)); break; + case 2: put_word (addr,swap16(*((uae_u16*)pr))); break; + case 4: put_long (addr,swap32(*((uae_u32*)pr))); break; + default: abort(); + } + } #ifdef JIT_DEBUG - write_log (L"JIT: Handled one access!\n"); + write_log (L"JIT: Handled one access!\n"); #endif - fflush(stdout); - segvcount++; - ctxPC+=len; - } - else { - void* tmp=target; - int i; - uae_u8 vecbuf[5]; + fflush(stdout); + segvcount++; + ctxPC+=len; + } + else { + void* tmp=target; + int i; + uae_u8 vecbuf[5]; - addr-=(uae_u32)NATMEM_OFFSET; + addr-=(uae_u32)NATMEM_OFFSET; #ifdef JIT_DEBUG - if ((addr>=0x10000000 && addr<0x40000000) || - (addr>=0x50000000)) { - write_log (L"JIT: Suspicious address 0x%x in SEGV handler.\n",addr); - } + if ((addr>=0x10000000 && addr<0x40000000) || + (addr>=0x50000000)) { + write_log (L"JIT: Suspicious address 0x%x in SEGV handler.\n",addr); + } #endif - target=(uae_u8*)ctxPC; - for (i=0;i<5;i++) - vecbuf[i]=target[i]; - emit_byte(0xe9); - emit_long((uae_u32)veccode-(uae_u32)target-4); + target=(uae_u8*)ctxPC; + for (i=0;i<5;i++) + vecbuf[i]=target[i]; + emit_byte(0xe9); + emit_long((uae_u32)veccode-(uae_u32)target-4); #ifdef JIT_DEBUG - write_log (L"JIT: Create jump to %p\n",veccode); - write_log (L"JIT: Handled one access!\n"); + write_log (L"JIT: Create jump to %p\n",veccode); + write_log (L"JIT: Handled one access!\n"); #endif - segvcount++; - - target=veccode; - - if (dir==SIG_READ) { - switch(size) { - case 1: raw_mov_b_ri(r,get_byte (addr)); break; - case 2: raw_mov_w_ri(r,swap16(get_word (addr))); break; - case 4: raw_mov_l_ri(r,swap32(get_long (addr))); break; - default: abort(); - } - } - else { /* write */ - switch(size) { - case 1: put_byte (addr,*((uae_u8*)pr)); break; - case 2: put_word (addr,swap16(*((uae_u16*)pr))); break; - case 4: put_long (addr,swap32(*((uae_u32*)pr))); break; - default: abort(); - } - } - for (i=0;i<5;i++) - raw_mov_b_mi(ctxPC+i,vecbuf[i]); - raw_mov_l_mi((uae_u32)&in_handler,0); - emit_byte(0xe9); - emit_long(ctxPC+len-(uae_u32)target-4); - in_handler=1; - target=(uae_u8*)tmp; - } - bi=active; - while (bi) { - if (bi->handler && - (uae_u8*)bi->direct_handler<=i && - (uae_u8*)bi->nexthandler>i) { + segvcount++; + + target=veccode; + + if (dir==SIG_READ) { + switch(size) { + case 1: raw_mov_b_ri(r,get_byte (addr)); break; + case 2: raw_mov_w_ri(r,swap16(get_word (addr))); break; + case 4: raw_mov_l_ri(r,swap32(get_long (addr))); break; + default: abort(); + } + } + else { /* write */ + switch(size) { + case 1: put_byte (addr,*((uae_u8*)pr)); break; + case 2: put_word (addr,swap16(*((uae_u16*)pr))); break; + case 4: put_long (addr,swap32(*((uae_u32*)pr))); break; + default: abort(); + } + } + for (i=0;i<5;i++) + raw_mov_b_mi(ctxPC+i,vecbuf[i]); + raw_mov_l_mi((uae_u32)&in_handler,0); + emit_byte(0xe9); + emit_long(ctxPC+len-(uae_u32)target-4); + in_handler=1; + target=(uae_u8*)tmp; + } + bi=active; + while (bi) { + if (bi->handler && + (uae_u8*)bi->direct_handler<=i && + (uae_u8*)bi->nexthandler>i) { #ifdef JIT_DEBUG - write_log (L"JIT: deleted trigger (%p<%p<%p) %p\n", - bi->handler, - i, - bi->nexthandler, - bi->pc_p); + write_log (L"JIT: deleted trigger (%p<%p<%p) %p\n", + bi->handler, + i, + bi->nexthandler, + bi->pc_p); #endif - invalidate_block(bi); - raise_in_cl_list(bi); - set_special(0); - return EXCEPTION_CONTINUE_EXECUTION; - } - bi=bi->next; - } - /* Not found in the active list. Might be a rom routine that - is in the dormant list */ - bi=dormant; - while (bi) { - if (bi->handler && - (uae_u8*)bi->direct_handler<=i && - (uae_u8*)bi->nexthandler>i) { + invalidate_block(bi); + raise_in_cl_list(bi); + set_special(0); + return EXCEPTION_CONTINUE_EXECUTION; + } + bi=bi->next; + } + /* Not found in the active list. Might be a rom routine that + is in the dormant list */ + bi=dormant; + while (bi) { + if (bi->handler && + (uae_u8*)bi->direct_handler<=i && + (uae_u8*)bi->nexthandler>i) { #ifdef JIT_DEBUG - write_log (L"JIT: deleted trigger (%p<%p<%p) %p\n", - bi->handler, - i, - bi->nexthandler, - bi->pc_p); + write_log (L"JIT: deleted trigger (%p<%p<%p) %p\n", + bi->handler, + i, + bi->nexthandler, + bi->pc_p); #endif - invalidate_block(bi); - raise_in_cl_list(bi); - set_special(0); - return EXCEPTION_CONTINUE_EXECUTION; - } - bi=bi->next; - } + invalidate_block(bi); + raise_in_cl_list(bi); + set_special(0); + return EXCEPTION_CONTINUE_EXECUTION; + } + bi=bi->next; + } #ifdef JIT_DEBUG - write_log (L"JIT: Huh? Could not find trigger!\n"); + write_log (L"JIT: Huh? Could not find trigger!\n"); #endif - return EXCEPTION_CONTINUE_EXECUTION; + return EXCEPTION_CONTINUE_EXECUTION; + } } - } - write_log (L"JIT: Can't handle access %08X!\n", i); + write_log (L"JIT: Can't handle access %08X!\n", i); #if 0 - if (i) - { - int j; + if (i) + { + int j; - for (j=0;j<10;j++) { - write_log (L"JIT: instruction byte %2d is 0x%02x\n",j,i[j]); + for (j=0;j<10;j++) { + write_log (L"JIT: instruction byte %2d is 0x%02x\n",j,i[j]); + } } - } - write_log (L"Please send the above info (starting at \"fault address\") to\n" - L"bmeyer@csse.monash.edu.au\n" - L"This shouldn't happen ;-)\n"); + write_log (L"Please send the above info (starting at \"fault address\") to\n" + L"bmeyer@csse.monash.edu.au\n" + L"This shouldn't happen ;-)\n"); #endif - return EXCEPTION_CONTINUE_SEARCH; + return EXCEPTION_CONTINUE_SEARCH; } #else static void vec(int x, struct sigcontext sc) { - uae_u8* i=(uae_u8*)sc.eip; - uae_u32 addr=sc.cr2; - int r=-1; - int size=4; - int dir=-1; - int len=0; - int j; - - write_log (L"JIT: fault address is %08x at %08x\n",sc.cr2,sc.eip); - if (!canbang) - write_log (L"JIT: Not happy! Canbang is 0 in SIGSEGV handler!\n"); - if (in_handler) - write_log (L"JIT: Argh --- Am already in a handler. Shouldn't happen!\n"); - - if (canbang && i>=compiled_code && i<=current_compile_p) { - if (*i==0x66) { - i++; - size=2; - len++; - } - - switch(i[0]) { - case 0x8a: - if ((i[1]&0xc0)==0x80) { - r=(i[1]>>3)&7; - dir=SIG_READ; - size=1; - len+=6; - break; - } - break; - case 0x88: - if ((i[1]&0xc0)==0x80) { - r=(i[1]>>3)&7; - dir=SIG_WRITE; - size=1; - len+=6; - break; - } - break; - - case 0x8b: - switch(i[1]&0xc0) { - case 0x80: - r=(i[1]>>3)&7; - dir=SIG_READ; - len+=6; - break; - case 0x40: - r=(i[1]>>3)&7; - dir=SIG_READ; - len+=3; - break; - case 0x00: - r=(i[1]>>3)&7; - dir=SIG_READ; - len+=2; - break; - default: - break; - } - break; - - case 0x89: - switch(i[1]&0xc0) { - case 0x80: - r=(i[1]>>3)&7; - dir=SIG_WRITE; - len+=6; - break; - case 0x40: - r=(i[1]>>3)&7; - dir=SIG_WRITE; - len+=3; - break; - case 0x00: - r=(i[1]>>3)&7; - dir=SIG_WRITE; - len+=2; - break; - } - break; - } - } - - if (r!=-1) { - void* pr=NULL; - write_log (L"JIT: register was %d, direction was %d, size was %d\n",r,dir,size); - - switch(r) { - case 0: pr=&(sc.eax); break; - case 1: pr=&(sc.ecx); break; - case 2: pr=&(sc.edx); break; - case 3: pr=&(sc.ebx); break; - case 4: pr=(size>1)?NULL:(((uae_u8*)&(sc.eax))+1); break; - case 5: pr=(size>1)? - (void*)(&(sc.ebp)): - (void*)(((uae_u8*)&(sc.ecx))+1); break; - case 6: pr=(size>1)? - (void*)(&(sc.esi)): - (void*)(((uae_u8*)&(sc.edx))+1); break; - case 7: pr=(size>1)? - (void*)(&(sc.edi)): - (void*)(((uae_u8*)&(sc.ebx))+1); break; - default: abort(); - } - if (pr) { - blockinfo* bi; - - if (currprefs.comp_oldsegv) { - addr-=NATMEM_OFFSET; - - if ((addr>=0x10000000 && addr<0x40000000) || - (addr>=0x50000000)) { - write_log (L"JIT: Suspicious address in %x SEGV handler.\n",addr); - } - if (dir==SIG_READ) { - switch(size) { - case 1: *((uae_u8*)pr)=get_byte (addr); break; - case 2: *((uae_u16*)pr)=get_word (addr); break; - case 4: *((uae_u32*)pr)=get_long (addr); break; - default: abort(); - } - } - else { /* write */ - switch(size) { - case 1: put_byte (addr,*((uae_u8*)pr)); break; - case 2: put_word (addr,*((uae_u16*)pr)); break; - case 4: put_long (addr,*((uae_u32*)pr)); break; - default: abort(); - } - } - write_log (L"JIT: Handled one access!\n"); - fflush(stdout); - segvcount++; - sc.eip+=len; - } - else { - void* tmp=target; - int i; - uae_u8 vecbuf[5]; - - addr-=NATMEM_OFFSET; - - if ((addr>=0x10000000 && addr<0x40000000) || - (addr>=0x50000000)) { - write_log (L"JIT: Suspicious address 0x%x in SEGV handler.\n",addr); - } + uae_u8* i=(uae_u8*)sc.eip; + uae_u32 addr=sc.cr2; + int r=-1; + int size=4; + int dir=-1; + int len=0; + int j; - target=(uae_u8*)sc.eip; - for (i=0;i<5;i++) - vecbuf[i]=target[i]; - emit_byte(0xe9); - emit_long((uae_u32)veccode-(uae_u32)target-4); - write_log (L"JIT: Create jump to %p\n",veccode); - - write_log (L"JIT: Handled one access!\n"); - segvcount++; - - target=veccode; - - if (dir==SIG_READ) { - switch(size) { - case 1: raw_mov_b_ri(r,get_byte (addr)); break; - case 2: raw_mov_w_ri(r,get_word (addr)); break; - case 4: raw_mov_l_ri(r,get_long (addr)); break; - default: abort(); - } + write_log (L"JIT: fault address is %08x at %08x\n",sc.cr2,sc.eip); + if (!canbang) + write_log (L"JIT: Not happy! Canbang is 0 in SIGSEGV handler!\n"); + if (in_handler) + write_log (L"JIT: Argh --- Am already in a handler. Shouldn't happen!\n"); + + if (canbang && i>=compiled_code && i<=current_compile_p) { + if (*i==0x66) { + i++; + size=2; + len++; } - else { /* write */ - switch(size) { - case 1: put_byte (addr,*((uae_u8*)pr)); break; - case 2: put_word (addr,*((uae_u16*)pr)); break; - case 4: put_long (addr,*((uae_u32*)pr)); break; - default: abort(); - } + + switch(i[0]) { + case 0x8a: + if ((i[1]&0xc0)==0x80) { + r=(i[1]>>3)&7; + dir=SIG_READ; + size=1; + len+=6; + break; + } + break; + case 0x88: + if ((i[1]&0xc0)==0x80) { + r=(i[1]>>3)&7; + dir=SIG_WRITE; + size=1; + len+=6; + break; + } + break; + + case 0x8b: + switch(i[1]&0xc0) { + case 0x80: + r=(i[1]>>3)&7; + dir=SIG_READ; + len+=6; + break; + case 0x40: + r=(i[1]>>3)&7; + dir=SIG_READ; + len+=3; + break; + case 0x00: + r=(i[1]>>3)&7; + dir=SIG_READ; + len+=2; + break; + default: + break; + } + break; + + case 0x89: + switch(i[1]&0xc0) { + case 0x80: + r=(i[1]>>3)&7; + dir=SIG_WRITE; + len+=6; + break; + case 0x40: + r=(i[1]>>3)&7; + dir=SIG_WRITE; + len+=3; + break; + case 0x00: + r=(i[1]>>3)&7; + dir=SIG_WRITE; + len+=2; + break; + } + break; } - for (i=0;i<5;i++) - raw_mov_b_mi(sc.eip+i,vecbuf[i]); - raw_mov_l_mi((uae_u32)&in_handler,0); - emit_byte(0xe9); - emit_long(sc.eip+len-(uae_u32)target-4); - in_handler=1; - target=tmp; - } - bi=active; - while (bi) { - if (bi->handler && - (uae_u8*)bi->direct_handler<=i && - (uae_u8*)bi->nexthandler>i) { - write_log (L"JIT: deleted trigger (%p<%p<%p) %p\n", - bi->handler, - i, - bi->nexthandler, - bi->pc_p); - invalidate_block(bi); - raise_in_cl_list(bi); - set_special(0); - return; + } + + if (r!=-1) { + void* pr=NULL; + write_log (L"JIT: register was %d, direction was %d, size was %d\n",r,dir,size); + + switch(r) { + case 0: pr=&(sc.eax); break; + case 1: pr=&(sc.ecx); break; + case 2: pr=&(sc.edx); break; + case 3: pr=&(sc.ebx); break; + case 4: pr=(size>1)?NULL:(((uae_u8*)&(sc.eax))+1); break; + case 5: pr=(size>1)? + (void*)(&(sc.ebp)): + (void*)(((uae_u8*)&(sc.ecx))+1); break; + case 6: pr=(size>1)? + (void*)(&(sc.esi)): + (void*)(((uae_u8*)&(sc.edx))+1); break; + case 7: pr=(size>1)? + (void*)(&(sc.edi)): + (void*)(((uae_u8*)&(sc.ebx))+1); break; + default: abort(); } - bi=bi->next; - } - /* Not found in the active list. Might be a rom routine that - is in the dormant list */ - bi=dormant; - while (bi) { - if (bi->handler && - (uae_u8*)bi->direct_handler<=i && - (uae_u8*)bi->nexthandler>i) { - write_log (L"JIT: deleted trigger (%p<%p<%p) %p\n", - bi->handler, - i, - bi->nexthandler, - bi->pc_p); - invalidate_block(bi); - raise_in_cl_list(bi); - set_special(0); - return; + if (pr) { + blockinfo* bi; + + if (currprefs.comp_oldsegv) { + addr-=NATMEM_OFFSET; + + if ((addr>=0x10000000 && addr<0x40000000) || + (addr>=0x50000000)) { + write_log (L"JIT: Suspicious address in %x SEGV handler.\n",addr); + } + if (dir==SIG_READ) { + switch(size) { + case 1: *((uae_u8*)pr)=get_byte (addr); break; + case 2: *((uae_u16*)pr)=get_word (addr); break; + case 4: *((uae_u32*)pr)=get_long (addr); break; + default: abort(); + } + } + else { /* write */ + switch(size) { + case 1: put_byte (addr,*((uae_u8*)pr)); break; + case 2: put_word (addr,*((uae_u16*)pr)); break; + case 4: put_long (addr,*((uae_u32*)pr)); break; + default: abort(); + } + } + write_log (L"JIT: Handled one access!\n"); + fflush(stdout); + segvcount++; + sc.eip+=len; + } + else { + void* tmp=target; + int i; + uae_u8 vecbuf[5]; + + addr-=NATMEM_OFFSET; + + if ((addr>=0x10000000 && addr<0x40000000) || + (addr>=0x50000000)) { + write_log (L"JIT: Suspicious address 0x%x in SEGV handler.\n",addr); + } + + target=(uae_u8*)sc.eip; + for (i=0;i<5;i++) + vecbuf[i]=target[i]; + emit_byte(0xe9); + emit_long((uae_u32)veccode-(uae_u32)target-4); + write_log (L"JIT: Create jump to %p\n",veccode); + + write_log (L"JIT: Handled one access!\n"); + segvcount++; + + target=veccode; + + if (dir==SIG_READ) { + switch(size) { + case 1: raw_mov_b_ri(r,get_byte (addr)); break; + case 2: raw_mov_w_ri(r,get_word (addr)); break; + case 4: raw_mov_l_ri(r,get_long (addr)); break; + default: abort(); + } + } + else { /* write */ + switch(size) { + case 1: put_byte (addr,*((uae_u8*)pr)); break; + case 2: put_word (addr,*((uae_u16*)pr)); break; + case 4: put_long (addr,*((uae_u32*)pr)); break; + default: abort(); + } + } + for (i=0;i<5;i++) + raw_mov_b_mi(sc.eip+i,vecbuf[i]); + raw_mov_l_mi((uae_u32)&in_handler,0); + emit_byte(0xe9); + emit_long(sc.eip+len-(uae_u32)target-4); + in_handler=1; + target=tmp; + } + bi=active; + while (bi) { + if (bi->handler && + (uae_u8*)bi->direct_handler<=i && + (uae_u8*)bi->nexthandler>i) { + write_log (L"JIT: deleted trigger (%p<%p<%p) %p\n", + bi->handler, + i, + bi->nexthandler, + bi->pc_p); + invalidate_block(bi); + raise_in_cl_list(bi); + set_special(0); + return; + } + bi=bi->next; + } + /* Not found in the active list. Might be a rom routine that + is in the dormant list */ + bi=dormant; + while (bi) { + if (bi->handler && + (uae_u8*)bi->direct_handler<=i && + (uae_u8*)bi->nexthandler>i) { + write_log (L"JIT: deleted trigger (%p<%p<%p) %p\n", + bi->handler, + i, + bi->nexthandler, + bi->pc_p); + invalidate_block(bi); + raise_in_cl_list(bi); + set_special(0); + return; + } + bi=bi->next; + } + write_log (L"JIT: Huh? Could not find trigger!\n"); + return; } - bi=bi->next; - } - write_log (L"JIT: Huh? Could not find trigger!\n"); - return; - } - } - write_log (L"JIT: Can't handle access!\n"); - for (j=0;j<10;j++) { - write_log (L"JIT: instruction byte %2d is %02x\n",j,i[j]); - } + } + write_log (L"JIT: Can't handle access!\n"); + for (j=0;j<10;j++) { + write_log (L"JIT: instruction byte %2d is %02x\n",j,i[j]); + } #if 0 - write_log (L"Please send the above info (starting at \"fault address\") to\n" - "bmeyer@csse.monash.edu.au\n" - "This shouldn't happen ;-)\n"); - fflush(stdout); + write_log (L"Please send the above info (starting at \"fault address\") to\n" + "bmeyer@csse.monash.edu.au\n" + "This shouldn't happen ;-)\n"); + fflush(stdout); #endif - signal(SIGSEGV,SIG_DFL); /* returning here will cause a "real" SEGV */ + signal(SIGSEGV,SIG_DFL); /* returning here will cause a "real" SEGV */ } #endif #endif /************************************************************************* - * Checking for CPU features * - *************************************************************************/ +* Checking for CPU features * +*************************************************************************/ struct cpuinfo_x86 { - uae_u8 x86; // CPU family - uae_u8 x86_vendor; // CPU vendor - uae_u8 x86_processor; // CPU canonical processor type - uae_u8 x86_brand_id; // CPU BrandID if supported, yield 0 otherwise - uae_u32 x86_hwcap; - uae_u8 x86_model; - uae_u8 x86_mask; - int cpuid_level; // Maximum supported CPUID level, -1=no CPUID - char x86_vendor_id[16]; + uae_u8 x86; // CPU family + uae_u8 x86_vendor; // CPU vendor + uae_u8 x86_processor; // CPU canonical processor type + uae_u8 x86_brand_id; // CPU BrandID if supported, yield 0 otherwise + uae_u32 x86_hwcap; + uae_u8 x86_model; + uae_u8 x86_mask; + int cpuid_level; // Maximum supported CPUID level, -1=no CPUID + char x86_vendor_id[16]; }; struct cpuinfo_x86 cpuinfo; enum { - X86_VENDOR_INTEL = 0, - X86_VENDOR_CYRIX = 1, - X86_VENDOR_AMD = 2, - X86_VENDOR_UMC = 3, - X86_VENDOR_NEXGEN = 4, - X86_VENDOR_CENTAUR = 5, - X86_VENDOR_RISE = 6, - X86_VENDOR_TRANSMETA = 7, - X86_VENDOR_NSC = 8, - X86_VENDOR_UNKNOWN = 0xff + X86_VENDOR_INTEL = 0, + X86_VENDOR_CYRIX = 1, + X86_VENDOR_AMD = 2, + X86_VENDOR_UMC = 3, + X86_VENDOR_NEXGEN = 4, + X86_VENDOR_CENTAUR = 5, + X86_VENDOR_RISE = 6, + X86_VENDOR_TRANSMETA = 7, + X86_VENDOR_NSC = 8, + X86_VENDOR_UNKNOWN = 0xff }; enum { - X86_PROCESSOR_I386, /* 80386 */ - X86_PROCESSOR_I486, /* 80486DX, 80486SX, 80486DX[24] */ - X86_PROCESSOR_PENTIUM, - X86_PROCESSOR_PENTIUMPRO, - X86_PROCESSOR_K6, - X86_PROCESSOR_ATHLON, - X86_PROCESSOR_PENTIUM4, - X86_PROCESSOR_K8, - X86_PROCESSOR_max + X86_PROCESSOR_I386, /* 80386 */ + X86_PROCESSOR_I486, /* 80486DX, 80486SX, 80486DX[24] */ + X86_PROCESSOR_PENTIUM, + X86_PROCESSOR_PENTIUMPRO, + X86_PROCESSOR_K6, + X86_PROCESSOR_ATHLON, + X86_PROCESSOR_PENTIUM4, + X86_PROCESSOR_K8, + X86_PROCESSOR_max }; static struct ptt { - const int align_loop; - const int align_loop_max_skip; - const int align_jump; - const int align_jump_max_skip; - const int align_func; + const int align_loop; + const int align_loop_max_skip; + const int align_jump; + const int align_jump_max_skip; + const int align_func; } x86_alignments[X86_PROCESSOR_max + 1] = { - { 4, 3, 4, 3, 4 }, - { 16, 15, 16, 15, 16 }, - { 16, 7, 16, 7, 16 }, - { 16, 15, 16, 7, 16 }, - { 32, 7, 32, 7, 32 }, - { 16, 7, 16, 7, 16 }, - { 0, 0, 0, 0, 0 }, - { 16, 7, 16, 7, 16 }, - { 0, 0, 0, 0, 0 } + { 4, 3, 4, 3, 4 }, + { 16, 15, 16, 15, 16 }, + { 16, 7, 16, 7, 16 }, + { 16, 15, 16, 7, 16 }, + { 32, 7, 32, 7, 32 }, + { 16, 7, 16, 7, 16 }, + { 0, 0, 0, 0, 0 }, + { 16, 7, 16, 7, 16 }, + { 0, 0, 0, 0, 0 } }; static void -x86_get_cpu_vendor(struct cpuinfo_x86 *c) + x86_get_cpu_vendor(struct cpuinfo_x86 *c) { char *v = c->x86_vendor_id; @@ -2315,7 +2312,7 @@ x86_get_cpu_vendor(struct cpuinfo_x86 *c) else if (!strcmp(v, "RiseRiseRise")) c->x86_vendor = X86_VENDOR_RISE; else if (!strcmp(v, "GenuineTMx86") || - !strcmp(v, "TransmetaCPU")) + !strcmp(v, "TransmetaCPU")) c->x86_vendor = X86_VENDOR_TRANSMETA; else c->x86_vendor = X86_VENDOR_UNKNOWN; @@ -2323,154 +2320,154 @@ x86_get_cpu_vendor(struct cpuinfo_x86 *c) static void cpuid(uae_u32 op, uae_u32 *eax, uae_u32 *ebx, uae_u32 *ecx, uae_u32 *edx) { - const int CPUID_SPACE = 4096; - uae_u8* cpuid_space = (uae_u8*)cache_alloc(CPUID_SPACE); - static uae_u32 s_op, s_eax, s_ebx, s_ecx, s_edx; - uae_u8* tmp=get_target(); - - s_op = op; - set_target(cpuid_space); - raw_push_l_r(0); /* eax */ - raw_push_l_r(1); /* ecx */ - raw_push_l_r(2); /* edx */ - raw_push_l_r(3); /* ebx */ - raw_mov_l_rm(0,(uintptr)&s_op); - raw_cpuid(0); - raw_mov_l_mr((uintptr)&s_eax,0); - raw_mov_l_mr((uintptr)&s_ebx,3); - raw_mov_l_mr((uintptr)&s_ecx,1); - raw_mov_l_mr((uintptr)&s_edx,2); - raw_pop_l_r(3); - raw_pop_l_r(2); - raw_pop_l_r(1); - raw_pop_l_r(0); - raw_ret(); - set_target(tmp); - - ((compop_func*)cpuid_space)(0); - if (eax != NULL) *eax = s_eax; - if (ebx != NULL) *ebx = s_ebx; - if (ecx != NULL) *ecx = s_ecx; - if (edx != NULL) *edx = s_edx; - - cache_free (cpuid_space); + const int CPUID_SPACE = 4096; + uae_u8* cpuid_space = (uae_u8*)cache_alloc(CPUID_SPACE); + static uae_u32 s_op, s_eax, s_ebx, s_ecx, s_edx; + uae_u8* tmp=get_target(); + + s_op = op; + set_target(cpuid_space); + raw_push_l_r(0); /* eax */ + raw_push_l_r(1); /* ecx */ + raw_push_l_r(2); /* edx */ + raw_push_l_r(3); /* ebx */ + raw_mov_l_rm(0,(uintptr)&s_op); + raw_cpuid(0); + raw_mov_l_mr((uintptr)&s_eax,0); + raw_mov_l_mr((uintptr)&s_ebx,3); + raw_mov_l_mr((uintptr)&s_ecx,1); + raw_mov_l_mr((uintptr)&s_edx,2); + raw_pop_l_r(3); + raw_pop_l_r(2); + raw_pop_l_r(1); + raw_pop_l_r(0); + raw_ret(); + set_target(tmp); + + ((compop_func*)cpuid_space)(0); + if (eax != NULL) *eax = s_eax; + if (ebx != NULL) *ebx = s_ebx; + if (ecx != NULL) *ecx = s_ecx; + if (edx != NULL) *edx = s_edx; + + cache_free (cpuid_space); } static void raw_init_cpu(void) { - struct cpuinfo_x86 *c = &cpuinfo; - uae_u32 xlvl; + struct cpuinfo_x86 *c = &cpuinfo; + uae_u32 xlvl; - /* Defaults */ - c->x86_processor = X86_PROCESSOR_max; - c->x86_vendor = X86_VENDOR_UNKNOWN; - c->cpuid_level = -1; /* CPUID not detected */ - c->x86_model = c->x86_mask = 0; /* So far unknown... */ - c->x86_vendor_id[0] = '\0'; /* Unset */ - c->x86_hwcap = 0; + /* Defaults */ + c->x86_processor = X86_PROCESSOR_max; + c->x86_vendor = X86_VENDOR_UNKNOWN; + c->cpuid_level = -1; /* CPUID not detected */ + c->x86_model = c->x86_mask = 0; /* So far unknown... */ + c->x86_vendor_id[0] = '\0'; /* Unset */ + c->x86_hwcap = 0; - /* Get vendor name */ - c->x86_vendor_id[12] = '\0'; - cpuid(0x00000000, + /* Get vendor name */ + c->x86_vendor_id[12] = '\0'; + cpuid(0x00000000, (uae_u32 *)&c->cpuid_level, (uae_u32 *)&c->x86_vendor_id[0], (uae_u32 *)&c->x86_vendor_id[8], (uae_u32 *)&c->x86_vendor_id[4]); - x86_get_cpu_vendor(c); - - /* Intel-defined flags: level 0x00000001 */ - c->x86_brand_id = 0; - if ( c->cpuid_level >= 0x00000001 ) { - uae_u32 tfms, brand_id; - cpuid(0x00000001, &tfms, &brand_id, NULL, &c->x86_hwcap); - c->x86 = (tfms >> 8) & 15; - c->x86_model = (tfms >> 4) & 15; - c->x86_brand_id = brand_id & 0xff; - if ( (c->x86_vendor == X86_VENDOR_AMD) && - (c->x86 == 0xf)) { - /* AMD Extended Family and Model Values */ - c->x86 += (tfms >> 20) & 0xff; - c->x86_model += (tfms >> 12) & 0xf0; - } - c->x86_mask = tfms & 15; - } else { - /* Have CPUID level 0 only - unheard of */ - c->x86 = 4; - } - - /* AMD-defined flags: level 0x80000001 */ - cpuid(0x80000000, &xlvl, NULL, NULL, NULL); - if ( (xlvl & 0xffff0000) == 0x80000000 ) { - if ( xlvl >= 0x80000001 ) { - uae_u32 features; - cpuid(0x80000001, NULL, NULL, NULL, &features); - if (features & (1 << 29)) { - /* Assume x86-64 if long mode is supported */ - c->x86_processor = X86_PROCESSOR_K8; - } - } - } - - /* Canonicalize processor ID */ - switch (c->x86) { - case 3: - c->x86_processor = X86_PROCESSOR_I386; - break; - case 4: - c->x86_processor = X86_PROCESSOR_I486; - break; - case 5: - if (c->x86_vendor == X86_VENDOR_AMD) - c->x86_processor = X86_PROCESSOR_K6; - else - c->x86_processor = X86_PROCESSOR_PENTIUM; - break; - case 6: - if (c->x86_vendor == X86_VENDOR_AMD) - c->x86_processor = X86_PROCESSOR_ATHLON; - else - c->x86_processor = X86_PROCESSOR_PENTIUMPRO; - break; - case 15: - if (c->x86_vendor == X86_VENDOR_INTEL) { - /* Assume any BrandID >= 8 and family == 15 yields a Pentium 4 */ - if (c->x86_brand_id >= 8) - c->x86_processor = X86_PROCESSOR_PENTIUM4; - } - if (c->x86_vendor == X86_VENDOR_AMD) { - /* Assume an Athlon processor if family == 15 and it was not - detected as an x86-64 so far */ - if (c->x86_processor == X86_PROCESSOR_max) - c->x86_processor = X86_PROCESSOR_ATHLON; - } - break; - } - - /* Have CMOV support? */ - have_cmov = c->x86_hwcap & (1 << 15); + x86_get_cpu_vendor(c); + + /* Intel-defined flags: level 0x00000001 */ + c->x86_brand_id = 0; + if ( c->cpuid_level >= 0x00000001 ) { + uae_u32 tfms, brand_id; + cpuid(0x00000001, &tfms, &brand_id, NULL, &c->x86_hwcap); + c->x86 = (tfms >> 8) & 15; + c->x86_model = (tfms >> 4) & 15; + c->x86_brand_id = brand_id & 0xff; + if ( (c->x86_vendor == X86_VENDOR_AMD) && + (c->x86 == 0xf)) { + /* AMD Extended Family and Model Values */ + c->x86 += (tfms >> 20) & 0xff; + c->x86_model += (tfms >> 12) & 0xf0; + } + c->x86_mask = tfms & 15; + } else { + /* Have CPUID level 0 only - unheard of */ + c->x86 = 4; + } + + /* AMD-defined flags: level 0x80000001 */ + cpuid(0x80000000, &xlvl, NULL, NULL, NULL); + if ( (xlvl & 0xffff0000) == 0x80000000 ) { + if ( xlvl >= 0x80000001 ) { + uae_u32 features; + cpuid(0x80000001, NULL, NULL, NULL, &features); + if (features & (1 << 29)) { + /* Assume x86-64 if long mode is supported */ + c->x86_processor = X86_PROCESSOR_K8; + } + } + } + + /* Canonicalize processor ID */ + switch (c->x86) { + case 3: + c->x86_processor = X86_PROCESSOR_I386; + break; + case 4: + c->x86_processor = X86_PROCESSOR_I486; + break; + case 5: + if (c->x86_vendor == X86_VENDOR_AMD) + c->x86_processor = X86_PROCESSOR_K6; + else + c->x86_processor = X86_PROCESSOR_PENTIUM; + break; + case 6: + if (c->x86_vendor == X86_VENDOR_AMD) + c->x86_processor = X86_PROCESSOR_ATHLON; + else + c->x86_processor = X86_PROCESSOR_PENTIUMPRO; + break; + case 15: + if (c->x86_vendor == X86_VENDOR_INTEL) { + /* Assume any BrandID >= 8 and family == 15 yields a Pentium 4 */ + if (c->x86_brand_id >= 8) + c->x86_processor = X86_PROCESSOR_PENTIUM4; + } + if (c->x86_vendor == X86_VENDOR_AMD) { + /* Assume an Athlon processor if family == 15 and it was not + detected as an x86-64 so far */ + if (c->x86_processor == X86_PROCESSOR_max) + c->x86_processor = X86_PROCESSOR_ATHLON; + } + break; + } + + /* Have CMOV support? */ + have_cmov = c->x86_hwcap & (1 << 15); #if 0 - /* Can the host CPU suffer from partial register stalls? */ - have_rat_stall = (c->x86_vendor == X86_VENDOR_INTEL); - /* It appears that partial register writes are a bad idea even on - AMD K7 cores, even though they are not supposed to have the - dreaded rat stall. Why? Anyway, that's why we lie about it ;-) */ - if (c->x86_processor == X86_PROCESSOR_ATHLON) - have_rat_stall = 1; + /* Can the host CPU suffer from partial register stalls? */ + have_rat_stall = (c->x86_vendor == X86_VENDOR_INTEL); + /* It appears that partial register writes are a bad idea even on + AMD K7 cores, even though they are not supposed to have the + dreaded rat stall. Why? Anyway, that's why we lie about it ;-) */ + if (c->x86_processor == X86_PROCESSOR_ATHLON) + have_rat_stall = 1; #endif - have_rat_stall = 1; + have_rat_stall = 1; - /* Alignments */ - if (tune_alignment) { - align_loops = x86_alignments[c->x86_processor].align_loop; - align_jumps = x86_alignments[c->x86_processor].align_jump; - } - { - TCHAR *s = au (c->x86_vendor_id); - write_log (L"CPUID level=%d, Family=%d, Model=%d, Mask=%d, Vendor=%s [%d]\n", - c->cpuid_level, c->x86, c->x86_model, c->x86_mask, s, c->x86_vendor); - xfree (s); - } + /* Alignments */ + if (tune_alignment) { + align_loops = x86_alignments[c->x86_processor].align_loop; + align_jumps = x86_alignments[c->x86_processor].align_jump; + } + { + TCHAR *s = au (c->x86_vendor_id); + write_log (L"CPUID level=%d, Family=%d, Model=%d, Mask=%d, Vendor=%s [%d]\n", + c->cpuid_level, c->x86, c->x86_model, c->x86_mask, s, c->x86_vendor); + xfree (s); + } } #if 0 @@ -2478,23 +2475,23 @@ static int target_check_bsf(void) { int mismatch = 0; for (int g_ZF = 0; g_ZF <= 1; g_ZF++) { - for (int g_CF = 0; g_CF <= 1; g_CF++) { - for (int g_OF = 0; g_OF <= 1; g_OF++) { - for (int g_SF = 0; g_SF <= 1; g_SF++) { - for (int value = -1; value <= 1; value++) { - unsigned long flags = (g_SF << 7) | (g_OF << 11) | (g_ZF << 6) | g_CF; - unsigned long tmp = value; - __asm__ __volatile__ ("push %0; popf; bsf %1,%1; pushf; pop %0" - : "+r" (flags), "+r" (tmp) : : "cc"); - int OF = (flags >> 11) & 1; - int SF = (flags >> 7) & 1; - int ZF = (flags >> 6) & 1; - int CF = flags & 1; - tmp = (value == 0); - if (ZF != tmp || SF != g_SF || OF != g_OF || CF != g_CF) - mismatch = true; - } - }}}} + for (int g_CF = 0; g_CF <= 1; g_CF++) { + for (int g_OF = 0; g_OF <= 1; g_OF++) { + for (int g_SF = 0; g_SF <= 1; g_SF++) { + for (int value = -1; value <= 1; value++) { + unsigned long flags = (g_SF << 7) | (g_OF << 11) | (g_ZF << 6) | g_CF; + unsigned long tmp = value; + __asm__ __volatile__ ("push %0; popf; bsf %1,%1; pushf; pop %0" + : "+r" (flags), "+r" (tmp) : : "cc"); + int OF = (flags >> 11) & 1; + int SF = (flags >> 7) & 1; + int ZF = (flags >> 6) & 1; + int CF = flags & 1; + tmp = (value == 0); + if (ZF != tmp || SF != g_SF || OF != g_OF || CF != g_CF) + mismatch = true; + } + }}}} if (mismatch) write_log (L"Target CPU defines all flags on BSF instruction\n"); return !mismatch; @@ -2504,1571 +2501,1571 @@ static int target_check_bsf(void) #if 0 /************************************************************************* - * Checking for CPU features * - *************************************************************************/ +* Checking for CPU features * +*************************************************************************/ typedef struct { - uae_u32 eax; - uae_u32 ecx; - uae_u32 edx; - uae_u32 ebx; + uae_u32 eax; + uae_u32 ecx; + uae_u32 edx; + uae_u32 ebx; } x86_regs; /* This could be so much easier if it could make assumptions about the - compiler... */ +compiler... */ static uae_u32 cpuid_ptr; static uae_u32 cpuid_level; static x86_regs cpuid(uae_u32 level) { - x86_regs answer; - uae_u8 *cpuid_space; - void* tmp=get_target(); - - cpuid_ptr=(uae_u32)&answer; - cpuid_level=level; - - cpuid_space = cache_alloc (256); - set_target(cpuid_space); - raw_push_l_r(0); /* eax */ - raw_push_l_r(1); /* ecx */ - raw_push_l_r(2); /* edx */ - raw_push_l_r(3); /* ebx */ - raw_push_l_r(7); /* edi */ - raw_mov_l_rm(0,(uae_u32)&cpuid_level); - raw_cpuid(0); - raw_mov_l_rm(7,(uae_u32)&cpuid_ptr); - raw_mov_l_Rr(7,0,0); - raw_mov_l_Rr(7,1,4); - raw_mov_l_Rr(7,2,8); - raw_mov_l_Rr(7,3,12); - raw_pop_l_r(7); - raw_pop_l_r(3); - raw_pop_l_r(2); - raw_pop_l_r(1); - raw_pop_l_r(0); - raw_ret(); - set_target(tmp); - - ((cpuop_func*)cpuid_space)(0); - cache_free (cpuid_space); - return answer; + x86_regs answer; + uae_u8 *cpuid_space; + void* tmp=get_target(); + + cpuid_ptr=(uae_u32)&answer; + cpuid_level=level; + + cpuid_space = cache_alloc (256); + set_target(cpuid_space); + raw_push_l_r(0); /* eax */ + raw_push_l_r(1); /* ecx */ + raw_push_l_r(2); /* edx */ + raw_push_l_r(3); /* ebx */ + raw_push_l_r(7); /* edi */ + raw_mov_l_rm(0,(uae_u32)&cpuid_level); + raw_cpuid(0); + raw_mov_l_rm(7,(uae_u32)&cpuid_ptr); + raw_mov_l_Rr(7,0,0); + raw_mov_l_Rr(7,1,4); + raw_mov_l_Rr(7,2,8); + raw_mov_l_Rr(7,3,12); + raw_pop_l_r(7); + raw_pop_l_r(3); + raw_pop_l_r(2); + raw_pop_l_r(1); + raw_pop_l_r(0); + raw_ret(); + set_target(tmp); + + ((cpuop_func*)cpuid_space)(0); + cache_free (cpuid_space); + return answer; } static void raw_init_cpu(void) { - x86_regs x; - uae_u32 maxlev; - - x=cpuid(0); - maxlev=x.eax; - write_log (L"Max CPUID level=%d Processor is %c%c%c%c%c%c%c%c%c%c%c%c\n", - maxlev, - x.ebx, - x.ebx>>8, - x.ebx>>16, - x.ebx>>24, - x.edx, - x.edx>>8, - x.edx>>16, - x.edx>>24, - x.ecx, - x.ecx>>8, - x.ecx>>16, - x.ecx>>24 - ); - have_rat_stall=(x.ecx==0x6c65746e); - - if (maxlev>=1) { - x=cpuid(1); - if (x.edx&(1<<15)) - have_cmov=1; - } - have_rat_stall=1; + x86_regs x; + uae_u32 maxlev; + + x=cpuid(0); + maxlev=x.eax; + write_log (L"Max CPUID level=%d Processor is %c%c%c%c%c%c%c%c%c%c%c%c\n", + maxlev, + x.ebx, + x.ebx>>8, + x.ebx>>16, + x.ebx>>24, + x.edx, + x.edx>>8, + x.edx>>16, + x.edx>>24, + x.ecx, + x.ecx>>8, + x.ecx>>16, + x.ecx>>24 + ); + have_rat_stall=(x.ecx==0x6c65746e); + + if (maxlev>=1) { + x=cpuid(1); + if (x.edx&(1<<15)) + have_cmov=1; + } + have_rat_stall=1; #if 0 - if (!have_cmov) - have_rat_stall=0; + if (!have_cmov) + have_rat_stall=0; #endif #if 0 - write_log (L"have_cmov=%d, avoid_cmov=%d, have_rat_stall=%d\n", - have_cmov,currprefs.avoid_cmov,have_rat_stall); - if (currprefs.avoid_cmov) { - write_log (L"Disabling cmov use despite processor claiming to support it!\n"); - have_cmov=0; - } + write_log (L"have_cmov=%d, avoid_cmov=%d, have_rat_stall=%d\n", + have_cmov,currprefs.avoid_cmov,have_rat_stall); + if (currprefs.avoid_cmov) { + write_log (L"Disabling cmov use despite processor claiming to support it!\n"); + have_cmov=0; + } #else - /* Dear Bernie, I don't want to keep around options which are useless, and not - represented in the GUI anymore... Is this okay? */ - write_log (L"have_cmov=%d, have_rat_stall=%d\n", have_cmov, have_rat_stall); + /* Dear Bernie, I don't want to keep around options which are useless, and not + represented in the GUI anymore... Is this okay? */ + write_log (L"have_cmov=%d, have_rat_stall=%d\n", have_cmov, have_rat_stall); #endif #if 0 /* For testing of non-cmov code! */ - have_cmov=0; + have_cmov=0; #endif #if 0 /* It appears that partial register writes are a bad idea even on - AMD K7 cores, even though they are not supposed to have the - dreaded rat stall. Why? Anyway, that's why we lie about it ;-) */ - if (have_cmov) - have_rat_stall=1; + AMD K7 cores, even though they are not supposed to have the + dreaded rat stall. Why? Anyway, that's why we lie about it ;-) */ + if (have_cmov) + have_rat_stall=1; #endif } #endif /************************************************************************* - * FPU stuff * - *************************************************************************/ +* FPU stuff * +*************************************************************************/ STATIC_INLINE void raw_fp_init(void) { - int i; + int i; - for (i=0;i1) { - emit_byte(0x9b); - emit_byte(0xdb); - emit_byte(0xe3); - live.tos=-1; - } + /* using FINIT instead of popping all the entries. + Seems to have side effects --- there is display corruption in + Quake when this is used */ + if (live.tos>1) { + emit_byte(0x9b); + emit_byte(0xdb); + emit_byte(0xe3); + live.tos=-1; + } #endif - while (live.tos>=1) { - emit_byte(0xde); - emit_byte(0xd9); - live.tos-=2; - } - while (live.tos>=0) { - emit_byte(0xdd); - emit_byte(0xd8); - live.tos--; - } - raw_fp_init(); + while (live.tos>=1) { + emit_byte(0xde); + emit_byte(0xd9); + live.tos-=2; + } + while (live.tos>=0) { + emit_byte(0xdd); + emit_byte(0xd8); + live.tos--; + } + raw_fp_init(); } STATIC_INLINE void make_tos(int r) { - int p,q; + int p,q; + + if (live.spos[r]<0) { /* Register not yet on stack */ + emit_byte(0xd9); + emit_byte(0xe8); /* Push '1' on the stack, just to grow it */ + live.tos++; + live.spos[r]=live.tos; + live.onstack[live.tos]=r; + return; + } + /* Register is on stack */ + if (live.tos==live.spos[r]) + return; + p=live.spos[r]; + q=live.onstack[live.tos]; - if (live.spos[r]<0) { /* Register not yet on stack */ emit_byte(0xd9); - emit_byte(0xe8); /* Push '1' on the stack, just to grow it */ - live.tos++; - live.spos[r]=live.tos; + emit_byte(0xc8+live.tos-live.spos[r]); /* exchange it with top of stack */ live.onstack[live.tos]=r; - return; - } - /* Register is on stack */ - if (live.tos==live.spos[r]) - return; - p=live.spos[r]; - q=live.onstack[live.tos]; - - emit_byte(0xd9); - emit_byte(0xc8+live.tos-live.spos[r]); /* exchange it with top of stack */ - live.onstack[live.tos]=r; - live.spos[r]=live.tos; - live.onstack[p]=q; - live.spos[q]=p; + live.spos[r]=live.tos; + live.onstack[p]=q; + live.spos[q]=p; } STATIC_INLINE int stackpos(int r) { - if (live.spos[r]<0) - abort(); - if (live.tos=0) { - /* source is on top of stack, and we already have the dest */ - int dd=stackpos(d); - emit_byte(0xdd); - emit_byte(0xd0+dd); - } - else { - emit_byte(0xd9); - emit_byte(0xc0+ds); /* duplicate source on tos */ - tos_make(d); /* store to destination, pop if necessary */ - } + ds=stackpos(s); + if (ds==0 && live.spos[d]>=0) { + /* source is on top of stack, and we already have the dest */ + int dd=stackpos(d); + emit_byte(0xdd); + emit_byte(0xd0+dd); + } + else { + emit_byte(0xd9); + emit_byte(0xc0+ds); /* duplicate source on tos */ + tos_make(d); /* store to destination, pop if necessary */ + } } LENDFUNC(NONE,NONE,2,raw_fmov_rr,(FW d, FR s)) -LOWFUNC(NONE,READ,2,raw_fldcw_m_indexed,(R4 index, IMM base)) + LOWFUNC(NONE,READ,2,raw_fldcw_m_indexed,(R4 index, IMM base)) { - emit_byte(0xd9); - emit_byte(0xa8+index); - emit_long(base); + emit_byte(0xd9); + emit_byte(0xa8+index); + emit_long(base); } LENDFUNC(NONE,READ,2,raw_fldcw_m_indexed,(R4 index, IMM base)) -LOWFUNC(NONE,NONE,2,raw_fsqrt_rr,(FW d, FR s)) + LOWFUNC(NONE,NONE,2,raw_fsqrt_rr,(FW d, FR s)) { - int ds; + int ds; - if (d!=s) { - ds=stackpos(s); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ - emit_byte(0xd9); - emit_byte(0xfa); /* fsqrt sqrt(x) */ - tos_make(d); /* store to destination */ - } - else { - make_tos(d); - emit_byte(0xd9); - emit_byte(0xfa); /* fsqrt y=sqrt(x) */ - } + if (d!=s) { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + emit_byte(0xd9); + emit_byte(0xfa); /* fsqrt sqrt(x) */ + tos_make(d); /* store to destination */ + } + else { + make_tos(d); + emit_byte(0xd9); + emit_byte(0xfa); /* fsqrt y=sqrt(x) */ + } } LENDFUNC(NONE,NONE,2,raw_fsqrt_rr,(FW d, FR s)) -LOWFUNC(NONE,NONE,2,raw_fabs_rr,(FW d, FR s)) + LOWFUNC(NONE,NONE,2,raw_fabs_rr,(FW d, FR s)) { - int ds; + int ds; - if (d!=s) { - ds=stackpos(s); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ - emit_byte(0xd9); - emit_byte(0xe1); /* fabs abs(x) */ - tos_make(d); /* store to destination */ - } - else { - make_tos(d); - emit_byte(0xd9); - emit_byte(0xe1); /* fabs y=abs(x) */ - } + if (d!=s) { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + emit_byte(0xd9); + emit_byte(0xe1); /* fabs abs(x) */ + tos_make(d); /* store to destination */ + } + else { + make_tos(d); + emit_byte(0xd9); + emit_byte(0xe1); /* fabs y=abs(x) */ + } } LENDFUNC(NONE,NONE,2,raw_fabs_rr,(FW d, FR s)) -LOWFUNC(NONE,NONE,2,raw_frndint_rr,(FW d, FR s)) + LOWFUNC(NONE,NONE,2,raw_frndint_rr,(FW d, FR s)) { - int ds; + int ds; - if (d!=s) { - ds=stackpos(s); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ - emit_byte(0xd9); - emit_byte(0xfc); /* frndint int(x) */ - tos_make(d); /* store to destination */ - } - else { - make_tos(d); - emit_byte(0xd9); - emit_byte(0xfc); /* frndint y=int(x) */ - } + if (d!=s) { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + emit_byte(0xd9); + emit_byte(0xfc); /* frndint int(x) */ + tos_make(d); /* store to destination */ + } + else { + make_tos(d); + emit_byte(0xd9); + emit_byte(0xfc); /* frndint y=int(x) */ + } } LENDFUNC(NONE,NONE,2,raw_frndint_rr,(FW d, FR s)) -LOWFUNC(NONE,NONE,2,raw_fgetexp_rr,(FW d, FR s)) + LOWFUNC(NONE,NONE,2,raw_fgetexp_rr,(FW d, FR s)) { - int ds; + int ds; - if (d!=s) { - ds=stackpos(s); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ - emit_byte(0xd9); - emit_byte(0xf4); /* fxtract exp push man */ - emit_byte(0xdd); - emit_byte(0xd8); /* fstp just pop man */ - tos_make(d); /* store exp to destination */ - } - else { - make_tos(d); /* tos=x=y */ - emit_byte(0xd9); - emit_byte(0xf4); /* fxtract exp push man */ - emit_byte(0xdd); - emit_byte(0xd8); /* fstp just pop man */ - } + if (d!=s) { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + emit_byte(0xd9); + emit_byte(0xf4); /* fxtract exp push man */ + emit_byte(0xdd); + emit_byte(0xd8); /* fstp just pop man */ + tos_make(d); /* store exp to destination */ + } + else { + make_tos(d); /* tos=x=y */ + emit_byte(0xd9); + emit_byte(0xf4); /* fxtract exp push man */ + emit_byte(0xdd); + emit_byte(0xd8); /* fstp just pop man */ + } } LENDFUNC(NONE,NONE,2,raw_fgetexp_rr,(FW d, FR s)) -LOWFUNC(NONE,NONE,2,raw_fgetman_rr,(FW d, FR s)) + LOWFUNC(NONE,NONE,2,raw_fgetman_rr,(FW d, FR s)) { - int ds; + int ds; - if (d!=s) { - ds=stackpos(s); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ - emit_byte(0xd9); - emit_byte(0xf4); /* fxtract exp push man */ - emit_byte(0xdd); - emit_byte(0xd9); /* fstp copy man up & pop */ - tos_make(d); /* store man to destination */ - } - else { - make_tos(d); /* tos=x=y */ - emit_byte(0xd9); - emit_byte(0xf4); /* fxtract exp push man */ - emit_byte(0xdd); - emit_byte(0xd9); /* fstp copy man up & pop */ - } + if (d!=s) { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + emit_byte(0xd9); + emit_byte(0xf4); /* fxtract exp push man */ + emit_byte(0xdd); + emit_byte(0xd9); /* fstp copy man up & pop */ + tos_make(d); /* store man to destination */ + } + else { + make_tos(d); /* tos=x=y */ + emit_byte(0xd9); + emit_byte(0xf4); /* fxtract exp push man */ + emit_byte(0xdd); + emit_byte(0xd9); /* fstp copy man up & pop */ + } } LENDFUNC(NONE,NONE,2,raw_fgetman_rr,(FW d, FR s)) -LOWFUNC(NONE,NONE,2,raw_fsin_rr,(FW d, FR s)) + LOWFUNC(NONE,NONE,2,raw_fsin_rr,(FW d, FR s)) { - int ds; + int ds; - if (d!=s) { - ds=stackpos(s); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ - emit_byte(0xd9); - emit_byte(0xfe); /* fsin sin(x) */ - tos_make(d); /* store to destination */ - } - else { - make_tos(d); - emit_byte(0xd9); - emit_byte(0xfe); /* fsin y=sin(x) */ - } + if (d!=s) { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + emit_byte(0xd9); + emit_byte(0xfe); /* fsin sin(x) */ + tos_make(d); /* store to destination */ + } + else { + make_tos(d); + emit_byte(0xd9); + emit_byte(0xfe); /* fsin y=sin(x) */ + } } LENDFUNC(NONE,NONE,2,raw_fsin_rr,(FW d, FR s)) -LOWFUNC(NONE,NONE,2,raw_fcos_rr,(FW d, FR s)) + LOWFUNC(NONE,NONE,2,raw_fcos_rr,(FW d, FR s)) { - int ds; + int ds; - if (d!=s) { - ds=stackpos(s); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ - emit_byte(0xd9); - emit_byte(0xff); /* fcos cos(x) */ - tos_make(d); /* store to destination */ - } - else { - make_tos(d); - emit_byte(0xd9); - emit_byte(0xff); /* fcos y=cos(x) */ - } + if (d!=s) { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + emit_byte(0xd9); + emit_byte(0xff); /* fcos cos(x) */ + tos_make(d); /* store to destination */ + } + else { + make_tos(d); + emit_byte(0xd9); + emit_byte(0xff); /* fcos y=cos(x) */ + } } LENDFUNC(NONE,NONE,2,raw_fcos_rr,(FW d, FR s)) -LOWFUNC(NONE,NONE,2,raw_ftan_rr,(FW d, FR s)) + LOWFUNC(NONE,NONE,2,raw_ftan_rr,(FW d, FR s)) { - int ds; + int ds; - if (d!=s) { - ds=stackpos(s); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ - emit_byte(0xd9); - emit_byte(0xf2); /* fptan tan(x)=y/1.0 */ - emit_byte(0xdd); - emit_byte(0xd8); /* fstp pop 1.0 */ - tos_make(d); /* store to destination */ - } - else { - make_tos(d); - emit_byte(0xd9); - emit_byte(0xf2); /* fptan tan(x)=y/1.0 */ - emit_byte(0xdd); - emit_byte(0xd8); /* fstp pop 1.0 */ - } + if (d!=s) { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + emit_byte(0xd9); + emit_byte(0xf2); /* fptan tan(x)=y/1.0 */ + emit_byte(0xdd); + emit_byte(0xd8); /* fstp pop 1.0 */ + tos_make(d); /* store to destination */ + } + else { + make_tos(d); + emit_byte(0xd9); + emit_byte(0xf2); /* fptan tan(x)=y/1.0 */ + emit_byte(0xdd); + emit_byte(0xd8); /* fstp pop 1.0 */ + } } LENDFUNC(NONE,NONE,2,raw_ftan_rr,(FW d, FR s)) -LOWFUNC(NONE,NONE,3,raw_fsincos_rr,(FW d, FW c, FR s)) -{ - int ds; - - if (s==d) { - //write_log (L"FSINCOS src = dest\n"); - make_tos(s); - emit_byte(0xd9); - emit_byte(0xfb); /* fsincos sin(x) push cos(x) */ - tos_make(c); /* store cos(x) to c */ - return; - } - - ds=stackpos(s); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ - emit_byte(0xd9); - emit_byte(0xfb); /* fsincos sin(x) push cos(x) */ - if (live.spos[c]<0) { - if (live.spos[d]<0) { /* occupy both regs directly */ - live.tos++; - live.spos[d]=live.tos; - live.onstack[live.tos]=d; /* sin(x) comes first */ - live.tos++; - live.spos[c]=live.tos; - live.onstack[live.tos]=c; + LOWFUNC(NONE,NONE,3,raw_fsincos_rr,(FW d, FW c, FR s)) +{ + int ds; + + if (s==d) { + //write_log (L"FSINCOS src = dest\n"); + make_tos(s); + emit_byte(0xd9); + emit_byte(0xfb); /* fsincos sin(x) push cos(x) */ + tos_make(c); /* store cos(x) to c */ + return; + } + + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + emit_byte(0xd9); + emit_byte(0xfb); /* fsincos sin(x) push cos(x) */ + if (live.spos[c]<0) { + if (live.spos[d]<0) { /* occupy both regs directly */ + live.tos++; + live.spos[d]=live.tos; + live.onstack[live.tos]=d; /* sin(x) comes first */ + live.tos++; + live.spos[c]=live.tos; + live.onstack[live.tos]=c; + } + else { + emit_byte(0xd9); + emit_byte(0xc9); /* fxch swap cos(x) with sin(x) */ + emit_byte(0xdd); /* store sin(x) to d & pop */ + emit_byte(0xd8+(live.tos+2)-live.spos[d]); + live.tos++; /* occupy a reg for cos(x) here */ + live.spos[c]=live.tos; + live.onstack[live.tos]=c; + } } else { - emit_byte(0xd9); - emit_byte(0xc9); /* fxch swap cos(x) with sin(x) */ - emit_byte(0xdd); /* store sin(x) to d & pop */ - emit_byte(0xd8+(live.tos+2)-live.spos[d]); - live.tos++; /* occupy a reg for cos(x) here */ - live.spos[c]=live.tos; - live.onstack[live.tos]=c; - } - } - else { - emit_byte(0xdd); /* store cos(x) to c & pop */ - emit_byte(0xd8+(live.tos+2)-live.spos[c]); - tos_make(d); /* store sin(x) to destination */ - } + emit_byte(0xdd); /* store cos(x) to c & pop */ + emit_byte(0xd8+(live.tos+2)-live.spos[c]); + tos_make(d); /* store sin(x) to destination */ + } } LENDFUNC(NONE,NONE,3,raw_fsincos_rr,(FW d, FW c, FR s)) -float one=1; + float one=1; LOWFUNC(NONE,NONE,2,raw_fscale_rr,(FRW d, FR s)) { - int ds; + int ds; - if (live.spos[d]==live.tos && live.spos[s]==live.tos-1) { - //write_log (L"fscale found x in TOS-1 and y in TOS\n"); - emit_byte(0xd9); - emit_byte(0xfd); /* fscale y*(2^x) */ - } - else { - make_tos(s); /* tos=x */ - ds=stackpos(d); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld y */ - emit_byte(0xd9); - emit_byte(0xfd); /* fscale y*(2^x) */ - tos_make(d); /* store y=y*(2^x) */ - } + if (live.spos[d]==live.tos && live.spos[s]==live.tos-1) { + //write_log (L"fscale found x in TOS-1 and y in TOS\n"); + emit_byte(0xd9); + emit_byte(0xfd); /* fscale y*(2^x) */ + } + else { + make_tos(s); /* tos=x */ + ds=stackpos(d); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld y */ + emit_byte(0xd9); + emit_byte(0xfd); /* fscale y*(2^x) */ + tos_make(d); /* store y=y*(2^x) */ + } } LENDFUNC(NONE,NONE,2,raw_fscale_rr,(FRW d, FR s)) -LOWFUNC(NONE,NONE,2,raw_ftwotox_rr,(FW d, FR s)) -{ - int ds; - - ds=stackpos(s); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ - emit_byte(0xd9); - emit_byte(0xfc); /* frndint int(x) */ - emit_byte(0xd9); - emit_byte(0xc1+ds); /* fld x again */ - emit_byte(0xd8); - emit_byte(0xe1); /* fsub frac(x) = x - int(x) */ - emit_byte(0xd9); - emit_byte(0xf0); /* f2xm1 (2^frac(x))-1 */ - emit_byte(0xd8); - emit_byte(0x05); - emit_long((uae_u32)&one); /* fadd (2^frac(x))-1 + 1 */ - emit_byte(0xd9); - emit_byte(0xfd); /* fscale (2^frac(x))*2^int(x) */ - emit_byte(0xdd); - emit_byte(0xd9); /* fstp copy & pop */ - tos_make(d); /* store y=2^x */ -} -LENDFUNC(NONE,NONE,2,raw_ftwotox_rr,(FW d, FR s)) - -LOWFUNC(NONE,NONE,2,raw_fetox_rr,(FW d, FR s)) + LOWFUNC(NONE,NONE,2,raw_ftwotox_rr,(FW d, FR s)) { - int ds; + int ds; - if (s==d) - make_tos(s); - else { ds=stackpos(s); emit_byte(0xd9); emit_byte(0xc0+ds); /* fld x */ - } - emit_byte(0xd9); - emit_byte(0xea); /* fldl2e log2(e) */ - emit_byte(0xd8); - emit_byte(0xc9); /* fmul x*log2(e) */ - emit_byte(0xdd); - emit_byte(0xd1); /* fst copy up */ - emit_byte(0xd9); - emit_byte(0xfc); /* frndint int(x*log2(e)) */ - emit_byte(0xd9); - emit_byte(0xc9); /* fxch swap top two elements */ - emit_byte(0xd8); - emit_byte(0xe1); /* fsub x*log2(e) - int(x*log2(e)) */ - emit_byte(0xd9); - emit_byte(0xf0); /* f2xm1 (2^frac(x))-1 */ - emit_byte(0xd8); - emit_byte(0x05); - emit_long((uae_u32)&one); /* fadd (2^frac(x))-1 + 1 */ - emit_byte(0xd9); - emit_byte(0xfd); /* fscale (2^frac(x))*2^int(x*log2(e)) */ - emit_byte(0xdd); - emit_byte(0xd9); /* fstp copy & pop */ - if (s!=d) - tos_make(d); /* store y=e^x */ -} -LENDFUNC(NONE,NONE,2,raw_fetox_rr,(FW d, FR s)) - -LOWFUNC(NONE,NONE,2,raw_fetoxM1_rr,(FW d, FR s)) -{ - int ds; - - if (s==d) - make_tos(s); - else { - ds=stackpos(s); emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ - } - emit_byte(0xd9); - emit_byte(0xea); /* fldl2e log2(e) */ - emit_byte(0xd8); - emit_byte(0xc9); /* fmul x*log2(e) */ - emit_byte(0xdd); - emit_byte(0xd1); /* fst copy up */ - emit_byte(0xd9); - emit_byte(0xfc); /* frndint int(x*log2(e)) */ - emit_byte(0xd9); - emit_byte(0xc9); /* fxch swap top two elements */ - emit_byte(0xd8); - emit_byte(0xe1); /* fsub x*log2(e) - int(x*log2(e)) */ - emit_byte(0xd9); - emit_byte(0xf0); /* f2xm1 (2^frac(x))-1 */ - emit_byte(0xd9); - emit_byte(0xfd); /* fscale ((2^frac(x))-1)*2^int(x*log2(e)) */ - emit_byte(0xdd); - emit_byte(0xd9); /* fstp copy & pop */ - if (s!=d) - tos_make(d); /* store y=(e^x)-1 */ + emit_byte(0xfc); /* frndint int(x) */ + emit_byte(0xd9); + emit_byte(0xc1+ds); /* fld x again */ + emit_byte(0xd8); + emit_byte(0xe1); /* fsub frac(x) = x - int(x) */ + emit_byte(0xd9); + emit_byte(0xf0); /* f2xm1 (2^frac(x))-1 */ + emit_byte(0xd8); + emit_byte(0x05); + emit_long((uae_u32)&one); /* fadd (2^frac(x))-1 + 1 */ + emit_byte(0xd9); + emit_byte(0xfd); /* fscale (2^frac(x))*2^int(x) */ + emit_byte(0xdd); + emit_byte(0xd9); /* fstp copy & pop */ + tos_make(d); /* store y=2^x */ } -LENDFUNC(NONE,NONE,2,raw_fetoxM1_rr,(FW d, FR s)) +LENDFUNC(NONE,NONE,2,raw_ftwotox_rr,(FW d, FR s)) -LOWFUNC(NONE,NONE,2,raw_ftentox_rr,(FW d, FR s)) + LOWFUNC(NONE,NONE,2,raw_fetox_rr,(FW d, FR s)) { - int ds; + int ds; - if (s==d) - make_tos(s); - else { - ds=stackpos(s); + if (s==d) + make_tos(s); + else { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + } emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ - } - emit_byte(0xd9); - emit_byte(0xe9); /* fldl2t log2(10) */ - emit_byte(0xd8); - emit_byte(0xc9); /* fmul x*log2(10) */ - emit_byte(0xdd); - emit_byte(0xd1); /* fst copy up */ - emit_byte(0xd9); - emit_byte(0xfc); /* frndint int(x*log2(10)) */ - emit_byte(0xd9); - emit_byte(0xc9); /* fxch swap top two elements */ - emit_byte(0xd8); - emit_byte(0xe1); /* fsub x*log2(10) - int(x*log2(10)) */ - emit_byte(0xd9); - emit_byte(0xf0); /* f2xm1 (2^frac(x))-1 */ - emit_byte(0xd8); - emit_byte(0x05); - emit_long((uae_u32)&one); /* fadd (2^frac(x))-1 + 1 */ - emit_byte(0xd9); - emit_byte(0xfd); /* fscale (2^frac(x))*2^int(x*log2(10)) */ - emit_byte(0xdd); - emit_byte(0xd9); /* fstp copy & pop */ - if (s!=d) - tos_make(d); /* store y=10^x */ + emit_byte(0xea); /* fldl2e log2(e) */ + emit_byte(0xd8); + emit_byte(0xc9); /* fmul x*log2(e) */ + emit_byte(0xdd); + emit_byte(0xd1); /* fst copy up */ + emit_byte(0xd9); + emit_byte(0xfc); /* frndint int(x*log2(e)) */ + emit_byte(0xd9); + emit_byte(0xc9); /* fxch swap top two elements */ + emit_byte(0xd8); + emit_byte(0xe1); /* fsub x*log2(e) - int(x*log2(e)) */ + emit_byte(0xd9); + emit_byte(0xf0); /* f2xm1 (2^frac(x))-1 */ + emit_byte(0xd8); + emit_byte(0x05); + emit_long((uae_u32)&one); /* fadd (2^frac(x))-1 + 1 */ + emit_byte(0xd9); + emit_byte(0xfd); /* fscale (2^frac(x))*2^int(x*log2(e)) */ + emit_byte(0xdd); + emit_byte(0xd9); /* fstp copy & pop */ + if (s!=d) + tos_make(d); /* store y=e^x */ +} +LENDFUNC(NONE,NONE,2,raw_fetox_rr,(FW d, FR s)) + + LOWFUNC(NONE,NONE,2,raw_fetoxM1_rr,(FW d, FR s)) +{ + int ds; + + if (s==d) + make_tos(s); + else { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + } + emit_byte(0xd9); + emit_byte(0xea); /* fldl2e log2(e) */ + emit_byte(0xd8); + emit_byte(0xc9); /* fmul x*log2(e) */ + emit_byte(0xdd); + emit_byte(0xd1); /* fst copy up */ + emit_byte(0xd9); + emit_byte(0xfc); /* frndint int(x*log2(e)) */ + emit_byte(0xd9); + emit_byte(0xc9); /* fxch swap top two elements */ + emit_byte(0xd8); + emit_byte(0xe1); /* fsub x*log2(e) - int(x*log2(e)) */ + emit_byte(0xd9); + emit_byte(0xf0); /* f2xm1 (2^frac(x))-1 */ + emit_byte(0xd9); + emit_byte(0xfd); /* fscale ((2^frac(x))-1)*2^int(x*log2(e)) */ + emit_byte(0xdd); + emit_byte(0xd9); /* fstp copy & pop */ + if (s!=d) + tos_make(d); /* store y=(e^x)-1 */ +} +LENDFUNC(NONE,NONE,2,raw_fetoxM1_rr,(FW d, FR s)) + + LOWFUNC(NONE,NONE,2,raw_ftentox_rr,(FW d, FR s)) +{ + int ds; + + if (s==d) + make_tos(s); + else { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + } + emit_byte(0xd9); + emit_byte(0xe9); /* fldl2t log2(10) */ + emit_byte(0xd8); + emit_byte(0xc9); /* fmul x*log2(10) */ + emit_byte(0xdd); + emit_byte(0xd1); /* fst copy up */ + emit_byte(0xd9); + emit_byte(0xfc); /* frndint int(x*log2(10)) */ + emit_byte(0xd9); + emit_byte(0xc9); /* fxch swap top two elements */ + emit_byte(0xd8); + emit_byte(0xe1); /* fsub x*log2(10) - int(x*log2(10)) */ + emit_byte(0xd9); + emit_byte(0xf0); /* f2xm1 (2^frac(x))-1 */ + emit_byte(0xd8); + emit_byte(0x05); + emit_long((uae_u32)&one); /* fadd (2^frac(x))-1 + 1 */ + emit_byte(0xd9); + emit_byte(0xfd); /* fscale (2^frac(x))*2^int(x*log2(10)) */ + emit_byte(0xdd); + emit_byte(0xd9); /* fstp copy & pop */ + if (s!=d) + tos_make(d); /* store y=10^x */ } LENDFUNC(NONE,NONE,2,raw_ftentox_rr,(FW d, FR s)) -LOWFUNC(NONE,NONE,2,raw_flog2_rr,(FW d, FR s)) + LOWFUNC(NONE,NONE,2,raw_flog2_rr,(FW d, FR s)) { - int ds; + int ds; - if (s==d) - make_tos(s); - else { - ds=stackpos(s); + if (s==d) + make_tos(s); + else { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + } emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ - } - emit_byte(0xd9); - emit_byte(0xe8); /* fld1 1 */ - emit_byte(0xd9); - emit_byte(0xc9); /* fxch swap 1 with x */ - emit_byte(0xd9); - emit_byte(0xf1); /* fyl2x 1*log2(x) */ - if (s!=d) - tos_make(d); /* store y=log2(x) */ + emit_byte(0xe8); /* fld1 1 */ + emit_byte(0xd9); + emit_byte(0xc9); /* fxch swap 1 with x */ + emit_byte(0xd9); + emit_byte(0xf1); /* fyl2x 1*log2(x) */ + if (s!=d) + tos_make(d); /* store y=log2(x) */ } LENDFUNC(NONE,NONE,2,raw_flog2_rr,(FW d, FR s)) -LOWFUNC(NONE,NONE,2,raw_flogN_rr,(FW d, FR s)) + LOWFUNC(NONE,NONE,2,raw_flogN_rr,(FW d, FR s)) { - int ds; + int ds; - if (s==d) - make_tos(s); - else { - ds=stackpos(s); + if (s==d) + make_tos(s); + else { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + } emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ - } - emit_byte(0xd9); - emit_byte(0xed); /* fldln2 logN(2) */ - emit_byte(0xd9); - emit_byte(0xc9); /* fxch swap logN(2) with x */ - emit_byte(0xd9); - emit_byte(0xf1); /* fyl2x logN(2)*log2(x) */ - if (s!=d) - tos_make(d); /* store y=logN(x) */ + emit_byte(0xed); /* fldln2 logN(2) */ + emit_byte(0xd9); + emit_byte(0xc9); /* fxch swap logN(2) with x */ + emit_byte(0xd9); + emit_byte(0xf1); /* fyl2x logN(2)*log2(x) */ + if (s!=d) + tos_make(d); /* store y=logN(x) */ } LENDFUNC(NONE,NONE,2,raw_flogN_rr,(FW d, FR s)) -LOWFUNC(NONE,NONE,2,raw_flogNP1_rr,(FW d, FR s)) + LOWFUNC(NONE,NONE,2,raw_flogNP1_rr,(FW d, FR s)) { - int ds; + int ds; - if (s==d) - make_tos(s); - else { - ds=stackpos(s); + if (s==d) + make_tos(s); + else { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + } emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ - } - emit_byte(0xd9); - emit_byte(0xed); /* fldln2 logN(2) */ - emit_byte(0xd9); - emit_byte(0xc9); /* fxch swap logN(2) with x */ - emit_byte(0xd9); - emit_byte(0xf9); /* fyl2xp1 logN(2)*log2(x+1) */ - if (s!=d) - tos_make(d); /* store y=logN(x+1) */ + emit_byte(0xed); /* fldln2 logN(2) */ + emit_byte(0xd9); + emit_byte(0xc9); /* fxch swap logN(2) with x */ + emit_byte(0xd9); + emit_byte(0xf9); /* fyl2xp1 logN(2)*log2(x+1) */ + if (s!=d) + tos_make(d); /* store y=logN(x+1) */ } LENDFUNC(NONE,NONE,2,raw_flogNP1_rr,(FW d, FR s)) -LOWFUNC(NONE,NONE,2,raw_flog10_rr,(FW d, FR s)) + LOWFUNC(NONE,NONE,2,raw_flog10_rr,(FW d, FR s)) { - int ds; + int ds; - if (s==d) - make_tos(s); - else { - ds=stackpos(s); + if (s==d) + make_tos(s); + else { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + } emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ - } - emit_byte(0xd9); - emit_byte(0xec); /* fldlg2 log10(2) */ - emit_byte(0xd9); - emit_byte(0xc9); /* fxch swap log10(2) with x */ - emit_byte(0xd9); - emit_byte(0xf1); /* fyl2x log10(2)*log2(x) */ - if (s!=d) - tos_make(d); /* store y=log10(x) */ + emit_byte(0xec); /* fldlg2 log10(2) */ + emit_byte(0xd9); + emit_byte(0xc9); /* fxch swap log10(2) with x */ + emit_byte(0xd9); + emit_byte(0xf1); /* fyl2x log10(2)*log2(x) */ + if (s!=d) + tos_make(d); /* store y=log10(x) */ } LENDFUNC(NONE,NONE,2,raw_flog10_rr,(FW d, FR s)) -LOWFUNC(NONE,NONE,2,raw_fasin_rr,(FW d, FR s)) -{ - int ds; - - ds=stackpos(s); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ - emit_byte(0xd8); - emit_byte(0xc8); /* fmul x*x */ - emit_byte(0xd9); - emit_byte(0xe8); /* fld 1.0 */ - emit_byte(0xde); - emit_byte(0xe1); /* fsubrp 1 - (x^2) */ - emit_byte(0xd9); - emit_byte(0xfa); /* fsqrt sqrt(1-(x^2)) */ - emit_byte(0xd9); - emit_byte(0xc1+ds); /* fld x again */ - emit_byte(0xd9); - emit_byte(0xc9); /* fxch swap x with sqrt(1-(x^2)) */ - emit_byte(0xd9); - emit_byte(0xf3); /* fpatan atan(x/sqrt(1-(x^2))) & pop */ - tos_make(d); /* store y=asin(x) */ + LOWFUNC(NONE,NONE,2,raw_fasin_rr,(FW d, FR s)) +{ + int ds; + + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + emit_byte(0xd8); + emit_byte(0xc8); /* fmul x*x */ + emit_byte(0xd9); + emit_byte(0xe8); /* fld 1.0 */ + emit_byte(0xde); + emit_byte(0xe1); /* fsubrp 1 - (x^2) */ + emit_byte(0xd9); + emit_byte(0xfa); /* fsqrt sqrt(1-(x^2)) */ + emit_byte(0xd9); + emit_byte(0xc1+ds); /* fld x again */ + emit_byte(0xd9); + emit_byte(0xc9); /* fxch swap x with sqrt(1-(x^2)) */ + emit_byte(0xd9); + emit_byte(0xf3); /* fpatan atan(x/sqrt(1-(x^2))) & pop */ + tos_make(d); /* store y=asin(x) */ } LENDFUNC(NONE,NONE,2,raw_fasin_rr,(FW d, FR s)) -static uae_u32 pihalf[] = {0x2168c234, 0xc90fdaa2, 0x3fff}; // LSB=0 to get acos(1)=0 + static uae_u32 pihalf[] = {0x2168c234, 0xc90fdaa2, 0x3fff}; // LSB=0 to get acos(1)=0 LOWFUNC(NONE,NONE,2,raw_facos_rr,(FW d, FR s)) { - int ds; - - ds=stackpos(s); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ - emit_byte(0xd8); - emit_byte(0xc8); /* fmul x*x */ - emit_byte(0xd9); - emit_byte(0xe8); /* fld 1.0 */ - emit_byte(0xde); - emit_byte(0xe1); /* fsubrp 1 - (x^2) */ - emit_byte(0xd9); - emit_byte(0xfa); /* fsqrt sqrt(1-(x^2)) */ - emit_byte(0xd9); - emit_byte(0xc1+ds); /* fld x again */ - emit_byte(0xd9); - emit_byte(0xc9); /* fxch swap x with sqrt(1-(x^2)) */ - emit_byte(0xd9); - emit_byte(0xf3); /* fpatan atan(x/sqrt(1-(x^2))) & pop */ - emit_byte(0xdb); - emit_byte(0x2d); - emit_long((uae_u32)&pihalf); /* fld load pi/2 from pihalf */ - emit_byte(0xde); - emit_byte(0xe1); /* fsubrp pi/2 - asin(x) & pop */ - tos_make(d); /* store y=acos(x) */ + int ds; + + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + emit_byte(0xd8); + emit_byte(0xc8); /* fmul x*x */ + emit_byte(0xd9); + emit_byte(0xe8); /* fld 1.0 */ + emit_byte(0xde); + emit_byte(0xe1); /* fsubrp 1 - (x^2) */ + emit_byte(0xd9); + emit_byte(0xfa); /* fsqrt sqrt(1-(x^2)) */ + emit_byte(0xd9); + emit_byte(0xc1+ds); /* fld x again */ + emit_byte(0xd9); + emit_byte(0xc9); /* fxch swap x with sqrt(1-(x^2)) */ + emit_byte(0xd9); + emit_byte(0xf3); /* fpatan atan(x/sqrt(1-(x^2))) & pop */ + emit_byte(0xdb); + emit_byte(0x2d); + emit_long((uae_u32)&pihalf); /* fld load pi/2 from pihalf */ + emit_byte(0xde); + emit_byte(0xe1); /* fsubrp pi/2 - asin(x) & pop */ + tos_make(d); /* store y=acos(x) */ } LENDFUNC(NONE,NONE,2,raw_facos_rr,(FW d, FR s)) -LOWFUNC(NONE,NONE,2,raw_fatan_rr,(FW d, FR s)) + LOWFUNC(NONE,NONE,2,raw_fatan_rr,(FW d, FR s)) { - int ds; + int ds; - if (s==d) - make_tos(s); - else { - ds=stackpos(s); + if (s==d) + make_tos(s); + else { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + } emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ - } - emit_byte(0xd9); - emit_byte(0xe8); /* fld 1.0 */ - emit_byte(0xd9); - emit_byte(0xf3); /* fpatan atan(x)/1 & pop*/ - if (s!=d) - tos_make(d); /* store y=atan(x) */ + emit_byte(0xe8); /* fld 1.0 */ + emit_byte(0xd9); + emit_byte(0xf3); /* fpatan atan(x)/1 & pop*/ + if (s!=d) + tos_make(d); /* store y=atan(x) */ } LENDFUNC(NONE,NONE,2,raw_fatan_rr,(FW d, FR s)) -LOWFUNC(NONE,NONE,2,raw_fatanh_rr,(FW d, FR s)) -{ - int ds; - - ds=stackpos(s); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ - emit_byte(0xd9); - emit_byte(0xe8); /* fld 1.0 */ - emit_byte(0xdc); - emit_byte(0xc1); /* fadd 1 + x */ - emit_byte(0xd8); - emit_byte(0xe2+ds); /* fsub 1 - x */ - emit_byte(0xde); - emit_byte(0xf9); /* fdivp (1+x)/(1-x) */ - emit_byte(0xd9); - emit_byte(0xed); /* fldl2e logN(2) */ - emit_byte(0xd9); - emit_byte(0xc9); /* fxch swap logN(2) with (1+x)/(1-x) */ - emit_byte(0xd9); - emit_byte(0xf1); /* fyl2x logN(2)*log2((1+x)/(1-x)) pop */ - emit_byte(0xd9); - emit_byte(0xe8); /* fld 1.0 */ - emit_byte(0xd9); - emit_byte(0xe0); /* fchs -1.0 */ - emit_byte(0xd9); - emit_byte(0xc9); /* fxch swap */ - emit_byte(0xd9); - emit_byte(0xfd); /* fscale logN((1+x)/(1-x)) * 2^(-1) */ - emit_byte(0xdd); - emit_byte(0xd9); /* fstp copy & pop */ - tos_make(d); /* store y=atanh(x) */ -} -LENDFUNC(NONE,NONE,2,raw_fatanh_rr,(FW d, FR s)) - -LOWFUNC(NONE,NONE,2,raw_fsinh_rr,(FW d, FR s)) + LOWFUNC(NONE,NONE,2,raw_fatanh_rr,(FW d, FR s)) { - int ds,tr; + int ds; - tr=live.onstack[live.tos+3]; - if (s==d) - make_tos(s); - else { ds=stackpos(s); emit_byte(0xd9); emit_byte(0xc0+ds); /* fld x */ - } - emit_byte(0xd9); - emit_byte(0xea); /* fldl2e log2(e) */ - emit_byte(0xd8); - emit_byte(0xc9); /* fmul x*log2(e) */ - emit_byte(0xdd); - emit_byte(0xd1); /* fst copy x*log2(e) */ - if (tr>=0) { - emit_byte(0xd9); - emit_byte(0xca); /* fxch swap with temp-reg */ - emit_byte(0x83); - emit_byte(0xc4); - emit_byte(0xf4); /* add -12 to esp */ - emit_byte(0xdb); - emit_byte(0x3c); - emit_byte(0x24); /* fstp store temp-reg to [esp] & pop */ - } - emit_byte(0xd9); - emit_byte(0xe0); /* fchs -x*log2(e) */ - emit_byte(0xd9); - emit_byte(0xc0); /* fld -x*log2(e) again */ - emit_byte(0xd9); - emit_byte(0xfc); /* frndint int(-x*log2(e)) */ - emit_byte(0xd9); - emit_byte(0xc9); /* fxch swap */ - emit_byte(0xd8); - emit_byte(0xe1); /* fsub -x*log2(e) - int(-x*log2(e)) */ - emit_byte(0xd9); - emit_byte(0xf0); /* f2xm1 (2^frac(x))-1 */ - emit_byte(0xd8); - emit_byte(0x05); - emit_long((uae_u32)&one); /* fadd (2^frac(x))-1 + 1 */ - emit_byte(0xd9); - emit_byte(0xfd); /* fscale (2^frac(x))*2^int(x*log2(e)) */ - emit_byte(0xd9); - emit_byte(0xca); /* fxch swap e^-x with x*log2(e) in tr */ - emit_byte(0xdd); - emit_byte(0xd1); /* fst copy x*log2(e) */ - emit_byte(0xd9); - emit_byte(0xfc); /* frndint int(x*log2(e)) */ - emit_byte(0xd9); - emit_byte(0xc9); /* fxch swap */ - emit_byte(0xd8); - emit_byte(0xe1); /* fsub x*log2(e) - int(x*log2(e)) */ - emit_byte(0xd9); - emit_byte(0xf0); /* f2xm1 (2^frac(x))-1 */ - emit_byte(0xd8); - emit_byte(0x05); - emit_long((uae_u32)&one); /* fadd (2^frac(x))-1 + 1 */ - emit_byte(0xd9); - emit_byte(0xfd); /* fscale (2^frac(x))*2^int(x*log2(e)) */ - emit_byte(0xdd); - emit_byte(0xd9); /* fstp copy e^x & pop */ - if (tr>=0) { - emit_byte(0xdb); - emit_byte(0x2c); - emit_byte(0x24); /* fld load temp-reg from [esp] */ - emit_byte(0x83); - emit_byte(0xc4); - emit_byte(0x0c); /* add +12 to esp */ emit_byte(0xd9); - emit_byte(0xca); /* fxch swap temp-reg with e^-x in tr */ - emit_byte(0xde); - emit_byte(0xe9); /* fsubp (e^x)-(e^-x) */ - } - else { + emit_byte(0xe8); /* fld 1.0 */ + emit_byte(0xdc); + emit_byte(0xc1); /* fadd 1 + x */ + emit_byte(0xd8); + emit_byte(0xe2+ds); /* fsub 1 - x */ emit_byte(0xde); - emit_byte(0xe1); /* fsubrp (e^x)-(e^-x) */ - } - emit_byte(0xd9); - emit_byte(0xe8); /* fld 1.0 */ - emit_byte(0xd9); - emit_byte(0xe0); /* fchs -1.0 */ - emit_byte(0xd9); - emit_byte(0xc9); /* fxch swap */ - emit_byte(0xd9); - emit_byte(0xfd); /* fscale ((e^x)-(e^-x))/2 */ - emit_byte(0xdd); - emit_byte(0xd9); /* fstp copy & pop */ - if (s!=d) - tos_make(d); /* store y=sinh(x) */ + emit_byte(0xf9); /* fdivp (1+x)/(1-x) */ + emit_byte(0xd9); + emit_byte(0xed); /* fldl2e logN(2) */ + emit_byte(0xd9); + emit_byte(0xc9); /* fxch swap logN(2) with (1+x)/(1-x) */ + emit_byte(0xd9); + emit_byte(0xf1); /* fyl2x logN(2)*log2((1+x)/(1-x)) pop */ + emit_byte(0xd9); + emit_byte(0xe8); /* fld 1.0 */ + emit_byte(0xd9); + emit_byte(0xe0); /* fchs -1.0 */ + emit_byte(0xd9); + emit_byte(0xc9); /* fxch swap */ + emit_byte(0xd9); + emit_byte(0xfd); /* fscale logN((1+x)/(1-x)) * 2^(-1) */ + emit_byte(0xdd); + emit_byte(0xd9); /* fstp copy & pop */ + tos_make(d); /* store y=atanh(x) */ } -LENDFUNC(NONE,NONE,2,raw_fsinh_rr,(FW d, FR s)) +LENDFUNC(NONE,NONE,2,raw_fatanh_rr,(FW d, FR s)) -LOWFUNC(NONE,NONE,2,raw_fcosh_rr,(FW d, FR s)) + LOWFUNC(NONE,NONE,2,raw_fsinh_rr,(FW d, FR s)) { - int ds,tr; + int ds,tr; - tr=live.onstack[live.tos+3]; - if (s==d) - make_tos(s); - else { - ds=stackpos(s); + tr=live.onstack[live.tos+3]; + if (s==d) + make_tos(s); + else { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + } emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ - } - emit_byte(0xd9); - emit_byte(0xea); /* fldl2e log2(e) */ - emit_byte(0xd8); - emit_byte(0xc9); /* fmul x*log2(e) */ - emit_byte(0xdd); - emit_byte(0xd1); /* fst copy x*log2(e) */ - if (tr>=0) { - emit_byte(0xd9); - emit_byte(0xca); /* fxch swap with temp-reg */ - emit_byte(0x83); - emit_byte(0xc4); - emit_byte(0xf4); /* add -12 to esp */ - emit_byte(0xdb); - emit_byte(0x3c); - emit_byte(0x24); /* fstp store temp-reg to [esp] & pop */ - } - emit_byte(0xd9); - emit_byte(0xe0); /* fchs -x*log2(e) */ - emit_byte(0xd9); - emit_byte(0xc0); /* fld -x*log2(e) again */ - emit_byte(0xd9); - emit_byte(0xfc); /* frndint int(-x*log2(e)) */ - emit_byte(0xd9); - emit_byte(0xc9); /* fxch swap */ - emit_byte(0xd8); - emit_byte(0xe1); /* fsub -x*log2(e) - int(-x*log2(e)) */ - emit_byte(0xd9); - emit_byte(0xf0); /* f2xm1 (2^frac(x))-1 */ - emit_byte(0xd8); - emit_byte(0x05); - emit_long((uae_u32)&one); /* fadd (2^frac(x))-1 + 1 */ - emit_byte(0xd9); - emit_byte(0xfd); /* fscale (2^frac(x))*2^int(x*log2(e)) */ - emit_byte(0xd9); - emit_byte(0xca); /* fxch swap e^-x with x*log2(e) in tr */ - emit_byte(0xdd); - emit_byte(0xd1); /* fst copy x*log2(e) */ - emit_byte(0xd9); - emit_byte(0xfc); /* frndint int(x*log2(e)) */ - emit_byte(0xd9); - emit_byte(0xc9); /* fxch swap */ - emit_byte(0xd8); - emit_byte(0xe1); /* fsub x*log2(e) - int(x*log2(e)) */ - emit_byte(0xd9); - emit_byte(0xf0); /* f2xm1 (2^frac(x))-1 */ - emit_byte(0xd8); - emit_byte(0x05); - emit_long((uae_u32)&one); /* fadd (2^frac(x))-1 + 1 */ - emit_byte(0xd9); - emit_byte(0xfd); /* fscale (2^frac(x))*2^int(x*log2(e)) */ - emit_byte(0xdd); - emit_byte(0xd9); /* fstp copy e^x & pop */ - if (tr>=0) { - emit_byte(0xdb); - emit_byte(0x2c); - emit_byte(0x24); /* fld load temp-reg from [esp] */ - emit_byte(0x83); - emit_byte(0xc4); - emit_byte(0x0c); /* add +12 to esp */ + emit_byte(0xea); /* fldl2e log2(e) */ + emit_byte(0xd8); + emit_byte(0xc9); /* fmul x*log2(e) */ + emit_byte(0xdd); + emit_byte(0xd1); /* fst copy x*log2(e) */ + if (tr>=0) { + emit_byte(0xd9); + emit_byte(0xca); /* fxch swap with temp-reg */ + emit_byte(0x83); + emit_byte(0xc4); + emit_byte(0xf4); /* add -12 to esp */ + emit_byte(0xdb); + emit_byte(0x3c); + emit_byte(0x24); /* fstp store temp-reg to [esp] & pop */ + } + emit_byte(0xd9); + emit_byte(0xe0); /* fchs -x*log2(e) */ + emit_byte(0xd9); + emit_byte(0xc0); /* fld -x*log2(e) again */ + emit_byte(0xd9); + emit_byte(0xfc); /* frndint int(-x*log2(e)) */ + emit_byte(0xd9); + emit_byte(0xc9); /* fxch swap */ + emit_byte(0xd8); + emit_byte(0xe1); /* fsub -x*log2(e) - int(-x*log2(e)) */ + emit_byte(0xd9); + emit_byte(0xf0); /* f2xm1 (2^frac(x))-1 */ + emit_byte(0xd8); + emit_byte(0x05); + emit_long((uae_u32)&one); /* fadd (2^frac(x))-1 + 1 */ emit_byte(0xd9); - emit_byte(0xca); /* fxch swap temp-reg with e^-x in tr */ - } - emit_byte(0xde); - emit_byte(0xc1); /* faddp (e^x)+(e^-x) */ - emit_byte(0xd9); - emit_byte(0xe8); /* fld 1.0 */ - emit_byte(0xd9); - emit_byte(0xe0); /* fchs -1.0 */ - emit_byte(0xd9); - emit_byte(0xc9); /* fxch swap */ - emit_byte(0xd9); - emit_byte(0xfd); /* fscale ((e^x)+(e^-x))/2 */ - emit_byte(0xdd); - emit_byte(0xd9); /* fstp copy & pop */ - if (s!=d) - tos_make(d); /* store y=cosh(x) */ + emit_byte(0xfd); /* fscale (2^frac(x))*2^int(x*log2(e)) */ + emit_byte(0xd9); + emit_byte(0xca); /* fxch swap e^-x with x*log2(e) in tr */ + emit_byte(0xdd); + emit_byte(0xd1); /* fst copy x*log2(e) */ + emit_byte(0xd9); + emit_byte(0xfc); /* frndint int(x*log2(e)) */ + emit_byte(0xd9); + emit_byte(0xc9); /* fxch swap */ + emit_byte(0xd8); + emit_byte(0xe1); /* fsub x*log2(e) - int(x*log2(e)) */ + emit_byte(0xd9); + emit_byte(0xf0); /* f2xm1 (2^frac(x))-1 */ + emit_byte(0xd8); + emit_byte(0x05); + emit_long((uae_u32)&one); /* fadd (2^frac(x))-1 + 1 */ + emit_byte(0xd9); + emit_byte(0xfd); /* fscale (2^frac(x))*2^int(x*log2(e)) */ + emit_byte(0xdd); + emit_byte(0xd9); /* fstp copy e^x & pop */ + if (tr>=0) { + emit_byte(0xdb); + emit_byte(0x2c); + emit_byte(0x24); /* fld load temp-reg from [esp] */ + emit_byte(0x83); + emit_byte(0xc4); + emit_byte(0x0c); /* add +12 to esp */ + emit_byte(0xd9); + emit_byte(0xca); /* fxch swap temp-reg with e^-x in tr */ + emit_byte(0xde); + emit_byte(0xe9); /* fsubp (e^x)-(e^-x) */ + } + else { + emit_byte(0xde); + emit_byte(0xe1); /* fsubrp (e^x)-(e^-x) */ + } + emit_byte(0xd9); + emit_byte(0xe8); /* fld 1.0 */ + emit_byte(0xd9); + emit_byte(0xe0); /* fchs -1.0 */ + emit_byte(0xd9); + emit_byte(0xc9); /* fxch swap */ + emit_byte(0xd9); + emit_byte(0xfd); /* fscale ((e^x)-(e^-x))/2 */ + emit_byte(0xdd); + emit_byte(0xd9); /* fstp copy & pop */ + if (s!=d) + tos_make(d); /* store y=sinh(x) */ } -LENDFUNC(NONE,NONE,2,raw_fcosh_rr,(FW d, FR s)) +LENDFUNC(NONE,NONE,2,raw_fsinh_rr,(FW d, FR s)) -LOWFUNC(NONE,NONE,2,raw_ftanh_rr,(FW d, FR s)) + LOWFUNC(NONE,NONE,2,raw_fcosh_rr,(FW d, FR s)) { - int ds,tr; + int ds,tr; - tr=live.onstack[live.tos+3]; - if (s==d) - make_tos(s); - else { - ds=stackpos(s); + tr=live.onstack[live.tos+3]; + if (s==d) + make_tos(s); + else { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + } emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld x */ - } - emit_byte(0xd9); - emit_byte(0xea); /* fldl2e log2(e) */ - emit_byte(0xd8); - emit_byte(0xc9); /* fmul x*log2(e) */ - emit_byte(0xdd); - emit_byte(0xd1); /* fst copy x*log2(e) */ - if (tr>=0) { - emit_byte(0xd9); - emit_byte(0xca); /* fxch swap with temp-reg */ - emit_byte(0x83); - emit_byte(0xc4); - emit_byte(0xf4); /* add -12 to esp */ - emit_byte(0xdb); - emit_byte(0x3c); - emit_byte(0x24); /* fstp store temp-reg to [esp] & pop */ - } - emit_byte(0xd9); - emit_byte(0xe0); /* fchs -x*log2(e) */ - emit_byte(0xd9); - emit_byte(0xc0); /* fld -x*log2(e) again */ - emit_byte(0xd9); - emit_byte(0xfc); /* frndint int(-x*log2(e)) */ - emit_byte(0xd9); - emit_byte(0xc9); /* fxch swap */ - emit_byte(0xd8); - emit_byte(0xe1); /* fsub -x*log2(e) - int(-x*log2(e)) */ - emit_byte(0xd9); - emit_byte(0xf0); /* f2xm1 (2^frac(x))-1 */ - emit_byte(0xd8); - emit_byte(0x05); - emit_long((uae_u32)&one); /* fadd (2^frac(x))-1 + 1 */ - emit_byte(0xd9); - emit_byte(0xfd); /* fscale (2^frac(x))*2^int(x*log2(e)) */ - emit_byte(0xd9); - emit_byte(0xca); /* fxch swap e^-x with x*log2(e) */ - emit_byte(0xdd); - emit_byte(0xd1); /* fst copy x*log2(e) */ - emit_byte(0xd9); - emit_byte(0xfc); /* frndint int(x*log2(e)) */ - emit_byte(0xd9); - emit_byte(0xc9); /* fxch swap */ - emit_byte(0xd8); - emit_byte(0xe1); /* fsub x*log2(e) - int(x*log2(e)) */ - emit_byte(0xd9); - emit_byte(0xf0); /* f2xm1 (2^frac(x))-1 */ - emit_byte(0xd8); - emit_byte(0x05); - emit_long((uae_u32)&one); /* fadd (2^frac(x))-1 + 1 */ - emit_byte(0xd9); - emit_byte(0xfd); /* fscale (2^frac(x))*2^int(x*log2(e)) */ - emit_byte(0xdd); - emit_byte(0xd1); /* fst copy e^x */ - emit_byte(0xd8); - emit_byte(0xc2); /* fadd (e^x)+(e^-x) */ - emit_byte(0xd9); - emit_byte(0xca); /* fxch swap with e^-x */ - emit_byte(0xde); - emit_byte(0xe9); /* fsubp (e^x)-(e^-x) */ - if (tr>=0) { - emit_byte(0xdb); - emit_byte(0x2c); - emit_byte(0x24); /* fld load temp-reg from [esp] */ - emit_byte(0x83); - emit_byte(0xc4); - emit_byte(0x0c); /* add +12 to esp */ + emit_byte(0xea); /* fldl2e log2(e) */ + emit_byte(0xd8); + emit_byte(0xc9); /* fmul x*log2(e) */ + emit_byte(0xdd); + emit_byte(0xd1); /* fst copy x*log2(e) */ + if (tr>=0) { + emit_byte(0xd9); + emit_byte(0xca); /* fxch swap with temp-reg */ + emit_byte(0x83); + emit_byte(0xc4); + emit_byte(0xf4); /* add -12 to esp */ + emit_byte(0xdb); + emit_byte(0x3c); + emit_byte(0x24); /* fstp store temp-reg to [esp] & pop */ + } emit_byte(0xd9); - emit_byte(0xca); /* fxch swap temp-reg with e^-x in tr */ - emit_byte(0xde); - emit_byte(0xf9); /* fdivp ((e^x)-(e^-x))/((e^x)+(e^-x)) */ - } - else { + emit_byte(0xe0); /* fchs -x*log2(e) */ + emit_byte(0xd9); + emit_byte(0xc0); /* fld -x*log2(e) again */ + emit_byte(0xd9); + emit_byte(0xfc); /* frndint int(-x*log2(e)) */ + emit_byte(0xd9); + emit_byte(0xc9); /* fxch swap */ + emit_byte(0xd8); + emit_byte(0xe1); /* fsub -x*log2(e) - int(-x*log2(e)) */ + emit_byte(0xd9); + emit_byte(0xf0); /* f2xm1 (2^frac(x))-1 */ + emit_byte(0xd8); + emit_byte(0x05); + emit_long((uae_u32)&one); /* fadd (2^frac(x))-1 + 1 */ + emit_byte(0xd9); + emit_byte(0xfd); /* fscale (2^frac(x))*2^int(x*log2(e)) */ + emit_byte(0xd9); + emit_byte(0xca); /* fxch swap e^-x with x*log2(e) in tr */ + emit_byte(0xdd); + emit_byte(0xd1); /* fst copy x*log2(e) */ + emit_byte(0xd9); + emit_byte(0xfc); /* frndint int(x*log2(e)) */ + emit_byte(0xd9); + emit_byte(0xc9); /* fxch swap */ + emit_byte(0xd8); + emit_byte(0xe1); /* fsub x*log2(e) - int(x*log2(e)) */ + emit_byte(0xd9); + emit_byte(0xf0); /* f2xm1 (2^frac(x))-1 */ + emit_byte(0xd8); + emit_byte(0x05); + emit_long((uae_u32)&one); /* fadd (2^frac(x))-1 + 1 */ + emit_byte(0xd9); + emit_byte(0xfd); /* fscale (2^frac(x))*2^int(x*log2(e)) */ + emit_byte(0xdd); + emit_byte(0xd9); /* fstp copy e^x & pop */ + if (tr>=0) { + emit_byte(0xdb); + emit_byte(0x2c); + emit_byte(0x24); /* fld load temp-reg from [esp] */ + emit_byte(0x83); + emit_byte(0xc4); + emit_byte(0x0c); /* add +12 to esp */ + emit_byte(0xd9); + emit_byte(0xca); /* fxch swap temp-reg with e^-x in tr */ + } emit_byte(0xde); - emit_byte(0xf1); /* fdivrp ((e^x)-(e^-x))/((e^x)+(e^-x)) */ - } - if (s!=d) - tos_make(d); /* store y=tanh(x) */ + emit_byte(0xc1); /* faddp (e^x)+(e^-x) */ + emit_byte(0xd9); + emit_byte(0xe8); /* fld 1.0 */ + emit_byte(0xd9); + emit_byte(0xe0); /* fchs -1.0 */ + emit_byte(0xd9); + emit_byte(0xc9); /* fxch swap */ + emit_byte(0xd9); + emit_byte(0xfd); /* fscale ((e^x)+(e^-x))/2 */ + emit_byte(0xdd); + emit_byte(0xd9); /* fstp copy & pop */ + if (s!=d) + tos_make(d); /* store y=cosh(x) */ } -LENDFUNC(NONE,NONE,2,raw_ftanh_rr,(FW d, FR s)) +LENDFUNC(NONE,NONE,2,raw_fcosh_rr,(FW d, FR s)) -LOWFUNC(NONE,NONE,2,raw_fneg_rr,(FW d, FR s)) + LOWFUNC(NONE,NONE,2,raw_ftanh_rr,(FW d, FR s)) { - int ds; + int ds,tr; - if (d!=s) { - ds=stackpos(s); + tr=live.onstack[live.tos+3]; + if (s==d) + make_tos(s); + else { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld x */ + } + emit_byte(0xd9); + emit_byte(0xea); /* fldl2e log2(e) */ + emit_byte(0xd8); + emit_byte(0xc9); /* fmul x*log2(e) */ + emit_byte(0xdd); + emit_byte(0xd1); /* fst copy x*log2(e) */ + if (tr>=0) { + emit_byte(0xd9); + emit_byte(0xca); /* fxch swap with temp-reg */ + emit_byte(0x83); + emit_byte(0xc4); + emit_byte(0xf4); /* add -12 to esp */ + emit_byte(0xdb); + emit_byte(0x3c); + emit_byte(0x24); /* fstp store temp-reg to [esp] & pop */ + } emit_byte(0xd9); - emit_byte(0xc0+ds); /* duplicate source */ + emit_byte(0xe0); /* fchs -x*log2(e) */ emit_byte(0xd9); - emit_byte(0xe0); /* take fchs */ - tos_make(d); /* store to destination */ - } - else { - make_tos(d); + emit_byte(0xc0); /* fld -x*log2(e) again */ + emit_byte(0xd9); + emit_byte(0xfc); /* frndint int(-x*log2(e)) */ + emit_byte(0xd9); + emit_byte(0xc9); /* fxch swap */ + emit_byte(0xd8); + emit_byte(0xe1); /* fsub -x*log2(e) - int(-x*log2(e)) */ + emit_byte(0xd9); + emit_byte(0xf0); /* f2xm1 (2^frac(x))-1 */ + emit_byte(0xd8); + emit_byte(0x05); + emit_long((uae_u32)&one); /* fadd (2^frac(x))-1 + 1 */ + emit_byte(0xd9); + emit_byte(0xfd); /* fscale (2^frac(x))*2^int(x*log2(e)) */ emit_byte(0xd9); - emit_byte(0xe0); /* take fchs */ - } + emit_byte(0xca); /* fxch swap e^-x with x*log2(e) */ + emit_byte(0xdd); + emit_byte(0xd1); /* fst copy x*log2(e) */ + emit_byte(0xd9); + emit_byte(0xfc); /* frndint int(x*log2(e)) */ + emit_byte(0xd9); + emit_byte(0xc9); /* fxch swap */ + emit_byte(0xd8); + emit_byte(0xe1); /* fsub x*log2(e) - int(x*log2(e)) */ + emit_byte(0xd9); + emit_byte(0xf0); /* f2xm1 (2^frac(x))-1 */ + emit_byte(0xd8); + emit_byte(0x05); + emit_long((uae_u32)&one); /* fadd (2^frac(x))-1 + 1 */ + emit_byte(0xd9); + emit_byte(0xfd); /* fscale (2^frac(x))*2^int(x*log2(e)) */ + emit_byte(0xdd); + emit_byte(0xd1); /* fst copy e^x */ + emit_byte(0xd8); + emit_byte(0xc2); /* fadd (e^x)+(e^-x) */ + emit_byte(0xd9); + emit_byte(0xca); /* fxch swap with e^-x */ + emit_byte(0xde); + emit_byte(0xe9); /* fsubp (e^x)-(e^-x) */ + if (tr>=0) { + emit_byte(0xdb); + emit_byte(0x2c); + emit_byte(0x24); /* fld load temp-reg from [esp] */ + emit_byte(0x83); + emit_byte(0xc4); + emit_byte(0x0c); /* add +12 to esp */ + emit_byte(0xd9); + emit_byte(0xca); /* fxch swap temp-reg with e^-x in tr */ + emit_byte(0xde); + emit_byte(0xf9); /* fdivp ((e^x)-(e^-x))/((e^x)+(e^-x)) */ + } + else { + emit_byte(0xde); + emit_byte(0xf1); /* fdivrp ((e^x)-(e^-x))/((e^x)+(e^-x)) */ + } + if (s!=d) + tos_make(d); /* store y=tanh(x) */ +} +LENDFUNC(NONE,NONE,2,raw_ftanh_rr,(FW d, FR s)) + + LOWFUNC(NONE,NONE,2,raw_fneg_rr,(FW d, FR s)) +{ + int ds; + + if (d!=s) { + ds=stackpos(s); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* duplicate source */ + emit_byte(0xd9); + emit_byte(0xe0); /* take fchs */ + tos_make(d); /* store to destination */ + } + else { + make_tos(d); + emit_byte(0xd9); + emit_byte(0xe0); /* take fchs */ + } } LENDFUNC(NONE,NONE,2,raw_fneg_rr,(FW d, FR s)) -LOWFUNC(NONE,NONE,2,raw_fadd_rr,(FRW d, FR s)) + LOWFUNC(NONE,NONE,2,raw_fadd_rr,(FRW d, FR s)) { - int ds; + int ds; - if (live.spos[s]==live.tos) { - /* Source is on top of stack */ - ds=stackpos(d); - emit_byte(0xdc); - emit_byte(0xc0+ds); /* add source to dest*/ - } - else { - make_tos(d); - ds=stackpos(s); + if (live.spos[s]==live.tos) { + /* Source is on top of stack */ + ds=stackpos(d); + emit_byte(0xdc); + emit_byte(0xc0+ds); /* add source to dest*/ + } + else { + make_tos(d); + ds=stackpos(s); - emit_byte(0xd8); - emit_byte(0xc0+ds); /* add source to dest*/ - } + emit_byte(0xd8); + emit_byte(0xc0+ds); /* add source to dest*/ + } } LENDFUNC(NONE,NONE,2,raw_fadd_rr,(FRW d, FR s)) -LOWFUNC(NONE,NONE,2,raw_fsub_rr,(FRW d, FR s)) + LOWFUNC(NONE,NONE,2,raw_fsub_rr,(FRW d, FR s)) { - int ds; + int ds; - if (live.spos[s]==live.tos) { - /* Source is on top of stack */ - ds=stackpos(d); - emit_byte(0xdc); - emit_byte(0xe8+ds); /* sub source from dest*/ - } - else { - make_tos(d); - ds=stackpos(s); + if (live.spos[s]==live.tos) { + /* Source is on top of stack */ + ds=stackpos(d); + emit_byte(0xdc); + emit_byte(0xe8+ds); /* sub source from dest*/ + } + else { + make_tos(d); + ds=stackpos(s); - emit_byte(0xd8); - emit_byte(0xe0+ds); /* sub src from dest */ - } + emit_byte(0xd8); + emit_byte(0xe0+ds); /* sub src from dest */ + } } LENDFUNC(NONE,NONE,2,raw_fsub_rr,(FRW d, FR s)) -LOWFUNC(NONE,NONE,2,raw_fcmp_rr,(FR d, FR s)) + LOWFUNC(NONE,NONE,2,raw_fcmp_rr,(FR d, FR s)) { - int ds; + int ds; - make_tos(d); - ds=stackpos(s); + make_tos(d); + ds=stackpos(s); - emit_byte(0xdd); - emit_byte(0xe0+ds); /* cmp dest with source*/ + emit_byte(0xdd); + emit_byte(0xe0+ds); /* cmp dest with source*/ } LENDFUNC(NONE,NONE,2,raw_fcmp_rr,(FR d, FR s)) -LOWFUNC(NONE,NONE,2,raw_fmul_rr,(FRW d, FR s)) + LOWFUNC(NONE,NONE,2,raw_fmul_rr,(FRW d, FR s)) { - int ds; + int ds; - if (live.spos[s]==live.tos) { - /* Source is on top of stack */ - ds=stackpos(d); - emit_byte(0xdc); - emit_byte(0xc8+ds); /* mul dest by source*/ - } - else { - make_tos(d); - ds=stackpos(s); + if (live.spos[s]==live.tos) { + /* Source is on top of stack */ + ds=stackpos(d); + emit_byte(0xdc); + emit_byte(0xc8+ds); /* mul dest by source*/ + } + else { + make_tos(d); + ds=stackpos(s); - emit_byte(0xd8); - emit_byte(0xc8+ds); /* mul dest by source*/ - } + emit_byte(0xd8); + emit_byte(0xc8+ds); /* mul dest by source*/ + } } LENDFUNC(NONE,NONE,2,raw_fmul_rr,(FRW d, FR s)) -LOWFUNC(NONE,NONE,2,raw_fdiv_rr,(FRW d, FR s)) + LOWFUNC(NONE,NONE,2,raw_fdiv_rr,(FRW d, FR s)) { - int ds; + int ds; - if (live.spos[s]==live.tos) { - /* Source is on top of stack */ - ds=stackpos(d); - emit_byte(0xdc); - emit_byte(0xf8+ds); /* div dest by source */ - } - else { - make_tos(d); - ds=stackpos(s); + if (live.spos[s]==live.tos) { + /* Source is on top of stack */ + ds=stackpos(d); + emit_byte(0xdc); + emit_byte(0xf8+ds); /* div dest by source */ + } + else { + make_tos(d); + ds=stackpos(s); - emit_byte(0xd8); - emit_byte(0xf0+ds); /* div dest by source*/ - } + emit_byte(0xd8); + emit_byte(0xf0+ds); /* div dest by source*/ + } } LENDFUNC(NONE,NONE,2,raw_fdiv_rr,(FRW d, FR s)) -LOWFUNC(NONE,NONE,2,raw_frem_rr,(FRW d, FR s)) + LOWFUNC(NONE,NONE,2,raw_frem_rr,(FRW d, FR s)) { - int ds; + int ds; - if (live.spos[d]==live.tos && live.spos[s]==live.tos-1) { - //write_log (L"frem found x in TOS-1 and y in TOS\n"); - emit_byte(0xd9); - emit_byte(0xf8); /* fprem rem(y/x) */ - } - else { - make_tos(s); /* tos=x */ - ds=stackpos(d); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld y */ - emit_byte(0xd9); - emit_byte(0xf8); /* fprem rem(y/x) */ - tos_make(d); /* store y=rem(y/x) */ - } + if (live.spos[d]==live.tos && live.spos[s]==live.tos-1) { + //write_log (L"frem found x in TOS-1 and y in TOS\n"); + emit_byte(0xd9); + emit_byte(0xf8); /* fprem rem(y/x) */ + } + else { + make_tos(s); /* tos=x */ + ds=stackpos(d); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld y */ + emit_byte(0xd9); + emit_byte(0xf8); /* fprem rem(y/x) */ + tos_make(d); /* store y=rem(y/x) */ + } } LENDFUNC(NONE,NONE,2,raw_frem_rr,(FRW d, FR s)) -LOWFUNC(NONE,NONE,2,raw_frem1_rr,(FRW d, FR s)) + LOWFUNC(NONE,NONE,2,raw_frem1_rr,(FRW d, FR s)) { - int ds; + int ds; - if (live.spos[d]==live.tos && live.spos[s]==live.tos-1) { - //write_log (L"frem1 found x in TOS-1 and y in TOS\n"); - emit_byte(0xd9); - emit_byte(0xf5); /* fprem1 rem1(y/x) */ - } - else { - make_tos(s); /* tos=x */ - ds=stackpos(d); - emit_byte(0xd9); - emit_byte(0xc0+ds); /* fld y */ - emit_byte(0xd9); - emit_byte(0xf5); /* fprem1 rem1(y/x) */ - tos_make(d); /* store y=rem(y/x) */ - } + if (live.spos[d]==live.tos && live.spos[s]==live.tos-1) { + //write_log (L"frem1 found x in TOS-1 and y in TOS\n"); + emit_byte(0xd9); + emit_byte(0xf5); /* fprem1 rem1(y/x) */ + } + else { + make_tos(s); /* tos=x */ + ds=stackpos(d); + emit_byte(0xd9); + emit_byte(0xc0+ds); /* fld y */ + emit_byte(0xd9); + emit_byte(0xf5); /* fprem1 rem1(y/x) */ + tos_make(d); /* store y=rem(y/x) */ + } } LENDFUNC(NONE,NONE,2,raw_frem1_rr,(FRW d, FR s)) -LOWFUNC(NONE,NONE,1,raw_ftst_r,(FR r)) + LOWFUNC(NONE,NONE,1,raw_ftst_r,(FR r)) { - make_tos(r); - emit_byte(0xd9); /* ftst */ - emit_byte(0xe4); + make_tos(r); + emit_byte(0xd9); /* ftst */ + emit_byte(0xe4); } LENDFUNC(NONE,NONE,1,raw_ftst_r,(FR r)) -STATIC_INLINE void raw_fflags_into_flags(int r) + STATIC_INLINE void raw_fflags_into_flags(int r) { - int p; + int p; - usereg(r); - p=stackpos(r); + usereg(r); + p=stackpos(r); - emit_byte(0xd9); - emit_byte(0xee); /* Push 0 */ - emit_byte(0xd9); - emit_byte(0xc9+p); /* swap top two around */ - if (have_cmov) { - // gb-- fucomi is for P6 cores only, not K6-2 then... - emit_byte(0xdb); - emit_byte(0xe9+p); /* fucomi them */ - } - else { + emit_byte(0xd9); + emit_byte(0xee); /* Push 0 */ + emit_byte(0xd9); + emit_byte(0xc9+p); /* swap top two around */ + if (have_cmov) { + // gb-- fucomi is for P6 cores only, not K6-2 then... + emit_byte(0xdb); + emit_byte(0xe9+p); /* fucomi them */ + } + else { + emit_byte(0xdd); + emit_byte(0xe1+p); /* fucom them */ + emit_byte(0x9b); + emit_byte(0xdf); + emit_byte(0xe0); /* fstsw ax */ + raw_sahf(0); /* sahf */ + } emit_byte(0xdd); - emit_byte(0xe1+p); /* fucom them */ - emit_byte(0x9b); - emit_byte(0xdf); - emit_byte(0xe0); /* fstsw ax */ - raw_sahf(0); /* sahf */ - } - emit_byte(0xdd); - emit_byte(0xd9+p); /* store value back, and get rid of 0 */ + emit_byte(0xd9+p); /* store value back, and get rid of 0 */ } diff --git a/jit/compemu_support.cpp b/jit/compemu_support.cpp index 5dd4daff..4f6bbfd0 100644 --- a/jit/compemu_support.cpp +++ b/jit/compemu_support.cpp @@ -20,7 +20,7 @@ #define NATMEM_OFFSETX (uae_u32)NATMEM_OFFSET // %%% BRIAN KING WAS HERE %%% -extern int canbang; +extern bool canbang; #include extern void jit_abort(const TCHAR*,...); compop_func *compfunctbl[65536]; @@ -421,12 +421,13 @@ STATIC_INLINE void alloc_blockinfos(void) /******************************************************************** * Preferences handling. This is just a convenient place to put it * ********************************************************************/ -extern int have_done_picasso; +extern bool have_done_picasso; -int check_prefs_changed_comp (void) +bool check_prefs_changed_comp (void) { - int changed = 0; - static int cachesize_prev, comptrust_prev, canbang_prev; + bool changed = 0; + static int cachesize_prev, comptrust_prev; + static bool canbang_prev; if (currprefs.comptrustbyte != changed_prefs.comptrustbyte || currprefs.comptrustword != changed_prefs.comptrustword || diff --git a/keybuf.cpp b/keybuf.cpp index 5906bb0b..1ea097f4 100644 --- a/keybuf.cpp +++ b/keybuf.cpp @@ -23,13 +23,6 @@ #include "custom.h" #include "savestate.h" -static int fakestate[MAX_JPORTS][7] = { {0},{0} }; - -static int *fs_np, *fs_ck, *fs_se; -#ifdef ARCADIA -static int *fs_xa1, *fs_xa2; -#endif - static int kpb_first, kpb_last; static int keybuf[256]; @@ -52,12 +45,6 @@ int get_next_key (void) return key; } -static void do_fake (int nr) -{ - int *fake = fakestate[nr]; - do_fake_joystick (nr, fake); -} - int record_key (int kc) { if (input_recording < 0 || pause_emulation) @@ -80,104 +67,9 @@ int record_key_direct (int kc) return 0; } - if (fs_np != 0) { - switch (k) { - case AK_NP8: fs = 1; fs_np[0] = b; break; - case AK_NP4: fs = 1; fs_np[1] = b; break; - case AK_NP6: fs = 1; fs_np[2] = b; break; - case AK_NP2: fs = 1; fs_np[3] = b; break; - case AK_NP0: case AK_NP5: fs = 1; fs_np[4] = b; break; - case AK_NPDEL: case AK_NPDIV: case AK_ENT: fs = 1; fs_np[5] = b; break; - } - } - if (fs_ck != 0) { - switch (k) { - case AK_UP: fs = 1; fs_ck[0] = b; break; - case AK_LF: fs = 1; fs_ck[1] = b; break; - case AK_RT: fs = 1; fs_ck[2] = b; break; - case AK_DN: fs = 1; fs_ck[3] = b; break; - case AK_RCTRL: case AK_RALT: fs = 1; fs_ck[4] = b; break; - case AK_RSH: fs = 1; fs_ck[5] = b; break; - } - } - if (fs_se != 0) { - switch (k) { - case AK_W: fs = 1; fs_se[0] = b; break; - case AK_A: fs = 1; fs_se[1] = b; break; - case AK_D: fs = 1; fs_se[2] = b; break; - case AK_S: fs = 1; fs_se[3] = b; break; - case AK_LALT: fs = 1; fs_se[4] = b; break; - case AK_LSH: fs = 1; fs_se[5] = b; break; - } - } -#ifdef ARCADIA - if (fs_xa1 != 0) { - switch (k) { - case AK_NP8: fs = 1; fs_xa1[0] = b; break; - case AK_NP4: fs = 1; fs_xa1[1] = b; break; - case AK_NP6: fs = 1; fs_xa1[2] = b; break; - case AK_NP2: case AK_NP5: fs = 1; fs_xa1[3] = b; break; - case AK_CTRL: fs = 1; fs_xa1[4] = b; break; - case AK_LALT: fs = 1; fs_xa1[5] = b; break; - case AK_SPC: fs = 1; fs_xa1[6] = b; break; - } - } - if (fs_xa2 != 0) { - switch (k) { - case AK_R: fs = 1; fs_xa2[0] = b; break; - case AK_D: fs = 1; fs_xa2[1] = b; break; - case AK_G: fs = 1; fs_xa2[2] = b; break; - case AK_F: fs = 1; fs_xa2[3] = b; break; - case AK_A: fs = 1; fs_xa2[4] = b; break; - case AK_S: fs = 1; fs_xa2[5] = b; break; - case AK_Q: fs = 1; fs_xa2[6] = b; break; - } - } -#endif - if (fs && currprefs.input_selected_setting == 0) { - if (JSEM_ISANYKBD (0, &currprefs)) - do_fake (0); - if (JSEM_ISANYKBD (1, &currprefs)) - do_fake (1); - if (JSEM_ISANYKBD (2, &currprefs)) - do_fake (2); - if (JSEM_ISANYKBD (3, &currprefs)) - do_fake (3); - return 0; - } else { - if ((kc >> 1) == AK_RCTRL) { - kc ^= AK_RCTRL << 1; - kc ^= AK_CTRL << 1; - } -#ifdef ARCADIA - if (fs_xa1 || fs_xa2) { - int k2 = k; - if (k == AK_1) - k2 = AK_F1; - if (k == AK_2) - k2 = AK_F2; - if (k == AK_3) - k2 = AK_LALT; - if (k == AK_4) - k2 = AK_RALT; - if (k == AK_6) - k2 = AK_DN; - if (k == AK_LBRACKET || k == AK_LSH) - k2 = AK_SPC; - if (k == AK_RBRACKET) - k2 = AK_RET; - if (k == AK_C) - k2 = AK_1; - if (k == AK_5) - k2 = AK_2; - if (k == AK_Z) - k2 = AK_3; - if (k == AK_X) - k2 = AK_4; - if (k != k2) - kc = (k2 << 1) | (b ? 0 : 1); - } -#endif + if ((kc >> 1) == AK_RCTRL) { + kc ^= AK_RCTRL << 1; + kc ^= AK_CTRL << 1; } if (input_recording > 0) { @@ -191,31 +83,6 @@ int record_key_direct (int kc) return 1; } -void joystick_setting_changed (void) -{ - int i; - - fs_np = fs_ck = fs_se = 0; -#ifdef ARCADIA - fs_xa1 = fs_xa2 = 0; -#endif - - for (i = 0; i < MAX_JPORTS; i++) { - if (JSEM_ISNUMPAD (i, &currprefs)) - fs_np = fakestate[i]; - if (JSEM_ISCURSOR (i, &currprefs)) - fs_ck = fakestate[i]; - if (JSEM_ISSOMEWHEREELSE (i, &currprefs)) - fs_se = fakestate[i]; -#ifdef ARCADIA - if (JSEM_ISXARCADE1 (i, &currprefs)) - fs_xa1 = fakestate[i]; - if (JSEM_ISXARCADE2 (i, &currprefs)) - fs_xa2 = fakestate[i]; -#endif - } -} - void keybuf_init (void) { kpb_first = kpb_last = 0; diff --git a/main.cpp b/main.cpp index 5a733a65..e4f5f44d 100644 --- a/main.cpp +++ b/main.cpp @@ -63,10 +63,10 @@ long int version = 256 * 65536L * UAEMAJOR + 65536L * UAEMINOR + UAESUBREV; struct uae_prefs currprefs, changed_prefs; int config_changed; -int no_gui = 0, quit_to_gui = 0; -int cloanto_rom = 0; -int kickstart_rom = 1; -int console_emulation = 0; +bool no_gui = 0, quit_to_gui = 0; +bool cloanto_rom = 0; +bool kickstart_rom = 1; +bool console_emulation = 0; struct gui_info gui_data; @@ -271,26 +271,6 @@ void fixup_prefs (struct uae_prefs *p) p->comptrustnaddr = 1; err = 1; } - if (p->compnf < 0 || p->compnf > 1) { - write_log (L"Bad value for compnf parameter: value must be within 0..1\n"); - p->compnf = 1; - err = 1; - } - if (p->comp_hardflush < 0 || p->comp_hardflush > 1) { - write_log (L"Bad value for comp_hardflush parameter: value must be within 0..1\n"); - p->comp_hardflush = 1; - err = 1; - } - if (p->comp_constjump < 0 || p->comp_constjump > 1) { - write_log (L"Bad value for comp_constjump parameter: value must be within 0..1\n"); - p->comp_constjump = 1; - err = 1; - } - if (p->comp_oldsegv < 0 || p->comp_oldsegv > 1) { - write_log (L"Bad value for comp_oldsegv parameter: value must be within 0..1\n"); - p->comp_oldsegv = 1; - err = 1; - } if (p->cachesize < 0 || p->cachesize > 16384) { write_log (L"Bad value for cachesize parameter: value must be within 0..16384\n"); p->cachesize = 0; @@ -652,6 +632,13 @@ void reset_all_systems (void) * Add #ifdefs around these as appropriate. */ +#ifndef JIT +extern int DummyException (LPEXCEPTION_POINTERS blah, int n_except) +{ + return EXCEPTION_CONTINUE_SEARCH; +} +#endif + void do_start_program (void) { if (quit_program == -1) @@ -664,7 +651,23 @@ void do_start_program (void) inputdevice_updateconfig (&currprefs); if (quit_program >= 0) quit_program = 2; - m68k_go (1); +#if (defined (_WIN32) || defined (_WIN64)) && !defined (NO_WIN32_EXCEPTION_HANDLER) + extern int EvalException (LPEXCEPTION_POINTERS blah, int n_except); + __try +#endif + { + m68k_go (1); + } +#if (defined (_WIN32) || defined (_WIN64)) && !defined (NO_WIN32_EXCEPTION_HANDLER) +#ifdef JIT + __except (EvalException (GetExceptionInformation (), GetExceptionCode ())) +#else + __except (DummyException (GetExceptionInformation (), GetExceptionCode ())) +#endif + { + // EvalException does the good stuff... + } +#endif } void do_leave_program (void) @@ -721,172 +724,147 @@ void leave_program (void) do_leave_program (); } -#ifndef JIT -extern int DummyException (LPEXCEPTION_POINTERS blah, int n_except) -{ - return EXCEPTION_CONTINUE_SEARCH; -} -#endif - static int real_main2 (int argc, TCHAR **argv) { -#if (defined (_WIN32) || defined (_WIN64)) && !defined (NO_WIN32_EXCEPTION_HANDLER) - extern int EvalException (LPEXCEPTION_POINTERS blah, int n_except); - __try -#endif - { #ifdef USE_SDL - SDL_Init (SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE); + SDL_Init (SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE); #endif - config_changed = 1; - if (restart_config[0]) { - default_prefs (&currprefs, 0); - fixup_prefs (&currprefs); - } + config_changed = 1; + if (restart_config[0]) { + default_prefs (&currprefs, 0); + fixup_prefs (&currprefs); + } - if (! graphics_setup ()) { - exit (1); - } + if (! graphics_setup ()) { + exit (1); + } #ifdef NATMEM_OFFSET - preinit_shm (); + preinit_shm (); #endif - if (restart_config[0]) - parse_cmdline_and_init_file (argc, argv); - else - currprefs = changed_prefs; + if (restart_config[0]) + parse_cmdline_and_init_file (argc, argv); + else + currprefs = changed_prefs; - if (!machdep_init ()) { - restart_program = 0; - return -1; - } - - if (console_emulation) { - consolehook_config (&currprefs); - fixup_prefs (&currprefs); - } + if (!machdep_init ()) { + restart_program = 0; + return -1; + } - if (! setup_sound ()) { - write_log (L"Sound driver unavailable: Sound output disabled\n"); - currprefs.produce_sound = 0; - } - inputdevice_init (); + if (console_emulation) { + consolehook_config (&currprefs); + fixup_prefs (&currprefs); + } - changed_prefs = currprefs; - no_gui = ! currprefs.start_gui; - if (restart_program == 2) - no_gui = 1; - else if (restart_program == 3) - no_gui = 0; - restart_program = 0; - if (! no_gui) { - int err = gui_init (); - currprefs = changed_prefs; - config_changed = 1; - if (err == -1) { - write_log (L"Failed to initialize the GUI\n"); - return -1; - } else if (err == -2) { - return 1; - } + if (! setup_sound ()) { + write_log (L"Sound driver unavailable: Sound output disabled\n"); + currprefs.produce_sound = 0; + } + inputdevice_init (); + + changed_prefs = currprefs; + no_gui = ! currprefs.start_gui; + if (restart_program == 2) + no_gui = 1; + else if (restart_program == 3) + no_gui = 0; + restart_program = 0; + if (! no_gui) { + int err = gui_init (); + currprefs = changed_prefs; + config_changed = 1; + if (err == -1) { + write_log (L"Failed to initialize the GUI\n"); + return -1; + } else if (err == -2) { + return 1; } + } - logging_init (); /* Yes, we call this twice - the first case handles when the user has loaded + logging_init (); /* Yes, we call this twice - the first case handles when the user has loaded a config using the cmd-line. This case handles loads through the GUI. */ #ifdef NATMEM_OFFSET - init_shm (); + init_shm (); #endif #ifdef JIT - if (!(currprefs.cpu_model >= 68020 && currprefs.address_space_24 == 0 && currprefs.cachesize)) - canbang = 0; + if (!(currprefs.cpu_model >= 68020 && currprefs.address_space_24 == 0 && currprefs.cachesize)) + canbang = 0; #endif - fixup_prefs (&currprefs); - changed_prefs = currprefs; - target_run (); - /* force sound settings change */ - currprefs.produce_sound = 0; + fixup_prefs (&currprefs); + changed_prefs = currprefs; + target_run (); + /* force sound settings change */ + currprefs.produce_sound = 0; #ifdef AUTOCONFIG - rtarea_setup (); + rtarea_setup (); #endif #ifdef FILESYS - rtarea_init (); - uaeres_install (); - hardfile_install (); + rtarea_init (); + uaeres_install (); + hardfile_install (); #endif - savestate_init (); + savestate_init (); #ifdef SCSIEMU - scsi_reset (); - scsidev_install (); + scsi_reset (); + scsidev_install (); #endif #ifdef SANA2 - netdev_install (); + netdev_install (); #endif #ifdef UAESERIAL - uaeserialdev_install (); + uaeserialdev_install (); #endif - keybuf_init (); /* Must come after init_joystick */ + keybuf_init (); /* Must come after init_joystick */ #ifdef AUTOCONFIG - expansion_init (); + expansion_init (); #endif #ifdef FILESYS - filesys_install (); + filesys_install (); #endif - memory_init (); - memory_reset (); + memory_init (); + memory_reset (); #ifdef AUTOCONFIG #if defined (BSDSOCKET) - bsdlib_install (); + bsdlib_install (); #endif - emulib_install (); - uaeexe_install (); - native2amiga_install (); + emulib_install (); + uaeexe_install (); + native2amiga_install (); #endif - custom_init (); /* Must come after memory_init */ + custom_init (); /* Must come after memory_init */ #ifdef SERIAL_PORT - serial_init (); + serial_init (); #endif - DISK_init (); + DISK_init (); - reset_frame_rate_hack (); - init_m68k (); /* must come after reset_frame_rate_hack (); */ + reset_frame_rate_hack (); + init_m68k (); /* must come after reset_frame_rate_hack (); */ - gui_update (); + gui_update (); - if (graphics_init ()) { - setup_brkhandler (); - if (currprefs.start_debugger && debuggable ()) - activate_debugger (); + if (graphics_init ()) { + setup_brkhandler (); + if (currprefs.start_debugger && debuggable ()) + activate_debugger (); - if (!init_audio ()) { - if (sound_available && currprefs.produce_sound > 1) { - write_log (L"Sound driver unavailable: Sound output disabled\n"); - } - currprefs.produce_sound = 0; + if (!init_audio ()) { + if (sound_available && currprefs.produce_sound > 1) { + write_log (L"Sound driver unavailable: Sound output disabled\n"); } - - start_program (); + currprefs.produce_sound = 0; } - + start_program (); } -#if (defined (_WIN32) || defined (_WIN64)) && !defined (NO_WIN32_EXCEPTION_HANDLER) -#ifdef JIT - __except (EvalException (GetExceptionInformation (), GetExceptionCode ())) -#else - __except (DummyException (GetExceptionInformation (), GetExceptionCode ())) -#endif - { - // EvalException does the good stuff... - } -#endif return 0; } diff --git a/memory.cpp b/memory.cpp index 9ddf7da6..7c99dad0 100644 --- a/memory.cpp +++ b/memory.cpp @@ -31,19 +31,19 @@ #include "gayle.h" #include "debug.h" -int canbang; +bool canbang; int candirect = -1; #ifdef JIT /* Set by each memory handler that does not simply access real memory. */ int special_mem; #endif -static int isdirectjit (void) +static bool isdirectjit (void) { return currprefs.cachesize && !currprefs.comptrustbyte; } -static int canjit (void) +static bool canjit (void) { if (currprefs.cpu_model < 68020 && currprefs.address_space_24) return 0; @@ -55,7 +55,7 @@ static void nocanbang (void) canbang = 0; } -int ersatzkickfile; +bool ersatzkickfile; uae_u32 allocated_chipmem; uae_u32 allocated_fastmem; @@ -66,6 +66,7 @@ uae_u32 allocated_a3000lmem; uae_u32 allocated_a3000hmem; uae_u32 allocated_cardmem; uae_u8 ce_banktype[65536]; +uae_u8 ce_cachable[65536]; #if defined(CPU_64_BIT) uae_u32 max_z3fastmem = 2048UL * 1024 * 1024; @@ -78,10 +79,10 @@ static size_t bootrom_filepos, chip_filepos, bogo_filepos, rom_filepos, a3000lme /* Set if we notice during initialization that settings changed, and we must clear all memory to prevent bogus contents from confusing the Kickstart. */ -static int need_hardreset; +static bool need_hardreset; /* The address space setting used during the last reset. */ -static int last_address_space_24; +static bool last_address_space_24; addrbank *mem_banks[MEMORY_BANKS]; @@ -2172,6 +2173,11 @@ static void fill_ce_banks (void) int i; memset (ce_banktype, CE_MEMBANK_FAST, sizeof ce_banktype); + // data cachable regions + memset (ce_cachable, 0, sizeof ce_cachable); + memset (ce_cachable + (0x00200000 >> 16), 1, currprefs.fastmem_size >> 16); + memset (ce_cachable + (0x10000000 >> 16), 1, currprefs.z3fastmem_size >> 16); + if (&get_mem_bank (0) == &chipmem_bank) { for (i = 0; i < (0x200000 >> 16); i++) ce_banktype[i] = CE_MEMBANK_CHIP; @@ -2186,8 +2192,10 @@ static void fill_ce_banks (void) addrbank *b; ce_banktype[i] = CE_MEMBANK_CIA; b = &get_mem_bank (i << 16); - if (b != &cia_bank) + if (b != &cia_bank) { ce_banktype[i] = CE_MEMBANK_FAST; + ce_cachable[i] = 1; + } } // CD32 ROM is 16-bit if (currprefs.cs_cd32cd) { diff --git a/native2amiga.cpp b/native2amiga.cpp index 216d78da..37e9cc40 100644 --- a/native2amiga.cpp +++ b/native2amiga.cpp @@ -108,21 +108,21 @@ void uae_NotificationHack (uaecptr port, uaecptr nr) void uae_NewList (uaecptr list) { - put_long_slow (list, list + 4); - put_long_slow (list + 4, 0); - put_long_slow (list + 8, list); + x_put_long (list, list + 4); + x_put_long (list + 4, 0); + x_put_long (list + 8, list); } uaecptr uae_AllocMem (TrapContext *context, uae_u32 size, uae_u32 flags) { m68k_dreg (regs, 0) = size; m68k_dreg (regs, 1) = flags; - return CallLib (context, get_long (4), -198); /* AllocMem */ + return CallLib (context, x_get_long (4), -198); /* AllocMem */ } void uae_FreeMem (TrapContext *context, uaecptr memory, uae_u32 size) { m68k_dreg (regs, 0) = size; m68k_areg (regs, 1) = memory; - CallLib (context, get_long (4), -0xD2); /* FreeMem */ + CallLib (context, x_get_long (4), -0xD2); /* FreeMem */ } diff --git a/newcpu.cpp b/newcpu.cpp index ea00fbad..aa160b38 100644 --- a/newcpu.cpp +++ b/newcpu.cpp @@ -38,7 +38,7 @@ extern uae_u8* compiled_code; #else /* Need to have these somewhere */ static void build_comp (void) {} -void check_prefs_changed_comp (void) {} +bool check_prefs_changed_comp (void) { return false; } #endif /* For faster JIT cycles handling */ signed long pissoff = 0; @@ -82,6 +82,8 @@ static uae_u32 tt0_030, tt1_030, tc_030; static uae_u16 mmusr_030; static struct cache020 caches020[CACHELINES020]; +static struct cache030 icaches030[CACHELINES030]; +static struct cache030 dcaches030[CACHELINES030]; static struct cache040 caches040[CACHESETS040]; #if COUNT_INSTRS @@ -134,31 +136,119 @@ void dump_counts (void) } #endif + +uae_u32 (*x_prefetch)(int); +uae_u32 (*x_next_iword)(void); +uae_u32 (*x_next_ilong)(void); +uae_u32 (*x_get_long)(uaecptr); +uae_u32 (*x_get_word)(uaecptr); +uae_u32 (*x_get_byte)(uaecptr); +void (*x_put_long)(uaecptr,uae_u32); +void (*x_put_word)(uaecptr,uae_u32); +void (*x_put_byte)(uaecptr,uae_u32); + +// 68020+ shared functions +static void set_x_funcs (void) +{ + if (currprefs.mmu_model) { + x_prefetch = get_iword_mmu; + x_next_iword = next_iword_mmu; + x_next_ilong = next_ilong_mmu; + x_put_long = put_long_mmu; + x_put_word = put_word_mmu; + x_put_byte = put_byte_mmu; + x_get_long = get_long_mmu; + x_get_word = get_word_mmu; + x_get_byte = get_byte_mmu; + } else if (!currprefs.cpu_cycle_exact) { + x_prefetch = get_iword; + x_next_iword = next_iword; + x_next_ilong = next_ilong; + x_put_long = put_long; + x_put_word = put_word; + x_put_byte = put_byte; + x_get_long = get_long; + x_get_word = get_word; + x_get_byte = get_byte; + } else if (currprefs.cpu_model == 68020) { + x_prefetch = get_word_ce020_prefetch; + x_next_iword = next_iword_020ce; + x_next_ilong = next_ilong_020ce; + x_put_long = put_long_ce020; + x_put_word = put_word_ce020; + x_put_byte = put_byte_ce020; + x_get_long = get_long_ce020; + x_get_word = get_word_ce020; + x_get_byte = get_byte_ce020; + } else { + x_prefetch = get_word_ce030_prefetch; + x_next_iword = next_iword_030ce; + x_next_ilong = next_ilong_030ce; + x_put_long = put_long_ce030; + x_put_word = put_word_ce030; + x_put_byte = put_byte_ce030; + x_get_long = get_long_ce030; + x_get_word = get_word_ce030; + x_get_byte = get_byte_ce030; + } + +} + static void set_cpu_caches (void) { int i, j; - if (currprefs.cpu_model < 68040) { - if (regs.cacr & 0x08) { // Clear Cache +#ifdef JIT + if (currprefs.cachesize) { + if (currprefs.cpu_model < 68040) { + set_cache_state (regs.cacr & 1); + if (regs.cacr & 0x08) { + flush_icache (0, 3); + } + } else { + set_cache_state ((regs.cacr & 0x8000) ? 1 : 0); + } + } +#endif + if (currprefs.cpu_model == 68020) { + if (regs.cacr & 0x08) { // clear instr cache for (i = 0; i < CACHELINES020; i++) caches020[i].valid = 0; regs.prefetch020addr = 0xff000000; } - if (regs.cacr & 0x04) { // Clear Entry - caches020[(regs.caar >> 2) & 0x3f].valid = 0; + if (regs.cacr & 0x04) { // clear entry in instr cache + caches020[(regs.caar >> 2) & (CACHELINES020 - 1)].valid = 0; regs.cacr &= ~0x04; } -#ifdef JIT - set_cache_state (regs.cacr & 1); - if (regs.cacr & 0x08) { - flush_icache (0, 3); + } else if (currprefs.cpu_model == 68030) { + //regs.cacr |= 0x100; + if (regs.cacr & 0x08) { // clear instr cache + for (i = 0; i < CACHELINES030; i++) { + icaches030[i].valid[0] = 0; + icaches030[i].valid[1] = 0; + icaches030[i].valid[2] = 0; + icaches030[i].valid[3] = 0; + } + regs.prefetch020addr = 0xff000000; } -#endif - regs.cacr &= ~0x08; - } else { -#ifdef JIT - set_cache_state ((regs.cacr & 0x8000) ? 1 : 0); -#endif + if (regs.cacr & 0x04) { // clear entry in instr cache + icaches030[(regs.caar >> 4) & (CACHELINES030 - 1)].valid[(regs.caar >> 2) & 3] = 0; + regs.cacr &= ~0x04; + } + if (regs.cacr & 0x800) { // clear data cache + for (i = 0; i < CACHELINES030; i++) { + dcaches030[i].valid[0] = 0; + dcaches030[i].valid[1] = 0; + dcaches030[i].valid[2] = 0; + dcaches030[i].valid[3] = 0; + } + regs.cacr &= ~0x800; + } + if (regs.cacr & 0x400) { // clear entry in data cache + dcaches030[(regs.caar >> 4) & (CACHELINES030 - 1)].valid[(regs.caar >> 2) & 3] = 0; + regs.cacr &= ~0x400; + } + } else if (currprefs.cpu_model == 68040) { if (!(regs.cacr & 0x8000)) { for (i = 0; i < CACHESETS040; i++) { for (j = 0; j < CACHELINES040; j++) { @@ -200,7 +290,7 @@ static void build_cpufunctbl (void) lvl = 5; tbl = op_smalltbl_0_ff; if (currprefs.cpu_cycle_exact) - tbl = op_smalltbl_20_ff; + tbl = op_smalltbl_21_ff; if (currprefs.mmu_model) tbl = op_smalltbl_31_ff; break; @@ -208,7 +298,7 @@ static void build_cpufunctbl (void) lvl = 4; tbl = op_smalltbl_1_ff; if (currprefs.cpu_cycle_exact) - tbl = op_smalltbl_21_ff; + tbl = op_smalltbl_22_ff; if (currprefs.mmu_model) tbl = op_smalltbl_31_ff; break; @@ -216,13 +306,13 @@ static void build_cpufunctbl (void) lvl = 3; tbl = op_smalltbl_2_ff; if (currprefs.cpu_cycle_exact) - tbl = op_smalltbl_22_ff; + tbl = op_smalltbl_23_ff; break; case 68020: lvl = 2; tbl = op_smalltbl_3_ff; if (currprefs.cpu_cycle_exact) - tbl = op_smalltbl_23_ff; + tbl = op_smalltbl_20_ff; break; case 68010: lvl = 1; @@ -347,7 +437,7 @@ static void update_68k_cycles (void) cpucycleunit = CYCLE_UNIT * currprefs.cpu_clock_multiplier; } } else if (currprefs.cpu_frequency) { - cpucycleunit = CYCLE_UNIT * baseclock / (currprefs.cpu_frequency * 8); + cpucycleunit = CYCLE_UNIT * baseclock / currprefs.cpu_frequency; } if (cpucycleunit < 1) cpucycleunit = 1; @@ -368,7 +458,7 @@ static void prefs_changed_cpu (void) void check_prefs_changed_cpu (void) { - int changed = 0; + bool changed = 0; if (!config_changed) return; @@ -441,9 +531,9 @@ void init_m68k (void) #endif write_log (L"Building CPU table for configuration: %d", currprefs.cpu_model); regs.address_space_mask = 0xffffffff; - if (currprefs.cpu_compatible > 0) { + if (currprefs.cpu_compatible) { if (currprefs.address_space_24 && currprefs.cpu_model >= 68030) - currprefs.address_space_24 = 0; + currprefs.address_space_24 = false; } if (currprefs.fpu_model > 0) write_log (L"/%d", currprefs.fpu_model); @@ -466,6 +556,7 @@ void init_m68k (void) write_log (L"%d CPU functions\n", nr_cpuop_funcs); build_cpufunctbl (); + set_x_funcs (); #ifdef JIT /* We need to check whether NATMEM settings have changed @@ -805,12 +896,11 @@ int get_cpu_model (void) return currprefs.cpu_model; } - /* * extract bitfield data from memory and return it in the MSBs * bdata caches the unmodified data for put_bitfield() */ -uae_u32 get_bitfield (uae_u32 src, uae_u32 bdata[2], uae_s32 offset, int width) +uae_u32 REGPARAM2 get_bitfield (uae_u32 src, uae_u32 bdata[2], uae_s32 offset, int width) { uae_u32 tmp, res, mask; @@ -859,7 +949,7 @@ uae_u32 get_bitfield (uae_u32 src, uae_u32 bdata[2], uae_s32 offset, int width) * write bitfield data (in the LSBs) back to memory, upper bits * must be cleared already. */ -void put_bitfield (uae_u32 dst, uae_u32 bdata[2], uae_u32 val, uae_s32 offset, int width) +void REGPARAM2 put_bitfield (uae_u32 dst, uae_u32 bdata[2], uae_u32 val, uae_s32 offset, int width) { offset = (offset & 7) + width; switch ((offset + 7) >> 3) { @@ -883,7 +973,7 @@ void put_bitfield (uae_u32 dst, uae_u32 bdata[2], uae_u32 val, uae_s32 offset, i } } -uae_u32 get_bitfield_020ce (uae_u32 src, uae_u32 bdata[2], uae_s32 offset, int width) +uae_u32 REGPARAM2 x_get_bitfield (uae_u32 src, uae_u32 bdata[2], uae_s32 offset, int width) { uae_u32 tmp, res, mask; @@ -891,33 +981,33 @@ uae_u32 get_bitfield_020ce (uae_u32 src, uae_u32 bdata[2], uae_s32 offset, int w mask = 0xffffffffu << (32 - width); switch ((offset + width + 7) >> 3) { case 1: - tmp = get_byte_ce020 (src); + tmp = x_get_byte (src); res = tmp << (24 + offset); bdata[0] = tmp & ~(mask >> (24 + offset)); break; case 2: - tmp = get_word_ce020 (src); + tmp = x_get_word (src); res = tmp << (16 + offset); bdata[0] = tmp & ~(mask >> (16 + offset)); break; case 3: - tmp = get_word_ce020 (src); + tmp = x_get_word (src); res = tmp << (16 + offset); bdata[0] = tmp & ~(mask >> (16 + offset)); - tmp = get_byte_ce020 (src + 2); + tmp = x_get_byte (src + 2); res |= tmp << (8 + offset); bdata[1] = tmp & ~(mask >> (8 + offset)); break; case 4: - tmp = get_long_ce020 (src); + tmp = x_get_long (src); res = tmp << offset; bdata[0] = tmp & ~(mask >> offset); break; case 5: - tmp = get_long_ce020 (src); + tmp = x_get_long (src); res = tmp << offset; bdata[0] = tmp & ~(mask >> offset); - tmp = get_byte_ce020 (src + 4); + tmp = x_get_byte (src + 4); res |= tmp >> (8 - offset); bdata[1] = tmp & ~(mask << (8 - offset)); break; @@ -929,101 +1019,30 @@ uae_u32 get_bitfield_020ce (uae_u32 src, uae_u32 bdata[2], uae_s32 offset, int w return res; } -void put_bitfield_020ce (uae_u32 dst, uae_u32 bdata[2], uae_u32 val, uae_s32 offset, int width) -{ - offset = (offset & 7) + width; - switch ((offset + 7) >> 3) { - case 1: - put_byte_ce020 (dst, bdata[0] | (val << (8 - offset))); - break; - case 2: - put_word_ce020 (dst, bdata[0] | (val << (16 - offset))); - break; - case 3: - put_word_ce020 (dst, bdata[0] | (val >> (offset - 16))); - put_byte_ce020 (dst + 2, bdata[1] | (val << (24 - offset))); - break; - case 4: - put_long_ce020 (dst, bdata[0] | (val << (32 - offset))); - break; - case 5: - put_long_ce020 (dst, bdata[0] | (val >> (offset - 32))); - put_byte_ce020 (dst + 4, bdata[1] | (val << (40 - offset))); - break; - } -} - - -uae_u32 get_bitfield_040mmu (uae_u32 src, uae_u32 bdata[2], uae_s32 offset, int width) -{ - uae_u32 tmp, res, mask; - - offset &= 7; - mask = 0xffffffffu << (32 - width); - switch ((offset + width + 7) >> 3) { - case 1: - tmp = get_byte_mmu (src); - res = tmp << (24 + offset); - bdata[0] = tmp & ~(mask >> (24 + offset)); - break; - case 2: - tmp = get_word_mmu (src); - res = tmp << (16 + offset); - bdata[0] = tmp & ~(mask >> (16 + offset)); - break; - case 3: - tmp = get_word_mmu (src); - res = tmp << (16 + offset); - bdata[0] = tmp & ~(mask >> (16 + offset)); - tmp = get_byte_mmu (src + 2); - res |= tmp << (8 + offset); - bdata[1] = tmp & ~(mask >> (8 + offset)); - break; - case 4: - tmp = get_long_mmu (src); - res = tmp << offset; - bdata[0] = tmp & ~(mask >> offset); - break; - case 5: - tmp = get_long_mmu (src); - res = tmp << offset; - bdata[0] = tmp & ~(mask >> offset); - tmp = get_byte_mmu (src + 4); - res |= tmp >> (8 - offset); - bdata[1] = tmp & ~(mask << (8 - offset)); - break; - default: - /* Panic? */ - res = 0; - break; - } - return res; -} -void put_bitfield_040mmu (uae_u32 dst, uae_u32 bdata[2], uae_u32 val, uae_s32 offset, int width) +void REGPARAM2 x_put_bitfield (uae_u32 dst, uae_u32 bdata[2], uae_u32 val, uae_s32 offset, int width) { offset = (offset & 7) + width; switch ((offset + 7) >> 3) { case 1: - put_byte_mmu (dst, bdata[0] | (val << (8 - offset))); + x_put_byte (dst, bdata[0] | (val << (8 - offset))); break; case 2: - put_word_mmu (dst, bdata[0] | (val << (16 - offset))); + x_put_word (dst, bdata[0] | (val << (16 - offset))); break; case 3: - put_word_mmu (dst, bdata[0] | (val >> (offset - 16))); - put_byte_mmu (dst + 2, bdata[1] | (val << (24 - offset))); + x_put_word (dst, bdata[0] | (val >> (offset - 16))); + x_put_byte (dst + 2, bdata[1] | (val << (24 - offset))); break; case 4: - put_long_mmu (dst, bdata[0] | (val << (32 - offset))); + x_put_long (dst, bdata[0] | (val << (32 - offset))); break; case 5: - put_long_mmu (dst, bdata[0] | (val >> (offset - 32))); - put_byte_mmu (dst + 4, bdata[1] | (val << (40 - offset))); + x_put_long (dst, bdata[0] | (val >> (offset - 32))); + x_put_byte (dst + 4, bdata[1] | (val << (40 - offset))); break; } } - uae_u32 REGPARAM2 get_disp_ea_020 (uae_u32 base, uae_u32 dp) { int reg = (dp >> 12) & 15; @@ -1036,15 +1055,22 @@ uae_u32 REGPARAM2 get_disp_ea_020 (uae_u32 base, uae_u32 dp) if (dp & 0x80) base = 0; if (dp & 0x40) regd = 0; - if ((dp & 0x30) == 0x20) base += (uae_s32)(uae_s16) next_iword (); - if ((dp & 0x30) == 0x30) base += next_ilong (); + if ((dp & 0x30) == 0x20) + base += (uae_s32)(uae_s16) next_iword (); + if ((dp & 0x30) == 0x30) + base += next_ilong (); - if ((dp & 0x3) == 0x2) outer = (uae_s32)(uae_s16) next_iword (); - if ((dp & 0x3) == 0x3) outer = next_ilong (); + if ((dp & 0x3) == 0x2) + outer = (uae_s32)(uae_s16) next_iword (); + if ((dp & 0x3) == 0x3) + outer = next_ilong (); - if ((dp & 0x4) == 0) base += regd; - if (dp & 0x3) base = get_long (base); - if (dp & 0x4) base += regd; + if ((dp & 0x4) == 0) + base += regd; + if (dp & 0x3) + base = get_long (base); + if (dp & 0x4) + base += regd; return base + outer; } else { @@ -1052,7 +1078,7 @@ uae_u32 REGPARAM2 get_disp_ea_020 (uae_u32 base, uae_u32 dp) } } -uae_u32 REGPARAM2 get_disp_ea_020ce (uae_u32 base, uae_u32 dp) +uae_u32 REGPARAM2 x_get_disp_ea_020 (uae_u32 base, uae_u32 dp) { int reg = (dp >> 12) & 15; int cycles = 0; @@ -1070,20 +1096,20 @@ uae_u32 REGPARAM2 get_disp_ea_020ce (uae_u32 base, uae_u32 dp) regd = 0; if ((dp & 0x30) == 0x20) { - base += (uae_s32)(uae_s16) next_iword_020ce (); + base += (uae_s32)(uae_s16) x_next_iword (); cycles++; } if ((dp & 0x30) == 0x30) { - base += next_ilong_020ce (); + base += x_next_ilong (); cycles++; } if ((dp & 0x3) == 0x2) { - outer = (uae_s32)(uae_s16) next_iword_020ce (); + outer = (uae_s32)(uae_s16) x_next_iword (); cycles++; } if ((dp & 0x3) == 0x3) { - outer = next_ilong_020ce (); + outer = x_next_ilong (); cycles++; } @@ -1092,7 +1118,7 @@ uae_u32 REGPARAM2 get_disp_ea_020ce (uae_u32 base, uae_u32 dp) cycles++; } if (dp & 0x3) { - base = get_long_ce020 (base); + base = x_get_long (base); cycles++; } if (dp & 0x4) { @@ -1108,40 +1134,6 @@ uae_u32 REGPARAM2 get_disp_ea_020ce (uae_u32 base, uae_u32 dp) return v; } -uae_u32 REGPARAM2 get_disp_ea_040mmu (uae_u32 base, uae_u32 dp) -{ - int reg = (dp >> 12) & 15; - uae_s32 regd = regs.regs[reg]; - if ((dp & 0x800) == 0) - regd = (uae_s32)(uae_s16)regd; - regd <<= (dp >> 9) & 3; - if (dp & 0x100) { - uae_s32 outer = 0; - if (dp & 0x80) base = 0; - if (dp & 0x40) regd = 0; - - if ((dp & 0x30) == 0x20) - base += (uae_s32)(uae_s16) next_iword_mmu (); - if ((dp & 0x30) == 0x30) - base += next_ilong_mmu (); - - if ((dp & 0x3) == 0x2) - outer = (uae_s32)(uae_s16) next_iword_mmu (); - if ((dp & 0x3) == 0x3) - outer = next_ilong_mmu (); - - if ((dp & 0x4) == 0) - base += regd; - if (dp & 0x3) - base = get_long_mmu (base); - if (dp & 0x4) - base += regd; - - return base + outer; - } else { - return base + (uae_s32)((uae_s8)dp) + regd; - } -} uae_u32 REGPARAM3 get_disp_ea_000 (uae_u32 base, uae_u32 dp) REGPARAM { @@ -1574,14 +1566,13 @@ kludge_me_do: exception_trace (nr); } - static void Exception_normal (int nr, uaecptr oldpc) { uae_u32 currpc = m68k_getpc (), newpc; int sv = regs.s; if (nr >= 24 && nr < 24 + 8 && currprefs.cpu_model <= 68010) - nr = get_byte (0x00fffff1 | (nr << 1)); + nr = x_get_byte (0x00fffff1 | (nr << 1)); exception_debug (nr); MakeSR (); @@ -1606,33 +1597,33 @@ static void Exception_normal (int nr, uaecptr oldpc) for (i = 0 ; i < 7 ; i++) { m68k_areg (regs, 7) -= 4; - put_long_mmu (m68k_areg (regs, 7), 0); + x_put_long (m68k_areg (regs, 7), 0); } m68k_areg (regs, 7) -= 4; - put_long_mmu (m68k_areg (regs, 7), regs.wb3_data); + x_put_long (m68k_areg (regs, 7), regs.wb3_data); m68k_areg (regs, 7) -= 4; - put_long_mmu (m68k_areg (regs, 7), regs.mmu_fault_addr); + x_put_long (m68k_areg (regs, 7), regs.mmu_fault_addr); m68k_areg (regs, 7) -= 4; - put_long_mmu (m68k_areg (regs, 7), regs.mmu_fault_addr); + x_put_long (m68k_areg (regs, 7), regs.mmu_fault_addr); m68k_areg (regs, 7) -= 2; - put_word_mmu (m68k_areg (regs, 7), 0); + x_put_word (m68k_areg (regs, 7), 0); m68k_areg (regs, 7) -= 2; - put_word_mmu (m68k_areg (regs, 7), 0); + x_put_word (m68k_areg (regs, 7), 0); m68k_areg (regs, 7) -= 2; - put_word_mmu (m68k_areg (regs, 7), regs.wb3_status); + x_put_word (m68k_areg (regs, 7), regs.wb3_status); regs.wb3_status = 0; m68k_areg (regs, 7) -= 2; - put_word_mmu (m68k_areg (regs, 7), regs.mmu_ssw); + x_put_word (m68k_areg (regs, 7), regs.mmu_ssw); m68k_areg (regs, 7) -= 4; - put_long_mmu (m68k_areg (regs, 7), regs.mmu_fault_addr); + x_put_long (m68k_areg (regs, 7), regs.mmu_fault_addr); m68k_areg (regs, 7) -= 2; - put_word_mmu (m68k_areg (regs, 7), 0x7000 + nr * 4); + x_put_word (m68k_areg (regs, 7), 0x7000 + nr * 4); m68k_areg (regs, 7) -= 4; - put_long_mmu (m68k_areg (regs, 7), oldpc); + x_put_long (m68k_areg (regs, 7), oldpc); m68k_areg (regs, 7) -= 2; - put_word_mmu (m68k_areg (regs, 7), regs.sr); - newpc = get_long_mmu (regs.vbr + 4 * nr); + x_put_word (m68k_areg (regs, 7), regs.sr); + newpc = x_get_long (regs.vbr + 4 * nr); if (newpc & 1) { if (nr == 2 || nr == 3) uae_reset (1); /* there is nothing else we can do.. */ @@ -1651,35 +1642,35 @@ static void Exception_normal (int nr, uaecptr oldpc) for (i = 0 ; i < 18 ; i++) { m68k_areg (regs, 7) -= 2; - put_word (m68k_areg (regs, 7), 0); + x_put_word (m68k_areg (regs, 7), 0); } m68k_areg (regs, 7) -= 4; - put_long (m68k_areg (regs, 7), last_fault_for_exception_3); + x_put_long (m68k_areg (regs, 7), last_fault_for_exception_3); m68k_areg (regs, 7) -= 2; - put_word (m68k_areg (regs, 7), 0); + x_put_word (m68k_areg (regs, 7), 0); m68k_areg (regs, 7) -= 2; - put_word (m68k_areg (regs, 7), 0); + x_put_word (m68k_areg (regs, 7), 0); m68k_areg (regs, 7) -= 2; - put_word (m68k_areg (regs, 7), 0); + x_put_word (m68k_areg (regs, 7), 0); m68k_areg (regs, 7) -= 2; - put_word (m68k_areg (regs, 7), 0x0140 | (sv ? 6 : 2)); /* SSW */ + x_put_word (m68k_areg (regs, 7), 0x0140 | (sv ? 6 : 2)); /* SSW */ m68k_areg (regs, 7) -= 4; - put_long (m68k_areg (regs, 7), last_addr_for_exception_3); + x_put_long (m68k_areg (regs, 7), last_addr_for_exception_3); m68k_areg (regs, 7) -= 2; - put_word (m68k_areg (regs, 7), 0x7000 + nr * 4); + x_put_word (m68k_areg (regs, 7), 0x7000 + nr * 4); m68k_areg (regs, 7) -= 4; - put_long (m68k_areg (regs, 7), oldpc); + x_put_long (m68k_areg (regs, 7), oldpc); m68k_areg (regs, 7) -= 2; - put_word (m68k_areg (regs, 7), regs.sr); + x_put_word (m68k_areg (regs, 7), regs.sr); goto kludge_me_do; } } else { m68k_areg (regs, 7) -= 4; - put_long (m68k_areg (regs, 7), last_fault_for_exception_3); + x_put_long (m68k_areg (regs, 7), last_fault_for_exception_3); m68k_areg (regs, 7) -= 2; - put_word (m68k_areg (regs, 7), 0x2000 + nr * 4); + x_put_word (m68k_areg (regs, 7), 0x2000 + nr * 4); } } else { // address error @@ -1688,62 +1679,62 @@ static void Exception_normal (int nr, uaecptr oldpc) ssw |= 0x20; for (i = 0 ; i < 36; i++) { m68k_areg (regs, 7) -= 2; - put_word (m68k_areg (regs, 7), 0); + x_put_word (m68k_areg (regs, 7), 0); } m68k_areg (regs, 7) -= 4; - put_long (m68k_areg (regs, 7), last_fault_for_exception_3); + x_put_long (m68k_areg (regs, 7), last_fault_for_exception_3); m68k_areg (regs, 7) -= 2; - put_word (m68k_areg (regs, 7), 0); + x_put_word (m68k_areg (regs, 7), 0); m68k_areg (regs, 7) -= 2; - put_word (m68k_areg (regs, 7), 0); + x_put_word (m68k_areg (regs, 7), 0); m68k_areg (regs, 7) -= 2; - put_word (m68k_areg (regs, 7), 0); + x_put_word (m68k_areg (regs, 7), 0); m68k_areg (regs, 7) -= 2; - put_word (m68k_areg (regs, 7), ssw); + x_put_word (m68k_areg (regs, 7), ssw); m68k_areg (regs, 7) -= 2; - put_word (m68k_areg (regs, 7), 0xb000 + nr * 4); + x_put_word (m68k_areg (regs, 7), 0xb000 + nr * 4); } - write_log (L"Exception %d (%x) at %x -> %x!\n", nr, oldpc, currpc, get_long (regs.vbr + 4*nr)); + write_log (L"Exception %d (%x) at %x -> %x!\n", nr, oldpc, currpc, x_get_long (regs.vbr + 4*nr)); } else if (nr ==5 || nr == 6 || nr == 7 || nr == 9) { m68k_areg (regs, 7) -= 4; - put_long (m68k_areg (regs, 7), oldpc); + x_put_long (m68k_areg (regs, 7), oldpc); m68k_areg (regs, 7) -= 2; - put_word (m68k_areg (regs, 7), 0x2000 + nr * 4); + x_put_word (m68k_areg (regs, 7), 0x2000 + nr * 4); } else if (regs.m && nr >= 24 && nr < 32) { /* M + Interrupt */ m68k_areg (regs, 7) -= 2; - put_word (m68k_areg (regs, 7), nr * 4); + x_put_word (m68k_areg (regs, 7), nr * 4); m68k_areg (regs, 7) -= 4; - put_long (m68k_areg (regs, 7), currpc); + x_put_long (m68k_areg (regs, 7), currpc); m68k_areg (regs, 7) -= 2; - put_word (m68k_areg (regs, 7), regs.sr); + x_put_word (m68k_areg (regs, 7), regs.sr); regs.sr |= (1 << 13); regs.msp = m68k_areg (regs, 7); m68k_areg (regs, 7) = regs.isp; m68k_areg (regs, 7) -= 2; - put_word (m68k_areg (regs, 7), 0x1000 + nr * 4); + x_put_word (m68k_areg (regs, 7), 0x1000 + nr * 4); } else { m68k_areg (regs, 7) -= 2; - put_word (m68k_areg (regs, 7), nr * 4); + x_put_word (m68k_areg (regs, 7), nr * 4); } } else if (nr == 2 || nr == 3) { uae_u16 mode = (sv ? 4 : 0) | (last_instructionaccess_for_exception_3 ? 2 : 1); mode |= last_writeaccess_for_exception_3 ? 0 : 16; m68k_areg (regs, 7) -= 14; /* fixme: bit3=I/N */ - put_word (m68k_areg (regs, 7) + 0, mode); - put_long (m68k_areg (regs, 7) + 2, last_fault_for_exception_3); - put_word (m68k_areg (regs, 7) + 6, last_op_for_exception_3); - put_word (m68k_areg (regs, 7) + 8, regs.sr); - put_long (m68k_areg (regs, 7) + 10, last_addr_for_exception_3); - write_log (L"Exception %d (%x) at %x -> %x!\n", nr, oldpc, currpc, get_long (regs.vbr + 4*nr)); + x_put_word (m68k_areg (regs, 7) + 0, mode); + x_put_long (m68k_areg (regs, 7) + 2, last_fault_for_exception_3); + x_put_word (m68k_areg (regs, 7) + 6, last_op_for_exception_3); + x_put_word (m68k_areg (regs, 7) + 8, regs.sr); + x_put_long (m68k_areg (regs, 7) + 10, last_addr_for_exception_3); + write_log (L"Exception %d (%x) at %x -> %x!\n", nr, oldpc, currpc, x_get_long (regs.vbr + 4*nr)); goto kludge_me_do; } m68k_areg (regs, 7) -= 4; - put_long (m68k_areg (regs, 7), currpc); + x_put_long (m68k_areg (regs, 7), currpc); m68k_areg (regs, 7) -= 2; - put_word (m68k_areg (regs, 7), regs.sr); + x_put_word (m68k_areg (regs, 7), regs.sr); kludge_me_do: - newpc = get_long (regs.vbr + 4 * nr); + newpc = x_get_long (regs.vbr + 4 * nr); if (newpc & 1) { if (nr == 2 || nr == 3) uae_reset (1); /* there is nothing else we can do.. */ @@ -2386,55 +2377,55 @@ static void mmu_op30_pmove (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr ex reg = L"TC"; siz = 4; if (rw) - put_long (extra, tc_030); + x_put_long (extra, tc_030); else - tc_030 = get_long (extra); + tc_030 = x_get_long (extra); break; case 0x12: // SRP reg = L"SRP"; siz = 8; if (rw) { - put_long (extra, srp_030 >> 32); - put_long (extra + 4, srp_030); + x_put_long (extra, srp_030 >> 32); + x_put_long (extra + 4, srp_030); } else { - srp_030 = (uae_u64)get_long (extra) << 32; - srp_030 |= get_long (extra + 4); + srp_030 = (uae_u64)x_get_long (extra) << 32; + srp_030 |= x_get_long (extra + 4); } break; case 0x13: // CRP reg = L"CRP"; siz = 8; if (rw) { - put_long (extra, crp_030 >> 32); - put_long (extra + 4, crp_030); + x_put_long (extra, crp_030 >> 32); + x_put_long (extra + 4, crp_030); } else { - crp_030 = (uae_u64)get_long (extra) << 32; - crp_030 |= get_long (extra + 4); + crp_030 = (uae_u64)x_get_long (extra) << 32; + crp_030 |= x_get_long (extra + 4); } break; case 0x18: // MMUSR reg = L"MMUSR"; siz = 2; if (rw) - put_word (extra, mmusr_030); + x_put_word (extra, mmusr_030); else - mmusr_030 = get_word (extra); + mmusr_030 = x_get_word (extra); break; case 0x02: // TT0 reg = L"TT0"; siz = 4; if (rw) - put_long (extra, tt0_030); + x_put_long (extra, tt0_030); else - tt0_030 = get_long (extra); + tt0_030 = x_get_long (extra); break; case 0x03: // TT1 reg = L"TT1"; siz = 4; if (rw) - put_long (extra, tt1_030); + x_put_long (extra, tt1_030); else - tt1_030 = get_long (extra); + tt1_030 = x_get_long (extra); break; } @@ -2446,17 +2437,17 @@ static void mmu_op30_pmove (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr ex { uae_u32 val; if (siz == 8) { - uae_u32 val2 = get_long (extra); - val = get_long (extra + 4); + uae_u32 val2 = x_get_long (extra); + val = x_get_long (extra + 4); if (rw) write_log (L"PMOVE %s,%08X%08X", reg, val2, val); else write_log (L"PMOVE %08X%08X,%s", val2, val, reg); } else { if (siz == 4) - val = get_long (extra); + val = x_get_long (extra); else - val = get_word (extra); + val = x_get_word (extra); if (rw) write_log (L"PMOVE %s,%08X", reg, val); else @@ -3050,7 +3041,7 @@ retry: TRY (prb) { for (;;) { pc = regs.fault_pc = m68k_getpc (); - opcode = get_iword_mmu (0); + opcode = x_prefetch (0); count_instr (opcode); do_cycles (cpu_cycles); cpu_cycles = (*cpufunctbl[opcode])(opcode); @@ -3097,7 +3088,7 @@ retry: } -/* "cycle exact" 68020 */ +/* "cycle exact" 68020/030 */ #define MAX68020CYCLES 4 static void m68k_run_2ce (void) { @@ -3106,7 +3097,7 @@ static void m68k_run_2ce (void) ipl_fetch (); for (;;) { - uae_u32 opcode = get_word_ce020_prefetch (0); + uae_u32 opcode = x_prefetch (0); (*cpufunctbl[opcode])(opcode); if (r->ce020memcycles > 0) { tmpcycles = CYCLE_UNIT * MAX68020CYCLES; @@ -3308,7 +3299,7 @@ void m68k_go (int may_quit) run_func = m68k_run_mmu; } else { run_func = currprefs.cpu_cycle_exact && currprefs.cpu_model == 68000 ? m68k_run_1_ce : - currprefs.cpu_compatible > 0 && currprefs.cpu_model == 68000 ? m68k_run_1 : + currprefs.cpu_compatible && currprefs.cpu_model == 68000 ? m68k_run_1 : #ifdef JIT currprefs.cpu_model >= 68020 && currprefs.cachesize ? m68k_run_jit : #endif @@ -4239,7 +4230,8 @@ STATIC_INLINE void fill_cache040 (uae_u32 addr) } #endif -STATIC_INLINE void fill_cache020 (uae_u32 addr) +// this one is really simple and easy +void fill_icache020 (uae_u32 addr) { int index; uae_u32 tag; @@ -4267,14 +4259,218 @@ STATIC_INLINE void fill_cache020 (uae_u32 addr) regs.prefetch020data = data; } -void fill_cache0x0 (uae_u32 addr) +// 68030 caches aren't so simple as 68020 cache.. +STATIC_INLINE struct cache030 *getcache030 (struct cache030 *cp, uaecptr addr, uae_u32 *tagp, int *lwsp) +{ + int index, lws; + uae_u32 tag; + struct cache030 *c; + + addr &= ~3; + index = (addr >> 4) & (CACHELINES030 - 1); + tag = regs.s | (addr & ~((CACHELINES030 << 4) - 1)); + lws = (addr >> 2) & 3; + c = &cp[index]; + *tagp = tag; + *lwsp = lws; + return c; +} + +STATIC_INLINE void update_cache030 (struct cache030 *c, uae_u32 val, uae_u32 tag, int lws) { + if (c->tag != tag) + c->valid[0] = c->valid[1] = c->valid[2] = c->valid[3] = false; + c->tag = tag; + c->valid[lws] = true; + c->data[lws] = val; +} + +void fill_icache030 (uae_u32 addr) +{ + int lws; + uae_u32 tag; + uae_u32 data; + struct cache030 *c; + + addr &= ~3; + c = getcache030 (icaches030, addr, &tag, &lws); + if (c->valid[lws] && c->tag == tag) { + // cache hit + regs.prefetch020addr = addr; + regs.prefetch020data = c->data[lws]; + return; + } + // cache miss + data = mem_access_delay_longi_read_ce020 (addr); + if ((regs.cacr & 3) == 1) { // not frozen and enabled + update_cache030 (c, data, tag, lws); #if 0 - if (currprefs.cpu_model >= 68040) - fill_cache040 (addr); - else + if ((regs.cacr & 0x11) == 0x11 && lws == 0 && !c->valid[0] && !c->valid[1] && !c->valid[2] && !c->valid[3] && ce_banktype[addr >> 16] == CE_MEMBANK_FAST) { + // do burst fetch if cache enabled, not frozen, all slots invalid, no chip ram + c->data[1] = mem_access_delay_long_read_ce020 (addr + 4); + c->data[2] = mem_access_delay_long_read_ce020 (addr + 8); + c->data[3] = mem_access_delay_long_read_ce020 (addr + 12); + c->valid[1] = c->valid[2] = c->valid[3] = true; + } #endif - fill_cache020 (addr); + } + regs.prefetch020addr = addr; + regs.prefetch020data = data; +} + +STATIC_INLINE bool cancache030 (uaecptr addr) +{ + return ce_cachable[addr >> 16]; +} + +// and finally the worst part, 68030 data cache.. +void write_dcache030 (uaecptr addr, uae_u32 val, int size) +{ + struct cache030 *c1, *c2; + int lws1, lws2; + uae_u32 tag1, tag2; + int aligned = addr & 3; + + if (!(regs.cacr & 0x100) || currprefs.cpu_model == 68040) // data cache disabled? 68040 shares this too. + return; + if (!cancache030 (addr)) + return; + + c1 = getcache030 (dcaches030, addr, &tag1, &lws1); + +#if 0 + uaecptr a = 0x1db0c; + if (addr - (1 << size) + 1 <= a && addr + (1 << size) >= a) { + write_log (L"%08x %d %d %08x %08x %d\n", addr, aligned, size, val, tag1, lws1); + if (aligned == 2) + write_log (L"*\n"); + } +#endif + + // easy one + if (size == 2 && aligned == 0) { + update_cache030 (c1, val, tag1, lws1); +#if 0 + if ((regs.cacr & 0x1100) == 0x1100 && lws1 == 0 && !c1->valid[0] && !c1->valid[1] && !c1->valid[2] && !c1->valid[3] && ce_banktype[addr >> 16] == CE_MEMBANK_FAST) { + // do burst fetch if cache enabled, not frozen, all slots invalid, no chip ram + c1->data[1] = mem_access_delay_long_read_ce020 (addr + 4); + c1->data[2] = mem_access_delay_long_read_ce020 (addr + 8); + c1->data[3] = mem_access_delay_long_read_ce020 (addr + 12); + c1->valid[1] = c1->valid[2] = c1->valid[3] = true; + } +#endif + return; + } + // argh!! merge partial write + c2 = getcache030 (dcaches030, addr + 4, &tag2, &lws2); + if (size == 2) { + if (c1->valid[lws1] && c1->tag == tag1) { + c1->data[lws1] &= ~(0xffffffff >> (aligned * 8)); + c1->data[lws1] |= val >> (aligned * 8); + } + if (c2->valid[lws2] && c2->tag == tag2) { + c2->data[lws2] &= 0xffffffff >> ((4 - aligned) * 8); + c2->data[lws2] |= val << ((4 - aligned) * 8); + } + } else if (size == 1) { + val <<= 16; + if (c1->valid[lws1] && c1->tag == tag1) { + c1->data[lws1] &= ~(0xffff0000 >> (aligned * 8)); + c1->data[lws1] |= val >> (aligned * 8); + } + if (c2->valid[lws2] && c2->tag == tag2 && aligned == 3) { + c2->data[lws2] &= 0x00ffffff; + c2->data[lws2] |= val << 8; + } + } else if (size == 0) { + val <<= 24; + if (c1->valid[lws1] && c1->tag == tag1) { + c1->data[lws1] &= ~(0xff000000 >> (aligned * 8)); + c1->data[lws1] |= val >> (aligned * 8); + } + } +} + +uae_u32 read_dcache030 (uaecptr addr, int size) +{ + struct cache030 *c1, *c2; + int lws1, lws2; + uae_u32 tag1, tag2; + int aligned = addr & 3; + int len = (1 << size) * 8; + uae_u32 v1, v2; + + if (!(regs.cacr & 0x100) || currprefs.cpu_model == 68040 || !cancache030 (addr)) { // data cache disabled? shared with 68040 "ce" + if (size == 2) + return mem_access_delay_long_read_ce020 (addr); + else if (size == 1) + return mem_access_delay_word_read_ce020 (addr); + else + return mem_access_delay_byte_read_ce020 (addr); + } + + c1 = getcache030 (dcaches030, addr, &tag1, &lws1); + addr &= ~3; + if (!c1->valid[lws1] || c1->tag != tag1) { + v1 = mem_access_delay_long_read_ce020 (addr); + update_cache030 (c1, v1, tag1, lws1); + } else { + v1 = c1->data[lws1]; + if (get_long (addr) != v1) { + write_log (L"data cache mismatch %d %d %08x %08x != %08x %08x %d PC=%08x\n", + size, aligned, addr, get_long (addr), v1, tag1, lws1, M68K_GETPC); + v1 = get_long (addr); + } + } + // only one long fetch needed? + if (size == 0) { + v1 >>= (3 - aligned) * 8; + return v1; + } else if (size == 1 && aligned <= 2) { + v1 >>= (2 - aligned) * 8; + return v1; + } else if (size == 2 && aligned == 0) { + return v1; + } + // need two longs + addr += 4; + c2 = getcache030 (dcaches030, addr, &tag2, &lws2); + if (!c2->valid[lws2] || c2->tag != tag2) { + v2 = mem_access_delay_long_read_ce020 (addr); + update_cache030 (c2, v2, tag2, lws2); + } else { + v2 = c2->data[lws2]; + if (get_long (addr) != v2) { + write_log (L"data cache mismatch %d %d %08x %08x != %08x %08x %d PC=%08x\n", + size, aligned, addr, get_long (addr), v2, tag2, lws2, M68K_GETPC); + v2 = get_long (addr); + } + } + if (size == 1 && aligned == 3) + return (v1 << 8) | (v2 >> 24); + else if (size == 2 && aligned == 1) + return (v1 << 8) | (v2 >> 24); + else if (size == 2 && aligned == 2) + return (v1 << 16) | (v2 >> 16); + else if (size == 2 && aligned == 3) + return (v1 << 24) | (v2 >> 8); + + write_log (L"dcache030 weirdness!?\n"); + return 0; +} + +void flush_dcache (uaecptr addr, int size) +{ + if (!currprefs.cpu_cycle_exact) + return; + if (currprefs.cpu_model >= 68030) { + for (int i = 0; i < CACHELINES030; i++) { + dcaches030[i].valid[0] = 0; + dcaches030[i].valid[1] = 0; + dcaches030[i].valid[2] = 0; + dcaches030[i].valid[3] = 0; + } + } } void do_cycles_ce020 (int clocks) @@ -4321,46 +4517,3 @@ void m68k_do_bsr_mmu (uaecptr oldpc, uae_s32 offset) m68k_areg (regs, 7) -= 4; m68k_incpci (offset); } - -void put_long_slow (uaecptr addr, uae_u32 v) -{ - if (currprefs.mmu_model) - put_long_mmu (addr, v); - else - put_long (addr, v); -} -void put_word_slow (uaecptr addr, uae_u32 v) -{ - if (currprefs.mmu_model) - put_word_mmu (addr, v); - else - put_word (addr, v); -} -void put_byte_slow (uaecptr addr, uae_u32 v) -{ - if (currprefs.mmu_model) - put_byte_mmu (addr, v); - else - put_byte (addr, v); -} -uae_u32 get_long_slow (uaecptr addr) -{ - if (currprefs.mmu_model) - return get_long_mmu (addr); - else - return get_long (addr); -} -uae_u32 get_word_slow (uaecptr addr) -{ - if (currprefs.mmu_model) - return get_word_mmu (addr); - else - return get_word (addr); -} -uae_u32 get_byte_slow (uaecptr addr) -{ - if (currprefs.mmu_model) - return get_byte_mmu (addr); - else - return get_byte (addr); -} diff --git a/od-win32/dinput.cpp b/od-win32/dinput.cpp index 312b666c..6c1fc743 100644 --- a/od-win32/dinput.cpp +++ b/od-win32/dinput.cpp @@ -93,6 +93,8 @@ struct didata { #define DI_BUFFER 30 #define DI_KBBUFFER 50 +static LPDIRECTINPUT8 g_lpdi; + static struct didata di_mouse[MAX_INPUT_DEVICES]; static struct didata di_keyboard[MAX_INPUT_DEVICES]; static struct didata di_joystick[MAX_INPUT_DEVICES]; @@ -167,6 +169,7 @@ static void fixthings (struct didata *did) { int i; + did->buttons_real = did->buttons; for (i = 0; i < did->axles; i++) addplusminus (did, i); } @@ -174,33 +177,16 @@ static void fixthings_mouse (struct didata *did) { int i; + did->buttons_real = did->buttons; for (i = 0; i < did->axles; i++) { if (did->axissort[i] == -97) addplusminus (did, i); } } -typedef BOOL (CALLBACK* REGISTERRAWINPUTDEVICES) - (PCRAWINPUTDEVICE, UINT, UINT); -static REGISTERRAWINPUTDEVICES pRegisterRawInputDevices; -typedef UINT (CALLBACK* GETRAWINPUTDATA) - (HRAWINPUT, UINT, LPVOID, PUINT, UINT); -static GETRAWINPUTDATA pGetRawInputData; -typedef UINT (CALLBACK* GETRAWINPUTDEVICELIST) - (PRAWINPUTDEVICELIST, PUINT, UINT); -static GETRAWINPUTDEVICELIST pGetRawInputDeviceList; -typedef UINT (CALLBACK* GETRAWINPUTDEVICEINFO) - (HANDLE, UINT, LPVOID, PUINT); -static GETRAWINPUTDEVICEINFO pGetRawInputDeviceInfo; -typedef UINT (CALLBACK* GETRAWINPUTBUFFER) - (PRAWINPUT, PUINT, UINT); -static GETRAWINPUTBUFFER pGetRawInputBuffer; -typedef LRESULT (CALLBACK* DEFRAWINPUTPROC) - (PRAWINPUT*, INT, UINT); -static DEFRAWINPUTPROC pDefRawInputProc; static int rawinput_available, rawinput_registered_mouse, rawinput_registered_kb; -static int register_rawinput (void) +static int register_rawinput (int flags) { int num, rm, rkb; RAWINPUTDEVICE rid[2]; @@ -237,7 +223,7 @@ static int register_rawinput (void) } if (num == 0) return 1; - if (pRegisterRawInputDevices (rid, num, sizeof (RAWINPUTDEVICE)) == FALSE) { + if (RegisterRawInputDevices (rid, num, sizeof (RAWINPUTDEVICE)) == FALSE) { write_log (L"RAWINPUT registration failed %d (%d,%d->%d,%d->%d)\n", GetLastError (), num, rawinput_registered_mouse, rm, @@ -298,7 +284,7 @@ static int keyhack (int scancode, int pressed, int num) return -1; } - if (!keyboard_german || currprefs.input_selected_setting > 0) + if (!keyboard_german) return scancode; //This code look so ugly because there is no Directinput @@ -749,28 +735,12 @@ static int initialize_rawinput (void) if (no_rawinput) goto error; - pRegisterRawInputDevices = (REGISTERRAWINPUTDEVICES)GetProcAddress ( - GetModuleHandle (L"user32.dll"), "RegisterRawInputDevices"); - pGetRawInputData = (GETRAWINPUTDATA)GetProcAddress ( - GetModuleHandle (L"user32.dll"), "GetRawInputData"); - pGetRawInputDeviceList = (GETRAWINPUTDEVICELIST)GetProcAddress ( - GetModuleHandle (L"user32.dll"), "GetRawInputDeviceList"); - pGetRawInputDeviceInfo = (GETRAWINPUTDEVICEINFO)GetProcAddress ( - GetModuleHandle (L"user32.dll"), "GetRawInputDeviceInfoW"); - pGetRawInputBuffer = (GETRAWINPUTBUFFER)GetProcAddress ( - GetModuleHandle (L"user32.dll"), "GetRawInputBuffer"); - pDefRawInputProc = (DEFRAWINPUTPROC)GetProcAddress ( - GetModuleHandle (L"user32.dll"), "DefRawInputProc"); - - if (!pRegisterRawInputDevices || !pGetRawInputData || !pGetRawInputDeviceList || - !pGetRawInputDeviceInfo || !pGetRawInputBuffer || !pDefRawInputProc) - goto error; bufsize = 10000 * sizeof (TCHAR); buf = xmalloc (TCHAR, bufsize / sizeof (TCHAR)); - register_rawinput (); - if (pGetRawInputDeviceList (NULL, &num, sizeof (RAWINPUTDEVICELIST)) != 0) { + register_rawinput (0); + if (GetRawInputDeviceList (NULL, &num, sizeof (RAWINPUTDEVICELIST)) != 0) { write_log (L"RAWINPUT error %08X\n", GetLastError()); goto error2; } @@ -778,7 +748,7 @@ static int initialize_rawinput (void) if (num <= 0) goto error2; ridl = xcalloc (RAWINPUTDEVICELIST, num); - gotnum = pGetRawInputDeviceList (ridl, &num, sizeof (RAWINPUTDEVICELIST)); + gotnum = GetRawInputDeviceList (ridl, &num, sizeof (RAWINPUTDEVICELIST)); if (gotnum <= 0) { write_log (L"RAWINPUT didn't find any devices\n"); goto error2; @@ -788,11 +758,11 @@ static int initialize_rawinput (void) int type = ridl[i].dwType; HANDLE h = ridl[i].hDevice; - if (pGetRawInputDeviceInfo (h, RIDI_DEVICENAME, NULL, &vtmp) == 1) + if (GetRawInputDeviceInfo (h, RIDI_DEVICENAME, NULL, &vtmp) == 1) continue; if (vtmp >= bufsize) continue; - if (pGetRawInputDeviceInfo (h, RIDI_DEVICENAME, buf, &vtmp) == -1) + if (GetRawInputDeviceInfo (h, RIDI_DEVICENAME, buf, &vtmp) == -1) continue; if (rdpdevice (buf)) continue; @@ -814,11 +784,11 @@ static int initialize_rawinput (void) PRID_DEVICE_INFO rdi; int v, j; - if (pGetRawInputDeviceInfo (h, RIDI_DEVICENAME, NULL, &vtmp) == -1) + if (GetRawInputDeviceInfo (h, RIDI_DEVICENAME, NULL, &vtmp) == -1) continue; if (vtmp >= bufsize) continue; - if (pGetRawInputDeviceInfo (h, RIDI_DEVICENAME, buf, &vtmp) == -1) + if (GetRawInputDeviceInfo (h, RIDI_DEVICENAME, buf, &vtmp) == -1) continue; if (did == di_mouse) { @@ -857,11 +827,11 @@ static int initialize_rawinput (void) rdi = (PRID_DEVICE_INFO)buf; memset (rdi, 0, sizeof (RID_DEVICE_INFO)); rdi->cbSize = sizeof (RID_DEVICE_INFO); - if (pGetRawInputDeviceInfo (h, RIDI_DEVICEINFO, NULL, &vtmp) == -1) + if (GetRawInputDeviceInfo (h, RIDI_DEVICEINFO, NULL, &vtmp) == -1) continue; if (vtmp >= bufsize) continue; - if (pGetRawInputDeviceInfo (h, RIDI_DEVICEINFO, buf, &vtmp) == -1) + if (GetRawInputDeviceInfo (h, RIDI_DEVICEINFO, buf, &vtmp) == -1) continue; if (type == RIM_TYPEMOUSE) { @@ -992,6 +962,7 @@ static void handle_rawinput_2 (RAWINPUT *raw) { int i, num; struct didata *did; + int istest = inputdevice_istest (); if (raw->header.dwType == RIM_TYPEMOUSE) { PRAWMOUSE rm = &raw->data.mouse; @@ -1015,14 +986,24 @@ static void handle_rawinput_2 (RAWINPUT *raw) if (num == num_mouse) return; - if (isfocus () > 0) { + if (isfocus () > 0 || istest) { + static int lastx[MAX_INPUT_DEVICES], lasty[MAX_INPUT_DEVICES]; + static int lastmbr[MAX_INPUT_DEVICES], lastmb[MAX_INPUT_DEVICES]; for (i = 0; i < (5 > did->buttons ? did->buttons : 5); i++) { - if (rm->usButtonFlags & (3 << (i * 2))) - setmousebuttonstate (num, i, (rm->usButtonFlags & (1 << (i * 2))) ? 1 : 0); + if (rm->usButtonFlags & (3 << (i * 2))) { + int state = (rm->usButtonFlags & (1 << (i * 2))) ? 1 : 0; + setmousebuttonstate (num, i, state); + lastmb[num] &= ~(1 << i); + if (state) + lastmb[num] |= 1 << i; + } } if (did->buttons > 5) { - for (i = 5; i < did->buttons; i++) - setmousebuttonstate (num, i, (rm->ulRawButtons & (1 << i)) ? 1 : 0); + for (i = 5; i < did->buttons; i++) { + if ((lastmbr[num] & (1 << i)) != (rm->ulRawButtons & (1 << i))) + setmousebuttonstate (num, i, (rm->ulRawButtons & (1 << i)) ? 1 : 0); + } + lastmbr[num] = rm->ulRawButtons; } if (rm->usButtonFlags & RI_MOUSE_WHEEL) { int val = (short)rm->usButtonData; @@ -1033,24 +1014,39 @@ static void handle_rawinput_2 (RAWINPUT *raw) else if (val > 0) setmousebuttonstate (num, bnum + 1, -1); } - setmousestate (num, 0, rm->lLastX, (rm->usFlags & MOUSE_MOVE_ABSOLUTE) ? 1 : 0); - setmousestate (num, 1, rm->lLastY, (rm->usFlags & MOUSE_MOVE_ABSOLUTE) ? 1 : 0); + if (istest) { + if (abs (rm->lLastX - lastx[num]) > 7) { + setmousestate (num, 0, rm->lLastX, (rm->usFlags & (MOUSE_MOVE_ABSOLUTE | MOUSE_VIRTUAL_DESKTOP)) ? 1 : 0); + lastx[num] = rm->lLastX; + lasty[num] = rm->lLastY; + } else if (abs (rm->lLastY - lasty[num]) > 7) { + setmousestate (num, 1, rm->lLastY, (rm->usFlags & (MOUSE_MOVE_ABSOLUTE | MOUSE_VIRTUAL_DESKTOP)) ? 1 : 0); + lastx[num] = rm->lLastX; + lasty[num] = rm->lLastY; + } + } else { + if (rm->lLastX != lastx[num]) + setmousestate (num, 0, rm->lLastX, (rm->usFlags & (MOUSE_MOVE_ABSOLUTE | MOUSE_VIRTUAL_DESKTOP)) ? 1 : 0); + if (rm->lLastY != lasty[num]) + setmousestate (num, 1, rm->lLastY, (rm->usFlags & (MOUSE_MOVE_ABSOLUTE | MOUSE_VIRTUAL_DESKTOP)) ? 1 : 0); + lastx[num] = rm->lLastX; + lasty[num] = rm->lLastY; + } } - if (isfocus ()) { + if (isfocus () && !istest) { if (did->buttons >= 3 && (rm->usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_DOWN)) { if (currprefs.win32_middle_mouse) { if (isfullscreen () > 0) minimizewindow (); if (mouseactive) - setmouseactive(0); + setmouseactive (0); } } } } else if (raw->header.dwType == RIM_TYPEKEYBOARD) { - int istest = inputdevice_istest (); PRAWKEYBOARD rk = &raw->data.keyboard; - uae_u8 scancode = (rk->MakeCode & 0x7f) | ((rk->Flags & RI_KEY_E0) ? 0x80 : 0x00); + int scancode = (rk->MakeCode & 0x7f) | ((rk->Flags & RI_KEY_E0) ? 0x80 : 0x00); int pressed = (rk->Flags & RI_KEY_BREAK) ? 0 : 1; #ifdef DI_DEBUG_RAWINPUT @@ -1074,17 +1070,25 @@ static void handle_rawinput_2 (RAWINPUT *raw) break; } if (num == num_keyboard) { - if (scancode == DIK_F12 && pressed) + if (!istest && scancode == DIK_F12 && pressed) inputdevice_add_inputcode (AKS_ENTERGUI, 1); return; } #endif - num = 0; if (rawkeystate[scancode] == pressed) return; rawkeystate[scancode] = pressed; if (istest) { - inputdevice_do_keyboard (scancode, pressed); + if (pressed && (scancode == DIK_F12 || scancode == DIK_F11)) + return; + if (scancode == DIK_F12) + scancode = -1; + if (scancode == DIK_F11) { + inputdevice_testrecord (IDTYPE_KEYBOARD, num, IDEV_WIDGET_BUTTON, 0x100, 1); + inputdevice_testrecord (IDTYPE_KEYBOARD, num, IDEV_WIDGET_BUTTON, 0x100, 0); + } else { + inputdevice_testrecord (IDTYPE_KEYBOARD, num, IDEV_WIDGET_BUTTON, scancode, pressed); + } } else { scancode = keyhack (scancode, pressed, num); if (scancode < 0 || isfocus () == 0) @@ -1120,12 +1124,12 @@ void handle_rawinput (LPARAM lParam) if (!rawinput_available) return; - pGetRawInputData ((HRAWINPUT)lParam, RID_INPUT, NULL, &dwSize, sizeof (RAWINPUTHEADER)); + GetRawInputData ((HRAWINPUT)lParam, RID_INPUT, NULL, &dwSize, sizeof (RAWINPUTHEADER)); if (dwSize <= sizeof (lpb)) { - if (pGetRawInputData ((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize, sizeof (RAWINPUTHEADER)) == dwSize) { + if (GetRawInputData ((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize, sizeof (RAWINPUTHEADER)) == dwSize) { raw = (RAWINPUT*)lpb; handle_rawinput_2 (raw); - pDefRawInputProc (&raw, 1, sizeof (RAWINPUTHEADER)); + DefRawInputProc (&raw, 1, sizeof (RAWINPUTHEADER)); } } } @@ -1449,10 +1453,6 @@ static BOOL CALLBACK di_enumcallbackj (LPCDIDEVICEINSTANCE lpddi, LPVOID dd) return di_enumcallback2 (lpddi, 1); } -extern HINSTANCE hInst; -static LPDIRECTINPUT8 g_lpdi; - - static void di_dev_free (struct didata *did) { if (did->lpdi) @@ -1478,19 +1478,18 @@ static int di_do_init (void) hr = DirectInput8Create (hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (LPVOID *)&g_lpdi, NULL); if (FAILED(hr)) { write_log (L"DirectInput8Create failed, %s\n", DXError (hr)); - gui_message (L"Failed to initialize DirectInput!"); - return 0; - } - if (dinput_enum_all) { - write_log (L"DirectInput enumeration..\n"); - g_lpdi->EnumDevices (DI8DEVCLASS_ALL, di_enumcallback, 0, DIEDFL_ATTACHEDONLY); } else { - write_log (L"DirectInput enumeration.. Keyboards..\n"); - g_lpdi->EnumDevices (DI8DEVCLASS_KEYBOARD, di_enumcallback, 0, DIEDFL_ATTACHEDONLY); - write_log (L"DirectInput enumeration.. Pointing devices..\n"); - g_lpdi->EnumDevices (DI8DEVCLASS_POINTER, di_enumcallback, 0, DIEDFL_ATTACHEDONLY); - write_log (L"DirectInput enumeration.. Game controllers..\n"); - g_lpdi->EnumDevices (DI8DEVCLASS_GAMECTRL, di_enumcallbackj, 0, DIEDFL_ATTACHEDONLY); + if (dinput_enum_all) { + write_log (L"DirectInput enumeration..\n"); + g_lpdi->EnumDevices (DI8DEVCLASS_ALL, di_enumcallback, 0, DIEDFL_ATTACHEDONLY); + } else { + write_log (L"DirectInput enumeration.. Keyboards..\n"); + g_lpdi->EnumDevices (DI8DEVCLASS_KEYBOARD, di_enumcallback, 0, DIEDFL_ATTACHEDONLY); + write_log (L"DirectInput enumeration.. Pointing devices..\n"); + g_lpdi->EnumDevices (DI8DEVCLASS_POINTER, di_enumcallback, 0, DIEDFL_ATTACHEDONLY); + write_log (L"DirectInput enumeration.. Game controllers..\n"); + g_lpdi->EnumDevices (DI8DEVCLASS_GAMECTRL, di_enumcallbackj, 0, DIEDFL_ATTACHEDONLY); + } } write_log (L"RawInput enumeration..\n"); initialize_rawinput (); @@ -1564,6 +1563,8 @@ static int get_mouse_widget_first (int mouse, int type) return di_mouse[mouse].axles; case IDEV_WIDGET_AXIS: return 0; + case IDEV_WIDGET_BUTTONAXIS: + return di_mouse[mouse].axles + di_mouse[mouse].buttons_real; } return -1; } @@ -1574,9 +1575,14 @@ static int get_mouse_widget_type (int mouse, int num, TCHAR *name, uae_u32 *code int axles = did->axles; int buttons = did->buttons; - if (num >= axles && num < axles + buttons) { + int realbuttons = did->buttons_real; + if (num >= axles + realbuttons && num < axles + buttons) { if (name) - _tcscpy (name, did->buttonname[num - did->axles]); + _tcscpy (name, did->buttonname[num - axles]); + return IDEV_WIDGET_BUTTONAXIS; + } else if (num >= axles && num < axles + realbuttons) { + if (name) + _tcscpy (name, did->buttonname[num - axles]); return IDEV_WIDGET_BUTTON; } else if (num < axles) { if (name) @@ -1664,7 +1670,7 @@ static int acquire_mouse (int num, int flags) } else normalmouse++; } - register_rawinput (); + register_rawinput (flags); return di_mouse[num].acquired > 0 ? 1 : 0; } @@ -2064,7 +2070,7 @@ static int acquire_kb (int num, int flags) normalkb++; di_keyboard[num].acquired = 1; } - register_rawinput (); + register_rawinput (flags); return di_keyboard[num].acquired > 0 ? 1 : 0; } @@ -2146,7 +2152,7 @@ static void read_kb (void) struct didata *did = &di_keyboard[i]; if (!did->acquired) continue; - if (isfocus () == 0) { + if (istest == 0 && isfocus () == 0) { if (did->acquired > 0) unacquire_kb (i); continue; @@ -2160,8 +2166,8 @@ static void read_kb (void) kb_do_refresh &= ~(1 << i); } elements = DI_KBBUFFER; - hr = IDirectInputDevice8_GetDeviceData (lpdi, sizeof(DIDEVICEOBJECTDATA), didod, &elements, 0); - if ((SUCCEEDED (hr) || hr == DI_BUFFEROVERFLOW) && isfocus ()) { + hr = IDirectInputDevice8_GetDeviceData (lpdi, sizeof (DIDEVICEOBJECTDATA), didod, &elements, 0); + if ((SUCCEEDED (hr) || hr == DI_BUFFEROVERFLOW) && (isfocus () || istest)) { if (did->superdevice && (normalkb || rawkb)) continue; for (j = 0; j < elements; j++) { @@ -2174,8 +2180,7 @@ static void read_kb (void) continue; di_keycodes[i][scancode] = pressed; if (istest) { - int q = di_keycodes[i][DIK_LMENU] && di_keycodes[i][DIK_RMENU]; - inputdevice_testrecord (IDTYPE_KEYBOARD, i, IDEV_WIDGET_BUTTON, q ? -1 : scancode, pressed); + inputdevice_testrecord (IDTYPE_KEYBOARD, i, IDEV_WIDGET_BUTTON, scancode, pressed); } else { if (stopoutput == 0) my_kbd_handler (i, scancode, pressed); @@ -2190,7 +2195,7 @@ static void read_kb (void) IDirectInputDevice8_Poll (lpdi); } #ifdef CATWEASEL - if (isfocus ()) { + if (isfocus () || istest) { uae_u8 kc; if (stopoutput == 0 && catweasel_read_keyboard (&kc)) inputdevice_do_keyboard (kc & 0x7f, kc & 0x80); @@ -2249,9 +2254,15 @@ void wait_keyrelease (void) stopoutput--; } -static int get_kb_flags (int kb) +static int get_kb_flags (int num) { - return 0; + if (di_keyboard[num].rawinput) + return 0; + if (di_keyboard[num].catweasel) + return 0; + if (di_keyboard[num].wininput == 1 && !rawinput_available) + return 0; + return 1; } struct inputdevice_functions inputdevicefunc_keyboard = { @@ -2276,7 +2287,11 @@ static int get_joystick_widget_num (int joy) static int get_joystick_widget_type (int joy, int num, TCHAR *name, uae_u32 *code) { struct didata *did = &di_joystick[joy]; - if (num >= did->axles && num < did->axles + did->buttons) { + if (num >= did->axles + did->buttons_real && num < did->axles + did->buttons) { + if (name) + _tcscpy (name, did->buttonname[num - did->axles]); + return IDEV_WIDGET_BUTTONAXIS; + } else if (num >= did->axles && num < did->axles + did->buttons_real) { if (name) _tcscpy (name, did->buttonname[num - did->axles]); return IDEV_WIDGET_BUTTON; @@ -2296,6 +2311,8 @@ static int get_joystick_widget_first (int joy, int type) return di_joystick[joy].axles; case IDEV_WIDGET_AXIS: return 0; + case IDEV_WIDGET_BUTTONAXIS: + return di_joystick[joy].axles + di_joystick[joy].buttons_real; } return -1; } @@ -2318,6 +2335,7 @@ static void read_joystick (void) DWORD elements; HRESULT hr; int i, j, k; + int istest = inputdevice_istest (); if (IGNOREEVERYTHING) return; @@ -2327,7 +2345,7 @@ static void read_joystick (void) if (!did->acquired) continue; if (did->connection == DIDC_CAT) { - if (getjoystickstate (i) && isfocus ()) { + if (getjoystickstate (i) && (isfocus () || istest)) { /* only read CW state if it is really needed */ uae_u8 cdir, cbuttons; if (catweasel_read_joystick (&cdir, &cbuttons)) { @@ -2347,7 +2365,8 @@ static void read_joystick (void) continue; elements = DI_BUFFER; hr = IDirectInputDevice8_GetDeviceData (lpdi, sizeof (DIDEVICEOBJECTDATA), didod, &elements, 0); - if ((SUCCEEDED (hr) || hr == DI_BUFFEROVERFLOW) && isfocus ()) { + if ((SUCCEEDED (hr) || hr == DI_BUFFEROVERFLOW) && (isfocus () || istest)) { + static uae_u16 axisold[MAX_INPUT_DEVICES][256]; for (j = 0; j < elements; j++) { int dimofs = didod[j].dwOfs; int data = didod[j].dwData; @@ -2379,12 +2398,15 @@ static void read_joystick (void) else bstate = data < -20000 ? 1 : 0; } - if (bstate >= 0) + if (bstate >= 0 && axisold[i][k] != bstate) { setjoybuttonstate (i, k, bstate); + axisold[i][k] = bstate; #ifdef DI_DEBUG2 - write_log (L"AB:NUM=%d OFF=%d AXIS=%d DIR=%d NAME=%s VAL=%d STATE=%d\n", - k, dimofs, axis, dir, did->buttonname[k], data, state); + write_log (L"AB:NUM=%d OFF=%d AXIS=%d DIR=%d NAME=%s VAL=%d STATE=%d BS=%d\n", + k, dimofs, axis, dir, did->buttonname[k], data, state, bstate); #endif + } + } else if (did->axisparent[k] < 0 && did->buttonmappings[k] == dimofs) { #ifdef DI_DEBUG2 @@ -2409,7 +2431,18 @@ static void read_joystick (void) if (data < -20000 || data > 20000) write_log (L"A:NUM=%d OFF=%d NAME=%s VAL=%d\n", k, dimofs, did->axisname[k], data); #endif - setjoystickstate (i, k, data, 32768); + if (istest) { + if (data < -20000) + data = -20000; + else if (data > 20000) + data = 20000; + else + data = 0; + } + if (axisold[i][k] != data) { + setjoystickstate (i, k, data, 32768); + axisold[i][k] = data; + } } } } @@ -2554,8 +2587,6 @@ int input_get_default_mouse (struct uae_input_device *uid, int i, int port) if (i >= num_mouse) return 0; did = &di_mouse[i]; - if (did->wininput) - port = 0; uid[i].eventid[ID_AXIS_OFFSET + 0][0] = port ? INPUTEVENT_MOUSE2_HORIZ : INPUTEVENT_MOUSE1_HORIZ; uid[i].eventid[ID_AXIS_OFFSET + 1][0] = port ? INPUTEVENT_MOUSE2_VERT : INPUTEVENT_MOUSE1_VERT; uid[i].eventid[ID_AXIS_OFFSET + 2][0] = port ? 0 : INPUTEVENT_MOUSE1_WHEEL; @@ -2584,8 +2615,6 @@ int input_get_default_lightpen (struct uae_input_device *uid, int i, int port) if (i >= num_mouse) return 0; did = &di_mouse[i]; - if (did->wininput) - port = 0; uid[i].eventid[ID_AXIS_OFFSET + 0][0] = INPUTEVENT_LIGHTPEN_HORIZ; uid[i].eventid[ID_AXIS_OFFSET + 1][0] = INPUTEVENT_LIGHTPEN_VERT; uid[i].eventid[ID_BUTTON_OFFSET + 0][0] = port ? INPUTEVENT_JOY2_3RD_BUTTON : INPUTEVENT_JOY1_3RD_BUTTON; @@ -2594,7 +2623,7 @@ int input_get_default_lightpen (struct uae_input_device *uid, int i, int port) return 0; } -int input_get_default_joystick (struct uae_input_device *uid, int i, int port, int cd32) +int input_get_default_joystick (struct uae_input_device *uid, int i, int port, int mode) { int j; struct didata *did; @@ -2603,7 +2632,10 @@ int input_get_default_joystick (struct uae_input_device *uid, int i, int port, i if (i >= num_joystick) return 0; did = &di_joystick[i]; - if (port >= 2) { + if (mode == JSEM_MODE_MOUSE_CDTV) { + h = INPUTEVENT_MOUSE_CDTV_HORIZ; + v = INPUTEVENT_MOUSE_CDTV_VERT; + } else if (port >= 2) { h = port == 3 ? INPUTEVENT_PAR_JOY2_HORIZ : INPUTEVENT_PAR_JOY1_HORIZ; v = port == 3 ? INPUTEVENT_PAR_JOY2_VERT : INPUTEVENT_PAR_JOY1_VERT; } else { @@ -2631,10 +2663,13 @@ int input_get_default_joystick (struct uae_input_device *uid, int i, int port, i j++; } } - if (cd32) { + if (mode == JSEM_MODE_JOYSTICK_CD32) { uid[i].eventid[ID_BUTTON_OFFSET + 0][0] = port ? INPUTEVENT_JOY2_CD32_RED : INPUTEVENT_JOY1_CD32_RED; - if (isrealbutton (did, 1)) + uid[i].eventid[ID_BUTTON_OFFSET + 0][1] = port ? INPUTEVENT_JOY2_FIRE_BUTTON : INPUTEVENT_JOY1_FIRE_BUTTON; + if (isrealbutton (did, 1)) { uid[i].eventid[ID_BUTTON_OFFSET + 1][0] = port ? INPUTEVENT_JOY2_CD32_BLUE : INPUTEVENT_JOY1_CD32_BLUE; + uid[i].eventid[ID_BUTTON_OFFSET + 1][1] = port ? INPUTEVENT_JOY2_2ND_BUTTON : INPUTEVENT_JOY1_2ND_BUTTON; + } if (isrealbutton (did, 2)) uid[i].eventid[ID_BUTTON_OFFSET + 2][0] = port ? INPUTEVENT_JOY2_CD32_GREEN : INPUTEVENT_JOY1_CD32_GREEN; if (isrealbutton (did, 3)) diff --git a/od-win32/direct3d.cpp b/od-win32/direct3d.cpp index ccb4088d..2bcb844a 100644 --- a/od-win32/direct3d.cpp +++ b/od-win32/direct3d.cpp @@ -418,8 +418,8 @@ int D3D_goodenough (void) d3dx = Direct3DCreate9 (D3D_SDK_VERSION); if (d3dx != NULL) { if (SUCCEEDED (d3dx->GetDeviceCaps (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &d3dCaps))) { - if (d3dCaps.PixelShaderVersion >= D3DPS_VERSION(1, 0) && d3dCaps.VertexShaderVersion >= D3DVS_VERSION(1, 0)) { - if ((d3dCaps.TextureCaps & (D3DPTEXTURECAPS_POW2 | D3DPTEXTURECAPS_NONPOW2CONDITIONAL)) != D3DPTEXTURECAPS_POW2) { + if (d3dCaps.PixelShaderVersion >= D3DPS_VERSION(1, 0)) { + if (((d3dCaps.TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL) == D3DPTEXTURECAPS_NONPOW2CONDITIONAL) || !(d3dCaps.TextureCaps & D3DPTEXTURECAPS_POW2)) { if (!(d3dCaps.TextureCaps & D3DPTEXTURECAPS_SQUAREONLY) && (d3dCaps.Caps2 & D3DCAPS2_DYNAMICTEXTURES)) { d3d_good = 1; shaderon = 1; @@ -1634,12 +1634,12 @@ const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth memset (&dpp, 0, sizeof (dpp)); dpp.Windowed = isfullscreen() <= 0; dpp.BackBufferFormat = mode.Format; - dpp.BackBufferCount = 1; + dpp.BackBufferCount = currprefs.gfx_backbuffers; dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; dpp.BackBufferWidth = w_w; dpp.BackBufferHeight = w_h; - dpp.PresentationInterval = dpp.Windowed ? D3DPRESENT_INTERVAL_IMMEDIATE : D3DPRESENT_INTERVAL_DEFAULT; + dpp.PresentationInterval = dpp.Windowed || currprefs.gfx_backbuffers == 0 ? D3DPRESENT_INTERVAL_IMMEDIATE : D3DPRESENT_INTERVAL_DEFAULT; modeex.Width = w_w; modeex.Height = w_h; @@ -1651,7 +1651,7 @@ const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth if (isfullscreen() > 0) { dpp.FullScreen_RefreshRateInHz = currprefs.gfx_refreshrate > 0 ? currprefs.gfx_refreshrate : 0; modeex.RefreshRate = dpp.FullScreen_RefreshRateInHz; - if (currprefs.gfx_avsync > 0) { + if (currprefs.gfx_avsync) { dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE; if (getvsyncrate (dpp.FullScreen_RefreshRateInHz) != dpp.FullScreen_RefreshRateInHz) { if (d3dCaps.PresentationIntervals & D3DPRESENT_INTERVAL_TWO) @@ -1665,20 +1665,39 @@ const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth d3dhwnd = ahwnd; t_depth = depth; - flags = 0; + flags = D3DCREATE_FPU_PRESERVE; // Check if hardware vertex processing is available - if(d3dCaps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) - flags |= D3DCREATE_HARDWARE_VERTEXPROCESSING; - else + if(d3dCaps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) { + flags |= D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE; + } else { flags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING; - flags |= D3DCREATE_FPU_PRESERVE; - + } if (d3d_ex && D3DEX) { ret = d3dex->CreateDeviceEx (adapter, D3DDEVTYPE_HAL, d3dhwnd, flags, &dpp, dpp.Windowed ? NULL : &modeex, &d3ddevex); d3ddev = d3ddevex; } else { ret = d3d->CreateDevice (adapter, D3DDEVTYPE_HAL, d3dhwnd, flags, &dpp, &d3ddev); } + if (FAILED (ret) && (flags & D3DCREATE_PUREDEVICE)) { + flags &= ~D3DCREATE_PUREDEVICE; + if (d3d_ex && D3DEX) { + ret = d3dex->CreateDeviceEx (adapter, D3DDEVTYPE_HAL, d3dhwnd, flags, &dpp, dpp.Windowed ? NULL : &modeex, &d3ddevex); + d3ddev = d3ddevex; + } else { + ret = d3d->CreateDevice (adapter, D3DDEVTYPE_HAL, d3dhwnd, flags, &dpp, &d3ddev); + } + if (FAILED (ret) && (flags & D3DCREATE_HARDWARE_VERTEXPROCESSING)) { + flags &= ~D3DCREATE_HARDWARE_VERTEXPROCESSING; + flags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING; + if (d3d_ex && D3DEX) { + ret = d3dex->CreateDeviceEx (adapter, D3DDEVTYPE_HAL, d3dhwnd, flags, &dpp, dpp.Windowed ? NULL : &modeex, &d3ddevex); + d3ddev = d3ddevex; + } else { + ret = d3d->CreateDevice (adapter, D3DDEVTYPE_HAL, d3dhwnd, flags, &dpp, &d3ddev); + } + } + } + if (FAILED (ret)) { _stprintf (errmsg, L"%s failed, %s\n", d3d_ex && D3DEX ? L"CreateDeviceEx" : L"CreateDevice", D3D_ErrorString (ret)); if (ret == D3DERR_INVALIDCALL && dpp.Windowed == 0 && dpp.FullScreen_RefreshRateInHz && !ddraw_fs) { @@ -1708,7 +1727,7 @@ const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth max_texture_w = d3dCaps.MaxTextureWidth; max_texture_h = d3dCaps.MaxTextureHeight; - write_log (L"%s: ", D3DHEAD); + write_log (L"%s: %08X ", D3DHEAD, flags); if (d3dCaps.TextureCaps & D3DPTEXTURECAPS_SQUAREONLY) write_log (L"SQUAREONLY "); if (d3dCaps.TextureCaps & D3DPTEXTURECAPS_POW2) diff --git a/od-win32/gencpu_msvc/gencpu_msvc.vcxproj b/od-win32/gencpu_msvc/gencpu_msvc.vcxproj index 5f5ac7bb..49067870 100644 --- a/od-win32/gencpu_msvc/gencpu_msvc.vcxproj +++ b/od-win32/gencpu_msvc/gencpu_msvc.vcxproj @@ -143,6 +143,7 @@ od-win32\gencpu_msvc\gencpu.exe Level3 true Default + Cdecl NDEBUG;%(PreprocessorDefinitions) diff --git a/od-win32/hardfile_win32.cpp b/od-win32/hardfile_win32.cpp index af9d9331..443acab7 100644 --- a/od-win32/hardfile_win32.cpp +++ b/od-win32/hardfile_win32.cpp @@ -481,8 +481,8 @@ int hdf_open_target (struct hardfiledata *hfd, const TCHAR *pname) } } if (hfd->handle_valid || hfd->drive_empty) { - hfd_log (L"HDF '%s' opened, size=%dK mode=%d empty=%d\n", - name, hfd->physsize / 1024, hfd->handle_valid, hfd->drive_empty); + hfd_log (L"HDF '%s' %p opened, size=%dK mode=%d empty=%d\n", + name, hfd, hfd->physsize / 1024, hfd->handle_valid, hfd->drive_empty); return 1; } end: @@ -833,7 +833,7 @@ static int hdf_write_2 (struct hardfiledata *hfd, void *buffer, uae_u64 offset, hdf_seek (hfd, offset); ReadFile (hfd->handle->h, tmp, tmplen, &outlen2, NULL); if (memcmp (hfd->cache, tmp, tmplen) != 0 || outlen != len) - gui_message (L"Harddrive\n%s\nblock zero write failed!", hfd->device_name); + gui_message (L"Harddrive\n%s\nblock zero write failed!", hfd->emptyname == NULL ? L"" : hfd->emptyname); VirtualFree (tmp, 0, MEM_RELEASE); } } diff --git a/od-win32/ioport.cpp b/od-win32/ioport.cpp index 322fa1d3..49e6b819 100644 --- a/od-win32/ioport.cpp +++ b/od-win32/ioport.cpp @@ -161,7 +161,7 @@ int parallel_direct_read_data (uae_u8 *v) { return 0; } #else -#include +#include typedef BOOL (*closePort)(HANDLE); typedef BOOL (*executeCycle)(HANDLE, PARAPORT_CYCLE*, int); diff --git a/od-win32/keyboard_win32.cpp b/od-win32/keyboard_win32.cpp index bdb5400d..5f715d8a 100644 --- a/od-win32/keyboard_win32.cpp +++ b/od-win32/keyboard_win32.cpp @@ -99,7 +99,7 @@ static struct uae_input_device_kbr_default keytrans[] = { { DIK_Y, INPUTEVENT_KEY_Y }, { DIK_Z, INPUTEVENT_KEY_Z }, - { DIK_CAPITAL, INPUTEVENT_KEY_CAPS_LOCK }, + { DIK_CAPITAL, INPUTEVENT_KEY_CAPS_LOCK, ID_FLAG_TOGGLE }, { DIK_NUMPAD1, INPUTEVENT_KEY_NP_1 }, { DIK_NUMPAD2, INPUTEVENT_KEY_NP_2 }, @@ -177,12 +177,17 @@ static struct uae_input_device_kbr_default keytrans[] = { { -1, 0 } }; -static int kb_np[] = { DIK_NUMPAD8, -1, DIK_NUMPAD4, -1, DIK_NUMPAD6, -1, DIK_NUMPAD2, -1, DIK_NUMPAD0, DIK_NUMPAD5, -1, DIK_DECIMAL, DIK_DIVIDE, DIK_NUMPADENTER, -1, -1 }; -static int kb_ck[] = { DIK_UP, -1, DIK_LEFT, -1, DIK_RIGHT, -1, DIK_DOWN, -1, DIK_RCONTROL, DIK_RMENU, -1, DIK_RSHIFT, -1, -1 }; -static int kb_se[] = { DIK_W, -1, DIK_A, -1, DIK_D, -1, DIK_S, -1, DIK_LMENU, -1, DIK_LSHIFT, -1, -1 }; -static int kb_empty[] = { -1, -1 }; -static int kb_cd32[] = { DIK_NUMPAD1, -1, DIK_NUMPAD3, -1, DIK_NUMPAD7, -1, DIK_NUMPAD9, -1, DIK_DIVIDE, -1, DIK_SUBTRACT, -1, DIK_MULTIPLY, -1, -1 }; -static int *kbmaps[] = { kb_np, kb_ck, kb_se, kb_empty, kb_empty, kb_cd32 }; +static int kb_np[] = { DIK_NUMPAD4, -1, DIK_NUMPAD6, -1, DIK_NUMPAD8, -1, DIK_NUMPAD2, -1, DIK_NUMPAD0, DIK_NUMPAD5, -1, DIK_DECIMAL, DIK_DIVIDE, DIK_NUMPADENTER, -1, -1 }; +static int kb_ck[] = { DIK_LEFT, -1, DIK_RIGHT, -1, DIK_UP, -1, DIK_DOWN, -1, DIK_RCONTROL, DIK_RMENU, -1, DIK_RSHIFT, -1, -1 }; +static int kb_se[] = { DIK_A, -1, DIK_D, -1, DIK_W, -1, DIK_S, -1, DIK_LMENU, -1, DIK_LSHIFT, -1, -1 }; +static int kb_cd32_np[] = { DIK_NUMPAD4, -1, DIK_NUMPAD6, -1, DIK_NUMPAD8, -1, DIK_NUMPAD2, -1, DIK_NUMPAD1, -1, DIK_NUMPAD3, -1, DIK_NUMPAD7, -1, DIK_NUMPAD9, -1, DIK_DIVIDE, -1, DIK_SUBTRACT, -1, DIK_MULTIPLY, -1, -1 }; +static int kb_cd32_ck[] = { DIK_LEFT, -1, DIK_RIGHT, -1, DIK_UP, -1, DIK_DOWN, -1, DIK_NUMPAD1, -1, DIK_NUMPAD3, -1, DIK_NUMPAD7, -1, DIK_NUMPAD9, -1, DIK_DIVIDE, -1, DIK_SUBTRACT, -1, DIK_MULTIPLY, -1, -1 }; +static int kb_cd32_se[] = { DIK_A, -1, DIK_D, -1, DIK_W, -1, DIK_S, -1, DIK_NUMPAD1, -1, DIK_NUMPAD3, -1, DIK_NUMPAD7, -1, DIK_NUMPAD9, -1, DIK_DIVIDE, -1, DIK_SUBTRACT, -1, DIK_MULTIPLY, -1, -1 }; +static int kb_xa1[] = { DIK_NUMPAD4, -1, DIK_NUMPAD6, -1, DIK_NUMPAD8, -1, DIK_NUMPAD2, DIK_NUMPAD5, -1, DIK_LCONTROL, -1, DIK_LMENU, -1, DIK_SPACE, -1, -1 }; +static int kb_xa2[] = { DIK_D, -1, DIK_G, -1, DIK_R, -1, DIK_F, -1, DIK_A, -1, DIK_S, -1, DIK_Q, -1 }; +static int kb_arcadia[] = { DIK_F2, -1, DIK_1, -1, DIK_2, -1, DIK_5, -1, DIK_6, -1, -1 }; +static int kb_arcadiaxa[] = { DIK_1, -1, DIK_2, -1, DIK_3, -1, DIK_4, -1, DIK_6, -1, DIK_LBRACKET, DIK_LSHIFT, -1, DIK_RBRACKET, -1, DIK_C, -1, DIK_5, -1, DIK_Z, -1, DIK_X, -1, -1 }; +static int *kbmaps[] = { kb_np, kb_ck, kb_se, kb_cd32_np, kb_cd32_ck, kb_cd32_se, kb_xa1, kb_xa2, kb_arcadia, kb_arcadiaxa }; extern int ispressed (int key); @@ -274,89 +279,13 @@ static int handlearcadia (int scancode, int state) #endif -#ifdef CDTV - -static int handlecdtv (int scancode, int state) -{ - int e = 0; - switch (scancode) - { - case DIK_UP: - if (specialpressed ()) - e = INPUTEVENT_KEY_CDTV_PLAYPAUSE; - break; - case DIK_DOWN: - if (specialpressed ()) - e = INPUTEVENT_KEY_CDTV_STOP; - break; - case DIK_LEFT: - if (specialpressed ()) { - if (shiftpressed ()) - e = INPUTEVENT_KEY_CDTV_REW; - else - e = INPUTEVENT_KEY_CDTV_PREV; - } - break; - case DIK_RIGHT: - if (specialpressed ()) { - if (shiftpressed ()) - e = INPUTEVENT_KEY_CDTV_FF; - else - e = INPUTEVENT_KEY_CDTV_NEXT; - } - break; - } - if (!e) - return 0; - handle_input_event (e, state, 1, 0); - return 1; -} -#endif - -#ifdef CD32 - -static int handlecd32 (int scancode, int state) -{ - int e = 0; - if (!currprefs.cs_cd32cd) - return 0; - switch (scancode) - { - case DIK_NUMPAD7: - e = INPUTEVENT_JOY2_CD32_GREEN; - break; - case DIK_NUMPAD9: - e = INPUTEVENT_JOY2_CD32_YELLOW; - break; - case DIK_NUMPAD1: - e = INPUTEVENT_JOY2_CD32_RED; - break; - case DIK_NUMPAD3: - e = INPUTEVENT_JOY2_CD32_BLUE; - break; - case DIK_DIVIDE: - e = INPUTEVENT_JOY2_CD32_RWD; - break; - case DIK_MULTIPLY: - e = INPUTEVENT_JOY2_CD32_PLAY; - break; - case DIK_SUBTRACT: - e = INPUTEVENT_JOY2_CD32_FFW; - break; - } - if (!e) - return 0; - handle_input_event (e, state, 1, 0); - return 1; -} -#endif - void clearallkeys (void) { inputdevice_updateconfig (&currprefs); } -static int np[] = { DIK_NUMPAD0, 0, DIK_NUMPADPERIOD, 0, DIK_NUMPAD1, 1, DIK_NUMPAD2, 2, +static int np[] = { + DIK_NUMPAD0, 0, DIK_NUMPADPERIOD, 0, DIK_NUMPAD1, 1, DIK_NUMPAD2, 2, DIK_NUMPAD3, 3, DIK_NUMPAD4, 4, DIK_NUMPAD5, 5, DIK_NUMPAD6, 6, DIK_NUMPAD7, 7, DIK_NUMPAD8, 8, DIK_NUMPAD9, 9, -1 }; @@ -552,21 +481,6 @@ void my_kbd_handler (int keyboard, int scancode, int newstate) capslockstate = host_scrolllockstate; } } - - if (currprefs.input_selected_setting == 0) { -#ifdef CD32 - if (handlecd32 (scancode, newstate)) - return; -#endif -#ifdef CDTV - if (handlecdtv (scancode, newstate)) - return; -#endif -#ifdef ARCADIA - if (handlearcadia (scancode, newstate)) - return; -#endif - } if (specialpressed ()) return; diff --git a/od-win32/lib/prowizard.lib b/od-win32/lib/prowizard.lib new file mode 100644 index 00000000..2cb23ec4 Binary files /dev/null and b/od-win32/lib/prowizard.lib differ diff --git a/od-win32/lib/prowizard_x64.lib b/od-win32/lib/prowizard_x64.lib new file mode 100644 index 00000000..925d51f2 Binary files /dev/null and b/od-win32/lib/prowizard_x64.lib differ diff --git a/od-win32/mman.cpp b/od-win32/mman.cpp index 625aa21e..15ba1f50 100644 --- a/od-win32/mman.cpp +++ b/od-win32/mman.cpp @@ -19,7 +19,6 @@ #define MAXZ3MEM64 0xF0000000 static struct shmid_ds shmids[MAX_SHMID]; -static int memwatchok = 0; uae_u8 *natmem_offset, *natmem_offset_end; static uae_u8 *p96mem_offset; static int p96mem_size; @@ -88,113 +87,14 @@ static uae_u32 lowmem (void) return change; } -typedef UINT (CALLBACK* GETWRITEWATCH) - (DWORD,PVOID,SIZE_T,PVOID*,PULONG_PTR,PULONG); -#define TEST_SIZE (2 * 4096) -static int testwritewatch (void) -{ - GETWRITEWATCH pGetWriteWatch; - void *mem; - void *pages[16]; - ULONG_PTR gwwcnt; - ULONG ps; - int ret = 0; - - ps = si.dwPageSize; - - pGetWriteWatch = (GETWRITEWATCH)GetProcAddress (GetModuleHandle (L"kernel32.dll"), "GetWriteWatch"); - if (pGetWriteWatch == NULL) { - write_log (L"GetWriteWatch(): missing!?\n"); - return 0; - } - mem = VirtualAlloc (NULL, TEST_SIZE, MEM_RESERVE | MEM_WRITE_WATCH, PAGE_EXECUTE_READWRITE); - if (mem == NULL) { - write_log (L"GetWriteWatch(): MEM_WRITE_WATCH not supported!? err=%d\n", GetLastError()); - return 0; - } - if (VirtualAlloc (mem, TEST_SIZE, MEM_COMMIT, PAGE_EXECUTE_READWRITE) == NULL) { - write_log (L"GetWriteWatch(): test memory area MEM_COMMIT failed!? err=%d\n", GetLastError()); - goto end; - } - ResetWriteWatch (mem, TEST_SIZE); - ((uae_u8*)mem)[1] = 0; - gwwcnt = TEST_SIZE / ps; - if (GetWriteWatch (WRITE_WATCH_FLAG_RESET, mem, TEST_SIZE, pages, &gwwcnt, &ps)) { - write_log (L"GetWriteWatch(): failed!? err=%d\n", GetLastError ()); - goto end; - } - if (ps != si.dwPageSize) { - write_log (L"GetWriteWatch(): pagesize %d != %d!?\n", si.dwPageSize, ps); - goto end; - } - if (gwwcnt != 1) { - write_log (L"GetWriteWatch(): modified pages returned %d != 1!?\n", gwwcnt); - goto end; - } - if (pages[0] != mem) { - write_log (L"GetWriteWatch(): modified page was wrong!?\n"); - goto end; - } - write_log (L"GetWriteWatch() test ok\n"); - ret = 1; - memwatchok = 1; -end: - if (mem) { - VirtualFree (mem, TEST_SIZE, MEM_DECOMMIT); - VirtualFree (mem, 0, MEM_RELEASE); - } - return ret; -} - -static uae_u8 *memwatchtable; - int mman_GetWriteWatch (PVOID lpBaseAddress, SIZE_T dwRegionSize, PVOID *lpAddresses, PULONG_PTR lpdwCount, PULONG lpdwGranularity) { - int i, j, off; - - if (memwatchok) - return GetWriteWatch (0, lpBaseAddress, dwRegionSize, lpAddresses, lpdwCount, lpdwGranularity); - j = 0; - off = ((uae_u8*)lpBaseAddress - (natmem_offset + p96ram_start)) / si.dwPageSize; - for (i = 0; i < dwRegionSize / si.dwPageSize; i++) { - if (j >= *lpdwCount) - break; - if (memwatchtable[off + i]) - lpAddresses[j++] = (uae_u8*)lpBaseAddress + i * si.dwPageSize; - } - *lpdwCount = j; - *lpdwGranularity = si.dwPageSize; - return 0; + return GetWriteWatch (0, lpBaseAddress, dwRegionSize, lpAddresses, lpdwCount, lpdwGranularity); } void mman_ResetWatch (PVOID lpBaseAddress, SIZE_T dwRegionSize) { - if (memwatchok) { - if (ResetWriteWatch (lpBaseAddress, dwRegionSize)) - write_log (L"ResetWriteWatch() failed, %d\n", GetLastError ()); - } else { - DWORD op; - memset (memwatchtable, 0, p96mem_size / si.dwPageSize); - if (!VirtualProtect (lpBaseAddress, dwRegionSize, PAGE_READWRITE | PAGE_GUARD, &op)) - write_log (L"VirtualProtect() failed, err=%d\n", GetLastError ()); - } -} - -int mman_guard_exception (LPEXCEPTION_POINTERS p) -{ - PEXCEPTION_RECORD record = p->ExceptionRecord; - PCONTEXT context = p->ContextRecord; - ULONG_PTR addr = record->ExceptionInformation[1]; - int rw = record->ExceptionInformation[0]; - ULONG_PTR p96addr = (ULONG_PTR)p96mem_offset; - - if (memwatchok) - return EXCEPTION_CONTINUE_SEARCH; - if (addr < p96addr || addr >= p96addr + p96mem_size) - return EXCEPTION_CONTINUE_EXECUTION; - addr -= p96addr; - addr /= si.dwPageSize; - memwatchtable[addr] = 1; - return EXCEPTION_CONTINUE_EXECUTION; + if (ResetWriteWatch (lpBaseAddress, dwRegionSize)) + write_log (L"ResetWriteWatch() failed, %d\n", GetLastError ()); } static uae_u64 size64; @@ -257,7 +157,6 @@ void preinit_shm (void) } write_log (L"Max Z3FastRAM %dM. Total physical RAM %uM\n", max_z3fastmem >> 20, totalphys64 >> 20); - testwritewatch (); canbang = 1; } @@ -331,14 +230,6 @@ restart: } natmemsize = size + z3size; - xfree (memwatchtable); - memwatchtable = 0; - if (currprefs.gfxmem_size) { - if (!memwatchok) { - write_log (L"GetWriteWatch() not supported, using guard pages, RTG performance will be slower.\n"); - memwatchtable = xcalloc (uae_u8, currprefs.gfxmem_size / si.dwPageSize + 1); - } - } if (currprefs.gfxmem_size) { rtgextra = si.dwPageSize; } else { @@ -368,7 +259,7 @@ restart: goto restart; } p96mem_offset = (uae_u8*)VirtualAlloc (natmem_offset + natmemsize + rtgbarrier, p96mem_size + rtgextra, - MEM_RESERVE | (memwatchok == 1 ? MEM_WRITE_WATCH : 0), PAGE_READWRITE); + MEM_RESERVE | MEM_WRITE_WATCH, PAGE_READWRITE); if (!p96mem_offset) { currprefs.gfxmem_size = changed_prefs.gfxmem_size = 0; write_log (L"NATMEM: failed to allocate special Picasso96 GFX RAM, err=%d\n", GetLastError ()); @@ -531,8 +422,6 @@ void *shmat (int shmid, void *shmaddr, int shmflg) p96ram_start = p96mem_offset - natmem_offset; shmaddr = natmem_offset + p96ram_start; size += BARRIER; - if (!memwatchok) - protect |= PAGE_GUARD; } if(!_tcscmp (shmids[shmid].name, L"bogo")) { shmaddr=natmem_offset+0x00C00000; diff --git a/od-win32/picasso96_win.cpp b/od-win32/picasso96_win.cpp index 949aacd8..577826e7 100644 --- a/od-win32/picasso96_win.cpp +++ b/od-win32/picasso96_win.cpp @@ -74,7 +74,7 @@ int mman_GetWriteWatch (PVOID lpBaseAddress, SIZE_T dwRegionSize, PVOID *lpAddre void mman_ResetWatch (PVOID lpBaseAddress, SIZE_T dwRegionSize); int p96refresh_active; -int have_done_picasso = 1; /* For the JIT compiler */ +bool have_done_picasso = 1; /* For the JIT compiler */ static int p96syncrate; int p96hsync_counter, full_refresh; #if defined(X86_MSVC_ASSEMBLY) @@ -2234,7 +2234,7 @@ static uae_u32 REGPARAM2 picasso_SetSwitch (TrapContext *ctx) /* Do not switch immediately. Tell the custom chip emulation about the * desired state, and wait for custom.c to call picasso_enablescreen * whenever it is ready to change the screen state. */ - picasso_requested_on = flag; + picasso_requested_on = flag != 0; p96text[0] = 0; if (flag) _stprintf (p96text, L"Picasso96 %dx%dx%d (%dx%dx%d)", diff --git a/od-win32/prowizard/prowizard.vcxproj b/od-win32/prowizard/prowizard.vcxproj index fd38fe82..b9e8d405 100644 --- a/od-win32/prowizard/prowizard.vcxproj +++ b/od-win32/prowizard/prowizard.vcxproj @@ -27,7 +27,7 @@ StaticLibrary Unicode - true + false StaticLibrary @@ -60,14 +60,15 @@ <_ProjectFileVersion>10.0.30128.1 - $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Configuration)\..\..\lib\ $(Configuration)\ - $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Configuration)\..\..\lib\ $(Configuration)\ $(SolutionDir)$(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ - $(SolutionDir)$(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\..\..\..\lib\ $(Platform)\$(Configuration)\ + $(ProjectName)_x64 @@ -75,12 +76,18 @@ WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) true EnableFastChecks - MultiThreadedDebugDLL + MultiThreadedDebug Level3 EditAndContinue + ..\..\prowizard\include;..\..\include;%(AdditionalIncludeDirectories) + 4996;%(DisableSpecificWarnings) + + + + @@ -97,14 +104,15 @@ Level3 ProgramDatabase StdCall - CompileAsC + Default 4996;%(DisableSpecificWarnings) - c:\dev\lib\prowizard.lib + $(OutDir)$(TargetName)$(TargetExt) - prowizard_search;%(ExportNamedFunctions) + + @@ -145,7 +153,7 @@ 4996;%(DisableSpecificWarnings) - c:\dev\lib\x64\prowizard.lib + $(OutDir)$(TargetName)$(TargetExt) prowizard_search;%(ExportNamedFunctions) diff --git a/od-win32/resources/resource b/od-win32/resources/resource index 5a71c61f..6e11945e 100644 --- a/od-win32/resources/resource +++ b/od-win32/resources/resource @@ -195,6 +195,7 @@ #define IDS_SOUND_FILTER_EMULATED 207 #define IDS_SOUND_FILTER_EMULATED_E 208 #define IDS_INPUT_COMPATIBILITY 209 +#define IDS_INPUT_GAMEPORTS 209 #define IDS_INPUT_CUSTOM 210 #define IDS_INPUT_COPY_DEFAULT 211 #define IDS_INPUT_COPY_CUSTOM 212 @@ -260,6 +261,8 @@ #define IDS_QS_CD 265 #define IDS_QS_CD_AUTO 266 #define IDS_QS_CD_IMAGE 267 +#define IDS_REMAPTITLE 268 +#define IDS_FILTER_NOOVERLAYS 269 #define IDS_NUMSG_NEEDEXT2 300 #define IDS_NUMSG_NOROMKEY 301 #define IDS_NUMSG_KSROMCRCERROR 302 @@ -323,6 +326,7 @@ #define IDS_PRINTER_POSTSCRIPT_DETECTION 353 #define IDI_EXPANSION 353 #define IDS_PRINTER_POSTSCRIPT_EMULATION 354 +#define IDD_INPUTMAP 354 #define IDS_PRINTER_PASSTHROUGH 355 #define IDS_RES_LORES 356 #define IDS_RES_HIRES 357 @@ -330,6 +334,10 @@ #define IDS_PRINTER_EPSON48 359 #define IDS_SELECTCD 360 #define IDS_CD 361 +#define IDS_BUFFER_SINGLE 362 +#define IDS_BUFFER_DOUBLE 363 +#define IDS_BUFFER_TRIPPLE 364 +#define IDS_BUFFER_TRIPLE 364 #define IDS_QS_MODELS 1000 #define IDS_QS_MODEL_A500 1001 #define IDS_QS_MODEL_A500P 1002 @@ -372,6 +380,7 @@ #define IDC_PORT_TABLET_CURSOR 1028 #define IDC_SHOWLEDSRTG 1028 #define IDC_SAMPLERLIST 1028 +#define IDC_DISPLAY_BUFFERCNT 1028 #define IDC_PORT0_JOYSMODE 1029 #define IDC_SLOWMEM 1030 #define IDC_PORT1_JOYSMODE 1030 @@ -595,11 +604,16 @@ #define IDC_SELECTRESTEXT 1510 #define IDC_FLUSHPRINTER 1510 #define IDC_MAPDRIVES_REMOVABLE 1510 +#define IDC_PORT0_TEST 1510 #define IDC_SCREENRESTEXT 1511 #define IDC_MAPDRIVES_AUTO 1511 +#define IDC_PORT0_TEST2 1511 +#define IDC_PORT1_TEST 1511 #define IDC_WIDTHTEXT 1512 #define IDC_WINDOWEDTEXT 1512 +#define IDC_PORT2_TEST 1512 #define IDC_HEIGHTTEXT 1513 +#define IDC_PORT3_TEST 1513 #define IDC_SETTINGSTEXT 1514 #define IDC_REFRESHTEXT 1515 #define IDC_SETTINGSTEXT2 1515 @@ -760,11 +774,14 @@ #define IDC_FILTERPRESETLOAD 1632 #define IDC_FLOPPYSPDTEXT 1633 #define IDC_FILTERPRESETSAVE 1633 +#define IDC_INPUTREMAP 1633 #define IDC_FLOPPYSPD_TEXT 1634 #define IDC_FILTERPRESETDELETE 1634 +#define IDC_INPUTTEST 1634 #define IDC_HARDDRIVE 1635 #define IDC_INACTIVE_PRI 1635 #define IDC_FILTERVZMULT 1635 +#define IDC_INPUTTEST2 1635 #define IDC_SOUNDPRIMARY 1636 #define IDC_MINIMIZED_PRI 1636 #define IDC_FILTERAUTOSCALE 1636 @@ -1007,13 +1024,22 @@ #define IDC_DD_SURFACETYPE 1791 #define IDC_RTG_SCALE_ALLOW 1791 #define IDC_CPU_FREQUENCY 1791 +#define IDC_PORT0_AUTOFIRE 1791 #define IDC_RTG_SCALE_ASPECTRATIO 1792 #define IDC_ASSOCIATE_ON 1792 #define IDC_DD_SURFACETYPE2 1792 #define IDC_DXMODE 1792 +#define IDC_PORT1_AUTOFIRE 1792 #define IDC_RTG_VBLANKRATE 1793 #define IDC_DF0WPTEXTQ 1793 #define IDC_DF1WPTEXTQ 1794 +#define IDC_INPUTMAPLIST 1797 +#define IDC_PORT1_REMAP 1798 +#define IDC_PORT0_REMAP 1799 +#define IDC_PORT2_REMAP 1800 +#define IDC_PORT3_REMAP 1801 +#define IDC_EDIT1 1801 +#define IDC_INPUTMAPOUT 1801 #define ID__FLOPPYDRIVES 40004 #define ID_FLOPPYDRIVES_DF0 40005 #define ID_ST_CONFIGURATION 40010 @@ -1057,9 +1083,9 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NO_MFC 1 #define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 354 +#define _APS_NEXT_RESOURCE_VALUE 355 #define _APS_NEXT_COMMAND_VALUE 40045 -#define _APS_NEXT_CONTROL_VALUE 1797 +#define _APS_NEXT_CONTROL_VALUE 1802 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/od-win32/resources/winuae.rc b/od-win32/resources/winuae.rc index c052d085..d428acfc 100644 --- a/od-win32/resources/winuae.rc +++ b/od-win32/resources/winuae.rc @@ -28,7 +28,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL IDI_APPICON ICON "winuae.ico" IDI_FLOPPY ICON "35floppy.ico" IDI_ABOUT ICON "amigainfo.ico" -IDI_HARDDISK ICON "Drive.ico" +IDI_HARDDISK ICON "drive.ico" IDI_CPU ICON "cpu.ico" IDI_GAMEPORTS ICON "joystick.ico" IDI_IOPORTS ICON "joystick.ico" @@ -38,7 +38,7 @@ IDI_MISC2 ICON "misc.ico" IDI_MOVE_UP ICON "move_up.ico" IDI_MOVE_DOWN ICON "move_dow.ico" IDI_AVIOUTPUT ICON "avioutput.ico" -IDI_DISK ICON "Drive.ico" +IDI_DISK ICON "drive.ico" IDI_FOLDER ICON "folder.ico" IDI_SOUND ICON "sound.ico" IDI_DISPLAY ICON "screen.ico" @@ -149,6 +149,7 @@ BEGIN CONTROL "Remove interlace artifacts",IDC_FLICKERFIXER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,19,139,99,10 RTEXT "Windowed:",IDC_STATIC,17,46,40,15,SS_CENTERIMAGE RTEXT "Fullscreen:",IDC_STATIC,17,19,40,15,SS_CENTERIMAGE + COMBOBOX IDC_DISPLAY_BUFFERCNT,187,47,87,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP END IDD_MEMORY DIALOGEX 0, 0, 300, 158 @@ -189,10 +190,20 @@ BEGIN CONTROL "68030",IDC_CPU3,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,13,54,64,10 CONTROL "68040",IDC_CPU4,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,13,67,66,10 CONTROL "68060",IDC_CPU5,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,13,80,66,10 + CONTROL "24-bit addressing",IDC_COMPATIBLE24,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_GROUP | WS_TABSTOP,10,94,73,8 CONTROL "More compatible [] Emulate 68000's prefetch registers. More compatible but slower.",IDC_COMPATIBLE, "Button",BS_AUTOCHECKBOX | BS_LEFT | WS_GROUP | WS_TABSTOP,10,107,73,8 CONTROL "JIT [] Enable just-in-time CPU emulator. Significantly increases the speed of the CPU emulation. Requires 68020 or higher CPU.",IDC_JITENABLE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,119,73,10 + CONTROL "68040 MMU [] 68040 MMU emulation. Not compatible with JIT.",IDC_MMUENABLE, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,132,73,10 + GROUPBOX "FPU",IDC_STATIC,5,147,81,90,BS_LEFT + CONTROL "None",IDC_FPU0,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,14,161,63,10 + CONTROL "68881",IDC_FPU1,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,14,175,63,10 + CONTROL "68882",IDC_FPU2,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,14,188,63,10 + CONTROL "CPU internal",IDC_FPU3,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,14,202,63,10 + CONTROL "More compatible [] More compatible but slower FPU emulation.",IDC_COMPATIBLE_FPU, + "Button",BS_AUTOCHECKBOX | BS_LEFT | WS_GROUP | WS_TABSTOP,9,221,73,10 GROUPBOX "CPU Emulation Speed",IDC_STATIC,90,3,205,92 CONTROL "Fastest possible, but maintain chipset timing",IDC_CS_HOST, "Button",BS_AUTORADIOBUTTON | BS_LEFT | WS_GROUP | WS_TABSTOP,95,18,195,10 @@ -200,35 +211,25 @@ BEGIN "Button",BS_AUTORADIOBUTTON | BS_LEFT | WS_TABSTOP,95,32,195,10 CONTROL "Adjustable between CPU and chipset",IDC_CS_ADJUSTABLE, "Button",BS_AUTORADIOBUTTON | BS_LEFT | WS_TABSTOP,95,46,195,10 + RTEXT "CPU",IDC_STATIC,96,77,17,10,SS_CENTERIMAGE CONTROL "Slider1",IDC_SPEED,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,114,71,67,20 + RTEXT "Chipset",IDC_STATIC,182,77,26,9,SS_CENTERIMAGE CONTROL "",IDC_CPUIDLE,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,219,71,69,20 + RTEXT "CPU Idle",IDC_STATIC,231,60,47,9,SS_CENTERIMAGE + GROUPBOX "Cycle-exact CPU Emulation Speed",IDC_STATIC,90,99,205,46 + RTEXT "CPU Frequency",IDC_STATIC,105,119,51,10,SS_CENTERIMAGE + COMBOBOX IDC_CPU_FREQUENCY,165,118,46,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + EDITTEXT IDC_CPU_FREQUENCY2,218,117,70,15 GROUPBOX "Advanced JIT Settings",IDC_STATIC,90,147,205,91 + RTEXT "Cache size:",IDC_STATIC,95,167,42,10,SS_CENTERIMAGE CONTROL "Slider1",IDC_CACHE,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,140,161,115,20 EDITTEXT IDC_CACHETEXT,255,166,30,12,ES_CENTER | ES_READONLY CONTROL "Hard flush",IDC_HARDFLUSH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,100,194,63,10 - CONTROL "Constant jump",IDC_CONSTJUMP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,100,208,63,10 - CONTROL "FPU support",IDC_JITFPU,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,100,222,62,10 CONTROL "No flags",IDC_NOFLAGS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,168,194,62,10 CONTROL "Direct",IDC_TRUST0,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,235,194,52,10 + CONTROL "Constant jump",IDC_CONSTJUMP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,100,208,63,10 + CONTROL "FPU support",IDC_JITFPU,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,100,222,62,10 CONTROL "Indirect",IDC_TRUST1,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,235,208,52,10 - CONTROL "More compatible [] More compatible but slower FPU emulation.",IDC_COMPATIBLE_FPU, - "Button",BS_AUTOCHECKBOX | BS_LEFT | WS_GROUP | WS_TABSTOP,9,221,73,10 - GROUPBOX "FPU",IDC_STATIC,5,147,81,90,BS_LEFT - CONTROL "24-bit addressing",IDC_COMPATIBLE24,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_GROUP | WS_TABSTOP,10,94,73,8 - CONTROL "None",IDC_FPU0,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,14,161,63,10 - CONTROL "68881",IDC_FPU1,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,14,175,63,10 - CONTROL "68882",IDC_FPU2,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,14,188,63,10 - CONTROL "CPU internal",IDC_FPU3,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,14,202,63,10 - RTEXT "CPU Frequency",IDC_STATIC,105,119,51,10,SS_CENTERIMAGE - GROUPBOX "Cycle-exact CPU Emulation Speed",IDC_STATIC,90,99,205,46 - RTEXT "CPU",IDC_STATIC,96,77,17,10,SS_CENTERIMAGE - RTEXT "Chipset",IDC_STATIC,182,77,26,9,SS_CENTERIMAGE - RTEXT "CPU Idle",IDC_STATIC,231,60,47,9,SS_CENTERIMAGE - RTEXT "Cache size:",IDC_STATIC,95,167,42,10,SS_CENTERIMAGE - CONTROL "68040 MMU [] 68040 MMU emulation. Not compatible with JIT.",IDC_MMUENABLE, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,132,73,10 - COMBOBOX IDC_CPU_FREQUENCY,165,118,46,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - EDITTEXT IDC_CPU_FREQUENCY2,218,117,70,15 END IDD_FLOPPY DIALOGEX 0, 0, 300, 240 @@ -348,7 +349,7 @@ IDD_LOADSAVE DIALOGEX 0, 0, 302, 241 STYLE DS_LOCALEDIT | DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN - CONTROL "",IDC_CONFIGTREE,"SysTreeView32",TVS_HASLINES | TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP,6,3,289,153,WS_EX_CLIENTEDGE + CONTROL "",IDC_CONFIGTREE,"SysTreeView32",TVS_HASLINES | TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | TVS_TRACKSELECT | WS_BORDER | WS_HSCROLL | WS_TABSTOP,6,3,289,153,WS_EX_CLIENTEDGE RTEXT "Name:",IDC_STATIC,4,161,40,15,SS_CENTERIMAGE EDITTEXT IDC_EDITNAME,48,162,146,13,ES_AUTOHSCROLL RTEXT "Description:",IDC_STATIC,2,182,41,15,SS_CENTERIMAGE @@ -400,31 +401,41 @@ BEGIN COMBOBOX IDC_SAMPLERLIST,49,85,232,134,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP END -IDD_GAMEPORTS DIALOGEX 0, 0, 300, 236 +IDD_GAMEPORTS DIALOGEX 0, 0, 300, 246 STYLE DS_LOCALEDIT | DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN - COMBOBOX IDC_PORT0_JOYS,45,29,241,130,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_PORT1_JOYS,45,65,241,130,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Swap port 0 and 1",IDC_SWAP,194,101,93,14 - RTEXT "Port 0:",IDC_STATIC,11,28,25,15,SS_CENTERIMAGE - RTEXT "Port 1:",IDC_STATIC,11,64,25,15,SS_CENTERIMAGE - LTEXT "X-Arcade layout information []#1",IDC_STATIC,64,87,106,15,SS_NOTIFY | SS_CENTERIMAGE - GROUPBOX "Mouse and Joystick settings",IDC_STATIC,4,15,292,148 - GROUPBOX "Mouse extra settings",IDC_STATIC,4,165,292,69 - RTEXT "Mouse speed:",IDC_STATIC,17,180,56,10,SS_CENTERIMAGE - EDITTEXT IDC_INPUTSPEEDM,87,180,25,12,ES_NUMBER - CONTROL "Install virtual mouse driver",IDC_PORT_TABLET,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,167,187,120,10 + GROUPBOX "Mouse and Joystick settings",IDC_STATIC,0,3,299,181 + RTEXT "Port 0:",IDC_STATIC,11,16,25,15,SS_CENTERIMAGE + COMBOBOX IDC_PORT0_JOYS,45,17,241,130,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_PORT0_JOYSMODE,104,35,87,130,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "Test [] Test Port 0 (mouse) configuration.",IDC_PORT0_TEST,196,35,44,14 + PUSHBUTTON "Remap [] Remap Port 0 configurarion.",IDC_PORT0_REMAP,245,35,41,14 + RTEXT "Port 1:",IDC_STATIC,11,52,25,15,SS_CENTERIMAGE + COMBOBOX IDC_PORT1_JOYS,45,53,241,130,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "Swap ports [] Swap ports 0 and 1.",IDC_SWAP,113,93,53,14 + COMBOBOX IDC_PORT1_JOYSMODE,104,70,88,130,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "Test [] Test Port 1 (joystick) configuration.",IDC_PORT1_TEST,196,70,44,14 + PUSHBUTTON "Remap [] Remap Port 1 configuration.",IDC_PORT1_REMAP,245,70,41,14 + LTEXT "Parallel port joystick adapter",IDC_STATIC,10,96,95,15,SS_CENTERIMAGE + LTEXT "X-Arcade layout information []#1",IDC_STATIC,177,96,109,15,SS_NOTIFY | SS_CENTERIMAGE + COMBOBOX IDC_PORT2_JOYS,45,114,241,130,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "Test [] Test Parallel port joystick port 0 configuration.",IDC_PORT2_TEST,196,131,44,14 + PUSHBUTTON "Remap [] Remap Parallel port joystick port 0 configurarion.",IDC_PORT2_REMAP,245,131,41,14 + COMBOBOX IDC_PORT3_JOYS,45,149,241,130,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "Test [] Test Parallel port joystick 1 configuration.",IDC_PORT3_TEST,196,165,44,14 + PUSHBUTTON "Remap [] Remap Parallel port joystick port 1 configurarion.",IDC_PORT3_REMAP,245,165,41,14 + GROUPBOX "Mouse extra settings",IDC_STATIC,0,186,299,60 + RTEXT "Mouse speed:",IDC_STATIC,17,200,56,10,SS_CENTERIMAGE + RTEXT "Magic Mouse cursor mode:",IDC_STATIC,17,217,138,10,SS_CENTERIMAGE + CONTROL "Install virtual mouse driver",IDC_PORT_TABLET,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,233,120,10 + EDITTEXT IDC_INPUTSPEEDM,87,200,25,12,ES_NUMBER + CONTROL "Magic Mouse",IDC_PORT_MOUSETRICK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,167,198,119,10 + COMBOBOX IDC_PORT_TABLET_CURSOR,167,214,119,130,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CONTROL "Full tablet input emulation",IDC_PORT_TABLET_FULL, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,167,220,121,10 - CONTROL "Magic Mouse",IDC_PORT_MOUSETRICK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,167,175,119,10 - COMBOBOX IDC_PORT_TABLET_CURSOR,167,201,119,130,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - RTEXT "Magic Mouse cursor mode:",IDC_STATIC,17,204,138,10,SS_CENTERIMAGE - COMBOBOX IDC_PORT0_JOYSMODE,195,47,91,130,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_PORT1_JOYSMODE,195,82,91,130,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_PORT2_JOYS,45,125,241,130,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Parallel port joystick adapter",IDC_STATIC,10,105,147,15,SS_CENTERIMAGE - COMBOBOX IDC_PORT3_JOYS,45,143,241,130,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,167,233,121,10 + CONTROL "Autofire",IDC_PORT0_AUTOFIRE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,46,37,53,10 + CONTROL "Autofire",IDC_PORT1_AUTOFIRE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,46,72,53,10 END IDD_CONTRIBUTORS DIALOGEX 0, 0, 411, 242 @@ -702,18 +713,20 @@ IDD_INPUT DIALOGEX 0, 0, 300, 242 STYLE DS_LOCALEDIT | DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN + CONTROL "List1",IDC_INPUTLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,22,290,146 COMBOBOX IDC_INPUTTYPE,5,5,98,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_INPUTDEVICE,109,5,167,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP CONTROL "",IDC_INPUTDEVICEDISABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,282,8,9,8 - CONTROL "List1",IDC_INPUTLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,22,290,146 COMBOBOX IDC_INPUTAMIGACNT,5,174,24,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_INPUTAMIGA,33,174,262,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_INPUTAMIGA,33,174,202,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "Test [] Test input mappings.",IDC_INPUTTEST,240,175,26,14 + PUSHBUTTON "Remap [] Find and remap quickly.",IDC_INPUTREMAP,267,175,30,14 RTEXT "Joystick dead zone (%):",-1,4,196,79,10,SS_CENTERIMAGE EDITTEXT IDC_INPUTDEADZONE,88,195,25,12,ES_NUMBER - RTEXT "Autofire rate (frames):",-1,4,212,79,10,SS_CENTERIMAGE - EDITTEXT IDC_INPUTAUTOFIRERATE,88,210,25,12,ES_NUMBER RTEXT "Digital joy-mouse speed:",-1,117,196,88,10,SS_CENTERIMAGE EDITTEXT IDC_INPUTSPEEDD,210,195,25,12,ES_NUMBER + RTEXT "Autofire rate (lines)",-1,4,212,79,10,SS_CENTERIMAGE + EDITTEXT IDC_INPUTAUTOFIRERATE,88,210,25,12,ES_NUMBER RTEXT "Analog joy-mouse speed:",-1,117,212,88,10,SS_CENTERIMAGE EDITTEXT IDC_INPUTSPEEDA,210,211,25,12,ES_NUMBER PUSHBUTTON "Copy from:",IDC_INPUTCOPY,240,195,56,14 @@ -725,7 +738,7 @@ IDD_FILTER DIALOGEX 0, 0, 296, 241 STYLE DS_LOCALEDIT | DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN - GROUPBOX "Filter Settings",-1,0,1,294,199 + GROUPBOX "Filter Settings",-1,0,1,295,134 COMBOBOX IDC_FILTERMODE,20,15,103,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_FILTERFILTER,132,15,83,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Reset to defaults",IDC_FILTERDEFAULT,221,15,67,14 @@ -741,8 +754,7 @@ BEGIN RTEXT "Vert. position:",-1,5,120,55,10,SS_CENTERIMAGE CONTROL "Slider1",IDC_FILTERVO,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,99,114,151,19 EDITTEXT IDC_FILTERVOV,253,116,34,12,ES_CENTER | ES_READONLY - RTEXT "Extra settings:",-1,105,135,57,10,SS_CENTERIMAGE - CONTROL "Slider1",IDC_FILTERXL,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,99,174,151,19 + CONTROL "Slider1",IDC_FILTERXL,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,107,174,141,19 EDITTEXT IDC_FILTERXLV,253,176,34,12,ES_CENTER | ES_READONLY COMBOBOX IDC_FILTERSLR,253,151,33,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP GROUPBOX "Presets",-1,0,203,296,36 @@ -754,10 +766,12 @@ BEGIN COMBOBOX IDC_FILTERVZMULT,59,80,35,150,CBS_DROPDOWN | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_FILTERXTRA,105,151,138,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_FILTERASPECT,14,151,73,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP - CONTROL "Keep aspect ratio",IDC_FILTERKEEPASPECT,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_GROUP | WS_TABSTOP,14,168,85,10 + CONTROL "Keep aspect ratio",IDC_FILTERKEEPASPECT,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_GROUP | WS_TABSTOP,14,168,77,10 COMBOBOX IDC_FILTERAUTOSCALE,132,36,83,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_FILTERASPECT2,14,180,73,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_FILTEROVERLAY,20,36,103,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP + GROUPBOX "Aspect Ratio Correction",-1,3,138,92,65 + GROUPBOX "Extra Settings",-1,101,137,194,65 END IDD_HARDDRIVE DIALOGEX 0, 0, 380, 76 @@ -816,7 +830,7 @@ CAPTION "WinUAE Properties" FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN GROUPBOX "",IDC_PANEL_FRAME,112,4,303,247,NOT WS_VISIBLE - CONTROL "",IDC_PANELTREE,"SysTreeView32",TVS_HASLINES | TVS_SHOWSELALWAYS | TVS_NOSCROLL | WS_BORDER | WS_HSCROLL | WS_TABSTOP,5,5,101,248,WS_EX_CLIENTEDGE + CONTROL "",IDC_PANELTREE,"SysTreeView32",TVS_HASLINES | TVS_SHOWSELALWAYS | TVS_TRACKSELECT | TVS_NOSCROLL | TVS_NOHSCROLL | WS_BORDER | WS_TABSTOP,5,5,101,248,WS_EX_CLIENTEDGE GROUPBOX "",IDC_PANEL_FRAME_OUTER,110,2,307,251 PUSHBUTTON "Reset",IDC_RESETAMIGA,5,259,47,14 PUSHBUTTON "Quit",IDC_QUITEMU,55,259,47,14 @@ -835,6 +849,7 @@ BEGIN PUSHBUTTON "...",IDC_PATHS_ROMS,281,15,11,15 LTEXT "Configuration files:",IDC_PATHS_CONFIGL,14,32,121,8,SS_CENTERIMAGE EDITTEXT IDC_PATHS_CONFIG,14,42,261,15,ES_AUTOHSCROLL + CONTROL "Cache Configuration files",IDC_PATHS_CONFIGCACHE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,177,32,97,10 PUSHBUTTON "...",IDC_PATHS_CONFIGS,281,42,11,15 LTEXT "Screenshots:",IDC_PATHS_SCREENSHOTL,14,59,260,8,SS_CENTERIMAGE EDITTEXT IDC_PATHS_SCREENSHOT,14,69,261,15,ES_AUTOHSCROLL @@ -853,7 +868,6 @@ BEGIN PUSHBUTTON "Clear registry",IDC_RESETREGISTRY,111,212,92,14 COMBOBOX IDC_PATHS_DEFAULTTYPE,111,197,163,150,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Clear disk history",IDC_RESETDISKHISTORY,14,228,92,14 - CONTROL "Cache Configuration files",IDC_PATHS_CONFIGCACHE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,177,32,97,10 LTEXT "Rips:",IDC_PATHS_RIPSL,13,168,261,8,SS_CENTERIMAGE EDITTEXT IDC_PATHS_RIP,13,178,261,15,ES_AUTOHSCROLL PUSHBUTTON "...",IDC_PATHS_RIPS,280,178,11,15 @@ -918,9 +932,9 @@ STYLE DS_LOCALEDIT | DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAP CAPTION "Enter text..." FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN + EDITTEXT IDC_STRINGBOXEDIT,7,17,214,14,ES_AUTOHSCROLL | ES_WANTRETURN DEFPUSHBUTTON "OK",IDOK,48,39,50,14 PUSHBUTTON "Cancel",IDCANCEL,151,39,50,14 - EDITTEXT IDC_STRINGBOXEDIT,7,17,214,14,ES_AUTOHSCROLL | ES_WANTRETURN END IDD_DEBUGGER DIALOGEX 0, 0, 454, 368 @@ -1005,6 +1019,14 @@ BEGIN GROUPBOX "Miscellaneous Expansions",IDC_STATIC,5,130,117,66 END +IDD_INPUTMAP DIALOGEX 0, 0, 300, 240 +STYLE DS_LOCALEDIT | DS_SETFONT | DS_3DLOOK | DS_CONTROL | WS_CHILD +FONT 8, "MS Sans Serif", 0, 0, 0x1 +BEGIN + CONTROL "",IDC_INPUTMAPLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,0,1,299,215 + EDITTEXT IDC_INPUTMAPOUT,0,222,299,14,ES_AUTOHSCROLL | WS_DISABLED +END + ///////////////////////////////////////////////////////////////////////////// // @@ -1012,8 +1034,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,1,0,0 - PRODUCTVERSION 2,1,0,0 + FILEVERSION 2,2,0,0 + PRODUCTVERSION 2,2,0,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -1029,12 +1051,12 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "FileDescription", "WinUAE" - VALUE "FileVersion", "2.1.0.0" + VALUE "FileVersion", "2.2.0.0" VALUE "InternalName", "WinUAE" VALUE "LegalCopyright", "© 1996-2010 under the GNU Public License (GPL)" VALUE "OriginalFilename", "WinUAE.exe" VALUE "ProductName", "WinUAE" - VALUE "ProductVersion", "2.1.0.0" + VALUE "ProductVersion", "2.2.0.0" END END BLOCK "VarFileInfo" @@ -1153,10 +1175,18 @@ IDB_LCD160X43 BITMAP "lcd.bmp" #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO BEGIN + IDD_DISPLAY, DIALOG + BEGIN + END + IDD_CPU, DIALOG BEGIN END + IDD_LOADSAVE, DIALOG + BEGIN + END + IDD_IOPORTS, DIALOG BEGIN END @@ -1165,6 +1195,10 @@ BEGIN BEGIN END + IDD_ABOUT, DIALOG + BEGIN + END + IDD_MISC1, DIALOG BEGIN END @@ -1186,9 +1220,26 @@ BEGIN BEGIN END + IDD_PANEL, DIALOG + BEGIN + END + + IDD_PATHS, DIALOG + BEGIN + END + IDD_FRONTEND, DIALOG BEGIN END + + IDD_STRINGBOX, DIALOG + BEGIN + END + + IDD_INPUTMAP, DIALOG + BEGIN + TOPMARGIN, 1 + END END #endif // APSTUDIO_INVOKED @@ -1273,7 +1324,6 @@ BEGIN IDS_INVALIDPRTPORT "The printer you have in this configuration is not valid on this machine.\n" IDS_RESTOREUSS "Restore a WinUAE snapshot file" IDS_USS "WinUAE snapshot files" - IDS_WRONGOSVERSION "WinUAE is no longer supported on Windows NT. Please upgrade to either Windows 2000 or Windows XP or a later version." IDS_SELECTFLASH "Select a flash or battery-backed RAM file..." IDS_FLASH "WinUAE flash or battery-backed RAM file" IDS_INPUTHOSTWIDGET "Input source" @@ -1332,6 +1382,8 @@ BEGIN IDS_QS_CD "CD" IDS_QS_CD_AUTO "Autodetect" IDS_QS_CD_IMAGE "Image file" + IDS_REMAPTITLE "Input captured. F12 = Exit. F11 = Skip curent event in Remap mode." + IDS_FILTER_NOOVERLAYS "No overlays available" END STRINGTABLE @@ -1374,13 +1426,13 @@ END STRINGTABLE BEGIN IDS_SOUND_FILTER_EMULATED_E "Emulated (A1200)" - IDS_INPUT_COMPATIBILITY "Compatibility mode" + IDS_INPUT_GAMEPORTS "Game Ports Panel" IDS_INPUT_CUSTOM "Configuration #%d" - IDS_INPUT_COPY_DEFAULT "Default" + IDS_INPUT_COPY_DEFAULT "GamePorts" IDS_INPUT_COPY_CUSTOM "Config #%d" IDS_3D_NO_FILTER "Point (%d-bit)" IDS_3D_BILINEAR "Bilinear (%d-bit)" - IDS_VSYNC_DEFAULT "Default" + IDS_VSYNC_DEFAULT "Default refresh rate" IDS_DRIVESOUND_NONE "No sound" IDS_DRIVESOUND_DEFAULT_A500 "A500 (WinUAE built-in)" IDS_AVIOUTPUT_NOCODEC "no codec selected" @@ -1534,6 +1586,9 @@ BEGIN IDS_PRINTER_EPSON48 "Epson Matrix Printer Emulation, 48pin" IDS_SELECTCD "Select a CD image file..." IDS_CD "CD image files" + IDS_BUFFER_SINGLE "No buffering" + IDS_BUFFER_DOUBLE "Double buffering" + IDS_BUFFER_TRIPLE "Triple buffering" END #endif // English resources diff --git a/od-win32/sounddep/sound.cpp b/od-win32/sounddep/sound.cpp index e09b1711..8f5a8945 100644 --- a/od-win32/sounddep/sound.cpp +++ b/od-win32/sounddep/sound.cpp @@ -85,12 +85,14 @@ struct sound_dp HANDLE paevent; int opacounter; int pablocking; + int pavolume; // wasapi IMMDevice *pDevice; IAudioClient *pAudioClient; IAudioRenderClient *pRenderClient; + ISimpleAudioVolume *pAudioVolume; IMMDeviceEnumerator *pEnumerator; #if 0 IAudioClock *pAudioClock; @@ -341,19 +343,33 @@ extern void setvolume_ahi (LONG); void set_volume_sound_device (struct sound_data *sd, int volume, int mute) { struct sound_dp *s = sd->data; + HRESULT hr; if (sd->devicetype == SOUND_DEVICE_AL) { float vol = 0.0; if (volume < 100 && !mute) vol = (100 - volume) / 100.0; alSourcef (s->al_Source, AL_GAIN, vol); } else if (sd->devicetype == SOUND_DEVICE_DS) { - HRESULT hr; LONG vol = DSBVOLUME_MIN; if (volume < 100 && !mute) vol = (LONG)((DSBVOLUME_MIN / 2) + (-DSBVOLUME_MIN / 2) * log (1 + (2.718281828 - 1) * (1 - volume / 100.0))); hr = IDirectSoundBuffer_SetVolume (s->lpDSBsecondary, vol); if (FAILED (hr)) write_log (L"DSSOUND: SetVolume(%d) failed: %s\n", vol, DXError (hr)); + } else if (sd->devicetype == SOUND_DEVICE_WASAPI) { + if (s->pAudioVolume) { + float vol = 0.0; + if (volume < 100 && !mute) + vol = (100 - volume) / 100.0; + hr = s->pAudioVolume->SetMasterVolume (vol, NULL); + if (FAILED (hr)) + write_log (L"AudioVolume->SetMasterVolume(%.2f) failed: %08Xs\n", vol, hr); + hr = s->pAudioVolume->SetMute (mute, NULL); + if (FAILED (hr)) + write_log (L"pAudioVolume->SetMute(%d) failed: %08Xs\n", mute, hr); + } + } else if (sd->devicetype == SOUND_DEVICE_PA) { + s->pavolume = volume; } } @@ -462,6 +478,13 @@ static DWORD fillsupportedmodes (struct sound_data *sd, int freq, struct dsaudio static void finish_sound_buffer_pa (struct sound_data *sd, uae_u16 *sndbuffer) { struct sound_dp *s = sd->data; + if (s->pavolume) { + int vol = 65536 - s->pavolume * 655; + for (int i = 0; i < sd->sndbufsize / sizeof (uae_u16); i++) { + uae_s16 v = (uae_s16)sndbuffer[i]; + sndbuffer[i] = v * vol / 65536; + } + } if (s->pablocking) { if (s->paframesperbuffer != sd->sndbufsize / (sd->channels * 2)) { write_log (L"sound buffer size mistmatch %d <> %d\n", s->paframesperbuffer, sd->sndbufsize / (sd->channels * 2)); @@ -469,7 +492,8 @@ static void finish_sound_buffer_pa (struct sound_data *sd, uae_u16 *sndbuffer) Pa_WriteStream (s->pastream, sndbuffer, s->paframesperbuffer); } } else { - while (s->opacounter == s->pacounter && s->pastream && !sd->paused) + int cnt = 2000 / 10; + while (s->opacounter == s->pacounter && s->pastream && !sd->paused && cnt-- >= 0) WaitForSingleObject (s->paevent, 10); s->opacounter = s->pacounter; memcpy (s->pasoundbuffer[s->patoggle], sndbuffer, sd->sndbufsize); @@ -688,6 +712,8 @@ static void close_audio_wasapi (struct sound_data *sd) if (s->pRenderClient) s->pRenderClient->Release (); + if (s->pAudioVolume) + s->pAudioVolume->Release (); #if 0 if (s->pAudioClock) s->pAudioClock->Release (); @@ -919,6 +945,11 @@ static int open_audio_wasapi (struct sound_data *sd, int index, int exclusive) write_log (L"WASAPI: GetService(IAudioRenderClient) %08X\n", hr); goto error; } + hr = s->pAudioClient->GetService (__uuidof(ISimpleAudioVolume), (void**)&s->pAudioVolume ); + if (FAILED (hr)) { + write_log (L"WASAPI: GetService(ISimpleAudioVolume) %08X\n", hr); + goto error; + } #if 0 hr = s->pAudioClient->GetService (IAudioClock, (void**)&s->pAudioClock); if (FAILED (hr)) { @@ -1577,7 +1608,6 @@ static void finish_sound_buffer_wasapi (struct sound_data *sd, uae_u16 *sndbuffe struct sound_dp *s = sd->data; HRESULT hr; BYTE *pData; - DWORD v; double skipmode; UINT32 numFramesPadding; int avail; diff --git a/od-win32/srcrelease.cmd b/od-win32/srcrelease.cmd index 01dae5da..301ad6d4 100644 --- a/od-win32/srcrelease.cmd +++ b/od-win32/srcrelease.cmd @@ -35,6 +35,7 @@ del cpuemu_0.cpp del cpuemu_11.cpp del cpuemu_12.cpp del cpuemu_20.cpp +del cpuemu_21.cpp del cpuemu_31.cpp del linetoscr.cpp @@ -63,6 +64,12 @@ rm -rf release rm -rf x64 cd .. +cd unpackers +rm -rf debug +rm -rf release +rm -rf x64 +cd .. + cd genlinetoscr_msvc rm -f genlinetoscr.exe rm -rf debug diff --git a/od-win32/sysconfig.h b/od-win32/sysconfig.h index b158afbb..ff568d3c 100644 --- a/od-win32/sysconfig.h +++ b/od-win32/sysconfig.h @@ -48,7 +48,8 @@ #define CPUEMU_0 /* generic 680x0 emulation */ #define CPUEMU_11 /* 68000+prefetch emulation */ #define CPUEMU_12 /* 68000 cycle-exact cpu&blitter */ -#define CPUEMU_20 /* 68020+ "cycle-exact" + blitter */ +#define CPUEMU_20 /* 68020 "cycle-exact" + blitter */ +#define CPUEMU_21 /* 68030 (040/060) "cycle-exact" + blitter */ #define CPUEMU_31 /* 68040 Aranym MMU */ #define ACTION_REPLAY /* Action Replay 1/2/3 support */ #define PICASSO96 /* Picasso96 display card emulation */ diff --git a/od-win32/uaeunp/uaeunp.vcxproj b/od-win32/uaeunp/uaeunp.vcxproj index 4c762b53..2c602b1f 100644 --- a/od-win32/uaeunp/uaeunp.vcxproj +++ b/od-win32/uaeunp/uaeunp.vcxproj @@ -57,13 +57,15 @@ Level3 EditAndContinue Default + StdCall - zlibstat.lib;wininet.lib;%(AdditionalDependencies) + zlibstat.lib;wininet.lib;lzmalib.lib;%(AdditionalDependencies) true Console false MachineX86 + $(SolutionDir)\..\lib\ @@ -78,25 +80,23 @@ Level3 ProgramDatabase + StdCall + true + false + false - zlibstat.lib;wininet.lib;%(AdditionalDependencies) + zlibstat.lib;wininet.lib;lzmalib.lib;%(AdditionalDependencies) wininet.dll;%(DelayLoadDLLs) true Console true true MachineX86 + $(SolutionDir)\..\lib\ - - - - - - - @@ -108,19 +108,6 @@ - - - - - - - - - - - - - @@ -132,9 +119,16 @@ - + + + + + + + + diff --git a/od-win32/uaeunp/uaeunp.vcxproj.filters b/od-win32/uaeunp/uaeunp.vcxproj.filters index 358d6fe0..361337d6 100644 --- a/od-win32/uaeunp/uaeunp.vcxproj.filters +++ b/od-win32/uaeunp/uaeunp.vcxproj.filters @@ -5,30 +5,6 @@ {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - {025b82fd-637e-4580-b73d-e9cb2b1704f3} - - - {f793e865-aaaa-4a92-ab71-042c6df63370} - - - {30815150-3af4-4642-a7b0-2f0a84e9184b} - - - {26e2cd32-bb63-4be1-8ce7-17a2670fbe68} - - - {02dd9255-7ba8-4931-8ed9-382100420cd3} - - - {9744d4a4-039b-43f0-a43b-2a3911cf429b} - - - {7a6a4d5c-b3f7-40e3-922d-ebf5ed25ac7f} - - - {e74cec8e-0727-401b-bea6-57f78b869c7d} - {1227b1a8-96c7-40ea-961b-03ac23a184bf} @@ -40,6 +16,27 @@ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + {00e42ee4-d20b-492c-b25b-0e9750a6d85b} + + + {eb98dae8-c6ec-49a7-8a3d-8cf32939312a} + + + {0fc9c7ac-e938-4981-9f98-cdf840415358} + + + {d6ab702f-21fd-4acd-b9ef-f3ae2b09e1da} + + + {b4819264-3304-4b7d-a26f-d0a1aa1efd34} + + + {8969d72b-d2d6-4daa-8989-486487e5e474} + + + {75e92f84-bad0-4dfb-a8d5-d7a678415e24} + @@ -63,134 +60,95 @@ Source Files + + Source Files\win32 + + + Source Files\win32 + + + Source Files\win32 + + + Source Files\win32 + + + Source Files\win32 + - Source Files\decompressors\dms + Source Files\unpackers\dms - Source Files\decompressors\dms + Source Files\unpackers\dms - Source Files\decompressors\dms + Source Files\unpackers\dms - Source Files\decompressors\dms + Source Files\unpackers\dms - Source Files\decompressors\dms + Source Files\unpackers\dms - Source Files\decompressors\dms + Source Files\unpackers\dms - Source Files\decompressors\dms + Source Files\unpackers\dms - Source Files\decompressors\dms + Source Files\unpackers\dms - Source Files\decompressors\dms + Source Files\unpackers\dms - Source Files\decompressors\dms + Source Files\unpackers\dms - Source Files\decompressors\dms - - - Source Files\decompressors\7z - - - Source Files\decompressors\7z - - - Source Files\decompressors\7z - - - Source Files\decompressors\7z - - - Source Files\decompressors\7z - - - Source Files\decompressors\7z - - - Source Files\decompressors\7z - - - Source Files\decompressors\7z - - - Source Files\decompressors\7z - - - Source Files\decompressors\7z - - - Source Files\decompressors\7z - - - Source Files\decompressors\7z - - - Source Files\decompressors\7z + Source Files\unpackers\dms - Source Files\decompressors\lha + Source Files\unpackers\lha - Source Files\decompressors\lha + Source Files\unpackers\lha - Source Files\decompressors\lha + Source Files\unpackers\lha - Source Files\decompressors\lha + Source Files\unpackers\lha - Source Files\decompressors\lha + Source Files\unpackers\lha - Source Files\decompressors\lha + Source Files\unpackers\lha - Source Files\decompressors\lha + Source Files\unpackers\lha - Source Files\decompressors\lha + Source Files\unpackers\lha - Source Files\decompressors\lha + Source Files\unpackers\lha - Source Files\decompressors\lha + Source Files\unpackers\lha - Source Files\decompressors\lha - - - Source Files\decompressors\zip + Source Files\unpackers\lha - Source Files\decompressors\lzx + Source Files\unpackers\lzx - Source Files\decompressors\wrp + Source Files\unpackers\wrp - - Source Files\win32 - - - Source Files\win32 - - - Source Files\win32 - - - Source Files\win32 - - - Source Files\win32 + + Source Files\unpackers\zip \ No newline at end of file diff --git a/od-win32/unpackers/unpackers.vcxproj b/od-win32/unpackers/unpackers.vcxproj new file mode 100644 index 00000000..548d699e --- /dev/null +++ b/od-win32/unpackers/unpackers.vcxproj @@ -0,0 +1,159 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {98BA115B-829F-4085-9729-ABD0D779A60A} + Win32Proj + unpackers + + + + StaticLibrary + true + Unicode + + + StaticLibrary + true + Unicode + + + StaticLibrary + false + false + Unicode + + + StaticLibrary + false + true + Unicode + + + + + + + + + + + + + + + + + + + $(SolutionDir)$(Configuration)\..\..\lib\ + + + $(SolutionDir)$(Platform)\$(Configuration)\..\..\..\lib\ + $(ProjectName)_x64 + + + $(SolutionDir)$(Configuration)\..\..\lib\ + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + MultiThreaded + ..\..\include;..\..;..\;%(AdditionalIncludeDirectories) + StdCall + false + + + Windows + true + + + %(ExportNamedFunctions) + + + + + + + + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + MultiThreaded + + + Windows + true + + + + + Level3 + NotUsing + MaxSpeed + true + true + WINVER=0x0500;NDEBUG;_WIN32_IE=0x0700;WIN32;%(PreprocessorDefinitions) + MultiThreaded + StdCall + ..\..\include;..\;%(AdditionalIncludeDirectories) + false + + + Windows + true + true + true + + + + + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + MultiThreaded + StdCall + ..\..\include;..\..;..\;..\resources;..\osdep;..\sounddep;..\..\prowizard\include;%(AdditionalIncludeDirectories) + + + Windows + true + true + true + + + + + + \ No newline at end of file diff --git a/od-win32/unpackers/unpackers.vcxproj.filters b/od-win32/unpackers/unpackers.vcxproj.filters new file mode 100644 index 00000000..d7ef6a1a --- /dev/null +++ b/od-win32/unpackers/unpackers.vcxproj.filters @@ -0,0 +1,17 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + \ No newline at end of file diff --git a/od-win32/win32.cpp b/od-win32/win32.cpp index a2c7a025..737ddc34 100644 --- a/od-win32/win32.cpp +++ b/od-win32/win32.cpp @@ -794,7 +794,7 @@ static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam, static int mm, minimized, recursive, ignoremousemove; #if MSGDEBUG > 1 - write_log (L"AWP: %x %d\n", hWnd, message); + write_log (L"AWP: %x %x\n", hWnd, message); #endif if (ignore_messages_all) return DefWindowProc (hWnd, message, wParam, lParam); @@ -1327,6 +1327,7 @@ static LRESULT CALLBACK MainWindowProc (HWND hWnd, UINT message, WPARAM wParam, switch (message) { + case WM_SETCURSOR: case WM_KILLFOCUS: case WM_SETFOCUS: case WM_MOUSEMOVE: @@ -1335,7 +1336,6 @@ static LRESULT CALLBACK MainWindowProc (HWND hWnd, UINT message, WPARAM wParam, case WM_ACTIVATEAPP: case WM_DROPFILES: case WM_ACTIVATE: - case WM_SETCURSOR: case WM_SYSCOMMAND: case WM_KEYUP: case WM_SYSKEYUP: @@ -1451,7 +1451,7 @@ static LRESULT CALLBACK MainWindowProc (HWND hWnd, UINT message, WPARAM wParam, case WM_NCLBUTTONDBLCLK: if (wParam == HTCAPTION) { - WIN32GFX_ToggleFullScreen (); + toggle_fullscreen (); return 0; } break; @@ -1706,11 +1706,6 @@ static int WIN32_RegisterClasses (void) return 1; } -#ifdef __GNUC__ -#undef WINAPI -#define WINAPI -#endif - static HINSTANCE hRichEdit = NULL, hHtmlHelp = NULL; int WIN32_CleanupLibraries (void) @@ -1826,9 +1821,6 @@ static TCHAR *getlanguagename(DWORD id) return NULL; } -typedef LANGID (CALLBACK* PGETUSERDEFAULTUILANGUAGE)(void); -static PGETUSERDEFAULTUILANGUAGE pGetUserDefaultUILanguage; - HMODULE language_load (WORD language) { HMODULE result = NULL; @@ -1838,11 +1830,7 @@ HMODULE language_load (WORD language) if (language <= 0) { /* new user-specific Windows ME/2K/XP method to get UI language */ - pGetUserDefaultUILanguage = (PGETUSERDEFAULTUILANGUAGE)GetProcAddress ( - GetModuleHandle (L"kernel32.dll"), "GetUserDefaultUILanguage"); - language = GetUserDefaultLangID (); - if (pGetUserDefaultUILanguage) - language = pGetUserDefaultUILanguage (); + language = GetUserDefaultUILanguage (); language &= 0x3ff; // low 9-bits form the primary-language ID } if (language == LANG_GERMAN) @@ -2635,6 +2623,7 @@ static const TCHAR *obsolete[] = { L"killwinkeys", L"sound_force_primary", L"iconified_highpriority", L"sound_sync", L"sound_tweak", L"directx6", L"sound_style", L"file_path", L"iconified_nospeed", L"activepriority", L"magic_mouse", + L"filesystem_codepage", 0 }; @@ -2642,6 +2631,8 @@ int target_parse_option (struct uae_prefs *p, TCHAR *option, TCHAR *value) { TCHAR tmpbuf[CONFIG_BLEN]; int i, v; + bool vb; + int result = (cfgfile_yesno (option, value, L"middle_mouse", &p->win32_middle_mouse) || cfgfile_yesno (option, value, L"map_drives", &p->win32_automount_drives) || cfgfile_yesno (option, value, L"map_drives_auto", &p->win32_automount_removable) @@ -2729,9 +2720,9 @@ int target_parse_option (struct uae_prefs *p, TCHAR *option, TCHAR *value) return 1; } - if (cfgfile_yesno (option, value, L"aspi", &v)) { - p->win32_uaescsimode = 0; - if (v) + if (cfgfile_yesno (option, value, L"aspi", &vb)) { + p->win32_uaescsimode = false; + if (vb) p->win32_uaescsimode = get_aspi (0); if (p->win32_uaescsimode < UAESCSI_ASPI_FIRST) p->win32_uaescsimode = UAESCSI_ADAPTECASPI; @@ -3134,16 +3125,16 @@ static int parseversion (TCHAR **vs) static int checkversion (TCHAR *vs) { + int ver; if (_tcslen (vs) < 10) return 0; - if (_tcsncmp (vs, L"WinUAE L", 7)) + if (_tcsncmp (vs, L"WinUAE ", 7)) return 0; vs += 7; - if (parseversion (&vs) > UAEMAJOR) - return 0; - if (parseversion (&vs) > UAEMINOR) - return 0; - if (parseversion (&vs) >= UAESUBREV) + ver = parseversion (&vs) << 16; + ver |= parseversion (&vs) << 8; + ver |= parseversion (&vs); + if (ver >= ((UAEMAJOR << 16) | (UAEMINOR << 8) | UAESUBREV)) return 0; return 1; } @@ -3522,7 +3513,7 @@ static void WIN32_HandleRegistryStuff (void) if (regexists (NULL, L"SoundDriverMask")) { regqueryint (NULL, L"SoundDriverMask", &sounddrivermask); } else { - sounddrivermask = 15; + sounddrivermask = 3; regsetint (NULL, L"SoundDriverMask", sounddrivermask); } if (regexists (NULL, L"ConfigurationCache")) @@ -4020,7 +4011,7 @@ static int parseargs (const TCHAR *arg, const TCHAR *np, const TCHAR *np2) return 1; } if (!_tcscmp (arg, L"-disableharddrivesafetycheck")) { - harddrive_dangerous = 0x1234dead; + //harddrive_dangerous = 0x1234dead; return 1; } if (!_tcscmp (arg, L"-noaspifiltering")) { diff --git a/od-win32/win32.h b/od-win32/win32.h index 648a3619..500bb55d 100644 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -15,11 +15,11 @@ #define GETBDM(x) (((x) - ((x / 10000) * 10000)) / 100) #define GETBDD(x) ((x) % 100) -#define WINUAEPUBLICBETA 0 +#define WINUAEPUBLICBETA 1 #define LANG_DLL 1 -#define WINUAEBETA L"" -#define WINUAEDATE MAKEBD(2010, 4, 28) +#define WINUAEBETA L"1" +#define WINUAEDATE MAKEBD(2010, 5, 15) #define WINUAEEXTRA L"" #define WINUAEREV L"" diff --git a/od-win32/win32_filesys.cpp b/od-win32/win32_filesys.cpp index a259c1e8..b663930f 100644 --- a/od-win32/win32_filesys.cpp +++ b/od-win32/win32_filesys.cpp @@ -40,7 +40,7 @@ static int valid_volumename (struct uaedev_mount_info *mountinfo, TCHAR *volumen } /* Returns 1 if an actual volume-name was found, 2 if no volume-name (so uses some defaults) */ -int target_get_volume_name (struct uaedev_mount_info *mtinf, const TCHAR *volumepath, TCHAR *volumename, int size, int inserted, int fullcheck) +int target_get_volume_name (struct uaedev_mount_info *mtinf, const TCHAR *volumepath, TCHAR *volumename, int size, bool inserted, bool fullcheck) { int result = 2; int drivetype; @@ -152,7 +152,7 @@ static void filesys_addexternals (void) /* Is this drive-letter valid (it used to check for media in drive) */ if(dwDriveMask & 1) { TCHAR devname[MAX_DPATH]; - BOOL inserted = CheckRM (volumepath); /* Is there a disk inserted? */ + bool inserted = CheckRM (volumepath) != 0; /* Is there a disk inserted? */ int nok = FALSE; int rw = 1; drivetype = GetDriveType (volumepath); @@ -186,7 +186,7 @@ static void filesys_addexternals (void) continue; volumename[0] = 0; if (inserted) { - target_get_volume_name (&mountinfo, volumepath, volumename, MAX_DPATH, inserted, 1); + target_get_volume_name (&mountinfo, volumepath, volumename, MAX_DPATH, inserted, true); if (!volumename[0]) _stprintf (volumename, L"WinUNK_%c", drive); } @@ -194,10 +194,12 @@ static void filesys_addexternals (void) _tcscat (volumepath, L"."); else _tcscat (volumepath, L".."); +#if 0 if (currprefs.win32_automount_drives > 1) { devname[0] = drive; devname[1] = 0; } +#endif //write_log (L"Drive type %d: '%s' '%s'\n", drivetype, volumepath, volumename); add_filesys_unit (devname[0] ? devname : NULL, volumename, volumepath, !rw, 0, 0, 0, 0, -20 - drvnum, 0, 1, 0, 0, 0); drvnum++; diff --git a/od-win32/win32gfx.cpp b/od-win32/win32gfx.cpp index 9d33194e..1a178b6f 100644 --- a/od-win32/win32gfx.cpp +++ b/od-win32/win32gfx.cpp @@ -103,6 +103,7 @@ extern int console_logging; int window_extra_width, window_extra_height; static struct winuae_currentmode *currentmode = ¤tmodestruct; +static int wasfullwindow_a, wasfullwindow_p; int screen_is_picasso = 0; @@ -1298,6 +1299,7 @@ int check_prefs_changed_gfx (void) c |= currprefs.gfx_display != changed_prefs.gfx_display ? (2|4|8) : 0; c |= _tcscmp (currprefs.gfx_display_name, changed_prefs.gfx_display_name) ? (2|4|8) : 0; c |= currprefs.gfx_blackerthanblack != changed_prefs.gfx_blackerthanblack ? (2 | 8) : 0; + c |= currprefs.gfx_backbuffers != changed_prefs.gfx_backbuffers ? (2 | 8) : 0; c |= currprefs.win32_alwaysontop != changed_prefs.win32_alwaysontop ? 32 : 0; c |= currprefs.win32_notaskbarbutton != changed_prefs.win32_notaskbarbutton ? 32 : 0; @@ -1358,6 +1360,7 @@ int check_prefs_changed_gfx (void) currprefs.gfx_display = changed_prefs.gfx_display; _tcscpy (currprefs.gfx_display_name, changed_prefs.gfx_display_name); currprefs.gfx_blackerthanblack = changed_prefs.gfx_blackerthanblack; + currprefs.gfx_backbuffers = changed_prefs.gfx_backbuffers; currprefs.win32_alwaysontop = changed_prefs.win32_alwaysontop; currprefs.win32_notaskbarbutton = changed_prefs.win32_notaskbarbutton; @@ -1467,7 +1470,7 @@ int check_prefs_changed_gfx (void) currprefs.win32_iconified_pause = changed_prefs.win32_iconified_pause; currprefs.win32_ctrl_F11_is_quit = changed_prefs.win32_ctrl_F11_is_quit; inputdevice_unacquire (); - currprefs.keyboard_leds_in_use = currprefs.keyboard_leds[0] | currprefs.keyboard_leds[1] | currprefs.keyboard_leds[2]; + currprefs.keyboard_leds_in_use = (currprefs.keyboard_leds[0] | currprefs.keyboard_leds[1] | currprefs.keyboard_leds[2]) != 0; pause_sound (); resume_sound (); inputdevice_acquire (TRUE); @@ -1697,9 +1700,9 @@ static int reopen (int full) return 0; } -int vsync_switchmode (int hz, int oldhz) +bool vsync_switchmode (int hz, int oldhz) { - static int tempvsync; + static bool tempvsync; int w = currentmode->native_width; int h = currentmode->native_height; int d = currentmode->native_depth / 8; @@ -1950,15 +1953,6 @@ void close_windows (void) close_hwnds (); } -void WIN32GFX_ToggleFullScreen (void) -{ - display_change_requested = 1; - if (screen_is_picasso) - currprefs.gfx_pfullscreen ^= 1; - else - currprefs.gfx_afullscreen ^= 1; -} - static void createstatuswindow (void) { HDC hdc; @@ -2375,6 +2369,10 @@ static BOOL doInit (void) int ret = 0; int mult = 0; + if (wasfullwindow_a == 0) + wasfullwindow_a = currprefs.gfx_afullscreen == 2 ? 1 : -1; + if (wasfullwindow_p == 0) + wasfullwindow_p = currprefs.gfx_pfullscreen == 2 ? 1 : -1; colortype = DirectDraw_GetPixelFormat (); gfxmode_reset (); @@ -2606,10 +2604,19 @@ void updatewinfsmode (struct uae_prefs *p) void toggle_fullscreen (void) { - if(picasso_on) - changed_prefs.gfx_pfullscreen = !changed_prefs.gfx_pfullscreen; - else - changed_prefs.gfx_afullscreen = !changed_prefs.gfx_afullscreen; + int *p = picasso_on ? &changed_prefs.gfx_pfullscreen : &changed_prefs.gfx_afullscreen; + int wfw = picasso_on ? wasfullwindow_p : wasfullwindow_a; + int v = *p; + if (v == 2) + v = 1; + else if (v == 0) + v = 1; + else if (v == 1) + if (wfw > 0) + v = 2; + else + v = 0; + *p = v; updatewinfsmode (&changed_prefs); } diff --git a/od-win32/win32gfx.h b/od-win32/win32gfx.h index 23598782..1cad516d 100644 --- a/od-win32/win32gfx.h +++ b/od-win32/win32gfx.h @@ -11,7 +11,6 @@ int WIN32GFX_GetWidth (void); int WIN32GFX_GetHeight(void); int WIN32GFX_GetDepth (int real); void WIN32GFX_DisplayChangeRequested (void); -void WIN32GFX_ToggleFullScreen (void); void WIN32GFX_DisablePicasso (void); void WIN32GFX_EnablePicasso (void); void WIN32GFX_WindowMove (void); diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index d4d407f1..e62b8a08 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -146,8 +146,8 @@ static int C_PAGES; #define MAX_C_PAGES 30 static int LOADSAVE_ID = -1, MEMORY_ID = -1, KICKSTART_ID = -1, CPU_ID = -1, DISPLAY_ID = -1, HW3D_ID = -1, CHIPSET_ID = -1, CHIPSET2_ID = -1, SOUND_ID = -1, FLOPPY_ID = -1, DISK_ID = -1, - HARDDISK_ID = -1, IOPORTS_ID = -1, GAMEPORTS_ID = -1, INPUT_ID = -1, MISC1_ID = -1, MISC2_ID = -1, AVIOUTPUT_ID = -1, - PATHS_ID = -1, QUICKSTART_ID = -1, ABOUT_ID = -1, EXPANSION_ID = -1, FRONTEND_ID = -1; + HARDDISK_ID = -1, IOPORTS_ID = -1, GAMEPORTS_ID = -1, INPUT_ID = -1, INPUTMAP_ID = -1, MISC1_ID = -1, MISC2_ID = -1, + AVIOUTPUT_ID = -1, PATHS_ID = -1, QUICKSTART_ID = -1, ABOUT_ID = -1, EXPANSION_ID = -1, FRONTEND_ID = -1; static HWND pages[MAX_C_PAGES]; #define MAX_IMAGETOOLTIPS 10 static HWND guiDlg, panelDlg, ToolTipHWND; @@ -158,7 +158,29 @@ struct ToolTipHWNDS { int imageid; }; static struct ToolTipHWNDS ToolTipHWNDS2[MAX_IMAGETOOLTIPS + 1]; +struct GUIPAGE { + DLGPROC dlgproc; + LPCTSTR title; + LPCTSTR icon; + HTREEITEM tv; + int himg; + int idx; + const TCHAR *help; + HACCEL accel; + int fullpanel; + struct newresource *nres; + int focusid; +}; +static struct GUIPAGE ppage[MAX_C_PAGES]; +static bool ischecked (HWND hDlg, DWORD id) +{ + return IsDlgButtonChecked (hDlg, id) == BST_CHECKED; +} +static void setfocus (HWND hDlg, int id) +{ + SendMessage (hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem (hDlg, id), TRUE); +} static void ew (HWND hDlg, DWORD id, int enable) { HWND w = GetDlgItem (hDlg, id); @@ -2181,7 +2203,7 @@ int DiskSelection_2 (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs _tcscpy (workprefs.cartfile, full_path); break; case IDC_INPREC_PLAY: - inprec_open (full_path, IsDlgButtonChecked (hDlg, IDC_INPREC_PLAYMODE) == BST_CHECKED ? -1 : -2); + inprec_open (full_path, ischecked (hDlg, IDC_INPREC_PLAYMODE) ? -1 : -2); break; case IDC_INPREC_RECORD: inprec_open (full_path, 1); @@ -2265,9 +2287,9 @@ static BOOL CreateHardFile (HWND hDlg, UINT hfsizem, TCHAR *dostype, TCHAR *newp dynamic = 0; dt = 0; hfsize = (uae_u64)hfsizem * 1024 * 1024; - if (IsDlgButtonChecked (hDlg, IDC_HF_SPARSE) == BST_CHECKED) + if (ischecked (hDlg, IDC_HF_SPARSE)) sparse = 1; - if (IsDlgButtonChecked (hDlg, IDC_HF_DYNAMIC) == BST_CHECKED) { + if (ischecked (hDlg, IDC_HF_DYNAMIC)) { dynamic = 1; sparse = 0; } @@ -3132,6 +3154,102 @@ static void update_listview_input (HWND hDlg) set_lventry_input (GetDlgItem (hDlg, IDC_INPUTLIST), i); } +static int inputmap_port = -1, inputmap_port_remap = -1; +static int inputmap_handle (HWND list, int currentdevnum, int currentwidgetnum, int *inputmap_portp, int *inputmap_indexp, int state) +{ + int cnt, portnum; + int mode, *events, *axistable; + bool found2 = false; + + for (portnum = 0; portnum < 4; portnum++) { + if (list) + portnum = inputmap_port; + cnt = 1; + if (inputdevice_get_compatibility_input (&workprefs, portnum, &mode, &events, &axistable)) { + int evtnum; + for (int i = 0; (evtnum = events[i]) >= 0; i++) { + struct inputevent *evt = inputdevice_get_eventinfo (evtnum); + LV_ITEM lvstruct; + int devnum; + int flags, status; + TCHAR name[256]; + bool found = false; + int *atp = axistable; + int atpidx; + int item; + + if (list) { + lvstruct.mask = LVIF_TEXT | LVIF_PARAM; + lvstruct.pszText = (TCHAR*)evt->name; + lvstruct.lParam = 0; + lvstruct.iItem = cnt; + lvstruct.iSubItem = 0; + item = ListView_InsertItem (list, &lvstruct); + } + + atpidx = 0; + while (*atp >= 0) { + if (*atp == evtnum) { + atp++; + atpidx = 2; + break; + } + if (atp[1] == evtnum || atp[2] == evtnum) { + atpidx = 1; + break; + } + atp += 3; + } + while (atpidx >= 0) { + devnum = 0; + while ((status = inputdevice_get_device_status (devnum)) >= 0) { + if (1 || status) { + for (int j = 0; j < inputdevice_get_widget_num (devnum); j++) { + for (int sub = 0; sub < MAX_INPUT_SUB_EVENT; sub++) { + if (inputdevice_get_mapped_name (devnum, j, &flags, NULL, NULL, sub) == evtnum && !found) { + TCHAR tmp[MAX_DPATH]; + inputdevice_get_widget_type (devnum, j, name); + if (list) { + _tcscpy (tmp, name); + _tcscat (tmp, L","); + _tcscat (tmp, inputdevice_get_device_name2 (devnum)); + ListView_SetItemText (list, item, 1, tmp); + found = true; + } else if (currentdevnum == devnum) { + if (currentwidgetnum == j) { + *inputmap_portp = portnum; + *inputmap_indexp = cnt - 1; + found2 = true; + if (state < 0) + return 1; + state = -1; + } + } + } + } + } + } + devnum++; + } + evtnum = *atp++; + atpidx--; + } + cnt++; + } + } + if (list) + break; + } + if (found2) + return 1; + return 0; +} +static void update_listview_inputmap (HWND hDlg) +{ + HWND list = GetDlgItem (hDlg, IDC_INPUTMAPLIST); + inputmap_handle (list, -1, -1, NULL, NULL, 0); +} + static int clicked_entry = -1; #define LOADSAVE_COLUMNS 2 @@ -3139,6 +3257,7 @@ static int clicked_entry = -1; #define HARDDISK_COLUMNS 8 #define DISK_COLUMNS 3 #define MISC2_COLUMNS 2 +#define INPUTMAP_COLUMNS 2 #define MAX_COLUMN_HEADING_WIDTH 20 #define LV_LOADSAVE 1 @@ -3146,6 +3265,11 @@ static int clicked_entry = -1; #define LV_INPUT 3 #define LV_DISK 4 #define LV_MISC2 5 +#define LV_INPUTMAP 6 +#define LV_MAX 7 + +static int lv_oldidx[LV_MAX]; +static int lv_old_type = -1; static int listview_num_columns; @@ -3168,30 +3292,45 @@ void InitializeListView (HWND hDlg) TCHAR tmp[10], tmp2[MAX_DPATH]; int listview_column_width[HARDDISK_COLUMNS]; + if (cachedlist) { + if (lv_old_type >= 0) + lv_oldidx[lv_old_type] = ListView_GetTopIndex (cachedlist); + lv_oldidx[lv_old_type] += ListView_GetCountPerPage (cachedlist) - 1; + cachedlist = NULL; + } + if (hDlg == pages[HARDDISK_ID]) { listview_num_columns = HARDDISK_COLUMNS; lv_type = LV_HARDDISK; _tcscpy (column_heading[0], L"*"); - WIN32GUI_LoadUIString(IDS_DEVICE, column_heading[1], MAX_COLUMN_HEADING_WIDTH); - WIN32GUI_LoadUIString(IDS_VOLUME, column_heading[2], MAX_COLUMN_HEADING_WIDTH); - WIN32GUI_LoadUIString(IDS_PATH, column_heading[3], MAX_COLUMN_HEADING_WIDTH); - WIN32GUI_LoadUIString(IDS_RW, column_heading[4], MAX_COLUMN_HEADING_WIDTH); - WIN32GUI_LoadUIString(IDS_BLOCKSIZE, column_heading[5], MAX_COLUMN_HEADING_WIDTH); - WIN32GUI_LoadUIString(IDS_HFDSIZE, column_heading[6], MAX_COLUMN_HEADING_WIDTH); - WIN32GUI_LoadUIString(IDS_BOOTPRI, column_heading[7], MAX_COLUMN_HEADING_WIDTH); - list = GetDlgItem(hDlg, IDC_VOLUMELIST); + WIN32GUI_LoadUIString (IDS_DEVICE, column_heading[1], MAX_COLUMN_HEADING_WIDTH); + WIN32GUI_LoadUIString (IDS_VOLUME, column_heading[2], MAX_COLUMN_HEADING_WIDTH); + WIN32GUI_LoadUIString (IDS_PATH, column_heading[3], MAX_COLUMN_HEADING_WIDTH); + WIN32GUI_LoadUIString (IDS_RW, column_heading[4], MAX_COLUMN_HEADING_WIDTH); + WIN32GUI_LoadUIString (IDS_BLOCKSIZE, column_heading[5], MAX_COLUMN_HEADING_WIDTH); + WIN32GUI_LoadUIString (IDS_HFDSIZE, column_heading[6], MAX_COLUMN_HEADING_WIDTH); + WIN32GUI_LoadUIString (IDS_BOOTPRI, column_heading[7], MAX_COLUMN_HEADING_WIDTH); + list = GetDlgItem (hDlg, IDC_VOLUMELIST); } else if (hDlg == pages[INPUT_ID]) { listview_num_columns = INPUT_COLUMNS; lv_type = LV_INPUT; - WIN32GUI_LoadUIString(IDS_INPUTHOSTWIDGET, column_heading[0], MAX_COLUMN_HEADING_WIDTH); - WIN32GUI_LoadUIString(IDS_INPUTAMIGAEVENT, column_heading[1], MAX_COLUMN_HEADING_WIDTH); - WIN32GUI_LoadUIString(IDS_INPUTAUTOFIRE, column_heading[2], MAX_COLUMN_HEADING_WIDTH); - WIN32GUI_LoadUIString(IDS_INPUTTOGGLE, column_heading[3], MAX_COLUMN_HEADING_WIDTH); + WIN32GUI_LoadUIString (IDS_INPUTHOSTWIDGET, column_heading[0], MAX_COLUMN_HEADING_WIDTH); + WIN32GUI_LoadUIString (IDS_INPUTAMIGAEVENT, column_heading[1], MAX_COLUMN_HEADING_WIDTH); + WIN32GUI_LoadUIString (IDS_INPUTAUTOFIRE, column_heading[2], MAX_COLUMN_HEADING_WIDTH); + WIN32GUI_LoadUIString (IDS_INPUTTOGGLE, column_heading[3], MAX_COLUMN_HEADING_WIDTH); _tcscpy (column_heading[4], L"#"); - list = GetDlgItem(hDlg, IDC_INPUTLIST); + list = GetDlgItem (hDlg, IDC_INPUTLIST); + + } else if (hDlg == pages[INPUTMAP_ID]) { + + listview_num_columns = INPUTMAP_COLUMNS; + lv_type = LV_INPUTMAP; + WIN32GUI_LoadUIString (IDS_INPUTAMIGAEVENT, column_heading[0], MAX_COLUMN_HEADING_WIDTH); + WIN32GUI_LoadUIString (IDS_INPUTHOSTWIDGET, column_heading[1], MAX_COLUMN_HEADING_WIDTH); + list = GetDlgItem (hDlg, IDC_INPUTMAPLIST); } else if (hDlg == pages[MISC2_ID]) { @@ -3206,15 +3345,18 @@ void InitializeListView (HWND hDlg) listview_num_columns = DISK_COLUMNS; lv_type = LV_DISK; _tcscpy (column_heading[0], L"#"); - WIN32GUI_LoadUIString(IDS_DISK_IMAGENAME, column_heading[1], MAX_COLUMN_HEADING_WIDTH); - WIN32GUI_LoadUIString(IDS_DISK_DRIVENAME, column_heading[2], MAX_COLUMN_HEADING_WIDTH); + WIN32GUI_LoadUIString (IDS_DISK_IMAGENAME, column_heading[1], MAX_COLUMN_HEADING_WIDTH); + WIN32GUI_LoadUIString (IDS_DISK_DRIVENAME, column_heading[2], MAX_COLUMN_HEADING_WIDTH); list = GetDlgItem (hDlg, IDC_DISK); } - cachedlist = list; + int flags = LVS_EX_ONECLICKACTIVATE | LVS_EX_UNDERLINEHOT | LVS_EX_DOUBLEBUFFER | LVS_EX_FULLROWSELECT; + ListView_SetExtendedListViewStyleEx (list, flags , flags); ListView_DeleteAllItems (list); + cachedlist = list; + for(i = 0; i < listview_num_columns; i++) listview_column_width[i] = ListView_GetStringWidth (list, column_heading[i]) + 15; @@ -3256,7 +3398,7 @@ void InitializeListView (HWND hDlg) lvstruct.iSubItem = 0; result = ListView_InsertItem (list, &lvstruct); width = ListView_GetStringWidth (list, lvstruct.pszText) + 15; - if( width > listview_column_width[0]) + if (width > listview_column_width[0]) listview_column_width[0] = width; entry++; } @@ -3266,6 +3408,12 @@ void InitializeListView (HWND hDlg) listview_column_width [4] = 30; update_listview_input (hDlg); + } else if (lv_type == LV_INPUTMAP) { + + listview_column_width [0] = 200; + listview_column_width [1] = 200; + update_listview_inputmap (hDlg); + } else if (lv_type == LV_DISK) { for (i = 0; i < MAX_SPARE_DRIVES; i++) { @@ -3430,12 +3578,14 @@ void InitializeListView (HWND hDlg) // Adjust our column widths so that we can see the contents... for(i = 0; i < listview_num_columns; i++) ListView_SetColumnWidth (list, i, listview_column_width[i]); - // Turn on full-row-select option - ListView_SetExtendedListViewStyle (list, LVS_EX_FULLROWSELECT); // Redraw the items in the list... items = ListView_GetItemCount (list); ListView_RedrawItems (list, 0, items); } + if (lv_oldidx[lv_type] >= 0) + ListView_EnsureVisible (list, lv_oldidx[lv_type], FALSE); + lv_old_type = lv_type; + } static int listview_find_selected (HWND list) @@ -3841,13 +3991,13 @@ static void loadsavecommands (HWND hDlg, WPARAM wParam, struct ConfigStruct **co break; case IDC_CONFIGAUTO: if (configtypepanel > 0) { - int ct = IsDlgButtonChecked (hDlg, IDC_CONFIGAUTO) == BST_CHECKED ? 1 : 0; + int ct = ischecked (hDlg, IDC_CONFIGAUTO) ? 1 : 0; ConfigToRegistry2 (ct, configtypepanel, -1); } break; case IDC_CONFIGNOLINK: if (configtypepanel == 0) { - int ct = IsDlgButtonChecked (hDlg, IDC_CONFIGNOLINK) == BST_CHECKED ? 1 : 0; + int ct = ischecked (hDlg, IDC_CONFIGNOLINK) ? 1 : 0; ConfigToRegistry2 (-1, -1, ct); } break; @@ -3894,7 +4044,7 @@ static INT_PTR CALLBACK LoadSaveDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPA case WM_CONTEXTMENU: { - int id = GetDlgCtrlID((HWND)wParam); + int id = GetDlgCtrlID ((HWND)wParam); if (id == IDC_SAVE || id == IDC_LOAD) { TCHAR *s = favoritepopup (hDlg); if (s) { @@ -4380,7 +4530,7 @@ static INT_PTR CALLBACK PathsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM reset_disk_history (); break; case IDC_PATHS_CONFIGCACHE: - configurationcache = IsDlgButtonChecked (hDlg, IDC_PATHS_CONFIGCACHE) ? 1 : 0; + configurationcache = ischecked (hDlg, IDC_PATHS_CONFIGCACHE) ? 1 : 0; regsetint (NULL, L"ConfigurationCache", configurationcache); break; @@ -4759,7 +4909,7 @@ static INT_PTR CALLBACK QuickstartDlgProc (HWND hDlg, UINT msg, WPARAM wParam, L switch (LOWORD (wParam)) { case IDC_QUICKSTARTMODE: - quickstart = IsDlgButtonChecked (hDlg, IDC_QUICKSTARTMODE); + quickstart = ischecked (hDlg, IDC_QUICKSTARTMODE); regsetint (NULL, L"QuickStartMode", quickstart); quickstart_cd = 0; if (quickstart) { @@ -5161,7 +5311,7 @@ static int display_toselect (int fs, int vsync, int p96) return 3; return fs; } -static void display_fromselect (int val, int *fs, int *vsync, int p96) +static void display_fromselect (int val, int *fs, bool *vsync, int p96) { int ofs = *fs; if (val == CB_ERR) @@ -5191,7 +5341,7 @@ static void display_fromselect (int val, int *fs, int *vsync, int p96) break; case 3: *fs = 1; - *vsync = 2; + *vsync = 1; break; case 4: *fs = 2; @@ -5305,6 +5455,15 @@ static void values_to_displaydlg (HWND hDlg) CheckDlgButton (hDlg, IDC_XCENTER, workprefs.gfx_xcenter); CheckDlgButton (hDlg, IDC_YCENTER, workprefs.gfx_ycenter); + SendDlgItemMessage(hDlg, IDC_DISPLAY_BUFFERCNT, CB_RESETCONTENT, 0, 0); + WIN32GUI_LoadUIString(IDS_BUFFER_SINGLE, buffer, sizeof buffer / sizeof (TCHAR)); + SendDlgItemMessage(hDlg, IDC_DISPLAY_BUFFERCNT, CB_ADDSTRING, 0, (LPARAM)buffer); + WIN32GUI_LoadUIString(IDS_BUFFER_DOUBLE, buffer, sizeof buffer / sizeof (TCHAR)); + SendDlgItemMessage(hDlg, IDC_DISPLAY_BUFFERCNT, CB_ADDSTRING, 0, (LPARAM)buffer); + WIN32GUI_LoadUIString(IDS_BUFFER_TRIPLE, buffer, sizeof buffer / sizeof (TCHAR)); + SendDlgItemMessage(hDlg, IDC_DISPLAY_BUFFERCNT, CB_ADDSTRING, 0, (LPARAM)buffer); + SendDlgItemMessage (hDlg, IDC_DISPLAY_BUFFERCNT, CB_SETCURSEL, workprefs.gfx_backbuffers, 0); + init_da (hDlg); } @@ -5352,12 +5511,12 @@ static void values_from_displaydlg (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l display_fromselect (SendDlgItemMessage (hDlg, IDC_SCREENMODE_RTG, CB_GETCURSEL, 0, 0), &workprefs.gfx_pfullscreen, &workprefs.gfx_pvsync, 1); - workprefs.gfx_lores_mode = IsDlgButtonChecked (hDlg, IDC_LORES_SMOOTHED); - workprefs.gfx_scandoubler = IsDlgButtonChecked (hDlg, IDC_FLICKERFIXER); - workprefs.gfx_blackerthanblack = IsDlgButtonChecked (hDlg, IDC_BLACKER_THAN_BLACK); - workprefs.gfx_linedbl = (IsDlgButtonChecked(hDlg, IDC_LM_SCANLINES) ? 2 : - IsDlgButtonChecked(hDlg, IDC_LM_DOUBLED) ? 1 : 0); - + workprefs.gfx_lores_mode = ischecked (hDlg, IDC_LORES_SMOOTHED); + workprefs.gfx_scandoubler = ischecked (hDlg, IDC_FLICKERFIXER); + workprefs.gfx_blackerthanblack = ischecked (hDlg, IDC_BLACKER_THAN_BLACK); + workprefs.gfx_linedbl = (ischecked (hDlg, IDC_LM_SCANLINES) ? 2 : + ischecked (hDlg, IDC_LM_DOUBLED) ? 1 : 0); + workprefs.gfx_backbuffers = SendDlgItemMessage (hDlg, IDC_DISPLAY_BUFFERCNT, CB_GETCURSEL, 0, 0); workprefs.gfx_framerate = SendDlgItemMessage (hDlg, IDC_FRAMERATE, TBM_GETPOS, 0, 0); workprefs.chipset_refreshrate = SendDlgItemMessage (hDlg, IDC_FRAMERATE2, TBM_GETPOS, 0, 0); @@ -5392,8 +5551,8 @@ static void values_from_displaydlg (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l } if (workprefs.chipset_refreshrate == (currprefs.ntscmode ? 60 : 50)) workprefs.chipset_refreshrate = 0; - workprefs.gfx_xcenter = (IsDlgButtonChecked (hDlg, IDC_XCENTER) ? 2 : 0 ); /* Smart centering */ - workprefs.gfx_ycenter = (IsDlgButtonChecked (hDlg, IDC_YCENTER) ? 2 : 0 ); /* Smart centering */ + workprefs.gfx_xcenter = ischecked (hDlg, IDC_XCENTER) ? 2 : 0; /* Smart centering */ + workprefs.gfx_ycenter = ischecked (hDlg, IDC_YCENTER) ? 2 : 0; /* Smart centering */ if (msg == WM_COMMAND && HIWORD (wParam) == CBN_SELCHANGE) { @@ -5593,11 +5752,12 @@ static void values_to_chipsetdlg (HWND hDlg) static void values_from_chipsetdlg (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { BOOL success = FALSE; - int n, snd; + int nn, snd; + bool n; - workprefs.genlock = IsDlgButtonChecked (hDlg, IDC_GENLOCK); - workprefs.immediate_blits = IsDlgButtonChecked (hDlg, IDC_BLITIMM); - n = IsDlgButtonChecked (hDlg, IDC_CYCLEEXACT) ? 1 : 0; + workprefs.genlock = ischecked (hDlg, IDC_GENLOCK); + workprefs.immediate_blits = ischecked (hDlg, IDC_BLITIMM); + n = ischecked (hDlg, IDC_CYCLEEXACT); if (workprefs.cpu_cycle_exact != n) { workprefs.cpu_cycle_exact = workprefs.blitter_cycle_exact = n; if (n) { @@ -5610,20 +5770,20 @@ static void values_from_chipsetdlg (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l workprefs.cachesize = 0; } } - workprefs.collision_level = IsDlgButtonChecked (hDlg, IDC_COLLISION0) ? 0 - : IsDlgButtonChecked (hDlg, IDC_COLLISION1) ? 1 - : IsDlgButtonChecked (hDlg, IDC_COLLISION2) ? 2 : 3; - workprefs.chipset_mask = IsDlgButtonChecked (hDlg, IDC_OCS) ? 0 - : IsDlgButtonChecked (hDlg, IDC_ECS_AGNUS) ? CSMASK_ECS_AGNUS - : IsDlgButtonChecked (hDlg, IDC_ECS_DENISE) ? CSMASK_ECS_DENISE - : IsDlgButtonChecked (hDlg, IDC_ECS) ? CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE + workprefs.collision_level = ischecked (hDlg, IDC_COLLISION0) ? 0 + : ischecked (hDlg, IDC_COLLISION1) ? 1 + : ischecked (hDlg, IDC_COLLISION2) ? 2 : 3; + workprefs.chipset_mask = ischecked (hDlg, IDC_OCS) ? 0 + : ischecked (hDlg, IDC_ECS_AGNUS) ? CSMASK_ECS_AGNUS + : ischecked (hDlg, IDC_ECS_DENISE) ? CSMASK_ECS_DENISE + : ischecked (hDlg, IDC_ECS) ? CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE : CSMASK_AGA | CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE; - n = IsDlgButtonChecked (hDlg, IDC_NTSC) ? 1 : 0; + n = ischecked (hDlg, IDC_NTSC); if (workprefs.ntscmode != n) { workprefs.ntscmode = n; } - snd = IsDlgButtonChecked (hDlg, IDC_CS_SOUND0) ? 0 - : IsDlgButtonChecked (hDlg, IDC_CS_SOUND1) ? 2 : 3; + snd = ischecked (hDlg, IDC_CS_SOUND0) ? 0 + : ischecked (hDlg, IDC_CS_SOUND1) ? 2 : 3; if (snd == 0 || snd == 3) { workprefs.produce_sound = snd; } else if (snd == 2) { @@ -5632,9 +5792,9 @@ static void values_from_chipsetdlg (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l else if (workprefs.produce_sound >= 2) workprefs.produce_sound = 2; } - n = SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_GETCURSEL, 0, 0); - if (n != CB_ERR) { - workprefs.cs_compatible = n; + nn = SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_GETCURSEL, 0, 0); + if (nn != CB_ERR) { + workprefs.cs_compatible = nn; built_in_chipset_prefs (&workprefs); } } @@ -5721,12 +5881,12 @@ static void values_to_chipsetdlg2 (HWND hDlg) CheckDlgButton (hDlg, IDC_CS_DENISE, workprefs.cs_deniserev >= 0); CheckDlgButton (hDlg, IDC_CS_DMAC, workprefs.cs_mbdmac == 1); CheckDlgButton (hDlg, IDC_CS_DMAC2, workprefs.cs_mbdmac == 2); - CheckDlgButton (hDlg, IDC_CS_A2091, workprefs.cs_a2091 > 0); - CheckDlgButton (hDlg, IDC_CS_A4091, workprefs.cs_a4091 > 0); - CheckDlgButton (hDlg, IDC_CS_CDTVSCSI, workprefs.cs_cdtvscsi > 0); + CheckDlgButton (hDlg, IDC_CS_A2091, workprefs.cs_a2091); + CheckDlgButton (hDlg, IDC_CS_A4091, workprefs.cs_a4091); + CheckDlgButton (hDlg, IDC_CS_CDTVSCSI, workprefs.cs_cdtvscsi); CheckDlgButton (hDlg, IDC_CS_SCSIMODE, workprefs.scsi == 2); - CheckDlgButton (hDlg, IDC_CS_PCMCIA, workprefs.cs_pcmcia > 0); - CheckDlgButton (hDlg, IDC_CS_SLOWISFAST, workprefs.cs_slowmemisfast > 0); + CheckDlgButton (hDlg, IDC_CS_PCMCIA, workprefs.cs_pcmcia); + CheckDlgButton (hDlg, IDC_CS_SLOWISFAST, workprefs.cs_slowmemisfast); CheckDlgButton (hDlg, IDC_CS_IDE1, workprefs.cs_ide > 0 && (workprefs.cs_ide & 1)); CheckDlgButton (hDlg, IDC_CS_IDE2, workprefs.cs_ide > 0 && (workprefs.cs_ide & 2)); txt[0] = 0; @@ -5775,41 +5935,41 @@ static void values_from_chipsetdlg2 (HWND hDlg, UINT msg, WPARAM wParam, LPARAM TCHAR txt[32], *p; int v; - workprefs.cs_compatible = IsDlgButtonChecked (hDlg, IDC_CS_COMPATIBLE); - workprefs.cs_resetwarning = IsDlgButtonChecked (hDlg, IDC_CS_RESETWARNING); - workprefs.cs_denisenoehb = IsDlgButtonChecked (hDlg, IDC_CS_NOEHB); - workprefs.cs_dipagnus = IsDlgButtonChecked (hDlg, IDC_CS_DIPAGNUS); + workprefs.cs_compatible = ischecked (hDlg, IDC_CS_COMPATIBLE); + workprefs.cs_resetwarning = ischecked (hDlg, IDC_CS_RESETWARNING); + workprefs.cs_denisenoehb = ischecked (hDlg, IDC_CS_NOEHB); + workprefs.cs_dipagnus = ischecked (hDlg, IDC_CS_DIPAGNUS); workprefs.cs_agnusbltbusybug = workprefs.cs_dipagnus; - workprefs.cs_ksmirror_e0 = IsDlgButtonChecked (hDlg, IDC_CS_KSMIRROR_E0); - workprefs.cs_ksmirror_a8 = IsDlgButtonChecked (hDlg, IDC_CS_KSMIRROR_A8); - workprefs.cs_ciaoverlay = IsDlgButtonChecked (hDlg, IDC_CS_CIAOVERLAY); - workprefs.cs_df0idhw = IsDlgButtonChecked (hDlg, IDC_CS_DF0IDHW); - workprefs.cs_cd32cd = IsDlgButtonChecked (hDlg, IDC_CS_CD32CD); - workprefs.cs_cd32c2p = IsDlgButtonChecked (hDlg, IDC_CS_CD32C2P); - workprefs.cs_cd32nvram = IsDlgButtonChecked (hDlg, IDC_CS_CD32NVRAM); - workprefs.cs_cdtvcd = IsDlgButtonChecked (hDlg, IDC_CS_CDTVCD); - workprefs.cs_cdtvram = IsDlgButtonChecked (hDlg, IDC_CS_CDTVRAM); - workprefs.cs_cdtvcard = IsDlgButtonChecked (hDlg, IDC_CS_CDTVRAMEXP) ? 64 : 0; - workprefs.cs_a1000ram = IsDlgButtonChecked (hDlg, IDC_CS_A1000RAM); - workprefs.cs_ramseyrev = IsDlgButtonChecked (hDlg, IDC_CS_RAMSEY) ? 0x0f : -1; - workprefs.cs_fatgaryrev = IsDlgButtonChecked (hDlg, IDC_CS_FATGARY) ? 0x00 : -1; - workprefs.cs_mbdmac = IsDlgButtonChecked (hDlg, IDC_CS_DMAC) ? 1 : 0; + workprefs.cs_ksmirror_e0 = ischecked (hDlg, IDC_CS_KSMIRROR_E0); + workprefs.cs_ksmirror_a8 = ischecked (hDlg, IDC_CS_KSMIRROR_A8); + workprefs.cs_ciaoverlay = ischecked (hDlg, IDC_CS_CIAOVERLAY); + workprefs.cs_df0idhw = ischecked (hDlg, IDC_CS_DF0IDHW); + workprefs.cs_cd32cd = ischecked (hDlg, IDC_CS_CD32CD); + workprefs.cs_cd32c2p = ischecked (hDlg, IDC_CS_CD32C2P); + workprefs.cs_cd32nvram = ischecked (hDlg, IDC_CS_CD32NVRAM); + workprefs.cs_cdtvcd = ischecked (hDlg, IDC_CS_CDTVCD); + workprefs.cs_cdtvram = ischecked (hDlg, IDC_CS_CDTVRAM); + workprefs.cs_cdtvcard = ischecked (hDlg, IDC_CS_CDTVRAMEXP) ? 64 : 0; + workprefs.cs_a1000ram = ischecked (hDlg, IDC_CS_A1000RAM); + workprefs.cs_ramseyrev = ischecked (hDlg, IDC_CS_RAMSEY) ? 0x0f : -1; + workprefs.cs_fatgaryrev = ischecked (hDlg, IDC_CS_FATGARY) ? 0x00 : -1; + workprefs.cs_mbdmac = ischecked (hDlg, IDC_CS_DMAC) ? 1 : 0; if (workprefs.cs_mbdmac == 0) - workprefs.cs_mbdmac = IsDlgButtonChecked (hDlg, IDC_CS_DMAC2) ? 2 : 0; - workprefs.cs_a2091 = IsDlgButtonChecked (hDlg, IDC_CS_A2091) ? 1 : 0; - workprefs.cs_a4091 = IsDlgButtonChecked (hDlg, IDC_CS_A4091) ? 1 : 0; + workprefs.cs_mbdmac = ischecked (hDlg, IDC_CS_DMAC2) ? 2 : 0; + workprefs.cs_a2091 = ischecked (hDlg, IDC_CS_A2091) ? 1 : 0; + workprefs.cs_a4091 = ischecked (hDlg, IDC_CS_A4091) ? 1 : 0; #if 0 if (msg == WM_COMMAND && LOWORD(wParam) == IDC_CS_SCSIMODE) - workprefs.scsi = IsDlgButtonChecked (hDlg, IDC_CS_SCSIMODE) ? 2 : 0; + workprefs.scsi = ischecked (hDlg, IDC_CS_SCSIMODE) ? 2 : 0; #endif - workprefs.cs_cdtvscsi = IsDlgButtonChecked (hDlg, IDC_CS_CDTVSCSI) ? 1 : 0; - workprefs.cs_pcmcia = IsDlgButtonChecked (hDlg, IDC_CS_PCMCIA) ? 1 : 0; - workprefs.cs_slowmemisfast = IsDlgButtonChecked (hDlg, IDC_CS_SLOWISFAST) ? 1 : 0; - workprefs.cs_ide = IsDlgButtonChecked (hDlg, IDC_CS_IDE1) ? 1 : (IsDlgButtonChecked (hDlg, IDC_CS_IDE2) ? 2 : 0); - workprefs.cs_ciaatod = IsDlgButtonChecked (hDlg, IDC_CS_CIAA_TOD1) ? 0 - : (IsDlgButtonChecked (hDlg, IDC_CS_CIAA_TOD2) ? 1 : 2); - workprefs.cs_rtc = IsDlgButtonChecked (hDlg, IDC_CS_RTC1) ? 0 - : (IsDlgButtonChecked (hDlg, IDC_CS_RTC2) ? 1 : 2); + workprefs.cs_cdtvscsi = ischecked (hDlg, IDC_CS_CDTVSCSI) ? 1 : 0; + workprefs.cs_pcmcia = ischecked (hDlg, IDC_CS_PCMCIA) ? 1 : 0; + workprefs.cs_slowmemisfast = ischecked (hDlg, IDC_CS_SLOWISFAST) ? 1 : 0; + workprefs.cs_ide = ischecked (hDlg, IDC_CS_IDE1) ? 1 : (ischecked (hDlg, IDC_CS_IDE2) ? 2 : 0); + workprefs.cs_ciaatod = ischecked (hDlg, IDC_CS_CIAA_TOD1) ? 0 + : (ischecked (hDlg, IDC_CS_CIAA_TOD2) ? 1 : 2); + workprefs.cs_rtc = ischecked (hDlg, IDC_CS_RTC1) ? 0 + : (ischecked (hDlg, IDC_CS_RTC2) ? 1 : 2); if (workprefs.cs_rtc) { txt[0] = 0; @@ -6338,26 +6498,26 @@ static INT_PTR CALLBACK ExpansionDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP switch (LOWORD (wParam)) { case IDC_RTG_MATCH_DEPTH: - workprefs.win32_rtgmatchdepth = IsDlgButtonChecked (hDlg, IDC_RTG_MATCH_DEPTH); + workprefs.win32_rtgmatchdepth = ischecked (hDlg, IDC_RTG_MATCH_DEPTH); break; case IDC_RTG_SCALE: - workprefs.win32_rtgscaleifsmall = IsDlgButtonChecked (hDlg, IDC_RTG_SCALE); + workprefs.win32_rtgscaleifsmall = ischecked (hDlg, IDC_RTG_SCALE); break; case IDC_RTG_SCALE_ALLOW: - workprefs.win32_rtgallowscaling = IsDlgButtonChecked (hDlg, IDC_RTG_SCALE_ALLOW); + workprefs.win32_rtgallowscaling = ischecked (hDlg, IDC_RTG_SCALE_ALLOW); break; case IDC_SOCKETS: - workprefs.socket_emu = IsDlgButtonChecked (hDlg, IDC_SOCKETS); + workprefs.socket_emu = ischecked (hDlg, IDC_SOCKETS); break; case IDC_SCSIDEVICE: - workprefs.scsi = IsDlgButtonChecked (hDlg, IDC_SCSIDEVICE) ? 1 : 0; + workprefs.scsi = ischecked (hDlg, IDC_SCSIDEVICE); enable_for_expansiondlg (hDlg); break; case IDC_SANA2: - workprefs.sana2 = IsDlgButtonChecked (hDlg, IDC_SANA2) ? 1 : 0; + workprefs.sana2 = ischecked (hDlg, IDC_SANA2); break; case IDC_A2065: - if (IsDlgButtonChecked (hDlg, IDC_A2065)) { + if (ischecked (hDlg, IDC_A2065)) { _tcscpy (workprefs.a2065name, L"none"); expansion_net (hDlg); enable_for_expansiondlg (hDlg); @@ -6368,7 +6528,7 @@ static INT_PTR CALLBACK ExpansionDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP } break; case IDC_CATWEASEL: - workprefs.catweasel = IsDlgButtonChecked (hDlg, IDC_CATWEASEL) ? -1 : 0; + workprefs.catweasel = ischecked (hDlg, IDC_CATWEASEL) ? -1 : 0; break; } if (HIWORD (wParam) == CBN_SELENDOK || HIWORD (wParam) == CBN_KILLFOCUS || HIWORD (wParam) == CBN_EDITCHANGE) { @@ -6730,15 +6890,15 @@ static INT_PTR CALLBACK KickstartDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP break; case IDC_KICKSHIFTER: - workprefs.kickshifter = IsDlgButtonChecked(hDlg, IDC_KICKSHIFTER); + workprefs.kickshifter = ischecked (hDlg, IDC_KICKSHIFTER); break; case IDC_MAPROM: - workprefs.maprom = IsDlgButtonChecked(hDlg, IDC_MAPROM) ? 0x0f000000 : 0; + workprefs.maprom = ischecked (hDlg, IDC_MAPROM) ? 0x0f000000 : 0; break; #if 0 case IDC_HRTMON: - workprefs.cart_internal = IsDlgButtonChecked(hDlg, IDC_HRTMON) ? 1 : 0; + workprefs.cart_internal = ischecked (hDlg, IDC_HRTMON) ? 1 : 0; ew (hDlg, IDC_CARTFILE, workprefs.cart_internal == 1 ? FALSE : TRUE); break; #endif @@ -6801,7 +6961,7 @@ static void misc_getkbled (HWND hDlg, int v, int n) workprefs.keyboard_leds[n] = nv; misc_kbled (hDlg, v, nv); } - workprefs.keyboard_leds_in_use = workprefs.keyboard_leds[0] | workprefs.keyboard_leds[1] | workprefs.keyboard_leds[2]; + workprefs.keyboard_leds_in_use = (workprefs.keyboard_leds[0] | workprefs.keyboard_leds[1] | workprefs.keyboard_leds[2]) != 0; } static void misc_getpri (HWND hDlg, int v, int *n) @@ -7100,73 +7260,73 @@ static INT_PTR MiscDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) savestate_state = STATE_DORESTORE; break; case IDC_STATE_CAPTURE: - workprefs.statecapture = IsDlgButtonChecked (hDlg, IDC_STATE_CAPTURE); + workprefs.statecapture = ischecked (hDlg, IDC_STATE_CAPTURE); enable_for_miscdlg (hDlg); break; case IDC_ILLEGAL: - workprefs.illegal_mem = IsDlgButtonChecked (hDlg, IDC_ILLEGAL); + workprefs.illegal_mem = ischecked (hDlg, IDC_ILLEGAL); break; case IDC_JULIAN: - workprefs.win32_middle_mouse = IsDlgButtonChecked(hDlg, IDC_JULIAN); + workprefs.win32_middle_mouse = ischecked (hDlg, IDC_JULIAN); break; case IDC_FOCUSMINIMIZE: - workprefs.win32_minimize_inactive = IsDlgButtonChecked (hDlg, IDC_FOCUSMINIMIZE); + workprefs.win32_minimize_inactive = ischecked (hDlg, IDC_FOCUSMINIMIZE); break; case IDC_SHOWLEDS: workprefs.leds_on_screen &= ~STATUSLINE_CHIPSET; - if (IsDlgButtonChecked(hDlg, IDC_SHOWLEDS)) + if (ischecked (hDlg, IDC_SHOWLEDS)) workprefs.leds_on_screen |= STATUSLINE_CHIPSET; break; case IDC_SHOWLEDSRTG: workprefs.leds_on_screen &= ~STATUSLINE_RTG; - if (IsDlgButtonChecked(hDlg, IDC_SHOWLEDSRTG)) + if (ischecked (hDlg, IDC_SHOWLEDSRTG)) workprefs.leds_on_screen |= STATUSLINE_RTG; break; case IDC_SHOWGUI: - workprefs.start_gui = IsDlgButtonChecked (hDlg, IDC_SHOWGUI); + workprefs.start_gui = ischecked (hDlg, IDC_SHOWGUI); break; case IDC_CREATELOGFILE: - workprefs.win32_logfile = IsDlgButtonChecked (hDlg, IDC_CREATELOGFILE); + workprefs.win32_logfile = ischecked (hDlg, IDC_CREATELOGFILE); enable_for_miscdlg(hDlg); break; case IDC_POWERSAVE: - workprefs.win32_powersavedisabled = IsDlgButtonChecked (hDlg, IDC_POWERSAVE); + workprefs.win32_powersavedisabled = ischecked (hDlg, IDC_POWERSAVE); break; case IDC_INACTIVE_NOSOUND: - if (!IsDlgButtonChecked (hDlg, IDC_INACTIVE_NOSOUND)) + if (!ischecked (hDlg, IDC_INACTIVE_NOSOUND)) CheckDlgButton (hDlg, IDC_INACTIVE_PAUSE, BST_UNCHECKED); case IDC_INACTIVE_PAUSE: - workprefs.win32_inactive_pause = IsDlgButtonChecked (hDlg, IDC_INACTIVE_PAUSE); + workprefs.win32_inactive_pause = ischecked (hDlg, IDC_INACTIVE_PAUSE); if (workprefs.win32_inactive_pause) CheckDlgButton (hDlg, IDC_INACTIVE_NOSOUND, BST_CHECKED); - workprefs.win32_inactive_nosound = IsDlgButtonChecked (hDlg, IDC_INACTIVE_NOSOUND); + workprefs.win32_inactive_nosound = ischecked (hDlg, IDC_INACTIVE_NOSOUND); break; case IDC_MINIMIZED_NOSOUND: - if (!IsDlgButtonChecked (hDlg, IDC_MINIMIZED_NOSOUND)) + if (!ischecked (hDlg, IDC_MINIMIZED_NOSOUND)) CheckDlgButton (hDlg, IDC_MINIMIZED_PAUSE, BST_UNCHECKED); case IDC_MINIMIZED_PAUSE: - workprefs.win32_iconified_pause = IsDlgButtonChecked (hDlg, IDC_MINIMIZED_PAUSE); + workprefs.win32_iconified_pause = ischecked (hDlg, IDC_MINIMIZED_PAUSE); if (workprefs.win32_iconified_pause) CheckDlgButton (hDlg, IDC_MINIMIZED_NOSOUND, BST_CHECKED); - workprefs.win32_iconified_nosound = IsDlgButtonChecked (hDlg, IDC_MINIMIZED_NOSOUND); + workprefs.win32_iconified_nosound = ischecked (hDlg, IDC_MINIMIZED_NOSOUND); break; case IDC_CTRLF11: - workprefs.win32_ctrl_F11_is_quit = IsDlgButtonChecked (hDlg, IDC_CTRLF11); + workprefs.win32_ctrl_F11_is_quit = ischecked (hDlg, IDC_CTRLF11); break; case IDC_CLOCKSYNC: - workprefs.tod_hack = IsDlgButtonChecked (hDlg, IDC_CLOCKSYNC); + workprefs.tod_hack = ischecked (hDlg, IDC_CLOCKSYNC); break; case IDC_NOTASKBARBUTTON: - workprefs.win32_notaskbarbutton = IsDlgButtonChecked (hDlg, IDC_NOTASKBARBUTTON); + workprefs.win32_notaskbarbutton = ischecked (hDlg, IDC_NOTASKBARBUTTON); break; case IDC_ALWAYSONTOP: - workprefs.win32_alwaysontop = IsDlgButtonChecked (hDlg, IDC_ALWAYSONTOP); + workprefs.win32_alwaysontop = ischecked (hDlg, IDC_ALWAYSONTOP); break; case IDC_KBLED_USB: - workprefs.win32_kbledmode = IsDlgButtonChecked (hDlg, IDC_KBLED_USB) ? 1 : 0; + workprefs.win32_kbledmode = ischecked (hDlg, IDC_KBLED_USB) ? 1 : 0; break; case IDC_FASTERRTG: - workprefs.picasso96_nocustom = IsDlgButtonChecked (hDlg, IDC_FASTERRTG); + workprefs.picasso96_nocustom = ischecked (hDlg, IDC_FASTERRTG); break; } recursive--; @@ -7323,24 +7483,24 @@ static void values_from_cpudlg (HWND hDlg) int newcpu, newfpu, newtrust, oldcache, jitena, idx; static int cachesize_prev, trust_prev; - workprefs.cpu_compatible = workprefs.cpu_cycle_exact | (IsDlgButtonChecked (hDlg, IDC_COMPATIBLE) ? 1 : 0); - workprefs.fpu_strict = IsDlgButtonChecked (hDlg, IDC_COMPATIBLE_FPU) ? 1 : 0; - workprefs.address_space_24 = IsDlgButtonChecked (hDlg, IDC_COMPATIBLE24) ? 1 : 0; - workprefs.m68k_speed = IsDlgButtonChecked (hDlg, IDC_CS_HOST) ? -1 - : IsDlgButtonChecked (hDlg, IDC_CS_68000) ? 0 + workprefs.cpu_compatible = workprefs.cpu_cycle_exact | (ischecked (hDlg, IDC_COMPATIBLE) ? 1 : 0); + workprefs.fpu_strict = ischecked (hDlg, IDC_COMPATIBLE_FPU) ? 1 : 0; + workprefs.address_space_24 = ischecked (hDlg, IDC_COMPATIBLE24) ? 1 : 0; + workprefs.m68k_speed = ischecked (hDlg, IDC_CS_HOST) ? -1 + : ischecked (hDlg, IDC_CS_68000) ? 0 : SendMessage (GetDlgItem (hDlg, IDC_SPEED), TBM_GETPOS, 0, 0) * CYCLE_UNIT; - workprefs.mmu_model = IsDlgButtonChecked (hDlg, IDC_MMUENABLE) ? 68040 : 0; - - newcpu = IsDlgButtonChecked (hDlg, IDC_CPU0) ? 68000 - : IsDlgButtonChecked (hDlg, IDC_CPU1) ? 68010 - : IsDlgButtonChecked (hDlg, IDC_CPU2) ? 68020 - : IsDlgButtonChecked (hDlg, IDC_CPU3) ? 68030 - : IsDlgButtonChecked (hDlg, IDC_CPU4) ? 68040 - : IsDlgButtonChecked (hDlg, IDC_CPU5) ? 68060 : 0; - newfpu = IsDlgButtonChecked (hDlg, IDC_FPU0) ? 0 - : IsDlgButtonChecked (hDlg, IDC_FPU1) ? 1 - : IsDlgButtonChecked (hDlg, IDC_FPU2) ? 2 - : IsDlgButtonChecked (hDlg, IDC_FPU3) ? 3 : 0; + workprefs.mmu_model = ischecked (hDlg, IDC_MMUENABLE) ? 68040 : 0; + + newcpu = ischecked (hDlg, IDC_CPU0) ? 68000 + : ischecked (hDlg, IDC_CPU1) ? 68010 + : ischecked (hDlg, IDC_CPU2) ? 68020 + : ischecked (hDlg, IDC_CPU3) ? 68030 + : ischecked (hDlg, IDC_CPU4) ? 68040 + : ischecked (hDlg, IDC_CPU5) ? 68060 : 0; + newfpu = ischecked (hDlg, IDC_FPU0) ? 0 + : ischecked (hDlg, IDC_FPU1) ? 1 + : ischecked (hDlg, IDC_FPU2) ? 2 + : ischecked (hDlg, IDC_FPU3) ? 3 : 0; /* When switching away from 68000, disable 24 bit addressing. */ workprefs.cpu_model = newcpu; @@ -7374,20 +7534,20 @@ static void values_from_cpudlg (HWND hDlg) break; } - newtrust = IsDlgButtonChecked (hDlg, IDC_TRUST0) ? 0 : 1; + newtrust = ischecked (hDlg, IDC_TRUST0) ? 0 : 1; workprefs.comptrustbyte = newtrust; workprefs.comptrustword = newtrust; workprefs.comptrustlong = newtrust; workprefs.comptrustnaddr= newtrust; - workprefs.compnf = IsDlgButtonChecked (hDlg, IDC_NOFLAGS); - workprefs.compfpu = IsDlgButtonChecked (hDlg, IDC_JITFPU); - workprefs.comp_hardflush = IsDlgButtonChecked (hDlg, IDC_HARDFLUSH); - workprefs.comp_constjump = IsDlgButtonChecked (hDlg, IDC_CONSTJUMP); + workprefs.compnf = ischecked (hDlg, IDC_NOFLAGS); + workprefs.compfpu = ischecked (hDlg, IDC_JITFPU); + workprefs.comp_hardflush = ischecked (hDlg, IDC_HARDFLUSH); + workprefs.comp_constjump = ischecked (hDlg, IDC_CONSTJUMP); #ifdef JIT oldcache = workprefs.cachesize; - jitena = IsDlgButtonChecked (hDlg, IDC_JITENABLE) ? 1 : 0; + jitena = ischecked (hDlg, IDC_JITENABLE) ? 1 : 0; workprefs.cachesize = SendMessage (GetDlgItem (hDlg, IDC_CACHE), TBM_GETPOS, 0, 0) * 1024; if (!jitena) { cachesize_prev = workprefs.cachesize; @@ -7829,11 +7989,11 @@ static void values_from_sounddlg (HWND hDlg) if (workprefs.sound_freq > 96000) workprefs.sound_freq = 96000; - workprefs.produce_sound = (IsDlgButtonChecked (hDlg, IDC_SOUND0) ? 0 - : IsDlgButtonChecked (hDlg, IDC_SOUND1) ? 1 - : IsDlgButtonChecked (hDlg, IDC_SOUND2) ? 2 : 3); + workprefs.produce_sound = (ischecked (hDlg, IDC_SOUND0) ? 0 + : ischecked (hDlg, IDC_SOUND1) ? 1 + : ischecked (hDlg, IDC_SOUND2) ? 2 : 3); - workprefs.sound_auto = IsDlgButtonChecked (hDlg, IDC_SOUND_AUTO) ? 1 : 0; + workprefs.sound_auto = ischecked (hDlg, IDC_SOUND_AUTO); idx = SendDlgItemMessage (hDlg, IDC_SOUNDSTEREO, CB_GETCURSEL, 0, 0); if (idx != CB_ERR) @@ -7853,7 +8013,7 @@ static void values_from_sounddlg (HWND hDlg) } workprefs.sound_interpol = SendDlgItemMessage (hDlg, IDC_SOUNDINTERPOLATION, CB_GETCURSEL, 0, 0); - workprefs.win32_soundexclusive = IsDlgButtonChecked (hDlg, IDC_SOUND_EXCLUSIVE) ? 1 : 0; + workprefs.win32_soundexclusive = ischecked (hDlg, IDC_SOUND_EXCLUSIVE); soundcard = SendDlgItemMessage (hDlg, IDC_SOUNDCARDLIST, CB_GETCURSEL, 0, 0L); if (soundcard != workprefs.win32_soundcard && soundcard != CB_ERR) { workprefs.win32_soundcard = soundcard; @@ -7889,7 +8049,7 @@ static void values_from_sounddlg (HWND hDlg) for (i = 0; sounddrivers[i]; i++) { int old = sounddrivermask; sounddrivermask &= ~(1 << i); - if (IsDlgButtonChecked (hDlg, sounddrivers[i])) + if (ischecked (hDlg, sounddrivers[i])) sounddrivermask |= 1 << i; if (old != sounddrivermask) regsetint (NULL, L"SoundDriverMask", sounddrivermask); @@ -8017,13 +8177,13 @@ struct hfdlg_vals int surfaces; int cylinders; int blocksize; - int rw; - int rdb; + bool rw; + bool rdb; int bootpri; - int donotmount; - int autoboot; + bool donotmount; + bool autoboot; int controller; - int original; + bool original; }; static struct hfdlg_vals empty_hfdlg = { L"", L"", L"", L"", 32, 2, 1, 0, 512, 1, 0, 0, 0, 1, 0, 1 }; @@ -8140,9 +8300,9 @@ static INT_PTR CALLBACK VolumeSettingsProc (HWND hDlg, UINT msg, WPARAM wParam, GetDlgItemText (hDlg, IDC_PATH_NAME, current_fsvdlg.rootdir, sizeof current_fsvdlg.rootdir / sizeof (TCHAR)); GetDlgItemText (hDlg, IDC_VOLUME_NAME, current_fsvdlg.volume, sizeof current_fsvdlg.volume / sizeof (TCHAR)); GetDlgItemText (hDlg, IDC_VOLUME_DEVICE, current_fsvdlg.device, sizeof current_fsvdlg.device / sizeof (TCHAR)); - current_fsvdlg.rw = IsDlgButtonChecked (hDlg, IDC_FS_RW); + current_fsvdlg.rw = ischecked (hDlg, IDC_FS_RW); current_fsvdlg.bootpri = GetDlgItemInt (hDlg, IDC_VOLUME_BOOTPRI, NULL, TRUE); - current_fsvdlg.autoboot = IsDlgButtonChecked (hDlg, IDC_FS_AUTOBOOT); + current_fsvdlg.autoboot = ischecked (hDlg, IDC_FS_AUTOBOOT); recursive--; break; } @@ -8426,13 +8586,13 @@ static INT_PTR CALLBACK HardfileSettingsProc (HWND hDlg, UINT msg, WPARAM wParam EndDialog (hDlg, 0); break; case IDC_HDF_RW: - current_hfdlg.rw = IsDlgButtonChecked (hDlg, IDC_HDF_RW); + current_hfdlg.rw = ischecked (hDlg, IDC_HDF_RW); break; case IDC_HDF_AUTOBOOT: - current_hfdlg.autoboot = IsDlgButtonChecked (hDlg, IDC_HDF_AUTOBOOT); + current_hfdlg.autoboot = ischecked (hDlg, IDC_HDF_AUTOBOOT); break; case IDC_HDF_DONOTMOUNT: - current_hfdlg.donotmount = IsDlgButtonChecked (hDlg, IDC_HDF_DONOTMOUNT); + current_hfdlg.donotmount = ischecked (hDlg, IDC_HDF_DONOTMOUNT); break; case IDC_HDF_RDB: SetDlgItemInt (hDlg, IDC_SECTORS, 0, FALSE); @@ -8543,7 +8703,7 @@ static INT_PTR CALLBACK HarddriveSettingsProc (HWND hDlg, UINT msg, WPARAM wPara } if (posn != CB_ERR) _tcscpy (current_hfdlg.filename, hdf_getnameharddrive ((int)posn, 0, ¤t_hfdlg.blocksize, NULL)); - current_hfdlg.rw = IsDlgButtonChecked (hDlg, IDC_HDF_RW); + current_hfdlg.rw = ischecked (hDlg, IDC_HDF_RW); posn = SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_GETCURSEL, 0, 0); if (posn != CB_ERR) current_hfdlg.controller = posn; @@ -8757,31 +8917,31 @@ static void harddiskdlg_button (HWND hDlg, int button) break; case IDC_MAPDRIVES_AUTO: - workprefs.win32_automount_removable = IsDlgButtonChecked (hDlg, IDC_MAPDRIVES_AUTO); + workprefs.win32_automount_removable = ischecked (hDlg, IDC_MAPDRIVES_AUTO); break; case IDC_MAPDRIVES: - workprefs.win32_automount_drives = IsDlgButtonChecked (hDlg, IDC_MAPDRIVES); + workprefs.win32_automount_drives = ischecked (hDlg, IDC_MAPDRIVES); break; case IDC_MAPDRIVES_REMOVABLE: - workprefs.win32_automount_removabledrives = IsDlgButtonChecked (hDlg, IDC_MAPDRIVES_REMOVABLE); + workprefs.win32_automount_removabledrives = ischecked (hDlg, IDC_MAPDRIVES_REMOVABLE); break; case IDC_MAPDRIVES_CD: - workprefs.win32_automount_cddrives = IsDlgButtonChecked (hDlg, IDC_MAPDRIVES_CD); + workprefs.win32_automount_cddrives = ischecked (hDlg, IDC_MAPDRIVES_CD); break; case IDC_MAPDRIVES_NET: - workprefs.win32_automount_netdrives = IsDlgButtonChecked (hDlg, IDC_MAPDRIVES_NET); + workprefs.win32_automount_netdrives = ischecked (hDlg, IDC_MAPDRIVES_NET); break; case IDC_NOUAEFSDB: - workprefs.filesys_no_uaefsdb = IsDlgButtonChecked (hDlg, IDC_NOUAEFSDB); + workprefs.filesys_no_uaefsdb = ischecked (hDlg, IDC_NOUAEFSDB); break; case IDC_NORECYCLEBIN: - workprefs.win32_norecyclebin = IsDlgButtonChecked (hDlg, IDC_NORECYCLEBIN); + workprefs.win32_norecyclebin = ischecked (hDlg, IDC_NORECYCLEBIN); break; } @@ -9127,7 +9287,7 @@ static void addfloppytype (HWND hDlg, int n) } else { ew (hDlg, f_enable, TRUE); } - CheckDlgButton(hDlg, f_enable, state ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton (hDlg, f_enable, state ? BST_CHECKED : BST_UNCHECKED); } chk = !showcd && disk_getwriteprotect (text) && state == TRUE ? BST_CHECKED : 0; if (f_wp >= 0) @@ -9158,7 +9318,7 @@ static void getfloppytypeq (HWND hDlg, int n) return; if (iscd (n)) return; - chk = IsDlgButtonChecked (hDlg, f_enable) ? 0 : -1; + chk = ischecked (hDlg, f_enable) ? 0 : -1; if (chk != workprefs.dfxtype[n]) { workprefs.dfxtype[n] = chk; addfloppytype (hDlg, n); @@ -9425,17 +9585,17 @@ static INT_PTR CALLBACK FloppyDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARA break; case IDC_DF0WP: case IDC_DF0WPQ: - floppysetwriteprotect (hDlg, 0, currentpage == QUICKSTART_ID ? IsDlgButtonChecked (hDlg, IDC_DF0WPQ) : IsDlgButtonChecked (hDlg, IDC_DF0WP)); + floppysetwriteprotect (hDlg, 0, currentpage == QUICKSTART_ID ? ischecked (hDlg, IDC_DF0WPQ) : ischecked (hDlg, IDC_DF0WP)); break; case IDC_DF1WP: case IDC_DF1WPQ: - floppysetwriteprotect (hDlg, 1, currentpage == QUICKSTART_ID ? IsDlgButtonChecked (hDlg, IDC_DF1WPQ) : IsDlgButtonChecked (hDlg, IDC_DF1WP)); + floppysetwriteprotect (hDlg, 1, currentpage == QUICKSTART_ID ? ischecked (hDlg, IDC_DF1WPQ) : ischecked (hDlg, IDC_DF1WP)); break; case IDC_DF2WP: - floppysetwriteprotect (hDlg, 2, IsDlgButtonChecked (hDlg, IDC_DF2WP)); + floppysetwriteprotect (hDlg, 2, ischecked (hDlg, IDC_DF2WP)); break; case IDC_DF3WP: - floppysetwriteprotect (hDlg, 3, IsDlgButtonChecked (hDlg, IDC_DF3WP)); + floppysetwriteprotect (hDlg, 3, ischecked (hDlg, IDC_DF3WP)); break; case IDC_DF0: case IDC_DF0QQ: @@ -9808,8 +9968,7 @@ static void enable_for_portsdlg (HWND hDlg) int v; int isprinter, issampler; - v = workprefs.input_selected_setting > 0 ? FALSE : TRUE; - ew (hDlg, IDC_SWAP, v); + ew (hDlg, IDC_SWAP, TRUE); #if !defined (SERIAL_PORT) ew (hDlg, IDC_MIDIOUTLIST, FALSE); ew (hDlg, IDC_MIDIINLIST, FALSE); @@ -9849,6 +10008,7 @@ static void enable_for_portsdlg (HWND hDlg) static int joys[] = { IDC_PORT0_JOYS, IDC_PORT1_JOYS, IDC_PORT2_JOYS, IDC_PORT3_JOYS }; static int joysm[] = { IDC_PORT0_JOYSMODE, IDC_PORT1_JOYSMODE, -1, -1 }; +static int joysaf[] = { IDC_PORT0_AUTOFIRE, IDC_PORT1_AUTOFIRE, -1, -1 }; static void updatejoyport (HWND hDlg) { @@ -9902,7 +10062,12 @@ static void updatejoyport (HWND hDlg) for (j = 0; j < inputdevice_get_device_total (IDTYPE_MOUSE); j++, total++) SendDlgItemMessage (hDlg, id, CB_ADDSTRING, 0, (LPARAM)inputdevice_get_device_name(IDTYPE_MOUSE, j)); } - idx = inputdevice_getjoyportdevice (v); + if (v == JPORT_CUSTOM) { + SendDlgItemMessage (hDlg, id, CB_ADDSTRING, 0, (LPARAM)L""); + total++; + } + + idx = inputdevice_getjoyportdevice (i, v); if (idx >= 0) idx += 2; else @@ -9910,12 +10075,16 @@ static void updatejoyport (HWND hDlg) if (idx >= total) idx = 0; SendDlgItemMessage (hDlg, id, CB_SETCURSEL, idx, 0); + if (joysaf[i] >= 0) + CheckDlgButton (hDlg, joysaf[i], workprefs.jports[i].autofire); } } static void fixjport (struct jport *port, int v) { int vv = port->id; + if (vv == JPORT_CUSTOM || vv == JPORT_NONE) + return; if (vv != v) return; if (vv >= JSEM_JOYS && vv < JSEM_MICE) { @@ -9952,12 +10121,12 @@ static void values_from_gameportsdlg (HWND hDlg, int d) if (success) currprefs.input_mouse_speed = workprefs.input_mouse_speed = i; - currprefs.input_magic_mouse = workprefs.input_magic_mouse = IsDlgButtonChecked (hDlg, IDC_PORT_MOUSETRICK) ? -1 : 0; + currprefs.input_magic_mouse = workprefs.input_magic_mouse = ischecked (hDlg, IDC_PORT_MOUSETRICK); workprefs.input_magic_mouse_cursor = SendDlgItemMessage (hDlg, IDC_PORT_TABLET_CURSOR, CB_GETCURSEL, 0, 0L); workprefs.input_tablet = 0; - if (IsDlgButtonChecked (hDlg, IDC_PORT_TABLET)) { + if (ischecked (hDlg, IDC_PORT_TABLET)) { workprefs.input_tablet = TABLET_MOUSEHACK; - if (IsDlgButtonChecked (hDlg, IDC_PORT_TABLET_FULL)) + if (ischecked (hDlg, IDC_PORT_TABLET_FULL)) workprefs.input_tablet = TABLET_REAL; } return; @@ -9972,9 +10141,16 @@ static void values_from_gameportsdlg (HWND hDlg, int d) int idm = joysm[i]; LRESULT v = SendDlgItemMessage (hDlg, id, CB_GETCURSEL, 0, 0L); if (v != CB_ERR && v > 0) { + int max = JSEM_LASTKBD + inputdevice_get_device_total (IDTYPE_JOYSTICK); + if (i < 2) + max += inputdevice_get_device_total (IDTYPE_MOUSE); v -= 2; if (v < 0) - *port = -1; + *port = JPORT_NONE; + else if (v >= max && prevport == JPORT_CUSTOM) + *port = JPORT_CUSTOM; + else if (v >= max) + *port = JPORT_NONE; else if (v < JSEM_LASTKBD) *port = JSEM_KBDLAYOUT + (int)v; else if (v >= JSEM_LASTKBD + inputdevice_get_device_total (IDTYPE_JOYSTICK)) @@ -9982,13 +10158,26 @@ static void values_from_gameportsdlg (HWND hDlg, int d) else *port = JSEM_JOYS + (int)v - JSEM_LASTKBD; } - v = SendDlgItemMessage (hDlg, idm, CB_GETCURSEL, 0, 0L); - if (v != CB_ERR && v > 0) - *portm = v; + if (idm >= 0) { + v = SendDlgItemMessage (hDlg, idm, CB_GETCURSEL, 0, 0L); + if (v != CB_ERR) { + if (*portm != v) + workprefs.input_selected_setting = GAMEPORT_INPUT_SETTINGS; + *portm = v; + } + + } + if (joysaf[i] >= 0) { + int is = ischecked (hDlg, joysaf[i]) ? 1 : 0; + if (is != workprefs.jports[i].autofire) + workprefs.input_selected_setting = GAMEPORT_INPUT_SETTINGS; + workprefs.jports[i].autofire = is; + } if (*port != prevport) changed = 1; } if (changed) { + workprefs.input_selected_setting = GAMEPORT_INPUT_SETTINGS; for (i = 0; i < MAX_JPORTS; i++) { for (j = 0; j < MAX_JPORTS; j++) { if (j != i) @@ -10063,17 +10252,17 @@ static void values_from_portsdlg (HWND hDlg) workprefs.sername[0] = 0; } workprefs.serial_demand = 0; - if (IsDlgButtonChecked (hDlg, IDC_SER_SHARED)) + if (ischecked (hDlg, IDC_SER_SHARED)) workprefs.serial_demand = 1; workprefs.serial_hwctsrts = 0; - if (IsDlgButtonChecked (hDlg, IDC_SER_CTSRTS)) + if (ischecked (hDlg, IDC_SER_CTSRTS)) workprefs.serial_hwctsrts = 1; workprefs.serial_direct = 0; - if (IsDlgButtonChecked (hDlg, IDC_SER_DIRECT)) + if (ischecked (hDlg, IDC_SER_DIRECT)) workprefs.serial_direct = 1; workprefs.uaeserial = 0; - if (IsDlgButtonChecked (hDlg, IDC_UAESERIAL)) + if (ischecked (hDlg, IDC_UAESERIAL)) workprefs.uaeserial = 1; GetDlgItemText (hDlg, IDC_PS_PARAMS, workprefs.ghostscript_parameters, sizeof workprefs.ghostscript_parameters / sizeof (TCHAR)); @@ -10301,6 +10490,20 @@ static void init_portsdlg (HWND hDlg) } } +static void input_test (HWND hDlg, int); +static void ports_remap (HWND, int); + +static void processport (HWND hDlg, bool reset, int port) +{ + if (reset) + inputdevice_compa_prepare_custom (&workprefs, port); + values_from_gameportsdlg (hDlg, 0); + enable_for_gameportsdlg (hDlg); + updatejoyport (hDlg); + inputdevice_updateconfig (&workprefs); + inputdevice_config_change (); +} + /* Handle messages for the Joystick Settings page of our property-sheet */ static INT_PTR CALLBACK GamePortsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -10368,32 +10571,55 @@ static INT_PTR CALLBACK GamePortsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP break; recursive++; if (LOWORD (wParam) == IDC_SWAP) { - struct jport tmp; - memcpy (&tmp, &workprefs.jports[0], sizeof (struct jport)); - memcpy (&workprefs.jports[0], &workprefs.jports[1], sizeof (struct jport)); - memcpy (&workprefs.jports[1], &tmp, sizeof (struct jport)); + inputdevice_swap_compa_ports (&workprefs, 0); temp = joyxprevious[0]; joyxprevious[0] = joyxprevious[1]; joyxprevious[1] = temp; enable_for_gameportsdlg (hDlg); updatejoyport (hDlg); - inputdevice_updateconfig (&workprefs); - inputdevice_config_change (); + } else if (LOWORD (wParam) == IDC_PORT0_AUTOFIRE) { + processport (hDlg, false, 0); + } else if (LOWORD (wParam) == IDC_PORT1_AUTOFIRE) { + processport (hDlg, false, 1); + } else if (LOWORD (wParam) == IDC_PORT0_REMAP) { + ports_remap (hDlg, 0); + } else if (LOWORD (wParam) == IDC_PORT1_REMAP) { + ports_remap (hDlg, 1); + } else if (LOWORD (wParam) == IDC_PORT2_REMAP) { + ports_remap (hDlg, 2); + } else if (LOWORD (wParam) == IDC_PORT3_REMAP) { + ports_remap (hDlg, 3); + } else if (LOWORD (wParam) == IDC_PORT0_TEST) { + input_test (hDlg, 0); + } else if (LOWORD (wParam) == IDC_PORT1_TEST) { + input_test (hDlg, 1); + } else if (LOWORD (wParam) == IDC_PORT2_TEST) { + input_test (hDlg, 2); + } else if (LOWORD (wParam) == IDC_PORT3_TEST) { + input_test (hDlg, 3); } else if (HIWORD (wParam) == CBN_SELCHANGE) { switch (LOWORD (wParam)) { - case IDC_PORT0_JOYS: - case IDC_PORT1_JOYS: - case IDC_PORT2_JOYS: - case IDC_PORT3_JOYS: - case IDC_PORT0_JOYSMODE: - case IDC_PORT1_JOYSMODE: - values_from_gameportsdlg (hDlg, 0); - enable_for_gameportsdlg (hDlg); - updatejoyport (hDlg); - inputdevice_updateconfig (&workprefs); - inputdevice_config_change (); - break; + case IDC_PORT0_JOYS: + case IDC_PORT1_JOYS: + case IDC_PORT2_JOYS: + case IDC_PORT3_JOYS: + case IDC_PORT0_JOYSMODE: + case IDC_PORT1_JOYSMODE: + { + int port = -1; + if (LOWORD (wParam) == IDC_PORT0_JOYS || LOWORD (wParam) == IDC_PORT0_JOYSMODE) + port = 0; + if (LOWORD (wParam) == IDC_PORT1_JOYS || LOWORD (wParam) == IDC_PORT1_JOYSMODE) + port = 1; + if (LOWORD (wParam) == IDC_PORT2_JOYS) + port = 2; + if (LOWORD (wParam) == IDC_PORT3_JOYS) + port = 3; + if (port >= 0) + processport (hDlg, true, port); + break; + } } } else { values_from_gameportsdlg (hDlg, 1); @@ -10456,7 +10682,8 @@ static INT_PTR CALLBACK IOPortsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPAR case IDC_PRINTERTYPELIST: { int item = SendDlgItemMessage (hDlg, IDC_PRINTERTYPELIST, CB_GETCURSEL, 0, 0L); - workprefs.parallel_postscript_detection = workprefs.parallel_postscript_emulation = workprefs.parallel_matrix_emulation = 0; + workprefs.parallel_postscript_detection = workprefs.parallel_postscript_emulation = false; + workprefs.parallel_matrix_emulation = 0; switch (item) { case 1: @@ -10469,11 +10696,11 @@ static INT_PTR CALLBACK IOPortsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPAR workprefs.parallel_matrix_emulation = PARALLEL_MATRIX_EPSON48; break; case 4: - workprefs.parallel_postscript_detection = 1; + workprefs.parallel_postscript_detection = true; break; case 5: - workprefs.parallel_postscript_detection = 1; - workprefs.parallel_postscript_emulation = 1; + workprefs.parallel_postscript_detection = true; + workprefs.parallel_postscript_emulation = true; break; } } @@ -10493,7 +10720,7 @@ static void values_to_inputdlg (HWND hDlg) SendDlgItemMessage (hDlg, IDC_INPUTTYPE, CB_SETCURSEL, workprefs.input_selected_setting, 0); SendDlgItemMessage (hDlg, IDC_INPUTDEVICE, CB_SETCURSEL, input_selected_device, 0); SetDlgItemInt (hDlg, IDC_INPUTDEADZONE, workprefs.input_joystick_deadzone, FALSE); - SetDlgItemInt (hDlg, IDC_INPUTAUTOFIRERATE, workprefs.input_autofire_framecnt, FALSE); + SetDlgItemInt (hDlg, IDC_INPUTAUTOFIRERATE, workprefs.input_autofire_linecnt, FALSE); SetDlgItemInt (hDlg, IDC_INPUTSPEEDD, workprefs.input_joymouse_speed, FALSE); SetDlgItemInt (hDlg, IDC_INPUTSPEEDA, workprefs.input_joymouse_multiplier, FALSE); CheckDlgButton (hDlg, IDC_INPUTDEVICEDISABLE, (!input_total_devices || inputdevice_get_device_status (input_selected_device)) ? BST_CHECKED : BST_UNCHECKED); @@ -10545,7 +10772,6 @@ static int askinputcustom (HWND hDlg, TCHAR *custom, int maxlen, DWORD titleid) } txt[0] = 0; SendMessage (GetDlgItem (hwnd, IDC_STRINGBOXEDIT), WM_SETTEXT, 0, (LPARAM)custom); - SetFocus (GetDlgItem (hwnd, IDC_STRINGBOXEDIT)); while (stringboxdialogactive == 1) { MSG msg; int ret; @@ -10567,13 +10793,13 @@ static int askinputcustom (HWND hDlg, TCHAR *custom, int maxlen, DWORD titleid) return 0; } -static void init_inputdlg_2(HWND hDlg) +static void init_inputdlg_2 (HWND hDlg) { TCHAR name1[256], name2[256]; TCHAR custom1[MAX_DPATH], tmp1[MAX_DPATH]; int cnt, index, af, aftmp; - if (input_selected_widget < 0 || workprefs.input_selected_setting == 0) { + if (input_selected_widget < 0 || workprefs.input_selected_setting == GAMEPORT_INPUT_SETTINGS) { EnableWindow (GetDlgItem (hDlg, IDC_INPUTAMIGA), FALSE); } else { EnableWindow (GetDlgItem (hDlg, IDC_INPUTAMIGA), TRUE); @@ -10611,23 +10837,22 @@ static void init_inputdlg (HWND hDlg) TCHAR buf[100], txt[100]; SendDlgItemMessage (hDlg, IDC_INPUTTYPE, CB_RESETCONTENT, 0, 0L); - WIN32GUI_LoadUIString (IDS_INPUT_COMPATIBILITY, buf, sizeof (buf) / sizeof (TCHAR)); - SendDlgItemMessage (hDlg, IDC_INPUTTYPE, CB_ADDSTRING, 0, (LPARAM)buf); WIN32GUI_LoadUIString (IDS_INPUT_CUSTOM, buf, sizeof (buf) / sizeof (TCHAR)); - for (i = 0; i < 4; i++) { + for (i = 0; i < GAMEPORT_INPUT_SETTINGS; i++) { _stprintf (txt, buf, i + 1); SendDlgItemMessage (hDlg, IDC_INPUTTYPE, CB_ADDSTRING, 0, (LPARAM)txt); } + WIN32GUI_LoadUIString (IDS_INPUT_GAMEPORTS, buf, sizeof (buf) / sizeof (TCHAR)); + SendDlgItemMessage (hDlg, IDC_INPUTTYPE, CB_ADDSTRING, 0, (LPARAM)buf); SendDlgItemMessage (hDlg, IDC_INPUTCOPYFROM, CB_RESETCONTENT, 0, 0L); - WIN32GUI_LoadUIString (IDS_INPUT_COPY_DEFAULT, buf, sizeof (buf) / sizeof (TCHAR)); - SendDlgItemMessage (hDlg, IDC_INPUTCOPYFROM, CB_ADDSTRING, 0, (LPARAM)L"GamePorts"); - SendDlgItemMessage (hDlg, IDC_INPUTCOPYFROM, CB_ADDSTRING, 0, (LPARAM)buf); WIN32GUI_LoadUIString (IDS_INPUT_COPY_CUSTOM, buf, sizeof (buf) / sizeof (TCHAR)); - for (i = 0; i < 4; i++) { + for (i = 0; i < MAX_INPUT_SETTINGS - 1; i++) { _stprintf (txt, buf, i + 1); SendDlgItemMessage (hDlg, IDC_INPUTCOPYFROM, CB_ADDSTRING, 0, (LPARAM)txt); } + WIN32GUI_LoadUIString (IDS_INPUT_COPY_DEFAULT, buf, sizeof (buf) / sizeof (TCHAR)); + SendDlgItemMessage (hDlg, IDC_INPUTCOPYFROM, CB_ADDSTRING, 0, (LPARAM)buf); SendDlgItemMessage (hDlg, IDC_INPUTCOPYFROM, CB_SETCURSEL, 0, 0); @@ -10660,18 +10885,19 @@ static void init_inputdlg (HWND hDlg) static void enable_for_inputdlg (HWND hDlg) { - int v = workprefs.input_selected_setting == 0 ? FALSE : TRUE; + bool v = workprefs.input_selected_setting != GAMEPORT_INPUT_SETTINGS; ew (hDlg, IDC_INPUTLIST, TRUE); ew (hDlg, IDC_INPUTAMIGA, v); ew (hDlg, IDC_INPUTAMIGACNT, TRUE); ew (hDlg, IDC_INPUTDEADZONE, TRUE); - ew (hDlg, IDC_INPUTAUTOFIRERATE, v); - ew (hDlg, IDC_INPUTSPEEDA, v); - ew (hDlg, IDC_INPUTSPEEDD, v); + ew (hDlg, IDC_INPUTAUTOFIRERATE, TRUE); + ew (hDlg, IDC_INPUTSPEEDA, TRUE); + ew (hDlg, IDC_INPUTSPEEDD, TRUE); ew (hDlg, IDC_INPUTCOPY, v); ew (hDlg, IDC_INPUTCOPYFROM, v); ew (hDlg, IDC_INPUTSWAP, v); ew (hDlg, IDC_INPUTDEVICEDISABLE, v); + ew (hDlg, IDC_INPUTREMAP, v); } static void clearinputlistview (HWND hDlg) @@ -10706,7 +10932,7 @@ static void values_from_inputdlgbottom (HWND hDlg) } v = GetDlgItemInt (hDlg, IDC_INPUTAUTOFIRERATE, &success, FALSE); if (success) - currprefs.input_autofire_framecnt = workprefs.input_autofire_framecnt = v; + currprefs.input_autofire_linecnt = workprefs.input_autofire_linecnt = v; v = GetDlgItemInt (hDlg, IDC_INPUTSPEEDD, &success, FALSE); if (success) currprefs.input_joymouse_speed = workprefs.input_joymouse_speed = v; @@ -10784,20 +11010,376 @@ static void input_swap (HWND hDlg) init_inputdlg (hDlg); } +static void input_find (HWND hDlg, int mode, int set); +static int rawmode; +static int inputmap_remap_counter; + +static void CALLBACK timerfunc (HWND hDlg, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) +{ + if (idEvent != 1) + return; + int inputmap; + WINDOWINFO pwi; + pwi.cbSize = sizeof pwi; + if (GetWindowInfo (guiDlg, &pwi)) { + // GUI inactive = disable capturing + if (pwi.dwWindowStatus != WS_ACTIVECAPTION) { + input_find (hDlg, 0, false); + return; + } + } + if (currentpage == INPUTMAP_ID) { + inputmap = inputmap_remap_counter >= 0 ? 1 : 2; + setfocus (hDlg, IDC_INPUTMAPLIST); + } else { + inputmap = 0; + setfocus (hDlg, IDC_INPUTLIST); + } + int inputmap_index; + int devnum, wtype, state; + int cnt = inputdevice_testread_count (); + if (cnt < 0) { + input_find (hDlg, 0, FALSE); + return; + } + if (!cnt) + return; + int ret = inputdevice_testread (&devnum, &wtype, &state); + if (ret > 0) { + if (wtype < 0) { + if (!state) + return; + if (inputmap == 1) { + int mode, *events, *axistable; + HWND h = GetDlgItem (hDlg, IDC_INPUTMAPLIST); + inputmap_remap_counter++; + ListView_EnsureVisible (h, inputmap_remap_counter, FALSE); + ListView_SetItemState (h, -1, 0, LVIS_SELECTED | LVIS_FOCUSED); + ListView_SetItemState (h, inputmap_remap_counter, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); + int max = inputdevice_get_compatibility_input (&workprefs, inputmap_port, &mode, &events, &axistable); + if (inputmap_remap_counter >= max) + inputmap_remap_counter = -1; + } + return; + } + if (input_selected_widget != devnum || input_selected_widget != wtype) { + int od = input_selected_device; + input_selected_device = devnum; + input_selected_widget = wtype; + int type = inputdevice_get_widget_type (input_selected_device, input_selected_widget, NULL); + + if (inputmap == 1) { // ports panel / remap + static int skipbuttonaxis; + + HWND h = GetDlgItem (hDlg, IDC_INPUTMAPLIST); + int mode, *events, *axistable, *axistable2; + int cntadd = 1; + + int max = inputdevice_get_compatibility_input (&workprefs, inputmap_port, &mode, &events, &axistable); + int evtnum = events[inputmap_remap_counter]; + int type2 = intputdevice_compa_get_eventtype (evtnum, &axistable2); + + if (type == IDEV_WIDGET_BUTTONAXIS) { + if (skipbuttonaxis) { + skipbuttonaxis = false; + return; + } + if (type2 != IDEV_WIDGET_BUTTON && type2 != IDEV_WIDGET_KEY) + return; + } + if (type == IDEV_WIDGET_AXIS) { + skipbuttonaxis = false; + if (type2 == IDEV_WIDGET_BUTTON || type2 == IDEV_WIDGET_KEY) + return; + if (type2 == IDEV_WIDGET_BUTTONAXIS) { + if (inputmap_remap_counter & 1) + return; + // use VERT or HORIZ events, not UP/DOWN/LEFT/RIGHT + evtnum = axistable2[0]; + cntadd = 2; + skipbuttonaxis = true; + } + } + + struct inputevent *ie = inputdevice_get_eventinfo (evtnum); + TCHAR name[256]; + inputdevice_get_eventname (ie, name); + //write_log (L"%d %d %d %s\n", input_selected_device, input_selected_widget, evtnum, name); + int sub = 0; + if (inputdevice_get_widget_type (input_selected_device, input_selected_widget, NULL) != IDEV_WIDGET_KEY) { + for (sub = 0; sub < MAX_INPUT_SUB_EVENT; sub++) { + if (!inputdevice_get_mapped_name (input_selected_device, input_selected_widget, NULL, NULL, NULL, sub)) + break; + } + } + if (sub >= MAX_INPUT_SUB_EVENT) + sub = MAX_INPUT_SUB_EVENT - 1; + inputdevice_set_mapping (input_selected_device, input_selected_widget, name, NULL, 0, sub); + InitializeListView (hDlg); + inputmap_remap_counter += cntadd; + ListView_EnsureVisible (h, inputmap_remap_counter, FALSE); + ListView_SetItemState (h, -1, 0, LVIS_SELECTED | LVIS_FOCUSED); + ListView_SetItemState (h, inputmap_remap_counter, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); + if (inputmap_remap_counter >= max) + inputmap_remap_counter = -1; + TCHAR tmp[256]; + tmp[0] = 0; + inputdevice_get_widget_type (input_selected_device, input_selected_widget, tmp); + _tcscat (tmp, L", "); + _tcscat (tmp, inputdevice_get_device_name2 (input_selected_device)); + SetWindowText (GetDlgItem (hDlg, IDC_INPUTMAPOUT), tmp); + + } else if (inputmap == 2) { // ports panel / test + + static int toggle, skipactive; + if (cnt == 2 && !skipactive) { + toggle ^= 1; + skipactive = 2; + } + if (skipactive) { + skipactive--; + if (cnt == 2 && toggle) + return; + if (cnt == 1 && !toggle) + return; + } + + bool found = false; + HWND h = GetDlgItem (hDlg, IDC_INPUTMAPLIST); + int op = inputmap_port; + if (inputmap_handle (NULL, input_selected_device, input_selected_widget, &op, &inputmap_index, state)) { + if (op == inputmap_port) { + ListView_EnsureVisible (h, inputmap_index, FALSE); + ListView_SetItemState (h, -1, 0, LVIS_SELECTED | LVIS_FOCUSED); + ListView_SetItemState (h, inputmap_index, LVIS_SELECTED , LVIS_SELECTED); + ListView_SetItemState (h, inputmap_index, LVIS_FOCUSED, LVIS_FOCUSED); + found = true; + } + } + if (!found) { + ListView_SetItemState (h, -1, 0, LVIS_SELECTED | LVIS_FOCUSED); + } + TCHAR tmp[256]; + tmp[0] = 0; + inputdevice_get_widget_type (input_selected_device, input_selected_widget, tmp); + _tcscat (tmp, L", "); + _tcscat (tmp, inputdevice_get_device_name2 (input_selected_device)); + SetWindowText (GetDlgItem (hDlg, IDC_INPUTMAPOUT), tmp); + + } else { + // input panel + + static int toggle, skipactive; + if (cnt == 2 && !skipactive) { + toggle ^= 1; + skipactive = 2; + } + if (skipactive) { + skipactive--; + if (cnt == 2 && toggle) + return; + if (cnt == 1 && !toggle) + return; + } + + if (rawmode == 1) { + inputdevice_set_device_status (devnum, TRUE); + values_to_inputdlg (hDlg); + } + if (od != devnum) + init_inputdlg (hDlg); + else + init_inputdlg_2 (hDlg); + ListView_EnsureVisible (GetDlgItem (hDlg, IDC_INPUTLIST), input_selected_widget, FALSE); + ListView_SetItemState (GetDlgItem (hDlg, IDC_INPUTLIST), -1, 0, LVIS_SELECTED | LVIS_FOCUSED); + ListView_SetItemState (GetDlgItem (hDlg, IDC_INPUTLIST), input_selected_widget, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); + if (rawmode == 1) { + input_find (hDlg, 0, FALSE); + setfocus (hDlg, IDC_INPUTAMIGA); + SendDlgItemMessage (hDlg, IDC_INPUTAMIGA, CB_SHOWDROPDOWN , TRUE, 0L); + } + } + } + } +} + +static HWND updatePanel (int id); + +static int rawdisable[] = { IDC_PANELTREE, 0, IDC_RESETAMIGA, 0, IDC_QUITEMU, 0, IDC_RESTARTEMU, 0, IDOK, 0, IDCANCEL, 0, IDHELP, 0, -1 }; + +static void input_find (HWND hDlg, int mode, int set) +{ + static TCHAR tmp[200]; + if (set && !rawmode) { + rawmode = mode ? 2 : 1; + inputdevice_acquire (-1); + inputdevice_settest (TRUE); + if (rawmode == 2) { + TCHAR tmp2[MAX_DPATH]; + GetWindowText (guiDlg, tmp, sizeof tmp / sizeof (TCHAR)); + WIN32GUI_LoadUIString (IDS_REMAPTITLE, tmp2, sizeof tmp2 / sizeof (TCHAR)); + SetWindowText (guiDlg, tmp2); + } + SetTimer (hDlg, 1, 30, timerfunc); + ew (hDlg, IDC_INPUTREMAP, FALSE); + ew (hDlg, IDC_INPUTTEST, FALSE); + for (int i = 0; rawdisable[i] >= 0; i += 2) { + rawdisable[i + 1] = IsWindowEnabled (GetDlgItem (guiDlg, rawdisable[i])); + EnableWindow (GetDlgItem (guiDlg, rawdisable[i]), FALSE); + } + ShowCursor (FALSE); + SetCapture (guiDlg); + RECT r; + GetWindowRect (guiDlg, &r); + ClipCursor (&r); + } else if (rawmode) { + KillTimer (hDlg, 1); + ClipCursor (NULL); + ReleaseCapture (); + ShowCursor (TRUE); + inputdevice_unacquire (); + for (int i = 0; rawdisable[i] >= 0; i += 2) + EnableWindow (GetDlgItem (guiDlg, rawdisable[i]), rawdisable[i + 1]); + ew (hDlg, IDC_INPUTREMAP, TRUE); + ew (hDlg, IDC_INPUTTEST, TRUE); + inputdevice_settest (FALSE); + if (rawmode == 2) { + SetWindowText (guiDlg, tmp); + SetFocus (hDlg); + } + rawmode = FALSE; + if (currentpage == INPUTMAP_ID) + updatePanel (GAMEPORTS_ID); + } +} + +static void ports_remap (HWND hDlg, int port) +{ + workprefs.input_selected_setting = GAMEPORT_INPUT_SETTINGS; + inputmap_port_remap = port; + inputmap_port = port; + inputmap_remap_counter = 0; + updatePanel (INPUTMAP_ID); +} +static void input_test (HWND hDlg, int port) +{ + workprefs.input_selected_setting = GAMEPORT_INPUT_SETTINGS; + inputmap_port_remap = -1; + inputmap_port = port; + inputmap_remap_counter = -1; + updatePanel (INPUTMAP_ID); +} + #if 0 -static void input_copy (HWND hDlg) +static void input_test (HWND hDlg, int port) +{ + inputmap_port_remap = -1; + inputmap_port =-1; + updatePanel (INPUTMAP_ID); + for (int idx = 0; idx < MAX_JPORTS; idx++) { + int mode, **events, *axistable; + write_log (L"Port: %d\n", idx); + if (inputdevice_get_compatibility_input (&workprefs, idx, &mode, &events, &axistable)) { + for (int k = 0; k < 2 && events[k]; k++) { + int *p = events[k]; + int evtnum; + for (int i = 0; (evtnum = p[i]) >= 0; i++) { + int devnum; + struct inputevent *evt = inputdevice_get_eventinfo (evtnum); + int flags, status; + TCHAR name[256]; + bool found = false; + int *atp = axistable; + int atpidx; + + write_log (L"- %d: %s = ", i, evt->name); + atpidx = 0; + while (*atp >= 0) { + if (*atp == evtnum) { + atp++; + atpidx = 2; + break; + } + if (atp[1] == evtnum || atp[2] == evtnum) { + atpidx = 1; + break; + } + atp += 3; + } + while (atpidx >= 0) { + devnum = 0; + while ((status = inputdevice_get_device_status (devnum)) >= 0) { + if (status) { + for (int j = 0; j < inputdevice_get_widget_num (devnum); j++) { + if (inputdevice_get_mapped_name (devnum, j, &flags, NULL, NULL, 0) == evtnum) { + inputdevice_get_widget_type (devnum, j, name); + write_log (L"[%s, %s]", inputdevice_get_device_name2 (devnum), name); + found = true; + } + } + } + devnum++; + } + evtnum = *atp++; + atpidx--; + } + if (!found) + write_log (L""); + write_log (L"\n"); + } + } + } else { + write_log (L""); + } + write_log (L"\n"); + } + +} +#endif + +static INT_PTR CALLBACK InputMapDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - TCHAR buf[2000]; - inputdevice_acquire (1); - for (;;) { - if (inputdevice_testread (buf)) - break; - Sleep (100); + static int recursive; + + switch (msg) + { + case WM_INITDIALOG: + { + pages[INPUTMAP_ID] = hDlg; + currentpage = INPUTMAP_ID; + inputdevice_updateconfig (&workprefs); + if (inputmap_remap_counter == 0) { + inputdevice_compa_prepare_custom (&workprefs, inputmap_port); + inputdevice_updateconfig (&workprefs); + } + InitializeListView (hDlg); + HWND h = GetDlgItem (hDlg, IDC_INPUTMAPLIST); + if (inputmap_remap_counter == 0) { + ListView_EnsureVisible (h, inputmap_remap_counter, FALSE); + ListView_SetItemState (h, -1, 0, LVIS_SELECTED | LVIS_FOCUSED); + ListView_SetItemState (h, inputmap_remap_counter, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); + } + input_find (hDlg, 1, true); + } + case WM_USER: + recursive++; + recursive--; + return TRUE; + case WM_DESTROY: + input_find (hDlg, 0, false); + break; + } + return 0; +} + +static void handlerawinput (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + if (msg == WM_INPUT) { + handle_rawinput (lParam); + DefWindowProc (hDlg, msg, wParam, lParam); } - inputdevice_unacquire (); } -#else static void input_copy (HWND hDlg) { int dst = workprefs.input_selected_setting; @@ -10805,15 +11387,11 @@ static void input_copy (HWND hDlg) if (src == CB_ERR) return; int v = (int)src; - if (v == 0) { - inputdevice_mergeconfig (&workprefs); - } else if (v >= 1 && v <= 5) { - v--; + if (v >= 0 && v <= 3) { inputdevice_copy_single_config (&workprefs, v, workprefs.input_selected_setting, input_selected_device); } init_inputdlg (hDlg); } -#endif static void input_toggleautofire (void) { @@ -10857,12 +11435,14 @@ static INT_PTR CALLBACK InputDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM switch (msg) { case WM_INITDIALOG: + recursive++; pages[INPUT_ID] = hDlg; currentpage = INPUT_ID; inputdevice_updateconfig (&workprefs); inputdevice_config_change (); input_selected_widget = -1; init_inputdlg (hDlg); + recursive--; case WM_USER: recursive++; @@ -10870,12 +11450,21 @@ static INT_PTR CALLBACK InputDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM values_to_inputdlg (hDlg); recursive--; return TRUE; + case WM_DESTROY: + input_find (hDlg, 0, false); + break; case WM_COMMAND: if (recursive) break; recursive++; switch (wParam) { + case IDC_INPUTREMAP: + input_find (hDlg, 0, true); + break; + case IDC_INPUTTEST: + input_find (hDlg, 1, true); + break; case IDC_INPUTCOPY: input_copy (hDlg); break; @@ -10883,7 +11472,7 @@ static INT_PTR CALLBACK InputDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM input_swap (hDlg); break; case IDC_INPUTDEVICEDISABLE: - inputdevice_set_device_status (input_selected_device, IsDlgButtonChecked (hDlg, IDC_INPUTDEVICEDISABLE) ? 1 : 0); + inputdevice_set_device_status (input_selected_device, ischecked (hDlg, IDC_INPUTDEVICEDISABLE)); break; default: switch (LOWORD (wParam)) @@ -10950,6 +11539,7 @@ static INT_PTR CALLBACK InputDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM } } } + handlerawinput (hDlg, msg, wParam, lParam); return FALSE; } @@ -11088,9 +11678,9 @@ struct filterpreset { }; static struct filterpreset filterpresets[] = { - { L"PAL", UAE_FILTER_PAL, 0, 0, 0, 0, 0, 0, 0, 50, 0, 0, 1, 1, 0, 0, 0, 10, 0, 0, 0, 300, 30, 0, 0, 0 }, - { L"D3D Autoscale", 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 1 }, - { L"D3D Full Scaling", 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0 }, + { L"PAL", UAE_FILTER_PAL, 0, 0, 0, 0, 0, 0, 0, 50, 0, 0, 1, 1, 0, 0, 0, 10, 0, 0, 0, 300, 30, 0, 0, 0 }, + { L"D3D Autoscale", UAE_FILTER_NULL, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 1 }, + { L"D3D Full Scaling", UAE_FILTER_NULL, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0 }, { NULL } }; @@ -11184,8 +11774,6 @@ static void values_to_hw3ddlg (HWND hDlg) SendDlgItemMessage (hDlg, IDC_FILTERMODE, CB_RESETCONTENT, 0, 0L); WIN32GUI_LoadUIString (IDS_NONE, tmp, MAX_DPATH); SendDlgItemMessage (hDlg, IDC_FILTERMODE, CB_ADDSTRING, 0, (LPARAM)tmp); - SendDlgItemMessage (hDlg, IDC_FILTEROVERLAY, CB_ADDSTRING, 0, (LPARAM)tmp); - SendDlgItemMessage (hDlg, IDC_FILTEROVERLAY, CB_SETCURSEL, 0, 0); uf = NULL; fltnum = 0; i = 0; j = 1; @@ -11221,6 +11809,10 @@ static void values_to_hw3ddlg (HWND hDlg) } } if (workprefs.gfx_api && D3D_goodenough ()) { + WIN32GUI_LoadUIString (IDS_NONE, tmp, MAX_DPATH); + SendDlgItemMessage (hDlg, IDC_FILTERMODE, CB_ADDSTRING, 0, (LPARAM)tmp); + SendDlgItemMessage (hDlg, IDC_FILTEROVERLAY, CB_ADDSTRING, 0, (LPARAM)tmp); + SendDlgItemMessage (hDlg, IDC_FILTEROVERLAY, CB_SETCURSEL, 0, 0); HANDLE h; WIN32_FIND_DATA wfd; TCHAR tmp[MAX_DPATH]; @@ -11244,6 +11836,10 @@ static void values_to_hw3ddlg (HWND hDlg) h = INVALID_HANDLE_VALUE; } } + } else { + WIN32GUI_LoadUIString (IDS_FILTER_NOOVERLAYS, tmp, MAX_DPATH); + SendDlgItemMessage (hDlg, IDC_FILTEROVERLAY, CB_ADDSTRING, 0, (LPARAM)tmp); + SendDlgItemMessage (hDlg, IDC_FILTEROVERLAY, CB_SETCURSEL, 0, 0); } SendDlgItemMessage (hDlg, IDC_FILTERMODE, CB_SETCURSEL, fltnum, 0); @@ -11583,7 +12179,7 @@ static INT_PTR CALLBACK hw3dDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM break; case IDC_FILTERKEEPASPECT: { - if (IsDlgButtonChecked (hDlg, IDC_FILTERKEEPASPECT)) + if (ischecked (hDlg, IDC_FILTERKEEPASPECT)) currprefs.gfx_filter_keep_aspect = workprefs.gfx_filter_keep_aspect = 1; else currprefs.gfx_filter_keep_aspect = workprefs.gfx_filter_keep_aspect = 0; @@ -11856,23 +12452,23 @@ static INT_PTR CALLBACK AVIOutputDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP { case IDC_AVIOUTPUT_FRAMELIMITER: - avioutput_framelimiter = IsDlgButtonChecked (hDlg, IDC_AVIOUTPUT_FRAMELIMITER) ? 0 : 1; + avioutput_framelimiter = ischecked (hDlg, IDC_AVIOUTPUT_FRAMELIMITER) ? 0 : 1; AVIOutput_SetSettings (); break; case IDC_AVIOUTPUT_NOSOUNDOUTPUT: - avioutput_nosoundoutput = IsDlgButtonChecked (hDlg, IDC_AVIOUTPUT_NOSOUNDOUTPUT) ? 1 : 0; + avioutput_nosoundoutput = ischecked (hDlg, IDC_AVIOUTPUT_NOSOUNDOUTPUT) ? 1 : 0; AVIOutput_SetSettings (); break; case IDC_AVIOUTPUT_NOSOUNDSYNC: - avioutput_nosoundsync = IsDlgButtonChecked (hDlg, IDC_AVIOUTPUT_NOSOUNDSYNC) ? 1 : 0; + avioutput_nosoundsync = ischecked (hDlg, IDC_AVIOUTPUT_NOSOUNDSYNC) ? 1 : 0; AVIOutput_SetSettings (); break; case IDC_AVIOUTPUT_ORIGINALSIZE: - avioutput_originalsize = IsDlgButtonChecked (hDlg, IDC_AVIOUTPUT_ORIGINALSIZE) ? 1 : 0; + avioutput_originalsize = ischecked (hDlg, IDC_AVIOUTPUT_ORIGINALSIZE) ? 1 : 0; AVIOutput_SetSettings (); break; case IDC_SCREENSHOT_ORIGINALSIZE: - screenshot_originalsize = IsDlgButtonChecked (hDlg, IDC_SCREENSHOT_ORIGINALSIZE) ? 1 : 0; + screenshot_originalsize = ischecked (hDlg, IDC_SCREENSHOT_ORIGINALSIZE) ? 1 : 0; regsetint (NULL, L"Screenshot_Original", screenshot_originalsize); break; @@ -11916,7 +12512,7 @@ static INT_PTR CALLBACK AVIOutputDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP { if (avioutput_enabled) AVIOutput_End (); - if(IsDlgButtonChecked (hDlg, IDC_AVIOUTPUT_AUDIO) == BST_CHECKED) { + if(ischecked (hDlg, IDC_AVIOUTPUT_AUDIO)) { avioutput_audio = AVIOutput_ChooseAudioCodec (hDlg, tmp, sizeof tmp / sizeof (TCHAR)); enable_for_avioutputdlg (hDlg); } else { @@ -11929,7 +12525,7 @@ static INT_PTR CALLBACK AVIOutputDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP { if (avioutput_enabled) AVIOutput_End (); - if(IsDlgButtonChecked (hDlg, IDC_AVIOUTPUT_VIDEO) == BST_CHECKED) { + if(ischecked (hDlg, IDC_AVIOUTPUT_VIDEO)) { avioutput_video = AVIOutput_ChooseVideoCodec (hDlg, tmp, sizeof tmp / sizeof (TCHAR)); if (avioutput_audio = AVIAUDIO_WAV) avioutput_audio = 0; @@ -11988,19 +12584,6 @@ static INT_PTR CALLBACK AVIOutputDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP } #endif -struct GUIPAGE { - DLGPROC dlgproc; - LPCTSTR title; - LPCTSTR icon; - HTREEITEM tv; - int himg; - int idx; - const TCHAR *help; - HACCEL accel; - int fullpanel; - struct newresource *nres; -}; - static int GetPanelRect (HWND hDlg, RECT *r) { RECT rect; @@ -12212,20 +12795,29 @@ static BOOL CALLBACK childenumproc (HWND hwnd, LPARAM lParam) return 1; } -static struct GUIPAGE ppage[MAX_C_PAGES]; #define PANEL_X 174 #define PANEL_Y 12 #define PANEL_WIDTH 456 #define PANEL_HEIGHT 396 -static HWND updatePanel (HWND hDlg, int id) +static HWND updatePanel (int id) { + HWND hDlg = guiDlg; static HWND hwndTT; RECT r1c, r1w, r2c, r2w, r3c, r3w; int w, h, pw, ph, x , y, i; int fullpanel; struct newresource *tres; + if (cachedlist) { + if (lv_old_type >= 0) + lv_oldidx[lv_old_type] = ListView_GetTopIndex (cachedlist); + lv_oldidx[lv_old_type] += ListView_GetCountPerPage (cachedlist) - 1; + cachedlist = NULL; + } + + if (id >= 0) + currentpage = id; ew (guiDlg, IDC_RESETAMIGA, full_property_sheet ? FALSE : TRUE); ew (guiDlg, IDOK, TRUE); if (panelDlg != NULL) { @@ -12311,6 +12903,10 @@ static HWND updatePanel (HWND hDlg, int id) hAccelTable = ppage[currentpage].accel; + if (ppage[id].focusid > 0) { + setfocus (panelDlg, ppage[id].focusid); + } + return panelDlg; } @@ -12665,7 +13261,7 @@ static INT_PTR CALLBACK DialogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l static int recursive = 0; static int waitfornext; - switch(msg) + switch (msg) { case WM_DEVICECHANGE: { @@ -12685,7 +13281,7 @@ static INT_PTR CALLBACK DialogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l } if (doit) { inputdevice_devicechange (&workprefs); - updatePanel (hDlg, currentpage); + updatePanel (currentpage); waitfornext = 0; } } @@ -12713,16 +13309,16 @@ static INT_PTR CALLBACK DialogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l WIN32GUI_LoadUIString (IDS_STARTEMULATION, tmp, sizeof (tmp) / sizeof (TCHAR)); SetWindowText (GetDlgItem (guiDlg, IDOK), tmp); } - ShowWindow (GetDlgItem(guiDlg, IDC_RESTARTEMU), full_property_sheet ? SW_HIDE : SW_SHOW); + ShowWindow (GetDlgItem (guiDlg, IDC_RESTARTEMU), full_property_sheet ? SW_HIDE : SW_SHOW); centerWindow (hDlg); createTreeView (hDlg, currentpage); - updatePanel (hDlg, currentpage); + updatePanel (currentpage); addnotifications (hDlg, FALSE, TRUE); return TRUE; case WM_DROPFILES: if (dragdrop (hDlg, (HDROP)wParam, (gui_active || full_property_sheet) ? &workprefs : &changed_prefs, currentpage)) SendMessage (hDlg, WM_COMMAND, IDOK, 0); - updatePanel (hDlg, currentpage); + updatePanel (currentpage); return FALSE; case WM_NOTIFY: { @@ -12737,9 +13333,8 @@ static INT_PTR CALLBACK DialogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l cp = (int)(tv->itemNew.lParam & 0xffff); cf = (int)(tv->itemNew.lParam >> 16); if (cp != currentpage || cf != configtype) { - currentpage = cp; configtypepanel = configtype = cf; - updatePanel (hDlg, currentpage); + updatePanel (cp); } return TRUE; } @@ -12768,14 +13363,14 @@ static INT_PTR CALLBACK DialogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l HtmlHelp (NULL, help_file, HH_DISPLAY_TOPIC, ppage[currentpage].help); return TRUE; case IDOK: - updatePanel (hDlg, -1); + updatePanel (-1); dialogreturn = 1; DestroyWindow (hDlg); gui_to_prefs (); guiDlg = NULL; return TRUE; case IDCANCEL: - updatePanel (hDlg, -1); + updatePanel (-1); dialogreturn = 0; DestroyWindow (hDlg); if (allow_quit) { @@ -12788,6 +13383,7 @@ static INT_PTR CALLBACK DialogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l break; } } + handlerawinput (hDlg, msg, wParam, lParam); return FALSE; } @@ -12865,7 +13461,7 @@ HWND CustomCreateDialog (int templ, HWND hDlg, DLGPROC proc) } static int init_page (int tmpl, int icon, int title, - INT_PTR (CALLBACK FAR *func) (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam), ACCEL *accels, TCHAR *help) + INT_PTR (CALLBACK FAR *func) (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam), ACCEL *accels, TCHAR *help, int focusid) { LPTSTR lpstrTitle; static int id = 0; @@ -12877,13 +13473,16 @@ static int init_page (int tmpl, int icon, int title, return -1; ppage[id].nres = res; ppage[id].icon = MAKEINTRESOURCE (icon); - lpstrTitle = xcalloc (TCHAR, MAX_DPATH); - LoadString (hUIDLL, title, lpstrTitle, MAX_DPATH); - ppage[id].title = lpstrTitle; + if (title >= 0) { + lpstrTitle = xcalloc (TCHAR, MAX_DPATH); + LoadString (hUIDLL, title, lpstrTitle, MAX_DPATH); + ppage[id].title = lpstrTitle; + } ppage[id].dlgproc = func; ppage[id].help = help; ppage[id].idx = id; ppage[id].accel = NULL; + ppage[id].focusid = focusid; if (!accels) accels = EmptyAccel; while (accels[++i].key); @@ -12985,6 +13584,7 @@ static int GetSettings (int all_options, HWND hwnd) full_property_sheet = all_options; allow_quit = all_options; pguiprefs = &currprefs; + memset (&workprefs, 0, sizeof (struct uae_prefs)); default_prefs (&workprefs, 0); WIN32GUI_LoadUIString (IDS_NONE, szNone, MAX_DPATH); @@ -12993,35 +13593,36 @@ static int GetSettings (int all_options, HWND hwnd) if (!init_called) { first = 1; panelresource = getresource (IDD_PANEL); - LOADSAVE_ID = init_page (IDD_LOADSAVE, IDI_FILE, IDS_LOADSAVE, LoadSaveDlgProc, NULL, L"gui/configurations.htm"); - MEMORY_ID = init_page (IDD_MEMORY, IDI_MEMORY, IDS_MEMORY, MemoryDlgProc, NULL, L"gui/ram.htm"); - EXPANSION_ID = init_page (IDD_EXPANSION, IDI_EXPANSION, IDS_EXPANSION, ExpansionDlgProc, NULL, L"gui/expansion.htm"); - KICKSTART_ID = init_page (IDD_KICKSTART, IDI_MEMORY, IDS_KICKSTART, KickstartDlgProc, NULL, L"gui/rom.htm"); - CPU_ID = init_page (IDD_CPU, IDI_CPU, IDS_CPU, CPUDlgProc, NULL, L"gui/cpu.htm"); - DISPLAY_ID = init_page (IDD_DISPLAY, IDI_DISPLAY, IDS_DISPLAY, DisplayDlgProc, NULL, L"gui/display.htm"); + LOADSAVE_ID = init_page (IDD_LOADSAVE, IDI_FILE, IDS_LOADSAVE, LoadSaveDlgProc, NULL, L"gui/configurations.htm", IDC_CONFIGTREE); + MEMORY_ID = init_page (IDD_MEMORY, IDI_MEMORY, IDS_MEMORY, MemoryDlgProc, NULL, L"gui/ram.htm", 0); + EXPANSION_ID = init_page (IDD_EXPANSION, IDI_EXPANSION, IDS_EXPANSION, ExpansionDlgProc, NULL, L"gui/expansion.htm", 0); + KICKSTART_ID = init_page (IDD_KICKSTART, IDI_MEMORY, IDS_KICKSTART, KickstartDlgProc, NULL, L"gui/rom.htm", 0); + CPU_ID = init_page (IDD_CPU, IDI_CPU, IDS_CPU, CPUDlgProc, NULL, L"gui/cpu.htm", 0); + DISPLAY_ID = init_page (IDD_DISPLAY, IDI_DISPLAY, IDS_DISPLAY, DisplayDlgProc, NULL, L"gui/display.htm", 0); #if defined (GFXFILTER) - HW3D_ID = init_page (IDD_FILTER, IDI_DISPLAY, IDS_FILTER, hw3dDlgProc, NULL, L"gui/filter.htm"); + HW3D_ID = init_page (IDD_FILTER, IDI_DISPLAY, IDS_FILTER, hw3dDlgProc, NULL, L"gui/filter.htm", 0); #endif - CHIPSET_ID = init_page (IDD_CHIPSET, IDI_CPU, IDS_CHIPSET, ChipsetDlgProc, NULL, L"gui/chipset.htm"); - CHIPSET2_ID = init_page (IDD_CHIPSET2, IDI_CPU, IDS_CHIPSET2, ChipsetDlgProc2, NULL, L"gui/chipset.htm"); - SOUND_ID = init_page (IDD_SOUND, IDI_SOUND, IDS_SOUND, SoundDlgProc, NULL, L"gui/sound.htm"); - FLOPPY_ID = init_page (IDD_FLOPPY, IDI_FLOPPY, IDS_FLOPPY, FloppyDlgProc, NULL, L"gui/floppies.htm"); - DISK_ID = init_page (IDD_DISK, IDI_FLOPPY, IDS_DISK, SwapperDlgProc, SwapperAccel, L"gui/disk.htm"); + CHIPSET_ID = init_page (IDD_CHIPSET, IDI_CPU, IDS_CHIPSET, ChipsetDlgProc, NULL, L"gui/chipset.htm", 0); + CHIPSET2_ID = init_page (IDD_CHIPSET2, IDI_CPU, IDS_CHIPSET2, ChipsetDlgProc2, NULL, L"gui/chipset.htm", 0); + SOUND_ID = init_page (IDD_SOUND, IDI_SOUND, IDS_SOUND, SoundDlgProc, NULL, L"gui/sound.htm", 0); + FLOPPY_ID = init_page (IDD_FLOPPY, IDI_FLOPPY, IDS_FLOPPY, FloppyDlgProc, NULL, L"gui/floppies.htm", 0); + DISK_ID = init_page (IDD_DISK, IDI_FLOPPY, IDS_DISK, SwapperDlgProc, SwapperAccel, L"gui/disk.htm", IDC_DISKLIST); #ifdef FILESYS - HARDDISK_ID = init_page (IDD_HARDDISK, IDI_HARDDISK, IDS_HARDDISK, HarddiskDlgProc, HarddiskAccel, L"gui/hard-drives.htm"); + HARDDISK_ID = init_page (IDD_HARDDISK, IDI_HARDDISK, IDS_HARDDISK, HarddiskDlgProc, HarddiskAccel, L"gui/hard-drives.htm", 0); #endif - GAMEPORTS_ID = init_page (IDD_GAMEPORTS, IDI_GAMEPORTS, IDS_GAMEPORTS, GamePortsDlgProc, NULL, L"gui/gameports.htm"); - IOPORTS_ID = init_page (IDD_IOPORTS, IDI_PORTS, IDS_IOPORTS, IOPortsDlgProc, NULL, L"gui/ioports.htm"); - INPUT_ID = init_page (IDD_INPUT, IDI_INPUT, IDS_INPUT, InputDlgProc, NULL, L"gui/input.htm"); - MISC1_ID = init_page (IDD_MISC1, IDI_MISC1, IDS_MISC1, MiscDlgProc1, NULL, L"gui/misc.htm"); - MISC2_ID = init_page (IDD_MISC2, IDI_MISC2, IDS_MISC2, MiscDlgProc2, NULL, L"gui/misc2.htm"); + GAMEPORTS_ID = init_page (IDD_GAMEPORTS, IDI_GAMEPORTS, IDS_GAMEPORTS, GamePortsDlgProc, NULL, L"gui/gameports.htm", 0); + INPUTMAP_ID = init_page (IDD_INPUTMAP, IDI_GAMEPORTS, IDS_GAMEPORTS, InputMapDlgProc, NULL, NULL, IDC_INPUTMAPLIST); + IOPORTS_ID = init_page (IDD_IOPORTS, IDI_PORTS, IDS_IOPORTS, IOPortsDlgProc, NULL, L"gui/ioports.htm", 0); + INPUT_ID = init_page (IDD_INPUT, IDI_INPUT, IDS_INPUT, InputDlgProc, NULL, L"gui/input.htm", IDC_INPUTLIST); + MISC1_ID = init_page (IDD_MISC1, IDI_MISC1, IDS_MISC1, MiscDlgProc1, NULL, L"gui/misc.htm", 0); + MISC2_ID = init_page (IDD_MISC2, IDI_MISC2, IDS_MISC2, MiscDlgProc2, NULL, L"gui/misc2.htm", 0); #ifdef AVIOUTPUT - AVIOUTPUT_ID = init_page (IDD_AVIOUTPUT, IDI_AVIOUTPUT, IDS_AVIOUTPUT, AVIOutputDlgProc, NULL, L"gui/output.htm"); + AVIOUTPUT_ID = init_page (IDD_AVIOUTPUT, IDI_AVIOUTPUT, IDS_AVIOUTPUT, AVIOutputDlgProc, NULL, L"gui/output.htm", 0); #endif - PATHS_ID = init_page (IDD_PATHS, IDI_PATHS, IDS_PATHS, PathsDlgProc, NULL, L"gui/paths.htm"); - QUICKSTART_ID = init_page (IDD_QUICKSTART, IDI_QUICKSTART, IDS_QUICKSTART, QuickstartDlgProc, NULL, L"gui/quickstart.htm"); - ABOUT_ID = init_page (IDD_ABOUT, IDI_ABOUT, IDS_ABOUT, AboutDlgProc, NULL, NULL); - FRONTEND_ID = init_page (IDD_FRONTEND, IDI_QUICKSTART, IDS_FRONTEND, AboutDlgProc, NULL, NULL); + PATHS_ID = init_page (IDD_PATHS, IDI_PATHS, IDS_PATHS, PathsDlgProc, NULL, L"gui/paths.htm", 0); + QUICKSTART_ID = init_page (IDD_QUICKSTART, IDI_QUICKSTART, IDS_QUICKSTART, QuickstartDlgProc, NULL, L"gui/quickstart.htm", 0); + ABOUT_ID = init_page (IDD_ABOUT, IDI_ABOUT, IDS_ABOUT, AboutDlgProc, NULL, NULL, 0); + FRONTEND_ID = init_page (IDD_FRONTEND, IDI_QUICKSTART, IDS_FRONTEND, AboutDlgProc, NULL, NULL, 0); C_PAGES = FRONTEND_ID + 1; init_called = 1; if (quickstart && !qs_override) @@ -13038,7 +13639,6 @@ static int GetSettings (int all_options, HWND hwnd) DragAcceptFiles (hwnd, TRUE); if (first) write_log (L"Entering GUI idle loop\n"); - //blah(); scaleresource_setmaxsize (800, 600); tres = scaleresource (panelresource, hwnd); @@ -13055,7 +13655,6 @@ static int GetSettings (int all_options, HWND hwnd) setguititle (dhwnd); ShowWindow (dhwnd, SW_SHOW); MapDialogRect (dhwnd, &dialog_rect); - hGUIWnd = dhwnd; for (;;) { HANDLE IPChandle; @@ -13074,11 +13673,21 @@ static int GetSettings (int all_options, HWND hwnd) continue; if (!IsWindow (dhwnd)) continue; - if (hAccelTable && panelDlg) { + if (hAccelTable && panelDlg && !rawmode) { if (TranslateAccelerator (panelDlg, hAccelTable, &msg)) continue; } - if (IsDialogMessage (dhwnd, &msg)) + if (rawmode) { + if (msg.message == WM_INPUT) { + handlerawinput (msg.hwnd, msg.message, msg.wParam, msg.lParam); + continue; + } + // eat all keyboard accelerators + if (msg.message == WM_KEYDOWN) + continue; + } + // IsDialogMessage() eats WM_INPUT messages?!?! + if (!rawmode && IsDialogMessage (dhwnd, &msg)) continue; TranslateMessage (&msg); DispatchMessage (&msg); diff --git a/od-win32/winuae_msvc10/winuae_msvc.sln b/od-win32/winuae_msvc10/winuae_msvc.sln index 090d5ee3..f0d5bad3 100644 --- a/od-win32/winuae_msvc10/winuae_msvc.sln +++ b/od-win32/winuae_msvc10/winuae_msvc.sln @@ -28,6 +28,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "consolewrapper", "..\consol EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "prowizard", "..\prowizard\prowizard.vcxproj", "{8627DA33-98D1-4F60-B404-ECCEE0EE7BF9}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unpackers", "..\unpackers\unpackers.vcxproj", "{98BA115B-829F-4085-9729-ABD0D779A60A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -130,6 +132,15 @@ Global {8627DA33-98D1-4F60-B404-ECCEE0EE7BF9}.FullRelease|x64.ActiveCfg = Release|Win32 {8627DA33-98D1-4F60-B404-ECCEE0EE7BF9}.Release|Win32.ActiveCfg = Release|Win32 {8627DA33-98D1-4F60-B404-ECCEE0EE7BF9}.Release|x64.ActiveCfg = Release|x64 + {98BA115B-829F-4085-9729-ABD0D779A60A}.Debug|Win32.ActiveCfg = Debug|Win32 + {98BA115B-829F-4085-9729-ABD0D779A60A}.Debug|Win32.Build.0 = Debug|Win32 + {98BA115B-829F-4085-9729-ABD0D779A60A}.Debug|x64.ActiveCfg = Debug|Win32 + {98BA115B-829F-4085-9729-ABD0D779A60A}.FullRelease|Win32.ActiveCfg = Release|Win32 + {98BA115B-829F-4085-9729-ABD0D779A60A}.FullRelease|Win32.Build.0 = Release|Win32 + {98BA115B-829F-4085-9729-ABD0D779A60A}.FullRelease|x64.ActiveCfg = Release|Win32 + {98BA115B-829F-4085-9729-ABD0D779A60A}.Release|Win32.ActiveCfg = Release|Win32 + {98BA115B-829F-4085-9729-ABD0D779A60A}.Release|Win32.Build.0 = Release|Win32 + {98BA115B-829F-4085-9729-ABD0D779A60A}.Release|x64.ActiveCfg = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/od-win32/winuae_msvc10/winuae_msvc.vcxproj b/od-win32/winuae_msvc10/winuae_msvc.vcxproj index 12a0a0f7..2cc68dab 100644 --- a/od-win32/winuae_msvc10/winuae_msvc.vcxproj +++ b/od-win32/winuae_msvc10/winuae_msvc.vcxproj @@ -158,7 +158,7 @@ /MACHINE:I386 %(AdditionalOptions) - ws2_32.lib;ddraw.lib;dxguid.lib;winmm.lib;comctl32.lib;version.lib;msacm32.lib;dsound.lib;dinput8.lib;d3d9.lib;d3dx9d.lib;winio.lib;setupapi.lib;wininet.lib;dxerr.lib;shlwapi.lib;zlibstat.lib;libpng.lib;lglcd.lib;wpcap.lib;packet.lib;openal32.lib;wintab32.lib;portaudio_x86.lib;freetype.lib;vfw32.lib;wtsapi32.lib;enet.lib;prowizard.lib;%(AdditionalDependencies) + ws2_32.lib;ddraw.lib;dxguid.lib;winmm.lib;comctl32.lib;version.lib;msacm32.lib;dsound.lib;dinput8.lib;d3d9.lib;d3dx9d.lib;winio.lib;setupapi.lib;wininet.lib;dxerr.lib;shlwapi.lib;zlibstat.lib;libpng.lib;lglcd.lib;wpcap.lib;packet.lib;openal32.lib;wintab32.lib;portaudio_x86.lib;vfw32.lib;wtsapi32.lib;enet.lib;prowizard.lib;lzmalib.lib;%(AdditionalDependencies) NotSet d:\amiga\winuae.exe true @@ -173,7 +173,7 @@ false - %(AdditionalLibraryDirectories) + %(AdditionalLibraryDirectories);$(SolutionDir)\..\lib\ @@ -217,11 +217,11 @@ 0x0409 - ws2_32.lib;ddraw.lib;dxguid.lib;winmm.lib;comctl32.lib;version.lib;vfw32.lib;msacm32.lib;dsound.lib;dinput8.lib;d3d9.lib;d3dx9.lib;setupapi.lib;wininet.lib;dxerr.lib;shlwapi.lib;zlibstat.lib;portaudio_x64.lib;packet.lib;wpcap.lib;openal32.lib;libpng.lib;lglcd.lib;wtsapi32.lib;wntab32x.lib;enet_x64.lib;prowizard.lib;%(AdditionalDependencies) + ws2_32.lib;ddraw.lib;dxguid.lib;winmm.lib;comctl32.lib;version.lib;vfw32.lib;msacm32.lib;dsound.lib;dinput8.lib;d3d9.lib;d3dx9.lib;setupapi.lib;wininet.lib;dxerr.lib;shlwapi.lib;zlibstat.lib;portaudio_x64.lib;packet.lib;wpcap.lib;openal32.lib;libpng.lib;lglcd.lib;wtsapi32.lib;wntab32x.lib;enet_x64.lib;prowizard_x64.lib;%(AdditionalDependencies) d:\amiga\winuae64.exe true - MSVCRT.lib;%(IgnoreSpecificDefaultLibraries) - wpcap.dll;packet.dll;d3dx9_42.dll;openal32.dll;wintab32.dll;portaudio_x64.dll;freetype6.dll;ws2_32.dll;msacm32.dll;wtsapi32.dll;dsound.dll;avrt.dll;%(DelayLoadDLLs) + %(IgnoreSpecificDefaultLibraries) + wpcap.dll;packet.dll;d3dx9_42.dll;openal32.dll;wintab32.dll;portaudio_x64.dll;ws2_32.dll;msacm32.dll;wtsapi32.dll;dsound.dll;%(DelayLoadDLLs) true $(Platform)\$(Configuration)\winuae.pdb Windows @@ -232,6 +232,7 @@ MachineX64 + %(AdditionalLibraryDirectories);$(SolutionDir)\..\lib\ ..\resources\winuae64.exe.manifest;%(AdditionalManifestFiles) @@ -259,7 +260,7 @@ Default MultiThreaded false - false + true NotSet Precise false @@ -283,10 +284,10 @@ 0x0409 - ws2_32.lib;ddraw.lib;dxguid.lib;winmm.lib;comctl32.lib;version.lib;msacm32.lib;dsound.lib;dinput8.lib;d3d9.lib;d3dx9.lib;winio.lib;setupapi.lib;wininet.lib;dxerr.lib;shlwapi.lib;zlibstat.lib;libpng.lib;lglcd.lib;wpcap.lib;packet.lib;openal32.lib;wintab32.lib;portaudio_x86.lib;freetype.lib;vfw32.lib;wtsapi32.lib;enet.lib;prowizard.lib;%(AdditionalDependencies) + ws2_32.lib;ddraw.lib;dxguid.lib;winmm.lib;comctl32.lib;version.lib;msacm32.lib;dsound.lib;dinput8.lib;d3d9.lib;d3dx9.lib;winio.lib;setupapi.lib;wininet.lib;dxerr.lib;shlwapi.lib;zlibstat.lib;libpng.lib;lglcd.lib;wpcap.lib;packet.lib;openal32.lib;wintab32.lib;portaudio_x86.lib;vfw32.lib;wtsapi32.lib;enet.lib;lzmalib.lib;prowizard.lib;%(AdditionalDependencies) d:\amiga\winuae.exe true - %(AdditionalLibraryDirectories) + %(AdditionalLibraryDirectories);$(SolutionDir)\..\lib\ %(AdditionalManifestDependencies) %(IgnoreSpecificDefaultLibraries) wpcap.dll;packet.dll;d3dx9_42.dll;openal32.dll;wintab32.dll;portaudio_x86.dll;ws2_32.dll;msacm32.dll;wtsapi32.dll;dsound.dll;wininet.dll;%(DelayLoadDLLs) @@ -304,7 +305,8 @@ false true MachineX86 - 5 + + ..\resources\winuae.exe.manifest;%(AdditionalManifestFiles) @@ -328,8 +330,7 @@ ..\..\include;..\..;..\;..\resources;..\osdep;..\sounddep;%(AdditionalIncludeDirectories) WINVER=0x0500;NDEBUG;_WIN32_IE=0x0700;WIN32;WIN64;%(PreprocessorDefinitions) true - - + false Default MultiThreaded false @@ -338,8 +339,7 @@ Precise false false - - + NotUsing $(Platform)\$(Configuration)/winuae_msvc.pch $(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ @@ -357,13 +357,13 @@ 0x0409 - ws2_32.lib;ddraw.lib;dxguid.lib;winmm.lib;comctl32.lib;version.lib;vfw32.lib;msacm32.lib;dsound.lib;dinput8.lib;d3d9.lib;d3dx9.lib;setupapi.lib;wininet.lib;dxerr.lib;shlwapi.lib;zlibstat.lib;portaudio_x64.lib;packet.lib;wpcap.lib;openal32.lib;libpng.lib;lglcd.lib;wtsapi32.lib;wntab32x.lib;enet_x64.lib;prowizard.lib;%(AdditionalDependencies) + ws2_32.lib;ddraw.lib;dxguid.lib;winmm.lib;comctl32.lib;version.lib;vfw32.lib;msacm32.lib;dsound.lib;dinput8.lib;d3d9.lib;d3dx9.lib;setupapi.lib;wininet.lib;dxerr.lib;shlwapi.lib;zlibstat.lib;portaudio_x64.lib;packet.lib;wpcap.lib;openal32.lib;libpng.lib;lglcd.lib;wtsapi32.lib;wntab32x.lib;enet_x64.lib;prowizard_x64.lib;%(AdditionalDependencies) NotSet d:\amiga\winuae64.exe true - %(AdditionalLibraryDirectories) - MSVCRT.lib;%(IgnoreSpecificDefaultLibraries) - wpcap.dll;packet.dll;d3dx9_42.dll;openal32.dll;wintab32.dll;portaudio_x64.dll;freetype6.dll;ws2_32.dll;msacm32.dll;wtsapi32.dll;dsound.dll;avrt.dll;%(DelayLoadDLLs) + %(AdditionalLibraryDirectories);$(SolutionDir)\..\lib\ + %(IgnoreSpecificDefaultLibraries) + wpcap.dll;packet.dll;d3dx9_42.dll;openal32.dll;wintab32.dll;portaudio_x64.dll;ws2_32.dll;msacm32.dll;wtsapi32.dll;dsound.dll;%(DelayLoadDLLs) true $(Platform)\$(Configuration)\winuae.pdb Windows @@ -429,10 +429,10 @@ 0x0409 - ws2_32.lib;ddraw.lib;dxguid.lib;winmm.lib;comctl32.lib;version.lib;msacm32.lib;dsound.lib;dinput8.lib;d3d9.lib;d3dx9.lib;winio.lib;setupapi.lib;wininet.lib;dxerr.lib;shlwapi.lib;zlibstat.lib;libpng.lib;lglcd.lib;wpcap.lib;packet.lib;openal32.lib;wintab32.lib;portaudio_x86.lib;freetype.lib;vfw32.lib;wtsapi32.lib;avrt.lib;wininet.lib;enet.lib;prowizard.lib;%(AdditionalDependencies) + ws2_32.lib;ddraw.lib;dxguid.lib;winmm.lib;comctl32.lib;version.lib;msacm32.lib;dsound.lib;dinput8.lib;d3d9.lib;d3dx9.lib;winio.lib;setupapi.lib;wininet.lib;dxerr.lib;shlwapi.lib;zlibstat.lib;libpng.lib;lglcd.lib;wpcap.lib;packet.lib;openal32.lib;wintab32.lib;portaudio_x86.lib;vfw32.lib;wtsapi32.lib;avrt.lib;enet.lib;prowizard.lib;lzmalib.lib;%(AdditionalDependencies) d:\amiga\winuae.exe true - %(AdditionalLibraryDirectories) + %(AdditionalLibraryDirectories);$(SolutionDir)\..\lib\ %(AdditionalManifestDependencies) %(IgnoreSpecificDefaultLibraries) wpcap.dll;packet.dll;d3dx9_42.dll;openal32.dll;wintab32.dll;portaudio_x86.dll;ws2_32.dll;msacm32.dll;wtsapi32.dll;dsound.dll;wininet.dll;%(DelayLoadDLLs) @@ -449,7 +449,8 @@ false true MachineX86 - 5 + + ..\resources\winuae9.exe.manifest;%(AdditionalManifestFiles) @@ -506,8 +507,8 @@ NotSet d:\amiga\winuae64.exe true - %(AdditionalLibraryDirectories) - MSVCRT.lib;%(IgnoreSpecificDefaultLibraries) + %(AdditionalLibraryDirectories);$(SolutionDir)\..\lib\ + %(IgnoreSpecificDefaultLibraries) wpcap.dll;packet.dll;d3dx9_42.dll;openal32.dll;wintab32.dll;portaudio_x64.dll;freetype6.dll;ws2_32.dll;msacm32.dll;wtsapi32.dll;dsound.dll;avrt.dll;%(DelayLoadDLLs) true $(Platform)\$(Configuration)\winuae.pdb @@ -527,6 +528,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -647,44 +674,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/od-win32/winuae_msvc10/winuae_msvc.vcxproj.filters b/od-win32/winuae_msvc10/winuae_msvc.vcxproj.filters index c64a3035..a7858e1f 100644 --- a/od-win32/winuae_msvc10/winuae_msvc.vcxproj.filters +++ b/od-win32/winuae_msvc10/winuae_msvc.vcxproj.filters @@ -20,29 +20,26 @@ {dab2f6c7-d741-4002-b0c9-566a1536642a} - - {f3ce6c07-bb5c-47dc-9e59-5e4acd06ff0d} + + {a88602d5-1980-49b2-a87a-79afa3ca7346} - - {ae0450a0-e0ff-442b-8896-a21eb8769fae} + + {6b855260-58da-4be4-b914-621ca2e33ca5} - - {c52448a0-4965-449e-bbdd-e8cb8bf9227a} + + {1af2c9da-63ab-4226-8b97-5544a0a34433} - - {492ad99e-6cf0-486b-8e97-083a9e50bb7c} + + {99d2fcb7-e014-45fe-a543-4a9b9242a35b} - - {d030c158-bae4-4025-9d74-bfe643846c44} + + {d2f2439b-d15d-47d5-bb26-1a9436aef770} - - {4abb311e-366e-4c88-bb5f-0086611a1145} + + {d69b4a6c-84db-480b-8b80-60a2a3646f6e} - - {4c157cd6-e04e-4dfa-ad84-a5e9f8abc1ed} - - - {43856f2f-e043-4cfe-aa2a-a767858d8ea4} + + {93fcf20a-8921-43e8-b4b9-e5fceb81332d} @@ -403,122 +400,86 @@ prowizard + + win32 + - decompressors\dms + unpackers\dms - decompressors\dms + unpackers\dms - decompressors\dms + unpackers\dms - decompressors\dms + unpackers\dms - decompressors\dms + unpackers\dms - decompressors\dms + unpackers\dms - decompressors\dms + unpackers\dms - decompressors\dms + unpackers\dms - decompressors\dms + unpackers\dms - decompressors\dms + unpackers\dms - decompressors\dms - - - decompressors\7z - - - decompressors\7z - - - decompressors\7z - - - decompressors\7z - - - decompressors\7z - - - decompressors\7z - - - decompressors\7z - - - decompressors\7z - - - decompressors\7z - - - decompressors\7z - - - decompressors\7z - - - decompressors\7z - - - decompressors\7z + unpackers\dms - decompressors\lha + unpackers\lha - decompressors\lha + unpackers\lha - decompressors\lha + unpackers\lha - decompressors\lha + unpackers\lha - decompressors\lha + unpackers\lha - decompressors\lha + unpackers\lha - decompressors\lha + unpackers\lha - decompressors\lha + unpackers\lha - decompressors\lha + unpackers\lha - decompressors\lha + unpackers\lha - decompressors\lha - - - decompressors\zip + unpackers\lha - decompressors\lzx + unpackers\lzx - decompressors\wrp + unpackers\wrp - - win32 + + unpackers\zip + + + common diff --git a/rommgr.cpp b/rommgr.cpp index 21cf7f93..2996f976 100644 --- a/rommgr.cpp +++ b/rommgr.cpp @@ -73,7 +73,7 @@ void romlist_add (TCHAR *path, struct romdata *rd) } -struct romdata *getromdatabypath(TCHAR *path) +struct romdata *getromdatabypath (TCHAR *path) { int i; for (i = 0; i < romlist_cnt; i++) { @@ -474,7 +474,7 @@ struct romdata *getarcadiarombyname (TCHAR *name) return NULL; } -struct romlist **getarcadiaroms(void) +struct romlist **getarcadiaroms (void) { int i, out, max; void *buf; @@ -686,7 +686,7 @@ void free_keyring (void) memset(keyring, 0, sizeof (struct rom_key) * ROM_KEY_NUM); } -struct romdata *getromdatabyname (TCHAR *name) +struct romdata *getromdatabyname (const TCHAR *name) { TCHAR tmp[MAX_PATH]; int i = 0; @@ -900,9 +900,11 @@ struct romdata *getromdatabyzfile (struct zfile *f) pos = zfile_ftell (f); zfile_fseek (f, 0, SEEK_END); size = zfile_ftell (f); + if (size > 2048 * 1024) + return NULL; p = xmalloc (uae_u8, size); if (!p) - return 0; + return NULL; memset (p, 0, size); zfile_fseek (f, 0, SEEK_SET); zfile_fread (p, 1, size, f); diff --git a/zfile.cpp b/zfile.cpp index 97285cdf..2f5ecf7d 100644 --- a/zfile.cpp +++ b/zfile.cpp @@ -31,7 +31,7 @@ static struct zfile *zlist = 0; -const TCHAR *uae_archive_extensions[] = { L"zip", L"rar", L"7z", L"lha", L"lzh", L"lzx", L"tar", NULL }; +const TCHAR *uae_archive_extensions[] = { L"zip", L"rar", L"7z", L"xz", L"lha", L"lzh", L"lzx", L"tar", NULL }; #define MAX_CACHE_ENTRIES 10 @@ -391,6 +391,8 @@ static uae_s64 vhd_fread (void *data, uae_u64 l1, uae_u64 l2, struct zfile *zf) uae_u64 out = 0; int len = 0; + if (!l1 || !l2) + return 0; if ((zf->seek & 511) || (size & 511)) { uae_u8 tmp[512]; @@ -1142,14 +1144,14 @@ static const TCHAR *archive_extensions[] = { L"hdf", L"tar", NULL }; -static const TCHAR *plugins_7z[] = { L"7z", L"rar", L"zip", L"lha", L"lzh", L"lzx", L"adf", L"dsq", L"hdf", L"tar", NULL }; -static const uae_char *plugins_7z_x[] = { "7z", "Rar!", "MK", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; +static const TCHAR *plugins_7z[] = { L"7z", L"xz", L"rar", L"zip", L"lha", L"lzh", L"lzx", L"adf", L"dsq", L"hdf", L"tar", NULL }; +static const uae_char *plugins_7z_x[] = { "7z", "xz", "Rar!", "MK", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; static const int plugins_7z_t[] = { - ArchiveFormat7Zip, ArchiveFormatRAR, ArchiveFormatZIP, ArchiveFormatLHA, ArchiveFormatLHA, ArchiveFormatLZX, + ArchiveFormat7Zip, ArchiveFormatXZ, ArchiveFormatRAR, ArchiveFormatZIP, ArchiveFormatLHA, ArchiveFormatLHA, ArchiveFormatLZX, ArchiveFormatADF, ArchiveFormatADF, ArchiveFormatADF, ArchiveFormatTAR }; static const int plugins_7z_m[] = { - ZFD_ARCHIVE, ZFD_ARCHIVE, ZFD_ARCHIVE, ZFD_ARCHIVE, ZFD_ARCHIVE, ZFD_ARCHIVE, + ZFD_ARCHIVE, ZFD_ARCHIVE, ZFD_ARCHIVE, ZFD_ARCHIVE, ZFD_ARCHIVE, ZFD_ARCHIVE, ZFD_ARCHIVE, ZFD_ADF, ZFD_ADF, ZFD_ADF, ZFD_ARCHIVE }; @@ -1181,6 +1183,11 @@ int iszip (struct zfile *z) return ArchiveFormat7Zip; return 0; } + if (!strcasecmp (ext, L".xz")) { + if (header[1] == '7' && header[2] == 'z' && header[3] == 'X' && header[4] == 'Z') + return ArchiveFormatXZ; + return 0; + } if (!strcasecmp (ext, L".rar")) { if (header[0] == 'R' && header[1] == 'a' && header[2] == 'r' && header[3] == '!') return ArchiveFormatRAR; @@ -1254,6 +1261,8 @@ struct zfile *zuncompress (struct znode *parent, struct zfile *z, int dodefault, if (mask & ZFD_ARCHIVE) { if (strcasecmp (ext, L"7z") == 0) return archive_access_select (parent, z, ArchiveFormat7Zip, dodefault, retcode, index); + if (strcasecmp (ext, L"xz") == 0) + return archive_access_select (parent, z, ArchiveFormatXZ, dodefault, retcode, index); if (strcasecmp (ext, L"zip") == 0) return archive_access_select (parent, z, ArchiveFormatZIP, dodefault, retcode, index); if (strcasecmp (ext, L"lha") == 0 || strcasecmp (ext, L"lzh") == 0) @@ -1575,6 +1584,9 @@ static struct zfile *zfile_fopen_x (const TCHAR *name, const TCHAR *mode, int ma } zfile_fseek (l, 0, SEEK_SET); break; + } else { + if (l2->parent == l) + l->opencnt--; } l = l2; } @@ -1758,6 +1770,7 @@ struct zfile *zfile_dup (struct zfile *zf) nzf->data = xmalloc (uae_u8, zf->size); memcpy (nzf->data, zf->data, zf->size); nzf->size = zf->size; + nzf->datasize = zf->datasize; } else if (zf->zipname) { nzf = openzip (zf->name); return nzf; @@ -1805,6 +1818,7 @@ struct zfile *zfile_fopen_empty (struct zfile *prev, const TCHAR *name, uae_u64 return NULL; } l->size = size; + l->datasize = size; } else { l->data = xcalloc (uae_u8, 1); l->size = 0; @@ -1824,6 +1838,7 @@ struct zfile *zfile_fopen_parent (struct zfile *z, const TCHAR *name, uae_u64 of else if (z->name) l->name = my_strdup (z->name); l->size = size; + l->datasize = size; l->offset = offset; for (;;) { l->parent = z; @@ -1845,6 +1860,7 @@ struct zfile *zfile_fopen_data (const TCHAR *name, uae_u64 size, uae_u8 *data) l->name = name ? my_strdup (name) : L""; l->data = xmalloc (uae_u8, size); l->size = size; + l->datasize = size; memcpy (l->data, data, size); return l; } @@ -1900,6 +1916,9 @@ size_t zfile_fread (void *b, size_t l1, size_t l2, struct zfile *z) if (z->zfileread) return z->zfileread (b, l1, l2, z); if (z->data) { + if (z->datasize < z->size && z->seek + l1 * l2 > z->datasize) { + ; + } if (z->seek + l1 * l2 > z->size) { if (l1) l2 = (z->size - z->seek) / l1; @@ -2378,6 +2397,8 @@ static struct zvolume *zfile_fopen_archive_ext (struct znode *parent, struct zfi zv = archive_directory_zip (zf); if (strcasecmp (ext, L"7z") == 0) zv = archive_directory_7z (zf); + if (strcasecmp (ext, L"xz") == 0) + zv = archive_directory_xz (zf); if (strcasecmp (ext, L"lzx") == 0) zv = archive_directory_lzx (zf); if (strcasecmp (ext, L"rar") == 0) @@ -2471,7 +2492,7 @@ static int zfile_fopen_archive_recurse (struct zvolume *zv) } } if (!done) { - z = archive_getzfile (zn, zv->method); + z = archive_getzfile (zn, zv->method, 0); if (z && iszip (z)) zfile_fopen_archive_recurse2 (zv, zn); } @@ -2973,7 +2994,7 @@ struct zfile *zfile_open_archive (const TCHAR *path, int flags) } if (zn->vfile) zn = zn->vfile; - z = archive_getzfile (zn, zn->volume->id); + z = archive_getzfile (zn, zn->volume->id, 0); if (z) zfile_fseek (z, 0, SEEK_SET); zn->f = z; @@ -3044,4 +3065,4 @@ TCHAR *zfile_geterror (void) void zfile_seterror (const TCHAR *format, ...) { } -#endif \ No newline at end of file +#endif diff --git a/zfile_archive.cpp b/zfile_archive.cpp index 836aaa42..1aea5222 100644 --- a/zfile_archive.cpp +++ b/zfile_archive.cpp @@ -6,11 +6,14 @@ * 2007 Toni Wilen */ -#define ZLIB_WINAPI - #include "sysconfig.h" #include "sysdeps.h" +#ifdef _WIN32 +#include +#include "win32.h" +#endif + #include "options.h" #include "zfile.h" #include "archivers/zip/unzip.h" @@ -21,10 +24,7 @@ #include -#ifdef _WIN32 -#include -#include "win32.h" -#endif + static time_t fromdostime (uae_u32 dd) { @@ -56,6 +56,9 @@ static struct zvolume *getzvolume (struct znode *parent, struct zfile *zf, unsig case ArchiveFormat7Zip: zv = archive_directory_7z (zf); break; + case ArchiveFormatXZ: + zv = archive_directory_xz (zf); + break; case ArchiveFormatRAR: zv = archive_directory_rar (zf); break; @@ -86,14 +89,14 @@ static struct zvolume *getzvolume (struct znode *parent, struct zfile *zf, unsig return zv; } -struct zfile *archive_getzfile (struct znode *zn, unsigned int id) +struct zfile *archive_getzfile (struct znode *zn, unsigned int id, int flags) { struct zfile *zf = NULL; switch (id) { case ArchiveFormatZIP: - zf = archive_access_zip (zn); + zf = archive_access_zip (zn, flags); break; case ArchiveFormat7Zip: zf = archive_access_7z (zn); @@ -138,7 +141,8 @@ struct zfile *archive_access_select (struct znode *parent, struct zfile *zf, uns struct zfile *z = NULL; int we_have_file; int diskimg; - int canhistory = (zf->zfdmask & ZFD_DISKHISTORY) && !(zf->zfdmask & ZFD_CHECKONLY); + int mask = zf->zfdmask; + int canhistory = (mask & ZFD_DISKHISTORY) && !(mask & ZFD_CHECKONLY); if (retcode) *retcode = 0; @@ -188,28 +192,24 @@ struct zfile *archive_access_select (struct znode *parent, struct zfile *zf, uns select = -1; if (zf->zipname && zf->zipname[0] == '#' && _tstol (zf->zipname + 1) == zipcnt) select = -1; - if (select && we_have_file <= 0) { - struct zfile *zt = archive_getzfile (zn, id); + if (select && we_have_file < 10) { + struct zfile *zt = archive_getzfile (zn, id, 1); if (zt) { int ft = zfile_gettype (zt); - if (select < 0 || ft) { - int whf = 1; - if (ft == ZFILE_CDIMAGE) { - TCHAR *ext = _tcsrchr (zn->fullname, '.'); - if (ext && we_have_file == 0) { - if (!_tcsicmp (ext, L".iso")) - whf = -1; // accept .cue if found later - } - } else if (we_have_file < 0) { - whf = 0; // ignore non-cdimage files if iso was found - } - if (whf) { - we_have_file = whf; - if (z) - zfile_fclose (z); - z = zt; - zt = NULL; - } + TCHAR *ext = _tcsrchr (zn->fullname, '.'); + int whf = 1; + if ((mask & ZFD_CD) && ft) { + if (ext && !_tcsicmp (ext, L".iso")) + whf = 2; + if (ext && !_tcsicmp (ext, L".cue")) + whf = 10; + } + if ((select < 0 || ft) && whf > we_have_file) { + we_have_file = whf; + if (z) + zfile_fclose (z); + z = zt; + zt = NULL; } zfile_fclose (zt); } @@ -253,7 +253,7 @@ void archive_access_scan (struct zfile *zf, zfile_callback zc, void *user, unsig zn = &zv->root; while (zn) { if (zn->type == ZNODE_FILE) { - struct zfile *zf2 = archive_getzfile (zn, id); + struct zfile *zf2 = archive_getzfile (zn, id, 0); if (zf2) { int ztype = iszip (zf2); if (ztype) { @@ -382,7 +382,7 @@ struct zvolume *archive_directory_zip (struct zfile *z) filename_inzip = au (filename_inzip2); dd = file_info.dosDate; t = fromdostime (dd); - memset(&zai, 0, sizeof zai); + memset (&zai, 0, sizeof zai); zai.name = filename_inzip; zai.t = t; zai.flags = -1; @@ -408,7 +408,7 @@ struct zvolume *archive_directory_zip (struct zfile *z) } -struct zfile *archive_access_zip (struct znode *zn) +struct zfile *archive_access_zip (struct znode *zn, int flags) { struct zfile *z = NULL; unzFile uz = zn->volume->handle; @@ -442,7 +442,9 @@ struct zfile *archive_access_zip (struct znode *zn) return 0; z = zfile_fopen_empty (NULL, zn->fullname, zn->size); if (z) { - err = unzReadCurrentFile (uz, z->data, zn->size); +// if (flags) +// z->datasize = PEEK_BYTES; + err = unzReadCurrentFile (uz, z->data, z->datasize); } unzCloseCurrentFile (uz); return z; @@ -450,33 +452,36 @@ struct zfile *archive_access_zip (struct znode *zn) /* 7Z */ -#include "archivers/7z/Types.h" -#include "archivers/7z/7zCrc.h" -#include "archivers/7z/Archive/7z/7zIn.h" -#include "archivers/7z/Archive/7z/7zExtract.h" -#include "archivers/7z/Archive/7z/7zAlloc.h" - -static ISzAlloc allocImp; -static ISzAlloc allocTempImp; +#include "7z/7z.h" +#include "7z/Alloc.h" +#include "7z/7zFile.h" +#include "7z/7zVersion.h" +#include "7z/7zCrc.h" -typedef struct +static void *SzAlloc (void *p, size_t size) { - ISeekInStream s; - struct zfile *zf; -} CFileInStream; - + return xmalloc (uae_u8, size); +} +static void SzFree(void *p, void *address) +{ + xfree (address); +} +static ISzAlloc allocImp; +static ISzAlloc allocTempImp; static SRes SzFileReadImp (void *object, void *buffer, size_t *size) { CFileInStream *s = (CFileInStream *)object; - *size = zfile_fread (buffer, 1, *size, s->zf); + struct zfile *zf = (struct zfile*)s->file.myhandle; + *size = zfile_fread (buffer, 1, *size, zf); return SZ_OK; } static SRes SzFileSeekImp(void *object, Int64 *pos, ESzSeek origin) { CFileInStream *s = (CFileInStream *)object; + struct zfile *zf = (struct zfile*)s->file.myhandle; int org = 0; switch (origin) { @@ -484,9 +489,9 @@ static SRes SzFileSeekImp(void *object, Int64 *pos, ESzSeek origin) case SZ_SEEK_CUR: org = SEEK_CUR; break; case SZ_SEEK_END: org = SEEK_END; break; } - zfile_fseek (s->zf, *pos, org); - *pos = zfile_ftell (s->zf); - return 0; + zfile_fseek (zf, *pos, org); + *pos = zfile_ftell (zf); + return SZ_OK; } static void init_7z (void) @@ -498,8 +503,8 @@ static void init_7z (void) initialized = 1; allocImp.Alloc = SzAlloc; allocImp.Free = SzFree; - allocTempImp.Alloc = SzAllocTemp; - allocTempImp.Free = SzFreeTemp; + allocTempImp.Alloc = SzAlloc; + allocTempImp.Free = SzFree; CrcGenerateTable (); _tzset (); } @@ -525,6 +530,11 @@ static void archive_close_7z (void *ctx) #define EPOCH_DIFF 0x019DB1DED53E8000LL /* 116444736000000000 nsecs */ #define RATE_DIFF 10000000 /* 100 nsecs */ +struct zvolume *archive_directory_xz (struct zfile *z) +{ + return NULL; +} + struct zvolume *archive_directory_7z (struct zfile *z) { SRes res; @@ -537,7 +547,7 @@ struct zvolume *archive_directory_7z (struct zfile *z) ctx->blockIndex = 0xffffffff; ctx->archiveStream.s.Read = SzFileReadImp; ctx->archiveStream.s.Seek = SzFileSeekImp; - ctx->archiveStream.zf = z; + ctx->archiveStream.file.myhandle = (void*)z; LookToRead_CreateVTable (&ctx->lookStream, False); ctx->lookStream.realStream = &ctx->archiveStream.s; LookToRead_Init (&ctx->lookStream); @@ -552,12 +562,12 @@ struct zvolume *archive_directory_7z (struct zfile *z) zv = zvolume_alloc (z, ArchiveFormat7Zip, ctx, NULL); for (i = 0; i < ctx->db.db.NumFiles; i++) { CSzFileItem *f = ctx->db.db.Files + i; - TCHAR *name = au (f->Name); + TCHAR *name = (TCHAR*)(ctx->db.FileNames.data + ctx->db.FileNameOffsets[i] * 2); struct zarchive_info zai; memset(&zai, 0, sizeof zai); zai.name = name; - zai.flags = -1; + zai.flags = f->AttribDefined ? f->Attrib : -1; zai.size = f->Size; zai.t = 0; if (f->MTimeDefined) { @@ -573,12 +583,16 @@ struct zvolume *archive_directory_7z (struct zfile *z) struct znode *zn = zvolume_addfile_abs (zv, &zai); zn->offset = i; } - xfree (name); } zv->method = ArchiveFormat7Zip; return zv; } +struct zfile *archive_access_xz (struct znode *zn) +{ + return NULL; +} + struct zfile *archive_access_7z (struct znode *zn) { SRes res; @@ -589,7 +603,7 @@ struct zfile *archive_access_7z (struct znode *zn) struct SevenZContext *ctx; ctx = (struct SevenZContext*)zv->handle; - res = SzAr_Extract (&ctx->db, &ctx->lookStream.s, zn->offset, + res = SzArEx_Extract (&ctx->db, &ctx->lookStream.s, zn->offset, &ctx->blockIndex, &ctx->outBuffer, &ctx->outBufferSize, &offset, &outSizeProcessed, &allocImp, &allocTempImp); @@ -690,7 +704,8 @@ static int rar_resetf (struct zfile *z) static void archive_close_rar (void *ctx) { - xfree ((struct RARContext*)ctx); + struct RARContext* rc = (struct RARContext*)ctx; + xfree (rc); } struct zvolume *archive_directory_rar (struct zfile *z) @@ -898,7 +913,7 @@ struct zvolume *archive_directory_arcacc (struct zfile *z, unsigned int id) if (!arcacc_init (z)) return NULL; - zv = zvolume_alloc (z, id, NULL, NULL); + zv = zvolume_alloc (z, ArchiveFormatAA, NULL, NULL); id_r = arcacc_push (z); ah = aaOpenArchive (readCallback, id_r, zv->archivesize, id, &status, NULL); if (!status) {