shithub: dumb

Download patch

ref: 68f8a3aa8fb53b98625232d99cc5bd040e67dd96
parent: 3e73bae5e9ddd3a44d9b0767093d93dfd45df1fc
author: Chris Moeller <kode54@gmail.com>
date: Sun Jun 9 06:33:32 EDT 2013

Fixed timekeeping

--- a/dumb/src/it/itrender.c
+++ b/dumb/src/it/itrender.c
@@ -4242,10 +4242,6 @@
 				*/
 #endif
 				bit_array_set(sigrenderer->played, sigrenderer->order * 256 + sigrenderer->row);
-				if (sigrenderer->looped == 0) {
-					timekeeping_array_push(sigrenderer->row_timekeeper, sigrenderer->order * 256 + sigrenderer->row, sigrenderer->time_played);
-				}
-				timekeeping_array_bump(sigrenderer->row_timekeeper, sigrenderer->order * 256 + sigrenderer->row);
 				{
 					int n;
 					for (n = 0; n < DUMB_IT_N_CHANNELS; n++)
@@ -4406,6 +4402,13 @@
 				}
 			}
 
+#ifdef BIT_ARRAY_BULLSHIT
+			if (sigrenderer->looped == 0) {
+				timekeeping_array_push(sigrenderer->row_timekeeper, sigrenderer->order * 256 + sigrenderer->row, sigrenderer->time_played);
+			}
+			timekeeping_array_bump(sigrenderer->row_timekeeper, sigrenderer->order * 256 + sigrenderer->row);
+#endif
+
 			if (!(sigdata->flags & IT_WAS_A_669))
 				reset_effects(sigrenderer);
 
@@ -5780,7 +5783,7 @@
 	int dt;
 	long todo;
 	int ret;
-	LONG_LONG time_left, t;
+	LONG_LONG t;
 
 	if (sigrenderer->order < 0) return 0; // problematic
 
@@ -5793,8 +5796,7 @@
 	if (!samples) volume = 0;
 
 	for (;;) {
-		time_left = ((LONG_LONG)sigrenderer->time_left << 16) | sigrenderer->sub_time_left;
-		todo = (long)(time_left / dt);
+		todo = (long)((((LONG_LONG)sigrenderer->time_left << 16) | sigrenderer->sub_time_left) / dt);
 
 		if (todo >= size)
 			break;
@@ -5809,7 +5811,7 @@
 		sigrenderer->time_left += (long)(t >> 16);
 
 #ifdef BIT_ARRAY_BULLSHIT
-		sigrenderer->time_played += time_left;
+		sigrenderer->time_played += (LONG_LONG)todo * dt;
 #endif
 
 		ret = process_tick(sigrenderer);