aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/access/room.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 181dcd6c5b..9b830770af 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -289,14 +289,16 @@ void Room::setWallCodes() {
void Room::buildScreen() {
int scrollCol = _vm->_screen->_scrollCol;
- int cnt = _vm->_screen->_vWindowWidth + 1;
int offset = 0;
// Clear current background buffer
_vm->_buffer1.clearBuffer();
+ // WORKAROUND: Original's use of '+ 1' would frequently cause memory overruns
+ int w = MIN(_vm->_screen->_vWindowWidth + 1, _playFieldWidth);
+
// Loop through drawing each column of tiles forming the background
- for (int idx = 0; idx < cnt; offset += TILE_WIDTH, ++idx) {
+ for (int idx = 0; idx < w; offset += TILE_WIDTH, ++idx) {
buildColumn(_vm->_screen->_scrollCol, offset);
++_vm->_screen->_scrollCol;
}