aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStrangerke2011-06-27 01:03:47 +0200
committerStrangerke2011-06-27 01:03:47 +0200
commit083d6ff6122cb2faf0a4330eb480bb9f77afa255 (patch)
treee8dae7dcccf1946d5df3518ff0e1221d6a881896
parente0673c113563ab9fc28d08c07a3bcb5c3b98fa1c (diff)
downloadscummvm-rg350-083d6ff6122cb2faf0a4330eb480bb9f77afa255.tar.gz
scummvm-rg350-083d6ff6122cb2faf0a4330eb480bb9f77afa255.tar.bz2
scummvm-rg350-083d6ff6122cb2faf0a4330eb480bb9f77afa255.zip
CGE: remove some if(n)def DEMO by using a new flag. Added CGEEngine in several classes in order to do so.
-rw-r--r--engines/cge/cge.cpp33
-rw-r--r--engines/cge/cge.h39
-rw-r--r--engines/cge/cge_main.cpp213
-rw-r--r--engines/cge/cge_main.h39
-rw-r--r--engines/cge/config.cpp126
-rw-r--r--engines/cge/detection.cpp4
-rw-r--r--engines/cge/game.cpp4
-rw-r--r--engines/cge/game.h4
-rw-r--r--engines/cge/gettext.cpp6
-rw-r--r--engines/cge/gettext.h11
-rw-r--r--engines/cge/jbw.h9
-rw-r--r--engines/cge/mixer.cpp4
-rw-r--r--engines/cge/mixer.h8
-rw-r--r--engines/cge/mouse.cpp2
-rw-r--r--engines/cge/mouse.h12
-rw-r--r--engines/cge/snail.cpp9
-rw-r--r--engines/cge/snail.h7
-rw-r--r--engines/cge/talk.cpp10
-rw-r--r--engines/cge/talk.h10
-rw-r--r--engines/cge/text.cpp14
-rw-r--r--engines/cge/text.h5
-rw-r--r--engines/cge/vga13h.cpp5
-rw-r--r--engines/cge/vga13h.h5
-rw-r--r--engines/cge/vmenu.cpp14
-rw-r--r--engines/cge/vmenu.h12
25 files changed, 329 insertions, 276 deletions
diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp
index d056a6737d..d09085857f 100644
--- a/engines/cge/cge.cpp
+++ b/engines/cge/cge.cpp
@@ -45,7 +45,8 @@ CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription)
// Debug/console setup
DebugMan.addDebugChannel(kCGEDebug, "general", "CGE general debug channel");
- debug("CGEEngine::CGEEngine");
+ _isDemo = _gameDescription->flags & ADGF_DEMO;
+
}
void CGEEngine::setup() {
@@ -56,22 +57,22 @@ void CGEEngine::setup() {
VFILE::init();
// Initialise engine objects
- Text = new TEXT(ProgName(), 128);
+ Text = new TEXT(this, ProgName(), 128);
Vga = new VGA(M13H);
Heart = new HEART;
- Hero = new WALK(NULL);
- Sys = new SYSTEM();
- PocLight = new SPRITE(LI);
- Mouse = new MOUSE;
+ Hero = new WALK(this, NULL);
+ Sys = new SYSTEM(this);
+ PocLight = new SPRITE(this, LI);
+ Mouse = new MOUSE(this);
for (int i = 0; i < POCKET_NX; i++)
- Pocket[i] = new SPRITE(NULL);
- Sprite = new SPRITE(NULL);
- MiniCave = new SPRITE(NULL);
- Shadow = new SPRITE(NULL);
- HorzLine = new SPRITE(HL);
- InfoLine = new INFO_LINE(INFO_W);
- CavLight = new SPRITE(PR);
- DebugLine = new INFO_LINE(SCR_WID);
+ Pocket[i] = new SPRITE(this, NULL);
+ Sprite = new SPRITE(this, NULL);
+ MiniCave = new SPRITE(this, NULL);
+ Shadow = new SPRITE(this, NULL);
+ HorzLine = new SPRITE(this, HL);
+ InfoLine = new INFO_LINE(this, INFO_W);
+ CavLight = new SPRITE(this, PR);
+ DebugLine = new INFO_LINE(this, SCR_WID);
MB[0] = new BITMAP("BRICK");
MB[1] = NULL;
HL[0] = new BITMAP("HLINE");
@@ -89,8 +90,8 @@ void CGEEngine::setup() {
LI[2] = new BITMAP("LITE2");
LI[3] = new BITMAP("LITE3");
LI[4] = NULL;
- Snail = new SNAIL(false);
- Snail_ = new SNAIL(true);
+ Snail = new SNAIL(this, false);
+ Snail_ = new SNAIL(this, true);
OffUseCount = atoi(Text->getText(OFF_USE_COUNT));
}
diff --git a/engines/cge/cge.h b/engines/cge/cge.h
index f8857f045f..c3f241b2fe 100644
--- a/engines/cge/cge.h
+++ b/engines/cge/cge.h
@@ -23,6 +23,7 @@
#ifndef CGE_H
#define CGE_H
+#include "cge/general.h"
#include "common/random.h"
#include "engines/engine.h"
#include "gui/debugger.h"
@@ -47,15 +48,51 @@ public:
~CGEEngine();
const ADGameDescription *_gameDescription;
+ bool _isDemo;
virtual Common::Error run();
GUI::Debugger *getDebugger() {
return _console;
}
+ void cge_main();
+ void SwitchCave(int cav);
+ void StartCountDown();
+ void Quit();
+ void ResetQSwitch();
+ void OptionTouch(int opt, uint16 mask);
+ void LoadGame(XFILE &file, bool tiny);
+ void SetMapBrick(int x, int z);
+ void SwitchMapping();
+ void LoadSprite(const char *fname, int ref, int cav, int col, int row, int pos);
+ void LoadScript(const char *fname);
+ void LoadUser();
+ void RunGame();
+ bool ShowTitle(const char *name);
+ void Movie(const char *ext);
+ void TakeName();
+ void Inf(const char *txt);
+ void SelectSound();
+ void SNSelect();
+ void dummy() {}
+ void NONE();
+ void SB();
+ void CaveDown();
+ void XCave();
+ void QGame();
+ void SBM();
+ void GUS();
+ void GUSM();
+ void MIDI();
+ void AUTO();
+ void SetPortD();
+ void SetPortM();
+ void SetIRQ();
+ void SetDMA();
+ void MainLoop();
+
private:
CGEConsole *_console;
-
void setup();
};
diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp
index 4121efdb78..dda6041f0a 100644
--- a/engines/cge/cge_main.cpp
+++ b/engines/cge/cge_main.cpp
@@ -44,6 +44,7 @@
#include "cge/gettext.h"
#include "cge/mixer.h"
#include "cge/cge_main.h"
+#include "cge/cge.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -54,7 +55,7 @@
namespace CGE {
#define STACK_SIZ (K(2))
-#define SVGCHKSUM (1956+Now+OldLev+Game+Music+DemoText)
+#define SVGCHKSUM (1956 + Now + OldLev + Game + Music + DemoText)
#define SVG0NAME ("{{INIT}}" SVG_EXT)
#define SVG0FILE CFILE
@@ -142,7 +143,6 @@ static int Startup = 1;
int OffUseCount;
uint16 *intStackPtr = false;
-
HXY HeroXY[CAVE_MAX] = {{0, 0}};
BAR Barriers[1 + CAVE_MAX] = { { 0xFF, 0xFF } };
@@ -248,7 +248,7 @@ struct SAVTAB {
};
-static void LoadGame(XFILE &file, bool tiny = false) {
+void CGEEngine::LoadGame(XFILE &file, bool tiny = false) {
SAVTAB *st;
SPRITE *spr;
int i;
@@ -274,15 +274,15 @@ static void LoadGame(XFILE &file, bool tiny = false) {
if (! tiny) { // load sprites & pocket
while (! file.Error) {
- SPRITE S(NULL);
+ SPRITE S(this, NULL);
uint16 n = file.Read((uint8 *) &S, sizeof(S));
if (n != sizeof(S))
break;
S.Prev = S.Next = NULL;
- spr = (scumm_stricmp(S.File + 2, "MUCHA") == 0) ? new FLY(NULL)
- : new SPRITE(NULL);
+ spr = (scumm_stricmp(S.File + 2, "MUCHA") == 0) ? new FLY(this, NULL)
+ : new SPRITE(this, NULL);
if (spr == NULL)
error("No core");
*spr = S;
@@ -385,8 +385,8 @@ CLUSTER Trace[MAX_FIND_LEVEL];
int FindLevel;
-WALK::WALK(BMP_PTR *shpl)
- : SPRITE(shpl), Dir(NO_DIR), TracePtr(-1) {
+WALK::WALK(CGEEngine *vm, BMP_PTR *shpl)
+ : SPRITE(vm, shpl), Dir(NO_DIR), TracePtr(-1), _vm(vm) {
}
@@ -545,13 +545,15 @@ void WALK::Reach(SPRITE *spr, int mode) {
class SQUARE : public SPRITE {
public:
- SQUARE(void);
+ SQUARE(CGEEngine *vm);
void Touch(uint16 mask, int x, int y);
+private:
+ CGEEngine *_vm;
};
-SQUARE::SQUARE(void)
- : SPRITE(MB) {
+SQUARE::SQUARE(CGEEngine *vm)
+ : SPRITE(vm, MB), _vm(vm) {
Flags.Kill = true;
Flags.BDel = false;
}
@@ -566,8 +568,8 @@ void SQUARE::Touch(uint16 mask, int x, int y) {
}
-static void SetMapBrick(int x, int z) {
- SQUARE *s = new SQUARE;
+void CGEEngine::SetMapBrick(int x, int z) {
+ SQUARE *s = new SQUARE(this);
if (s) {
static char n[] = "00:00";
s->Goto(x * MAP_XGRID, MAP_TOP + z * MAP_ZGRID);
@@ -579,10 +581,9 @@ static void SetMapBrick(int x, int z) {
}
}
-void dummy(void) {}
-static void SwitchMapping(void);
+//static void SwitchMapping(void);
static void SwitchColorMode(void);
-static void StartCountDown(void);
+//static void StartCountDown(void);
static void SwitchDebug(void);
static void SwitchMusic(void);
static void KillSprite(void);
@@ -597,16 +598,17 @@ static void KeyClick(void) {
}
-static void ResetQSwitch(void) {
+void CGEEngine::ResetQSwitch() {
SNPOST_(SNSEQ, 123, 0, NULL);
KeyClick();
}
-static void Quit(void) {
- static CHOICE QuitMenu[] = { { NULL, StartCountDown },
- { NULL, ResetQSwitch },
- { NULL, dummy }
+void CGEEngine::Quit() {
+ static CHOICE QuitMenu[] = {
+ { NULL, &CGEEngine::StartCountDown },
+ { NULL, &CGEEngine::ResetQSwitch },
+ { NULL, &CGEEngine::dummy }
};
if (Snail->Idle() && ! Hero->Flags.Hide) {
@@ -616,7 +618,7 @@ static void Quit(void) {
} else {
QuitMenu[0].Text = Text->getText(QUIT_TEXT);
QuitMenu[1].Text = Text->getText(NOQUIT_TEXT);
- (new VMENU(QuitMenu, -1, -1))->SetName(Text->getText(QUIT_TITLE));
+ (new VMENU(this, QuitMenu, -1, -1))->SetName(Text->getText(QUIT_TITLE));
SNPOST_(SNSEQ, 123, 1, NULL);
KeyClick();
}
@@ -744,7 +746,7 @@ static void CaveUp(void) {
}
-static void CaveDown(void) {
+void CGEEngine::CaveDown() {
SPRITE *spr;
if (! HorzLine->Flags.Hide)
SwitchMapping();
@@ -762,13 +764,13 @@ static void CaveDown(void) {
}
-static void XCave(void) {
+void CGEEngine::XCave() {
CaveDown();
CaveUp();
}
-static void QGame(void) {
+void CGEEngine::QGame() {
CaveDown();
OldLev = Lev;
SaveSound();
@@ -779,7 +781,7 @@ static void QGame(void) {
}
-void SwitchCave(int cav) {
+void CGEEngine::SwitchCave(int cav) {
if (cav != Now) {
Heart->Enable = false;
if (cav < 0) {
@@ -793,11 +795,10 @@ void SwitchCave(int cav) {
if (Hero) {
Hero->Park();
Hero->Step(0);
-#ifndef DEMO
+ if (!_isDemo)
///// protection: auto-destruction on! ----------------------
- Vga->SpareQ->Show = STARTUP::Summa * (cav <= CAVE_MAX);
+ Vga->SpareQ->Show = STARTUP::Summa * (cav <= CAVE_MAX);
/////--------------------------------------------------------
-#endif
}
CavLight->Goto(CAVE_X + ((Now - 1) % CAVE_NX) * CAVE_DX + CAVE_SX,
CAVE_Y + ((Now - 1) / CAVE_NX) * CAVE_DY + CAVE_SY);
@@ -812,7 +813,7 @@ void SwitchCave(int cav) {
}
}
-SYSTEM::SYSTEM() : SPRITE(NULL) {
+SYSTEM::SYSTEM(CGEEngine *vm) : SPRITE(vm, NULL), _vm(vm) {
FunDel = HEROFUN0;
SetPal();
Tick();
@@ -820,7 +821,6 @@ SYSTEM::SYSTEM() : SPRITE(NULL) {
void SYSTEM::Touch(uint16 mask, int x, int y) {
static int pp = 0;
- void SwitchCave(int cav);
FunTouch();
@@ -862,7 +862,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) {
if (KEYBOARD::Key[ALT])
SaveMapping();
else
- SwitchMapping();
+ _vm->SwitchMapping();
break;
case F1:
SwitchDebug();
@@ -911,7 +911,7 @@ void SYSTEM::Touch(uint16 mask, int x, int y) {
break;
case F10 :
if (Snail->Idle() && ! Hero->Flags.Hide)
- StartCountDown();
+ _vm->StartCountDown();
break;
case 'J':
if (pp == 0)
@@ -956,14 +956,14 @@ void SYSTEM::Touch(uint16 mask, int x, int y) {
if (mask & L_UP) {
if (cav && Snail->Idle() && Hero->TracePtr < 0)
- SwitchCave(cav);
+ _vm->SwitchCave(cav);
if (!HorzLine->Flags.Hide) {
if (y >= MAP_TOP && y < MAP_TOP + MAP_HIG) {
int8 x1, z1;
XZ(x, y).Split(x1, z1);
CLUSTER::Map[z1][x1] = 1;
- SetMapBrick(x1, z1);
+ _vm->SetMapBrick(x1, z1);
}
} else
{
@@ -1057,18 +1057,17 @@ static void SwitchMusic(void) {
}
-static void StartCountDown(void) {
+void CGEEngine::StartCountDown() {
//SNPOST(SNSEQ, 123, 0, NULL);
SwitchCave(-1);
}
-#ifndef DEMO
-static void TakeName(void) {
+void CGEEngine::TakeName() {
if (GET_TEXT::Ptr)
SNPOST_(SNKILL, -1, 0, GET_TEXT::Ptr);
else {
- GET_TEXT *tn = new GET_TEXT(Text->getText(GETNAME_PROMPT), UsrFnam, 8, KeyClick);
+ GET_TEXT *tn = new GET_TEXT(this, Text->getText(GETNAME_PROMPT), UsrFnam, 8, KeyClick);
if (tn) {
tn->SetName(Text->getText(GETNAME_TITLE));
tn->Center();
@@ -1078,10 +1077,9 @@ static void TakeName(void) {
}
}
}
-#endif
-static void SwitchMapping(void) {
+void CGEEngine::SwitchMapping() {
if (HorzLine->Flags.Hide) {
int i;
for (i = 0; i < MAP_ZCNT; i++) {
@@ -1228,7 +1226,7 @@ static void SwitchDebug(void) {
}
-static void OptionTouch(int opt, uint16 mask) {
+void CGEEngine::OptionTouch(int opt, uint16 mask) {
switch (opt) {
case 1 :
if (mask & L_UP)
@@ -1240,7 +1238,7 @@ static void OptionTouch(int opt, uint16 mask) {
else if (mask & R_UP)
if (! MIXER::Appear) {
MIXER::Appear = true;
- new MIXER(BUTTON_X, BUTTON_Y);
+ new MIXER(this, BUTTON_X, BUTTON_Y);
}
break;
case 3 :
@@ -1259,7 +1257,7 @@ void SPRITE::Touch(uint16 mask, int x, int y) {
if (mask & (R_DN | L_DN))
Sprite = this;
if (Ref / 10 == 12) {
- OptionTouch(Ref % 10, mask);
+ _vm->OptionTouch(Ref % 10, mask);
return;
}
if (Flags.Syst)
@@ -1324,7 +1322,7 @@ void SPRITE::Touch(uint16 mask, int x, int y) {
}
-static void LoadSprite(const char *fname, int ref, int cav, int col = 0, int row = 0, int pos = 0) {
+void CGEEngine::LoadSprite(const char *fname, int ref, int cav, int col = 0, int row = 0, int pos = 0) {
static const char *Comd[] = { "Name", "Type", "Phase", "East",
"Left", "Right", "Top", "Bottom",
"Seq", "Near", "Take",
@@ -1391,7 +1389,7 @@ static void LoadSprite(const char *fname, int ref, int cav, int col = 0, int row
// make sprite of choosen type
switch (type) {
case 1 : { // AUTO
- Sprite = new SPRITE(NULL);
+ Sprite = new SPRITE(this, NULL);
if (Sprite) {
Sprite->Goto(col, row);
//Sprite->Time = 1;//-----------$$$$$$$$$$$$$$$$
@@ -1399,7 +1397,7 @@ static void LoadSprite(const char *fname, int ref, int cav, int col = 0, int row
break;
}
case 2 : { // WALK
- WALK *w = new WALK(NULL);
+ WALK *w = new WALK(this, NULL);
if (w && ref == 1) {
w->Goto(col, row);
if (Hero)
@@ -1444,13 +1442,13 @@ static void LoadSprite(const char *fname, int ref, int cav, int col = 0, int row
break;
}
case 5 : { // FLY
- FLY *f = new FLY(NULL);
+ FLY *f = new FLY(this, NULL);
Sprite = f;
//////Sprite->Time = 1;//-----------$$$$$$$$$$$$$$
break;
}
default: { // DEAD
- Sprite = new SPRITE(NULL);
+ Sprite = new SPRITE(this, NULL);
if (Sprite)
Sprite->Goto(col, row);
break;
@@ -1474,7 +1472,7 @@ static void LoadSprite(const char *fname, int ref, int cav, int col = 0, int row
}
-static void LoadScript(const char *fname) {
+void CGEEngine::LoadScript(const char *fname) {
char line[LINE_MAX];
char *SpN;
int SpI, SpA, SpX, SpY, SpZ;
@@ -1534,30 +1532,29 @@ static void LoadScript(const char *fname) {
}
-static void MainLoop(void) {
+void CGEEngine::MainLoop() {
SayDebug();
-#ifdef DEMO
- static uint32 tc = 0;
- if (/* FIXME: TimerCount - tc >= ((182L*6L) * 5L) && */ Talk == NULL && Snail.Idle()) {
- if (Text->getText(DemoText)) {
- SNPOST(SNSOUND, -1, 4, NULL); // drumla
- SNPOST(SNINF, -1, DemoText, NULL);
- SNPOST(SNLABEL, -1, -1, NULL);
- if (Text->getText(++ DemoText) == NULL)
- DemoText = DEMO_TEXT + 1;
+ if (_isDemo) {
+ static uint32 tc = 0;
+ if (/* FIXME: TimerCount - tc >= ((182L * 6L) * 5L) && */ Talk == NULL && Snail->Idle()) {
+ if (Text->getText(DemoText)) {
+ SNPOST(SNSOUND, -1, 4, NULL); // drumla
+ SNPOST(SNINF, -1, DemoText, NULL);
+ SNPOST(SNLABEL, -1, -1, NULL);
+ if (Text->getText(++ DemoText) == NULL)
+ DemoText = DEMO_TEXT + 1;
+ }
+ //FIXME: tc = TimerCount;
}
- //FIXME: tc = TimerCount;
}
-#endif
-
Vga->Show();
Snail_->RunCom();
Snail->RunCom();
}
-void LoadUser(void) {
+void CGEEngine::LoadUser() {
// set scene
if (STARTUP::Mode == 0) { // user .SVG file found
CFILE cfile = CFILE(UsrPath(UsrFnam), REA, RCrypt);
@@ -1578,7 +1575,7 @@ void LoadUser(void) {
}
-static void RunGame(void) {
+void CGEEngine::RunGame() {
Text->Clear();
Text->Preload(100, 1000);
LoadHeroXY();
@@ -1689,7 +1686,7 @@ static void RunGame(void) {
}
-void Movie(const char *ext) {
+void CGEEngine::Movie(const char *ext) {
const char *fn = ProgName(ext);
if (INI_FILE::Exist(fn)) {
LoadScript(fn);
@@ -1711,13 +1708,13 @@ void Movie(const char *ext) {
}
-bool ShowTitle(const char *name) {
+bool CGEEngine::ShowTitle(const char *name) {
BITMAP::Pal = SysPal;
BMP_PTR LB[] = { new BITMAP(name), NULL };
BITMAP::Pal = NULL;
bool usr_ok = false;
- SPRITE D(LB);
+ SPRITE D(this, LB);
D.Flags.Kill = true;
D.Flags.BDel = true;
D.Center();
@@ -1752,42 +1749,43 @@ bool ShowTitle(const char *name) {
}
if (STARTUP::Mode < 2) {
-#ifdef DEMO
- strcpy(UsrFnam, ProgName(SVG_EXT));
- usr_ok = true;
-#else
- //-----------------------------------------
+ if (_isDemo) {
+ strcpy(UsrFnam, ProgName(SVG_EXT));
+ usr_ok = true;
+ } else {
+ //-----------------------------------------
#ifndef EVA
#ifdef CD
- STARTUP::Summa |= (0xC0 + (DriveCD(0) << 6)) & 0xFF;
+ STARTUP::Summa |= (0xC0 + (DriveCD(0) << 6)) & 0xFF;
#else
-// Boot * b = ReadBoot(getdisk());
- warning("ShowTitle: FIXME ReadBoot");
- Boot *b = ReadBoot(0);
- uint32 sn = (b->XSign == 0x29) ? b->Serial : b->lTotSecs;
- free(b);
- sn -= ((IDENT *)Copr)->disk;
- STARTUP::Summa |= Lo(sn) | Hi(sn);
+// Boot * b = ReadBoot(getdisk());
+ warning("ShowTitle: FIXME ReadBoot");
+ Boot *b = ReadBoot(0);
+ uint32 sn = (b->XSign == 0x29) ? b->Serial : b->lTotSecs;
+ free(b);
+ sn -= ((IDENT *)Copr)->disk;
+ STARTUP::Summa |= Lo(sn) | Hi(sn);
#endif
+ //-----------------------------------------
+ Movie("X00"); // paylist
+ Vga->CopyPage(1, 2);
+ Vga->CopyPage(0, 1);
+ Vga->ShowQ->Append(Mouse);
+ //Mouse.On();
+ Heart->Enable = true;
+ for (TakeName(); GET_TEXT::Ptr;)
+ MainLoop();
+ Heart->Enable = false;
+ if (KEYBOARD::Last() == Enter && *UsrFnam)
+ usr_ok = true;
+ if (usr_ok)
+ strcat(UsrFnam, SVG_EXT);
+ //Mouse.Off();
+ Vga->ShowQ->Clear();
+ Vga->CopyPage(0, 2);
#endif
- //-----------------------------------------
- Movie("X00"); // paylist
- Vga->CopyPage(1, 2);
- Vga->CopyPage(0, 1);
- Vga->ShowQ->Append(Mouse);
- //Mouse.On();
- Heart->Enable = true;
- for (TakeName(); GET_TEXT::Ptr;)
- MainLoop();
- Heart->Enable = false;
- if (KEYBOARD::Last() == Enter && *UsrFnam)
- usr_ok = true;
- if (usr_ok)
- strcat(UsrFnam, SVG_EXT);
- //Mouse.Off();
- Vga->ShowQ->Clear();
- Vga->CopyPage(0, 2);
-#endif
+ }
+
if (usr_ok && STARTUP::Mode == 0) {
const char *n = UsrPath(UsrFnam);
if (CFILE::Exist(n)) {
@@ -1809,11 +1807,10 @@ bool ShowTitle(const char *name) {
Vga->CopyPage(0, 2);
-#ifdef DEMO
- return true;
-#else
- return (STARTUP::Mode == 2 || usr_ok);
-#endif
+ if (_isDemo)
+ return true;
+ else
+ return (STARTUP::Mode == 2 || usr_ok);
}
@@ -1825,7 +1822,7 @@ void StkDump (void) {
*/
-void cge_main(void) {
+void CGEEngine::cge_main(void) {
uint16 intStack[STACK_SIZ / 2];
intStackPtr = intStack;
@@ -1842,17 +1839,15 @@ void cge_main(void) {
HorzLine->Flags.Hide = true;
//srand((uint16) Timer());
- Sys = new SYSTEM;
+ Sys = new SYSTEM(this);
if (Music && STARTUP::SoundOk)
LoadMIDI(0);
if (STARTUP::Mode < 2)
Movie(LGO_EXT);
if (ShowTitle("WELCOME")) {
-#ifndef DEMO
- if (STARTUP::Mode == 1)
+ if ((!_isDemo) && (STARTUP::Mode == 1))
Movie("X02"); // intro
-#endif
RunGame();
Startup = 2;
if (FINIS)
diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h
index f3a95e786c..146c3cb6c9 100644
--- a/engines/cge/cge_main.h
+++ b/engines/cge/cge_main.h
@@ -35,11 +35,11 @@
namespace CGE {
#define TSEQ 96
-#define HTALK (TSEQ+4)
-#define TOO_FAR (TSEQ+5)
-#define NO_WAY (TSEQ+5)
-#define POC_FUL (TSEQ+5)
-#define OFF_USE (TSEQ+6)
+#define HTALK (TSEQ + 4)
+#define TOO_FAR (TSEQ + 5)
+#define NO_WAY (TSEQ + 5)
+#define POC_FUL (TSEQ + 5)
+#define OFF_USE (TSEQ + 6)
#define EXIT_OK_TEXT 40
#define NOMUSIC_TEXT 98
#define BADSVG_TEXT 99
@@ -57,25 +57,21 @@ namespace CGE {
#define DEMO_TEXT 300
#define NOSOUND_TEXT 310
#define PAN_HIG 40
-#define WORLD_HIG (SCR_HIG-PAN_HIG)
+#define WORLD_HIG (SCR_HIG - PAN_HIG)
#define INFO_X 177
#define INFO_Y 164
#define INFO_W 140
-
-#if defined(DEMO)
#define CAVE_X 4
#define CAVE_Y 166
#define CAVE_SX 0
#define CAVE_SY 0
+
+#ifdef DEMO
#define CAVE_DX 23
#define CAVE_DY 29
#define CAVE_NX 3
#define CAVE_NY 1
#else
-#define CAVE_X 4
-#define CAVE_Y 166
-#define CAVE_SX 0
-#define CAVE_SY 0
#define CAVE_DX 9
#define CAVE_DY 10
#define CAVE_NX 8
@@ -101,7 +97,7 @@ namespace CGE {
#define SHP_MAX 1024
#define STD_DELAY 3
#define LEV_MAX 5
-#define CAVE_MAX (CAVE_NX*CAVE_NY)
+#define CAVE_MAX (CAVE_NX * CAVE_NY)
#define MAX_FIND_LEVEL 3
#define MAX_DISTANCE 3
#define INI_EXT ".INI"
@@ -111,8 +107,8 @@ namespace CGE {
#define WALKSIDE 10
#define BUSY_REF 500
#define SYSTIMERATE 6 // 12 Hz
-#define HEROFUN0 (40*12)
-#define HEROFUN1 ( 2*12)
+#define HEROFUN0 (40 * 12)
+#define HEROFUN1 ( 2 * 12)
#define PAIN (Flag[0])
#define FINIS (Flag[3])
@@ -122,12 +118,14 @@ class SYSTEM : public SPRITE {
public:
int FunDel;
- SYSTEM();
+ SYSTEM(CGEEngine *vm);
void SetPal();
void FunTouch();
void Touch(uint16 mask, int x, int y);
void Tick();
+private:
+ CGEEngine *_vm;
};
@@ -144,9 +142,10 @@ public:
class WALK : public SPRITE {
public:
CLUSTER Here;
- enum DIR { NO_DIR = -1, NN, EE, SS, WW } Dir;
int TracePtr;
- WALK(BMP_PTR *shpl);
+
+ enum DIR { NO_DIR = -1, NN, EE, SS, WW } Dir;
+ WALK(CGEEngine *vm, BMP_PTR *shpl);
void Tick(void);
void FindWay(CLUSTER c);
void FindWay(SPRITE *spr);
@@ -155,6 +154,9 @@ public:
void Park(void);
bool Lower(SPRITE *spr);
void Reach(SPRITE *spr, int mode = -1);
+private:
+ CGEEngine *_vm;
+
};
@@ -163,7 +165,6 @@ CLUSTER XZ(COUPLE xy);
void ExpandSprite(SPRITE *spr);
void ContractSprite(SPRITE *spr);
-void cge_main(void);
extern WALK *Hero;
extern VGA *Vga;
diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp
index fe2d1bc16e..4aa4f40c8a 100644
--- a/engines/cge/config.cpp
+++ b/engines/cge/config.cpp
@@ -78,83 +78,83 @@ static int DevName[] = {
};
static CHOICE DevMenu[] = {
- { NULL, NONE },
- { NULL, SB },
- { NULL, SBM },
- { NULL, GUS },
- { NULL, GUSM },
- { NULL, MIDI },
- { NULL, AUTO },
- { NULL, NULL }
+ { NULL, &CGEEngine::NONE },
+ { NULL, &CGEEngine::SB },
+ { NULL, &CGEEngine::SBM },
+ { NULL, &CGEEngine::GUS },
+ { NULL, &CGEEngine::GUSM },
+ { NULL, &CGEEngine::MIDI },
+ { NULL, &CGEEngine::AUTO },
+ { NULL, NULL }
};
static CHOICE DigiPorts[] = {
- { " 210h", SetPortD },
- { " 220h", SetPortD },
- { " 230h", SetPortD },
- { " 240h", SetPortD },
- { " 250h", SetPortD },
- { " 260h", SetPortD },
- { "AUTO ", SetPortD },
+ { " 210h", &CGEEngine::SetPortD },
+ { " 220h", &CGEEngine::SetPortD },
+ { " 230h", &CGEEngine::SetPortD },
+ { " 240h", &CGEEngine::SetPortD },
+ { " 250h", &CGEEngine::SetPortD },
+ { " 260h", &CGEEngine::SetPortD },
+ { "AUTO ", &CGEEngine::SetPortD },
{ NULL, NULL }
};
static CHOICE MIDIPorts[] = {
- { " 220h", SetPortM },
- { " 230h", SetPortM },
- { " 240h", SetPortM },
- { " 250h", SetPortM },
- { " 300h", SetPortM },
- { " 320h", SetPortM },
- { " 330h", SetPortM },
- { " 340h", SetPortM },
- { " 350h", SetPortM },
- { " 360h", SetPortM },
- { "AUTO ", SetPortM },
+ { " 220h", &CGEEngine::SetPortM },
+ { " 230h", &CGEEngine::SetPortM },
+ { " 240h", &CGEEngine::SetPortM },
+ { " 250h", &CGEEngine::SetPortM },
+ { " 300h", &CGEEngine::SetPortM },
+ { " 320h", &CGEEngine::SetPortM },
+ { " 330h", &CGEEngine::SetPortM },
+ { " 340h", &CGEEngine::SetPortM },
+ { " 350h", &CGEEngine::SetPortM },
+ { " 360h", &CGEEngine::SetPortM },
+ { "AUTO ", &CGEEngine::SetPortM },
{ NULL, NULL }
};
static CHOICE BlsterIRQ[] = {
- { "IRQ 2", SetIRQ },
- { "IRQ 5", SetIRQ },
- { "IRQ 7", SetIRQ },
- { "IRQ 10", SetIRQ },
- { "AUTO ", SetIRQ },
+ { "IRQ 2", &CGEEngine::SetIRQ },
+ { "IRQ 5", &CGEEngine::SetIRQ },
+ { "IRQ 7", &CGEEngine::SetIRQ },
+ { "IRQ 10", &CGEEngine::SetIRQ },
+ { "AUTO ", &CGEEngine::SetIRQ },
{ NULL, NULL }
};
static CHOICE GravisIRQ[] = {
- { "IRQ 2", SetIRQ },
- { "IRQ 5", SetIRQ },
- { "IRQ 7", SetIRQ },
- { "IRQ 11", SetIRQ },
- { "IRQ 12", SetIRQ },
- { "IRQ 15", SetIRQ },
- { "AUTO ", SetIRQ },
+ { "IRQ 2", &CGEEngine::SetIRQ },
+ { "IRQ 5", &CGEEngine::SetIRQ },
+ { "IRQ 7", &CGEEngine::SetIRQ },
+ { "IRQ 11", &CGEEngine::SetIRQ },
+ { "IRQ 12", &CGEEngine::SetIRQ },
+ { "IRQ 15", &CGEEngine::SetIRQ },
+ { "AUTO ", &CGEEngine::SetIRQ },
{ NULL, NULL }
};
static CHOICE GravisDMA[] = {
- { "DMA 1", SetDMA },
- { "DMA 3", SetDMA },
- { "DMA 5", SetDMA },
- { "DMA 6", SetDMA },
- { "DMA 7", SetDMA },
- { "AUTO ", SetDMA },
+ { "DMA 1", &CGEEngine::SetDMA },
+ { "DMA 3", &CGEEngine::SetDMA },
+ { "DMA 5", &CGEEngine::SetDMA },
+ { "DMA 6", &CGEEngine::SetDMA },
+ { "DMA 7", &CGEEngine::SetDMA },
+ { "AUTO ", &CGEEngine::SetDMA },
{ NULL, NULL }
};
static CHOICE BlsterDMA[] = {
- { "DMA 0", SetDMA },
- { "DMA 1", SetDMA },
- { "DMA 3", SetDMA },
- { "AUTO ", SetDMA },
+ { "DMA 0", &CGEEngine::SetDMA },
+ { "DMA 1", &CGEEngine::SetDMA },
+ { "DMA 3", &CGEEngine::SetDMA },
+ { "AUTO ", &CGEEngine::SetDMA },
{ NULL, NULL }
};
-void SelectSound(void) {
+void CGEEngine::SelectSound() {
int i;
Sound.Close();
if (VMENU::Addr)
@@ -163,7 +163,7 @@ void SelectSound(void) {
Talk->Goto(Talk->X, FONT_HIG / 2);
for (i = 0; i < ArrayCount(DevName); i++)
DevMenu[i].Text = Text->getText(DevName[i]);
- (new VMENU(DevMenu, SCR_WID / 2, Talk->Y + Talk->H + TEXT_VM + FONT_HIG))->SetName(Text->getText(MENU_TEXT));
+ (new VMENU(this, DevMenu, SCR_WID / 2, Talk->Y + Talk->H + TEXT_VM + FONT_HIG))->SetName(Text->getText(MENU_TEXT));
}
@@ -195,10 +195,10 @@ static uint16 xdeco(const char *str) {
static CHOICE *Cho;
static int Hlp;
-static void SNSelect(void) {
+void CGEEngine::SNSelect() {
Inf(Text->getText(Hlp));
Talk->Goto(Talk->X, FONT_HIG / 2);
- (new VMENU(Cho, SCR_WID / 2, Talk->Y + Talk->H + TEXT_VM + FONT_HIG))->SetName(Text->getText(MENU_TEXT));
+ (new VMENU(this, Cho, SCR_WID / 2, Talk->Y + Talk->H + TEXT_VM + FONT_HIG))->SetName(Text->getText(MENU_TEXT));
}
@@ -211,14 +211,14 @@ static void Select(CHOICE *cho, int hlp) {
}
-static void NONE(void) {
+void CGEEngine::NONE() {
SNDDrvInfo.DDEV = DEV_QUIET;
SNDDrvInfo.MDEV = DEV_QUIET;
Sound.Open();
}
-static void SB(void) {
+void CGEEngine::SB() {
SNDDrvInfo.DDEV = DEV_SB;
SNDDrvInfo.MDEV = DEV_SB;
Reset();
@@ -226,7 +226,7 @@ static void SB(void) {
}
-static void SBM(void) {
+void CGEEngine::SBM() {
SNDDrvInfo.DDEV = DEV_SB;
SNDDrvInfo.MDEV = DEV_GM;
Reset();
@@ -234,7 +234,7 @@ static void SBM(void) {
}
-static void GUS(void) {
+void CGEEngine::GUS() {
SNDDrvInfo.DDEV = DEV_GUS;
SNDDrvInfo.MDEV = DEV_GUS;
Reset();
@@ -242,7 +242,7 @@ static void GUS(void) {
}
-static void GUSM(void) {
+void CGEEngine::GUSM() {
SNDDrvInfo.DDEV = DEV_GUS;
SNDDrvInfo.MDEV = DEV_GM;
Reset();
@@ -250,7 +250,7 @@ static void GUSM(void) {
}
-static void MIDI(void) {
+void CGEEngine::MIDI() {
SNDDrvInfo.DDEV = DEV_QUIET;
SNDDrvInfo.MDEV = DEV_GM;
SNDDrvInfo.MBASE = DETECT;
@@ -258,7 +258,7 @@ static void MIDI(void) {
}
-static void AUTO(void) {
+void CGEEngine::AUTO() {
SNDDrvInfo.DDEV = DEV_AUTO;
SNDDrvInfo.MDEV = DEV_AUTO;
Reset();
@@ -266,25 +266,25 @@ static void AUTO(void) {
}
-static void SetPortD(void) {
+void CGEEngine::SetPortD() {
SNDDrvInfo.DBASE = xdeco(DigiPorts[VMENU::Recent].Text);
Select((SNDDrvInfo.DDEV == DEV_SB) ? BlsterIRQ : GravisIRQ, SIRQ_TEXT);
}
-static void SetPortM(void) {
+void CGEEngine::SetPortM() {
SNDDrvInfo.MBASE = xdeco(MIDIPorts[VMENU::Recent].Text);
Sound.Open();
}
-static void SetIRQ(void) {
+void CGEEngine::SetIRQ() {
SNDDrvInfo.DIRQ = ddeco(((SNDDrvInfo.DDEV == DEV_SB) ? BlsterIRQ : GravisIRQ)[VMENU::Recent].Text);
Select((SNDDrvInfo.DDEV == DEV_SB) ? BlsterDMA : GravisDMA, SDMA_TEXT);
}
-static void SetDMA(void) {
+void CGEEngine::SetDMA() {
SNDDrvInfo.DDMA = ddeco(((SNDDrvInfo.DDEV == DEV_SB) ? BlsterDMA : GravisDMA)[VMENU::Recent].Text);
if (SNDDrvInfo.MDEV != SNDDrvInfo.DDEV)
Select(MIDIPorts, MPORT_TEXT);
diff --git a/engines/cge/detection.cpp b/engines/cge/detection.cpp
index bebb342c03..f03a42fb35 100644
--- a/engines/cge/detection.cpp
+++ b/engines/cge/detection.cpp
@@ -64,7 +64,7 @@ static const ADGameDescription gameDescriptions[] = {
{"vol.dat", 0, "75d385a6074c58b69f7730481f256051", 1796710},
AD_LISTEND
},
- Common::PL_POL, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE
+ Common::PL_POL, Common::kPlatformPC, ADGF_DEMO, GUIO_NONE
},
{
"soltys", "Soltys Demo",
@@ -73,7 +73,7 @@ static const ADGameDescription gameDescriptions[] = {
{"vol.dat", 0, "c5d9b15863cab61dc125551576dece04", 1075272},
AD_LISTEND
},
- Common::PL_POL, Common::kPlatformPC, ADGF_NO_FLAGS, GUIO_NONE
+ Common::PL_POL, Common::kPlatformPC, ADGF_DEMO, GUIO_NONE
},
AD_TABLE_END_MARKER
};
diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp
index afa6fbeed0..21e8ceddeb 100644
--- a/engines/cge/game.cpp
+++ b/engines/cge/game.cpp
@@ -67,8 +67,8 @@ int FLY::L = 20,
FLY::B = 100;
-FLY::FLY(BITMAP **shpl)
- : SPRITE(shpl), Tx(0), Ty(0) {
+FLY::FLY(CGEEngine *vm, BITMAP **shpl)
+ : SPRITE(vm, shpl), Tx(0), Ty(0), _vm(vm) {
Step(new_random(2));
Goto(L + new_random(R - L - W), T + new_random(B - T - H));
}
diff --git a/engines/cge/game.h b/engines/cge/game.h
index 1d65d0c767..7892b1c93f 100644
--- a/engines/cge/game.h
+++ b/engines/cge/game.h
@@ -48,8 +48,10 @@ class FLY : public SPRITE {
static int L, T, R, B;
public:
int Tx, Ty;
- FLY(BITMAP **shpl);
+ FLY(CGEEngine *vm, BITMAP **shpl);
void Tick(void);
+private:
+ CGEEngine *_vm;
};
} // End of namespace CGE
diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp
index b6b47a05f9..69e19b175c 100644
--- a/engines/cge/gettext.cpp
+++ b/engines/cge/gettext.cpp
@@ -36,9 +36,9 @@ namespace CGE {
GET_TEXT *GET_TEXT::Ptr = NULL;
-GET_TEXT::GET_TEXT(const char *info, char *text, int size, void (*click)(void))
- : Text(text), Size(min<int>(size, GTMAX)), Len(min<int>(Size, strlen(text))),
- Cntr(GTBLINK), Click(click), OldKeybClient(KEYBOARD::SetClient(this)) {
+GET_TEXT::GET_TEXT(CGEEngine *vm, const char *info, char *text, int size, void (*click)(void))
+ : 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) {
int i = 2 * TEXT_HM + Font->Width(info);
Ptr = this;
Mode = RECT;
diff --git a/engines/cge/gettext.h b/engines/cge/gettext.h
index 3fc7e4ff34..c868232677 100644
--- a/engines/cge/gettext.h
+++ b/engines/cge/gettext.h
@@ -42,13 +42,16 @@ class GET_TEXT : public TALK {
uint16 Size, Len;
uint16 Cntr;
SPRITE *OldKeybClient;
- void (*Click)(void);
+ void (*Click)();
public:
static GET_TEXT *Ptr;
- GET_TEXT(const char *info, char *text, int size, void (*click)(void) = NULL);
- ~GET_TEXT(void);
+ GET_TEXT(CGEEngine *vm, const char *info, char *text, int size, void (*click)(void) = NULL);
+ ~GET_TEXT();
void Touch(uint16 mask, int x, int y);
- void Tick(void);
+ void Tick();
+
+private:
+ CGEEngine *_vm;
};
} // End of namespace CGE
diff --git a/engines/cge/jbw.h b/engines/cge/jbw.h
index 4c96507ab7..12c6609f4e 100644
--- a/engines/cge/jbw.h
+++ b/engines/cge/jbw.h
@@ -34,7 +34,6 @@ namespace CGE {
// Defines found in cge.mak
#define VOL
-//#define DEMO
#define INI_FILE VFILE // Or is it CFILE?
#define PIC_FILE VFILE
#define BMP_MODE 0
@@ -56,7 +55,7 @@ namespace CGE {
#define IsAlNum(c) (IsAlpha(c) || IsDigit(c))
#define IsHxDig(c) (IsDigit(c) || ((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f'))
-#define farnew(t,n) ((t *) malloc(sizeof(t) * (n)))
+#define farnew(t, n) ((t *) malloc(sizeof(t) * (n)))
#define ArrayCount(a) (sizeof(a) / sizeof((a)[0]))
#define MAX_TIMER 0x1800B0L
@@ -141,12 +140,6 @@ struct KeyStatStruct {
#define PostFlag (*((volatile uint16 *) ((void _seg *) 0x40 + (void *) 0x72)))
#define POST ((void (*)(void)) ((void _seg *) 0xF000 + (void *) 0xFFF0))
-#ifdef DEMO
-#define Demo(x) x
-#else
-#define Demo(x)
-#endif
-
#ifdef __cplusplus
#define EC extern "C"
diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp
index e0a4409a86..864fb6cdba 100644
--- a/engines/cge/mixer.cpp
+++ b/engines/cge/mixer.cpp
@@ -40,7 +40,7 @@ extern MOUSE *Mouse;
bool MIXER::Appear = false;
-MIXER::MIXER(int x, int y) : SPRITE(NULL), Fall(MIX_FALL) {
+MIXER::MIXER(CGEEngine *vm, int x, int y) : SPRITE(vm, NULL), Fall(MIX_FALL), _vm(vm) {
Appear = true;
mb[0] = new BITMAP("VOLUME");
mb[1] = NULL;
@@ -65,7 +65,7 @@ MIXER::MIXER(int x, int y) : SPRITE(NULL), Fall(MIX_FALL) {
lb[i] = NULL;
for (i = 0; i < ArrayCount(Led); i++) {
- register SPRITE *spr = new SPRITE(lb);
+ register SPRITE *spr = new SPRITE(_vm, lb);
spr->SetSeq(ls);
spr->Goto(x + 2 + 12 * i, y + 8);
spr->Flags.Tran = true;
diff --git a/engines/cge/mixer.h b/engines/cge/mixer.h
index 81bc7c7cdf..d589aceaea 100644
--- a/engines/cge/mixer.h
+++ b/engines/cge/mixer.h
@@ -48,10 +48,12 @@ class MIXER : public SPRITE {
void Update(void);
public:
static bool Appear;
- MIXER(int x, int y);
- ~MIXER(void);
+ MIXER(CGEEngine *vm, int x, int y);
+ ~MIXER();
void Touch(uint16 mask, int x, int y);
- void Tick(void);
+ void Tick();
+private:
+ CGEEngine *_vm;
};
} // End of namespace CGE
diff --git a/engines/cge/mouse.cpp b/engines/cge/mouse.cpp
index 8ad12742d3..10953291f2 100644
--- a/engines/cge/mouse.cpp
+++ b/engines/cge/mouse.cpp
@@ -39,7 +39,7 @@ MOUSE_FUN *MOUSE::OldMouseFun = NULL;
uint16 MOUSE::OldMouseMask = 0;
-MOUSE::MOUSE(BITMAP **shpl) : SPRITE(shpl), Busy(NULL), Hold(NULL), hx(0) {
+MOUSE::MOUSE(CGEEngine *vm, BITMAP **shpl) : SPRITE(vm, shpl), Busy(NULL), Hold(NULL), hx(0), _vm(vm) {
static SEQ ms[] = {
{ 0, 0, 0, 0, 1 },
{ 1, 1, 0, 0, 1 }
diff --git a/engines/cge/mouse.h b/engines/cge/mouse.h
index 78f43665cd..61503fadd1 100644
--- a/engines/cge/mouse.h
+++ b/engines/cge/mouse.h
@@ -69,12 +69,14 @@ public:
int Buttons;
SPRITE *Busy;
//SPRITE * Touched;
- MOUSE(BITMAP **shpl = MC);
- ~MOUSE(void);
- void On(void);
- void Off(void);
+ MOUSE(CGEEngine *vm, BITMAP **shpl = MC);
+ ~MOUSE();
+ void On();
+ void Off();
static void ClrEvt(SPRITE *spr = NULL);
- void Tick(void);
+ void Tick();
+private:
+ CGEEngine *_vm;
};
} // End of namespace CGE
diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp
index cc79dfcc62..7325d767b4 100644
--- a/engines/cge/snail.cpp
+++ b/engines/cge/snail.cpp
@@ -424,10 +424,10 @@ const char *SNAIL::ComTxt[] = {
};
-SNAIL::SNAIL(bool turbo)
+SNAIL::SNAIL(CGEEngine *vm, bool turbo)
: Turbo(turbo), Busy(false), TextDelay(false),
Pause(0), TalkEnable(true),
- Head(0), Tail(0), SNList(farnew(COM, 256)) {
+ Head(0), Tail(0), SNList(farnew(COM, 256)), _vm(vm) {
}
@@ -907,7 +907,6 @@ static void SNMouse(bool on) {
void SNAIL::RunCom(void) {
static int count = 1;
-// extern void SwitchCave(int);
if (! Busy) {
Busy = true;
uint8 tmphea = Head;
@@ -955,13 +954,13 @@ void SNAIL::RunCom(void) {
if (sprel && TalkEnable) {
if (sprel == Hero && sprel->SeqTest(-1))
sprel->Step(HTALK);
- Say(Text->getText(snc->Val), sprel);
+ Text->Say(Text->getText(snc->Val), sprel);
Sys->FunDel = HEROFUN0;
}
break;
case SNINF :
if (TalkEnable) {
- Inf(Text->getText(snc->Val));
+ _vm->Inf(Text->getText(snc->Val));
Sys->FunDel = HEROFUN0;
}
break;
diff --git a/engines/cge/snail.h b/engines/cge/snail.h
index 54c7809fda..9449a8081e 100644
--- a/engines/cge/snail.h
+++ b/engines/cge/snail.h
@@ -29,6 +29,7 @@
#define __SNAIL__
#include "cge/jbw.h"
+#include "cge/cge.h"
namespace CGE {
@@ -89,12 +90,14 @@ public:
uint16 Pause;
static const char *ComTxt[];
bool TalkEnable;
- SNAIL(bool turbo = false);
- ~SNAIL(void);
+ SNAIL(CGEEngine *vm, bool turbo = false);
+ ~SNAIL();
void RunCom(void);
void AddCom(SNCOM com, int ref = 0, int val = 0, void *ptr = NULL);
void InsCom(SNCOM com, int ref = 0, int val = 0, void *ptr = NULL);
bool Idle(void);
+private:
+ CGEEngine *_vm;
};
diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp
index 9f162d0e6c..b67d9082ac 100644
--- a/engines/cge/talk.cpp
+++ b/engines/cge/talk.cpp
@@ -97,8 +97,8 @@ void FONT::Save(void) {
*/
-TALK::TALK(const char *tx, TBOX_STYLE mode)
- : SPRITE(NULL), Mode(mode) {
+TALK::TALK(CGEEngine *vm, const char *tx, TBOX_STYLE mode)
+ : SPRITE(vm, NULL), Mode(mode), _vm(vm) {
TS[0] = TS[1] = NULL;
Flags.Syst = true;
Update(tx);
@@ -106,8 +106,8 @@ TALK::TALK(const char *tx, TBOX_STYLE mode)
}
-TALK::TALK(void)
- : SPRITE(NULL), Mode(PURE) {
+TALK::TALK(CGEEngine *vm)
+ : SPRITE(vm, NULL), Mode(PURE), _vm(vm) {
TS[0] = TS[1] = NULL;
Flags.Syst = true;
}
@@ -275,7 +275,7 @@ void TALK::PutLine(int line, const char *text) {
}
-INFO_LINE::INFO_LINE(uint16 w) : OldTxt(NULL) {
+INFO_LINE::INFO_LINE(CGEEngine *vm, uint16 w) : TALK(vm), OldTxt(NULL), _vm(vm) {
TS[0] = new BITMAP(w, FONT_HIG, TEXT_BG);
SetShapeList(TS);
}
diff --git a/engines/cge/talk.h b/engines/cge/talk.h
index 67b4fc91d6..ba4952c3e6 100644
--- a/engines/cge/talk.h
+++ b/engines/cge/talk.h
@@ -75,20 +75,24 @@ protected:
BITMAP *Box(uint16 w, uint16 h);
public:
FONT *Font;
- TALK(const char *tx, TBOX_STYLE mode = PURE);
- TALK(void);
+ TALK(CGEEngine *vm, const char *tx, TBOX_STYLE mode = PURE);
+ TALK(CGEEngine *vm);
//~TALK (void);
virtual void Update(const char *tx);
virtual void Update(void) {}
void PutLine(int line, const char *text);
+private:
+ CGEEngine *_vm;
};
class INFO_LINE : public TALK {
const char *OldTxt;
public:
- INFO_LINE(uint16 wid);
+ INFO_LINE(CGEEngine *vm, uint16 wid);
void Update(const char *tx);
+private:
+ CGEEngine *_vm;
};
} // End of namespace CGE
diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp
index a8bf0d0cf8..6d7341af0a 100644
--- a/engines/cge/text.cpp
+++ b/engines/cge/text.cpp
@@ -42,7 +42,7 @@ namespace CGE {
TEXT *Text;
TALK *Talk = NULL;
-TEXT::TEXT(const char *fname, int size) {
+TEXT::TEXT(CGEEngine *vm, const char *fname, int size) : _vm(vm) {
Cache = new HAN[size];
MergeExt(FileName, fname, SAY_EXT);
if (!INI_FILE::Exist(FileName))
@@ -55,7 +55,7 @@ TEXT::TEXT(const char *fname, int size) {
}
-TEXT::~TEXT(void) {
+TEXT::~TEXT() {
Clear();
delete[] Cache;
}
@@ -180,14 +180,14 @@ char *TEXT::getText(int ref) {
}
-void Say(const char *txt, SPRITE *spr) {
+void TEXT::Say(const char *txt, SPRITE *spr) {
KillText();
- Talk = new TALK(txt, ROUND);
+ Talk = new TALK(_vm, txt, ROUND);
if (Talk) {
bool east = spr->Flags.East;
int x = (east) ? (spr->X + spr->W - 2) : (spr->X + 2);
int y = spr->Y + 2;
- SPRITE *spike = new SPRITE(SP);
+ SPRITE *spike = new SPRITE(_vm, SP);
uint16 sw = spike->W;
if (east) {
@@ -221,9 +221,9 @@ void Say(const char *txt, SPRITE *spr) {
}
}
-void Inf(const char *txt) {
+void CGEEngine::Inf(const char *txt) {
KillText();
- Talk = new TALK(txt, RECT);
+ Talk = new TALK(this, txt, RECT);
if (Talk) {
Talk->Flags.Kill = true;
Talk->Flags.BDel = true;
diff --git a/engines/cge/text.h b/engines/cge/text.h
index 64e3b1d669..161b2e813a 100644
--- a/engines/cge/text.h
+++ b/engines/cge/text.h
@@ -61,11 +61,14 @@ class TEXT {
char *Load(int idx, int ref);
int Find(int ref);
public:
- TEXT(const char *fname, int size);
+ TEXT(CGEEngine *vm, const char *fname, int size);
~TEXT(void);
void Clear(int from = 1, int upto = 0x7FFF);
void Preload(int from = 1, int upto = 0x7FFF);
char *getText(int ref);
+ void Say(const char *txt, SPRITE *spr);
+private:
+ CGEEngine *_vm;
};
diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp
index d7c6946e87..1038cd2631 100644
--- a/engines/cge/vga13h.cpp
+++ b/engines/cge/vga13h.cpp
@@ -35,6 +35,7 @@
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
+#include "cge/cge.h"
namespace CGE {
@@ -345,10 +346,10 @@ void HEART::SetXTimer(uint16 *ptr, uint16 time) {
}
-SPRITE::SPRITE(BMP_PTR *shp)
+SPRITE::SPRITE(CGEEngine *vm, BMP_PTR *shp)
: X(0), Y(0), Z(0), NearPtr(0), TakePtr(0),
Next(NULL), Prev(NULL), SeqPtr(NO_SEQ), Time(0), //Delay(0),
- Ext(NULL), Ref(-1), Cave(0) {
+ Ext(NULL), Ref(-1), Cave(0), _vm(vm) {
memset(File, 0, sizeof(File));
*((uint16 *)&Flags) = 0;
SetShapeList(shp);
diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h
index d5bbf3972e..7d23954059 100644
--- a/engines/cge/vga13h.h
+++ b/engines/cge/vga13h.h
@@ -32,6 +32,7 @@
#include <stddef.h>
#include "cge/bitmap.h"
#include "cge/snail.h"
+#include "cge/cge.h"
namespace CGE {
@@ -197,7 +198,7 @@ public:
inline bool Active(void) {
return Ext != NULL;
}
- SPRITE(BMP_PTR *shp);
+ SPRITE(CGEEngine *vm, BMP_PTR *shp);
virtual ~SPRITE(void);
BMP_PTR Shp(void);
BMP_PTR *SetShapeList(BMP_PTR *shp);
@@ -222,6 +223,8 @@ public:
SNAIL::COM *SnList(SNLIST type);
virtual void Touch(uint16 mask, int x, int y);
virtual void Tick(void);
+private:
+ CGEEngine *_vm;
};
diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp
index e2b2a29515..7db5a79f85 100644
--- a/engines/cge/vmenu.cpp
+++ b/engines/cge/vmenu.cpp
@@ -45,7 +45,7 @@ namespace CGE {
-MENU_BAR::MENU_BAR(uint16 w) {
+MENU_BAR::MENU_BAR(CGEEngine *vm, uint16 w) : TALK(vm), _vm(vm) {
int h = FONT_HIG + 2 * MB_VM, i = (w += 2 * MB_HM) * h;
uint8 *p = farnew(uint8, i), * p1, * p2;
@@ -98,8 +98,8 @@ VMENU *VMENU::Addr = NULL;
int VMENU::Recent = -1;
-VMENU::VMENU(CHOICE *list, int x, int y)
- : TALK(VMGather(list), RECT), Menu(list), Bar(NULL) {
+VMENU::VMENU(CGEEngine *vm, CHOICE *list, int x, int y)
+ : TALK(vm, VMGather(list), RECT), Menu(list), Bar(NULL), _vm(vm) {
CHOICE *cp;
Addr = this;
@@ -114,7 +114,7 @@ VMENU::VMENU(CHOICE *list, int x, int y)
else
Goto(x - W / 2, y - (TEXT_VM + FONT_HIG / 2));
Vga->ShowQ->Insert(this, Vga->ShowQ->Last());
- Bar = new MENU_BAR(W - 2 * TEXT_HM);
+ Bar = new MENU_BAR(_vm, W - 2 * TEXT_HM);
Bar->Goto(X + TEXT_HM - MB_HM, Y + TEXT_VM - MB_VM);
Vga->ShowQ->Insert(Bar, Vga->ShowQ->Last());
}
@@ -126,7 +126,7 @@ VMENU::~VMENU(void) {
void VMENU::Touch(uint16 mask, int x, int y) {
-#define h (FONT_HIG + TEXT_LS)
+ uint16 h = FONT_HIG + TEXT_LS;
bool ok = false;
if (Items) {
@@ -147,10 +147,10 @@ void VMENU::Touch(uint16 mask, int x, int y) {
if (ok && (mask & L_UP)) {
Items = 0;
SNPOST_(SNKILL, -1, 0, this);
- Menu[Recent = n].Proc();
+ //Menu[Recent = n].Proc();
+ warning("Missing call to proc()");
}
}
-#undef h
}
} // End of namespace CGE
diff --git a/engines/cge/vmenu.h b/engines/cge/vmenu.h
index ecec9d51b5..61645d2c55 100644
--- a/engines/cge/vmenu.h
+++ b/engines/cge/vmenu.h
@@ -38,13 +38,15 @@ namespace CGE {
typedef struct {
char *Text;
- void (* Proc)(void);
+ void (CGEEngine::*Proc)();
} CHOICE;
class MENU_BAR : public TALK {
public:
- MENU_BAR(uint16 w);
+ MENU_BAR(CGEEngine *vm, uint16 w);
+private:
+ CGEEngine *_vm;
};
@@ -55,9 +57,11 @@ public:
static VMENU *Addr;
static int Recent;
MENU_BAR *Bar;
- VMENU(CHOICE *list, int x, int y);
- ~VMENU(void);
+ VMENU(CGEEngine *vm, CHOICE *list, int x, int y);
+ ~VMENU();
void Touch(uint16 mask, int x, int y);
+private:
+ CGEEngine *_vm;
};
} // End of namespace CGE