From 7aeb53926689ff132a96b62525ddd766161994fd Mon Sep 17 00:00:00 2001 From: profi200 Date: Sun, 3 May 2020 22:43:19 +0200 Subject: [PATCH] Added variable framerate code to sync GBA mode and LCD framerate. --- source/arm11/hardware/lgyfb.c | 8 ++++++++ source/arm11/main.c | 31 ------------------------------- 2 files changed, 8 insertions(+), 31 deletions(-) diff --git a/source/arm11/hardware/lgyfb.c b/source/arm11/hardware/lgyfb.c index 886365e..eeb386d 100644 --- a/source/arm11/hardware/lgyfb.c +++ b/source/arm11/hardware/lgyfb.c @@ -34,6 +34,14 @@ static void lgyFbDmaIrqHandler(UNUSED u32 intSource) { DMA330_ackIrq(0); DMA330_run(0, program); + + // If the top LCD ran >=20% ahead of LgyFb, slow it down. + // Check V-position. + u32 vtotal; + if(*((vu32*)0x10400454) > 83) vtotal = 415; + else vtotal = 413; + *((vu32*)0x10400424) = vtotal; + atomic_store_explicit(&flag, true, memory_order_relaxed); } diff --git a/source/arm11/main.c b/source/arm11/main.c index a82ac81..145530b 100644 --- a/source/arm11/main.c +++ b/source/arm11/main.c @@ -77,34 +77,3 @@ int main(void) return 0; } - - -/*u32 vblankTest(void); -int main(void) -{ - GFX_init(GFX_RGB5A1, GFX_RGB565); - GFX_setBrightness(0x30, 0x30); - consoleInit(SCREEN_BOT, NULL, false); - - - do - { - const u32 cycles = vblankTest(); - ee_printf("\r%lu %lu %lu %lu", 268111856u / 2 / cycles, cycles, *((vu32*)0x10400424), *((vu32*)0x10400400)); - updateScreens(); - - hidScanInput(); - const u32 kDown = hidKeysDown(); - if(kDown & KEY_DUP) *((vu32*)0x10400424) += 1; // 494 = 50.040660858 Hz - if(kDown & KEY_DDOWN) *((vu32*)0x10400424) -= 1; - if(kDown & KEY_DRIGHT) *((vu32*)0x10400400) += 1; - if(kDown & KEY_DLEFT) *((vu32*)0x10400400) -= 1; - - if(hidGetExtraKeys(KEY_POWER) & KEY_POWER) break; - } while(1); - - GFX_deinit(); - power_off(); - - return 0; -}*/