]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Re-recorder updates
authorToni Wilen <twilen@winuae.net>
Tue, 16 May 2023 17:05:48 +0000 (20:05 +0300)
committerToni Wilen <twilen@winuae.net>
Tue, 16 May 2023 17:05:48 +0000 (20:05 +0300)
include/inputrecord.h
inputdevice.cpp
inputrecord.cpp
newcpu.cpp
savestate.cpp

index 7adf4ec9d3800f4e4434a233d0cc817c792fa46b..d8eb520b998be732c25cae52025ca8a9f3cf7f2b 100644 (file)
@@ -21,9 +21,11 @@ extern int inputrecord_debug;
 //#define INPREC_VSYNC 6
 //#define INPREC_CIAVSYNC 7
 #define INPREC_EVENT 8
+#define INPREC_DEBUG_START 0x60
+#define INPREC_DEBUG 0x60
 #define INPREC_CIADEBUG 0x61
-#define INPREC_DEBUG 0x62
-#define INPREC_DEBUG2 0x63
+#define INPREC_CPUDEBUG 0x62
+#define INPREC_DEBUG_END 0x6f
 #define INPREC_STOP 0x7d
 #define INPREC_END 0x7e
 #define INPREC_QUIT 0x7f
@@ -50,8 +52,8 @@ extern void inprec_recorddiskchange (int nr, const TCHAR *fname, bool writeprote
 
 extern void inprec_recorddebug (uae_u32);
 extern void inprec_playdebug (uae_u32);
-extern void inprec_recorddebug_cpu (int);
-extern void inprec_playdebug_cpu (int);
+extern void inprec_recorddebug_cpu (int, uae_u16);
+extern void inprec_playdebug_cpu (int, uae_u16);
 extern void inprec_recorddebug_cia (uae_u32, uae_u32, uae_u32);
 extern void inprec_playdebug_cia (uae_u32, uae_u32, uae_u32);
 
index 800370a7ee92f83e5b8d7a9204a6211ed87c6e98..0ee78de4c41e13d74b98b10e0f2f22d261e03321 100644 (file)
@@ -3580,7 +3580,7 @@ static void maybe_read_input(void)
        if (inputread >= 0 && (vpos - inputread) <= maxvpos_display / 3) {
                return;
        }
-       if (input_record) {
+       if (input_record || savestate_state == STATE_DOSAVE) {
                return;
        }
        inputread = vpos;
index cf8c58c39ab75eb86c61d78071541b6f5e347acf..92deb2c2bc9474e7c08bf2bbfcbd5a9b00a4ac1d 100644 (file)
@@ -33,7 +33,7 @@
 #include "newcpu.h"
 #endif
 
-int inputrecord_debug = 3;
+int inputrecord_debug = 1 | 2;
 
 extern int inputdevice_logging;
 
@@ -122,7 +122,7 @@ static bool inprec_rstart (uae_u8 type)
        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))
+       if ((type < INPREC_DEBUG_START || type > INPREC_DEBUG_END) || (0 && vsync_counter >= 49 && vsync_counter <= 51))
                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);
@@ -236,7 +236,7 @@ static int inprec_pstart (uae_u8 type)
                        return 1;
                }
                if (cycles < cycles2) {
-                       if (type2 != INPREC_DEBUG && type2 != INPREC_DEBUG2 && type2 != INPREC_CIADEBUG) {
+                       if (type2 < INPREC_DEBUG_START || type2 > INPREC_DEBUG_END) {
                                int diff = (uae_u32)((cycles2 - cycles) / CYCLE_UNIT);
                                if (diff < maxhpos) {
                                        event2_newevent_x_replace(diff, 0, inprec_event);
@@ -246,7 +246,7 @@ static int inprec_pstart (uae_u8 type)
                        break;
                }
                if (type2 == type) {
-                       if (type != INPREC_DEBUG && type != INPREC_DEBUG2 && type != INPREC_CIADEBUG && cycles != cycles2)
+                       if ((type < INPREC_DEBUG_START || type > INPREC_DEBUG_END) && cycles != cycles2)
                                write_log (_T("INPREC: %010d/%03d: %d (%d/%d) (%d/%d) %08X/%08X\n"), hc, hpos, type, hc % mvp, mvp, hc_orig - hc2_orig, hpos - hpos2, cycles, cycles2);
                        if (cycles != cycles2 + cycleoffset) {
                                if (warned > 0) {
@@ -632,29 +632,28 @@ void inprec_playdebug_cia (uae_u32 v1, uae_u32 v2, uae_u32 v3)
 #endif
 }
 
-void inprec_recorddebug_cpu (int mode)
+void inprec_recorddebug_cpu (int mode, uae_u16 data)
 {
 #if INPUTRECORD_DEBUG > 0
-       if (inprec_rstart (INPREC_DEBUG2)) {
-               inprec_ru32 (m68k_getpc ());
-               inprec_ru64 (get_cycles () | mode);
+       if (inprec_rstart (INPREC_CPUDEBUG + mode)) {
+               inprec_ru32(m68k_getpc());
+               inprec_ru16(data);
                inprec_rend ();
        }
 #endif
 }
-void inprec_playdebug_cpu (int mode)
+void inprec_playdebug_cpu (int mode, uae_u16 data)
 {
 #if INPUTRECORD_DEBUG > 0
        int err = 0;
-       if (inprec_pstart (INPREC_DEBUG2)) {
-               uae_u32 pc1 = m68k_getpc ();
-               uae_u32 pc2 = inprec_pu32 ();
-               uae_u64 v1 = get_cycles () | mode;
-               uae_u64 v2 = inprec_pu64 ();
-               if (pc1 != pc2) {
+       if (inprec_pstart (INPREC_CPUDEBUG + mode)) {
+               uae_u32 pc1 = m68k_getpc();
+               uae_u32 pc2 = inprec_pu32();
+               uae_u16 data2 = inprec_pu16();
+               if (pc1 != pc2 || data != data2) {
                        if (warned > 0) {
                                warned--;
-                               write_log (_T("SYNC ERROR2 PC %08x != %08x\n"), pc1, pc2);
+                               write_log (_T("SYNC ERROR2 PC %08x - %08x, D %04x - %04x, M %d\n"), pc1, pc2, data, data2, mode);
                                for (int i = 0; i < 15; i++)
                                        write_log (_T("%08x "), pcs[i]);
                                write_log (_T("\n"));
@@ -667,16 +666,6 @@ void inprec_playdebug_cpu (int mode)
                        memmove(pcs2 + 1, pcs2, 15 * sizeof(uae_u64));
                        pcs2[0] = get_cycles();
                }
-               if (v1 != v2) {
-                       if (warned > 0) {
-                               warned--;
-                               write_log (_T("SYNC ERROR2 %08x != %08x\n"), v1, v2);
-                               for (int i = 0; i < 15; i++)
-                                       write_log (_T("%08x "), pcs[i]);
-                               write_log (_T("\n"));
-                       }
-                       err = 1;
-               }
                inprec_pend ();
        } else if (input_play > 0) {
                if (warned > 0) {
index 83dfed6fcbebcb09c02b8436038bca65c46b0702..0c098181eafbecced2a5bac32731e3ac2e598116 100644 (file)
@@ -3497,9 +3497,9 @@ static void do_interrupt (int nr)
 #endif
        if (inputrecord_debug & 2) {
                if (input_record > 0)
-                       inprec_recorddebug_cpu (2);
+                       inprec_recorddebug_cpu(2, 0);
                else if (input_play > 0)
-                       inprec_playdebug_cpu (2);
+                       inprec_playdebug_cpu(2, 0);
        }
 
        assert (nr < 8 && nr >= 0);
@@ -5007,9 +5007,9 @@ static void m68k_run_1_ce (void)
 
                                if (inputrecord_debug & 4) {
                                        if (input_record > 0)
-                                               inprec_recorddebug_cpu (1);
+                                               inprec_recorddebug_cpu(1, r->opcode);
                                        else if (input_play > 0)
-                                               inprec_playdebug_cpu (1);
+                                               inprec_playdebug_cpu(1, r->opcode);
                                }
 
 #ifdef DEBUGGER
@@ -6112,9 +6112,9 @@ static void m68k_run_2ce (void)
 
                                if (inputrecord_debug & 4) {
                                        if (input_record > 0)
-                                               inprec_recorddebug_cpu (1);
+                                               inprec_recorddebug_cpu(1, r->opcode);
                                        else if (input_play > 0)
-                                               inprec_playdebug_cpu (1);
+                                               inprec_playdebug_cpu(1, r->opcode);
                                }
 #ifdef DEBUGGER
                                if (debug_opcode_watch) {
@@ -6240,9 +6240,9 @@ static void m68k_run_2p (void)
 
                                if (inputrecord_debug & 4) {
                                        if (input_record > 0)
-                                               inprec_recorddebug_cpu (1);
+                                               inprec_recorddebug_cpu(1, r->opcode);
                                        else if (input_play > 0)
-                                               inprec_playdebug_cpu (1);
+                                               inprec_playdebug_cpu(1, r->opcode);
                                }
 #ifdef DEBUGGER
                                if (debug_opcode_watch) {
@@ -6537,15 +6537,15 @@ void m68k_go (int may_quit)
                                memory_clear ();
                                write_log (_T("hardreset, memory cleared\n"));
                        }
+#ifdef DEBUGGER
+                       if (debug_dma) {
+                               record_dma_reset(1);
+                               record_dma_reset(1);
+                       }
+#endif
 #ifdef SAVESTATE
                        /* We may have been restoring state, but we're done now.  */
                        if (isrestore ()) {
-#ifdef DEBUGGER
-                               if (debug_dma) {
-                                       record_dma_reset(0);
-                                       record_dma_reset(0);
-                               }
-#endif
                                restored = savestate_restore_finish ();
                                memory_map_dump ();
                                if (currprefs.mmu_model == 68030) {
index 50fdf2322be2efc5aad8f7b836ecfd98988831fe..90289b534f4d8974e783be7948269305cc088106 100644 (file)
@@ -1547,14 +1547,14 @@ void savestate_capture (int force)
        struct staterecord *st;
        bool firstcapture = false;
 
-#ifdef FILESYS
-       if (nr_units ())
-               return;
-#endif
        if (!staterecords)
                return;
        if (!input_record)
                return;
+#ifdef FILESYS
+       if (nr_units())
+               return;
+#endif
        if (currprefs.statecapturerate && hsync_counter == 0 && input_record == INPREC_RECORD_START && savestate_first_capture > 0) {
                // first capture
                force = true;