From 4e624668673914e0545077d4fc7662e94970194f Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sun, 6 Nov 2016 16:56:56 +0200 Subject: [PATCH] keyboard connected -option. --- cfgfile.cpp | 8 +++++-- cia.cpp | 55 +++++++++++++++++++++++++++++------------------ include/cia.h | 2 ++ include/options.h | 1 + 4 files changed, 43 insertions(+), 23 deletions(-) diff --git a/cfgfile.cpp b/cfgfile.cpp index d60deb24..fa99557d 100644 --- a/cfgfile.cpp +++ b/cfgfile.cpp @@ -2187,6 +2187,7 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_write_bool(f, _T("fm801_pci"), p->obs_sound_fm801); #endif + cfgfile_dwrite_bool(f, _T("keyboard_connected"), p->keyboard_connected); cfgfile_write_str (f, _T("kbd_lang"), (p->keyboard_lang == KBD_LANG_DE ? _T("de") : p->keyboard_lang == KBD_LANG_DK ? _T("dk") : p->keyboard_lang == KBD_LANG_ES ? _T("es") @@ -3438,6 +3439,7 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) return 1; } + if (_tcscmp (option, _T("kbd_lang")) == 0) { KbdLang l; if ((l = KBD_LANG_DE, strcasecmp (value, _T("de")) == 0) @@ -4718,6 +4720,7 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, const TCHAR *option, TCH || cfgfile_yesno(option, value, _T("gfxcard_hardware_vblank"), &p->rtg_hardwareinterrupt) || cfgfile_yesno(option, value, _T("gfxcard_hardware_sprite"), &p->rtg_hardwaresprite) || cfgfile_yesno(option, value, _T("synchronize_clock"), &p->tod_hack) + || cfgfile_yesno(option, value, _T("keyboard_connected"), &p->keyboard_connected) || cfgfile_yesno (option, value, _T("kickshifter"), &p->kickshifter) || cfgfile_yesno (option, value, _T("ks_write_enabled"), &p->rom_readwrite) @@ -6718,6 +6721,7 @@ void default_prefs (struct uae_prefs *p, bool reset, int type) inputdevice_joyport_config_store(p, _T("kbd1"), 1, -1, 0); } p->keyboard_lang = KBD_LANG_US; + p->keyboard_connected = true; p->produce_sound = 3; p->sound_stereo = SND_STEREO; @@ -7076,8 +7080,8 @@ static void buildin_default_prefs (struct uae_prefs *p) p->bogomem_size = 0x00080000; p->z3chipmem_size = 0; for (int i = 0; i < MAX_RAM_BOARDS; i++) { - p->fastmem[i].size = 0; - p->z3fastmem[i].size = 0; + memset(p->fastmem, 0, sizeof(struct ramboard)); + memset(p->z3fastmem, 0, sizeof(struct ramboard)); } for (int i = 0; i < MAX_RTG_BOARDS; i++) { p->rtgboards[i].rtgmem_size = 0x00000000; diff --git a/cia.cpp b/cia.cpp index 8d469add..e07a7629 100644 --- a/cia.cpp +++ b/cia.cpp @@ -795,28 +795,41 @@ void CIAB_tod_handler (int hoffset) } } +void keyboard_connected(void) +{ + kbstate = 0; + kblostsynccnt = 0; + resetwarning_phase = 0; +} + static void check_keyboard(void) { - if ((keys_available () || kbstate < 3) && !kblostsynccnt ) { - switch (kbstate) - { - case 0: - kbcode = 0; /* powerup resync */ - kbstate++; - break; - case 1: - setcode (AK_INIT_POWERUP); - kbstate++; - break; - case 2: - setcode (AK_TERM_POWERUP); - kbstate++; - break; - case 3: - kbcode = ~get_next_key (); - break; - } - keyreq (); + if (currprefs.keyboard_connected) { + if ((keys_available () || kbstate < 3) && !kblostsynccnt ) { + switch (kbstate) + { + case 0: + kbcode = 0; /* powerup resync */ + kbstate++; + break; + case 1: + setcode (AK_INIT_POWERUP); + kbstate++; + break; + case 2: + setcode (AK_TERM_POWERUP); + kbstate++; + break; + case 3: + kbcode = ~get_next_key (); + break; + } + keyreq (); + } + } else { + while (keys_available()) { + get_next_key(); + } } } @@ -832,7 +845,7 @@ void CIA_hsync_posthandler (bool ciahsync, bool dotod) if (currprefs.tod_hack && ciaatodon) do_tod_hack (dotod); - } else { + } else if (currprefs.keyboard_connected) { // custom hsync if (resetwarning_phase) { resetwarning_check (); diff --git a/include/cia.h b/include/cia.h index 1b7e1769..dc29ac9d 100644 --- a/include/cia.h +++ b/include/cia.h @@ -36,4 +36,6 @@ extern int parallel_direct_read_status (uae_u8*); extern void rtc_hardreset (void); +extern void keyboard_connected(void); + #endif /* UAE_CIA_H */ diff --git a/include/options.h b/include/options.h index e48a793d..c390e29e 100644 --- a/include/options.h +++ b/include/options.h @@ -506,6 +506,7 @@ struct uae_prefs { bool immediate_blits; int waiting_blits; unsigned int chipset_mask; + bool keyboard_connected; bool ntscmode; bool genlock; int genlock_image; -- 2.47.3