From 005861cb1431c5521160112fee3ba00033fa352b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B6rn=20Andersson?= Date: Tue, 28 Feb 2006 08:49:51 +0000 Subject: [PATCH] This may be needless paranoia, but I always get nervous about order of evaluation when there are multiple side-effects on the same variable (in this case the internal state modified by va_arg()) in the same expression. So let's just humor me and do the va_arg() calls one at a time. svn-id: r20970 --- engines/kyra/sound_adlib.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/engines/kyra/sound_adlib.cpp b/engines/kyra/sound_adlib.cpp index 295e722e422..e15dd5e11c1 100644 --- a/engines/kyra/sound_adlib.cpp +++ b/engines/kyra/sound_adlib.cpp @@ -449,14 +449,19 @@ int AdlibDriver::snd_unkOpcode3(va_list &list) { } int AdlibDriver::snd_readByte(va_list &list) { - uint8 *ptr = _soundData + READ_LE_UINT16(&_soundData[va_arg(list, int) << 1]) + va_arg(list, int); + int a = va_arg(list, int); + int b = va_arg(list, int); + uint8 *ptr = _soundData + READ_LE_UINT16(&_soundData[a << 1]) + b; return *ptr; } int AdlibDriver::snd_writeByte(va_list &list) { - uint8 *ptr = _soundData + READ_LE_UINT16(&_soundData[va_arg(list, int) << 1]) + va_arg(list, int); + int a = va_arg(list, int); + int b = va_arg(list, int); + int c = va_arg(list, int); + uint8 *ptr = _soundData + READ_LE_UINT16(&_soundData[a << 1]) + b; uint8 oldValue = *ptr; - *ptr = (uint8)va_arg(list, int); + *ptr = (uint8)c; return oldValue; } @@ -567,7 +572,7 @@ void AdlibDriver::callbackProcess() { unkOutput1(table); } else { int8 opcode = 0; - while (1 && table.dataptr) { + while (table.dataptr) { uint16 command = READ_LE_UINT16(table.dataptr); table.dataptr += 2; if (command & 0x0080) {