From 0b6cb8a025a812fb482212fce0f2cbcd23526983 Mon Sep 17 00:00:00 2001
From: Birte Kristina Friesel <derf@finalrewind.org>
Date: Sun, 11 Feb 2024 09:26:21 +0100
Subject: [PATCH] bad-apple on msp430fr / sharp96: more consistent main loop

---
 src/app/bad-apple-msp430fr-sharp96/main.cc | 23 +++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/app/bad-apple-msp430fr-sharp96/main.cc b/src/app/bad-apple-msp430fr-sharp96/main.cc
index 67e8fa5..d524f87 100644
--- a/src/app/bad-apple-msp430fr-sharp96/main.cc
+++ b/src/app/bad-apple-msp430fr-sharp96/main.cc
@@ -30,47 +30,48 @@ int main(void)
 	sharp96.clear();
 
 	timer.setup_hz(frame_rate);
+	timer_done = 0;
+	timer.start(1);
 
 	while (1) {
 		for (i = 0; i < (sizeof(frames) / sizeof(frames[0])); i++) {
 
-			timer_done = 0;
-			timer.start(1);
-
-			for (line = 0; line < 72; line++) {
-				sharp96.writeLine(line, img_buf + (12 * 72 * 2) + (12 * line));
-			}
-
 			inflate(frames[i], sizeof(img_buf), img_buf, sizeof(img_buf));
 
 			while (!timer_done) {
 				arch.idle();
 			}
-			timer.stop();
 
+			timer.stop();
 			timer_done = 0;
 			timer.start(1);
 
 			for (line = 0; line < 72; line++) {
-				sharp96.writeLine(line, img_buf + (12 * line));
+				sharp96.writeLine(line, img_buf + (12 * 72 * 0 ) + (12 * line));
 			}
 
 			while (!timer_done) {
 				arch.idle();
 			}
-			timer.stop();
 
+			timer.stop();
 			timer_done = 0;
 			timer.start(1);
 
 			for (line = 0; line < 72; line++) {
-				sharp96.writeLine(line, img_buf + (12 * 72) + (12 * line));
+				sharp96.writeLine(line, img_buf + (12 * 72 * 1) + (12 * line));
 			}
 
 			while (!timer_done) {
 				arch.idle();
 			}
 			timer.stop();
+			timer_done = 0;
+			timer.start(1);
+
+			for (line = 0; line < 72; line++) {
+				sharp96.writeLine(line, img_buf + (12 * 72 * 2) + (12 * line));
+			}
 
 			if ((i%10)==0) {
 				sharp96.toggleVCOM();
-- 
GitLab