2007-05-30 21:56:52 +00:00
|
|
|
/* 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.
|
2003-12-16 02:10:15 +00:00
|
|
|
*
|
|
|
|
* 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
|
2008-01-05 12:45:14 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2003-12-16 02:10:15 +00:00
|
|
|
* 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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2003-12-16 02:10:15 +00:00
|
|
|
*
|
2006-02-11 10:01:01 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2003-12-16 02:10:15 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-02-20 18:04:13 +00:00
|
|
|
#ifndef SWORD1_LOGIC_H
|
|
|
|
#define SWORD1_LOGIC_H
|
2003-12-16 02:10:15 +00:00
|
|
|
// combination of logic.c and scr_int.c
|
|
|
|
|
2004-10-21 12:43:49 +00:00
|
|
|
#include "sword1/sworddefs.h"
|
|
|
|
#include "sword1/objectman.h"
|
2003-12-16 02:10:15 +00:00
|
|
|
#include "common/util.h"
|
2010-03-18 15:07:11 +00:00
|
|
|
#include "common/random.h"
|
2004-01-18 05:52:04 +00:00
|
|
|
#include "sound/mixer.h"
|
2003-12-16 02:10:15 +00:00
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
namespace Sword1 {
|
|
|
|
|
2003-12-16 02:10:15 +00:00
|
|
|
#define NON_ZERO_SCRIPT_VARS 95
|
|
|
|
#define NUM_SCRIPT_VARS 1179
|
|
|
|
|
2008-09-27 17:47:22 +00:00
|
|
|
class SwordEngine;
|
2004-01-11 15:47:41 +00:00
|
|
|
class Text;
|
|
|
|
class Sound;
|
2003-12-16 02:10:15 +00:00
|
|
|
class EventManager;
|
2004-01-11 15:47:41 +00:00
|
|
|
class Menu;
|
|
|
|
class Router;
|
|
|
|
class Screen;
|
|
|
|
class Mouse;
|
|
|
|
class Music;
|
2003-12-16 02:10:15 +00:00
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
class Logic;
|
|
|
|
typedef int (Logic::*BSMcodeTable)(Object *, int32, int32, int32, int32, int32, int32, int32);
|
2003-12-16 02:10:15 +00:00
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
class Logic {
|
2003-12-16 02:10:15 +00:00
|
|
|
public:
|
2008-09-27 17:47:22 +00:00
|
|
|
Logic(SwordEngine *vm, ObjectMan *pObjMan, ResMan *resMan, Screen *pScreen, Mouse *pMouse, Sound *pSound, Music *pMusic, Menu *pMenu, OSystem *system, Audio::Mixer *mixer);
|
2009-11-02 21:54:57 +00:00
|
|
|
~Logic();
|
|
|
|
void initialize();
|
2003-12-16 09:43:08 +00:00
|
|
|
void newScreen(uint32 screen);
|
2009-11-02 21:54:57 +00:00
|
|
|
void engine();
|
|
|
|
void updateScreenParams();
|
2004-01-11 15:47:41 +00:00
|
|
|
void runMouseScript(Object *cpt, int32 scriptId);
|
2004-12-08 04:38:39 +00:00
|
|
|
void startPositions(uint32 pos);
|
2003-12-16 02:10:15 +00:00
|
|
|
|
|
|
|
static uint32 _scriptVars[NUM_SCRIPT_VARS];
|
2004-01-01 18:00:34 +00:00
|
|
|
// public for mouse (menu looking)
|
2004-01-11 15:47:41 +00:00
|
|
|
int cfnPresetScript (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
2003-12-16 02:10:15 +00:00
|
|
|
private:
|
2008-09-27 17:47:22 +00:00
|
|
|
SwordEngine *_vm;
|
2003-12-16 02:10:15 +00:00
|
|
|
ObjectMan *_objMan;
|
2004-01-18 05:52:04 +00:00
|
|
|
OSystem *_system;
|
2005-05-10 23:48:48 +00:00
|
|
|
Audio::Mixer *_mixer;
|
2003-12-16 02:10:15 +00:00
|
|
|
ResMan *_resMan;
|
2004-01-11 15:47:41 +00:00
|
|
|
Screen *_screen;
|
|
|
|
Sound *_sound;
|
|
|
|
Mouse *_mouse;
|
|
|
|
Router *_router;
|
|
|
|
Text *_textMan;
|
2003-12-16 02:10:15 +00:00
|
|
|
EventManager *_eventMan;
|
2004-01-11 15:47:41 +00:00
|
|
|
Menu *_menu;
|
|
|
|
Music *_music;
|
2003-12-16 02:10:15 +00:00
|
|
|
uint32 _newScript; // <= ugly, but I can't avoid it.
|
|
|
|
bool _speechRunning, _speechFinished, _textRunning;
|
|
|
|
uint8 _speechClickDelay;
|
|
|
|
Common::RandomSource _rnd;
|
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
int scriptManager(Object *compact, uint32 id);
|
|
|
|
void processLogic(Object *compact, uint32 id);
|
|
|
|
int interpretScript(Object *compact, int id, Header *scriptModule, int scriptBase, int scriptNum);
|
2003-12-16 02:10:15 +00:00
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
int logicWaitTalk(Object *compact);
|
|
|
|
int logicStartTalk(Object *compact);
|
|
|
|
int logicArAnimate(Object *compact, uint32 id);
|
|
|
|
int speechDriver(Object *compact);
|
|
|
|
int fullAnimDriver(Object *compact);
|
|
|
|
int animDriver(Object *compact);
|
2003-12-16 02:10:15 +00:00
|
|
|
|
2006-09-09 09:30:16 +00:00
|
|
|
void setupMcodeTable();
|
|
|
|
const BSMcodeTable *_mcodeTable;
|
2005-11-06 13:14:10 +00:00
|
|
|
|
2003-12-16 02:10:15 +00:00
|
|
|
uint16 inRange(uint16 a, uint16 b, uint16 c);
|
|
|
|
|
|
|
|
//- mcodeTable:
|
2004-01-11 15:47:41 +00:00
|
|
|
int fnBackground (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnForeground (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnSort (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
2004-12-08 04:38:39 +00:00
|
|
|
int fnNoSprite (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnMegaSet (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
2004-01-11 15:47:41 +00:00
|
|
|
int fnAnim (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnSetFrame (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnFullAnim (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnFullSetFrame (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnFadeDown (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnFadeUp (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnCheckFade (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnSetSpritePalette(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnSetWholePalette(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnSetFadeTargetPalette(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnSetPaletteToFade(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnSetPaletteToCut(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
2004-12-08 04:38:39 +00:00
|
|
|
int fnPlaySequence (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
2004-01-11 15:47:41 +00:00
|
|
|
|
|
|
|
int fnIdle (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnPause (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnPauseSeconds (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnQuit (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnKillId (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnSuicide (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnNewScript (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnSubScript (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnRestartScript (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnSetBookmark (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnGotoBookmark (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnSendSync (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnWaitSync (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
int cfnClickInteract(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int cfnSetScript (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
|
|
|
|
int fnInteract (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnIssueEvent (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnCheckForEvent (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnWipeHands (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnISpeak (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnTheyDo (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnTheyDoWeWait (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnWeWait (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnChangeSpeechText(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnTalkError (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnStartTalk (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnCheckForTextLine(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnAddTalkWaitStatusBit(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnRemoveTalkWaitStatusBit(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
|
|
|
|
int fnNoHuman (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnAddHuman (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnBlankMouse (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnNormalMouse (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnLockMouse (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnUnlockMouse (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnSetMousePointer(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnSetMouseLuggage(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnMouseOn (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnMouseOff (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnChooser (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnEndChooser (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnStartMenu (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnEndMenu (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
int cfnReleaseMenu (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
int fnAddSubject (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
2004-12-08 04:38:39 +00:00
|
|
|
int fnAddObject (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
2004-01-11 15:47:41 +00:00
|
|
|
int fnRemoveObject (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
2004-12-08 04:38:39 +00:00
|
|
|
int fnEnterSection (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
2004-01-11 15:47:41 +00:00
|
|
|
int fnLeaveSection (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnChangeFloor (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnWalk (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnTurn (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnStand (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnStandAt (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnFace (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnFaceXy (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnIsFacing (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnGetTo (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnGetToError (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnGetPos (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnGetGamepadXy (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnPlayFx (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnStopFx (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnPlayMusic (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnStopMusic (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnInnerSpace (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnRandom (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnSetScreen (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnPreload (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnCheckCD (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnRestartGame (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnQuitGame (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnDeathScreen (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnSetParallax (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnTdebug (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
|
|
|
|
int fnRedFlash (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnBlueFlash (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnYellow (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnGreen (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnPurple (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
|
|
|
int fnBlack (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
|
2003-12-16 02:10:15 +00:00
|
|
|
static const uint32 _scriptVarInit[NON_ZERO_SCRIPT_VARS][2];
|
2004-12-08 04:38:39 +00:00
|
|
|
static const uint8 *_startData[];
|
|
|
|
static const uint8 *_helperData[];
|
|
|
|
void startPosCallFn(uint8 fnId, uint32 param1, uint32 param2, uint32 param3);
|
|
|
|
void runStartScript(const uint8 *data);
|
|
|
|
};
|
|
|
|
|
|
|
|
enum StartPosOpcodes {
|
|
|
|
opcSeqEnd = 0,
|
|
|
|
opcCallFn,
|
|
|
|
opcCallFnLong,
|
|
|
|
opcSetVar8,
|
|
|
|
opcSetVar16,
|
|
|
|
opcSetVar32,
|
|
|
|
opcGeorge,
|
|
|
|
opcRunStart,
|
|
|
|
opcRunHelper,
|
|
|
|
opcPlaySequence,
|
|
|
|
opcAddObject,
|
|
|
|
opcRemoveObject,
|
|
|
|
opcMegaSet,
|
|
|
|
opcNoSprite
|
|
|
|
};
|
|
|
|
|
|
|
|
enum HelperScripts {
|
|
|
|
HELP_IRELAND = 0,
|
|
|
|
HELP_SYRIA,
|
|
|
|
HELP_SPAIN,
|
|
|
|
HELP_NIGHTTRAIN,
|
|
|
|
HELP_SCOTLAND,
|
|
|
|
HELP_WHITECOAT,
|
|
|
|
HELP_SPAIN2
|
2003-12-16 02:10:15 +00:00
|
|
|
};
|
|
|
|
|
2005-07-30 21:11:48 +00:00
|
|
|
} // End of namespace Sword1
|
2004-01-11 15:47:41 +00:00
|
|
|
|
2003-12-16 02:10:15 +00:00
|
|
|
#endif //BSLOGIC_H
|