diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sludge/loadsave.cpp | 4 | ||||
-rw-r--r-- | engines/sludge/moreio.cpp | 28 | ||||
-rw-r--r-- | engines/sludge/moreio.h | 2 | ||||
-rw-r--r-- | engines/sludge/people.cpp | 24 | ||||
-rw-r--r-- | engines/sludge/sprites.cpp | 8 | ||||
-rw-r--r-- | engines/sludge/statusba.cpp | 4 |
6 files changed, 20 insertions, 50 deletions
diff --git a/engines/sludge/loadsave.cpp b/engines/sludge/loadsave.cpp index df7bf9bd4d..d1fd187c92 100644 --- a/engines/sludge/loadsave.cpp +++ b/engines/sludge/loadsave.cpp @@ -413,7 +413,7 @@ bool saveGame(char *fname) { fp->writeUint16BE(fontHeight); writeString(fontOrder.getUTF8String(), fp); } - putSigned(fontSpace, fp); + fp->writeSint16LE(fontSpace); // Save backdrop fp->writeUint16BE(cameraX); @@ -595,7 +595,7 @@ bool loadGame(char *fname) { loadFont(fontNum, charOrder, fontHeight); delete []charOrder; - fontSpace = getSigned(fp); + fontSpace = fp->readSint16LE(); killAllPeople(); killAllRegions(); diff --git a/engines/sludge/moreio.cpp b/engines/sludge/moreio.cpp index 0102b31ffd..874254c8ce 100644 --- a/engines/sludge/moreio.cpp +++ b/engines/sludge/moreio.cpp @@ -97,34 +97,6 @@ void putFloat(float f, Common::WriteStream *stream) { stream->write(&f, sizeof(float)); } -int16 shortSwap(int16 s) { - byte b1, b2; - - b1 = s & 255; - b2 = (s >> 8) & 255; - - return (b1 << 8) + b2; -} - -int16 getSigned(Common::SeekableReadStream *stream) { - int16 f; - uint bytes_read = stream->read(&f, sizeof(int16)); - if (bytes_read != sizeof(int16) && stream->err()) { - debug("Reading error in getSigned.\n"); - } -#ifdef __BIG_ENDIAN__ - f = shortSwap(f); -#endif - return f; -} - -void putSigned(int16 f, Common::WriteStream *stream) { -#ifdef __BIG_ENDIAN__ - f = shortSwap(f); -#endif - stream->write(&f, sizeof(int16)); -} - char *encodeFilename(char *nameIn) { if (!nameIn) return NULL; diff --git a/engines/sludge/moreio.h b/engines/sludge/moreio.h index 462d005141..b22b76ac8c 100644 --- a/engines/sludge/moreio.h +++ b/engines/sludge/moreio.h @@ -27,12 +27,10 @@ namespace Sludge { // Read char *readString(Common::SeekableReadStream *stream); float getFloat(Common::SeekableReadStream *stream); -int16 getSigned(Common::SeekableReadStream *stream); // Write void writeString(Common::String s, Common::WriteStream *stream); void putFloat(float f, Common::WriteStream *stream); -void putSigned(int16 f, Common::WriteStream *stream); char *encodeFilename(char *nameIn); char *decodeFilename(char *nameIn); diff --git a/engines/sludge/people.cpp b/engines/sludge/people.cpp index a477fbea85..276edf5d75 100644 --- a/engines/sludge/people.cpp +++ b/engines/sludge/people.cpp @@ -1049,8 +1049,8 @@ bool savePeople(Common::WriteStream *stream) { onScreenPerson *me = allPeople; int countPeople = 0, a; - putSigned(scaleHorizon, stream); - putSigned(scaleDivide, stream); + stream->writeSint16LE(scaleHorizon); + stream->writeSint16LE(scaleDivide); while (me) { countPeople++; @@ -1081,7 +1081,7 @@ bool savePeople(Common::WriteStream *stream) { stream->writeUint16BE(me->frameTick); stream->writeUint16BE(me->walkSpeed); stream->writeUint16BE(me->spinSpeed); - putSigned(me->floaty, stream); + stream->writeSint16LE(me->floaty); stream->writeByte(me->show); stream->writeByte(me->walking); stream->writeByte(me->spinning); @@ -1095,9 +1095,9 @@ bool savePeople(Common::WriteStream *stream) { stream->writeUint16BE(me->angle); stream->writeUint16BE(me->angleOffset); stream->writeUint16BE(me->wantAngle); - putSigned(me->directionWhenDoneWalking, stream); - putSigned(me->inPoly, stream); - putSigned(me->walkToPoly, stream); + stream->writeSint16LE(me->directionWhenDoneWalking); + stream->writeSint16LE(me->inPoly); + stream->writeSint16LE(me->walkToPoly); stream->writeByte(me->r); stream->writeByte(me->g); @@ -1116,8 +1116,8 @@ bool loadPeople(Common::SeekableReadStream *stream) { onScreenPerson * * pointy = &allPeople; onScreenPerson *me; - scaleHorizon = getSigned(stream); - scaleDivide = getSigned(stream); + scaleHorizon = stream->readSint16LE(); + scaleDivide = stream->readSint16LE(); int countPeople = stream->readUint16BE(); int a; @@ -1156,7 +1156,7 @@ bool loadPeople(Common::SeekableReadStream *stream) { me->frameTick = stream->readUint16BE(); me->walkSpeed = stream->readUint16BE(); me->spinSpeed = stream->readUint16BE(); - me->floaty = getSigned(stream); + me->floaty = stream->readSint16LE(); me->show = stream->readByte(); me->walking = stream->readByte(); me->spinning = stream->readByte(); @@ -1175,9 +1175,9 @@ bool loadPeople(Common::SeekableReadStream *stream) { me->angleOffset = 0; } me->wantAngle = stream->readUint16BE(); - me->directionWhenDoneWalking = getSigned(stream); - me->inPoly = getSigned(stream); - me->walkToPoly = getSigned(stream); + me->directionWhenDoneWalking = stream->readSint16LE(); + me->inPoly = stream->readSint16LE(); + me->walkToPoly = stream->readSint16LE(); if (ssgVersion >= VERSION(2, 0)) { me->r = stream->readByte(); me->g = stream->readByte(); diff --git a/engines/sludge/sprites.cpp b/engines/sludge/sprites.cpp index bba4ca3f86..43bc590a96 100644 --- a/engines/sludge/sprites.cpp +++ b/engines/sludge/sprites.cpp @@ -165,8 +165,8 @@ bool loadSpriteBank(int fileNum, spriteBank &loadhere, bool isFont) { if (spriteBankVersion == 3) { debug(kSludgeDebugGraphics, "png sprite"); for (int i = 0; i < total; i++) { - loadhere.sprites[i].xhot = getSigned(bigDataFile); - loadhere.sprites[i].yhot = getSigned(bigDataFile); + loadhere.sprites[i].xhot = bigDataFile->readSint16LE(); + loadhere.sprites[i].yhot = bigDataFile->readSint16LE(); if (!ImgLoader::loadPNGImage(bigDataFile, &loadhere.sprites[i].surface, false)) { return fatal("fail to read png sprite"); } @@ -183,8 +183,8 @@ bool loadSpriteBank(int fileNum, spriteBank &loadhere, bool isFont) { if (spriteBankVersion == 2) { picwidth = bigDataFile->readUint16BE(); picheight = bigDataFile->readUint16BE(); - loadhere.sprites[i].xhot = getSigned(bigDataFile); - loadhere.sprites[i].yhot = getSigned(bigDataFile); + loadhere.sprites[i].xhot = bigDataFile->readSint16LE(); + loadhere.sprites[i].yhot = bigDataFile->readSint16LE(); } else { picwidth = (byte)bigDataFile->readByte(); picheight = (byte)bigDataFile->readByte(); diff --git a/engines/sludge/statusba.cpp b/engines/sludge/statusba.cpp index 9af0f3f512..577e82b64a 100644 --- a/engines/sludge/statusba.cpp +++ b/engines/sludge/statusba.cpp @@ -178,7 +178,7 @@ void saveStatusBars(Common::WriteStream *stream) { statusBar *viewLine = nowStatus->firstStatusBar; stream->writeUint16BE(nowStatus->alignStatus); - putSigned(nowStatus->litStatus, stream); + stream->writeSint16LE(nowStatus->litStatus); stream->writeUint16BE(nowStatus->statusX); stream->writeUint16BE(nowStatus->statusY); @@ -202,7 +202,7 @@ bool loadStatusBars(Common::SeekableReadStream *stream) { clearStatusBar(); nowStatus->alignStatus = stream->readUint16BE(); - nowStatus->litStatus = getSigned(stream); + nowStatus->litStatus = stream->readSint16LE(); nowStatus->statusX = stream->readUint16BE(); nowStatus->statusY = stream->readUint16BE(); |