]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Re-recorder updates.
authorToni Wilen <twilen@winuae.net>
Sun, 14 May 2023 17:31:54 +0000 (20:31 +0300)
committerToni Wilen <twilen@winuae.net>
Sun, 14 May 2023 17:31:54 +0000 (20:31 +0300)
debug.cpp
include/inputdevice.h
inputdevice.cpp
inputrecord.cpp

index b1ebcc32eca6be5255c51b5cf813c38db37b9332..a7e182968bf78e8f7570f08540c5cb3b15827c0c 100644 (file)
--- a/debug.cpp
+++ b/debug.cpp
@@ -2778,7 +2778,7 @@ void log_dma_record (void)
        if (!input_record && !input_play)
                return;
        if (!debug_dma)
-               debug_dma = 1;
+               return;
        decode_dma_record (0, 0, 0, true);
 }
 
index 8171c2091d0ac61d880ea349fd2939d575bead1d..44d08cec9196f8626133e227f66ba88971e7241a 100644 (file)
@@ -364,6 +364,7 @@ extern int inputdevice_uaelib (const TCHAR *, const TCHAR *);
 extern int inputdevice_uaelib(const TCHAR *s, int parm, int max, bool autofire);
 extern int handle_custom_event (const TCHAR *custom, int append);
 extern int inputdevice_geteventid(const TCHAR *s);
+extern void inputdevice_playevents(void);
 
 extern int inputdevice_testread (int*, int*, int*, bool);
 extern int inputdevice_istest (void);
index 09db352e5733c580c45be891208e725cfaf4270f..e9dc1dfb9fedfc9ee4af43ce9f8a2868961b52c8 100644 (file)
@@ -3573,8 +3573,12 @@ static void inputdevice_read(void)
 
 static void maybe_read_input(void)
 {
-       if (inputread >= 0 && (vpos - inputread) <= maxvpos_display / 3)
+       if (inputread >= 0 && (vpos - inputread) <= maxvpos_display / 3) {
                return;
+       }
+       if (input_record) {
+               return;
+       }
        inputread = vpos;
        inputdevice_read();
 }
@@ -3612,14 +3616,6 @@ uae_u16 JOY1DAT (void)
        v = getjoystate (1);
        v = dongle_joydat (1, v);
        v = alg_joydat(1, v);
-
-       if (inputrecord_debug & 2) {
-               if (input_record > 0)
-                       inprec_recorddebug_cia (v, -1, m68k_getpc ());
-               else if (input_play > 0)
-                       inprec_playdebug_cia (v, -1, m68k_getpc ());
-       }
-
        return v;
 }
 
@@ -4228,6 +4224,14 @@ int handle_custom_event (const TCHAR *custom, int append)
        return 0;
 }
 
+void inputdevice_playevents(void)
+{
+       inprec_playdiskchange();
+       int nr, state, max, autofire;
+       while (inprec_playevent(&nr, &state, &max, &autofire))
+               handle_input_event(nr, state, max, (autofire ? HANDLE_IE_FLAG_AUTOFIRE : 0) | HANDLE_IE_FLAG_PLAYBACKEVENT);
+}
+
 void inputdevice_hsync (bool forceread)
 {
        cap_check(true);
@@ -4299,10 +4303,7 @@ void inputdevice_hsync (bool forceread)
                        inputdevice_read();
        }
        if (input_play) {
-               inprec_playdiskchange ();
-               int nr, state, max, autofire;
-               while (inprec_playevent (&nr, &state, &max, &autofire))
-                       handle_input_event (nr, state, max, (autofire ? HANDLE_IE_FLAG_AUTOFIRE : 0) | HANDLE_IE_FLAG_PLAYBACKEVENT);
+               inputdevice_playevents();
                if (vpos == 0)
                        handle_msgpump(true);
        }
index a4fa99fe90d488431f223dde25beb6792b32e0f6..cf8c58c39ab75eb86c61d78071541b6f5e347acf 100644 (file)
@@ -3,20 +3,21 @@
 *
 * Input record/playback
 *
-* Copyright 2010 Toni Wilen
+* Copyright 2010-2023 Toni Wilen
 *
 */
 
 #define INPUTRECORD_DEBUG 1
 #define ENABLE_DEBUGGER 0
 
-#define HEADERSIZE 12
+#define HEADERSIZE 16
 
 #include "sysconfig.h"
 #include "sysdeps.h"
 
 #include "options.h"
 #include "inputrecord.h"
+#include "inputdevice.h"
 #include "zfile.h"
 #include "custom.h"
 #include "savestate.h"
@@ -118,15 +119,16 @@ static bool inprec_rstart (uae_u8 type)
 {
        if (!input_record || !inprec_zf || input_record == INPREC_RECORD_PLAYING)
                return false;
+       int hpos = current_hpos();
        lastcycle = get_cycles ();
        int mvp = current_maxvpos ();
        if ((type != INPREC_DEBUG && type != INPREC_DEBUG2 && type != INPREC_CIADEBUG) || (0 && vsync_counter >= 49 && vsync_counter <= 51))
-               write_log (_T("INPREC: %010d/%03d: %d (%d/%d) %08x\n"), hsync_counter, current_hpos (), type, hsync_counter % mvp, mvp, lastcycle);
+               write_log (_T("INPREC: %010d/%03d: %d (%d/%d) %08x\n"), hsync_counter, hpos, type, hsync_counter % mvp, mvp, lastcycle);
        inprec_plast = inprec_p;
        inprec_ru8 (type);
        inprec_ru16 (0xffff);
        inprec_ru32 (hsync_counter);
-       inprec_ru8 (current_hpos ());
+       inprec_ru8 (hpos);
        inprec_ru64 (lastcycle);
        return true;
 }
@@ -160,6 +162,11 @@ static bool inprec_realtime (bool stopstart)
        return true;
 }
 
+static void inprec_event(uae_u32 v)
+{
+       inputdevice_playevents();
+}
+
 static int inprec_pstart (uae_u8 type)
 {
        uae_u8 *p = inprec_p;
@@ -200,7 +207,9 @@ static int inprec_pstart (uae_u8 type)
                uae_u32 type2 = p[0];
                uae_u32 hc2 = (p[3] << 24) | (p[4] << 16) | (p[5] << 8) | p[6];
                uae_u32 hpos2 = p[7];
-               frame_time_t cycles2 = (p[8] << 24) | (p[9] << 16) | (p[10] << 8) | p[11];
+               uae_u32 chi = (p[8] << 24) | (p[9] << 16) | (p[10] << 8) | p[11];
+               uae_u32 clo = (p[12] << 24) | (p[13] << 16) | (p[14] << 8) | p[15];
+               frame_time_t cycles2 = (((uae_u64)chi) << 32) | clo;
 
                if (p >= inprec_buffer + inprec_size)
                        break;
@@ -212,8 +221,9 @@ static int inprec_pstart (uae_u8 type)
                }
 #endif
                hc2_orig = hc2;
-               if (type2 == type && hc > hc2) {
-                       write_log (_T("INPREC: %010d/%03d > %010d/%03d: %d missed!\n"), hc, hpos, hc2, hpos2, p[0]);
+               if (type2 == type && cycles > cycles2) {
+                       int diff = (int)((cycles2 - cycles) / CYCLE_UNIT);
+                       write_log (_T("INPREC: %010d/%03d > %010d/%03d: %d %d missed!\n"), hc, hpos, hc2, hpos2, diff, p[0]);
 #if ENABLE_DEBUGGER == 0
                        gui_message (_T("INPREC missed error"));
 #else
@@ -221,11 +231,17 @@ static int inprec_pstart (uae_u8 type)
 #endif
                        lastcycle = cycles;
                        inprec_plast = p;
-                       inprec_plastptr = p + 12;
+                       inprec_plastptr = p + HEADERSIZE;
                        setlasthsync ();
                        return 1;
                }
-               if (hc2 != hc) {
+               if (cycles < cycles2) {
+                       if (type2 != INPREC_DEBUG && type2 != INPREC_DEBUG2 && type2 != INPREC_CIADEBUG) {
+                               int diff = (uae_u32)((cycles2 - cycles) / CYCLE_UNIT);
+                               if (diff < maxhpos) {
+                                       event2_newevent_x_replace(diff, 0, inprec_event);
+                               }
+                       }
                        lastp = p;
                        break;
                }
@@ -239,17 +255,19 @@ static int inprec_pstart (uae_u8 type)
                                                write_log (_T("%08x (%016llx) "), pcs[i], pcs2[i]);
                                        write_log (_T("\n"));
                                }
-                               cycleoffset = (uae_u32)(cycles - cycles2);
+                               uae_u32 fixedcycleoffset = (uae_u32)(cycles - cycles2);
 #if ENABLE_DEBUGGER == 0
-                               gui_message (_T("INPREC OFFSET=%d\n"), (int)cycleoffset / CYCLE_UNIT);
+                               gui_message (_T("INPREC OFFSET=%d\n"), fixedcycleoffset / CYCLE_UNIT);
 #else
                                activate_debugger ();
 #endif
+                               cycleoffset = fixedcycleoffset;
                        }
                        lastcycle = cycles;
                        inprec_plast = p;
-                       inprec_plastptr = p + 12;
-                       setlasthsync ();
+                       inprec_plastptr = p + HEADERSIZE;
+                       setlasthsync();
+                       //write_log(_T("INPREC: %010d/%03d %llx %d\n"), hc, hpos, cycles, p[0]);
                        return 1;
                }
                if (type2 == INPREC_END || type2 == INPREC_QUIT)
@@ -387,7 +405,7 @@ int inprec_open (const TCHAR *fname, const TCHAR *statefilename)
                        return 0;
                }
                int v = inprec_pu8 ();
-               if (v != 2) {
+               if (v != 3) {
                        inprec_close (true);
                        return 0;
                }
@@ -451,7 +469,7 @@ int inprec_open (const TCHAR *fname, const TCHAR *statefilename)
                seed = uaesrand (seed);
                inprec_buffer = inprec_p = xmalloc (uae_u8, inprec_size);
                inprec_ru32 ('UAE\0');
-               inprec_ru8 (2);
+               inprec_ru8 (3);
                inprec_ru8 (UAEMAJOR);
                inprec_ru8 (UAEMINOR);
                inprec_ru8 (UAESUBREV);