#define IOSIZE 0x1000 /* bytes in io space */
#define MEMORY_SIZE 0x80000
static uint8_t *memory = NULL;
+static uint8_t *stop_event = NULL;
static uint8_t *image = NULL;
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 200
/* execute until the rendered image is ready (wait for VBL) */
cycle_count = 0;
do {
- cycle_count += execute_cpu(0, mercenary_stop_at, &event);
+ cycle_count += execute_cpu(0, &event);
/* handle special events */
if (event != STOP_AT_WAIT_VBL)
special_event(event);
last_time = current_time - 1000 * SOUND_CHUNKS / IRQ_RATE;
}
while (diff > 1000 / IRQ_RATE) {
- execute_cpu(3, NULL, NULL);
- execute_cpu(4, NULL, NULL);
+ execute_cpu(3, NULL);
+ execute_cpu(4, NULL);
had_first_irq = 1;
/* render benson without game view
* because we only got benson refreshed during VBL IRQ
print_error("Failed to allocate cpu's memory\n");
goto done;
}
+ stop_event = calloc(MEMORY_SIZE, 1);
+ if (!stop_event) {
+ print_error("Failed to allocate cpu's stop_event memory\n");
+ goto done;
+ }
chipreg = calloc(IOSIZE, 1);
if (!chipreg) {
print_error("Failed to allocate chip register\n");
}
/* init cpu code */
- execute_init(MEMORY_SIZE, memory, chipreg, io_read, io_write);
+ execute_init(MEMORY_SIZE, memory, stop_event, chipreg, io_read, io_write, mercenary_stop_at);
/* init disk emulation */
disk_init(disk_read, disk_write);
if (chipreg)
free(chipreg);
+ if (stop_event)
+ free(stop_event);
if (memory)
free(memory);
if (sound_buffer)