2007-07-17 21:35:01 +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 .
*
*/
# include "common/events.h"
2007-07-28 19:43:26 +00:00
# include "common/keyboard.h"
2007-07-17 21:35:01 +00:00
# include "common/file.h"
# include "common/savefile.h"
# include "common/config-manager.h"
2011-04-24 11:34:27 +03:00
# include "common/textconsole.h"
2007-07-17 21:35:01 +00:00
2010-11-08 23:07:42 +00:00
# include "backends/audiocd/audiocd.h"
2007-07-17 21:35:01 +00:00
# include "base/plugins.h"
# include "base/version.h"
2010-05-04 11:58:12 +00:00
# include "engines/util.h"
2011-02-09 01:09:01 +00:00
# include "audio/mixer.h"
2007-07-17 21:35:01 +00:00
# include "drascula/drascula.h"
2010-06-15 10:18:34 +00:00
# include "drascula/console.h"
2007-07-17 21:35:01 +00:00
namespace Drascula {
struct GameSettings {
const char * gameid ;
const char * description ;
byte id ;
uint32 features ;
const char * detectname ;
} ;
2007-07-17 22:29:09 +00:00
static const GameSettings drasculaSettings [ ] = {
2007-07-17 21:35:01 +00:00
{ " drascula " , " Drascula game " , 0 , 0 , 0 } ,
{ NULL , NULL , 0 , 0 , NULL }
} ;
2007-11-03 21:06:58 +00:00
DrasculaEngine : : DrasculaEngine ( OSystem * syst , const DrasculaGameDescription * gameDesc ) : Engine ( syst ) , _gameDescription ( gameDesc ) {
2009-03-01 04:42:46 +00:00
_charMap = 0 ;
_itemLocations = 0 ;
_polX = 0 ;
_polY = 0 ;
_verbBarX = 0 ;
_x1d_menu = 0 ;
_y1d_menu = 0 ;
_frameX = 0 ;
_candleX = 0 ;
_candleY = 0 ;
_pianistX = 0 ;
_drunkX = 0 ;
_roomPreUpdates = 0 ;
_roomUpdates = 0 ;
_roomActions = 0 ;
_text = 0 ;
_textd = 0 ;
_textb = 0 ;
_textbj = 0 ;
_texte = 0 ;
_texti = 0 ;
_textl = 0 ;
_textp = 0 ;
_textt = 0 ;
_textvb = 0 ;
_textsys = 0 ;
_texthis = 0 ;
_textverbs = 0 ;
_textmisc = 0 ;
_textd1 = 0 ;
2010-05-24 16:58:42 +00:00
_talkSequences = 0 ;
2013-01-04 13:02:17 +02:00
_currentSaveSlot = 0 ;
2009-03-01 04:42:46 +00:00
2013-10-17 13:51:30 +03:00
bjX = 0 ;
bjY = 0 ;
trackBJ = 0 ;
framesWithoutAction = 0 ;
term_int = 0 ;
currentChapter = 0 ;
_loadedDifferentChapter = 0 ;
musicStopped = 0 ;
FrameSSN = 0 ;
globalSpeed = 0 ;
LastFrame = 0 ;
flag_tv = 0 ;
_charMapSize = 0 ;
_itemLocationsSize = 0 ;
_polXSize = 0 ;
_verbBarXSize = 0 ;
_x1dMenuSize = 0 ;
_frameXSize = 0 ;
_candleXSize = 0 ;
_pianistXSize = 0 ;
_drunkXSize = 0 ;
_roomPreUpdatesSize = 0 ;
_roomUpdatesSize = 0 ;
_roomActionsSize = 0 ;
_talkSequencesSize = 0 ;
_numLangs = 0 ;
2009-03-01 04:42:46 +00:00
_color = 0 ;
blinking = 0 ;
2013-08-19 03:08:11 +03:00
_mouseX = 0 ;
_mouseY = 0 ;
_leftMouseButton = 0 ;
_rightMouseButton = 0 ;
2009-03-01 04:42:46 +00:00
* textName = 0 ;
2007-07-17 21:35:01 +00:00
2011-05-16 16:35:10 +02:00
_rnd = new Common : : RandomSource ( " drascula " ) ;
2007-08-01 20:11:32 +00:00
2011-01-27 07:58:57 +00:00
_console = 0 ;
2007-08-01 20:11:32 +00:00
int cd_num = ConfMan . getInt ( " cdrom " ) ;
if ( cd_num > = 0 )
2010-06-15 04:13:12 +00:00
_system - > getAudioCDManager ( ) - > openCD ( cd_num ) ;
2008-05-02 15:09:20 +00:00
2008-09-16 08:12:13 +00:00
_lang = kEnglish ;
2008-12-03 17:35:37 +00:00
_keyBufferHead = _keyBufferTail = 0 ;
2010-03-09 23:35:30 +00:00
_roomHandlers = 0 ;
2007-07-17 21:35:01 +00:00
}
DrasculaEngine : : ~ DrasculaEngine ( ) {
delete _rnd ;
2009-08-18 15:31:26 +00:00
stopSound ( ) ;
2008-06-07 20:47:52 +00:00
2010-03-09 23:35:30 +00:00
freeRoomsTable ( ) ;
2010-06-15 10:21:59 +00:00
delete _console ;
2008-06-07 20:47:52 +00:00
free ( _charMap ) ;
2008-06-09 14:36:58 +00:00
free ( _itemLocations ) ;
free ( _polX ) ;
free ( _polY ) ;
free ( _verbBarX ) ;
free ( _x1d_menu ) ;
free ( _y1d_menu ) ;
free ( _frameX ) ;
free ( _candleX ) ;
free ( _candleY ) ;
free ( _pianistX ) ;
free ( _drunkX ) ;
free ( _roomPreUpdates ) ;
free ( _roomUpdates ) ;
free ( _roomActions ) ;
2008-09-09 15:59:06 +00:00
free ( _talkSequences ) ;
2008-06-08 21:59:12 +00:00
freeTexts ( _text ) ;
freeTexts ( _textd ) ;
freeTexts ( _textb ) ;
freeTexts ( _textbj ) ;
freeTexts ( _texte ) ;
freeTexts ( _texti ) ;
freeTexts ( _textl ) ;
freeTexts ( _textp ) ;
freeTexts ( _textt ) ;
freeTexts ( _textvb ) ;
freeTexts ( _textsys ) ;
freeTexts ( _texthis ) ;
freeTexts ( _textverbs ) ;
freeTexts ( _textmisc ) ;
freeTexts ( _textd1 ) ;
2007-07-17 21:35:01 +00:00
}
2011-01-28 08:07:50 +00:00
bool DrasculaEngine : : hasFeature ( EngineFeature f ) const {
return
( f = = kSupportsRTL ) ;
}
2009-03-01 04:42:46 +00:00
Common : : Error DrasculaEngine : : run ( ) {
2007-07-17 21:35:01 +00:00
// Initialize backend
2008-11-14 22:08:10 +00:00
initGraphics ( 320 , 200 , false ) ;
2007-07-17 21:35:01 +00:00
2008-05-24 21:23:06 +00:00
switch ( getLanguage ( ) ) {
case Common : : EN_ANY :
2008-09-16 08:12:13 +00:00
_lang = kEnglish ;
2008-05-24 21:23:06 +00:00
break ;
case Common : : ES_ESP :
2008-09-16 08:12:13 +00:00
_lang = kSpanish ;
2008-05-24 21:23:06 +00:00
break ;
case Common : : DE_DEU :
2008-09-16 08:12:13 +00:00
_lang = kGerman ;
2008-05-24 21:23:06 +00:00
break ;
case Common : : FR_FRA :
2008-09-16 08:12:13 +00:00
_lang = kFrench ;
2008-05-24 21:23:06 +00:00
break ;
case Common : : IT_ITA :
2008-09-16 08:12:13 +00:00
_lang = kItalian ;
2008-05-24 21:23:06 +00:00
break ;
default :
warning ( " Unknown game language. Falling back to English " ) ;
2008-09-16 08:12:13 +00:00
_lang = kEnglish ;
2008-05-24 21:23:06 +00:00
}
2010-06-15 10:18:34 +00:00
_console = new Console ( this ) ;
2008-06-07 20:47:52 +00:00
if ( ! loadDrasculaDat ( ) )
2008-11-06 17:05:54 +00:00
return Common : : kUnknownError ;
2008-06-07 20:47:52 +00:00
2013-01-04 13:02:17 +02:00
checkForOldSaveGames ( ) ;
2008-06-05 13:23:57 +00:00
setupRoomsTable ( ) ;
2008-06-02 06:51:59 +00:00
loadArchives ( ) ;
2008-06-01 11:44:45 +00:00
2009-03-01 04:42:46 +00:00
// Setup mixer
2011-03-19 14:56:20 +01:00
syncSoundSettings ( ) ;
2007-07-17 21:35:01 +00:00
2008-05-31 09:16:26 +00:00
currentChapter = 1 ; // values from 1 to 6 will start each part of game
2013-08-19 03:08:11 +03:00
_loadedDifferentChapter = false ;
2013-01-04 13:02:17 +02:00
setTotalPlayTime ( 0 ) ;
// Check if a save is loaded from the launcher
int directSaveSlotLoading = ConfMan . getInt ( " save_slot " ) ;
if ( directSaveSlotLoading > = 0 ) {
loadGame ( directSaveSlotLoading ) ;
}
2007-07-26 19:52:18 +00:00
2008-08-19 10:12:35 +00:00
checkCD ( ) ;
2011-01-28 08:07:50 +00:00
while ( ! shouldQuit ( ) ) {
2008-05-11 08:36:53 +00:00
int i ;
2008-05-29 22:34:03 +00:00
takeObject = 0 ;
2009-05-13 11:59:49 +00:00
_menuBar = false ;
_menuScreen = false ;
_hasName = false ;
2007-08-02 07:09:28 +00:00
frame_y = 0 ;
2009-05-13 11:59:49 +00:00
curX = - 1 ;
characterMoved = 0 ;
trackProtagonist = 3 ;
2013-08-19 03:08:11 +03:00
_characterFrame = 0 ;
2009-05-13 11:59:49 +00:00
hare_se_ve = 1 ;
2008-05-29 22:34:03 +00:00
checkFlags = 1 ;
2008-05-30 07:19:09 +00:00
doBreak = 0 ;
2008-05-29 22:34:03 +00:00
walkToObject = 0 ;
2009-05-13 11:59:49 +00:00
stepX = STEP_X ;
stepY = STEP_Y ;
curHeight = CHARACTER_HEIGHT ;
curWidth = CHARACTER_WIDTH ;
feetHeight = FEET_HEIGHT ;
2008-05-29 22:34:03 +00:00
hasAnswer = 0 ;
2008-06-04 07:58:34 +00:00
savedTime = 0 ;
2008-05-31 00:15:01 +00:00
breakOut = 0 ;
2009-05-13 11:59:49 +00:00
vonBraunX = 120 ;
trackVonBraun = 1 ;
vonBraunHasMoved = 0 ;
2008-06-06 14:50:19 +00:00
framesWithoutAction = 0 ;
2007-08-02 07:09:28 +00:00
term_int = 0 ;
2008-05-29 22:34:03 +00:00
musicStopped = 0 ;
globalSpeed = 0 ;
2008-06-04 10:48:18 +00:00
curExcuseLook = 0 ;
curExcuseAction = 0 ;
2013-08-19 03:08:11 +03:00
_roomNumber = 0 ;
2007-08-02 07:09:28 +00:00
2008-06-06 14:50:19 +00:00
for ( i = 0 ; i < 8 ; i + + )
actorFrames [ i ] = 0 ;
actorFrames [ kFrameVonBraun ] = 1 ;
2008-05-11 09:46:50 +00:00
allocMemory ( ) ;
2008-02-29 00:04:43 +00:00
2008-09-28 22:07:16 +00:00
_subtitlesDisabled = ! ConfMan . getBool ( " subtitles " ) ;
2007-08-02 07:09:28 +00:00
2008-08-26 07:48:19 +00:00
if ( currentChapter ! = 3 )
2008-06-04 10:27:10 +00:00
loadPic ( 96 , frontSurface , COMPLETE_PAL ) ;
2008-08-26 07:48:19 +00:00
2010-06-15 10:21:42 +00:00
loadPic ( 99 , cursorSurface ) ;
2008-08-26 07:48:19 +00:00
if ( currentChapter = = 1 ) {
2008-05-31 09:16:26 +00:00
} else if ( currentChapter = = 2 ) {
2008-06-04 10:27:10 +00:00
loadPic ( " pts.alg " , drawSurface2 ) ;
2008-05-31 09:16:26 +00:00
} else if ( currentChapter = = 3 ) {
2008-06-10 18:54:32 +00:00
loadPic ( " aux13.alg " , bgSurface , COMPLETE_PAL ) ;
2008-06-04 10:27:10 +00:00
loadPic ( 96 , frontSurface ) ;
2008-05-31 09:16:26 +00:00
} else if ( currentChapter = = 4 ) {
2013-08-19 03:08:11 +03:00
if ( ! _loadedDifferentChapter )
2013-01-04 19:30:36 +02:00
animation_castle ( ) ;
2008-06-04 10:27:10 +00:00
loadPic ( 96 , frontSurface ) ;
2008-05-02 11:44:47 +00:00
clearRoom ( ) ;
2008-05-31 09:16:26 +00:00
} else if ( currentChapter = = 5 ) {
} else if ( currentChapter = = 6 ) {
2010-03-09 23:35:56 +00:00
igorX = 105 ;
igorY = 85 ;
trackIgor = 1 ;
drasculaX = 62 ;
drasculaY = 99 ;
trackDrascula = 1 ;
2008-06-06 14:50:19 +00:00
actorFrames [ kFramePendulum ] = 0 ;
2007-09-05 20:45:47 +00:00
flag_tv = 0 ;
2008-08-26 07:48:19 +00:00
}
2008-09-11 09:31:45 +00:00
loadPic ( 95 , tableSurface ) ;
for ( i = 0 ; i < 25 ; i + + )
memcpy ( crosshairCursor + i * 40 , tableSurface + 225 + ( 56 + i ) * 320 , 40 ) ;
if ( _lang = = kSpanish )
loadPic ( 974 , tableSurface ) ;
2008-08-26 07:48:19 +00:00
if ( currentChapter ! = 2 ) {
2010-06-15 10:22:19 +00:00
loadPic ( 99 , cursorSurface ) ;
2008-06-04 10:27:10 +00:00
loadPic ( 99 , backSurface ) ;
loadPic ( 97 , extraSurface ) ;
2008-01-28 00:14:17 +00:00
}
2008-08-26 07:48:19 +00:00
2008-05-11 11:20:40 +00:00
memset ( iconName , 0 , sizeof ( iconName ) ) ;
2008-05-11 08:36:53 +00:00
for ( i = 0 ; i < 6 ; i + + )
2013-10-17 13:40:17 +03:00
strlcpy ( iconName [ i + 1 ] , _textverbs [ i ] , 13 ) ;
2007-07-26 19:52:18 +00:00
2008-09-10 12:03:42 +00:00
assignPalette ( defaultPalette ) ;
2013-01-04 13:02:17 +02:00
2008-06-05 15:15:20 +00:00
if ( ! runCurrentChapter ( ) ) {
2008-06-08 16:42:12 +00:00
endChapter ( ) ;
2007-08-02 07:09:28 +00:00
break ;
}
2008-06-08 16:42:12 +00:00
endChapter ( ) ;
2008-05-31 09:16:26 +00:00
if ( currentChapter = = 6 )
2007-10-07 22:00:43 +00:00
break ;
2008-03-09 08:30:24 +00:00
2008-05-31 09:16:26 +00:00
currentChapter + + ;
2007-08-02 07:09:28 +00:00
}
2007-09-10 16:03:12 +00:00
2008-11-06 17:05:54 +00:00
return Common : : kNoError ;
2007-07-26 19:52:18 +00:00
}
2008-06-08 16:42:12 +00:00
void DrasculaEngine : : endChapter ( ) {
2008-06-05 08:25:29 +00:00
stopSound ( ) ;
2008-05-02 11:44:47 +00:00
clearRoom ( ) ;
2008-05-11 12:47:26 +00:00
black ( ) ;
2007-07-26 19:52:18 +00:00
MusicFadeout ( ) ;
2008-05-11 10:03:06 +00:00
stopMusic ( ) ;
2008-05-11 09:51:30 +00:00
freeMemory ( ) ;
2007-07-26 19:52:18 +00:00
}
2008-06-05 15:15:20 +00:00
bool DrasculaEngine : : runCurrentChapter ( ) {
2007-09-10 16:03:12 +00:00
int n ;
2007-07-26 19:52:18 +00:00
2013-08-19 03:08:11 +03:00
_rightMouseButton = 0 ;
2008-08-10 17:15:30 +00:00
2008-05-11 12:47:26 +00:00
previousMusic = - 1 ;
2007-07-26 19:52:18 +00:00
2008-05-31 09:16:26 +00:00
if ( currentChapter ! = 2 ) {
2007-09-10 16:03:12 +00:00
int soc = 0 ;
for ( n = 0 ; n < 6 ; n + + ) {
2008-05-11 10:53:59 +00:00
soc = soc + CHARACTER_WIDTH ;
2008-06-09 10:11:42 +00:00
_frameX [ n ] = soc ;
2007-09-10 16:03:12 +00:00
}
2007-07-26 19:52:18 +00:00
}
2010-03-09 23:35:56 +00:00
for ( n = 1 ; n < ARRAYSIZE ( inventoryObjects ) ; n + + )
2008-05-27 12:22:34 +00:00
inventoryObjects [ n ] = 0 ;
2007-07-26 19:52:18 +00:00
2008-05-11 10:28:25 +00:00
for ( n = 0 ; n < NUM_FLAGS ; n + + )
2007-07-26 19:52:18 +00:00
flags [ n ] = 0 ;
2007-07-28 09:45:05 +00:00
2008-05-31 09:16:26 +00:00
if ( currentChapter = = 2 ) {
2007-08-02 20:59:03 +00:00
flags [ 16 ] = 1 ;
flags [ 17 ] = 1 ;
flags [ 27 ] = 1 ;
}
2007-07-26 19:52:18 +00:00
for ( n = 1 ; n < 7 ; n + + )
2008-05-27 12:22:34 +00:00
inventoryObjects [ n ] = n ;
2007-07-26 19:52:18 +00:00
2008-05-31 09:16:26 +00:00
if ( currentChapter = = 1 ) {
2008-05-11 11:20:40 +00:00
pickObject ( 28 ) ;
2007-07-26 19:52:18 +00:00
2013-08-19 03:08:11 +03:00
if ( ! _loadedDifferentChapter )
2008-05-02 11:02:28 +00:00
animation_1_1 ( ) ;
2007-07-26 19:52:18 +00:00
2009-05-12 10:02:18 +00:00
selectVerb ( kVerbNone ) ;
2008-06-04 10:27:10 +00:00
loadPic ( " 2aux62.alg " , drawSurface2 ) ;
2008-06-03 08:54:49 +00:00
trackProtagonist = 1 ;
2008-05-29 22:34:03 +00:00
objExit = 104 ;
2013-08-19 03:08:11 +03:00
if ( _loadedDifferentChapter ) {
2013-01-04 13:02:17 +02:00
if ( ! loadGame ( _currentSaveSlot ) ) {
2008-02-29 00:04:43 +00:00
return true ;
}
} else {
2008-06-04 09:08:37 +00:00
enterRoom ( 62 ) ;
2008-06-02 23:09:19 +00:00
curX = - 20 ;
curY = 56 ;
2008-06-03 08:54:49 +00:00
gotoObject ( 65 , 145 ) ;
2007-08-02 20:59:03 +00:00
}
2013-01-04 19:30:36 +02:00
// REMINDER: This is a good place to debug animations
2008-05-31 09:16:26 +00:00
} else if ( currentChapter = = 2 ) {
2008-06-05 15:03:48 +00:00
addObject ( kItemPhone ) ;
2008-06-03 08:54:49 +00:00
trackProtagonist = 3 ;
2008-05-29 22:34:03 +00:00
objExit = 162 ;
2013-08-19 03:08:11 +03:00
if ( ! _loadedDifferentChapter )
2008-06-04 09:08:37 +00:00
enterRoom ( 14 ) ;
2008-02-29 00:04:43 +00:00
else {
2013-01-04 13:02:17 +02:00
if ( ! loadGame ( _currentSaveSlot ) ) {
2008-02-29 00:04:43 +00:00
return true ;
}
}
2008-05-31 09:16:26 +00:00
} else if ( currentChapter = = 3 ) {
2008-06-05 15:03:48 +00:00
addObject ( kItemPhone ) ;
addObject ( kItemEarplugs ) ;
addObject ( kItemSickle ) ;
addObject ( kItemHandbag ) ;
addObject ( kItemCross ) ;
addObject ( kItemReefer ) ;
addObject ( kItemOneCoin ) ;
2007-08-17 11:19:17 +00:00
flags [ 1 ] = 1 ;
2008-06-03 08:54:49 +00:00
trackProtagonist = 1 ;
2008-05-29 22:34:03 +00:00
objExit = 99 ;
2013-08-19 03:08:11 +03:00
if ( ! _loadedDifferentChapter )
2008-06-04 09:08:37 +00:00
enterRoom ( 20 ) ;
2008-02-29 00:04:43 +00:00
else {
2013-01-04 13:02:17 +02:00
if ( ! loadGame ( _currentSaveSlot ) ) {
2008-02-29 00:04:43 +00:00
return true ;
}
}
2008-06-05 15:03:48 +00:00
// From here onwards the items have different IDs
2008-05-31 09:16:26 +00:00
} else if ( currentChapter = = 4 ) {
2008-06-05 15:03:48 +00:00
addObject ( kItemPhone2 ) ;
addObject ( kItemCross2 ) ;
addObject ( kItemReefer2 ) ;
addObject ( kItemOneCoin2 ) ;
2008-05-29 22:34:03 +00:00
objExit = 100 ;
2013-08-19 03:08:11 +03:00
if ( ! _loadedDifferentChapter ) {
2008-06-04 09:08:37 +00:00
enterRoom ( 21 ) ;
2008-06-03 08:54:49 +00:00
trackProtagonist = 0 ;
2008-06-02 23:09:19 +00:00
curX = 235 ;
curY = 164 ;
2008-02-29 00:04:43 +00:00
} else {
2013-01-04 13:02:17 +02:00
if ( ! loadGame ( _currentSaveSlot ) ) {
2008-02-29 00:04:43 +00:00
return true ;
}
}
2008-05-31 09:16:26 +00:00
} else if ( currentChapter = = 5 ) {
2008-05-29 22:34:03 +00:00
addObject ( 28 ) ;
addObject ( 7 ) ;
addObject ( 9 ) ;
addObject ( 11 ) ;
addObject ( 13 ) ;
addObject ( 14 ) ;
addObject ( 15 ) ;
addObject ( 17 ) ;
addObject ( 20 ) ;
2008-06-03 08:54:49 +00:00
trackProtagonist = 1 ;
2008-05-29 22:34:03 +00:00
objExit = 100 ;
2013-08-19 03:08:11 +03:00
if ( ! _loadedDifferentChapter ) {
2008-06-04 09:08:37 +00:00
enterRoom ( 45 ) ;
2008-02-29 00:04:43 +00:00
} else {
2013-01-04 13:02:17 +02:00
if ( ! loadGame ( _currentSaveSlot ) ) {
2008-02-29 00:04:43 +00:00
return true ;
}
}
2008-05-31 09:16:26 +00:00
} else if ( currentChapter = = 6 ) {
2008-05-29 22:34:03 +00:00
addObject ( 28 ) ;
addObject ( 9 ) ;
2007-09-05 20:45:47 +00:00
2008-06-03 08:54:49 +00:00
trackProtagonist = 1 ;
2008-05-29 22:34:03 +00:00
objExit = 104 ;
2013-08-19 03:08:11 +03:00
if ( ! _loadedDifferentChapter ) {
2008-06-04 09:08:37 +00:00
enterRoom ( 58 ) ;
2008-05-02 11:02:28 +00:00
animation_1_6 ( ) ;
2008-03-08 19:47:44 +00:00
} else {
2013-01-04 13:02:17 +02:00
if ( ! loadGame ( _currentSaveSlot ) ) {
2008-02-29 00:04:43 +00:00
return true ;
}
2008-06-04 10:27:10 +00:00
loadPic ( " auxdr.alg " , drawSurface2 ) ;
2007-09-05 20:45:47 +00:00
}
2007-07-26 19:52:18 +00:00
}
2008-09-11 09:31:45 +00:00
showCursor ( ) ;
2011-01-28 08:07:50 +00:00
while ( ! shouldQuit ( ) ) {
2008-05-31 08:26:06 +00:00
if ( characterMoved = = 0 ) {
2008-06-02 20:46:00 +00:00
stepX = STEP_X ;
stepY = STEP_Y ;
2008-05-31 08:26:06 +00:00
}
if ( characterMoved = = 0 & & walkToObject = = 1 ) {
2008-06-03 08:54:49 +00:00
trackProtagonist = trackFinal ;
2008-05-31 08:26:06 +00:00
walkToObject = 0 ;
}
2008-03-09 11:13:20 +00:00
2008-05-31 09:16:26 +00:00
if ( currentChapter = = 2 ) {
2008-06-10 20:19:44 +00:00
// NOTE: the checks for room number 14 below are a hack used in the original
// game, and move the character to a place where his feet are not drawn above
// the pianist's head. Originally, walkToObject was not updated properly, which
// lead to an incorrect setting of the protagonist's tracking flag (above). This
// made the character start walking off screen, as his actual position was
// different than the displayed one
2013-08-19 03:08:11 +03:00
if ( _roomNumber = = 3 & & ( curX = = 279 ) & & ( curY + curHeight = = 101 ) ) {
2008-09-09 15:59:06 +00:00
gotoObject ( 178 , 121 ) ;
gotoObject ( 169 , 135 ) ;
2013-08-19 03:08:11 +03:00
} else if ( _roomNumber = = 14 & & ( curX = = 214 ) & & ( curY + curHeight = = 121 ) ) {
2008-06-10 20:19:44 +00:00
walkToObject = 1 ;
2008-06-03 08:54:49 +00:00
gotoObject ( 190 , 130 ) ;
2013-08-19 03:08:11 +03:00
} else if ( _roomNumber = = 14 & & ( curX = = 246 ) & & ( curY + curHeight = = 112 ) ) {
2008-06-10 20:19:44 +00:00
walkToObject = 1 ;
2008-06-03 08:54:49 +00:00
gotoObject ( 190 , 130 ) ;
2008-06-10 20:19:44 +00:00
}
2008-05-31 08:26:06 +00:00
}
2007-07-26 19:52:18 +00:00
2008-05-31 08:26:06 +00:00
moveCursor ( ) ;
2008-05-31 12:40:02 +00:00
updateScreen ( ) ;
2007-07-26 19:52:18 +00:00
2008-05-31 09:16:26 +00:00
if ( currentChapter = = 2 ) {
2008-05-31 08:26:06 +00:00
if ( musicStatus ( ) = = 0 & & roomMusic ! = 0 )
playMusic ( roomMusic ) ;
} else {
if ( musicStatus ( ) = = 0 )
playMusic ( roomMusic ) ;
}
2007-07-26 19:52:18 +00:00
2008-08-03 12:02:09 +00:00
delay ( 25 ) ;
2008-08-10 17:15:30 +00:00
# ifndef _WIN32_WCE
// FIXME
// This and the following #ifndefs disable the excess updateEvents() calls *within* the game loop.
// Events such as keypresses or mouse clicks are dropped on the ground with no processing
// by these calls. They are properly handled by the implicit call through getScan() below.
// It is not a good practice to not process events and indeed this created problems with synthesized
// events in the wince port.
2008-05-29 14:14:31 +00:00
updateEvents ( ) ;
2008-08-10 17:15:30 +00:00
# endif
2007-07-28 09:45:05 +00:00
2009-05-13 11:59:49 +00:00
if ( ! _menuScreen & & takeObject = = 1 )
2008-05-31 08:26:06 +00:00
checkObjects ( ) ;
2009-01-01 15:06:43 +00:00
2008-08-10 17:15:30 +00:00
# ifdef _WIN32_WCE
2013-08-19 03:08:11 +03:00
if ( _rightMouseButton ) {
2009-05-13 11:59:49 +00:00
if ( _menuScreen ) {
2008-08-10 17:15:30 +00:00
# else
2013-08-19 03:08:11 +03:00
if ( _rightMouseButton = = 1 & & _menuScreen ) {
2008-08-10 17:15:30 +00:00
# endif
2013-08-19 03:08:11 +03:00
_rightMouseButton = 0 ;
2008-08-19 10:05:07 +00:00
delay ( 100 ) ;
2010-06-15 10:22:19 +00:00
if ( currentChapter = = 2 ) {
loadPic ( menuBackground , cursorSurface ) ;
2008-06-04 10:27:10 +00:00
loadPic ( menuBackground , backSurface ) ;
2010-06-15 10:22:19 +00:00
} else {
loadPic ( 99 , cursorSurface ) ;
2008-06-04 10:27:10 +00:00
loadPic ( 99 , backSurface ) ;
2010-06-15 10:22:19 +00:00
}
2008-05-31 08:26:06 +00:00
setPalette ( ( byte * ) & gamePalette ) ;
2009-05-13 11:59:49 +00:00
_menuScreen = false ;
2008-08-10 17:15:30 +00:00
# ifndef _WIN32_WCE
// FIXME: This call here is in hope that it will catch the rightmouseup event so the
// next if block won't be executed. This too is not a good coding practice. I've recoded it
// with a mutual exclusive if block for the menu. I would commit this properly but I cannot test
// for other (see Desktop) ports right now.
2008-05-31 08:26:06 +00:00
updateEvents ( ) ;
2008-08-10 17:15:30 +00:00
# endif
# ifdef _WIN32_WCE
} else {
# else
2008-05-31 08:26:06 +00:00
}
2008-08-25 15:58:45 +00:00
// Do not show the inventory screen in chapter 5, if the right mouse button is clicked
// while the plug (object 16) is held
// Fixes bug #2059621 - "DRASCULA: Plug bug"
2013-08-19 03:08:11 +03:00
if ( _rightMouseButton = = 1 & & ! _menuScreen & &
2008-08-25 15:58:45 +00:00
! ( currentChapter = = 5 & & pickedObject = = 16 ) ) {
2008-08-10 17:15:30 +00:00
# endif
2013-08-19 03:08:11 +03:00
_rightMouseButton = 0 ;
2008-08-24 21:28:20 +00:00
delay ( 100 ) ;
2008-05-31 08:26:06 +00:00
characterMoved = 0 ;
2008-06-03 08:54:49 +00:00
if ( trackProtagonist = = 2 )
trackProtagonist = 1 ;
2010-06-15 10:22:19 +00:00
if ( currentChapter = = 4 ) {
2008-06-04 10:27:10 +00:00
loadPic ( " icons2.alg " , backSurface ) ;
2010-06-15 10:22:19 +00:00
loadPic ( " icons2.alg " , cursorSurface ) ;
} else if ( currentChapter = = 5 ) {
2008-06-04 10:27:10 +00:00
loadPic ( " icons3.alg " , backSurface ) ;
2010-06-15 10:22:19 +00:00
loadPic ( " icons3.alg " , cursorSurface ) ;
} else if ( currentChapter = = 6 ) {
2008-06-04 10:27:10 +00:00
loadPic ( " iconsp.alg " , backSurface ) ;
2010-06-15 10:22:19 +00:00
loadPic ( " iconsp.alg " , cursorSurface ) ;
} else {
2008-06-04 10:27:10 +00:00
loadPic ( " icons.alg " , backSurface ) ;
2010-06-15 10:22:19 +00:00
loadPic ( " icons.alg " , cursorSurface ) ;
}
2009-05-13 11:59:49 +00:00
_menuScreen = true ;
2008-08-10 17:15:30 +00:00
# ifndef _WIN32_WCE
2008-05-31 08:26:06 +00:00
updateEvents ( ) ;
2008-08-10 17:15:30 +00:00
# endif
2009-05-12 10:02:18 +00:00
selectVerb ( kVerbNone ) ;
2008-05-31 08:26:06 +00:00
}
2011-03-08 20:11:13 +01:00
# ifdef _WIN32_WCE
}
# endif
2007-07-26 19:52:18 +00:00
2013-08-19 03:08:11 +03:00
if ( _leftMouseButton = = 1 & & _menuBar ) {
2008-08-24 21:28:20 +00:00
delay ( 100 ) ;
2008-06-02 22:41:58 +00:00
selectVerbFromBar ( ) ;
2013-08-19 03:08:11 +03:00
} else if ( _leftMouseButton = = 1 & & takeObject = = 0 ) {
2008-08-19 10:05:07 +00:00
delay ( 100 ) ;
2008-06-02 22:41:58 +00:00
if ( verify1 ( ) )
2008-05-31 08:26:06 +00:00
return true ;
2013-08-19 03:08:11 +03:00
} else if ( _leftMouseButton = = 1 & & takeObject = = 1 ) {
2008-06-02 22:41:58 +00:00
if ( verify2 ( ) )
2008-05-31 08:26:06 +00:00
return true ;
}
2013-08-19 03:08:11 +03:00
_menuBar = ( _mouseY < 24 & & ! _menuScreen ) ? true : false ;
2008-05-31 08:26:06 +00:00
Common : : KeyCode key = getScan ( ) ;
2009-05-13 11:59:49 +00:00
if ( key = = Common : : KEYCODE_F1 & & ! _menuScreen ) {
2009-05-12 10:02:18 +00:00
selectVerb ( kVerbLook ) ;
2009-05-13 11:59:49 +00:00
} else if ( key = = Common : : KEYCODE_F2 & & ! _menuScreen ) {
2009-05-12 10:02:18 +00:00
selectVerb ( kVerbPick ) ;
2009-05-13 11:59:49 +00:00
} else if ( key = = Common : : KEYCODE_F3 & & ! _menuScreen ) {
2009-05-12 10:02:18 +00:00
selectVerb ( kVerbOpen ) ;
2009-05-13 11:59:49 +00:00
} else if ( key = = Common : : KEYCODE_F4 & & ! _menuScreen ) {
2009-05-12 10:02:18 +00:00
selectVerb ( kVerbClose ) ;
2009-05-13 11:59:49 +00:00
} else if ( key = = Common : : KEYCODE_F5 & & ! _menuScreen ) {
2009-05-12 10:02:18 +00:00
selectVerb ( kVerbTalk ) ;
2009-05-13 11:59:49 +00:00
} else if ( key = = Common : : KEYCODE_F6 & & ! _menuScreen ) {
2009-05-12 10:02:18 +00:00
selectVerb ( kVerbMove ) ;
2013-01-04 13:02:17 +02:00
} else if ( key = = Common : : KEYCODE_F7 ) {
// ScummVM load screen
if ( ! scummVMSaveLoadDialog ( false ) )
2008-05-31 08:26:06 +00:00
return true ;
} else if ( key = = Common : : KEYCODE_F8 ) {
2009-05-12 10:02:18 +00:00
selectVerb ( kVerbNone ) ;
2013-01-04 13:02:17 +02:00
} else if ( key = = Common : : KEYCODE_F9 ) {
volumeControls ( ) ;
} else if ( key = = Common : : KEYCODE_F10 ) {
if ( ! ConfMan . getBool ( " originalsaveload " ) ) {
// ScummVM save screen
scummVMSaveLoadDialog ( true ) ;
} else {
// Original save/load screen
if ( ! saveLoadScreen ( ) )
return true ;
}
2008-05-31 08:26:06 +00:00
} else if ( key = = Common : : KEYCODE_v ) {
2008-09-28 22:07:16 +00:00
_subtitlesDisabled = true ;
ConfMan . setBool ( " subtitles " , ! _subtitlesDisabled ) ;
2008-09-10 08:25:12 +00:00
print_abc ( _textsys [ 2 ] , 96 , 86 ) ;
2008-05-31 12:40:02 +00:00
updateScreen ( ) ;
2008-05-31 08:26:06 +00:00
delay ( 1410 ) ;
} else if ( key = = Common : : KEYCODE_t ) {
2008-09-28 22:07:16 +00:00
_subtitlesDisabled = false ;
ConfMan . setBool ( " subtitles " , ! _subtitlesDisabled ) ;
2008-09-10 08:25:12 +00:00
print_abc ( _textsys [ 3 ] , 94 , 86 ) ;
2008-05-31 12:40:02 +00:00
updateScreen ( ) ;
2008-05-31 08:26:06 +00:00
delay ( 1460 ) ;
} else if ( key = = Common : : KEYCODE_ESCAPE ) {
if ( ! confirmExit ( ) )
return false ;
2010-06-15 10:18:34 +00:00
} else if ( key = = Common : : KEYCODE_TILDE | | key = = Common : : KEYCODE_BACKQUOTE ) {
_console - > attach ( ) ;
_console - > onFrame ( ) ;
2013-08-19 03:08:11 +03:00
} else if ( currentChapter = = 6 & & key = = Common : : KEYCODE_0 & & _roomNumber = = 61 ) {
2008-06-10 18:54:32 +00:00
loadPic ( " alcbar.alg " , bgSurface , 255 ) ;
2008-06-06 14:50:19 +00:00
}
2009-01-01 15:06:43 +00:00
2013-08-19 03:08:11 +03:00
if ( _leftMouseButton ! = 0 | | _rightMouseButton ! = 0 | | key ! = 0 )
2013-01-04 19:30:36 +02:00
framesWithoutAction = 0 ;
2008-06-06 14:50:19 +00:00
if ( framesWithoutAction = = 15000 ) {
screenSaver ( ) ;
2013-01-04 19:30:36 +02:00
framesWithoutAction = 0 ;
2008-05-31 08:26:06 +00:00
}
2008-06-06 14:50:19 +00:00
2013-01-04 19:30:36 +02:00
framesWithoutAction + + ;
2007-09-10 16:03:12 +00:00
}
2011-01-28 08:07:50 +00:00
return false ;
2007-07-26 19:52:18 +00:00
}
2008-05-31 09:38:12 +00:00
2008-06-02 22:41:58 +00:00
bool DrasculaEngine : : verify1 ( ) {
2007-07-26 19:52:18 +00:00
int l ;
2009-05-13 11:59:49 +00:00
if ( _menuScreen )
2008-05-29 14:04:47 +00:00
removeObject ( ) ;
2007-07-26 19:52:18 +00:00
else {
2008-05-11 20:05:09 +00:00
for ( l = 0 ; l < numRoomObjs ; l + + ) {
2013-08-19 03:08:11 +03:00
if ( _mouseX > = _objectX1 [ l ] & & _mouseY > = _objectY1 [ l ]
& & _mouseX < = _objectX2 [ l ] & & _mouseY < = _objectY2 [ l ] & & doBreak = = 0 ) {
2008-05-29 22:34:03 +00:00
if ( exitRoom ( l ) )
2007-08-02 07:09:28 +00:00
return true ;
2008-05-30 07:19:09 +00:00
if ( doBreak = = 1 )
2007-07-26 19:52:18 +00:00
break ;
}
}
2013-08-19 03:08:11 +03:00
if ( _mouseX > curX & & _mouseY > curY
& & _mouseX < curX + curWidth & & _mouseY < curY + curHeight )
2008-05-30 07:19:09 +00:00
doBreak = 1 ;
2007-07-26 19:52:18 +00:00
2008-05-11 20:05:09 +00:00
for ( l = 0 ; l < numRoomObjs ; l + + ) {
2013-08-19 03:08:11 +03:00
if ( _mouseX > _objectX1 [ l ] & & _mouseY > _objectY1 [ l ]
& & _mouseX < _objectX2 [ l ] & & _mouseY < _objectY2 [ l ] & & doBreak = = 0 ) {
2008-06-03 08:54:49 +00:00
roomX = roomObjX [ l ] ;
roomY = roomObjY [ l ] ;
trackFinal = trackObj [ l ] ;
2008-05-30 07:19:09 +00:00
doBreak = 1 ;
2008-05-29 22:34:03 +00:00
walkToObject = 1 ;
startWalking ( ) ;
2007-07-26 19:52:18 +00:00
}
}
2008-05-30 07:19:09 +00:00
if ( doBreak = = 0 ) {
2013-08-19 03:08:11 +03:00
roomX = CLIP ( _mouseX , floorX1 , floorX2 ) ;
roomY = CLIP ( _mouseY , floorY1 + feetHeight , floorY2 ) ;
2008-05-29 22:34:03 +00:00
startWalking ( ) ;
2007-07-26 19:52:18 +00:00
}
2008-05-30 07:19:09 +00:00
doBreak = 0 ;
2007-07-26 19:52:18 +00:00
}
2007-08-02 07:09:28 +00:00
return false ;
2007-07-26 19:52:18 +00:00
}
2008-06-02 22:41:58 +00:00
bool DrasculaEngine : : verify2 ( ) {
2007-07-26 19:52:18 +00:00
int l ;
2009-05-13 11:59:49 +00:00
if ( _menuScreen ) {
2008-05-29 22:34:03 +00:00
if ( pickupObject ( ) )
2007-10-07 22:00:43 +00:00
return true ;
2007-10-13 12:42:32 +00:00
} else {
2009-05-13 11:59:49 +00:00
if ( ! strcmp ( textName , " hacker " ) & & _hasName ) {
2008-06-05 13:23:57 +00:00
if ( checkAction ( 50 ) )
2007-10-07 22:00:43 +00:00
return true ;
2007-10-13 12:42:32 +00:00
} else {
2008-05-11 20:05:09 +00:00
for ( l = 0 ; l < numRoomObjs ; l + + ) {
2013-08-19 03:08:11 +03:00
if ( _mouseX > _objectX1 [ l ] & & _mouseY > _objectY1 [ l ]
& & _mouseX < _objectX2 [ l ] & & _mouseY < _objectY2 [ l ] & & visible [ l ] = = 1 ) {
2008-06-03 08:54:49 +00:00
trackFinal = trackObj [ l ] ;
2008-05-29 22:34:03 +00:00
walkToObject = 1 ;
2008-06-03 08:54:49 +00:00
gotoObject ( roomObjX [ l ] , roomObjY [ l ] ) ;
2008-06-05 13:23:57 +00:00
if ( checkAction ( objectNum [ l ] ) )
2007-10-07 22:00:43 +00:00
return true ;
2008-05-31 09:16:26 +00:00
if ( currentChapter = = 4 )
2007-08-17 11:19:17 +00:00
break ;
2007-07-28 09:45:05 +00:00
}
2007-07-26 19:52:18 +00:00
}
2007-10-13 12:42:32 +00:00
}
2007-07-28 09:45:05 +00:00
}
2007-10-07 22:00:43 +00:00
return false ;
2007-07-26 19:52:18 +00:00
}
2008-05-29 22:34:03 +00:00
Common : : KeyCode DrasculaEngine : : getScan ( ) {
2008-05-11 09:51:30 +00:00
updateEvents ( ) ;
2009-08-04 21:56:59 +00:00
if ( _keyBufferHead = = _keyBufferTail )
return Common : : KEYCODE_INVALID ;
2008-12-03 17:35:37 +00:00
Common : : KeyCode key = _keyBuffer [ _keyBufferTail ] . keycode ;
_keyBufferTail = ( _keyBufferTail + 1 ) % KEYBUFSIZE ;
2007-07-28 19:43:26 +00:00
2008-12-03 17:35:37 +00:00
return key ;
}
void DrasculaEngine : : addKeyToBuffer ( Common : : KeyState & key ) {
if ( ( _keyBufferHead + 1 ) % KEYBUFSIZE = = _keyBufferTail ) {
warning ( " key buffer overflow " ) ;
return ;
}
_keyBuffer [ _keyBufferHead ] = key ;
_keyBufferHead = ( _keyBufferHead + 1 ) % KEYBUFSIZE ;
}
void DrasculaEngine : : flushKeyBuffer ( ) {
updateEvents ( ) ;
_keyBufferHead = _keyBufferTail = 0 ;
2007-07-28 09:45:05 +00:00
}
2007-07-26 19:52:18 +00:00
2008-05-11 09:51:30 +00:00
void DrasculaEngine : : updateEvents ( ) {
2007-07-28 14:45:26 +00:00
Common : : Event event ;
2007-07-28 19:43:26 +00:00
Common : : EventManager * eventMan = _system - > getEventManager ( ) ;
2007-07-28 14:45:26 +00:00
2008-09-16 11:49:40 +00:00
updateMusic ( ) ;
2007-08-01 20:11:32 +00:00
2008-08-10 17:15:30 +00:00
# ifdef _WIN32_WCE
if ( eventMan - > pollEvent ( event ) ) {
# else
2007-07-28 19:43:26 +00:00
while ( eventMan - > pollEvent ( event ) ) {
2008-08-10 17:15:30 +00:00
# endif
2008-09-13 15:23:23 +00:00
switch ( event . type ) {
2007-07-28 14:45:26 +00:00
case Common : : EVENT_KEYDOWN :
2008-12-03 17:35:37 +00:00
addKeyToBuffer ( event . kbd ) ;
2007-07-28 19:43:26 +00:00
break ;
case Common : : EVENT_KEYUP :
2007-07-28 14:45:26 +00:00
break ;
2007-07-28 19:43:26 +00:00
case Common : : EVENT_MOUSEMOVE :
2013-08-19 03:08:11 +03:00
_mouseX = event . mouse . x ;
_mouseY = event . mouse . y ;
2007-07-28 14:45:26 +00:00
break ;
case Common : : EVENT_LBUTTONDOWN :
2013-08-19 03:08:11 +03:00
_leftMouseButton = 1 ;
2007-07-28 14:45:26 +00:00
break ;
case Common : : EVENT_LBUTTONUP :
2013-08-19 03:08:11 +03:00
_leftMouseButton = 0 ;
2007-07-28 14:45:26 +00:00
break ;
2007-07-28 19:43:26 +00:00
case Common : : EVENT_RBUTTONDOWN :
2010-06-15 10:24:19 +00:00
// We changed semantic and react only on button up event
2007-07-28 14:45:26 +00:00
break ;
2007-07-28 19:43:26 +00:00
case Common : : EVENT_RBUTTONUP :
2013-08-19 03:08:11 +03:00
_rightMouseButton = 1 ;
2007-07-28 14:45:26 +00:00
break ;
2007-07-28 22:10:30 +00:00
default :
2007-07-28 14:45:26 +00:00
break ;
}
}
}
2008-06-07 19:40:43 +00:00
void DrasculaEngine : : delay ( int ms ) {
2010-06-15 10:24:38 +00:00
uint32 end = _system - > getMillis ( ) + ms * 2 ; // originally was 1
do {
_system - > delayMillis ( 10 ) ;
updateEvents ( ) ;
_system - > updateScreen ( ) ;
2011-11-13 20:54:13 +01:00
} while ( _system - > getMillis ( ) < end & & ! shouldQuit ( ) ) ;
2007-07-26 19:52:18 +00:00
}
2008-06-07 19:40:43 +00:00
void DrasculaEngine : : pause ( int duration ) {
2010-06-15 10:24:38 +00:00
delay ( duration * 15 ) ;
2008-06-05 08:25:29 +00:00
}
2008-06-07 19:40:43 +00:00
int DrasculaEngine : : getTime ( ) {
2010-03-09 23:35:30 +00:00
return _system - > getMillis ( ) / 20 ; // originally was 1
2008-06-07 19:40:43 +00:00
}
2007-07-28 09:45:05 +00:00
2008-06-07 19:40:43 +00:00
void DrasculaEngine : : reduce_hare_chico ( int xx1 , int yy1 , int xx2 , int yy2 , int width , int height , int factor , byte * dir_inicio , byte * dir_fin ) {
float totalX , totalY ;
int n , m ;
float pixelX , pixelY ;
2007-07-26 19:52:18 +00:00
2008-06-07 19:40:43 +00:00
newWidth = ( width * factor ) / 100 ;
newHeight = ( height * factor ) / 100 ;
2007-07-26 19:52:18 +00:00
2008-06-07 19:40:43 +00:00
totalX = width / newWidth ;
totalY = height / newHeight ;
2007-07-26 19:52:18 +00:00
2008-06-07 19:40:43 +00:00
pixelX = xx1 ;
pixelY = yy1 ;
2007-07-26 19:52:18 +00:00
2008-06-07 19:40:43 +00:00
for ( n = 0 ; n < newHeight ; n + + ) {
for ( m = 0 ; m < newWidth ; m + + ) {
2009-01-01 15:06:43 +00:00
copyRect ( ( int ) pixelX , ( int ) pixelY , xx2 + m , yy2 + n ,
2008-09-12 12:54:16 +00:00
1 , 1 , dir_inicio , dir_fin ) ;
2007-07-26 19:52:18 +00:00
2008-06-07 19:40:43 +00:00
pixelX + = totalX ;
2007-07-26 19:52:18 +00:00
}
2008-06-07 19:40:43 +00:00
pixelX = xx1 ;
pixelY + = totalY ;
2007-07-26 19:52:18 +00:00
}
}
2008-06-07 19:40:43 +00:00
void DrasculaEngine : : hipo_sin_nadie ( int counter ) {
int y = 0 , trackCharacter = 0 ;
if ( currentChapter = = 3 )
y = - 1 ;
2007-07-26 19:52:18 +00:00
2008-06-07 19:40:43 +00:00
do {
counter - - ;
2008-06-04 19:24:50 +00:00
2008-08-26 08:21:21 +00:00
copyBackground ( ) ;
2008-06-07 19:40:43 +00:00
if ( currentChapter = = 3 )
updateScreen ( 0 , 0 , 0 , y , 320 , 200 , screenSurface ) ;
else
updateScreen ( 0 , 1 , 0 , y , 320 , 198 , screenSurface ) ;
2007-07-26 19:52:18 +00:00
2008-06-07 19:40:43 +00:00
if ( trackCharacter = = 0 )
y + + ;
else
y - - ;
2007-10-07 22:00:43 +00:00
2008-05-31 09:16:26 +00:00
if ( currentChapter = = 3 ) {
2008-05-30 08:00:42 +00:00
if ( y = = 1 )
2008-06-04 10:48:18 +00:00
trackCharacter = 1 ;
2008-05-30 08:00:42 +00:00
if ( y = = - 1 )
2008-06-04 10:48:18 +00:00
trackCharacter = 0 ;
2008-05-30 08:00:42 +00:00
} else {
if ( y = = 2 )
2008-06-04 10:48:18 +00:00
trackCharacter = 1 ;
2008-05-30 08:00:42 +00:00
if ( y = = 0 )
2008-06-04 10:48:18 +00:00
trackCharacter = 0 ;
2008-05-30 08:00:42 +00:00
}
} while ( counter > 0 ) ;
2007-10-07 22:00:43 +00:00
2008-08-26 08:21:21 +00:00
copyBackground ( ) ;
2008-05-31 12:40:02 +00:00
updateScreen ( ) ;
2008-05-02 11:18:46 +00:00
}
2007-10-07 22:00:43 +00:00
2008-06-07 20:47:52 +00:00
bool DrasculaEngine : : loadDrasculaDat ( ) {
Common : : File in ;
2008-06-09 10:11:42 +00:00
int i ;
2008-06-07 20:47:52 +00:00
in . open ( " drascula.dat " ) ;
if ( ! in . isOpen ( ) ) {
Common : : String errorMessage = " You're missing the 'drascula.dat' file. Get it from the ScummVM website " ;
GUIErrorMessage ( errorMessage ) ;
2008-11-16 20:20:31 +00:00
warning ( " %s " , errorMessage . c_str ( ) ) ;
2008-06-07 20:47:52 +00:00
return false ;
}
char buf [ 256 ] ;
int ver ;
in . read ( buf , 8 ) ;
buf [ 8 ] = ' \0 ' ;
2011-11-02 23:18:10 +00:00
if ( strcmp ( buf , " DRASCULA " ) ! = 0 ) {
2008-06-07 20:47:52 +00:00
Common : : String errorMessage = " File 'drascula.dat' is corrupt. Get it from the ScummVM website " ;
GUIErrorMessage ( errorMessage ) ;
2008-11-16 20:20:31 +00:00
warning ( " %s " , errorMessage . c_str ( ) ) ;
2008-06-07 20:47:52 +00:00
return false ;
}
ver = in . readByte ( ) ;
2009-01-01 15:06:43 +00:00
2008-06-07 20:47:52 +00:00
if ( ver ! = DRASCULA_DAT_VER ) {
2011-06-02 02:53:48 +01:00
Common : : String errorMessage = Common : : String : : format ( " File 'drascula.dat' is wrong version. Expected %d but got %d. Get it from the ScummVM website " , DRASCULA_DAT_VER , ver ) ;
GUIErrorMessage ( errorMessage ) ;
warning ( " %s " , errorMessage . c_str ( ) ) ;
2008-06-07 20:47:52 +00:00
return false ;
}
_charMapSize = in . readUint16BE ( ) ;
_charMap = ( CharInfo * ) malloc ( sizeof ( CharInfo ) * _charMapSize ) ;
2008-06-09 10:11:42 +00:00
for ( i = 0 ; i < _charMapSize ; i + + ) {
2008-06-07 20:47:52 +00:00
_charMap [ i ] . inChar = in . readByte ( ) ;
2008-06-10 21:07:11 +00:00
_charMap [ i ] . mappedChar = in . readSint16BE ( ) ;
2008-06-07 20:47:52 +00:00
_charMap [ i ] . charType = in . readByte ( ) ;
}
2008-06-07 21:02:03 +00:00
_itemLocationsSize = in . readUint16BE ( ) ;
2008-06-09 10:11:42 +00:00
_itemLocations = ( ItemLocation * ) malloc ( sizeof ( ItemLocation ) * _itemLocationsSize ) ;
for ( i = 0 ; i < _itemLocationsSize ; i + + ) {
2008-06-10 21:07:11 +00:00
_itemLocations [ i ] . x = in . readSint16BE ( ) ;
_itemLocations [ i ] . y = in . readSint16BE ( ) ;
2008-06-07 21:02:03 +00:00
}
2008-06-09 10:11:42 +00:00
_polXSize = in . readUint16BE ( ) ;
_polX = ( int * ) malloc ( sizeof ( int ) * _polXSize ) ;
_polY = ( int * ) malloc ( sizeof ( int ) * _polXSize ) ;
for ( i = 0 ; i < _polXSize ; i + + ) {
2008-06-10 21:07:11 +00:00
_polX [ i ] = in . readSint16BE ( ) ;
_polY [ i ] = in . readSint16BE ( ) ;
2008-06-07 21:02:03 +00:00
}
_verbBarXSize = in . readUint16BE ( ) ;
2008-06-09 10:11:42 +00:00
_verbBarX = ( int * ) malloc ( sizeof ( int ) * _verbBarXSize ) ;
for ( i = 0 ; i < _verbBarXSize ; i + + ) {
2008-06-10 21:07:11 +00:00
_verbBarX [ i ] = in . readSint16BE ( ) ;
2008-06-07 21:02:03 +00:00
}
_x1dMenuSize = in . readUint16BE ( ) ;
2008-06-09 10:11:42 +00:00
_x1d_menu = ( int * ) malloc ( sizeof ( int ) * _x1dMenuSize ) ;
_y1d_menu = ( int * ) malloc ( sizeof ( int ) * _x1dMenuSize ) ;
for ( i = 0 ; i < _x1dMenuSize ; i + + ) {
2008-06-10 21:07:11 +00:00
_x1d_menu [ i ] = in . readSint16BE ( ) ;
_y1d_menu [ i ] = in . readSint16BE ( ) ;
2008-06-07 21:02:03 +00:00
}
_frameXSize = in . readUint16BE ( ) ;
2008-06-09 10:11:42 +00:00
_frameX = ( int * ) malloc ( sizeof ( int ) * _frameXSize ) ;
for ( i = 0 ; i < _frameXSize ; i + + ) {
2008-06-10 21:07:11 +00:00
_frameX [ i ] = in . readSint16BE ( ) ;
2008-06-07 21:02:03 +00:00
}
_candleXSize = in . readUint16BE ( ) ;
2008-06-09 10:11:42 +00:00
_candleX = ( int * ) malloc ( sizeof ( int ) * _candleXSize ) ;
_candleY = ( int * ) malloc ( sizeof ( int ) * _candleXSize ) ;
for ( i = 0 ; i < _candleXSize ; i + + ) {
2008-06-10 21:07:11 +00:00
_candleX [ i ] = in . readSint16BE ( ) ;
_candleY [ i ] = in . readSint16BE ( ) ;
2008-06-07 21:02:03 +00:00
}
_pianistXSize = in . readUint16BE ( ) ;
2008-06-09 10:11:42 +00:00
_pianistX = ( int * ) malloc ( sizeof ( int ) * _pianistXSize ) ;
for ( i = 0 ; i < _pianistXSize ; i + + ) {
2008-06-10 21:07:11 +00:00
_pianistX [ i ] = in . readSint16BE ( ) ;
2008-06-07 21:02:03 +00:00
}
_drunkXSize = in . readUint16BE ( ) ;
2008-06-09 10:11:42 +00:00
_drunkX = ( int * ) malloc ( sizeof ( int ) * _drunkXSize ) ;
for ( i = 0 ; i < _drunkXSize ; i + + ) {
2008-06-10 21:07:11 +00:00
_drunkX [ i ] = in . readSint16BE ( ) ;
2008-06-07 21:02:03 +00:00
}
_roomPreUpdatesSize = in . readUint16BE ( ) ;
2008-06-09 10:11:42 +00:00
_roomPreUpdates = ( RoomUpdate * ) malloc ( sizeof ( RoomUpdate ) * _roomPreUpdatesSize ) ;
for ( i = 0 ; i < _roomPreUpdatesSize ; i + + ) {
2008-06-10 21:07:11 +00:00
_roomPreUpdates [ i ] . roomNum = in . readSint16BE ( ) ;
_roomPreUpdates [ i ] . flag = in . readSint16BE ( ) ;
_roomPreUpdates [ i ] . flagValue = in . readSint16BE ( ) ;
_roomPreUpdates [ i ] . sourceX = in . readSint16BE ( ) ;
_roomPreUpdates [ i ] . sourceY = in . readSint16BE ( ) ;
_roomPreUpdates [ i ] . destX = in . readSint16BE ( ) ;
_roomPreUpdates [ i ] . destY = in . readSint16BE ( ) ;
_roomPreUpdates [ i ] . width = in . readSint16BE ( ) ;
_roomPreUpdates [ i ] . height = in . readSint16BE ( ) ;
_roomPreUpdates [ i ] . type = in . readSint16BE ( ) ;
2008-06-07 21:02:03 +00:00
}
_roomUpdatesSize = in . readUint16BE ( ) ;
2008-06-09 10:11:42 +00:00
_roomUpdates = ( RoomUpdate * ) malloc ( sizeof ( RoomUpdate ) * _roomUpdatesSize ) ;
for ( i = 0 ; i < _roomUpdatesSize ; i + + ) {
2008-06-10 21:07:11 +00:00
_roomUpdates [ i ] . roomNum = in . readSint16BE ( ) ;
_roomUpdates [ i ] . flag = in . readSint16BE ( ) ;
_roomUpdates [ i ] . flagValue = in . readSint16BE ( ) ;
_roomUpdates [ i ] . sourceX = in . readSint16BE ( ) ;
_roomUpdates [ i ] . sourceY = in . readSint16BE ( ) ;
_roomUpdates [ i ] . destX = in . readSint16BE ( ) ;
_roomUpdates [ i ] . destY = in . readSint16BE ( ) ;
_roomUpdates [ i ] . width = in . readSint16BE ( ) ;
_roomUpdates [ i ] . height = in . readSint16BE ( ) ;
_roomUpdates [ i ] . type = in . readSint16BE ( ) ;
2008-06-07 21:02:03 +00:00
}
_roomActionsSize = in . readUint16BE ( ) ;
2008-06-09 10:11:42 +00:00
_roomActions = ( RoomTalkAction * ) malloc ( sizeof ( RoomTalkAction ) * _roomActionsSize ) ;
for ( i = 0 ; i < _roomActionsSize ; i + + ) {
2008-06-10 21:07:11 +00:00
_roomActions [ i ] . room = in . readSint16BE ( ) ;
_roomActions [ i ] . chapter = in . readSint16BE ( ) ;
_roomActions [ i ] . action = in . readSint16BE ( ) ;
_roomActions [ i ] . objectID = in . readSint16BE ( ) ;
_roomActions [ i ] . speechID = in . readSint16BE ( ) ;
2008-06-07 21:02:03 +00:00
}
2008-09-09 15:59:06 +00:00
_talkSequencesSize = in . readUint16BE ( ) ;
_talkSequences = ( TalkSequenceCommand * ) malloc ( sizeof ( TalkSequenceCommand ) * _talkSequencesSize ) ;
for ( i = 0 ; i < _talkSequencesSize ; i + + ) {
_talkSequences [ i ] . chapter = in . readSint16BE ( ) ;
_talkSequences [ i ] . sequence = in . readSint16BE ( ) ;
_talkSequences [ i ] . commandType = in . readSint16BE ( ) ;
_talkSequences [ i ] . action = in . readSint16BE ( ) ;
}
2008-06-07 21:02:03 +00:00
_numLangs = in . readUint16BE ( ) ;
2008-06-08 21:59:12 +00:00
_text = loadTexts ( in ) ;
_textd = loadTexts ( in ) ;
_textb = loadTexts ( in ) ;
_textbj = loadTexts ( in ) ;
_texte = loadTexts ( in ) ;
_texti = loadTexts ( in ) ;
_textl = loadTexts ( in ) ;
_textp = loadTexts ( in ) ;
_textt = loadTexts ( in ) ;
_textvb = loadTexts ( in ) ;
_textsys = loadTexts ( in ) ;
_texthis = loadTexts ( in ) ;
_textverbs = loadTexts ( in ) ;
_textmisc = loadTexts ( in ) ;
_textd1 = loadTexts ( in ) ;
2008-06-07 20:47:52 +00:00
return true ;
}
2008-09-10 08:25:12 +00:00
char * * DrasculaEngine : : loadTexts ( Common : : File & in ) {
2008-06-08 21:59:12 +00:00
int numTexts = in . readUint16BE ( ) ;
2008-09-10 08:25:12 +00:00
char * * res = ( char * * ) malloc ( sizeof ( char * ) * numTexts ) ;
2008-06-08 21:59:12 +00:00
int entryLen ;
2008-09-10 08:25:12 +00:00
char * pos = 0 ;
2008-06-08 21:59:12 +00:00
int len ;
for ( int lang = 0 ; lang < _numLangs ; lang + + ) {
entryLen = in . readUint16BE ( ) ;
2008-09-10 08:25:12 +00:00
if ( lang = = _lang ) {
2011-01-27 14:07:45 +00:00
pos = ( char * ) malloc ( entryLen ) ;
2008-09-10 08:25:12 +00:00
in . read ( pos , entryLen ) ;
2011-01-27 14:07:45 +00:00
res [ 0 ] = pos ;
pos + = DATAALIGNMENT ;
2008-06-08 21:59:12 +00:00
2011-01-27 14:07:45 +00:00
for ( int i = 1 ; i < numTexts ; i + + ) {
pos - = 2 ;
2008-06-08 21:59:12 +00:00
2011-01-27 14:07:45 +00:00
len = READ_BE_UINT16 ( pos ) ;
pos + = 2 + len ;
2008-06-08 21:59:12 +00:00
2008-09-10 08:25:12 +00:00
res [ i ] = pos ;
2011-01-27 14:07:45 +00:00
}
} else
in . seek ( entryLen , SEEK_CUR ) ;
2008-06-08 21:59:12 +00:00
}
return res ;
}
2008-09-10 08:25:12 +00:00
void DrasculaEngine : : freeTexts ( char * * ptr ) {
2008-08-02 21:05:46 +00:00
if ( ! ptr )
return ;
2010-03-09 23:35:30 +00:00
free ( * ptr ) ;
2008-06-08 21:59:12 +00:00
free ( ptr ) ;
}
2007-07-17 21:35:01 +00:00
} // End of namespace Drascula