return 0;
}
+static void special_event(int event)
+{
+}
+
static void main_loop(void)
{
int had_first_irq = 0;
static uint32_t current_time, last_time = 0, diff;
int i, rc;
int space, length;
- int cycle_count;
+ int cycle_count, event;
double render_delay = 0.0;
uint32_t palette_address;
uint16_t palette[16];
/* STEP 1: let the CPU render/process the game */
/* don't render if we still delay */
if (!render_delay) {
- /* execute until the rendered image is ready */
- cycle_count = execute_cpu(0, mercenary_stop_at);
+ /* execute until the rendered image is ready (wait for VBL) */
+ cycle_count = 0;
+ do {
+ cycle_count += execute_cpu(0, mercenary_stop_at, &event);
+ /* handle special events */
+ if (event != STOP_AT_WAIT_VBL)
+ special_event(event);
+ } while (event != STOP_AT_WAIT_VBL);
/* copy palette */
palette_address = mercenary_palette();
for (i = 0; i < 16; i++)
last_time = current_time - 1000 * SOUND_CHUNKS / IRQ_RATE;
}
while (diff > 1000 / IRQ_RATE) {
- execute_cpu(3, NULL);
- execute_cpu(4, NULL);
+ execute_cpu(3, NULL, NULL);
+ execute_cpu(4, NULL, NULL);
had_first_irq = 1;
/* render benson without game view
* because we only got benson refreshed during VBL IRQ