- minor screen fix for OS

- added new debug channel for sound
- updated 2 opcodes comments

svn-id: r29790
This commit is contained in:
Gregory Montoir 2007-12-09 13:41:59 +00:00
parent 65b11e7a34
commit a94fada0ae
10 changed files with 45 additions and 52 deletions

View File

@ -104,7 +104,9 @@ byte loadBg(const char *bgName) {
ptr += 2;
}
loadRelatedPalette(bgName);
if (g_cine->getGameType() == Cine::GType_FW) {
loadRelatedPalette(bgName);
}
gfxResetRawPage(page2Raw);
gfxConvertSpriteToRaw(page2Raw, ptr, 160, 200);

View File

@ -53,6 +53,7 @@ CineEngine *g_cine;
CineEngine::CineEngine(OSystem *syst, const CINEGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
Common::addSpecialDebugLevel(kCineDebugScript, "Script", "Script debug level");
Common::addSpecialDebugLevel(kCineDebugPart, "Part", "Part debug level");
Common::addSpecialDebugLevel(kCineDebugSound, "Sound", "Sound debug level");
// Setup mixer
if (!_mixer->isReady()) {
@ -72,6 +73,7 @@ CineEngine::~CineEngine() {
freePoldatDat();
freeErrmessDat();
}
Common::clearAllSpecialDebugLevels();
}
int CineEngine::init() {

View File

@ -126,7 +126,8 @@ enum {
enum {
kCineDebugScript = 1 << 0,
kCineDebugPart = 1 << 1
kCineDebugPart = 1 << 1,
kCineDebugSound = 1 << 2
};
enum {

View File

@ -474,6 +474,10 @@ void blitRawScreen(byte *frontBuffer) {
void flip(void) {
blitRawScreen(page1Raw);
if (fadeRequired) {
memcpy(c_palette, tempPalette, sizeof(uint16) * 16);
fadeRequired = false;
}
}
} // End of namespace Cine

View File

@ -214,7 +214,7 @@ void CineEngine::mainLoop(int bootScriptIdx) {
allowPlayerInput = 0;
checkForPendingDataLoadSwitch = 0;
fadeRequired = 0;
fadeRequired = false;
isDrawCommandEnabled = 0;
waitForPlayerClick = 0;
menuCommandLen = 0;

View File

@ -292,7 +292,7 @@ void setupOpcodes() {
{ 0, 0 },
{ o2_loadPart, "s" },
/* 40 */
{ 0, 0 },
{ 0, 0 }, /* o1_closePart, triggered by some scripts (STARTA.PRC 4 for ex.) */
{ o1_loadNewPrcName, "bs" },
{ o1_requestCheckPendingDataLoad, "" },
{ 0, 0 },
@ -1306,11 +1306,9 @@ void o1_blitAndFade() {
debugC(5, kCineDebugScript, "Line: %d: request fadein", _currentLine);
// TODO: use real code
memcpy(c_palette, tempPalette, sizeof(uint16) * 16);
drawOverlays();
fadeRequired = true;
flip();
fadeRequired = 1;
}
void o1_fadeToBlack() {
@ -1595,6 +1593,9 @@ void o1_playSample() {
if (volume < 50) {
volume = 50;
}
if (g_cine->getGameType() == Cine::GType_OS && size == 0) {
return;
}
g_sound->stopMusic();
if (size == 0xFFFF) {
g_sound->playSound(channel, 0, animDataTable[anim].ptr1, 0, 0, 0, volume, 0);
@ -1662,8 +1663,10 @@ void o2_playSampleAlt() {
}
if (animDataTable[num].ptr1) {
if (g_cine->getPlatform() == Common::kPlatformPC) {
// if speaker output is enabled, play sound on it
// if speaker output is available, play sound on it
// if it's another device, don't play anything
// TODO: implement this, it's used in the introduction for example
// on each letter displayed
} else {
g_sound->playSound(channel, frequency, animDataTable[num].ptr1, size, 0, 0, 63, 0);
}
@ -1869,9 +1872,10 @@ void o2_loadBg() {
if (additionalBgTable[param]) {
currentAdditionalBgIdx = param;
//if (adBgVar0 == 0) {
//if (_screenNeedFadeOut == 0) {
// adBgVar1 = 1;
//}
fadeRequired = true;
}
}

View File

@ -744,32 +744,37 @@ PCSound::~PCSound() {
}
void PCSound::loadMusic(const char *name) {
debugC(5, kCineDebugSound, "PCSound::loadMusic('%s')", name);
_player->load(name);
}
void PCSound::playMusic() {
debugC(5, kCineDebugSound, "PCSound::playMusic()");
_player->play();
}
void PCSound::stopMusic() {
debugC(5, kCineDebugSound, "PCSound::stopMusic()");
_player->stop();
}
void PCSound::fadeOutMusic() {
debugC(5, kCineDebugSound, "PCSound::fadeOutMusic()");
_player->fadeOut();
}
void PCSound::playSound(int channel, int frequency, const uint8 *data, int size, int volumeStep, int stepCount, int volume, int repeat) {
debugC(5, kCineDebugSound, "PCSound::playSound() channel %d size %d", channel, size);
_soundDriver->playSample(data, size, channel, volume);
}
void PCSound::stopSound(int channel) {
debugC(5, kCineDebugSound, "PCSound::stopSound() channel %d", channel);
_soundDriver->resetChannel(channel);
}
PaulaSound::PaulaSound(Audio::Mixer *mixer, CineEngine *vm)
: Sound(mixer, vm) {
memset(_soundChannelsTable, 0, sizeof(_soundChannelsTable));
_moduleStream = 0;
}
@ -781,6 +786,7 @@ PaulaSound::~PaulaSound() {
}
void PaulaSound::loadMusic(const char *name) {
debugC(5, kCineDebugSound, "PaulaSound::loadMusic('%s')", name);
if (_vm->getGameType() == GType_FW) {
// look for separate files
Common::File f;
@ -800,6 +806,7 @@ void PaulaSound::loadMusic(const char *name) {
}
void PaulaSound::playMusic() {
debugC(5, kCineDebugSound, "PaulaSound::playMusic()");
_mixer->stopHandle(_moduleHandle);
if (_moduleStream) {
_mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_moduleHandle, _moduleStream);
@ -807,60 +814,45 @@ void PaulaSound::playMusic() {
}
void PaulaSound::stopMusic() {
debugC(5, kCineDebugSound, "PaulaSound::stopMusic()");
_mixer->stopHandle(_moduleHandle);
}
void PaulaSound::fadeOutMusic() {
debugC(5, kCineDebugSound, "PaulaSound::fadeOutMusic()");
// TODO
stopMusic();
}
void PaulaSound::playSound(int channel, int frequency, const uint8 *data, int size, int volumeStep, int stepCount, int volume, int repeat) {
// TODO: handle volume slides and repeat
debugC(5, kCineDebugSound, "PaulaSound::playSound() channel %d size %d", channel, size);
stopSound(channel);
SoundChannel *ch = &_soundChannelsTable[channel];
size = MIN<int>(size - SPL_HDR_SIZE, READ_BE_UINT16(data + 4));
// TODO: consider skipping the header in loadSpl directly
if (size > 0) {
ch->data = (byte *)malloc(size);
if (ch->data) {
memcpy(ch->data, data + SPL_HDR_SIZE, size);
ch->frequency = frequency;
ch->size = size;
ch->volumeStep = volumeStep;
ch->stepCount = stepCount;
ch->step = stepCount;
ch->repeat = repeat != 0;
ch->volume = volume;
byte *sound = (byte *)malloc(size);
if (sound) {
memcpy(sound, data + SPL_HDR_SIZE, size);
playSoundChannel(channel, frequency, sound, size, volume);
}
}
}
void PaulaSound::stopSound(int channel) {
debugC(5, kCineDebugSound, "PaulaSound::stopSound() channel %d", channel);
_mixer->stopHandle(_channelsTable[channel]);
free(_soundChannelsTable[channel].data);
_soundChannelsTable[channel].data = 0;
}
void PaulaSound::update() {
// process volume slides and start sound playback
for (int i = 0; i < NUM_CHANNELS; ++i) {
SoundChannel *ch = &_soundChannelsTable[i];
if (ch->data) {
if (ch->step) {
--ch->step;
continue;
}
ch->step = ch->stepCount;
ch->volume = CLIP(ch->volume + ch->volumeStep, 0, 63);
playSoundChannel(i, ch->frequency, ch->data, ch->size, ch->volume);
ch->data = 0;
}
}
// TODO
}
void PaulaSound::playSoundChannel(int channel, int frequency, uint8 *data, int size, int volume) {
assert(frequency > 0);
frequency = PAULA_FREQ / frequency;
_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_channelsTable[channel], data, size, frequency, 0);
_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_channelsTable[channel], data, size, frequency, Audio::Mixer::FLAG_AUTOFREE);
_mixer->setChannelVolume(_channelsTable[channel], volume * Audio::Mixer::kMaxChannelVolume / 63);
}

View File

@ -102,23 +102,11 @@ public:
SPL_HDR_SIZE = 22
};
struct SoundChannel {
int frequency;
uint8 *data;
int size;
int volumeStep;
int stepCount;
int step;
bool repeat;
int volume;
};
protected:
void playSoundChannel(int channel, int frequency, uint8 *data, int size, int volume);
Audio::SoundHandle _channelsTable[NUM_CHANNELS];
SoundChannel _soundChannelsTable[NUM_CHANNELS];
Audio::SoundHandle _moduleHandle;
Audio::AudioStream *_moduleStream;
};

View File

@ -71,7 +71,7 @@ uint16 allowPlayerInput;
uint16 checkForPendingDataLoadSwitch;
uint16 fadeRequired;
bool fadeRequired;
uint16 isDrawCommandEnabled;
uint16 waitForPlayerClick;
uint16 menuCommandLen;
@ -513,7 +513,7 @@ bool CineEngine::makeLoad(char *saveName) {
globalVars[VAR_MOUSE_X_POS] = 0;
globalVars[VAR_MOUSE_Y_POS] = 0;
fadeRequired = 0;
fadeRequired = false;
for (i = 0; i < 16; i++) {
c_palette[i] = 0;

View File

@ -90,7 +90,7 @@ extern uint16 allowPlayerInput;
extern uint16 checkForPendingDataLoadSwitch;
extern uint16 fadeRequired;
extern bool fadeRequired;
extern uint16 isDrawCommandEnabled;
extern uint16 waitForPlayerClick;
extern uint16 menuCommandLen;