]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Keyboard handshake pulse length logging.
authorToni Wilen <twilen@winuae.net>
Sat, 5 Jan 2019 13:38:33 +0000 (15:38 +0200)
committerToni Wilen <twilen@winuae.net>
Sat, 5 Jan 2019 13:38:33 +0000 (15:38 +0200)
cfgfile.cpp
cia.cpp

index 314729b2fa213177855e557fb3395f85a4658504..af4aa7e26dd1779f8d5b1699f7674b6d98c99bda 100644 (file)
@@ -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 be01c90217fcb1d2251165db8258c397e0c8dcfd..d5442e9c57bedad023e14ec92d8372546eba45ae 100644 (file)
--- 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);