From 15bf8050b822db25c3ab4802c0e8438d0151a3cd Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 16 Sep 2011 06:45:28 +0200 Subject: CGE: Move two globals functions to CGEEngine --- engines/cge/cge.h | 2 ++ engines/cge/cge_main.cpp | 18 ++++++++++++++++++ engines/cge/events.cpp | 2 +- engines/cge/snail.cpp | 4 ++-- engines/cge/snail.h | 1 + engines/cge/vga13h.cpp | 18 ------------------ engines/cge/vga13h.h | 3 --- 7 files changed, 24 insertions(+), 24 deletions(-) (limited to 'engines/cge') diff --git a/engines/cge/cge.h b/engines/cge/cge.h index f62280aabc..24288cdece 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -230,6 +230,8 @@ public: int takeEnum(const char **tab, const char *text); int newRandom(int range); void sndSetVolume(); + Sprite *locate(int ref); + Sprite *spriteAt(int x, int y); void snBackPt(Sprite *spr, int stp); void snHBarrier(const int scene, const int barX); diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 86ea267c80..c5450aefd3 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -1221,6 +1221,24 @@ void CGEEngine::loadScript(const char *fname) { error("Bad INI line %d [%s]", lcnt, fname); } +Sprite *CGEEngine::locate(int ref) { + Sprite *spr = _vga->_showQ->locate(ref); + return (spr) ? spr : _vga->_spareQ->locate(ref); +} + +Sprite *CGEEngine::spriteAt(int x, int y) { + Sprite *spr = NULL, * tail = _vga->_showQ->last(); + if (tail) { + for (spr = tail->_prev; spr; spr = spr->_prev) { + if (! spr->_flags._hide && ! spr->_flags._tran) { + if (spr->shp()->solidAt(x - spr->_x, y - spr->_y)) + break; + } + } + } + return spr; +} + void CGEEngine::mainLoop() { _vga->show(); _snail_->runCom(); diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 072771ebac..1330466aa2 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -242,7 +242,7 @@ void Mouse::newMouse(Common::Event &event) { CGEEvent &evt = _eventManager->getNextEvent(); evt._x = event.mouse.x; evt._y = event.mouse.y; - evt._spritePtr = spriteAt(evt._x, evt._y); + evt._spritePtr = _vm->spriteAt(evt._x, evt._y); switch (event.type) { case Common::EVENT_MOUSEMOVE: diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 1acfd1f9d5..19adf6bcb4 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -964,7 +964,7 @@ void Snail::runCom() { break; } - Sprite *spr = ((snc->_ref >= 0) ? locate(snc->_ref) : ((Sprite *) snc->_ptr)); + Sprite *spr = ((snc->_ref >= 0) ? _vm->locate(snc->_ref) : ((Sprite *) snc->_ptr)); switch (snc->_com) { case kSnLabel: break; @@ -1033,7 +1033,7 @@ void Snail::runCom() { _vm->snCover(spr, snc->_val); break; case kSnUncover: - _vm->snUncover(spr, (snc->_val >= 0) ? locate(snc->_val) : ((Sprite *) snc->_ptr)); + _vm->snUncover(spr, (snc->_val >= 0) ? _vm->locate(snc->_val) : ((Sprite *) snc->_ptr)); break; case kSnKeep: _vm->snKeep(spr, snc->_val); diff --git a/engines/cge/snail.h b/engines/cge/snail.h index c6157a0096..533d6b74ef 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -70,6 +70,7 @@ public: bool _talkEnable; Snail(CGEEngine *vm, bool turbo); ~Snail(); + void runCom(); void addCom(SnCom com, int ref, int val, void *ptr); void addCom2(SnCom com, int ref, int val, CallbackType cbType); diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index 286fadd1ef..f0fbd630e1 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -64,11 +64,6 @@ Dac mkDac(uint8 r, uint8 g, uint8 b) { return x; } -Sprite *locate(int ref) { - Sprite *spr = _vga->_showQ->locate(ref); - return (spr) ? spr : _vga->_spareQ->locate(ref); -} - Sprite::Sprite(CGEEngine *vm, BitmapPtr *shpP) : _x(0), _y(0), _z(0), _nearPtr(0), _takePtr(0), _next(NULL), _prev(NULL), _seqPtr(kNoSeq), _time(0), @@ -556,19 +551,6 @@ void Sprite::sync(Common::Serializer &s) { s.syncAsUint16LE(unused); // _next } -Sprite *spriteAt(int x, int y) { - Sprite *spr = NULL, * tail = _vga->_showQ->last(); - if (tail) { - for (spr = tail->_prev; spr; spr = spr->_prev) { - if (! spr->_flags._hide && ! spr->_flags._tran) { - if (spr->shp()->solidAt(x - spr->_x, y - spr->_y)) - break; - } - } - } - return spr; -} - Queue::Queue(bool show) : _head(NULL), _tail(NULL), _show(show) { } diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index d8648248df..f382e05a44 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -266,9 +266,6 @@ uint8 closest(CBLK *pal, CBLK x) { #undef f } -Sprite *spriteAt(int x, int y); -Sprite *locate(int ref); - } // End of namespace CGE #endif -- cgit v1.2.3