aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorJoost Peters2009-07-26 21:06:53 +0000
committerJoost Peters2009-07-26 21:06:53 +0000
commit6d18ada7ef3df70f59430a6b3466bb76672832f1 (patch)
tree9fe0741d657b3a07b0d3258c46973dbbc94b4566 /engines
parentdc6fa53bad0b50a747f0f4dfa31a5adef24086a5 (diff)
downloadscummvm-rg350-6d18ada7ef3df70f59430a6b3466bb76672832f1.tar.gz
scummvm-rg350-6d18ada7ef3df70f59430a6b3466bb76672832f1.tar.bz2
scummvm-rg350-6d18ada7ef3df70f59430a6b3466bb76672832f1.zip
fix/workaround for cruise crash on OSX
svn-id: r42826
Diffstat (limited to 'engines')
-rw-r--r--engines/cruise/mainDraw.cpp32
-rw-r--r--engines/cruise/mainDraw.h4
2 files changed, 30 insertions, 6 deletions
diff --git a/engines/cruise/mainDraw.cpp b/engines/cruise/mainDraw.cpp
index 2932e6dc7d..047f00ee90 100644
--- a/engines/cruise/mainDraw.cpp
+++ b/engines/cruise/mainDraw.cpp
@@ -206,10 +206,34 @@ int m_first_Y;
int m_scaleValue;
int m_color;
-int16 DIST_3D[512];
-int16 polyBuffer2[512];
-int16 XMIN_XMAX[404];
-int16 polyBuffer4[512];
+/*
+ FIXME: Whether intentional or not, the game often seems to use negative indexing
+ of one or more of the arrays below and expects(?) to end up in the preceding one.
+ This "worked" on many platforms so far, but on OSX apparently the buffers don't
+ occupy contiguous memory, and this causes severe corruption and subsequent crashes.
+ Since I'm not really familiar with how the strange drawing code is supposed to work,
+ or whether this behaviour is intentional or not, the short-term fix is to allocate a big
+ buffer and setup pointers within it. This fixes the crashes I'm seeing without causing any
+ (visual) side-effects.
+ If anyone wants to look, this is easily reproduced by starting the game and examining the rug.
+ drawPolyMode1() will then (indirectly) negatively index polyBuffer4. Good luck!
+*/
+
+//int16 DIST_3D[512];
+//int16 polyBuffer2[512];
+//int16 XMIN_XMAX[404];
+//int16 polyBuffer4[512];
+
+int16 bigPolyBuf[512 + 512 + 404 + 512]; /* consolidates the 4 separate buffers above */
+
+//set up the replacement index pointers.
+int16 *DIST_3D = &bigPolyBuf[0];
+int16 *polyBuffer2 = &bigPolyBuf[512];
+int16 *XMIN_XMAX = &bigPolyBuf[512 + 512];
+int16 *polyBuffer4 = &bigPolyBuf[512 + 512 + 404];
+
+
+
// this function fills the sizeTable for the poly (OLD: mainDrawSub1Sub2)
void getPolySize(int positionX, int positionY, int scale, int sizeTable[4], unsigned char *dataPtr) {
diff --git a/engines/cruise/mainDraw.h b/engines/cruise/mainDraw.h
index dc988b551d..620ac6e4d7 100644
--- a/engines/cruise/mainDraw.h
+++ b/engines/cruise/mainDraw.h
@@ -29,8 +29,8 @@
namespace Cruise {
extern int currentTransparent;
-extern int16 polyBuffer2[512];
-extern int16 XMIN_XMAX[404];
+extern int16 *polyBuffer2;
+extern int16 *XMIN_XMAX;
extern int m_color;
int upscaleValue(int value, int scale);