diff options
author | Strangerke | 2011-07-07 08:11:29 +0200 |
---|---|---|
committer | Alyssa Milburn | 2011-07-07 09:24:08 +0200 |
commit | affaa1f4d6cf5f27f654029133b1aec7b9eca4b5 (patch) | |
tree | 4b33e8e914164310e7ee88450f81c861686899e7 /engines | |
parent | c86c62b288dd3c8a1a630864142f99b177e4db3a (diff) | |
download | scummvm-rg350-affaa1f4d6cf5f27f654029133b1aec7b9eca4b5.tar.gz scummvm-rg350-affaa1f4d6cf5f27f654029133b1aec7b9eca4b5.tar.bz2 scummvm-rg350-affaa1f4d6cf5f27f654029133b1aec7b9eca4b5.zip |
CGE: Some cleanup: Move some static functions to CGEEngine, remove parameters to GetText, rename members of SavTab
Diffstat (limited to 'engines')
-rw-r--r-- | engines/cge/cge.cpp | 102 | ||||
-rw-r--r-- | engines/cge/cge.h | 23 | ||||
-rw-r--r-- | engines/cge/cge_main.cpp | 109 | ||||
-rw-r--r-- | engines/cge/general.cpp | 9 | ||||
-rw-r--r-- | engines/cge/gettext.cpp | 7 | ||||
-rw-r--r-- | engines/cge/gettext.h | 3 | ||||
-rw-r--r-- | engines/cge/startup.cpp | 107 |
7 files changed, 187 insertions, 173 deletions
diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp index 067b9eb6e9..b953f2f5b0 100644 --- a/engines/cge/cge.cpp +++ b/engines/cge/cge.cpp @@ -117,56 +117,56 @@ void CGEEngine::setup() { _volume[0] = 0; _volume[1] = 0; - _savTab[0].Ptr = &_now; - _savTab[0].Len = sizeof(_now); - _savTab[0].Flg = 1; - _savTab[1].Ptr = &_oldLev; - _savTab[1].Len = sizeof(_oldLev); - _savTab[1].Flg = 1; - _savTab[2].Ptr = &_demoText; - _savTab[2].Len = sizeof(_demoText); - _savTab[2].Flg = 1; - _savTab[3].Ptr = &_game; - _savTab[3].Len = sizeof(_game); - _savTab[3].Flg = 1; - _savTab[4].Ptr = &_game; - _savTab[4].Len = sizeof(_game); - _savTab[4].Flg = 1; - _savTab[5].Ptr = &_game; - _savTab[5].Len = sizeof(_game); - _savTab[5].Flg = 1; - _savTab[6].Ptr = &_game; - _savTab[6].Len = sizeof(_game); - _savTab[6].Flg = 1; - _savTab[7].Ptr = &_game; - _savTab[7].Len = sizeof(_game); - _savTab[7].Flg = 1; - _savTab[8].Ptr = &_vga->_mono; - _savTab[8].Len = sizeof(_vga->_mono); - _savTab[8].Flg = 0; - _savTab[9].Ptr = &_music; - _savTab[9].Len = sizeof(_music); - _savTab[9].Flg = 1; - _savTab[10].Ptr = _volume; - _savTab[10].Len = sizeof(_volume); - _savTab[10].Flg = 1; - _savTab[11].Ptr = _flag; - _savTab[11].Len = sizeof(_flag); - _savTab[11].Flg = 1; - _savTab[12].Ptr = _heroXY; -// _savTab[12].Len = sizeof(_heroXY); FIXME: illegal sizeof - _savTab[12].Len = 0; - _savTab[12].Flg = 1; - _savTab[13].Ptr = _barriers; -// _savTab[13].Len = sizeof(_barriers); FIXME: illegal sizeof - _savTab[13].Len = 0; - _savTab[13].Flg = 1; - _savTab[14].Ptr = _pocref; - _savTab[14].Len = sizeof(_pocref); - _savTab[14].Flg = 1; - _savTab[15].Ptr = NULL; - _savTab[15].Len = 0; - _savTab[15].Flg = 0; + _savTab[0]._ptr = &_now; + _savTab[0]._len = sizeof(_now); + _savTab[0]._flag = true; + _savTab[1]._ptr = &_oldLev; + _savTab[1]._len = sizeof(_oldLev); + _savTab[1]._flag = true; + _savTab[2]._ptr = &_demoText; + _savTab[2]._len = sizeof(_demoText); + _savTab[2]._flag = true; + _savTab[3]._ptr = &_game; + _savTab[3]._len = sizeof(_game); + _savTab[3]._flag = true; + _savTab[4]._ptr = &_game; + _savTab[4]._len = sizeof(_game); + _savTab[4]._flag = true; + _savTab[5]._ptr = &_game; + _savTab[5]._len = sizeof(_game); + _savTab[5]._flag = true; + _savTab[6]._ptr = &_game; + _savTab[6]._len = sizeof(_game); + _savTab[6]._flag = true; + _savTab[7]._ptr = &_game; + _savTab[7]._len = sizeof(_game); + _savTab[7]._flag = true; + _savTab[8]._ptr = &_vga->_mono; + _savTab[8]._len = sizeof(_vga->_mono); + _savTab[8]._flag = false; + _savTab[9]._ptr = &_music; + _savTab[9]._len = sizeof(_music); + _savTab[9]._flag = true; + _savTab[10]._ptr = _volume; + _savTab[10]._len = sizeof(_volume); + _savTab[10]._flag = true; + _savTab[11]._ptr = _flag; + _savTab[11]._len = sizeof(_flag); + _savTab[11]._flag = true; + _savTab[12]._ptr = _heroXY; +// _savTab[12]._len = sizeof(_heroXY); FIXME: illegal sizeof + _savTab[12]._len = 0; + _savTab[12]._flag = true; + _savTab[13]._ptr = _barriers; +// _savTab[13]._len = sizeof(_barriers); FIXME: illegal sizeof + _savTab[13]._len = 0; + _savTab[13]._flag = true; + _savTab[14]._ptr = _pocref; + _savTab[14]._len = sizeof(_pocref); + _savTab[14]._flag = true; + _savTab[15]._ptr = NULL; + _savTab[15]._len = 0; + _savTab[15]._flag = false; if (_isDemo) { _maxCaveArr[0] = CAVE_MAX; @@ -187,6 +187,8 @@ void CGEEngine::setup() { _now = 1; _lev = -1; + for (int i = 0; i < 4; i++) + _flag[i] = false; } diff --git a/engines/cge/cge.h b/engines/cge/cge.h index e4b8ef86c1..4f6b452850 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -49,9 +49,9 @@ enum SNLIST { NEAR, TAKE }; #define POCKET_NX 8 struct SavTab { - void *Ptr; - int Len; - uint8 Flg; + void *_ptr; + int32 _len; + bool _flag; }; class CGEEngine : public Engine { @@ -124,7 +124,7 @@ public: void setIRQ(); void setDMA(); void mainLoop(); - void SaveGame(XFile &file); + void saveGame(XFile &file); void switchMusic(); void selectPocket(int n); void expandSprite(Sprite *spr); @@ -135,6 +135,21 @@ public: void hide1(Sprite *spr); void loadMapping(); void saveMapping(); + void saveSound(); + void heroCover(int cvr); + void trouble(int seq, int txt); + void offUse(); + void tooFar(); + void noWay(); + void loadHeroXY(); + void keyClick(); + void switchColorMode(); + void killSprite(); + void pushSprite(); + void pullSprite(); + void sayDebug(); + void nextStep(); + void switchDebug(); void snBackPt(Sprite *spr, int stp); void snBarrier(int cav, int bar, bool horz); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 456a11092e..e7ca76a98f 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -247,14 +247,14 @@ void CGEEngine::loadGame(XFile &file, bool tiny = false) { } -static void SaveSound() { +void CGEEngine::saveSound() { CFile cfg(usrPath(progName(CFG_EXT)), WRI); if (!cfg._error) cfg.write(&_sndDrvInfo, sizeof(_sndDrvInfo) - sizeof(_sndDrvInfo.Vol2)); } -void CGEEngine::SaveGame(XFile &file) { +void CGEEngine::saveGame(XFile &file) { SavTab *st; Sprite *spr; int i; @@ -267,10 +267,10 @@ void CGEEngine::SaveGame(XFile &file) { _volume[0] = _sndDrvInfo.Vol2._d; _volume[1] = _sndDrvInfo.Vol2._m; - for (st = _savTab; st->Ptr; st++) { + for (st = _savTab; st->_ptr; st++) { if (file._error) error("Bad SVG"); - file.write((uint8 *) st->Ptr, st->Len); + file.write((uint8 *) st->_ptr, st->_len); } file.write((uint8 *) & (i = SVGCHKSUM), sizeof(i)); @@ -281,13 +281,11 @@ void CGEEngine::SaveGame(XFile &file) { file.write((uint8 *)spr, sizeof(*spr)); } - -static void HeroCover(int cvr) { +void CGEEngine::heroCover(int cvr) { SNPOST(SNCOVER, 1, cvr, NULL); } - -static void trouble(int seq, int txt) { +void CGEEngine::trouble(int seq, int txt) { _hero->park(); SNPOST(SNWAIT, -1, -1, _hero); SNPOST(SNSEQ, -1, seq, _hero); @@ -296,31 +294,27 @@ static void trouble(int seq, int txt) { SNPOST(SNSAY, 1, txt, _hero); } - -static void offUse() { +void CGEEngine::offUse() { trouble(OFF_USE, OFF_USE_TEXT + new_random(_offUseCount)); } - -static void tooFar() { +void CGEEngine::tooFar() { trouble(TOO_FAR, TOO_FAR_TEXT); } - // Used in stubbed function, do not remove! -static void noWay() { +void CGEEngine::noWay() { trouble(NO_WAY, NO_WAY_TEXT); } -static void loadHeroXY() { +void CGEEngine::loadHeroXY() { INI_FILE cf(progName(".HXY")); memset(_heroXY, 0, sizeof(_heroXY)); if (!cf._error) cf.CFREAD(&_heroXY); } - void CGEEngine::loadMapping() { if (_now <= CAVE_MAX) { INI_FILE cf(progName(".TAB")); @@ -536,21 +530,19 @@ void CGEEngine::setMapBrick(int x, int z) { } } -static void SwitchColorMode(); -static void switchDebug(); -static void KillSprite(); -static void PushSprite(); -static void PullSprite(); -static void NextStep(); +//static void switchColorMode(); +//static void switchDebug(); +//static void pullSprite(); +//static void NextStep(); -static void KeyClick() { +void CGEEngine::keyClick() { SNPOST_(SNSOUND, -1, 5, NULL); } void CGEEngine::resetQSwitch() { SNPOST_(SNSEQ, 123, 0, NULL); - KeyClick(); + keyClick(); } @@ -570,7 +562,7 @@ void CGEEngine::quit() { QuitMenu[1]._text = _text->getText(NOQUIT_TEXT); (new Vmenu(this, QuitMenu, -1, -1))->setName(_text->getText(QUIT_TITLE)); SNPOST_(SNSEQ, 123, 1, NULL); - KeyClick(); + keyClick(); } } } @@ -723,9 +715,9 @@ void CGEEngine::xCave() { void CGEEngine::qGame() { caveDown(); _oldLev = _lev; - SaveSound(); + saveSound(); CFile file = CFile(usrPath(_usrFnam), WRI, RCrypt); - SaveGame(file); + saveGame(file); _vga->sunset(); _finis = true; } @@ -754,7 +746,7 @@ void CGEEngine::switchCave(int cav) { CAVE_Y + ((_now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY); killText(); if (!_startupMode) - KeyClick(); + keyClick(); SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint //TODO Change the SNPOST message send to a special way to send function pointer //SNPOST(SNEXEC, 0, 0, (void *)&XCave); // switch cave @@ -776,7 +768,7 @@ void System::touch(uint16 mask, int x, int y) { if (mask & KEYB) { int pp0; - KeyClick(); + _vm->keyClick(); killText(); if (_vm->_startupMode == 1) { SNPOST(SNCLEAR, -1, 0, NULL); @@ -788,7 +780,7 @@ void System::touch(uint16 mask, int x, int y) { if (_keyboard->_key[ALT] && _keyboard->_key[CTRL]) AltCtrlDel(); else - KillSprite(); + _vm->killSprite(); break; case 'F': if (_keyboard->_key[ALT]) { @@ -800,13 +792,13 @@ void System::touch(uint16 mask, int x, int y) { } break; case PgUp: - PushSprite(); + _vm->pushSprite(); break; case PgDn: - PullSprite(); + _vm->pullSprite(); break; case '+': - NextStep(); + _vm->nextStep(); break; case '`': if (_keyboard->_key[ALT]) @@ -815,7 +807,7 @@ void System::touch(uint16 mask, int x, int y) { _vm->switchMapping(); break; case F1: - switchDebug(); + _vm->switchDebug(); break; case F3: _hero->step(TSEQ + 4); @@ -933,19 +925,19 @@ void System::tick() { killText(); if (_snail->idle()) { if (PAIN) - HeroCover(9); + _vm->heroCover(9); else if (Startup::_core >= CORE_MID) { int n = new_random(100); if (n > 96) - HeroCover(6 + (_hero->_x + _hero->_w / 2 < SCR_WID / 2)); + _vm->heroCover(6 + (_hero->_x + _hero->_w / 2 < SCR_WID / 2)); else { if (n > 90) - HeroCover(5); + _vm->heroCover(5); else { if (n > 60) - HeroCover(4); + _vm->heroCover(4); else - HeroCover(3); + _vm->heroCover(3); } } } @@ -975,9 +967,9 @@ static void SpkClose() { */ -static void SwitchColorMode() { +void CGEEngine::switchColorMode() { SNPOST_(SNSEQ, 121, _vga->_mono = !_vga->_mono, NULL); - KeyClick(); + keyClick(); _vga->setColors(Vga::_sysPal, 64); } @@ -998,7 +990,7 @@ void CGEEngine::switchMusic() { SNPOST(SNINF, -1, NOMUSIC_TEXT, NULL); else { SNPOST_(SNSEQ, 122, (_music = !_music), NULL); - KeyClick(); + keyClick(); } } if (_music) @@ -1018,7 +1010,7 @@ void CGEEngine::takeName() { if (GetText::_ptr) SNPOST_(SNKILL, -1, 0, GetText::_ptr); else { - GetText *tn = new GetText(this, _text->getText(GETNAME_PROMPT), _usrFnam, 8, KeyClick); + GetText *tn = new GetText(this, _text->getText(GETNAME_PROMPT), _usrFnam, 8); if (tn) { tn->setName(_text->getText(GETNAME_TITLE)); tn->center(); @@ -1049,16 +1041,14 @@ void CGEEngine::switchMapping() { _horzLine->_flags._hide = !_horzLine->_flags._hide; } - -static void KillSprite() { +void CGEEngine::killSprite() { _sprite->_flags._kill = true; _sprite->_flags._bDel = true; SNPOST_(SNKILL, -1, 0, _sprite); _sprite = NULL; } - -static void PushSprite() { +void CGEEngine::pushSprite() { Sprite *spr = _sprite->_prev; if (spr) { _vga->_showQ->insert(_vga->_showQ->remove(_sprite), spr); @@ -1068,8 +1058,7 @@ static void PushSprite() { SNPOST_(SNSOUND, -1, 2, NULL); } - -static void PullSprite() { +void CGEEngine::pullSprite() { bool ok = false; Sprite *spr = _sprite->_next; if (spr) { @@ -1086,12 +1075,10 @@ static void PullSprite() { SNPOST_(SNSOUND, -1, 2, NULL); } - -static void NextStep() { +void CGEEngine::nextStep() { SNPOST_(SNSTEP, 0, 0, _sprite); } - void CGEEngine::saveMapping() { { IoHand cf(progName(".TAB"), UPD); @@ -1131,7 +1118,7 @@ static char DebugText[] = " N=00000 F=000000 X=000 Y=000 FPS=0000\0S=00:00 0 #define SP_F (DebugText + 67) #define SP__ (DebugText + 70) -static void sayDebug() { +void CGEEngine::sayDebug() { if (!_debugLine->_flags._hide) { static long t = -1L; long t1 = timer(); @@ -1172,7 +1159,7 @@ static void sayDebug() { } -static void switchDebug() { +void CGEEngine::switchDebug() { _debugLine->_flags._hide = !_debugLine->_flags._hide; } @@ -1181,7 +1168,7 @@ void CGEEngine::optionTouch(int opt, uint16 mask) { switch (opt) { case 1 : if (mask & L_UP) - SwitchColorMode(); + switchColorMode(); break; case 2 : if (mask & L_UP) @@ -1224,10 +1211,10 @@ void Sprite::touch(uint16 mask, int x, int y) { if (works(ps)) { _vm->feedSnail(ps, TAKE); } else - offUse(); + _vm->offUse(); _vm->selectPocket(-1); } else - tooFar(); + _vm->tooFar(); } else { if (_flags._kept) mask |= L_UP; @@ -1245,15 +1232,15 @@ void Sprite::touch(uint16 mask, int x, int y) { } else { if (_takePtr != NO_PTR) { if (snList(TAKE)[_takePtr]._com == SNNEXT) - offUse(); + _vm->offUse(); else _vm->feedSnail(this, TAKE); } else - offUse(); + _vm->offUse(); } }/// else - tooFar(); + _vm->tooFar(); } } } @@ -1548,7 +1535,7 @@ void CGEEngine::loadUser() { loadScript(progName(INI_EXT)); _music = true; CFile file = CFile(SVG0NAME, WRI); - SaveGame(file); + saveGame(file); error("Ok [%s]", SVG0NAME); } } diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 8464d020e5..6ed6884aba 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -109,11 +109,6 @@ const char *progName(const char *ext) { } char *mergeExt(char *buf, const char *nam, const char *ext) { -// char dr[MAXDRIVE], di[MAXDIR], na[MAXFILE], ex[MAXEXT]; -// fnmerge(buf, dr, di, na, (fnsplit(nam, dr, di, na, ex) & EXTENSION) ? ex : ext); -// return buf; - warning("mergeExt"); - strcpy(buf, nam); char *dot = strrchr(buf, '.'); if (!dot) @@ -123,10 +118,6 @@ char *mergeExt(char *buf, const char *nam, const char *ext) { } char *forceExt(char *buf, const char *nam, const char *ext) { -// char dr[MAXDRIVE], di[MAXDIR], na[MAXFILE], ex[MAXEXT]; -// fnsplit(nam, dr, di, na, ex); -// fnmerge(buf, dr, di, na, ext); -// return buf; strcpy(buf, nam); char *dot = strrchr(buf, '.'); if (dot) diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index 508175ccd5..2ee6dc42eb 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -34,9 +34,9 @@ namespace CGE { GetText *GetText::_ptr = NULL; -GetText::GetText(CGEEngine *vm, const char *info, char *text, int size, void (*click)()) +GetText::GetText(CGEEngine *vm, const char *info, char *text, int size) : Talk(vm), _text(text), _size(min<int>(size, GTMAX)), _len(min<int>(_size, strlen(text))), - _cntr(GTBLINK), _click(click), _oldKeybClient(_keyboard->setClient(this)), _vm(vm) { + _cntr(GTBLINK), _oldKeybClient(_keyboard->setClient(this)), _vm(vm) { int i = 2 * TEXT_HM + _font->width(info); _ptr = this; _mode = RECT; @@ -74,8 +74,7 @@ void GetText::touch(uint16 mask, int x, int y) { char *p; if (mask & KEYB) { - if (_click) - _click(); + _vm->keyClick(); switch (x) { case Enter : _buff[_len] = '\0'; diff --git a/engines/cge/gettext.h b/engines/cge/gettext.h index d29d11abb7..188e90c776 100644 --- a/engines/cge/gettext.h +++ b/engines/cge/gettext.h @@ -44,11 +44,10 @@ class GetText : public Talk { uint16 _len; uint16 _cntr; Sprite *_oldKeybClient; - void (*_click)(); public: static GetText *_ptr; - GetText(CGEEngine *vm, const char *info, char *text, int size, void (*click)(void) = NULL); + GetText(CGEEngine *vm, const char *info, char *text, int size); ~GetText(); void touch(uint16 mask, int x, int y); void tick(); diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp index 6a06cbc537..9210b40c77 100644 --- a/engines/cge/startup.cpp +++ b/engines/cge/startup.cpp @@ -57,49 +57,70 @@ bool Startup::getParms() { _summa = 0; /* - int i = _argc; - while (i > 1) - { - static char *PrmTab[] = { "NEW", "MK0SVG", "QUIET", "SB", "GUS", "MIDI", - "P", "D", "I", "M" }; - int n = takeEnum(PrmTab, strtok(_argv[--i], " =:(")); - uint16 p = xtow(strtok(NULL, " h,)")); - switch (n) - { - case 0 : if (Mode != 2) Mode = 1; break; - case 1 : Mode = 2; break; - case 2 : SNDDrvInfo.DDEV = DEV_QUIET; break; - case 3 : SNDDrvInfo.DDEV = DEV_SB; break; - case 4 : SNDDrvInfo.DDEV = DEV_GUS; break; - case 5 : SNDDrvInfo.MDEV = DEV_GM; break; - case 6 : SNDDrvInfo.DBASE = p; break; - case 7 : SNDDrvInfo.DDMA = p; break; - case 8 : SNDDrvInfo.DIRQ = p; break; - case 9 : SNDDrvInfo.MBASE = p; - SNDDrvInfo.MDEV = DEV_GM; break; - default: return false; - } - if (n >= 2) SoundOk = 2; - } - #ifdef DEMO - // protection disabled - Summa = 0; - #else - #ifdef EVA - { - union { dosdate_t d; uint32 n; } today; - _dos_getdate(&today.d); - id.disk += (id.disk < today.n); - } - #endif - #ifdef CD - Summa = 0; - #else - // disk signature checksum - Summa = ChkSum(Copr, sizeof(Ident)); - #endif - #endif - if (SNDDrvInfo.MDEV != DEV_GM) SNDDrvInfo.MDEV = SNDDrvInfo.DDEV; + int i = _argc; + while (i > 1) { + static char *PrmTab[] = { "NEW", "MK0SVG", "QUIET", "SB", "GUS", "MIDI", "P", "D", "I", "M" }; + int n = takeEnum(PrmTab, strtok(_argv[--i], " =:(")); + uint16 p = xtow(strtok(NULL, " h,)")); + switch (n) { + case 0 : + if (Mode != 2) + Mode = 1; + break; + case 1 : + Mode = 2; + break; + case 2 : + SNDDrvInfo.DDEV = DEV_QUIET; + break; + case 3 : + SNDDrvInfo.DDEV = DEV_SB; + break; + case 4 : + SNDDrvInfo.DDEV = DEV_GUS; + break; + case 5 : + SNDDrvInfo.MDEV = DEV_GM; + break; + case 6 : + SNDDrvInfo.DBASE = p; + break; + case 7 : + SNDDrvInfo.DDMA = p; + break; + case 8 : + SNDDrvInfo.DIRQ = p; + break; + case 9 : + SNDDrvInfo.MBASE = p; + SNDDrvInfo.MDEV = DEV_GM; + break; + default: + return false; + } + + if (n >= 2) + SoundOk = 2; + } + if (_vm->_isDemo) + // protection disabled + Summa = 0; + else { +#ifdef EVA + union { dosdate_t d; uint32 n; } today; + _dos_getdate(&today.d); + id.disk += (id.disk < today.n); +#endif +#ifdef CD + Summa = 0; +#else + // disk signature checksum + Summa = ChkSum(Copr, sizeof(Ident)); +#endif + } + + if (SNDDrvInfo.MDEV != DEV_GM) + SNDDrvInfo.MDEV = SNDDrvInfo.DDEV; return true; */ warning("STUB: Startup::get_parms"); |