2013-06-18 15:52:25 +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 .
*
* 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 .
*
*/
/*
* This code is based on the original source code of Lord Avalot d ' Argent version 1.3 .
* Copyright ( c ) 1994 - 1995 Mike , Mark and Thomas Thurman .
*/
2013-09-07 07:00:34 +00:00
# ifndef AVALANCHE_AVALANCHE_H
# define AVALANCHE_AVALANCHE_H
2013-06-18 15:52:25 +00:00
# include "avalanche/console.h"
2013-07-24 15:02:08 +00:00
# include "avalanche/graphics.h"
2013-07-27 19:36:07 +00:00
# include "avalanche/parser.h"
2013-06-29 08:20:22 +00:00
# include "avalanche/avalot.h"
2013-09-15 11:03:21 +00:00
# include "avalanche/pingo.h"
2013-09-21 16:06:37 +00:00
# include "avalanche/dialogs.h"
2013-09-19 18:53:47 +00:00
# include "avalanche/background.h"
2013-09-15 11:03:21 +00:00
# include "avalanche/sequence.h"
2013-09-08 09:30:23 +00:00
# include "avalanche/timer.h"
2013-09-07 17:09:06 +00:00
# include "avalanche/animation.h"
2013-09-18 05:47:52 +00:00
# include "avalanche/menu.h"
2013-09-15 11:03:21 +00:00
# include "avalanche/closing.h"
2013-09-18 21:59:26 +00:00
# include "avalanche/sound.h"
2013-11-22 17:03:01 +00:00
# include "avalanche/nim.h"
2014-01-15 22:04:59 +00:00
# include "avalanche/clock.h"
2013-06-20 12:08:58 +00:00
2013-08-19 16:18:02 +00:00
# include "common/serializer.h"
2013-06-20 12:08:58 +00:00
# include "engines/engine.h"
2013-06-18 15:52:25 +00:00
# include "engines/advancedDetector.h"
2013-08-16 11:00:00 +00:00
# include "graphics/cursorman.h"
2013-06-18 15:52:25 +00:00
namespace Common {
class RandomSource ;
}
namespace Avalanche {
2013-11-03 09:51:15 +00:00
struct AvalancheGameDescription {
ADGameDescription desc ;
} ;
2013-06-20 06:32:58 +00:00
2013-11-23 09:18:04 +00:00
static const int kSavegameVersion = 2 ;
2013-06-18 15:52:25 +00:00
2013-09-26 23:34:38 +00:00
enum Pitch {
kPitchInvalid ,
kPitchLower ,
kPitchSame ,
kPitchHigher
} ;
2013-06-18 15:52:25 +00:00
class AvalancheEngine : public Engine {
public :
2013-09-22 15:45:48 +00:00
byte _saveNum ; // number of times this game has been saved
2013-07-11 16:02:15 +00:00
2013-09-26 23:34:38 +00:00
Clock * _clock ;
2013-09-29 15:54:03 +00:00
GraphicManager * _graphics ;
2013-09-22 15:45:48 +00:00
Parser * _parser ;
2013-07-24 16:50:13 +00:00
Pingo * _pingo ;
2013-09-21 16:06:37 +00:00
Dialogs * _dialogs ;
2013-09-19 18:53:47 +00:00
Background * _background ;
2013-07-24 17:43:10 +00:00
Sequence * _sequence ;
2013-09-08 09:30:23 +00:00
Timer * _timer ;
2013-09-07 17:09:06 +00:00
Animation * _animation ;
2013-09-18 05:47:52 +00:00
Menu * _menu ;
2013-07-24 17:43:10 +00:00
Closing * _closing ;
2013-09-18 21:59:26 +00:00
SoundHandler * _sound ;
2013-11-22 17:03:01 +00:00
Nim * _nim ;
2013-06-28 10:27:14 +00:00
2013-07-24 15:52:57 +00:00
OSystem * _system ;
2013-06-20 06:32:58 +00:00
AvalancheEngine ( OSystem * syst , const AvalancheGameDescription * gd ) ;
2013-06-18 15:52:25 +00:00
~ AvalancheEngine ( ) ;
2013-09-07 07:00:34 +00:00
Common : : ErrorCode initialize ( ) ;
2013-06-18 15:52:25 +00:00
GUI : : Debugger * getDebugger ( ) ;
Common : : RandomSource * _rnd ;
2013-09-07 07:00:34 +00:00
2013-06-20 06:32:58 +00:00
const AvalancheGameDescription * _gameDescription ;
2013-06-18 15:52:25 +00:00
uint32 getFeatures ( ) const ;
const char * getGameId ( ) const ;
Common : : Platform getPlatform ( ) const ;
bool hasFeature ( EngineFeature f ) const ;
const char * getCopyrightString ( ) const ;
2013-08-19 16:18:02 +00:00
void synchronize ( Common : : Serializer & sz ) ;
2013-08-18 13:08:32 +00:00
virtual bool canSaveGameStateCurrently ( ) ;
Common : : Error saveGameState ( int slot , const Common : : String & desc ) ;
2013-08-19 16:18:02 +00:00
bool saveGame ( const int16 slot , const Common : : String & desc ) ;
2013-08-19 19:14:21 +00:00
Common : : String getSaveFileName ( const int slot ) ;
2013-08-18 13:08:32 +00:00
virtual bool canLoadGameStateCurrently ( ) ;
2013-08-19 19:14:21 +00:00
Common : : Error loadGameState ( int slot ) ;
bool loadGame ( const int16 slot ) ;
2013-08-20 17:23:24 +00:00
Common : : String expandDate ( int d , int m , int y ) ;
2013-11-05 20:50:41 +00:00
uint32 getTimeInSeconds ( ) ;
2013-08-20 17:23:24 +00:00
2013-08-18 13:08:32 +00:00
void updateEvents ( ) ;
2013-08-19 16:18:02 +00:00
bool getEvent ( Common : : Event & event ) ; // A wrapper around _eventMan->pollEvent(), so we can use it in Scrolls::normscroll() for example.
2013-08-16 15:29:22 +00:00
Common : : Point getMousePos ( ) ;
2013-06-18 15:52:25 +00:00
protected :
// Engine APIs
Common : : Error run ( ) ;
private :
AvalancheConsole * _console ;
Common : : Platform _platform ;
2013-09-26 23:34:38 +00:00
public :
// For Thinkabout:
static const bool kThing = true ;
static const bool kPerson = false ;
static const char kSpludwicksOrder [ 3 ] ;
static const uint16 kNotes [ 12 ] ;
bool _holdLeftMouse ;
2013-09-29 20:19:12 +00:00
2013-09-26 23:34:38 +00:00
// If this is greater than zero, the next line you type is stored in the DNA in a position dictated by the value.
// If a scroll comes up, or you leave the room, it's automatically set to zero.
byte _interrogation ;
// Former DNA structure
byte _carryNum ; // How many objects you're carrying...
bool _objects [ kObjectNum ] ; // ...and which ones they are.
int16 _dnascore ; // your score, of course
int32 _money ; // your current amount of dosh
Room _room ; // your current room
bool _wonNim ; // Have you *won* Nim? (That's harder.)
byte _wineState ; // 0=good (Notts), 1=passable(Argent) ... 3=vinegar.
bool _cwytalotGone ; // Has Cwytalot rushed off to Jerusalem yet?
byte _passwordNum ; // Number of the passw for this game.
bool _aylesIsAwake ; // pretty obvious!
byte _drawbridgeOpen ; // Between 0 (shut) and 4 (open).
byte _avariciusTalk ; // How much Avaricius has said to you.
bool _rottenOnion ; // And has it rotted?
bool _onionInVinegar ; // Is the onion in the vinegar?
byte _givenToSpludwick ; // 0 = nothing given, 1 = onion...
byte _brummieStairs ; // Progression through the stairs trick.
byte _cardiffQuestionNum ; // Things you get asked in Cardiff.
bool _avvyIsAwake ; // Well? Is Avvy awake? (Screen 1 only.)
bool _avvyInBed ; // True if Avvy's in bed, but awake.
bool _userMovesAvvy ; // If this is false, the user has no control over Avvy's movements.
byte _npcFacing ; // If there's an NPC in the current room which turns it's head according to Avvy's movement (keep looking at him), this variable tells which way it's facing at the moment.
bool _givenBadgeToIby ; // Have you given the badge to Iby yet?
bool _friarWillTieYouUp ; // If you're going to get tied up.
bool _tiedUp ; // You ARE tied up!
byte _boxContent ; // 0 = money (sixpence), 254 = empty, any other number implies the contents of the box.
bool _talkedToCrapulus ; // Pretty self-explanatory.
byte _jacquesState ; // 0=asleep, 1=awake, 2=gets up, 3=gone.
bool _bellsAreRinging ; // Is Jacques ringing the bells?
bool _standingOnDais ; // In room 71, inside Cardiff Castle.
bool _takenPen ; // Have you taken the pen (in Cardiff?)
bool _arrowInTheDoor ; // Did the arrow hit the wall?
2013-10-22 04:00:00 +00:00
Common : : String _favoriteDrink , _favoriteSong , _worstPlaceOnEarth , _spareEvening ; // Personalisation str's
2013-11-05 20:50:41 +00:00
uint32 _startTime ; // When did you start playing this session?
uint32 _totalTime ; // Your total time playing this game, in seconds. Updated only at saving and loading.
2013-09-26 23:34:38 +00:00
byte _jumpStatus ; // Fixes how high you're jumping.
bool _mushroomGrowing ; // Is the mushroom growing in 42?
bool _crapulusWillTell ; // Will Crapulus tell you about Spludwick being away?
bool _enterCatacombsFromLustiesRoom ;
bool _teetotal ; // Are we touching any more drinks?
byte _malagauche ; // Position of Malagauche. See Celer for more info.
char _drinking ; // What's he getting you?
bool _enteredLustiesRoomAsMonk ;
byte _catacombX , _catacombY ; // XY coords in the catacombs.
bool _avvysInTheCupboard ; // On screen 22.
bool _geidaFollows ; // Is Geida following you?
bool _givenPotionToGeida ; // Does Geida have the potion?
bool _lustieIsAsleep ; // Is BDL asleep?
bool _beenTiedUp ; // In r__Robins.
bool _sittingInPub ; // Are you sitting down in the pub?
byte _spurgeTalkCount ; // Count for talking to Spurge.
bool _metAvaroid ;
bool _takenMushroom , _givenPenToAyles , _askedDogfoodAboutNim ;
// End of former DNA Structure
2013-09-29 20:19:12 +00:00
bool _showDebugLines ;
2013-09-26 23:34:38 +00:00
byte _lineNum ; // Number of lines.
LineType _lines [ 50 ] ; // For Also.
2013-10-01 04:50:27 +00:00
bool _dropsOk ;
bool _cheat ; // CHECKME: Currently unused
2013-09-26 23:34:38 +00:00
bool _letMeOut ;
2013-10-01 05:43:21 +00:00
byte _thinks ;
bool _thinkThing ;
2013-09-30 20:00:05 +00:00
bool _seeScroll ; // TODO: maybe this means we're interacting with the toolbar / a scroll?
2013-09-26 23:34:38 +00:00
char _objectList [ 10 ] ;
// Called .free() for them in ~Gyro().
2013-10-01 19:04:37 +00:00
2013-09-26 23:34:38 +00:00
byte _currentMouse ; // current mouse-void
Common : : String * _also [ 31 ] [ 2 ] ;
PedType _peds [ 15 ] ;
MagicType _magics [ 15 ] ;
MagicType _portals [ 7 ] ;
FieldType _fields [ 30 ] ;
byte _fieldNum ;
Common : : String _listen ;
2013-10-01 19:58:01 +00:00
byte _cp , _ledStatus ;
2013-09-26 23:34:38 +00:00
FontType _font ;
bool _alive ;
byte _subjectNum ; // The same thing.
People _him , _her ;
byte _it ;
2013-11-05 20:12:50 +00:00
uint32 _roomCycles ; // Set to 0 when you enter a room, added to in every loop. Cycles since you've been in this room.
2013-09-26 23:34:38 +00:00
bool _doingSpriteRun ; // Only set to True if we're doing a sprite_run at this moment. This stops the trippancy system from moving any of the sprites.
2013-10-01 04:50:27 +00:00
bool _soundFx ;
2013-09-26 23:34:38 +00:00
2013-11-05 20:50:41 +00:00
bool _isLoaded ; // Is it a loaded gamestate?
2013-11-05 20:57:50 +00:00
2013-09-26 23:34:38 +00:00
void callVerb ( VerbCode id ) ;
void loadRoom ( byte num ) ;
void thinkAbout ( byte object , bool type ) ; // Hey!!! Get it and put it!!!
void incScore ( byte num ) ; // Add on no. of points
void fxToggle ( ) ;
void refreshObjectList ( ) ;
void errorLed ( ) ;
2013-10-08 22:39:16 +00:00
void fadeOut ( ) ;
void fadeIn ( ) ;
2013-09-26 23:34:38 +00:00
void drawDirection ( ) ; // Draws the little icon at the left end of the text input field.
void gameOver ( ) ;
uint16 bearing ( byte whichPed ) ; // Returns the bearing from ped 'whichped' to Avvy, in degrees.
// There are two kinds of redraw: Major and Minor. Minor is what happens when you load a game, etc. Major redraws EVERYTHING.
void minorRedraw ( ) ;
void majorRedraw ( ) ;
void spriteRun ( ) ;
Common : : String intToStr ( int32 num ) ;
void newGame ( ) ; // This sets up the DNA for a completely new game.
2013-09-30 05:04:24 +00:00
bool getFlag ( char x ) ;
2013-09-26 23:34:38 +00:00
bool decreaseMoney ( uint16 amount ) ; // Called pennycheck in the original.
2013-11-22 20:31:39 +00:00
2013-09-26 23:34:38 +00:00
Common : : String getName ( People whose ) ;
Common : : String getItem ( byte which ) ; // Called get_better in the original.
Common : : String f5Does ( ) ; // This procedure determines what f5 does.
void openDoor ( Room whither , byte ped , byte magicnum ) ; // Handles slidey-open doors.
void flipRoom ( Room room , byte ped ) ;
void setRoom ( People persId , Room roomId ) ;
Room getRoom ( People persId ) ;
private :
2013-10-01 21:31:31 +00:00
static const int16 kMaxSprites = 2 ; // Current max no. of sprites.
2013-09-26 23:34:38 +00:00
static Room _whereIs [ 29 ] ;
2013-10-01 20:52:30 +00:00
// Will be used in dusk() and dawn().
bool _fxHidden ;
2013-10-08 22:39:16 +00:00
byte _fxPal [ 16 ] [ 16 ] [ 3 ] ;
2013-09-30 22:12:28 +00:00
bool _spludwickAtHome ; // Is Spludwick at home?
2013-10-01 20:52:30 +00:00
bool _passedCwytalotInHerts ; // Have you passed Cwytalot in Herts?
bool _holdTheDawn ; // If this is true, calling Dawn will do nothing. It's used, for example, at the start, to stop Load from dawning.
2013-09-30 22:12:28 +00:00
byte _lastRoom ;
byte _lastRoomNotMap ;
byte _roomCount [ 100 ] ; // Add one to each every time you enter a room
2013-10-01 04:50:27 +00:00
Common : : String _mouseText ;
2013-10-01 19:58:01 +00:00
Common : : String _flags ;
2013-10-01 20:52:30 +00:00
Common : : String _roomnName ; // Name of actual room
2013-10-01 19:04:37 +00:00
int8 _scoreToDisplay [ 3 ] ;
2013-09-30 22:12:28 +00:00
2013-10-04 15:40:24 +00:00
Common : : String readAlsoStringFromFile ( Common : : File & file ) ;
2013-10-01 20:52:30 +00:00
void runAvalot ( ) ;
void init ( ) ;
2013-10-25 21:37:41 +00:00
void initVariables ( ) ;
2013-10-01 20:52:30 +00:00
void setup ( ) ;
2013-09-26 23:34:38 +00:00
void scram ( Common : : String & str ) ;
void unScramble ( ) ;
2013-10-01 20:52:30 +00:00
void handleKeyDown ( Common : : Event & event ) ; // To replace Basher::keyboard_link() and Basher::typein().
2013-09-26 23:34:38 +00:00
void enterNewTown ( ) ;
void findPeople ( byte room ) ;
void putGeidaAt ( byte whichPed , byte ped ) ;
void guideAvvy ( Common : : Point cursorPos ) ;
2013-10-01 20:52:30 +00:00
void enterRoom ( Room room , byte ped ) ;
void exitRoom ( byte x ) ;
void drawToolbar ( ) ;
void drawScore ( ) ;
void useCompass ( const Common : : Point & cursorPos ) ; // Click on the compass on the toolbar to control Avvy's movement.
void checkClick ( ) ;
void fixFlashers ( ) ;
void loadAlso ( byte num ) ;
2014-01-03 07:10:40 +00:00
void resetAllVariables ( ) ;
2013-10-01 20:52:30 +00:00
void resetVariables ( ) ;
2013-06-18 15:52:25 +00:00
} ;
} // End of namespace Avalanche
2013-09-07 07:00:34 +00:00
# endif // AVALANCHE_AVALANCHE_H