aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryinsimei2017-05-30 09:59:56 +0200
committerEugene Sandulenko2017-07-13 18:27:45 +0200
commit8c59f8deac6da7fd3b46234b70ca1cea428ca1f5 (patch)
tree5ceb323ae2ac20c28120084726330b17bbd2861c
parentb920f61a111b2dddac41b44a318c9078dea833ff (diff)
downloadscummvm-rg350-8c59f8deac6da7fd3b46234b70ca1cea428ca1f5.tar.gz
scummvm-rg350-8c59f8deac6da7fd3b46234b70ca1cea428ca1f5.tar.bz2
scummvm-rg350-8c59f8deac6da7fd3b46234b70ca1cea428ca1f5.zip
SLUDGE: Replace sludge stream reading functions by scummvm ones
-rw-r--r--engines/sludge/backdrop.cpp56
-rw-r--r--engines/sludge/bg_effects.cpp24
-rw-r--r--engines/sludge/fileset.cpp26
-rw-r--r--engines/sludge/floor.cpp12
-rw-r--r--engines/sludge/language.cpp4
-rw-r--r--engines/sludge/loadsave.cpp102
-rw-r--r--engines/sludge/moreio.cpp64
-rw-r--r--engines/sludge/moreio.h6
-rw-r--r--engines/sludge/objtypes.cpp30
-rw-r--r--engines/sludge/people.cpp130
-rw-r--r--engines/sludge/region.cpp32
-rw-r--r--engines/sludge/savedata.cpp22
-rw-r--r--engines/sludge/sludger.cpp99
-rw-r--r--engines/sludge/sound_bass.cpp22
-rw-r--r--engines/sludge/sound_nosound.cpp16
-rw-r--r--engines/sludge/sound_openal.cpp22
-rw-r--r--engines/sludge/sprites.cpp8
-rw-r--r--engines/sludge/statusba.cpp43
-rw-r--r--engines/sludge/talk.cpp40
-rw-r--r--engines/sludge/thumbnail.cpp16
-rw-r--r--engines/sludge/zbuffer.cpp8
21 files changed, 363 insertions, 419 deletions
diff --git a/engines/sludge/backdrop.cpp b/engines/sludge/backdrop.cpp
index da71289464..07f4d35618 100644
--- a/engines/sludge/backdrop.cpp
+++ b/engines/sludge/backdrop.cpp
@@ -107,10 +107,10 @@ void nosnapshot() {
void saveSnapshot(Common::WriteStream *stream) {
#if 0
if (snapshotTextureName) {
- putch(1, stream); // 1 for snapshot follows
+ stream->writeByte(1); // 1 for snapshot follows
saveCoreHSI(stream, snapshotTextureName, winWidth, winHeight);
} else {
- putch(0, stream);
+ stream->writeByte(0);
}
#endif
}
@@ -167,8 +167,8 @@ bool snapshot() {
}
bool restoreSnapshot(Common::SeekableReadStream *stream) {
- unsigned int picWidth = get2bytes(stream);
- unsigned int picHeight = get2bytes(stream);
+ unsigned int picWidth = stream->readUint16BE();
+ unsigned int picHeight = stream->readUint16BE();
if ((picWidth != winWidth) || (picHeight != winHeight))
return false;
@@ -190,9 +190,9 @@ bool restoreSnapshot(Common::SeekableReadStream *stream) {
for (t2 = 0; t2 < winHeight; t2++) {
t1 = 0;
while (t1 < winWidth) {
- c = (unsigned short) get2bytes(stream);
+ c = (unsigned short)stream->readUint16BE();
if (c & 32) {
- n = getch(stream) + 1;
+ n = stream->readByte() + 1;
c -= 32;
} else {
n = 1;
@@ -653,8 +653,8 @@ bool loadLightMap(int v) {
fileIsPNG = false;
fseek(bigDataFile, file_pointer, SEEK_SET);
- newPicWidth = lightMap.w = get2bytes(bigDataFile);
- newPicHeight = lightMap.h = get2bytes(bigDataFile);
+ newPicWidth = lightMap.w = bigDataFile->readUint16BE();
+ newPicHeight = lightMap.h = bigDataFile->readUint16BE();
} else {
// Read the PNG header
@@ -745,7 +745,7 @@ bool loadLightMap(int v) {
for (t2 = 0; t2 < lightMap.h; t2 ++) {
t1 = 0;
while (t1 < lightMap.w) {
- c = (unsigned short) get2bytes(bigDataFile);
+ c = (unsigned short)bigDataFile->readUint16BE();
if (c & 32) {
n = fgetc(bigDataFile) + 1;
c -= 32;
@@ -859,8 +859,8 @@ bool loadParallax(unsigned short v, unsigned short fracX,
fileIsPNG = false;
fseek(bigDataFile, file_pointer, SEEK_SET);
- picWidth = nP->width = get2bytes(bigDataFile);
- picHeight = nP->height = get2bytes(bigDataFile);
+ picWidth = nP->width = bigDataFile->readUint16BE();
+ picHeight = nP->height = bigDataFile->readUint16BE();
} else {
// Read the PNG header
@@ -955,7 +955,7 @@ bool loadParallax(unsigned short v, unsigned short fracX,
for (t2 = 0; t2 < nP->height; t2 ++) {
t1 = 0;
while (t1 < nP->width) {
- c = (unsigned short) get2bytes(bigDataFile);
+ c = (unsigned short)bigDataFile->readUint16BE();
if (c & 32) {
n = fgetc(bigDataFile) + 1;
c -= 32;
@@ -1111,8 +1111,8 @@ bool loadByteArray(int &picWidth, int &picHeight, int &realPicWidth, int &realPi
int32_t transCol = reserve ? -1 : 63519;
int t1, t2, n;
unsigned short c;
- picWidth = realPicWidth = get2bytes(stream);
- picHeight = realPicHeight = get2bytes(stream);
+ picWidth = realPicWidth = stream->readUint16BE();
+ picHeight = realPicHeight = stream->readUint16BE();
if (reserve) {
if (!resizeBackdrop(realPicWidth, realPicHeight)) return false;
@@ -1121,9 +1121,9 @@ bool loadByteArray(int &picWidth, int &picHeight, int &realPicWidth, int &realPi
for (t2 = 0; t2 < realPicHeight; t2 ++) {
t1 = 0;
while (t1 < realPicWidth) {
- c = (unsigned short) get2bytes(stream);
+ c = (unsigned short)stream->readUint16BE();
if (c & 32) {
- n = getch(stream) + 1;
+ n = stream->readByte() + 1;
c -= 32;
} else {
n = 1;
@@ -1337,8 +1337,8 @@ bool mixHSI(Common::SeekableReadStream *stream, int x, int y) {
fileIsPNG = false;
stream->seek(file_pointer, SEEK_SET);
- picWidth = realPicWidth = get2bytes(stream);
- picHeight = realPicHeight = get2bytes(stream);
+ picWidth = realPicWidth = stream->readUint16BE();
+ picHeight = realPicHeight = stream->readUint16BE();
} else {
// Read the PNG header
@@ -1446,9 +1446,9 @@ bool mixHSI(Common::SeekableReadStream *stream, int x, int y) {
for (t2 = 0; t2 < realPicHeight; t2 ++) {
t1 = 0;
while (t1 < realPicWidth) {
- c = (unsigned short) get2bytes(stream);
+ c = (unsigned short)stream->readUint16BE();
if (c & 32) {
- n = getch(stream) + 1;
+ n = stream->readByte() + 1;
c -= 32;
} else {
n = 1;
@@ -1701,8 +1701,8 @@ void saveCoreHSI(Common::WriteStream *stream, GLuint texture, int w, int h) {
int x, y, lookAhead;
unsigned short int *fromHere, * lookPointer;
- put2bytes(w, stream);
- put2bytes(h, stream);
+ stream->writeUint16BE(w);
+ stream->writeUint16BE(h);
for (y = 0; y < h; y ++) {
fromHere = image + (y * tw);
@@ -1717,8 +1717,8 @@ void saveCoreHSI(Common::WriteStream *stream, GLuint texture, int w, int h) {
if (lookAhead == x + 1) {
put2bytes((* fromHere) & 65503, stream);
} else {
- put2bytes(* fromHere | 32, stream);
- putch(lookAhead - x - 1, stream);
+ stream->writeUint16BE(* fromHere | 32);
+ stream->writeByte(lookAhead - x - 1);
}
fromHere = lookPointer;
x = lookAhead;
@@ -1738,10 +1738,10 @@ void saveHSI(Common::WriteStream *stream) {
void saveParallaxRecursive(parallaxLayer *me, Common::WriteStream *stream) {
if (me) {
saveParallaxRecursive(me->next, stream);
- putch(1, stream);
- put2bytes(me->fileNum, stream);
- put2bytes(me->fractionX, stream);
- put2bytes(me->fractionY, stream);
+ stream->writeByte(1);
+ stream->writeUint16BE(me->fileNum);
+ stream->writeUint16BE(me->fractionX);
+ stream->writeUint16BE(me->fractionY);
}
}
diff --git a/engines/sludge/bg_effects.cpp b/engines/sludge/bg_effects.cpp
index 8a615514fa..9c8bcb304b 100644
--- a/engines/sludge/bg_effects.cpp
+++ b/engines/sludge/bg_effects.cpp
@@ -118,16 +118,16 @@ static int s_matrixEffectBase = 0;
void blur_saveSettings(Common::WriteStream *stream) {
if (s_matrixEffectData) {
- put4bytes(s_matrixEffectDivide, stream);
- put4bytes(s_matrixEffectWidth, stream);
- put4bytes(s_matrixEffectHeight, stream);
- put4bytes(s_matrixEffectBase, stream);
+ stream->writeUint32LE(s_matrixEffectDivide);
+ stream->writeUint32LE(s_matrixEffectWidth);
+ stream->writeUint32LE(s_matrixEffectHeight);
+ stream->writeUint32LE(s_matrixEffectBase);
stream->write(s_matrixEffectData, sizeof(int) * s_matrixEffectWidth * s_matrixEffectHeight);
} else {
- put4bytes(0, stream);
- put4bytes(0, stream);
- put4bytes(0, stream);
- put4bytes(0, stream);
+ stream->writeUint32LE(0);
+ stream->writeUint32LE(0);
+ stream->writeUint32LE(0);
+ stream->writeUint32LE(0);
}
}
@@ -143,10 +143,10 @@ static int *blur_allocateMemoryForEffect() {
}
void blur_loadSettings(Common::SeekableReadStream *stream) {
- s_matrixEffectDivide = get4bytes(stream);
- s_matrixEffectWidth = get4bytes(stream);
- s_matrixEffectHeight = get4bytes(stream);
- s_matrixEffectBase = get4bytes(stream);
+ s_matrixEffectDivide = stream->readUint32LE();
+ s_matrixEffectWidth = stream->readUint32LE();
+ s_matrixEffectHeight = stream->readUint32LE();
+ s_matrixEffectBase = stream->readUint32LE();
if (blur_allocateMemoryForEffect()) {
size_t bytes_read = stream->read(s_matrixEffectData, sizeof(int) * s_matrixEffectWidth * s_matrixEffectHeight);
diff --git a/engines/sludge/fileset.cpp b/engines/sludge/fileset.cpp
index eb39166019..d6ecdef2bb 100644
--- a/engines/sludge/fileset.cpp
+++ b/engines/sludge/fileset.cpp
@@ -35,6 +35,8 @@
#include "CommonCode/version.h"
#include "common/file.h"
+#include "common/debug.h"
+#include "sludge.h"
namespace Sludge {
@@ -56,7 +58,7 @@ bool openSubSlice(int num) {
}
// fprintf (dbug, "Going to position %li\n", startOfSubIndex + (num << 2));
bigDataFile->seek(startOfSubIndex + (num << 2), 0);
- bigDataFile->seek(get4bytes(bigDataFile), 0);
+ bigDataFile->seek(bigDataFile->readUint32LE(), 0);
// fprintf (dbug, "Told to skip forward to %li\n", ftell (bigDataFile));
// fclose (dbug);
@@ -75,7 +77,7 @@ bool openObjectSlice(int num) {
// fprintf (dbug, "Going to position %li\n", startOfObjectIndex + (num << 2));
bigDataFile->seek(startOfObjectIndex + (num << 2), 0);
- bigDataFile->seek(get4bytes(bigDataFile), 0);
+ bigDataFile->seek(bigDataFile->readUint32LE(), 0);
// fprintf (dbug, "Told to skip forward to %li\n", ftell (bigDataFile));
// fclose (dbug);
return sliceBusy = true;
@@ -92,12 +94,12 @@ unsigned int openFileFromNum(int num) {
// fprintf (dbug, "\nTrying to open file %i\n", num);
// fprintf (dbug, "Jumping to %li (for index) \n", startOfDataIndex + (num << 2));
bigDataFile->seek(startOfDataIndex + (num << 2), 0);
- bigDataFile->seek(get4bytes(bigDataFile), 1);
+ bigDataFile->seek(bigDataFile->readUint32LE(), 1);
// fprintf (dbug, "Jumping to %li (for data) \n", ftell (bigDataFile));
sliceBusy = true;
// fclose (dbug);
- return get4bytes(bigDataFile);
+ return bigDataFile->readUint32LE();
}
// Converts a string from Windows CP-1252 to UTF-8.
@@ -173,7 +175,7 @@ char *getNumberedString(int value) {
}
bigDataFile->seek((value << 2) + startOfTextIndex, 0);
- value = get4bytes(bigDataFile);
+ value = bigDataFile->readUint32LE();
bigDataFile->seek(value, 0);
char *s = readString(bigDataFile);
@@ -218,26 +220,30 @@ void setFileIndices(Common::File *fp, int numLanguages,
// STRINGS
int skipAfter = numLanguages - skipBefore;
while (skipBefore) {
- fp->seek(get4bytes(fp), SEEK_SET);
+ fp->seek(fp->readUint32LE(), SEEK_SET);
skipBefore--;
}
startOfTextIndex = fp->pos() + 4;
+ debug(kSludgeDebugDataLoad, "startOfTextIndex: %i", startOfTextIndex);
- fp->seek(get4bytes(fp), SEEK_SET);
+ fp->seek(fp->readUint32LE(), SEEK_SET);
while (skipAfter) {
- fp->seek(get4bytes(fp), SEEK_SET);
+ fp->seek(fp->readUint32LE(), SEEK_SET);
skipAfter--;
}
startOfSubIndex = fp->pos() + 4;
- fp->seek(get4bytes(fp), SEEK_CUR);
+ fp->seek(fp->readUint32LE(), SEEK_CUR);
+ debug(kSludgeDebugDataLoad, "startOfSubIndex: %i", startOfTextIndex);
startOfObjectIndex = fp->pos() + 4;
- fp->seek(get4bytes(fp), SEEK_CUR);
+ fp->seek(fp->readUint32LE(), SEEK_CUR);
+ debug(kSludgeDebugDataLoad, "startOfObjectIndex: %i", startOfTextIndex);
// Remember that the data section starts here
startOfDataIndex = fp->pos();
+ debug(kSludgeDebugDataLoad, "startOfDataIndex: %i", startOfTextIndex);
}
} // End of namespace Sludge
diff --git a/engines/sludge/floor.cpp b/engines/sludge/floor.cpp
index ec5738728f..cfb64d5b4a 100644
--- a/engines/sludge/floor.cpp
+++ b/engines/sludge/floor.cpp
@@ -135,7 +135,7 @@ bool setFloor(int fileNum) {
// Find out how many polygons there are and reserve memory
currentFloor->originalNum = fileNum;
- currentFloor->numPolygons = getch(bigDataFile);
+ currentFloor->numPolygons = bigDataFile->readByte();
currentFloor->polygon = new floorPolygon[currentFloor->numPolygons];
if (!checkNew(currentFloor->polygon))
return false;
@@ -146,7 +146,7 @@ bool setFloor(int fileNum) {
// Find out how many vertex IDs there are and reserve memory
- currentFloor->polygon[i].numVertices = getch(bigDataFile);
+ currentFloor->polygon[i].numVertices = bigDataFile->readByte();
currentFloor->polygon[i].vertexID =
new int[currentFloor->polygon[i].numVertices];
if (!checkNew(currentFloor->polygon[i].vertexID))
@@ -155,21 +155,21 @@ bool setFloor(int fileNum) {
// Read in each vertex ID
for (j = 0; j < currentFloor->polygon[i].numVertices; j++) {
- currentFloor->polygon[i].vertexID[j] = get2bytes(bigDataFile);
+ currentFloor->polygon[i].vertexID[j] = bigDataFile->readUint16BE();
}
}
// Find out how many vertices there are and reserve memory
- i = get2bytes(bigDataFile);
+ i = bigDataFile->readUint16BE();
currentFloor->vertex = new POINT[i];
if (!checkNew(currentFloor->vertex))
return false;
for (j = 0; j < i; j++) {
- currentFloor->vertex[j].x = get2bytes(bigDataFile);
- currentFloor->vertex[j].y = get2bytes(bigDataFile);
+ currentFloor->vertex[j].x = bigDataFile->readUint16BE();
+ currentFloor->vertex[j].y = bigDataFile->readUint16BE();
}
finishAccess();
diff --git a/engines/sludge/language.cpp b/engines/sludge/language.cpp
index 6bbb6d3882..b6a7ab62d2 100644
--- a/engines/sludge/language.cpp
+++ b/engines/sludge/language.cpp
@@ -115,7 +115,7 @@ void readIniFile(char *filename) {
bool doingSecond = false;
do {
- readChar = getch(&fd);
+ readChar = fd.readByte();
if (fd.eos()) {
readChar = '\n';
keepGoing = false;
@@ -193,7 +193,7 @@ void makeLanguageTable(Common::File *table) {
return;
for (unsigned int i = 0; i <= gameSettings.numLanguages; i++) {
- languageTable[i] = i ? get2bytes(table) : 0;
+ languageTable[i] = i ? table->readUint16BE() : 0;
debug(kSludgeDebugDataLoad, "languageTable %i: %i", i,
languageTable[i]);
languageName[i] = 0;
diff --git a/engines/sludge/loadsave.cpp b/engines/sludge/loadsave.cpp
index 125e3183b6..f3eb93f1bb 100644
--- a/engines/sludge/loadsave.cpp
+++ b/engines/sludge/loadsave.cpp
@@ -105,7 +105,7 @@ void saveStack(variableStack *vs, Common::WriteStream *stream) {
stackDebug((stackfp, " stack contains %d elements\n", elements));
- put2bytes(elements, stream);
+ stream->writeUint16BE(elements);
search = vs;
for (a = 0; a < elements; ++a) {
saveVariable(&search->thisVar, stream);
@@ -115,7 +115,7 @@ void saveStack(variableStack *vs, Common::WriteStream *stream) {
variableStack *loadStack(Common::SeekableReadStream *stream,
variableStack **last) {
- int elements = get2bytes(stream);
+ int elements = stream->readUint16BE();
int a;
variableStack *first = NULL;
variableStack * * changeMe = &first;
@@ -142,14 +142,14 @@ bool saveStackRef(stackHandler *vs, Common::WriteStream *stream) {
int a = 0;
while (s) {
if (s->stack == vs) {
- putch(1, stream);
- put2bytes(stackLibTotal - a, stream);
+ stream->writeByte(1);
+ stream->writeUint16BE(stackLibTotal - a);
return true;
}
s = s->next;
++a;
}
- putch(0, stream);
+ stream->writeByte(0);
saveStack(vs->first, stream);
s = new stackLibrary;
stackLibTotal++;
@@ -183,10 +183,10 @@ stackHandler *getStackFromLibrary(int n) {
stackHandler *loadStackRef(Common::SeekableReadStream *stream) {
stackHandler *nsh;
- if (getch(stream)) { // It's one we've loaded already...
+ if (stream->readByte()) { // It's one we've loaded already...
stackDebug((stackfp, "loadStackRef (duplicate, get from library)\n"));
- nsh = getStackFromLibrary(get2bytes(stream));
+ nsh = getStackFromLibrary(stream->readUint16BE());
nsh->timesUsed++;
} else {
stackDebug((stackfp, "loadStackRef (new one)\n"));
@@ -231,14 +231,14 @@ bool saveVariable(variable *from, Common::WriteStream *stream) {
}
#endif
- putch(from->varType, stream);
+ stream->writeByte(from->varType);
switch (from->varType) {
case SVT_INT:
case SVT_FUNC:
case SVT_BUILT:
case SVT_FILE:
case SVT_OBJTYPE:
- put4bytes(from->varData.intValue, stream);
+ stream->writeUint32LE(from->varData.intValue);
return true;
case SVT_STRING:
@@ -268,14 +268,14 @@ bool saveVariable(variable *from, Common::WriteStream *stream) {
}
bool loadVariable(variable *to, Common::SeekableReadStream *stream) {
- to->varType = (variableType) getch(stream);
+ to->varType = (variableType)stream->readByte();
switch (to->varType) {
case SVT_INT:
case SVT_FUNC:
case SVT_BUILT:
case SVT_FILE:
case SVT_OBJTYPE:
- to->varData.intValue = get4bytes(stream);
+ to->varData.intValue = stream->readUint32LE();
return true;
case SVT_STRING:
@@ -318,18 +318,18 @@ bool loadVariable(variable *to, Common::SeekableReadStream *stream) {
//----------------------------------------------------------------------
void saveFunction(loadedFunction *fun, Common::WriteStream *stream) {
int a;
- put2bytes(fun->originalNumber, stream);
+ stream->writeUint16BE(fun->originalNumber);
if (fun->calledBy) {
- putch(1, stream);
+ stream->writeByte(1);
saveFunction(fun->calledBy, stream);
} else {
- putch(0, stream);
+ stream->writeByte(0);
}
- put4bytes(fun->timeLeft, stream);
- put2bytes(fun->runThisLine, stream);
- putch(fun->cancelMe, stream);
- putch(fun->returnSomething, stream);
- putch(fun->isSpeech, stream);
+ stream->writeUint32LE(fun->timeLeft);
+ stream->writeUint16BE(fun->runThisLine);
+ stream->writeByte(fun->cancelMe);
+ stream->writeByte(fun->returnSomething);
+ stream->writeByte(fun->isSpeech);
saveVariable(&(fun->reg), stream);
if (fun->freezerLevel) {
@@ -352,20 +352,20 @@ loadedFunction *loadFunction(Common::SeekableReadStream *stream) {
// See what it was called by and load if we need to...
- buildFunc->originalNumber = get2bytes(stream);
+ buildFunc->originalNumber = stream->readUint16BE();
buildFunc->calledBy = NULL;
- if (getch(stream)) {
+ if (stream->readByte()) {
buildFunc->calledBy = loadFunction(stream);
if (!buildFunc->calledBy)
return NULL;
}
- buildFunc->timeLeft = get4bytes(stream);
- buildFunc->runThisLine = get2bytes(stream);
+ buildFunc->timeLeft = stream->readUint32LE();
+ buildFunc->runThisLine = stream->readUint16BE();
buildFunc->freezerLevel = 0;
- buildFunc->cancelMe = getch(stream);
- buildFunc->returnSomething = getch(stream);
- buildFunc->isSpeech = getch(stream);
+ buildFunc->cancelMe = stream->readByte();
+ buildFunc->returnSomething = stream->readByte();
+ buildFunc->isSpeech = stream->readByte();
loadVariable(&(buildFunc->reg), stream);
loadFunctionCode(buildFunc);
@@ -407,15 +407,15 @@ bool saveGame(char *fname) {
fputc(fontTableSize > 0, fp);
if (fontTableSize > 0) {
- put2bytes(loadedFontNum, fp);
- put2bytes(fontHeight, fp);
+ fp->writeUint16BE(loadedFontNum);
+ fp->writeUint16BE(fontHeight);
writeString(fontOrderString, fp);
}
putSigned(fontSpace, fp);
// Save backdrop
- put2bytes(cameraX, fp);
- put2bytes(cameraY, fp);
+ fp->writeUint16BE(cameraX);
+ fp->writeUint16BE(cameraY);
putFloat(cameraZoom, fp);
fputc(brightnessLevel, fp);
@@ -428,7 +428,7 @@ bool saveGame(char *fname) {
saveRegions(fp);
saveAnim(mouseCursorAnim, fp);
- put2bytes(mouseCursorFrameNum, fp);
+ fp->writeUint16BE(mouseCursorFrameNum);
// Save functions
loadedFunction *thisFunction = allRunningFunctions;
@@ -437,7 +437,7 @@ bool saveGame(char *fname) {
countFunctions ++;
thisFunction = thisFunction->next;
}
- put2bytes(countFunctions, fp);
+ fp->writeUint16BE(countFunctions);
thisFunction = allRunningFunctions;
while (thisFunction) {
@@ -453,17 +453,17 @@ bool saveGame(char *fname) {
if (currentFloor->numPolygons) {
fputc(1, fp);
- put2bytes(currentFloor->originalNum, fp);
+ fp->writeUint16BE(currentFloor->originalNum);
} else fputc(0, fp);
if (zBuffer.tex) {
fputc(1, fp);
- put2bytes(zBuffer.originalNum, fp);
+ fp->writeUint16BE(zBuffer.originalNum);
} else fputc(0, fp);
if (lightMap.data) {
fputc(1, fp);
- put2bytes(lightMapNumber, fp);
+ fp->writeUint16BE(lightMapNumber);
} else fputc(0, fp);
fputc(lightMapMode, fp);
@@ -473,11 +473,11 @@ bool saveGame(char *fname) {
saveStatusBars(fp);
saveSounds(fp);
- put2bytes(saveEncoding, fp);
+ fp->writeUint16BE(saveEncoding);
blur_saveSettings(fp);
- put2bytes(currentBlankColour, fp);
+ fp->writeUint16BE(currentBlankColour);
fputc(currentBurnR, fp);
fputc(currentBurnG, fp);
fputc(currentBurnB, fp);
@@ -538,8 +538,8 @@ bool loadGame(char *fname) {
int fontNum;
char *charOrder;
if (fontLoaded) {
- fontNum = get2bytes(fp);
- fontHeight = get2bytes(fp);
+ fontNum = fp->readUint16BE();
+ fontHeight = fp->readUint16BE();
if (ssgVersion < VERSION(2, 2)) {
int x;
@@ -563,8 +563,8 @@ bool loadGame(char *fname) {
killAllPeople();
killAllRegions();
- int camerX = get2bytes(fp);
- int camerY = get2bytes(fp);
+ int camerX = fp->readUint16BE();
+ int camerY = fp->readUint16BE();
float camerZ;
if (ssgVersion >= VERSION(2, 0)) {
camerZ = getFloat(fp);
@@ -581,12 +581,12 @@ bool loadGame(char *fname) {
mouseCursorAnim = new personaAnimation;
if (! checkNew(mouseCursorAnim)) return false;
if (! loadAnim(mouseCursorAnim, fp)) return false;
- mouseCursorFrameNum = get2bytes(fp);
+ mouseCursorFrameNum = fp->readUint16BE();
loadedFunction *rFunc;
loadedFunction * * buildList = &allRunningFunctions;
- int countFunctions = get2bytes(fp);
+ int countFunctions = fp->readUint16BE();
while (countFunctions --) {
rFunc = loadFunction(fp);
rFunc->next = NULL;
@@ -602,15 +602,15 @@ bool loadGame(char *fname) {
loadPeople(fp);
if (fgetc(fp)) {
- if (! setFloor(get2bytes(fp))) return false;
+ if (! setFloor(fp->readUint16BE())) return false;
} else setFloorNull();
if (fgetc(fp)) {
- if (! setZBuffer(get2bytes(fp))) return false;
+ if (! setZBuffer(fp->readUint16BE())) return false;
}
if (fgetc(fp)) {
- if (! loadLightMap(get2bytes(fp))) return false;
+ if (! loadLightMap(fp->readUint16BE())) return false;
}
if (ssgVersion >= VERSION(1, 4)) {
@@ -623,7 +623,7 @@ bool loadGame(char *fname) {
loadStatusBars(fp);
loadSounds(fp);
- saveEncoding = get2bytes(fp);
+ saveEncoding = fp->readUint16BE();
if (ssgVersion >= VERSION(1, 6)) {
if (ssgVersion < VERSION(2, 0)) {
@@ -637,16 +637,16 @@ bool loadGame(char *fname) {
}
if (ssgVersion >= VERSION(1, 3)) {
- currentBlankColour = get2bytes(fp);
+ currentBlankColour = fp->readUint16BE();
currentBurnR = fgetc(fp);
currentBurnG = fgetc(fp);
currentBurnB = fgetc(fp);
// Read parallax layers
while (fgetc(fp)) {
- int im = get2bytes(fp);
- int fx = get2bytes(fp);
- int fy = get2bytes(fp);
+ int im = fp->readUint16BE();
+ int fx = fp->readUint16BE();
+ int fy = fp->readUint16BE();
if (! loadParallax(im, fx, fy)) return false;
}
diff --git a/engines/sludge/moreio.cpp b/engines/sludge/moreio.cpp
index 754f22c46a..ed3a7ecdc7 100644
--- a/engines/sludge/moreio.cpp
+++ b/engines/sludge/moreio.cpp
@@ -40,44 +40,22 @@ namespace Sludge {
bool allowAnyFilename = true;
-int getch(Common::SeekableReadStream *stream) {
- return stream->readByte();
-}
-
-void putch(int c, Common::WriteStream *stream) {
- stream->writeByte(c);
-}
-
-int get2bytes(Common::SeekableReadStream *stream) {
- int f1, f2;
-
- f1 = getch(stream);
- f2 = getch(stream);
-
- return (f1 * 256 + f2);
-}
-
-void put2bytes(int numtoput, Common::WriteStream *stream) {
- putch((char) (numtoput / 256), stream);
- putch((char) (numtoput % 256), stream);
-}
-
void writeString(char *s, Common::WriteStream *stream) {
int a, len = strlen(s);
- put2bytes(len, stream);
+ stream->writeUint16BE(len);
for (a = 0; a < len; ++a) {
- putch(s[a] + 1, stream);
+ stream->writeByte(s[a] + 1);
}
}
char *readString(Common::SeekableReadStream *stream) {
- int a, len = get2bytes(stream);
+ int a, len = stream->readUint16BE();
char *s = new char[len + 1];
if (!checkNew(s)) {
return NULL;
}
for (a = 0; a < len; ++a) {
- s[a] = (char) (getch(stream) - 1);
+ s[a] = (char)(stream->readByte() - 1);
}
s[len] = 0;
debug(kSludgeDebugDataLoad, "Read string of length %i: %s", len, s);
@@ -101,7 +79,6 @@ float floatSwap(float f) {
float getFloat(Common::SeekableReadStream *stream) {
float f;
size_t bytes_read = stream->read(&f, sizeof(float));
- //fread(& f, sizeof(float), 1, fp);
if (bytes_read != sizeof(float) && stream->err()) {
debug("Reading error in getFloat.\n");
}
@@ -118,7 +95,6 @@ void putFloat(float f, Common::WriteStream *stream) {
f = floatSwap(f);
#endif
stream->write(&f, sizeof(float));
- //fwrite(& f, sizeof(float), 1, fp);
}
short shortSwap(short s) {
@@ -149,38 +125,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.
-
-int32_t get4bytes(Common::SeekableReadStream *stream) {
- int f1, f2, f3, f4;
-
- f1 = getch(stream);
- f2 = getch(stream);
- f3 = getch(stream);
- f4 = getch(stream);
-
- unsigned int x = f1 + f2 * 256 + f3 * 256 * 256 + f4 * 256 * 256 * 256;
-
- return x;
-}
-
-void put4bytes(unsigned int i, Common::WriteStream *stream) {
- unsigned char f1, f2, f3, f4;
-
- f4 = i / (256 * 256 * 256);
- i = i % (256 * 256 * 256);
- f3 = i / (256 * 256);
- i = i % (256 * 256);
- f2 = i / 256;
- f1 = i % 256;
-
- putch(f1, stream);
- putch(f2, stream);
- putch(f3, stream);
- putch(f4, stream);
-}
-
char *encodeFilename(char *nameIn) {
if (!nameIn)
return NULL;
diff --git a/engines/sludge/moreio.h b/engines/sludge/moreio.h
index 9c2287b274..1e2f3146de 100644
--- a/engines/sludge/moreio.h
+++ b/engines/sludge/moreio.h
@@ -27,20 +27,14 @@
namespace Sludge {
// Read
-int getch(Common::SeekableReadStream *stream);
-int get2bytes(Common::SeekableReadStream *stream);
char *readString(Common::SeekableReadStream *stream);
float getFloat(Common::SeekableReadStream *stream);
short getSigned(Common::SeekableReadStream *stream);
-int32_t get4bytes(Common::SeekableReadStream *stream);
// Write
-void putch(int c, Common::WriteStream *stream);
-void put2bytes(int numtoput, Common::WriteStream *stream);
void writeString(char *s, Common::WriteStream *stream);
void putFloat(float f, Common::WriteStream *stream);
void putSigned(short f, Common::WriteStream *stream);
-void put4bytes(uint32_t f, Common::WriteStream *stream);
char *encodeFilename(char *nameIn);
char *decodeFilename(char *nameIn);
diff --git a/engines/sludge/objtypes.cpp b/engines/sludge/objtypes.cpp
index 5f82fb0281..3c79374e8c 100644
--- a/engines/sludge/objtypes.cpp
+++ b/engines/sludge/objtypes.cpp
@@ -56,29 +56,29 @@ objectType *loadObjectType(int i) {
if (checkNew(newType)) {
if (openObjectSlice(i)) {
- nameNum = get2bytes(bigDataFile);
- newType->r = (byte) getch(bigDataFile);
- newType->g = (byte) getch(bigDataFile);
- newType->b = (byte) getch(bigDataFile);
- newType->speechGap = getch(bigDataFile);
- newType->walkSpeed = getch(bigDataFile);
- newType->wrapSpeech = get4bytes(bigDataFile);
- newType->spinSpeed = get2bytes(bigDataFile);
+ nameNum = bigDataFile->readUint16BE();
+ newType->r = (byte)bigDataFile->readByte();
+ newType->g = (byte)bigDataFile->readByte();
+ newType->b = (byte)bigDataFile->readByte();
+ newType->speechGap = bigDataFile->readByte();
+ newType->walkSpeed = bigDataFile->readByte();
+ newType->wrapSpeech = bigDataFile->readUint32LE();
+ newType->spinSpeed = bigDataFile->readUint16BE();
if (gameVersion >= VERSION(1, 6)) {
// aaLoad
- getch(bigDataFile);
+ bigDataFile->readByte();
getFloat(bigDataFile);
getFloat(bigDataFile);
}
if (gameVersion >= VERSION(1, 4)) {
- newType->flags = get2bytes(bigDataFile);
+ newType->flags = bigDataFile->readUint16BE();
} else {
newType->flags = 0;
}
- newType->numCom = get2bytes(bigDataFile);
+ newType->numCom = bigDataFile->readUint16BE();
newType->allCombis =
(newType->numCom) ? new combination[newType->numCom] : NULL;
@@ -90,8 +90,8 @@ objectType *loadObjectType(int i) {
#endif
for (a = 0; a < newType->numCom; a++) {
- newType->allCombis[a].withObj = get2bytes(bigDataFile);
- newType->allCombis[a].funcNum = get2bytes(bigDataFile);
+ newType->allCombis[a].withObj = bigDataFile->readUint16BE();
+ newType->allCombis[a].funcNum = bigDataFile->readUint16BE();
#if DEBUG_COMBINATIONS
if (callEventLog) {
fprintf(callEventLog, "%d(%d) ", newType -> allCombis[a].withObj, newType -> allCombis[a].funcNum);
@@ -117,14 +117,14 @@ objectType *loadObjectType(int i) {
}
objectType *loadObjectRef(Common::SeekableReadStream *stream) {
- objectType *r = loadObjectType(get2bytes(stream));
+ objectType *r = loadObjectType(stream->readUint16BE());
delete r->screenName;
r->screenName = readString(stream);
return r;
}
void saveObjectRef(objectType *r, Common::WriteStream *stream) {
- put2bytes(r->objectNum, stream);
+ stream->writeUint16BE(r->objectNum);
writeString(r->screenName, stream);
}
diff --git a/engines/sludge/people.cpp b/engines/sludge/people.cpp
index 93f1d6c16a..9b19bbf847 100644
--- a/engines/sludge/people.cpp
+++ b/engines/sludge/people.cpp
@@ -1009,34 +1009,34 @@ void removeOneCharacter(int i) {
}
bool saveAnim(personaAnimation *p, Common::WriteStream *stream) {
- put2bytes(p->numFrames, stream);
+ stream->writeUint16BE(p->numFrames);
if (p->numFrames) {
- put4bytes(p->theSprites->ID, stream);
+ stream->writeUint32LE(p->theSprites->ID);
for (int a = 0; a < p->numFrames; ++a) {
- put4bytes(p->frames[a].frameNum, stream);
- put4bytes(p->frames[a].howMany, stream);
- put4bytes(p->frames[a].noise, stream);
+ stream->writeUint32LE(p->frames[a].frameNum);
+ stream->writeUint32LE(p->frames[a].howMany);
+ stream->writeUint32LE(p->frames[a].noise);
}
}
return true;
}
bool loadAnim(personaAnimation *p, Common::SeekableReadStream *stream) {
- p->numFrames = get2bytes(stream);
+ p->numFrames = stream->readUint16BE();
if (p->numFrames) {
- int a = get4bytes(stream);
+ int a = stream->readUint32LE();
p->frames = new animFrame[p->numFrames];
if (!checkNew(p->frames))
return false;
p->theSprites = loadBankForAnim(a);
for (a = 0; a < p->numFrames; ++a) {
- p->frames[a].frameNum = get4bytes(stream);
- p->frames[a].howMany = get4bytes(stream);
+ p->frames[a].frameNum = stream->readUint32LE();
+ p->frames[a].howMany = stream->readUint32LE();
if (ssgVersion >= VERSION(2, 0)) {
- p->frames[a].noise = get4bytes(stream);
+ p->frames[a].noise = stream->readUint32LE();
} else {
p->frames[a].noise = 0;
}
@@ -1064,7 +1064,7 @@ bool loadAnim(personaAnimation *p, Common::SeekableReadStream *stream) {
*/
bool saveCostume(persona *cossy, Common::WriteStream *stream) {
int a;
- put2bytes(cossy->numDirections, stream);
+ stream->writeUint16BE(cossy->numDirections);
for (a = 0; a < cossy->numDirections * 3; ++a) {
if (!saveAnim(cossy->animation[a], stream))
return false;
@@ -1075,7 +1075,7 @@ bool saveCostume(persona *cossy, Common::WriteStream *stream) {
bool loadCostume(persona *cossy, Common::SeekableReadStream *stream) {
int a;
- cossy->numDirections = get2bytes(stream);
+ cossy->numDirections = stream->readUint16BE();
cossy->animation = new personaAnimation *[cossy->numDirections * 3];
if (!checkNew(cossy->animation))
return false;
@@ -1103,7 +1103,7 @@ bool savePeople(Common::WriteStream *stream) {
me = me->next;
}
- put2bytes(countPeople, stream);
+ stream->writeUint16BE(countPeople);
me = allPeople;
for (a = 0; a < countPeople; ++a) {
@@ -1113,43 +1113,43 @@ bool savePeople(Common::WriteStream *stream) {
saveCostume(me->myPersona, stream);
saveAnim(me->myAnim, stream);
- putch(me->myAnim == me->lastUsedAnim, stream);
+ stream->writeByte(me->myAnim == me->lastUsedAnim);
putFloat(me->scale, stream);
- put2bytes(me->extra, stream);
- put2bytes(me->height, stream);
- put2bytes(me->walkToX, stream);
- put2bytes(me->walkToY, stream);
- put2bytes(me->thisStepX, stream);
- put2bytes(me->thisStepY, stream);
- put2bytes(me->frameNum, stream);
- put2bytes(me->frameTick, stream);
- put2bytes(me->walkSpeed, stream);
- put2bytes(me->spinSpeed, stream);
+ stream->writeUint16BE(me->extra);
+ stream->writeUint16BE(me->height);
+ stream->writeUint16BE(me->walkToX);
+ stream->writeUint16BE(me->walkToY);
+ stream->writeUint16BE(me->thisStepX);
+ stream->writeUint16BE(me->thisStepY);
+ stream->writeUint16BE(me->frameNum);
+ stream->writeUint16BE(me->frameTick);
+ stream->writeUint16BE(me->walkSpeed);
+ stream->writeUint16BE(me->spinSpeed);
putSigned(me->floaty, stream);
- putch(me->show, stream);
- putch(me->walking, stream);
- putch(me->spinning, stream);
+ stream->writeByte(me->show);
+ stream->writeByte(me->walking);
+ stream->writeByte(me->spinning);
if (me->continueAfterWalking) {
- putch(1, stream);
+ stream->writeByte(1);
saveFunction(me->continueAfterWalking, stream);
} else {
- putch(0, stream);
+ stream->writeByte(0);
}
- put2bytes(me->direction, stream);
- put2bytes(me->angle, stream);
- put2bytes(me->angleOffset, stream);
- put2bytes(me->wantAngle, stream);
+ stream->writeUint16BE(me->direction);
+ stream->writeUint16BE(me->angle);
+ stream->writeUint16BE(me->angleOffset);
+ stream->writeUint16BE(me->wantAngle);
putSigned(me->directionWhenDoneWalking, stream);
putSigned(me->inPoly, stream);
putSigned(me->walkToPoly, stream);
- putch(me->r, stream);
- putch(me->g, stream);
- putch(me->b, stream);
- putch(me->colourmix, stream);
- putch(me->transparency, stream);
+ stream->writeByte(me->r);
+ stream->writeByte(me->g);
+ stream->writeByte(me->b);
+ stream->writeByte(me->colourmix);
+ stream->writeByte(me->transparency);
saveObjectRef(me->thisType, stream);
@@ -1165,7 +1165,7 @@ bool loadPeople(Common::SeekableReadStream *stream) {
scaleHorizon = getSigned(stream);
scaleDivide = getSigned(stream);
- int countPeople = get2bytes(stream);
+ int countPeople = stream->readUint16BE();
int a;
allPeople = NULL;
@@ -1188,50 +1188,50 @@ bool loadPeople(Common::SeekableReadStream *stream) {
loadCostume(me->myPersona, stream);
loadAnim(me->myAnim, stream);
- me->lastUsedAnim = getch(stream) ? me->myAnim : NULL;
+ me->lastUsedAnim = stream->readByte() ? me->myAnim : NULL;
me->scale = getFloat(stream);
- me->extra = get2bytes(stream);
- me->height = get2bytes(stream);
- me->walkToX = get2bytes(stream);
- me->walkToY = get2bytes(stream);
- me->thisStepX = get2bytes(stream);
- me->thisStepY = get2bytes(stream);
- me->frameNum = get2bytes(stream);
- me->frameTick = get2bytes(stream);
- me->walkSpeed = get2bytes(stream);
- me->spinSpeed = get2bytes(stream);
+ me->extra = stream->readUint16BE();
+ me->height = stream->readUint16BE();
+ me->walkToX = stream->readUint16BE();
+ me->walkToY = stream->readUint16BE();
+ me->thisStepX = stream->readUint16BE();
+ me->thisStepY = stream->readUint16BE();
+ me->frameNum = stream->readUint16BE();
+ me->frameTick = stream->readUint16BE();
+ me->walkSpeed = stream->readUint16BE();
+ me->spinSpeed = stream->readUint16BE();
me->floaty = getSigned(stream);
- me->show = getch(stream);
- me->walking = getch(stream);
- me->spinning = getch(stream);
- if (getch(stream)) {
+ me->show = stream->readByte();
+ me->walking = stream->readByte();
+ me->spinning = stream->readByte();
+ if (stream->readByte()) {
me->continueAfterWalking = loadFunction(stream);
if (!me->continueAfterWalking)
return false;
} else {
me->continueAfterWalking = NULL;
}
- me->direction = get2bytes(stream);
- me->angle = get2bytes(stream);
+ me->direction = stream->readUint16BE();
+ me->angle = stream->readUint16BE();
if (ssgVersion >= VERSION(2, 0)) {
- me->angleOffset = get2bytes(stream);
+ me->angleOffset = stream->readUint16BE();
} else {
me->angleOffset = 0;
}
- me->wantAngle = get2bytes(stream);
+ me->wantAngle = stream->readUint16BE();
me->directionWhenDoneWalking = getSigned(stream);
me->inPoly = getSigned(stream);
me->walkToPoly = getSigned(stream);
if (ssgVersion >= VERSION(2, 0)) {
- me->r = getch(stream);
- me->g = getch(stream);
- me->b = getch(stream);
- me->colourmix = getch(stream);
- me->transparency = getch(stream);
+ me->r = stream->readByte();
+ me->g = stream->readByte();
+ me->b = stream->readByte();
+ me->colourmix = stream->readByte();
+ me->transparency = stream->readByte();
} else {
- setMyDrawMode(me, get2bytes(stream));
+ setMyDrawMode(me, stream->readUint16BE());
}
me->thisType = loadObjectRef(stream);
@@ -1239,7 +1239,7 @@ bool loadPeople(Common::SeekableReadStream *stream) {
if (ssgVersion >= VERSION(1, 6)) {
if (ssgVersion < VERSION(2, 0)) {
// aaLoad
- getch(stream);
+ stream->readByte();
getFloat(stream);
getFloat(stream);
}
diff --git a/engines/sludge/region.cpp b/engines/sludge/region.cpp
index f837d32a17..efc6908b1b 100644
--- a/engines/sludge/region.cpp
+++ b/engines/sludge/region.cpp
@@ -72,16 +72,16 @@ void saveRegions(Common::WriteStream *stream) {
thisRegion = thisRegion->next;
numRegions++;
}
- put2bytes(numRegions, stream);
+ stream->writeUint16BE(numRegions);
thisRegion = allScreenRegions;
while (thisRegion) {
- put2bytes(thisRegion->x1, stream);
- put2bytes(thisRegion->y1, stream);
- put2bytes(thisRegion->x2, stream);
- put2bytes(thisRegion->y2, stream);
- put2bytes(thisRegion->sX, stream);
- put2bytes(thisRegion->sY, stream);
- put2bytes(thisRegion->di, stream);
+ stream->writeUint16BE(thisRegion->x1);
+ stream->writeUint16BE(thisRegion->y1);
+ stream->writeUint16BE(thisRegion->x2);
+ stream->writeUint16BE(thisRegion->y2);
+ stream->writeUint16BE(thisRegion->sX);
+ stream->writeUint16BE(thisRegion->sY);
+ stream->writeUint16BE(thisRegion->di);
saveObjectRef(thisRegion->thisType, stream);
thisRegion = thisRegion->next;
@@ -89,7 +89,7 @@ void saveRegions(Common::WriteStream *stream) {
}
void loadRegions(Common::SeekableReadStream *stream) {
- int numRegions = get2bytes(stream);
+ int numRegions = stream->readUint16BE();
screenRegion *newRegion;
screenRegion * * pointy = &allScreenRegions;
@@ -99,13 +99,13 @@ void loadRegions(Common::SeekableReadStream *stream) {
*pointy = newRegion;
pointy = &(newRegion->next);
- newRegion->x1 = get2bytes(stream);
- newRegion->y1 = get2bytes(stream);
- newRegion->x2 = get2bytes(stream);
- newRegion->y2 = get2bytes(stream);
- newRegion->sX = get2bytes(stream);
- newRegion->sY = get2bytes(stream);
- newRegion->di = get2bytes(stream);
+ newRegion->x1 = stream->readUint16BE();
+ newRegion->y1 = stream->readUint16BE();
+ newRegion->x2 = stream->readUint16BE();
+ newRegion->y2 = stream->readUint16BE();
+ newRegion->sX = stream->readUint16BE();
+ newRegion->sY = stream->readUint16BE();
+ newRegion->di = stream->readUint16BE();
newRegion->thisType = loadObjectRef(stream);
}
*pointy = NULL;
diff --git a/engines/sludge/savedata.cpp b/engines/sludge/savedata.cpp
index 805f006f7b..e387b92bfb 100644
--- a/engines/sludge/savedata.cpp
+++ b/engines/sludge/savedata.cpp
@@ -64,20 +64,20 @@ extern char *gamePath;
void writeStringEncoded(const char *s, Common::WriteStream *stream) {
int a, len = strlen(s);
- put2bytes(len, stream);
+ stream->writeUint16BE(len);
for (a = 0; a < len; a++) {
- putch(s[a] ^ encode1, stream);
+ stream->writeByte(s[a] ^ encode1);
encode1 += encode2;
}
}
char *readStringEncoded(Common::File *fp) {
- int a, len = get2bytes(fp);
+ int a, len = fp->readUint16BE();
char *s = new char[len + 1];
if (!checkNew(s))
return NULL;
for (a = 0; a < len; a++) {
- s[a] = (char) (getch(fp) ^ encode1);
+ s[a] = (char) (fp->readByte() ^ encode1);
encode1 += encode2;
}
s[len] = 0;
@@ -95,7 +95,7 @@ char *readTextPlain(Common::File *fp) {
startPos = fp->pos();
while (keepGoing) {
- gotChar = (char) getch(fp);
+ gotChar = (char) fp->readByte();
if ((gotChar == '\n') || (fp->eos())) {
keepGoing = false;
} else {
@@ -114,7 +114,7 @@ char *readTextPlain(Common::File *fp) {
if (bytes_read != stringSize && fp->err()) {
debugOut("Reading error in readTextPlain.\n");
}
- getch(fp); // Skip the newline character
+ fp->readByte(); // Skip the newline character
reply[stringSize] = 0;
}
@@ -157,7 +157,7 @@ bool fileToStack(char *filename, stackHandler *sH) {
encode2 = (unsigned char) (saveEncoding >> 8);
while (*checker) {
- if (getch(&fd) != *checker) {
+ if (fd.readByte() != *checker) {
fd.close();
return fatal(LOAD_ERROR "This isn't a SLUDGE custom data file:",
filename);
@@ -179,7 +179,7 @@ bool fileToStack(char *filename, stackHandler *sH) {
for (;;) {
if (saveEncoding) {
- char i = getch(&fd) ^ encode1;
+ char i = fd.readByte() ^ encode1;
if (fd.eos())
break;
@@ -192,11 +192,11 @@ bool fileToStack(char *filename, stackHandler *sH) {
break;
case 1:
- setVariable(stringVar, SVT_INT, get4bytes(&fd));
+ setVariable(stringVar, SVT_INT, fd.readUint32LE());
break;
case 2:
- setVariable(stringVar, SVT_INT, getch(&fd));
+ setVariable(stringVar, SVT_INT, fd.readByte());
break;
default:
@@ -260,7 +260,7 @@ bool stackToFile(char *filename, const variable &from) {
fputc(hereWeAre -> thisVar.varData.intValue, fp);
} else {
fputc(1 ^ encode1, fp);
- put4bytes(hereWeAre -> thisVar.varData.intValue, fp);
+ fp->writeUint32LE(hereWeAre -> thisVar.varData.intValue);
}
break;
diff --git a/engines/sludge/sludger.cpp b/engines/sludge/sludger.cpp
index c7ffd9d309..7fe21192e4 100644
--- a/engines/sludge/sludger.cpp
+++ b/engines/sludge/sludger.cpp
@@ -127,23 +127,23 @@ const char *sludgeText[] = { "?????", "RETURN", "BRANCH", "BR_ZERO",
"INDEXGET", "INC_INDEX", "DEC_INDEX", "QUICK_PUSH" };
void loadHandlers(Common::SeekableReadStream *stream) {
- currentEvents->leftMouseFunction = get2bytes(stream);
- currentEvents->leftMouseUpFunction = get2bytes(stream);
- currentEvents->rightMouseFunction = get2bytes(stream);
- currentEvents->rightMouseUpFunction = get2bytes(stream);
- currentEvents->moveMouseFunction = get2bytes(stream);
- currentEvents->focusFunction = get2bytes(stream);
- currentEvents->spaceFunction = get2bytes(stream);
+ currentEvents->leftMouseFunction = stream->readUint16BE();
+ currentEvents->leftMouseUpFunction = stream->readUint16BE();
+ currentEvents->rightMouseFunction = stream->readUint16BE();
+ currentEvents->rightMouseUpFunction = stream->readUint16BE();
+ currentEvents->moveMouseFunction = stream->readUint16BE();
+ currentEvents->focusFunction = stream->readUint16BE();
+ currentEvents->spaceFunction = stream->readUint16BE();
}
void saveHandlers(Common::WriteStream *stream) {
- put2bytes(currentEvents->leftMouseFunction, stream);
- put2bytes(currentEvents->leftMouseUpFunction, stream);
- put2bytes(currentEvents->rightMouseFunction, stream);
- put2bytes(currentEvents->rightMouseUpFunction, stream);
- put2bytes(currentEvents->moveMouseFunction, stream);
- put2bytes(currentEvents->focusFunction, stream);
- put2bytes(currentEvents->spaceFunction, stream);
+ stream->writeUint16BE(currentEvents->leftMouseFunction);
+ stream->writeUint16BE(currentEvents->leftMouseUpFunction);
+ stream->writeUint16BE(currentEvents->rightMouseFunction);
+ stream->writeUint16BE(currentEvents->rightMouseUpFunction);
+ stream->writeUint16BE(currentEvents->moveMouseFunction);
+ stream->writeUint16BE(currentEvents->focusFunction);
+ stream->writeUint16BE(currentEvents->spaceFunction);
}
Common::File *openAndVerify(char *filename, char extra1, char extra2,
@@ -154,32 +154,32 @@ Common::File *openAndVerify(char *filename, char extra1, char extra2,
return NULL;
}
bool headerBad = false;
- if (getch(fp) != 'S')
+ if (fp->readByte() != 'S')
headerBad = true;
- if (getch(fp) != 'L')
+ if (fp->readByte() != 'L')
headerBad = true;
- if (getch(fp) != 'U')
+ if (fp->readByte() != 'U')
headerBad = true;
- if (getch(fp) != 'D')
+ if (fp->readByte() != 'D')
headerBad = true;
- if (getch(fp) != extra1)
+ if (fp->readByte() != extra1)
headerBad = true;
- if (getch(fp) != extra2)
+ if (fp->readByte() != extra2)
headerBad = true;
if (headerBad) {
fatal(er, filename);
return NULL;
}
char c;
- c = getch(fp);
+ c = fp->readByte();
debug("%c", c);
- while ((c = getch(fp))) {
+ while ((c = fp->readByte())) {
debug("%c", c);
}
- int majVersion = getch(fp);
+ int majVersion = fp->readByte();
debug(kSludgeDebugDataLoad, "majVersion %i", majVersion);
- int minVersion = getch(fp);
+ int minVersion = fp->readByte();
debug(kSludgeDebugDataLoad, "minVersion %i", minVersion);
fileVersion = majVersion * 256 + minVersion;
@@ -206,9 +206,9 @@ bool initSludge(char *filename) {
if (!fp)
return false;
- char c = getch(fp);
+ char c = fp->readByte();
if (c) {
- numBIFNames = get2bytes(fp);
+ numBIFNames = fp->readUint16BE();
debug(kSludgeDebugDataLoad, "numBIFNames %i", numBIFNames);
allBIFNames = new char *[numBIFNames];
if (!checkNew(allBIFNames))
@@ -217,7 +217,7 @@ bool initSludge(char *filename) {
for (int fn = 0; fn < numBIFNames; fn++) {
allBIFNames[fn] = readString(fp);
}
- numUserFunc = get2bytes(fp);
+ numUserFunc = fp->readUint16BE();
debug(kSludgeDebugDataLoad, "numUserFunc %i", numUserFunc);
allUserFunc = new char *[numUserFunc];
if (!checkNew(allUserFunc))
@@ -227,7 +227,7 @@ bool initSludge(char *filename) {
allUserFunc[fn] = readString(fp);
}
if (gameVersion >= VERSION(1, 3)) {
- numResourceNames = get2bytes(fp);
+ numResourceNames = fp->readUint16BE();
debug(kSludgeDebugDataLoad, "numResourceNames %i",
numResourceNames);
allResourceNames = new char *[numResourceNames];
@@ -240,13 +240,13 @@ bool initSludge(char *filename) {
}
}
- winWidth = get2bytes(fp);
+ winWidth = fp->readUint16BE();
debug(kSludgeDebugDataLoad, "winWidth : %i", winWidth);
- winHeight = get2bytes(fp);
+ winHeight = fp->readUint16BE();
debug(kSludgeDebugDataLoad, "winHeight : %i", winHeight);
- specialSettings = getch(fp);
+ specialSettings = fp->readByte();
debug(kSludgeDebugDataLoad, "specialSettings : %i", specialSettings);
- desiredfps = 1000 / getch(fp);
+ desiredfps = 1000 / fp->readByte();
delete[] readString(fp); // Unused - was used for registration purposes.
@@ -261,14 +261,14 @@ bool initSludge(char *filename) {
debug(kSludgeDebugDataLoad, "dataFol : %s", dataFol);
gameSettings.numLanguages =
- (gameVersion >= VERSION(1, 3)) ? (getch(fp)) : 0;
+ (gameVersion >= VERSION(1, 3)) ? (fp->readByte()) : 0;
debug(kSludgeDebugDataLoad, "numLanguages : %c", gameSettings.numLanguages);
makeLanguageTable(fp);
if (gameVersion >= VERSION(1, 6)) {
- getch(fp);
+ fp->readByte();
// aaLoad
- getch(fp);
+ fp->readByte();
getFloat(fp);
getFloat(fp);
}
@@ -281,7 +281,7 @@ bool initSludge(char *filename) {
delete checker;
checker = NULL;
- unsigned char customIconLogo = getch(fp);
+ unsigned char customIconLogo = fp->readByte();
debug(kSludgeDebugDataLoad, "Game icon type: %i", customIconLogo);
if (customIconLogo & 1) {
@@ -309,8 +309,8 @@ bool initSludge(char *filename) {
fileIsPNG = false;
fseek(fp, file_pointer, SEEK_SET);
- iconW = get2bytes(fp);
- iconH = get2bytes(fp);
+ iconW = fp->readUint16BE();
+ iconH = fp->readUint16BE();
} else {
// Read the PNG header
@@ -373,7 +373,7 @@ bool initSludge(char *filename) {
for (int t2 = 0; t2 < iconH; t2 ++) {
int t1 = 0;
while (t1 < iconW) {
- unsigned short c = (unsigned short) get2bytes(fp);
+ unsigned short c = (unsigned short) fp->readUint16BE();
if (c & 32) {
n = fgetc(fp) + 1;
c -= 32;
@@ -418,8 +418,8 @@ bool initSludge(char *filename) {
fileIsPNG = false;
fseek(fp, file_pointer, SEEK_SET);
- logoW = get2bytes(fp);
- logoH = get2bytes(fp);
+ logoW = fp->readUint16BE();
+ logoH = fp->readUint16BE();
} else {
// Read the PNG header
@@ -490,7 +490,7 @@ bool initSludge(char *filename) {
for (int t2 = 0; t2 < logoH; t2 ++) {
int t1 = 0;
while (t1 < logoW) {
- unsigned short c = (unsigned short) get2bytes(fp);
+ unsigned short c = (unsigned short) fp->readUint16BE();
if (c & 32) {
n = fgetc(fp) + 1;
c -= 32;
@@ -518,7 +518,7 @@ bool initSludge(char *filename) {
#endif
}
- numGlobals = get2bytes(fp);
+ numGlobals = fp->readUint16BE();
debug("numGlobals : %i", numGlobals);
globalVars = new variable[numGlobals];
@@ -1398,21 +1398,20 @@ bool loadFunctionCode(loadedFunction *newFunc) {
debug(kSludgeDebugDataLoad, "Load function code");
- newFunc->unfreezable = getch(bigDataFile);
- numLines = get2bytes(bigDataFile);
+ newFunc->unfreezable = bigDataFile->readByte();
+ numLines = bigDataFile->readUint16BE();
debug(kSludgeDebugDataLoad, "numLines: %i", numLines);
- newFunc->numArgs = get2bytes(bigDataFile);
+ newFunc->numArgs = bigDataFile->readUint16BE();
debug(kSludgeDebugDataLoad, "numArgs: %i", newFunc->numArgs);
- newFunc->numLocals = get2bytes(bigDataFile);
+ newFunc->numLocals = bigDataFile->readUint16BE();
debug(kSludgeDebugDataLoad, "numLocals: %i", newFunc->numLocals);
newFunc->compiledLines = new lineOfCode[numLines];
if (!checkNew(newFunc->compiledLines))
return false;
for (numLinesRead = 0; numLinesRead < numLines; numLinesRead++) {
- newFunc->compiledLines[numLinesRead].theCommand = (sludgeCommand) getch(
- bigDataFile);
- newFunc->compiledLines[numLinesRead].param = get2bytes(bigDataFile);
+ newFunc->compiledLines[numLinesRead].theCommand = (sludgeCommand) bigDataFile->readByte();
+ newFunc->compiledLines[numLinesRead].param = bigDataFile->readUint16BE();
debug(kSludgeDebugDataLoad, "command line %i: %i", numLinesRead,
newFunc->compiledLines[numLinesRead].theCommand);
}
diff --git a/engines/sludge/sound_bass.cpp b/engines/sludge/sound_bass.cpp
index 5bb4e79e51..c2fa56d9da 100644
--- a/engines/sludge/sound_bass.cpp
+++ b/engines/sludge/sound_bass.cpp
@@ -379,29 +379,29 @@ void saveSounds(Common::WriteStream *stream) {
if (soundOK) {
for (int i = 0; i < MAX_SAMPLES; i++) {
if (soundCache[i].looping) {
- putch(1, stream);
- put2bytes(soundCache[i].fileLoaded, stream);
- put2bytes(soundCache[i].vol, stream);
+ stream->writeByte(1);
+ stream->writeUint16BE(soundCache[i].fileLoaded);
+ stream->writeUint16BE(soundCache[i].vol);
}
}
}
- putch(0, stream);
- put2bytes(defSoundVol, stream);
- put2bytes(defVol, stream);
+ stream->writeByte(0);
+ stream->writeUint16BE(defSoundVol);
+ stream->writeUint16BE(defVol);
}
void loadSounds(Common::SeekableReadStream *stream) {
for (int i = 0; i < MAX_SAMPLES; i++)
freeSound(i);
- while (getch(stream)) {
- int fileLoaded = get2bytes(stream);
- defSoundVol = get2bytes(stream);
+ while (stream->readByte()) {
+ int fileLoaded = stream->readUint16BE();
+ defSoundVol = stream->readUint16BE();
startSound(fileLoaded, 1);
}
- defSoundVol = get2bytes(stream);
- defVol = get2bytes(stream);
+ defSoundVol = stream->readUint16BE();
+ defVol = stream->readUint16BE();
}
bool getSoundCacheStack(stackHandler *sH) {
diff --git a/engines/sludge/sound_nosound.cpp b/engines/sludge/sound_nosound.cpp
index 292148b1fe..2c347e6af4 100644
--- a/engines/sludge/sound_nosound.cpp
+++ b/engines/sludge/sound_nosound.cpp
@@ -113,19 +113,19 @@ bool startSound(int f, bool loopy) {
}
void saveSounds(Common::WriteStream *stream) {
- putch(0, stream);
- put2bytes(defSoundVol, stream);
- put2bytes(defVol, stream);
+ stream->writeByte(0);
+ stream->writeUint16BE(defSoundVol);
+ stream->writeUint16BE(defVol);
}
void loadSounds(Common::SeekableReadStream *stream) {
- while (getch(stream)) {
- get2bytes(stream);
- get2bytes(stream);
+ while (stream->readByte()) {
+ stream->readUint16BE();
+ stream->readUint16BE();
}
- defSoundVol = get2bytes(stream);
- defVol = get2bytes(stream);
+ defSoundVol = stream->readUint16BE();
+ defVol = stream->readUint16BE();
}
bool getSoundCacheStack(stackHandler *sH) {
diff --git a/engines/sludge/sound_openal.cpp b/engines/sludge/sound_openal.cpp
index 72824d37ca..e180bf8e08 100644
--- a/engines/sludge/sound_openal.cpp
+++ b/engines/sludge/sound_openal.cpp
@@ -606,29 +606,29 @@ void saveSounds(Common::WriteStream *stream) {
if (soundOK) {
for (int i = 0; i < MAX_SAMPLES; i++) {
if (soundCache[i].looping) {
- putch(1, stream);
- put2bytes(soundCache[i].fileLoaded, stream);
- put2bytes(soundCache[i].vol, stream);
+ stream->writeByte(1);
+ stream->writeUint16BE(soundCache[i].fileLoaded);
+ stream->writeUint16BE(soundCache[i].vol);
}
}
}
- putch(0, stream);
- put2bytes(defSoundVol, stream);
- put2bytes(defVol, stream);
+ stream->writeByte(0);
+ stream->writeUint16BE(defSoundVol);
+ stream->writeUint16BE(defVol);
}
void loadSounds(Common::SeekableReadStream *stream) {
for (int i = 0; i < MAX_SAMPLES; i++)
freeSound(i);
- while (getch(stream)) {
- int fileLoaded = get2bytes(stream);
- defSoundVol = get2bytes(stream);
+ while (stream->readByte()) {
+ int fileLoaded = stream->readUint16BE();
+ defSoundVol = stream->readUint16BE();
startSound(fileLoaded, 1);
}
- defSoundVol = get2bytes(stream);
- defVol = get2bytes(stream);
+ defSoundVol = stream->readUint16BE();
+ defVol = stream->readUint16BE();
}
bool getSoundCacheStack(stackHandler *sH) {
diff --git a/engines/sludge/sprites.cpp b/engines/sludge/sprites.cpp
index 5b372e6ece..069d97f54b 100644
--- a/engines/sludge/sprites.cpp
+++ b/engines/sludge/sprites.cpp
@@ -130,13 +130,13 @@ bool loadSpriteBank(int fileNum, spriteBank &loadhere, bool isFont) {
loadhere.isFont = isFont;
- total = get2bytes(bigDataFile);
+ total = bigDataFile->readUint16BE();
if (! total) {
spriteBankVersion = fgetc(bigDataFile);
if (spriteBankVersion == 1) {
total = 0;
} else {
- total = get2bytes(bigDataFile);
+ total = bigDataFile->readUint16BE();
}
}
@@ -223,8 +223,8 @@ bool loadSpriteBank(int fileNum, spriteBank &loadhere, bool isFont) {
break;
}
case 2:
- picwidth = get2bytes(bigDataFile);
- picheight = get2bytes(bigDataFile);
+ picwidth = bigDataFile->readUint16BE();
+ picheight = bigDataFile->readUint16BE();
loadhere.sprites[i].xhot = getSigned(bigDataFile);
loadhere.sprites[i].yhot = getSigned(bigDataFile);
break;
diff --git a/engines/sludge/statusba.cpp b/engines/sludge/statusba.cpp
index d90d3a2d29..da9d655022 100644
--- a/engines/sludge/statusba.cpp
+++ b/engines/sludge/statusba.cpp
@@ -29,6 +29,7 @@
#include "stringy.h"
#include "newfatal.h"
#include "statusba.h"
+#include "common/file.h"
namespace Sludge {
@@ -176,48 +177,48 @@ const char *statusBarText() {
void saveStatusBars(Common::WriteStream *stream) {
statusBar *viewLine = nowStatus->firstStatusBar;
- put2bytes(nowStatus->alignStatus, stream);
+ stream->writeUint16BE(nowStatus->alignStatus);
putSigned(nowStatus->litStatus, stream);
- put2bytes(nowStatus->statusX, stream);
- put2bytes(nowStatus->statusY, stream);
+ stream->writeUint16BE(nowStatus->statusX);
+ stream->writeUint16BE(nowStatus->statusY);
- putch(nowStatus->statusR, stream);
- putch(nowStatus->statusG, stream);
- putch(nowStatus->statusB, stream);
- putch(nowStatus->statusLR, stream);
- putch(nowStatus->statusLG, stream);
- putch(nowStatus->statusLB, stream);
+ stream->writeByte(nowStatus->statusR);
+ stream->writeByte(nowStatus->statusG);
+ stream->writeByte(nowStatus->statusB);
+ stream->writeByte(nowStatus->statusLR);
+ stream->writeByte(nowStatus->statusLG);
+ stream->writeByte(nowStatus->statusLB);
// Write what's being said
while (viewLine) {
- putch(1, stream);
+ stream->writeByte(1);
writeString(viewLine->text, stream);
viewLine = viewLine->next;
}
- putch(0, stream);
+ stream->writeByte(0);
}
bool loadStatusBars(Common::SeekableReadStream *stream) {
clearStatusBar();
- nowStatus->alignStatus = get2bytes(stream);
+ nowStatus->alignStatus = stream->readUint16BE();
nowStatus->litStatus = getSigned(stream);
- nowStatus->statusX = get2bytes(stream);
- nowStatus->statusY = get2bytes(stream);
+ nowStatus->statusX = stream->readUint16BE();
+ nowStatus->statusY = stream->readUint16BE();
- nowStatus->statusR = getch(stream);
- nowStatus->statusG = getch(stream);
- nowStatus->statusB = getch(stream);
- nowStatus->statusLR = getch(stream);
- nowStatus->statusLG = getch(stream);
- nowStatus->statusLB = getch(stream);
+ nowStatus->statusR = stream->readByte();
+ nowStatus->statusG = stream->readByte();
+ nowStatus->statusB = stream->readByte();
+ nowStatus->statusLR = stream->readByte();
+ nowStatus->statusLG = stream->readByte();
+ nowStatus->statusLB = stream->readByte();
setFontColour(verbLinePalette, nowStatus->statusR, nowStatus->statusG, nowStatus->statusB);
setFontColour(litVerbLinePalette, nowStatus->statusLR, nowStatus->statusLG, nowStatus->statusLB);
// Read what's being said
statusBar * * viewLine = & (nowStatus->firstStatusBar);
statusBar *newOne;
- while (getch(stream)) {
+ while (stream->readByte()) {
newOne = new statusBar;
if (! checkNew(newOne)) return false;
newOne->text = readString(stream);
diff --git a/engines/sludge/talk.cpp b/engines/sludge/talk.cpp
index 5e6c10dd25..0b66815a35 100644
--- a/engines/sludge/talk.cpp
+++ b/engines/sludge/talk.cpp
@@ -219,32 +219,32 @@ void saveSpeech(speechStruct *sS, Common::WriteStream *stream) {
#if 0
speechLine *viewLine = sS->allSpeech;
- putch(sS->talkCol.originalRed, stream);
- putch(sS->talkCol.originalGreen, stream);
- putch(sS->talkCol.originalBlue, stream);
+ stream->writeByte(sS->talkCol.originalRed);
+ stream->writeByte(sS->talkCol.originalGreen);
+ stream->writeByte(sS->talkCol.originalBlue);
putFloat(speechSpeed, stream);
// Write y co-ordinate
- put2bytes(sS->speechY, stream);
+ stream->writeUint16BE(sS->speechY);
// Write which character's talking
- put2bytes(sS->lookWhosTalking, stream);
+ stream->writeUint16BE(sS->lookWhosTalking);
if (sS->currentTalker) {
- putch(1, stream);
- put2bytes(sS->currentTalker->thisType->objectNum, stream);
+ stream->writeByte(1);
+ stream->writeUint16BE(sS->currentTalker->thisType->objectNum);
} else {
- putch(0, stream);
+ stream->writeByte(0);
}
// Write what's being said
while (viewLine) {
- putch(1, stream);
+ stream->writeByte(1);
writeString(viewLine->textLine, stream);
- put2bytes(viewLine->x, stream);
+ stream->writeUint16BE(viewLine->x);
viewLine = viewLine->next;
}
- putch(0, stream);
+ stream->writeByte(0);
#endif
}
@@ -252,21 +252,21 @@ bool loadSpeech(speechStruct *sS, Common::SeekableReadStream *stream) {
#if 0
speech->currentTalker = NULL;
killAllSpeech();
- byte r = getch(stream);
- byte g = getch(stream);
- byte b = getch(stream);
+ byte r = stream->readByte();
+ byte g = stream->readByte();
+ byte b = stream->readByte();
setFontColour(sS->talkCol, r, g, b);
speechSpeed = getFloat(stream);
// Read y co-ordinate
- sS->speechY = get2bytes(stream);
+ sS->speechY = stream->readUint16BE();
// Read which character's talking
- sS->lookWhosTalking = get2bytes(stream);
+ sS->lookWhosTalking = stream->readUint16BE();
- if (getch(stream)) {
- sS->currentTalker = findPerson(get2bytes(stream));
+ if (stream->readByte()) {
+ sS->currentTalker = findPerson(stream->readUint16BE());
} else {
sS->currentTalker = NULL;
}
@@ -275,11 +275,11 @@ bool loadSpeech(speechStruct *sS, Common::SeekableReadStream *stream) {
speechLine * * viewLine = &sS->allSpeech;
speechLine *newOne;
speech->lastFile = -1;
- while (getch(stream)) {
+ while (stream->readByte()) {
newOne = new speechLine;
if (! checkNew(newOne)) return false;
newOne->textLine = readString(stream);
- newOne->x = get2bytes(stream);
+ newOne->x = stream->readUint16BE();
newOne->next = NULL;
(* viewLine) = newOne;
viewLine = &(newOne->next);
diff --git a/engines/sludge/thumbnail.cpp b/engines/sludge/thumbnail.cpp
index 7c588a283a..5e77936fb6 100644
--- a/engines/sludge/thumbnail.cpp
+++ b/engines/sludge/thumbnail.cpp
@@ -44,8 +44,8 @@ bool saveThumbnail(Common::WriteStream *stream) {
#if 0
GLuint thumbnailTextureName = 0;
- put4bytes(thumbWidth, fp);
- put4bytes(thumbHeight, fp);
+ fp->writeUint32LE(thumbWidth);
+ fp->writeUint32LE(thumbHeight);
if (thumbWidth && thumbHeight) {
if (! freeze()) return false;
@@ -148,8 +148,8 @@ void showThumbnail(char *filename, int atX, int atY) {
FILE *fp = openAndVerify(filename, 'S', 'A', ERROR_GAME_LOAD_NO, ssgVersion);
if (ssgVersion >= VERSION(1, 4)) {
if (fp == NULL) return;
- int fileWidth = get4bytes(fp);
- int fileHeight = get4bytes(fp);
+ int fileWidth = fp->readUint32LE();
+ int fileHeight = fp->readUint32LE();
int picWidth = fileWidth;
int picHeight = fileHeight;
@@ -170,7 +170,7 @@ void showThumbnail(char *filename, int atX, int atY) {
for (t2 = 0; t2 < fileHeight; t2 ++) {
t1 = 0;
while (t1 < fileWidth) {
- c = (unsigned short) get2bytes(fp);
+ c = (unsigned short) fp->readUint16BE();
target = thumbnailTexture + 4 * picWidth * t2 + t1 * 4;
target[0] = (GLubyte) redValue(c);
target[1] = (GLubyte) greenValue(c);
@@ -252,12 +252,12 @@ void showThumbnail(char *filename, int atX, int atY) {
}
bool skipThumbnail(Common::SeekableReadStream *stream) {
- thumbWidth = get4bytes(stream);
- thumbHeight = get4bytes(stream);
+ thumbWidth = stream->readUint32LE();
+ thumbHeight = stream->readUint32LE();
uint32_t skippy = thumbWidth;
skippy *= thumbHeight << 1;
stream->seek(skippy, 1);
- return (getch(stream) == '!');
+ return (stream->readByte() == '!');
}
} // End of namespace Sludge
diff --git a/engines/sludge/zbuffer.cpp b/engines/sludge/zbuffer.cpp
index fe13a98116..d81fde6dd5 100644
--- a/engines/sludge/zbuffer.cpp
+++ b/engines/sludge/zbuffer.cpp
@@ -87,8 +87,8 @@ bool setZBuffer(int y) {
break;
case 1:
- zBuffer.width = get2bytes(bigDataFile);
- zBuffer.height = get2bytes(bigDataFile);
+ zBuffer.width = bigDataFile->readUint16BE();
+ zBuffer.height = bigDataFile->readUint16BE();
break;
default:
@@ -102,7 +102,7 @@ bool setZBuffer(int y) {
zBuffer.numPanels = fgetc(bigDataFile);
for (y = 0; y < zBuffer.numPanels; y ++) {
- yPalette[y] = get2bytes(bigDataFile);
+ yPalette[y] = bigDataFile->readUint16BE();
}
sortZPal(yPalette, sorted, zBuffer.numPanels);
for (y = 0; y < zBuffer.numPanels; y ++) {
@@ -124,7 +124,7 @@ bool setZBuffer(int y) {
if (stillToGo == 0) {
n = fgetc(bigDataFile);
stillToGo = n >> 4;
- if (stillToGo == 15) stillToGo = get2bytes(bigDataFile) + 16l;
+ if (stillToGo == 15) stillToGo = bigDataFile->readUint16BE() + 16l;
else stillToGo ++;
n &= 15;
}