aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorMax Horn2005-05-26 11:30:56 +0000
committerMax Horn2005-05-26 11:30:56 +0000
commitc060d56cc8ef52b5ae7df43c215813d724940398 (patch)
tree1d9423ca161cc7510d32d88090f566ade2d2f3ed /scumm
parentd733a4ec46f18b3cd10d881dc650f3c21f127f44 (diff)
downloadscummvm-rg350-c060d56cc8ef52b5ae7df43c215813d724940398.tar.gz
scummvm-rg350-c060d56cc8ef52b5ae7df43c215813d724940398.tar.bz2
scummvm-rg350-c060d56cc8ef52b5ae7df43c215813d724940398.zip
Properly use operator '%' to compute a queue wrap around, instead of relying on the queue size to be a power of 2 and then abusing the '&' operator
svn-id: r18259
Diffstat (limited to 'scumm')
-rw-r--r--scumm/imuse.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/scumm/imuse.cpp b/scumm/imuse.cpp
index c02fee7876..66994236ef 100644
--- a/scumm/imuse.cpp
+++ b/scumm/imuse.cpp
@@ -376,7 +376,7 @@ void IMuseInternal::handle_marker(uint id, byte data) {
p = _cmd_queue[pos].array;
if (p[0] == TRIGGER_ID && p[1] == id && p[2] == data)
break;
- pos = (pos + 1) & (ARRAYSIZE(_cmd_queue) - 1);
+ pos = (pos + 1) % ARRAYSIZE(_cmd_queue);
}
if (pos == _queue_pos)
@@ -388,7 +388,7 @@ void IMuseInternal::handle_marker(uint id, byte data) {
_trigger_count--;
_queue_cleared = false;
do {
- pos = (pos + 1) & (ARRAYSIZE(_cmd_queue) - 1);
+ pos = (pos + 1) % ARRAYSIZE(_cmd_queue);
if (_queue_pos == pos)
break;
p = _cmd_queue[pos].array;
@@ -460,7 +460,7 @@ int IMuseInternal::get_queue_sound_status(int sound) const {
a = _cmd_queue[i].array;
if (a[0] == COMMAND_ID && a[1] == 8 && a[2] == (uint16)sound)
return 2;
- i = (i + 1) & (ARRAYSIZE(_cmd_queue) - 1);
+ i = (i + 1) % ARRAYSIZE(_cmd_queue);
}
for (i = 0; i < ARRAYSIZE (_deferredCommands); ++i) {
@@ -550,13 +550,13 @@ int IMuseInternal::enqueue_command(int a, int b, int c, int d, int e, int f, int
p[6] = f;
p[7] = g;
- i = (i + 1) & (ARRAYSIZE(_cmd_queue) - 1);
+ i = (i + 1) % ARRAYSIZE(_cmd_queue);
if (_queue_end != i) {
_queue_pos = i;
return 0;
} else {
- _queue_pos = (i - 1) & (ARRAYSIZE(_cmd_queue) - 1);
+ _queue_pos = (i - 1) % ARRAYSIZE(_cmd_queue);
return -1;
}
}
@@ -644,9 +644,9 @@ int IMuseInternal::enqueue_trigger(int sound, int marker) {
p[1] = sound;
p[2] = marker;
- pos = (pos + 1) & (ARRAYSIZE(_cmd_queue) - 1);
+ pos = (pos + 1) % ARRAYSIZE(_cmd_queue);
if (_queue_end == pos) {
- _queue_pos = (pos - 1) & (ARRAYSIZE(_cmd_queue) - 1);
+ _queue_pos = (pos - 1) % ARRAYSIZE(_cmd_queue);
return -1;
}