#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 0x5a16c
// #define RESET_VECTOR 0x5a1a4 /* strange reset vector that causes the player to fly around */
-const uint32_t mercenary_stop_at[] = {
- 0x5a826, /* done with rendering, waiting for VBL */
- 0x55d8c, /* after pressing 'HELP' key before showing menu line on benson */
- 0x56398, /* waiting for menu command */
- 0x55d94, /* after pressing 'HELP' key while showing menu line on benson */
- 0x563a6, /* after pressing 'RETURN' while game waits for other key to resume */
- 0x52946, /* 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[] = {
+ { 0x5a826, STOP_AT_WAIT_VBL }, /* done with rendering, waiting for VBL */
+ { 0x55d8c, STOP_AT_WAIT_VBL }, /* after pressing 'HELP' key before showing menu line on benson */
+ { 0x56398, STOP_AT_WAIT_VBL }, /* waiting for menu command */
+ { 0x55d94, STOP_AT_WAIT_VBL }, /* after pressing 'HELP' key while showing menu line on benson */
+ { 0x563a6, STOP_AT_WAIT_VBL }, /* after pressing 'RETURN' while game waits for other key to resume */
+ { 0x52946, STOP_AT_WAIT_VBL }, /* after dying, waiting for VBL to fade out palette */
+ { 0x0, STOP_AT_END }, /* end */
+};
extern const uint32_t mercenary3_hex[];
extern int mercenary3_hex_size;
/* reduce loop that waits for disk stepper to move */
if (m68k_read_memory_32(0x562f8) != 0x000091b0) {
- fprintf(stderr, "expecting loop counter of 0x000091b0 here, please fix!\n");
+ print_error("expecting loop counter of 0x000091b0 here, please fix!\n");
exit(0);
}
m68k_write_memory_32(0x562f8, 1);
/* reduce loop that waits for disk side change */
if (m68k_read_memory_32(0x55f5c) != 0x0000d020) {
- fprintf(stderr, "expecting loop counter of 0x0000d020 here, please fix!\n");
+ print_error("expecting loop counter of 0x0000d020 here, please fix!\n");
exit(0);
}
m68k_write_memory_32(0x55f5c, 1);
return m68k_read_memory_32(0x0072b0);
}
+const char *mercenary_gamesavesuffix = ".m3save";
+