Removed references to _vm from the engine itself.

svn-id: r35358
This commit is contained in:
Nicola Mettifogo 2008-12-14 10:32:26 +00:00
parent e98bc7e402
commit dc3e9027f4
13 changed files with 50 additions and 51 deletions

View file

@ -261,9 +261,10 @@ class BalloonManager_ns : public BalloonManager {
Balloon *getBalloon(uint id); Balloon *getBalloon(uint id);
Gfx *_gfx; Gfx *_gfx;
Font *_font;
public: public:
BalloonManager_ns(Gfx *gfx); BalloonManager_ns(Gfx *gfx, Font *font);
~BalloonManager_ns(); ~BalloonManager_ns();
void freeBalloons(); void freeBalloons();
@ -276,7 +277,7 @@ public:
int16 BalloonManager_ns::_dialogueBalloonX[5] = { 80, 120, 150, 150, 150 }; int16 BalloonManager_ns::_dialogueBalloonX[5] = { 80, 120, 150, 150, 150 };
BalloonManager_ns::BalloonManager_ns(Gfx *gfx) : _numBalloons(0), _gfx(gfx) { BalloonManager_ns::BalloonManager_ns(Gfx *gfx, Font *font) : _numBalloons(0), _gfx(gfx), _font(font) {
_textColors[kSelectedColor] = 0; _textColors[kSelectedColor] = 0;
_textColors[kUnselectedColor] = 3; _textColors[kUnselectedColor] = 3;
_textColors[kNormalColor] = 0; _textColors[kNormalColor] = 0;
@ -331,7 +332,7 @@ int BalloonManager_ns::setSingleBalloon(const char *text, uint16 x, uint16 y, ui
int16 w, h; int16 w, h;
StringExtent_NS se(_vm->_dialogueFont); StringExtent_NS se(_font);
se.calc(text, MAX_BALLOON_WIDTH); se.calc(text, MAX_BALLOON_WIDTH);
w = se.width() + 14; w = se.width() + 14;
h = se.height() + 20; h = se.height() + 20;
@ -339,7 +340,7 @@ int BalloonManager_ns::setSingleBalloon(const char *text, uint16 x, uint16 y, ui
int id = createBalloon(w+5, h, winding, 1); int id = createBalloon(w+5, h, winding, 1);
Balloon *balloon = &_intBalloons[id]; Balloon *balloon = &_intBalloons[id];
StringWriter_NS sw(_vm->_dialogueFont); StringWriter_NS sw(_font);
sw.write(text, MAX_BALLOON_WIDTH, _textColors[textColor], balloon->surface); sw.write(text, MAX_BALLOON_WIDTH, _textColors[textColor], balloon->surface);
// TODO: extract some text to make a name for obj // TODO: extract some text to make a name for obj
@ -355,7 +356,7 @@ int BalloonManager_ns::setDialogueBalloon(const char *text, uint16 winding, Text
int16 w, h; int16 w, h;
StringExtent_NS se(_vm->_dialogueFont); StringExtent_NS se(_font);
se.calc(text, MAX_BALLOON_WIDTH); se.calc(text, MAX_BALLOON_WIDTH);
w = se.width() + 14; w = se.width() + 14;
h = se.height() + 20; h = se.height() + 20;
@ -364,7 +365,7 @@ int BalloonManager_ns::setDialogueBalloon(const char *text, uint16 winding, Text
int id = createBalloon(w+5, h, winding, 1); int id = createBalloon(w+5, h, winding, 1);
Balloon *balloon = &_intBalloons[id]; Balloon *balloon = &_intBalloons[id];
StringWriter_NS sw(_vm->_dialogueFont); StringWriter_NS sw(_font);
sw.write(text, MAX_BALLOON_WIDTH, _textColors[textColor], balloon->surface); sw.write(text, MAX_BALLOON_WIDTH, _textColors[textColor], balloon->surface);
// TODO: extract some text to make a name for obj // TODO: extract some text to make a name for obj
@ -385,7 +386,7 @@ void BalloonManager_ns::setBalloonText(uint id, const char *text, TextColor text
Balloon *balloon = getBalloon(id); Balloon *balloon = getBalloon(id);
balloon->surface->fillRect(balloon->innerBox, 1); balloon->surface->fillRect(balloon->innerBox, 1);
StringWriter_NS sw(_vm->_dialogueFont); StringWriter_NS sw(_font);
sw.write(text, MAX_BALLOON_WIDTH, _textColors[textColor], balloon->surface); sw.write(text, MAX_BALLOON_WIDTH, _textColors[textColor], balloon->surface);
} }
@ -394,14 +395,14 @@ int BalloonManager_ns::setLocationBalloon(const char *text, bool endGame) {
int16 w, h; int16 w, h;
StringExtent_NS se(_vm->_dialogueFont); StringExtent_NS se(_font);
se.calc(text, MAX_BALLOON_WIDTH); se.calc(text, MAX_BALLOON_WIDTH);
w = se.width() + 14; w = se.width() + 14;
h = se.height() + 20; h = se.height() + 20;
int id = createBalloon(w+(endGame ? 5 : 10), h+5, -1, BALLOON_TRANSPARENT_COLOR_NS); int id = createBalloon(w+(endGame ? 5 : 10), h+5, -1, BALLOON_TRANSPARENT_COLOR_NS);
Balloon *balloon = &_intBalloons[id]; Balloon *balloon = &_intBalloons[id];
StringWriter_NS sw(_vm->_dialogueFont); StringWriter_NS sw(_font);
sw.write(text, MAX_BALLOON_WIDTH, _textColors[kNormalColor], balloon->surface); sw.write(text, MAX_BALLOON_WIDTH, _textColors[kNormalColor], balloon->surface);
// TODO: extract some text to make a name for obj // TODO: extract some text to make a name for obj
@ -548,6 +549,7 @@ class BalloonManager_br : public BalloonManager {
Disk *_disk; Disk *_disk;
Gfx *_gfx; Gfx *_gfx;
Font *_font;
Frames *_leftBalloon; Frames *_leftBalloon;
Frames *_rightBalloon; Frames *_rightBalloon;
@ -561,7 +563,7 @@ class BalloonManager_br : public BalloonManager {
StringWriter_BR _writer; StringWriter_BR _writer;
public: public:
BalloonManager_br(Disk *disk, Gfx *gfx); BalloonManager_br(Disk *disk, Gfx *gfx, Font *font);
~BalloonManager_br(); ~BalloonManager_br();
void freeBalloons(); void freeBalloons();
@ -669,7 +671,7 @@ int BalloonManager_br::setDialogueBalloon(const char *text, uint16 winding, Text
void BalloonManager_br::setBalloonText(uint id, const char *text, TextColor textColor) { void BalloonManager_br::setBalloonText(uint id, const char *text, TextColor textColor) {
Balloon *balloon = getBalloon(id); Balloon *balloon = getBalloon(id);
StringWriter_BR sw(_vm->_dialogueFont); StringWriter_BR sw(_font);
sw.write(text, 216, _textColors[textColor], balloon->surface); sw.write(text, 216, _textColors[textColor], balloon->surface);
} }
@ -693,7 +695,7 @@ int BalloonManager_br::createBalloon(int16 w, int16 h, uint16 borderThickness) {
} }
int BalloonManager_br::setLocationBalloon(const char *text, bool endGame) { int BalloonManager_br::setLocationBalloon(const char *text, bool endGame) {
StringExtent_BR se(_vm->_dialogueFont); StringExtent_BR se(_font);
se.calc(text, 240); se.calc(text, 240);
@ -742,8 +744,8 @@ void BalloonManager_br::cacheAnims() {
BalloonManager_br::BalloonManager_br(Disk *disk, Gfx *gfx) : _numBalloons(0), _disk(disk), _gfx(gfx), BalloonManager_br::BalloonManager_br(Disk *disk, Gfx *gfx, Font *font) : _numBalloons(0), _disk(disk), _gfx(gfx), _font(font),
_leftBalloon(0), _rightBalloon(0), _writer(_vm->_dialogueFont) { _leftBalloon(0), _rightBalloon(0), _writer(_font) {
_textColors[kSelectedColor] = 12; _textColors[kSelectedColor] = 12;
_textColors[kUnselectedColor] = 0; _textColors[kUnselectedColor] = 0;
@ -756,11 +758,11 @@ BalloonManager_br::~BalloonManager_br() {
} }
void Parallaction::setupBalloonManager() { void Parallaction::setupBalloonManager() {
if (_vm->getGameType() == GType_Nippon) { if (getGameType() == GType_Nippon) {
_balloonMan = new BalloonManager_ns(_vm->_gfx); _balloonMan = new BalloonManager_ns(_gfx, _dialogueFont);
} else } else
if (_vm->getGameType() == GType_BRA) { if (getGameType() == GType_BRA) {
_balloonMan = new BalloonManager_br(_vm->_disk, _vm->_gfx); _balloonMan = new BalloonManager_br(_disk, _gfx, _dialogueFont);
} else { } else {
error("Unknown game type"); error("Unknown game type");
} }

View file

@ -171,7 +171,7 @@ void Parallaction_ns::_c_fade(void *parm) {
_gfx->setPalette(pal); _gfx->setPalette(pal);
_gfx->updateScreen(); _gfx->updateScreen();
_vm->_system->delayMillis(20); _system->delayMillis(20);
} }
return; return;
@ -306,7 +306,7 @@ void Parallaction_ns::_c_endComment(void *param) {
_gfx->setPalette(_gfx->_palette); _gfx->setPalette(_gfx->_palette);
_gfx->updateScreen(); _gfx->updateScreen();
_vm->_system->delayMillis(20); _system->delayMillis(20);
} }
_input->waitForButtonEvent(kMouseLeftUp); _input->waitForButtonEvent(kMouseLeftUp);
@ -325,10 +325,10 @@ void Parallaction_ns::_c_frankenstein(void *parm) {
} }
for (uint16 _di = 0; _di < 30; _di++) { for (uint16 _di = 0; _di < 30; _di++) {
_vm->_system->delayMillis(20); _system->delayMillis(20);
_gfx->setPalette(pal0); _gfx->setPalette(pal0);
_gfx->updateScreen(); _gfx->updateScreen();
_vm->_system->delayMillis(20); _system->delayMillis(20);
_gfx->setPalette(pal1); _gfx->setPalette(pal1);
_gfx->updateScreen(); _gfx->updateScreen();
} }

View file

@ -409,7 +409,7 @@ void Parallaction::exitDialogueMode() {
_input->_inputMode = Input::kInputModeGame; _input->_inputMode = Input::kInputModeGame;
if (_dialogueMan->_cmdList) { if (_dialogueMan->_cmdList) {
_vm->_cmdExec->run(*_dialogueMan->_cmdList); _cmdExec->run(*_dialogueMan->_cmdList);
} }
// The current instance of _dialogueMan must be destroyed before the zone commands // The current instance of _dialogueMan must be destroyed before the zone commands

View file

@ -152,6 +152,7 @@ protected:
void loadMask(BackgroundInfo& info, const char *name); void loadMask(BackgroundInfo& info, const char *name);
void loadPath(BackgroundInfo& info, const char *name); void loadPath(BackgroundInfo& info, const char *name);
void loadBackground(BackgroundInfo& info, const char *name); void loadBackground(BackgroundInfo& info, const char *name);
void buildMask(byte* buf);
public: public:
AmigaDisk_ns(Parallaction *vm); AmigaDisk_ns(Parallaction *vm);

View file

@ -914,7 +914,7 @@ Common::SeekableReadStream *AmigaDisk_ns::tryOpenFile(const char* name) {
NOTE: this routine is only able to build masks for Nippon Safes, since mask widths are hardcoded NOTE: this routine is only able to build masks for Nippon Safes, since mask widths are hardcoded
into the main loop. into the main loop.
*/ */
void buildMask(byte* buf) { void AmigaDisk_ns::buildMask(byte* buf) {
byte mask1[16] = { 0, 0x80, 0x20, 0xA0, 8, 0x88, 0x28, 0xA8, 2, 0x82, 0x22, 0xA2, 0xA, 0x8A, 0x2A, 0xAA }; byte mask1[16] = { 0, 0x80, 0x20, 0xA0, 8, 0x88, 0x28, 0xA8, 2, 0x82, 0x22, 0xA2, 0xA, 0x8A, 0x2A, 0xAA };
byte mask0[16] = { 0, 0x40, 0x10, 0x50, 4, 0x44, 0x14, 0x54, 1, 0x41, 0x11, 0x51, 0x5, 0x45, 0x15, 0x55 }; byte mask0[16] = { 0, 0x40, 0x10, 0x50, 4, 0x44, 0x14, 0x54, 1, 0x41, 0x11, 0x51, 0x5, 0x45, 0x15, 0x55 };

View file

@ -44,6 +44,8 @@ class Parallaction_br;
class CommandExec { class CommandExec {
protected: protected:
Parallaction *_vm;
struct ParallactionStruct1 { struct ParallactionStruct1 {
CommandPtr cmd; CommandPtr cmd;
ZonePtr z; ZonePtr z;
@ -69,7 +71,7 @@ public:
virtual void run(CommandList &list, ZonePtr z = nullZonePtr); virtual void run(CommandList &list, ZonePtr z = nullZonePtr);
void runSuspended(); void runSuspended();
CommandExec() { CommandExec(Parallaction *vm) : _vm(vm) {
_suspendedCtxt.valid = false; _suspendedCtxt.valid = false;
} }
virtual ~CommandExec() { virtual ~CommandExec() {

View file

@ -438,7 +438,7 @@ void CommandExec::runSuspended() {
} }
} }
CommandExec_ns::CommandExec_ns(Parallaction_ns* vm) : _vm(vm) { CommandExec_ns::CommandExec_ns(Parallaction_ns* vm) : CommandExec(vm), _vm(vm) {
} }

View file

@ -73,8 +73,9 @@ int32 Gfx::getVar(const Common::String &name) {
#define LABEL_TRANSPARENT_COLOR 0xFF #define LABEL_TRANSPARENT_COLOR 0xFF
void halfbritePixel(int x, int y, int color, void *data) { void halfbritePixel(int x, int y, int color, void *data) {
byte *buffer = (byte*)data; Graphics::Surface *surf = (Graphics::Surface *)data;
buffer[x + y * _vm->_screenWidth] &= ~0x20; byte *pixel = (byte*)surf->getBasePtr(x, y);
*pixel &= ~0x20;
} }
void drawCircleLine(int xCenter, int yCenter, int x, int y, int color, void (*plotProc)(int, int, int, void *), void *data){ void drawCircleLine(int xCenter, int yCenter, int x, int y, int color, void (*plotProc)(int, int, int, void *), void *data){
@ -524,7 +525,7 @@ void Gfx::applyHalfbriteEffect_NS(Graphics::Surface &surf) {
} }
} }
if (_hbCircleRadius > 0) { if (_hbCircleRadius > 0) {
drawCircle(_hbCirclePos.x, _hbCirclePos.y, _hbCircleRadius, 0, &halfbritePixel, surf.pixels); drawCircle(_hbCirclePos.x, _hbCirclePos.y, _hbCircleRadius, 0, &halfbritePixel, &surf);
} }
} }

View file

@ -42,9 +42,7 @@
namespace Parallaction { namespace Parallaction {
// FIXME: remove this
Parallaction *_vm = NULL; Parallaction *_vm = NULL;
// public stuff // public stuff
char _saveData1[30] = { '\0' }; char _saveData1[30] = { '\0' };
@ -61,11 +59,7 @@ uint32 _globalFlags = 0;
Parallaction::Parallaction(OSystem *syst, const PARALLACTIONGameDescription *gameDesc) : Parallaction::Parallaction(OSystem *syst, const PARALLACTIONGameDescription *gameDesc) :
Engine(syst), _gameDescription(gameDesc), _char(this) { Engine(syst), _gameDescription(gameDesc), _char(this) {
// FIXME: Fingolfin asks: why is there a FIXME here? Please either clarify what
// needs fixing, or remove it!
// FIXME
_vm = this; _vm = this;
Common::addSpecialDebugLevel(kDebugDialogue, "dialogue", "Dialogues debug level"); Common::addSpecialDebugLevel(kDebugDialogue, "dialogue", "Dialogues debug level");
Common::addSpecialDebugLevel(kDebugParser, "parser", "Parser debug level"); Common::addSpecialDebugLevel(kDebugParser, "parser", "Parser debug level");
Common::addSpecialDebugLevel(kDebugDisk, "disk", "Disk debug level"); Common::addSpecialDebugLevel(kDebugDisk, "disk", "Disk debug level");
@ -161,7 +155,7 @@ void Parallaction::updateView() {
//foot.y -= ... //foot.y -= ...
int min = SCROLL_BAND_WIDTH; int min = SCROLL_BAND_WIDTH;
int max = _vm->_screenWidth - SCROLL_BAND_WIDTH; int max = _screenWidth - SCROLL_BAND_WIDTH;
if (foot.x < min) { if (foot.x < min) {
scrollX -= (min - foot.x); scrollX -= (min - foot.x);
@ -175,7 +169,7 @@ void Parallaction::updateView() {
_gfx->animatePalette(); _gfx->animatePalette();
_gfx->updateScreen(); _gfx->updateScreen();
_vm->_system->delayMillis(30); _system->delayMillis(30);
} }
@ -296,8 +290,8 @@ void Parallaction::showSlide(const char *name, int x, int y) {
BackgroundInfo *info = new BackgroundInfo; BackgroundInfo *info = new BackgroundInfo;
_disk->loadSlide(*info, name); _disk->loadSlide(*info, name);
info->x = (x == CENTER_LABEL_HORIZONTAL) ? ((_vm->_screenWidth - info->width) >> 1) : x; info->x = (x == CENTER_LABEL_HORIZONTAL) ? ((_screenWidth - info->width) >> 1) : x;
info->y = (y == CENTER_LABEL_VERTICAL) ? ((_vm->_screenHeight - info->height) >> 1) : y; info->y = (y == CENTER_LABEL_VERTICAL) ? ((_screenHeight - info->height) >> 1) : y;
_gfx->setBackground(kBackgroundSlide, info); _gfx->setBackground(kBackgroundSlide, info);
} }
@ -411,7 +405,7 @@ void Parallaction::doLocationEnterTransition() {
pal.fadeTo(_gfx->_palette, 4); pal.fadeTo(_gfx->_palette, 4);
_gfx->setPalette(pal); _gfx->setPalette(pal);
_gfx->updateScreen(); _gfx->updateScreen();
_vm->_system->delayMillis(20); _system->delayMillis(20);
} }
_gfx->setPalette(_gfx->_palette); _gfx->setPalette(_gfx->_palette);

View file

@ -519,7 +519,6 @@ private:
void _c_password(void*); void _c_password(void*);
}; };
// FIXME: remove global
extern Parallaction *_vm; extern Parallaction *_vm;

View file

@ -267,8 +267,8 @@ void Parallaction_br::parseLocation(const char *filename) {
delete script; delete script;
// this loads animation scripts // this loads animation scripts
AnimationList::iterator it = _vm->_location._animations.begin(); AnimationList::iterator it = _location._animations.begin();
for ( ; it != _vm->_location._animations.end(); it++) { for ( ; it != _location._animations.end(); it++) {
if ((*it)->_scriptName) { if ((*it)->_scriptName) {
loadProgram(*it, (*it)->_scriptName); loadProgram(*it, (*it)->_scriptName);
} }
@ -289,7 +289,7 @@ void Parallaction_br::loadProgram(AnimationPtr a, const char *filename) {
delete script; delete script;
_vm->_location._programs.push_back(program); _location._programs.push_back(program);
debugC(1, kDebugParser, "loadProgram() done"); debugC(1, kDebugParser, "loadProgram() done");

View file

@ -260,7 +260,7 @@ void Parallaction_ns::switchBackground(const char* background, const char* mask)
v2 += 4; v2 += 4;
} }
_vm->_system->delayMillis(20); _system->delayMillis(20);
_gfx->setPalette(pal); _gfx->setPalette(pal);
_gfx->updateScreen(); _gfx->updateScreen();
} }
@ -375,15 +375,15 @@ void Parallaction_ns::parseLocation(const char *filename) {
// TODO: the following two lines are specific to Nippon Safes // TODO: the following two lines are specific to Nippon Safes
// and should be moved into something like 'initializeParsing()' // and should be moved into something like 'initializeParsing()'
_vm->_location._hasSound = false; _location._hasSound = false;
_locationParser->parse(script); _locationParser->parse(script);
delete script; delete script;
// this loads animation scripts // this loads animation scripts
AnimationList::iterator it = _vm->_location._animations.begin(); AnimationList::iterator it = _location._animations.begin();
for ( ; it != _vm->_location._animations.end(); it++) { for ( ; it != _location._animations.end(); it++) {
if ((*it)->_scriptName) { if ((*it)->_scriptName) {
loadProgram(*it, (*it)->_scriptName); loadProgram(*it, (*it)->_scriptName);
} }

View file

@ -356,7 +356,7 @@ void Parallaction_ns::loadProgram(AnimationPtr a, const char *filename) {
delete script; delete script;
_vm->_location._programs.push_back(program); _location._programs.push_back(program);
debugC(1, kDebugParser, "loadProgram() done"); debugC(1, kDebugParser, "loadProgram() done");