Skip to content

Commit

Permalink
CINE: Skip resource header in loadSpl.
Browse files Browse the repository at this point in the history
This implements a long standing TODO in PaulaSound::playSound.
  • Loading branch information
Johannes Schickel committed Sep 7, 2012
1 parent 17d6d73 commit b107454
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion engines/cine/anim.cpp
Expand Up @@ -535,7 +535,7 @@ int loadSpl(const char *resourceName, int16 idx) {

entry = idx < 0 ? emptyAnimSpace() : idx;
assert(entry >= 0);
g_cine->_animDataTable[entry].load(dataPtr, ANIM_RAW, g_cine->_partBuffer[foundFileIdx].unpackedSize, 1, foundFileIdx, 0, currentPartName);
g_cine->_animDataTable[entry].load(dataPtr + 0x16, ANIM_RAW, g_cine->_partBuffer[foundFileIdx].unpackedSize - 0x16, 1, foundFileIdx, 0, currentPartName);

free(dataPtr);
return entry + 1;
Expand Down
3 changes: 3 additions & 0 deletions engines/cine/script_fw.cpp
Expand Up @@ -1818,6 +1818,9 @@ int FWScript::o1_playSample() {
if (g_cine->getPlatform() == Common::kPlatformAmiga || g_cine->getPlatform() == Common::kPlatformAtariST) {
if (size == 0xFFFF) {
size = g_cine->_animDataTable[anim]._width * g_cine->_animDataTable[anim]._height;
} else if (size > g_cine->_animDataTable[anim]._width * g_cine->_animDataTable[anim]._height) {
warning("o1_playSample: Got invalid sample size %d for sample %d", size, anim);
size = g_cine->_animDataTable[anim]._width * g_cine->_animDataTable[anim]._height;
}
if (channel < 10) { // || _currentOpcode == 0x78
int channel1, channel2;
Expand Down
4 changes: 1 addition & 3 deletions engines/cine/sound.cpp
Expand Up @@ -1052,12 +1052,10 @@ void PaulaSound::playSound(int channel, int frequency, const uint8 *data, int si
// TODO: handle volume slides and repeat
debugC(5, kCineDebugSound, "PaulaSound::playSound() channel %d size %d", channel, size);
stopSound(channel);
size = MIN<int>(size - SPL_HDR_SIZE, READ_BE_UINT16(data + 4));
// TODO: consider skipping the header in loadSpl directly
if (size > 0) {
byte *sound = (byte *)malloc(size);
if (sound) {
memcpy(sound, data + SPL_HDR_SIZE, size);
memcpy(sound, data, size);
playSoundChannel(channel, frequency, sound, size, volume);
}
}
Expand Down
3 changes: 1 addition & 2 deletions engines/cine/sound.h
Expand Up @@ -95,8 +95,7 @@ class PaulaSound : public Sound {

enum {
PAULA_FREQ = 7093789,
NUM_CHANNELS = 4,
SPL_HDR_SIZE = 22
NUM_CHANNELS = 4
};

protected:
Expand Down

0 comments on commit b107454

Please sign in to comment.