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();
}
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;
}
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);
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);
}
*
* 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"
{
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;
}
return true;
}
+static void inprec_event(uae_u32 v)
+{
+ inputdevice_playevents();
+}
+
static int inprec_pstart (uae_u8 type)
{
uae_u8 *p = inprec_p;
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;
}
#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
#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;
}
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)
return 0;
}
int v = inprec_pu8 ();
- if (v != 2) {
+ if (v != 3) {
inprec_close (true);
return 0;
}
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);