Implemented cmdUpdateCues() in the new sound code and fixed a crash when loading music with a resource number of zero

svn-id: r46435
This commit is contained in:
Filippos Karapetis 2009-12-20 16:35:37 +00:00
parent c1eaafcac7
commit c1e90ce3cc
2 changed files with 27 additions and 27 deletions

View file

@ -1809,7 +1809,7 @@ bool ResourceManager::hasSci1Voc900() {
}
SoundResource::SoundResource(uint32 resNumber, ResourceManager *resMan) : _resMan(resMan) {
Resource *res = resNumber ? _resMan->findResource(ResourceId(kResourceTypeSound, resNumber), true) : NULL;
Resource *res = _resMan->findResource(ResourceId(kResourceTypeSound, resNumber), true);
if (!res)
return;

View file

@ -604,6 +604,9 @@ void SoundCommandParser::cmdUpdateHandle(reg_t obj, int16 value) {
}
void SoundCommandParser::cmdUpdateCues(reg_t obj, int16 value) {
if (!obj.segment)
return;
#ifdef USE_OLD_MUSIC_FUNCTIONS
int signal = 0;
int min = 0;
@ -674,35 +677,32 @@ void SoundCommandParser::cmdUpdateCues(reg_t obj, int16 value) {
PUT_SEL32V(_segMan, obj, frame, frame);
}
#else
// TODO
#endif
#if 0
if (hobj == 0)
int slot = _music->findListSlot(obj);
if (slot < 0) {
warning("cmdUpdateCues: Slot not found");
return;
Object obj(hobj);
HEAPHANDLE hnode = obj.getProperty(44); // nodePtr
if (hnode) {
MusicEntry *pSnd = (MusicEntry *)heap2Ptr(hnode);
switch (pSnd->signal) {
case 0:
if (pSnd->dataInc != obj.getProperty(92)) { // dataInc
obj.setProperty(92, pSnd->dataInc); // dataInc
obj.setProperty(17, pSnd->dataInc + 127); // signal
}
if (!GET_SEL32(_segMan, obj, nodePtr).isNull()) {
int16 signal = GET_SEL32V(_segMan, obj, signal);
int16 dataInc = GET_SEL32V(_segMan, obj, dataInc);
switch (signal) {
case 0:
PUT_SEL32V(_segMan, obj, signal, dataInc + 127);
break;
case 0xFFFF:
StopSnd(hobj);
cmdStopHandle(obj, value);
break;
default:
obj.setProperty(17, pSnd->signal); // signal
break;
}
//D13E
pSnd->signal = 0;
obj.setProperty(94, pSnd->ticker / 3600); // .min
obj.setProperty(95, pSnd->ticker % 3600 / 60); // .sec
obj.setProperty(96, pSnd->ticker); // .frame
obj.setProperty(97, pSnd->volume); // volume
uint16 ticker = _music->_playList[slot]->ticker;
PUT_SEL32V(_segMan, obj, min, ticker / 3600);
PUT_SEL32V(_segMan, obj, sec, ticker % 3600 / 60);
PUT_SEL32V(_segMan, obj, frame, ticker);
}
#endif
}