shithub: ft²

Download patch

ref: 3fea9dd32dab91503bd948a3ac2ef0111533edb7
parent: 178bdf8be18b8056ba13e0b281246cfbaca666ca
author: Olav Sørensen <olav.sorensen@live.no>
date: Sun Dec 29 17:48:45 EST 2024

Code cleanup

--- a/src/ft2_header.h
+++ b/src/ft2_header.h
@@ -22,7 +22,8 @@
 #define VBLANK_HZ 60
 
 // 70Hz (FT2 vblank) delta -> 60Hz vblank delta (rounded)
-#define SCALE_VBLANK_DELTA(x) (int32_t)(((x) * ((double)VBLANK_HZ / FT2_VBLANK_HZ)) + 0.5)
+#define SCALE_VBLANK_DELTA(x) (int32_t)(((x) * (FT2_VBLANK_HZ / (double)VBLANK_HZ)) + 0.5)
+#define SCALE_VBLANK_DELTA_REV(x) (int32_t)(((x) * (VBLANK_HZ / (double)FT2_VBLANK_HZ)) + 0.5)
 
 /* Amount of extra bytes to allocate for every instrument sample,
 ** this is used for a hack for resampling interpolation to be
--- a/src/ft2_nibbles.c
+++ b/src/ft2_nibbles.c
@@ -848,9 +848,9 @@
 	assert(config.NI_Speed < 4);
 	NI_CurSpeed = NI_Speeds[config.NI_Speed];
 
-	// adjust for 70Hz -> 60Hz frames (this is not exact, but we don't want fractional numbers aka. frame skipping)
-	NI_CurSpeed60Hz = (uint8_t)SCALE_VBLANK_DELTA(NI_CurSpeed);
-	NI_CurTick60Hz = (uint8_t)SCALE_VBLANK_DELTA(NI_Speeds[2]);
+	// adjust for 70Hz -> 60Hz countdown frames (this is not exact, but we don't want fractional numbers aka. frame skipping)
+	NI_CurSpeed60Hz = (uint8_t)SCALE_VBLANK_DELTA_REV(NI_CurSpeed);
+	NI_CurTick60Hz = (uint8_t)SCALE_VBLANK_DELTA_REV(NI_Speeds[2]);
 
 	editor.NI_Play = true;
 	NI_P1Score = 0;
--