puae 2.3.1

parent 9f992501
...@@ -132,7 +132,7 @@ EXTRA_DIST = \ ...@@ -132,7 +132,7 @@ EXTRA_DIST = \
uae_SOURCES = \ uae_SOURCES = \
main.c newcpu.c memory.c rommgr.c custom.c serial.c dongle.c cia.c \ main.c newcpu.c memory.c rommgr.c custom.c serial.c dongle.c cia.c \
blitter.c autoconf.c traps.c ersatz.c keybuf.c expansion.c \ blitter.c autoconf.c traps.c ersatz.c keybuf.c expansion.c inputrecord.c \
diskutil.c zfile.c zfile_archive.c cfgfile.c picasso96.c inputdevice.c \ diskutil.c zfile.c zfile_archive.c cfgfile.c picasso96.c inputdevice.c \
gfxutil.c audio.c sinctable.c statusline.c drawing.c consolehook.c \ gfxutil.c audio.c sinctable.c statusline.c drawing.c consolehook.c \
native2amiga.c disk.c crc32.c savestate.c arcadia.c cdtv.c cd32_fmv.c \ native2amiga.c disk.c crc32.c savestate.c arcadia.c cdtv.c cd32_fmv.c \
......
...@@ -673,14 +673,12 @@ static uae_u8 ReadCIAA (unsigned int addr) ...@@ -673,14 +673,12 @@ static uae_u8 ReadCIAA (unsigned int addr)
if (notinrom()) if (notinrom())
write_log ("BFE001 R %02X %s\n", tmp, debuginfo(0)); write_log ("BFE001 R %02X %s\n", tmp, debuginfo(0));
#endif #endif
#if INPREC
if (inputrecord_debug & 2) { if (inputrecord_debug & 2) {
if (input_record > 0) if (input_record > 0)
inprec_recorddebug_cia (tmp, div10, m68k_getpc ()); inprec_recorddebug_cia (tmp, div10, m68k_getpc ());
else if (input_play > 0) else if (input_play > 0)
inprec_playdebug_cia (tmp, div10, m68k_getpc ()); inprec_playdebug_cia (tmp, div10, m68k_getpc ());
} }
#endif
return tmp; return tmp;
case 1: case 1:
#ifdef PARALLEL_PORT #ifdef PARALLEL_PORT
......
...@@ -5716,25 +5716,6 @@ static void hsync_handler_post (bool isvsync) ...@@ -5716,25 +5716,6 @@ static void hsync_handler_post (bool isvsync)
do_sprites (0); do_sprites (0);
#endif #endif
#ifdef INPREC
while (input_recording < 0 && inprec_pstart (INPREC_KEY)) {
record_key_direct (inprec_pu8 ());
inprec_pend ();
}
while (input_recording < 0 && inprec_pstart (INPREC_DISKREMOVE)) {
disk_eject (inprec_pu8 ());
inprec_pend ();
}
while (input_recording < 0 && inprec_pstart (INPREC_DISKINSERT)) {
int drv = inprec_pu8 ();
inprec_pstr (currprefs.floppyslots[drv].df);
_tcscpy (changed_prefs.floppyslots[drv].df, currprefs.floppyslots[drv].df);
disk_insert_force (drv, currprefs.floppyslots[drv].df);
inprec_pend ();
}
#endif
inputdevice_hsync ();
#ifdef GAYLE #ifdef GAYLE
gayle_hsync (); gayle_hsync ();
#endif #endif
...@@ -7118,7 +7099,6 @@ uae_u8 *save_custom_event_delay (int *len, uae_u8 *dstptr) ...@@ -7118,7 +7099,6 @@ uae_u8 *save_custom_event_delay (int *len, uae_u8 *dstptr)
save_u8 (1); save_u8 (1);
save_u64 (e->evtime - get_cycles ()); save_u64 (e->evtime - get_cycles ());
save_u32 (e->data); save_u32 (e->data);
} }
} }
......
...@@ -3640,7 +3640,7 @@ void debug (void) ...@@ -3640,7 +3640,7 @@ void debug (void)
&& nr_units () == 0 && nr_units () == 0
#endif #endif
) { ) {
savestate_capture (1); //savestate_capture (1);
} }
for (i = 0; i < BREAKPOINT_TOTAL; i++) { for (i = 0; i < BREAKPOINT_TOTAL; i++) {
if (bpnodes[i].enabled) if (bpnodes[i].enabled)
......
...@@ -931,10 +931,8 @@ static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const TCHAR ...@@ -931,10 +931,8 @@ static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const TCHAR
return 0; return 0;
} }
#ifdef INPREC
if (!fake) if (!fake)
inprec_recorddiskchange (dnum, fname, drv->wrprot); inprec_recorddiskchange (dnum, fname, drv->wrprot);
#endif
_tcsncpy (currprefs.floppyslots[dnum].df, fname, 255); _tcsncpy (currprefs.floppyslots[dnum].df, fname, 255);
currprefs.floppyslots[dnum].df[255] = 0; currprefs.floppyslots[dnum].df[255] = 0;
...@@ -2049,9 +2047,7 @@ static void drive_eject (drive * drv) ...@@ -2049,9 +2047,7 @@ static void drive_eject (drive * drv)
drive_settype_id (drv); /* Back to 35 DD */ drive_settype_id (drv); /* Back to 35 DD */
if (disk_debug_logging > 0) if (disk_debug_logging > 0)
write_log ("eject drive %d\n", drv - &floppy[0]); write_log ("eject drive %d\n", drv - &floppy[0]);
#ifdef INPREC
inprec_recorddiskchange (drv - floppy, NULL, false); inprec_recorddiskchange (drv - floppy, NULL, false);
#endif
} }
/* We use this function if we have no Kickstart ROM. /* We use this function if we have no Kickstart ROM.
......
...@@ -2668,7 +2668,8 @@ void vsync_handle_redraw (int long_frame, int lof_changed) ...@@ -2668,7 +2668,8 @@ void vsync_handle_redraw (int long_frame, int lof_changed)
#ifdef SAVESTATE #ifdef SAVESTATE
if (!savestate_state) { if (!savestate_state) {
if (currprefs.quitstatefile[0]) { if (currprefs.quitstatefile[0]) {
savestate_initsave (currprefs.quitstatefile, 1, 1, true); write_log ("Draw: Save_State");
savestate_initsave (currprefs.quitstatefile, 1, 1, true);
save_state (currprefs.quitstatefile, ""); save_state (currprefs.quitstatefile, "");
} }
} }
......
...@@ -52,5 +52,5 @@ extern void inprec_playdebug_cia (uae_u32, uae_u32, uae_u32); ...@@ -52,5 +52,5 @@ extern void inprec_playdebug_cia (uae_u32, uae_u32, uae_u32);
extern int inprec_getposition (void); extern int inprec_getposition (void);
extern void inprec_setposition (int offset, int replaycounter); extern void inprec_setposition (int offset, int replaycounter);
extern bool inprec_realtime (void); extern bool inprec_realtimev (void);
extern void inprec_getstatus (TCHAR*); extern void inprec_getstatus (TCHAR*);
\ No newline at end of file
...@@ -133,33 +133,34 @@ ...@@ -133,33 +133,34 @@
#define KBLED_SCROLLLOCKM (1 << KBLED_SCROLLLOCKB) #define KBLED_SCROLLLOCKM (1 << KBLED_SCROLLLOCKB)
enum aks { AKS_ENTERGUI = 0x200, AKS_SCREENSHOT_FILE, AKS_SCREENSHOT_CLIPBOARD, AKS_FREEZEBUTTON, enum aks { AKS_ENTERGUI = 0x200, AKS_SCREENSHOT_FILE, AKS_SCREENSHOT_CLIPBOARD, AKS_FREEZEBUTTON,
AKS_FLOPPY0, AKS_FLOPPY1, AKS_FLOPPY2, AKS_FLOPPY3, AKS_FLOPPY0, AKS_FLOPPY1, AKS_FLOPPY2, AKS_FLOPPY3,
AKS_EFLOPPY0, AKS_EFLOPPY1, AKS_EFLOPPY2, AKS_EFLOPPY3, AKS_EFLOPPY0, AKS_EFLOPPY1, AKS_EFLOPPY2, AKS_EFLOPPY3,
AKS_TOGGLEDEFAULTSCREEN, AKS_TOGGLEDEFAULTSCREEN,
AKS_TOGGLEWINDOWEDFULLSCREEN, AKS_TOGGLEFULLWINDOWFULLSCREEN, AKS_TOGGLEWINDOWFULLWINDOW, AKS_TOGGLEWINDOWEDFULLSCREEN, AKS_TOGGLEFULLWINDOWFULLSCREEN, AKS_TOGGLEWINDOWFULLWINDOW,
AKS_ENTERDEBUGGER, AKS_IRQ7, AKS_ENTERDEBUGGER, AKS_IRQ7,
AKS_PAUSE, AKS_WARP, AKS_INHIBITSCREEN, AKS_STATEREWIND, AKS_PAUSE, AKS_WARP, AKS_INHIBITSCREEN,
AKS_VOLDOWN, AKS_VOLUP, AKS_VOLMUTE, AKS_STATEREWIND, AKS_STATECURRENT, AKS_STATECAPTURE,
AKS_MVOLDOWN, AKS_MVOLUP, AKS_MVOLMUTE, AKS_VOLDOWN, AKS_VOLUP, AKS_VOLMUTE,
AKS_QUIT, AKS_HARDRESET, AKS_SOFTRESET, AKS_MVOLDOWN, AKS_MVOLUP, AKS_MVOLMUTE,
AKS_STATESAVEQUICK, AKS_STATERESTOREQUICK, AKS_QUIT, AKS_HARDRESET, AKS_SOFTRESET,
AKS_STATESAVEQUICK1, AKS_STATERESTOREQUICK1, AKS_STATESAVEQUICK, AKS_STATERESTOREQUICK,
AKS_STATESAVEQUICK2, AKS_STATERESTOREQUICK2, AKS_STATESAVEQUICK1, AKS_STATERESTOREQUICK1,
AKS_STATESAVEQUICK3, AKS_STATERESTOREQUICK3, AKS_STATESAVEQUICK2, AKS_STATERESTOREQUICK2,
AKS_STATESAVEQUICK4, AKS_STATERESTOREQUICK4, AKS_STATESAVEQUICK3, AKS_STATERESTOREQUICK3,
AKS_STATESAVEQUICK5, AKS_STATERESTOREQUICK5, AKS_STATESAVEQUICK4, AKS_STATERESTOREQUICK4,
AKS_STATESAVEQUICK6, AKS_STATERESTOREQUICK6, AKS_STATESAVEQUICK5, AKS_STATERESTOREQUICK5,
AKS_STATESAVEQUICK7, AKS_STATERESTOREQUICK7, AKS_STATESAVEQUICK6, AKS_STATERESTOREQUICK6,
AKS_STATESAVEQUICK8, AKS_STATERESTOREQUICK8, AKS_STATESAVEQUICK7, AKS_STATERESTOREQUICK7,
AKS_STATESAVEQUICK9, AKS_STATERESTOREQUICK9, AKS_STATESAVEQUICK8, AKS_STATERESTOREQUICK8,
AKS_STATESAVEDIALOG, AKS_STATERESTOREDIALOG, AKS_STATESAVEQUICK9, AKS_STATERESTOREQUICK9,
AKS_DECREASEREFRESHRATE, AKS_STATESAVEDIALOG, AKS_STATERESTOREDIALOG,
AKS_INCREASEREFRESHRATE, AKS_DECREASEREFRESHRATE,
AKS_ARCADIADIAGNOSTICS, AKS_ARCADIAPLY1, AKS_ARCADIAPLY2, AKS_ARCADIACOIN1, AKS_ARCADIACOIN2, AKS_INCREASEREFRESHRATE,
AKS_TOGGLEMOUSEGRAB, AKS_SWITCHINTERPOL, AKS_ARCADIADIAGNOSTICS, AKS_ARCADIAPLY1, AKS_ARCADIAPLY2, AKS_ARCADIACOIN1, AKS_ARCADIACOIN2,
AKS_INPUT_CONFIG_1,AKS_INPUT_CONFIG_2,AKS_INPUT_CONFIG_3,AKS_INPUT_CONFIG_4, AKS_TOGGLEMOUSEGRAB, AKS_SWITCHINTERPOL,
AKS_DISKSWAPPER_NEXT,AKS_DISKSWAPPER_PREV, AKS_INPUT_CONFIG_1,AKS_INPUT_CONFIG_2,AKS_INPUT_CONFIG_3,AKS_INPUT_CONFIG_4,
AKS_DISKSWAPPER_INSERT0,AKS_DISKSWAPPER_INSERT1,AKS_DISKSWAPPER_INSERT2,AKS_DISKSWAPPER_INSERT3, AKS_DISKSWAPPER_NEXT,AKS_DISKSWAPPER_PREV,
AKS_DISKSWAPPER_INSERT0,AKS_DISKSWAPPER_INSERT1,AKS_DISKSWAPPER_INSERT2,AKS_DISKSWAPPER_INSERT3,
AKS_DISK_PREV0, AKS_DISK_PREV1, AKS_DISK_PREV2, AKS_DISK_PREV3, AKS_DISK_PREV0, AKS_DISK_PREV1, AKS_DISK_PREV2, AKS_DISK_PREV3,
AKS_DISK_NEXT0, AKS_DISK_NEXT1, AKS_DISK_NEXT2, AKS_DISK_NEXT3, AKS_DISK_NEXT0, AKS_DISK_NEXT1, AKS_DISK_NEXT2, AKS_DISK_NEXT3,
AKS_CDTV_FRONT_PANEL_STOP, AKS_CDTV_FRONT_PANEL_PLAYPAUSE, AKS_CDTV_FRONT_PANEL_PREV, AKS_CDTV_FRONT_PANEL_STOP, AKS_CDTV_FRONT_PANEL_PLAYPAUSE, AKS_CDTV_FRONT_PANEL_PREV,
......
...@@ -14,6 +14,7 @@ struct zfile { ...@@ -14,6 +14,7 @@ struct zfile {
int archiveid; int archiveid;
uae_s64 size; // real size uae_s64 size; // real size
uae_s64 datasize; // available size (not yet unpacked completely?) uae_s64 datasize; // available size (not yet unpacked completely?)
uae_s64 allocsize; // memory allocated before realloc() needed again
uae_s64 seek; // seek position uae_s64 seek; // seek position
int deleteafterclose; int deleteafterclose;
int textmode; int textmode;
......
...@@ -69,6 +69,7 @@ extern int zfile_convertimage (const TCHAR *src, const TCHAR *dst); ...@@ -69,6 +69,7 @@ extern int zfile_convertimage (const TCHAR *src, const TCHAR *dst);
//extern struct zfile *zuncompress (struct znode*, struct zfile *z, int dodefault, int mask, int *retcode, int index); //extern struct zfile *zuncompress (struct znode*, struct zfile *z, int dodefault, int mask, int *retcode, int index);
extern void zfile_seterror (const TCHAR *format, ...); extern void zfile_seterror (const TCHAR *format, ...);
extern TCHAR *zfile_geterror (void); extern TCHAR *zfile_geterror (void);
extern int zfile_truncate (struct zfile *z, uae_s64 size);
#define ZFD_NONE 0 #define ZFD_NONE 0
#define ZFD_ARCHIVE 1 //zip/lha.. #define ZFD_ARCHIVE 1 //zip/lha..
...@@ -120,3 +121,4 @@ extern unsigned int zfile_read_archive (struct zfile *d, void *b, unsigned int s ...@@ -120,3 +121,4 @@ extern unsigned int zfile_read_archive (struct zfile *d, void *b, unsigned int s
extern void zfile_close_archive (struct zfile *d); extern void zfile_close_archive (struct zfile *d);
extern struct zfile *zfile_open_archive (const TCHAR *path, int flags); extern struct zfile *zfile_open_archive (const TCHAR *path, int flags);
extern int zfile_exists_archive (const TCHAR *path, const TCHAR *rel); extern int zfile_exists_archive (const TCHAR *path, const TCHAR *rel);
extern bool zfile_needwrite (struct zfile*);
\ No newline at end of file
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include "cia.h" #include "cia.h"
#include "autoconf.h" #include "autoconf.h"
#include "dongle.h" #include "dongle.h"
#include "cdtv.h"
#include <ctype.h> #include <ctype.h>
extern int bootrom_header, bootrom_items; extern int bootrom_header, bootrom_items;
...@@ -101,7 +102,9 @@ static uae_u8 scancodeused[MAX_INPUT_DEVICES][256]; ...@@ -101,7 +102,9 @@ static uae_u8 scancodeused[MAX_INPUT_DEVICES][256];
// fire/left mouse button pullup resistors enabled? // fire/left mouse button pullup resistors enabled?
static bool mouse_pullup = true; static bool mouse_pullup = true;
static bool joystick_pullup = false;
static int joymodes[MAX_JPORTS];
static int *joyinputs[MAX_JPORTS];
static int input_acquired; static int input_acquired;
static int testmode, testmode_read, testmode_toggle; static int testmode, testmode_read, testmode_toggle;
...@@ -118,258 +121,13 @@ static int testmode_count; ...@@ -118,258 +121,13 @@ static int testmode_count;
static struct teststore testmode_data[TESTMODE_MAX]; static struct teststore testmode_data[TESTMODE_MAX];
static struct teststore testmode_wait[TESTMODE_MAX]; static struct teststore testmode_wait[TESTMODE_MAX];
static uae_u8 *inprec_buffer, *inprec_p;
static struct zfile *inprec_zf;
static int inprec_size;
int input_recording = 0;
static uae_u8 *inprec_plast, *inprec_plastptr;
static int inprec_div;
static uae_u32 oldbuttons[4];
static uae_u16 oldjoy[2];
static int bouncy; static int bouncy;
static signed long bouncy_cycles; static signed long bouncy_cycles;
#define BOUNCY_CYCLES 30
#ifdef INPREC static int handle_input_event (int nr, int state, int max, int autofire, bool canstoprecord, bool playbackevent);
int inprec_open (TCHAR *fname, int record)
{
uae_u32 t = (uae_u32)time(0);
int i;
inprec_close();
inprec_zf = zfile_fopen (fname, record > 0 ? "wb" : "rb", ZFD_NORMAL);
if (inprec_zf == NULL)
return 0;
inprec_size = 10000;
inprec_div = 1;
if (record < 0) {
uae_u32 id;
zfile_fseek (inprec_zf, 0, SEEK_END);
inprec_size = zfile_ftell (inprec_zf);
zfile_fseek (inprec_zf, 0, SEEK_SET);
inprec_buffer = inprec_p = xmalloc (uae_u8, inprec_size);
zfile_fread (inprec_buffer, inprec_size, 1, inprec_zf);
inprec_plastptr = inprec_buffer;
id = inprec_pu32();
if (id != 'UAE\0') {
inprec_close ();
return 0;
}
inprec_pu32();
t = inprec_pu32 ();
i = inprec_pu32 ();
while (i-- > 0)
inprec_pu8 ();
inprec_p = inprec_plastptr;
if (inprec_pstart (INPREC_STATEFILE)) {
inprec_pstr (savestate_fname);
savestate_state = STATE_RESTORE;
inprec_pend ();
}
oldbuttons[0] = oldbuttons[1] = oldbuttons[2] = oldbuttons[3] = 0;
oldjoy[0] = oldjoy[1] = 0;
if (record < -1)
inprec_div = maxvpos;
} else if (record > 0) {
inprec_buffer = inprec_p = xmalloc (uae_u8, inprec_size);
inprec_ru32 ('UAE\0');
inprec_ru8 (1);
inprec_ru8 (UAEMAJOR);
inprec_ru8 (UAEMINOR);
inprec_ru8 (UAESUBREV);
inprec_ru32 (t);
inprec_ru32 (0); // extra header size
if (savestate_state == STATE_DORESTORE) {
inprec_rstart (INPREC_STATEFILE);
inprec_rstr (savestate_fname);
inprec_rend ();
}
} else {
return 0;
}
input_recording = record;
srand (t);
CIA_inprec_prepare ();
write_log ("inprec initialized '%s', mode=%d\n", fname, input_recording);
return 1;
}
void inprec_close(void) static int isdevice (struct uae_input_device *id)
{
if (!inprec_zf)
return;
if (inprec_buffer && input_recording > 0) {
hsync_counter++;
inprec_rstart(INPREC_END);
inprec_rend();
hsync_counter--;
zfile_fwrite (inprec_buffer, inprec_p - inprec_buffer, 1, inprec_zf);
inprec_p = inprec_buffer;
}
zfile_fclose (inprec_zf);
inprec_zf = NULL;
xfree (inprec_buffer);
inprec_buffer = NULL;
input_recording = 0;
write_log ("inprec finished\n");
}
void inprec_ru8(uae_u8 v)
{
*inprec_p++= v;
}
void inprec_ru16 (uae_u16 v)
{
inprec_ru8 ((uae_u8)(v >> 8));
inprec_ru8 ((uae_u8)v);
}
void inprec_ru32 (uae_u32 v)
{
inprec_ru16 ((uae_u16)(v >> 16));
inprec_ru16 ((uae_u16)v);
}
void inprec_rstr (const TCHAR *src)
{
char *s = ua (src);
while(*s) {
inprec_ru8 (*s);
s++;
}
inprec_ru8 (0);
xfree (s);
}
void inprec_rstart (uae_u8 type)
{
write_log ("INPREC: %08X: %d\n", hsync_counter, type);
inprec_ru32 (hsync_counter);
inprec_ru8 (0);
inprec_plast = inprec_p;
inprec_ru8 (0xff);
inprec_ru8 (type);
}
void inprec_rend (void)
{
*inprec_plast = inprec_p - (inprec_plast + 2);
if (inprec_p >= inprec_buffer + inprec_size - 256) {
zfile_fwrite (inprec_buffer, inprec_p - inprec_buffer, 1, inprec_zf);
inprec_p = inprec_buffer;
}
}
int inprec_pstart (uae_u8 type)
{
uae_u8 *p = inprec_p;
uae_u32 hc = hsync_counter;
static uae_u8 *lastp;
uae_u32 hc_orig, hc2_orig;
if (savestate_state)
return 0;
if (p[5 + 1] == INPREC_END) {
inprec_close ();
return 0;
} else if (p[5 + 1] == INPREC_QUIT) {
inprec_close ();
uae_quit ();
return 0;
}
hc_orig = hc;
hc /= inprec_div;
hc *= inprec_div;
for (;;) {
uae_u32 hc2 = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
if (p > lastp) {
write_log ("INPREC: Next %08x (%08x=%d): %d (%d)\n", hc2, hc, hc2 - hc, p[5 + 1], p[5]);
lastp = p;
}
hc2_orig = hc2;
hc2 /= inprec_div;
hc2 *= inprec_div;
if (hc > hc2) {
write_log ("INPREC: %08x > %08x: %d (%d) missed!\n", hc, hc2, p[5 + 1], p[5]);
inprec_close ();
return 0;
}
if (hc2 != hc) {
lastp = p;
break;
}
if (p[5 + 1] == type) {
write_log ("INPREC: %08x: %d (%d) (%+d)\n", hc, type, p[5], hc_orig - hc2_orig);
inprec_plast = p;
inprec_plastptr = p + 5 + 2;
return 1;
}
p += 5 + 2 + p[5];
}
inprec_plast = NULL;
return 0;
}
void inprec_pend (void)
{
uae_u8 *p = inprec_p;
uae_u32 hc = hsync_counter;
if (!inprec_plast)
return;
inprec_plast[5 + 1] = 0;
inprec_plast = NULL;
inprec_plastptr = NULL;
hc /= inprec_div;
hc *= inprec_div;
for (;;) {
uae_u32 hc2 = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
hc2 /= inprec_div;
hc2 *= inprec_div;
if (hc2 != hc)
break;
if (p[5 + 1] != 0)
return;
p += 5 + 2 + p[5];
}
inprec_p = p;
if (p[5 + 1] == INPREC_END)
inprec_close ();
}
uae_u8 inprec_pu8 (void)
{
return *inprec_plastptr++;
}
uae_u16 inprec_pu16 (void)
{
uae_u16 v = inprec_pu8 () << 8;
v |= inprec_pu8 ();
return v;
}
uae_u32 inprec_pu32 (void)
{
uae_u32 v = inprec_pu16 () << 16;
v |= inprec_pu16 ();
return v;
}
int inprec_pstr (TCHAR *dst)
{
char tmp[MAX_DPATH];
char *s;
int len = 0;
s = tmp;
for(;;) {
uae_u8 v = inprec_pu8 ();
*s++ = v;
if (!v)
break;
len++;
}
au_copy (dst, MAX_DPATH, tmp);
return len;
}
#endif
static int isdevice (const struct uae_input_device *id)
{ {
int i, j; int i, j;
for (i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) { for (i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) {
...@@ -387,7 +145,7 @@ int inputdevice_uaelib (TCHAR *s, TCHAR *parm) ...@@ -387,7 +145,7 @@ int inputdevice_uaelib (TCHAR *s, TCHAR *parm)
for (i = 1; events[i].name; i++) { for (i = 1; events[i].name; i++) {
if (!_tcscmp (s, events[i].confname)) { if (!_tcscmp (s, events[i].confname)) {
handle_input_event (i, _tstol (parm), 1, 0); handle_input_event (i, _tstol (parm), 1, 0, false, false);
return 1; return 1;
} }
} }
...@@ -773,6 +531,7 @@ void write_inputdevice_config (struct uae_prefs *p, struct zfile *f) ...@@ -773,6 +531,7 @@ void write_inputdevice_config (struct uae_prefs *p, struct zfile *f)
cfgfile_write (f, "input.analog_joystick_offset", "%d", p->input_analog_joystick_offset); cfgfile_write (f, "input.analog_joystick_offset", "%d", p->input_analog_joystick_offset);
cfgfile_write (f, "input.mouse_speed", "%d", p->input_mouse_speed); cfgfile_write (f, "input.mouse_speed", "%d", p->input_mouse_speed);
cfgfile_write (f, "input.autofire_speed", "%d", p->input_autofire_linecnt); cfgfile_write (f, "input.autofire_speed", "%d", p->input_autofire_linecnt);
cfgfile_dwrite (f, "input.contact_bounce", "%d", p->input_contact_bounce);
for (id = 0; id < MAX_INPUT_SETTINGS; id++) { for (id = 0; id < MAX_INPUT_SETTINGS; id++) {
for (i = 0; i < MAX_INPUT_DEVICES; i++) for (i = 0; i < MAX_INPUT_DEVICES; i++)
write_config (f, id, i, "joystick", &p->joystick_settings[id][i], &joysticks2[i], &idev[IDTYPE_JOYSTICK]); write_config (f, id, i, "joystick", &p->joystick_settings[id][i], &joysticks2[i], &idev[IDTYPE_JOYSTICK]);
...@@ -1805,37 +1564,9 @@ STATIC_INLINE int adjust (int val) ...@@ -1805,37 +1564,9 @@ STATIC_INLINE int adjust (int val)
return val; return val;
} }
int getbuttonstate (int joy, int button) static int getbuttonstate (int joy, int button)
{ {
#ifdef INPREC
int v;
v = (joybutton[joy] & (1 << button)) ? 1 : 0;
if (input_recording > 0 && ((joybutton[joy] ^ oldbuttons[joy]) & (1 << button))) {
oldbuttons[joy] &= ~(1 << button);
if (v)
oldbuttons[joy] |= 1 << button;
inprec_rstart (INPREC_JOYBUTTON);
inprec_ru8 (joy);
inprec_ru8 (button);
inprec_ru8 (v);
inprec_rend ();
} else if (input_recording < 0) {
while (inprec_pstart (INPREC_JOYBUTTON)) {
uae_u8 j = inprec_pu8 ();
uae_u8 but = inprec_pu8 ();
uae_u8 vv = inprec_pu8 ();
inprec_pend ();
oldbuttons[j] &= ~(1 << but);
if (vv)
oldbuttons[j] |= 1 << but;
}
v = (oldbuttons[joy] & (1 << button)) ? 1 : 0;
}
return v;
#else
return (joybutton[joy] & (1 << button)) ? 1 : 0; return (joybutton[joy] & (1 << button)) ? 1 : 0;
#endif
} }
static int getvelocity (int num, int subnum, int pct) static int getvelocity (int num, int subnum, int pct)
...@@ -1954,27 +1685,24 @@ static void readinput (void) ...@@ -1954,27 +1685,24 @@ static void readinput (void)
uae_u32 totalvpos; uae_u32 totalvpos;
int diff; int diff;
totalvpos = input_frame * maxvpos + vpos; totalvpos = input_frame * current_maxvpos () + vpos;
diff = totalvpos - input_vpos; diff = totalvpos - input_vpos;
if (diff > 0) { if (diff > 0) {
if (diff < 10) { if (diff < 10) {
mouseupdate (0, 0); mouseupdate (0, 0);
} else { } else {
mouseupdate (diff * 1000 / maxvpos, 0); mouseupdate (diff * 1000 / current_maxvpos (), 0);
} }
} }
input_vpos = totalvpos; input_vpos = totalvpos;
} }
int getjoystate (int joy) static uae_u16 getjoystate (int joy)
{ {
int left = 1, right = 1, top = 1, bot = 1; int left = 1, right = 1, top = 1, bot = 1;
uae_u16 v; uae_u16 v;
if (inputdevice_logging & 2)
write_log ("JOY%dDAT %08x\n", joy, M68K_GETPC);
readinput ();
if (joydir[joy] & DIR_LEFT) if (joydir[joy] & DIR_LEFT)
left = 0; left = 0;
if (joydir[joy] & DIR_RIGHT) if (joydir[joy] & DIR_RIGHT)
...@@ -1999,27 +1727,15 @@ int getjoystate (int joy) ...@@ -1999,27 +1727,15 @@ int getjoystate (int joy)
if (notinrom ()) if (notinrom ())
write_log ("JOY%dDAT %04X %s\n", joy, v, debuginfo (0)); write_log ("JOY%dDAT %04X %s\n", joy, v, debuginfo (0));
#endif #endif
#ifdef INPREC if (inputdevice_logging & 2)
if (input_recording > 0 && oldjoy[joy] != v) { write_log ("JOY%dDAT=%04x %08x\n", joy, v, M68K_GETPC);
oldjoy[joy] = v;
inprec_rstart (INPREC_JOYPORT);
inprec_ru16 (v);
inprec_rend ();
} else if (input_recording < 0) {
v = oldjoy[joy];
if (inprec_pstart (INPREC_JOYPORT)) {
v = inprec_pu16 ();
inprec_pend ();
}
oldjoy[joy] = v;
}
#endif
return v; return v;
} }
uae_u16 JOY0DAT (void) uae_u16 JOY0DAT (void)
{ {
uae_u16 v; uae_u16 v;
readinput ();
v = getjoystate (0); v = getjoystate (0);
v = dongle_joydat (0, v); v = dongle_joydat (0, v);
return v; return v;
...@@ -2031,14 +1747,14 @@ uae_u16 JOY1DAT (void) ...@@ -2031,14 +1747,14 @@ uae_u16 JOY1DAT (void)
readinput (); readinput ();
v = getjoystate (1); v = getjoystate (1);
v = dongle_joydat (1, v); v = dongle_joydat (1, v);
#ifdef INPREC
if (inputrecord_debug & 2) { if (inputrecord_debug & 2) {
if (input_record > 0) if (input_record > 0)
inprec_recorddebug_cia (v, -1, m68k_getpc ()); inprec_recorddebug_cia (v, -1, m68k_getpc ());
else if (input_play > 0) else if (input_play > 0)
inprec_playdebug_cia (v, -1, m68k_getpc ()); inprec_playdebug_cia (v, -1, m68k_getpc ());
} }
#endif
return v; return v;
} }
...@@ -2126,6 +1842,14 @@ static bool cd32padmode (uae_u16 p5dir, uae_u16 p5dat) ...@@ -2126,6 +1842,14 @@ static bool cd32padmode (uae_u16 p5dir, uae_u16 p5dat)
return true; return true;
} }
static bool is_joystick_pullup (int joy)
{
return joymodes[joy] == JSEM_MODE_GAMEPAD;
}
static bool is_mouse_pullup (int joy)
{
return mouse_pullup;
}
static void charge_cap (int joy, int idx, int charge) static void charge_cap (int joy, int idx, int charge)
{ {
...@@ -2171,13 +1895,13 @@ static void cap_check (void) ...@@ -2171,13 +1895,13 @@ static void cap_check (void)
joypot = joydirpot[joy][i]; joypot = joydirpot[joy][i];
if (analog_port[joy][i] && pot_cap[joy][i] < joypot) if (analog_port[joy][i] && pot_cap[joy][i] < joypot)
charge = 1; // slow charge via pot variable resistor charge = 1; // slow charge via pot variable resistor
if (((joystick_pullup && digital_port[joy][i]) || (mouse_pullup && mouse_port[joy] && digital_port[joy][i]))) if ((is_joystick_pullup (joy) && digital_port[joy][i]) || (is_mouse_pullup (joy) && mouse_port[joy]))
charge = 1; // slow charge via pull-up resistor charge = 1; // slow charge via pull-up resistor
} }
if (!(potgo_value & pdir)) { // input? if (!(potgo_value & pdir)) { // input?
if (pot_dat_act[joy][i]) if (pot_dat_act[joy][i])
pot_dat[joy][i]++; pot_dat[joy][i]++;
/* first 8 lines after potgo has been started = discharge cap */ /* first 7 or 8 lines after potgo has been started = discharge cap */
if (pot_dat_act[joy][i] == 1) { if (pot_dat_act[joy][i] == 1) {
if (pot_dat[joy][i] < (currprefs.ntscmode ? POTDAT_DELAY_NTSC : POTDAT_DELAY_PAL)) { if (pot_dat[joy][i] < (currprefs.ntscmode ? POTDAT_DELAY_NTSC : POTDAT_DELAY_PAL)) {
charge = -2; /* fast discharge delay */ charge = -2; /* fast discharge delay */
...@@ -2219,13 +1943,13 @@ static void cap_check (void) ...@@ -2219,13 +1943,13 @@ static void cap_check (void)
/* official Commodore mouse has pull-up resistors in button lines /* official Commodore mouse has pull-up resistors in button lines
* NOTE: 3rd party mice may not have pullups! */ * NOTE: 3rd party mice may not have pullups! */
if (dong < 0 && (mouse_pullup && mouse_port[joy] && digital_port[joy][i]) && charge == 0) if (dong < 0 && (is_mouse_pullup (joy) && mouse_port[joy] && digital_port[joy][i]) && charge == 0)
charge = 2; charge = 2;
/* emulate pullup resistor if button mapped because there too many broken /* emulate pullup resistor if button mapped because there too many broken
* programs that read second button in input-mode (and most 2+ button pads have * programs that read second button in input-mode (and most 2+ button pads have
* pullups) * pullups)
*/ */
if (dong < 0 && (joystick_pullup && digital_port[joy][i]) && charge == 0) if (dong < 0 && (is_joystick_pullup (joy) && digital_port[joy][i]) && charge == 0)
charge = 2; charge = 2;
charge_cap (joy, i, charge); charge_cap (joy, i, charge);
...@@ -2263,8 +1987,12 @@ uae_u8 handle_joystick_buttons (uae_u8 pra, uae_u8 dra) ...@@ -2263,8 +1987,12 @@ uae_u8 handle_joystick_buttons (uae_u8 pra, uae_u8 dra)
} }
} }
if (inputdevice_logging & 4) if (inputdevice_logging & 4) {
write_log ("BFE001: %02X:%02X %x\n", dra, but, M68K_GETPC); static uae_u8 old;
if (but != old)
write_log ("BFE001: %02X:%02X %x\n", dra, but, M68K_GETPC);
old = but;
}
return but; return but;
} }
...@@ -2369,7 +2097,7 @@ void inputdevice_hsync (void) ...@@ -2369,7 +2097,7 @@ void inputdevice_hsync (void)
iq->state = 0; iq->state = 0;
else else
iq->state = iq->storedstate; iq->state = iq->storedstate;
handle_input_event (iq->event, iq->state, iq->max, 0); handle_input_event (iq->event, iq->state, iq->max, 0, false, true);
iq->linecnt = iq->nextlinecnt; iq->linecnt = iq->nextlinecnt;
} }
} }
...@@ -2378,12 +2106,27 @@ void inputdevice_hsync (void) ...@@ -2378,12 +2106,27 @@ void inputdevice_hsync (void)
if (bouncy && get_cycles () > bouncy_cycles) if (bouncy && get_cycles () > bouncy_cycles)
bouncy = 0; bouncy = 0;
if ((++cnt & 63) == 63) { if (input_record && input_record != INPREC_RECORD_PLAYING) {
inputdevice_read (); if (vpos == 0)
} else if (inputdelay > 0) { inputdevice_read ();
inputdelay--; inputdelay = 0;
if (inputdelay == 0) }
if (input_play) {
inprec_playdiskchange ();
int nr, state, max, autofire;
while (inprec_playevent (&nr, &state, &max, &autofire))
handle_input_event (nr, state, max, autofire, false, true);
//if (vpos == 0)
//handle_msgpump ();
}
if (!input_record && !input_play) {
if ((++cnt & 63) == 63 ) {
inputdevice_read (); inputdevice_read ();
} else if (inputdelay > 0) {
inputdelay--;
if (inputdelay == 0)
inputdevice_read ();
}
} }
} }
...@@ -2490,7 +2233,7 @@ static void queue_input_event (int event, int state, int max, int linecnt, int a ...@@ -2490,7 +2233,7 @@ static void queue_input_event (int event, int state, int max, int linecnt, int a
iq->linecnt = -1; iq->linecnt = -1;
iq->event = 0; iq->event = 0;
if (iq->state == 0) if (iq->state == 0)
handle_input_event (event, 0, 1, 0); handle_input_event (event, 0, 1, 0, false, false);
} else if (i < 0) { } else if (i < 0) {
for (i = 0; i < INPUT_QUEUE_SIZE; i++) { for (i = 0; i < INPUT_QUEUE_SIZE; i++) {
iq = &input_queue[i]; iq = &input_queue[i];
...@@ -2566,15 +2309,47 @@ void inputdevice_do_keyboard (int code, int state) ...@@ -2566,15 +2309,47 @@ void inputdevice_do_keyboard (int code, int state)
inputdevice_add_inputcode (code, state); inputdevice_add_inputcode (code, state);
} }
// these need cpu trace data
static bool needcputrace (int code)
{
switch (code)
{
case AKS_ENTERGUI:
case AKS_STATECAPTURE:
case AKS_STATESAVEQUICK:
case AKS_STATESAVEQUICK1:
case AKS_STATESAVEQUICK2:
case AKS_STATESAVEQUICK3:
case AKS_STATESAVEQUICK4:
case AKS_STATESAVEQUICK5:
case AKS_STATESAVEQUICK6:
case AKS_STATESAVEQUICK7:
case AKS_STATESAVEQUICK8:
case AKS_STATESAVEQUICK9:
case AKS_STATESAVEDIALOG:
return true;
}
return false;
}
void inputdevice_handle_inputcode (void) void inputdevice_handle_inputcode (void)
{ {
static int swapperslot; static int swapperslot;
int code = inputcode_pending; int code = inputcode_pending;
int state = inputcode_pending_state; int state = inputcode_pending_state;
static int tracer_enable;
inputcode_pending = 0;
if (code == 0) if (code == 0)
return; goto end;
if (needcputrace (code) && can_cpu_tracer () == true && is_cpu_tracer () == false && !input_play && !input_record) {
if (set_cpu_tracer (true)) {
tracer_enable = 1;
return; // wait for next frame
}
}
inputcode_pending = 0;
if (vpos != 0) if (vpos != 0)
write_log ("inputcode=%d but vpos = %d", code, vpos); write_log ("inputcode=%d but vpos = %d", code, vpos);
...@@ -2660,9 +2435,15 @@ void inputdevice_handle_inputcode (void) ...@@ -2660,9 +2435,15 @@ void inputdevice_handle_inputcode (void)
break; break;
#ifdef SAVESTATE #ifdef SAVESTATE
case AKS_STATEREWIND: case AKS_STATEREWIND:
savestate_dorewind (1); savestate_dorewind (-2);
#endif break;
case AKS_STATECURRENT:
savestate_dorewind (-1);
break; break;
case AKS_STATECAPTURE:
savestate_capture (1);
break;
#endif
case AKS_VOLDOWN: case AKS_VOLDOWN:
sound_volume (-1); sound_volume (-1);
break; break;
...@@ -2834,6 +2615,11 @@ void inputdevice_handle_inputcode (void) ...@@ -2834,6 +2615,11 @@ void inputdevice_handle_inputcode (void)
break; break;
#endif #endif
} }
end:
if (tracer_enable) {
set_cpu_tracer (false);
tracer_enable = 0;
}
} }
int handle_custom_event (TCHAR *custom) int handle_custom_event (TCHAR *custom)
...@@ -2864,15 +2650,32 @@ int handle_custom_event (TCHAR *custom) ...@@ -2864,15 +2650,32 @@ int handle_custom_event (TCHAR *custom)
return 0; return 0;
} }
int handle_input_event (int nr, int state, int max, int autofire) static int handle_input_event (int nr, int state, int max, int autofire, bool canstopplayback, bool playbackevent)
{ {
struct inputevent *ie; struct inputevent *ie;
int joy; int joy;
bool isaks = false;
if (nr <= 0) if (nr <= 0)
return 0; return 0;
ie = &events[nr]; ie = &events[nr];
if (inputdevice_logging & 1) if (ie->unit == 0 && ie->data >= 0x200)
isaks = true;
if (!isaks) {
if (input_record && input_record != INPREC_RECORD_PLAYING)
inprec_recordevent (nr, state, max, autofire);
if (input_play && state && canstopplayback) {
if (inprec_realtimev ()) {
if (input_record && input_record != INPREC_RECORD_PLAYING)
inprec_recordevent (nr, state, max, autofire);
}
}
if (!playbackevent && input_play)
return 0;
}
if ((inputdevice_logging & 1) || input_record || input_play)
write_log ("'%s' STATE=%d MAX=%d AF=%d\n", ie->name, state, max, autofire); write_log ("'%s' STATE=%d MAX=%d AF=%d\n", ie->name, state, max, autofire);
if (autofire) { if (autofire) {
if (state) if (state)
...@@ -2930,9 +2733,11 @@ int handle_input_event (int nr, int state, int max, int autofire) ...@@ -2930,9 +2733,11 @@ int handle_input_event (int nr, int state, int max, int autofire)
} }
if (ie->data == 0 && old != (joybutton[joy] & (1 << ie->data)) && currprefs.cpu_cycle_exact) { if (ie->data == 0 && old != (joybutton[joy] & (1 << ie->data)) && currprefs.cpu_cycle_exact) {
// emulate contact bounce, 1st button only, others have capacitors if (!input_record && !input_play && currprefs.input_contact_bounce) {
bouncy = 1; // emulate contact bounce, 1st button only, others have capacitors
bouncy_cycles = get_cycles () + CYCLE_UNIT * BOUNCY_CYCLES; bouncy = 1;
bouncy_cycles = get_cycles () + CYCLE_UNIT * currprefs.input_contact_bounce;
}
} }
...@@ -3189,9 +2994,13 @@ void inputdevice_vsync (void) ...@@ -3189,9 +2994,13 @@ void inputdevice_vsync (void)
input_frame++; input_frame++;
mouseupdate (0, 1); mouseupdate (0, 1);
inputdevice_read ();
inputdelay = rand () % (maxvpos <= 1 ? 1 : maxvpos - 1); if (!input_record) {
inputdevice_read ();
if (!input_play)
inputdelay = uaerand () % (maxvpos <= 1 ? 1 : maxvpos - 1);
}
inputdevice_handle_inputcode (); inputdevice_handle_inputcode ();
if (mouseedge_alive > 0) if (mouseedge_alive > 0)
mouseedge_alive--; mouseedge_alive--;
...@@ -3223,6 +3032,7 @@ void inputdevice_reset (void) ...@@ -3223,6 +3032,7 @@ void inputdevice_reset (void)
// mousehack_reset (); // mousehack_reset ();
if (inputdevice_is_tablet ()) if (inputdevice_is_tablet ())
mousehack_enable (); mousehack_enable ();
bouncy = 0;
} }
static int getoldport (struct uae_input_device *id) static int getoldport (struct uae_input_device *id)
...@@ -3390,6 +3200,10 @@ static void setbuttonstateall (struct uae_input_device *id, struct uae_input_dev ...@@ -3390,6 +3200,10 @@ static void setbuttonstateall (struct uae_input_device *id, struct uae_input_dev
uae_u32 omask = id2->buttonmask & mask; uae_u32 omask = id2->buttonmask & mask;
uae_u32 nmask = (state ? 1 : 0) << button; uae_u32 nmask = (state ? 1 : 0) << button;
if (input_play && state)
inprec_realtimev ();
if (input_play)
return;
if (!id->enabled) { if (!id->enabled) {
if (state) if (state)
switchdevice (id, button, 1); switchdevice (id, button, 1);
...@@ -3404,7 +3218,7 @@ static void setbuttonstateall (struct uae_input_device *id, struct uae_input_dev ...@@ -3404,7 +3218,7 @@ static void setbuttonstateall (struct uae_input_device *id, struct uae_input_dev
int toggle = (id->flags[ID_BUTTON_OFFSET + button][sublevdir[state <= 0 ? 1 : 0][i]] & ID_FLAG_TOGGLE) ? 1 : 0; int toggle = (id->flags[ID_BUTTON_OFFSET + button][sublevdir[state <= 0 ? 1 : 0][i]] & ID_FLAG_TOGGLE) ? 1 : 0;
if (state < 0) { if (state < 0) {
handle_input_event (evt, 1, 1, 0); handle_input_event (evt, 1, 1, 0, true, false);
queue_input_event (evt, 0, 1, 1, 0); /* send release event next frame */ queue_input_event (evt, 0, 1, 1, 0); /* send release event next frame */
if (i == 0) if (i == 0)
process_custom_event (id, ID_BUTTON_OFFSET + button, state); process_custom_event (id, ID_BUTTON_OFFSET + button, state);
...@@ -3416,12 +3230,12 @@ static void setbuttonstateall (struct uae_input_device *id, struct uae_input_dev ...@@ -3416,12 +3230,12 @@ static void setbuttonstateall (struct uae_input_device *id, struct uae_input_dev
continue; continue;
id->flags[ID_BUTTON_OFFSET + button][sublevdir[state <= 0 ? 1 : 0][i]] ^= ID_FLAG_TOGGLED; id->flags[ID_BUTTON_OFFSET + button][sublevdir[state <= 0 ? 1 : 0][i]] ^= ID_FLAG_TOGGLED;
toggled = (id->flags[ID_BUTTON_OFFSET + button][sublevdir[state <= 0 ? 1 : 0][i]] & ID_FLAG_TOGGLED) ? 1 : 0; toggled = (id->flags[ID_BUTTON_OFFSET + button][sublevdir[state <= 0 ? 1 : 0][i]] & ID_FLAG_TOGGLED) ? 1 : 0;
handle_input_event (evt, toggled, 1, autofire); handle_input_event (evt, toggled, 1, autofire, true, false);
if (i == 0) if (i == 0)
process_custom_event (id, ID_BUTTON_OFFSET + button, toggled); process_custom_event (id, ID_BUTTON_OFFSET + button, toggled);
} else { } else {
if ((omask ^ nmask) & mask) { if ((omask ^ nmask) & mask) {
handle_input_event (evt, state, 1, autofire); handle_input_event (evt, state, 1, autofire, true, false);
if (i == 0) if (i == 0)
process_custom_event (id, ID_BUTTON_OFFSET + button, state); process_custom_event (id, ID_BUTTON_OFFSET + button, state);
} }
...@@ -3501,19 +3315,19 @@ static int isanalog (int ei) ...@@ -3501,19 +3315,19 @@ static int isanalog (int ei)
static int isdigitalbutton (int ei) static int isdigitalbutton (int ei)
{ {
if (ei == INPUTEVENT_JOY1_2ND_BUTTON) { if (ei == INPUTEVENT_JOY1_2ND_BUTTON) {
digital_port[0][0] = 1; digital_port[0][1] = 1;
return 1; return 1;
} }
if (ei == INPUTEVENT_JOY1_3RD_BUTTON) { if (ei == INPUTEVENT_JOY1_3RD_BUTTON) {
digital_port[0][1] = 1; digital_port[0][0] = 1;
return 1; return 1;
} }
if (ei == INPUTEVENT_JOY2_2ND_BUTTON) { if (ei == INPUTEVENT_JOY2_2ND_BUTTON) {
digital_port[1][0] = 1; digital_port[1][1] = 1;
return 1; return 1;
} }
if (ei == INPUTEVENT_JOY2_3RD_BUTTON) { if (ei == INPUTEVENT_JOY2_3RD_BUTTON) {
digital_port[1][1] = 1; digital_port[1][0] = 1;
return 1; return 1;
} }
return 0; return 0;
...@@ -3530,7 +3344,7 @@ static void scanevents (struct uae_prefs *p) ...@@ -3530,7 +3344,7 @@ static void scanevents (struct uae_prefs *p)
parport_joystick_enabled = 0; parport_joystick_enabled = 0;
mouse_port[0] = mouse_port[1] = 0; mouse_port[0] = mouse_port[1] = 0;
for (i = 0; i < 2; i++) { for (i = 0; i < NORMAL_JPORTS; i++) {
for (j = 0; j < 2; j++) { for (j = 0; j < 2; j++) {
digital_port[i][j] = 0; digital_port[i][j] = 0;
analog_port[i][j] = 0; analog_port[i][j] = 0;
...@@ -3538,9 +3352,6 @@ static void scanevents (struct uae_prefs *p) ...@@ -3538,9 +3352,6 @@ static void scanevents (struct uae_prefs *p)
} }
} }
for (i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++)
joydir[i] = 0;
for (i = 0; i < MAX_INPUT_DEVICES; i++) { for (i = 0; i < MAX_INPUT_DEVICES; i++) {
use_joysticks[i] = 0; use_joysticks[i] = 0;
use_mice[i] = 0; use_mice[i] = 0;
...@@ -3714,6 +3525,16 @@ static int ip_joy2[] = { ...@@ -3714,6 +3525,16 @@ static int ip_joy2[] = {
INPUTEVENT_JOY2_FIRE_BUTTON, INPUTEVENT_JOY2_2ND_BUTTON, INPUTEVENT_JOY2_FIRE_BUTTON, INPUTEVENT_JOY2_2ND_BUTTON,
-1 -1
}; };
static int ip_joypad1[] = {
INPUTEVENT_JOY1_LEFT, INPUTEVENT_JOY1_RIGHT, INPUTEVENT_JOY1_UP, INPUTEVENT_JOY1_DOWN,
INPUTEVENT_JOY1_FIRE_BUTTON, INPUTEVENT_JOY1_2ND_BUTTON, INPUTEVENT_JOY1_3RD_BUTTON,
-1
};
static int ip_joypad2[] = {
INPUTEVENT_JOY2_LEFT, INPUTEVENT_JOY2_RIGHT, INPUTEVENT_JOY2_UP, INPUTEVENT_JOY2_DOWN,
INPUTEVENT_JOY2_FIRE_BUTTON, INPUTEVENT_JOY2_2ND_BUTTON, INPUTEVENT_JOY2_3RD_BUTTON,
-1
};
static int ip_joycd321[] = { static int ip_joycd321[] = {
INPUTEVENT_JOY1_LEFT, INPUTEVENT_JOY1_RIGHT, INPUTEVENT_JOY1_UP, INPUTEVENT_JOY1_DOWN, INPUTEVENT_JOY1_LEFT, INPUTEVENT_JOY1_RIGHT, INPUTEVENT_JOY1_UP, INPUTEVENT_JOY1_DOWN,
INPUTEVENT_JOY1_CD32_RED, INPUTEVENT_JOY1_CD32_BLUE, INPUTEVENT_JOY1_CD32_GREEN, INPUTEVENT_JOY1_CD32_YELLOW, INPUTEVENT_JOY1_CD32_RED, INPUTEVENT_JOY1_CD32_BLUE, INPUTEVENT_JOY1_CD32_GREEN, INPUTEVENT_JOY1_CD32_YELLOW,
...@@ -3803,6 +3624,8 @@ static void checkcompakb (int *kb, int *srcmap) ...@@ -3803,6 +3624,8 @@ static void checkcompakb (int *kb, int *srcmap)
} }
j++; j++;
} }
if (srcmap[k] < 0)
break;
j++; j++;
k++; k++;
} }
...@@ -3902,9 +3725,6 @@ static void setcompakb (int *kb, int *srcmap, int index, int af) ...@@ -3902,9 +3725,6 @@ static void setcompakb (int *kb, int *srcmap, int index, int af)
} }
} }
static int joymodes[MAX_JPORTS];
static int *joyinputs[MAX_JPORTS];
int inputdevice_get_compatibility_input (struct uae_prefs *prefs, int index, int *typelist, int **inputlist, int **at) int inputdevice_get_compatibility_input (struct uae_prefs *prefs, int index, int *typelist, int **inputlist, int **at)
{ {
if (index >= MAX_JPORTS || joymodes[index] < 0) if (index >= MAX_JPORTS || joymodes[index] < 0)
...@@ -4151,6 +3971,9 @@ static void setjoyinputs (struct uae_prefs *prefs, int port) ...@@ -4151,6 +3971,9 @@ static void setjoyinputs (struct uae_prefs *prefs, int port)
else else
joyinputs[port] = port == 1 ? ip_joy2 : ip_joy1; joyinputs[port] = port == 1 ? ip_joy2 : ip_joy1;
break; break;
case JSEM_MODE_GAMEPAD:
joyinputs[port] = port ? ip_joypad2 : ip_joypad1;
break;
case JSEM_MODE_JOYSTICK_CD32: case JSEM_MODE_JOYSTICK_CD32:
joyinputs[port] = port ? ip_joycd322 : ip_joycd321; joyinputs[port] = port ? ip_joycd322 : ip_joycd321;
break; break;
...@@ -4243,15 +4066,21 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports) ...@@ -4243,15 +4066,21 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
{ {
case JSEM_MODE_DEFAULT: case JSEM_MODE_DEFAULT:
case JSEM_MODE_JOYSTICK: case JSEM_MODE_JOYSTICK:
case JSEM_MODE_GAMEPAD:
case JSEM_MODE_JOYSTICK_CD32: case JSEM_MODE_JOYSTICK_CD32:
default: default:
{ {
bool iscd32 = mode == JSEM_MODE_JOYSTICK_CD32 || (mode == JSEM_MODE_DEFAULT && prefs->cs_cd32cd); bool iscd32 = mode == JSEM_MODE_JOYSTICK_CD32 || (mode == JSEM_MODE_DEFAULT && prefs->cs_cd32cd);
joymodes[i] = iscd32 ? JSEM_MODE_JOYSTICK_CD32 : JSEM_MODE_JOYSTICK; if (iscd32) {
if (!iscd32) joymodes[i] = JSEM_MODE_JOYSTICK_CD32;
joyinputs[i] = i ? ip_joy2 : ip_joy1;
else
joyinputs[i] = i ? ip_joycd322 : ip_joycd321; joyinputs[i] = i ? ip_joycd322 : ip_joycd321;
} else if (mode == JSEM_MODE_GAMEPAD) {
joymodes[i] = JSEM_MODE_GAMEPAD;
joyinputs[i] = i ? ip_joypad2 : ip_joypad1;
} else {
joymodes[i] = JSEM_MODE_JOYSTICK;
joyinputs[i] = i ? ip_joy2 : ip_joy1;
}
break; break;
} }
case JSEM_MODE_JOYSTICK_ANALOG: case JSEM_MODE_JOYSTICK_ANALOG:
...@@ -4329,12 +4158,18 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports) ...@@ -4329,12 +4158,18 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
{ {
case JSEM_MODE_DEFAULT: case JSEM_MODE_DEFAULT:
case JSEM_MODE_JOYSTICK: case JSEM_MODE_JOYSTICK:
case JSEM_MODE_GAMEPAD:
case JSEM_MODE_JOYSTICK_CD32: case JSEM_MODE_JOYSTICK_CD32:
default: default:
{ {
bool iscd32 = mode == JSEM_MODE_JOYSTICK_CD32 || (mode == JSEM_MODE_DEFAULT && prefs->cs_cd32cd); bool iscd32 = mode == JSEM_MODE_JOYSTICK_CD32 || (mode == JSEM_MODE_DEFAULT && prefs->cs_cd32cd);
input_get_default_joystick (joysticks, joy, i, af, iscd32 ? JSEM_MODE_JOYSTICK_CD32 : 0); input_get_default_joystick (joysticks, joy, i, af, mode);
joymodes[i] = iscd32 ? JSEM_MODE_JOYSTICK_CD32 : JSEM_MODE_JOYSTICK; if (iscd32)
joymodes[i] = JSEM_MODE_JOYSTICK_CD32;
else if (mode == JSEM_MODE_GAMEPAD)
joymodes[i] = JSEM_MODE_GAMEPAD;
else
joymodes[i] = JSEM_MODE_JOYSTICK;
break; break;
} }
case JSEM_MODE_JOYSTICK_ANALOG: case JSEM_MODE_JOYSTICK_ANALOG:
...@@ -4364,16 +4199,20 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports) ...@@ -4364,16 +4199,20 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
if (gameports) { if (gameports) {
// replace possible old mappings with default keyboard mapping // replace possible old mappings with default keyboard mapping
for (i = KBR_DEFAULT_MAP_NP; i <= KBR_DEFAULT_MAP_SE; i++) { for (i = KBR_DEFAULT_MAP_FIRST; i <= KBR_DEFAULT_MAP_LAST; i++) {
checkcompakb (keyboard_default_kbmaps[i], ip_joy2); checkcompakb (keyboard_default_kbmaps[i], ip_joy2);
checkcompakb (keyboard_default_kbmaps[i], ip_joy1); checkcompakb (keyboard_default_kbmaps[i], ip_joy1);
checkcompakb (keyboard_default_kbmaps[i], ip_joypad2);
checkcompakb (keyboard_default_kbmaps[i], ip_joypad1);
checkcompakb (keyboard_default_kbmaps[i], ip_parjoy2); checkcompakb (keyboard_default_kbmaps[i], ip_parjoy2);
checkcompakb (keyboard_default_kbmaps[i], ip_parjoy1); checkcompakb (keyboard_default_kbmaps[i], ip_parjoy1);
checkcompakb (keyboard_default_kbmaps[i], ip_mouse2); checkcompakb (keyboard_default_kbmaps[i], ip_mouse2);
checkcompakb (keyboard_default_kbmaps[i], ip_mouse1); checkcompakb (keyboard_default_kbmaps[i], ip_mouse1);
} }
checkcompakb (keyboard_default_kbmaps[5], ip_joycd321); for (i = KBR_DEFAULT_MAP_CD32_FIRST; i <= KBR_DEFAULT_MAP_CD32_LAST; i++) {
checkcompakb (keyboard_default_kbmaps[5], ip_joycd322); checkcompakb (keyboard_default_kbmaps[i], ip_joycd321);
checkcompakb (keyboard_default_kbmaps[i], ip_joycd322);
}
} }
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
...@@ -4387,16 +4226,22 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports) ...@@ -4387,16 +4226,22 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
if (JSEM_ISNUMPAD (i, prefs)) { if (JSEM_ISNUMPAD (i, prefs)) {
if (cd32) if (cd32)
kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_CD32_NP]; kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_CD32_NP];
else if (mode == JSEM_MODE_GAMEPAD)
kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_NP3];
else else
kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_NP]; kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_NP];
} else if (JSEM_ISCURSOR (i, prefs)) { } else if (JSEM_ISCURSOR (i, prefs)) {
if (cd32) if (cd32)
kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_CD32_CK]; kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_CD32_CK];
else if (mode == JSEM_MODE_GAMEPAD)
kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_CK3];
else else
kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_CK]; kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_CK];
} else if (JSEM_ISSOMEWHEREELSE (i, prefs)) { } else if (JSEM_ISSOMEWHEREELSE (i, prefs)) {
if (cd32) if (cd32)
kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_CD32_SE]; kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_CD32_SE];
else if (mode == JSEM_MODE_GAMEPAD)
kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_SE3];
else else
kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_SE]; kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_SE];
} else if (JSEM_ISXARCADE1 (i, prefs)) { } else if (JSEM_ISXARCADE1 (i, prefs)) {
...@@ -4408,11 +4253,15 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports) ...@@ -4408,11 +4253,15 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
switch (mode) switch (mode)
{ {
case JSEM_MODE_JOYSTICK: case JSEM_MODE_JOYSTICK:
case JSEM_MODE_GAMEPAD:
case JSEM_MODE_JOYSTICK_CD32: case JSEM_MODE_JOYSTICK_CD32:
case JSEM_MODE_DEFAULT: case JSEM_MODE_DEFAULT:
if (cd32) { if (cd32) {
setcompakb (kb, i ? ip_joycd322 : ip_joycd321, i, af); setcompakb (kb, i ? ip_joycd322 : ip_joycd321, i, af);
joymodes[i] = JSEM_MODE_JOYSTICK_CD32; joymodes[i] = JSEM_MODE_JOYSTICK_CD32;
} else if (mode == JSEM_MODE_GAMEPAD) {
setcompakb (kb, i ? ip_joypad2 : ip_joypad1, i, af);
joymodes[i] = JSEM_MODE_GAMEPAD;
} else { } else {
setcompakb (kb, i ? ip_joy2 : ip_joy1, i, af); setcompakb (kb, i ? ip_joy2 : ip_joy1, i, af);
joymodes[i] = JSEM_MODE_JOYSTICK; joymodes[i] = JSEM_MODE_JOYSTICK;
...@@ -4619,36 +4468,21 @@ bool inputdevice_set_gameports_mapping (struct uae_prefs *prefs, int devnum, int ...@@ -4619,36 +4468,21 @@ bool inputdevice_set_gameports_mapping (struct uae_prefs *prefs, int devnum, int
return true; return true;
} }
void inputdevice_updateconfig (struct uae_prefs *prefs) static void resetinput (void)
{ {
int i; if ((input_play || input_record) && hsync_counter > 0)
return;
copyjport (&changed_prefs, &currprefs, 0);
copyjport (&changed_prefs, &currprefs, 1);
copyjport (&changed_prefs, &currprefs, 2);
copyjport (&changed_prefs, &currprefs, 3);
#ifdef RETROPLATFORM
rp_input_change (0);
rp_input_change (1);
rp_input_change (2);
rp_input_change (3);
for (i = 0; i < MAX_JPORTS; i++)
rp_update_gameport (i, -1, 0);
#endif
joybutton[0] = joybutton[1] = 0;
joydir[0] = joydir[1] = 0;
oldmx[0] = oldmx[1] = -1;
oldmy[0] = oldmy[1] = -1;
cd32_shifter[0] = cd32_shifter[1] = 8; cd32_shifter[0] = cd32_shifter[1] = 8;
for (i = 0; i < 4; i++) { unsigned int i;
for (i = 0; i < MAX_JPORTS; i++) {
oleft[i] = 0; oleft[i] = 0;
oright[i] = 0; oright[i] = 0;
otop[i] = 0; otop[i] = 0;
obot[i] = 0; obot[i] = 0;
} oldmx[i] = -1;
for (i = 0; i < MAX_INPUT_DEVICES; i++) { oldmy[i] = -1;
joybutton[i] = 0;
joydir[i] = 0;
mouse_deltanoreset[i][0] = 0; mouse_deltanoreset[i][0] = 0;
mouse_delta[i][0] = 0; mouse_delta[i][0] = 0;
mouse_deltanoreset[i][1] = 0; mouse_deltanoreset[i][1] = 0;
...@@ -4656,8 +4490,7 @@ void inputdevice_updateconfig (struct uae_prefs *prefs) ...@@ -4656,8 +4490,7 @@ void inputdevice_updateconfig (struct uae_prefs *prefs)
mouse_deltanoreset[i][2] = 0; mouse_deltanoreset[i][2] = 0;
mouse_delta[i][2] = 0; mouse_delta[i][2] = 0;
} }
memset (keybuf, 0, sizeof (keybuf)); memset (keybuf, 0, sizeof keybuf);
for (i = 0; i < INPUT_QUEUE_SIZE; i++) for (i = 0; i < INPUT_QUEUE_SIZE; i++)
input_queue[i].linecnt = input_queue[i].nextlinecnt = -1; input_queue[i].linecnt = input_queue[i].nextlinecnt = -1;
...@@ -4665,6 +4498,27 @@ void inputdevice_updateconfig (struct uae_prefs *prefs) ...@@ -4665,6 +4498,27 @@ void inputdevice_updateconfig (struct uae_prefs *prefs)
sublevdir[0][i] = i; sublevdir[0][i] = i;
sublevdir[1][i] = MAX_INPUT_SUB_EVENT - i - 1; sublevdir[1][i] = MAX_INPUT_SUB_EVENT - i - 1;
} }
}
void inputdevice_updateconfig (struct uae_prefs *prefs)
{
int i;
copyjport (&changed_prefs, &currprefs, 0);
copyjport (&changed_prefs, &currprefs, 1);
copyjport (&changed_prefs, &currprefs, 2);
copyjport (&changed_prefs, &currprefs, 3);
#ifdef RETROPLATFORM
rp_input_change (0);
rp_input_change (1);
rp_input_change (2);
rp_input_change (3);
for (i = 0; i < MAX_JPORTS; i++)
rp_update_gameport (i, -1, 0);
#endif
resetinput ();
joysticks = prefs->joystick_settings[prefs->input_selected_setting]; joysticks = prefs->joystick_settings[prefs->input_selected_setting];
mice = prefs->mouse_settings[prefs->input_selected_setting]; mice = prefs->mouse_settings[prefs->input_selected_setting];
...@@ -4827,6 +4681,7 @@ static int inputdevice_translatekeycode_2 (int keyboard, int scancode, int state ...@@ -4827,6 +4681,7 @@ static int inputdevice_translatekeycode_2 (int keyboard, int scancode, int state
if (!keyboards || scancode < 0) if (!keyboards || scancode < 0)
return handled; return handled;
j = 0; j = 0;
while (j < MAX_INPUT_DEVICE_EVENTS && na->extra[j] >= 0) { while (j < MAX_INPUT_DEVICE_EVENTS && na->extra[j] >= 0) {
if (na->extra[j] == scancode) { if (na->extra[j] == scancode) {
...@@ -4856,9 +4711,9 @@ static int inputdevice_translatekeycode_2 (int keyboard, int scancode, int state ...@@ -4856,9 +4711,9 @@ static int inputdevice_translatekeycode_2 (int keyboard, int scancode, int state
continue; continue;
na->flags[j][sublevdir[state == 0 ? 1 : 0][k]] ^= ID_FLAG_TOGGLED; na->flags[j][sublevdir[state == 0 ? 1 : 0][k]] ^= ID_FLAG_TOGGLED;
toggled = (na->flags[j][sublevdir[state == 0 ? 1 : 0][k]] & ID_FLAG_TOGGLED) ? 1 : 0; toggled = (na->flags[j][sublevdir[state == 0 ? 1 : 0][k]] & ID_FLAG_TOGGLED) ? 1 : 0;
handled |= handle_input_event (evt, toggled, 1, autofire); handled |= handle_input_event (evt, toggled, 1, autofire, true, false);
} else { } else {
handled |= handle_input_event (evt, state, 1, autofire); handled |= handle_input_event (evt, state, 1, autofire, true, false);
} }
} }
process_custom_event (na, j, state); process_custom_event (na, j, state);
...@@ -4923,9 +4778,7 @@ void inputdevice_close (void) ...@@ -4923,9 +4778,7 @@ void inputdevice_close (void)
idev[IDTYPE_JOYSTICK].close (); idev[IDTYPE_JOYSTICK].close ();
idev[IDTYPE_MOUSE].close (); idev[IDTYPE_MOUSE].close ();
idev[IDTYPE_KEYBOARD].close (); idev[IDTYPE_KEYBOARD].close ();
#ifdef INPREC inprec_close (true);
inprec_close ();
#endif
} }
static struct uae_input_device *get_uid (const struct inputdevice_functions *id, int devnum) static struct uae_input_device *get_uid (const struct inputdevice_functions *id, int devnum)
...@@ -5651,13 +5504,17 @@ void setjoystickstate (int joy, int axis, int state, int max) ...@@ -5651,13 +5504,17 @@ void setjoystickstate (int joy, int axis, int state, int max)
v2 = 0; v2 = 0;
if (v1 == v2) if (v1 == v2)
return; return;
if (input_play && state)
inprec_realtimev ();
if (input_play)
return;
if (!joysticks[joy].enabled) { if (!joysticks[joy].enabled) {
if (v1) if (v1)
switchdevice (&joysticks[joy], axis * 2 + (v1 < 0 ? 0 : 1), 0); switchdevice (&joysticks[joy], axis * 2 + (v1 < 0 ? 0 : 1), 0);
return; return;
} }
for (i = 0; i < MAX_INPUT_SUB_EVENT; i++) for (i = 0; i < MAX_INPUT_SUB_EVENT; i++)
handle_input_event (id->eventid[ID_AXIS_OFFSET + axis][i], state, max, id->flags[ID_AXIS_OFFSET + axis][i] & ID_FLAG_AUTOFIRE); handle_input_event (id->eventid[ID_AXIS_OFFSET + axis][i], state, max, id->flags[ID_AXIS_OFFSET + axis][i] & ID_FLAG_AUTOFIRE, true, false);
id2->states[axis] = state; id2->states[axis] = state;
} }
int getjoystickstate (int joy) int getjoystickstate (int joy)
...@@ -5681,6 +5538,8 @@ void setmousestate (int mouse, int axis, int data, int isabs) ...@@ -5681,6 +5538,8 @@ void setmousestate (int mouse, int axis, int data, int isabs)
inputdevice_testrecord (IDTYPE_MOUSE, mouse, IDEV_WIDGET_AXIS, axis, 0); inputdevice_testrecord (IDTYPE_MOUSE, mouse, IDEV_WIDGET_AXIS, axis, 0);
return; return;
} }
if (input_play)
return;
if (!mice[mouse].enabled) { if (!mice[mouse].enabled) {
if (isabs && currprefs.input_tablet > 0) { if (isabs && currprefs.input_tablet > 0) {
if (axis == 0) if (axis == 0)
...@@ -5721,7 +5580,7 @@ void setmousestate (int mouse, int axis, int data, int isabs) ...@@ -5721,7 +5580,7 @@ void setmousestate (int mouse, int axis, int data, int isabs)
v += diff; v += diff;
fract[mouse][axis] -= diff; fract[mouse][axis] -= diff;
for (i = 0; i < MAX_INPUT_SUB_EVENT; i++) for (i = 0; i < MAX_INPUT_SUB_EVENT; i++)
handle_input_event (id->eventid[ID_AXIS_OFFSET + axis][i], v, 0, 0); handle_input_event (id->eventid[ID_AXIS_OFFSET + axis][i], v, 0, 0, true, false);
} }
int getmousestate (int joy) int getmousestate (int joy)
......
...@@ -314,7 +314,11 @@ DEFEVENT(SPC_PAUSE,"Pause emulation",AM_K,0,0,AKS_PAUSE) ...@@ -314,7 +314,11 @@ DEFEVENT(SPC_PAUSE,"Pause emulation",AM_K,0,0,AKS_PAUSE)
DEFEVENT(SPC_WARP,"Warp mode",AM_K,0,0,AKS_WARP) DEFEVENT(SPC_WARP,"Warp mode",AM_K,0,0,AKS_WARP)
DEFEVENT(SPC_INHIBITSCREEN,"Toggle screen updates",AM_K,0,0,AKS_INHIBITSCREEN) DEFEVENT(SPC_INHIBITSCREEN,"Toggle screen updates",AM_K,0,0,AKS_INHIBITSCREEN)
DEFEVENT(SPC_IRQ7,"Level 7 interrupt",AM_K,0,0,AKS_IRQ7) DEFEVENT(SPC_IRQ7,"Level 7 interrupt",AM_K,0,0,AKS_IRQ7)
DEFEVENT(SPC_STATEREWIND,"Load previous state capture",AM_K,0,0,AKS_STATEREWIND)
DEFEVENT(SPC_STATEREWIND,"Load previous state capture checkpoint",AM_K,0,0,AKS_STATEREWIND)
DEFEVENT(SPC_STATECURRENT,"Load current state capture checkpoint",AM_K,0,0,AKS_STATECURRENT)
DEFEVENT(SPC_STATECAPTURE,"Save state capture checkpoint",AM_K,0,0,AKS_STATECAPTURE)
DEFEVENT(SPC_VOLUME_DOWN,"Decrease volume level",AM_K,0,0,AKS_VOLDOWN) DEFEVENT(SPC_VOLUME_DOWN,"Decrease volume level",AM_K,0,0,AKS_VOLDOWN)
DEFEVENT(SPC_VOLUME_UP,"Increase volume level",AM_K,0,0,AKS_VOLUP) DEFEVENT(SPC_VOLUME_UP,"Increase volume level",AM_K,0,0,AKS_VOLUP)
DEFEVENT(SPC_VOLUME_MUTE,"Mute/unmute volume",AM_K,0,0,AKS_VOLMUTE) DEFEVENT(SPC_VOLUME_MUTE,"Mute/unmute volume",AM_K,0,0,AKS_VOLMUTE)
...@@ -336,12 +340,6 @@ DEFEVENT(SPC_TOGGLEMOUSEGRAB,"Toggle between mouse grabbed and un-grabbed",AM_K, ...@@ -336,12 +340,6 @@ DEFEVENT(SPC_TOGGLEMOUSEGRAB,"Toggle between mouse grabbed and un-grabbed",AM_K,
DEFEVENT(SPC_DECREASE_REFRESHRATE,"Decrease emulation speed",AM_K,0,0,AKS_DECREASEREFRESHRATE) DEFEVENT(SPC_DECREASE_REFRESHRATE,"Decrease emulation speed",AM_K,0,0,AKS_DECREASEREFRESHRATE)
DEFEVENT(SPC_INCREASE_REFRESHRATE,"Increase emulation speed",AM_K,0,0,AKS_INCREASEREFRESHRATE) DEFEVENT(SPC_INCREASE_REFRESHRATE,"Increase emulation speed",AM_K,0,0,AKS_INCREASEREFRESHRATE)
DEFEVENT(SPC_SWITCHINTERPOL,"Switch between audio interpolation methods",AM_K,0,0,AKS_SWITCHINTERPOL) DEFEVENT(SPC_SWITCHINTERPOL,"Switch between audio interpolation methods",AM_K,0,0,AKS_SWITCHINTERPOL)
DEFEVENT(SPC_GLPANLEFT,"Pan opengl texture to the left",AM_K,0,0,AKS_GLPANLEFT) /*Koko*/
DEFEVENT(SPC_GLPANRIGHT,"Pan opengl texture to the left",AM_K,0,0,AKS_GLPANRIGHT) /*Koko*/
DEFEVENT(SPC_GLPANUP,"Pan opengl texture to the left",AM_K,0,0,AKS_GLPANUP) /*Koko*/
DEFEVENT(SPC_GLPANDOWN,"Pan opengl texture to the left",AM_K,0,0,AKS_GLPANDOWN) /*Koko*/
DEFEVENT(SPC_GLPANSCANMORE,"ZoomIn opengl texture",AM_K,0,0,AKS_GLPANSCANMORE) /*Koko*/
DEFEVENT(SPC_GLPANSCANLESS,"ZoomOut opengl texture",AM_K,0,0,AKS_GLPANSCANLESS) /*Koko*/
DEFEVENT(SPC_DISKSWAPPER_NEXT,"Next slot in Disk Swapper",AM_K,0,0,AKS_DISKSWAPPER_NEXT) DEFEVENT(SPC_DISKSWAPPER_NEXT,"Next slot in Disk Swapper",AM_K,0,0,AKS_DISKSWAPPER_NEXT)
DEFEVENT(SPC_DISKSWAPPER_PREV,"Previous slot in Disk Swapper",AM_K,0,0,AKS_DISKSWAPPER_PREV) DEFEVENT(SPC_DISKSWAPPER_PREV,"Previous slot in Disk Swapper",AM_K,0,0,AKS_DISKSWAPPER_PREV)
...@@ -377,3 +375,9 @@ DEFEVENT(SPC_CDTV_FRONT_PANEL_NEXT,"CDTV Front Panel Next",AM_K,0,0,AKS_CDTV_FRO ...@@ -377,3 +375,9 @@ DEFEVENT(SPC_CDTV_FRONT_PANEL_NEXT,"CDTV Front Panel Next",AM_K,0,0,AKS_CDTV_FRO
DEFEVENT(SPC_CDTV_FRONT_PANEL_REW,"CDTV Front Panel Rewind",AM_K,0,0,AKS_CDTV_FRONT_PANEL_REW) DEFEVENT(SPC_CDTV_FRONT_PANEL_REW,"CDTV Front Panel Rewind",AM_K,0,0,AKS_CDTV_FRONT_PANEL_REW)
DEFEVENT(SPC_CDTV_FRONT_PANEL_FF,"CDTV Front Panel Fast Forward",AM_K,0,0,AKS_CDTV_FRONT_PANEL_FF) DEFEVENT(SPC_CDTV_FRONT_PANEL_FF,"CDTV Front Panel Fast Forward",AM_K,0,0,AKS_CDTV_FRONT_PANEL_FF)
DEFEVENT(SPC_GLPANLEFT,"Pan opengl texture to the left",AM_K,0,0,AKS_GLPANLEFT) /*Koko*/
DEFEVENT(SPC_GLPANRIGHT,"Pan opengl texture to the left",AM_K,0,0,AKS_GLPANRIGHT) /*Koko*/
DEFEVENT(SPC_GLPANUP,"Pan opengl texture to the left",AM_K,0,0,AKS_GLPANUP) /*Koko*/
DEFEVENT(SPC_GLPANDOWN,"Pan opengl texture to the left",AM_K,0,0,AKS_GLPANDOWN) /*Koko*/
DEFEVENT(SPC_GLPANSCANMORE,"ZoomIn opengl texture",AM_K,0,0,AKS_GLPANSCANMORE) /*Koko*/
DEFEVENT(SPC_GLPANSCANLESS,"ZoomOut opengl texture",AM_K,0,0,AKS_GLPANSCANLESS) /*Koko*/
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#define ENABLE_DEBUGGER 0 #define ENABLE_DEBUGGER 0
#define HEADERSIZE 12 #define HEADERSIZE 12
#define TRUE 1
#define FALSE 0
#include "sysconfig.h" #include "sysconfig.h"
#include "sysdeps.h" #include "sysdeps.h"
...@@ -162,6 +164,7 @@ static int inprec_pstart (uae_u8 type) ...@@ -162,6 +164,7 @@ static int inprec_pstart (uae_u8 type)
static uae_u8 *lastp; static uae_u8 *lastp;
uae_u32 hc_orig, hc2_orig; uae_u32 hc_orig, hc2_orig;
int mvp = current_maxvpos (); int mvp = current_maxvpos ();
unsigned int i;
if (!input_play || !inprec_zf) if (!input_play || !inprec_zf)
return 0; return 0;
...@@ -228,7 +231,7 @@ static int inprec_pstart (uae_u8 type) ...@@ -228,7 +231,7 @@ static int inprec_pstart (uae_u8 type)
if (cycles != cycles2 + cycleoffset) { if (cycles != cycles2 + cycleoffset) {
if (warned > 0) { if (warned > 0) {
warned--; warned--;
for (int i = 0; i < 7; i++) for (i = 0; i < 7; i++)
write_log ("%08x (%08x) ", pcs[i], pcs2[i]); write_log ("%08x (%08x) ", pcs[i], pcs2[i]);
write_log ("\n"); write_log ("\n");
} }
...@@ -316,9 +319,9 @@ static int inprec_pstr (TCHAR *dst) ...@@ -316,9 +319,9 @@ static int inprec_pstr (TCHAR *dst)
len++; len++;
} }
if (tmp[0]) { if (tmp[0]) {
TCHAR *d = utf8u (tmp); //TCHAR *d = utf8u (tmp);
_tcscpy (dst, d); _tcscpy (dst, tmp);
xfree (d); //xfree (d);
} }
return len; return len;
} }
...@@ -342,7 +345,7 @@ int inprec_open (const TCHAR *fname, const TCHAR *statefilename) ...@@ -342,7 +345,7 @@ int inprec_open (const TCHAR *fname, const TCHAR *statefilename)
inprec_close (false); inprec_close (false);
if (fname == NULL) if (fname == NULL)
inprec_zf = zfile_fopen_empty (NULL, "inp"); inprec_zf = zfile_fopen_empty (NULL, "inp", false);
else else
inprec_zf = zfile_fopen (fname, input_record ? "wb" : "rb", ZFD_NORMAL); inprec_zf = zfile_fopen (fname, input_record ? "wb" : "rb", ZFD_NORMAL);
if (inprec_zf == NULL) if (inprec_zf == NULL)
...@@ -516,14 +519,14 @@ void inprec_close (bool clear) ...@@ -516,14 +519,14 @@ void inprec_close (bool clear)
static void setwriteprotect (const TCHAR *fname, bool readonly) static void setwriteprotect (const TCHAR *fname, bool readonly)
{ {
struct _stat64 st; struct stat64 st;
int mode, oldmode; int mode, oldmode;
if (stat (fname, &st)) if (stat (fname, &st))
return; return;
oldmode = mode = st.st_mode; oldmode = mode = st.st_mode;
mode &= ~FILEFLAG_WRITE; mode &= ~0x04;
if (!readonly) if (!readonly)
mode |= FILEFLAG_WRITE; mode |= 0x04;
if (mode != oldmode) if (mode != oldmode)
chmod (fname, mode); chmod (fname, mode);
} }
...@@ -615,6 +618,8 @@ void inprec_playdebug_cpu (int mode) ...@@ -615,6 +618,8 @@ void inprec_playdebug_cpu (int mode)
{ {
#if INPUTRECORD_DEBUG > 0 #if INPUTRECORD_DEBUG > 0
int err = 0; int err = 0;
unsigned int i;
if (inprec_pstart (INPREC_DEBUG2)) { if (inprec_pstart (INPREC_DEBUG2)) {
uae_u32 pc1 = m68k_getpc (); uae_u32 pc1 = m68k_getpc ();
uae_u32 pc2 = inprec_pu32 (); uae_u32 pc2 = inprec_pu32 ();
...@@ -624,7 +629,7 @@ void inprec_playdebug_cpu (int mode) ...@@ -624,7 +629,7 @@ void inprec_playdebug_cpu (int mode)
if (warned > 0) { if (warned > 0) {
warned--; warned--;
write_log ("SYNC ERROR2 PC %08x != %08x\n", pc1, pc2); write_log ("SYNC ERROR2 PC %08x != %08x\n", pc1, pc2);
for (int i = 0; i < 15; i++) for (i = 0; i < 15; i++)
write_log ("%08x ", pcs[i]); write_log ("%08x ", pcs[i]);
write_log ("\n"); write_log ("\n");
...@@ -640,7 +645,7 @@ void inprec_playdebug_cpu (int mode) ...@@ -640,7 +645,7 @@ void inprec_playdebug_cpu (int mode)
if (warned > 0) { if (warned > 0) {
warned--; warned--;
write_log ("SYNC ERROR2 %08x != %08x\n", v1, v2); write_log ("SYNC ERROR2 %08x != %08x\n", v1, v2);
for (int i = 0; i < 15; i++) for (i = 0; i < 15; i++)
write_log ("%08x ", pcs[i]); write_log ("%08x ", pcs[i]);
write_log ("\n"); write_log ("\n");
} }
...@@ -757,7 +762,7 @@ void inprec_playtorecord (void) ...@@ -757,7 +762,7 @@ void inprec_playtorecord (void)
input_play = INPREC_PLAY_RERECORD; input_play = INPREC_PLAY_RERECORD;
input_record = INPREC_RECORD_PLAYING; input_record = INPREC_RECORD_PLAYING;
zfile_fclose (inprec_zf); zfile_fclose (inprec_zf);
inprec_zf = zfile_fopen_empty (NULL, "inp"); inprec_zf = zfile_fopen_empty (NULL, "inp", false);
zfile_fwrite (inprec_buffer, header_end2, 1, inprec_zf); zfile_fwrite (inprec_buffer, header_end2, 1, inprec_zf);
uae_u8 *p = inprec_buffer + header_end2; uae_u8 *p = inprec_buffer + header_end2;
uae_u8 *end = inprec_buffer + inprec_size; uae_u8 *end = inprec_buffer + inprec_size;
...@@ -768,7 +773,7 @@ void inprec_playtorecord (void) ...@@ -768,7 +773,7 @@ void inprec_playtorecord (void)
} }
zfile_fwrite (inprec_buffer + header_end2, inprec_size - header_end2, 1, inprec_zf); zfile_fwrite (inprec_buffer + header_end2, inprec_size - header_end2, 1, inprec_zf);
inprec_realtime (false); inprec_realtime (false);
savestate_capture_request (); // savestate_capture_request ();
} }
void inprec_setposition (int offset, int replaycounter) void inprec_setposition (int offset, int replaycounter)
...@@ -801,7 +806,7 @@ static void savelog (const TCHAR *path, const TCHAR *file) ...@@ -801,7 +806,7 @@ static void savelog (const TCHAR *path, const TCHAR *file)
_tcscpy (tmp, path); _tcscpy (tmp, path);
_tcscat (tmp, file); _tcscat (tmp, file);
_tcscat (tmp, ".log.txt"); _tcscat (tmp, ".log.txt");
struct zfile *zfd = zfile_fopen (tmp, "wb"); struct zfile *zfd = zfile_fopen (tmp, "wb", 0);
if (zfd) { if (zfd) {
int loglen; int loglen;
uae_u8 *log; uae_u8 *log;
...@@ -842,7 +847,7 @@ static int savedisk (const TCHAR *path, const TCHAR *file, uae_u8 *data, uae_u8 ...@@ -842,7 +847,7 @@ static int savedisk (const TCHAR *path, const TCHAR *file, uae_u8 *data, uae_u8
_tcscat (filename, "."); _tcscat (filename, ".");
getfilepart (filename + _tcslen (filename), MAX_DPATH, zfile_getname (zf)); getfilepart (filename + _tcslen (filename), MAX_DPATH, zfile_getname (zf));
_tcscat (tmp, filename); _tcscat (tmp, filename);
struct zfile *zfd = zfile_fopen (tmp, "wb"); struct zfile *zfd = zfile_fopen (tmp, "wb", 0);
if (zfd) { if (zfd) {
int size = zfile_size (zf); int size = zfile_size (zf);
uae_u8 *data = zfile_getdata (zf, 0, size); uae_u8 *data = zfile_getdata (zf, 0, size);
...@@ -914,7 +919,7 @@ void inprec_save (const TCHAR *filename, const TCHAR *statefilename) ...@@ -914,7 +919,7 @@ void inprec_save (const TCHAR *filename, const TCHAR *statefilename)
} }
} }
bool inprec_realtime (void) bool inprec_realtimev (void)
{ {
if (input_record != INPREC_RECORD_PLAYING || input_play != INPREC_PLAY_RERECORD) if (input_record != INPREC_RECORD_PLAYING || input_play != INPREC_PLAY_RERECORD)
return false; return false;
......
...@@ -48,11 +48,7 @@ int get_next_key (void) ...@@ -48,11 +48,7 @@ int get_next_key (void)
int record_key (int kc) int record_key (int kc)
{ {
#ifdef INPREC
if (input_recording < 0 || pause_emulation)
#else
if (pause_emulation) if (pause_emulation)
#endif
return 0; return 0;
return record_key_direct (kc); return record_key_direct (kc);
} }
......
...@@ -77,6 +77,9 @@ TCHAR warning_buffer[256]; ...@@ -77,6 +77,9 @@ TCHAR warning_buffer[256];
TCHAR optionsfile[256]; TCHAR optionsfile[256];
static uae_u32 randseed;
static int oldhcounter;
static void hr (void) static void hr (void)
{ {
write_log ("------------------------------------------------------------------------------------\n"); write_log ("------------------------------------------------------------------------------------\n");
...@@ -103,9 +106,27 @@ static void show_version_full (void) ...@@ -103,9 +106,27 @@ static void show_version_full (void)
hr (); hr ();
} }
int uaerand (void) uae_u32 uaesrand (uae_u32 seed)
{
oldhcounter = -1;
randseed = seed;
//randseed = 0x12345678;
//write_log (L"seed=%08x\n", randseed);
return randseed;
}
uae_u32 uaerand (void)
{ {
return rand (); if (oldhcounter != hsync_counter) {
srand (hsync_counter ^ randseed);
oldhcounter = hsync_counter;
}
uae_u32 r = rand ();
//write_log (L"rand=%08x\n", r);
return r;
}
uae_u32 uaerandgetseed (void)
{
return randseed;
} }
void discard_prefs (struct uae_prefs *p, int type) void discard_prefs (struct uae_prefs *p, int type)
...@@ -452,6 +473,10 @@ static int default_config; ...@@ -452,6 +473,10 @@ static int default_config;
void uae_reset (int hardreset) void uae_reset (int hardreset)
{ {
if (debug_dma) {
record_dma_reset ();
record_dma_reset ();
}
currprefs.quitstatefile[0] = changed_prefs.quitstatefile[0] = 0; currprefs.quitstatefile[0] = changed_prefs.quitstatefile[0] = 0;
if (quit_program == 0) { if (quit_program == 0) {
......
...@@ -633,6 +633,48 @@ uae_u8 *save_log (int bootlog, int *len) ...@@ -633,6 +633,48 @@ uae_u8 *save_log (int bootlog, int *len)
return dst; return dst;
} }
void stripslashes (TCHAR *p)
{
while (_tcslen (p) > 0 && (p[_tcslen (p) - 1] == '\\' || p[_tcslen (p) - 1] == '/'))
p[_tcslen (p) - 1] = 0;
}
void fixtrailing (TCHAR *p)
{
if (_tcslen(p) == 0)
return;
if (p[_tcslen(p) - 1] == '/' || p[_tcslen(p) - 1] == '\\')
return;
_tcscat(p, "\\");
}
void getpathpart (TCHAR *outpath, int size, const TCHAR *inpath)
{
_tcscpy (outpath, inpath);
TCHAR *p = _tcsrchr (outpath, '\\');
if (p)
p[0] = 0;
fixtrailing (outpath);
}
void getfilepart (TCHAR *out, int size, const TCHAR *path)
{
out[0] = 0;
const TCHAR *p = _tcsrchr (path, '\\');
if (p)
_tcscpy (out, p + 1);
else
_tcscpy (out, path);
}
void refreshtitle (void)
{
/*
if (isfullscreen () == 0)
setmaintitle (hMainWnd);
*/
}
// win32gui.c // win32gui.c
#define MAX_ROM_PATHS 10 #define MAX_ROM_PATHS 10
int scan_roms (int show) int scan_roms (int show)
...@@ -802,6 +844,14 @@ void fetch_ripperpath (TCHAR *out, int size) ...@@ -802,6 +844,14 @@ void fetch_ripperpath (TCHAR *out, int size)
{ {
fetch_path ("RipperPath", out, size); fetch_path ("RipperPath", out, size);
} }
void fetch_statefilepath (TCHAR *out, int size)
{
fetch_path ("StatefilePath", out, size);
}
void fetch_inputfilepath (TCHAR *out, int size)
{
fetch_path ("InputPath", out, size);
}
void fetch_datapath (TCHAR *out, int size) void fetch_datapath (TCHAR *out, int size)
{ {
fetch_path (NULL, out, size); fetch_path (NULL, out, size);
...@@ -854,7 +904,15 @@ void debugger_change (int mode) ...@@ -854,7 +904,15 @@ void debugger_change (int mode)
// unicode.c // unicode.c
char *ua (const TCHAR *s) char *ua (const TCHAR *s)
{ {
return s; return s;
}
char *uutf8 (const char *s)
{
return s;
}
char *utf8u (const char *s)
{
return s;
} }
// fsdb_mywin32.c // fsdb_mywin32.c
...@@ -1146,7 +1204,7 @@ void my_kbd_handler (int keyboard, int scancode, int newstate) ...@@ -1146,7 +1204,7 @@ void my_kbd_handler (int keyboard, int scancode, int newstate)
if (specialpressed ()) if (specialpressed ())
return; return;
write_log ("kbd = %d, scancode = %d, state = %d\n", keyboard, scancode, newstate ); // write_log ("kbd = %d, scancode = %d, state = %d\n", keyboard, scancode, newstate );
inputdevice_translatekeycode (keyboard, scancode, newstate); inputdevice_translatekeycode (keyboard, scancode, newstate);
} }
......
...@@ -828,10 +828,8 @@ bool set_cpu_tracer (bool state) ...@@ -828,10 +828,8 @@ bool set_cpu_tracer (bool state)
if (cpu_tracer < 0) if (cpu_tracer < 0)
return false; return false;
int old = cpu_tracer; int old = cpu_tracer;
#ifdef INPREC
if (input_record) if (input_record)
state = true; state = true;
#endif
cpu_tracer = 0; cpu_tracer = 0;
if (state && can_cpu_tracer ()) { if (state && can_cpu_tracer ()) {
cpu_tracer = 1; cpu_tracer = 1;
...@@ -2318,14 +2316,12 @@ STATIC_INLINE void do_interrupt (int nr) ...@@ -2318,14 +2316,12 @@ STATIC_INLINE void do_interrupt (int nr)
if (debug_dma) if (debug_dma)
record_dma_event (DMA_EVENT_CPUIRQ, current_hpos (), vpos); record_dma_event (DMA_EVENT_CPUIRQ, current_hpos (), vpos);
#endif #endif
#ifdef INPREC
if (inputrecord_debug & 2) { if (inputrecord_debug & 2) {
if (input_record > 0) if (input_record > 0)
inprec_recorddebug_cpu (2); inprec_recorddebug_cpu (2);
else if (input_play > 0) else if (input_play > 0)
inprec_playdebug_cpu (2); inprec_playdebug_cpu (2);
} }
#endif
regs.stopped = 0; regs.stopped = 0;
unset_special (SPCFLAG_STOP); unset_special (SPCFLAG_STOP);
...@@ -3509,14 +3505,12 @@ static void m68k_run_1_ce (void) ...@@ -3509,14 +3505,12 @@ static void m68k_run_1_ce (void)
cputrace.cyclecounter = cputrace.cyclecounter_pre = cputrace.cyclecounter_post = 0; cputrace.cyclecounter = cputrace.cyclecounter_pre = cputrace.cyclecounter_post = 0;
cputrace.readcounter = cputrace.writecounter = 0; cputrace.readcounter = cputrace.writecounter = 0;
} }
#ifdef INPREC
if (inputrecord_debug & 4) { if (inputrecord_debug & 4) {
if (input_record > 0) if (input_record > 0)
inprec_recorddebug_cpu (1); inprec_recorddebug_cpu (1);
else if (input_play > 0) else if (input_play > 0)
inprec_playdebug_cpu (1); inprec_playdebug_cpu (1);
} }
#endif
(*cpufunctbl[opcode])(opcode); (*cpufunctbl[opcode])(opcode);
if (cpu_tracer) { if (cpu_tracer) {
...@@ -3837,14 +3831,12 @@ static void m68k_run_2ce (void) ...@@ -3837,14 +3831,12 @@ static void m68k_run_2ce (void)
cputrace.cyclecounter = cputrace.cyclecounter_pre = cputrace.cyclecounter_post = 0; cputrace.cyclecounter = cputrace.cyclecounter_pre = cputrace.cyclecounter_post = 0;
cputrace.readcounter = cputrace.writecounter = 0; cputrace.readcounter = cputrace.writecounter = 0;
} }
#ifdef INPREC
if (inputrecord_debug & 4) { if (inputrecord_debug & 4) {
if (input_record > 0) if (input_record > 0)
inprec_recorddebug_cpu (1); inprec_recorddebug_cpu (1);
else if (input_play > 0) else if (input_play > 0)
inprec_playdebug_cpu (1); inprec_playdebug_cpu (1);
} }
#endif
docodece020 (opcode); docodece020 (opcode);
...@@ -3989,7 +3981,6 @@ void m68k_go (int may_quit) ...@@ -3989,7 +3981,6 @@ void m68k_go (int may_quit)
cputrace.state = -1; cputrace.state = -1;
#ifdef INPREC
if (currprefs.inprecfile[0] && input_play) { if (currprefs.inprecfile[0] && input_play) {
inprec_open (currprefs.inprecfile, NULL); inprec_open (currprefs.inprecfile, NULL);
changed_prefs.inprecfile[0] = currprefs.inprecfile[0] = 0; changed_prefs.inprecfile[0] = currprefs.inprecfile[0] = 0;
...@@ -3997,7 +3988,6 @@ void m68k_go (int may_quit) ...@@ -3997,7 +3988,6 @@ void m68k_go (int may_quit)
} }
if (input_play || input_record) if (input_play || input_record)
inprec_startup (); inprec_startup ();
#endif
if (quit_program > 0) { if (quit_program > 0) {
int hardreset = (quit_program == 3 ? 1 : 0) | hardboot; int hardreset = (quit_program == 3 ? 1 : 0) | hardboot;
...@@ -4045,12 +4035,9 @@ void m68k_go (int may_quit) ...@@ -4045,12 +4035,9 @@ void m68k_go (int may_quit)
if (!restored || hsync_counter == 0) if (!restored || hsync_counter == 0)
savestate_check (); savestate_check ();
#ifdef INPREC
if (input_record == INPREC_RECORD_START) if (input_record == INPREC_RECORD_START)
input_record = INPREC_RECORD_NORMAL; input_record = INPREC_RECORD_NORMAL;
#endif
} else { } else {
#ifdef INPREC
if (input_record == INPREC_RECORD_START) { if (input_record == INPREC_RECORD_START) {
input_record = INPREC_RECORD_NORMAL; input_record = INPREC_RECORD_NORMAL;
savestate_init (); savestate_init ();
...@@ -4058,13 +4045,10 @@ void m68k_go (int may_quit) ...@@ -4058,13 +4045,10 @@ void m68k_go (int may_quit)
vsync_counter = 0; vsync_counter = 0;
savestate_check (); savestate_check ();
} }
#endif
} }
#ifdef INPREC
if (changed_prefs.inprecfile[0] && input_record) if (changed_prefs.inprecfile[0] && input_record)
inprec_prepare_record (savestate_fname[0] ? savestate_fname : NULL); inprec_prepare_record (savestate_fname[0] ? savestate_fname : NULL);
#endif
set_cpu_tracer (false); set_cpu_tracer (false);
#ifdef DEBUGGER #ifdef DEBUGGER
......
...@@ -708,9 +708,7 @@ void savestate_initsave (const TCHAR *filename, int mode, int nodialogs, bool sa ...@@ -708,9 +708,7 @@ void savestate_initsave (const TCHAR *filename, int mode, int nodialogs, bool sa
new_blitter = false; new_blitter = false;
if (save) { if (save) {
savestate_free (); savestate_free ();
#ifdef INPREC
inprec_close (true); inprec_close (true);
#endif
} }
} }
...@@ -1060,10 +1058,8 @@ void savestate_quick (int slot, int save) ...@@ -1060,10 +1058,8 @@ void savestate_quick (int slot, int save)
bool savestate_check (void) bool savestate_check (void)
{ {
if (vpos == 0 && !savestate_state) { if (vpos == 0 && !savestate_state) {
#ifdef INPREC
if (hsync_counter == 0 && input_play == INPREC_PLAY_NORMAL) if (hsync_counter == 0 && input_play == INPREC_PLAY_NORMAL)
savestate_memorysave (); savestate_memorysave ();
#endif
savestate_capture (0); savestate_capture (0);
} }
if (savestate_state == STATE_DORESTORE) { if (savestate_state == STATE_DORESTORE) {
...@@ -1239,9 +1235,7 @@ void savestate_rewind (void) ...@@ -1239,9 +1235,7 @@ void savestate_rewind (void)
uae_reset (0); uae_reset (0);
return; return;
} }
#ifdef INPREC
inprec_setposition (st->inprecoffset, pos); inprec_setposition (st->inprecoffset, pos);
#endif
write_log ("state %d restored. (%010d/%03d)\n", pos, hsync_counter, vsync_counter); write_log ("state %d restored. (%010d/%03d)\n", pos, hsync_counter, vsync_counter);
if (rewind) { if (rewind) {
replaycounter--; replaycounter--;
...@@ -1285,7 +1279,6 @@ void savestate_capture (int force) ...@@ -1285,7 +1279,6 @@ void savestate_capture (int force)
#endif #endif
if (!staterecords) if (!staterecords)
return; return;
#ifdef INPREC
if (!input_record) if (!input_record)
return; return;
if (currprefs.statecapturerate && hsync_counter == 0 && input_record == INPREC_RECORD_START && savestate_first_capture > 0) { if (currprefs.statecapturerate && hsync_counter == 0 && input_record == INPREC_RECORD_START && savestate_first_capture > 0) {
...@@ -1296,7 +1289,6 @@ void savestate_capture (int force) ...@@ -1296,7 +1289,6 @@ void savestate_capture (int force)
force = true; force = true;
firstcapture = false; firstcapture = false;
} }
#endif
if (!force) { if (!force) {
if (currprefs.statecapturerate <= 0) if (currprefs.statecapturerate <= 0)
return; return;
...@@ -1598,9 +1590,7 @@ retry2: ...@@ -1598,9 +1590,7 @@ retry2:
save_u32_func (&p, tlen); save_u32_func (&p, tlen);
st->end = p; st->end = p;
st->inuse = 1; st->inuse = 1;
#ifdef INPREC
st->inprecoffset = inprec_getposition (); st->inprecoffset = inprec_getposition ();
#endif
replaycounter++; replaycounter++;
if (replaycounter >= staterecords_max) if (replaycounter >= staterecords_max)
...@@ -1618,19 +1608,13 @@ retry2: ...@@ -1618,19 +1608,13 @@ retry2:
if (firstcapture) { if (firstcapture) {
savestate_memorysave (); savestate_memorysave ();
#ifdef INPREC
input_record++; input_record++;
#endif
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
bool wp = true; bool wp = true;
DISK_validate_filename (currprefs.floppyslots[i].df, false, &wp, NULL, NULL); DISK_validate_filename (currprefs.floppyslots[i].df, false, &wp, NULL, NULL);
#ifdef INPREC
inprec_recorddiskchange (i, currprefs.floppyslots[i].df, wp); inprec_recorddiskchange (i, currprefs.floppyslots[i].df, wp);
#endif
} }
#ifdef INPREC
input_record--; input_record--;
#endif
} }
...@@ -1660,7 +1644,6 @@ void savestate_init (void) ...@@ -1660,7 +1644,6 @@ void savestate_init (void)
staterecords_max = currprefs.statecapturebuffersize; staterecords_max = currprefs.statecapturebuffersize;
staterecords = xcalloc (struct staterecord*, staterecords_max); staterecords = xcalloc (struct staterecord*, staterecords_max);
statefile_alloc = STATEFILE_ALLOC_SIZE; statefile_alloc = STATEFILE_ALLOC_SIZE;
#ifdef INPREC
if (input_record && savestate_state != STATE_DORESTORE) { if (input_record && savestate_state != STATE_DORESTORE) {
zfile_fclose (staterecord_statefile); zfile_fclose (staterecord_statefile);
staterecord_statefile = NULL; staterecord_statefile = NULL;
...@@ -1668,7 +1651,6 @@ void savestate_init (void) ...@@ -1668,7 +1651,6 @@ void savestate_init (void)
inprec_open (NULL, NULL); inprec_open (NULL, NULL);
savestate_first_capture = 1; savestate_first_capture = 1;
} }
#endif
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#define ZLIB_WINAPI #define ZLIB_WINAPI
#define RECURSIVE_ARCHIVES 1 #define RECURSIVE_ARCHIVES 1
//#define ZFILE_DEBUG //#define ZFILE_DEBUG
#define FSDB_DIR_SEPARATOR_S "\\"
#include "sysconfig.h" #include "sysconfig.h"
#include "sysdeps.h" #include "sysdeps.h"
...@@ -1839,9 +1840,11 @@ struct zfile *zfile_fopen_empty (struct zfile *prev, const TCHAR *name, uae_u64 ...@@ -1839,9 +1840,11 @@ struct zfile *zfile_fopen_empty (struct zfile *prev, const TCHAR *name, uae_u64
} }
l->size = size; l->size = size;
l->datasize = size; l->datasize = size;
l->allocsize = size;
} else { } else {
l->data = xcalloc (uae_u8, 1); l->data = xcalloc (uae_u8, 1000);
l->size = 0; l->size = 0;
l->allocsize = 1000;
} }
return l; return l;
} }
...@@ -1885,6 +1888,24 @@ struct zfile *zfile_fopen_data (const TCHAR *name, uae_u64 size, uae_u8 *data) ...@@ -1885,6 +1888,24 @@ struct zfile *zfile_fopen_data (const TCHAR *name, uae_u64 size, uae_u8 *data)
return l; return l;
} }
int zfile_truncate (struct zfile *z, uae_s64 size)
{
if (z->data) {
if (z->size > size) {
z->size = size;
if (z->datasize > z->size)
z->datasize = z->size;
if (z->seek > z->size)
z->seek = z->size;
return 1;
}
return 0;
} else {
/* !!! */
return 0;
}
}
uae_s64 zfile_size (struct zfile *z) uae_s64 zfile_size (struct zfile *z)
{ {
return z->size; return z->size;
...@@ -1983,12 +2004,25 @@ size_t zfile_fwrite (void *b, size_t l1, size_t l2, struct zfile *z) ...@@ -1983,12 +2004,25 @@ size_t zfile_fwrite (void *b, size_t l1, size_t l2, struct zfile *z)
return 0; return 0;
if (z->data) { if (z->data) {
int off = z->seek + l1 * l2; int off = z->seek + l1 * l2;
if (off > z->size) { if (z->allocsize == 0) {
z->data = xrealloc (uae_u8, z->data, off); write_log ("zfile_fwrite(data,%s) but allocsize=0!\n", z->name);
return 0;
}
if (off > z->allocsize) {
if (z->allocsize < off)
z->allocsize = off;
z->allocsize += z->size / 2;
if (z->allocsize < 10000)
z->allocsize = 10000;
z->data = xrealloc (uae_u8, z->data, z->allocsize);
z->datasize = z->size = off; z->datasize = z->size = off;
} }
memcpy (z->data + z->seek, b, l1 * l2); memcpy (z->data + z->seek, b, l1 * l2);
z->seek += l1 * l2; z->seek += l1 * l2;
if (z->seek > z->size)
z->size = z->seek;
if (z->size > z->datasize)
z->datasize = z->size;
return l2; return l2;
} }
return fwrite (b, l1, l2, z->f); return fwrite (b, l1, l2, z->f);
...@@ -2089,7 +2123,7 @@ int zfile_ferror (struct zfile *z) ...@@ -2089,7 +2123,7 @@ int zfile_ferror (struct zfile *z)
uae_u8 *zfile_getdata (struct zfile *z, uae_s64 offset, int len) uae_u8 *zfile_getdata (struct zfile *z, uae_s64 offset, int len)
{ {
uae_s64 pos; uae_s64 pos = zfile_ftell (z);
uae_u8 *b; uae_u8 *b;
if (len < 0) { if (len < 0) {
zfile_fseek (z, 0, SEEK_END); zfile_fseek (z, 0, SEEK_END);
...@@ -2097,7 +2131,6 @@ uae_u8 *zfile_getdata (struct zfile *z, uae_s64 offset, int len) ...@@ -2097,7 +2131,6 @@ uae_u8 *zfile_getdata (struct zfile *z, uae_s64 offset, int len)
zfile_fseek (z, 0, SEEK_SET); zfile_fseek (z, 0, SEEK_SET);
} }
b = xmalloc (uae_u8, len); b = xmalloc (uae_u8, len);
pos = zfile_ftell (z);
zfile_fseek (z, offset, SEEK_SET); zfile_fseek (z, offset, SEEK_SET);
zfile_fread (b, len, 1, z); zfile_fread (b, len, 1, z);
zfile_fseek (z, pos, SEEK_SET); zfile_fseek (z, pos, SEEK_SET);
...@@ -2206,7 +2239,6 @@ static struct zvolume *zvolume_list; ...@@ -2206,7 +2239,6 @@ static struct zvolume *zvolume_list;
static void recurparent (TCHAR *newpath, struct znode *zn, int recurse) static void recurparent (TCHAR *newpath, struct znode *zn, int recurse)
{ {
TCHAR tmp[2] = { FSDB_DIR_SEPARATOR, 0 };
if (zn->parent && (&zn->volume->root != zn->parent || zn->volume->parentz == NULL)) { if (zn->parent && (&zn->volume->root != zn->parent || zn->volume->parentz == NULL)) {
if (&zn->volume->root == zn->parent && zn->volume->parentz == NULL && !_tcscmp (zn->name, zn->parent->name)) if (&zn->volume->root == zn->parent && zn->volume->parentz == NULL && !_tcscmp (zn->name, zn->parent->name))
goto end; goto end;
...@@ -2218,7 +2250,7 @@ static void recurparent (TCHAR *newpath, struct znode *zn, int recurse) ...@@ -2218,7 +2250,7 @@ static void recurparent (TCHAR *newpath, struct znode *zn, int recurse)
} }
end: end:
if (newpath[0]) if (newpath[0])
_tcscat (newpath, tmp); _tcscat (newpath, FSDB_DIR_SEPARATOR_S);
_tcscat (newpath, zn->name); _tcscat (newpath, zn->name);
} }
...@@ -2228,7 +2260,6 @@ static struct znode *znode_alloc (struct znode *parent, const TCHAR *name) ...@@ -2228,7 +2260,6 @@ static struct znode *znode_alloc (struct znode *parent, const TCHAR *name)
TCHAR tmpname[MAX_DPATH]; TCHAR tmpname[MAX_DPATH];
struct znode *zn = xcalloc (struct znode, 1); struct znode *zn = xcalloc (struct znode, 1);
struct znode *zn2; struct znode *zn2;
TCHAR sep[] = { FSDB_DIR_SEPARATOR, 0 };
_tcscpy (tmpname, name); _tcscpy (tmpname, name);
zn2 = parent->child; zn2 = parent->child;
...@@ -2255,7 +2286,7 @@ static struct znode *znode_alloc (struct znode *parent, const TCHAR *name) ...@@ -2255,7 +2286,7 @@ static struct znode *znode_alloc (struct znode *parent, const TCHAR *name)
fullpath[0] = 0; fullpath[0] = 0;
recurparent (fullpath, parent, 0); recurparent (fullpath, parent, 0);
_tcscat (fullpath, sep); _tcscat (fullpath, FSDB_DIR_SEPARATOR_S);
_tcscat (fullpath, tmpname); _tcscat (fullpath, tmpname);
#ifdef ZFILE_DEBUG #ifdef ZFILE_DEBUG
write_log ("znode_alloc vol='%s' parent='%s' name='%s'\n", parent->volume->root.name, parent->name, name); write_log ("znode_alloc vol='%s' parent='%s' name='%s'\n", parent->volume->root.name, parent->name, name);
...@@ -2657,11 +2688,10 @@ struct znode *znode_adddir (struct znode *parent, const TCHAR *name, struct zarc ...@@ -2657,11 +2688,10 @@ struct znode *znode_adddir (struct znode *parent, const TCHAR *name, struct zarc
{ {
struct znode *zn; struct znode *zn;
TCHAR path[MAX_DPATH]; TCHAR path[MAX_DPATH];
TCHAR sep[] = { FSDB_DIR_SEPARATOR, 0 };
path[0] = 0; path[0] = 0;
//recurparent (path, parent, 0); recurparent (path, parent, 0);
_tcscat (path, sep); _tcscat (path, FSDB_DIR_SEPARATOR_S);
_tcscat (path, name); _tcscat (path, name);
//zn = get_znode (parent->volume, path, 0); //zn = get_znode (parent->volume, path, 0);
if (zn) if (zn)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment