aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMax Horn2009-05-12 23:31:55 +0000
committerMax Horn2009-05-12 23:31:55 +0000
commit05c3c6ccb3ce41dbe5605073ed54a2290525e179 (patch)
tree0d34b65732355f975e12423fc7683bb64ae14abf /engines
parente3d79c58f0e94e03a8176a32ea1355e6dbb2a055 (diff)
downloadscummvm-rg350-05c3c6ccb3ce41dbe5605073ed54a2290525e179.tar.gz
scummvm-rg350-05c3c6ccb3ce41dbe5605073ed54a2290525e179.tar.bz2
scummvm-rg350-05c3c6ccb3ce41dbe5605073ed54a2290525e179.zip
SCI: Replaced SFX_OK/SFX_ERROR by Common::Error, and got rid of sfx/sfx.h
svn-id: r40517
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/engine/ksound.cpp5
-rw-r--r--engines/sci/sfx/core.cpp8
-rw-r--r--engines/sci/sfx/core.h8
-rw-r--r--engines/sci/sfx/device.h21
-rw-r--r--engines/sci/sfx/device/alsa-midi.cpp26
-rw-r--r--engines/sci/sfx/device/camd-midi.cpp16
-rw-r--r--engines/sci/sfx/device/unixraw-midi.cpp16
-rw-r--r--engines/sci/sfx/player.h36
-rw-r--r--engines/sci/sfx/player/player.cpp38
-rw-r--r--engines/sci/sfx/player/polled.cpp46
-rw-r--r--engines/sci/sfx/player/realtime.cpp59
-rw-r--r--engines/sci/sfx/sci_midi.h7
-rw-r--r--engines/sci/sfx/seq/gm.cpp38
-rw-r--r--engines/sci/sfx/seq/instrument-map.cpp40
-rw-r--r--engines/sci/sfx/seq/oss-adlib.cpp4
-rw-r--r--engines/sci/sfx/sequencer.h38
-rw-r--r--engines/sci/sfx/sfx.h40
-rw-r--r--engines/sci/sfx/sfx_pcm.h2
-rw-r--r--engines/sci/sfx/softseq.h8
-rw-r--r--engines/sci/sfx/softseq/SN76496.cpp8
-rw-r--r--engines/sci/sfx/softseq/amiga.cpp16
-rw-r--r--engines/sci/sfx/softseq/fluidsynth.cpp18
-rw-r--r--engines/sci/sfx/softseq/opl2.cpp17
-rw-r--r--engines/sci/sfx/softseq/pcspeaker.cpp10
24 files changed, 245 insertions, 280 deletions
diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp
index 3bd66f969c..39b41734ee 100644
--- a/engines/sci/engine/ksound.cpp
+++ b/engines/sci/engine/ksound.cpp
@@ -370,8 +370,6 @@ reg_t kDoSound_SCI0(EngineState *s, int funct_nr, int argc, reg_t *argv) {
return s->r_acc;
}
-int sfx_send_midi(sfx_state_t *self, song_handle_t handle, int channel,
- int command, int arg1, int arg2);
reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
uint16 command = UKPV(0);
@@ -673,9 +671,6 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
return s->r_acc;
}
-int sfx_send_midi(sfx_state_t *self, song_handle_t handle, int channel,
- int command, int arg1, int arg2);
-
reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
uint16 command = UKPV(0);
reg_t obj = KP_ALT(1, NULL_REG);
diff --git a/engines/sci/sfx/core.cpp b/engines/sci/sfx/core.cpp
index e35a3abad1..32f4cc272b 100644
--- a/engines/sci/sfx/core.cpp
+++ b/engines/sci/sfx/core.cpp
@@ -707,7 +707,7 @@ static const int MIDI_cmdlen[16] = {0, 0, 0, 0, 0, 0, 0, 0,
static const song_handle_t midi_send_base = 0xffff0000;
-int sfx_send_midi(sfx_state_t *self, song_handle_t handle, int channel,
+Common::Error sfx_send_midi(sfx_state_t *self, song_handle_t handle, int channel,
int command, int arg1, int arg2) {
byte buffer[5];
tell_synth_func *tell = sfx_get_player_tell_func();
@@ -724,7 +724,7 @@ int sfx_send_midi(sfx_state_t *self, song_handle_t handle, int channel,
/* We need to have a GET_PLAYMASK interface to use
here. SET_PLAYMASK we've got.
*/
- return SFX_OK;
+ return Common::kNoError;
}
buffer[0] = channel | command; /* No channel remapping yet */
@@ -745,12 +745,12 @@ int sfx_send_midi(sfx_state_t *self, song_handle_t handle, int channel,
break;
default:
sciprintf("Unexpected explicit MIDI command %02x\n", command);
- return SFX_ERROR;
+ return Common::kUnknownError;
}
if (tell)
tell(MIDI_cmdlen[command >> 4], buffer);
- return SFX_OK;
+ return Common::kNoError;
}
int sfx_get_volume(sfx_state_t *self) {
diff --git a/engines/sci/sfx/core.h b/engines/sci/sfx/core.h
index 107c05a17e..ca5025edf7 100644
--- a/engines/sci/sfx/core.h
+++ b/engines/sci/sfx/core.h
@@ -27,7 +27,7 @@
#ifndef SCI_SFX_SFX_ENGINE_H
#define SCI_SFX_SFX_ENGINE_H
-#include "sci/sfx/sfx.h"
+#include "common/error.h"
#include "sci/sfx/songlib.h"
#include "sci/scicore/resource.h"
@@ -162,6 +162,12 @@ void sfx_song_set_fade(sfx_state_t *self, song_handle_t handle, fade_params_t *f
** (fade_params_t *) fade_setup: The precise fade-out configuration to use
*/
+
+// Previously undocumented:
+Common::Error sfx_send_midi(sfx_state_t *self, song_handle_t handle, int channel,
+ int command, int arg1, int arg2);
+
+
} // End of namespace Sci
#endif // SCI_SFX_SFX_ENGINE_H
diff --git a/engines/sci/sfx/device.h b/engines/sci/sfx/device.h
index c27dcb9cb5..e1b8c9ea06 100644
--- a/engines/sci/sfx/device.h
+++ b/engines/sci/sfx/device.h
@@ -29,6 +29,7 @@
#define SCI_SFX_DEVICE_H
#include "common/scummsys.h"
+#include "common/error.h"
namespace Sci {
@@ -40,43 +41,43 @@ namespace Sci {
struct _midi_device {
const char *name;
- int (*init)(struct _midi_device *self);
+ Common::Error (*init)(struct _midi_device *self);
/* Initializes the device
** Parameters: (midi_device_t *) self: Self reference
- ** Returns : (int) SFX_OK on success, SFX_ERROR if the device could not be
+ ** Returns : (int) Common::kNoError on success, Common::kUnknownError if the device could not be
** opened
*/
- int (*set_option)(struct _midi_device *self, char *name, char *value);
+ Common::Error (*set_option)(struct _midi_device *self, char *name, char *value);
/* Sets an option for the device
** Parameters: (char *) name: Name of the option to set
** (char *) value: Value of the option to set
- ** Returns : (int) SFX_OK on success, SFX_ERROR otherwise (unsupported option)
+ ** Returns : (int) Common::kNoError on success, Common::kUnknownError otherwise (unsupported option)
*/
};
struct midi_writer_t {
char *name; /* Name description of the device */
- int (*init)(midi_writer_t *self);
+ Common::Error (*init)(midi_writer_t *self);
/* Initializes the writer
** Parameters: (midi_writer_t *) self: Self reference
- ** Returns : (int) SFX_OK on success, SFX_ERROR if the device could not be
+ ** Returns : (int) Common::kNoError on success, Common::kUnknownError if the device could not be
** opened
*/
- int (*set_option)(midi_writer_t *self, char *name, char *value);
+ Common::Error (*set_option)(midi_writer_t *self, char *name, char *value);
/* Sets an option for the writer
** Parameters: (char *) name: Name of the option to set
** (char *) value: Value of the option to set
- ** Returns : (int) SFX_OK on success, SFX_ERROR otherwise (unsupported option)
+ ** Returns : (int) Common::kNoError on success, Common::kUnknownError otherwise (unsupported option)
*/
- int (*write)(midi_writer_t *self, unsigned char *buf, int len);
+ Common::Error (*write)(midi_writer_t *self, unsigned char *buf, int len);
/* Writes some bytes to the MIDI stream
** Parameters: (char *) buf: The buffer to write
** (int) len: Number of bytes to write
- ** Returns : (int) SFX_OK on success, SFX_ERROR on failure
+ ** Returns : (int) Common::kNoError on success, Common::kUnknownError on failure
** No delta time is expected here.
*/
diff --git a/engines/sci/sfx/device/alsa-midi.cpp b/engines/sci/sfx/device/alsa-midi.cpp
index cc4037b020..0041e4a3c8 100644
--- a/engines/sci/sfx/device/alsa-midi.cpp
+++ b/engines/sci/sfx/device/alsa-midi.cpp
@@ -71,16 +71,16 @@ static void _set_tempo(void) {
}
-static int am_subscribe_to_ports(void) {
+static Common::Error am_subscribe_to_ports(void) {
if ((port_out = snd_seq_connect_to(seq, port_out, port_nr, subport_nr)) < 0) {
fprintf(stderr, "[SFX] Could not connect to ALSA sequencer port: %s\n", snd_strerror(port_out));
- return SFX_ERROR;
+ return Common::kUnknownError;
}
- return SFX_OK;
+ return Common::kNoError;
}
-static int aminit(midi_writer_t *self) {
+static Common::Error aminit(midi_writer_t *self) {
int err;
snd_midi_event_new(4096, &parser);
@@ -91,7 +91,7 @@ static int aminit(midi_writer_t *self) {
if (snd_seq_open(&seq, seq_name, SND_SEQ_OPEN_OUTPUT, SND_SEQ_NONBLOCK)) {
fprintf(stderr, "[SFX] Failed to open ALSA MIDI sequencer '%s' for output\n",
seq_name);
- return SFX_ERROR;
+ return Common::kUnknownError;
}
if ((port_out = snd_seq_create_simple_port(seq, "FreeSCI",
@@ -100,11 +100,11 @@ static int aminit(midi_writer_t *self) {
SND_SEQ_PORT_CAP_READ,
SND_SEQ_PORT_TYPE_MIDI_GENERIC)) < 0) {
fprintf(stderr, "[SFX] Could not create ALSA sequencer port\n");
- return SFX_ERROR;
+ return Common::kUnknownError;
}
if (am_subscribe_to_ports())
- return SFX_ERROR;
+ return Common::kUnknownError;
queue = snd_seq_alloc_queue(seq);
_set_tempo();
@@ -115,18 +115,18 @@ static int aminit(midi_writer_t *self) {
fflush(NULL);
fprintf(stderr, "[SFX] Error while draining: %s\n",
snd_strerror(err));
- return SFX_ERROR;
+ return Common::kUnknownError;
}
- return SFX_OK;
+ return Common::kNoError;
}
-static int amsetopt(midi_writer_t *self, char *name, char *value) {
- return SFX_ERROR;
+static Common::Error amsetopt(midi_writer_t *self, char *name, char *value) {
+ return Common::kUnknownError;
}
-static int amwrite(midi_writer_t *self, unsigned char *buf, int len) {
+static Common::Error amwrite(midi_writer_t *self, unsigned char *buf, int len) {
snd_seq_event_t evt;
#if 0
@@ -162,7 +162,7 @@ static int amwrite(midi_writer_t *self, unsigned char *buf, int len) {
#endif
- return SFX_OK;
+ return Common::kNoError;
}
static void amdelay(midi_writer_t *self, int ticks) {
diff --git a/engines/sci/sfx/device/camd-midi.cpp b/engines/sci/sfx/device/camd-midi.cpp
index 78be387d3c..26e3db6520 100644
--- a/engines/sci/sfx/device/camd-midi.cpp
+++ b/engines/sci/sfx/device/camd-midi.cpp
@@ -58,10 +58,10 @@ static struct MidiNode *midi_node = NULL;
sciprintf("[SFX] CAMD driver: "); \
sciprintf(m); \
sciprintf("\n"); \
- return SFX_ERROR; \
+ return Common::kUnknownError; \
}
-static int camd_init(midi_writer_t *self) {
+static Common::Error camd_init(midi_writer_t *self) {
sciprintf("[SFX] Initialising CAMD raw MIDI backend, v%s\n", SCI_CAMD_MIDI_VERSION);
CamdBase = IExec->OpenLibrary("camd.library", 36L);
@@ -82,18 +82,18 @@ static int camd_init(midi_writer_t *self) {
sciprintf("[SFX] CAMD initialisation completed\n");
- return SFX_OK;
+ return Common::kNoError;
}
-static int camd_set_option(midi_writer_t *self, char *name, char *value) {
- return SFX_ERROR;
+static Common::Error camd_set_option(midi_writer_t *self, char *name, char *value) {
+ return Common::kUnknownError;
}
#define MAX_MIDI_LEN 3
-static int camd_write(midi_writer_t *self, unsigned char *buffer, int len) {
+static Common::Error camd_write(midi_writer_t *self, unsigned char *buffer, int len) {
if (len == 0)
- return SFX_OK;
+ return Common::kNoError;
if (buffer[0] == SYSEX_PREFIX) {
/* Must send this as a SysEx */
@@ -117,7 +117,7 @@ static int camd_write(midi_writer_t *self, unsigned char *buffer, int len) {
ICamd->PutMidi(midi_link, data);
}
- return SFX_OK;
+ return Common::kNoError;
}
static void camd_delay(midi_writer_t *self, int ticks) {
diff --git a/engines/sci/sfx/device/unixraw-midi.cpp b/engines/sci/sfx/device/unixraw-midi.cpp
index c6f393423c..bc9e8b7427 100644
--- a/engines/sci/sfx/device/unixraw-midi.cpp
+++ b/engines/sci/sfx/device/unixraw-midi.cpp
@@ -41,29 +41,29 @@ namespace Sci {
static int fd;
static const char *devicename = "/dev/midi";
-static int unixraw_init(midi_writer_t *self) {
+static Common::Error unixraw_init(midi_writer_t *self) {
sciprintf("[SFX] Initialising UNIX raw MIDI backend, v%s\n", SCI_UNIXRAW_MIDI_VERSION);
fd = open(devicename, O_WRONLY | O_SYNC);
if (!IS_VALID_FD(fd)) {
sciprintf("[SFX] Failed to open %s\n", devicename);
- return SFX_ERROR;
+ return Common::kUnknownError;
}
- return SFX_OK;
+ return Common::kNoError;
}
-static int unixraw_set_option(midi_writer_t *self, char *name, char *value) {
- return SFX_ERROR;
+static Common::Error unixraw_set_option(midi_writer_t *self, char *name, char *value) {
+ return Common::kUnknownError;
}
-static int unixraw_write(midi_writer_t *self, unsigned char *buffer, int len) {
+static Common::Error unixraw_write(midi_writer_t *self, unsigned char *buffer, int len) {
if (write(fd, buffer, len) != len) {
sciprintf("[SFX] MIDI write error\n");
- return SFX_ERROR;
+ return Common::kUnknownError;
}
- return SFX_OK;
+ return Common::kNoError;
}
static void unixraw_delay(midi_writer_t *self, int ticks) {
diff --git a/engines/sci/sfx/player.h b/engines/sci/sfx/player.h
index d77c12da6e..ca73d5b582 100644
--- a/engines/sci/sfx/player.h
+++ b/engines/sci/sfx/player.h
@@ -41,65 +41,65 @@ struct sfx_player_t {
const char *name;
const char *version;
- int (*set_option)(char *name, char *value);
+ Common::Error (*set_option)(char *name, char *value);
/* Sets an option for player timing mechanism
** Parameters: (char *) name: The name describing what to set
** (char *) value: The value to set
- ** Returns : (int) SFX_OK, or SFX_ERROR if the name wasn't understood
+ ** Returns : (int) Common::kNoError, or Common::kUnknownError if the name wasn't understood
*/
- int (*init)(ResourceManager *resmgr, int expected_latency);
+ Common::Error (*init)(ResourceManager *resmgr, int expected_latency);
/* Initializes the player
** Parameters: (ResourceManager *) resmgr: A resource manager for driver initialization
** (int) expected_latency: Expected delay in between calls to 'maintenance'
** (in microseconds)
- ** Returns : (int) SFX_OK on success, SFX_ERROR on failure
+ ** Returns : (int) Common::kNoError on success, Common::kUnknownError on failure
*/
- int (*add_iterator)(SongIterator *it, uint32 start_time);
+ Common::Error (*add_iterator)(SongIterator *it, uint32 start_time);
/* Adds an iterator to the song player
** Parameters: (songx_iterator_t *) it: The iterator to play
** (uint32) start_time: The time to assume as the
** time the first MIDI command executes at
- ** Returns : (int) SFX_OK on success, SFX_ERROR on failure
+ ** Returns : (int) Common::kNoError on success, Common::kUnknownError on failure
** The iterator should not be cloned (to avoid memory leaks) and
** may be modified according to the needs of the player.
** Implementors may use the 'sfx_iterator_combine()' function
** to add iterators onto their already existing iterators
*/
- int (*fade_out)();
+ Common::Error (*fade_out)();
/* Fades out the currently playing song (within two seconds
- ** Returns : (int) SFX_OK on success, SFX_ERROR on failure
+ ** Returns : (int) Common::kNoError on success, Common::kUnknownError on failure
*/
- int (*stop)();
+ Common::Error (*stop)();
/* Stops the currently playing song and deletes the associated iterator
- ** Returns : (int) SFX_OK on success, SFX_ERROR on failure
+ ** Returns : (int) Common::kNoError on success, Common::kUnknownError on failure
*/
- int (*iterator_message)(const SongIterator::Message &msg);
+ Common::Error (*iterator_message)(const SongIterator::Message &msg);
/* Transmits a song iterator message to the active song
** Parameters: (SongIterator::Message) msg: The message to transmit
- ** Returns : (int) SFX_OK on success, SFX_ERROR on failure
+ ** Returns : (int) Common::kNoError on success, Common::kUnknownError on failure
** OPTIONAL -- may be NULL
** If this method is not present, sending messages will stop
** and re-start playing, so it is preferred that it is present
*/
- int (*pause)(); /* OPTIONAL -- may be NULL */
+ Common::Error (*pause)(); /* OPTIONAL -- may be NULL */
/* Pauses song playing
- ** Returns : (int) SFX_OK on success, SFX_ERROR on failure
+ ** Returns : (int) Common::kNoError on success, Common::kUnknownError on failure
*/
- int (*resume)(); /* OPTIONAL -- may be NULL */
+ Common::Error (*resume)(); /* OPTIONAL -- may be NULL */
/* Resumes song playing after a pause
- ** Returns : (int) SFX_OK on success, SFX_ERROR on failure
+ ** Returns : (int) Common::kNoError on success, Common::kUnknownError on failure
*/
- int (*exit)();
+ Common::Error (*exit)();
/* Stops the player
- ** Returns : (int) SFX_OK on success, SFX_ERROR on failure
+ ** Returns : (int) Common::kNoError on success, Common::kUnknownError on failure
*/
void (*maintenance)(); /* OPTIONAL -- may be NULL */
diff --git a/engines/sci/sfx/player/player.cpp b/engines/sci/sfx/player/player.cpp
index e2ad9e5213..2336978743 100644
--- a/engines/sci/sfx/player/player.cpp
+++ b/engines/sci/sfx/player/player.cpp
@@ -112,11 +112,11 @@ static void player_void_callback(void) {
/* API implementation */
-static int player_set_option(char *name, char *value) {
- return SFX_ERROR;
+static Common::Error player_set_option(char *name, char *value) {
+ return Common::kUnknownError;
}
-static int player_init(ResourceManager *resmgr, int expected_latency) {
+static Common::Error player_init(ResourceManager *resmgr, int expected_latency) {
MidiDriverType musicDriver = MidiDriver::detectMusicDriver(MDT_PCSPK | MDT_ADLIB);
switch(musicDriver) {
@@ -148,10 +148,10 @@ static int player_init(ResourceManager *resmgr, int expected_latency) {
mididrv->open(resmgr);
mididrv->setVolume(volume);
- return SFX_OK;
+ return Common::kNoError;
}
-static int player_add_iterator(SongIterator *it, uint32 start_time) {
+static Common::Error player_add_iterator(SongIterator *it, uint32 start_time) {
mutex->lock();
SIMSG_SEND(it, SIMSG_SET_PLAYMASK(mididrv->getPlayMask()));
SIMSG_SEND(it, SIMSG_SET_RHYTHM(mididrv->hasRhythmChannel()));
@@ -166,15 +166,15 @@ static int player_add_iterator(SongIterator *it, uint32 start_time) {
play_it_done = 0;
mutex->unlock();
- return SFX_OK;
+ return Common::kNoError;
}
-static int player_fade_out(void) {
+static Common::Error player_fade_out(void) {
warning("Attempt to fade out - not implemented yet");
- return SFX_ERROR;
+ return Common::kUnknownError;
}
-static int player_stop(void) {
+static Common::Error player_stop(void) {
debug(3, "Player: Stopping song iterator %p", (void *)play_it);
mutex->lock();
delete play_it;
@@ -183,23 +183,23 @@ static int player_stop(void) {
static_cast<MidiDriver *>(mididrv)->send(0xb0 + i, SCI_MIDI_CHANNEL_NOTES_OFF, 0);
mutex->unlock();
- return SFX_OK;
+ return Common::kNoError;
}
-static int player_send_iterator_message(const SongIterator::Message &msg) {
+static Common::Error player_send_iterator_message(const SongIterator::Message &msg) {
mutex->lock();
if (!play_it) {
mutex->unlock();
- return SFX_ERROR;
+ return Common::kUnknownError;
}
songit_handle_message(&play_it, msg);
mutex->unlock();
- return SFX_OK;
+ return Common::kNoError;
}
-static int player_pause(void) {
+static Common::Error player_pause(void) {
mutex->lock();
play_paused = 1;
play_pause_diff = wakeup_time.msecsDiff(current_time);
@@ -207,27 +207,27 @@ static int player_pause(void) {
mididrv->playSwitch(false);
mutex->unlock();
- return SFX_OK;
+ return Common::kNoError;
}
-static int player_resume(void) {
+static Common::Error player_resume(void) {
mutex->lock();
wakeup_time = Audio::Timestamp(current_time.msecs() + play_pause_diff, SFX_TICKS_PER_SEC);
mididrv->playSwitch(true);
play_paused = 0;
mutex->unlock();
- return SFX_OK;
+ return Common::kNoError;
}
-static int player_exit(void) {
+static Common::Error player_exit(void) {
mididrv->close();
delete mididrv;
delete mutex;
delete play_it;
play_it = NULL;
- return SFX_OK;
+ return Common::kNoError;
}
sfx_player_t sfx_player_player = {
diff --git a/engines/sci/sfx/player/polled.cpp b/engines/sci/sfx/player/polled.cpp
index 706e6581b7..27d0f88ffe 100644
--- a/engines/sci/sfx/player/polled.cpp
+++ b/engines/sci/sfx/player/polled.cpp
@@ -268,13 +268,13 @@ static void pp_timer_callback() {
/* Hey, we're polled anyway ;-) */
}
-static int pp_set_option(char *name, char *value) {
- return SFX_ERROR;
+static Common::Error pp_set_option(char *name, char *value) {
+ return Common::kUnknownError;
}
-static int pp_init(ResourceManager *resmgr, int expected_latency) {
+static Common::Error pp_init(ResourceManager *resmgr, int expected_latency) {
if (!g_system->getMixer()->isReady())
- return SFX_ERROR;
+ return Common::kUnknownError;
Resource *res = NULL, *res2 = NULL;
@@ -286,7 +286,7 @@ static int pp_init(ResourceManager *resmgr, int expected_latency) {
if (!seq) {
sciprintf("[sfx:seq:polled] Initialisation failed: Could not find software sequencer\n");
- return SFX_ERROR;
+ return Common::kUnknownError;
}
if (seq->patch_nr != SFX_SEQ_PATCHFILE_NONE) {
@@ -304,7 +304,7 @@ static int pp_init(ResourceManager *resmgr, int expected_latency) {
(res2) ? res2->size : 0)) {
sciprintf("[sfx:seq:polled] Initialisation failed: Sequencer '%s', v%s failed to initialise\n",
seq->name, seq->version);
- return SFX_ERROR;
+ return Common::kUnknownError;
}
seq->set_volume(seq, volume);
@@ -314,10 +314,10 @@ static int pp_init(ResourceManager *resmgr, int expected_latency) {
g_system->getMixer()->playInputStream(Audio::Mixer::kSFXSoundType, 0, newStream);
sfx_player_polled.polyphony = seq->polyphony;
- return SFX_OK;
+ return Common::kNoError;
}
-static int pp_add_iterator(SongIterator *it, uint32 start_time) {
+static Common::Error pp_add_iterator(SongIterator *it, uint32 start_time) {
SongIterator *old = play_it;
SIMSG_SEND(it, SIMSG_SET_PLAYMASK(seq->playmask));
@@ -339,15 +339,15 @@ static int pp_add_iterator(SongIterator *it, uint32 start_time) {
new_song = 1;
}
- return SFX_OK;
+ return Common::kNoError;
}
-static int pp_fade_out() {
+static Common::Error pp_fade_out() {
warning(__FILE__": Attempt to fade out- not implemented yet");
- return SFX_ERROR;
+ return Common::kUnknownError;
}
-static int pp_stop() {
+static Common::Error pp_stop() {
SongIterator *it = play_it;
play_it = NULL;
@@ -356,28 +356,28 @@ static int pp_stop() {
seq->allstop(seq);
- return SFX_OK;
+ return Common::kNoError;
}
-static int pp_send_iterator_message(const SongIterator::Message &msg) {
+static Common::Error pp_send_iterator_message(const SongIterator::Message &msg) {
if (!play_it)
- return SFX_ERROR;
+ return Common::kUnknownError;
songit_handle_message(&play_it, msg);
- return SFX_OK;
+ return Common::kNoError;
}
-static int pp_pause() {
+static Common::Error pp_pause() {
play_paused = 1;
seq->set_volume(seq, 0);
- return SFX_OK;
+ return Common::kNoError;
}
-static int pp_resume() {
+static Common::Error pp_resume() {
if (!play_it) {
play_paused = 0;
- return SFX_OK; /* Nothing to resume */
+ return Common::kNoError; /* Nothing to resume */
}
if (play_paused)
@@ -387,15 +387,15 @@ static int pp_resume() {
play_paused = 0;
seq->set_volume(seq, volume);
- return SFX_OK;
+ return Common::kNoError;
}
-static int pp_exit() {
+static Common::Error pp_exit() {
seq->exit(seq);
delete play_it;
play_it = NULL;
- return SFX_OK;
+ return Common::kNoError;
}
sfx_player_t sfx_player_polled = {
diff --git a/engines/sci/sfx/player/realtime.cpp b/engines/sci/sfx/player/realtime.cpp
index 2b6d9a18d0..b279e91908 100644
--- a/engines/sci/sfx/player/realtime.cpp
+++ b/engines/sci/sfx/player/realtime.cpp
@@ -137,7 +137,7 @@ static Resource *find_patch(ResourceManager *resmgr, const char *seq_name, int p
if (patchfile != SFX_SEQ_PATCHFILE_NONE) {
res = resmgr->findResource(kResourceTypePatch, patchfile, 0);
if (!res) {
- fprintf(stderr, "[SFX] " __FILE__": patch.%03d requested by sequencer (%s), but not found\n",
+ warning("[SFX] " __FILE__": patch.%03d requested by sequencer (%s), but not found",
patchfile, seq_name);
}
}
@@ -147,19 +147,19 @@ static Resource *find_patch(ResourceManager *resmgr, const char *seq_name, int p
/* API implementation */
-static int rt_set_option(char *name, char *value) {
- return SFX_ERROR;
+static Common::Error rt_set_option(char *name, char *value) {
+ return Common::kUnknownError;
}
-static int rt_init(ResourceManager *resmgr, int expected_latency) {
+static Common::Error rt_init(ResourceManager *resmgr, int expected_latency) {
Resource *res = NULL, *res2 = NULL;
void *seq_dev = NULL;
seq = sfx_find_sequencer(NULL);
if (!seq) {
- fprintf(stderr, "[SFX] " __FILE__": Could not find sequencer\n");
- return SFX_ERROR;
+ warning("[SFX] " __FILE__": Could not find sequencer");
+ return Common::kUnknownError;
}
sfx_player_realtime.polyphony = seq->polyphony;
@@ -175,8 +175,8 @@ static int rt_init(ResourceManager *resmgr, int expected_latency) {
res2 ? res2->size : 0,
res2 ? res2->data : NULL,
seq_dev)) {
- fprintf(stderr, "[SFX] " __FILE__": Sequencer failed to initialize\n");
- return SFX_ERROR;
+ warning("[SFX] " __FILE__": Sequencer failed to initialize");
+ return Common::kUnknownError;
}
play_writeahead = expected_latency;
@@ -188,10 +188,10 @@ static int rt_init(ResourceManager *resmgr, int expected_latency) {
if (seq->reset_timer)
seq->reset_timer(0);
- return SFX_OK;
+ return Common::kNoError;
}
-static int rt_add_iterator(SongIterator *it, uint32 start_time) {
+static Common::Error rt_add_iterator(SongIterator *it, uint32 start_time) {
if (seq->reset_timer) /* Restart timer counting if possible */
seq->reset_timer(start_time);
@@ -203,15 +203,15 @@ static int rt_add_iterator(SongIterator *it, uint32 start_time) {
play_it_done = 0;
play_moredelay = 0;
- return SFX_OK;
+ return Common::kNoError;
}
-static int rt_fade_out(void) {
- fprintf(stderr, __FILE__": Attempt to fade out- not implemented yet\n");
- return SFX_ERROR;
+static Common::Error rt_fade_out(void) {
+ warning(__FILE__": Attempt to fade out- not implemented yet");
+ return Common::kUnknownError;
}
-static int rt_stop(void) {
+static Common::Error rt_stop(void) {
SongIterator *it = play_it;
play_it = NULL;
@@ -220,45 +220,42 @@ static int rt_stop(void) {
if (seq && seq->allstop)
seq->allstop();
- return SFX_OK;
+ return Common::kNoError;
}
-static int rt_send_iterator_message(const SongIterator::Message &msg) {
+static Common::Error rt_send_iterator_message(const SongIterator::Message &msg) {
if (!play_it)
- return SFX_ERROR;
+ return Common::kUnknownError;
songit_handle_message(&play_it, msg);
- return SFX_OK;
+ return Common::kNoError;
}
-static int rt_pause(void) {
+static Common::Error rt_pause(void) {
play_pause_started = g_system->getMillis();
- /* Also, indicate that we haven't modified the time counter
- ** yet */
+ // Also, indicate that we haven't modified the time counter yet
play_pause_counter = play_pause_started;
play_paused = 1;
if (!seq->allstop) {
sciprintf("[SFX] Cannot suspend sequencer, sound will continue for a bit\n");
- return SFX_OK;
+ return Common::kNoError;
} else
return seq->allstop();
}
-static int rt_resume(void) {
+static Common::Error rt_resume(void) {
play_paused = 0;
- return SFX_OK;
+ return Common::kNoError;
}
-static int rt_exit(void) {
- int retval = SFX_OK;
-
+static Common::Error rt_exit(void) {
if (seq->close()) {
- fprintf(stderr, "[SFX] Sequencer reported error on close\n");
- retval = SFX_ERROR;
+ warning("[SFX] Sequencer reported error on close");
+ return Common::kUnknownError;
}
- return retval;
+ return Common::kNoError;
}
sfx_player_t sfx_player_realtime = {
diff --git a/engines/sci/sfx/sci_midi.h b/engines/sci/sfx/sci_midi.h
index 31e3912942..ed97c9db1a 100644
--- a/engines/sci/sfx/sci_midi.h
+++ b/engines/sci/sfx/sci_midi.h
@@ -28,12 +28,17 @@
#include "sound/mididrv.h"
#include "sound/softsynth/emumidi.h"
-#include "sci/sfx/sfx.h"
+#include "common/error.h"
namespace Sci {
class ResourceManager;
+enum {
+ MIDI_CHANNELS = 16
+};
+
+
#define MIDI_RHYTHM_CHANNEL 9
/* Special SCI sound stuff */
diff --git a/engines/sci/sfx/seq/gm.cpp b/engines/sci/sfx/seq/gm.cpp
index bd4a171ed5..f63f47fab1 100644
--- a/engines/sci/sfx/seq/gm.cpp
+++ b/engines/sci/sfx/seq/gm.cpp
@@ -32,7 +32,7 @@ namespace Sci {
static midi_writer_t *writer = NULL;
-static int midi_gm_open(int patch_len, byte *data, int patch2_len, byte *data2, void *device) {
+static Common::Error midi_gm_open(int patch_len, byte *data, int patch2_len, byte *data2, void *device) {
sfx_instrument_map_t *instrument_map = sfx_instrument_map_load_sci(data, patch_len);
if (!instrument_map) {
@@ -43,19 +43,19 @@ static int midi_gm_open(int patch_len, byte *data, int patch2_len, byte *data2,
writer = sfx_mapped_writer((midi_writer_t *) device, instrument_map);
if (!writer)
- return SFX_ERROR;
+ return Common::kUnknownError;
if (writer->reset_timer)
writer->reset_timer(writer);
- return SFX_OK;
+ return Common::kNoError;
}
-static int midi_gm_close(void) {
- return SFX_OK;
+static Common::Error midi_gm_close(void) {
+ return Common::kNoError;
}
-static int midi_gm_event(byte command, int argc, byte *argv) {
+static Common::Error midi_gm_event(byte command, int argc, byte *argv) {
byte data[4];
assert(argc < 4);
@@ -64,24 +64,24 @@ static int midi_gm_event(byte command, int argc, byte *argv) {
writer->write(writer, data, argc + 1);
- return SFX_OK;
+ return Common::kNoError;
}
-static int midi_gm_delay(int ticks) {
+static Common::Error midi_gm_delay(int ticks) {
writer->delay(writer, ticks);
- return SFX_OK;
+ return Common::kNoError;
}
-static int midi_gm_reset_timer(uint32 ts) {
+static Common::Error midi_gm_reset_timer(uint32 ts) {
writer->reset_timer(writer);
- return SFX_OK;
+ return Common::kNoError;
}
#define MIDI_MASTER_VOLUME_LEN 8
-static int midi_gm_volume(uint8 volume) {
+static Common::Error midi_gm_volume(uint8 volume) {
byte data[MIDI_MASTER_VOLUME_LEN] = {
0xf0,
0x7f,
@@ -97,10 +97,10 @@ static int midi_gm_volume(uint8 volume) {
if (writer->flush)
writer->flush(writer);
- return SFX_OK;
+ return Common::kNoError;
}
-static int midi_gm_allstop(void) {
+static Common::Error midi_gm_allstop(void) {
byte data[3] = { 0xb0,
0x78, /* all sound off */
0
@@ -115,10 +115,10 @@ static int midi_gm_allstop(void) {
if (writer->flush)
writer->flush(writer);
- return SFX_OK;
+ return Common::kNoError;
}
-static int midi_gm_reverb(int reverb) {
+static Common::Error midi_gm_reverb(int reverb) {
byte data[3] = { 0xb0,
91, /* set reverb */
reverb
@@ -134,11 +134,11 @@ static int midi_gm_reverb(int reverb) {
if (writer->flush)
writer->flush(writer);
- return SFX_OK;
+ return Common::kNoError;
}
-static int midi_gm_set_option(char *x, char *y) {
- return SFX_ERROR;
+static Common::Error midi_gm_set_option(char *x, char *y) {
+ return Common::kUnknownError;
}
sfx_sequencer_t sfx_sequencer_gm = {
diff --git a/engines/sci/sfx/seq/instrument-map.cpp b/engines/sci/sfx/seq/instrument-map.cpp
index 14ce623f3e..d9218d8a5b 100644
--- a/engines/sci/sfx/seq/instrument-map.cpp
+++ b/engines/sci/sfx/seq/instrument-map.cpp
@@ -258,31 +258,31 @@ static int bound_hard_127(int i, const char *descr) {
return r;
}
-static int set_bend_range(midi_writer_t *writer, int channel, int range) {
+static Common::Error set_bend_range(midi_writer_t *writer, int channel, int range) {
byte buf[3] = {0xb0, 0x65, 0x00};
buf[0] |= channel & 0xf;
- if (writer->write(writer, buf, 3) != SFX_OK)
- return SFX_ERROR;
+ if (writer->write(writer, buf, 3) != Common::kNoError)
+ return Common::kUnknownError;
buf[1] = 0x64;
- if (writer->write(writer, buf, 3) != SFX_OK)
- return SFX_ERROR;
+ if (writer->write(writer, buf, 3) != Common::kNoError)
+ return Common::kUnknownError;
buf[1] = 0x06;
buf[2] = BOUND_127(range);
- if (writer->write(writer, buf, 3) != SFX_OK)
- return SFX_ERROR;
+ if (writer->write(writer, buf, 3) != Common::kNoError)
+ return Common::kUnknownError;
buf[1] = 0x26;
buf[2] = 0;
- if (writer->write(writer, buf, 3) != SFX_OK)
- return SFX_ERROR;
+ if (writer->write(writer, buf, 3) != Common::kNoError)
+ return Common::kUnknownError;
- return SFX_OK;
+ return Common::kNoError;
}
-static int write_decorated(decorated_midi_writer_t *self, byte *buf, int len) {
+static Common::Error write_decorated(decorated_midi_writer_t *self, byte *buf, int len) {
sfx_instrument_map_t *map = self->map;
int op = *buf & 0xf0;
int chan = *buf & 0x0f;
@@ -300,18 +300,18 @@ static int write_decorated(decorated_midi_writer_t *self, byte *buf, int len) {
self->patches[chan] = map->patch_map[patch];
if (instrument == SFX_UNMAPPED || instrument == SFX_MAPPED_TO_RHYTHM)
- return SFX_OK;
+ return Common::kNoError;
assert(len >= 2);
buf[1] = bound_hard_127(instrument, "patch lookup");
- if (self->writer->write(self->writer, buf, len) != SFX_OK)
- return SFX_ERROR;
+ if (self->writer->write(self->writer, buf, len) != Common::kNoError)
+ return Common::kUnknownError;
if (bend_range != SFX_UNMAPPED)
return set_bend_range(self->writer, chan, bend_range);
- return SFX_OK;
+ return Common::kNoError;
}
if (chan == MIDI_RHYTHM_CHANNEL || patch == SFX_MAPPED_TO_RHYTHM) {
@@ -332,7 +332,7 @@ static int write_decorated(decorated_midi_writer_t *self, byte *buf, int len) {
}
if (instrument == SFX_UNMAPPED)
- return SFX_OK;
+ return Common::kNoError;
assert(len >= 3);
@@ -365,7 +365,7 @@ static int write_decorated(decorated_midi_writer_t *self, byte *buf, int len) {
/* Instrument channel handling */
if (patch == SFX_UNMAPPED)
- return SFX_OK;
+ return Common::kNoError;
switch (op) {
case 0x80:
@@ -485,9 +485,9 @@ midi_writer_t *sfx_mapped_writer(midi_writer_t *writer, sfx_instrument_map_t *ma
strcpy(retval->name, writer->name);
strcat(retval->name, NAME_SUFFIX);
- retval->init = (int (*)(midi_writer_t *)) init_decorated;
- retval->set_option = (int (*)(midi_writer_t *, char *, char *)) set_option_decorated;
- retval->write = (int (*)(midi_writer_t *, byte *, int)) write_decorated;
+ retval->init = (Common::Error (*)(midi_writer_t *)) init_decorated;
+ retval->set_option = (Common::Error (*)(midi_writer_t *, char *, char *)) set_option_decorated;
+ retval->write = (Common::Error (*)(midi_writer_t *, byte *, int)) write_decorated;
retval->delay = (void (*)(midi_writer_t *, int)) delay_decorated;
retval->flush = (void (*)(midi_writer_t *)) flush_decorated;
retval->reset_timer = (void (*)(midi_writer_t *)) reset_timer_decorated;
diff --git a/engines/sci/sfx/seq/oss-adlib.cpp b/engines/sci/sfx/seq/oss-adlib.cpp
index edb21c86e2..45165e4320 100644
--- a/engines/sci/sfx/seq/oss-adlib.cpp
+++ b/engines/sci/sfx/seq/oss-adlib.cpp
@@ -322,11 +322,11 @@ static int midi_adlib_event(byte command, int argc, byte *argv) {
static int midi_adlib_delay(int ticks) {
SEQ_DELTA_TIME(ticks);
- return SFX_OK;
+ return Common::kNoError;
}
static int midi_adlib_set_option(char *name, char *value) {
- return SFX_ERROR; /* No options are supported at this time */
+ return Common::kUnknownError; /* No options are supported at this time */
}
/* the driver struct */
diff --git a/engines/sci/sfx/sequencer.h b/engines/sci/sfx/sequencer.h
index f2f394e6b3..ba9edcdad7 100644
--- a/engines/sci/sfx/sequencer.h
+++ b/engines/sci/sfx/sequencer.h
@@ -29,7 +29,7 @@
#include "common/scummsys.h"
-#include "sci/sfx/sfx.h"
+#include "common/error.h"
#include "sci/sfx/device.h"
namespace Sci {
@@ -42,20 +42,20 @@ struct sfx_sequencer_t {
int device; /* Type of device the sequencer depends on, may be SFX_DEVICE_NONE. */
- int (*set_option)(char *name, char *value);
+ Common::Error (*set_option)(char *name, char *value);
/* Sets an option for the sequencing mechanism
** Parameters: (char *) name: The name describing what to set
** (char *) value: The value to set
- ** Returns : (int) SFX_OK, or SFX_ERROR if the name wasn't understood
+ ** Returns : (int) Common::kNoError, or Common::kUnknownError if the name wasn't understood
*/
- int (*open)(int patch_len, byte *patch, int patch2_len, byte *patch2, void *device);
+ Common::Error (*open)(int patch_len, byte *patch, int patch2_len, byte *patch2, void *device);
/* Opens the sequencer for writing
** Parameters: (int) patch_len, patch2_len: Length of the patch data
** (byte *) patch, patch2: Bulk patch data
** (void *) device: A device matching the 'device' property, or NULL
** if the property is null.
- ** Returns : (int) SFX_OK on success, SFX_ERROR otherwise
+ ** Returns : (int) Common::kNoError on success, Common::kUnknownError otherwise
** The device should be initialized to a tick frequency of 60 Hz.
** 'patch' and 'patch_len' refer to the patch resource passed to open,
** as specified by the 'patchfile' property. 'patch' may be NULL if the
@@ -65,50 +65,50 @@ struct sfx_sequencer_t {
** data.
*/
- int (*close)();
+ Common::Error (*close)();
/* Closes the sequencer
- ** Returns : SFX_OK on success, SFX_ERROR otherwise
+ ** Returns : Common::kNoError on success, Common::kUnknownError otherwise
*/
- int (*event)(byte command, int argc, byte *argv);
+ Common::Error (*event)(byte command, int argc, byte *argv);
/* Plays a MIDI event
** Parameters: (byte) command: MIDI command to play
** (int) argc: Number of arguments to the command
** (byte *) argv: Pointer to additional arguments
- ** Returns : SFX_OK on success, SFX_ERROR otherwise
+ ** Returns : Common::kNoError on success, Common::kUnknownError otherwise
** argv is guaranteed to point to a sufficiently large number of
** arguments, as indicated by 'command' and the MIDI standard.
** No 'running status' will be passed, 'command' will always be
** explicit.
*/
- int (*delay)(int ticks); /* OPTIONAL -- may be NULL, but highly recommended */
+ Common::Error (*delay)(int ticks); /* OPTIONAL -- may be NULL, but highly recommended */
/* Inserts a delay (delta time) into the sequencer cue
** Parameters: (int) ticks: Number of 60 Hz ticks to delay
- ** Returns : SFX_OK on success, SFX_ERROR otherwise
+ ** Returns : Common::kNoError on success, Common::kUnknownError otherwise
*/
- int (*reset_timer)(uint32 ts);
+ Common::Error (*reset_timer)(uint32 ts);
/* OPTIONAL -- may be NULL, but highly recommended in combination with delay() */
/* Resets the timer counter associated with the 'delay()' function
** Parameters: (uint32) ts: Timestamp of the base time
- ** Returns : SFX_OK on success, SFX_ERROR otherwise
+ ** Returns : Common::kNoError on success, Common::kUnknownError otherwise
*/
- int (*allstop)(); /* OPTIONAL -- may be NULL */
+ Common::Error (*allstop)(); /* OPTIONAL -- may be NULL */
/* Stops playing everything in the sequencer queue
- ** Returns : SFX_OK on success, SFX_ERROR otherwise
+ ** Returns : Common::kNoError on success, Common::kUnknownError otherwise
*/
- int (*volume)(uint8 volume); /* OPTIONAL -- can be NULL */
+ Common::Error (*volume)(uint8 volume); /* OPTIONAL -- can be NULL */
/* Sets the sequencer volume
** Parameters; (byte) volume: The volume to set, with 0 being mute and 127 full volume
- ** Returns : SFX_OK on success, SFX_ERROR otherwise
+ ** Returns : Common::kNoError on success, Common::kUnknownError otherwise
*/
- int (*reverb)(int param); /* OPTIONAL -- may be NULL */
+ Common::Error (*reverb)(int param); /* OPTIONAL -- may be NULL */
/* Sets the device reverb
** Parameters; (int) param: The reverb to set
- ** Returns : SFX_OK on success, SFX_ERROR otherwise
+ ** Returns : Common::kNoError on success, Common::kUnknownError otherwise
*/
int patchfile, patchfile2; /* Patch resources to pass into the call to open(),
diff --git a/engines/sci/sfx/sfx.h b/engines/sci/sfx/sfx.h
deleted file mode 100644
index 36fb1c24c1..0000000000
--- a/engines/sci/sfx/sfx.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef SCI_SFX_SFX_CORE_H
-#define SCI_SFX_SFX_CORE_H
-
-#include "common/scummsys.h"
-
-namespace Sci {
-
-#define SFX_OK 0
-#define SFX_ERROR -1
-
-#define MIDI_CHANNELS 16
-
-} // End of namespace Sci
-
-#endif // SCI_SFX_SFX_CORE_H
diff --git a/engines/sci/sfx/sfx_pcm.h b/engines/sci/sfx/sfx_pcm.h
index 6a588ba387..aa3a3e8ea0 100644
--- a/engines/sci/sfx/sfx_pcm.h
+++ b/engines/sci/sfx/sfx_pcm.h
@@ -26,7 +26,7 @@
#ifndef SCI_SFX_SFX_PCM_H
#define SCI_SFX_SFX_PCM_H
-#include "sci/sfx/sfx.h"
+#include "common/error.h"
#include "sound/timestamp.h"
namespace Sci {
diff --git a/engines/sci/sfx/softseq.h b/engines/sci/sfx/softseq.h
index 4070f9e4e5..32ad98f4b9 100644
--- a/engines/sci/sfx/softseq.h
+++ b/engines/sci/sfx/softseq.h
@@ -26,7 +26,7 @@
#ifndef SCI_SFX_SOFTSEQ_H
#define SCI_SFX_SOFTSEQ_H
-#include "sci/sfx/sfx.h"
+#include "common/error.h"
#include "sci/sfx/sfx_pcm.h"
#include "sci/sfx/sequencer.h"
#include "sci/tools.h"
@@ -38,7 +38,7 @@ struct sfx_softseq_t {
const char *name;
const char *version;
- int (*set_option)(sfx_softseq_t *self, const char *name, const char *value);
+ Common::Error (*set_option)(sfx_softseq_t *self, const char *name, const char *value);
/* Sets an option for the sequencer
** Parameters: (sfx_softseq_t *) self: Self reference
** (const char *) name: Name of the option to set
@@ -46,7 +46,7 @@ struct sfx_softseq_t {
** Returns : (int) GFX_OK on success, or GFX_ERROR if not supported
*/
- int (*init)(sfx_softseq_t *self, byte *res_data, int res_size,
+ Common::Error (*init)(sfx_softseq_t *self, byte *res_data, int res_size,
byte *res2_data, int res2_size);
/* Initialises the sequencer
** Parameters: (sfx_softseq_t *) self: Self reference
@@ -54,7 +54,7 @@ struct sfx_softseq_t {
** (int) res_size: Number of bytes in 'res_data'
** (byte *) res2_data: Resource data for 'patch2_nr' (see below)
** (int) res2_size: Number of bytes in 'res2_data'
- ** Returns : (int) SFX_OK on success, SFX_ERROR otherwise
+ ** Returns : (int) Common::kNoError on success, Common::kUnknownError otherwise
** Note that 'res_data' is only a valid pointer for this call. If the
** data is needed later during execution, it should be backed up internally.
** If the requested resource is not available, res_data will be NULL
diff --git a/engines/sci/sfx/softseq/SN76496.cpp b/engines/sci/sfx/softseq/SN76496.cpp
index f63f75ea71..f6892d37d5 100644
--- a/engines/sci/sfx/softseq/SN76496.cpp
+++ b/engines/sci/sfx/softseq/SN76496.cpp
@@ -46,13 +46,13 @@ extern sfx_softseq_t sfx_softseq_pcspeaker;
/* Forward-declare the sequencer we are defining here */
-static int SN76496_set_option(sfx_softseq_t *self, const char *name, const char *value) {
- return SFX_ERROR;
+static Common::Error SN76496_set_option(sfx_softseq_t *self, const char *name, const char *value) {
+ return Common::kUnknownError;
}
-static int SN76496_init(sfx_softseq_t *self, byte *patch, int patch_len, byte *patch2,
+static Common::Error SN76496_init(sfx_softseq_t *self, byte *patch, int patch_len, byte *patch2,
int patch2_len) {
- return SFX_OK;
+ return Common::kNoError;
}
static void SN76496_exit(sfx_softseq_t *self) {
diff --git a/engines/sci/sfx/softseq/amiga.cpp b/engines/sci/sfx/softseq/amiga.cpp
index 11feaebd96..d097ec47f5 100644
--- a/engines/sci/sfx/softseq/amiga.cpp
+++ b/engines/sci/sfx/softseq/amiga.cpp
@@ -446,23 +446,23 @@ static instrument_t *read_instrument(Common::File &file, int *id) {
return instrument;
}
-static int ami_set_option(sfx_softseq_t *self, const char *name, const char *value) {
- return SFX_ERROR;
+static Common::Error ami_set_option(sfx_softseq_t *self, const char *name, const char *value) {
+ return Common::kUnknownError;
}
-static int ami_init(sfx_softseq_t *self, byte *patch, int patch_len, byte *patch2, int patch2_len) {
+static Common::Error ami_init(sfx_softseq_t *self, byte *patch, int patch_len, byte *patch2, int patch2_len) {
Common::File file;
byte header[40];
int i;
if (!file.open("bank.001")) {
sciprintf("[sfx:seq:amiga] Error: file bank.001 not found\n");
- return SFX_ERROR;
+ return Common::kUnknownError;
}
if (file.read(header, 40) < 40) {
sciprintf("[sfx:seq:amiga] Error: failed to read header of file bank.001\n");
- return SFX_ERROR;
+ return Common::kUnknownError;
}
for (i = 0; i < 256; i++)
@@ -491,18 +491,18 @@ static int ami_init(sfx_softseq_t *self, byte *patch, int patch_len, byte *patch
if (!instrument) {
sciprintf("[sfx:seq:amiga] Error: failed to read bank.001\n");
- return SFX_ERROR;
+ return Common::kUnknownError;
}
if (id < 0 || id > 255) {
sciprintf("[sfx:seq:amiga] Error: instrument ID out of bounds\n");
- return SFX_ERROR;
+ return Common::kUnknownError;
}
bank.instruments[id] = instrument;
}
- return SFX_OK;
+ return Common::kNoError;
}
static void ami_exit(sfx_softseq_t *self) {
diff --git a/engines/sci/sfx/softseq/fluidsynth.cpp b/engines/sci/sfx/softseq/fluidsynth.cpp
index 9450ab55de..218e52d24c 100644
--- a/engines/sci/sfx/softseq/fluidsynth.cpp
+++ b/engines/sci/sfx/softseq/fluidsynth.cpp
@@ -51,11 +51,11 @@ static int rpn[16];
/* MIDI writer */
static int fluidsynth_midi_init(struct _midi_writer *self) {
- return SFX_OK;
+ return Common::kNoError;
}
static int fluidsynth_midi_set_option(struct _midi_writer *self, char *name, char *value) {
- return SFX_ERROR;
+ return Common::kUnknownError;
}
static int fluidsynth_midi_write(struct _midi_writer *self, unsigned char *buf, int len) {
@@ -118,7 +118,7 @@ static int fluidsynth_midi_write(struct _midi_writer *self, unsigned char *buf,
} else
sciprintf("FluidSynth: Skipping invalid message of %i bytes.\n", len);
- return SFX_OK;
+ return Common::kNoError;
}
static void fluidsynth_midi_delay(struct _midi_writer *self, int ticks) {
@@ -154,13 +154,13 @@ static int fluidsynth_init(sfx_softseq_t *self, byte *data_ptr, int data_length,
if (0) {
sciprintf("FluidSynth ERROR: Mono sound output not supported.\n");
- return SFX_ERROR;
+ return Common::kUnknownError;
}
gmseq = sfx_find_sequencer("General MIDI");
if (!gmseq) {
sciprintf("FluidSynth ERROR: Unable to find General MIDI sequencer.\n");
- return SFX_ERROR;
+ return Common::kUnknownError;
}
settings = new_fluid_settings();
@@ -170,7 +170,7 @@ static int fluidsynth_init(sfx_softseq_t *self, byte *data_ptr, int data_length,
sciprintf("FluidSynth ERROR: Sample rate '%i' not supported. Valid "
"range is (%i-%i).\n", SAMPLE_RATE, (int) min, (int) max);
delete_fluid_settings(settings);
- return SFX_ERROR;
+ return Common::kUnknownError;
}
fluid_settings_setnum(settings, "synth.sample-rate", SAMPLE_RATE);
@@ -181,13 +181,13 @@ static int fluidsynth_init(sfx_softseq_t *self, byte *data_ptr, int data_length,
if ((sfont_id = fluid_synth_sfload(synth, soundfont, 1)) < 0) {
delete_fluid_synth(synth);
delete_fluid_settings(settings);
- return SFX_ERROR;
+ return Common::kUnknownError;
}
gmseq->open(data_length, data_ptr, data2_length, data2_ptr,
&midi_writer_fluidsynth);
- return SFX_OK;
+ return Common::kNoError;
}
static void fluidsynth_exit(sfx_softseq_t *self) {
@@ -206,7 +206,7 @@ static void fluidsynth_volume(sfx_softseq_t *self, int volume) {
}
static int fluidsynth_set_option(sfx_softseq_t *self, const char *name, const char *value) {
- return SFX_ERROR;
+ return Common::kUnknownError;
}
static void fluidsynth_event(sfx_softseq_t *self, byte cmd, int argc, byte *argv) {
diff --git a/engines/sci/sfx/softseq/opl2.cpp b/engines/sci/sfx/softseq/opl2.cpp
index 9bb231d57d..21fe41962c 100644
--- a/engines/sci/sfx/softseq/opl2.cpp
+++ b/engines/sci/sfx/softseq/opl2.cpp
@@ -46,8 +46,9 @@
#include "sci/tools.h"
#include "sci/sfx/iterator.h"
-#include "../softseq.h"
-#include "../adlib_sbi.h"
+#include "sci/sfx/softseq.h"
+#include "sci/sfx/adlib_sbi.h"
+#include "sci/sfx/sci_midi.h"
#include "sound/fmopl.h"
@@ -404,14 +405,14 @@ static void opl2_poll(sfx_softseq_t *self, byte *dest, int count) {
YM3812UpdateOne(ym3812, ptr, count);
}
-static int opl2_init(sfx_softseq_t *self, byte *data_ptr, int data_length, byte *data2_ptr,
+static Common::Error opl2_init(sfx_softseq_t *self, byte *data_ptr, int data_length, byte *data2_ptr,
int data2_length) {
int i;
/* load up the patch.003 file, parse out the instruments */
if (data_length < 1344) {
sciprintf("[sfx:seq:opl2] Invalid patch.003: Expected %d, got %d\n", 1344, data_length);
- return -1;
+ return Common::kUnknownError;
}
for (i = 0; i < 48; i++)
@@ -423,13 +424,13 @@ static int opl2_init(sfx_softseq_t *self, byte *data_ptr, int data_length, byte
if (!(ym3812 = makeAdlibOPL(SAMPLE_RATE))) {
sciprintf("[sfx:seq:opl2] Failure: Emulator init failed!\n");
- return SFX_ERROR;
+ return Common::kUnknownError;
}
ready = 1;
opl2_allstop(self);
- return SFX_OK;
+ return Common::kNoError;
}
@@ -543,8 +544,8 @@ static void opl2_volume(sfx_softseq_t *self, int volume) {
#endif
}
-int opl2_set_option(sfx_softseq_t *self, const char *name, const char *value) {
- return SFX_ERROR;
+static Common::Error opl2_set_option(sfx_softseq_t *self, const char *name, const char *value) {
+ return Common::kUnknownError;
}
void opl2_event(sfx_softseq_t *self, byte cmd, int argc, byte *argv) {
diff --git a/engines/sci/sfx/softseq/pcspeaker.cpp b/engines/sci/sfx/softseq/pcspeaker.cpp
index c72a71d34b..3a05c7bef9 100644
--- a/engines/sci/sfx/softseq/pcspeaker.cpp
+++ b/engines/sci/sfx/softseq/pcspeaker.cpp
@@ -40,13 +40,13 @@ extern sfx_softseq_t sfx_softseq_pcspeaker;
/* Forward-declare the sequencer we are defining here */
-static int sps_set_option(sfx_softseq_t *self, const char *name, const char *value) {
- return SFX_ERROR;
+static Common::Error sps_set_option(sfx_softseq_t *self, const char *name, const char *value) {
+ return Common::kUnknownError;
}
-static int sps_init(sfx_softseq_t *self, byte *patch, int patch_len, byte *patch2,
+static Common::Error sps_init(sfx_softseq_t *self, byte *patch, int patch_len, byte *patch2,
int patch2_len) {
- return SFX_OK;
+ return Common::kNoError;
}
static void sps_exit(sfx_softseq_t *self) {
@@ -89,7 +89,7 @@ static void sps_event(sfx_softseq_t *self, byte command, int argc, byte *argv) {
#define BASE_NOTE 129 /* A10 */
#define BASE_OCTAVE 10 /* A10, as I said */
-static int freq_table[12] = { /* A4 is 440Hz, halftone map is x |-> ** 2^(x/12) */
+static const int freq_table[12] = { /* A4 is 440Hz, halftone map is x |-> ** 2^(x/12) */
28160, /* A10 */
29834,
31608,