From: Toni Wilen Date: Sat, 31 Mar 2012 12:58:29 +0000 (+0300) Subject: 2410b1 X-Git-Tag: 2410~13 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=828e4de552af222f94fcc1bafb4f606d9e783cd0;p=francis%2Fwinuae.git 2410b1 --- diff --git a/calc.cpp b/calc.cpp index 20963764..ec774a04 100644 --- a/calc.cpp +++ b/calc.cpp @@ -12,7 +12,7 @@ */ -#define CALC_DEBUG 0 +#define CALC_DEBUG 1 #if CALC_DEBUG #define calc_log(x) do { write_log x; } while(0) diff --git a/cfgfile.cpp b/cfgfile.cpp index a2c9afc2..7643f05a 100644 --- a/cfgfile.cpp +++ b/cfgfile.cpp @@ -798,8 +798,12 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_dwrite_bool (f, _T("clipboard_sharing"), p->clipboard_sharing); cfgfile_dwrite_bool (f, _T("native_code"), p->native_code); - cfgfile_write (f, _T("gfx_display"), _T("%d"), p->gfx_display); - cfgfile_dwrite_str (f, _T("gfx_display_name"), p->gfx_display_name); + cfgfile_write (f, _T("gfx_display"), _T("%d"), p->gfx_apmode[APMODE_NATIVE].gfx_display); + cfgfile_dwrite_str (f, _T("gfx_display_name"), p->gfx_apmode[APMODE_NATIVE].gfx_display_name); + if (p->gfx_apmode[APMODE_NATIVE].gfx_display != p->gfx_apmode[APMODE_RTG].gfx_display || p->gfx_apmode[APMODE_RTG].gfx_display_name[0]) { + cfgfile_write (f, _T("gfx_display_rtg"), _T("%d"), p->gfx_apmode[APMODE_RTG].gfx_display); + cfgfile_dwrite_str (f, _T("gfx_display_name_rtg"), p->gfx_apmode[APMODE_RTG].gfx_display_name); + } cfgfile_write (f, _T("gfx_framerate"), _T("%d"), p->gfx_framerate); cfgfile_write (f, _T("gfx_width"), _T("%d"), p->gfx_size_win.width); /* compatibility with old versions */ cfgfile_write (f, _T("gfx_height"), _T("%d"), p->gfx_size_win.height); /* compatibility with old versions */ @@ -1026,10 +1030,12 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_write (f, _T("chipmem_size"), _T("%d"), p->chipmem_size == 0x20000 ? -1 : (p->chipmem_size == 0x40000 ? 0 : p->chipmem_size / 0x80000)); cfgfile_dwrite (f, _T("megachipmem_size"), _T("%d"), p->z3chipmem_size / 0x100000); - if (p->m68k_speed > 0) + if (p->m68k_speed > 0) { cfgfile_write (f, _T("finegrain_cpu_speed"), _T("%d"), p->m68k_speed); - else + } else { cfgfile_write_str (f, _T("cpu_speed"), p->m68k_speed < 0 ? _T("max") : _T("real")); + } + cfgfile_write (f, _T("cpu_throttle"), _T("%d"), p->m68k_speed_throttle); /* do not reorder start */ write_compatibility_cpu(f, p); @@ -1471,7 +1477,6 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) || cfgfile_intval (option, value, _T("sound_stereo_separation"), &p->sound_stereo_separation, 1) || cfgfile_intval (option, value, _T("sound_stereo_mixing_delay"), &p->sound_mixed_stereo_delay, 1) - || cfgfile_intval (option, value, _T("gfx_display"), &p->gfx_display, 1) || cfgfile_intval (option, value, _T("gfx_framerate"), &p->gfx_framerate, 1) || cfgfile_intval (option, value, _T("gfx_width_windowed"), &p->gfx_size_win.width, 1) || cfgfile_intval (option, value, _T("gfx_height_windowed"), &p->gfx_size_win.height, 1) @@ -1479,12 +1484,12 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) || cfgfile_intval (option, value, _T("gfx_left_windowed"), &p->gfx_size_win.y, 1) || cfgfile_intval (option, value, _T("gfx_width_fullscreen"), &p->gfx_size_fs.width, 1) || cfgfile_intval (option, value, _T("gfx_height_fullscreen"), &p->gfx_size_fs.height, 1) - || cfgfile_intval (option, value, _T("gfx_refreshrate"), &p->gfx_apmode[0].gfx_refreshrate, 1) - || cfgfile_intval (option, value, _T("gfx_refreshrate_rtg"), &p->gfx_apmode[1].gfx_refreshrate, 1) + || cfgfile_intval (option, value, _T("gfx_refreshrate"), &p->gfx_apmode[APMODE_NATIVE].gfx_refreshrate, 1) + || cfgfile_intval (option, value, _T("gfx_refreshrate_rtg"), &p->gfx_apmode[APMODE_RTG].gfx_refreshrate, 1) || cfgfile_yesno (option, value, _T("gfx_autoresolution"), &p->gfx_autoresolution) - || cfgfile_intval (option, value, _T("gfx_backbuffers"), &p->gfx_apmode[0].gfx_backbuffers, 1) - || cfgfile_intval (option, value, _T("gfx_backbuffers_rtg"), &p->gfx_apmode[1].gfx_backbuffers, 1) - || cfgfile_yesno (option, value, _T("gfx_interlace"), &p->gfx_apmode[0].gfx_interlaced) + || cfgfile_intval (option, value, _T("gfx_backbuffers"), &p->gfx_apmode[APMODE_NATIVE].gfx_backbuffers, 1) + || cfgfile_intval (option, value, _T("gfx_backbuffers_rtg"), &p->gfx_apmode[APMODE_RTG].gfx_backbuffers, 1) + || cfgfile_yesno (option, value, _T("gfx_interlace"), &p->gfx_apmode[APMODE_NATIVE].gfx_interlaced) || cfgfile_intval (option, value, _T("gfx_center_horizontal_position"), &p->gfx_xcenter_pos, 1) || cfgfile_intval (option, value, _T("gfx_center_vertical_position"), &p->gfx_ycenter_pos, 1) @@ -1526,7 +1531,6 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) || cfgfile_path (option, value, _T("floppy1soundext"), p->floppyslots[1].dfxclickexternal, sizeof p->floppyslots[1].dfxclickexternal / sizeof (TCHAR)) || cfgfile_path (option, value, _T("floppy2soundext"), p->floppyslots[2].dfxclickexternal, sizeof p->floppyslots[2].dfxclickexternal / sizeof (TCHAR)) || cfgfile_path (option, value, _T("floppy3soundext"), p->floppyslots[3].dfxclickexternal, sizeof p->floppyslots[3].dfxclickexternal / sizeof (TCHAR)) - || cfgfile_string (option, value, _T("gfx_display_name"), p->gfx_display_name, sizeof p->gfx_display_name / sizeof (TCHAR)) || cfgfile_string (option, value, _T("config_window_title"), p->config_window_title, sizeof p->config_window_title / sizeof (TCHAR)) || cfgfile_string (option, value, _T("config_info"), p->info, sizeof p->info / sizeof (TCHAR)) || cfgfile_string (option, value, _T("config_description"), p->description, sizeof p->description / sizeof (TCHAR))) @@ -1561,8 +1565,8 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) || cfgfile_strval (option, value, _T("gfx_resolution"), &p->gfx_resolution, lorestype1, 0) || cfgfile_strval (option, value, _T("gfx_lores"), &p->gfx_resolution, lorestype2, 0) || cfgfile_strval (option, value, _T("gfx_lores_mode"), &p->gfx_lores_mode, loresmode, 0) - || cfgfile_strval (option, value, _T("gfx_fullscreen_amiga"), &p->gfx_apmode[0].gfx_fullscreen, fullmodes, 0) - || cfgfile_strval (option, value, _T("gfx_fullscreen_picasso"), &p->gfx_apmode[1].gfx_fullscreen, fullmodes, 0) + || cfgfile_strval (option, value, _T("gfx_fullscreen_amiga"), &p->gfx_apmode[APMODE_NATIVE].gfx_fullscreen, fullmodes, 0) + || cfgfile_strval (option, value, _T("gfx_fullscreen_picasso"), &p->gfx_apmode[APMODE_RTG].gfx_fullscreen, fullmodes, 0) || cfgfile_strval (option, value, _T("gfx_center_horizontal"), &p->gfx_xcenter, centermode1, 1) || cfgfile_strval (option, value, _T("gfx_center_vertical"), &p->gfx_ycenter, centermode1, 1) || cfgfile_strval (option, value, _T("gfx_center_horizontal"), &p->gfx_xcenter, centermode2, 0) @@ -1580,6 +1584,22 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) || cfgfile_strval (option, value, _T("absolute_mouse"), &p->input_tablet, abspointers, 0)) return 1; + + if (cfgfile_intval (option, value, _T("gfx_display"), &p->gfx_apmode[APMODE_NATIVE].gfx_display, 1)) { + p->gfx_apmode[APMODE_RTG].gfx_display = p->gfx_apmode[APMODE_NATIVE].gfx_display; + return 1; + } + if (cfgfile_intval (option, value, _T("gfx_display_rtg"), &p->gfx_apmode[APMODE_RTG].gfx_display, 1)) { + return 1; + } + if (cfgfile_string (option, value, _T("gfx_display_name"), p->gfx_apmode[APMODE_NATIVE].gfx_display_name, sizeof p->gfx_apmode[APMODE_NATIVE].gfx_display_name / sizeof (TCHAR))) { + _tcscpy (p->gfx_apmode[APMODE_RTG].gfx_display_name, p->gfx_apmode[APMODE_NATIVE].gfx_display_name); + return 1; + } + if (cfgfile_string (option, value, _T("gfx_display_name_rtg"), p->gfx_apmode[APMODE_RTG].gfx_display_name, sizeof p->gfx_apmode[APMODE_RTG].gfx_display_name / sizeof (TCHAR))) { + return 1; + } + if (_tcscmp (option, _T("gfx_linemode")) == 0) { int v; p->gfx_vresolution = VRES_DOUBLE; @@ -1591,18 +1611,18 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) return 1; } if (_tcscmp (option, _T("gfx_vsync")) == 0) { - if (cfgfile_strval (option, value, _T("gfx_vsync"), &p->gfx_apmode[0].gfx_vsync, vsyncmodes, 0) >= 0) + if (cfgfile_strval (option, value, _T("gfx_vsync"), &p->gfx_apmode[APMODE_NATIVE].gfx_vsync, vsyncmodes, 0) >= 0) return 1; - return cfgfile_yesno (option, value, _T("gfx_vsync"), &p->gfx_apmode[0].gfx_vsync); + return cfgfile_yesno (option, value, _T("gfx_vsync"), &p->gfx_apmode[APMODE_NATIVE].gfx_vsync); } if (_tcscmp (option, _T("gfx_vsync_picasso")) == 0) { - if (cfgfile_strval (option, value, _T("gfx_vsync_picasso"), &p->gfx_apmode[1].gfx_vsync, vsyncmodes, 0) >= 0) + if (cfgfile_strval (option, value, _T("gfx_vsync_picasso"), &p->gfx_apmode[APMODE_RTG].gfx_vsync, vsyncmodes, 0) >= 0) return 1; - return cfgfile_yesno (option, value, _T("gfx_vsync_picasso"), &p->gfx_apmode[1].gfx_vsync); + return cfgfile_yesno (option, value, _T("gfx_vsync_picasso"), &p->gfx_apmode[APMODE_RTG].gfx_vsync); } - if (cfgfile_strval (option, value, _T("gfx_vsyncmode"), &p->gfx_apmode[0].gfx_vsyncmode, vsyncmodes2, 0)) + if (cfgfile_strval (option, value, _T("gfx_vsyncmode"), &p->gfx_apmode[APMODE_NATIVE].gfx_vsyncmode, vsyncmodes2, 0)) return 1; - if (cfgfile_strval (option, value, _T("gfx_vsyncmode_picasso"), &p->gfx_apmode[1].gfx_vsyncmode, vsyncmodes2, 0)) + if (cfgfile_strval (option, value, _T("gfx_vsyncmode_picasso"), &p->gfx_apmode[APMODE_RTG].gfx_vsyncmode, vsyncmodes2, 0)) return 1; if (cfgfile_yesno (option, value, _T("show_leds"), &vb)) { @@ -2462,7 +2482,9 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, const TCHAR *option, TCH p->m68k_speed *= CYCLE_UNIT; return 1; } - + if (cfgfile_intval (option, value, _T("cpu_throttle"), &p->m68k_speed_throttle, 1)) { + return 1; + } if (cfgfile_intval (option, value, _T("finegrain_cpu_speed"), &p->m68k_speed, 1)) { if (OFFICIAL_CYCLE_UNIT > CYCLE_UNIT) { int factor = OFFICIAL_CYCLE_UNIT / CYCLE_UNIT; diff --git a/custom.cpp b/custom.cpp index 872c885f..6f858b48 100644 --- a/custom.cpp +++ b/custom.cpp @@ -453,7 +453,7 @@ STATIC_INLINE void alloc_cycle_maybe (int hpos, int type) alloc_cycle (hpos, type); } -void alloc_cycle_ext(int hpos, int type) +void alloc_cycle_ext (int hpos, int type) { alloc_cycle (hpos, type); } @@ -5128,9 +5128,9 @@ static void do_savestate(void); static int rpt_vsync (void) { - int v = read_processor_time () - vsyncmaxtime; + int v = read_processor_time () - vsyncwaittime; if (v > (int)syncbase || v < -((int)syncbase)) { - vsyncmintime = vsyncmaxtime = read_processor_time (); + vsyncmintime = vsyncmaxtime = vsyncwaittime = read_processor_time (); v = 0; } return v; @@ -5153,7 +5153,7 @@ static void framewait (void) if (vs > 0) { curr_time = read_processor_time (); - vsyncmaxtime = curr_time + vsynctimebase; + vsyncwaittime = vsyncmaxtime = curr_time + vsynctimebase; render_screen (); show_screen (); frame_shown = true; @@ -5174,8 +5174,10 @@ static void framewait (void) vsync_busywait_end (); vsync_busywait_do (NULL, (bplcon0 & 4) != 0 && !lof_changed && !lof_changing, lof_store != 0); vsync_busywait_start (); + vsyncmintime = curr_time; - vsyncmaxtime = curr_time + vsynctimebase * (100 - currprefs.m68k_speed_throttle) / 100; + vsyncwaittime = curr_time + vsynctimebase; + vsyncmaxtime = curr_time + vsynctimebase * (1000 + currprefs.m68k_speed_throttle) / 1000; } else { @@ -5184,6 +5186,7 @@ static void framewait (void) vsync_busywait_do (&freetime, (bplcon0 & 4) != 0 && !lof_changed && !lof_changing, lof_store != 0); curr_time = read_processor_time (); vsyncmintime = curr_time; + vsyncwaittime = curr_time + vsynctimebase; vsyncmaxtime = curr_time + vsynctimebase; if (!show) { show_screen (); @@ -5195,37 +5198,53 @@ static void framewait (void) } return; } + if (currprefs.m68k_speed < 0) { + + for (;;) { + double v = rpt_vsync () / (syncbase / 1000.0); + if (v >= -4) + break; + rtg_vsynccheck (); + sleep_millis_main (2); + } + while (rpt_vsync () < 0) + rtg_vsynccheck (); curr_time = read_processor_time (); - if (curr_time - vsyncmaxtime >= 0 && curr_time - vsyncmaxtime < vsynctimebase) { - vsyncmaxtime = curr_time + vsynctimebase * (100 - currprefs.m68k_speed_throttle) / 100 - (curr_time - vsyncmaxtime); + if ((int)curr_time - (int)vsyncwaittime > 0 && (int)curr_time - (int)vsyncwaittime < vsynctimebase / 2) { + int adjust = curr_time - vsyncmaxtime; + vsyncmaxtime = curr_time + vsynctimebase * (1000 + currprefs.m68k_speed_throttle) / 1000 - adjust; + vsyncwaittime = curr_time + vsynctimebase - adjust; } else { - vsyncmaxtime = curr_time + vsynctimebase * (100 - currprefs.m68k_speed_throttle) / 100; + vsyncmaxtime = curr_time + vsynctimebase * (1000 + currprefs.m68k_speed_throttle) / 1000; + vsyncwaittime = curr_time + vsynctimebase; } vsyncmintime = curr_time; - return; - } + + } else { - bool didrender = false; - if (!picasso_on) - didrender = render_screen (); - for (;;) { - double v = rpt_vsync () / (syncbase / 1000.0); - if (v >= -4) - break; - rtg_vsynccheck (); - sleep_millis_main (2); - } - curr_time = start = read_processor_time (); - while (rpt_vsync () < 0) - rtg_vsynccheck (); - idletime += read_processor_time() - start; - curr_time = read_processor_time (); - vsyncmintime = curr_time; - vsyncmaxtime = curr_time + vsynctimebase; - if (didrender) - show_screen (); - frame_shown = true; + bool didrender = false; + if (!picasso_on) + didrender = render_screen (); + for (;;) { + double v = rpt_vsync () / (syncbase / 1000.0); + if (v >= -4) + break; + rtg_vsynccheck (); + sleep_millis_main (2); + } + curr_time = start = read_processor_time (); + while (rpt_vsync () < 0) + rtg_vsynccheck (); + idletime += read_processor_time() - start; + curr_time = read_processor_time (); + vsyncmintime = curr_time; + vsyncmaxtime = vsyncwaittime = curr_time + vsynctimebase; + if (didrender) + show_screen (); + frame_shown = true; + + } } static frame_time_t frametime2; @@ -5802,7 +5821,20 @@ static void hsync_handler_post (bool onvsync) #endif events_dmal_hsync (); - +#if 0 + static int cnt = 0; + cnt++; + if (cnt == 500) { + int port_insert_custom (int inputmap_port, int devicetype, DWORD flags, const TCHAR *custom); + port_insert_custom (0, 0, 0, L"Left=0xC8 Right=0xD0 Up=0xCB Down=0xCD Fire=0x39"); + port_insert_custom (1, 0, 0, L"Left=0x48 Right=0x50 Up=0x4B Down=0x4D Fire=0x4C"); + } else if (cnt == 1000) { + TCHAR out[256]; + bool port_get_custom (int inputmap_port, TCHAR *out); + port_get_custom (0, out); + port_get_custom (1, out); + } +#endif if (currprefs.m68k_speed < 0) { if (vpos + 1 == maxvpos + lof_store) { /* really last line, just run the cpu emulation until whole vsync time has been used */ @@ -5813,7 +5845,7 @@ static void hsync_handler_post (bool onvsync) vsyncmintime = vsyncmaxtime; /* emulate if still time left */ } else { /* end of scanline, run cpu emulation as long as we still have time */ - vsyncmintime += (vsynctimebase * (100 - currprefs.m68k_speed_throttle)) / (maxvpos_nom * 100); + vsyncmintime += (vsynctimebase * (1000 + currprefs.m68k_speed_throttle)) / (maxvpos_nom * 1000); if (!vblank_found_chipset && (int)vsyncmaxtime - (int)vsyncmintime > 0) { is_syncline = -1; frame_time_t rpt = read_processor_time (); @@ -5823,19 +5855,14 @@ static void hsync_handler_post (bool onvsync) } } } else { -#if 0 - if (vpos + 1 < maxvpos + lof_store) { - int mult = 90; + if (vpos + 1 < maxvpos + lof_store && (vpos == maxvpos_nom * 1 / 3 || vpos == maxvpos_nom * 2 / 3)) { frame_time_t rpt = read_processor_time (); - vsyncmintime += (vsynctimebase * mult) / (maxvpos_nom * 100); - if ((int)vsyncmintime - (int)vsyncmaxtime > 0) - vsyncmintime = vsyncmaxtime; + vsyncmintime += vsynctimebase / 3; // sleep if more than 2ms "free" time if (!vblank_found_chipset && (int)vsyncmintime - (int)(rpt + vsynctimebase / 10) > 0) { sleep_millis_main (1); } } -#endif } diff --git a/events.cpp b/events.cpp index 07c472b1..696779d0 100644 --- a/events.cpp +++ b/events.cpp @@ -21,7 +21,7 @@ long max_cycles_to_next_event; long cycles_to_hsync_event; unsigned long start_cycles; -frame_time_t vsynctimebase, vsyncmintime, vsyncmaxtime; +frame_time_t vsynctimebase, vsyncmintime, vsyncmaxtime, vsyncwaittime; void events_schedule (void) { diff --git a/filesys.cpp b/filesys.cpp index e76a3671..980b15c4 100644 --- a/filesys.cpp +++ b/filesys.cpp @@ -3403,7 +3403,7 @@ static int exalldo (uaecptr exalldata, uae_u32 exalldatasize, uae_u32 type, uaec if (unit->volflags & MYVOLUMEINFO_ARCHIVE) zfile_stat_archive (aino->nname, &statbuf); else if (unit->volflags & MYVOLUMEINFO_CDFS) - isofs_stat (unit->cdfs_superblock, aino->uniq_external, &statbuf); + isofs_stat (unit->ui.cdfs_superblock, aino->uniq_external, &statbuf); else stat (aino->nname, &statbuf); diff --git a/include/events.h b/include/events.h index ecc428f8..0cf4b1a7 100644 --- a/include/events.h +++ b/include/events.h @@ -16,7 +16,7 @@ #include "machdep/rpt.h" -extern frame_time_t vsynctimebase, vsyncmintime, vsyncmaxtime; +extern frame_time_t vsynctimebase, vsyncmintime, vsyncmaxtime, vsyncwaittime; extern void reset_frame_rate_hack (void); extern frame_time_t syncbase; extern unsigned long int vsync_cycles; diff --git a/include/inputdevice.h b/include/inputdevice.h index 9572cb19..b2050072 100644 --- a/include/inputdevice.h +++ b/include/inputdevice.h @@ -45,7 +45,6 @@ struct inputdevice_functions { int (*get_widget_first)(int,int); int (*get_flags)(int); }; -extern struct inputdevice_functions idev[3]; extern struct inputdevice_functions inputdevicefunc_joystick; extern struct inputdevice_functions inputdevicefunc_mouse; extern struct inputdevice_functions inputdevicefunc_keyboard; @@ -135,7 +134,7 @@ struct inputevent { #define ID_AXIS_TOTAL 32 extern int inputdevice_iterate (int devnum, int num, TCHAR *name, int *af); -extern bool inputdevice_set_gameports_mapping (struct uae_prefs *prefs, int devnum, int num, const TCHAR *name, int port); +extern bool inputdevice_set_gameports_mapping (struct uae_prefs *prefs, int devnum, int num, int evtnum, int port); extern int inputdevice_set_mapping (int devnum, int num, const TCHAR *name, TCHAR *custom, int flags, int port, int sub); extern int inputdevice_get_mapping (int devnum, int num, int *pflags, int *port, TCHAR *name, TCHAR *custom, int sub); extern void inputdevice_copyconfig (const struct uae_prefs *src, struct uae_prefs *dst); @@ -204,8 +203,8 @@ 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 bool inputdevice_get_eventname (const struct inputevent *ie, TCHAR *out); +extern void inputdevice_compa_prepare_custom (struct uae_prefs *prefs, int index, int mode); extern void inputdevice_compa_clear (struct uae_prefs *prefs, int index); extern int intputdevice_compa_get_eventtype (int evt, int **axistable); diff --git a/include/options.h b/include/options.h index 5702a6cc..82185d74 100644 --- a/include/options.h +++ b/include/options.h @@ -167,9 +167,14 @@ struct chipset_refresh TCHAR commands[256]; }; +#define APMODE_NATIVE 0 +#define APMODE_RTG 1 + struct apmode { int gfx_fullscreen; + int gfx_display; + TCHAR gfx_display_name[256]; int gfx_vsync; // 0 = immediate flip // -1 = wait for flip, before frame ends @@ -246,8 +251,6 @@ struct uae_prefs { 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; diff --git a/inputdevice.cpp b/inputdevice.cpp index 68f2fcf2..2ae3308c 100644 --- a/inputdevice.cpp +++ b/inputdevice.cpp @@ -134,6 +134,7 @@ static signed long bouncy_cycles; static int handle_input_event (int nr, int state, int max, int autofire, bool canstoprecord, bool playbackevent); +static struct inputdevice_functions idev[3]; static int isdevice (struct uae_input_device *id) { @@ -222,7 +223,8 @@ static int use_keyboards[MAX_INPUT_DEVICES]; #define INPUT_QUEUE_SIZE 16 struct input_queue_struct { - int event, storedstate, state, max, linecnt, nextlinecnt; + int evt, storedstate, state, max, linecnt, nextlinecnt; + TCHAR *custom; }; static struct input_queue_struct input_queue[INPUT_QUEUE_SIZE]; @@ -752,6 +754,9 @@ static bool read_slot (TCHAR *parm, int num, int joystick, int button, struct ua } return false; } + if (custom) + ie = &events[INPUTEVENT_SPC_CUSTOM_EVENT]; + if (joystick < 0) { if (!(ie->allow_mask & AM_K)) return false; @@ -2177,6 +2182,36 @@ void inputdevice_read (void) } while (handle_msgpump ()); } +static int handle_custom_event (TCHAR *custom) +{ + TCHAR *p, *buf, *nextp; + + if (custom == NULL) + return 0; + //write_log (_T("%s\n"), custom); + p = buf = my_strdup (custom); + while (p && *p) { + TCHAR *p2; + if (*p != '\"') + break; + p++; + p2 = p; + while (*p2 != '\"' && *p2 != 0) + p2++; + if (*p2 == '\"') { + *p2++ = 0; + nextp = p2 + 1; + while (*nextp == ' ') + nextp++; + } + cfgfile_parse_line (&changed_prefs, p, 0); + p = nextp; + } + xfree (buf); + config_changed = 1; + return 0; +} + void inputdevice_hsync (void) { static int cnt; @@ -2195,7 +2230,10 @@ void inputdevice_hsync (void) iq->state = 0; else iq->state = iq->storedstate; - handle_input_event (iq->event, iq->state, iq->max, 0, false, true); + if (iq->custom) + handle_custom_event (iq->custom); + if (iq->evt) + handle_input_event (iq->evt, iq->state, iq->max, 0, false, true); iq->linecnt = iq->nextlinecnt; } } @@ -2306,43 +2344,47 @@ uae_u16 POTGOR (void) return v; } -static int check_input_queue (int event) +static int check_input_queue (int evt) { struct input_queue_struct *iq; int i; for (i = 0; i < INPUT_QUEUE_SIZE; i++) { iq = &input_queue[i]; - if (iq->event == event) + if (iq->evt == evt) return i; } return -1; } -static void queue_input_event (int event, int state, int max, int linecnt, int autofire) +static void queue_input_event (int evt, const TCHAR *custom, int state, int max, int linecnt, int autofire) { struct input_queue_struct *iq; - int i = check_input_queue (event); + int idx = check_input_queue (evt); - if (event <= 0) - return; - if (state < 0 && i >= 0) { - iq = &input_queue[i]; + if (state < 0 && idx >= 0) { + iq = &input_queue[idx]; iq->nextlinecnt = -1; iq->linecnt = -1; - iq->event = 0; - if (iq->state == 0) - handle_input_event (event, 0, 1, 0, false, false); - } else if (state >= 0 && i < 0) { - for (i = 0; i < INPUT_QUEUE_SIZE; i++) { - iq = &input_queue[i]; + iq->evt = 0; + if (iq->state == 0 && evt > 0) + handle_input_event (evt, 0, 1, 0, false, false); + } else if (state >= 0 && idx < 0) { + if (evt == 0 && custom == NULL) + return; + for (idx = 0; idx < INPUT_QUEUE_SIZE; idx++) { + iq = &input_queue[idx]; if (iq->linecnt < 0) break; } - if (i == INPUT_QUEUE_SIZE) { + if (idx == INPUT_QUEUE_SIZE) { write_log (_T("input queue overflow\n")); return; } - iq->event = event; + xfree (iq->custom); + iq->custom = NULL; + if (custom) + iq->custom = my_strdup (custom); + iq->evt = evt; iq->state = iq->storedstate = state; iq->max = max; iq->linecnt = linecnt; @@ -2688,36 +2730,6 @@ end: } } -static int handle_custom_event (TCHAR *custom) -{ - TCHAR *p, *buf, *nextp; - - if (custom == NULL) - return 0; - //write_log (_T("%s\n"), custom); - p = buf = my_strdup (custom); - while (p && *p) { - TCHAR *p2; - if (*p != '\"') - break; - p++; - p2 = p; - while (*p2 != '\"' && *p2 != 0) - p2++; - if (*p2 == '\"') { - *p2++ = 0; - nextp = p2 + 1; - while (*nextp == ' ') - nextp++; - } - cfgfile_parse_line (&changed_prefs, p, 0); - p = nextp; - } - xfree (buf); - config_changed = 1; - return 0; -} - static int isqual (int evt) { if (evt > INPUTEVENT_SPC_QUALIFIER_START && evt < INPUTEVENT_SPC_QUALIFIER_END) @@ -2759,9 +2771,9 @@ static int handle_input_event (int nr, int state, int max, int autofire, bool ca write_log (_T("STATE=%05d MAX=%05d AF=%d QUAL=%08x '%s' \n"), state, max, autofire, qualifiers, ie->name); if (autofire) { if (state) - queue_input_event (nr, state, max, currprefs.input_autofire_linecnt, 1); + queue_input_event (nr, NULL, state, max, currprefs.input_autofire_linecnt, 1); else - queue_input_event (nr, -1, 0, 0, 1); + queue_input_event (nr, NULL, -1, 0, 0, 1); } switch (ie->unit) { @@ -3310,7 +3322,7 @@ static int getqualmask (struct uae_input_device *id, int num, bool *qualonly) return mask; } -static void process_custom_event (struct uae_input_device *id, int offset, int state, int qualmask) +static void process_custom_event (struct uae_input_device *id, int offset, int state, int qualmask, int autofire) { int idx, slotoffset, flags, custompos; TCHAR *custom; @@ -3345,6 +3357,12 @@ static void process_custom_event (struct uae_input_device *id, int offset, int s handle_custom_event (custom); + if (autofire) + queue_input_event (-1, custom, 1, 1, currprefs.input_autofire_linecnt, 1); + if (!state) + queue_input_event (-1, NULL, -1, 0, 0, 1); + + id->flags[offset][slotoffset] &= ~ID_FLAG_CUSTOMEVENT_TOGGLED; id->flags[offset][slotoffset] |= custompos ? ID_FLAG_CUSTOMEVENT_TOGGLED : 0; } @@ -3396,19 +3414,18 @@ static void setbuttonstateall (struct uae_input_device *id, struct uae_input_dev if (!checkqualifiers (evt, flags, qualmask)) continue; handle_input_event (evt, 1, 1, 0, true, false); - queue_input_event (evt, 0, 1, 1, 0); /* send release event next frame */ - if (i == 0) - process_custom_event (id, ID_BUTTON_OFFSET + button, state, qualmask); + queue_input_event (evt, NULL, 0, 1, 1, 0); /* send release event next frame */ + process_custom_event (id, ID_BUTTON_OFFSET + button, state, qualmask, 0); } else if (inverttoggle) { /* pressed = firebutton, not pressed = autofire */ if (state) { - queue_input_event (evt, -1, 0, 0, 1); + queue_input_event (evt, NULL, -1, 0, 0, 1); handle_input_event (evt, 1, 1, 0, true, false); } else { handle_input_event (evt, 1, 1, autofire, true, false); } if (i == 0) - process_custom_event (id, ID_BUTTON_OFFSET + button, 1, qualmask); + process_custom_event (id, ID_BUTTON_OFFSET + button, 1, qualmask, autofire); } else if (toggle) { if (!state) continue; @@ -3420,7 +3437,7 @@ static void setbuttonstateall (struct uae_input_device *id, struct uae_input_dev int toggled = (*flagsp & ID_FLAG_TOGGLED) ? 1 : 0; handle_input_event (evt, toggled, 1, autofire, true, false); if (i == 0) - process_custom_event (id, ID_BUTTON_OFFSET + button, toggled, qualmask); + process_custom_event (id, ID_BUTTON_OFFSET + button, toggled, qualmask, autofire); } else { if (!checkqualifiers (evt, flags, qualmask)) { if (!state && !(flags & ID_FLAG_CANRELEASE)) @@ -3435,7 +3452,7 @@ static void setbuttonstateall (struct uae_input_device *id, struct uae_input_dev if ((omask ^ nmask) & mask) { handle_input_event (evt, state, 1, autofire, true, false); if (i == 0) - process_custom_event (id, ID_BUTTON_OFFSET + button, state, qualmask); + process_custom_event (id, ID_BUTTON_OFFSET + button, state, qualmask, autofire); } } } @@ -3946,6 +3963,7 @@ static void setcompakb (int *kb, int *srcmap, int index, int af) int inputdevice_get_compatibility_input (struct uae_prefs *prefs, int index, int *typelist, int **inputlist, int **at) { + //write_log (L"index=%d joymodes=%d\n", index, joymodes[index]); if (index >= MAX_JPORTS || joymodes[index] < 0) return 0; *typelist = joymodes[index]; @@ -4096,13 +4114,16 @@ static void remove_custom_config (struct uae_prefs *prefs, bool nocustom, int in } // prepare port for custom mapping, remove all current Amiga side device mappings -void inputdevice_compa_prepare_custom (struct uae_prefs *prefs, int index) +void inputdevice_compa_prepare_custom (struct uae_prefs *prefs, int index, int newmode) { int mode = prefs->jports[index].mode; freejport (prefs, index); resetjport (prefs, index); - if (mode == 0) + if (newmode >= 0) { + mode = newmode; + } else if (mode == 0) { mode = index == 0 ? JSEM_MODE_MOUSE : (prefs->cs_cd32cd ? JSEM_MODE_JOYSTICK_CD32 : JSEM_MODE_JOYSTICK); + } prefs->jports[index].mode = mode; prefs->jports[index].id = -2; @@ -4654,8 +4675,14 @@ static void matchdevices_all (struct uae_prefs *prefs) } } -bool inputdevice_set_gameports_mapping (struct uae_prefs *prefs, int devnum, int num, const TCHAR *name, int port) +bool inputdevice_set_gameports_mapping (struct uae_prefs *prefs, int devnum, int num, int evtnum, int port) { + TCHAR name[256]; + struct inputevent *ie; + + ie = inputdevice_get_eventinfo (evtnum); + if (!inputdevice_get_eventname (ie, name)) + return false; joysticks = prefs->joystick_settings[GAMEPORT_INPUT_SETTINGS]; mice = prefs->mouse_settings[GAMEPORT_INPUT_SETTINGS]; keyboards = prefs->keyboard_settings[GAMEPORT_INPUT_SETTINGS]; @@ -4933,11 +4960,13 @@ static int inputdevice_translatekeycode_2 (int keyboard, int scancode, int state if (inverttoggle) { na->flags[j][sublevdir[state == 0 ? 1 : 0][k]] &= ~ID_FLAG_TOGGLED; if (state) { - queue_input_event (evt, -1, 0, 0, 1); + queue_input_event (evt, NULL, -1, 0, 0, 1); handled |= handle_input_event (evt, 1, 1, 0, true, false); } else { handled |= handle_input_event (evt, 1, 1, autofire, true, false); } + if (k == 0) + process_custom_event (na, j, state, qualmask, autofire); } else if (toggle) { if (!state) continue; @@ -4946,6 +4975,8 @@ static int inputdevice_translatekeycode_2 (int keyboard, int scancode, int state *flagsp ^= ID_FLAG_TOGGLED; toggled = (*flagsp & ID_FLAG_TOGGLED) ? 1 : 0; handled |= handle_input_event (evt, toggled, 1, autofire, true, false); + if (k == 0) + process_custom_event (na, j, state, qualmask, autofire); } else { if (!checkqualifiers (evt, flags, qualmask)) { if (!state && !(flags & ID_FLAG_CANRELEASE)) @@ -4958,10 +4989,10 @@ static int inputdevice_translatekeycode_2 (int keyboard, int scancode, int state else *flagsp &= ~ID_FLAG_CANRELEASE; handled |= handle_input_event (evt, state, 1, autofire, true, false); - + if (k == 0) + process_custom_event (na, j, state, qualmask, autofire); } } - process_custom_event (na, j, state, qualmask); return handled; } j++; @@ -5010,8 +5041,6 @@ void inputdevice_checkqualifierkeycode (int keyboard, int scancode, int state) inputdevice_translatekeycode_2 (keyboard, scancode, state, true); } -static struct inputdevice_functions idev[3]; - void inputdevice_init (void) { idev[IDTYPE_JOYSTICK] = inputdevicefunc_joystick; @@ -5086,7 +5115,9 @@ 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; + int i, ret; + + ret = -1; 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; @@ -5094,7 +5125,7 @@ static int put_event_data (const struct inputdevice_functions *id, int devnum, i uid->port[i][sub] = port; xfree (uid->custom[i][sub]); uid->custom[i][sub] = custom && _tcslen (custom) > 0 ? my_strdup (custom) : NULL; - return i; + ret = i; } else if (type == IDEV_WIDGET_AXIS) { i = num - id->get_widget_first (devnum, type) + ID_AXIS_OFFSET; uid->eventid[i][sub] = eventid; @@ -5102,7 +5133,7 @@ static int put_event_data (const struct inputdevice_functions *id, int devnum, i uid->port[i][sub] = port; xfree (uid->custom[i][sub]); uid->custom[i][sub] = custom && _tcslen (custom) > 0 ? my_strdup (custom) : NULL; - return i; + ret = i; } else if (type == IDEV_WIDGET_KEY) { i = num - id->get_widget_first (devnum, type); uid->eventid[i][sub] = eventid; @@ -5110,9 +5141,13 @@ static int put_event_data (const struct inputdevice_functions *id, int devnum, i uid->port[i][sub] = port; xfree (uid->custom[i][sub]); uid->custom[i][sub] = custom && _tcslen (custom) > 0 ? my_strdup (custom) : NULL; - return i; + ret = i; } - return -1; + if (ret < 0) + return -1; + if (uid->custom[i][sub]) + uid->eventid[i][sub] = INPUTEVENT_SPC_CUSTOM_EVENT; + return ret; } static int is_event_used (const struct inputdevice_functions *id, int devnum, int isnum, int isevent) @@ -5236,11 +5271,12 @@ int inputdevice_get_widget_num (int devnum) } // return name of event, do not use ie->name directly -void inputdevice_get_eventname (const struct inputevent *ie, TCHAR *out) +bool inputdevice_get_eventname (const struct inputevent *ie, TCHAR *out) { if (!out) - return; + return false; _tcscpy (out, ie->name); + return true; } int inputdevice_iterate (int devnum, int num, TCHAR *name, int *af) diff --git a/inputevents.def b/inputevents.def index 97e42d67..1ecd01ad 100644 --- a/inputevents.def +++ b/inputevents.def @@ -315,6 +315,7 @@ DEFEVENT(KEY_7F,_T("Keycode 0x7F"),AM_K,0,0,0x7f) /* special */ +DEFEVENT(SPC_CUSTOM_EVENT,_T(""),AM_K,0,0,0) DEFEVENT(SPC_ENTERGUI,_T("Enter GUI"),AM_K,0,0,AKS_ENTERGUI) DEFEVENT(SPC_SCREENSHOT,_T("Screenshot (file)"),AM_K,0,0,AKS_SCREENSHOT_FILE) DEFEVENT(SPC_SCREENSHOT_CLIPBOARD,_T("Screenshot (clipboard)"),AM_K,0,0,AKS_SCREENSHOT_CLIPBOARD) diff --git a/newcpu.cpp b/newcpu.cpp index 6db55435..864f4f8d 100644 --- a/newcpu.cpp +++ b/newcpu.cpp @@ -1051,22 +1051,26 @@ static void fill_prefetch_quick (void) regs.irc = get_word (m68k_getpc () + 2); } -static unsigned long cycles_mask, cycles_val, cycles_shift; +#define CYCLES_DIV 8192 +static unsigned long cycles_mult; static void update_68k_cycles (void) { - cycles_mask = 0; - cycles_shift = 0; - cycles_val = currprefs.m68k_speed; - if (currprefs.m68k_speed < 1) { - cycles_mask = 0xFFFFFFFF; - cycles_val = 0; + cycles_mult = 0; + if (currprefs.m68k_speed >= 0 && !currprefs.cpu_cycle_exact) { + if (currprefs.m68k_speed_throttle < 0) { + cycles_mult = CYCLES_DIV * 1000 / (1000 + currprefs.m68k_speed_throttle); + } else if (currprefs.m68k_speed_throttle > 0) { + cycles_mult = CYCLES_DIV * 1000 / (1000 + currprefs.m68k_speed_throttle); + } } if (currprefs.m68k_speed == 0 && currprefs.cpu_model >= 68020) { - cycles_shift = 2; - cycles_val = CYCLE_UNIT / 2; - cycles_mask = ~((CYCLE_UNIT / 2) - 1); + if (!cycles_mult) + cycles_mult = CYCLES_DIV / 4; + else + cycles_mult /= 4; } + currprefs.cpu_clock_multiplier = changed_prefs.cpu_clock_multiplier; currprefs.cpu_frequency = changed_prefs.cpu_frequency; @@ -1123,9 +1127,11 @@ void check_prefs_changed_cpu (void) } if (changed || currprefs.m68k_speed != changed_prefs.m68k_speed + || currprefs.m68k_speed_throttle != changed_prefs.m68k_speed_throttle || currprefs.cpu_clock_multiplier != changed_prefs.cpu_clock_multiplier || currprefs.cpu_frequency != changed_prefs.cpu_frequency) { currprefs.m68k_speed = changed_prefs.m68k_speed; + currprefs.m68k_speed_throttle = changed_prefs.m68k_speed_throttle; update_68k_cycles (); changed = true; } @@ -3512,6 +3518,15 @@ static void out_cd32io (uae_u32 pc) #endif +STATIC_INLINE int adjust_cycles (int cycles) +{ + if (currprefs.m68k_speed < 0 || cycles_mult == 0) + return cycles; + cpu_cycles *= cycles_mult; + cpu_cycles /= CYCLES_DIV; + return cpu_cycles; +} + #ifndef CPUEMU_11 static void m68k_run_1 (void) @@ -3548,8 +3563,7 @@ static void m68k_run_1 (void) #endif do_cycles (cpu_cycles); cpu_cycles = (*cpufunctbl[opcode])(opcode); - cpu_cycles &= cycles_mask; - cpu_cycles |= cycles_val; + cpu_cycles = adjust_cycles (cpu_cycles); if (r->spcflags) { if (do_specialties (cpu_cycles)) return; @@ -3676,10 +3690,7 @@ void exec_nostats (void) { uae_u16 opcode = get_iword (0); cpu_cycles = (*cpufunctbl[opcode])(opcode); - - cpu_cycles &= cycles_mask; - cpu_cycles |= cycles_val; - + cpu_cycles = adjust_cycles (cpu_cycles); do_cycles (cpu_cycles); if (end_block (opcode) || r->spcflags || uae_int_requested) @@ -3711,9 +3722,7 @@ void execute_normal (void) pc_hist[blocklen].location = (uae_u16*)r->pc_p; cpu_cycles = (*cpufunctbl[opcode])(opcode); - - cpu_cycles &= cycles_mask; - cpu_cycles |= cycles_val; + cpu_cycles = adjust_cycles (cpu_cycles); do_cycles (cpu_cycles); total_cycles += cpu_cycles; pc_hist[blocklen].specmem = special_mem; @@ -3831,8 +3840,7 @@ retry: count_instr (opcode); do_cycles (cpu_cycles); cpu_cycles = (*cpufunctbl[opcode])(opcode); - cpu_cycles &= cycles_mask; - cpu_cycles |= cycles_val; + cpu_cycles = adjust_cycles (cpu_cycles); if (regs.spcflags) { if (do_specialties (cpu_cycles)) return; @@ -4021,9 +4029,7 @@ static void m68k_run_2p (void) count_instr (opcode); cpu_cycles = (*cpufunctbl[opcode])(opcode); - cpu_cycles >>= cycles_shift; - cpu_cycles &= cycles_mask; - cpu_cycles |= cycles_val; + cpu_cycles = adjust_cycles (cpu_cycles); if (r->spcflags) { if (do_specialties (cpu_cycles)) return; @@ -4054,9 +4060,7 @@ static void m68k_run_2 (void) #endif do_cycles (cpu_cycles); cpu_cycles = (*cpufunctbl[opcode])(opcode); - cpu_cycles >>= cycles_shift; - cpu_cycles &= cycles_mask; - cpu_cycles |= cycles_val; + cpu_cycles = adjust_cycles (cpu_cycles); if (r->spcflags) { if (do_specialties (cpu_cycles)) return; @@ -4072,9 +4076,7 @@ static void m68k_run_mmu (void) do_cycles (cpu_cycles); mmu_backup_regs = regs; cpu_cycles = (*cpufunctbl[opcode])(opcode); - cpu_cycles >>= cycles_shift; - cpu_cycles &= cycles_mask; - cpu_cycles |= cycles_val; + cpu_cycles = adjust_cycles (cpu_cycles); if (mmu_triggered) mmu_do_hit (); if (regs.spcflags) { @@ -4744,9 +4746,6 @@ uae_u8 *restore_cpu (uae_u8 *src) regs.caar = restore_u32 (); regs.cacr = restore_u32 (); regs.msp = restore_u32 (); - /* A500 speed in 68020 mode isn't too logical.. */ - if (changed_prefs.m68k_speed == 0 && !(currprefs.cpu_cycle_exact)) - currprefs.m68k_speed = changed_prefs.m68k_speed = -1; } if (model >= 68030) { crp_030 = restore_u64 (); diff --git a/od-win32/cloanto/RetroPlatformIPC.h b/od-win32/cloanto/RetroPlatformIPC.h index 59a9a3c8..8d891b72 100644 --- a/od-win32/cloanto/RetroPlatformIPC.h +++ b/od-win32/cloanto/RetroPlatformIPC.h @@ -3,12 +3,12 @@ Project : RetroPlatform Player Client : Cloanto Italia srl Support : http://www.retroplatform.com - Legal : Copyright 2007-2011 Cloanto Italia srl - All rights reserved. This - : file is made available under the terms of the GNU General Public - : License version 2 as published by the Free Software Foundation. + Legal : Copyright 2007-2012 Cloanto Italia srl - All rights reserved. This + : file is made available under the terms of the Mozilla Public License + : version 2.0 as published by Mozilla Corporation. Authors : os, mcb Created : 2007-08-27 13:55:49 - Updated : 2011-08-02 16:52:00 + Updated : 2012-03-27 16:00:00 Comment : RP Player interprocess communication include file *****************************************************************************/ @@ -17,9 +17,9 @@ #include -#define RETROPLATFORM_API_VER "3.0" +#define RETROPLATFORM_API_VER "3.2" #define RETROPLATFORM_API_VER_MAJOR 3 -#define RETROPLATFORM_API_VER_MINOR 0 +#define RETROPLATFORM_API_VER_MINOR 2 #define RPIPC_HostWndClass "RetroPlatformHost%s" #define RPIPC_GuestWndClass "RetroPlatformGuest%d" @@ -29,54 +29,54 @@ // Guest-to-Host Messages // **************************************************************************** -#define RPIPCGM_REGISTER (WM_APP + 0) -#define RPIPCGM_FEATURES (WM_APP + 1) -#define RPIPCGM_CLOSED (WM_APP + 2) -#define RPIPCGM_ACTIVATED (WM_APP + 3) -#define RPIPCGM_DEACTIVATED (WM_APP + 4) -#define RPIPCGM_ENABLED (WM_APP + 5) -#define RPIPCGM_DISABLED (WM_APP + 6) -#define RPIPCGM_SCREENMODE (WM_APP + 9) -#define RPIPCGM_POWERLED (WM_APP + 10) -#define RPIPCGM_DEVICES (WM_APP + 11) -#define RPIPCGM_DEVICEACTIVITY (WM_APP + 12) -#define RPIPCGM_MOUSECAPTURE (WM_APP + 13) -#define RPIPCGM_HOSTAPIVERSION (WM_APP + 14) -#define RPIPCGM_PAUSE (WM_APP + 15) -#define RPIPCGM_TURBO (WM_APP + 17) -#define RPIPCGM_PING (WM_APP + 18) -#define RPIPCGM_VOLUME (WM_APP + 19) -#define RPIPCGM_ESCAPED (WM_APP + 20) -#define RPIPCGM_PARENT (WM_APP + 21) -#define RPIPCGM_DEVICESEEK (WM_APP + 22) -#define RPIPCGM_CLOSE (WM_APP + 23) -#define RPIPCGM_DEVICEREADWRITE (WM_APP + 24) -#define RPIPCGM_HOSTVERSION (WM_APP + 25) -#define RPIPCGM_INPUTDEVICE (WM_APP + 26) // introduced in RetroPlatform API 3.0 -#define RPIPCGM_DEVICECONTENT (WM_APP + 27) // extended in RetroPlatform API 3.0 +#define RP_IPC_TO_HOST_REGISTER (WM_APP + 0) +#define RP_IPC_TO_HOST_FEATURES (WM_APP + 1) +#define RP_IPC_TO_HOST_CLOSED (WM_APP + 2) +#define RP_IPC_TO_HOST_ACTIVATED (WM_APP + 3) +#define RP_IPC_TO_HOST_DEACTIVATED (WM_APP + 4) +#define RP_IPC_TO_HOST_ENABLED (WM_APP + 5) +#define RP_IPC_TO_HOST_DISABLED (WM_APP + 6) +#define RP_IPC_TO_HOST_SCREENMODE (WM_APP + 9) +#define RP_IPC_TO_HOST_POWERLED (WM_APP + 10) +#define RP_IPC_TO_HOST_DEVICES (WM_APP + 11) +#define RP_IPC_TO_HOST_DEVICEACTIVITY (WM_APP + 12) +#define RP_IPC_TO_HOST_MOUSECAPTURE (WM_APP + 13) +#define RP_IPC_TO_HOST_HOSTAPIVERSION (WM_APP + 14) +#define RP_IPC_TO_HOST_PAUSE (WM_APP + 15) +#define RP_IPC_TO_HOST_TURBO (WM_APP + 17) +#define RP_IPC_TO_HOST_PING (WM_APP + 18) +#define RP_IPC_TO_HOST_VOLUME (WM_APP + 19) +#define RP_IPC_TO_HOST_ESCAPED (WM_APP + 20) +#define RP_IPC_TO_HOST_PARENT (WM_APP + 21) +#define RP_IPC_TO_HOST_DEVICESEEK (WM_APP + 22) +#define RP_IPC_TO_HOST_CLOSE (WM_APP + 23) +#define RP_IPC_TO_HOST_DEVICEREADWRITE (WM_APP + 24) +#define RP_IPC_TO_HOST_HOSTVERSION (WM_APP + 25) +#define RP_IPC_TO_HOST_INPUTDEVICE (WM_APP + 26) // introduced in RetroPlatform API 3.0 +#define RP_IPC_TO_HOST_DEVICECONTENT (WM_APP + 27) // extended in RetroPlatform API 3.0 // **************************************************************************** // Host-to-Guest Messages // **************************************************************************** -#define RPIPCHM_CLOSE (WM_APP + 200) -#define RPIPCHM_SCREENMODE (WM_APP + 202) -#define RPIPCHM_SCREENCAPTURE (WM_APP + 203) -#define RPIPCHM_PAUSE (WM_APP + 204) -#define RPIPCHM_RESET (WM_APP + 206) -#define RPIPCHM_TURBO (WM_APP + 207) -#define RPIPCHM_PING (WM_APP + 208) -#define RPIPCHM_VOLUME (WM_APP + 209) -#define RPIPCHM_ESCAPEKEY (WM_APP + 210) -#define RPIPCHM_EVENT (WM_APP + 211) -#define RPIPCHM_MOUSECAPTURE (WM_APP + 212) -#define RPIPCHM_SAVESTATE (WM_APP + 213) -#define RPIPCHM_LOADSTATE (WM_APP + 214) -#define RPIPCHM_FLUSH (WM_APP + 215) -#define RPIPCHM_DEVICEREADWRITE (WM_APP + 216) -#define RPIPCHM_QUERYSCREENMODE (WM_APP + 217) -#define RPIPCHM_GUESTAPIVERSION (WM_APP + 218) // introduced in RetroPlatform API 3.0 -#define RPIPCHM_DEVICECONTENT (WM_APP + 219) // extended in RetroPlatform API 3.0 +#define RP_IPC_TO_GUEST_CLOSE (WM_APP + 200) +#define RP_IPC_TO_GUEST_SCREENMODE (WM_APP + 202) +#define RP_IPC_TO_GUEST_SCREENCAPTURE (WM_APP + 203) +#define RP_IPC_TO_GUEST_PAUSE (WM_APP + 204) +#define RP_IPC_TO_GUEST_RESET (WM_APP + 206) +#define RP_IPC_TO_GUEST_TURBO (WM_APP + 207) +#define RP_IPC_TO_GUEST_PING (WM_APP + 208) +#define RP_IPC_TO_GUEST_VOLUME (WM_APP + 209) +#define RP_IPC_TO_GUEST_ESCAPEKEY (WM_APP + 210) +#define RP_IPC_TO_GUEST_EVENT (WM_APP + 211) +#define RP_IPC_TO_GUEST_MOUSECAPTURE (WM_APP + 212) +#define RP_IPC_TO_GUEST_SAVESTATE (WM_APP + 213) +#define RP_IPC_TO_GUEST_LOADSTATE (WM_APP + 214) +#define RP_IPC_TO_GUEST_FLUSH (WM_APP + 215) +#define RP_IPC_TO_GUEST_DEVICEREADWRITE (WM_APP + 216) +#define RP_IPC_TO_GUEST_QUERYSCREENMODE (WM_APP + 217) +#define RP_IPC_TO_GUEST_GUESTAPIVERSION (WM_APP + 218) // introduced in RetroPlatform API 3.0 +#define RP_IPC_TO_GUEST_DEVICECONTENT (WM_APP + 219) // extended in RetroPlatform API 3.0 // **************************************************************************** // Message Data Structures and Defines @@ -89,11 +89,11 @@ #define RP_FEATURE_SCREEN3X 0x00000008 // 3x mode is available #define RP_FEATURE_SCREEN4X 0x00000010 // 4x mode is available #define RP_FEATURE_FULLSCREEN 0x00000020 // fullscreen display is available -#define RP_FEATURE_SCREENCAPTURE 0x00000040 // screen capture functionality is available (see RPIPCHM_SCREENCAPTURE message) -#define RP_FEATURE_PAUSE 0x00000080 // pause functionality is available (see RPIPCHM_PAUSE message) -#define RP_FEATURE_TURBO 0x00000100 // turbo mode functionality is available (see RPIPCHM_TURBO message) -#define RP_FEATURE_VOLUME 0x00000200 // volume adjustment is possible (see RPIPCHM_VOLUME message) -#define RP_FEATURE_STATE 0x00000400 // loading and saving of emulation state is supported (see RPIPCHM_SAVESTATE/RPIPCHM_LOADSTATE message) +#define RP_FEATURE_SCREENCAPTURE 0x00000040 // screen capture functionality is available (see RP_IPC_TO_GUEST_SCREENCAPTURE message) +#define RP_FEATURE_PAUSE 0x00000080 // pause functionality is available (see RP_IPC_TO_GUEST_PAUSE message) +#define RP_FEATURE_TURBO 0x00000100 // turbo mode functionality is available (see RP_IPC_TO_GUEST_TURBO message) +#define RP_FEATURE_VOLUME 0x00000200 // volume adjustment is possible (see RP_IPC_TO_GUEST_VOLUME message) +#define RP_FEATURE_STATE 0x00000400 // loading and saving of emulation state is supported (see RP_IPC_TO_GUEST_SAVESTATE/RP_IPC_TO_GUEST_LOADSTATE message) #define RP_FEATURE_SCANLINES 0x00000800 // scan lines video effect is available #define RP_FEATURE_DEVICEREADWRITE 0x00001000 // device read/write can be set at runtime on floppy and hard disks #define RP_FEATURE_SCALING_SUBPIXEL 0x00002000 // supports sub-pixel scaling of windowed and fullscreen modes (i.e. not just integer multipliers like 1X, 2X, etc., but stretch to fill any desired pixel size) @@ -115,7 +115,7 @@ typedef struct RPScreenMode LONG lClipTop; // in guest pixel units; -1 = ignore (0 is a valid value) LONG lClipWidth; // in guest pixel units; -1 = ignore LONG lClipHeight; // in guest pixel units; -1 = ignore - HWND hGuestWindow; // only valid for RPIPCGM_SCREENMODE + HWND hGuestWindow; // only valid for RP_IPC_TO_HOST_SCREENMODE DWORD dwClipFlags; // clip flags (or 0) LONG lTargetWidth; // in exact host pixels; if set, must also set lTargetHeight; ignored unless RP_SCREENMODE_SCALE_TARGET is set (resulting size is result of clipping and scaling); RP_SCREENMODE_SCALING_SUBPIXEL and RP_SCREENMODE_SCALING_STRETCH are taken into account LONG lTargetHeight; // in exact host pixels, used with lTargetWidth @@ -127,7 +127,7 @@ typedef struct RPScreenMode #define RP_SCREENMODE_SCALE_3X 0x00000002 // 3x window or fullscreen mode ("triple CGA mode") #define RP_SCREENMODE_SCALE_4X 0x00000003 // 4x window or fullscreen mode ("double VGA mode") #define RP_SCREENMODE_SCALE_TARGET 0x000000FE // scale to maximum within lTargetWidth/lTargetHeight (default: maximum possible integer multiplication, no subpixel stretching, preserve ratio; may change to non-integer mode depending on RP_SCREENMODE_SCALING_SUBPIXEL and RP_SCREENMODE_SCALING_STRETCH) -#define RP_SCREENMODE_SCALE_MAX 0x000000FF // scale to auto-determined maximum size (default: maximum possible nX integer multiplication, no subpixel stretching, preserve ratio; may change to non-integer mode depending on RP_SCREENMODE_SCALING_SUBPIXEL and RP_SCREENMODE_SCALING_STRETCH); must be set in fullscreen modes +#define RP_SCREENMODE_SCALE_MAX 0x000000FF // scale to auto-determined maximum size (default: maximum possible nX integer multiplication, no subpixel stretching, preserve ratio; may change to non-integer mode depending on RP_SCREENMODE_SCALING_SUBPIXEL and RP_SCREENMODE_SCALING_STRETCH); must be set in fullscreen (shared or exclusive) modes #define RP_SCREENMODE_SCALEMASK 0x000000FF #define RP_SCREENMODE_SCALE(m) ((m) & RP_SCREENMODE_SCALEMASK) // returns the #X mode @@ -223,16 +223,16 @@ typedef struct RPScreenMode // // In window mode, if no lTargetWidth and lTargetHeight are set, when the host asks for a change in clipping (net content size), the host window size will be adjusted taking into account the current integer multiplication factor. // -// In window mode, after a change of clipping or size, the player may have to reset the visual hilight of the 1X, 2X etc. buttons according to new RPIPCGM_SCREENMODE data (setting a hilight if the correct scaling button is present in the user interface, or removing all hilights if the corresponding button is missing). +// In window mode, after a change of clipping or size, the player may have to reset the visual hilight of the 1X, 2X etc. buttons according to new RP_IPC_TO_HOST_SCREENMODE data (setting a hilight if the correct scaling button is present in the user interface, or removing all hilights if the corresponding button is missing). // -// RPInputDeviceDescription (used by initial host device enumeration via RPIPCGM_INPUTDEVICE, right after RPIPCGM_FEATURES and before RPIPCGM_SCREENMODE) +// RPInputDeviceDescription (used by initial host device enumeration via RP_IPC_TO_HOST_INPUTDEVICE, right after RP_IPC_TO_HOST_FEATURES and before RP_IPC_TO_HOST_SCREENMODE) typedef struct RPInputDeviceDescription { DWORD dwHostInputType; // host-side input device type (RP_HOSTINPUT_MOUSE, RP_HOSTINPUT_JOYSTICK, etc.) - WCHAR szHostInputID[260]; // host device "ProductGUID InstanceGUID", GUID, etc. (can be any format, as long as string is unique across all devices) + WCHAR szHostInputID[260]; // host device "ProductGUID InstanceGUID", GUID, etc. (can be any format, as long as string is unique across all devices; keyboard layout strings must not contain spaces) WCHAR szHostInputName[260]; // host device product description string ("5-Axis,12-Button with POV", "HID keyboard device", etc.) as listed by Windows; identical devices will result in identical strings (it is up to the host to add " (2)" etc. to the display names) DWORD dwHostInputVendorID; // host device Vendor ID (identification as issued by usb.org and found in USB and DirectInput device descriptors), or 0 if not available DWORD dwHostInputProductID; // host device Product ID (identification as assigned by manufacturer and used in USB and DirectInput device descriptors), or 0 if not available @@ -241,8 +241,7 @@ typedef struct RPInputDeviceDescription } RPINPUTDEVICEDESCRIPTION; - -// RPDeviceContent (used by RPIPCGM_DEVICECONTENT and RPIPCHM_DEVICECONTENT) +// RPDeviceContent (used by RP_IPC_TO_HOST_DEVICECONTENT and RP_IPC_TO_GUEST_DEVICECONTENT) typedef struct RPDeviceContent { @@ -250,10 +249,29 @@ typedef struct RPDeviceContent BYTE btDeviceNumber; // device number (range 0..31), e.g. Amiga floppy drive unit 0, C64 disk unit 8 or 9, etc. DWORD dwInputDevice; // (guest-side) input device type (RP_INPUTDEVICE_MOUSE, RP_INPUTDEVICE_JOYSTICK, etc.); currently set to 0 if not RP_DEVICE_INPUTPORT DWORD dwFlags; // flags (or 0); e.g. see RP_DEVICEFLAGS_MOUSE_ (for "mouse hack"), RP_DEVICEFLAGS_RW_ (for read/write status) - WCHAR szContent[260]; // if RP_DEVICECATEGORY_INPUTPORT, then host device ID, otherwise full path and name of the media image file to load, if file content (not used for input devices, which only use szHostInputID); szContent is ignored if btDeviceCategory == RP_DEVICECATEGORY_INPUTPORT and dwInputDevice == RP_INPUTDEVICE_EMPTY + WCHAR szContent[260]; // if RP_DEVICECATEGORY_INPUTPORT, then host device ID, otherwise full path and name of the media image file to load, if file content (not used for input devices, which only use szHostInputID); see comment for format of KeyboardCustom string; szContent is ignored if btDeviceCategory == RP_DEVICECATEGORY_INPUTPORT and dwInputDevice == RP_INPUTDEVICE_EMPTY } RPDEVICECONTENT; +// +// Keyboard layouts for joystick emulation +// +// These are virtual devices enumerated and named by the guest, rather than by the operating system. Any device name set by the guest will do, as long as it does not contain space characters. +// +// In the initial device enumeration (guest to host), the szHostInputID strings are enumerated with names like +// "KeyboardLayout1", "KeyboardLayout2", "KeyboardLayout3" and "KeyboardCustom" +// +// In dwHostInputType: +// - "KeyboardLayout1", "KeyboardLayout2", "KeyboardLayout3" are flagged +// RP_HOSTINPUT_KEYJOY_MAP1, RP_HOSTINPUT_KEYJOY_MAP2, RP_HOSTINPUT_KEYJOY_MAP3 +// - "KeyboardCustom" is flagged RP_HOSTINPUT_KEYJOY_CUSTOM +// +// In RP_IPC_TO_GUEST_DEVICECONTENT (host to guest) messages, the key code strings are appended to the device string in szContent. +// For example: +// "KeyboardCustom Left=0xC8 Right=0xD0 Up=0xCB Down=0xCD Fire=0x39" +// + + // Device Categories #define RP_DEVICECATEGORY_FLOPPY 0 // floppy disk drive #define RP_DEVICECATEGORY_HD 1 // hard disk drive @@ -262,27 +280,29 @@ typedef struct RPDeviceContent #define RP_DEVICECATEGORY_TAPE 4 // cassette tape drive #define RP_DEVICECATEGORY_CARTRIDGE 5 // expansion cartridge #define RP_DEVICECATEGORY_INPUTPORT 6 // input port (hosts an INPUTDEVICE: mouse, joystick, joystick emulated via keyboard, etc.) -#define RP_DEVICECATEGORY_COUNT 7 // total number of device categories +#define RP_DEVICECATEGORY_KEYBOARD 7 // keyboard +#define RP_DEVICECATEGORY_COUNT 8 // total number of device categories -#define RP_ALL_DEVICES 32 // constant for the RPIPCGM_DEVICEACTIVITY message (to turn on/off all LEDs for a device category) +#define RP_ALL_DEVICES 32 // constant for the RP_IPC_TO_HOST_DEVICEACTIVITY message (to turn on/off all LEDs for a device category) // Host Input Device Types (used to enumerate host devices) -#define RP_HOSTINPUT_MOUSE 0 // Mouse/trackball (supports relative moves) -#define RP_HOSTINPUT_TABLET 1 // Pen tablet (no relative moves, only absolute positions) -#define RP_HOSTINPUT_JOYSTICK 2 // PC joystick, gamepad, trackball, etc. -#define RP_HOSTINPUT_KEYJOY_MAP1 3 // Keyboard Layout 1; Amiga/C64: Keyboard Layout A for WinUAE/VICE (numeric keypad, 0 to fire, etc.) -#define RP_HOSTINPUT_KEYJOY_MAP2 4 // Keyboard Layout 2; Amiga/C64: Keyboard Layout B for WinUAE/VICE (cursor keys, right Control to fire, etc.) -#define RP_HOSTINPUT_KEYJOY_MAP3 5 // Keyboard Layout 3; Amiga/C64: Keyboard Layout C for WinUAE/VICE (W, S, A, D keys, left Alt to fire, etc.) -#define RP_HOSTINPUT_ARCADE_LEFT 6 // Left part of arcade dual joystick input device ("player 1") -#define RP_HOSTINPUT_ARCADE_RIGHT 7 // Right part of arcade dual joystick input device ("player 2") -#define RP_HOSTINPUT_COUNT 8 // total number of device types +#define RP_HOSTINPUT_MOUSE 0 // Mouse/trackball (supports relative moves) +#define RP_HOSTINPUT_TABLET 1 // Pen tablet (no relative moves, only absolute positions) +#define RP_HOSTINPUT_JOYSTICK 2 // PC joystick, gamepad, trackball, etc. +#define RP_HOSTINPUT_KEYJOY_MAP1 3 // Keyboard Layout 1; Amiga/C64: Keyboard Layout A for WinUAE/VICE (8, 2, 4, 6 on keypad, 0 to fire, etc.) +#define RP_HOSTINPUT_KEYJOY_MAP2 4 // Keyboard Layout 2; Amiga/C64: Keyboard Layout B for WinUAE/VICE (cursor keys, right Control to fire, etc.) +#define RP_HOSTINPUT_KEYJOY_MAP3 5 // Keyboard Layout 3; Amiga/C64: Keyboard Layout C for WinUAE/VICE (W, S, A, D keys, left Alt to fire, etc.) +#define RP_HOSTINPUT_ARCADE_LEFT 6 // Left part of arcade dual joystick input device ("player 1") +#define RP_HOSTINPUT_ARCADE_RIGHT 7 // Right part of arcade dual joystick input device ("player 2") +#define RP_HOSTINPUT_KEYJOY_CUSTOM 8 // Custom Keyboard Layout (e.g. "KeyboardCustom Left=0xC8 Right=0xD0 Up=0xCB Down=0xCD Fire=0x39" set in szContent) +#define RP_HOSTINPUT_COUNT 9 // total number of device types // Host Input Device Flags -#define RP_HOSTINPUTFLAGS_MOUSE_RAW 0x00000000 // Individual raw mouse device with no acceleration +#define RP_HOSTINPUTFLAGS_MOUSE_RAW 0x00000000 // Individual raw mouse device with no acceleration (multi-mouse warning: RAW and SMART devices cannot be used simultaneously) #define RP_HOSTINPUTFLAGS_MOUSE_SMART 0x00000001 // System pointer mouse with acceleration and aggregation of multiple devices #define RP_HOSTINPUTFLAGS_MOUSEMASK 0x00000001 -#define RP_HOSTINPUTFLAGS_MOUSE(m) ((m) & RP_DEVICEFLAGS_MOUSEMASK) // returns RP_HOSTINPUTFLAGS_MOUSE_RAW or RP_HOSTINPUTFLAGS_MOUSE_SMART +#define RP_HOSTINPUTFLAGS_MOUSE(m) ((m) & RP_HOSTINPUTFLAGS_MOUSEMASK) // returns RP_HOSTINPUTFLAGS_MOUSE_RAW or RP_HOSTINPUTFLAGS_MOUSE_SMART // Guest Input Device Types (used to describe what the host side device is mapped to on the guest side) @@ -297,7 +317,7 @@ typedef struct RPDeviceContent #define RP_INPUTDEVICE_TABLET 8 // [currently unused] Pen tablet (no relative moves, only absolute positions); on Amiga: pressure support as per Electronic Arts Tablet.library #define RP_INPUTDEVICE_COUNT 9 // total number of device types -// Device Read/Write status (used in RPIPCGM_DEVICECONTENT, RPIPCHM_DEVICECONTENT; used for device categories RP_DEVICECATEGORY_FLOPPY, RP_DEVICECATEGORY_HD, RP_DEVICECATEGORY_TAPE, RP_DEVICECATEGORY_CARTRIDGE) +// Device Read/Write status (used in RP_IPC_TO_HOST_DEVICECONTENT, RP_IPC_TO_GUEST_DEVICECONTENT; used for device categories RP_DEVICECATEGORY_FLOPPY, RP_DEVICECATEGORY_HD, RP_DEVICECATEGORY_TAPE, RP_DEVICECATEGORY_CARTRIDGE) #define RP_DEVICEFLAGS_RW_READONLY 0x00000000 // the medium is write-protected #define RP_DEVICEFLAGS_RW_READWRITE 0x00000001 // the medium is read/write #define RP_DEVICEFLAGS_RWMASK 0x00000001 @@ -323,7 +343,7 @@ typedef struct RPDeviceContent #define RP_JOYSTICK_BUTTON7 0x00000400 // button 7 - CDTV/CD32 Forward -// Device Read/Write status (used in RPIPCGM_DEVICEREADWRITE, RPIPCHM_DEVICEREADWRITE; used for device categories RP_DEVICECATEGORY_FLOPPY, RP_DEVICECATEGORY_HD, RP_DEVICECATEGORY_TAPE, RP_DEVICECATEGORY_CARTRIDGE) +// Device Read/Write status (used in RP_IPC_TO_HOST_DEVICEREADWRITE, RP_IPC_TO_GUEST_DEVICEREADWRITE; used for device categories RP_DEVICECATEGORY_FLOPPY, RP_DEVICECATEGORY_HD, RP_DEVICECATEGORY_TAPE, RP_DEVICECATEGORY_CARTRIDGE) #define RP_DEVICE_READONLY 0 // the medium is write-protected #define RP_DEVICE_READWRITE 1 // the medium is read/write @@ -336,17 +356,17 @@ typedef struct RPDeviceContent #define RP_RESET_SOFT 0 // soft reset #define RP_RESET_HARD 1 // hard reset -// RPIPCGM_MOUSECAPTURE/RPIPCHM_MOUSECAPTURE +// RP_IPC_TO_HOST_MOUSECAPTURE/RP_IPC_TO_GUEST_MOUSECAPTURE #define RP_MOUSECAPTURE_CAPTURED 0x00000001 #define RP_MOUSECAPTURE_MAGICMOUSE 0x00000002 -// RPIPCGM_DEVICEACTIVITY +// RP_IPC_TO_HOST_DEVICEACTIVITY #define RP_DEVICEACTIVITY_GREEN 0x0000 // green led #define RP_DEVICEACTIVITY_RED 0x0001 // red led #define RP_DEVICEACTIVITY_READ RP_DEVICEACTIVITY_GREEN // device activity is a read operation #define RP_DEVICEACTIVITY_WRITE RP_DEVICEACTIVITY_RED // device activity is a write operation -// RPIPCGM_HOSTVERSION +// RP_IPC_TO_HOST_HOSTVERSION // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 // +-----------------------+-------------------+-------------------+ @@ -359,8 +379,8 @@ typedef struct RPDeviceContent // Legacy Compatibility (pre-3.0) -#define RPIPCGM_DEVICECONTENT_LEGACY (WM_APP + 16) -#define RPIPCHM_DEVICECONTENT_LEGACY (WM_APP + 205) +#define RP_IPC_TO_HOST_DEVICECONTENT_LEGACY (WM_APP + 16) +#define RP_IPC_TO_GUEST_DEVICECONTENT_LEGACY (WM_APP + 205) #define RPLATFORM_API_VER RETROPLATFORM_API_VER #define RPLATFORM_API_VER_MAJOR RETROPLATFORM_API_VER_MAJOR #define RPLATFORM_API_VER_MINOR RETROPLATFORM_API_VER_MINOR @@ -394,12 +414,57 @@ typedef struct RPDeviceContent_Legacy #define RP_DEVICE_INPUTPORT RP_DEVICECATEGORY_INPUTPORT #define RP_DEVICE_CATEGORIES RP_DEVICECATEGORY_COUNT // Legacy Host Side Input Port Devices -#define RP_IPD_MOUSE1 _T("Mouse1") // \0\0-terminated first mouse type ("Mouse1\0\0" = default Windows mouse, or exact mouse described as "Mouse1\\\?\HID#VID_046D&PID_C521&MI_00#8&3b7afb0d&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd\0\0") -#define RP_IPD_JOYSTICK1 _T("Joystick1") // \0\0-terminated first joystick type (e.g. standard joystick for WinUAE, described as "Joystick1\0ProductGUID InstanceGUID\0ProductName\0\0"); ProductName must be stripped of trailing spaces, if any -#define RP_IPD_JOYSTICK2 _T("Joystick2") // \0\0-terminated second joystick type (e.g. X-Arcade (Left) joystick for WinUAE, described as "Joystick2\0ProductGUID InstanceGUID\0ProductName\0\0"); ProductName must be stripped of trailing spaces, if any -#define RP_IPD_JOYSTICK3 _T("Joystick3") // \0\0-terminated third joystick type (e.g. X-Arcade (Right) joystick for WinUAE, described as "Joystick3\0ProductGUID InstanceGUID\0ProductName\0\0"); ProductName must be stripped of trailing spaces, if any -#define RP_IPD_KEYBDL1 _T("KeyboardLayout1") // \0\0-terminated first joystick emulation keyboard layout (e.g. Keyboard Layout A for WinUAE) -#define RP_IPD_KEYBDL2 _T("KeyboardLayout2") // \0\0-terminated second joystick emulation keyboard layout (e.g. Keyboard Layout B for WinUAE) -#define RP_IPD_KEYBDL3 _T("KeyboardLayout3") // \0\0-terminated third joystick emulation keyboard layout (e.g. Keyboard Layout C for WinUAE) +#define RP_IPD_MOUSE1 L"Mouse1" // \0\0-terminated first mouse type ("Mouse1\0\0" = default Windows mouse, or exact mouse described as "Mouse1\\\?\HID#VID_046D&PID_C521&MI_00#8&3b7afb0d&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd\0\0") +#define RP_IPD_JOYSTICK1 L"Joystick1" // \0\0-terminated first joystick type (e.g. standard joystick for WinUAE, described as "Joystick1\0ProductGUID InstanceGUID\0ProductName\0\0"); ProductName must be stripped of trailing spaces, if any +#define RP_IPD_JOYSTICK2 L"Joystick2" // \0\0-terminated second joystick type (e.g. X-Arcade (Left) joystick for WinUAE, described as "Joystick2\0ProductGUID InstanceGUID\0ProductName\0\0"); ProductName must be stripped of trailing spaces, if any +#define RP_IPD_JOYSTICK3 L"Joystick3" // \0\0-terminated third joystick type (e.g. X-Arcade (Right) joystick for WinUAE, described as "Joystick3\0ProductGUID InstanceGUID\0ProductName\0\0"); ProductName must be stripped of trailing spaces, if any +#define RP_IPD_KEYBDL1 L"KeyboardLayout1" // \0\0-terminated first joystick emulation keyboard layout (e.g. Keyboard Layout A for WinUAE) +#define RP_IPD_KEYBDL2 L"KeyboardLayout2" // \0\0-terminated second joystick emulation keyboard layout (e.g. Keyboard Layout B for WinUAE) +#define RP_IPD_KEYBDL3 L"KeyboardLayout3" // \0\0-terminated third joystick emulation keyboard layout (e.g. Keyboard Layout C for WinUAE) +// Messages +#define RPIPCGM_REGISTER RP_IPC_TO_HOST_REGISTER +#define RPIPCGM_FEATURES RP_IPC_TO_HOST_FEATURES +#define RPIPCGM_CLOSED RP_IPC_TO_HOST_CLOSED +#define RPIPCGM_ACTIVATED RP_IPC_TO_HOST_ACTIVATED +#define RPIPCGM_DEACTIVATED RP_IPC_TO_HOST_DEACTIVATED +#define RPIPCGM_ENABLED RP_IPC_TO_HOST_ENABLED +#define RPIPCGM_DISABLED RP_IPC_TO_HOST_DISABLED +#define RPIPCGM_SCREENMODE RP_IPC_TO_HOST_SCREENMODE +#define RPIPCGM_POWERLED RP_IPC_TO_HOST_POWERLED +#define RPIPCGM_DEVICES RP_IPC_TO_HOST_DEVICES +#define RPIPCGM_DEVICEACTIVITY RP_IPC_TO_HOST_DEVICEACTIVITY +#define RPIPCGM_MOUSECAPTURE RP_IPC_TO_HOST_MOUSECAPTURE +#define RPIPCGM_HOSTAPIVERSION RP_IPC_TO_HOST_HOSTAPIVERSION +#define RPIPCGM_PAUSE RP_IPC_TO_HOST_PAUSE +#define RPIPCGM_TURBO RP_IPC_TO_HOST_TURBO +#define RPIPCGM_PING RP_IPC_TO_HOST_PING +#define RPIPCGM_VOLUME RP_IPC_TO_HOST_VOLUME +#define RPIPCGM_ESCAPED RP_IPC_TO_HOST_ESCAPED +#define RPIPCGM_PARENT RP_IPC_TO_HOST_PARENT +#define RPIPCGM_DEVICESEEK RP_IPC_TO_HOST_DEVICESEEK +#define RPIPCGM_CLOSE RP_IPC_TO_HOST_CLOSE +#define RPIPCGM_DEVICEREADWRITE RP_IPC_TO_HOST_DEVICEREADWRITE +#define RPIPCGM_HOSTVERSION RP_IPC_TO_HOST_HOSTVERSION +#define RPIPCGM_INPUTDEVICE RP_IPC_TO_HOST_INPUTDEVICE +#define RPIPCGM_DEVICECONTENT RP_IPC_TO_HOST_DEVICECONTENT +#define RPIPCHM_CLOSE RP_IPC_TO_GUEST_CLOSE +#define RPIPCHM_SCREENMODE RP_IPC_TO_GUEST_SCREENMODE +#define RPIPCHM_SCREENCAPTURE RP_IPC_TO_GUEST_SCREENCAPTURE +#define RPIPCHM_PAUSE RP_IPC_TO_GUEST_PAUSE +#define RPIPCHM_RESET RP_IPC_TO_GUEST_RESET +#define RPIPCHM_TURBO RP_IPC_TO_GUEST_TURBO +#define RPIPCHM_PING RP_IPC_TO_GUEST_PING +#define RPIPCHM_VOLUME RP_IPC_TO_GUEST_VOLUME +#define RPIPCHM_ESCAPEKEY RP_IPC_TO_GUEST_ESCAPEKEY +#define RPIPCHM_EVENT RP_IPC_TO_GUEST_EVENT +#define RPIPCHM_MOUSECAPTURE RP_IPC_TO_GUEST_MOUSECAPTURE +#define RPIPCHM_SAVESTATE RP_IPC_TO_GUEST_SAVESTATE +#define RPIPCHM_LOADSTATE RP_IPC_TO_GUEST_LOADSTATE +#define RPIPCHM_FLUSH RP_IPC_TO_GUEST_FLUSH +#define RPIPCHM_DEVICEREADWRITE RP_IPC_TO_GUEST_DEVICEREADWRITE +#define RPIPCHM_QUERYSCREENMODE RP_IPC_TO_GUEST_QUERYSCREENMODE +#define RPIPCHM_GUESTAPIVERSION RP_IPC_TO_GUEST_GUESTAPIVERSION +#define RPIPCHM_DEVICECONTENT RP_IPC_TO_GUEST_DEVICECONTENT +// End of Legacy Compatibility #endif // __CLOANTO_RETROPLATFORMIPC_H__ diff --git a/od-win32/dxwrap.cpp b/od-win32/dxwrap.cpp index 0a115f37..83406f0a 100644 --- a/od-win32/dxwrap.cpp +++ b/od-win32/dxwrap.cpp @@ -34,7 +34,7 @@ HRESULT DirectDraw_GetDisplayMode (void) static LPDIRECTDRAWSURFACE7 getlocksurface (void) { - if (dxdata.backbuffers > 0 && currprefs.gfx_apmode[0].gfx_fullscreen > 0 && !WIN32GFX_IsPicassoScreen ()) + if (dxdata.backbuffers > 0 && currprefs.gfx_apmode[APMODE_NATIVE].gfx_fullscreen > 0 && !WIN32GFX_IsPicassoScreen ()) return dxdata.flipping[0]; return dxdata.secondary; } @@ -1183,7 +1183,8 @@ int DirectDraw_Start (void) guid = NULL; if (isfullscreen () > 0) { - int disp = currprefs.gfx_display - 1; + MultiDisplay *md = getdisplay (&currprefs); + int disp = md - Displays; if (disp < 0) disp = 0; if (disp >= MAX_DISPLAYS) diff --git a/od-win32/resources/resource b/od-win32/resources/resource index 0d439fa7..cd29145d 100644 --- a/od-win32/resources/resource +++ b/od-win32/resources/resource @@ -629,6 +629,7 @@ #define IDC_FLUSHPRINTER 1510 #define IDC_MAPDRIVES_REMOVABLE 1510 #define IDC_PORT0_TEST 1510 +#define IDC_CACHETEXT2 1510 #define IDC_SCREENRESTEXT 1511 #define IDC_MAPDRIVES_AUTO 1511 #define IDC_PORT0_TEST2 1511 diff --git a/od-win32/resources/winuae.rc b/od-win32/resources/winuae.rc index fbe13d0d..69b75afe 100644 --- a/od-win32/resources/winuae.rc +++ b/od-win32/resources/winuae.rc @@ -214,17 +214,12 @@ BEGIN 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 - CONTROL "Approximate A500 or A500/A1200 cycle-exact",IDC_CS_68000, + CONTROL "Fastest possible",IDC_CS_HOST,"Button",BS_AUTORADIOBUTTON | BS_LEFT | WS_GROUP | WS_TABSTOP,95,18,195,10 + CONTROL "Approximate A500/A1200 or cycle-exact",IDC_CS_68000, "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 "Slider1",IDC_SPEED,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,96,51,192,20 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 + CTEXT "CPU Idle",IDC_STATIC,179,76,35,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 @@ -232,13 +227,15 @@ BEGIN 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 + EDITTEXT IDC_CPUTEXT,144,75,30,12,ES_CENTER | ES_READONLY CONTROL "Hard flush",IDC_HARDFLUSH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,100,194,63,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 + EDITTEXT IDC_CACHETEXT2,265,175,30,12,ES_CENTER | ES_READONLY + CTEXT "CPU Speed",IDC_STATIC,93,76,43,9,SS_CENTERIMAGE END IDD_FLOPPY DIALOGEX 0, 0, 300, 240 diff --git a/od-win32/rp.cpp b/od-win32/rp.cpp index ff7c8f59..9184ecf1 100644 --- a/od-win32/rp.cpp +++ b/od-win32/rp.cpp @@ -149,14 +149,136 @@ static const int inputdevmode[] = { 0, 0, }; -static int port_insert (int num, int devicetype, DWORD flags, const TCHAR *name) +#define KEYBOARDCUSTOM _T("KeyboardCustom ") + +struct rp_customevent +{ + const TCHAR *name; + int evt; +}; + +static const TCHAR *customeventorder[] = { + _T("Left"), + _T("Right"), + _T("Up"), + _T("Down"), + _T("Fire"), + NULL +}; + +bool port_get_custom (int inputmap_port, TCHAR *out) +{ + int kb; + bool first = true; + TCHAR *p = out; + int mode, *events, *axistable; + int max; + + max = inputdevice_get_compatibility_input (&currprefs, inputmap_port, &mode, &events, &axistable); + if (!max) + return false; + + _tcscpy (p, KEYBOARDCUSTOM); + p += _tcslen (p); + kb = inputdevice_get_device_total (IDTYPE_JOYSTICK) + inputdevice_get_device_total (IDTYPE_MOUSE); + for (int i = 0; customeventorder[i]; i++) { + int evtnum = events[i]; + for (int j = 0; j < inputdevicefunc_keyboard.get_widget_num (kb); j++) { + int flags, port; + if (inputdevice_get_mapping (kb, j, &flags, &port, NULL, NULL, 0) == evtnum) { + if (port == inputmap_port + 1) { + uae_u32 kc = 0; + inputdevicefunc_keyboard.get_widget_type (kb, j, NULL, &kc); + if (!first) + *p++ = ' '; + first = false; + _stprintf (p, _T("%s=0x%02X"), customeventorder[i], kc); + p += _tcslen (p); + break; + } + } + } + } + write_log (L"********* -> %s\n", out); + return true; +} + +int port_insert_custom (int inputmap_port, int devicetype, DWORD flags, const TCHAR *custom) +{ + const TCHAR *p = custom; + int mode, *events, *axistable; + int max, evtnum; + int kb; + + kb = inputdevice_get_device_total (IDTYPE_JOYSTICK) + inputdevice_get_device_total (IDTYPE_MOUSE); + + inputdevice_updateconfig (&changed_prefs); + inputdevice_compa_prepare_custom (&changed_prefs, inputmap_port, JSEM_MODE_JOYSTICK); + inputdevice_updateconfig (&changed_prefs); + max = inputdevice_get_compatibility_input (&changed_prefs, inputmap_port, &mode, &events, &axistable); + write_log (L"custom='%s' max=%d port=%d\n", custom, max, inputmap_port); + if (!max) + return FALSE; + + while (p && p[0]) { + int idx = -1, kc = -1; + int wdnum = -1; + const TCHAR *p2 = _tcschr (p, '='); + if (!p2) + break; + for (int i = 0; customeventorder[i]; i++) { + if (!_tcsncmp (p, customeventorder[i], p2 - p)) { + idx = i; + break; + } + } + if (idx < 0 || idx > 4) + break; + p2++; + if (p2[0] == '0' && (p2[1] == 'x' || p2[1] == 'X')) + kc = _tcstol (p2 + 2, NULL, 16); + else + kc = _tstol (p2); + p = _tcschr (p2, ' '); + if (p) + p++; + if (kc < 0) + break; + evtnum = events[idx]; + + write_log (L"evt=%d kc=%d\n", evtnum, kc); + + for (int j = 0; j < inputdevice_get_device_total (IDTYPE_KEYBOARD); j++) { + for (int i = 0; i < inputdevicefunc_keyboard.get_widget_num (kb + j); i++) { + uae_u32 kc2 = 0; + inputdevicefunc_keyboard.get_widget_type (kb + j, i, NULL, &kc2); + if (kc == kc2) { + wdnum = i; + break; + } + } + if (wdnum >= 0) + inputdevice_set_gameports_mapping (&changed_prefs, kb + j, wdnum, evtnum, inputmap_port); + } + } + + inputdevice_updateconfig (&changed_prefs); + return TRUE; +} + +static int port_insert (int inputmap_port, int devicetype, DWORD flags, const TCHAR *name) { int devicetype2; - if (num < 0 || num >= maxjports) + write_log (L"port_insert %d '%s'\n", inputmap_port, name); + + if (inputmap_port < 0 || inputmap_port >= maxjports) return FALSE; + + inputdevice_compa_clear (&changed_prefs, inputmap_port); + if (_tcslen (name) == 0) { - inputdevice_joyport_config (&changed_prefs, _T("none"), num, 0, 0); + inputdevice_joyport_config (&changed_prefs, _T("none"), inputmap_port, 0, 0); return TRUE; } devicetype2 = -1; @@ -169,15 +291,19 @@ static int port_insert (int num, int devicetype, DWORD flags, const TCHAR *name) if (devicetype2 < 0) return FALSE; + if (!_tcsncmp (name, KEYBOARDCUSTOM, _tcslen (KEYBOARDCUSTOM))) { + return port_insert_custom (inputmap_port, devicetype, flags, name + _tcslen (KEYBOARDCUSTOM)); + } + for (int i = 0; i < 10; i++) { TCHAR tmp2[100]; _stprintf (tmp2, _T("KeyboardLayout%d"), i); if (!_tcscmp (tmp2, name)) { _stprintf (tmp2, _T("kbd%d"), i + 1); - return inputdevice_joyport_config (&changed_prefs, tmp2, num, devicetype2, 0); + return inputdevice_joyport_config (&changed_prefs, tmp2, inputmap_port, devicetype2, 0); } } - return inputdevice_joyport_config (&changed_prefs, name, num, devicetype2, 1); + return inputdevice_joyport_config (&changed_prefs, name, inputmap_port, devicetype2, 1); } static int cd_insert (int num, const TCHAR *name) @@ -391,7 +517,7 @@ static void get_screenmode (struct RPScreenMode *sm, struct uae_prefs *p) } if (full) { m &= ~RP_SCREENMODE_DISPLAYMASK; - m |= p->gfx_display << 8; + m |= p->gfx_apmode[APMODE_NATIVE].gfx_display << 8; } if (full > 1) m |= RP_SCREENMODE_FULLWINDOW; @@ -413,7 +539,7 @@ static void get_screenmode (struct RPScreenMode *sm, struct uae_prefs *p) if (log_rp) write_log (_T("GET_RPSM: %08X %dx%d %dx%d hres=%d (%d) vres=%d (%d) disp=%d fs=%d\n"), sm->dwScreenMode, sm->lClipLeft, sm->lClipTop, sm->lClipWidth, sm->lClipHeight, - totalhdbl, hres, totalvdbl, vres, p->gfx_display, full); + totalhdbl, hres, totalvdbl, vres, p->gfx_apmode[APMODE_NATIVE].gfx_display, full); } static void set_screenmode (struct RPScreenMode *sm, struct uae_prefs *p) @@ -434,8 +560,10 @@ static void set_screenmode (struct RPScreenMode *sm, struct uae_prefs *p) storeflags = sm->dwScreenMode; minimized = 0; if (display) { - p->gfx_display = display; - p->gfx_display_name[0] = 0; + p->gfx_apmode[APMODE_NATIVE].gfx_display = display; + p->gfx_apmode[APMODE_NATIVE].gfx_display_name[0] = 0; + p->gfx_apmode[APMODE_RTG].gfx_display = display; + p->gfx_apmode[APMODE_RTG].gfx_display_name[0] = 0; if (sm->dwScreenMode & RP_SCREENMODE_FULLWINDOW) fs = 2; else @@ -866,7 +994,7 @@ static void sendenum (void) _stprintf (tmp2, _T("KeyboardLayout%d"), cnt); _tcscpy (desc.szHostInputID, tmp2); _tcscpy (desc.szHostInputName, p1); - desc.dwHostInputType= RP_HOSTINPUT_KEYJOY_MAP1 + cnt; + desc.dwHostInputType= (RP_HOSTINPUT_KEYJOY_MAP1 + cnt); desc.dwInputDeviceFeatures = RP_FEATURE_INPUTDEVICE_JOYSTICK; if (cnt == 0) desc.dwInputDeviceFeatures |= RP_FEATURE_INPUTDEVICE_JOYPAD; @@ -879,6 +1007,12 @@ static void sendenum (void) break; } } + memset (&desc, 0, sizeof desc); + _tcscpy (desc.szHostInputID, _T("KeyboardCustom")); + _tcscpy (desc.szHostInputName, _T("KeyboardCustom")); + desc.dwHostInputType = RP_HOSTINPUT_KEYJOY_CUSTOM; + desc.dwInputDeviceFeatures = RP_FEATURE_INPUTDEVICE_JOYSTICK; + RPSendMessagex (RPIPCGM_INPUTDEVICE, 0, 0, &desc, sizeof desc, &guestinfo, NULL); cnt = 0; while ((cnt = rp_input_enum (&desc, cnt)) >= 0) { if (log_rp) @@ -1049,7 +1183,9 @@ void rp_input_change (int num) return; name[0] = 0; - if (k >= 0) { + if (currprefs.jports[num].id == JPORT_CUSTOM) { + port_get_custom (num, name); + } else if (k >= 0) { _stprintf (name, _T("KeyboardLayout%d"), k); } else if (j >= 0) { _tcscpy (name, inputdevice_get_device_unique_name (IDTYPE_JOYSTICK, j)); diff --git a/od-win32/win32.cpp b/od-win32/win32.cpp index fcda8d40..a3d17356 100644 --- a/od-win32/win32.cpp +++ b/od-win32/win32.cpp @@ -2862,6 +2862,20 @@ void target_default_options (struct uae_prefs *p, int type) WIN32GUI_LoadUIString (IDS_INPUT_CUSTOM, buf, sizeof buf / sizeof (TCHAR)); for (int i = 0; i < GAMEPORT_INPUT_SETTINGS; i++) _stprintf (p->input_config_name[i], buf, i + 1); + + /* switch from 32 to 16 or vice versa if mode does not exist */ + struct MultiDisplay *md = getdisplay (p); + int depth = currprefs.color_mode == 5 ? 4 : 2; + for (int i = 0; md->DisplayModes[i].depth >= 0; i++) { + if (md->DisplayModes[i].depth == depth) { + depth = 0; + break; + } + } + if (depth) { + currprefs.color_mode = currprefs.color_mode == 5 ? 2 : 5; + } + } if (type == 1 || type == 0) { p->win32_uaescsimode = UAESCSI_CDEMU; diff --git a/od-win32/win32.h b/od-win32/win32.h index aae911de..327e32fc 100644 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -19,8 +19,8 @@ #define LANG_DLL 1 //#define WINUAEBETA _T("") -#define WINUAEBETA _T("Beta 0") -#define WINUAEDATE MAKEBD(2012, 3, 29) +#define WINUAEBETA _T("Beta 1") +#define WINUAEDATE MAKEBD(2012, 3, 31) #define WINUAEEXTRA _T("") //#define WINUAEEXTRA _T("AmiKit Preview") #define WINUAEREV _T("") diff --git a/od-win32/win32gfx.cpp b/od-win32/win32gfx.cpp index c02b6cf4..944295e7 100644 --- a/od-win32/win32gfx.cpp +++ b/od-win32/win32gfx.cpp @@ -254,30 +254,41 @@ HWND hStatusWnd = NULL; static uae_u8 scrlinebuf[4096 * 4]; /* this is too large, but let's rather play on the safe side here */ -struct MultiDisplay *getdisplay (struct uae_prefs *p) -{ - int i; - int display = p->gfx_display - 1; - - i = 0; - while (Displays[i].monitorname) { - struct MultiDisplay *md = &Displays[i]; - if (p->gfx_display_name[0] && !_tcscmp (md->adaptername, p->gfx_display_name)) - return md; - if (p->gfx_display_name[0] && !_tcscmp (md->adaptername, p->gfx_display_name)) - return md; - i++; +static struct MultiDisplay *getdisplay2 (struct uae_prefs *p, int index) +{ + int max; + int display = index < 0 ? p->gfx_apmode[screen_is_picasso ? APMODE_RTG : APMODE_NATIVE].gfx_display - 1 : index; + + max = 0; + while (Displays[max].monitorname) { + if (index < 0) { + struct MultiDisplay *md = &Displays[max]; + if (screen_is_picasso) { + if (p->gfx_apmode[APMODE_RTG].gfx_display_name[0] && !_tcscmp (md->adaptername, p->gfx_apmode[APMODE_RTG].gfx_display_name)) + return md; + } else { + if (p->gfx_apmode[APMODE_NATIVE].gfx_display_name[0] && !_tcscmp (md->adaptername, p->gfx_apmode[APMODE_NATIVE].gfx_display_name)) + return md; + } + } + max++; } - if (i == 0) { + if (max == 0) { gui_message (_T("no display adapters! Exiting")); exit (0); } - if (display >= i) + if (index >= 0 && display >= max) + return NULL; + if (display >= max) display = 0; if (display < 0) display = 0; return &Displays[display]; } +struct MultiDisplay *getdisplay (struct uae_prefs *p) +{ + return getdisplay2 (p, -1); +} void desktop_coords (int *dw, int *dh, int *ax, int *ay, int *aw, int *ah) { @@ -1446,8 +1457,10 @@ int check_prefs_changed_gfx (void) c |= currprefs.gfx_lores_mode != changed_prefs.gfx_lores_mode ? (2 | 8) : 0; c |= currprefs.gfx_scandoubler != changed_prefs.gfx_scandoubler ? (2 | 8) : 0; - c |= currprefs.gfx_display != changed_prefs.gfx_display ? (2|4|8) : 0; - c |= _tcscmp (currprefs.gfx_display_name, changed_prefs.gfx_display_name) ? (2|4|8) : 0; + c |= currprefs.gfx_apmode[APMODE_NATIVE].gfx_display != changed_prefs.gfx_apmode[APMODE_NATIVE].gfx_display ? (2|4|8) : 0; + c |= currprefs.gfx_apmode[APMODE_RTG].gfx_display != changed_prefs.gfx_apmode[APMODE_RTG].gfx_display ? (2|4|8) : 0; + c |= _tcscmp (currprefs.gfx_apmode[APMODE_NATIVE].gfx_display_name, changed_prefs.gfx_apmode[APMODE_NATIVE].gfx_display_name) ? (2|4|8) : 0; + c |= _tcscmp (currprefs.gfx_apmode[APMODE_RTG].gfx_display_name, changed_prefs.gfx_apmode[APMODE_RTG].gfx_display_name) ? (2|4|8) : 0; c |= currprefs.gfx_blackerthanblack != changed_prefs.gfx_blackerthanblack ? (2 | 8) : 0; c |= currprefs.gfx_apmode[0].gfx_backbuffers != changed_prefs.gfx_apmode[0].gfx_backbuffers ? (2 | 8) : 0; c |= currprefs.gfx_apmode[0].gfx_interlaced != changed_prefs.gfx_apmode[0].gfx_interlaced ? (2 | 8) : 0; @@ -1519,8 +1532,10 @@ int check_prefs_changed_gfx (void) currprefs.gfx_lores_mode = changed_prefs.gfx_lores_mode; currprefs.gfx_scandoubler = changed_prefs.gfx_scandoubler; - currprefs.gfx_display = changed_prefs.gfx_display; - _tcscpy (currprefs.gfx_display_name, changed_prefs.gfx_display_name); + currprefs.gfx_apmode[APMODE_NATIVE].gfx_display = changed_prefs.gfx_apmode[APMODE_NATIVE].gfx_display; + currprefs.gfx_apmode[APMODE_RTG].gfx_display = changed_prefs.gfx_apmode[APMODE_RTG].gfx_display; + _tcscpy (currprefs.gfx_apmode[APMODE_NATIVE].gfx_display_name, changed_prefs.gfx_apmode[APMODE_NATIVE].gfx_display_name); + _tcscpy (currprefs.gfx_apmode[APMODE_RTG].gfx_display_name, changed_prefs.gfx_apmode[APMODE_RTG].gfx_display_name); currprefs.gfx_blackerthanblack = changed_prefs.gfx_blackerthanblack; currprefs.gfx_apmode[0].gfx_backbuffers = changed_prefs.gfx_apmode[0].gfx_backbuffers; currprefs.gfx_apmode[0].gfx_interlaced = changed_prefs.gfx_apmode[0].gfx_interlaced; @@ -2250,56 +2265,69 @@ static int createnotification (HWND hwnd) static int getbestmode (int nextbest) { - int i, startidx, disp; - struct MultiDisplay *md = getdisplay (&currprefs); + int i, startidx; + struct MultiDisplay *md; int ratio; + int index = -1; - ratio = currentmode->native_width > currentmode->native_height ? 1 : 0; - disp = currprefs.gfx_display; - for (i = 0; md->DisplayModes[i].depth >= 0; i++) { - struct PicassoResolution *pr = &md->DisplayModes[i]; - if (pr->res.width == currentmode->native_width && pr->res.height == currentmode->native_height) - break; - } - if (md->DisplayModes[i].depth >= 0) { - if (!nextbest) - return 1; - while (md->DisplayModes[i].res.width == currentmode->native_width && md->DisplayModes[i].res.height == currentmode->native_height) - i++; - } else { - i = 0; - } - // first iterate only modes that have similar aspect ratio - startidx = i; - for (; md->DisplayModes[i].depth >= 0; i++) { - struct PicassoResolution *pr = &md->DisplayModes[i]; - int r = pr->res.width > pr->res.height ? 1 : 0; - if (pr->res.width >= currentmode->native_width && pr->res.height >= currentmode->native_height && r == ratio) { - write_log (_T("FS: %dx%d -> %dx%d (%d)\n"), currentmode->native_width, currentmode->native_height, - pr->res.width, pr->res.height, ratio); - currentmode->native_width = pr->res.width; - currentmode->native_height = pr->res.height; - currentmode->current_width = currentmode->native_width; - currentmode->current_height = currentmode->native_height; - return 1; + for(;;) { + md = getdisplay2 (&currprefs, index); + if (!md) + return 0; + ratio = currentmode->native_width > currentmode->native_height ? 1 : 0; + for (i = 0; md->DisplayModes[i].depth >= 0; i++) { + struct PicassoResolution *pr = &md->DisplayModes[i]; + if (pr->res.width == currentmode->native_width && pr->res.height == currentmode->native_height) + break; } - } - // still not match? check all modes - i = startidx; - for (; md->DisplayModes[i].depth >= 0; i++) { - struct PicassoResolution *pr = &md->DisplayModes[i]; - int r = pr->res.width > pr->res.height ? 1 : 0; - if (pr->res.width >= currentmode->native_width && pr->res.height >= currentmode->native_height) { - write_log (_T("FS: %dx%d -> %dx%d\n"), currentmode->native_width, currentmode->native_height, - pr->res.width, pr->res.height); - currentmode->native_width = pr->res.width; - currentmode->native_height = pr->res.height; - currentmode->current_width = currentmode->native_width; - currentmode->current_height = currentmode->native_height; - return 1; + if (md->DisplayModes[i].depth >= 0) { + if (!nextbest) + break; + while (md->DisplayModes[i].res.width == currentmode->native_width && md->DisplayModes[i].res.height == currentmode->native_height) + i++; + } else { + i = 0; + } + // first iterate only modes that have similar aspect ratio + startidx = i; + for (; md->DisplayModes[i].depth >= 0; i++) { + struct PicassoResolution *pr = &md->DisplayModes[i]; + int r = pr->res.width > pr->res.height ? 1 : 0; + if (pr->res.width >= currentmode->native_width && pr->res.height >= currentmode->native_height && r == ratio) { + write_log (_T("FS: %dx%d -> %dx%d (%d)\n"), currentmode->native_width, currentmode->native_height, + pr->res.width, pr->res.height, ratio); + currentmode->native_width = pr->res.width; + currentmode->native_height = pr->res.height; + currentmode->current_width = currentmode->native_width; + currentmode->current_height = currentmode->native_height; + break; + } } + // still not match? check all modes + i = startidx; + for (; md->DisplayModes[i].depth >= 0; i++) { + struct PicassoResolution *pr = &md->DisplayModes[i]; + int r = pr->res.width > pr->res.height ? 1 : 0; + if (pr->res.width >= currentmode->native_width && pr->res.height >= currentmode->native_height) { + write_log (_T("FS: %dx%d -> %dx%d\n"), currentmode->native_width, currentmode->native_height, + pr->res.width, pr->res.height); + currentmode->native_width = pr->res.width; + currentmode->native_height = pr->res.height; + currentmode->current_width = currentmode->native_width; + currentmode->current_height = currentmode->native_height; + break; + } + } + index++; } - return 0; + if (index >= 0) { + currprefs.gfx_apmode[screen_is_picasso ? APMODE_RTG : APMODE_NATIVE].gfx_display = + changed_prefs.gfx_apmode[screen_is_picasso ? APMODE_RTG : APMODE_NATIVE].gfx_display = index; + currprefs.gfx_apmode[screen_is_picasso ? APMODE_RTG : APMODE_NATIVE].gfx_display_name[0] = + changed_prefs.gfx_apmode[screen_is_picasso ? APMODE_RTG : APMODE_NATIVE].gfx_display_name[0] = 0; + write_log (L"Monitor switched to '%s'\n", md->adaptername); + } + return 1; } static volatile frame_time_t vblank_prev_time, thread_vblank_time; @@ -3144,6 +3172,9 @@ static int create_windows (void) { if (!create_windows_2 ()) return 0; + + + return set_ddraw (); } diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index 4a182cdd..7734cc19 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -5806,7 +5806,7 @@ static void init_displays_combo (HWND hDlg) int displaynum; int idx = 0; - displaynum = workprefs.gfx_display - 1; + displaynum = workprefs.gfx_apmode[APMODE_NATIVE].gfx_display - 1; if (displaynum < 0) displaynum = 0; SendDlgItemMessage (hDlg, IDC_DISPLAYSELECT, CB_RESETCONTENT, 0, 0); @@ -5840,7 +5840,7 @@ static void get_displays_combo (HWND hDlg) if (posn == CB_ERR) return; - displaynum = workprefs.gfx_display - 1; + displaynum = workprefs.gfx_apmode[APMODE_NATIVE].gfx_display - 1; if (displaynum < 0) displaynum = 0; while (md->monitorname) { @@ -5856,7 +5856,8 @@ static void get_displays_combo (HWND hDlg) if (foundnum >= 0) { if (foundnum == displaynum) return; - workprefs.gfx_display = foundnum + 1; + workprefs.gfx_apmode[APMODE_NATIVE].gfx_display = foundnum + 1; + workprefs.gfx_apmode[APMODE_RTG].gfx_display = foundnum + 1; init_displays_combo (hDlg); init_resolution_combo (hDlg); init_display_mode (hDlg); @@ -7907,8 +7908,7 @@ static void enable_for_cpudlg (HWND hDlg) BOOL enable = FALSE, jitenable = FALSE; BOOL cpu_based_enable = FALSE; - /* These four items only get enabled when adjustable CPU style is enabled */ - ew (hDlg, IDC_SPEED, workprefs.m68k_speed > 0); + ew (hDlg, IDC_SPEED, !workprefs.cpu_cycle_exact); ew (hDlg, IDC_COMPATIBLE24, workprefs.cpu_model == 68020); ew (hDlg, IDC_CS_HOST, !workprefs.cpu_cycle_exact); ew (hDlg, IDC_CS_68000, !workprefs.cpu_cycle_exact); @@ -7951,6 +7951,9 @@ static void enable_for_cpudlg (HWND hDlg) ew (hDlg, IDC_FPU2, TRUE); ew (hDlg, IDC_FPU3, workprefs.cpu_model >= 68040); ew (hDlg, IDC_MMUENABLE, workprefs.cpu_model == 68040 && workprefs.cachesize == 0); + + SendDlgItemMessage (hDlg, IDC_SPEED, TBM_SETRANGE, TRUE, workprefs.m68k_speed < 0 ? MAKELONG(-9, 0) : MAKELONG (-9, 50)); + SendDlgItemMessage (hDlg, IDC_SPEED, TBM_SETPAGESIZE, 0, 1); } static int getcpufreq (int m) @@ -7963,11 +7966,12 @@ static int getcpufreq (int m) static void values_to_cpudlg (HWND hDlg) { - TCHAR cache[8] = _T(""); + TCHAR buffer[8] = _T(""); int cpu; - SendDlgItemMessage (hDlg, IDC_SPEED, TBM_SETPOS, TRUE, workprefs.m68k_speed <= 0 ? 1 : workprefs.m68k_speed / CYCLE_UNIT ); - SetDlgItemInt( hDlg, IDC_CPUTEXT, workprefs.m68k_speed <= 0 ? 1 : workprefs.m68k_speed / CYCLE_UNIT, FALSE ); + SendDlgItemMessage (hDlg, IDC_SPEED, TBM_SETPOS, TRUE, workprefs.m68k_speed_throttle / 100); + _stprintf (buffer, _T("%+d%%"), workprefs.m68k_speed_throttle / 10); + SetDlgItemText (hDlg, IDC_CPUTEXT, buffer); CheckDlgButton (hDlg, IDC_COMPATIBLE, workprefs.cpu_compatible); CheckDlgButton (hDlg, IDC_COMPATIBLE24, workprefs.address_space_24); CheckDlgButton (hDlg, IDC_COMPATIBLE_FPU, workprefs.fpu_strict); @@ -7980,16 +7984,14 @@ static void values_to_cpudlg (HWND hDlg) if (workprefs.m68k_speed < 0) CheckRadioButton(hDlg, IDC_CS_HOST, IDC_CS_ADJUSTABLE, IDC_CS_HOST); - else if (workprefs.m68k_speed == 0) + else if (workprefs.m68k_speed >= 0) CheckRadioButton(hDlg, IDC_CS_HOST, IDC_CS_ADJUSTABLE, IDC_CS_68000); - else - CheckRadioButton(hDlg, IDC_CS_HOST, IDC_CS_ADJUSTABLE, IDC_CS_ADJUSTABLE); CheckRadioButton (hDlg, IDC_TRUST0, IDC_TRUST1, trust_ids[workprefs.comptrustbyte]); SendDlgItemMessage (hDlg, IDC_CACHE, TBM_SETPOS, TRUE, workprefs.cachesize / 1024); - _stprintf (cache, _T("%d MB"), workprefs.cachesize / 1024 ); - SetDlgItemText (hDlg, IDC_CACHETEXT, cache); + _stprintf (buffer, _T("%d MB"), workprefs.cachesize / 1024 ); + SetDlgItemText (hDlg, IDC_CACHETEXT, buffer); CheckDlgButton (hDlg, IDC_NOFLAGS, workprefs.compnf); CheckDlgButton (hDlg, IDC_JITFPU, workprefs.compfpu); @@ -8018,9 +8020,10 @@ static void values_from_cpudlg (HWND hDlg) 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.m68k_speed = ischecked (hDlg, IDC_CS_HOST) ? -1 : 0; + workprefs.m68k_speed_throttle = SendMessage (GetDlgItem (hDlg, IDC_SPEED), TBM_GETPOS, 0, 0) * 100; + if (workprefs.m68k_speed_throttle > 0 && workprefs.m68k_speed < 0) + workprefs.m68k_speed_throttle = 0; workprefs.mmu_model = ischecked (hDlg, IDC_MMUENABLE) ? 68040 : 0; newcpu = ischecked (hDlg, IDC_CPU0) ? 68000 @@ -8147,8 +8150,6 @@ static INT_PTR CALLBACK CPUDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l recursive++; pages[CPU_ID] = hDlg; currentpage = CPU_ID; - SendDlgItemMessage (hDlg, IDC_SPEED, TBM_SETRANGE, TRUE, MAKELONG (MIN_M68K_PRIORITY, MAX_M68K_PRIORITY)); - SendDlgItemMessage (hDlg, IDC_SPEED, TBM_SETPAGESIZE, 0, 1); SendDlgItemMessage (hDlg, IDC_CACHE, TBM_SETRANGE, TRUE, MAKELONG (MIN_CACHE_SIZE, MAX_CACHE_SIZE)); SendDlgItemMessage (hDlg, IDC_CACHE, TBM_SETPAGESIZE, 0, 1); SendDlgItemMessage (hDlg, IDC_CPUIDLE, TBM_SETRANGE, TRUE, MAKELONG (0, 10)); @@ -8187,8 +8188,8 @@ static INT_PTR CALLBACK CPUDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l case WM_USER: recursive++; - values_to_cpudlg (hDlg); enable_for_cpudlg (hDlg); + values_to_cpudlg (hDlg); recursive--; return TRUE; @@ -8197,16 +8198,16 @@ static INT_PTR CALLBACK CPUDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l break; recursive++; values_from_cpudlg (hDlg); - values_to_cpudlg (hDlg); enable_for_cpudlg (hDlg); + values_to_cpudlg (hDlg); recursive--; break; case WM_HSCROLL: recursive++; values_from_cpudlg( hDlg ); - values_to_cpudlg( hDlg ); enable_for_cpudlg( hDlg ); + values_to_cpudlg( hDlg ); recursive--; break; } @@ -11777,7 +11778,7 @@ static void CALLBACK timerfunc (HWND hDlg, UINT uMsg, UINT_PTR idEvent, DWORD dw 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); @@ -11803,11 +11804,8 @@ static void CALLBACK timerfunc (HWND hDlg, UINT uMsg, UINT_PTR idEvent, DWORD dw } } - struct inputevent *ie = inputdevice_get_eventinfo (evtnum); - TCHAR name[256]; - inputdevice_get_eventname (ie, name); //write_log (_T("%d %d %d %s\n"), input_selected_device, input_selected_widget, evtnum, name); - inputdevice_set_gameports_mapping (&workprefs, input_selected_device, input_selected_widget, name, inputmap_port); + inputdevice_set_gameports_mapping (&workprefs, input_selected_device, input_selected_widget, evtnum, inputmap_port); InitializeListView (hDlg); inputmap_remap_counter += cntadd; ListView_EnsureVisible (h, inputmap_remap_counter, FALSE); @@ -12062,7 +12060,7 @@ static INT_PTR CALLBACK InputMapDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPA currentpage = INPUTMAP_ID; inputdevice_updateconfig (&workprefs); if (inputmap_remap_counter == 0) { - inputdevice_compa_prepare_custom (&workprefs, inputmap_port); + inputdevice_compa_prepare_custom (&workprefs, inputmap_port, -1); inputdevice_updateconfig (&workprefs); } InitializeListView (hDlg); diff --git a/od-win32/winuaechangelog.txt b/od-win32/winuaechangelog.txt index 2fd64121..6fdda018 100644 --- a/od-win32/winuaechangelog.txt +++ b/od-win32/winuaechangelog.txt @@ -1,3 +1,22 @@ +- cpu throttling +- custom event autofire +- cycle exact mode scanline sync +- restore only single input target to default. +- hdd from command line + +Beta 1: + +- Input custom event autofire support. +- Automatically switch to another monitor if current monitor does not support selected RTG mode. + (RTG mode list always lists all monitors' modes) +- CDFS ACTION_EXAMINE_ALL crash. (It seems this was 2.4's most stupid bug) +- Fastest possible CPU mode (including JIT) CPU speed throttle option. +- Non fastest possible CPU mode CPU speed adjustment option. Currently GUI allows from -90% to 500%. +- Removed Adjustable CPU/Chipset speed option, above option should be much better. +- Switch from 16bit to 32bit (or vice versa) on startup if selected color depth does not exist. + (Beta Windows 8 + NVidia don't seem to have any 16bit modes) +- Experimental sound sync update. Should increase stability of sound sync in non-fastest modes. + (Side-effects possible) 2.4.0