[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freesci-develop] r1576 - in freesci/branches/glutton/src: engine includ
From: |
freesci |
Subject: |
[freesci-develop] r1576 - in freesci/branches/glutton/src: engine include sfx sfx/softseq |
Date: |
Wed, 01 Nov 2006 16:24:52 +0100 |
Author: skovmanden
Date: 2006-11-01 16:24:40 +0100 (Wed, 01 Nov 2006)
New Revision: 1576
Modified:
freesci/branches/glutton/src/engine/gc.c
freesci/branches/glutton/src/engine/ksound.c
freesci/branches/glutton/src/include/sfx_iterator.h
freesci/branches/glutton/src/sfx/core.c
freesci/branches/glutton/src/sfx/softseq/opl2.c
Log:
Add fade message to song iterators, and use it.
Doesn't actually do anything, but fixes a hang in the CotL
intro. Preparation for more bug fixes.
Yes, this is the first update in a long time.
Lars
Modified: freesci/branches/glutton/src/engine/gc.c
===================================================================
--- freesci/branches/glutton/src/engine/gc.c 2006-07-17 18:11:21 UTC (rev
1575)
+++ freesci/branches/glutton/src/engine/gc.c 2006-11-01 15:24:40 UTC (rev
1576)
@@ -22,7 +22,7 @@
#define WORKLIST_CHUNK_SIZE 32
-#define DEBUG_GC
+/*#define DEBUG_GC*/
/*#define DEBUG_GC_VERBOSE*/
typedef struct _worklist {
@@ -284,7 +284,7 @@
seg_manager_t *sm = &(s->seg_manager);
#ifdef DEBUG_GC
- c_segtable(s);
+// c_segtable(s);
sciprintf("[GC] Running...\n");
memset(&(deallocator.segcount), 0, sizeof(int) * (MEM_OBJ_MAX + 1));
#endif
Modified: freesci/branches/glutton/src/engine/ksound.c
===================================================================
--- freesci/branches/glutton/src/engine/ksound.c 2006-07-17 18:11:21 UTC
(rev 1575)
+++ freesci/branches/glutton/src/engine/ksound.c 2006-11-01 15:24:40 UTC
(rev 1576)
@@ -86,6 +86,16 @@
#define SCRIPT_ASSERT_ZERO(fun) if (fun) script_debug_flag = script_error_flag
= 1;
+static int
+get_builtin_priority(state_t *s, int song_nr)
+{
+ resource_t *song = scir_find_resource(s->resmgr, sci_sound, song_nr, 0);
+
+ if (song->data[0] == 0xf0)
+ return song->data[1]; else
+ return 50;
+}
+
static song_iterator_t *
build_iterator(state_t *s, int song_nr, int type, songit_id_t id)
{
@@ -407,6 +417,8 @@
int vol = GET_SEL32V(obj, vol);
int pri = GET_SEL32V(obj, pri);
+ if (number == 886) break;
+
if (obj.segment && (scir_test_resource(s->resmgr, sci_sound,
number)))
{
sciprintf("Initializing song number %d\n",
GET_SEL32V(obj, number));
@@ -700,6 +712,13 @@
int vol = GET_SEL32V(obj, vol);
int pri = GET_SEL32V(obj, pri);
+ if (GET_SEL32V(obj, nodePtr))
+ {
+ sfx_song_set_status(&s->sound,
+ handle, SOUND_STATUS_STOPPED);
+ sfx_remove_song(&s->sound, handle);
+ }
+
if (obj.segment && (scir_test_resource(s->resmgr, sci_sound,
number))) {
sciprintf("Initializing song number %d\n",
GET_SEL32V(obj, number));
SCRIPT_ASSERT_ZERO(sfx_add_song(&s->sound,
@@ -736,12 +755,29 @@
}
case _K_SCI1_SOUND_FADE_HANDLE :
{
- /* FIXME: The next couple of lines actually STOP the handle, rather
- ** than fading it! */
- PUT_SEL32V(obj, signal, -1);
+ fade_params_t fade;
if (obj.segment) {
- sfx_song_set_status(&s->sound,
- handle, SOUND_STATUS_STOPPED);
+ fade.final_volume = UKPV(2);
+ fade.ticks_per_step = UKPV(3);
+ fade.step_size = UKPV(4);
+ fade.action = UKPV(5) ?
+ FADE_ACTION_FADE_AND_STOP :
+ FADE_ACTION_FADE_AND_CONT;
+
+ sfx_song_set_fade(&s->sound,
+ handle,
+ &fade);
+
+ /* FIXME: The next couple of lines actually STOP the
handle, rather
+ ** than fading it! */
+ if (UKPV(5))
+ {
+ PUT_SEL32V(obj, signal, -1);
+ PUT_SEL32V(obj, nodePtr, 0);
+ PUT_SEL32V(obj, handle, 0);
+ sfx_song_set_status(&s->sound,
+ handle,
SOUND_STATUS_STOPPED);
+ }
}
break;
}
Modified: freesci/branches/glutton/src/include/sfx_iterator.h
===================================================================
--- freesci/branches/glutton/src/include/sfx_iterator.h 2006-07-17 18:11:21 UTC
(rev 1575)
+++ freesci/branches/glutton/src/include/sfx_iterator.h 2006-11-01 15:24:40 UTC
(rev 1576)
@@ -38,6 +38,17 @@
#define SI_PCM -5 /* Found a PCM */
#define SI_MORPH -255 /* Song iterator requested self-morph. */
+#define FADE_ACTION_NONE 0
+#define FADE_ACTION_FADE_AND_STOP 1
+#define FADE_ACTION_FADE_AND_CONT 2
+
+typedef struct {
+ int ticks_per_step;
+ int final_volume;
+ int step_size;
+ int action;
+} fade_params_t;
+
#define SONG_ITERATOR_MESSAGE_ARGUMENTS_NR 2
/* Helper defs for messages */
@@ -53,7 +64,8 @@
#define _SIMSG_BASEMSG_ACK_MORPH 4 /* Acknowledge self-morph */
#define _SIMSG_BASEMSG_STOP 5 /* Stop iterator */
#define _SIMSG_BASEMSG_PRINT 6 /* Print self to stderr, after printing param1
tabs */
-#define _SIMSG_BASEMSG_SET_HOLD 7
+#define _SIMSG_BASEMSG_SET_HOLD 7 /* Set value of hold parameter to expect */
+#define _SIMSG_BASEMSG_SET_FADE 8 /* Set fade parameters */
/* "Plastic" (discardable) wrapper messages */
#define _SIMSG_PLASTICWRAP 1 /* Any base decoder */
@@ -68,6 +80,7 @@
#define SIMSG_STOP _SIMSG_BASE,_SIMSG_BASEMSG_STOP,0,0
#define SIMSG_PRINT(indentation)
_SIMSG_BASE,_SIMSG_BASEMSG_PRINT,(indentation),0
#define SIMSG_SET_HOLD(x) _SIMSG_BASE,_SIMSG_BASEMSG_SET_HOLD,(x),0
+#define SIMSG_SET_FADE(x) _SIMSG_BASE,_SIMSG_BASEMSG_SET_FADE,(x),0
/* Message transmission macro: Takes song reference, message reference */
#define SIMSG_SEND(o, m) songit_handle_message(&(o),
songit_make_message((o)->ID, m))
@@ -85,6 +98,7 @@
#define INHERITS_SONG_ITERATOR \
songit_id_t ID;
\
guint16 channel_mask;
\
+ fade_params_t fade;
\
int (*next) (song_iterator_t *self, unsigned char *buf, int *buf_size);
\
sfx_pcm_feed_t * (*get_pcm_feed) (song_iterator_t *s);
\
song_iterator_t * (* handle_message)(song_iterator_t *self,
song_iterator_message_t msg); \
@@ -100,6 +114,7 @@
songit_id_t ID;
guint16 channel_mask; /* Bitmask of all channels this iterator will use
*/
+ fade_params_t fade;
int (*next) (struct _song_iterator *self,
unsigned char *buf, int *result);
Modified: freesci/branches/glutton/src/sfx/core.c
===================================================================
--- freesci/branches/glutton/src/sfx/core.c 2006-07-17 18:11:21 UTC (rev
1575)
+++ freesci/branches/glutton/src/sfx/core.c 2006-11-01 15:24:40 UTC (rev
1576)
@@ -136,6 +136,7 @@
{
song_t *song = self->song;
+#if 0
fprintf(stderr, "Cue iterators:\n");
song = *(self->songlib.lib);
while (song) {
@@ -149,6 +150,7 @@
fprintf(stderr, "Audio iterator:\n");
player->iterator_message(songit_make_message(0,
SIMSG_PRINT(1)));
}
+#endif
}
@@ -687,7 +689,7 @@
if (song) {
_sfx_set_song_status(self, song, SOUND_STATUS_STOPPED);
- fprintf(stderr, "Overwriting old song (%d) ...\n",
song->status);
+ fprintf(stderr, "Overwriting old song (%08lx) ...\n", handle);
if (song->status == SOUND_STATUS_PLAYING
|| song->status == SOUND_STATUS_SUSPENDED) {
fprintf(stderr, "Unexpected (error): Song %d still
playing/suspended (%d)\n",
@@ -745,7 +747,27 @@
_update(self);
}
+void
+sfx_song_set_fade(sfx_state_t *self, song_handle_t handle,
+ fade_params_t *params)
+{
+ static char *stopmsg[] = {"??? Should not happen", "Do not stop
afterwards","Stop afterwards"};
+ song_t *song = song_lib_find(self->songlib, handle);
+ ASSERT_SONG(song);
+
+#ifdef DEBUG_SONG_API
+ fprintf(stderr, "[sfx-core] Setting fade params of %08lx to "
+ "final volume %d in steps of %d per %d ticks. %s.\n",
+ handle, fade->final_volume, fade->step_size,
fade->ticks_per_step,
+ stopmsg[fade->action]);
+#endif
+
+ SIMSG_SEND(song->it, SIMSG_SET_FADE(params));
+
+ _update(self);
+}
+
void
sfx_song_renice(sfx_state_t *self, song_handle_t handle, int priority)
{
Modified: freesci/branches/glutton/src/sfx/softseq/opl2.c
===================================================================
--- freesci/branches/glutton/src/sfx/softseq/opl2.c 2006-07-17 18:11:21 UTC
(rev 1575)
+++ freesci/branches/glutton/src/sfx/softseq/opl2.c 2006-11-01 15:24:40 UTC
(rev 1576)
@@ -634,6 +634,7 @@
oper = command & 0xf0;
switch (oper) {
case 0xc0: /* change instrument */
+ printf("ADLIB: Selecting instrument %d on channel %d\n", param, channel);
instr[channel] = param;
return 0;
default:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freesci-develop] r1576 - in freesci/branches/glutton/src: engine include sfx sfx/softseq,
freesci <=