diff options
Diffstat (limited to 'engines/sci/sound/drivers/amigamac.cpp')
-rw-r--r-- | engines/sci/sound/drivers/amigamac.cpp | 52 |
1 files changed, 24 insertions, 28 deletions
diff --git a/engines/sci/sound/drivers/amigamac.cpp b/engines/sci/sound/drivers/amigamac.cpp index 2f159c23ee..3c750401b9 100644 --- a/engines/sci/sound/drivers/amigamac.cpp +++ b/engines/sci/sound/drivers/amigamac.cpp @@ -24,6 +24,7 @@ #include "sci/sound/drivers/mididriver.h" #include "sci/resource.h" +#include "common/debug-channels.h" #include "common/file.h" #include "common/frac.h" #include "common/memstream.h" @@ -177,7 +178,7 @@ int MidiDriver_AmigaMac::interpolate(int8 *samples, frac_t offset, bool isUnsign int diff = (s2 - s1) << 8; return (s1 << 8) + fracToInt(diff * (offset & FRAC_LO_MASK)); } - + int diff = (samples[x + 1] - samples[x]) << 8; return (samples[x] << 8) + fracToInt(diff * (offset & FRAC_LO_MASK)); } @@ -372,7 +373,7 @@ void MidiDriver_AmigaMac::setOutputFrac(int voice) { fnote -= instrument->baseNote; fnote *= 4; // FIXME: check how SSCI maps this - fnote += (_channels[_voices[voice].hw_channel].pitch - 0x2000) / 169; + fnote += (_channels[_voices[voice].hw_channel].pitch - 0x2000) / 169; while (fnote < 0) { divFact *= 2; @@ -460,9 +461,9 @@ MidiDriver_AmigaMac::InstrumentSample *MidiDriver_AmigaMac::readInstrumentSCI0(C instrument->fixedNote = 101; instrument->mode = header[33]; - instrument->transpose = (int8) header[34]; + instrument->transpose = (int8)header[34]; for (int i = 0; i < 4; i++) { - int length = (int8) header[49 + i]; + int length = (int8)header[49 + i]; if (length == 0 && i > 0) length = 256; @@ -482,13 +483,18 @@ MidiDriver_AmigaMac::InstrumentSample *MidiDriver_AmigaMac::readInstrumentSCI0(C strncpy(instrument->name, (char *) header + 2, 29); instrument->name[29] = 0; - debugC(kDebugLevelSound, "Amiga/Mac driver: Reading instrument %i: \"%s\" (%i bytes)", - *id, instrument->name, size); - debugC(kDebugLevelSound, " Mode: %02x", instrument->mode); - debugC(kDebugLevelSound, " Looping: %s", instrument->mode & kModeLoop ? "on" : "off"); - debugC(kDebugLevelSound, " Pitch changes: %s", instrument->mode & kModePitch ? "on" : "off"); - debugC(kDebugLevelSound, " Segment sizes: %i %i %i", seg_size[0], seg_size[1], seg_size[2]); - debugC(kDebugLevelSound, " Segment offsets: 0 %i %i", loop_offset, (int32)READ_BE_UINT32(header + 43)); + if (DebugMan.isDebugChannelEnabled(kDebugLevelSound)) { + debug("Amiga/Mac driver: Reading instrument %i: \"%s\" (%i bytes)", + *id, instrument->name, size); + debugN(" Mode: %02x (", header[33]); + debugN("looping: %s, ", header[33] & kModeLoop ? "on" : "off"); + debug("pitch changes: %s)", header[33] & kModePitch ? "on" : "off"); + debug(" Transpose: %i", (int8)header[34]); + for (uint i = 0; i < 3; i++) + debug(" Segment %i: %i words @ offset %i", i, (int16)READ_BE_UINT16(header + 35 + 6 * i), (i == 0 ? 0 : (int32)READ_BE_UINT32(header + 31 + 6 * i))); + for (uint i = 0; i < 4; i++) + debug(" Envelope %i: period %i / delta %i / target %i", i, header[49 + i], (int8)header[53 + i], header[57 + i]); + } instrument->samples = (int8 *) malloc(size + 1); if (file.read(instrument->samples, size) < (unsigned int)size) { @@ -503,10 +509,8 @@ MidiDriver_AmigaMac::InstrumentSample *MidiDriver_AmigaMac::readInstrumentSCI0(C if (instrument->mode & kModeLoop) { if (loop_offset + seg_size[1] > size) { -#ifdef DEBUG - warning("Amiga/Mac driver: looping samples extend %i bytes past end of sample block", - loop_offset + seg_size[1] - size); -#endif + debugC(kDebugLevelSound, "Amiga/Mac driver: looping samples extend %i bytes past end of sample block", + loop_offset + seg_size[1] - size); seg_size[1] = size - loop_offset; } @@ -613,7 +617,7 @@ int MidiDriver_AmigaMac::open() { } else if (!loadInstrumentsSCI0Mac(stream)) return Common::kUnknownError; } - + MidiDriver_Emulated::open(); _mixer->playStream(Audio::Mixer::kPlainSoundType, &_mixerSoundHandle, this, -1, _mixer->kMaxChannelVolume, 0, DisposeAfterUse::NO); @@ -667,15 +671,11 @@ void MidiDriver_AmigaMac::send(uint32 b) { break; case 0x0a: // pan // TODO -#ifdef DEBUG - warning("Amiga/Mac driver: ignoring pan 0x%02x event for channel %i", op2, channel); -#endif + debugC(1, kDebugLevelSound, "Amiga/Mac driver: ignoring pan 0x%02x event for channel %i", op2, channel); break; case 0x40: // hold // TODO -#ifdef DEBUG - warning("Amiga/Mac driver: ignoring hold 0x%02x event for channel %i", op2, channel); -#endif + debugC(1, kDebugLevelSound, "Amiga/Mac driver: ignoring hold 0x%02x event for channel %i", op2, channel); break; case 0x4b: // voice mapping break; @@ -760,9 +760,7 @@ bool MidiDriver_AmigaMac::loadInstrumentsSCI0(Common::File &file) { _bank.size = READ_BE_UINT16(header + 38); strncpy(_bank.name, (char *) header + 8, 29); _bank.name[29] = 0; -#ifdef DEBUG - debugN("Amiga/Mac driver: Reading %i instruments from bank \"%s\"\n", _bank.size, _bank.name); -#endif + debugC(kDebugLevelSound, "Amiga/Mac driver: Reading %i instruments from bank \"%s\"", _bank.size, _bank.name); for (uint i = 0; i < _bank.size; i++) { int id; @@ -799,9 +797,7 @@ bool MidiDriver_AmigaMac::loadInstrumentsSCI0Mac(Common::SeekableReadStream &fil _bank.size = 128; strncpy(_bank.name, (char *) header + 8, 29); _bank.name[29] = 0; -#ifdef DEBUG - debugN("Amiga/Mac driver: Reading %i instruments from bank \"%s\"\n", _bank.size, _bank.name); -#endif + debugC(kDebugLevelSound, "Amiga/Mac driver: Reading %i instruments from bank \"%s\"", _bank.size, _bank.name); Common::Array<uint32> instrumentOffsets; instrumentOffsets.resize(_bank.size); |