From af7309b98d8c8e55caba1d7a3b17a4c3d504f735 Mon Sep 17 00:00:00 2001
From: Lior Halphon <LIJI32@gmail.com>
Date: Sat, 2 Apr 2016 19:15:07 +0300
Subject: [PATCH] Moved the call to display_run to advance_cycle.

This fixes games with delicate timings such as X/Ekkusu, that expect STAT to change *during* an opcode.
---
 Core/gb.c     | 1 -
 Core/timing.c | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/Core/gb.c b/Core/gb.c
index 9fbfffd..840c13e 100644
--- a/Core/gb.c
+++ b/Core/gb.c
@@ -404,7 +404,6 @@ void gb_run(GB_gameboy_t *gb)
     update_joyp(gb);
     debugger_run(gb);
     cpu_run(gb);
-    display_run(gb);
 }
 
 void gb_set_pixels_output(GB_gameboy_t *gb, uint32_t *output)
diff --git a/Core/timing.c b/Core/timing.c
index 3e797bf..b80ba77 100644
--- a/Core/timing.c
+++ b/Core/timing.c
@@ -1,6 +1,7 @@
 #include "gb.h"
 #include "timing.h"
 #include "memory.h"
+#include "display.h"
 
 void advance_cycles(GB_gameboy_t *gb, unsigned char cycles)
 {
@@ -25,6 +26,7 @@ void advance_cycles(GB_gameboy_t *gb, unsigned char cycles)
     hdma_run(gb);
     timers_run(gb);
     apu_run(gb);
+    display_run(gb);
 }
 
 void timers_run(GB_gameboy_t *gb)