diff options
author | uruk | 2014-05-26 15:58:07 +0200 |
---|---|---|
committer | uruk | 2014-05-26 15:58:07 +0200 |
commit | 75546134c817a2f267c4ffff13b822ccf7e5e923 (patch) | |
tree | 4fca5f3e86fadd4e39b61d8592d76bcdaf451928 | |
parent | 8fa31d1168ab6b361125a001fb3a38f0f7389129 (diff) | |
download | scummvm-rg350-75546134c817a2f267c4ffff13b822ccf7e5e923.tar.gz scummvm-rg350-75546134c817a2f267c4ffff13b822ccf7e5e923.tar.bz2 scummvm-rg350-75546134c817a2f267c4ffff13b822ccf7e5e923.zip |
CGE2: Implement loadUser() and loadPos().
Revise File I/O a bit to do so.
-rw-r--r-- | engines/cge2/cge2.h | 1 | ||||
-rw-r--r-- | engines/cge2/cge2_main.cpp | 35 | ||||
-rw-r--r-- | engines/cge2/fileio.cpp | 8 | ||||
-rw-r--r-- | engines/cge2/fileio.h | 5 |
4 files changed, 41 insertions, 8 deletions
diff --git a/engines/cge2/cge2.h b/engines/cge2/cge2.h index 8520424ea5..c2e0dab2be 100644 --- a/engines/cge2/cge2.h +++ b/engines/cge2/cge2.h @@ -135,6 +135,7 @@ public: void loadUser(); void checkSaySwitch(); void qGame(); + void loadPos(); void setEye(V3D &e); void setEye(const V2D& e2, int z = -kScrWidth); diff --git a/engines/cge2/cge2_main.cpp b/engines/cge2/cge2_main.cpp index a2ebc34860..83569cc98a 100644 --- a/engines/cge2/cge2_main.cpp +++ b/engines/cge2/cge2_main.cpp @@ -556,7 +556,35 @@ void CGE2Engine::runGame() { } void CGE2Engine::loadUser() { - warning("STUB: CGE2Engine::loadUser()"); + // set scene + if (_mode == 0) { // user .SVG file found + warning("STUB: CGE2Engine::loadUser()"); + // Missing loading from save file. TODO: Implement it with the saving/loading! + } else if (_mode == 1) { + loadScript("CGE.INI"); + loadPos(); + // Missing saving to save file. TODO: Implement it with the saving/loading! + } +} + +void CGE2Engine::loadPos() { + if (_resman->exist("CGE.HXY")) { + for (int cav = 0; cav < kCaveMax; cav++) + _heroTab[1]->_posTab[cav] = new V2D(this, 180, 10); + + EncryptedStream file(this, "CGE.HXY"); + + for (int cav = 0; cav < kCaveMax; cav++) { + _heroTab[0]->_posTab[cav]->x = file.readSint16LE(); + _heroTab[0]->_posTab[cav]->y = file.readSint16LE(); + } + + for (int cav = 0; cav < 41; cav++) { // (564 - 400) / 4 = 41 + _heroTab[1]->_posTab[cav]->x = file.readSint16LE(); + _heroTab[1]->_posTab[cav]->y = file.readSint16LE(); + } + } else + error("Missing file: CGE.HXY"); } void CGE2Engine::checkSaySwitch() { @@ -575,11 +603,10 @@ void CGE2Engine::loadTab() { if (_resman->exist(kTabName)) { EncryptedStream f(this, kTabName); - Common::File output; for (int i = 0; i < kCaveMax; i++) { for (int j = 0; j < 3; j++) { - signed b = f.readSigned(); - unsigned a = f.readUnsigned(); + signed b = f.readSint16BE(); + unsigned a = f.readUint16BE(); uint16 round = uint16((long(a) << 16) / 100); if (round > 0x7FFF) diff --git a/engines/cge2/fileio.cpp b/engines/cge2/fileio.cpp index 5885871b29..fc6303bbe2 100644 --- a/engines/cge2/fileio.cpp +++ b/engines/cge2/fileio.cpp @@ -216,14 +216,18 @@ uint32 EncryptedStream::read(byte *dataPtr, uint32 dataSize) { return _readStream->read(dataPtr, dataSize); } -unsigned EncryptedStream::readUnsigned() { +unsigned EncryptedStream::readUint16BE() { return _readStream->readUint16BE(); } -signed EncryptedStream::readSigned() { +signed EncryptedStream::readSint16BE() { return _readStream->readSint16BE(); } +signed EncryptedStream::readSint16LE() { + return _readStream->readSint16LE(); +} + bool EncryptedStream::err() { return (_error & _readStream->err()); } diff --git a/engines/cge2/fileio.h b/engines/cge2/fileio.h index a35b014311..ab5de22d07 100644 --- a/engines/cge2/fileio.h +++ b/engines/cge2/fileio.h @@ -121,8 +121,9 @@ public: int32 pos(); int32 size(); uint32 read(byte *dataPtr, uint32 dataSize); - unsigned readUnsigned(); - signed readSigned(); + unsigned readUint16BE(); + signed readSint16BE(); + signed readSint16LE(); Common::String readLine(); int getLineCount() { return _lineCount; } |