end_of_sound now maybe works.
authorTimo Korvola <tkorvola@iki.fi>
Sat, 3 Mar 2018 18:59:22 +0000 (20:59 +0200)
committerDavid Griffith <dave@661.org>
Sun, 11 Mar 2018 11:48:50 +0000 (04:48 -0700)
Went back to end_of_sound taking no args, so sound.c got reverted.
Should be easier on DOS frotz, which I never attempted to fix.  Made
interpret call os_tick, as SDL front end expects (WinFrotz also has
os_tick).  os_tick calls end_of_sound as appropriate.  Added os_tick
to the other front ends.  In dumb it does nothing, in curses it
handles resizes.

src/common/frotz.h
src/common/process.c
src/common/sound.c
src/curses/ux_input.c
src/dumb/dumb_input.c
src/sdl/sf_sound.c

index b2f8e6b869c3339eaae89c8fd6ecd50be8e5c3df..bfa287e91cbc60bab8b68461ba65a9dba7cbfeea 100644 (file)
@@ -750,7 +750,7 @@ void        branch (bool);
 void   storeb (zword, zbyte);
 void   storew (zword, zword);
 
-void end_of_sound (zword routine);
+void end_of_sound (void);
 
 int completion (const zchar *buffer, zchar *result);
 
@@ -800,6 +800,12 @@ void       os_init_setup (void);
 void   os_warn (const char *, ...);
 void   os_quit (void);
 
+/**
+ * Called regularly by the interpreter, at least every few instructions
+ * (only when interpreting: e.g., not when waiting for input).
+ */
+void    os_tick (void);
+
 /* Front ends call this if the terminal size changes. */
 void    resize_screen(void);
 
index c542b133e102c40f6692bd8aaa5dd90224727a40..9187b0bbd293b3514dbf76a8f8de20d795576208 100644 (file)
@@ -306,10 +306,11 @@ void interpret (void)
        }
 
 #if defined(DJGPP) && defined(SOUND_SUPPORT)
-    if (end_of_sound_flag)
-       end_of_sound ();
+        if (end_of_sound_flag)
+            end_of_sound ();
 #endif
 
+        os_tick();
     } while (finished == 0);
 
     finished--;
index 2998734bda90c412da253ceecff29bd0b754de39..e5e29e740f516990efbf68033a142713b9e0af9f 100644 (file)
@@ -31,6 +31,8 @@
 
 extern int direct_call (zword);
 
+static zword routine = 0;
+
 static int next_sample = 0;
 static int next_volume = 0;
 
@@ -74,6 +76,7 @@ static void start_sample (int number, int volume, int repeats, zword eos)
 
     os_start_sample (number, volume, repeats, eos);
 
+    routine = eos;
     playing = TRUE;
 
 }/* start_sample */
@@ -106,7 +109,7 @@ static void start_next_sample (void)
  * interrupt (which requires extremely careful programming).
  *
  */
-void end_of_sound (zword routine)
+void end_of_sound (void)
 {
 #if defined(DJGPP) && defined(SOUND_SUPPORT)
     end_of_sound_flag = 0;
index b3e90329abdd4d85a008b834d648beae605836b2..00cd934c0a097caee8e40a37da089ab28e373385 100644 (file)
@@ -133,6 +133,15 @@ static int timeout_to_ms()
 #endif
 
 
+void os_tick()
+{
+    while (terminal_resized) {
+        terminal_resized = 0;
+        unix_resize_display();
+    }
+}
+
+
 /*
  * unix_read_char
  *
@@ -155,10 +164,7 @@ static int unix_read_char(int extkeys)
         /* Wait with select so that we get interrupted on SIGWINCH. */
         FD_ZERO(&rsel);
         FD_SET(fd, &rsel);
-        while (terminal_resized) {
-            terminal_resized = 0;
-            unix_resize_display();
-        }
+        os_tick();
         refresh();
         t_left = timeout_left(&tval) ? &tval : NULL;
         sel = select(fd + 1, &rsel, NULL, NULL, t_left);
index 10e36cdbcaf1a19637cd196cce962ecc9cb75c44..81c4e8dcdef1cf3d9b78c7d6a40290af2d7ddd6c 100644 (file)
  * Or visit http://www.fsf.org/
  */
 
-#include "dumb_frotz.h"
-
 #include <string.h>
 
+#include "dumb_frotz.h"
+
 f_setup_t f_setup;
 
 static char runtime_usage[] =
@@ -476,3 +476,6 @@ zword os_read_mouse(void)
        /* NOT IMPLEMENTED */
     return 0;
 }
+
+void os_tick()
+{}
index 1ffdc66398e9b06b77b99a6856ca5f56993030a5..ac9c0ed9f6def639e1d722e13c651b49c261aaab 100644 (file)
@@ -335,8 +335,10 @@ void os_start_sample(int number, int volume, int repeats, zword eos)
        // NOTE: geteffect may return an already loaded effect
   e = geteffect(number);
   if (!e) return;
-  if (e->type == SFX_TYPE) stopsample();
-  else stopmodule();
+  if (e->type == SFX_TYPE)
+      stopsample();
+  else
+      stopmodule();
   if (repeats < 1) repeats = 1;
   if (repeats == 255) repeats = -1;
   if (volume < 0) volume = 0;
@@ -389,7 +391,7 @@ void sf_checksound()
        if (e_sfx->eos)
                {
                end_of_sound_flag = 1;
-               end_of_sound(e_sfx->eos);
+               end_of_sound();
                }
        }
   if ((e_mod) && (e_mod->ended))
@@ -398,7 +400,7 @@ void sf_checksound()
        if (e_mod->eos)
                {
                end_of_sound_flag = 1;
-               end_of_sound(e_mod->eos);
+               end_of_sound();
                }
        }
   }