From c3f22a5afb716a723de6b534b143704c7304fff4 Mon Sep 17 00:00:00 2001 From: Rezmason Date: Tue, 7 Jun 2022 20:20:13 -0700 Subject: [PATCH] Reducing the number of fade variants when the effect is running quicker, to gain some more CPU. --- playdate/matrix_c/main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/playdate/matrix_c/main.c b/playdate/matrix_c/main.c index 5498936..faa23d1 100644 --- a/playdate/matrix_c/main.c +++ b/playdate/matrix_c/main.c @@ -128,12 +128,15 @@ static void init(void) static int update(void* ud) { float delta; + int currentFadeSkip = 1; + if (sys->isCrankDocked()) { speed += 0.07f; if (speed > maxSpeed) { speed = maxSpeed; } delta = sys->getElapsedTime() * speed; + currentFadeSkip = 6; } else { speed -= 0.07f; if (speed < minSpeed) { @@ -144,6 +147,8 @@ static int update(void* ud) sys->resetElapsedTime(); time += delta; + int currentNumFades = numFades / currentFadeSkip; + PDButtons currentButtons; sys->getButtonState(¤tButtons, NULL, NULL); int addPDGlyphs = currentButtons & kButtonA && currentButtons & kButtonB; @@ -160,7 +165,8 @@ static int update(void* ud) 1 ); - int fadeIndex = brightness * numFades; + int fadeIndex = brightness * currentNumFades; + fadeIndex *= currentFadeSkip; if (fadeIndex < 0) fadeIndex = 0; if (fadeIndex >= numFades - 1) fadeIndex = numFades - 1; if (cell->fadeIndex != fadeIndex) {