aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorStrangerke2011-07-04 08:15:56 +0200
committerStrangerke2011-07-04 08:15:56 +0200
commitfae1d7efd885eae98ee9b0c8ae9bc99612942430 (patch)
treeef5db813d0e1b3a49b1a1e395236e121a58ed125 /engines
parentc313d2cce8d647265f192400c667d72824874dbc (diff)
downloadscummvm-rg350-fae1d7efd885eae98ee9b0c8ae9bc99612942430.tar.gz
scummvm-rg350-fae1d7efd885eae98ee9b0c8ae9bc99612942430.tar.bz2
scummvm-rg350-fae1d7efd885eae98ee9b0c8ae9bc99612942430.zip
CGE: This ends the first renaming pass. Also move some functions to CGEEngine
Diffstat (limited to 'engines')
-rw-r--r--engines/cge/cge.cpp66
-rw-r--r--engines/cge/cge.h28
-rw-r--r--engines/cge/cge_main.cpp148
-rw-r--r--engines/cge/cge_main.h17
-rw-r--r--engines/cge/config.cpp10
-rw-r--r--engines/cge/ems.cpp24
-rw-r--r--engines/cge/events.cpp2
-rw-r--r--engines/cge/general.cpp8
-rw-r--r--engines/cge/general.h26
-rw-r--r--engines/cge/snail.cpp27
-rw-r--r--engines/cge/snail.h3
-rw-r--r--engines/cge/sound.cpp129
-rw-r--r--engines/cge/sound.h56
-rw-r--r--engines/cge/startup.cpp2
-rw-r--r--engines/cge/startup.h2
-rw-r--r--engines/cge/vol.cpp14
-rw-r--r--engines/cge/vol.h20
-rw-r--r--engines/cge/wav.h125
18 files changed, 375 insertions, 332 deletions
diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp
index 0487441517..87c3964563 100644
--- a/engines/cge/cge.cpp
+++ b/engines/cge/cge.cpp
@@ -46,7 +46,12 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription)
// Debug/console setup
DebugMan.addDebugChannel(kCGEDebug, "general", "CGE general debug channel");
- _isDemo = _gameDescription->flags & ADGF_DEMO;
+ _isDemo = _gameDescription->flags & ADGF_DEMO;
+ _startupMode = 1;
+ _demoText = DEMO_TEXT;
+ _oldLev = 0;
+ _jbw = false;
+ _pocPtr = 0;
}
@@ -68,7 +73,7 @@ void CGEEngine::setup() {
_vga = new Vga(M13H);
_heart = new Heart;
_hero = new WALK(this, NULL);
- _sys = new SYSTEM(this);
+ _sys = new System(this);
_pocLight = new Sprite(this, LI);
for (int i = 0; i < POCKET_NX; i++)
_pocket[i] = new Sprite(this, NULL);
@@ -103,6 +108,63 @@ void CGEEngine::setup() {
_keyboard = new Keyboard();
_eventManager = new EventManager();
_offUseCount = atoi(_text->getText(OFF_USE_COUNT));
+ _music = true;
+
+ for (int i = 0; i < POCKET_NX; i++)
+ _pocref[i] = -1;
+ _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;
}
CGEEngine::~CGEEngine() {
diff --git a/engines/cge/cge.h b/engines/cge/cge.h
index ba6326726a..04f395559f 100644
--- a/engines/cge/cge.h
+++ b/engines/cge/cge.h
@@ -36,12 +36,21 @@
namespace CGE {
class Console;
+class Sprite;
// our engine debug channels
enum {
kCGEDebug = 1 << 0
};
+#define POCKET_NX 8
+
+struct SavTab {
+ void *Ptr;
+ int Len;
+ uint8 Flg;
+};
+
class CGEEngine : public Engine {
private:
uint32 _lastFrame;
@@ -50,8 +59,17 @@ public:
CGEEngine(OSystem *syst, const ADGameDescription *gameDescription);
~CGEEngine();
- const ADGameDescription *_gameDescription;
- bool _isDemo;
+ const ADGameDescription *_gameDescription;
+ bool _isDemo;
+ int _startupMode;
+ int _demoText;
+ int _oldLev;
+ bool _jbw;
+ int _pocPtr;
+ SavTab _savTab[16];
+ bool _music;
+ int _pocref[POCKET_NX];
+ uint8 _volume[2];
virtual Common::Error run();
GUI::Debugger *getDebugger() {
@@ -81,6 +99,7 @@ public:
void NONE();
void SB();
void caveDown();
+ void caveUp();
void xCave();
void qGame();
void SBM();
@@ -93,6 +112,11 @@ public:
void setIRQ();
void setDMA();
void mainLoop();
+ void SaveGame(XFile &file);
+ void switchMusic();
+ void selectPocket(int n);
+ void SNKeep(Sprite *spr, int stp);
+ void SNGive(Sprite *spr, int stp);
private:
CGEConsole *_console;
diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp
index 2caa9e0a98..6b02f82910 100644
--- a/engines/cge/cge_main.cpp
+++ b/engines/cge/cge_main.cpp
@@ -58,7 +58,7 @@ uint16 _stklen = (STACK_SIZ * 2);
Vga *_vga;
Heart *_heart;
WALK *_hero;
-SYSTEM *_sys;
+System *_sys;
Sprite *_pocLight;
EventManager *_eventManager;
Keyboard *_keyboard;
@@ -91,21 +91,14 @@ Snail *_snail_;
// coditionals EVA for 2-month evaluation version
static char _usrFnam[15] = "\0ɱ%^þúȼ´ ÇÉ";
-static int _oldLev = 0;
-static int _demoText = DEMO_TEXT;
//--------------------------------------------------------------------------
-bool _jbw = false;
-
-//-------------------------------------------------------------------------
-int _pocPtr = 0;
-
-static EMS *_mini = _miniEmm.alloc((uint16)MINI_EMM_SIZE);
+static Ems *_mini = _miniEmm.alloc((uint16)MINI_EMM_SIZE);
static BMP_PTR *_miniShpList = NULL;
static BMP_PTR _miniShp[] = { NULL, NULL };
static bool _finis = false;
-static int _startup = 1;
+//static int _startup = 1;
int _offUseCount;
uint16 *_intStackPtr = false;
@@ -115,11 +108,11 @@ Bar _barriers[1 + CAVE_MAX] = { { 0xFF, 0xFF } };
extern int findPocket(Sprite *);
extern Dac _stdPal[58];
-void feedSnail(Sprite *spr, SNLIST snq); // defined in SNAIL
-uint8 Cluster::_map[MAP_ZCNT][MAP_XCNT];
+void feedSnail(Sprite *spr, SNLIST snq); // defined in SNAIL
+uint8 Cluster::_map[MAP_ZCNT][MAP_XCNT];
-uint8 &Cluster::cell() {
+uint8 &Cluster::cell() {
return _map[_b][_a];
}
@@ -184,36 +177,6 @@ Cluster XZ(Couple xy) {
return XZ(x, y);
}
-
-int _pocref[POCKET_NX];
-uint8 _volume[2];
-
-struct SavTab {
- void *Ptr;
- int Len;
- uint8 Flg;
-};
-
-SavTab _savTab[] = {
- { &_now, sizeof(_now), 1 },
- { &_oldLev, sizeof(_oldLev), 1 },
- { &_demoText, sizeof(_demoText), 1 },
- { &_game, sizeof(_game), 1 },
- { &_game, sizeof(_game), 1 }, // spare 1
- { &_game, sizeof(_game), 1 }, // spare 2
- { &_game, sizeof(_game), 1 }, // spare 3
- { &_game, sizeof(_game), 1 }, // spare 4
-// { &VGA::Mono, sizeof(VGA::Mono), 0 },
- { &_music, sizeof(_music), 1 },
- { _volume, sizeof(_volume), 1 },
- { _flag, sizeof(_flag), 1 },
- { _heroXY, sizeof(_heroXY), 1 },
- { _barriers, sizeof(_barriers), 1 },
- { _pocref, sizeof(_pocref), 1 },
- { NULL, 0, 0 }
-};
-
-
void CGEEngine::loadGame(XFile &file, bool tiny = false) {
SavTab *st;
Sprite *spr;
@@ -270,7 +233,7 @@ static void SaveSound(void) {
}
-static void SaveGame(XFile &file) {
+void CGEEngine::SaveGame(XFile &file) {
SavTab *st;
Sprite *spr;
int i;
@@ -366,7 +329,7 @@ void WALK::tick() {
if (Dir != NO_DIR) {
Sprite *spr;
- _sys->FunTouch();
+ _sys->funTouch();
for (spr = _vga->_showQ->first(); spr; spr = spr->_next) {
if (distance(spr) < 2) {
if (!spr->_flags._near) {
@@ -554,7 +517,6 @@ void CGEEngine::setMapBrick(int x, int z) {
static void SwitchColorMode(void);
static void switchDebug();
-static void SwitchMusic(void);
static void KillSprite(void);
static void PushSprite(void);
static void PullSprite(void);
@@ -605,22 +567,22 @@ static void miniStep(int stp) {
else {
&*_mini;
*_miniShp[0] = *_miniShpList[stp];
- if (_fx.Current)
- &*(_fx.Current->EAddr());
+ if (_fx._current)
+ &*(_fx._current->eAddr());
_miniCave->_flags._hide = false;
}
}
-static void PostMiniStep(int stp) {
+static void postMiniStep(int stp) {
//static int recent = -2;
//TODO Change the SNPOST message send to a special way to send function pointer
//if (MiniCave && stp != recent) SNPOST_(SNEXEC, -1, recent = stp, (void *)&MiniStep);
warning("STUB: PostMiniStep()");
}
-void SYSTEM::SetPal(void) {
+void System::setPal() {
uint i;
Dac *p = Vga::_sysPal + 256 - ArrayCount(_stdPal);
for (i = 0; i < ArrayCount(_stdPal); i++) {
@@ -631,10 +593,10 @@ void SYSTEM::SetPal(void) {
}
-void SYSTEM::FunTouch(void) {
+void System::funTouch() {
uint16 n = (PAIN) ? HEROFUN1 : HEROFUN0;
- if (_talk == NULL || n > FunDel)
- FunDel = n;
+ if (_talk == NULL || n > _funDel)
+ _funDel = n;
}
@@ -646,16 +608,16 @@ static void ShowBak(int ref) {
Bitmap::_pal = NULL;
spr->show(2);
_vga->copyPage(1, 2);
- _sys->SetPal();
+ _sys->setPal();
spr->contract();
}
}
-static void caveUp() {
+void CGEEngine::caveUp() {
int BakRef = 1000 * _now;
if (_music)
- LoadMIDI(_now);
+ loadMidi(_now);
ShowBak(BakRef);
loadMapping();
@@ -673,10 +635,10 @@ static void caveUp() {
spr = n;
}
if (_sndDrvInfo._dDev) {
- _sound.Stop();
- _fx.Clear();
- _fx.Preload(0);
- _fx.Preload(BakRef);
+ _sound.stop();
+ _fx.clear();
+ _fx.preload(0);
+ _fx.preload(BakRef);
}
if (_hero) {
@@ -707,7 +669,7 @@ static void caveUp() {
_vga->show();
_vga->sunrise(Vga::_sysPal);
_dark = false;
- if (!_startup)
+ if (!_startupMode)
_mouse->On();
_heart->_enable = true;
@@ -771,7 +733,7 @@ void CGEEngine::switchCave(int cav) {
_cavLight->gotoxy(CAVE_X + ((_now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX,
CAVE_Y + ((_now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY);
killText();
- if (!_startup)
+ if (!_startupMode)
KeyClick();
SNPOST(SNLABEL, -1, 0, NULL); // wait for repaint
//TODO Change the SNPOST message send to a special way to send function pointer
@@ -781,22 +743,22 @@ void CGEEngine::switchCave(int cav) {
}
}
-SYSTEM::SYSTEM(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) {
- FunDel = HEROFUN0;
- SetPal();
- Tick();
+System::System(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) {
+ _funDel = HEROFUN0;
+ setPal();
+ tick();
}
-void SYSTEM::touch(uint16 mask, int x, int y) {
+void System::touch(uint16 mask, int x, int y) {
static int pp = 0;
- FunTouch();
+ funTouch();
if (mask & KEYB) {
int pp0;
KeyClick();
killText();
- if (_startup == 1) {
+ if (_vm->_startupMode == 1) {
SNPOST(SNCLEAR, -1, 0, NULL);
return;
}
@@ -854,7 +816,7 @@ void SYSTEM::touch(uint16 mask, int x, int y) {
_hero->step(TSEQ + 3);
break;
case F9:
- _sys->FunDel = 1;
+ _sys->_funDel = 1;
break;
case 'X':
if (_keyboard->_key[ALT])
@@ -891,13 +853,13 @@ void SYSTEM::touch(uint16 mask, int x, int y) {
break;
case 'W':
if (pp == 2)
- _jbw = !_jbw;
+ _vm->_jbw = !_vm->_jbw;
break;
}
if (pp == pp0)
pp = 0;
} else {
- if (_startup)
+ if (_vm->_startupMode)
return;
int cav = 0;
_infoLine->update(NULL);
@@ -915,12 +877,12 @@ void SYSTEM::touch(uint16 mask, int x, int y) {
if (y >= POCKET_Y && y < POCKET_Y + POCKET_NY * POCKET_DY &&
x >= POCKET_X && x < POCKET_X + POCKET_NX * POCKET_DX) {
int n = ((y - POCKET_Y) / POCKET_DY) * POCKET_NX + (x - POCKET_X) / POCKET_DX;
- selectPocket(n);
+ _vm->selectPocket(n);
}
}
}
- PostMiniStep(cav - 1);
+ postMiniStep(cav - 1);
if (mask & L_UP) {
if (cav && _snail->idle() && _hero->_tracePtr < 0)
@@ -945,9 +907,9 @@ void SYSTEM::touch(uint16 mask, int x, int y) {
}
-void SYSTEM::Tick(void) {
- if (!_startup)
- if (--FunDel == 0) {
+void System::tick() {
+ if (!_vm->_startupMode)
+ if (--_funDel == 0) {
killText();
if (_snail->idle()) {
if (PAIN)
@@ -968,7 +930,7 @@ void SYSTEM::Tick(void) {
}
}
}
- FunTouch();
+ funTouch();
}
_time = SYSTIMERATE;
}
@@ -1001,7 +963,7 @@ static void SwitchColorMode(void) {
-static void SwitchMusic(void) {
+void CGEEngine::switchMusic() {
if (_keyboard->_key[ALT]) {
if (Vmenu::_addr)
SNPOST_(SNKILL, -1, 0, Vmenu::_addr);
@@ -1020,9 +982,9 @@ static void SwitchMusic(void) {
}
}
if (_music)
- LoadMIDI(_now);
+ loadMidi(_now);
else
- KillMIDI();
+ killMidi();
}
@@ -1203,7 +1165,7 @@ void CGEEngine::optionTouch(int opt, uint16 mask) {
break;
case 2 :
if (mask & L_UP)
- SwitchMusic();
+ switchMusic();
else if (mask & R_UP)
if (!Mixer::_appear) {
Mixer::_appear = true;
@@ -1220,7 +1182,7 @@ void CGEEngine::optionTouch(int opt, uint16 mask) {
#pragma argsused
void Sprite::touch(uint16 mask, int x, int y) {
- _sys->FunTouch();
+ _sys->funTouch();
if ((mask & ATTN) == 0) {
_infoLine->update(name());
if (mask & (R_DN | L_DN))
@@ -1236,14 +1198,14 @@ void Sprite::touch(uint16 mask, int x, int y) {
mask |= R_UP;
}
if ((mask & R_UP) && _snail->idle()) {
- Sprite *ps = (_pocLight->_seqPtr) ? _pocket[_pocPtr] : NULL;
+ Sprite *ps = (_pocLight->_seqPtr) ? _pocket[_vm->_pocPtr] : NULL;
if (ps) {
if (_flags._kept || _hero->distance(this) < MAX_DISTANCE) {
if (works(ps)) {
feedSnail(ps, TAKE);
} else
offUse();
- selectPocket(-1);
+ _vm->selectPocket(-1);
} else
tooFar();
} else {
@@ -1280,7 +1242,7 @@ void Sprite::touch(uint16 mask, int x, int y) {
int n;
for (n = 0; n < POCKET_NX; n++) {
if (_pocket[n] == this) {
- selectPocket(n);
+ _vm->selectPocket(n);
break;
}
}
@@ -1614,7 +1576,7 @@ void CGEEngine::runGame() {
_sprite->step(_music);
SNPOST_(SNSEQ, -1, _music, _sprite);
if (!_music)
- KillMIDI();
+ killMidi();
if (_mini && INI_FILE::exist("MINI.SPR")) {
uint8 *ptr = (uint8 *) &*_mini;
@@ -1626,7 +1588,7 @@ void CGEEngine::runGame() {
_miniCave->moveShapes(ptr);
_miniShp[0] = new Bitmap(*_miniCave->shp());
_miniShpList = _miniCave->setShapeList(_miniShp);
- PostMiniStep(-1);
+ postMiniStep(-1);
}
}
}
@@ -1661,7 +1623,7 @@ void CGEEngine::runGame() {
if (_mouse->Busy)
ExpandSprite(_mouse->Busy);
- _startup = 0;
+ _startupMode = 0;
SNPOST(SNLEVEL, -1, _oldLev, &_cavLight);
_cavLight->gotoxy(CAVE_X + ((_now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX,
@@ -1761,7 +1723,7 @@ bool CGEEngine::showTitle(const char *name) {
_vga->copyPage(0, 2);
Startup::_soundOk = 2;
if (_music)
- LoadMIDI(0);
+ loadMidi(0);
}
if (Startup::_mode < 2) {
@@ -1854,10 +1816,10 @@ void CGEEngine::cge_main(void) {
_horzLine->_flags._hide = true;
//srand((uint16) Timer());
- _sys = new SYSTEM(this);
+ _sys = new System(this);
if (_music && Startup::_soundOk)
- LoadMIDI(0);
+ loadMidi(0);
if (Startup::_mode < 2)
movie(LGO_EXT);
@@ -1865,7 +1827,7 @@ void CGEEngine::cge_main(void) {
if ((!_isDemo) && (Startup::_mode == 1))
movie("X02"); // intro
runGame();
- _startup = 2;
+ _startupMode = 2;
if (FINIS)
movie("X03");
} else
diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h
index c5be2adc26..e9c96931c3 100644
--- a/engines/cge/cge_main.h
+++ b/engines/cge/cge_main.h
@@ -113,17 +113,17 @@ namespace CGE {
#define FINIS (_flag[3])
-class SYSTEM : public Sprite {
- int lum;
+class System : public Sprite {
+ int _lum;
public:
- int FunDel;
+ int _funDel;
- SYSTEM(CGEEngine *vm);
+ System(CGEEngine *vm);
- void SetPal();
- void FunTouch();
+ void setPal();
+ void funTouch();
virtual void touch(uint16 mask, int x, int y);
- void Tick();
+ void tick();
private:
CGEEngine *_vm;
};
@@ -159,7 +159,6 @@ private:
};
-
Cluster XZ(int x, int y);
Cluster XZ(Couple xy);
@@ -169,7 +168,7 @@ void ContractSprite(Sprite *spr);
extern WALK *_hero;
extern Vga *_vga;
extern Heart *_heart;
-extern SYSTEM *_sys;
+extern System *_sys;
extern int _offUseCount;
extern Sprite *_pocLight;
extern Keyboard *_keyboard;
diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp
index 8812207371..11f2088034 100644
--- a/engines/cge/config.cpp
+++ b/engines/cge/config.cpp
@@ -143,7 +143,7 @@ static Choice BlsterDMA[] = {
void CGEEngine::selectSound() {
int i;
- _sound.Close();
+ _sound.close();
if (Vmenu::_addr)
SNPOST_(SNKILL, -1, 0, Vmenu::_addr);
inf(_text->getText(STYPE_TEXT));
@@ -201,7 +201,7 @@ static void select(Choice *cho, int hlp) {
void CGEEngine::NONE() {
_sndDrvInfo._dDev = DEV_QUIET;
_sndDrvInfo._mDev = DEV_QUIET;
- _sound.Open();
+ _sound.open();
}
@@ -249,7 +249,7 @@ void CGEEngine::AUTO() {
_sndDrvInfo._dDev = DEV_AUTO;
_sndDrvInfo._mDev = DEV_AUTO;
reset();
- _sound.Open();
+ _sound.open();
}
@@ -261,7 +261,7 @@ void CGEEngine::setPortD() {
void CGEEngine::setPortM() {
_sndDrvInfo._mBase = xdeco(MIDIPorts[Vmenu::_recent]._text);
- _sound.Open();
+ _sound.open();
}
@@ -276,7 +276,7 @@ void CGEEngine::setDMA() {
if (_sndDrvInfo._mDev != _sndDrvInfo._dDev)
select(MIDIPorts, MPORT_TEXT);
else
- _sound.Open();
+ _sound.open();
}
} // End of namespace CGE
diff --git a/engines/cge/ems.cpp b/engines/cge/ems.cpp
index 158857c002..ddb4861f03 100644
--- a/engines/cge/ems.cpp
+++ b/engines/cge/ems.cpp
@@ -41,10 +41,10 @@ enum EMM_FUN {
};
-void *EMM::_frame = NULL;
+void *Emm::_frame = NULL;
-EMM::EMM(long size): _han(-1), _top(0), _lim(0), _list(NULL) {
+Emm::Emm(long size): _han(-1), _top(0), _lim(0), _list(NULL) {
/*
if (Test())
{
@@ -82,7 +82,7 @@ EMM::EMM(long size): _han(-1), _top(0), _lim(0), _list(NULL) {
}
-EMM::~EMM(void) {
+Emm::~Emm(void) {
/* FIXME
Release();
if (Han >= 0)
@@ -97,7 +97,7 @@ EMM::~EMM(void) {
}
-bool EMM::test() {
+bool Emm::test() {
/*
static char e[] = "EMMXXXX0";
@@ -130,7 +130,7 @@ bool EMM::test() {
}
-EMS *EMM::alloc(uint16 siz) {
+Ems *Emm::alloc(uint16 siz) {
/*
long size = SIZ(siz),
top = Top;
@@ -167,14 +167,14 @@ EMS *EMM::alloc(uint16 siz) {
}
fail: return NULL;
*/
- warning("STUB: EMM::alloc");
+ warning("STUB: Emm::alloc");
return NULL;
}
-void EMM::release() {
+void Emm::release() {
while (_list) {
- EMS *e = _list;
+ Ems *e = _list;
_list = e->_next;
delete e;
}
@@ -182,11 +182,11 @@ void EMM::release() {
}
-EMS::EMS(void) : _ptr(0), _size(0), _next(NULL) {
+Ems::Ems() : _ptr(0), _size(0), _next(NULL) {
}
-void *EMS::operator & () const {
+void *Ems::operator & () const {
/*
uint16 pgn = (uint16) (Ptr >> 14),
off = (uint16) Ptr & PAGE_MASK,
@@ -213,12 +213,12 @@ void *EMS::operator & () const {
return (void *) (EMM::Frame + (void *) off);
*/
- warning("STUB: EMS::operator &");
+ warning("STUB: Ems::operator &");
return NULL;
}
-uint16 EMS::size() {
+uint16 Ems::size() {
return _size;
}
diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp
index 5bafd46884..accd6fb4ab 100644
--- a/engines/cge/events.cpp
+++ b/engines/cge/events.cpp
@@ -95,7 +95,7 @@ Keyboard::~Keyboard() {
}
Sprite *Keyboard::setClient(Sprite *spr) {
- Swap(_client, spr);
+ swap(_client, spr);
return spr;
}
diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp
index 6b0327ff23..3c0dc8a802 100644
--- a/engines/cge/general.cpp
+++ b/engines/cge/general.cpp
@@ -326,7 +326,7 @@ void sndMidiStop() {
// FIXME: STUB: sndMIDIStop
}
-DATACK *LoadWave(XFile *file, EMM *emm) {
+DataCk *loadWave(XFile *file, Emm *emm) {
warning("STUB: LoadWave");
return NULL;
}
@@ -394,9 +394,9 @@ Engine_::~Engine_() {
warning("STUB: Engine_::~Engine_");
}
-DATACK::~DATACK () {
- if (!e && Buf)
- free(Buf);
+DataCk::~DataCk() {
+ if (!_e && _buf)
+ free(_buf);
}
} // End of namespace CGE
diff --git a/engines/cge/general.h b/engines/cge/general.h
index 63b94d3872..95660ad4df 100644
--- a/engines/cge/general.h
+++ b/engines/cge/general.h
@@ -109,41 +109,41 @@ public:
};
-class EMS;
+class Ems;
-class EMM {
- friend class EMS;
+class Emm {
+ friend class Ems;
bool test();
long _top;
long _lim;
- EMS *_list;
+ Ems *_list;
int _han;
static void *_frame;
public:
- EMM(long size = 0);
- ~EMM();
- EMS *alloc(uint16 siz);
+ Emm(long size = 0);
+ ~Emm();
+ Ems *alloc(uint16 siz);
void release();
};
-class EMS {
- friend class EMM;
- EMM *_emm;
+class Ems {
+ friend class Emm;
+ Emm *_emm;
long _ptr;
uint16 _size;
- EMS *_next;
+ Ems *_next;
public:
- EMS();
+ Ems();
void *operator & () const;
uint16 size(void);
};
template <class T>
-void Swap(T &A, T &B) {
+void swap(T &A, T &B) {
T a = A;
A = B;
B = a;
diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp
index edafd59111..4c1b8d4c2f 100644
--- a/engines/cge/snail.cpp
+++ b/engines/cge/snail.cpp
@@ -60,7 +60,6 @@ extern Sprite *_pocLight;
// int _pocPtr = 0;
//-------------------------------------------------------------------------
extern Sprite *_pocket[];
-extern int _pocPtr;
static void SNGame(Sprite *spr, int num) {
switch (num) {
@@ -290,7 +289,7 @@ int findPocket(Sprite *spr) {
}
-void selectPocket(int n) {
+void CGEEngine::selectPocket(int n) {
if (n < 0 || (_pocLight->_seqPtr && _pocPtr == n)) {
_pocLight->step(0);
n = findPocket(NULL);
@@ -591,10 +590,10 @@ void SNSwap(Sprite *spr, int xref) {
bool was1 = (was == 0 || was == _now);
bool xwas1 = (xwas == 0 || xwas == _now);
- Swap(spr->_cave, xspr->_cave);
- Swap(spr->_x, xspr->_x);
- Swap(spr->_y, xspr->_y);
- Swap(spr->_z, xspr->_z);
+ swap(spr->_cave, xspr->_cave);
+ swap(spr->_x, xspr->_x);
+ swap(spr->_y, xspr->_y);
+ swap(spr->_z, xspr->_z);
if (spr->_flags._kept) {
int n = findPocket(spr);
if (n >= 0)
@@ -762,14 +761,14 @@ void SNKill(Sprite *spr) {
static void SNSound(Sprite *spr, int wav, int cnt) {
if (_sndDrvInfo._dDev) {
if (wav == -1)
- _sound.Stop();
+ _sound.stop();
else
- _sound.Play(_fx[wav], (spr) ? ((spr->_x + spr->_w / 2) / (SCR_WID / 16)) : 8, cnt);
+ _sound.play(_fx[wav], (spr) ? ((spr->_x + spr->_w / 2) / (SCR_WID / 16)) : 8, cnt);
}
}
-void SNKeep(Sprite *spr, int stp) {
+void CGEEngine::SNKeep(Sprite *spr, int stp) {
selectPocket(-1);
if (spr && ! spr->_flags._kept && _pocket[_pocPtr] == NULL) {
SNSound(spr, 3, 1);
@@ -785,7 +784,7 @@ void SNKeep(Sprite *spr, int stp) {
}
-void SNGive(Sprite *spr, int stp) {
+void CGEEngine::SNGive(Sprite *spr, int stp) {
if (spr) {
int p = findPocket(spr);
if (p >= 0) {
@@ -956,13 +955,13 @@ void Snail::runCom() {
if (sprel == _hero && sprel->seqTest(-1))
sprel->step(HTALK);
_text->say(_text->getText(snc->_val), sprel);
- _sys->FunDel = HEROFUN0;
+ _sys->_funDel = HEROFUN0;
}
break;
case SNINF :
if (_talkEnable) {
_vm->inf(_text->getText(snc->_val));
- _sys->FunDel = HEROFUN0;
+ _sys->_funDel = HEROFUN0;
}
break;
case SNTIME :
@@ -998,10 +997,10 @@ void Snail::runCom() {
SNUncover(sprel, (snc->_val >= 0) ? locate(snc->_val) : ((Sprite *) snc->_ptr));
break;
case SNKEEP :
- SNKeep(sprel, snc->_val);
+ _vm->SNKeep(sprel, snc->_val);
break;
case SNGIVE :
- SNGive(sprel, snc->_val);
+ _vm->SNGive(sprel, snc->_val);
break;
case SNGAME :
SNGame(sprel, snc->_val);
diff --git a/engines/cge/snail.h b/engines/cge/snail.h
index 2e06149526..bd874a35b4 100644
--- a/engines/cge/snail.h
+++ b/engines/cge/snail.h
@@ -37,7 +37,6 @@ namespace CGE {
#define POCKET_Y 176
#define POCKET_DX 18
#define POCKET_DY 22
-#define POCKET_NX 8
#define POCKET_NY 1
#define POCKET_SX 8
@@ -100,7 +99,6 @@ private:
};
-void selectPocket(int n);
void pocFul();
@@ -110,7 +108,6 @@ extern bool _dark;
extern int _now;
extern int _lev;
extern int _maxCave;
-extern int _pocPtr;
extern Bar _barriers[];
extern struct Hxy {
int _x;
diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp
index aca4b4d534..a163949ddd 100644
--- a/engines/cge/sound.cpp
+++ b/engines/cge/sound.cpp
@@ -35,85 +35,84 @@
namespace CGE {
-bool _music = true;
-FX _fx = 16; // must precede SOUND!!
-SOUND _sound;
+Fx _fx = 16; // must precede SOUND!!
+Sound _sound;
-SOUND::SOUND(void) {
+Sound::Sound() {
if (Startup::_soundOk)
- Open();
+ open();
}
-SOUND::~SOUND(void) {
- Close();
+Sound::~Sound() {
+ close();
}
-void SOUND::Close(void) {
- KillMIDI();
+void Sound::close() {
+ killMidi();
sndDone();
}
-void SOUND::Open(void) {
+void Sound::open() {
sndInit();
- Play(_fx[30000], 8);
+ play(_fx[30000], 8);
}
-void SOUND::Play(DATACK *wav, int pan, int cnt) {
+void Sound::play(DataCk *wav, int pan, int cnt) {
if (wav) {
- Stop();
- smpinf._saddr = (uint8 *) &*(wav->EAddr());
- smpinf._slen = (uint16)wav->Size();
- smpinf._span = pan;
- smpinf._sflag = cnt;
- sndDigiStart(&smpinf);
+ stop();
+ _smpinf._saddr = (uint8 *) &*(wav->eAddr());
+ _smpinf._slen = (uint16)wav->size();
+ _smpinf._span = pan;
+ _smpinf._sflag = cnt;
+ sndDigiStart(&_smpinf);
}
}
-void SOUND::Stop(void) {
- sndDigiStop(&smpinf);
+void Sound::stop() {
+ sndDigiStop(&_smpinf);
}
-FX::FX(int size) : Emm(0L), Current(NULL) {
- Cache = new HAN[size];
- for (Size = 0; Size < size; Size++) {
- Cache[Size].Ref = 0;
- Cache[Size].Wav = NULL;
+Fx::Fx(int size) : _emm(0L), _current(NULL) {
+ _cache = new Han[size];
+ for (_size = 0; _size < size; _size++) {
+ _cache[_size]._ref = 0;
+ _cache[_size]._wav = NULL;
}
}
-FX::~FX(void) {
- Clear();
- delete[] Cache;
+Fx::~Fx() {
+ clear();
+ delete[] _cache;
}
-void FX::Clear(void) {
- HAN *p, * q;
- for (p = Cache, q = p + Size; p < q; p++) {
- if (p->Ref) {
- p->Ref = 0;
- delete p->Wav;
- p->Wav = NULL;
+void Fx::clear() {
+ Han *p, * q;
+ for (p = _cache, q = p + _size; p < q; p++) {
+ if (p->_ref) {
+ p->_ref = 0;
+ delete p->_wav;
+ p->_wav = NULL;
}
}
- Emm.release();
- Current = NULL;
+ _emm.release();
+ _current = NULL;
}
-int FX::Find(int ref) {
- HAN *p, * q;
+int Fx::find(int ref) {
+ Han *p, * q;
int i = 0;
- for (p = Cache, q = p + Size; p < q; p++) {
- if (p->Ref == ref)
+ for (p = _cache, q = p + _size; p < q; p++) {
+ if (p->_ref == ref)
break;
else
++i;
@@ -122,60 +121,60 @@ int FX::Find(int ref) {
}
-void FX::Preload(int ref0) {
- HAN *CacheLim = Cache + Size;
+void Fx::preload(int ref0) {
+ Han *cacheLim = _cache + _size;
int ref;
for (ref = ref0; ref < ref0 + 10; ref++) {
static char fname[] = "FX00000.WAV";
wtom(ref, fname + 2, 10, 5);
INI_FILE file = INI_FILE(fname);
- DATACK *wav = LoadWave(&file, &Emm);
+ DataCk *wav = loadWave(&file, &_emm);
if (wav) {
- HAN *p = &Cache[Find(0)];
- if (p >= CacheLim)
+ Han *p = &_cache[find(0)];
+ if (p >= cacheLim)
break;
- p->Wav = wav;
- p->Ref = ref;
+ p->_wav = wav;
+ p->_ref = ref;
}
}
}
-DATACK *FX::Load(int idx, int ref) {
+DataCk *Fx::load(int idx, int ref) {
static char fname[] = "FX00000.WAV";
wtom(ref, fname + 2, 10, 5);
INI_FILE file = INI_FILE(fname);
- DATACK *wav = LoadWave(&file, &Emm);
+ DataCk *wav = loadWave(&file, &_emm);
if (wav) {
- HAN *p = &Cache[idx];
- p->Wav = wav;
- p->Ref = ref;
+ Han *p = &_cache[idx];
+ p->_wav = wav;
+ p->_ref = ref;
}
return wav;
}
-DATACK *FX::operator [](int ref) {
+DataCk *Fx::operator [](int ref) {
int i;
- if ((i = Find(ref)) < Size)
- Current = Cache[i].Wav;
+ if ((i = find(ref)) < _size)
+ _current = _cache[i]._wav;
else {
- if ((i = Find(0)) >= Size) {
- Clear();
+ if ((i = find(0)) >= _size) {
+ clear();
i = 0;
}
- Current = Load(i, ref);
+ _current = load(i, ref);
}
- return Current;
+ return _current;
}
-static uint8 *midi = NULL;
+static uint8 *midi = NULL;
-void KillMIDI(void) {
+void killMidi() {
sndMidiStop();
if (midi) {
delete[] midi;
@@ -184,11 +183,11 @@ void KillMIDI(void) {
}
-void LoadMIDI(int ref) {
+void loadMidi(int ref) {
static char fn[] = "00.MID";
wtom(ref, fn, 10, 2);
if (INI_FILE::exist(fn)) {
- KillMIDI();
+ killMidi();
INI_FILE mid = fn;
if (mid._error == 0) {
uint16 siz = (uint16) mid.size();
@@ -196,7 +195,7 @@ void LoadMIDI(int ref) {
if (midi) {
mid.read(midi, siz);
if (mid._error)
- KillMIDI();
+ killMidi();
else
sndMidiStart(midi);
}
diff --git a/engines/cge/sound.h b/engines/cge/sound.h
index 55dd1615cc..fda8d4f128 100644
--- a/engines/cge/sound.h
+++ b/engines/cge/sound.h
@@ -37,44 +37,42 @@ namespace CGE {
#define BAD_MIDI_TEXT 98
-class SOUND {
+class Sound {
public:
- SmpInfo smpinf;
- SOUND(void);
- ~SOUND(void);
- void Open(void);
- void Close(void);
- void Play(DATACK *wav, int pan, int cnt = 1);
- void Stop(void);
+ SmpInfo _smpinf;
+ Sound();
+ ~Sound();
+ void open();
+ void close();
+ void play(DataCk *wav, int pan, int cnt = 1);
+ void stop();
};
-class FX {
- EMM Emm;
- struct HAN {
- int Ref;
- DATACK *Wav;
- } *Cache;
- int Size;
- DATACK *Load(int idx, int ref);
- int Find(int ref);
+class Fx {
+ Emm _emm;
+ struct Han {
+ int _ref;
+ DataCk *_wav;
+ } *_cache;
+ int _size;
+ DataCk *load(int idx, int ref);
+ int find(int ref);
public:
- DATACK *Current;
- FX(int size = 16);
- ~FX(void);
- void Clear(void);
- void Preload(int ref0);
- DATACK *operator[](int ref);
+ DataCk *_current;
+ Fx(int size = 16);
+ ~Fx();
+ void clear();
+ void preload(int ref0);
+ DataCk *operator[](int ref);
};
+extern Sound _sound;
+extern Fx _fx;
-extern bool _music;
-extern SOUND _sound;
-extern FX _fx;
-
-void LoadMIDI(int ref);
-void KillMIDI();
+void loadMidi(int ref);
+void killMidi();
} // End of namespace CGE
diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp
index 0dfbc67916..6a06cbc537 100644
--- a/engines/cge/startup.cpp
+++ b/engines/cge/startup.cpp
@@ -38,7 +38,7 @@ extern char _copr[];
#define id (*(Ident*)_copr)
-EMM _miniEmm = MINI_EMM_SIZE;
+Emm _miniEmm = MINI_EMM_SIZE;
// static Startup _startUp;
diff --git a/engines/cge/startup.h b/engines/cge/startup.h
index 96c7388070..cc16f2a123 100644
--- a/engines/cge/startup.h
+++ b/engines/cge/startup.h
@@ -70,7 +70,7 @@ public:
};
-extern EMM _miniEmm;
+extern Emm _miniEmm;
const char *usrPath(const char *nam);
diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp
index 2988f9ab11..04a9189682 100644
--- a/engines/cge/vol.cpp
+++ b/engines/cge/vol.cpp
@@ -105,4 +105,18 @@ void VFile::readBuff() {
_ptr = 0;
}
+long VFile::mark() {
+ return (_bufMark + _ptr) - _begMark;
+}
+
+long VFile::size() {
+ return _endMark - _begMark;
+}
+
+long VFile::seek(long pos) {
+ _recent = NULL;
+ _lim = 0;
+ return (_bufMark = _begMark + pos);
+}
+
} // End of namespace CGE
diff --git a/engines/cge/vol.h b/engines/cge/vol.h
index d8ba0979cb..8ed33d0ab4 100644
--- a/engines/cge/vol.h
+++ b/engines/cge/vol.h
@@ -70,28 +70,20 @@ private:
long _begMark;
long _endMark;
- void readBuff(void);
- void writeBuff(void) { }
+ void readBuff();
+ void writeBuff() { }
void make(const char *fspec);
public:
VFile(const char *name, IOMODE mode = REA);
~VFile();
+
static void init();
static void deinit();
-
static bool exist(const char *name);
static const char *next();
- long mark() {
- return (_bufMark + _ptr) - _begMark;
- }
- long size() {
- return _endMark - _begMark;
- }
- long seek(long pos) {
- _recent = NULL;
- _lim = 0;
- return (_bufMark = _begMark + pos);
- }
+ long mark();
+ long size();
+ long seek(long pos);
};
diff --git a/engines/cge/wav.h b/engines/cge/wav.h
index 062f83dfca..c3e67f5f95 100644
--- a/engines/cge/wav.h
+++ b/engines/cge/wav.h
@@ -37,114 +37,111 @@ namespace CGE {
#define IBM_FORMAT_ALAW 0x0102
#define IBM_FORMAT_ADPCM 0x0103
+typedef char FourCC[4]; // Four-character code
-typedef char FOURCC[4]; // Four-character code
-typedef uint32 CKSIZE; // 32-bit unsigned size
-
-
-class CKID { // Chunk type identifier
+class ChunkId { // Chunk type identifier
union {
- FOURCC Tx;
- uint32 Id;
+ FourCC _tx;
+ uint32 _id;
};
protected:
static XFile *ckFile;
public:
- CKID(FOURCC t) {
- memcpy(Tx, t, sizeof(Tx));
+ ChunkId(FourCC t) {
+ memcpy(_tx, t, sizeof(_tx));
}
- CKID(uint32 d) {
- Id = d;
+ ChunkId(uint32 d) {
+ _id = d;
}
- CKID(XFile *xf) {
- (ckFile = xf)->read(Tx, sizeof(Tx));
+ ChunkId(XFile *xf) {
+ (ckFile = xf)->read(_tx, sizeof(_tx));
}
- bool operator !=(CKID &X) {
- return Id != X.Id;
+ bool operator !=(ChunkId &X) {
+ return _id != X._id;
}
- bool operator ==(CKID &X) {
- return Id == X.Id;
+ bool operator ==(ChunkId &X) {
+ return _id == X._id;
}
- const char *Name(void);
+ const char *name();
};
-class CKHEA : public CKID {
+class CkHea : public ChunkId {
protected:
- CKSIZE ckSize; // Chunk size field (size of ckData)
+ uint32 _ckSize; // Chunk size field (size of ckData)
public:
- CKHEA(XFile *xf) : CKID(xf) {
- XRead(xf, &ckSize);
+ CkHea(XFile *xf) : ChunkId(xf) {
+ XRead(xf, &_ckSize);
}
- CKHEA(char id[]) : CKID(id), ckSize(0) { }
- void Skip(void);
- CKSIZE Size(void) {
- return ckSize;
+ CkHea(char id[]) : ChunkId(id), _ckSize(0) { }
+ void skip();
+ uint32 size() {
+ return _ckSize;
}
};
-class FMTCK : public CKHEA {
- struct WAV {
- uint16 wFormatTag; // Format category
- uint16 wChannels; // Number of channels
- uint32 dwSamplesPerSec; // Sampling rate
- uint32 dwAvgBytesPerSec; // For buffer estimation
- uint16 wBlockAlign; // Data block size
- } Wav;
+class FmtCk : public CkHea {
+ struct Wav {
+ uint16 _wFormatTag; // Format category
+ uint16 _wChannels; // Number of channels
+ uint32 _dwSamplesPerSec; // Sampling rate
+ uint32 _dwAvgBytesPerSec; // For buffer estimation
+ uint16 _wBlockAlign; // Data block size
+ } _wav;
union {
struct {
- uint16 wBitsPerSample; // Sample size
- } Pcm;
+ uint16 _wBitsPerSample; // Sample size
+ } _pcm;
};
public:
- FMTCK(CKHEA &hea);
- inline uint16 Channels(void) {
- return Wav.wChannels;
+ FmtCk(CkHea &hea);
+ inline uint16 channels() {
+ return _wav._wChannels;
}
- inline uint32 SmplRate(void) {
- return Wav.dwSamplesPerSec;
+ inline uint32 smplRate() {
+ return _wav._dwSamplesPerSec;
}
- inline uint32 ByteRate(void) {
- return Wav.dwAvgBytesPerSec;
+ inline uint32 byteRate() {
+ return _wav._dwAvgBytesPerSec;
}
- inline uint16 BlckSize(void) {
- return Wav.wBlockAlign;
+ inline uint16 blckSize() {
+ return _wav._wBlockAlign;
}
- inline uint16 SmplSize(void) {
- return Pcm.wBitsPerSample;
+ inline uint16 smplSize() {
+ return _pcm._wBitsPerSample;
}
};
-class DATACK : public CKHEA {
- bool e;
+class DataCk : public CkHea {
+ bool _e;
union {
- uint8 *Buf;
- EMS *EBuf;
+ uint8 *_buf;
+ Ems *_eBuf;
};
public:
- DATACK(CKHEA &hea);
- DATACK(CKHEA &hea, EMM *emm);
- DATACK(int first, int last);
- ~DATACK(void);
- inline uint8 *Addr(void) {
- return Buf;
+ DataCk(CkHea &hea);
+ DataCk(CkHea &hea, Emm *emm);
+ DataCk(int first, int last);
+ ~DataCk();
+ inline uint8 *addr() {
+ return _buf;
}
- inline EMS *EAddr(void) {
- return EBuf;
+ inline Ems *eAddr() {
+ return _eBuf;
}
};
-extern CKID RIFF;
-extern CKID WAVE;
-extern CKID FMT;
-extern CKID DATA;
+extern ChunkId _riff;
+extern ChunkId _wave;
+extern ChunkId _fmt;
+extern ChunkId _data;
-DATACK *LoadWave(XFile *file, EMM *emm = NULL);
+DataCk *loadWave(XFile *file, Emm *emm = NULL);
} // End of namespace CGE