SLUDGE: code formatting
This commit is contained in:
parent
2dddb900c9
commit
ca2ee02496
52 changed files with 2157 additions and 1718 deletions
|
@ -320,7 +320,9 @@ void loadBackDrop(int fileNum, int x, int y) {
|
|||
|
||||
if (!loadHSI(bigDataFile, x, y, false)) {
|
||||
char mess[200];
|
||||
sprintf(mess, "Can't paste overlay image outside scene dimensions\n\nX = %i\nY = %i\nWidth = %i\nHeight = %i", x, y, sceneWidth, sceneHeight);
|
||||
sprintf(mess,
|
||||
"Can't paste overlay image outside scene dimensions\n\nX = %i\nY = %i\nWidth = %i\nHeight = %i",
|
||||
x, y, sceneWidth, sceneHeight);
|
||||
fatal(mess);
|
||||
}
|
||||
|
||||
|
@ -1006,11 +1008,14 @@ bool loadParallax(unsigned short v, unsigned short fracX,
|
|||
|
||||
extern int viewportOffsetX, viewportOffsetY;
|
||||
|
||||
bool loadPng(int &picWidth, int &picHeight, int &realPicWidth, int &realPicHeight, Common::SeekableReadStream *stream, bool reserve) {
|
||||
debug("Loading back drop png.");
|
||||
bool loadPng(int &picWidth, int &picHeight, int &realPicWidth,
|
||||
int &realPicHeight, Common::SeekableReadStream *stream, bool reserve) {
|
||||
debug(kSludgeDebugGraphics, "Loading back drop png.");
|
||||
::Image::PNGDecoder png;
|
||||
if (!png.loadStream(*stream))
|
||||
if (!png.loadStream(*stream)) {
|
||||
debug(kSludgeDebugGraphics, "Back drop is not a png");
|
||||
return false;
|
||||
}
|
||||
backdropSurface.copyFrom(*(png.getSurface()));
|
||||
picWidth = realPicWidth = backdropSurface.w;
|
||||
picHeight = realPicHeight = backdropSurface.h;
|
||||
|
@ -1086,7 +1091,8 @@ bool loadPng(int &picWidth, int &picHeight, int &realPicWidth, int &realPicHeigh
|
|||
#endif
|
||||
}
|
||||
|
||||
bool loadByteArray(int &picWidth, int &picHeight, int &realPicWidth, int &realPicHeight, Common::SeekableReadStream *stream, bool reserve) {
|
||||
bool loadByteArray(int &picWidth, int &picHeight, int &realPicWidth,
|
||||
int &realPicHeight, Common::SeekableReadStream *stream, bool reserve) {
|
||||
#if 0
|
||||
int32_t transCol = reserve ? -1 : 63519;
|
||||
int t1, t2, n;
|
||||
|
@ -1128,17 +1134,25 @@ bool loadByteArray(int &picWidth, int &picHeight, int &realPicWidth, int &realPi
|
|||
#endif
|
||||
}
|
||||
|
||||
bool loadImage(int &picWidth, int &picHeight, int &realPicWidth, int &realPicHeight, Common::SeekableReadStream *stream, int x, int y, bool reserve) {
|
||||
bool loadImage(int &picWidth, int &picHeight, int &realPicWidth,
|
||||
int &realPicHeight, Common::SeekableReadStream *stream, int x, int y,
|
||||
bool reserve) {
|
||||
debug(kSludgeDebugGraphics, "Loading back drop image.");
|
||||
if (!loadPng(picWidth, picHeight, realPicWidth, realPicHeight, stream, reserve)) {
|
||||
if (!loadByteArray(picWidth, picHeight, realPicWidth, realPicHeight, stream, reserve)) {
|
||||
if (!loadPng(picWidth, picHeight, realPicWidth, realPicHeight, stream,
|
||||
reserve)) {
|
||||
if (!loadByteArray(picWidth, picHeight, realPicWidth, realPicHeight,
|
||||
stream, reserve)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (x == IN_THE_CENTRE) x = (sceneWidth - realPicWidth) >> 1;
|
||||
if (y == IN_THE_CENTRE) y = (sceneHeight - realPicHeight) >> 1;
|
||||
if (x < 0 || x + realPicWidth > sceneWidth || y < 0 || y + realPicHeight > sceneHeight) return false;
|
||||
if (x == IN_THE_CENTRE)
|
||||
x = (sceneWidth - realPicWidth) >> 1;
|
||||
if (y == IN_THE_CENTRE)
|
||||
y = (sceneHeight - realPicHeight) >> 1;
|
||||
if (x < 0 || x + realPicWidth > sceneWidth || y < 0
|
||||
|| y + realPicHeight > sceneHeight)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1269,7 +1283,8 @@ bool loadHSI(Common::SeekableReadStream *stream, int x, int y, bool reserve) {
|
|||
int picWidth, picHeight;
|
||||
int realPicWidth, realPicHeight;
|
||||
|
||||
if (!loadImage(picWidth, picHeight, realPicWidth, realPicHeight, stream, x, y, reserve))
|
||||
if (!loadImage(picWidth, picHeight, realPicWidth, realPicHeight, stream, x,
|
||||
y, reserve))
|
||||
return false;
|
||||
#if 0
|
||||
GLuint tmpTex;
|
||||
|
|
|
@ -46,7 +46,6 @@ enum {
|
|||
extern unsigned int winWidth, winHeight, sceneWidth, sceneHeight;
|
||||
extern int lightMapMode;
|
||||
|
||||
|
||||
struct parallaxLayer {
|
||||
#if 0
|
||||
GLubyte *texture;
|
||||
|
|
|
@ -25,7 +25,14 @@
|
|||
|
||||
namespace Sludge {
|
||||
|
||||
enum builtReturn {BR_KEEP_AND_PAUSE, BR_ERROR, BR_CONTINUE, BR_PAUSE, BR_CALLAFUNC, BR_ALREADY_GONE};
|
||||
enum builtReturn {
|
||||
BR_KEEP_AND_PAUSE,
|
||||
BR_ERROR,
|
||||
BR_CONTINUE,
|
||||
BR_PAUSE,
|
||||
BR_CALLAFUNC,
|
||||
BR_ALREADY_GONE
|
||||
};
|
||||
|
||||
bool failSecurityCheck(char *fn);
|
||||
builtReturn callBuiltIn(int whichFunc, int numParams, loadedFunction *fun);
|
||||
|
|
|
@ -42,7 +42,8 @@ inline unsigned short makeGrey(unsigned short int r) {
|
|||
return ((r >> 3) << 11) | ((r >> 2) << 5) | (r >> 3);
|
||||
}
|
||||
|
||||
inline unsigned short makeColour(unsigned short int r, unsigned short int g, unsigned short int b) {
|
||||
inline unsigned short makeColour(unsigned short int r, unsigned short int g,
|
||||
unsigned short int b) {
|
||||
return ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
|
||||
namespace Sludge {
|
||||
|
||||
SludgeConsole::SludgeConsole(SludgeEngine *vm) : GUI::Debugger() {
|
||||
SludgeConsole::SludgeConsole(SludgeEngine *vm) :
|
||||
GUI::Debugger() {
|
||||
_vm = vm;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,20 +25,49 @@
|
|||
|
||||
namespace Sludge {
|
||||
|
||||
enum sludgeCommand {SLU_UNKNOWN,
|
||||
SLU_RETURN, SLU_BRANCH, SLU_BR_ZERO, SLU_SET_GLOBAL,
|
||||
SLU_SET_LOCAL, SLU_LOAD_GLOBAL, SLU_LOAD_LOCAL,
|
||||
SLU_PLUS, SLU_MINUS, SLU_MULT, SLU_DIVIDE,
|
||||
SLU_AND, SLU_OR, SLU_EQUALS, SLU_NOT_EQ, SLU_MODULUS,
|
||||
SLU_LOAD_VALUE, SLU_LOAD_BUILT, SLU_LOAD_FUNC, SLU_CALLIT,
|
||||
SLU_LOAD_STRING, SLU_LOAD_FILE, /*SLU_LOAD_SCENE,*/ SLU_LOAD_OBJTYPE,
|
||||
SLU_NOT, SLU_LOAD_NULL, SLU_STACK_PUSH, SLU_LESSTHAN, SLU_MORETHAN, SLU_NEGATIVE,
|
||||
SLU_UNREG, SLU_LESS_EQUAL, SLU_MORE_EQUAL,
|
||||
enum sludgeCommand {
|
||||
SLU_UNKNOWN,
|
||||
SLU_RETURN,
|
||||
SLU_BRANCH,
|
||||
SLU_BR_ZERO,
|
||||
SLU_SET_GLOBAL,
|
||||
SLU_SET_LOCAL,
|
||||
SLU_LOAD_GLOBAL,
|
||||
SLU_LOAD_LOCAL,
|
||||
SLU_PLUS,
|
||||
SLU_MINUS,
|
||||
SLU_MULT,
|
||||
SLU_DIVIDE,
|
||||
SLU_AND,
|
||||
SLU_OR,
|
||||
SLU_EQUALS,
|
||||
SLU_NOT_EQ,
|
||||
SLU_MODULUS,
|
||||
SLU_LOAD_VALUE,
|
||||
SLU_LOAD_BUILT,
|
||||
SLU_LOAD_FUNC,
|
||||
SLU_CALLIT,
|
||||
SLU_LOAD_STRING,
|
||||
SLU_LOAD_FILE, /*SLU_LOAD_SCENE,*/
|
||||
SLU_LOAD_OBJTYPE,
|
||||
SLU_NOT,
|
||||
SLU_LOAD_NULL,
|
||||
SLU_STACK_PUSH,
|
||||
SLU_LESSTHAN,
|
||||
SLU_MORETHAN,
|
||||
SLU_NEGATIVE,
|
||||
SLU_UNREG,
|
||||
SLU_LESS_EQUAL,
|
||||
SLU_MORE_EQUAL,
|
||||
SLU_INCREMENT_LOCAL,
|
||||
SLU_DECREMENT_LOCAL,
|
||||
SLU_INCREMENT_GLOBAL,
|
||||
SLU_DECREMENT_GLOBAL, SLU_INDEXSET, SLU_INDEXGET,
|
||||
SLU_INCREMENT_INDEX, SLU_DECREMENT_INDEX, SLU_QUICK_PUSH,
|
||||
SLU_DECREMENT_GLOBAL,
|
||||
SLU_INDEXSET,
|
||||
SLU_INDEXGET,
|
||||
SLU_INCREMENT_INDEX,
|
||||
SLU_DECREMENT_INDEX,
|
||||
SLU_QUICK_PUSH,
|
||||
numSludgeCommands
|
||||
};
|
||||
|
||||
|
|
|
@ -82,7 +82,8 @@ void displayCursor() {
|
|||
}
|
||||
|
||||
void pasteCursor(int x, int y, personaAnimation *c) {
|
||||
if (c -> numFrames) pasteSpriteToBackDrop(x, y,
|
||||
if (c->numFrames)
|
||||
pasteSpriteToBackDrop(x, y,
|
||||
c->theSprites->bank.sprites[c->frames[0].frameNum],
|
||||
c->theSprites->bank.myPalette);
|
||||
}
|
||||
|
|
|
@ -42,8 +42,8 @@ bool sliceBusy = true;
|
|||
|
||||
Common::File *bigDataFile = NULL;
|
||||
|
||||
uint32_t startOfDataIndex, startOfTextIndex,
|
||||
startOfSubIndex, startOfObjectIndex;
|
||||
uint32_t startOfDataIndex, startOfTextIndex, startOfSubIndex,
|
||||
startOfObjectIndex;
|
||||
|
||||
bool openSubSlice(int num) {
|
||||
// FILE * dbug = fopen ("debuggy.txt", "at");
|
||||
|
@ -100,7 +100,6 @@ unsigned int openFileFromNum(int num) {
|
|||
return get4bytes(bigDataFile);
|
||||
}
|
||||
|
||||
|
||||
// Converts a string from Windows CP-1252 to UTF-8.
|
||||
// This is needed for old games.
|
||||
char *convertString(char *s) {
|
||||
|
@ -160,7 +159,6 @@ char *convertString(char *s) {
|
|||
}
|
||||
iconv_close(convert);
|
||||
|
||||
|
||||
delete [] sOrig;
|
||||
return copyString(buf = bufOrig);
|
||||
#endif
|
||||
|
@ -199,7 +197,8 @@ void finishAccess() {
|
|||
|
||||
int32_t startIndex;
|
||||
|
||||
void setFileIndices(Common::File *fp, int numLanguages, unsigned int skipBefore) {
|
||||
void setFileIndices(Common::File *fp, int numLanguages,
|
||||
unsigned int skipBefore) {
|
||||
if (fp) {
|
||||
// Keep hold of the file handle, and let things get at it
|
||||
bigDataFile = fp;
|
||||
|
|
|
@ -35,17 +35,15 @@ bool pointInFloorPolygon(floorPolygon &floorPoly, int x, int y) {
|
|||
float xp_i, yp_i;
|
||||
float xp_j, yp_j;
|
||||
|
||||
for (j = floorPoly.numVertices - 1; i < floorPoly.numVertices;
|
||||
j = i ++) {
|
||||
for (j = floorPoly.numVertices - 1; i < floorPoly.numVertices; j = i++) {
|
||||
|
||||
xp_i = currentFloor->vertex[floorPoly.vertexID[i]].x;
|
||||
yp_i = currentFloor->vertex[floorPoly.vertexID[i]].y;
|
||||
xp_j = currentFloor->vertex[floorPoly.vertexID[j]].x;
|
||||
yp_j = currentFloor->vertex[floorPoly.vertexID[j]].y;
|
||||
|
||||
if ((((yp_i <= y) && (y < yp_j)) ||
|
||||
((yp_j <= y) && (y < yp_i))) &&
|
||||
(x < (xp_j - xp_i) * (y - yp_i) / (yp_j - yp_i) + xp_i)) {
|
||||
if ((((yp_i <= y) && (y < yp_j)) || ((yp_j <= y) && (y < yp_i)))
|
||||
&& (x < (xp_j - xp_i) * (y - yp_i) / (yp_j - yp_i) + xp_i)) {
|
||||
|
||||
c = !c;
|
||||
}
|
||||
|
@ -53,7 +51,8 @@ bool pointInFloorPolygon(floorPolygon &floorPoly, int x, int y) {
|
|||
return c;
|
||||
}
|
||||
|
||||
bool getMatchingCorners(floorPolygon &a, floorPolygon &b, int &cornerA, int &cornerB) {
|
||||
bool getMatchingCorners(floorPolygon &a, floorPolygon &b, int &cornerA,
|
||||
int &cornerB) {
|
||||
int sharedVertices = 0;
|
||||
int i, j;
|
||||
|
||||
|
@ -80,7 +79,8 @@ bool polysShareSide(floorPolygon &a, floorPolygon &b) {
|
|||
for (i = 0; i < a.numVertices; i++) {
|
||||
for (j = 0; j < b.numVertices; j++) {
|
||||
if (a.vertexID[i] == b.vertexID[j]) {
|
||||
if (sharedVertices ++) return true;
|
||||
if (sharedVertices++)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,8 @@ void noFloor() {
|
|||
|
||||
bool initFloor() {
|
||||
currentFloor = new flor;
|
||||
if (! checkNew(currentFloor)) return false;
|
||||
if (!checkNew(currentFloor))
|
||||
return false;
|
||||
noFloor();
|
||||
return true;
|
||||
}
|
||||
|
@ -128,14 +129,16 @@ bool setFloor(int fileNum) {
|
|||
|
||||
setResourceForFatal(fileNum);
|
||||
|
||||
if (! openFileFromNum(fileNum)) return false;
|
||||
if (!openFileFromNum(fileNum))
|
||||
return false;
|
||||
|
||||
// Find out how many polygons there are and reserve memory
|
||||
|
||||
currentFloor->originalNum = fileNum;
|
||||
currentFloor->numPolygons = getch(bigDataFile);
|
||||
currentFloor->polygon = new floorPolygon[currentFloor->numPolygons];
|
||||
if (! checkNew(currentFloor -> polygon)) return false;
|
||||
if (!checkNew(currentFloor->polygon))
|
||||
return false;
|
||||
|
||||
// Read in each polygon
|
||||
|
||||
|
@ -144,8 +147,10 @@ bool setFloor(int fileNum) {
|
|||
// Find out how many vertex IDs there are and reserve memory
|
||||
|
||||
currentFloor->polygon[i].numVertices = getch(bigDataFile);
|
||||
currentFloor -> polygon[i].vertexID = new int[currentFloor -> polygon[i].numVertices];
|
||||
if (! checkNew(currentFloor -> polygon[i].vertexID)) return false;
|
||||
currentFloor->polygon[i].vertexID =
|
||||
new int[currentFloor->polygon[i].numVertices];
|
||||
if (!checkNew(currentFloor->polygon[i].vertexID))
|
||||
return false;
|
||||
|
||||
// Read in each vertex ID
|
||||
|
||||
|
@ -158,7 +163,8 @@ bool setFloor(int fileNum) {
|
|||
|
||||
i = get2bytes(bigDataFile);
|
||||
currentFloor->vertex = new POINT[i];
|
||||
if (! checkNew(currentFloor -> vertex)) return false;
|
||||
if (!checkNew(currentFloor->vertex))
|
||||
return false;
|
||||
|
||||
for (j = 0; j < i; j++) {
|
||||
|
||||
|
@ -173,12 +179,14 @@ bool setFloor(int fileNum) {
|
|||
currentFloor->matrix = new int *[currentFloor->numPolygons];
|
||||
int * * distanceMatrix = new int *[currentFloor->numPolygons];
|
||||
|
||||
if (! checkNew(currentFloor -> matrix)) return false;
|
||||
if (!checkNew(currentFloor->matrix))
|
||||
return false;
|
||||
|
||||
for (i = 0; i < currentFloor->numPolygons; i++) {
|
||||
currentFloor->matrix[i] = new int[currentFloor->numPolygons];
|
||||
distanceMatrix[i] = new int[currentFloor->numPolygons];
|
||||
if (! checkNew(currentFloor -> matrix[i])) return false;
|
||||
if (!checkNew(currentFloor->matrix[i]))
|
||||
return false;
|
||||
for (j = 0; j < currentFloor->numPolygons; j++) {
|
||||
currentFloor->matrix[i][j] = -1;
|
||||
distanceMatrix[i][j] = 10000;
|
||||
|
@ -188,7 +196,8 @@ bool setFloor(int fileNum) {
|
|||
for (i = 0; i < currentFloor->numPolygons; i++) {
|
||||
for (j = 0; j < currentFloor->numPolygons; j++) {
|
||||
if (i != j) {
|
||||
if (polysShareSide(currentFloor -> polygon[i], currentFloor -> polygon[j])) {
|
||||
if (polysShareSide(currentFloor->polygon[i],
|
||||
currentFloor->polygon[j])) {
|
||||
currentFloor->matrix[i][j] = j;
|
||||
distanceMatrix[i][j] = 1;
|
||||
}
|
||||
|
@ -213,9 +222,10 @@ bool setFloor(int fileNum) {
|
|||
// OK, so we don't know how to get from i to j...
|
||||
for (int d = 0; d < currentFloor->numPolygons; d++) {
|
||||
if (d != i && d != j) {
|
||||
if (currentFloor -> matrix[i][d] == d &&
|
||||
currentFloor -> matrix[d][j] >= 0 &&
|
||||
distanceMatrix [d][j] <= lookForDistance) {
|
||||
if (currentFloor->matrix[i][d] == d
|
||||
&& currentFloor->matrix[d][j] >= 0
|
||||
&& distanceMatrix[d][j]
|
||||
<= lookForDistance) {
|
||||
|
||||
currentFloor->matrix[i][j] = d;
|
||||
distanceMatrix[i][j] = lookForDistance + 1;
|
||||
|
@ -247,15 +257,21 @@ void drawFloor() {
|
|||
nV = currentFloor->polygon[i].numVertices;
|
||||
if (nV > 1) {
|
||||
for (j = 1; j < nV; j++) {
|
||||
drawLine(currentFloor -> vertex[currentFloor -> polygon[i].vertexID[j - 1]].x,
|
||||
currentFloor -> vertex[currentFloor -> polygon[i].vertexID[j - 1]].y,
|
||||
drawLine(
|
||||
currentFloor->vertex[currentFloor->polygon[i].vertexID[j
|
||||
- 1]].x,
|
||||
currentFloor->vertex[currentFloor->polygon[i].vertexID[j
|
||||
- 1]].y,
|
||||
currentFloor->vertex[currentFloor->polygon[i].vertexID[j]].x,
|
||||
currentFloor->vertex[currentFloor->polygon[i].vertexID[j]].y);
|
||||
}
|
||||
drawLine(currentFloor -> vertex[currentFloor -> polygon[i].vertexID[0]].x,
|
||||
drawLine(
|
||||
currentFloor->vertex[currentFloor->polygon[i].vertexID[0]].x,
|
||||
currentFloor->vertex[currentFloor->polygon[i].vertexID[0]].y,
|
||||
currentFloor -> vertex[currentFloor -> polygon[i].vertexID[nV - 1]].x,
|
||||
currentFloor -> vertex[currentFloor -> polygon[i].vertexID[nV - 1]].y);
|
||||
currentFloor->vertex[currentFloor->polygon[i].vertexID[nV
|
||||
- 1]].x,
|
||||
currentFloor->vertex[currentFloor->polygon[i].vertexID[nV
|
||||
- 1]].y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -270,7 +286,8 @@ int inFloor(int x, int y) {
|
|||
return r;
|
||||
}
|
||||
|
||||
bool closestPointOnLine(int &closestX, int &closestY, int x1, int y1, int x2, int y2, int xP, int yP) {
|
||||
bool closestPointOnLine(int &closestX, int &closestY, int x1, int y1, int x2,
|
||||
int y2, int xP, int yP) {
|
||||
int xDiff = x2 - x1;
|
||||
int yDiff = y2 - y1;
|
||||
|
||||
|
|
|
@ -54,7 +54,8 @@ bool setFloor(int fileNum);
|
|||
void drawFloor();
|
||||
int inFloor(int x, int y);
|
||||
bool getMatchingCorners(floorPolygon &, floorPolygon &, int &, int &);
|
||||
bool closestPointOnLine(int &closestX, int &closestY, int x1, int y1, int x2, int y2, int xP, int yP);
|
||||
bool closestPointOnLine(int &closestX, int &closestY, int x1, int y1, int x2,
|
||||
int y2, int xP, int yP);
|
||||
|
||||
} // End of namespace Sludge
|
||||
|
||||
|
|
|
@ -51,11 +51,14 @@ unsigned int fontTableSize = 0;
|
|||
extern float cameraZoom;
|
||||
|
||||
bool isInFont(char *theText) {
|
||||
if (! fontTableSize) return 0;
|
||||
if (! theText[0]) return 0;
|
||||
if (!fontTableSize)
|
||||
return 0;
|
||||
if (!theText[0])
|
||||
return 0;
|
||||
|
||||
// We don't want to compare strings. Only single characters allowed!
|
||||
if (u8_strlen(theText) > 1) return false;
|
||||
if (u8_strlen(theText) > 1)
|
||||
return false;
|
||||
|
||||
int i = 0;
|
||||
uint32_t c = u8_nextchar(theText, &i);
|
||||
|
@ -72,7 +75,8 @@ int stringWidth(char *theText) {
|
|||
uint32_t c;
|
||||
int xOff = 0;
|
||||
|
||||
if (! fontTableSize) return 0;
|
||||
if (!fontTableSize)
|
||||
return 0;
|
||||
|
||||
while (theText[a]) {
|
||||
c = u8_nextchar(theText, &a);
|
||||
|
@ -87,7 +91,8 @@ void pasteString(char *theText, int xOff, int y, spritePalette &thePal) {
|
|||
int a = 0;
|
||||
uint32_t c;
|
||||
|
||||
if (! fontTableSize) return;
|
||||
if (!fontTableSize)
|
||||
return;
|
||||
|
||||
xOff += (int) ((float) (fontSpace >> 1) / cameraZoom);
|
||||
while (theText[a]) {
|
||||
|
@ -98,12 +103,14 @@ void pasteString(char *theText, int xOff, int y, spritePalette &thePal) {
|
|||
}
|
||||
}
|
||||
|
||||
void pasteStringToBackdrop(char *theText, int xOff, int y, spritePalette &thePal) {
|
||||
void pasteStringToBackdrop(char *theText, int xOff, int y,
|
||||
spritePalette &thePal) {
|
||||
sprite *mySprite;
|
||||
int a = 0;
|
||||
uint32_t c;
|
||||
|
||||
if (! fontTableSize) return;
|
||||
if (!fontTableSize)
|
||||
return;
|
||||
|
||||
xOff += fontSpace >> 1;
|
||||
while (theText[a]) {
|
||||
|
@ -114,12 +121,14 @@ void pasteStringToBackdrop(char *theText, int xOff, int y, spritePalette &thePal
|
|||
}
|
||||
}
|
||||
|
||||
void burnStringToBackdrop(char *theText, int xOff, int y, spritePalette &thePal) {
|
||||
void burnStringToBackdrop(char *theText, int xOff, int y,
|
||||
spritePalette &thePal) {
|
||||
sprite *mySprite;
|
||||
int a = 0;
|
||||
uint32_t c;
|
||||
|
||||
if (! fontTableSize) return;
|
||||
if (!fontTableSize)
|
||||
return;
|
||||
|
||||
xOff += fontSpace >> 1;
|
||||
while (theText[a]) {
|
||||
|
@ -174,17 +183,18 @@ bool loadFont(int filenum, const char *charOrder, int h) {
|
|||
|
||||
loadedFontNum = filenum;
|
||||
|
||||
|
||||
fontTableSize = 0;
|
||||
while (charOrder[a]) {
|
||||
c = u8_nextchar(charOrder, &a);
|
||||
if (c > fontTableSize) fontTableSize = c;
|
||||
if (c > fontTableSize)
|
||||
fontTableSize = c;
|
||||
}
|
||||
fontTableSize++;
|
||||
|
||||
delete[] fontTable;
|
||||
fontTable = new uint32_t[fontTableSize];
|
||||
if (! checkNew(fontTable)) return false;
|
||||
if (!checkNew(fontTable))
|
||||
return false;
|
||||
|
||||
for (a = 0; a < fontTableSize; a++) {
|
||||
fontTable[a] = 0;
|
||||
|
|
|
@ -89,7 +89,6 @@ void freezeGraphics() {
|
|||
int antiAlias = gameSettings.antiAlias;
|
||||
gameSettings.antiAlias = 0;
|
||||
|
||||
|
||||
int x = 0;
|
||||
while (x < winWidth) {
|
||||
int y = 0;
|
||||
|
@ -132,7 +131,6 @@ void freezeGraphics() {
|
|||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
|
||||
// Copy Our ViewPort To The Texture
|
||||
copyTexSubImage2D(GL_TEXTURE_2D, 0, x, y, 0, 0, w, h, freezeTextureName);
|
||||
#endif
|
||||
|
@ -152,7 +150,8 @@ void freezeGraphics() {
|
|||
bool freeze() {
|
||||
debugOut("calling freeze()\n");
|
||||
frozenStuffStruct *newFreezer = new frozenStuffStruct;
|
||||
if (! checkNew(newFreezer)) return false;
|
||||
if (!checkNew(newFreezer))
|
||||
return false;
|
||||
|
||||
// Grab a copy of the current scene
|
||||
freezeGraphics();
|
||||
|
@ -192,7 +191,8 @@ bool freeze() {
|
|||
zBuffer.tex = NULL;
|
||||
#endif
|
||||
// resizeBackdrop kills parallax stuff, light map, z-buffer...
|
||||
if (! resizeBackdrop(winWidth, winHeight)) return fatal("Can't create new temporary backdrop buffer");
|
||||
if (!resizeBackdrop(winWidth, winHeight))
|
||||
return fatal("Can't create new temporary backdrop buffer");
|
||||
|
||||
if (!NPOT_textures) {
|
||||
picWidth = getNextPOT(sceneWidth);
|
||||
|
@ -229,7 +229,8 @@ bool freeze() {
|
|||
allPeople = NULL;
|
||||
|
||||
statusStuff *newStatusStuff = new statusStuff;
|
||||
if (! checkNew(newStatusStuff)) return false;
|
||||
if (!checkNew(newStatusStuff))
|
||||
return false;
|
||||
newFreezer->frozenStatus = copyStatusBarStuff(newStatusStuff);
|
||||
|
||||
newFreezer->allScreenRegions = allScreenRegions;
|
||||
|
@ -246,7 +247,8 @@ bool freeze() {
|
|||
|
||||
newFreezer->currentEvents = currentEvents;
|
||||
currentEvents = new eventHandlers;
|
||||
if (! checkNew(currentEvents)) return false;
|
||||
if (!checkNew(currentEvents))
|
||||
return false;
|
||||
memset(currentEvents, 0, sizeof(eventHandlers));
|
||||
|
||||
newFreezer->next = frozenStuff;
|
||||
|
@ -272,7 +274,8 @@ extern GLubyte *backdropTexture;
|
|||
void unfreeze(bool killImage) {
|
||||
frozenStuffStruct *killMe = frozenStuff;
|
||||
|
||||
if (! frozenStuff) return;
|
||||
if (!frozenStuff)
|
||||
return;
|
||||
|
||||
sceneWidth = frozenStuff->sceneWidth;
|
||||
sceneHeight = frozenStuff->sceneHeight;
|
||||
|
|
|
@ -48,7 +48,6 @@ struct frozenStuffStruct {
|
|||
frozenStuffStruct *next;
|
||||
};
|
||||
|
||||
|
||||
bool freeze();
|
||||
void unfreeze(bool killImage = true);
|
||||
int howFrozen();
|
||||
|
|
|
@ -289,7 +289,6 @@ void drawQuad(GLint program, const GLfloat *vertices, int numTexCoords, ...) {
|
|||
|
||||
}
|
||||
|
||||
|
||||
void setPMVMatrix(GLint program) {
|
||||
glUniformMatrix4fv(glGetUniformLocation(program, "myPMVMatrix"), 1, GL_FALSE, aPMVMatrix);
|
||||
}
|
||||
|
@ -348,7 +347,6 @@ void setPixelCoords(bool pixels) {
|
|||
int desktopW = 0, desktopH = 0;
|
||||
bool runningFullscreen = false;
|
||||
|
||||
|
||||
#if defined(HAVE_GLES2)
|
||||
void saveTexture(GLuint tex, GLubyte *data) {
|
||||
// use an FBO to easily grab the texture...
|
||||
|
@ -823,7 +821,6 @@ void setGraphicsWindow(bool fullscreen, bool restoreGraphics, bool resize) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
reloadSpriteTextures();
|
||||
reloadParallaxTextures();
|
||||
zBuffer.texName = 0;
|
||||
|
@ -923,7 +920,6 @@ void setupOpenGLStuff() {
|
|||
|
||||
}
|
||||
|
||||
|
||||
// I found this function on a coding forum on the 'net.
|
||||
// Looks a bit weird, but it should work.
|
||||
int getNextPOT(int n) {
|
||||
|
|
|
@ -87,7 +87,8 @@ void setPMVMatrix(GLint program);
|
|||
#endif
|
||||
|
||||
void setPixelCoords(bool pixels);
|
||||
void setGraphicsWindow(bool fullscreen, bool restoreGraphics = true, bool resize = false);
|
||||
void setGraphicsWindow(bool fullscreen, bool restoreGraphics = true,
|
||||
bool resize = false);
|
||||
|
||||
void setupOpenGLStuff();
|
||||
|
||||
|
@ -117,6 +118,7 @@ int printOglError(const char *file, int line);
|
|||
#define printOpenGLError() printOglError(__FILE__, __LINE__)
|
||||
#endif
|
||||
|
||||
} // End of namespace Sludge
|
||||
}
|
||||
// End of namespace Sludge
|
||||
|
||||
#endif
|
||||
|
|
|
@ -56,7 +56,6 @@ unsigned int stringToInt(char *s) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
char *getPrefsFilename(char *filename) {
|
||||
// Yes, this trashes the original string, but
|
||||
// we also free it at the end (warning!)...
|
||||
|
@ -92,7 +91,8 @@ void readIniFile(char *filename) {
|
|||
|
||||
Common::File fd;
|
||||
if (!fd.open(langName)) {
|
||||
debug(kSludgeDebugDataLoad, "Fail to open language file : %s", langName);
|
||||
debug(kSludgeDebugDataLoad, "Fail to open language file : %s",
|
||||
langName);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -185,19 +185,23 @@ void saveIniFile(char *filename) {
|
|||
|
||||
void makeLanguageTable(Common::File *table) {
|
||||
languageTable = new int[gameSettings.numLanguages + 1];
|
||||
if (! checkNew(languageTable)) return;
|
||||
if (!checkNew(languageTable))
|
||||
return;
|
||||
|
||||
languageName = new char *[gameSettings.numLanguages + 1];
|
||||
if (! checkNew(languageName)) return;
|
||||
if (!checkNew(languageName))
|
||||
return;
|
||||
|
||||
for (unsigned int i = 0; i <= gameSettings.numLanguages; i++) {
|
||||
languageTable[i] = i ? get2bytes(table) : 0;
|
||||
debug(kSludgeDebugDataLoad, "languageTable %i: %i", i, languageTable[i]);
|
||||
debug(kSludgeDebugDataLoad, "languageTable %i: %i", i,
|
||||
languageTable[i]);
|
||||
languageName[i] = 0;
|
||||
if (gameVersion >= VERSION(2, 0)) {
|
||||
if (gameSettings.numLanguages) {
|
||||
languageName[i] = readString(table);
|
||||
debug(kSludgeDebugDataLoad, "languageName %i: %s\n", i, languageName[i]);
|
||||
debug(kSludgeDebugDataLoad, "languageName %i: %s\n", i,
|
||||
languageName[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +211,8 @@ int getLanguageForFileB() {
|
|||
int indexNum = -1;
|
||||
|
||||
for (unsigned int i = 0; i <= gameSettings.numLanguages; i++) {
|
||||
if (languageTable[i] == gameSettings.languageID) indexNum = i;
|
||||
if (languageTable[i] == gameSettings.languageID)
|
||||
indexNum = i;
|
||||
}
|
||||
|
||||
return indexNum;
|
||||
|
|
|
@ -69,10 +69,8 @@ void drawLine(int x1, int y1, int x2, int y2) {
|
|||
}
|
||||
setPixelCoords(true);
|
||||
|
||||
|
||||
glLineWidth(2.0);
|
||||
|
||||
|
||||
int xoffset = 0;
|
||||
while (xoffset < diffX) {
|
||||
int w = (diffX - xoffset < viewportWidth) ? diffX - xoffset : viewportWidth;
|
||||
|
@ -98,7 +96,6 @@ void drawLine(int x1, int y1, int x2, int y2) {
|
|||
backdropTexW, backdropTexH
|
||||
};
|
||||
|
||||
|
||||
glUseProgram(shader.texture);
|
||||
|
||||
setPMVMatrix(shader.texture);
|
||||
|
@ -118,7 +115,6 @@ void drawLine(int x1, int y1, int x2, int y2) {
|
|||
xo2, -yoffset + diffY, 0,
|
||||
};
|
||||
|
||||
|
||||
glUseProgram(shader.color);
|
||||
|
||||
setPMVMatrix(shader.color);
|
||||
|
|
|
@ -78,7 +78,6 @@ extern parallaxLayer *parallaxStuff; // "
|
|||
extern int lightMapMode; // "
|
||||
extern int languageNum;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Globals (so we know what's saved already and what's a reference
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -114,7 +113,8 @@ void saveStack(variableStack *vs, Common::WriteStream *stream) {
|
|||
}
|
||||
}
|
||||
|
||||
variableStack *loadStack(Common::SeekableReadStream *stream, variableStack **last) {
|
||||
variableStack *loadStack(Common::SeekableReadStream *stream,
|
||||
variableStack **last) {
|
||||
int elements = get2bytes(stream);
|
||||
int a;
|
||||
variableStack *first = NULL;
|
||||
|
@ -122,7 +122,8 @@ variableStack *loadStack(Common::SeekableReadStream *stream, variableStack **las
|
|||
|
||||
for (a = 0; a < elements; ++a) {
|
||||
variableStack *nS = new variableStack;
|
||||
if (!checkNew(nS)) return NULL;
|
||||
if (!checkNew(nS))
|
||||
return NULL;
|
||||
loadVariable(&(nS->thisVar), stream);
|
||||
if (last && a == elements - 1) {
|
||||
stackDebug((stackfp, "Setting last to %p\n", nS));
|
||||
|
@ -152,7 +153,8 @@ bool saveStackRef(stackHandler *vs, Common::WriteStream *stream) {
|
|||
saveStack(vs->first, stream);
|
||||
s = new stackLibrary;
|
||||
stackLibTotal++;
|
||||
if (! checkNew(s)) return false;
|
||||
if (!checkNew(s))
|
||||
return false;
|
||||
s->next = stackLib;
|
||||
s->stack = vs;
|
||||
stackLib = s;
|
||||
|
@ -192,7 +194,8 @@ stackHandler *loadStackRef(Common::SeekableReadStream *stream) {
|
|||
// Load the new stack
|
||||
|
||||
nsh = new stackHandler;
|
||||
if (! checkNew(nsh)) return NULL;
|
||||
if (!checkNew(nsh))
|
||||
return NULL;
|
||||
nsh->last = NULL;
|
||||
nsh->first = loadStack(stream, &nsh->last);
|
||||
nsh->timesUsed = 1;
|
||||
|
@ -206,7 +209,8 @@ stackHandler *loadStackRef(Common::SeekableReadStream *stream) {
|
|||
// Add it to the library of loaded stacks
|
||||
|
||||
stackLibrary *s = new stackLibrary;
|
||||
if (! checkNew(s)) return NULL;
|
||||
if (!checkNew(s))
|
||||
return NULL;
|
||||
s->stack = nsh;
|
||||
s->next = stackLib;
|
||||
stackLib = s;
|
||||
|
@ -258,8 +262,7 @@ bool saveVariable(variable *from, Common::WriteStream *stream) {
|
|||
default:
|
||||
fatal("Can't save variables of this type:",
|
||||
(from->varType < SVT_NUM_TYPES) ?
|
||||
typeName[from->varType] :
|
||||
"bad ID");
|
||||
typeName[from->varType] : "bad ID");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -292,13 +295,15 @@ bool loadVariable(variable *to, Common::SeekableReadStream *stream) {
|
|||
|
||||
case SVT_COSTUME:
|
||||
to->varData.costumeHandler = new persona;
|
||||
if (! checkNew(to->varData.costumeHandler)) return false;
|
||||
if (!checkNew(to->varData.costumeHandler))
|
||||
return false;
|
||||
loadCostume(to->varData.costumeHandler, stream);
|
||||
return true;
|
||||
|
||||
case SVT_ANIM:
|
||||
to->varData.animHandler = new personaAnimation;
|
||||
if (! checkNew(to->varData.animHandler)) return false;
|
||||
if (!checkNew(to->varData.animHandler))
|
||||
return false;
|
||||
loadAnim(to->varData.animHandler, stream);
|
||||
return true;
|
||||
|
||||
|
@ -342,7 +347,8 @@ loadedFunction *loadFunction(Common::SeekableReadStream *stream) {
|
|||
// Reserve memory...
|
||||
|
||||
loadedFunction *buildFunc = new loadedFunction;
|
||||
if (! checkNew(buildFunc)) return NULL;
|
||||
if (!checkNew(buildFunc))
|
||||
return NULL;
|
||||
|
||||
// See what it was called by and load if we need to...
|
||||
|
||||
|
@ -350,7 +356,8 @@ loadedFunction *loadFunction(Common::SeekableReadStream *stream) {
|
|||
buildFunc->calledBy = NULL;
|
||||
if (getch(stream)) {
|
||||
buildFunc->calledBy = loadFunction(stream);
|
||||
if (! buildFunc->calledBy) return NULL;
|
||||
if (!buildFunc->calledBy)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
buildFunc->timeLeft = get4bytes(stream);
|
||||
|
@ -579,7 +586,6 @@ bool loadGame(char *fname) {
|
|||
loadedFunction *rFunc;
|
||||
loadedFunction * * buildList = &allRunningFunctions;
|
||||
|
||||
|
||||
int countFunctions = get2bytes(fp);
|
||||
while (countFunctions --) {
|
||||
rFunc = loadFunction(fp);
|
||||
|
@ -595,7 +601,6 @@ bool loadGame(char *fname) {
|
|||
|
||||
loadPeople(fp);
|
||||
|
||||
|
||||
if (fgetc(fp)) {
|
||||
if (! setFloor(get2bytes(fp))) return false;
|
||||
} else setFloorNull();
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include <time.h>
|
||||
|
@ -348,7 +347,6 @@ try
|
|||
time_t t;
|
||||
srand((unsigned) time(&t));
|
||||
|
||||
|
||||
// bundleFolder is used to look for the game file
|
||||
// and later to find the shader programs
|
||||
#ifdef __APPLE__
|
||||
|
@ -392,11 +390,13 @@ try
|
|||
|
||||
// The player pressed cancel in the file selection dialogue,
|
||||
// so we should quit now.
|
||||
if (!sludgeFile) return 0;
|
||||
if (!sludgeFile)
|
||||
return 0;
|
||||
|
||||
// OK, so we DO want to start up, then...
|
||||
setGameFilePath(sludgeFile);
|
||||
if (!initSludge(sludgeFile)) return 0;
|
||||
if (!initSludge(sludgeFile))
|
||||
return 0;
|
||||
|
||||
#if 0
|
||||
/* Initialize the SDL library */
|
||||
|
@ -430,12 +430,16 @@ try
|
|||
|
||||
registerWindowForFatal();
|
||||
|
||||
if (!resizeBackdrop(winWidth, winHeight)) return fatal("Couldn't allocate memory for backdrop");
|
||||
if (!resizeBackdrop(winWidth, winHeight))
|
||||
return fatal("Couldn't allocate memory for backdrop");
|
||||
|
||||
blankScreen(0, 0, winWidth, winHeight);
|
||||
if (!initPeople()) return fatal("Couldn't initialise people stuff");
|
||||
if (!initFloor()) return fatal("Couldn't initialise floor stuff");
|
||||
if (!initObjectTypes()) return fatal("Couldn't initialise object type stuff");
|
||||
if (!initPeople())
|
||||
return fatal("Couldn't initialise people stuff");
|
||||
if (!initFloor())
|
||||
return fatal("Couldn't initialise floor stuff");
|
||||
if (!initObjectTypes())
|
||||
return fatal("Couldn't initialise object type stuff");
|
||||
initSpeech();
|
||||
initStatusBar();
|
||||
resetRandW();
|
||||
|
@ -473,7 +477,9 @@ try
|
|||
walkAllPeople();
|
||||
handleInput();
|
||||
sludgeDisplay();
|
||||
g_system->copyRectToScreen(backdropSurface.getPixels(), backdropSurface.pitch, 0, 0, backdropSurface.w, backdropSurface.h);
|
||||
g_system->copyRectToScreen(backdropSurface.getPixels(),
|
||||
backdropSurface.pitch, 0, 0, backdropSurface.w,
|
||||
backdropSurface.h);
|
||||
g_system->updateScreen();
|
||||
#if 0
|
||||
Wait_Frame();
|
||||
|
@ -509,4 +515,5 @@ catch (std::exception &ex) { //NOTE by reference, not value
|
|||
}
|
||||
#endif
|
||||
|
||||
} // End of namespace Sludge
|
||||
}
|
||||
// End of namespace Sludge
|
||||
|
|
|
@ -70,7 +70,6 @@ void writeString(char *s, Common::WriteStream *stream) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
char *readString(Common::SeekableReadStream *stream) {
|
||||
int a, len = get2bytes(stream);
|
||||
char *s = new char[len + 1];
|
||||
|
@ -99,7 +98,6 @@ float floatSwap(float f) {
|
|||
return dat2.f;
|
||||
}
|
||||
|
||||
|
||||
float getFloat(Common::SeekableReadStream *stream) {
|
||||
float f;
|
||||
size_t bytes_read = stream->read(&f, sizeof(float));
|
||||
|
@ -132,7 +130,6 @@ short shortSwap(short s) {
|
|||
return (b1 << 8) + b2;
|
||||
}
|
||||
|
||||
|
||||
short getSigned(Common::SeekableReadStream *stream) {
|
||||
short f;
|
||||
size_t bytes_read = stream->read(&f, sizeof(short));
|
||||
|
@ -152,7 +149,6 @@ void putSigned(short f, Common::WriteStream *stream) {
|
|||
stream->write(&f, sizeof(short));
|
||||
}
|
||||
|
||||
|
||||
// The following two functions treat signed integers as unsigned.
|
||||
// That's done on purpose.
|
||||
|
||||
|
@ -169,7 +165,6 @@ int32_t get4bytes(Common::SeekableReadStream *stream) {
|
|||
return x;
|
||||
}
|
||||
|
||||
|
||||
void put4bytes(unsigned int i, Common::WriteStream *stream) {
|
||||
unsigned char f1, f2, f3, f4;
|
||||
|
||||
|
@ -187,10 +182,12 @@ void put4bytes(unsigned int i, Common::WriteStream *stream) {
|
|||
}
|
||||
|
||||
char *encodeFilename(char *nameIn) {
|
||||
if (!nameIn) return NULL;
|
||||
if (!nameIn)
|
||||
return NULL;
|
||||
if (allowAnyFilename) {
|
||||
char *newName = new char[strlen(nameIn) * 2 + 1];
|
||||
if (!checkNew(newName)) return NULL;
|
||||
if (!checkNew(newName))
|
||||
return NULL;
|
||||
|
||||
int i = 0;
|
||||
while (*nameIn) {
|
||||
|
@ -250,7 +247,8 @@ char *encodeFilename(char *nameIn) {
|
|||
#ifdef _WIN32
|
||||
if (nameIn[a] == '/') nameIn[a] = '\\';
|
||||
#else
|
||||
if (nameIn[a] == '\\') nameIn[a] = '/';
|
||||
if (nameIn[a] == '\\')
|
||||
nameIn[a] = '/';
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -261,7 +259,8 @@ char *encodeFilename(char *nameIn) {
|
|||
char *decodeFilename(char *nameIn) {
|
||||
if (allowAnyFilename) {
|
||||
char *newName = new char[strlen(nameIn) + 1];
|
||||
if (!checkNew(newName)) return NULL;
|
||||
if (!checkNew(newName))
|
||||
return NULL;
|
||||
|
||||
int i = 0;
|
||||
while (*nameIn) {
|
||||
|
|
|
@ -126,7 +126,6 @@ typedef struct videoQueue {
|
|||
|
||||
videoQueue videoQ;
|
||||
|
||||
|
||||
void audio_queue_init(audioQueue *q) {
|
||||
memset(q, 0, sizeof(audioQueue));
|
||||
|
||||
|
@ -161,7 +160,6 @@ int audio_queue_put(audioQueue *q, char *buffer, unsigned int size, long long ti
|
|||
inline static int audio_queue_get(audioQueue *q, char **buffer) {
|
||||
int ret = 0;
|
||||
|
||||
|
||||
audioBuffers *audioBuf;
|
||||
|
||||
SDL_LockMutex(q->mutex);
|
||||
|
@ -540,12 +538,10 @@ int playMovie(int fileNumber) {
|
|||
fatal("Movie error: Segment has no clusters.\n");
|
||||
}
|
||||
|
||||
|
||||
/* Initialize video codec */
|
||||
if (vpx_codec_dec_init(&codec, interface, NULL, 0))
|
||||
die_codec(&codec, "Failed to initialize decoder for movie.");
|
||||
|
||||
|
||||
unsigned char *frame = new unsigned char[256 * 1024];
|
||||
if (! checkNew(frame)) return false;
|
||||
|
||||
|
@ -683,7 +679,6 @@ int playMovie(int fileNumber) {
|
|||
|
||||
theFrame.Read(&reader, frame);
|
||||
|
||||
|
||||
/* Decode the frame */
|
||||
if (vpx_codec_decode(&codec, frame, size, NULL, 0))
|
||||
die_codec(&codec, "Failed to decode frame");
|
||||
|
@ -730,7 +725,6 @@ int playMovie(int fileNumber) {
|
|||
video_queue_put(&videoQ, ytex, utex, vtex,
|
||||
img->d_w, img->d_h, time_ns / 1000000);
|
||||
|
||||
|
||||
}
|
||||
|
||||
} else if (trackNum == audioTrack) {
|
||||
|
@ -879,7 +873,6 @@ movieHasEnded:
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, yTextureName);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h,
|
||||
GL_ALPHA, GL_UNSIGNED_BYTE, ytex);
|
||||
|
@ -946,7 +939,6 @@ movieHasEnded:
|
|||
|
||||
glUseProgram(0);
|
||||
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
Wait_Frame();
|
||||
|
@ -971,11 +963,9 @@ movieHasEnded:
|
|||
for (int i = 0; i < 10; i++) Wait_Frame();
|
||||
huntKillFreeSound(fileNumber);
|
||||
|
||||
|
||||
if (vpx_codec_destroy(&codec))
|
||||
die_codec(&codec, "Failed to destroy codec");
|
||||
|
||||
|
||||
vorbis_dsp_clear(&vorbisDspState);
|
||||
vorbis_block_clear(&vorbisBlock);
|
||||
vorbis_comment_clear(&vorbisComment);
|
||||
|
|
|
@ -28,9 +28,7 @@ namespace Sludge {
|
|||
movieIsPlaying tracks the state of movie playing
|
||||
*/
|
||||
enum movieStates {
|
||||
nothing = 0,
|
||||
playing,
|
||||
paused
|
||||
nothing = 0, playing, paused
|
||||
};
|
||||
extern movieStates movieIsPlaying;
|
||||
|
||||
|
|
|
@ -41,7 +41,9 @@ namespace Sludge {
|
|||
const char emergencyMemoryMessage[] = "Out of memory displaying error message!";
|
||||
|
||||
static char *fatalMessage = NULL;
|
||||
static char *fatalInfo = joinStrings("Initialisation error! Something went wrong before we even got started!", "");
|
||||
static char *fatalInfo =
|
||||
joinStrings("Initialisation error! Something went wrong before we even got started!",
|
||||
"");
|
||||
|
||||
extern int numResourceNames /* = 0*/;
|
||||
extern char * *allResourceNames /*= NULL*/;
|
||||
|
@ -49,14 +51,18 @@ extern char * *allResourceNames /*= NULL*/;
|
|||
int resourceForFatal = -1;
|
||||
|
||||
const char *resourceNameFromNum(int i) {
|
||||
if (i == -1) return NULL;
|
||||
if (numResourceNames == 0) return "RESOURCE";
|
||||
if (i < numResourceNames) return allResourceNames[i];
|
||||
if (i == -1)
|
||||
return NULL;
|
||||
if (numResourceNames == 0)
|
||||
return "RESOURCE";
|
||||
if (i < numResourceNames)
|
||||
return allResourceNames[i];
|
||||
return "Unknown resource";
|
||||
}
|
||||
|
||||
bool hasFatal() {
|
||||
if (fatalMessage) return true;
|
||||
if (fatalMessage)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -77,7 +83,10 @@ void warning(const char *l) {
|
|||
|
||||
void registerWindowForFatal() {
|
||||
delete fatalInfo;
|
||||
fatalInfo = joinStrings("There's an error with this SLUDGE game! If you're designing this game, please turn on verbose error messages in the project manager and recompile. If not, please contact the author saying where and how this problem occured.", "");
|
||||
fatalInfo =
|
||||
joinStrings(
|
||||
"There's an error with this SLUDGE game! If you're designing this game, please turn on verbose error messages in the project manager and recompile. If not, please contact the author saying where and how this problem occured.",
|
||||
"");
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -93,8 +102,8 @@ int inFatal(const char *str) {
|
|||
}
|
||||
#endif
|
||||
fatalMessage = copyString(str);
|
||||
if (fatalMessage == NULL) fatalMessage = copyString("Out of memory");
|
||||
|
||||
if (fatalMessage == NULL)
|
||||
fatalMessage = copyString("Out of memory");
|
||||
|
||||
killSoundStuff();
|
||||
|
||||
|
@ -121,7 +130,9 @@ int checkNew(const void *mem) {
|
|||
void setFatalInfo(const char *userFunc, const char *BIF) {
|
||||
delete fatalInfo;
|
||||
fatalInfo = new char[strlen(userFunc) + strlen(BIF) + 38];
|
||||
if (fatalInfo) sprintf(fatalInfo, "Currently in this sub: %s\nCalling: %s", userFunc, BIF);
|
||||
if (fatalInfo)
|
||||
sprintf(fatalInfo, "Currently in this sub: %s\nCalling: %s", userFunc,
|
||||
BIF);
|
||||
debug("%s", fatalInfo);
|
||||
}
|
||||
|
||||
|
@ -132,17 +143,20 @@ void setResourceForFatal(int n) {
|
|||
int fatal(const char *str1) {
|
||||
if (numResourceNames && resourceForFatal != -1) {
|
||||
const char *r = resourceNameFromNum(resourceForFatal);
|
||||
char *newStr = new char[strlen(str1) + strlen(r) + strlen(fatalInfo) + 14];
|
||||
char *newStr = new char[strlen(str1) + strlen(r) + strlen(fatalInfo)
|
||||
+ 14];
|
||||
if (checkNew(newStr)) {
|
||||
sprintf(newStr, "%s\nResource: %s\n\n%s", fatalInfo, r, str1);
|
||||
inFatal(newStr);
|
||||
} else fatal(emergencyMemoryMessage);
|
||||
} else
|
||||
fatal(emergencyMemoryMessage);
|
||||
} else {
|
||||
char *newStr = new char[strlen(str1) + strlen(fatalInfo) + 3];
|
||||
if (checkNew(newStr)) {
|
||||
sprintf(newStr, "%s\n\n%s", fatalInfo, str1);
|
||||
inFatal(newStr);
|
||||
} else fatal(emergencyMemoryMessage);
|
||||
} else
|
||||
fatal(emergencyMemoryMessage);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -152,7 +166,8 @@ int fatal(const char *str1, const char *str2) {
|
|||
if (checkNew(newStr)) {
|
||||
sprintf(newStr, "%s %s", str1, str2);
|
||||
fatal(newStr);
|
||||
} else fatal(emergencyMemoryMessage);
|
||||
} else
|
||||
fatal(emergencyMemoryMessage);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,8 @@ objectType *findObjectType(int i) {
|
|||
objectType *huntType = allObjectTypes;
|
||||
|
||||
while (huntType) {
|
||||
if (huntType -> objectNum == i) return huntType;
|
||||
if (huntType->objectNum == i)
|
||||
return huntType;
|
||||
huntType = huntType->next;
|
||||
}
|
||||
|
||||
|
@ -78,7 +79,8 @@ objectType *loadObjectType(int i) {
|
|||
}
|
||||
|
||||
newType->numCom = get2bytes(bigDataFile);
|
||||
newType -> allCombis = (newType -> numCom) ? new combination[newType -> numCom] : NULL;
|
||||
newType->allCombis =
|
||||
(newType->numCom) ? new combination[newType->numCom] : NULL;
|
||||
|
||||
#if DEBUG_COMBINATIONS
|
||||
FILE *callEventLog = fopen("callEventLog.txt", "at");
|
||||
|
|
|
@ -71,7 +71,8 @@ inline int TF_abs(int a) {
|
|||
}
|
||||
|
||||
void setFrames(onScreenPerson &m, int a) {
|
||||
m.myAnim = m.myPersona->animation[(a * m.myPersona->numDirections) + m.direction];
|
||||
m.myAnim = m.myPersona->animation[(a * m.myPersona->numDirections)
|
||||
+ m.direction];
|
||||
}
|
||||
|
||||
personaAnimation *createPersonaAnim(int num, variableStack *&stacky) {
|
||||
|
@ -92,8 +93,10 @@ personaAnimation *createPersonaAnim(int num, variableStack *&stacky) {
|
|||
} else if (stacky->thisVar.varType == SVT_FUNC) {
|
||||
newP->frames[a].noise = -stacky->thisVar.varData.intValue;
|
||||
} else if (stacky->thisVar.varType == SVT_STACK) {
|
||||
getValueType(frameNum, SVT_INT, stacky->thisVar.varData.theStack->first->thisVar);
|
||||
getValueType(howMany, SVT_INT, stacky->thisVar.varData.theStack->first->next->thisVar);
|
||||
getValueType(frameNum, SVT_INT,
|
||||
stacky->thisVar.varData.theStack->first->thisVar);
|
||||
getValueType(howMany, SVT_INT,
|
||||
stacky->thisVar.varData.theStack->first->next->thisVar);
|
||||
} else {
|
||||
getValueType(frameNum, SVT_INT, stacky->thisVar);
|
||||
howMany = 1;
|
||||
|
@ -108,8 +111,8 @@ personaAnimation *createPersonaAnim(int num, variableStack *&stacky) {
|
|||
|
||||
personaAnimation *makeNullAnim() {
|
||||
personaAnimation *newAnim = new personaAnimation;
|
||||
if (!checkNew(newAnim)) return NULL;
|
||||
|
||||
if (!checkNew(newAnim))
|
||||
return NULL;
|
||||
|
||||
newAnim->theSprites = NULL;
|
||||
newAnim->numFrames = 0;
|
||||
|
@ -121,7 +124,8 @@ personaAnimation *copyAnim(personaAnimation *orig) {
|
|||
int num = orig->numFrames;
|
||||
|
||||
personaAnimation *newAnim = new personaAnimation;
|
||||
if (!checkNew(newAnim)) return NULL;
|
||||
if (!checkNew(newAnim))
|
||||
return NULL;
|
||||
|
||||
// Copy the easy bits...
|
||||
newAnim->theSprites = orig->theSprites;
|
||||
|
@ -132,7 +136,8 @@ personaAnimation *copyAnim(personaAnimation *orig) {
|
|||
// Argh!Frames!We need a whole NEW array of animFrame structures...
|
||||
|
||||
newAnim->frames = new animFrame[num];
|
||||
if (!checkNew(newAnim->frames)) return NULL;
|
||||
if (!checkNew(newAnim->frames))
|
||||
return NULL;
|
||||
|
||||
for (int a = 0; a < num; ++a) {
|
||||
newAnim->frames[a].frameNum = orig->frames[a].frameNum;
|
||||
|
@ -161,7 +166,8 @@ void turnMeAngle(onScreenPerson *thisPerson, int direc) {
|
|||
int d = thisPerson->myPersona->numDirections;
|
||||
thisPerson->angle = direc;
|
||||
direc += (180 / d) + 180 + thisPerson->angleOffset;
|
||||
while (direc >= 360) direc -= 360;
|
||||
while (direc >= 360)
|
||||
direc -= 360;
|
||||
thisPerson->direction = (direc * d) / 360;
|
||||
}
|
||||
|
||||
|
@ -176,7 +182,10 @@ bool initPeople() {
|
|||
|
||||
void spinStep(onScreenPerson *thisPerson) {
|
||||
int diff = (thisPerson->angle + 360) - thisPerson->wantAngle;
|
||||
int eachSlice = thisPerson->spinSpeed ? thisPerson->spinSpeed : (360 / thisPerson->myPersona->numDirections);
|
||||
int eachSlice =
|
||||
thisPerson->spinSpeed ?
|
||||
thisPerson->spinSpeed :
|
||||
(360 / thisPerson->myPersona->numDirections);
|
||||
while (diff > 180) {
|
||||
diff -= 360;
|
||||
}
|
||||
|
@ -194,19 +203,22 @@ void spinStep(onScreenPerson *thisPerson) {
|
|||
void rethinkAngle(onScreenPerson *thisPerson) {
|
||||
int d = thisPerson->myPersona->numDirections;
|
||||
int direc = thisPerson->angle + (180 / d) + 180 + thisPerson->angleOffset;
|
||||
while (direc >= 360) direc -= 360;
|
||||
while (direc >= 360)
|
||||
direc -= 360;
|
||||
thisPerson->direction = (direc * d) / 360;
|
||||
}
|
||||
|
||||
bool turnPersonToFace(int thisNum, int direc) {
|
||||
onScreenPerson *thisPerson = findPerson(thisNum);
|
||||
if (thisPerson) {
|
||||
if (thisPerson->continueAfterWalking) abortFunction(thisPerson->continueAfterWalking);
|
||||
if (thisPerson->continueAfterWalking)
|
||||
abortFunction(thisPerson->continueAfterWalking);
|
||||
thisPerson->continueAfterWalking = NULL;
|
||||
thisPerson->walking = false;
|
||||
thisPerson->spinning = false;
|
||||
turnMeAngle(thisPerson, direc);
|
||||
setFrames(* thisPerson, (thisPerson == speech->currentTalker) ? ANI_TALK : ANI_STAND);
|
||||
setFrames(*thisPerson,
|
||||
(thisPerson == speech->currentTalker) ? ANI_TALK : ANI_STAND);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -216,7 +228,8 @@ bool setPersonExtra(int thisNum, int extra) {
|
|||
onScreenPerson *thisPerson = findPerson(thisNum);
|
||||
if (thisPerson) {
|
||||
thisPerson->extra = extra;
|
||||
if (extra & EXTRA_NOSCALE) thisPerson->scale = 1;
|
||||
if (extra & EXTRA_NOSCALE)
|
||||
thisPerson->scale = 1;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -230,13 +243,15 @@ void setScale(short int h, short int d) {
|
|||
void moveAndScale(onScreenPerson &me, float x, float y) {
|
||||
me.x = x;
|
||||
me.y = y;
|
||||
if (!(me.extra & EXTRA_NOSCALE) && scaleDivide) me.scale = (me.y - scaleHorizon) / scaleDivide;
|
||||
if (!(me.extra & EXTRA_NOSCALE) && scaleDivide)
|
||||
me.scale = (me.y - scaleHorizon) / scaleDivide;
|
||||
}
|
||||
|
||||
onScreenPerson *findPerson(int v) {
|
||||
onScreenPerson *thisPerson = allPeople;
|
||||
while (thisPerson) {
|
||||
if (v == thisPerson->thisType->objectNum) break;
|
||||
if (v == thisPerson->thisType->objectNum)
|
||||
break;
|
||||
thisPerson = thisPerson->next;
|
||||
}
|
||||
return thisPerson;
|
||||
|
@ -244,12 +259,14 @@ onScreenPerson *findPerson(int v) {
|
|||
|
||||
void movePerson(int x, int y, int objNum) {
|
||||
onScreenPerson *moveMe = findPerson(objNum);
|
||||
if (moveMe) moveAndScale(* moveMe, x, y);
|
||||
if (moveMe)
|
||||
moveAndScale(*moveMe, x, y);
|
||||
}
|
||||
|
||||
void setShown(bool h, int ob) {
|
||||
onScreenPerson *moveMe = findPerson(ob);
|
||||
if (moveMe) moveMe->show = h;
|
||||
if (moveMe)
|
||||
moveMe->show = h;
|
||||
}
|
||||
|
||||
enum drawModes {
|
||||
|
@ -384,22 +401,27 @@ void setMyDrawMode(onScreenPerson *moveMe, int h) {
|
|||
|
||||
void setDrawMode(int h, int ob) {
|
||||
onScreenPerson *moveMe = findPerson(ob);
|
||||
if (!moveMe) return;
|
||||
if (!moveMe)
|
||||
return;
|
||||
|
||||
setMyDrawMode(moveMe, h);
|
||||
}
|
||||
|
||||
void setPersonTransparency(int ob, unsigned char x) {
|
||||
onScreenPerson *moveMe = findPerson(ob);
|
||||
if (!moveMe) return;
|
||||
if (!moveMe)
|
||||
return;
|
||||
|
||||
if (x > 254) x = 254;
|
||||
if (x > 254)
|
||||
x = 254;
|
||||
moveMe->transparency = x;
|
||||
}
|
||||
|
||||
void setPersonColourise(int ob, unsigned char r, unsigned char g, unsigned char b, unsigned char colourmix) {
|
||||
void setPersonColourise(int ob, unsigned char r, unsigned char g,
|
||||
unsigned char b, unsigned char colourmix) {
|
||||
onScreenPerson *moveMe = findPerson(ob);
|
||||
if (!moveMe) return;
|
||||
if (!moveMe)
|
||||
return;
|
||||
|
||||
moveMe->r = r;
|
||||
moveMe->g = g;
|
||||
|
@ -407,22 +429,23 @@ void setPersonColourise(int ob, unsigned char r, unsigned char g, unsigned char
|
|||
moveMe->colourmix = colourmix;
|
||||
}
|
||||
|
||||
|
||||
|
||||
extern screenRegion *overRegion;
|
||||
|
||||
void shufflePeople() {
|
||||
onScreenPerson * * thisReference = &allPeople;
|
||||
onScreenPerson *A, *B;
|
||||
|
||||
if (!allPeople) return;
|
||||
if (!allPeople)
|
||||
return;
|
||||
|
||||
while ((*thisReference)->next) {
|
||||
float y1 = (*thisReference)->y;
|
||||
if ((* thisReference)->extra & EXTRA_FRONT) y1 += 1000;
|
||||
if ((*thisReference)->extra & EXTRA_FRONT)
|
||||
y1 += 1000;
|
||||
|
||||
float y2 = (*thisReference)->next->y;
|
||||
if ((* thisReference)->next->extra & EXTRA_FRONT) y2 += 1000;
|
||||
if ((*thisReference)->next->extra & EXTRA_FRONT)
|
||||
y2 += 1000;
|
||||
|
||||
if (y1 > y2) {
|
||||
A = (*thisReference);
|
||||
|
@ -436,8 +459,6 @@ void shufflePeople() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void drawPeople() {
|
||||
shufflePeople();
|
||||
|
||||
|
@ -453,15 +474,20 @@ void drawPeople() {
|
|||
thisPerson->frameNum = 0;
|
||||
thisPerson->frameTick = myAnim->frames[0].howMany;
|
||||
if (myAnim->frames[thisPerson->frameNum].noise > 0) {
|
||||
startSound(myAnim->frames[thisPerson->frameNum].noise, false);
|
||||
startSound(myAnim->frames[thisPerson->frameNum].noise,
|
||||
false);
|
||||
thisPerson->frameNum++;
|
||||
thisPerson->frameNum %= thisPerson->myAnim->numFrames;
|
||||
thisPerson->frameTick = thisPerson->myAnim->frames[thisPerson->frameNum].howMany;
|
||||
thisPerson->frameTick =
|
||||
thisPerson->myAnim->frames[thisPerson->frameNum].howMany;
|
||||
} else if (myAnim->frames[thisPerson->frameNum].noise) {
|
||||
startNewFunctionNum(- myAnim->frames[thisPerson->frameNum].noise, 0, NULL, noStack);
|
||||
startNewFunctionNum(
|
||||
-myAnim->frames[thisPerson->frameNum].noise, 0,
|
||||
NULL, noStack);
|
||||
thisPerson->frameNum++;
|
||||
thisPerson->frameNum %= thisPerson->myAnim->numFrames;
|
||||
thisPerson->frameTick = thisPerson->myAnim->frames[thisPerson->frameNum].howMany;
|
||||
thisPerson->frameTick =
|
||||
thisPerson->myAnim->frames[thisPerson->frameNum].howMany;
|
||||
}
|
||||
}
|
||||
int fNumSign = myAnim->frames[thisPerson->frameNum].frameNum;
|
||||
|
@ -473,10 +499,12 @@ void drawPeople() {
|
|||
}
|
||||
if (m != 2) {
|
||||
bool r = false;
|
||||
r = scaleSprite(myAnim->theSprites->bank.sprites[fNum], myAnim->theSprites->bank.myPalette, thisPerson, m);
|
||||
r = scaleSprite(myAnim->theSprites->bank.sprites[fNum],
|
||||
myAnim->theSprites->bank.myPalette, thisPerson, m);
|
||||
if (r) {
|
||||
if (thisPerson->thisType->screenName[0]) {
|
||||
if (personRegion.thisType != thisPerson->thisType) lastRegion = NULL;
|
||||
if (personRegion.thisType != thisPerson->thisType)
|
||||
lastRegion = NULL;
|
||||
personRegion.thisType = thisPerson->thisType;
|
||||
overRegion = &personRegion;
|
||||
}
|
||||
|
@ -486,18 +514,24 @@ void drawPeople() {
|
|||
if (!--thisPerson->frameTick) {
|
||||
thisPerson->frameNum++;
|
||||
thisPerson->frameNum %= thisPerson->myAnim->numFrames;
|
||||
thisPerson->frameTick = thisPerson->myAnim->frames[thisPerson->frameNum].howMany;
|
||||
thisPerson->frameTick =
|
||||
thisPerson->myAnim->frames[thisPerson->frameNum].howMany;
|
||||
if (thisPerson->show && myAnim && myAnim->frames) {
|
||||
if (myAnim->frames[thisPerson->frameNum].noise > 0) {
|
||||
startSound(myAnim->frames[thisPerson->frameNum].noise, false);
|
||||
startSound(myAnim->frames[thisPerson->frameNum].noise,
|
||||
false);
|
||||
thisPerson->frameNum++;
|
||||
thisPerson->frameNum %= thisPerson->myAnim->numFrames;
|
||||
thisPerson->frameTick = thisPerson->myAnim->frames[thisPerson->frameNum].howMany;
|
||||
thisPerson->frameTick =
|
||||
thisPerson->myAnim->frames[thisPerson->frameNum].howMany;
|
||||
} else if (myAnim->frames[thisPerson->frameNum].noise) {
|
||||
startNewFunctionNum(- myAnim->frames[thisPerson->frameNum].noise, 0, NULL, noStack);
|
||||
startNewFunctionNum(
|
||||
-myAnim->frames[thisPerson->frameNum].noise, 0,
|
||||
NULL, noStack);
|
||||
thisPerson->frameNum++;
|
||||
thisPerson->frameNum %= thisPerson->myAnim->numFrames;
|
||||
thisPerson->frameTick = thisPerson->myAnim->frames[thisPerson->frameNum].howMany;
|
||||
thisPerson->frameTick =
|
||||
thisPerson->myAnim->frames[thisPerson->frameNum].howMany;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -514,8 +548,8 @@ void makeSilent(onScreenPerson &me) {
|
|||
}
|
||||
|
||||
bool handleClosestPoint(int &setX, int &setY, int &setPoly) {
|
||||
int gotX = 320, gotY = 200, gotPoly = -1, i, j, xTest1, yTest1,
|
||||
xTest2, yTest2, closestX, closestY, oldJ, currentDistance = 0xFFFFF,
|
||||
int gotX = 320, gotY = 200, gotPoly = -1, i, j, xTest1, yTest1, xTest2,
|
||||
yTest2, closestX, closestY, oldJ, currentDistance = 0xFFFFF,
|
||||
thisDistance;
|
||||
|
||||
// FILE * dbug = fopen ("debug_closest.txt", "at");
|
||||
|
@ -525,11 +559,16 @@ bool handleClosestPoint(int &setX, int &setY, int &setPoly) {
|
|||
oldJ = currentFloor->polygon[i].numVertices - 1;
|
||||
for (j = 0; j < currentFloor->polygon[i].numVertices; j++) {
|
||||
// fprintf (dbug, "Polygon %i, line %i... ", i, j);
|
||||
xTest1 = currentFloor->vertex[currentFloor->polygon[i].vertexID[j]].x;
|
||||
yTest1 = currentFloor->vertex[currentFloor->polygon[i].vertexID[j]].y;
|
||||
xTest2 = currentFloor->vertex[currentFloor->polygon[i].vertexID[oldJ]].x;
|
||||
yTest2 = currentFloor->vertex[currentFloor->polygon[i].vertexID[oldJ]].y;
|
||||
closestPointOnLine(closestX, closestY, xTest1, yTest1, xTest2, yTest2, setX, setY);
|
||||
xTest1 =
|
||||
currentFloor->vertex[currentFloor->polygon[i].vertexID[j]].x;
|
||||
yTest1 =
|
||||
currentFloor->vertex[currentFloor->polygon[i].vertexID[j]].y;
|
||||
xTest2 =
|
||||
currentFloor->vertex[currentFloor->polygon[i].vertexID[oldJ]].x;
|
||||
yTest2 =
|
||||
currentFloor->vertex[currentFloor->polygon[i].vertexID[oldJ]].y;
|
||||
closestPointOnLine(closestX, closestY, xTest1, yTest1, xTest2,
|
||||
yTest2, setX, setY);
|
||||
// fprintf (dbug, "closest point is %i, %i... ", closestX, closestY);
|
||||
xTest1 = setX - closestX;
|
||||
yTest1 = setY - closestY;
|
||||
|
@ -549,7 +588,8 @@ bool handleClosestPoint(int &setX, int &setY, int &setPoly) {
|
|||
}
|
||||
// fclose (dbug);
|
||||
|
||||
if (gotPoly == -1) return false;
|
||||
if (gotPoly == -1)
|
||||
return false;
|
||||
setX = gotX;
|
||||
setY = gotY;
|
||||
setPoly = gotPoly;
|
||||
|
@ -565,11 +605,13 @@ bool doBorderStuff(onScreenPerson *moveMe) {
|
|||
} else {
|
||||
// The section in which we need to be next...
|
||||
int newPoly = currentFloor->matrix[moveMe->inPoly][moveMe->walkToPoly];
|
||||
if (newPoly == -1) return false;
|
||||
if (newPoly == -1)
|
||||
return false;
|
||||
|
||||
// Grab the index of the second matching corner...
|
||||
int ID, ID2;
|
||||
if (!getMatchingCorners(currentFloor->polygon[moveMe->inPoly], currentFloor->polygon[newPoly], ID, ID2))
|
||||
if (!getMatchingCorners(currentFloor->polygon[moveMe->inPoly],
|
||||
currentFloor->polygon[newPoly], ID, ID2))
|
||||
return fatal("Not a valid floor plan!");
|
||||
|
||||
// Remember that we're walking to the new polygon...
|
||||
|
@ -605,8 +647,8 @@ bool doBorderStuff(onScreenPerson *moveMe) {
|
|||
dy23 *= dy23;
|
||||
dy24 *= dy24;
|
||||
|
||||
if (sqrt((double) dx13 + dy13) + sqrt((double) dx23 + dy23) <
|
||||
sqrt((double) dx14 + dy14) + sqrt((double) dx24 + dy24)) {
|
||||
if (sqrt((double) dx13 + dy13) + sqrt((double) dx23 + dy23)
|
||||
< sqrt((double) dx14 + dy14) + sqrt((double) dx24 + dy24)) {
|
||||
moveMe->thisStepX = x3;
|
||||
moveMe->thisStepY = y3;
|
||||
} else {
|
||||
|
@ -634,9 +676,12 @@ bool walkMe(onScreenPerson *thisPerson, bool move = true) {
|
|||
xDiff = thisPerson->thisStepX - thisPerson->x;
|
||||
yDiff = (thisPerson->thisStepY - thisPerson->y) * 2;
|
||||
s = thisPerson->scale * thisPerson->walkSpeed;
|
||||
if (s < 0.2) s = 0.2;
|
||||
if (s < 0.2)
|
||||
s = 0.2;
|
||||
|
||||
maxDiff = (TF_abs(xDiff) >= TF_abs(yDiff)) ? TF_abs(xDiff) : TF_abs(yDiff);
|
||||
maxDiff =
|
||||
(TF_abs(xDiff) >= TF_abs(yDiff)) ?
|
||||
TF_abs(xDiff) : TF_abs(yDiff);
|
||||
|
||||
if (TF_abs(maxDiff) > s) {
|
||||
if (thisPerson->spinning) {
|
||||
|
@ -645,8 +690,7 @@ bool walkMe(onScreenPerson *thisPerson, bool move = true) {
|
|||
}
|
||||
s = maxDiff / s;
|
||||
if (move)
|
||||
moveAndScale(* thisPerson,
|
||||
thisPerson->x + xDiff / s,
|
||||
moveAndScale(*thisPerson, thisPerson->x + xDiff / s,
|
||||
thisPerson->y + yDiff / (s * 2));
|
||||
return true;
|
||||
}
|
||||
|
@ -659,24 +703,27 @@ bool walkMe(onScreenPerson *thisPerson, bool move = true) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
if (!doBorderStuff(thisPerson)) break;
|
||||
if (!doBorderStuff(thisPerson))
|
||||
break;
|
||||
}
|
||||
|
||||
thisPerson->walking = false;
|
||||
setFrames(*thisPerson, ANI_STAND);
|
||||
moveAndScale(* thisPerson,
|
||||
thisPerson->walkToX,
|
||||
thisPerson->walkToY);
|
||||
moveAndScale(*thisPerson, thisPerson->walkToX, thisPerson->walkToY);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool makeWalkingPerson(int x, int y, int objNum, loadedFunction *func, int di) {
|
||||
if (x == 0 && y == 0) return false;
|
||||
if (currentFloor->numPolygons == 0) return false;
|
||||
if (x == 0 && y == 0)
|
||||
return false;
|
||||
if (currentFloor->numPolygons == 0)
|
||||
return false;
|
||||
onScreenPerson *moveMe = findPerson(objNum);
|
||||
if (!moveMe) return false;
|
||||
if (!moveMe)
|
||||
return false;
|
||||
|
||||
if (moveMe->continueAfterWalking) abortFunction(moveMe->continueAfterWalking);
|
||||
if (moveMe->continueAfterWalking)
|
||||
abortFunction(moveMe->continueAfterWalking);
|
||||
moveMe->continueAfterWalking = NULL;
|
||||
moveMe->walking = true;
|
||||
moveMe->directionWhenDoneWalking = di;
|
||||
|
@ -685,13 +732,16 @@ bool makeWalkingPerson(int x, int y, int objNum, loadedFunction *func, int di) {
|
|||
moveMe->walkToY = y;
|
||||
moveMe->walkToPoly = inFloor(x, y);
|
||||
if (moveMe->walkToPoly == -1) {
|
||||
if (!handleClosestPoint(moveMe->walkToX, moveMe->walkToY, moveMe->walkToPoly)) return false;
|
||||
if (!handleClosestPoint(moveMe->walkToX, moveMe->walkToY,
|
||||
moveMe->walkToPoly))
|
||||
return false;
|
||||
}
|
||||
|
||||
moveMe->inPoly = inFloor(moveMe->x, moveMe->y);
|
||||
if (moveMe->inPoly == -1) {
|
||||
int xxx = moveMe->x, yyy = moveMe->y;
|
||||
if (!handleClosestPoint(xxx, yyy, moveMe->inPoly)) return false;
|
||||
if (!handleClosestPoint(xxx, yyy, moveMe->inPoly))
|
||||
return false;
|
||||
}
|
||||
|
||||
doBorderStuff(moveMe);
|
||||
|
@ -717,12 +767,16 @@ bool stopPerson(int o) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool forceWalkingPerson(int x, int y, int objNum, loadedFunction *func, int di) {
|
||||
if (x == 0 && y == 0) return false;
|
||||
bool forceWalkingPerson(int x, int y, int objNum, loadedFunction *func,
|
||||
int di) {
|
||||
if (x == 0 && y == 0)
|
||||
return false;
|
||||
onScreenPerson *moveMe = findPerson(objNum);
|
||||
if (!moveMe) return false;
|
||||
if (!moveMe)
|
||||
return false;
|
||||
|
||||
if (moveMe->continueAfterWalking) abortFunction(moveMe->continueAfterWalking);
|
||||
if (moveMe->continueAfterWalking)
|
||||
abortFunction(moveMe->continueAfterWalking);
|
||||
moveMe->walking = true;
|
||||
moveMe->continueAfterWalking = NULL;
|
||||
moveMe->directionWhenDoneWalking = di;
|
||||
|
@ -745,10 +799,13 @@ bool forceWalkingPerson(int x, int y, int objNum, loadedFunction *func, int di)
|
|||
}
|
||||
|
||||
void jumpPerson(int x, int y, int objNum) {
|
||||
if (x == 0 && y == 0) return;
|
||||
if (x == 0 && y == 0)
|
||||
return;
|
||||
onScreenPerson *moveMe = findPerson(objNum);
|
||||
if (!moveMe) return;
|
||||
if (moveMe->continueAfterWalking) abortFunction(moveMe->continueAfterWalking);
|
||||
if (!moveMe)
|
||||
return;
|
||||
if (moveMe->continueAfterWalking)
|
||||
abortFunction(moveMe->continueAfterWalking);
|
||||
moveMe->continueAfterWalking = NULL;
|
||||
moveMe->walking = false;
|
||||
moveMe->spinning = false;
|
||||
|
@ -757,15 +814,18 @@ void jumpPerson(int x, int y, int objNum) {
|
|||
|
||||
bool floatCharacter(int f, int objNum) {
|
||||
onScreenPerson *moveMe = findPerson(objNum);
|
||||
if (!moveMe) return false;
|
||||
if (!moveMe)
|
||||
return false;
|
||||
moveMe->floaty = f;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool setCharacterWalkSpeed(int f, int objNum) {
|
||||
if (f <= 0) return false;
|
||||
if (f <= 0)
|
||||
return false;
|
||||
onScreenPerson *moveMe = findPerson(objNum);
|
||||
if (!moveMe) return false;
|
||||
if (!moveMe)
|
||||
return false;
|
||||
moveMe->walkSpeed = f;
|
||||
return true;
|
||||
}
|
||||
|
@ -780,7 +840,8 @@ void walkAllPeople() {
|
|||
spinStep(thisPerson);
|
||||
setFrames(*thisPerson, ANI_STAND);
|
||||
}
|
||||
if ((!thisPerson->walking) && (!thisPerson->spinning) && thisPerson->continueAfterWalking) {
|
||||
if ((!thisPerson->walking) && (!thisPerson->spinning)
|
||||
&& thisPerson->continueAfterWalking) {
|
||||
restartFunction(thisPerson->continueAfterWalking);
|
||||
thisPerson->continueAfterWalking = NULL;
|
||||
}
|
||||
|
@ -790,7 +851,8 @@ void walkAllPeople() {
|
|||
|
||||
bool addPerson(int x, int y, int objNum, persona *p) {
|
||||
onScreenPerson *newPerson = new onScreenPerson;
|
||||
if (!checkNew(newPerson)) return false;
|
||||
if (!checkNew(newPerson))
|
||||
return false;
|
||||
|
||||
// EASY STUFF
|
||||
newPerson->thisType = loadObjectType(objNum);
|
||||
|
@ -828,10 +890,12 @@ bool addPerson(int x, int y, int objNum, persona *p) {
|
|||
if (fNumSigned < 0) {
|
||||
newPerson->height = 5;
|
||||
} else {
|
||||
newPerson->height = p->animation[0]->theSprites->bank.sprites[0].yhot + 5;
|
||||
newPerson->height =
|
||||
p->animation[0]->theSprites->bank.sprites[0].yhot + 5;
|
||||
}
|
||||
} else {
|
||||
newPerson->height = p->animation[0]->theSprites->bank.sprites[fNum].yhot + 5;
|
||||
newPerson->height = p->animation[0]->theSprites->bank.sprites[fNum].yhot
|
||||
+ 5;
|
||||
}
|
||||
|
||||
// NOW ADD IT IN THE RIGHT PLACE
|
||||
|
@ -857,7 +921,8 @@ int timeForAnim(personaAnimation *fram) {
|
|||
void animatePerson(int obj, personaAnimation *fram) { // Set a new SINGLE animation
|
||||
onScreenPerson *moveMe = findPerson(obj);
|
||||
if (moveMe) {
|
||||
if (moveMe->continueAfterWalking) abortFunction(moveMe->continueAfterWalking);
|
||||
if (moveMe->continueAfterWalking)
|
||||
abortFunction(moveMe->continueAfterWalking);
|
||||
moveMe->continueAfterWalking = NULL;
|
||||
moveMe->walking = false;
|
||||
moveMe->spinning = false;
|
||||
|
@ -885,7 +950,8 @@ void animatePerson(int obj, persona *per) { // Set a new costume
|
|||
void killAllPeople() {
|
||||
onScreenPerson *killPeople;
|
||||
while (allPeople) {
|
||||
if (allPeople->continueAfterWalking) abortFunction(allPeople->continueAfterWalking);
|
||||
if (allPeople->continueAfterWalking)
|
||||
abortFunction(allPeople->continueAfterWalking);
|
||||
allPeople->continueAfterWalking = NULL;
|
||||
killPeople = allPeople;
|
||||
allPeople = allPeople->next;
|
||||
|
@ -908,7 +974,8 @@ void killMostPeople() {
|
|||
(*lookyHere) = killPeople->next;
|
||||
|
||||
// Gone from the list... now free some memory
|
||||
if (killPeople->continueAfterWalking) abortFunction(killPeople->continueAfterWalking);
|
||||
if (killPeople->continueAfterWalking)
|
||||
abortFunction(killPeople->continueAfterWalking);
|
||||
killPeople->continueAfterWalking = NULL;
|
||||
removeObjectType(killPeople->thisType);
|
||||
delete killPeople;
|
||||
|
@ -920,17 +987,18 @@ void removeOneCharacter(int i) {
|
|||
onScreenPerson *p = findPerson(i);
|
||||
|
||||
if (p) {
|
||||
if (overRegion == &personRegion && overRegion->thisType == p->thisType) {
|
||||
if (overRegion == &personRegion
|
||||
&& overRegion->thisType == p->thisType) {
|
||||
overRegion = NULL;
|
||||
}
|
||||
|
||||
if (p->continueAfterWalking) abortFunction(p->continueAfterWalking);
|
||||
if (p->continueAfterWalking)
|
||||
abortFunction(p->continueAfterWalking);
|
||||
p->continueAfterWalking = NULL;
|
||||
onScreenPerson * * killPeople;
|
||||
|
||||
for (killPeople = & allPeople;
|
||||
* killPeople != p;
|
||||
killPeople = & ((* killPeople)->next)) {
|
||||
for (killPeople = &allPeople; *killPeople != p; killPeople =
|
||||
&((*killPeople)->next)) {
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -960,7 +1028,8 @@ bool loadAnim(personaAnimation *p, Common::SeekableReadStream *stream) {
|
|||
if (p->numFrames) {
|
||||
int a = get4bytes(stream);
|
||||
p->frames = new animFrame[p->numFrames];
|
||||
if (!checkNew(p->frames)) return false;
|
||||
if (!checkNew(p->frames))
|
||||
return false;
|
||||
p->theSprites = loadBankForAnim(a);
|
||||
|
||||
for (a = 0; a < p->numFrames; ++a) {
|
||||
|
@ -997,7 +1066,8 @@ bool saveCostume(persona *cossy, Common::WriteStream *stream) {
|
|||
int a;
|
||||
put2bytes(cossy->numDirections, stream);
|
||||
for (a = 0; a < cossy->numDirections * 3; ++a) {
|
||||
if (!saveAnim(cossy->animation[a], stream)) return false;
|
||||
if (!saveAnim(cossy->animation[a], stream))
|
||||
return false;
|
||||
}
|
||||
// debugCostume ("Saved", cossy);
|
||||
return true;
|
||||
|
@ -1007,12 +1077,15 @@ bool loadCostume(persona *cossy, Common::SeekableReadStream *stream) {
|
|||
int a;
|
||||
cossy->numDirections = get2bytes(stream);
|
||||
cossy->animation = new personaAnimation *[cossy->numDirections * 3];
|
||||
if (!checkNew(cossy->animation)) return false;
|
||||
if (!checkNew(cossy->animation))
|
||||
return false;
|
||||
for (a = 0; a < cossy->numDirections * 3; ++a) {
|
||||
cossy->animation[a] = new personaAnimation;
|
||||
if (!checkNew(cossy->animation[a])) return false;
|
||||
if (!checkNew(cossy->animation[a]))
|
||||
return false;
|
||||
|
||||
if (!loadAnim(cossy->animation[a], stream)) return false;
|
||||
if (!loadAnim(cossy->animation[a], stream))
|
||||
return false;
|
||||
}
|
||||
// debugCostume ("Loaded", cossy);
|
||||
return true;
|
||||
|
@ -1098,13 +1171,16 @@ bool loadPeople(Common::SeekableReadStream *stream) {
|
|||
allPeople = NULL;
|
||||
for (a = 0; a < countPeople; ++a) {
|
||||
me = new onScreenPerson;
|
||||
if (!checkNew(me)) return false;
|
||||
if (!checkNew(me))
|
||||
return false;
|
||||
|
||||
me->myPersona = new persona;
|
||||
if (!checkNew(me->myPersona)) return false;
|
||||
if (!checkNew(me->myPersona))
|
||||
return false;
|
||||
|
||||
me->myAnim = new personaAnimation;
|
||||
if (!checkNew(me->myAnim)) return false;
|
||||
if (!checkNew(me->myAnim))
|
||||
return false;
|
||||
|
||||
me->x = getFloat(stream);
|
||||
me->y = getFloat(stream);
|
||||
|
@ -1132,7 +1208,8 @@ bool loadPeople(Common::SeekableReadStream *stream) {
|
|||
me->spinning = getch(stream);
|
||||
if (getch(stream)) {
|
||||
me->continueAfterWalking = loadFunction(stream);
|
||||
if (!me->continueAfterWalking) return false;
|
||||
if (!me->continueAfterWalking)
|
||||
return false;
|
||||
} else {
|
||||
me->continueAfterWalking = NULL;
|
||||
}
|
||||
|
|
|
@ -96,13 +96,16 @@ void makeSilent(onScreenPerson &me);
|
|||
void setShown(bool h, int ob);
|
||||
void setDrawMode(int h, int ob);
|
||||
void setPersonTransparency(int ob, unsigned char x);
|
||||
void setPersonColourise(int ob, unsigned char r, unsigned char g, unsigned char b, unsigned char colourmix);
|
||||
void setPersonColourise(int ob, unsigned char r, unsigned char g,
|
||||
unsigned char b, unsigned char colourmix);
|
||||
|
||||
// Moving 'em
|
||||
|
||||
void movePerson(int x, int y, int objNum);
|
||||
bool makeWalkingPerson(int x, int y, int objNum, struct loadedFunction *func, int di);
|
||||
bool forceWalkingPerson(int x, int y, int objNum, struct loadedFunction *func, int di);
|
||||
bool makeWalkingPerson(int x, int y, int objNum, struct loadedFunction *func,
|
||||
int di);
|
||||
bool forceWalkingPerson(int x, int y, int objNum, struct loadedFunction *func,
|
||||
int di);
|
||||
void jumpPerson(int x, int y, int objNum);
|
||||
void walkAllPeople();
|
||||
bool turnPersonToFace(int thisNum, int direc);
|
||||
|
|
|
@ -55,7 +55,8 @@ void removeScreenRegion(int objectNum) {
|
|||
killMe = *huntRegion;
|
||||
*huntRegion = killMe->next;
|
||||
removeObjectType(killMe->thisType);
|
||||
if (killMe == overRegion) overRegion = NULL;
|
||||
if (killMe == overRegion)
|
||||
overRegion = NULL;
|
||||
delete killMe;
|
||||
killMe = NULL;
|
||||
} else {
|
||||
|
@ -121,9 +122,11 @@ void killAllRegions() {
|
|||
overRegion = NULL;
|
||||
}
|
||||
|
||||
bool addScreenRegion(int x1, int y1, int x2, int y2, int sX, int sY, int di, int objectNum) {
|
||||
bool addScreenRegion(int x1, int y1, int x2, int y2, int sX, int sY, int di,
|
||||
int objectNum) {
|
||||
screenRegion *newRegion = new screenRegion;
|
||||
if (!checkNew(newRegion)) return false;
|
||||
if (!checkNew(newRegion))
|
||||
return false;
|
||||
newRegion->di = di;
|
||||
newRegion->x1 = x1;
|
||||
newRegion->y1 = y1;
|
||||
|
@ -140,8 +143,10 @@ bool addScreenRegion(int x1, int y1, int x2, int y2, int sX, int sY, int di, int
|
|||
void getOverRegion() {
|
||||
screenRegion *thisRegion = allScreenRegions;
|
||||
while (thisRegion) {
|
||||
if ((input.mouseX >= thisRegion->x1 - cameraX) && (input.mouseY >= thisRegion->y1 - cameraY) &&
|
||||
(input.mouseX <= thisRegion->x2 - cameraX) && (input.mouseY <= thisRegion->y2 - cameraY)) {
|
||||
if ((input.mouseX >= thisRegion->x1 - cameraX)
|
||||
&& (input.mouseY >= thisRegion->y1 - cameraY)
|
||||
&& (input.mouseX <= thisRegion->x2 - cameraX)
|
||||
&& (input.mouseY <= thisRegion->y2 - cameraY)) {
|
||||
overRegion = thisRegion;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,8 @@ void writeStringEncoded(const char *s, Common::WriteStream *stream) {
|
|||
char *readStringEncoded(Common::File *fp) {
|
||||
int a, len = get2bytes(fp);
|
||||
char *s = new char[len + 1];
|
||||
if (!checkNew(s)) return NULL;
|
||||
if (!checkNew(s))
|
||||
return NULL;
|
||||
for (a = 0; a < len; a++) {
|
||||
s[a] = (char) (getch(fp) ^ encode1);
|
||||
encode1 += encode2;
|
||||
|
@ -107,7 +108,8 @@ char *readTextPlain(Common::File *fp) {
|
|||
} else {
|
||||
fp->seek(startPos, SEEK_SET);
|
||||
reply = new char[stringSize + 1];
|
||||
if (reply == NULL) return NULL;
|
||||
if (reply == NULL)
|
||||
return NULL;
|
||||
size_t bytes_read = fp->read(reply, stringSize);
|
||||
if (bytes_read != stringSize && fp->err()) {
|
||||
debugOut("Reading error in readTextPlain.\n");
|
||||
|
@ -123,7 +125,9 @@ bool fileToStack(char *filename, stackHandler *sH) {
|
|||
|
||||
variable stringVar;
|
||||
stringVar.varType = SVT_NULL;
|
||||
const char *checker = saveEncoding ? "[Custom data (encoded)]\r\n" : "[Custom data (ASCII)]\n";
|
||||
const char *checker =
|
||||
saveEncoding ?
|
||||
"[Custom data (encoded)]\r\n" : "[Custom data (ASCII)]\n";
|
||||
|
||||
Common::File fd;
|
||||
|
||||
|
@ -155,7 +159,8 @@ bool fileToStack(char *filename, stackHandler *sH) {
|
|||
while (*checker) {
|
||||
if (getch(&fd) != *checker) {
|
||||
fd.close();
|
||||
return fatal(LOAD_ERROR "This isn't a SLUDGE custom data file:", filename);
|
||||
return fatal(LOAD_ERROR "This isn't a SLUDGE custom data file:",
|
||||
filename);
|
||||
}
|
||||
checker++;
|
||||
}
|
||||
|
@ -164,18 +169,20 @@ bool fileToStack(char *filename, stackHandler *sH) {
|
|||
char *checker = readStringEncoded(&fd);
|
||||
if (strcmp(checker, "UN<EFBFBD>LO<EFBFBD>CKED")) {
|
||||
fd.close();
|
||||
return fatal(LOAD_ERROR "The current file encoding setting does not match the encoding setting used when this file was created:", filename);
|
||||
return fatal(
|
||||
LOAD_ERROR "The current file encoding setting does not match the encoding setting used when this file was created:",
|
||||
filename);
|
||||
}
|
||||
delete checker;
|
||||
checker = NULL;
|
||||
}
|
||||
|
||||
|
||||
for (;;) {
|
||||
if (saveEncoding) {
|
||||
char i = getch(&fd) ^ encode1;
|
||||
|
||||
if (fd.eos()) break;
|
||||
if (fd.eos())
|
||||
break;
|
||||
switch (i) {
|
||||
case 0: {
|
||||
char *g = readStringEncoded(&fd);
|
||||
|
@ -199,17 +206,20 @@ bool fileToStack(char *filename, stackHandler *sH) {
|
|||
}
|
||||
} else {
|
||||
char *line = readTextPlain(&fd);
|
||||
if (!line) break;
|
||||
if (!line)
|
||||
break;
|
||||
makeTextVar(stringVar, line);
|
||||
}
|
||||
|
||||
if (sH->first == NULL) {
|
||||
// Adds to the TOP of the array... oops!
|
||||
if (!addVarToStackQuick(stringVar, sH -> first)) return false;
|
||||
if (!addVarToStackQuick(stringVar, sH->first))
|
||||
return false;
|
||||
sH->last = sH->first;
|
||||
} else {
|
||||
// Adds to the END of the array... much better
|
||||
if (!addVarToStackQuick(stringVar, sH -> last -> next)) return false;
|
||||
if (!addVarToStackQuick(stringVar, sH->last->next))
|
||||
return false;
|
||||
sH->last = sH->last->next;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,16 +117,14 @@ inputType input;
|
|||
variable *globalVars;
|
||||
int numGlobals;
|
||||
|
||||
const char *sludgeText[] = { "?????", "RETURN", "BRANCH", "BR_ZERO", "SET_GLOBAL",
|
||||
"SET_LOCAL", "LOAD_GLOBAL", "LOAD_LOCAL",
|
||||
"PLUS", "MINUS", "MULT", "DIVIDE",
|
||||
"AND", "OR", "EQUALS", "NOT_EQ", "MODULUS", "LOAD_VALUE",
|
||||
"LOAD_BUILT", "LOAD_FUNC", "CALLIT", "LOAD_STRING", "LOAD_FILE",
|
||||
"LOAD_OBJTYPE", "NOT", "LOAD_NULL", "STACK_PUSH",
|
||||
const char *sludgeText[] = { "?????", "RETURN", "BRANCH", "BR_ZERO",
|
||||
"SET_GLOBAL", "SET_LOCAL", "LOAD_GLOBAL", "LOAD_LOCAL", "PLUS", "MINUS",
|
||||
"MULT", "DIVIDE", "AND", "OR", "EQUALS", "NOT_EQ", "MODULUS",
|
||||
"LOAD_VALUE", "LOAD_BUILT", "LOAD_FUNC", "CALLIT", "LOAD_STRING",
|
||||
"LOAD_FILE", "LOAD_OBJTYPE", "NOT", "LOAD_NULL", "STACK_PUSH",
|
||||
"LESSTHAN", "MORETHAN", "NEGATIVE", "U", "LESS_EQUAL", "MORE_EQUAL",
|
||||
"INC_LOCAL", "DEC_LOCAL", "INC_GLOBAL", "DEC_GLOBAL", "INDEXSET", "INDEXGET",
|
||||
"INC_INDEX", "DEC_INDEX", "QUICK_PUSH"
|
||||
};
|
||||
"INC_LOCAL", "DEC_LOCAL", "INC_GLOBAL", "DEC_GLOBAL", "INDEXSET",
|
||||
"INDEXGET", "INC_INDEX", "DEC_INDEX", "QUICK_PUSH" };
|
||||
|
||||
void loadHandlers(Common::SeekableReadStream *stream) {
|
||||
currentEvents->leftMouseFunction = get2bytes(stream);
|
||||
|
@ -148,19 +146,26 @@ void saveHandlers(Common::WriteStream *stream) {
|
|||
put2bytes(currentEvents->spaceFunction, stream);
|
||||
}
|
||||
|
||||
Common::File *openAndVerify(char *filename, char extra1, char extra2, const char *er, int &fileVersion) {
|
||||
Common::File *openAndVerify(char *filename, char extra1, char extra2,
|
||||
const char *er, int &fileVersion) {
|
||||
Common::File *fp = new Common::File();
|
||||
if (!fp->open(filename)) {
|
||||
fatal("Can't open file", filename);
|
||||
return NULL;
|
||||
}
|
||||
bool headerBad = false;
|
||||
if (getch(fp) != 'S') headerBad = true;
|
||||
if (getch(fp) != 'L') headerBad = true;
|
||||
if (getch(fp) != 'U') headerBad = true;
|
||||
if (getch(fp) != 'D') headerBad = true;
|
||||
if (getch(fp) != extra1) headerBad = true;
|
||||
if (getch(fp) != extra2) headerBad = true;
|
||||
if (getch(fp) != 'S')
|
||||
headerBad = true;
|
||||
if (getch(fp) != 'L')
|
||||
headerBad = true;
|
||||
if (getch(fp) != 'U')
|
||||
headerBad = true;
|
||||
if (getch(fp) != 'D')
|
||||
headerBad = true;
|
||||
if (getch(fp) != extra1)
|
||||
headerBad = true;
|
||||
if (getch(fp) != extra2)
|
||||
headerBad = true;
|
||||
if (headerBad) {
|
||||
fatal(er, filename);
|
||||
return NULL;
|
||||
|
@ -196,15 +201,18 @@ bool initSludge(char *filename) {
|
|||
int a = 0;
|
||||
mouseCursorAnim = makeNullAnim();
|
||||
|
||||
Common::File *fp = openAndVerify(filename, 'G', 'E', ERROR_BAD_HEADER, gameVersion);
|
||||
if (!fp) return false;
|
||||
Common::File *fp = openAndVerify(filename, 'G', 'E', ERROR_BAD_HEADER,
|
||||
gameVersion);
|
||||
if (!fp)
|
||||
return false;
|
||||
|
||||
char c = getch(fp);
|
||||
if (c) {
|
||||
numBIFNames = get2bytes(fp);
|
||||
debug(kSludgeDebugDataLoad, "numBIFNames %i", numBIFNames);
|
||||
allBIFNames = new char *[numBIFNames];
|
||||
if (!checkNew(allBIFNames)) return false;
|
||||
if (!checkNew(allBIFNames))
|
||||
return false;
|
||||
|
||||
for (int fn = 0; fn < numBIFNames; fn++) {
|
||||
allBIFNames[fn] = readString(fp);
|
||||
|
@ -212,16 +220,19 @@ bool initSludge(char *filename) {
|
|||
numUserFunc = get2bytes(fp);
|
||||
debug(kSludgeDebugDataLoad, "numUserFunc %i", numUserFunc);
|
||||
allUserFunc = new char *[numUserFunc];
|
||||
if (!checkNew(allUserFunc)) return false;
|
||||
if (!checkNew(allUserFunc))
|
||||
return false;
|
||||
|
||||
for (int fn = 0; fn < numUserFunc; fn++) {
|
||||
allUserFunc[fn] = readString(fp);
|
||||
}
|
||||
if (gameVersion >= VERSION(1, 3)) {
|
||||
numResourceNames = get2bytes(fp);
|
||||
debug(kSludgeDebugDataLoad, "numResourceNames %i", numResourceNames);
|
||||
debug(kSludgeDebugDataLoad, "numResourceNames %i",
|
||||
numResourceNames);
|
||||
allResourceNames = new char *[numResourceNames];
|
||||
if (!checkNew(allResourceNames)) return false;
|
||||
if (!checkNew(allResourceNames))
|
||||
return false;
|
||||
|
||||
for (int fn = 0; fn < numResourceNames; fn++) {
|
||||
allResourceNames[fn] = readString(fp);
|
||||
|
@ -244,10 +255,13 @@ bool initSludge(char *filename) {
|
|||
debug("Reading error in initSludge.");
|
||||
}
|
||||
|
||||
char *dataFol = (gameVersion >= VERSION(1, 3)) ? readString(fp) : joinStrings("", "");
|
||||
char *dataFol =
|
||||
(gameVersion >= VERSION(1, 3)) ?
|
||||
readString(fp) : joinStrings("", "");
|
||||
debug(kSludgeDebugDataLoad, "dataFol : %s", dataFol);
|
||||
|
||||
gameSettings.numLanguages = (gameVersion >= VERSION(1, 3)) ? (getch(fp)) : 0;
|
||||
gameSettings.numLanguages =
|
||||
(gameVersion >= VERSION(1, 3)) ? (getch(fp)) : 0;
|
||||
debug(kSludgeDebugDataLoad, "numLanguages : %c", gameSettings.numLanguages);
|
||||
makeLanguageTable(fp);
|
||||
|
||||
|
@ -262,7 +276,8 @@ bool initSludge(char *filename) {
|
|||
char *checker = readString(fp);
|
||||
debug(kSludgeDebugDataLoad, "checker : %s", checker);
|
||||
|
||||
if (strcmp(checker, "okSoFar")) return fatal(ERROR_BAD_HEADER, filename);
|
||||
if (strcmp(checker, "okSoFar"))
|
||||
return fatal(ERROR_BAD_HEADER, filename);
|
||||
delete checker;
|
||||
checker = NULL;
|
||||
|
||||
|
@ -507,8 +522,10 @@ bool initSludge(char *filename) {
|
|||
debug("numGlobals : %i", numGlobals);
|
||||
|
||||
globalVars = new variable[numGlobals];
|
||||
if (!checkNew(globalVars)) return false;
|
||||
for (a = 0; a < numGlobals; a ++) initVarNew(globalVars[a]);
|
||||
if (!checkNew(globalVars))
|
||||
return false;
|
||||
for (a = 0; a < numGlobals; a++)
|
||||
initVarNew(globalVars[a]);
|
||||
|
||||
// Get the original (untranslated) name of the game and convert it to Unicode.
|
||||
// We use this to find saved preferences and saved games.
|
||||
|
@ -551,7 +568,8 @@ bool initSludge(char *filename) {
|
|||
|
||||
// Now set file indices properly to the chosen language.
|
||||
languageNum = getLanguageForFileB();
|
||||
if (languageNum < 0) return fatal("Can't find the translation data specified!");
|
||||
if (languageNum < 0)
|
||||
return fatal("Can't find the translation data specified!");
|
||||
setFileIndices(NULL, gameSettings.numLanguages, languageNum);
|
||||
|
||||
if (dataFol[0]) {
|
||||
|
@ -631,20 +649,20 @@ void sludgeDisplay() {
|
|||
fbo_tex_w = (float)realWinWidth / width;
|
||||
fbo_tex_h = (float)realWinHeight / height;
|
||||
// create shader for blitting the fbo...
|
||||
const char _blit_vsh[] = " \n\t" \
|
||||
"attribute highp vec2 aPosition; \n\t" \
|
||||
"attribute highp vec2 aTexCoord; \n\t" \
|
||||
"varying mediump vec2 vTexCoord; \n\t" \
|
||||
"void main(){ \n\t" \
|
||||
"gl_Position = vec4(aPosition.x, aPosition.y, 0.0, 1.0);\n\t" \
|
||||
"vTexCoord = aTexCoord; \n\t" \
|
||||
const char _blit_vsh[] = " \n\t"
|
||||
"attribute highp vec2 aPosition; \n\t"
|
||||
"attribute highp vec2 aTexCoord; \n\t"
|
||||
"varying mediump vec2 vTexCoord; \n\t"
|
||||
"void main(){ \n\t"
|
||||
"gl_Position = vec4(aPosition.x, aPosition.y, 0.0, 1.0);\n\t"
|
||||
"vTexCoord = aTexCoord; \n\t"
|
||||
"} \n\t";
|
||||
|
||||
const char _blit_fsh[] = " \n\t" \
|
||||
"uniform sampler2D uTex; \n\t" \
|
||||
"varying mediump vec2 vTexCoord; \n\t" \
|
||||
"void main(){ \n\t" \
|
||||
"gl_FragColor = texture2D(uTex, vTexCoord); \n\t" \
|
||||
const char _blit_fsh[] = " \n\t"
|
||||
"uniform sampler2D uTex; \n\t"
|
||||
"varying mediump vec2 vTexCoord; \n\t"
|
||||
"void main(){ \n\t"
|
||||
"gl_FragColor = texture2D(uTex, vTexCoord); \n\t"
|
||||
"} \n\t";
|
||||
|
||||
GLint success;
|
||||
|
@ -755,7 +773,8 @@ void killSpeechTimers() {
|
|||
loadedFunction *thisFunction = allRunningFunctions;
|
||||
|
||||
while (thisFunction) {
|
||||
if (thisFunction->freezerLevel == 0 && thisFunction->isSpeech && thisFunction->timeLeft) {
|
||||
if (thisFunction->freezerLevel == 0 && thisFunction->isSpeech
|
||||
&& thisFunction->timeLeft) {
|
||||
thisFunction->timeLeft = 0;
|
||||
thisFunction->isSpeech = false;
|
||||
}
|
||||
|
@ -769,7 +788,8 @@ void completeTimers() {
|
|||
loadedFunction *thisFunction = allRunningFunctions;
|
||||
|
||||
while (thisFunction) {
|
||||
if (thisFunction->freezerLevel == 0) thisFunction->timeLeft = 0;
|
||||
if (thisFunction->freezerLevel == 0)
|
||||
thisFunction->timeLeft = 0;
|
||||
thisFunction = thisFunction->next;
|
||||
}
|
||||
}
|
||||
|
@ -778,9 +798,11 @@ void finishFunction(loadedFunction *fun) {
|
|||
int a;
|
||||
|
||||
pauseFunction(fun);
|
||||
if (fun->stack) fatal(ERROR_NON_EMPTY_STACK);
|
||||
if (fun->stack)
|
||||
fatal(ERROR_NON_EMPTY_STACK);
|
||||
delete fun->compiledLines;
|
||||
for (a = 0; a < fun->numLocals; a ++) unlinkVar(fun->localVars[a]);
|
||||
for (a = 0; a < fun->numLocals; a++)
|
||||
unlinkVar(fun->localVars[a]);
|
||||
delete fun->localVars;
|
||||
unlinkVar(fun->reg);
|
||||
delete fun;
|
||||
|
@ -791,12 +813,15 @@ void abortFunction(loadedFunction *fun) {
|
|||
int a;
|
||||
|
||||
pauseFunction(fun);
|
||||
while (fun->stack) trimStack(fun->stack);
|
||||
while (fun->stack)
|
||||
trimStack(fun->stack);
|
||||
delete fun->compiledLines;
|
||||
for (a = 0; a < fun->numLocals; a ++) unlinkVar(fun->localVars[a]);
|
||||
for (a = 0; a < fun->numLocals; a++)
|
||||
unlinkVar(fun->localVars[a]);
|
||||
delete fun->localVars;
|
||||
unlinkVar(fun->reg);
|
||||
if (fun->calledBy) abortFunction(fun->calledBy);
|
||||
if (fun->calledBy)
|
||||
abortFunction(fun->calledBy);
|
||||
delete fun;
|
||||
fun = NULL;
|
||||
}
|
||||
|
@ -810,7 +835,8 @@ int cancelAFunction(int funcNum, loadedFunction *myself, bool &killedMyself) {
|
|||
if (fun->originalNumber == funcNum) {
|
||||
fun->cancelMe = true;
|
||||
n++;
|
||||
if (fun == myself) killedMyself = true;
|
||||
if (fun == myself)
|
||||
killedMyself = true;
|
||||
}
|
||||
fun = fun->next;
|
||||
}
|
||||
|
@ -834,12 +860,12 @@ void unfreezeSubs() {
|
|||
loadedFunction *thisFunction = allRunningFunctions;
|
||||
|
||||
while (thisFunction) {
|
||||
if (thisFunction->freezerLevel) thisFunction->freezerLevel --;
|
||||
if (thisFunction->freezerLevel)
|
||||
thisFunction->freezerLevel--;
|
||||
thisFunction = thisFunction->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool continueFunction(loadedFunction *fun) {
|
||||
bool keepLooping = true;
|
||||
bool advanceNow;
|
||||
|
@ -864,8 +890,11 @@ bool continueFunction(loadedFunction *fun) {
|
|||
|
||||
if (numBIFNames) {
|
||||
setFatalInfo(
|
||||
(fun->originalNumber < numUserFunc) ? allUserFunc[fun->originalNumber] : "Unknown user function",
|
||||
(com < numSludgeCommands) ? sludgeText[com] : ERROR_UNKNOWN_MCODE);
|
||||
(fun->originalNumber < numUserFunc) ?
|
||||
allUserFunc[fun->originalNumber] :
|
||||
"Unknown user function",
|
||||
(com < numSludgeCommands) ?
|
||||
sludgeText[com] : ERROR_UNKNOWN_MCODE);
|
||||
// newDebug (
|
||||
// (com < numSludgeCommands) ? sludgeText[com] : "Unknown SLUDGE machine code",
|
||||
// param);
|
||||
|
@ -877,7 +906,8 @@ bool continueFunction(loadedFunction *fun) {
|
|||
case SLU_RETURN:
|
||||
if (fun->calledBy) {
|
||||
loadedFunction *returnTo = fun->calledBy;
|
||||
if (fun->returnSomething) copyVariable(fun->reg, returnTo->reg);
|
||||
if (fun->returnSomething)
|
||||
copyVariable(fun->reg, returnTo->reg);
|
||||
finishFunction(fun);
|
||||
fun = returnTo;
|
||||
restartFunction(fun);
|
||||
|
@ -892,22 +922,32 @@ bool continueFunction(loadedFunction *fun) {
|
|||
switch (fun->reg.varType) {
|
||||
case SVT_FUNC:
|
||||
pauseFunction(fun);
|
||||
if (numBIFNames) setFatalInfo(
|
||||
(fun->originalNumber < numUserFunc) ? allUserFunc[fun->originalNumber] : "Unknown user function",
|
||||
(fun->reg.varData.intValue < numUserFunc) ? allUserFunc[fun->reg.varData.intValue] : "Unknown user function");
|
||||
if (numBIFNames)
|
||||
setFatalInfo(
|
||||
(fun->originalNumber < numUserFunc) ?
|
||||
allUserFunc[fun->originalNumber] :
|
||||
"Unknown user function",
|
||||
(fun->reg.varData.intValue < numUserFunc) ?
|
||||
allUserFunc[fun->reg.varData.intValue] :
|
||||
"Unknown user function");
|
||||
|
||||
if (!startNewFunctionNum(fun->reg.varData.intValue, param, fun, fun->stack)) return false;
|
||||
if (!startNewFunctionNum(fun->reg.varData.intValue, param, fun,
|
||||
fun->stack))
|
||||
return false;
|
||||
fun = allRunningFunctions;
|
||||
advanceNow = false; // So we don't do anything else with "fun"
|
||||
break;
|
||||
|
||||
case SVT_BUILT: {
|
||||
debug(kSludgeDebugStackMachine, "Built-in init value: %i", fun->reg.varData.intValue);
|
||||
builtReturn br = callBuiltIn(fun->reg.varData.intValue, param, fun);
|
||||
debug(kSludgeDebugStackMachine, "Built-in init value: %i",
|
||||
fun->reg.varData.intValue);
|
||||
builtReturn br = callBuiltIn(fun->reg.varData.intValue, param,
|
||||
fun);
|
||||
|
||||
switch (br) {
|
||||
case BR_ERROR:
|
||||
return fatal("Unknown error. This shouldn't happen. Please notify the SLUDGE developers.");
|
||||
return fatal(
|
||||
"Unknown error. This shouldn't happen. Please notify the SLUDGE developers.");
|
||||
|
||||
case BR_PAUSE:
|
||||
pauseFunction(fun);
|
||||
|
@ -926,10 +966,16 @@ bool continueFunction(loadedFunction *fun) {
|
|||
int i = fun->reg.varData.intValue;
|
||||
setVariable(fun->reg, SVT_INT, 1);
|
||||
pauseFunction(fun);
|
||||
if (numBIFNames) setFatalInfo(
|
||||
(fun->originalNumber < numUserFunc) ? allUserFunc[fun->originalNumber] : "Unknown user function",
|
||||
(i < numUserFunc) ? allUserFunc[i] : "Unknown user function");
|
||||
if (!startNewFunctionNum(i, 0, fun, noStack, false)) return false;
|
||||
if (numBIFNames)
|
||||
setFatalInfo(
|
||||
(fun->originalNumber < numUserFunc) ?
|
||||
allUserFunc[fun->originalNumber] :
|
||||
"Unknown user function",
|
||||
(i < numUserFunc) ?
|
||||
allUserFunc[i] :
|
||||
"Unknown user function");
|
||||
if (!startNewFunctionNum(i, 0, fun, noStack, false))
|
||||
return false;
|
||||
fun = allRunningFunctions;
|
||||
advanceNow = false; // So we don't do anything else with "fun"
|
||||
}
|
||||
|
@ -961,16 +1007,19 @@ bool continueFunction(loadedFunction *fun) {
|
|||
break;
|
||||
|
||||
case SLU_LOAD_LOCAL:
|
||||
if (!copyVariable(fun->localVars[param], fun->reg)) return false;
|
||||
if (!copyVariable(fun->localVars[param], fun->reg))
|
||||
return false;
|
||||
break;
|
||||
|
||||
case SLU_AND:
|
||||
setVariable(fun->reg, SVT_INT, getBoolean(fun->reg) && getBoolean(fun->stack->thisVar));
|
||||
setVariable(fun->reg, SVT_INT,
|
||||
getBoolean(fun->reg) && getBoolean(fun->stack->thisVar));
|
||||
trimStack(fun->stack);
|
||||
break;
|
||||
|
||||
case SLU_OR:
|
||||
setVariable(fun->reg, SVT_INT, getBoolean(fun->reg) || getBoolean(fun->stack->thisVar));
|
||||
setVariable(fun->reg, SVT_INT,
|
||||
getBoolean(fun->reg) || getBoolean(fun->stack->thisVar));
|
||||
trimStack(fun->stack);
|
||||
break;
|
||||
|
||||
|
@ -987,7 +1036,8 @@ bool continueFunction(loadedFunction *fun) {
|
|||
break;
|
||||
|
||||
case SLU_UNREG:
|
||||
if (dialogValue != 1) fatal(ERROR_HACKER);
|
||||
if (dialogValue != 1)
|
||||
fatal(ERROR_HACKER);
|
||||
break;
|
||||
|
||||
case SLU_LOAD_STRING:
|
||||
|
@ -1015,11 +1065,16 @@ bool continueFunction(loadedFunction *fun) {
|
|||
return fatal(ERROR_INDEX_EMPTY);
|
||||
} else {
|
||||
int ii;
|
||||
if (!getValueType(ii, SVT_INT, fun->reg)) return false;
|
||||
variable *grab = (fun->stack->thisVar.varType == SVT_FASTARRAY) ?
|
||||
fastArrayGetByIndex(fun->stack->thisVar.varData.fastArray, ii)
|
||||
:
|
||||
stackGetByIndex(fun->stack->thisVar.varData.theStack->first, ii);
|
||||
if (!getValueType(ii, SVT_INT, fun->reg))
|
||||
return false;
|
||||
variable *grab =
|
||||
(fun->stack->thisVar.varType == SVT_FASTARRAY) ?
|
||||
fastArrayGetByIndex(
|
||||
fun->stack->thisVar.varData.fastArray,
|
||||
ii) :
|
||||
stackGetByIndex(
|
||||
fun->stack->thisVar.varData.theStack->first,
|
||||
ii);
|
||||
|
||||
trimStack(fun->stack);
|
||||
|
||||
|
@ -1029,19 +1084,22 @@ bool continueFunction(loadedFunction *fun) {
|
|||
int ii;
|
||||
switch (com) {
|
||||
case SLU_INCREMENT_INDEX:
|
||||
if (!getValueType(ii, SVT_INT, * grab)) return false;
|
||||
if (!getValueType(ii, SVT_INT, *grab))
|
||||
return false;
|
||||
setVariable(fun->reg, SVT_INT, ii);
|
||||
grab->varData.intValue = ii + 1;
|
||||
break;
|
||||
|
||||
case SLU_DECREMENT_INDEX:
|
||||
if (!getValueType(ii, SVT_INT, * grab)) return false;
|
||||
if (!getValueType(ii, SVT_INT, *grab))
|
||||
return false;
|
||||
setVariable(fun->reg, SVT_INT, ii);
|
||||
grab->varData.intValue = ii - 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!copyVariable(* grab, fun->reg)) return false;
|
||||
if (!copyVariable(*grab, fun->reg))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1059,8 +1117,11 @@ bool continueFunction(loadedFunction *fun) {
|
|||
return fatal(ERROR_INDEX_EMPTY);
|
||||
} else {
|
||||
int ii;
|
||||
if (!getValueType(ii, SVT_INT, fun->reg)) return false;
|
||||
if (!stackSetByIndex(fun->stack->thisVar.varData.theStack->first, ii, fun->stack->next->thisVar)) {
|
||||
if (!getValueType(ii, SVT_INT, fun->reg))
|
||||
return false;
|
||||
if (!stackSetByIndex(
|
||||
fun->stack->thisVar.varData.theStack->first, ii,
|
||||
fun->stack->next->thisVar)) {
|
||||
return false;
|
||||
}
|
||||
trimStack(fun->stack);
|
||||
|
@ -1070,10 +1131,14 @@ bool continueFunction(loadedFunction *fun) {
|
|||
|
||||
case SVT_FASTARRAY: {
|
||||
int ii;
|
||||
if (!getValueType(ii, SVT_INT, fun->reg)) return false;
|
||||
variable *v = fastArrayGetByIndex(fun->stack->thisVar.varData.fastArray, ii);
|
||||
if (v == NULL) return fatal("Not within bounds of fast array.");
|
||||
if (!copyVariable(fun->stack->next->thisVar, * v)) return false;
|
||||
if (!getValueType(ii, SVT_INT, fun->reg))
|
||||
return false;
|
||||
variable *v = fastArrayGetByIndex(
|
||||
fun->stack->thisVar.varData.fastArray, ii);
|
||||
if (v == NULL)
|
||||
return fatal("Not within bounds of fast array.");
|
||||
if (!copyVariable(fun->stack->next->thisVar, *v))
|
||||
return false;
|
||||
trimStack(fun->stack);
|
||||
trimStack(fun->stack);
|
||||
}
|
||||
|
@ -1089,7 +1154,8 @@ bool continueFunction(loadedFunction *fun) {
|
|||
|
||||
case SLU_INCREMENT_LOCAL: {
|
||||
int ii;
|
||||
if (!getValueType(ii, SVT_INT, fun->localVars[param])) return false;
|
||||
if (!getValueType(ii, SVT_INT, fun->localVars[param]))
|
||||
return false;
|
||||
setVariable(fun->reg, SVT_INT, ii);
|
||||
setVariable(fun->localVars[param], SVT_INT, ii + 1);
|
||||
}
|
||||
|
@ -1097,7 +1163,8 @@ bool continueFunction(loadedFunction *fun) {
|
|||
|
||||
case SLU_INCREMENT_GLOBAL: {
|
||||
int ii;
|
||||
if (!getValueType(ii, SVT_INT, globalVars[param])) return false;
|
||||
if (!getValueType(ii, SVT_INT, globalVars[param]))
|
||||
return false;
|
||||
setVariable(fun->reg, SVT_INT, ii);
|
||||
setVariable(globalVars[param], SVT_INT, ii + 1);
|
||||
}
|
||||
|
@ -1105,7 +1172,8 @@ bool continueFunction(loadedFunction *fun) {
|
|||
|
||||
case SLU_DECREMENT_LOCAL: {
|
||||
int ii;
|
||||
if (!getValueType(ii, SVT_INT, fun->localVars[param])) return false;
|
||||
if (!getValueType(ii, SVT_INT, fun->localVars[param]))
|
||||
return false;
|
||||
setVariable(fun->reg, SVT_INT, ii);
|
||||
setVariable(fun->localVars[param], SVT_INT, ii - 1);
|
||||
}
|
||||
|
@ -1113,35 +1181,41 @@ bool continueFunction(loadedFunction *fun) {
|
|||
|
||||
case SLU_DECREMENT_GLOBAL: {
|
||||
int ii;
|
||||
if (!getValueType(ii, SVT_INT, globalVars[param])) return false;
|
||||
if (!getValueType(ii, SVT_INT, globalVars[param]))
|
||||
return false;
|
||||
setVariable(fun->reg, SVT_INT, ii);
|
||||
setVariable(globalVars[param], SVT_INT, ii - 1);
|
||||
}
|
||||
break;
|
||||
|
||||
case SLU_SET_LOCAL:
|
||||
if (!copyVariable(fun->reg, fun->localVars[param])) return false;
|
||||
if (!copyVariable(fun->reg, fun->localVars[param]))
|
||||
return false;
|
||||
break;
|
||||
|
||||
case SLU_SET_GLOBAL:
|
||||
// newDebug (" Copying TO global variable", param);
|
||||
// newDebug (" Global type at the moment", globalVars[param].varType);
|
||||
if (!copyVariable(fun->reg, globalVars[param])) return false;
|
||||
if (!copyVariable(fun->reg, globalVars[param]))
|
||||
return false;
|
||||
// newDebug (" New type", globalVars[param].varType);
|
||||
break;
|
||||
|
||||
case SLU_LOAD_GLOBAL:
|
||||
// newDebug (" Copying FROM global variable", param);
|
||||
// newDebug (" Global type at the moment", globalVars[param].varType);
|
||||
if (!copyVariable(globalVars[param], fun->reg)) return false;
|
||||
if (!copyVariable(globalVars[param], fun->reg))
|
||||
return false;
|
||||
break;
|
||||
|
||||
case SLU_STACK_PUSH:
|
||||
if (!addVarToStack(fun->reg, fun->stack)) return false;
|
||||
if (!addVarToStack(fun->reg, fun->stack))
|
||||
return false;
|
||||
break;
|
||||
|
||||
case SLU_QUICK_PUSH:
|
||||
if (!addVarToStackQuick(fun->reg, fun->stack)) return false;
|
||||
if (!addVarToStackQuick(fun->reg, fun->stack))
|
||||
return false;
|
||||
break;
|
||||
|
||||
case SLU_NOT:
|
||||
|
@ -1162,7 +1236,8 @@ bool continueFunction(loadedFunction *fun) {
|
|||
|
||||
case SLU_NEGATIVE: {
|
||||
int i;
|
||||
if (!getValueType(i, SVT_INT, fun->reg)) return false;
|
||||
if (!getValueType(i, SVT_INT, fun->reg))
|
||||
return false;
|
||||
setVariable(fun->reg, SVT_INT, -i);
|
||||
}
|
||||
break;
|
||||
|
@ -1201,41 +1276,51 @@ bool continueFunction(loadedFunction *fun) {
|
|||
break;
|
||||
|
||||
default:
|
||||
if (!getValueType(firstValue, SVT_INT, fun->stack->thisVar)) return false;
|
||||
if (!getValueType(secondValue, SVT_INT, fun->reg)) return false;
|
||||
if (!getValueType(firstValue, SVT_INT, fun->stack->thisVar))
|
||||
return false;
|
||||
if (!getValueType(secondValue, SVT_INT, fun->reg))
|
||||
return false;
|
||||
trimStack(fun->stack);
|
||||
|
||||
switch (com) {
|
||||
case SLU_MULT:
|
||||
setVariable(fun->reg, SVT_INT, firstValue * secondValue);
|
||||
setVariable(fun->reg, SVT_INT,
|
||||
firstValue * secondValue);
|
||||
break;
|
||||
|
||||
case SLU_MINUS:
|
||||
setVariable(fun->reg, SVT_INT, firstValue - secondValue);
|
||||
setVariable(fun->reg, SVT_INT,
|
||||
firstValue - secondValue);
|
||||
break;
|
||||
|
||||
case SLU_MODULUS:
|
||||
setVariable(fun->reg, SVT_INT, firstValue % secondValue);
|
||||
setVariable(fun->reg, SVT_INT,
|
||||
firstValue % secondValue);
|
||||
break;
|
||||
|
||||
case SLU_DIVIDE:
|
||||
setVariable(fun->reg, SVT_INT, firstValue / secondValue);
|
||||
setVariable(fun->reg, SVT_INT,
|
||||
firstValue / secondValue);
|
||||
break;
|
||||
|
||||
case SLU_LESSTHAN:
|
||||
setVariable(fun->reg, SVT_INT, firstValue < secondValue);
|
||||
setVariable(fun->reg, SVT_INT,
|
||||
firstValue < secondValue);
|
||||
break;
|
||||
|
||||
case SLU_MORETHAN:
|
||||
setVariable(fun->reg, SVT_INT, firstValue > secondValue);
|
||||
setVariable(fun->reg, SVT_INT,
|
||||
firstValue > secondValue);
|
||||
break;
|
||||
|
||||
case SLU_LESS_EQUAL:
|
||||
setVariable(fun->reg, SVT_INT, firstValue <= secondValue);
|
||||
setVariable(fun->reg, SVT_INT,
|
||||
firstValue <= secondValue);
|
||||
break;
|
||||
|
||||
case SLU_MORE_EQUAL:
|
||||
setVariable(fun->reg, SVT_INT, firstValue >= secondValue);
|
||||
setVariable(fun->reg, SVT_INT,
|
||||
firstValue >= secondValue);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -1251,13 +1336,13 @@ bool continueFunction(loadedFunction *fun) {
|
|||
return fatal(ERROR_UNKNOWN_CODE);
|
||||
}
|
||||
|
||||
if (advanceNow) fun->runThisLine ++;
|
||||
if (advanceNow)
|
||||
fun->runThisLine++;
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool runSludge() {
|
||||
|
||||
loadedFunction *thisFunction = allRunningFunctions;
|
||||
|
@ -1269,7 +1354,8 @@ bool runSludge() {
|
|||
if (!thisFunction->freezerLevel) {
|
||||
if (thisFunction->timeLeft) {
|
||||
if (thisFunction->timeLeft < 0) {
|
||||
if (!stillPlayingSound(findInSoundCache(speech->lastFile))) {
|
||||
if (!stillPlayingSound(
|
||||
findInSoundCache(speech->lastFile))) {
|
||||
thisFunction->timeLeft = 0;
|
||||
}
|
||||
} else if (!--(thisFunction->timeLeft)) {
|
||||
|
@ -1292,7 +1378,8 @@ bool runSludge() {
|
|||
saveGame(loadNow + 1);
|
||||
setVariable(saverFunc->reg, SVT_INT, 1);
|
||||
} else {
|
||||
if (!loadGame(loadNow)) return false;
|
||||
if (!loadGame(loadNow))
|
||||
return false;
|
||||
}
|
||||
delete loadNow;
|
||||
loadNow = NULL;
|
||||
|
@ -1306,7 +1393,8 @@ bool loadFunctionCode(loadedFunction *newFunc) {
|
|||
debug(kSludgeDebugDataLoad, "Current address: %i", bigDataFile->pos());
|
||||
unsigned int numLines, numLinesRead;
|
||||
|
||||
if (!openSubSlice(newFunc->originalNumber)) return false;
|
||||
if (!openSubSlice(newFunc->originalNumber))
|
||||
return false;
|
||||
|
||||
debug(kSludgeDebugDataLoad, "Load function code");
|
||||
|
||||
|
@ -1318,18 +1406,22 @@ bool loadFunctionCode(loadedFunction *newFunc) {
|
|||
newFunc->numLocals = get2bytes(bigDataFile);
|
||||
debug(kSludgeDebugDataLoad, "numLocals: %i", newFunc->numLocals);
|
||||
newFunc->compiledLines = new lineOfCode[numLines];
|
||||
if (!checkNew(newFunc->compiledLines)) return false;
|
||||
if (!checkNew(newFunc->compiledLines))
|
||||
return false;
|
||||
|
||||
for (numLinesRead = 0; numLinesRead < numLines; numLinesRead++) {
|
||||
newFunc->compiledLines[numLinesRead].theCommand = (sludgeCommand) getch(bigDataFile);
|
||||
newFunc->compiledLines[numLinesRead].theCommand = (sludgeCommand) getch(
|
||||
bigDataFile);
|
||||
newFunc->compiledLines[numLinesRead].param = get2bytes(bigDataFile);
|
||||
debug(kSludgeDebugDataLoad, "command line %i: %i", numLinesRead, newFunc->compiledLines[numLinesRead].theCommand);
|
||||
debug(kSludgeDebugDataLoad, "command line %i: %i", numLinesRead,
|
||||
newFunc->compiledLines[numLinesRead].theCommand);
|
||||
}
|
||||
finishAccess();
|
||||
|
||||
// Now we need to reserve memory for the local variables
|
||||
newFunc->localVars = new variable[newFunc->numLocals];
|
||||
if (!checkNew(newFunc->localVars)) return false;
|
||||
if (!checkNew(newFunc->localVars))
|
||||
return false;
|
||||
for (int a = 0; a < newFunc->numLocals; a++) {
|
||||
initVarNew(newFunc->localVars[a]);
|
||||
}
|
||||
|
@ -1337,21 +1429,26 @@ bool loadFunctionCode(loadedFunction *newFunc) {
|
|||
return true;
|
||||
}
|
||||
|
||||
int startNewFunctionNum(unsigned int funcNum, unsigned int numParamsExpected, loadedFunction *calledBy, variableStack *&vStack, bool returnSommet) {
|
||||
int startNewFunctionNum(unsigned int funcNum, unsigned int numParamsExpected,
|
||||
loadedFunction *calledBy, variableStack *&vStack, bool returnSommet) {
|
||||
loadedFunction *newFunc = new loadedFunction;
|
||||
checkNew(newFunc);
|
||||
newFunc->originalNumber = funcNum;
|
||||
|
||||
loadFunctionCode(newFunc);
|
||||
|
||||
if (newFunc->numArgs != (int)numParamsExpected) return fatal("Wrong number of parameters!");
|
||||
if (newFunc->numArgs > newFunc->numLocals) return fatal("More arguments than local variable space!");
|
||||
if (newFunc->numArgs != (int) numParamsExpected)
|
||||
return fatal("Wrong number of parameters!");
|
||||
if (newFunc->numArgs > newFunc->numLocals)
|
||||
return fatal("More arguments than local variable space!");
|
||||
|
||||
// Now, lets copy the parameters from the calling function's stack...
|
||||
|
||||
while (numParamsExpected) {
|
||||
numParamsExpected--;
|
||||
if (vStack == NULL) return fatal("Corrupted file!The stack's empty and there were still parameters expected");
|
||||
if (vStack == NULL)
|
||||
return fatal(
|
||||
"Corrupted file!The stack's empty and there were still parameters expected");
|
||||
copyVariable(vStack->thisVar, newFunc->localVars[numParamsExpected]);
|
||||
trimStack(vStack);
|
||||
}
|
||||
|
@ -1406,38 +1503,53 @@ bool handleInput() {
|
|||
l = 0;
|
||||
}
|
||||
|
||||
if (!overRegion) getOverRegion();
|
||||
if (!overRegion)
|
||||
getOverRegion();
|
||||
|
||||
if (input.justMoved) {
|
||||
if (currentEvents->moveMouseFunction) {
|
||||
if (!startNewFunctionNum(currentEvents->moveMouseFunction, 0, NULL, noStack)) return false;
|
||||
if (!startNewFunctionNum(currentEvents->moveMouseFunction, 0, NULL,
|
||||
noStack))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
input.justMoved = false;
|
||||
|
||||
if (lastRegion != overRegion && currentEvents->focusFunction) {
|
||||
variableStack *tempStack = new variableStack;
|
||||
if (!checkNew(tempStack)) return false;
|
||||
if (!checkNew(tempStack))
|
||||
return false;
|
||||
|
||||
initVarNew(tempStack->thisVar);
|
||||
if (overRegion) {
|
||||
setVariable(tempStack->thisVar, SVT_OBJTYPE, overRegion->thisType->objectNum);
|
||||
setVariable(tempStack->thisVar, SVT_OBJTYPE,
|
||||
overRegion->thisType->objectNum);
|
||||
} else {
|
||||
setVariable(tempStack->thisVar, SVT_INT, 0);
|
||||
}
|
||||
tempStack->next = NULL;
|
||||
if (!startNewFunctionNum(currentEvents->focusFunction, 1, NULL, tempStack)) return false;
|
||||
if (!startNewFunctionNum(currentEvents->focusFunction, 1, NULL,
|
||||
tempStack))
|
||||
return false;
|
||||
}
|
||||
if (input.leftRelease && currentEvents->leftMouseUpFunction) {
|
||||
if (!startNewFunctionNum(currentEvents->leftMouseUpFunction, 0, NULL, noStack)) return false;
|
||||
if (!startNewFunctionNum(currentEvents->leftMouseUpFunction, 0, NULL,
|
||||
noStack))
|
||||
return false;
|
||||
}
|
||||
if (input.rightRelease && currentEvents->rightMouseUpFunction) {
|
||||
if (!startNewFunctionNum(currentEvents->rightMouseUpFunction, 0, NULL, noStack)) return false;
|
||||
if (!startNewFunctionNum(currentEvents->rightMouseUpFunction, 0, NULL,
|
||||
noStack))
|
||||
return false;
|
||||
}
|
||||
if (input.leftClick && currentEvents->leftMouseFunction)
|
||||
if (!startNewFunctionNum(currentEvents->leftMouseFunction, 0, NULL, noStack)) return false;
|
||||
if (!startNewFunctionNum(currentEvents->leftMouseFunction, 0, NULL,
|
||||
noStack))
|
||||
return false;
|
||||
if (input.rightClick && currentEvents->rightMouseFunction) {
|
||||
if (!startNewFunctionNum(currentEvents->rightMouseFunction, 0, NULL, noStack)) return false;
|
||||
if (!startNewFunctionNum(currentEvents->rightMouseFunction, 0, NULL,
|
||||
noStack))
|
||||
return false;
|
||||
}
|
||||
if (input.keyPressed && currentEvents->spaceFunction) {
|
||||
char *tempString = NULL;
|
||||
|
@ -1549,13 +1661,16 @@ bool handleInput() {
|
|||
|
||||
if (tempString) {
|
||||
variableStack *tempStack = new variableStack;
|
||||
if (!checkNew(tempStack)) return false;
|
||||
if (!checkNew(tempStack))
|
||||
return false;
|
||||
initVarNew(tempStack->thisVar);
|
||||
makeTextVar(tempStack->thisVar, tempString);
|
||||
delete tempString;
|
||||
tempString = NULL;
|
||||
tempStack->next = NULL;
|
||||
if (!startNewFunctionNum(currentEvents->spaceFunction, 1, NULL, tempStack)) return false;
|
||||
if (!startNewFunctionNum(currentEvents->spaceFunction, 1, NULL,
|
||||
tempStack))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
input.rightClick = false;
|
||||
|
|
|
@ -80,10 +80,10 @@ struct inputType {
|
|||
extern unsigned char *gameIcon;
|
||||
extern int iconW, iconH;
|
||||
|
||||
|
||||
bool initSludge(char *);
|
||||
void sludgeDisplay();
|
||||
int startNewFunctionNum(unsigned int, unsigned int, loadedFunction *, variableStack*&, bool = true);
|
||||
int startNewFunctionNum(unsigned int, unsigned int, loadedFunction *,
|
||||
variableStack*&, bool = true);
|
||||
bool handleInput();
|
||||
void restartFunction(loadedFunction *fun);
|
||||
bool loadFunctionCode(loadedFunction *newFunc);
|
||||
|
@ -92,7 +92,8 @@ void saveHandlers(Common::WriteStream *stream);
|
|||
|
||||
void finishFunction(loadedFunction *fun);
|
||||
void abortFunction(loadedFunction *fun);
|
||||
Common::File *openAndVerify(char *filename, char extra1, char extra2, const char *er, int &fileVersion);
|
||||
Common::File *openAndVerify(char *filename, char extra1, char extra2,
|
||||
const char *er, int &fileVersion);
|
||||
|
||||
void freezeSubs();
|
||||
void unfreezeSubs();
|
||||
|
|
|
@ -49,9 +49,11 @@ soundThing soundCache[MAX_SAMPLES];
|
|||
int defVol = 128;
|
||||
int defSoundVol = 255;
|
||||
|
||||
char *loadEntireFileToMemory(Common::SeekableReadStream *inputFile, uint32_t size) {
|
||||
char *loadEntireFileToMemory(Common::SeekableReadStream *inputFile,
|
||||
uint32_t size) {
|
||||
char *allData = new char[size];
|
||||
if (!allData) return NULL;
|
||||
if (!allData)
|
||||
return NULL;
|
||||
inputFile->read(allData, size);
|
||||
finishAccess();
|
||||
|
||||
|
@ -69,14 +71,16 @@ void stopMOD(int i) {
|
|||
int findInSoundCache(int a) {
|
||||
int i;
|
||||
for (i = 0; i < MAX_SAMPLES; i++) {
|
||||
if (soundCache[i].fileLoaded == a) return i;
|
||||
if (soundCache[i].fileLoaded == a)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void huntKillSound(int filenum) {
|
||||
int gotSlot = findInSoundCache(filenum);
|
||||
if (gotSlot == -1) return;
|
||||
if (gotSlot == -1)
|
||||
return;
|
||||
soundCache[gotSlot].looping = false;
|
||||
BASS_SampleStop(soundCache[gotSlot].sample);
|
||||
}
|
||||
|
@ -90,7 +94,8 @@ void freeSound(int a) {
|
|||
|
||||
void huntKillFreeSound(int filenum) {
|
||||
int gotSlot = findInSoundCache(filenum);
|
||||
if (gotSlot != -1) freeSound(gotSlot);
|
||||
if (gotSlot != -1)
|
||||
freeSound(gotSlot);
|
||||
}
|
||||
|
||||
bool initSoundStuff(HWND hwnd) {
|
||||
|
@ -119,8 +124,10 @@ bool initSoundStuff(HWND hwnd) {
|
|||
void killSoundStuff() {
|
||||
if (soundOK) {
|
||||
int a;
|
||||
for (a = 0; a < MAX_MODS; a ++) stopMOD(a);
|
||||
for (a = 0; a < MAX_SAMPLES; a ++) freeSound(a);
|
||||
for (a = 0; a < MAX_MODS; a++)
|
||||
stopMOD(a);
|
||||
for (a = 0; a < MAX_SAMPLES; a++)
|
||||
freeSound(a);
|
||||
BASS_Free();
|
||||
}
|
||||
}
|
||||
|
@ -132,13 +139,19 @@ bool playMOD(int f, int a, int fromTrack) {
|
|||
|
||||
setResourceForFatal(f);
|
||||
uint32_t length = openFileFromNum(f);
|
||||
if (length == 0) return NULL;
|
||||
if (length == 0)
|
||||
return NULL;
|
||||
|
||||
char *memImage;
|
||||
memImage = loadEntireFileToMemory(bigDataFile, length);
|
||||
if (!memImage) return fatal(ERROR_MUSIC_MEMORY_LOW);
|
||||
if (!memImage)
|
||||
return fatal(ERROR_MUSIC_MEMORY_LOW);
|
||||
|
||||
mod[a] = BASS_MusicLoad(true, memImage, 0, length, BASS_MUSIC_LOOP | BASS_MUSIC_RAMP/*|BASS_MUSIC_PRESCAN needed too if we're going to set the position in bytes*/, 0);
|
||||
mod[a] =
|
||||
BASS_MusicLoad(true, memImage, 0, length,
|
||||
BASS_MUSIC_LOOP
|
||||
| BASS_MUSIC_RAMP/*|BASS_MUSIC_PRESCAN needed too if we're going to set the position in bytes*/,
|
||||
0);
|
||||
delete memImage;
|
||||
|
||||
if (!mod[a]) {
|
||||
|
@ -149,8 +162,10 @@ bool playMOD(int f, int a, int fromTrack) {
|
|||
if (!BASS_ChannelPlay(mod[a], true))
|
||||
debugOut("playMOD: Error %d!\n", BASS_ErrorGetCode());
|
||||
|
||||
BASS_ChannelSetPosition(mod[a], MAKELONG(fromTrack, 0), BASS_POS_MUSIC_ORDER);
|
||||
BASS_ChannelFlags(mod[a], BASS_SAMPLE_LOOP | BASS_MUSIC_RAMP, BASS_SAMPLE_LOOP | BASS_MUSIC_RAMP);
|
||||
BASS_ChannelSetPosition(mod[a], MAKELONG(fromTrack, 0),
|
||||
BASS_POS_MUSIC_ORDER);
|
||||
BASS_ChannelFlags(mod[a], BASS_SAMPLE_LOOP | BASS_MUSIC_RAMP,
|
||||
BASS_SAMPLE_LOOP | BASS_MUSIC_RAMP);
|
||||
}
|
||||
setResourceForFatal(-1);
|
||||
}
|
||||
|
@ -160,7 +175,8 @@ bool playMOD(int f, int a, int fromTrack) {
|
|||
void setMusicVolume(int a, int v) {
|
||||
int ret;
|
||||
if (soundOK && mod[a]) {
|
||||
ret = BASS_ChannelSetAttribute(mod[a], BASS_ATTRIB_VOL, (float) v / 256);
|
||||
ret = BASS_ChannelSetAttribute(mod[a], BASS_ATTRIB_VOL,
|
||||
(float) v / 256);
|
||||
if (!ret) {
|
||||
debugOut("setMusicVolume: Error %d\n", BASS_ErrorGetCode());
|
||||
}
|
||||
|
@ -176,7 +192,8 @@ void setSoundVolume(int a, int v) {
|
|||
int ch = findInSoundCache(a);
|
||||
if (ch != -1) {
|
||||
if (BASS_ChannelIsActive(soundCache[ch].mostRecentChannel)) {
|
||||
BASS_ChannelSetAttribute(soundCache[ch].mostRecentChannel, BASS_ATTRIB_VOL, (float) v / 256);
|
||||
BASS_ChannelSetAttribute(soundCache[ch].mostRecentChannel,
|
||||
BASS_ATTRIB_VOL, (float) v / 256);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -186,7 +203,8 @@ bool stillPlayingSound(int ch) {
|
|||
if (soundOK)
|
||||
if (ch != -1)
|
||||
if (soundCache[ch].fileLoaded != -1)
|
||||
if (BASS_ChannelIsActive(soundCache[ch].mostRecentChannel) != BASS_ACTIVE_STOPPED)
|
||||
if (BASS_ChannelIsActive(soundCache[ch].mostRecentChannel)
|
||||
!= BASS_ACTIVE_STOPPED)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -224,7 +242,8 @@ int findEmptySoundSlot() {
|
|||
for (t = 0; t < MAX_SAMPLES; t++) {
|
||||
emptySoundSlot++;
|
||||
emptySoundSlot %= MAX_SAMPLES;
|
||||
if (!soundCache[emptySoundSlot].looping) return emptySoundSlot;
|
||||
if (!soundCache[emptySoundSlot].looping)
|
||||
return emptySoundSlot;
|
||||
}
|
||||
|
||||
// Holy crap, they're all looping!What's this twat playing at?
|
||||
|
@ -267,16 +286,20 @@ bool forceRemoveSound() {
|
|||
int cacheSound(int f) {
|
||||
setResourceForFatal(f);
|
||||
|
||||
if (!soundOK) return 0;
|
||||
if (!soundOK)
|
||||
return 0;
|
||||
|
||||
int a = findInSoundCache(f);
|
||||
if (a != -1) return a;
|
||||
if (f == -2) return -1;
|
||||
if (a != -1)
|
||||
return a;
|
||||
if (f == -2)
|
||||
return -1;
|
||||
a = findEmptySoundSlot();
|
||||
freeSound(a);
|
||||
|
||||
uint32_t length = openFileFromNum(f);
|
||||
if (!length) return -1;
|
||||
if (!length)
|
||||
return -1;
|
||||
|
||||
char *memImage;
|
||||
|
||||
|
@ -295,7 +318,8 @@ int cacheSound(int f) {
|
|||
|
||||
for (;;) {
|
||||
// soundWarning (" Trying to load sound into slot", a);
|
||||
soundCache[a].sample = BASS_SampleLoad(true, memImage, 0, length, 65535, 0);
|
||||
soundCache[a].sample = BASS_SampleLoad(true, memImage, 0, length, 65535,
|
||||
0);
|
||||
|
||||
if (soundCache[a].sample) {
|
||||
soundCache[a].fileLoaded = f;
|
||||
|
@ -315,17 +339,21 @@ int cacheSound(int f) {
|
|||
bool startSound(int f, bool loopy) {
|
||||
if (soundOK) {
|
||||
int a = cacheSound(f);
|
||||
if (a == -1) return false;
|
||||
if (a == -1)
|
||||
return false;
|
||||
|
||||
soundCache[a].looping = loopy;
|
||||
soundCache[a].vol = defSoundVol;
|
||||
|
||||
soundCache[a].mostRecentChannel = BASS_SampleGetChannel(soundCache[a].sample, false);
|
||||
soundCache[a].mostRecentChannel = BASS_SampleGetChannel(
|
||||
soundCache[a].sample, false);
|
||||
if (soundCache[a].mostRecentChannel) {
|
||||
BASS_ChannelPlay(soundCache[a].mostRecentChannel, true);
|
||||
BASS_ChannelSetAttribute(soundCache[a].mostRecentChannel, BASS_ATTRIB_VOL, defSoundVol);
|
||||
BASS_ChannelSetAttribute(soundCache[a].mostRecentChannel,
|
||||
BASS_ATTRIB_VOL, defSoundVol);
|
||||
if (loopy) {
|
||||
BASS_ChannelFlags(soundCache[a].mostRecentChannel, BASS_SAMPLE_LOOP, BASS_SAMPLE_LOOP); // set LOOP flag
|
||||
BASS_ChannelFlags(soundCache[a].mostRecentChannel,
|
||||
BASS_SAMPLE_LOOP, BASS_SAMPLE_LOOP); // set LOOP flag
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -363,7 +391,8 @@ void saveSounds(Common::WriteStream *stream) {
|
|||
}
|
||||
|
||||
void loadSounds(Common::SeekableReadStream *stream) {
|
||||
for (int i = 0; i < MAX_SAMPLES; i ++) freeSound(i);
|
||||
for (int i = 0; i < MAX_SAMPLES; i++)
|
||||
freeSound(i);
|
||||
|
||||
while (getch(stream)) {
|
||||
int fileLoaded = get2bytes(stream);
|
||||
|
@ -382,8 +411,10 @@ bool getSoundCacheStack(stackHandler *sH) {
|
|||
for (int a = 0; a < MAX_SAMPLES; a++) {
|
||||
if (soundCache[a].fileLoaded != -1) {
|
||||
setVariable(newFileHandle, SVT_FILE, soundCache[a].fileLoaded);
|
||||
if (!addVarToStackQuick(newFileHandle, sH -> first)) return false;
|
||||
if (sH -> last == NULL) sH -> last = sH -> first;
|
||||
if (!addVarToStackQuick(newFileHandle, sH->first))
|
||||
return false;
|
||||
if (sH->last == NULL)
|
||||
sH->last = sH->first;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -97,7 +97,8 @@ bool initSoundStuff(HWND hwnd) {
|
|||
}
|
||||
|
||||
void killSoundStuff() {
|
||||
if (! soundOK) return;
|
||||
if (!soundOK)
|
||||
return;
|
||||
#if 0
|
||||
SilenceIKillYou = true;
|
||||
for (int i = 0; i < MAX_SAMPLES; i ++) {
|
||||
|
@ -151,7 +152,8 @@ void killSoundStuff() {
|
|||
*/
|
||||
|
||||
void setMusicVolume(int a, int v) {
|
||||
if (! soundOK) return;
|
||||
if (!soundOK)
|
||||
return;
|
||||
|
||||
if (modCache[a].playing) {
|
||||
#if 0
|
||||
|
@ -165,7 +167,8 @@ void setDefaultMusicVolume(int v) {
|
|||
}
|
||||
|
||||
void setSoundVolume(int a, int v) {
|
||||
if (! soundOK) return;
|
||||
if (!soundOK)
|
||||
return;
|
||||
int ch = findInSoundCache(a);
|
||||
if (ch != -1) {
|
||||
if (soundCache[ch].playing) {
|
||||
|
@ -241,7 +244,8 @@ int findInSoundCache(int a) {
|
|||
}
|
||||
|
||||
void stopMOD(int i) {
|
||||
if (! soundOK) return;
|
||||
if (!soundOK)
|
||||
return;
|
||||
#if 0
|
||||
alGetError();
|
||||
if (modCache[i].playing) {
|
||||
|
@ -253,7 +257,8 @@ void stopMOD(int i) {
|
|||
}
|
||||
|
||||
void huntKillSound(int filenum) {
|
||||
if (! soundOK) return;
|
||||
if (!soundOK)
|
||||
return;
|
||||
#if 0
|
||||
// Clear OpenAL errors to make sure they don't block anything:
|
||||
alGetError();
|
||||
|
@ -273,7 +278,8 @@ void huntKillSound(int filenum) {
|
|||
}
|
||||
|
||||
void freeSound(int a) {
|
||||
if (! soundOK) return;
|
||||
if (!soundOK)
|
||||
return;
|
||||
#if 0
|
||||
// Clear OpenAL errors to make sure they don't block anything:
|
||||
alGetError();
|
||||
|
@ -297,11 +303,12 @@ void freeSound(int a) {
|
|||
SilenceIKillYou = false;
|
||||
}
|
||||
|
||||
|
||||
void huntKillFreeSound(int filenum) {
|
||||
if (! soundOK) return;
|
||||
if (!soundOK)
|
||||
return;
|
||||
int gotSlot = findInSoundCache(filenum);
|
||||
if (gotSlot == -1) return;
|
||||
if (gotSlot == -1)
|
||||
return;
|
||||
freeSound(gotSlot);
|
||||
}
|
||||
|
||||
|
@ -361,9 +368,11 @@ void playStream(int a, bool isMOD, bool loopy) {
|
|||
#endif
|
||||
}
|
||||
|
||||
char *loadEntireFileToMemory(Common::SeekableReadStream *inputFile, uint32_t size) {
|
||||
char *loadEntireFileToMemory(Common::SeekableReadStream *inputFile,
|
||||
uint32_t size) {
|
||||
char *allData = new char[size];
|
||||
if (! allData) return NULL;
|
||||
if (!allData)
|
||||
return NULL;
|
||||
|
||||
size_t bytes_read = inputFile->read(allData, size);
|
||||
if (bytes_read != size && inputFile->err()) {
|
||||
|
@ -376,7 +385,8 @@ char *loadEntireFileToMemory(Common::SeekableReadStream *inputFile, uint32_t siz
|
|||
}
|
||||
|
||||
bool playMOD(int f, int a, int fromTrack) {
|
||||
if (! soundOK) return true;
|
||||
if (!soundOK)
|
||||
return true;
|
||||
stopMOD(a);
|
||||
|
||||
setResourceForFatal(f);
|
||||
|
@ -475,7 +485,8 @@ int findEmptySoundSlot() {
|
|||
for (t = 0; t < MAX_SAMPLES; t++) {
|
||||
emptySoundSlot++;
|
||||
emptySoundSlot %= MAX_SAMPLES;
|
||||
if (! soundCache[emptySoundSlot].looping) return emptySoundSlot;
|
||||
if (!soundCache[emptySoundSlot].looping)
|
||||
return emptySoundSlot;
|
||||
}
|
||||
|
||||
// Holy crap, they're all looping! What's this twat playing at?
|
||||
|
@ -487,7 +498,8 @@ int findEmptySoundSlot() {
|
|||
|
||||
int cacheSound(int f) {
|
||||
|
||||
if (! soundOK) return -1;
|
||||
if (!soundOK)
|
||||
return -1;
|
||||
|
||||
unsigned int chunkLength;
|
||||
int retval;
|
||||
|
@ -606,7 +618,8 @@ void saveSounds(Common::WriteStream *stream) {
|
|||
}
|
||||
|
||||
void loadSounds(Common::SeekableReadStream *stream) {
|
||||
for (int i = 0; i < MAX_SAMPLES; i ++) freeSound(i);
|
||||
for (int i = 0; i < MAX_SAMPLES; i++)
|
||||
freeSound(i);
|
||||
|
||||
while (getch(stream)) {
|
||||
int fileLoaded = get2bytes(stream);
|
||||
|
@ -625,8 +638,10 @@ bool getSoundCacheStack(stackHandler *sH) {
|
|||
for (int a = 0; a < MAX_SAMPLES; a++) {
|
||||
if (soundCache[a].fileLoaded != -1) {
|
||||
setVariable(newFileHandle, SVT_FILE, soundCache[a].fileLoaded);
|
||||
if (! addVarToStackQuick(newFileHandle, sH -> first)) return false;
|
||||
if (sH -> last == NULL) sH -> last = sH -> first;
|
||||
if (!addVarToStackQuick(newFileHandle, sH->first))
|
||||
return false;
|
||||
if (sH->last == NULL)
|
||||
sH->last = sH->first;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -634,19 +649,22 @@ bool getSoundCacheStack(stackHandler *sH) {
|
|||
|
||||
soundList *deleteSoundFromList(soundList *s) {
|
||||
// Don't delete a playing sound.
|
||||
if (s->cacheIndex) return NULL;
|
||||
if (s->cacheIndex)
|
||||
return NULL;
|
||||
|
||||
soundList *o = NULL;
|
||||
if (!s->next) {
|
||||
o = s->prev;
|
||||
if (o) o-> next = NULL;
|
||||
if (o)
|
||||
o->next = NULL;
|
||||
delete s;
|
||||
return o;
|
||||
}
|
||||
if (s != s->next) {
|
||||
o = s->next;
|
||||
o->prev = s->prev;
|
||||
if (o->prev) o->prev->next = o;
|
||||
if (o->prev)
|
||||
o->prev->next = o;
|
||||
}
|
||||
delete s;
|
||||
return o;
|
||||
|
|
|
@ -31,7 +31,6 @@ loadedSpriteBank *allLoadedBanks = NULL;
|
|||
extern spriteBank theFont;
|
||||
extern int loadedFontNum, fontTableSize;
|
||||
|
||||
|
||||
loadedSpriteBank *loadBankForAnim(int ID) {
|
||||
//debugOut ("loadBankForAnim: Looking for sprite bank with ID %d\n", ID);
|
||||
loadedSpriteBank *returnMe = allLoadedBanks;
|
||||
|
@ -53,10 +52,12 @@ loadedSpriteBank *loadBankForAnim(int ID) {
|
|||
debugOut("loadBankForAnim: New sprite bank created OK\n");
|
||||
return returnMe;
|
||||
} else {
|
||||
debugOut("loadBankForAnim: I guess I couldn't load the sprites...\n");
|
||||
debugOut(
|
||||
"loadBankForAnim: I guess I couldn't load the sprites...\n");
|
||||
return NULL;
|
||||
}
|
||||
} else return NULL;
|
||||
} else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void reloadSpriteTextures() {
|
||||
|
|
|
@ -57,7 +57,6 @@ extern float cameraZoom;
|
|||
|
||||
unsigned char currentBurnR = 0, currentBurnG = 0, currentBurnB = 0;
|
||||
|
||||
|
||||
void forgetSpriteBank(spriteBank &forgetme) {
|
||||
#if 0
|
||||
deleteTextures(forgetme.myPalette.numTextures, forgetme.myPalette.tex_names);
|
||||
|
@ -89,7 +88,6 @@ void forgetSpriteBank(spriteBank &forgetme) {
|
|||
delete forgetme.sprites;
|
||||
forgetme.sprites = NULL;
|
||||
|
||||
|
||||
// TODO: also remove sprite bank from allLoadedBanks
|
||||
// And add a function call for this function to the scripting language
|
||||
}
|
||||
|
@ -103,16 +101,21 @@ bool reserveSpritePal(spritePalette &sP, int n) {
|
|||
}
|
||||
|
||||
sP.pal = new unsigned short int[n];
|
||||
if (! checkNew(sP.pal)) return false;
|
||||
if (!checkNew(sP.pal))
|
||||
return false;
|
||||
|
||||
sP.r = new unsigned char[n];
|
||||
if (! checkNew(sP.r)) return false;
|
||||
if (!checkNew(sP.r))
|
||||
return false;
|
||||
sP.g = new unsigned char[n];
|
||||
if (! checkNew(sP.g)) return false;
|
||||
if (!checkNew(sP.g))
|
||||
return false;
|
||||
sP.b = new unsigned char[n];
|
||||
if (! checkNew(sP.b)) return false;
|
||||
if (!checkNew(sP.b))
|
||||
return false;
|
||||
sP.total = n;
|
||||
return (bool)(sP.pal != NULL) && (sP.r != NULL) && (sP.g != NULL) && (sP.b != NULL);
|
||||
return (bool) (sP.pal != NULL) && (sP.r != NULL) && (sP.g != NULL)
|
||||
&& (sP.b != NULL);
|
||||
}
|
||||
|
||||
bool loadSpriteBank(int fileNum, spriteBank &loadhere, bool isFont) {
|
||||
|
@ -287,7 +290,6 @@ bool loadSpriteBank(int fileNum, spriteBank &loadhere, bool isFont) {
|
|||
}
|
||||
numTextures++;
|
||||
|
||||
|
||||
if (! spriteBankVersion) {
|
||||
howmany = fgetc(bigDataFile);
|
||||
startIndex = fgetc(bigDataFile);
|
||||
|
@ -436,7 +438,8 @@ bool loadSpriteBank(int fileNum, spriteBank &loadhere, bool isFont) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void pasteSpriteToBackDrop(int x1, int y1, sprite &single, const spritePalette &fontPal) {
|
||||
void pasteSpriteToBackDrop(int x1, int y1, sprite &single,
|
||||
const spritePalette &fontPal) {
|
||||
#if 0
|
||||
float tx1 = (float)(single.tex_x) / fontPal.tex_w[single.texNum];
|
||||
float ty1 = 0.0;
|
||||
|
@ -490,7 +493,6 @@ void pasteSpriteToBackDrop(int x1, int y1, sprite &single, const spritePalette &
|
|||
while (yoffset < diffY) {
|
||||
int h = (diffY - yoffset < viewportHeight) ? diffY - yoffset : viewportHeight;
|
||||
|
||||
|
||||
// Render the sprite to the backdrop
|
||||
// (using mulitexturing, so the backdrop is seen where alpha < 1.0)
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
|
@ -536,7 +538,8 @@ void pasteSpriteToBackDrop(int x1, int y1, sprite &single, const spritePalette &
|
|||
setPixelCoords(false);
|
||||
}
|
||||
|
||||
void burnSpriteToBackDrop(int x1, int y1, sprite &single, const spritePalette &fontPal) {
|
||||
void burnSpriteToBackDrop(int x1, int y1, sprite &single,
|
||||
const spritePalette &fontPal) {
|
||||
#if 0
|
||||
float tx1 = (float)(single.tex_x - 0.5) / fontPal.tex_w[single.texNum];
|
||||
float ty1 = 0.0;
|
||||
|
@ -644,11 +647,13 @@ void burnSpriteToBackDrop(int x1, int y1, sprite &single, const spritePalette &f
|
|||
extern GLuint backdropTextureName;
|
||||
#endif
|
||||
|
||||
void fontSprite(bool flip, int x, int y, sprite &single, const spritePalette &fontPal) {
|
||||
void fontSprite(bool flip, int x, int y, sprite &single,
|
||||
const spritePalette &fontPal) {
|
||||
|
||||
float tx1 = (float) (single.tex_x - 0.5) / fontPal.tex_w[single.texNum];
|
||||
float ty1 = 0.0;
|
||||
float tx2 = (float)(single.tex_x + single.width + (flip ? 1.0 : 0.5)) / fontPal.tex_w[single.texNum];
|
||||
float tx2 = (float) (single.tex_x + single.width + (flip ? 1.0 : 0.5))
|
||||
/ fontPal.tex_w[single.texNum];
|
||||
float ty2 = (float) (single.height + 2) / fontPal.tex_h[single.texNum];
|
||||
|
||||
float x1 = (float) x - (float) single.xhot / cameraZoom;
|
||||
|
@ -707,13 +712,11 @@ void fontSprite(int x, int y, sprite &single, const spritePalette &fontPal) {
|
|||
fontSprite(false, x, y, single, fontPal);
|
||||
}
|
||||
|
||||
void flipFontSprite(int x, int y, sprite &single, const spritePalette &fontPal) {
|
||||
void flipFontSprite(int x, int y, sprite &single,
|
||||
const spritePalette &fontPal) {
|
||||
fontSprite(true, x, y, single, fontPal);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
unsigned char curLight[3];
|
||||
|
||||
void setDrawMode(onScreenPerson *thisPerson) {
|
||||
|
@ -734,7 +737,8 @@ extern GLuint backdropTextureName;
|
|||
|
||||
bool checkColourChange(bool reset);
|
||||
|
||||
bool scaleSprite(sprite &single, const spritePalette &fontPal, onScreenPerson *thisPerson, bool mirror) {
|
||||
bool scaleSprite(sprite &single, const spritePalette &fontPal,
|
||||
onScreenPerson *thisPerson, bool mirror) {
|
||||
#if 0
|
||||
float x = thisPerson->x;
|
||||
float y = thisPerson->y;
|
||||
|
@ -909,7 +913,8 @@ bool scaleSprite(sprite &single, const spritePalette &fontPal, onScreenPerson *t
|
|||
}
|
||||
|
||||
// Paste a scaled sprite onto the backdrop
|
||||
void fixScaleSprite(int x, int y, sprite &single, const spritePalette &fontPal, onScreenPerson *thisPerson, int camX, int camY, bool mirror) {
|
||||
void fixScaleSprite(int x, int y, sprite &single, const spritePalette &fontPal,
|
||||
onScreenPerson *thisPerson, int camX, int camY, bool mirror) {
|
||||
#if 0
|
||||
float scale = thisPerson-> scale;
|
||||
bool useZB = !(thisPerson->extra & EXTRA_NOZB);
|
||||
|
@ -942,7 +947,6 @@ void fixScaleSprite(int x, int y, sprite &single, const spritePalette &fontPal,
|
|||
|
||||
GLfloat z;
|
||||
|
||||
|
||||
if (useZB && zBuffer.numPanels) {
|
||||
int i;
|
||||
for (i = 1; i < zBuffer.numPanels; i++) {
|
||||
|
|
|
@ -55,9 +55,10 @@ public:
|
|||
int numTextures;
|
||||
unsigned char originalRed, originalGreen, originalBlue, total;
|
||||
|
||||
spritePalette(): pal(0), r(0), g(0), b(0)/*, tex_names(0), burnTex_names(0)*/
|
||||
, tex_w(0), tex_h(0), numTextures(0)
|
||||
, total(0) {}
|
||||
spritePalette() :
|
||||
pal(0), r(0), g(0), b(0)/*, tex_names(0), burnTex_names(0)*/
|
||||
, tex_w(0), tex_h(0), numTextures(0), total(0) {
|
||||
}
|
||||
|
||||
~spritePalette() {
|
||||
delete[] pal;
|
||||
|
@ -84,13 +85,19 @@ bool loadSpriteBank(char *filename, spriteBank &loadhere);
|
|||
bool loadSpriteBank(int fileNum, spriteBank &loadhere, bool isFont);
|
||||
|
||||
void fontSprite(int x1, int y1, sprite &single, const spritePalette &fontPal);
|
||||
void flipFontSprite(int x1, int y1, sprite &single, const spritePalette &fontPal);
|
||||
void flipFontSprite(int x1, int y1, sprite &single,
|
||||
const spritePalette &fontPal);
|
||||
|
||||
bool scaleSprite(sprite &single, const spritePalette &fontPal, onScreenPerson *thisPerson, bool mirror);
|
||||
void pasteSpriteToBackDrop(int x1, int y1, sprite &single, const spritePalette &fontPal);
|
||||
bool scaleSprite(sprite &single, const spritePalette &fontPal,
|
||||
onScreenPerson *thisPerson, bool mirror);
|
||||
void pasteSpriteToBackDrop(int x1, int y1, sprite &single,
|
||||
const spritePalette &fontPal);
|
||||
bool reserveSpritePal(spritePalette &sP, int n);
|
||||
void fixScaleSprite(int x1, int y1, sprite &single, const spritePalette &fontPal, onScreenPerson *thisPerson, const int camX, const int camY, bool);
|
||||
void burnSpriteToBackDrop(int x1, int y1, sprite &single, const spritePalette &fontPal);
|
||||
void fixScaleSprite(int x1, int y1, sprite &single,
|
||||
const spritePalette &fontPal, onScreenPerson *thisPerson,
|
||||
const int camX, const int camY, bool);
|
||||
void burnSpriteToBackDrop(int x1, int y1, sprite &single,
|
||||
const spritePalette &fontPal);
|
||||
|
||||
} // End of namespace Sludge
|
||||
|
||||
|
|
|
@ -29,14 +29,16 @@ namespace Sludge {
|
|||
|
||||
char *copyString(const char *copyMe) {
|
||||
char *newString = new char[strlen(copyMe) + 1];
|
||||
if (! checkNew(newString)) return NULL;
|
||||
if (!checkNew(newString))
|
||||
return NULL;
|
||||
strcpy(newString, copyMe);
|
||||
return newString;
|
||||
}
|
||||
|
||||
char *joinStrings(const char *s1, const char *s2) {
|
||||
char *newString = new char[strlen(s1) + strlen(s2) + 1];
|
||||
if (! checkNew(newString)) return NULL;
|
||||
if (!checkNew(newString))
|
||||
return NULL;
|
||||
sprintf(newString, "%s%s", s1, s2);
|
||||
return newString;
|
||||
}
|
||||
|
|
|
@ -96,7 +96,8 @@ void addSpeechLine(char *theLine, int x, int &offset) {
|
|||
speech->allSpeech = newLine;
|
||||
if ((xx1 < 5) && (offset < (5 - xx1))) {
|
||||
offset = 5 - xx1;
|
||||
} else if ((xx2 >= ((float)winWidth / cameraZoom) - 5) && (offset > (((float)winWidth / cameraZoom) - 5 - xx2))) {
|
||||
} else if ((xx2 >= ((float) winWidth / cameraZoom) - 5)
|
||||
&& (offset > (((float) winWidth / cameraZoom) - 5 - xx2))) {
|
||||
offset = ((float) winWidth / cameraZoom) - 5 - xx2;
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +112,8 @@ int wrapSpeechXY(char *theText, int x, int y, int wrap, int sampleFile) {
|
|||
killAllSpeech();
|
||||
|
||||
int speechTime = (strlen(theText) + 20) * speechSpeed;
|
||||
if (speechTime < 1) speechTime = 1;
|
||||
if (speechTime < 1)
|
||||
speechTime = 1;
|
||||
if (sampleFile != -1) {
|
||||
if (speechMode >= 1) {
|
||||
#if 0
|
||||
|
@ -143,8 +145,12 @@ int wrapSpeechXY(char *theText, int x, int y, int wrap, int sampleFile) {
|
|||
addSpeechLine(theText, x, offset);
|
||||
y -= fontHeight / cameraZoom;
|
||||
|
||||
if (y < 0) speech->speechY -= y;
|
||||
else if (speech->speechY > cameraY + (float)(winHeight - fontHeight / 3) / cameraZoom) speech->speechY = cameraY + (float)(winHeight - fontHeight / 3) / cameraZoom;
|
||||
if (y < 0)
|
||||
speech->speechY -= y;
|
||||
else if (speech->speechY
|
||||
> cameraY + (float) (winHeight - fontHeight / 3) / cameraZoom)
|
||||
speech->speechY = cameraY
|
||||
+ (float) (winHeight - fontHeight / 3) / cameraZoom;
|
||||
|
||||
if (offset) {
|
||||
speechLine *viewLine = speech->allSpeech;
|
||||
|
@ -156,8 +162,13 @@ int wrapSpeechXY(char *theText, int x, int y, int wrap, int sampleFile) {
|
|||
return speechTime;
|
||||
}
|
||||
|
||||
int wrapSpeechPerson(char *theText, onScreenPerson &thePerson, int sampleFile, bool animPerson) {
|
||||
int i = wrapSpeechXY(theText, thePerson.x - cameraX, thePerson.y - cameraY - (thePerson.scale * (thePerson.height - thePerson.floaty)) - thePerson.thisType->speechGap, thePerson.thisType->wrapSpeech, sampleFile);
|
||||
int wrapSpeechPerson(char *theText, onScreenPerson &thePerson, int sampleFile,
|
||||
bool animPerson) {
|
||||
int i = wrapSpeechXY(theText, thePerson.x - cameraX,
|
||||
thePerson.y - cameraY
|
||||
- (thePerson.scale * (thePerson.height - thePerson.floaty))
|
||||
- thePerson.thisType->speechGap,
|
||||
thePerson.thisType->wrapSpeech, sampleFile);
|
||||
if (animPerson) {
|
||||
makeTalker(thePerson);
|
||||
speech->currentTalker = &thePerson;
|
||||
|
@ -177,11 +188,15 @@ int wrapSpeech(char *theText, int objT, int sampleFile, bool animPerson) {
|
|||
screenRegion *thisRegion = getRegionForObject(objT);
|
||||
if (thisRegion) {
|
||||
setObjFontColour(thisRegion->thisType);
|
||||
i = wrapSpeechXY(theText, ((thisRegion->x1 + thisRegion->x2) >> 1) - cameraX, thisRegion->y1 - thisRegion->thisType->speechGap - cameraY, thisRegion->thisType->wrapSpeech, sampleFile);
|
||||
i = wrapSpeechXY(theText,
|
||||
((thisRegion->x1 + thisRegion->x2) >> 1) - cameraX,
|
||||
thisRegion->y1 - thisRegion->thisType->speechGap - cameraY,
|
||||
thisRegion->thisType->wrapSpeech, sampleFile);
|
||||
} else {
|
||||
objectType *temp = findObjectType(objT);
|
||||
setObjFontColour(temp);
|
||||
i = wrapSpeechXY(theText, winWidth >> 1, 10, temp->wrapSpeech, sampleFile);
|
||||
i = wrapSpeechXY(theText, winWidth >> 1, 10, temp->wrapSpeech,
|
||||
sampleFile);
|
||||
}
|
||||
}
|
||||
return i;
|
||||
|
|
|
@ -32,7 +32,6 @@ struct speechLine {
|
|||
int x;
|
||||
};
|
||||
|
||||
|
||||
struct speechStruct {
|
||||
onScreenPerson *currentTalker;
|
||||
speechLine *allSpeech;
|
||||
|
|
|
@ -40,7 +40,6 @@ int thumbWidth = 0, thumbHeight = 0;
|
|||
extern GLuint backdropTextureName;
|
||||
#endif
|
||||
|
||||
|
||||
bool saveThumbnail(Common::WriteStream *stream) {
|
||||
#if 0
|
||||
GLuint thumbnailTextureName = 0;
|
||||
|
@ -72,7 +71,6 @@ bool saveThumbnail(Common::WriteStream *stream) {
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
|
||||
|
||||
const GLfloat vertices[] = {
|
||||
0., 0., 0.,
|
||||
thumbWidth - 1.f, 0., 0.,
|
||||
|
@ -120,8 +118,6 @@ bool saveThumbnail(Common::WriteStream *stream) {
|
|||
glReadPixels(viewportOffsetX, viewportOffsetY, thumbWidth, thumbHeight, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, image);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
glUseProgram(0);
|
||||
#endif
|
||||
setPixelCoords(false);
|
||||
|
|
|
@ -59,4 +59,5 @@ void Wait_Frame(void) {
|
|||
}
|
||||
#endif
|
||||
|
||||
} // End of namespace Sludge
|
||||
}
|
||||
// End of namespace Sludge
|
||||
|
|
|
@ -187,7 +187,6 @@ bool reserveTransitionTexture() {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
void transitionDisolve() {
|
||||
|
||||
#if 0
|
||||
|
|
|
@ -42,9 +42,8 @@
|
|||
namespace Sludge {
|
||||
|
||||
const char *typeName[] = { "undefined", "number", "user function", "string",
|
||||
"built-in function", "file", "stack",
|
||||
"object type", "animation", "costume"
|
||||
};
|
||||
"built-in function", "file", "stack", "object type", "animation",
|
||||
"costume" };
|
||||
|
||||
extern char *outputDir;
|
||||
|
||||
|
@ -58,7 +57,8 @@ void unlinkVar(variable &thisVar) {
|
|||
case SVT_STACK:
|
||||
thisVar.varData.theStack->timesUsed--;
|
||||
if (thisVar.varData.theStack->timesUsed <= 0) {
|
||||
while (thisVar.varData.theStack -> first) trimStack(thisVar.varData.theStack -> first);
|
||||
while (thisVar.varData.theStack->first)
|
||||
trimStack(thisVar.varData.theStack->first);
|
||||
delete thisVar.varData.theStack;
|
||||
thisVar.varData.theStack = NULL;
|
||||
}
|
||||
|
@ -101,7 +101,8 @@ personaAnimation *getAnimationFromVar(variable &thisVar) {
|
|||
if (thisVar.varType == SVT_INT && thisVar.varData.intValue == 0)
|
||||
return makeNullAnim();
|
||||
|
||||
fatal("Expecting an animation variable; found variable of type", typeName[thisVar.varType]);
|
||||
fatal("Expecting an animation variable; found variable of type",
|
||||
typeName[thisVar.varType]);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -117,10 +118,12 @@ persona *getCostumeFromVar(variable &thisVar) {
|
|||
switch (thisVar.varType) {
|
||||
case SVT_ANIM:
|
||||
p = new persona;
|
||||
if (! checkNew(p)) return NULL;
|
||||
if (!checkNew(p))
|
||||
return NULL;
|
||||
p->numDirections = 1;
|
||||
p->animation = new personaAnimation *[3];
|
||||
if (! checkNew(p -> animation)) return NULL;
|
||||
if (!checkNew(p->animation))
|
||||
return NULL;
|
||||
|
||||
for (int iii = 0; iii < 3; iii++)
|
||||
p->animation[iii] = copyAnim(thisVar.varData.animHandler);
|
||||
|
@ -132,7 +135,8 @@ persona *getCostumeFromVar(variable &thisVar) {
|
|||
break;
|
||||
|
||||
default:
|
||||
fatal("Expecting an animation variable; found variable of type", typeName[thisVar.varType]);
|
||||
fatal("Expecting an animation variable; found variable of type",
|
||||
typeName[thisVar.varType]);
|
||||
}
|
||||
|
||||
return p;
|
||||
|
@ -156,7 +160,8 @@ char *ConvertFromUTF16(const WCHAR *input);
|
|||
|
||||
bool getSavedGamesStack(stackHandler *sH, char *ext) {
|
||||
char *pattern = joinStrings("*", ext);
|
||||
if (! pattern) return false;
|
||||
if (!pattern)
|
||||
return false;
|
||||
|
||||
variable newName;
|
||||
newName.varType = SVT_NULL;
|
||||
|
@ -189,7 +194,8 @@ bool getSavedGamesStack(stackHandler *sH, char *ext) {
|
|||
#else
|
||||
|
||||
DIR *dir = opendir(".");
|
||||
if (! dir) return false;
|
||||
if (!dir)
|
||||
return false;
|
||||
|
||||
struct dirent *d = readdir(dir);
|
||||
while (d != NULL) {
|
||||
|
@ -198,14 +204,15 @@ bool getSavedGamesStack(stackHandler *sH, char *ext) {
|
|||
char *decoded = decodeFilename(d->d_name);
|
||||
makeTextVar(newName, decoded);
|
||||
delete[] decoded;
|
||||
if (! addVarToStack(newName, sH -> first)) return false;
|
||||
if (sH -> last == NULL) sH -> last = sH -> first;
|
||||
if (!addVarToStack(newName, sH->first))
|
||||
return false;
|
||||
if (sH->last == NULL)
|
||||
sH->last = sH->first;
|
||||
}
|
||||
|
||||
d = readdir(dir);
|
||||
}
|
||||
|
||||
|
||||
closedir(dir);
|
||||
|
||||
#endif
|
||||
|
@ -218,7 +225,8 @@ bool getSavedGamesStack(stackHandler *sH, char *ext) {
|
|||
bool copyStack(const variable &from, variable &to) {
|
||||
to.varType = SVT_STACK;
|
||||
to.varData.theStack = new stackHandler;
|
||||
if (! checkNew(to.varData.theStack)) return false;
|
||||
if (!checkNew(to.varData.theStack))
|
||||
return false;
|
||||
to.varData.theStack->first = NULL;
|
||||
to.varData.theStack->last = NULL;
|
||||
to.varData.theStack->timesUsed = 1;
|
||||
|
@ -345,11 +353,14 @@ char *getTextFromAnyVar(const variable &from) {
|
|||
|
||||
for (int i = 0; i < from.varData.fastArray->size; i++) {
|
||||
builder2 = joinStrings(builder, " ");
|
||||
if (! builder2) return NULL;
|
||||
if (!builder2)
|
||||
return NULL;
|
||||
delete builder;
|
||||
grabText = getTextFromAnyVar(from.varData.fastArray -> fastVariables[i]);
|
||||
grabText = getTextFromAnyVar(
|
||||
from.varData.fastArray->fastVariables[i]);
|
||||
builder = joinStrings(builder2, grabText);
|
||||
if (! builder) return NULL;
|
||||
if (!builder)
|
||||
return NULL;
|
||||
delete grabText;
|
||||
grabText = NULL;
|
||||
delete builder2;
|
||||
|
@ -367,11 +378,13 @@ char *getTextFromAnyVar(const variable &from) {
|
|||
|
||||
while (stacky) {
|
||||
builder2 = joinStrings(builder, " ");
|
||||
if (! builder2) return NULL;
|
||||
if (!builder2)
|
||||
return NULL;
|
||||
delete builder;
|
||||
grabText = getTextFromAnyVar(stacky->thisVar);
|
||||
builder = joinStrings(builder2, grabText);
|
||||
if (! builder) return NULL;
|
||||
if (!builder)
|
||||
return NULL;
|
||||
delete grabText;
|
||||
grabText = NULL;
|
||||
delete builder2;
|
||||
|
@ -383,7 +396,8 @@ char *getTextFromAnyVar(const variable &from) {
|
|||
|
||||
case SVT_INT: {
|
||||
char *buff = new char[10];
|
||||
if (! checkNew(buff)) return NULL;
|
||||
if (!checkNew(buff))
|
||||
return NULL;
|
||||
sprintf(buff, "%i", from.varData.intValue);
|
||||
return buff;
|
||||
}
|
||||
|
@ -405,7 +419,8 @@ char *getTextFromAnyVar(const variable &from) {
|
|||
|
||||
case SVT_OBJTYPE: {
|
||||
objectType *thisType = findObjectType(from.varData.intValue);
|
||||
if (thisType) return copyString(thisType -> screenName);
|
||||
if (thisType)
|
||||
return copyString(thisType->screenName);
|
||||
}
|
||||
|
||||
default:
|
||||
|
@ -487,18 +502,23 @@ bool copyVariable(const variable &from, variable &to) {
|
|||
}
|
||||
|
||||
variable *fastArrayGetByIndex(fastArrayHandler *vS, unsigned int theIndex) {
|
||||
if (theIndex < 0 || theIndex >= vS -> size) return NULL;
|
||||
if (theIndex < 0 || theIndex >= vS->size)
|
||||
return NULL;
|
||||
return &vS->fastVariables[theIndex];
|
||||
}
|
||||
|
||||
bool makeFastArraySize(variable &to, int size) {
|
||||
if (size < 0) return fatal("Can't create a fast array with a negative number of elements!");
|
||||
if (size < 0)
|
||||
return fatal(
|
||||
"Can't create a fast array with a negative number of elements!");
|
||||
unlinkVar(to);
|
||||
to.varType = SVT_FASTARRAY;
|
||||
to.varData.fastArray = new fastArrayHandler;
|
||||
if (! checkNew(to.varData.fastArray)) return false;
|
||||
if (!checkNew(to.varData.fastArray))
|
||||
return false;
|
||||
to.varData.fastArray->fastVariables = new variable[size];
|
||||
if (! checkNew(to.varData.fastArray -> fastVariables)) return false;
|
||||
if (!checkNew(to.varData.fastArray->fastVariables))
|
||||
return false;
|
||||
for (int i = 0; i < size; i++) {
|
||||
initVarNew(to.varData.fastArray->fastVariables[i]);
|
||||
}
|
||||
|
@ -509,7 +529,8 @@ bool makeFastArraySize(variable &to, int size) {
|
|||
|
||||
bool makeFastArrayFromStack(variable &to, const stackHandler *stacky) {
|
||||
int size = stackSize(stacky);
|
||||
if (! makeFastArraySize(to, size)) return false;
|
||||
if (!makeFastArraySize(to, size))
|
||||
return false;
|
||||
|
||||
// Now let's fill up the new array
|
||||
|
||||
|
@ -533,18 +554,22 @@ bool moveVariable (variable & from, variable & to) {
|
|||
|
||||
bool addVarToStack(const variable &va, variableStack *&thisStack) {
|
||||
variableStack *newStack = new variableStack;
|
||||
if (! checkNew(newStack)) return false;
|
||||
if (!checkNew(newStack))
|
||||
return false;
|
||||
|
||||
if (! copyMain(va, newStack -> thisVar)) return false;
|
||||
if (!copyMain(va, newStack->thisVar))
|
||||
return false;
|
||||
newStack->next = thisStack;
|
||||
thisStack = newStack;
|
||||
debug(kSludgeDebugStackMachine, "Variable %s was added to stack", getTextFromAnyVar(va));
|
||||
debug(kSludgeDebugStackMachine, "Variable %s was added to stack",
|
||||
getTextFromAnyVar(va));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool addVarToStackQuick(variable &va, variableStack *&thisStack) {
|
||||
variableStack *newStack = new variableStack;
|
||||
if (! checkNew(newStack)) return false;
|
||||
if (!checkNew(newStack))
|
||||
return false;
|
||||
|
||||
// if (! copyMain (va, newStack -> thisVar)) return false;
|
||||
|
||||
|
@ -553,14 +578,17 @@ bool addVarToStackQuick(variable &va, variableStack *&thisStack) {
|
|||
|
||||
newStack->next = thisStack;
|
||||
thisStack = newStack;
|
||||
debug(kSludgeDebugStackMachine, "Variable %s was added to stack quick", getTextFromAnyVar(va));
|
||||
debug(kSludgeDebugStackMachine, "Variable %s was added to stack quick",
|
||||
getTextFromAnyVar(va));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool stackSetByIndex(variableStack *vS, unsigned int theIndex, const variable &va) {
|
||||
bool stackSetByIndex(variableStack *vS, unsigned int theIndex,
|
||||
const variable &va) {
|
||||
while (theIndex--) {
|
||||
vS = vS->next;
|
||||
if (! vS) return fatal("Index past end of stack.");
|
||||
if (!vS)
|
||||
return fatal("Index past end of stack.");
|
||||
}
|
||||
return copyVariable(va, vS->thisVar);
|
||||
}
|
||||
|
@ -575,7 +603,8 @@ variable *stackGetByIndex(variableStack *vS, unsigned int theIndex) {
|
|||
return &(vS->thisVar);
|
||||
}
|
||||
|
||||
int deleteVarFromStack(const variable &va, variableStack *&thisStack, bool allOfEm) {
|
||||
int deleteVarFromStack(const variable &va, variableStack *&thisStack,
|
||||
bool allOfEm) {
|
||||
variableStack * * huntVar = &thisStack;
|
||||
variableStack *killMe;
|
||||
int reply = 0;
|
||||
|
@ -586,7 +615,8 @@ int deleteVarFromStack(const variable &va, variableStack *&thisStack, bool allOf
|
|||
*huntVar = killMe->next;
|
||||
unlinkVar(killMe->thisVar);
|
||||
delete killMe;
|
||||
if (! allOfEm) return 1;
|
||||
if (!allOfEm)
|
||||
return 1;
|
||||
reply++;
|
||||
} else {
|
||||
huntVar = &((*huntVar)->next);
|
||||
|
@ -610,8 +640,12 @@ variableStack *stackFindLast(variableStack *hunt) {
|
|||
bool getValueType(int &toHere, variableType vT, const variable &v) {
|
||||
//if (! v) return false;
|
||||
if (v.varType != vT) {
|
||||
char *e1 = joinStrings("Can only perform specified operation on a value which is of type ", typeName[vT]);
|
||||
char *e2 = joinStrings("... value supplied was of type ", typeName[v.varType]);
|
||||
char *e1 =
|
||||
joinStrings(
|
||||
"Can only perform specified operation on a value which is of type ",
|
||||
typeName[vT]);
|
||||
char *e2 = joinStrings("... value supplied was of type ",
|
||||
typeName[v.varType]);
|
||||
fatal(e1, e2);
|
||||
|
||||
return false;
|
||||
|
@ -624,7 +658,8 @@ void trimStack(variableStack *&stack) {
|
|||
variableStack *killMe = stack;
|
||||
stack = stack->next;
|
||||
|
||||
debug(kSludgeDebugStackMachine, "Variable %s was removed from stack", getTextFromAnyVar(killMe -> thisVar));
|
||||
debug(kSludgeDebugStackMachine, "Variable %s was removed from stack",
|
||||
getTextFromAnyVar(killMe->thisVar));
|
||||
|
||||
// When calling this, we've ALWAYS checked that stack != NULL
|
||||
unlinkVar(killMe->thisVar);
|
||||
|
|
|
@ -27,10 +27,19 @@ namespace Sludge {
|
|||
struct variable;
|
||||
struct variableStack;
|
||||
|
||||
enum variableType {SVT_NULL, SVT_INT, SVT_FUNC, SVT_STRING,
|
||||
SVT_BUILT, SVT_FILE, SVT_STACK,
|
||||
SVT_OBJTYPE, SVT_ANIM, SVT_COSTUME,
|
||||
SVT_FASTARRAY, SVT_NUM_TYPES
|
||||
enum variableType {
|
||||
SVT_NULL,
|
||||
SVT_INT,
|
||||
SVT_FUNC,
|
||||
SVT_STRING,
|
||||
SVT_BUILT,
|
||||
SVT_FILE,
|
||||
SVT_STACK,
|
||||
SVT_OBJTYPE,
|
||||
SVT_ANIM,
|
||||
SVT_COSTUME,
|
||||
SVT_FASTARRAY,
|
||||
SVT_NUM_TYPES
|
||||
};
|
||||
|
||||
struct fastArrayHandler {
|
||||
|
@ -94,7 +103,8 @@ bool getValueType(int &toHere, variableType vT, const variable &v);
|
|||
bool addVarToStack(const variable &va, variableStack *&thisStack);
|
||||
bool addVarToStackQuick(variable &va, variableStack *&thisStack);
|
||||
void trimStack(variableStack *&stack);
|
||||
int deleteVarFromStack(const variable &va, variableStack *&thisStack, bool allOfEm = false);
|
||||
int deleteVarFromStack(const variable &va, variableStack *&thisStack,
|
||||
bool allOfEm = false);
|
||||
variableStack *stackFindLast(variableStack *hunt);
|
||||
bool copyStack(const variable &from, variable &to);
|
||||
int stackSize(const stackHandler *me);
|
||||
|
@ -106,7 +116,6 @@ bool makeFastArrayFromStack(variable &to, const stackHandler *stacky);
|
|||
bool makeFastArraySize(variable &to, int size);
|
||||
variable *fastArrayGetByIndex(fastArrayHandler *vS, unsigned int theIndex);
|
||||
|
||||
|
||||
#define DEBUG_STACKINESS 0
|
||||
|
||||
#if DEBUG_STACKINESS
|
||||
|
|
|
@ -64,7 +64,8 @@ extern HWND hMainWindow;
|
|||
|
||||
void initialiseMovieStuff() {
|
||||
char buffer[500];
|
||||
if (ExpandEnvironmentStrings("%temp%", buffer, 499) == 0) buffer[0] = NULL;
|
||||
if (ExpandEnvironmentStrings("%temp%", buffer, 499) == 0)
|
||||
buffer[0] = NULL;
|
||||
videoFile = joinStrings(buffer, "\\test.avi");
|
||||
// warning (videoFile);
|
||||
}
|
||||
|
@ -73,9 +74,11 @@ bool getStream(DWORD type, timStream &intoHere) {
|
|||
if (AVIFileGetStream(pAviFile, &intoHere.got, type, 0)) {
|
||||
intoHere.got = NULL;
|
||||
return true;
|
||||
} else if (AVIStreamInfo(intoHere.got, & intoHere.info, sizeof(AVISTREAMINFO))) {
|
||||
} else if (AVIStreamInfo(intoHere.got, &intoHere.info,
|
||||
sizeof(AVISTREAMINFO))) {
|
||||
return fatal("Can't get stream info");
|
||||
} else if (AVIStreamReadFormat(intoHere.got, AVIStreamStart(intoHere.got), NULL, & intoHere.chunkSize)) {
|
||||
} else if (AVIStreamReadFormat(intoHere.got, AVIStreamStart(intoHere.got),
|
||||
NULL, &intoHere.chunkSize)) {
|
||||
return fatal("Can't get stream chunk size");
|
||||
} else {
|
||||
// So far so good! Let's read a chunk of data (huh?)
|
||||
|
@ -84,7 +87,9 @@ bool getStream(DWORD type, timStream &intoHere) {
|
|||
|
||||
if (!intoHere.chunk) {
|
||||
return fatal("Out of memory");
|
||||
} else if (AVIStreamReadFormat(intoHere.got, AVIStreamStart(intoHere.got), intoHere.chunk, & intoHere.chunkSize)) {
|
||||
} else if (AVIStreamReadFormat(intoHere.got,
|
||||
AVIStreamStart(intoHere.got), intoHere.chunk,
|
||||
&intoHere.chunkSize)) {
|
||||
return fatal("Couldn't read stream format");
|
||||
}
|
||||
}
|
||||
|
@ -135,8 +140,10 @@ void handleAudio () {
|
|||
void finishVideo() {
|
||||
videoPlaying = false;
|
||||
AVIStreamGetFrameClose(pgf);
|
||||
if (audio.got) AVIStreamRelease(audio.got);
|
||||
if (video.got) AVIStreamRelease(video.got);
|
||||
if (audio.got)
|
||||
AVIStreamRelease(audio.got);
|
||||
if (video.got)
|
||||
AVIStreamRelease(video.got);
|
||||
killStream(audio);
|
||||
killStream(video);
|
||||
AVIFileRelease(pAviFile);
|
||||
|
@ -144,7 +151,8 @@ void finishVideo() {
|
|||
#ifdef _MSC_VER
|
||||
_unlink(videoFile);
|
||||
#else
|
||||
unlink(videoFile);
|
||||
unlink(videoFile)
|
||||
;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -154,7 +162,8 @@ bool extractSlice(int fileNum, char *toName) {
|
|||
unsigned char buff[COPYSIZE];
|
||||
|
||||
unsigned long fileLength = openFileFromNum(fileNum);
|
||||
if (! fileLength) return false; // Error already displayed
|
||||
if (!fileLength)
|
||||
return false; // Error already displayed
|
||||
#if 0
|
||||
FILE *copyVid = fopen(toName, "wb");
|
||||
if (! copyVid) return fatal("Can't extract resource");
|
||||
|
@ -182,24 +191,30 @@ bool startVideo(int fileNum) {
|
|||
|
||||
AVIFILEINFO info;
|
||||
|
||||
if (videoPlaying) finishVideo();
|
||||
if (videoPlaying)
|
||||
finishVideo();
|
||||
AVIFileInit();
|
||||
|
||||
if (! extractSlice(fileNum, videoFile)) return false;
|
||||
if (!extractSlice(fileNum, videoFile))
|
||||
return false;
|
||||
if (AVIFileOpen(&pAviFile, videoFile, OF_READ, NULL))
|
||||
return fatal(ERROR_AVI_FILE_ERROR);
|
||||
|
||||
AVIFileInfo(pAviFile, &info, sizeof(info));
|
||||
|
||||
if (! getStream(streamtypeAUDIO, audio)) return false;
|
||||
if (! getStream(streamtypeVIDEO, video)) return false;
|
||||
if (!getStream(streamtypeAUDIO, audio))
|
||||
return false;
|
||||
if (!getStream(streamtypeVIDEO, video))
|
||||
return false;
|
||||
|
||||
if (! video.got) return fatal(ERROR_AVI_NO_STREAM);
|
||||
if (!video.got)
|
||||
return fatal(ERROR_AVI_NO_STREAM);
|
||||
|
||||
// if (audio.got) handleAudio ();
|
||||
|
||||
pgf = AVIStreamGetFrameOpen(video.got, NULL);
|
||||
if (!pgf) return fatal(ERROR_AVI_ARGH);
|
||||
if (!pgf)
|
||||
return fatal(ERROR_AVI_ARGH);
|
||||
|
||||
LPBITMAPINFO pInfo = (LPBITMAPINFO)(video.chunk);
|
||||
vidBytesPerPixel = pInfo->bmiHeader.biBitCount / 8;
|
||||
|
@ -216,7 +231,8 @@ bool startVideo(int fileNum) {
|
|||
}
|
||||
|
||||
bool nextVideoFrame() {
|
||||
LPBITMAPINFOHEADER lpbi = (LPBITMAPINFOHEADER) AVIStreamGetFrame(pgf, videoFrameNum);
|
||||
LPBITMAPINFOHEADER lpbi = (LPBITMAPINFOHEADER) AVIStreamGetFrame(pgf,
|
||||
videoFrameNum);
|
||||
if (!lpbi) {
|
||||
finishVideo();
|
||||
return false;
|
||||
|
@ -244,8 +260,7 @@ bool nextVideoFrame() {
|
|||
|
||||
default: {
|
||||
WORD Pixel16 = *((WORD *) pData);
|
||||
(* toHere) = makeColour(
|
||||
(((UINT)(Pixel16) >> 10) & 0x1F) << 3,
|
||||
(*toHere) = makeColour((((UINT)(Pixel16) >> 10) & 0x1F) << 3,
|
||||
(((UINT)(Pixel16) >> 5) & 0x1F) << 3,
|
||||
(((UINT)(Pixel16) >> 0) & 0x1F) << 3);
|
||||
}
|
||||
|
|
|
@ -76,7 +76,6 @@ char *ConvertFromUTF16(const WCHAR *input) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
char *grabFileName() {
|
||||
OPENFILENAME ofn;
|
||||
WCHAR path[MAX_PATH];
|
||||
|
|
|
@ -51,7 +51,8 @@ void sortZPal(int *oldpal, int *newpal, int size) {
|
|||
newpal[i] = i;
|
||||
}
|
||||
|
||||
if (size < 2) return;
|
||||
if (size < 2)
|
||||
return;
|
||||
|
||||
for (i = 1; i < size; i++) {
|
||||
if (oldpal[newpal[i]] < oldpal[newpal[i - 1]]) {
|
||||
|
|
|
@ -44,7 +44,6 @@ struct zBufferData {
|
|||
#endif
|
||||
};
|
||||
|
||||
|
||||
bool setZBuffer(int y);
|
||||
void killZBuffer();
|
||||
void drawZBuffer(int x, int y, bool upsidedown);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue