From: Toni Wilen Date: Sat, 5 Jan 2019 13:38:33 +0000 (+0200) Subject: Keyboard handshake pulse length logging. X-Git-Tag: 4200~92 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=3c41bb307f65f9c0d347fae363b71b397eb1f290;p=francis%2Fwinuae.git Keyboard handshake pulse length logging. --- diff --git a/cfgfile.cpp b/cfgfile.cpp index 314729b2..af4aa7e2 100644 --- a/cfgfile.cpp +++ b/cfgfile.cpp @@ -2328,6 +2328,7 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_dwrite_str(f, _T("ciaa_type"), ciatype[p->cs_ciatype[0]]); cfgfile_dwrite_str(f, _T("ciab_type"), ciatype[p->cs_ciatype[1]]); cfgfile_dwrite_str(f, _T("unmapped_address_space"), unmapped[p->cs_unmapped_space]); + cfgfile_dwrite(f, _T("keyboard_handshake"), _T("%d"), currprefs.cs_kbhandshake); cfgfile_dwrite (f, _T("chipset_hacks"), _T("0x%x"), p->cs_hacks); if (is_board_enabled(p, ROMTYPE_CD32CART, 0)) { @@ -5335,7 +5336,8 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, const TCHAR *option, TCH || cfgfile_intval(option, value, _T("kickstart_ext_rom_file2addr"), &p->romextfile2addr, 1) || cfgfile_intval(option, value, _T("monitoremu_monitor"), &p->monitoremu_mon, 1) || cfgfile_intval(option, value, _T("genlock_scale"), &p->genlock_scale, 1) - || cfgfile_intval(option, value, _T("genlock_mix"), &p->genlock_mix, 1)) + || cfgfile_intval(option, value, _T("genlock_mix"), &p->genlock_mix, 1) + || cfgfile_intval(option, value, _T("keyboard_handshake"), &p->cs_kbhandshake, 1)) return 1; if (cfgfile_strval (option, value, _T("comp_trustbyte"), &p->comptrustbyte, compmode, 0) diff --git a/cia.cpp b/cia.cpp index be01c902..d5442e9c 100644 --- a/cia.cpp +++ b/cia.cpp @@ -100,6 +100,7 @@ static unsigned int ciaapra, ciaaprb, ciaadra, ciaadrb, ciaasdr, ciaasdr_cnt; static unsigned int ciabprb, ciabdra, ciabdrb, ciabsdr, ciabsdr_cnt; static int div10; static int kbstate, kblostsynccnt; +static unsigned long kbhandshakestart; static uae_u8 kbcode; static uae_u8 serbits; @@ -1526,8 +1527,20 @@ static void WriteCIAA (uae_u16 addr, uae_u8 val, uae_u32 *flags) if (m68k_getpc() >= 0xf00000 && m68k_getpc() < 0xf80000) check_keyboard(); } - if ((val & 0x40) == 0 && (ciaacra & 0x40) != 0) { + if ((val & 0x40) != 0 && (ciaacra & 0x40) == 0) { + // handshake start + if (kblostsynccnt > 0 && currprefs.cs_kbhandshake) { + kbhandshakestart = get_cycles(); + } + } else if ((val & 0x40) == 0 && (ciaacra & 0x40) != 0) { + // handshake end /* todo: check if low to high or high to low only */ + if (kblostsynccnt > 0 && currprefs.cs_kbhandshake) { + int len = (int)get_cycles() - (int)kbhandshakestart; + if (len < currprefs.cs_kbhandshake * CYCLE_UNIT) { + write_log(_T("Keyboard handshake pulse length %d < %d (CCKs)\n"), len / CYCLE_UNIT, currprefs.cs_kbhandshake); + } + } kblostsynccnt = 0; #if KB_DEBUG write_log (_T("KB_ACK %02x->%02x %08x\n"), ciaacra, val, M68K_GETPC);