Skip to content

Commit

Permalink
TSAGE: Implemented new Globals for Blue Force, and beginnings of impl…
Browse files Browse the repository at this point in the history
…ementation of Scene 100 (Title Screen)
  • Loading branch information
dreammaster committed Aug 11, 2011
1 parent c903411 commit 744f04b
Show file tree
Hide file tree
Showing 11 changed files with 335 additions and 5 deletions.
5 changes: 5 additions & 0 deletions engines/tsage/blueforce_logic.cpp
Expand Up @@ -22,6 +22,7 @@

#include "tsage/blueforce_logic.h"
#include "tsage/blueforce_scenes0.h"
#include "tsage/blueforce_scenes1.h"
#include "tsage/scenes.h"
#include "tsage/tsage.h"
#include "tsage/staticres.h"
Expand All @@ -37,13 +38,17 @@ void BlueForceGame::start() {

Scene *BlueForceGame::createScene(int sceneNumber) {
switch (sceneNumber) {
/* Scene Group #0 */
case 20:
// Tsunami Title Screen
return new BF_Scene20();
case 50:
case 60:
error("Scene group 0 not implemented");
/* Scene Group #1 */
case 100:
// Tsnunami Title Screen #2
return new BF_Scene100();
case 109:
case 110:
case 114:
Expand Down
195 changes: 195 additions & 0 deletions engines/tsage/blueforce_scenes1.cpp
@@ -0,0 +1,195 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

#include "common/config-manager.h"
#include "tsage/blueforce_scenes1.h"
#include "tsage/scenes.h"
#include "tsage/tsage.h"
#include "tsage/staticres.h"
#include "tsage/globals.h"

namespace tSage {

/*--------------------------------------------------------------------------
* Scene 100 - Tsunami Title Screen #2
*
*--------------------------------------------------------------------------*/

void BF_Scene100::Action1::signal() {
static byte black[3] = { 0, 0, 0 };

switch (_actionIndex++) {
case 0:
_state = 0;
setDelay(6);
break;
case 1: {
Common::String msg1 = _resourceManager->getMessage(100, _state++);
if (!msg1.compareTo("LASTCREDIT")) {
Common::String msg2 = _resourceManager->getMessage(100, _state++);
setTextStrings(msg1, msg2, this);
} else {
setTextStrings(BF_NAME, BF_ALL_RIGHTS_RESERVED, this);

Common::Point pt(_sceneText1._position.x, 80);
NpcMover *mover = new NpcMover();
_sceneText1.addMover(mover, &pt, this);
}
break;
}
case 2:
setDelay(600);
break;
case 3:
BF_GLOBALS._sound1.fade(0, 10, 10, 1, this);
GLOBALS._scenePalette.addFader(black, 1, 2, NULL);
break;
case 4:
error("??exit");
break;
}
}

void BF_Scene100::Action1::setTextStrings(const Common::String &msg1, const Common::String &msg2, Action *action) {
// Set data for first text control
_sceneText1._fontNumber = 10;
_sceneText1._width = 160;
_sceneText1._textMode = ALIGN_RIGHT;
_sceneText1._color1 = _globals->_fontColors.background;
_sceneText1._color2 = _globals->_fontColors.foreground;
_sceneText1._color3 = _globals->_fontColors.background;
_sceneText1.setup(msg1);
_sceneText1.setFrame2(-1);
_sceneText1.setPosition(Common::Point(
(SCREEN_WIDTH - _sceneText1.getFrame().getBounds().width()) / 2, 202));
_sceneText1._moveRate = 30;
_sceneText1._moveDiff.y = 1;

// Set data for second text control
_sceneText2._fontNumber = 10;
_sceneText2._width = _sceneText1._width;
_sceneText2._textMode = _sceneText1._textMode;
_sceneText2._color1 = _globals->_fontColors.background;
_sceneText2._color2 = _globals->_fontColors.foreground;
_sceneText2._color3 = _globals->_fontColors.background;
_sceneText2.setup(msg1);
_sceneText2.setFrame2(-1);
GfxSurface textSurface = _sceneText2.getFrame();
_sceneText2.setPosition(Common::Point((SCREEN_WIDTH - textSurface.getBounds().width()) / 2, 202));
_sceneText2._moveRate = 30;
_sceneText2._moveDiff.y = 1;

_textHeight = textSurface.getBounds().height();
int yp = -(_textHeight * 2);

Common::Point pt(_sceneText1._position.x, yp);
NpcMover *mover = new NpcMover();
_sceneText1.addMover(mover, &pt, action);
}

void BF_Scene100::Action2::signal() {
BF_Scene100 *scene = (BF_Scene100 *)_globals->_sceneManager._scene;
static byte black[3] = {0, 0, 0};

switch (_actionIndex++) {
case 0:
BF_GLOBALS._scenePalette.addFader(black, 1, -2, this);
break;
case 1:
setDelay(180);
break;
case 2: {
const char *SEEN_INTRO = "seen_intro";
if (!ConfMan.hasKey(SEEN_INTRO) || !ConfMan.getBool(SEEN_INTRO)) {
// First time being played, so will need to show the intro
ConfMan.setBool(SEEN_INTRO, true);
ConfMan.flushToDisk();
} else {
// Prompt user for whether to start play or watch introduction
_globals->_player.enableControl();

if (MessageDialog::show2(WATCH_INTRO_MSG, START_PLAY_BTN_STRING, INTRODUCTION_BTN_STRING) == 0) {
// Signal to start the game
scene->_index = 190;
remove();
return;
}
}

// At this point the introduction needs to start
_globals->_scenePalette.addFader(black, 1, 2, this);
break;
}
case 3:
remove();
break;
}
}

/*--------------------------------------------------------------------------*/

BF_Scene100::BF_Scene100(): Scene() {
_index = 0;
}

void BF_Scene100::postInit(SceneObjectList *OwnerList) {
BF_GLOBALS._scenePalette.loadPalette(2);
BF_GLOBALS._v51C44 = 1;
Scene::postInit();
BF_GLOBALS._v51C24 = 200;

_globals->_player.enableControl();
_globals->_player.hide();
_globals->_player.disableControl();
_index = 109;

if (BF_GLOBALS._v4CEA2 < 6) {
// Title
loadScene(100);
BF_GLOBALS._sound1.play(2);
setAction(&_action2, this);
} else {
// Credits
loadScene(101);
BF_GLOBALS._sound1.play(118);
setAction(&_action1, this);
}

loadScene(20);
setZoomPercents(60, 85, 200, 100);
}

void BF_Scene100::signal() {
++_sceneMode;
if (BF_GLOBALS._v4CEA2 < 6) {
BF_GLOBALS._scenePalette.clearListeners();
BF_GLOBALS._scenePalette.loadPalette(100);
BF_GLOBALS._sceneManager.changeScene(_index);
} else {
if (_sceneMode > 1)
BF_GLOBALS._events.setCursor(CURSOR_ARROW);

setAction(this, &_action1, this);
}
}

} // End of namespace tSage
73 changes: 73 additions & 0 deletions engines/tsage/blueforce_scenes1.h
@@ -0,0 +1,73 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

#ifndef TSAGE_BLUEFORCE_SCENES1_H
#define TSAGE_BLUEFORCE_SCENES1_H

#include "common/scummsys.h"
#include "tsage/blueforce_logic.h"
#include "tsage/converse.h"
#include "tsage/events.h"
#include "tsage/core.h"
#include "tsage/scenes.h"
#include "tsage/globals.h"
#include "tsage/sound.h"

namespace tSage {

class BF_Scene100: public Scene {
/* Actions */
class Action1: public ActionExt {
private:
void setTextStrings(const Common::String &msg1, const Common::String &msg2, Action *action);
public:
SceneText _sceneText1, _sceneText2;
int _textHeight;

virtual Common::String getClassName() { return "BF100Action1"; }
virtual void synchronize(Serializer &s) {
ActionExt::synchronize(s);
s.syncAsSint16LE(_textHeight);
}
virtual void signal();
};
class Action2: public ActionExt {
public:
virtual Common::String getClassName() { return "BF100Action2"; }
virtual void signal();
};
public:
SequenceManager _sequenceManager;
Action1 _action1;
Action2 _action2;
ScenePalette _scenePalette;
SceneObjectExt2 _object1, _object2, _object3, _object4, _object5;
int _index;

BF_Scene100();
virtual void postInit(SceneObjectList *OwnerList = NULL);
virtual void signal();
};

} // End of namespace tSage

#endif
2 changes: 1 addition & 1 deletion engines/tsage/events.cpp
Expand Up @@ -155,7 +155,7 @@ void EventsClass::setCursor(CursorType cursorType) {
// No cursor
_globals->setFlag(122);

if (_vm->getFeatures() & GF_DEMO) {
if ((_vm->getFeatures() & GF_DEMO) || (_vm->getGameID() == GType_BlueForce)) {
CursorMan.showMouse(false);
return;
}
Expand Down
12 changes: 12 additions & 0 deletions engines/tsage/globals.cpp
Expand Up @@ -166,5 +166,17 @@ void Globals::dispatchSounds() {
Common::for_each(_sounds.begin(), _sounds.end(), Globals::dispatchSound);
}

/*--------------------------------------------------------------------------*/

BlueForceGlobals::BlueForceGlobals(): Globals() {
_v51C24 = 0;
_v51C44 = 1;
_v4CEA2 = 0;
}

void BlueForceGlobals::synchronize(Serializer &s) {
Globals::synchronize(s);
error("Sync variables");
}

} // end of namespace tSage
15 changes: 15 additions & 0 deletions engines/tsage/globals.h
Expand Up @@ -96,8 +96,23 @@ class Globals : public SavedObject {
void dispatchSounds();
};

class BlueForceGlobals: public Globals {
public:
ASound _sound1, _sound2, _sound3;
int _v4CEA2;
int _v51C44;
int _v51C24;

BlueForceGlobals();
virtual Common::String getClassName() { return "BFGlobals"; }
virtual void synchronize(Serializer &s);
};

extern Globals *_globals;

#define GLOBALS (*_globals)
#define BF_GLOBALS (*((BlueForceGlobals *)_globals))

// Note: Currently this can't be part of the _globals structure, since it needs to be constructed
// prior to many of the fields in Globals execute their constructors
extern ResourceManager *_resourceManager;
Expand Down
1 change: 1 addition & 0 deletions engines/tsage/module.mk
Expand Up @@ -3,6 +3,7 @@ MODULE := engines/tsage
MODULE_OBJS := \
blueforce_logic.o \
blueforce_scenes0.o \
blueforce_scenes1.o \
converse.o \
core.o \
debugger.o \
Expand Down
8 changes: 5 additions & 3 deletions engines/tsage/scenes.cpp
Expand Up @@ -28,9 +28,6 @@

namespace tSage {

// TODO: Doesn't seem to be ever set
const bool _v52C9F = false;

SceneManager::SceneManager() {
_scene = NULL;
_hasPalette = false;
Expand Down Expand Up @@ -505,8 +502,13 @@ void Scene::setZoomPercents(int yStart, int minPercent, int yEnd, int maxPercent
}

byte *Scene::preloadVisage(int resNum) {
// This isn't being used, since modern systems can load the data much quicker, and in any case
// visage data is specially loaded into the Visage class, and the resources discarded from memory.
return NULL;
/*
assert(!_v52C9F);
return _resourceManager->getResource(RES_VISAGE, resNum, 9999, false);
*/
}

/*--------------------------------------------------------------------------*/
Expand Down
11 changes: 11 additions & 0 deletions engines/tsage/staticres.cpp
Expand Up @@ -118,4 +118,15 @@ const char *EXIT_BTN_STRING = "Exit";
const char *DEMO_BTN_STRING = "Demo";
const char *DEMO_RESUME_BTN_STRING = "Resume";

// Blue Force general messages
const char *BF_NAME = "Blue Force";
const char *BF_COPYRIGHT = " Copyright, 1993 Tsunami Media, Inc.";
const char *BF_ALL_RIGHTS_RESERVED = "All Rights Reserved";
const char *BF_19840518 = "May 18, 1984";
const char *BF_19840515 = "May 15, 1984";
const char *BF_3_DAYS = "Three days later";
const char *BF_11_YEARS = "Eleven years later.";
const char *BF_NEXT_DAY = "The Next Day";
const char *BF_ACADEMY = "Here we are at the Academy";

} // End of namespace tSage

0 comments on commit 744f04b

Please sign in to comment.