aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--boxes.cpp2
-rw-r--r--costume.cpp2
-rw-r--r--resource.cpp7
-rw-r--r--script_v1.cpp10
-rw-r--r--simon/simon.cpp26
-rw-r--r--sound.cpp70
6 files changed, 97 insertions, 20 deletions
diff --git a/boxes.cpp b/boxes.cpp
index 25db3eb9f7..f8d68dca98 100644
--- a/boxes.cpp
+++ b/boxes.cpp
@@ -71,7 +71,7 @@ byte Scumm::getMaskFromBox(int box)
void Scumm::setBoxFlags(int box, int val)
{
- debug(1, "setBoxFlags(%d, 0x%02x)", box, val);
+ debug(2, "setBoxFlags(%d, 0x%02x)", box, val);
/* FULL_THROTTLE stuff */
if (val & 0xC000) {
diff --git a/costume.cpp b/costume.cpp
index 98a8257fb1..1996613929 100644
--- a/costume.cpp
+++ b/costume.cpp
@@ -1349,7 +1349,7 @@ void CostumeRenderer::setPalette(byte *palette)
byte color;
for (i = 0; i < _loaded._numColors; i++) {
- if (_vm->_vars[_vm->VAR_CURRENT_LIGHTS] & LIGHTMODE_actor_color) {
+ if ((_vm->_vars[_vm->VAR_CURRENT_LIGHTS] & LIGHTMODE_actor_color) || (_vm->_features & GF_AFTER_V6)) {
color = palette[i];
if (color == 255)
color = _loaded._ptr[8 + i];
diff --git a/resource.cpp b/resource.cpp
index 5a214f282f..89e825481f 100644
--- a/resource.cpp
+++ b/resource.cpp
@@ -725,6 +725,11 @@ int Scumm::readSoundResource(int type, int idx)
total_size = fileReadDwordBE();
fileRead(_fileHandle, createResource(type, idx, total_size), total_size - 8);
return 1;
+ } else if (basetag == MKID('Crea')) {
+ fileSeek(_fileHandle, -12, SEEK_CUR);
+ total_size = fileReadDwordBE();
+ fileRead(_fileHandle, createResource(type, idx, total_size), total_size - 8);
+ return 1;
} else {
fprintf(stderr, "WARNING: Unrecognized base tag 0x%08lx in sound %d\n", basetag, idx);
}
@@ -837,7 +842,6 @@ void Scumm::nukeResource(int type, int idx)
{
byte *ptr;
- debug(9, "nukeResource(%s,%d)", resTypeFromId(type), idx);
CHECK_HEAP if (!res.address[type])
return;
@@ -845,6 +849,7 @@ void Scumm::nukeResource(int type, int idx)
assert(idx >= 0 && idx < res.num[type]);
if ((ptr = res.address[type][idx]) != NULL) {
+ debug(9, "nukeResource(%s,%d)", resTypeFromId(type), idx);
res.address[type][idx] = 0;
res.flags[type][idx] = 0;
_allocatedSize -= ((MemBlkHeader *)ptr)->size;
diff --git a/script_v1.cpp b/script_v1.cpp
index 2fa4c55890..c056de812d 100644
--- a/script_v1.cpp
+++ b/script_v1.cpp
@@ -1989,7 +1989,10 @@ void Scumm::o5_roomOps()
FILE *out;
a = getVarOrDirectByte(0x80);
- s = buf;
+
+ // FIXME - check for buffer overflow
+ strcpy(buf, getSavePath());
+ s = buf + strlen(buf);
while ((*s++ = fetchScriptByte()));
// Use buf as filename
@@ -2007,7 +2010,10 @@ void Scumm::o5_roomOps()
FILE *in;
a = getVarOrDirectByte(0x80);
- s = buf;
+
+ // FIXME - check for buffer overflow
+ strcpy(buf, getSavePath());
+ s = buf + strlen(buf);
while ((*s++ = fetchScriptByte()));
// Use buf as filename
diff --git a/simon/simon.cpp b/simon/simon.cpp
index c7e34ccbcb..a60234d7a2 100644
--- a/simon/simon.cpp
+++ b/simon/simon.cpp
@@ -2707,16 +2707,14 @@ void SimonState::timer_proc1()
timer_vga_sprites_2();
#endif
- if (!(_game & GAME_SIMON2)) {
- if (_copy_partial_mode == 1) {
- dx_copy_from_2_to_attached(80, 46, 208 - 80, 94 - 46);
- }
+ if (_copy_partial_mode == 1) {
+ dx_copy_from_2_to_attached(80, 46, 208 - 80, 94 - 46);
+ }
- if (_copy_partial_mode == 2) {
- /* copy partial from attached to 2 */
- dx_copy_from_attached_to_2(176, 61, 320 - 176, 134 - 61);
- _copy_partial_mode = 0;
- }
+ if (_copy_partial_mode == 2) {
+ /* copy partial from attached to 2 */
+ dx_copy_from_attached_to_2(176, 61, 320 - 176, 134 - 61);
+ _copy_partial_mode = 0;
}
/* XXX: more stuff here */
@@ -3206,6 +3204,7 @@ void SimonState::video_toggle_colors(HitArea * ha, byte a, byte b, byte c, byte
if (!(h > 0 && w > 0 && ha->x + w <= 320 && ha->y + h <= 200)) {
warning("Invalid coordinates in video_toggle_colors (%d,%d,%d,%d)", ha->x, ha->y, ha->width,
ha->height);
+ _lock_word &= ~0x8000;
return;
}
@@ -4453,8 +4452,10 @@ bool SimonState::save_game(uint slot, const char *caption)
#endif
f = fopen(gen_savename(slot), "wb");
- if (f == NULL)
+ if (f == NULL) {
+ _lock_word &= ~0x100;
return false;
+ }
fwrite(caption, 1, 0x12, f);
@@ -4559,8 +4560,10 @@ bool SimonState::load_game(uint slot)
#endif
f = fopen(gen_savename(slot), "rb");
- if (f == NULL)
+ if (f == NULL) {
+ _lock_word &= ~0x100;
return false;
+ }
fread(ident, 1, 18, f);
@@ -4568,6 +4571,7 @@ bool SimonState::load_game(uint slot)
if (fileReadBE32(f) != 0xFFFFFFFF || num != _itemarray_inited - 1) {
fclose(f);
+ _lock_word &= ~0x100;
return false;
}
diff --git a/sound.cpp b/sound.cpp
index 777c73d449..2f947a7148 100644
--- a/sound.cpp
+++ b/sound.cpp
@@ -48,6 +48,11 @@ void Sound::addSoundToQueue(int sound) {
_scumm->_vars[_scumm->VAR_LAST_SOUND] = sound;
_scumm->ensureResourceLoaded(rtSound, sound);
addSoundToQueue2(sound);
+ } else {
+ // WARNING ! This may break something, maybe this sould be put inside if(_gameID == GID_FT) ?
+ // But why addSoundToQueue should not queue sound ?
+ _scumm->ensureResourceLoaded(rtSound, sound);
+ addSoundToQueue2(sound);
}
// if (_features & GF_AUDIOTRACKS)
@@ -162,10 +167,59 @@ void Sound::processSoundQues() {
_soundQuePos = 0;
}
+static char * read_creative_voc_file(byte * ptr, int & size, int & rate) {
+ assert(strncmp((char*)ptr, "Creative Voice File\x1A", 20) == 0);
+ int offset = READ_LE_UINT16(ptr+20);
+ short version = READ_LE_UINT16(ptr+22);
+ short code = READ_LE_UINT16(ptr+24);
+ assert(version == 0x010A || version == 0x0114);
+ assert(code == ~version + 0x1234);
+ bool quit = 0;
+ char * ret_sound = 0; size = 0;
+ while(!quit) {
+ int len = READ_LE_UINT32(ptr + offset);
+ offset += 4;
+ int code = len & 0xFF; // FIXME not sure this is endian correct
+ len >>= 8;
+ switch(code) {
+ case 0: quit = 1; break;
+ case 1: {
+ int time_constant = ptr[offset++];
+ int packing = ptr[offset++];
+ len -= 2;
+ rate = 1000000L / (256L - time_constant);
+ debug(9, "VOC Data Bloc : %d, %d, %d", rate, packing, len);
+ if(packing == 0) {
+ if(size) {
+ ret_sound = (char*)realloc(ret_sound, size + len);
+ } else {
+ ret_sound = (char*)malloc(len);
+ }
+ memcpy(ret_sound + size, ptr + offset, len);
+ size += len;
+ } else {
+ warning("VOC file packing %d unsupported", packing);
+ }
+ } break;
+ case 6: // begin of loop
+ debug(3, "loops in Creative files not supported");
+ break;
+ case 7: // end of loop
+ break;
+ default:
+ warning("Invalid code in VOC file : %d", code);
+ //~ quit = 1;
+ break;
+ }
+ offset += len;
+ }
+ debug(9, "VOC Data Size : %d", size);
+ return ret_sound;
+}
+
void Sound::playSound(int sound) {
byte *ptr;
- IMuse *se = _scumm->_imuse;
-
+
ptr = _scumm->getResourceAddress(rtSound, sound);
if (ptr != NULL && READ_UINT32_UNALIGNED(ptr) == MKID('SOUN')) {
ptr += 8;
@@ -180,11 +234,10 @@ void Sound::playSound(int sound) {
_scumm->current_cd_sound = sound;
return;
}
-
// Support for SFX in Monkey Island 1, Mac version
// This is rather hackish right now, but works OK. SFX are not sounding
// 100% correct, though, not sure right now what is causing this.
- if (ptr != NULL && READ_UINT32_UNALIGNED(ptr) == MKID('Mac1')) {
+ else if (ptr != NULL && READ_UINT32_UNALIGNED(ptr) == MKID('Mac1')) {
// Read info from the header
int size = READ_UINT32_UNALIGNED(ptr+0x60);
@@ -216,6 +269,14 @@ void Sound::playSound(int sound) {
_scumm->_mixer->play_raw(NULL, sound, size, rate, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
return;
}
+ else if (ptr != NULL && READ_UINT32_UNALIGNED(ptr) == MKID('Crea')) {
+ int size, rate;
+ char * sound = read_creative_voc_file(ptr, size, rate);
+ if(sound != NULL) {
+ _scumm->_mixer->play_raw(NULL, sound, size, rate, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
+ }
+ return;
+ }
// Support for sampled sound effects in Monkey1 and Monkey2
else if (ptr != NULL && READ_UINT32_UNALIGNED(ptr) == MKID('SBL ')) {
debug(2, "Using SBL sound effect");
@@ -332,6 +393,7 @@ void Sound::playSound(int sound) {
if (_scumm->_gameId == GID_MONKEY_VGA)
return; /* FIXME */
+ IMuse *se = _scumm->_imuse;
if (se) {
_scumm->getResourceAddress(rtSound, sound);
se->start_sound(sound);