aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorStrangerke2011-07-29 10:02:32 +0200
committerStrangerke2011-07-29 10:02:32 +0200
commit316b73ee00091da6f0399bd7b446e859cd9d8c0d (patch)
tree512cd5865a8d726ed947089e8f431607a65d4675 /engines
parent7d5eb1ee639bf04e8f3b2ca280e631c3f67b1e9b (diff)
downloadscummvm-rg350-316b73ee00091da6f0399bd7b446e859cd9d8c0d.tar.gz
scummvm-rg350-316b73ee00091da6f0399bd7b446e859cd9d8c0d.tar.bz2
scummvm-rg350-316b73ee00091da6f0399bd7b446e859cd9d8c0d.zip
CGE: Remove Startup class, set _fx and _sound as dynamic
Diffstat (limited to 'engines')
-rw-r--r--engines/cge/cge.cpp10
-rw-r--r--engines/cge/cge.h2
-rw-r--r--engines/cge/cge_main.cpp54
-rw-r--r--engines/cge/cge_main.h3
-rw-r--r--engines/cge/module.mk1
-rw-r--r--engines/cge/snail.cpp4
-rw-r--r--engines/cge/sound.cpp13
-rw-r--r--engines/cge/sound.h11
-rw-r--r--engines/cge/startup.cpp176
-rw-r--r--engines/cge/startup.h63
10 files changed, 52 insertions, 285 deletions
diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp
index 3c3f14884d..435a552bb4 100644
--- a/engines/cge/cge.cpp
+++ b/engines/cge/cge.cpp
@@ -36,7 +36,6 @@
#include "cge/text.h"
#include "cge/vol.h"
#include "cge/walk.h"
-#include "cge/startup.h"
namespace CGE {
@@ -100,6 +99,9 @@ void CGEEngine::setup() {
_mouse = new Mouse(this);
_keyboard = new Keyboard();
_eventManager = new EventManager();
+ _fx = new Fx(16); // must precede SOUND!!
+ _sound = new Sound(this);
+
_offUseCount = atoi(_text->getText(kOffUseCount));
_music = true;
@@ -134,6 +136,9 @@ void CGEEngine::setup() {
for (int i = 0; i < 4; i++)
_flag[i] = false;
+ _mode = 0;
+ _soundOk = 0;
+
_startGameSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1;
}
@@ -167,6 +172,9 @@ CGEEngine::~CGEEngine() {
delete _pocLight;
delete _keyboard;
delete _mouse;
+ delete _eventManager;
+ delete _fx;
+ delete _sound;
for (int i = 0; i < kPocketNX; i++)
delete _pocket[i];
delete _snail;
diff --git a/engines/cge/cge.h b/engines/cge/cge.h
index 255dadfac6..6d2842c613 100644
--- a/engines/cge/cge.h
+++ b/engines/cge/cge.h
@@ -115,6 +115,8 @@ public:
int _now;
int _lev;
char _usrFnam[15];
+ int _mode;
+ int _soundOk;
Common::RandomSource _randomSource;
byte * _mini;
diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp
index 8681a6314a..855834b489 100644
--- a/engines/cge/cge_main.cpp
+++ b/engines/cge/cge_main.cpp
@@ -35,7 +35,6 @@
#include "graphics/thumbnail.h"
#include "cge/general.h"
#include "cge/sound.h"
-#include "cge/startup.h"
#include "cge/config.h"
#include "cge/vga13h.h"
#include "cge/snail.h"
@@ -51,6 +50,7 @@
#include "cge/cge_main.h"
#include "cge/cge.h"
#include "cge/walk.h"
+#include "cge/sound.h"
namespace CGE {
@@ -81,6 +81,8 @@ InfoLine *_debugLine;
Snail *_snail;
Snail *_snail_;
+Fx *_fx;
+Sound *_sound;
// 0.75 - 17II95 - full sound support
// 0.76 - 18II95 - small MiniEMS in DEMO,
// unhide CavLight in SNLEVEL
@@ -335,7 +337,7 @@ void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteSt
}
} else {
// Loading game
- if (Startup::_soundOk == 1 && Startup::_mode == 0) {
+ if (_soundOk == 1 && _mode == 0) {
// _sndDrvInfo.Vol2._d = _volume[0];
// _sndDrvInfo.Vol2._m = _volume[1];
warning("STUB: CGEEngine::syncGame Digital and Midi volume");
@@ -536,8 +538,8 @@ void CGEEngine::miniStep(int stp) {
_miniCave->_flags._hide = true;
else {
*_miniShp[0] = *_miniShpList[stp];
- if (_fx._current)
- &*(_fx._current->addr());
+ if (_fx->_current)
+ &*(_fx->_current->addr());
_miniCave->_flags._hide = false;
}
@@ -588,10 +590,10 @@ void CGEEngine::caveUp() {
spr = n;
}
- _sound.stop();
- _fx.clear();
- _fx.preload(0);
- _fx.preload(BakRef);
+ _sound->stop();
+ _fx->clear();
+ _fx->preload(0);
+ _fx->preload(BakRef);
if (_hero) {
_hero->gotoxy(_heroXY[_now - 1]._x, _heroXY[_now - 1]._y);
@@ -1465,16 +1467,14 @@ void CGEEngine::tick() {
void CGEEngine::loadUser() {
// set scene
- if (Startup::_mode == 0) {
+ if (_mode == 0) {
// user .SVG file found - load it from slot 0
loadGame(0, NULL);
- } else {
- if (Startup::_mode == 1) {
+ } else if (_mode == 1) {
// Load either initial game state savegame or launcher specified savegame
loadGame(_startGameSlot, NULL);
- } else {
+ } else {
error("Creating setup savegames not supported");
- }
}
loadScript(progName(kIn0Ext));
}
@@ -1647,7 +1647,7 @@ bool CGEEngine::showTitle(const char *name) {
D.center();
D.show(2);
- if (Startup::_mode == 2) {
+ if (_mode == 2) {
inf(SVG0NAME);
_talk->show(2);
}
@@ -1658,7 +1658,7 @@ bool CGEEngine::showTitle(const char *name) {
selectPocket(-1);
_vga->sunrise(Vga::_sysPal);
- if (Startup::_mode < 2 && !Startup::_soundOk) {
+ if (_mode < 2 && !_soundOk) {
_vga->copyPage(1, 2);
_vga->copyPage(0, 1);
_vga->_showQ->append(_mouse);
@@ -1674,12 +1674,12 @@ bool CGEEngine::showTitle(const char *name) {
_heart->_enable = false;
_vga->_showQ->clear();
_vga->copyPage(0, 2);
- Startup::_soundOk = 2;
+ _soundOk = 2;
if (_music)
loadMidi(0);
}
- if (Startup::_mode < 2) {
+ if (_mode < 2) {
if (_isDemo) {
strcpy(_usrFnam, progName(kSvgExt));
usr_ok = true;
@@ -1714,22 +1714,22 @@ bool CGEEngine::showTitle(const char *name) {
#endif
}
- if (usr_ok && Startup::_mode == 0) {
+ if (usr_ok && _mode == 0) {
if (savegameExists(0)) {
// Load the savegame
loadGame(0, NULL, true); // only system vars
_vga->setColors(Vga::_sysPal, 64);
_vga->update();
if (_flag[3]) { //flag FINIS
- Startup::_mode++;
+ _mode++;
_flag[3] = false;
}
} else
- Startup::_mode++;
+ _mode++;
}
}
- if (Startup::_mode < 2)
+ if (_mode < 2)
movie("X01"); // wink
_vga->copyPage(0, 2);
@@ -1737,7 +1737,7 @@ bool CGEEngine::showTitle(const char *name) {
if (_isDemo)
return true;
else
- return (Startup::_mode == 2 || usr_ok);
+ return (_mode == 2 || usr_ok);
}
void CGEEngine::cge_main() {
@@ -1750,28 +1750,28 @@ void CGEEngine::cge_main() {
error("%s", _text->getText(NO_MOUSE_TEXT));
if (!SVG0FILE::exist(SVG0NAME))
- Startup::_mode = 2;
+ _mode = 2;
_debugLine->_flags._hide = true;
_horzLine->_flags._hide = true;
- if (_music && Startup::_soundOk)
+ if (_music && _soundOk)
loadMidi(0);
if (_startGameSlot != -1) {
// Starting up a savegame from the launcher
- Startup::_mode++;
+ _mode++;
runGame();
_startupMode = 2;
if (_flag[3]) // Flag FINIS
movie("X03");
} else {
- if (Startup::_mode < 2)
+ if (_mode < 2)
movie(kLgoExt);
if (showTitle("WELCOME")) {
- if ((!_isDemo) && (Startup::_mode == 1))
+ if ((!_isDemo) && (_mode == 1))
movie("X02"); // intro
runGame();
_startupMode = 2;
diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h
index 8586d84d50..681e756c06 100644
--- a/engines/cge/cge_main.h
+++ b/engines/cge/cge_main.h
@@ -31,6 +31,7 @@
#include "cge/wav.h"
#include "cge/vga13h.h"
#include "cge/events.h"
+#include "cge/sound.h"
namespace CGE {
#define CAVE_X 4
@@ -138,6 +139,8 @@ extern Sprite *_cavLight;
extern InfoLine *_debugLine;
extern Snail *_snail;
extern Snail *_snail_;
+extern Fx *_fx;
+extern Sound *_sound;
} // End of namespace CGE
diff --git a/engines/cge/module.mk b/engines/cge/module.mk
index c1112c7ec2..8829883e26 100644
--- a/engines/cge/module.mk
+++ b/engines/cge/module.mk
@@ -16,7 +16,6 @@ MODULE_OBJS := \
mixer.o \
snail.o \
sound.o \
- startup.o \
talk.o \
text.o \
vga13h.o \
diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp
index 697e70bf8e..d1978ef845 100644
--- a/engines/cge/snail.cpp
+++ b/engines/cge/snail.cpp
@@ -798,9 +798,9 @@ void CGEEngine::snSound(Sprite *spr, int wav, int cnt) {
debugC(1, kCGEDebugEngine, "CGEEngine::snSound(spr, %d, %d)", wav, cnt);
if (wav == -1)
- _sound.stop();
+ _sound->stop();
else
- _sound.play(_fx[wav], (spr) ? ((spr->_x + spr->_w / 2) / (kScrWidth / 16)) : 8, cnt);
+ _sound->play((*_fx)[wav], (spr) ? ((spr->_x + spr->_w / 2) / (kScrWidth / 16)) : 8, cnt);
}
diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp
index 9bf0d59be0..56db1a6482 100644
--- a/engines/cge/sound.cpp
+++ b/engines/cge/sound.cpp
@@ -26,22 +26,17 @@
*/
#include "cge/general.h"
-#include "cge/startup.h"
#include "cge/sound.h"
#include "cge/text.h"
#include "cge/cfile.h"
#include "cge/vol.h"
+#include "cge/cge_main.h"
namespace CGE {
-Fx _fx = 16; // must precede SOUND!!
-Sound _sound;
-
-
-Sound::Sound() {
- if (Startup::_soundOk)
- open();
+Sound::Sound(CGEEngine *vm) : _vm(vm) {
+ open();
}
@@ -58,7 +53,7 @@ void Sound::close() {
void Sound::open() {
sndInit();
- play(_fx[30000], 8);
+ play((*_fx)[30000], 8);
}
diff --git a/engines/cge/sound.h b/engines/cge/sound.h
index 3ca4deaecc..292cb30e76 100644
--- a/engines/cge/sound.h
+++ b/engines/cge/sound.h
@@ -30,18 +30,21 @@
#include "cge/wav.h"
#include "cge/snddrv.h"
+#include "cge/cge.h"
namespace CGE {
class Sound {
public:
SmpInfo _smpinf;
- Sound();
+ Sound(CGEEngine *vm);
~Sound();
void open();
void close();
void play(DataCk *wav, int pan, int cnt = 1);
void stop();
+private:
+ CGEEngine *_vm;
};
@@ -55,17 +58,13 @@ class Fx {
int find(int ref);
public:
DataCk *_current;
- Fx(int size = 16);
+ Fx(int size);
~Fx();
void clear();
void preload(int ref0);
DataCk *operator[](int ref);
};
-extern Sound _sound;
-extern Fx _fx;
-
-
void loadMidi(int ref);
void killMidi();
diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp
deleted file mode 100644
index 5e1c8b8d64..0000000000
--- a/engines/cge/startup.cpp
+++ /dev/null
@@ -1,176 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-/*
- * This code is based on original Soltys source code
- * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
- */
-
-#include "cge/startup.h"
-#include "cge/text.h"
-#include "cge/sound.h"
-#include "cge/cfile.h"
-#include "cge/snddrv.h"
-
-namespace CGE {
-
-extern char _copr[];
-
-#define id (*(Ident*)_copr)
-
-// static Startup _startUp;
-
-int Startup::_mode = 0;
-int Startup::_soundOk = 0;
-
-
-void quitNow(int ref) {
- error("%s", _text->getText(ref));
-}
-
-
-bool Startup::getParms() {
- /*
- 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 (SNDDrvInfo.MDEV != DEV_GM)
- SNDDrvInfo.MDEV = SNDDrvInfo.DDEV;
- return true;
- */
- warning("STUB: Startup::get_parms");
- return true;
-}
-
-
-Startup::Startup() {
- /*
- uint32 m = farcoreleft() >> 10;
- if (m < 0x7FFF)
- Core = (int) m;
- else
- Core = 0x7FFF;
-
- if (! IsVga())
- quit_now(NOT_VGA_TEXT);
- if (Cpu() < _80286)
- quit_now(BAD_CHIP_TEXT);
- if (100 * _osmajor + _osminor < 330)
- quit_now(BAD_DOS_TEXT);
- if (! get_parms())
- quit_now(BAD_ARG_TEXT);
- //--- load sound configuration
- const char * fn = usrPath(ProgName(CFG_EXT));
- if (!Startup::_soundOk && CFILE::Exist(fn)) {
- CFILE cfg(fn, REA);
- if (! cfg.Error) {
- cfg.Read(&SNDDrvInfo, sizeof(SNDDrvInfo)-sizeof(SNDDrvInfo.VOL2));
- if (! cfg.Error)
- Startup::_soundOk = 1;
- }
- }
- */
- warning("STUB: Startup::Startup");
-}
-
-
-const char *usrPath(const char *nam) {
- static char buf[kPathMax] = ".\\", *p = buf + 2;
-#if defined(CD)
- if (DriveCD(0)) {
- bool ok = false;
- CFILE ini = Text[CDINI_FNAME];
- if (!ini.Error) {
- char *key = Text[GAME_ID];
- int i = strlen(key);
- while (ini.Read(buf) && !ok) {
- int j = strlen(buf);
- if (j)
- if (buf[--j] == '\n')
- buf[j] = '\0';
- if (scumm_strnicmp((const char *) buf, (const char*) key, i) == 0)
- ok = true;
- }
- if (ok) {
- strcpy(buf, buf + i);
- p = buf + strlen(buf);
- if (*(p - 1) != '\\')
- *(p++) = '\\';
- strcpy(p, "NUL");
- if (_dos_open(buf, 0, &i) == 0)
- _dos_close(i);
- else
- ok = false;
- }
- }
- if (!ok)
- quit_now(BADCD_TEXT);
- }
-#endif
- strcpy(p, nam);
- return buf;
-}
-
-} // End of namespace CGE
diff --git a/engines/cge/startup.h b/engines/cge/startup.h
deleted file mode 100644
index 8a8305040c..0000000000
--- a/engines/cge/startup.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-/*
- * This code is based on original Soltys source code
- * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
- */
-
-#ifndef __CGE_STARTUP__
-#define __CGE_STARTUP__
-
-
-#include "cge/general.h"
-
-namespace CGE {
-
-#define GAME_ID 45
-#define CDINI_FNAME 46
-
-#define NOT_VGA_TEXT 90
-#define BAD_CHIP_TEXT 91
-#define BAD_DOS_TEXT 92
-#define NO_CORE_TEXT 93
-#define BAD_MIPS_TEXT 94
-#define NO_MOUSE_TEXT 95
-#define BAD_ARG_TEXT 96
-#define BADCD_TEXT 97
-
-#define CFG_EXT ".CFG"
-
-class Startup {
- static bool getParms();
- Startup();
-public:
- static int _mode;
- static int _soundOk;
-};
-
-
-const char *usrPath(const char *nam);
-
-} // End of namespace CGE
-
-#endif