shithub: dumb

Download patch

ref: ac46a8b6056cf12bff464407bc1582301051c1f1
parent: 425a8407fb003e1ca7d5f332cad9d7be90a6e2ee
author: Chris Moeller <kode54@gmail.com>
date: Wed Dec 26 08:22:49 EST 2012

Fixed STM speed handling

--- a/dumb/include/internal/it.h
+++ b/dumb/include/internal/it.h
@@ -412,6 +412,8 @@
 
 #define IT_WAS_AN_OKT     2048
 
+#define IT_WAS_AN_STM     4096
+
 #define IT_ORDER_END  255
 #define IT_ORDER_SKIP 254
 
--- a/dumb/src/it/itrender.c
+++ b/dumb/src/it/itrender.c
@@ -2148,7 +2148,18 @@
 					/*if (entry->effectvalue == 255)
 						if (sigrenderer->callbacks->xm_speed_zero && (*sigrenderer->callbacks->xm_speed_zero)(sigrenderer->callbacks->xm_speed_zero_data))
 							return 1;*/
-					sigrenderer->tick = sigrenderer->speed = entry->effectvalue;
+                    if (sigdata->flags & IT_WAS_AN_STM)
+                    {
+                        int n = entry->effectvalue;
+                        if (n >= 32)
+                        {
+                            sigrenderer->tick = sigrenderer->speed = n;
+                        }
+                    }
+                    else
+                    {
+                        sigrenderer->tick = sigrenderer->speed = entry->effectvalue;
+                    }
 				}
 				else if ((sigdata->flags & (IT_WAS_AN_XM|IT_WAS_A_MOD)) == IT_WAS_AN_XM) {
 #ifdef BIT_ARRAY_BULLSHIT
@@ -4395,9 +4406,12 @@
 			update_effects(sigrenderer);
 		}
 	} else {
-		speed0:
-		update_effects(sigrenderer);
-		update_tick_counts(sigrenderer);
+        if ( !(sigdata->flags & IT_WAS_AN_STM) || !(sigrenderer->tick & 15))
+        {
+            speed0:
+            update_effects(sigrenderer);
+            update_tick_counts(sigrenderer);
+        }
 	}
 
 	if (sigrenderer->globalvolume == 0) {
@@ -4420,7 +4434,12 @@
 	process_all_playing(sigrenderer);
 
 	{
-		LONG_LONG t = sigrenderer->sub_time_left + ((LONG_LONG)TICK_TIME_DIVIDEND << 16) / sigrenderer->tempo;
+        LONG_LONG t = ((LONG_LONG)TICK_TIME_DIVIDEND << 16) / sigrenderer->tempo;
+        if ( sigrenderer->sigdata->flags & IT_WAS_AN_STM )
+        {
+            t /= 16;
+        }
+        t += sigrenderer->sub_time_left;
 		sigrenderer->time_left += (int)(t >> 16);
 		sigrenderer->sub_time_left = (int)t & 65535;
 	}
--- a/dumb/src/it/readstm.c
+++ b/dumb/src/it/readstm.c
@@ -25,11 +25,11 @@
 #include "dumb.h"
 #include "internal/it.h"
 
-#ifdef _MSC_VER
-#define strnicmp _strnicmp
-#else
-#define strnicmp strncasecmp
-#endif
+#ifdef _MSC_VER
+#define strnicmp _strnicmp
+#else
+#define strnicmp strncasecmp
+#endif
 
 /** WARNING: this is duplicated in itread.c */
 static int it_seek(DUMBFILE *f, long offset)
@@ -161,9 +161,9 @@
 					entry->mask |= IT_ENTRY_VOLPAN;
 				entry->mask |= IT_ENTRY_EFFECT;
 				switch ( entry->effect ) {
-					case IT_SET_SPEED:
-						entry->effectvalue >>= 4;
-						break;
+                    case IT_SET_SPEED:
+                    /* taken care of in the renderer */
+                        break;
 
 					case IT_BREAK_TO_ROW:
 						entry->effectvalue -= (entry->effectvalue >> 4) * 6;
@@ -255,16 +255,17 @@
 	sigdata->n_samples = 31;
 	sigdata->n_pchannels = 4;
 
-	sigdata->tempo = 125;
-	sigdata->mixing_volume = 48;
+    sigdata->tempo = 125;
+    sigdata->mixing_volume = 48;
 	sigdata->pan_separation = 128;
 
 	/** WARNING: which ones? */
-	sigdata->flags = IT_OLD_EFFECTS | IT_COMPATIBLE_GXX | IT_WAS_AN_S3M | IT_STEREO;
+    sigdata->flags = IT_OLD_EFFECTS | IT_COMPATIBLE_GXX | IT_WAS_AN_S3M | IT_WAS_AN_STM | IT_STEREO;
 
-	sigdata->speed = dumbfile_getc(f) >> 4;
-	if ( sigdata->speed < 1 ) sigdata->speed = 1;
-	sigdata->n_patterns = dumbfile_getc(f);
+    n = dumbfile_getc(f);
+    if ( n < 32 ) n = 32;
+    sigdata->speed = n;
+    sigdata->n_patterns = dumbfile_getc(f);
 	sigdata->global_volume = dumbfile_getc(f) << 1;
 	if ( sigdata->global_volume > 128 ) sigdata->global_volume = 128;