#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
+#include "../libsdl/print.h"
#include "../libcpu/m68k.h"
+#include "../libcpu/execute.h"
#include "mercenary.h"
#define INITIAL_STACK 0x7fffa
#define RESET_VECTOR 0x59484
-const uint32_t mercenary_stop_at[] = {
- 0x59a4e, /* done with rendering, waiting for VBL */
- 0x54c26, /* after pressing 'HELP' key before showing menu line on benson */
- 0x55438, /* waiting for menu command */
- 0x54c2e, /* after pressing 'HELP' key while showing menu line on benson */
- 0x55446, /* after pressing 'RETURN' while game waits for other key to resume */
- 0x51620, /* after dying, waiting for VBL to fade out palette */
- 0x0 /* end */
-}; /* break points for rendering and continue with processing loop */
+
+/* interrupt CPU execution at special break points and tell emulation what to do */
+const struct cpu_stop mercenary_stop_at[] = {
+ { 0x59a4e, STOP_AT_WAIT_VBL }, /* done with rendering, waiting for VBL */
+ { 0x54c26, STOP_AT_WAIT_VBL }, /* after pressing 'HELP' key before showing menu line on benson */
+ { 0x55438, STOP_AT_WAIT_VBL }, /* waiting for menu command */
+ { 0x54c2e, STOP_AT_WAIT_VBL }, /* after pressing 'HELP' key while showing menu line on benson */
+ { 0x55446, STOP_AT_WAIT_VBL }, /* after pressing 'RETURN' while game waits for other key to resume */
+ { 0x51620, STOP_AT_WAIT_VBL }, /* after dying, waiting for VBL to fade out palette */
+ { 0x0, STOP_AT_END }, /* end */
+};
extern const uint32_t mercenary2_hex[];
extern int mercenary2_hex_size;
/* reset vector */
m68k_write_memory_32(0x00004, RESET_VECTOR);
-#if 0
- /* patch away the function call that is outside chip memory
- * is this a copy protection????
- */
- m68k_write_memory_16(0x5a17c, 0x4e71); /* nop */
- m68k_write_memory_16(0x5a17e, 0x4e71); /* nop */
- m68k_write_memory_16(0x5a180, 0x4e71); /* nop */
-#endif
-
/* remove wait for VBL */
m68k_write_memory_16(0x59a54, 0x4e71); /* nop */
/* reduce loop that waits for disk stepper to move */
if (m68k_read_memory_32(0x55398) != 0x0000091b) {
- fprintf(stderr, "expecting loop counter of 0x0000091b here, please fix!\n");
+ print_error("expecting loop counter of 0x0000091b here, please fix!\n");
exit(0);
}
m68k_write_memory_32(0x55398, 1);
/* reduce loop that waits for disk side change */
if (m68k_read_memory_32(0x54ffc) != 0x00000d02) {
- fprintf(stderr, "expecting loop counter of 0x00000d02 here, please fix!\n");
+ print_error("expecting loop counter of 0x00000d02 here, please fix!\n");
exit(0);
}
m68k_write_memory_32(0x54ffc, 1);
return m68k_read_memory_32(0x007c14);
}
+const char *mercenary_gamesavesuffix = ".m2save";
+