}
int action_replay_flag = ACTION_REPLAY_INACTIVE;
+static int ar_state1 = -1, ar_state2 = -1, ar_hide;
static int ar_rom_file_size;
/* Use this for relocating AR? */
static void hide_cart (int hide)
{
+ ar_hide = hide;
#ifdef ACTION_REPLAY_HIDE_CARTRIDGE
if(hide) {
action_replay_unmap_banks ();
} else {
if (action_replay_flag == ACTION_REPLAY_INACTIVE)
return;
-
- if (isrestore ()) {
- if (m68k_getpc () >= arrom_start && m68k_getpc () <= arrom_start + arrom_size) {
- action_replay_flag = ACTION_REPLAY_ACTIVE;
- hide_cart (0);
- } else {
- action_replay_flag = ACTION_REPLAY_IDLE;
- hide_cart (1);
- }
+ if (isrestore ())
return;
- }
if (armodel == 1) {
/* We need to mark it as active here, because the kickstart rom jumps directly into it. */
action_replay_flag = ACTION_REPLAY_ACTIVE;
write_log_debug (_T("Action Replay State:(%s)\nHrtmon State:(%s)\n"),
state[action_replay_flag + 3], state[hrtmon_flag + 3]);
- if (armemory_rom && armodel == 1) {
- if (is_ar_pc_in_ram() || is_ar_pc_in_rom() || action_replay_flag == ACTION_REPLAY_WAIT_PC) {
- write_log (_T("Can't Unload Action Replay 1. It is Active.\n"));
- return 0;
- }
- } else {
- if (action_replay_flag != ACTION_REPLAY_IDLE && action_replay_flag != ACTION_REPLAY_INACTIVE) {
- write_log (_T("Can't Unload Action Replay. It is Active.\n"));
- return 0; /* Don't unload it whilst it's active, or it will crash the amiga if not the emulator */
- }
- if (hrtmon_flag != ACTION_REPLAY_IDLE && hrtmon_flag != ACTION_REPLAY_INACTIVE) {
- write_log (_T("Can't Unload Hrtmon. It is Active.\n"));
- return 0; /* Don't unload it whilst it's active, or it will crash the amiga if not the emulator */
- }
- }
-
unset_special (SPCFLAG_ACTION_REPLAY); /* This shouldn't be necessary here, but just in case. */
action_replay_flag = ACTION_REPLAY_INACTIVE;
hrtmon_flag = ACTION_REPLAY_INACTIVE;
dstbak = dst = dstptr;
else
dstbak = dst = xmalloc (uae_u8, arram_size + sizeof ar_custom + sizeof ar_ciaa + sizeof ar_ciab + 1024);
- save_u8 (0);
+ save_u8 (1 | ((regs.spcflags & SPCFLAG_ACTION_REPLAY) ? 2 : 0) | (ar_hide ? 4 : 0));
save_u8 (armodel);
save_u32 (get_crc32 (armemory_rom + 4, arrom_size - 4));
save_string (currprefs.cartfile);
save_u32 (sizeof ar_ciab);
memcpy (dst, ar_ciab, sizeof ar_ciab);
dst += sizeof ar_ciab;
+ save_u8(action_replay_flag);
+ save_u8(armode_read);
+ save_u8(armode_write);
*len = dst - dstbak;
return dstbak;
}
uae_u8 *restore_action_replay (uae_u8 *src)
{
TCHAR *s;
+ uae_u32 flags;
action_replay_unload (1);
- restore_u8 ();
+ flags = restore_u8 ();
armodel = restore_u8 ();
if (!armodel)
return src;
src += sizeof ar_ciaa;
restore_u32 ();
src += sizeof ar_ciab;
- action_replay_flag = ACTION_REPLAY_IDLE;
- if (is_ar_pc_in_rom ())
- action_replay_flag = ACTION_REPLAY_ACTIVE;
+ armode_read = armode_write = 0;
+ ar_state1 = -1;
+ ar_state2 = -1;
+ if (flags & 1) {
+ ar_state1 = restore_u8();
+ ar_state2 = 0;
+ armode_read = restore_u8();
+ armode_write = restore_u8();
+ if (flags & 2)
+ ar_state2 |= 1;
+ if (flags & 4)
+ ar_state2 |= 2;
+ } else {
+ action_replay_flag = ACTION_REPLAY_IDLE;
+ if (is_ar_pc_in_rom ())
+ action_replay_flag = ACTION_REPLAY_ACTIVE;
+ }
return src;
}
+void restore_ar_finish(void)
+{
+ if (ar_state2 < 0) {
+ if (m68k_getpc () >= arrom_start && m68k_getpc () <= arrom_start + arrom_size) {
+ action_replay_flag = ACTION_REPLAY_ACTIVE;
+ hide_cart (0);
+ } else {
+ action_replay_flag = ACTION_REPLAY_IDLE;
+ hide_cart (1);
+ }
+ } else {
+ action_replay_flag = ar_state1;
+ if (ar_state2 & 1)
+ set_special (SPCFLAG_ACTION_REPLAY);
+ hide_cart((ar_state2 & 2) ? 1 : 0);
+ }
+}
#define NPSIZE 65536