diff options
author | uruk | 2014-05-23 10:05:02 +0200 |
---|---|---|
committer | uruk | 2014-05-23 10:05:02 +0200 |
commit | ba8e801ada1be7dbf7329ca444e20a24f7dca166 (patch) | |
tree | c2fb9e656deefae05876286edeb0ccf05a84fa59 | |
parent | 8a1b90acaf85166200e84f823471fbc497f9711e (diff) | |
download | scummvm-rg350-ba8e801ada1be7dbf7329ca444e20a24f7dca166.tar.gz scummvm-rg350-ba8e801ada1be7dbf7329ca444e20a24f7dca166.tar.bz2 scummvm-rg350-ba8e801ada1be7dbf7329ca444e20a24f7dca166.zip |
CGE2: Implement Sprite::expand().
Add functions:
*Bitmap::moveHi()
*Bitmap::moveLo()
*CGE2Engine::tail()
and warning comments to various places during the process.
Also add _lab data member to CommandHandler::Command.
-rw-r--r-- | engines/cge2/bitmap.cpp | 10 | ||||
-rw-r--r-- | engines/cge2/bitmap.h | 2 | ||||
-rw-r--r-- | engines/cge2/cge2.h | 1 | ||||
-rw-r--r-- | engines/cge2/cge2_main.cpp | 10 | ||||
-rw-r--r-- | engines/cge2/cge2_main.h | 2 | ||||
-rw-r--r-- | engines/cge2/snail.h | 1 | ||||
-rw-r--r-- | engines/cge2/vga13h.cpp | 115 |
7 files changed, 131 insertions, 10 deletions
diff --git a/engines/cge2/bitmap.cpp b/engines/cge2/bitmap.cpp index 4bde584ec8..10fd6f1163 100644 --- a/engines/cge2/bitmap.cpp +++ b/engines/cge2/bitmap.cpp @@ -375,4 +375,14 @@ void Bitmap::xLatPos(V2D& p) { p.y = kWorldHeight - p.y - _h; } +bool Bitmap::moveHi(void) { + warning("STUB: Bitmap::moveHi()"); + return true; +} + +bool Bitmap::moveLo(void) { + warning("STUB: Bitmap::moveLo()"); + return true; +} + } // End of namespace CGE2 diff --git a/engines/cge2/bitmap.h b/engines/cge2/bitmap.h index 7f467903af..07f83b8045 100644 --- a/engines/cge2/bitmap.h +++ b/engines/cge2/bitmap.h @@ -79,6 +79,8 @@ public: void xShow(int16 x, int16 y); bool solidAt(int16 x, int16 y); void xLatPos(V2D& p); + bool moveHi(void); + bool moveLo(void); }; diff --git a/engines/cge2/cge2.h b/engines/cge2/cge2.h index 0a275d5c9d..5e16864cb5 100644 --- a/engines/cge2/cge2.h +++ b/engines/cge2/cge2.h @@ -125,6 +125,7 @@ public: int number(char *s); char *token(char *s); + char *tail(char *s); int takeEnum(const char **tab, const char *text); ID ident(const char *s); bool testBool(char *s); diff --git a/engines/cge2/cge2_main.cpp b/engines/cge2/cge2_main.cpp index 3a4ff180c0..f11965c07d 100644 --- a/engines/cge2/cge2_main.cpp +++ b/engines/cge2/cge2_main.cpp @@ -37,7 +37,7 @@ namespace CGE2 { -int CGE2Engine::number(char *s) { +int CGE2Engine::number(char *s) { // TODO: Rework it later to include the preceding token() call! int r = atoi(s); char *pp = strchr(s, ':'); if (pp) @@ -49,6 +49,12 @@ char *CGE2Engine::token(char *s) { return strtok(s, " =\t,;/()"); } +char *CGE2Engine::tail(char *s) { + if (s && (*s == '=')) + s++; + return s; +} + int CGE2Engine::takeEnum(const char **tab, const char *text) { if (text) { for (const char **e = tab; *e; e++) { @@ -222,7 +228,7 @@ void CGE2Engine::loadSprite(const char *fname, int ref, int scene, V3D &pos) { *p = '\0'; _sprite->_shpCnt = shpcnt; - _sprite->_seqPtr = seqcnt; + _sprite->_seqCnt = seqcnt; for (int i = 0; i < kActions; i++) _sprite->_actionCtrl[i]._cnt = cnt[i]; diff --git a/engines/cge2/cge2_main.h b/engines/cge2/cge2_main.h index 432a6a4b10..1472e2ef7b 100644 --- a/engines/cge2/cge2_main.h +++ b/engines/cge2/cge2_main.h @@ -32,7 +32,7 @@ namespace CGE2 { #define kLineMax 512 #define kIntroExt ".I80" -#define kNoByte -1 +#define kNoByte -1 // Recheck this! We have no proof for it's original value. #define kTabName "CGE.TAB" #define kInfoW 140 #define kPocketFull 170 diff --git a/engines/cge2/snail.h b/engines/cge2/snail.h index 00e0d0912a..a2f4bec028 100644 --- a/engines/cge2/snail.h +++ b/engines/cge2/snail.h @@ -114,6 +114,7 @@ class CommandHandler { public: struct Command { CommandType _commandType; + byte _lab; int _ref; int _val; void *_spritePtr; diff --git a/engines/cge2/vga13h.cpp b/engines/cge2/vga13h.cpp index d11e71f5fc..992d0c0d10 100644 --- a/engines/cge2/vga13h.cpp +++ b/engines/cge2/vga13h.cpp @@ -232,8 +232,6 @@ Sprite *Sprite::expand() { if (!*_file) return this; - char fname[kPathMax]; - Common::Array<BitmapPtr> shplist; for (int i = 0; i < _shpCnt; ++i) shplist.push_back(NULL); @@ -244,6 +242,9 @@ Sprite *Sprite::expand() { maxnow = 0, maxnxt = 0; + char fname[kPathMax]; + _vm->mergeExt(fname, _file, kSprExt); + Seq *seq; if (_seqCnt) { seq = new Seq[_seqCnt]; @@ -265,14 +266,114 @@ Sprite *Sprite::expand() { _ext->_actions[i] = nullptr; } - int section = kIdPhase; - - _vm->mergeExt(fname, _file, kSprExt); if (_vm->_resman->exist(fname)) { // sprite description file exist + EncryptedStream sprf(_vm, fname); + if (sprf.err()) + error("Bad SPR [%s]", fname); + + int label = kNoByte; + ID section = kIdPhase; + ID id; + Common::String line; + char tmpStr[kLineMax + 1]; + + for (line = sprf.readLine(); !sprf.eos(); line = sprf.readLine()){ + int len = line.size(); + Common::strlcpy(tmpStr, line.c_str(), sizeof(tmpStr)); + if (len == 0 || *tmpStr == ';') + continue; + + char *p = _vm->token(tmpStr); + if (*p == '@') { + label = atoi(p + 1); + continue; + } - warning("STUB: Sprite::expand()"); + id = _vm->ident(p); + switch (id) { + case kIdType: + break; + case kIdNear: + case kIdMTake: + case kIdFTake: + case kIdPhase: + case kIdSeq: + section = id; + break; + case kIdName: + Common::strlcpy(tmpStr, line.c_str(), sizeof(tmpStr)); + for (p = tmpStr; *p != '='; p++); // We search for the = + setName(_vm->tail(p)); + break; + default: + if (id >= kIdNear) + break; + Seq *s; + switch (section) { + case kIdNear: + case kIdMTake: + case kIdFTake: + id = (ID)_vm->_commandHandler->com(p); + if (_actionCtrl[section]._cnt) { + CommandHandler::Command *c = &_ext->_actions[section][cnt[section]++]; + c->_commandType = CommandType(id); + c->_lab = label; + if ((p = _vm->token(nullptr)) == NULL) + error("Unexpected end of file! %s", fname); + c->_ref = _vm->number(p); + if ((p = _vm->token(nullptr)) == NULL) + error("Unexpected end of file! %s", fname); + c->_val = _vm->number(p); + c->_spritePtr = nullptr; + } + break; + case kIdSeq: + s = &seq[seqcnt++]; + s->_now = atoi(p); + if (s->_now > maxnow) + maxnow = s->_now; + if ((p = _vm->token(nullptr)) == NULL) + break; + s->_next = _vm->number(p); + switch (s->_next) { + case 0xFF: + s->_next = seqcnt; + break; + case 0xFE: + s->_next = seqcnt - 1; + break; + } + if (s->_next > maxnxt) + maxnxt = s->_next; + if ((p = _vm->token(nullptr)) == NULL) + error("Unexpected end of file! %s", fname); + s->_dx = _vm->number(p); + if ((p = _vm->token(nullptr)) == NULL) + error("Unexpected end of file! %s", fname); + s->_dy = _vm->number(p); + if ((p = _vm->token(nullptr)) == NULL) + error("Unexpected end of file! %s", fname); + s->_dz = _vm->number(p); + if ((p = _vm->token(nullptr)) == NULL) + error("Unexpected end of file! %s", fname); + s->_dly = _vm->number(p); + break; + case kIdPhase: + BitmapPtr bmp = new Bitmap(_vm, p); + shplist[shpcnt] = bmp; + if (!shplist[shpcnt]->moveHi()) + error("No EMS"); + shpcnt++; + break; + } + break; + } + label = kNoByte; + } - } else // no sprite description: try to read immediately from .BMP + if (!shpcnt) + error("No shapes - %s", fname); + } else // no sprite description: try to read immediately from .BMP shplist[shpcnt++] = new Bitmap (_vm, _file); if (seq) { |