CGE: Cleanup and renaming. Also move some static and global functions to CGEEngine.

This commit is contained in:
Strangerke 2011-07-05 23:13:12 +02:00 committed by Alyssa Milburn
parent 2997db0040
commit c86c62b288
19 changed files with 281 additions and 260 deletions

View File

@ -142,7 +142,7 @@ Bitmap::Bitmap(const Bitmap &bmp) : _w(bmp._w), _h(bmp._h), _m(NULL), _v(NULL) {
}
Bitmap::~Bitmap(void) {
Bitmap::~Bitmap() {
if (memType(_m) == FAR_MEM)
free(_m);
@ -196,7 +196,7 @@ uint16 Bitmap::moveVmap(uint8 *buf) {
}
BMP_PTR Bitmap::code(void) {
BMP_PTR Bitmap::code() {
if (_m) {
uint16 i, cnt;

View File

@ -52,7 +52,7 @@ BtFile::BtFile(const char *name, IOMODE mode, CRYPT *crpt)
}
BtFile::~BtFile(void) {
BtFile::~BtFile() {
for (int i = 0; i < BT_LEVELS; i++) {
putPage(i, false);
delete _buff[i]._page;

View File

@ -51,7 +51,7 @@ IoBuf::IoBuf(const char *name, IOMODE mode, CRYPT *crpt)
error("No core for I/O [%s]", name);
}
IoBuf::~IoBuf(void) {
IoBuf::~IoBuf() {
if (_mode > REA)
writeBuff();
if (_buff)
@ -59,14 +59,14 @@ IoBuf::~IoBuf(void) {
}
void IoBuf::readBuff(void) {
void IoBuf::readBuff() {
_bufMark = IoHand::mark();
_lim = IoHand::read(_buff, IOBUF_SIZE);
_ptr = 0;
}
void IoBuf::writeBuff(void) {
void IoBuf::writeBuff() {
if (_lim) {
IoHand::write(_buff, _lim);
_bufMark = IoHand::mark();
@ -203,11 +203,11 @@ CFile::CFile(const char *name, IOMODE mode, CRYPT *crpt)
}
CFile::~CFile(void) {
CFile::~CFile() {
}
void CFile::flush(void) {
void CFile::flush() {
if (_mode > REA)
writeBuff();
else
@ -222,7 +222,7 @@ void CFile::flush(void) {
}
long CFile::mark(void) {
long CFile::mark() {
return _bufMark + ((_mode > REA) ? _lim : _ptr);
}

View File

@ -167,6 +167,27 @@ void CGEEngine::setup() {
_savTab[15].Ptr = NULL;
_savTab[15].Len = 0;
_savTab[15].Flg = 0;
if (_isDemo) {
_maxCaveArr[0] = CAVE_MAX;
_maxCaveArr[1] = -1;
_maxCaveArr[2] = -1;
_maxCaveArr[3] = -1;
_maxCaveArr[4] = -1;
} else {
_maxCaveArr[0] = 1;
_maxCaveArr[1] = 8;
_maxCaveArr[2] = 16;
_maxCaveArr[3] = 23;
_maxCaveArr[4] = 24;
};
_maxCave = 0;
_dark = false;
_game = false;
_now = 1;
_lev = -1;
}
CGEEngine::~CGEEngine() {

View File

@ -30,6 +30,7 @@
#include "graphics/surface.h"
#include "engines/advancedDetector.h"
#include "cge/console.h"
#include "cge/bitmap.h"
#define CGE_SAVEGAME_VERSION 1
@ -43,6 +44,8 @@ enum {
kCGEDebug = 1 << 0
};
enum SNLIST { NEAR, TAKE };
#define POCKET_NX 8
struct SavTab {
@ -70,6 +73,15 @@ public:
bool _music;
int _pocref[POCKET_NX];
uint8 _volume[2];
int _maxCaveArr[5];
int _maxCave;
bool _flag[4];
bool _dark;
bool _game;
int _now;
int _lev;
Common::RandomSource _randomSource;
virtual Common::Error run();
@ -95,7 +107,6 @@ public:
void takeName();
void inf(const char *txt);
void selectSound();
void SNSelect();
void dummy() {}
void NONE();
void SB();
@ -116,8 +127,58 @@ public:
void SaveGame(XFile &file);
void switchMusic();
void selectPocket(int n);
void SNKeep(Sprite *spr, int stp);
void SNGive(Sprite *spr, int stp);
void expandSprite(Sprite *spr);
void contractSprite(Sprite *spr);
int findPocket(Sprite *spr);
void feedSnail(Sprite *spr, SNLIST snq);
void pocFul();
void hide1(Sprite *spr);
void loadMapping();
void saveMapping();
void snBackPt(Sprite *spr, int stp);
void snBarrier(int cav, int bar, bool horz);
void snCover(Sprite *spr, int xref);
void snFlag(int fn, bool v);
void snFlash(bool on);
void snGame(Sprite *spr, int num);
void snGhost(Bitmap *bmp);
void snGive(Sprite *spr, int stp);
void snHide(Sprite *spr, int val);
void snKeep(Sprite *spr, int stp);
void snKill(Sprite *spr);
void snLevel(Sprite *spr, int lev);
void snLight(bool in);
void snMouse(bool on);
void snNNext(Sprite *sprel, int p);
void snPort(Sprite *spr, int port);
void snReach(Sprite *spr, int mode);
void snRelZ(Sprite *spr, int z);
void snRNNext(Sprite *sprel, int p);
void snRTNext(Sprite *sprel, int p);
void snSelect();
void snSend(Sprite *spr, int val);
void snRelX(Sprite *spr, int x);
void snRelY(Sprite *spr, int y);
void snRmNear(Sprite *spr);
void snRmTake(Sprite *spr);
void snRSeq(Sprite *spr, int val);
void snSeq(Sprite *spr, int val);
void snSetRef(Sprite *spr, int nr);
void snSetX(Sprite *spr, int x);
void snSetX0(int cav, int x0);
void snSetXY(Sprite *spr, uint16 xy);
void snSetY(Sprite *spr, int y);
void snSetY0(int cav, int y0);
void snSetZ(Sprite *spr, int z);
void snSlave(Sprite *spr, int ref);
void snSound(Sprite *spr, int wav, int cnt);
void snSwap(Sprite *spr, int xref);
void snTNext(Sprite *sprel, int p);
void snTrans(Sprite *spr, int trans);
void snUncover(Sprite *spr, Sprite *xspr);
void snWalk(Sprite *spr, int x, int y);
void snZTrim(Sprite *spr);
private:
CGEConsole *_console;
@ -128,7 +189,7 @@ private:
class Console : public GUI::Debugger {
public:
Console(CGEEngine *vm) {}
virtual ~Console(void) {}
virtual ~Console() {}
};
} // End of namespace CGE

View File

@ -100,17 +100,14 @@ 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;
int _offUseCount;
uint16 *_intStackPtr = false;
Hxy _heroXY[CAVE_MAX] = {{0, 0}};
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];
@ -119,7 +116,7 @@ uint8 &Cluster::cell() {
}
bool Cluster::Protected(void) {
bool Cluster::Protected() {
/*
if (A == Barriers[Now]._vert || B == Barriers[Now]._horz)
return true;
@ -250,7 +247,7 @@ void CGEEngine::loadGame(XFile &file, bool tiny = false) {
}
static void SaveSound(void) {
static void SaveSound() {
CFile cfg(usrPath(progName(CFG_EXT)), WRI);
if (!cfg._error)
cfg.write(&_sndDrvInfo, sizeof(_sndDrvInfo) - sizeof(_sndDrvInfo.Vol2));
@ -324,7 +321,7 @@ static void loadHeroXY() {
}
static void loadMapping() {
void CGEEngine::loadMapping() {
if (_now <= CAVE_MAX) {
INI_FILE cf(progName(".TAB"));
if (!cf._error) {
@ -357,7 +354,7 @@ void WALK::tick() {
for (spr = _vga->_showQ->first(); spr; spr = spr->_next) {
if (distance(spr) < 2) {
if (!spr->_flags._near) {
feedSnail(spr, NEAR);
_vm->feedSnail(spr, NEAR);
spr->_flags._near = true;
}
} else {
@ -423,7 +420,7 @@ void WALK::turn(DIR d) {
}
void WALK::park(void) {
void WALK::park() {
if (_time == 0)
++_time;
@ -438,7 +435,7 @@ void WALK::park(void) {
void WALK::findWay(Cluster c) {
warning("STUB: WALK::findWay");
/*
bool Find1Way(void);
bool Find1Way();
extern uint16 Target;
if (c != Here) {
@ -539,15 +536,14 @@ void CGEEngine::setMapBrick(int x, int z) {
}
}
static void SwitchColorMode(void);
static void SwitchColorMode();
static void switchDebug();
static void KillSprite(void);
static void PushSprite(void);
static void PullSprite(void);
static void NextStep(void);
static void SaveMapping(void);
static void KillSprite();
static void PushSprite();
static void PullSprite();
static void NextStep();
static void KeyClick(void) {
static void KeyClick() {
SNPOST_(SNSOUND, -1, 5, NULL);
}
@ -654,7 +650,7 @@ void CGEEngine::caveUp() {
if (spr->_flags._back)
spr->backShow();
else
ExpandSprite(spr);
expandSprite(spr);
}
spr = n;
}
@ -814,7 +810,7 @@ void System::touch(uint16 mask, int x, int y) {
break;
case '`':
if (_keyboard->_key[ALT])
SaveMapping();
_vm->saveMapping();
else
_vm->switchMapping();
break;
@ -890,9 +886,9 @@ void System::touch(uint16 mask, int x, int y) {
if (y >= WORLD_HIG) {
if (x < BUTTON_X) { // select cave?
if (y >= CAVE_Y && y < CAVE_Y + CAVE_NY * CAVE_DY &&
x >= CAVE_X && x < CAVE_X + CAVE_NX * CAVE_DX && !_game) {
x >= CAVE_X && x < CAVE_X + CAVE_NX * CAVE_DX && !_vm->_game) {
cav = ((y - CAVE_Y) / CAVE_DY) * CAVE_NX + (x - CAVE_X) / CAVE_DX + 1;
if (cav > _maxCave)
if (cav > _vm->_maxCave)
cav = 0;
} else {
cav = 0;
@ -922,7 +918,7 @@ void System::touch(uint16 mask, int x, int y) {
} else
{
if (!_talk && _snail->idle() && _hero
&& y >= MAP_TOP && y < MAP_TOP + MAP_HIG && !_game) {
&& y >= MAP_TOP && y < MAP_TOP + MAP_HIG && !_vm->_game) {
_hero->findWay(XZ(x, y));
}
}
@ -961,7 +957,7 @@ void System::tick() {
/*
static void SpkOpen(void) {
static void SpkOpen() {
asm in al,0x61
asm or al,0x03
asm out 0x61,al
@ -970,7 +966,7 @@ static void SpkOpen(void) {
}
static void SpkClose(void) {
static void SpkClose() {
asm in al,0x61
asm and al,0xFC
asm out 0x61,al
@ -979,7 +975,7 @@ static void SpkClose(void) {
*/
static void SwitchColorMode(void) {
static void SwitchColorMode() {
SNPOST_(SNSEQ, 121, _vga->_mono = !_vga->_mono, NULL);
KeyClick();
_vga->setColors(Vga::_sysPal, 64);
@ -1054,7 +1050,7 @@ void CGEEngine::switchMapping() {
}
static void KillSprite(void) {
static void KillSprite() {
_sprite->_flags._kill = true;
_sprite->_flags._bDel = true;
SNPOST_(SNKILL, -1, 0, _sprite);
@ -1062,7 +1058,7 @@ static void KillSprite(void) {
}
static void PushSprite(void) {
static void PushSprite() {
Sprite *spr = _sprite->_prev;
if (spr) {
_vga->_showQ->insert(_vga->_showQ->remove(_sprite), spr);
@ -1073,7 +1069,7 @@ static void PushSprite(void) {
}
static void PullSprite(void) {
static void PullSprite() {
bool ok = false;
Sprite *spr = _sprite->_next;
if (spr) {
@ -1091,12 +1087,12 @@ static void PullSprite(void) {
}
static void NextStep(void) {
static void NextStep() {
SNPOST_(SNSTEP, 0, 0, _sprite);
}
static void SaveMapping() {
void CGEEngine::saveMapping() {
{
IoHand cf(progName(".TAB"), UPD);
if (!cf._error) {
@ -1217,7 +1213,7 @@ void Sprite::touch(uint16 mask, int x, int y) {
}
if (_flags._syst)
return; // cannot access system sprites
if (_game) if (mask & L_UP) {
if (_vm->_game) if (mask & L_UP) {
mask &= ~L_UP;
mask |= R_UP;
}
@ -1226,7 +1222,7 @@ void Sprite::touch(uint16 mask, int x, int y) {
if (ps) {
if (_flags._kept || _hero->distance(this) < MAX_DISTANCE) {
if (works(ps)) {
feedSnail(ps, TAKE);
_vm->feedSnail(ps, TAKE);
} else
offUse();
_vm->selectPocket(-1);
@ -1239,8 +1235,8 @@ void Sprite::touch(uint16 mask, int x, int y) {
if (_hero->distance(this) < MAX_DISTANCE) {
///
if (_flags._port) {
if (findPocket(NULL) < 0)
pocFul();
if (_vm->findPocket(NULL) < 0)
_vm->pocFul();
else {
SNPOST(SNREACH, -1, -1, this);
SNPOST(SNKEEP, -1, -1, this);
@ -1251,7 +1247,7 @@ void Sprite::touch(uint16 mask, int x, int y) {
if (snList(TAKE)[_takePtr]._com == SNNEXT)
offUse();
else
feedSnail(this, TAKE);
_vm->feedSnail(this, TAKE);
} else
offUse();
}
@ -1606,7 +1602,7 @@ void CGEEngine::runGame() {
uint8 *ptr = (uint8 *) &*_mini;
if (ptr != NULL) {
loadSprite("MINI", -1, 0, MINI_X, MINI_Y);
ExpandSprite(_miniCave = _sprite); // NULL is ok
expandSprite(_miniCave = _sprite); // NULL is ok
if (_miniCave) {
_miniCave->_flags._hide = true;
_miniCave->moveShapes(ptr);
@ -1618,7 +1614,7 @@ void CGEEngine::runGame() {
}
if (_hero) {
ExpandSprite(_hero);
expandSprite(_hero);
_hero->gotoxy(_heroXY[_now - 1]._x, _heroXY[_now - 1]._y);
if (INI_FILE::exist("00SHADOW.SPR")) {
loadSprite("00SHADOW", -1, 0, _hero->_x + 14, _hero->_y + 51);
@ -1645,7 +1641,7 @@ void CGEEngine::runGame() {
_mouse->Busy = _vga->_spareQ->locate(BUSY_REF);
if (_mouse->Busy)
ExpandSprite(_mouse->Busy);
expandSprite(_mouse->Busy);
_startupMode = 0;
@ -1682,7 +1678,7 @@ void CGEEngine::movie(const char *ext) {
const char *fn = progName(ext);
if (INI_FILE::exist(fn)) {
loadScript(fn);
ExpandSprite(_vga->_spareQ->locate(999));
expandSprite(_vga->_spareQ->locate(999));
feedSnail(_vga->_showQ->locate(999), TAKE);
// FIXME: Allow ScummVM to handle mouse display
@ -1793,9 +1789,9 @@ bool CGEEngine::showTitle(const char *name) {
loadGame(file, true); // only system vars
_vga->setColors(Vga::_sysPal, 64);
_vga->update();
if (FINIS) {
if (_flag[3]) { //flag FINIS
Startup::_mode++;
FINIS = false;
_flag[3] = false;
}
} else
Startup::_mode++;
@ -1815,14 +1811,14 @@ bool CGEEngine::showTitle(const char *name) {
/*
void StkDump (void) {
void StkDump () {
CFILE f("!STACK.DMP", BFW);
f.Write((uint8 *) (intStackPtr-STACK_SIZ/2), STACK_SIZ*2);
}
*/
void CGEEngine::cge_main(void) {
void CGEEngine::cge_main() {
uint16 intStack[STACK_SIZ / 2];
_intStackPtr = intStack;
@ -1852,7 +1848,7 @@ void CGEEngine::cge_main(void) {
movie("X02"); // intro
runGame();
_startupMode = 2;
if (FINIS)
if (_flag[3]) // Flag FINIS
movie("X03");
} else
_vga->sunset();

View File

@ -109,8 +109,8 @@ namespace CGE {
#define SYSTIMERATE 6 // 12 Hz
#define HEROFUN0 (40 * 12)
#define HEROFUN1 ( 2 * 12)
#define PAIN (_flag[0])
#define FINIS (_flag[3])
#define PAIN (_vm->_flag[0])
//#define FINIS (_vm->_flag[3])
class System : public Sprite {
@ -132,10 +132,10 @@ private:
class Cluster : public Couple {
public:
static uint8 _map[MAP_ZCNT][MAP_XCNT];
uint8 &cell(void);
Cluster(void) : Couple() { }
uint8 &cell();
Cluster() : Couple() { }
Cluster(int a, int b) : Couple(a, b) { }
bool Protected(void);
bool Protected();
};
@ -162,9 +162,6 @@ private:
Cluster XZ(int x, int y);
Cluster XZ(Couple xy);
void ExpandSprite(Sprite *spr);
void ContractSprite(Sprite *spr);
extern WALK *_hero;
extern Vga *_vga;
extern Heart *_heart;

View File

@ -154,7 +154,7 @@ void CGEEngine::selectSound() {
}
static void reset(void) {
static void reset() {
_sndDrvInfo._dBase = _sndDrvInfo._dIrq = _sndDrvInfo._dDma = _sndDrvInfo._mBase = DETECT;
}
@ -182,7 +182,7 @@ static uint16 xdeco(const char *str) {
static Choice *_cho;
static int _hlp;
void CGEEngine::SNSelect() {
void CGEEngine::snSelect() {
inf(_text->getText(_hlp));
_talk->gotoxy(_talk->_x, FONT_HIG / 2);
(new Vmenu(this, _cho, SCR_WID / 2, _talk->_y + _talk->_h + TEXT_VM + FONT_HIG))->setName(_text->getText(MENU_TEXT));

View File

@ -32,7 +32,7 @@ class CGEEngine;
class CGEConsole : public GUI::Debugger {
public:
CGEConsole(CGEEngine *vm);
virtual ~CGEConsole(void);
virtual ~CGEConsole();
private:
CGEEngine *_vm;

View File

@ -82,7 +82,7 @@ Emm::Emm(long size): _han(-1), _top(0), _lim(0), _list(NULL) {
}
Emm::~Emm(void) {
Emm::~Emm() {
/* FIXME
Release();
if (Han >= 0)

View File

@ -162,17 +162,17 @@ MOUSE::MOUSE(CGEEngine *vm, Bitmap **shpl) : Sprite(vm, shpl), Busy(NULL), Hold(
}
MOUSE::~MOUSE(void) {
MOUSE::~MOUSE() {
Off();
}
//void MOUSE::SetFun (void)
//void MOUSE::SetFun()
//{
//}
void MOUSE::On(void) {
void MOUSE::On() {
if (_seqPtr && Exist) {
_active = true;
step(0);
@ -181,7 +181,7 @@ void MOUSE::On(void) {
}
void MOUSE::Off(void) {
void MOUSE::Off() {
if (_seqPtr == 0) {
if (Exist) {
_active = false;
@ -261,7 +261,7 @@ void EventManager::poll() {
}
}
void EventManager::handleEvents(void) {
void EventManager::handleEvents() {
while (EvtTail != EvtHead) {
CGEEvent e = Evt[EvtTail];
if (e._msk) {

View File

@ -138,10 +138,10 @@ char *forceExt(char *buf, const char *nam, const char *ext) {
static unsigned Seed = 0xA5;
unsigned FastRand(void) {
unsigned fastRand() {
return Seed = 257 * Seed + 817;
}
unsigned FastRand(unsigned s) {
unsigned fastRand(unsigned s) {
return Seed = 257 * s + 817;
}
@ -149,12 +149,12 @@ uint16 RCrypt(void *buf, uint16 siz, uint16 seed) {
if (buf && siz) {
byte *b = static_cast<byte *>(buf);
byte *q = b + (siz - 1);
seed = FastRand(seed);
seed = fastRand(seed);
*b++ ^= seed;
while (buf < q)
*b++ ^= FastRand();
*b++ ^= fastRand();
if (buf == q)
*b ^= (seed = FastRand());
*b ^= (seed = fastRand());
}
return seed;
}
@ -225,7 +225,7 @@ IoHand::IoHand(const char *name, IOMODE mode, CRYPT *crpt)
_file->open(name);
}
IoHand::~IoHand(void) {
IoHand::~IoHand() {
_file->close();
delete _file;
}
@ -258,7 +258,7 @@ uint16 IoHand::write(void *buf, uint16 len) {
*/
}
long IoHand::mark(void) {
long IoHand::mark() {
return _file->pos();
}
@ -267,7 +267,7 @@ long IoHand::seek(long pos) {
return _file->pos();
}
long IoHand::size(void) {
long IoHand::size() {
return _file->size();
}
@ -344,7 +344,7 @@ int takeEnum(const char **tab, const char *txt) {
return -1;
}
long timer(void) {
long timer() {
/*
asm mov ax,0x40
asm mov es,ax

View File

@ -105,7 +105,7 @@ protected:
static void newTimer(...);
public:
Engine_(uint16 tdiv);
~Engine_(void);
~Engine_();
};
@ -138,7 +138,7 @@ class Ems {
public:
Ems();
void *operator & () const;
uint16 size(void);
uint16 size();
};
@ -200,7 +200,7 @@ public:
long mark();
long size();
long seek(long pos);
//timeb Time (void);
//timeb Time ();
// void SetTime (timeb t);
};
@ -226,7 +226,7 @@ void _fqsort(void *base, uint16 nelem, uint16 width, int (*fcmp)(const void *, c
const char *progName(const char *ext = NULL);
char *mergeExt(char *buf, const char *nam, const char *ext);
char *forceExt(char *buf, const char *nam, const char *ext);
unsigned fastRand(void);
unsigned fastRand();
unsigned fastRand(unsigned s);
uint16 rCrypt(void *buf, uint16 siz, uint16 seed);
uint16 atow(const char *a);
@ -234,7 +234,7 @@ uint16 xtow(const char *x);
char *wtom(uint16 val, char *str, int radix, int len);
char *dwtom(uint32 val, char * str, int radix, int len);
int takeEnum(const char **tab, const char *txt);
long timer(void);
long timer();
int new_random(int range);
} // End of namespace CGE

View File

@ -132,7 +132,7 @@ void Mixer::tick() {
}
void Mixer::update(void) {
void Mixer::update() {
_led[0]->step(_sndDrvInfo.Vol4._ml);
_led[1]->step(_sndDrvInfo.Vol4._dl);

View File

@ -44,14 +44,6 @@ static void _disable() {
warning("STUB: _disable");
}
int _maxCave = 0;
bool _flag[4];
bool _dark = false;
bool _game = false;
int _now = 1;
int _lev = -1;
extern Sprite *_pocLight;
//-------------------------------------------------------------------------
@ -61,7 +53,7 @@ extern Sprite *_pocLight;
//-------------------------------------------------------------------------
extern Sprite *_pocket[];
static void SNGame(Sprite *spr, int num) {
void CGEEngine::snGame(Sprite *spr, int num) {
switch (num) {
case 1 : {
#define STAGES 8
@ -270,18 +262,18 @@ static void SNGame(Sprite *spr, int num) {
}
void ExpandSprite(Sprite *spr) {
void CGEEngine::expandSprite(Sprite *spr) {
if (spr)
_vga->_showQ->insert(_vga->_spareQ->remove(spr));
}
void ContractSprite(Sprite *spr) {
void CGEEngine::contractSprite(Sprite *spr) {
if (spr)
_vga->_spareQ->append(_vga->_showQ->remove(spr));
}
int findPocket(Sprite *spr) {
int CGEEngine::findPocket(Sprite *spr) {
for (int i = 0; i < POCKET_NX; i++)
if (_pocket[i] == spr)
return i;
@ -304,8 +296,7 @@ void CGEEngine::selectPocket(int n) {
_pocLight->gotoxy(POCKET_X + _pocPtr * POCKET_DX + POCKET_SX, POCKET_Y + POCKET_SY);
}
void pocFul() {
void CGEEngine::pocFul() {
_hero->park();
SNPOST(SNWAIT, -1, -1, _hero);
SNPOST(SNSEQ, -1, POC_FUL, _hero);
@ -314,13 +305,11 @@ void pocFul() {
SNPOST(SNSAY, 1, POC_FUL_TEXT, _hero);
}
void Hide1(Sprite *spr) {
void CGEEngine::hide1(Sprite *spr) {
SNPOST_(SNGHOST, -1, 0, spr->ghost());
}
void SNGhost(Bitmap *bmp) {
void CGEEngine::snGhost(Bitmap *bmp) {
// TODO : Get x and y from M but not using segment / offset
//bmp->Hide(FP_OFF(bmp->_m), FP_SEG(bmp->_m));
bmp->_m = NULL;
@ -328,8 +317,7 @@ void SNGhost(Bitmap *bmp) {
warning("STUB: SNGhost");
}
void feedSnail(Sprite *spr, SNLIST snq) {
void CGEEngine::feedSnail(Sprite *spr, SNLIST snq) {
if (spr)
if (spr->active()) {
uint8 ptr = (snq == TAKE) ? spr->_takePtr : spr->_nearPtr;
@ -402,7 +390,6 @@ void feedSnail(Sprite *spr, SNLIST snq) {
}
}
const char *Snail::_comTxt[] = {
"LABEL", "PAUSE", "WAIT", "LEVEL", "HIDE",
"SAY", "INF", "TIME", "CAVE", "KILL",
@ -424,13 +411,11 @@ Snail::Snail(CGEEngine *vm, bool turbo)
_head(0), _tail(0), _snList(farnew(Com, 256)), _vm(vm) {
}
Snail::~Snail() {
if (_snList)
free(_snList);
}
void Snail::addCom(SNCOM com, int ref, int val, void *ptr) {
_disable();
Com *snc = &_snList[_head++];
@ -446,7 +431,6 @@ void Snail::addCom(SNCOM com, int ref, int val, void *ptr) {
_enable();
}
void Snail::insCom(SNCOM com, int ref, int val, void *ptr) {
Com *snc;
@ -469,36 +453,32 @@ void Snail::insCom(SNCOM com, int ref, int val, void *ptr) {
_enable();
}
static void SNNNext(Sprite *sprel, int p) {
void CGEEngine::snNNext(Sprite *sprel, int p) {
if (sprel)
if (sprel->_nearPtr != NO_PTR)
sprel->_nearPtr = p;
}
static void SNTNext(Sprite *sprel, int p) {
void CGEEngine::snTNext(Sprite *sprel, int p) {
if (sprel)
if (sprel->_takePtr != NO_PTR)
sprel->_takePtr = p;
}
static void SNRNNext(Sprite *sprel, int p) {
void CGEEngine::snRNNext(Sprite *sprel, int p) {
if (sprel)
if (sprel->_nearPtr != NO_PTR)
sprel->_nearPtr += p;
}
static void SNRTNext(Sprite *sprel, int p) {
void CGEEngine::snRTNext(Sprite *sprel, int p) {
if (sprel)
if (sprel->_takePtr != NO_PTR)
sprel->_takePtr += p;
}
static void SNZTrim(Sprite *spr) {
void CGEEngine::snZTrim(Sprite *spr) {
if (spr)
if (spr->active()) {
bool en = _heart->_enable;
@ -514,8 +494,7 @@ static void SNZTrim(Sprite *spr) {
}
}
static void SNHide(Sprite *spr, int val) {
void CGEEngine::snHide(Sprite *spr, int val) {
if (spr) {
spr->_flags._hide = (val >= 0) ? (val != 0) : (!spr->_flags._hide);
if (spr->_flags._shad)
@ -523,20 +502,17 @@ static void SNHide(Sprite *spr, int val) {
}
}
static void SNRmNear(Sprite *spr) {
void CGEEngine::snRmNear(Sprite *spr) {
if (spr)
spr->_nearPtr = NO_PTR;
}
static void SNRmTake(Sprite *spr) {
void CGEEngine::snRmTake(Sprite *spr) {
if (spr)
spr->_takePtr = NO_PTR;
}
void SNSeq(Sprite *spr, int val) {
void CGEEngine::snSeq(Sprite *spr, int val) {
if (spr) {
if (spr == _hero && val == 0)
_hero->park();
@ -545,14 +521,12 @@ void SNSeq(Sprite *spr, int val) {
}
}
void SNRSeq(Sprite *spr, int val) {
void CGEEngine::snRSeq(Sprite *spr, int val) {
if (spr)
SNSeq(spr, spr->_seqPtr + val);
snSeq(spr, spr->_seqPtr + val);
}
void SNSend(Sprite *spr, int val) {
void CGEEngine::snSend(Sprite *spr, int val) {
if (spr) {
int was = spr->_cave;
bool was1 = (was == 0 || was == _now);
@ -565,8 +539,8 @@ void SNSend(Sprite *spr, int val) {
if (n >= 0)
_pocket[n] = NULL;
}
Hide1(spr);
ContractSprite(spr);
hide1(spr);
contractSprite(spr);
spr->_flags._slav = false;
} else {
if (spr->_ref % 1000 == 0)
@ -574,7 +548,7 @@ void SNSend(Sprite *spr, int val) {
if (spr->_flags._back)
spr->backShow(true);
else
ExpandSprite(spr);
expandSprite(spr);
Bitmap::_pal = NULL;
}
}
@ -582,7 +556,7 @@ void SNSend(Sprite *spr, int val) {
}
void SNSwap(Sprite *spr, int xref) {
void CGEEngine::snSwap(Sprite *spr, int xref) {
Sprite *xspr = locate(xref);
if (spr && xspr) {
int was = spr->_cave;
@ -603,28 +577,28 @@ void SNSwap(Sprite *spr, int xref) {
}
if (xwas1 != was1) {
if (was1) {
Hide1(spr);
ContractSprite(spr);
hide1(spr);
contractSprite(spr);
} else
ExpandSprite(spr);
expandSprite(spr);
if (xwas1) {
Hide1(xspr);
ContractSprite(xspr);
hide1(xspr);
contractSprite(xspr);
} else
ExpandSprite(xspr);
expandSprite(xspr);
}
}
}
void SNCover(Sprite *spr, int xref) {
void CGEEngine::snCover(Sprite *spr, int xref) {
Sprite *xspr = locate(xref);
if (spr && xspr) {
spr->_flags._hide = true;
xspr->_z = spr->_z;
xspr->_cave = spr->_cave;
xspr->gotoxy(spr->_x, spr->_y);
ExpandSprite(xspr);
expandSprite(xspr);
if ((xspr->_flags._shad = spr->_flags._shad) == 1) {
_vga->_showQ->insert(_vga->_showQ->remove(spr->_prev), xspr);
spr->_flags._shad = false;
@ -634,7 +608,7 @@ void SNCover(Sprite *spr, int xref) {
}
void SNUncover(Sprite *spr, Sprite *xspr) {
void CGEEngine::snUncover(Sprite *spr, Sprite *xspr) {
if (spr && xspr) {
spr->_flags._hide = false;
spr->_cave = xspr->_cave;
@ -644,75 +618,71 @@ void SNUncover(Sprite *spr, Sprite *xspr) {
xspr->_flags._shad = false;
}
spr->_z = xspr->_z;
SNSend(xspr, -1);
snSend(xspr, -1);
if (spr->_time == 0)
spr->_time++;
}
}
void SNSetX0(int cav, int x0) {
void CGEEngine::snSetX0(int cav, int x0) {
_heroXY[cav - 1]._x = x0;
}
void SNSetY0(int cav, int y0) {
void CGEEngine::snSetY0(int cav, int y0) {
_heroXY[cav - 1]._y = y0;
}
void SNSetXY(Sprite *spr, uint16 xy) {
void CGEEngine::snSetXY(Sprite *spr, uint16 xy) {
if (spr)
spr->gotoxy(xy % SCR_WID, xy / SCR_WID);
}
void SNRelX(Sprite *spr, int x) {
void CGEEngine::snRelX(Sprite *spr, int x) {
if (spr && _hero)
spr->gotoxy(_hero->_x + x, spr->_y);
}
void SNRelY(Sprite *spr, int y) {
void CGEEngine::snRelY(Sprite *spr, int y) {
if (spr && _hero)
spr->gotoxy(spr->_x, _hero->_y + y);
}
void SNRelZ(Sprite *spr, int z) {
void CGEEngine::snRelZ(Sprite *spr, int z) {
if (spr && _hero) {
spr->_z = _hero->_z + z;
SNZTrim(spr);
snZTrim(spr);
}
}
void SNSetX(Sprite *spr, int x) {
void CGEEngine::snSetX(Sprite *spr, int x) {
if (spr)
spr->gotoxy(x, spr->_y);
}
void SNSetY(Sprite *spr, int y) {
void CGEEngine::snSetY(Sprite *spr, int y) {
if (spr)
spr->gotoxy(spr->_x, y);
}
void SNSetZ(Sprite *spr, int z) {
void CGEEngine::snSetZ(Sprite *spr, int z) {
if (spr) {
spr->_z = z;
//SNPOST_(SNZTRIM, -1, 0, spr);
SNZTrim(spr);
snZTrim(spr);
}
}
void SNSlave(Sprite *spr, int ref) {
void CGEEngine::snSlave(Sprite *spr, int ref) {
Sprite *slv = locate(ref);
if (spr && slv) {
if (spr->active()) {
SNSend(slv, spr->_cave);
snSend(slv, spr->_cave);
slv->_flags._slav = true;
slv->_z = spr->_z;
_vga->_showQ->insert(_vga->_showQ->remove(slv), spr->_next);
@ -721,19 +691,17 @@ void SNSlave(Sprite *spr, int ref) {
}
void SNTrans(Sprite *spr, int trans) {
void CGEEngine::snTrans(Sprite *spr, int trans) {
if (spr)
spr->_flags._tran = (trans < 0) ? !spr->_flags._tran : (trans != 0);
}
void SNPort(Sprite *spr, int port) {
void CGEEngine::snPort(Sprite *spr, int port) {
if (spr)
spr->_flags._port = (port < 0) ? !spr->_flags._port : (port != 0);
}
void SNKill(Sprite *spr) {
void CGEEngine::snKill(Sprite *spr) {
if (spr) {
if (spr->_flags._kept) {
int n = findPocket(spr);
@ -741,7 +709,7 @@ void SNKill(Sprite *spr) {
_pocket[n] = NULL;
}
Sprite *nx = spr->_next;
Hide1(spr);
hide1(spr);
_vga->_showQ->remove(spr);
EventManager::ClrEvt(spr);
if (spr->_flags._kill)
@ -752,13 +720,13 @@ void SNKill(Sprite *spr) {
}
if (nx) {
if (nx->_flags._slav)
SNKill(nx);
snKill(nx);
}
}
}
static void SNSound(Sprite *spr, int wav, int cnt) {
void CGEEngine::snSound(Sprite *spr, int wav, int cnt) {
if (_sndDrvInfo._dDev) {
if (wav == -1)
_sound.stop();
@ -768,10 +736,10 @@ static void SNSound(Sprite *spr, int wav, int cnt) {
}
void CGEEngine::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);
snSound(spr, 3, 1);
_pocket[_pocPtr] = spr;
spr->_cave = 0;
spr->_flags._kept = true;
@ -784,7 +752,7 @@ void CGEEngine::SNKeep(Sprite *spr, int stp) {
}
void CGEEngine::SNGive(Sprite *spr, int stp) {
void CGEEngine::snGive(Sprite *spr, int stp) {
if (spr) {
int p = findPocket(spr);
if (p >= 0) {
@ -799,7 +767,7 @@ void CGEEngine::SNGive(Sprite *spr, int stp) {
}
static void SNBackPt(Sprite *spr, int stp) {
void CGEEngine::snBackPt(Sprite *spr, int stp) {
if (spr) {
if (stp >= 0)
spr->step(stp);
@ -807,13 +775,7 @@ static void SNBackPt(Sprite *spr, int stp) {
}
}
static void SNLevel(Sprite *spr, int lev) {
#ifdef DEMO
static int maxcav[] = { CAVE_MAX };
#else
static int maxcav[] = { 1, 8, 16, 23, 24 };
#endif
void CGEEngine::snLevel(Sprite *spr, int lev) {
while (_lev < lev) {
_lev++;
spr = _vga->_spareQ->locate(100 + _lev);
@ -822,24 +784,22 @@ static void SNLevel(Sprite *spr, int lev) {
spr->_cave = 0;
}
}
_maxCave = maxcav[_lev];
_maxCave = _maxCaveArr[_lev];
if (spr)
spr->_flags._hide = false;
}
static void SNFlag(int fn, bool v) {
void CGEEngine::snFlag(int fn, bool v) {
_flag[fn] = v;
}
static void SNSetRef(Sprite *spr, int nr) {
void CGEEngine::snSetRef(Sprite *spr, int nr) {
if (spr)
spr->_ref = nr;
}
void SNFlash(bool on) {
void CGEEngine::snFlash(bool on) {
if (on) {
Dac *pal = farnew(Dac, PAL_CNT);
if (pal) {
@ -861,7 +821,7 @@ void SNFlash(bool on) {
}
static void SNLight(bool in) {
void CGEEngine::snLight(bool in) {
if (in)
_vga->sunrise(Vga::_sysPal);
else
@ -869,13 +829,11 @@ static void SNLight(bool in) {
_dark = ! in;
}
static void SNBarrier(int cav, int bar, bool horz) {
void CGEEngine::snBarrier(int cav, int bar, bool horz) {
((uint8 *)(_barriers + ((cav > 0) ? cav : _now)))[horz] = bar;
}
static void SNWalk(Sprite *spr, int x, int y) {
void CGEEngine::snWalk(Sprite *spr, int x, int y) {
if (_hero) {
if (spr && y < 0)
_hero->findWay(spr);
@ -884,14 +842,12 @@ static void SNWalk(Sprite *spr, int x, int y) {
}
}
static void SNReach(Sprite *spr, int mode) {
void CGEEngine::snReach(Sprite *spr, int mode) {
if (_hero)
_hero->reach(spr, mode);
}
static void SNMouse(bool on) {
void CGEEngine::snMouse(bool on) {
if (on)
_mouse->On();
else
@ -945,10 +901,10 @@ void Snail::runCom() {
}
break;
case SNLEVEL :
SNLevel(sprel, snc->_val);
_vm->snLevel(sprel, snc->_val);
break;
case SNHIDE :
SNHide(sprel, snc->_val);
_vm->snHide(sprel, snc->_val);
break;
case SNSAY :
if (sprel && _talkEnable) {
@ -976,125 +932,125 @@ void Snail::runCom() {
warning("Problematic call of SwitchCave in SNAIL::runCom");
break;
case SNKILL :
SNKill(sprel);
_vm->snKill(sprel);
break;
case SNSEQ :
SNSeq(sprel, snc->_val);
_vm->snSeq(sprel, snc->_val);
break;
case SNRSEQ :
SNRSeq(sprel, snc->_val);
_vm->snRSeq(sprel, snc->_val);
break;
case SNSEND :
SNSend(sprel, snc->_val);
_vm->snSend(sprel, snc->_val);
break;
case SNSWAP :
SNSwap(sprel, snc->_val);
_vm->snSwap(sprel, snc->_val);
break;
case SNCOVER :
SNCover(sprel, snc->_val);
_vm->snCover(sprel, snc->_val);
break;
case SNUNCOVER :
SNUncover(sprel, (snc->_val >= 0) ? locate(snc->_val) : ((Sprite *) snc->_ptr));
_vm->snUncover(sprel, (snc->_val >= 0) ? locate(snc->_val) : ((Sprite *) snc->_ptr));
break;
case SNKEEP :
_vm->SNKeep(sprel, snc->_val);
_vm->snKeep(sprel, snc->_val);
break;
case SNGIVE :
_vm->SNGive(sprel, snc->_val);
_vm->snGive(sprel, snc->_val);
break;
case SNGAME :
SNGame(sprel, snc->_val);
_vm->snGame(sprel, snc->_val);
break;
case SNSETX0 :
SNSetX0(snc->_ref, snc->_val);
_vm->snSetX0(snc->_ref, snc->_val);
break;
case SNSETY0 :
SNSetY0(snc->_ref, snc->_val);
_vm->snSetY0(snc->_ref, snc->_val);
break;
case SNSETXY :
SNSetXY(sprel, snc->_val);
_vm->snSetXY(sprel, snc->_val);
break;
case SNRELX :
SNRelX(sprel, snc->_val);
_vm->snRelX(sprel, snc->_val);
break;
case SNRELY :
SNRelY(sprel, snc->_val);
_vm->snRelY(sprel, snc->_val);
break;
case SNRELZ :
SNRelZ(sprel, snc->_val);
_vm->snRelZ(sprel, snc->_val);
break;
case SNSETX :
SNSetX(sprel, snc->_val);
_vm->snSetX(sprel, snc->_val);
break;
case SNSETY :
SNSetY(sprel, snc->_val);
_vm->snSetY(sprel, snc->_val);
break;
case SNSETZ :
SNSetZ(sprel, snc->_val);
_vm->snSetZ(sprel, snc->_val);
break;
case SNSLAVE :
SNSlave(sprel, snc->_val);
_vm->snSlave(sprel, snc->_val);
break;
case SNTRANS :
SNTrans(sprel, snc->_val);
_vm->snTrans(sprel, snc->_val);
break;
case SNPORT :
SNPort(sprel, snc->_val);
_vm->snPort(sprel, snc->_val);
break;
case SNNEXT :
case SNIF :
case SNTALK :
break;
case SNMOUSE :
SNMouse(snc->_val != 0);
_vm->snMouse(snc->_val != 0);
break;
case SNNNEXT :
SNNNext(sprel, snc->_val);
_vm->snNNext(sprel, snc->_val);
break;
case SNTNEXT :
SNTNext(sprel, snc->_val);
_vm->snTNext(sprel, snc->_val);
break;
case SNRNNEXT :
SNRNNext(sprel, snc->_val);
_vm->snRNNext(sprel, snc->_val);
break;
case SNRTNEXT :
SNRTNext(sprel, snc->_val);
_vm->snRTNext(sprel, snc->_val);
break;
case SNRMNEAR :
SNRmNear(sprel);
_vm->snRmNear(sprel);
break;
case SNRMTAKE :
SNRmTake(sprel);
_vm->snRmTake(sprel);
break;
case SNFLAG :
SNFlag(snc->_ref & 3, snc->_val != 0);
_vm->snFlag(snc->_ref & 3, snc->_val != 0);
break;
case SNSETREF :
SNSetRef(sprel, snc->_val);
_vm->snSetRef(sprel, snc->_val);
break;
case SNBACKPT :
SNBackPt(sprel, snc->_val);
_vm->snBackPt(sprel, snc->_val);
break;
case SNFLASH :
SNFlash(snc->_val != 0);
_vm->snFlash(snc->_val != 0);
break;
case SNLIGHT :
SNLight(snc->_val != 0);
_vm->snLight(snc->_val != 0);
break;
case SNSETHB :
SNBarrier(snc->_ref, snc->_val, true);
_vm->snBarrier(snc->_ref, snc->_val, true);
break;
case SNSETVB :
SNBarrier(snc->_ref, snc->_val, false);
_vm->snBarrier(snc->_ref, snc->_val, false);
break;
case SNWALK :
SNWalk(sprel, snc->_ref, snc->_val);
_vm->snWalk(sprel, snc->_ref, snc->_val);
break;
case SNREACH :
SNReach(sprel, snc->_val);
_vm->snReach(sprel, snc->_val);
break;
case SNSOUND :
SNSound(sprel, snc->_val, count);
_vm->snSound(sprel, snc->_val, count);
count = 1;
break;
case SNCOUNT :
@ -1109,10 +1065,10 @@ void Snail::runCom() {
sprel->step();
break;
case SNZTRIM :
SNZTrim(sprel);
_vm->snZTrim(sprel);
break;
case SNGHOST :
SNGhost((Bitmap *) snc->_ptr);
_vm->snGhost((Bitmap *) snc->_ptr);
break;
default :
warning("Unhandled snc->_com in SNMouse(bool)");

View File

@ -70,8 +70,6 @@ enum SNCOM {
SNZTRIM, SNGHOST
};
enum SNLIST { NEAR, TAKE };
class Snail {
public:
struct Com {
@ -99,15 +97,8 @@ private:
};
void pocFul();
extern bool _flag[4];
extern bool _game;
extern bool _dark;
extern int _now;
extern int _lev;
extern int _maxCave;
extern Bar _barriers[];
extern struct Hxy {
int _x;

View File

@ -63,7 +63,7 @@ bool SpeedTest = false;
Seq _seq1[] = { { 0, 0, 0, 0, 0 } };
Seq _seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } };
extern "C" void SNDMIDIPlay(void);
extern "C" void SNDMIDIPlay();
/*
static void Video() {
@ -87,7 +87,7 @@ static void Video() {
*/
uint16 *SaveScreen(void) {
uint16 *SaveScreen() {
/*
uint16 cxy, cur, siz, * scr = NULL, * sav;
@ -201,7 +201,7 @@ Sprite *locate(int ref) {
}
Heart::Heart(void)
Heart::Heart()
: Engine_(TMR_DIV) {
_enable = false;
_xTimer = NULL;
@ -427,7 +427,7 @@ bool Sprite::works(Sprite *spr) {
if (c != NULL) {
c += spr->_takePtr;
if (c->_ref == _ref)
if (c->_com != SNLABEL || (c->_val == 0 || c->_val == _now))
if (c->_com != SNLABEL || (c->_val == 0 || c->_val == _vm->_now))
return true;
}
}
@ -1136,7 +1136,7 @@ void Vga::setColors(Dac *tab, int lum) {
}
void Vga::setColors(void) {
void Vga::setColors() {
memset(_newColors, 0, PAL_SIZ);
updateColors();
}

View File

@ -209,7 +209,7 @@ public:
return _ext != NULL;
}
Sprite(CGEEngine *vm, BMP_PTR *shp);
virtual ~Sprite(void);
virtual ~Sprite();
BMP_PTR shp();
BMP_PTR *setShapeList(BMP_PTR *shp);
void moveShapes(uint8 *buf);
@ -288,7 +288,7 @@ public:
static Dac *_sysPal;
Vga(int mode);
~Vga(void);
~Vga();
static void init();
static void deinit();
@ -340,7 +340,6 @@ uint8 closest(CBLK *pal, CBLK x) {
#undef f
}
//static void Video (void);
uint16 *saveScreen();
void restoreScreen(uint16 * &sav);
Sprite *spriteAt(int x, int y);

View File

@ -119,7 +119,7 @@ Vmenu::Vmenu(CGEEngine *vm, Choice *list, int x, int y)
}
Vmenu::~Vmenu(void) {
Vmenu::~Vmenu() {
_addr = NULL;
}