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
*
2021-12-26 18:47:58 +01: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 3 of the License , or
* ( at your option ) any later version .
2014-02-18 02:34:25 +01:00
*
2003-12-16 02:10:15 +00:00
* 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 .
2014-02-18 02:34:25 +01:00
*
2003-12-16 02:10:15 +00:00
* You should have received a copy of the GNU General Public License
2021-12-26 18:47:58 +01:00
* along with this program . If not , see < http : //www.gnu.org/licenses/>.
2003-12-16 02:10:15 +00:00
*
*/
2005-06-24 16:01:42 +00:00
# include "sword1/sword1.h"
2003-12-16 02:10:15 +00:00
2004-10-21 12:43:49 +00:00
# include "sword1/resman.h"
# include "sword1/objectman.h"
# include "sword1/mouse.h"
# include "sword1/logic.h"
# include "sword1/sound.h"
# include "sword1/screen.h"
# include "sword1/swordres.h"
# include "sword1/menu.h"
# include "sword1/control.h"
2003-12-16 02:10:15 +00:00
2008-11-13 12:22:58 +00:00
# include "common/config-manager.h"
2011-04-24 11:34:27 +03:00
# include "common/textconsole.h"
2023-08-18 13:32:53 +02:00
# include "common/timer.h"
2008-11-13 12:22:58 +00:00
2023-01-14 21:09:40 +01:00
# include "engines/advancedDetector.h"
2010-05-04 11:58:12 +00:00
# include "engines/util.h"
2004-07-11 04:41:48 +00:00
# include "gui/message.h"
2004-01-11 15:47:41 +00:00
namespace Sword1 {
2003-12-16 02:10:15 +00:00
SystemVars SwordEngine : : _systemVars ;
2023-01-14 21:09:40 +01:00
SwordEngine : : SwordEngine ( OSystem * syst , const ADGameDescription * gameDesc )
2003-12-16 02:10:15 +00:00
: Engine ( syst ) {
2023-01-14 21:09:40 +01:00
_features = gameDesc - > flags ;
_systemVars . platform = gameDesc - > platform ;
2004-08-31 07:52:47 +00:00
2004-11-24 00:14:21 +00:00
// Add default file directories
2023-09-17 18:23:46 +02:00
const Common : : FSNode gameDataDir ( ConfMan . getPath ( " path " ) ) ;
2010-05-04 11:56:52 +00:00
SearchMan . addSubDirectoryMatching ( gameDataDir , " music " ) ;
SearchMan . addSubDirectoryMatching ( gameDataDir , " speech " ) ;
2012-01-06 23:50:58 -05:00
SearchMan . addSubDirectoryMatching ( gameDataDir , " streams " ) ; // PSX videos
2023-01-14 21:10:03 +01:00
//SearchMan.addSubDirectoryMatching(gameDataDir, "clusters"); // Comes from AD
2023-03-02 00:26:16 +01:00
SearchMan . addSubDirectoryMatching ( gameDataDir , " video " ) ; // Comes from AD
SearchMan . addSubDirectoryMatching ( gameDataDir , " smackshi " ) ; // Comes from AD
2023-01-14 21:10:03 +01:00
//SearchMan.addSubDirectoryMatching(gameDataDir, "english"); // PSX Demo // Comes from AD
//SearchMan.addSubDirectoryMatching(gameDataDir, "italian"); // PSX Demo // Comes from AD
2010-11-08 12:22:58 +00:00
2020-02-09 08:36:00 -08:00
setDebugger ( new SwordConsole ( this ) ) ;
2013-10-30 09:14:06 +02:00
_mouseState = 0 ;
_resMan = 0 ;
_objectMan = 0 ;
_screen = 0 ;
_mouse = 0 ;
_logic = 0 ;
_sound = 0 ;
_menu = 0 ;
_control = 0 ;
2003-12-16 02:10:15 +00:00
}
SwordEngine : : ~ SwordEngine ( ) {
2004-11-09 04:06:10 +00:00
delete _control ;
delete _logic ;
delete _menu ;
delete _sound ;
delete _screen ;
delete _mouse ;
delete _objectMan ;
delete _resMan ;
2003-12-16 02:10:15 +00:00
}
2008-11-06 17:05:54 +00:00
Common : : Error SwordEngine : : init ( ) {
2004-06-28 00:06:31 +00:00
2017-10-01 00:56:01 -05:00
initGraphics ( 640 , 480 ) ;
2007-09-19 08:40:12 +00:00
2004-12-10 17:55:03 +00:00
checkCdFiles ( ) ;
2003-12-16 02:10:15 +00:00
debug ( 5 , " Starting resource manager " ) ;
2023-12-02 11:38:40 +01:00
_resMan = new ResMan ( " swordres.rif " , _systemVars . platform = = Common : : kPlatformMacintosh ,
Common : : parseLanguage ( ConfMan . get ( " language " ) ) = = Common : : KO_KOR ) ;
2003-12-16 02:10:15 +00:00
debug ( 5 , " Starting object manager " ) ;
_objectMan = new ObjectMan ( _resMan ) ;
2004-01-11 15:47:41 +00:00
_mouse = new Mouse ( _system , _resMan , _objectMan ) ;
2023-10-03 13:27:44 +02:00
_screen = new Screen ( _system , this , _resMan , _objectMan ) ;
2023-10-02 18:13:36 +02:00
_sound = new Sound ( _mixer , this , _resMan ) ;
2004-01-11 15:47:41 +00:00
_menu = new Menu ( _screen , _mouse ) ;
2023-10-04 23:01:01 +02:00
_logic = new Logic ( this , _objectMan , _resMan , _screen , _mouse , _sound , _menu , _system , _mixer ) ;
2003-12-17 05:16:37 +00:00
_mouse - > useLogicAndMenu ( _logic , _menu ) ;
2023-09-28 09:20:04 +02:00
_mouse - > useScreenMutex ( & _screen - > _screenAccessMutex ) ;
2003-12-16 02:10:15 +00:00
2023-10-05 00:02:04 +02:00
// Init the virtual mouse coordinates to be at the center of the screen
_mouseCoord . x = SCREEN_WIDTH / 2 ;
_mouseCoord . y = SCREEN_FULL_DEPTH / 2 ;
2008-07-17 20:08:59 +00:00
syncSoundSettings ( ) ;
2004-01-06 11:48:30 +00:00
2004-03-31 18:00:46 +00:00
_systemVars . justRestoredGame = 0 ;
_systemVars . currentCD = 0 ;
2004-11-09 04:06:10 +00:00
_systemVars . controlPanelMode = CP_NEWGAME ;
2023-09-13 01:13:04 +02:00
_systemVars . saveGameFlag = SGF_DONE ;
_systemVars . snrStatus = SNR_BLANK ;
2004-03-03 07:37:46 +00:00
_systemVars . wantFade = true ;
2012-10-06 16:21:48 +02:00
_systemVars . realLanguage = Common : : parseLanguage ( ConfMan . get ( " language " ) ) ;
2021-06-15 18:47:31 +03:00
_systemVars . isLangRtl = false ;
2023-08-19 18:20:54 +02:00
_systemVars . debugMode = ( gDebugLevel > = 0 ) ;
2023-08-20 19:09:14 +02:00
_systemVars . slowMode = false ;
_systemVars . fastMode = false ;
2023-09-13 01:13:04 +02:00
_systemVars . parallaxOn = true ;
2003-12-16 10:08:27 +00:00
2012-10-06 16:21:48 +02:00
switch ( _systemVars . realLanguage ) {
2003-12-16 10:08:27 +00:00
case Common : : DE_DEU :
_systemVars . language = BS1_GERMAN ;
break ;
case Common : : FR_FRA :
_systemVars . language = BS1_FRENCH ;
break ;
case Common : : IT_ITA :
_systemVars . language = BS1_ITALIAN ;
break ;
case Common : : ES_ESP :
_systemVars . language = BS1_SPANISH ;
break ;
case Common : : PT_BRA :
_systemVars . language = BS1_PORT ;
break ;
2022-01-30 18:43:35 -05:00
case Common : : CS_CZE :
2004-01-06 12:28:24 +00:00
_systemVars . language = BS1_CZECH ;
break ;
2021-06-15 18:47:31 +03:00
case Common : : HE_ISR :
// Hebrew is using "faked" English
_systemVars . language = BS1_ENGLISH ;
_systemVars . isLangRtl = true ;
break ;
2003-12-16 10:08:27 +00:00
default :
_systemVars . language = BS1_ENGLISH ;
2012-10-06 16:21:48 +02:00
break ;
2003-12-16 10:08:27 +00:00
}
2003-12-17 14:36:52 +00:00
_systemVars . showText = ConfMan . getBool ( " subtitles " ) ;
2023-09-23 13:21:27 +02:00
_systemVars . textNumber = 0 ;
2017-07-08 12:41:22 +01:00
_systemVars . playSpeech = true ;
2003-12-17 11:54:48 +00:00
_mouseState = 0 ;
2010-01-25 01:39:44 +00:00
2023-09-23 13:21:27 +02:00
_systemVars . gamePaused = false ;
_systemVars . displayDebugText = false ;
2023-09-24 21:18:36 +02:00
_systemVars . displayDebugMouse = false ;
_systemVars . displayDebugGrid = false ;
2023-09-23 13:21:27 +02:00
_systemVars . framesPerSecondCounter = 0 ;
_systemVars . gameCycle = 0 ;
2009-07-12 18:52:38 +00:00
// Some Mac versions use big endian for the speech files but not all of them.
if ( _systemVars . platform = = Common : : kPlatformMacintosh )
_sound - > checkSpeechFileEndianness ( ) ;
2003-12-20 09:12:54 +00:00
_logic - > initialize ( ) ;
_objectMan - > initialize ( ) ;
_mouse - > initialize ( ) ;
2023-10-04 23:01:01 +02:00
_control = new Control ( this , _saveFileMan , _resMan , _objectMan , _system , _mouse , _sound , _screen , _logic ) ;
2023-10-16 11:18:22 +02:00
_logic - > setControlPanelObject ( _control ) ;
2005-07-30 21:11:48 +00:00
2008-11-06 17:05:54 +00:00
return Common : : kNoError ;
2003-12-20 09:12:54 +00:00
}
2009-11-02 21:54:57 +00:00
void SwordEngine : : reinitialize ( ) {
2023-10-02 17:03:11 +02:00
_sound - > clearAllFx ( ) ;
2004-11-19 07:55:33 +00:00
_resMan - > flush ( ) ; // free everything that's currently alloced and opened. (*evil*)
2003-12-20 09:12:54 +00:00
_logic - > initialize ( ) ; // now reinitialize these objects as they (may) have locked
_objectMan - > initialize ( ) ; // resources which have just been wiped.
_mouse - > initialize ( ) ;
2004-03-28 16:30:50 +00:00
_system - > warpMouse ( 320 , 240 ) ;
2003-12-22 11:23:40 +00:00
_systemVars . wantFade = true ;
2003-12-17 11:54:48 +00:00
}
2008-07-17 17:49:38 +00:00
void SwordEngine : : syncSoundSettings ( ) {
2011-03-19 15:09:21 +01:00
Engine : : syncSoundSettings ( ) ;
2023-10-04 23:37:56 +02:00
_sound - > getVolumes ( ) ;
2008-07-17 17:49:38 +00:00
}
2004-12-10 17:55:03 +00:00
void SwordEngine : : flagsToBool ( bool * dest , uint8 flags ) {
uint8 bitPos = 0 ;
while ( flags ) {
if ( flags & 1 )
dest [ bitPos ] = true ;
flags > > = 1 ;
bitPos + + ;
}
}
2023-09-13 01:13:04 +02:00
void SwordEngine : : checkKeys ( ) {
2023-09-23 13:21:27 +02:00
if ( _systemVars . gamePaused ) {
2023-10-03 18:56:07 +02:00
_sound - > pauseSpeech ( ) ;
_sound - > pauseMusic ( ) ;
_sound - > pauseFx ( ) ;
2023-09-23 13:21:27 +02:00
while ( _keyPressed . keycode ! = Common : : KEYCODE_p & & ! Engine : : shouldQuit ( ) ) {
pollInput ( 0 ) ;
2023-10-04 22:51:30 +02:00
_sound - > updateMusicStreaming ( ) ;
2023-09-23 13:21:27 +02:00
}
2023-10-03 18:56:07 +02:00
_sound - > unpauseSpeech ( ) ;
_sound - > unpauseMusic ( ) ;
_sound - > unpauseFx ( ) ;
2023-09-23 13:21:27 +02:00
_systemVars . gamePaused = false ;
_keyPressed . reset ( ) ;
}
2023-09-13 01:13:04 +02:00
switch ( _keyPressed . keycode ) {
case Common : : KEYCODE_F5 :
case Common : : KEYCODE_ESCAPE :
2023-10-16 20:26:55 +02:00
if ( ( Logic : : _scriptVars [ MOUSE_STATUS ] & 1 ) & &
( Logic : : _scriptVars [ GEORGE_HOLDING_PIECE ] = = 0 ) & &
( Logic : : _scriptVars [ SCREEN ] ! = 91 ) ) { // Disable the save screen on the phone envelope room!
2023-09-13 01:13:04 +02:00
_systemVars . saveGameFlag = SGF_SAVE ;
_systemVars . snrStatus = SNR_MAINPANEL ;
}
2023-09-23 13:21:27 +02:00
break ;
case Common : : KEYCODE_q :
if ( _keyPressed . hasFlags ( Common : : KBD_CTRL ) )
Engine : : quitGame ( ) ;
break ;
case Common : : KEYCODE_p :
_systemVars . gamePaused = true ;
2023-09-13 01:13:04 +02:00
break ;
default :
break ;
}
// Debug keys!
if ( ! _systemVars . isDemo & & _systemVars . debugMode ) {
2023-08-19 18:20:54 +02:00
switch ( _keyPressed . keycode ) {
2023-09-23 13:21:27 +02:00
case Common : : KEYCODE_t : // CTRL-T: Toggles debug text
if ( _keyPressed . hasFlags ( Common : : KBD_CTRL ) )
_systemVars . displayDebugText = ! _systemVars . displayDebugText ;
break ;
2023-09-24 21:18:36 +02:00
case Common : : KEYCODE_m : // SHIFT-M: Toggles debug mouse tracking
// This was originally CTRL-M, but ScummVM steals that event to
// lock the mouse cursor within the window boundaries.
if ( _keyPressed . hasFlags ( Common : : KBD_SHIFT ) )
_systemVars . displayDebugMouse = ! _systemVars . displayDebugMouse ;
2023-09-24 21:25:49 +02:00
_screen - > fullRefresh ( true ) ;
2023-09-24 21:18:36 +02:00
break ;
case Common : : KEYCODE_g : // CTRL-G: Toggles walkgrid displaying
if ( _keyPressed . hasFlags ( Common : : KBD_CTRL ) )
_systemVars . displayDebugGrid = ! _systemVars . displayDebugGrid ;
2023-09-24 21:25:49 +02:00
_screen - > fullRefresh ( true ) ;
2023-09-24 21:18:36 +02:00
break ;
2023-09-13 01:13:04 +02:00
case Common : : KEYCODE_1 : // Slow mode
{
if ( _systemVars . slowMode ) {
_systemVars . slowMode = false ;
_targetFrameTime = DEFAULT_FRAME_TIME ; // 12.5Hz
} else {
_systemVars . slowMode = true ;
_targetFrameTime = SLOW_FRAME_TIME ; // 2Hz
2023-08-26 17:32:46 +02:00
}
2023-09-13 01:13:04 +02:00
_systemVars . fastMode = false ; // For good measure...
_rate = _targetFrameTime / 10 ;
2023-08-19 18:20:54 +02:00
}
break ;
2023-09-13 01:13:04 +02:00
case Common : : KEYCODE_4 : // Fast mode
{
if ( _systemVars . fastMode ) {
_systemVars . fastMode = false ;
_targetFrameTime = DEFAULT_FRAME_TIME ; // 12.5Hz
} else {
_systemVars . fastMode = true ;
_targetFrameTime = FAST_FRAME_TIME ; // 100Hz
2023-08-19 18:20:54 +02:00
}
2023-09-13 01:13:04 +02:00
_systemVars . slowMode = false ; // For good measure...
_rate = _targetFrameTime / 10 ;
2023-08-19 18:20:54 +02:00
}
2023-09-13 01:13:04 +02:00
break ;
default :
break ;
2023-08-19 18:20:54 +02:00
}
}
}
2011-09-08 00:05:09 +02:00
static const char * const errorMsgs [ ] = {
2004-12-10 17:55:03 +00:00
" The file \" %s \" is missing and the game doesn't work without it. \n "
" Please copy it from CD %d and try starting the game again. \n "
" The Readme file also contains further information. " ,
2005-07-30 21:11:48 +00:00
2004-12-10 17:55:03 +00:00
" %d important files are missing, the game can't start without them. \n "
" Please copy these files from their corresponding CDs: \n " ,
2005-10-20 13:08:43 +00:00
" The file \" %s \" is missing. \n "
2004-12-10 17:55:03 +00:00
" Even though the game may initially seem to \n "
" work fine, it will crash when it needs the \n "
" data from this file and you will be thrown back to your last savegame. \n "
" Please copy the file from CD %d and start the game again. " ,
" %d files are missing. \n "
" Even though the game may initially seem to \n "
" work fine, it will crash when it needs the \n "
" data from these files and you will be thrown back to your last savegame. \n "
" Please copy these files from their corresponding CDs: \n "
} ;
2006-11-12 19:05:51 +00:00
const CdFile SwordEngine : : _pcCdFileList [ ] = {
2004-12-10 17:55:03 +00:00
{ " paris2.clu " , FLAG_CD1 } ,
{ " ireland.clu " , FLAG_CD2 } ,
{ " paris3.clu " , FLAG_CD1 } ,
{ " paris4.clu " , FLAG_CD1 } ,
{ " scotland.clu " , FLAG_CD2 } ,
{ " spain.clu " , FLAG_CD2 } ,
{ " syria.clu " , FLAG_CD2 } ,
{ " train.clu " , FLAG_CD2 } ,
{ " compacts.clu " , FLAG_CD1 | FLAG_DEMO | FLAG_IMMED } ,
{ " general.clu " , FLAG_CD1 | FLAG_DEMO | FLAG_IMMED } ,
{ " maps.clu " , FLAG_CD1 | FLAG_DEMO } ,
{ " paris1.clu " , FLAG_CD1 | FLAG_DEMO } ,
{ " scripts.clu " , FLAG_CD1 | FLAG_DEMO | FLAG_IMMED } ,
{ " swordres.rif " , FLAG_CD1 | FLAG_DEMO | FLAG_IMMED } ,
{ " text.clu " , FLAG_CD1 | FLAG_DEMO } ,
2020-09-01 16:37:07 +02:00
{ " 1m14a.wav " , FLAG_DEMO } ,
2004-12-10 17:55:03 +00:00
{ " speech1.clu " , FLAG_SPEECH1 } ,
2023-01-14 23:54:24 +01:00
{ " speech2.clu " , FLAG_SPEECH2 }
2007-06-26 05:51:47 +00:00
# ifdef USE_FLAC
2011-09-07 23:54:34 +02:00
, { " speech1.clf " , FLAG_SPEECH1 } ,
{ " speech2.clf " , FLAG_SPEECH2 }
2004-10-14 06:36:05 +00:00
# endif
2005-08-10 12:42:56 +00:00
# ifdef USE_VORBIS
2011-09-07 23:54:34 +02:00
, { " speech1.clv " , FLAG_SPEECH1 } ,
{ " speech2.clv " , FLAG_SPEECH2 }
2004-10-14 06:36:05 +00:00
# endif
2007-06-26 05:51:47 +00:00
# ifdef USE_MAD
2011-09-07 23:54:34 +02:00
, { " speech1.cl3 " , FLAG_SPEECH1 } ,
{ " speech2.cl3 " , FLAG_SPEECH2 }
2007-06-26 05:51:47 +00:00
# endif
2004-12-10 17:55:03 +00:00
} ;
2003-12-30 22:57:52 +00:00
2006-11-12 19:05:51 +00:00
const CdFile SwordEngine : : _macCdFileList [ ] = {
{ " paris2.clm " , FLAG_CD1 } ,
{ " ireland.clm " , FLAG_CD2 } ,
{ " paris3.clm " , FLAG_CD1 } ,
{ " paris4.clm " , FLAG_CD1 } ,
{ " scotland.clm " , FLAG_CD2 } ,
{ " spain.clm " , FLAG_CD2 } ,
{ " syria.clm " , FLAG_CD2 } ,
{ " train.clm " , FLAG_CD2 } ,
{ " compacts.clm " , FLAG_CD1 | FLAG_DEMO | FLAG_IMMED } ,
{ " general.clm " , FLAG_CD1 | FLAG_DEMO | FLAG_IMMED } ,
{ " maps.clm " , FLAG_CD1 | FLAG_DEMO } ,
{ " paris1.clm " , FLAG_CD1 | FLAG_DEMO } ,
{ " scripts.clm " , FLAG_CD1 | FLAG_DEMO | FLAG_IMMED } ,
{ " swordres.rif " , FLAG_CD1 | FLAG_DEMO | FLAG_IMMED } ,
{ " text.clm " , FLAG_CD1 | FLAG_DEMO } ,
{ " speech1.clu " , FLAG_SPEECH1 } ,
2011-09-07 23:54:34 +02:00
{ " speech2.clu " , FLAG_SPEECH2 }
2007-06-26 05:51:47 +00:00
# ifdef USE_FLAC
, { " speech1.clf " , FLAG_SPEECH1 } ,
2011-09-07 23:54:34 +02:00
{ " speech2.clf " , FLAG_SPEECH2 }
2006-11-12 19:05:51 +00:00
# endif
# ifdef USE_VORBIS
, { " speech1.clv " , FLAG_SPEECH1 } ,
2011-09-07 23:54:34 +02:00
{ " speech2.clv " , FLAG_SPEECH2 }
2006-11-12 19:05:51 +00:00
# endif
2007-06-26 05:51:47 +00:00
# ifdef USE_MAD
, { " speech1.cl3 " , FLAG_SPEECH1 } ,
2011-09-07 23:54:34 +02:00
{ " speech2.cl3 " , FLAG_SPEECH2 }
2007-06-26 05:51:47 +00:00
# endif
2006-11-12 19:05:51 +00:00
} ;
2009-02-28 10:46:33 +00:00
const CdFile SwordEngine : : _psxCdFileList [ ] = { // PSX edition has only one cd
{ " paris2.clu " , FLAG_CD1 } ,
{ " ireland.clu " , FLAG_CD1 } ,
{ " paris3.clu " , FLAG_CD1 } ,
{ " paris4.clu " , FLAG_CD1 } ,
{ " scotland.clu " , FLAG_CD1 } ,
{ " spain.clu " , FLAG_CD1 } ,
{ " syria.clu " , FLAG_CD1 } ,
{ " train.clu " , FLAG_CD1 } ,
{ " train.plx " , FLAG_CD1 } ,
2009-06-08 12:37:24 +00:00
{ " compacts.clu " , FLAG_CD1 | FLAG_DEMO | FLAG_IMMED } ,
{ " general.clu " , FLAG_CD1 | FLAG_DEMO | FLAG_IMMED } ,
{ " maps.clu " , FLAG_CD1 | FLAG_DEMO } ,
{ " paris1.clu " , FLAG_CD1 | FLAG_DEMO } ,
{ " scripts.clu " , FLAG_CD1 | FLAG_DEMO | FLAG_IMMED } ,
{ " swordres.rif " , FLAG_CD1 | FLAG_DEMO | FLAG_IMMED } ,
{ " text.clu " , FLAG_CD1 | FLAG_DEMO } ,
{ " speech.dat " , FLAG_SPEECH1 | FLAG_DEMO } ,
{ " speech.tab " , FLAG_SPEECH1 | FLAG_DEMO } ,
{ " speech.inf " , FLAG_SPEECH1 | FLAG_DEMO } ,
{ " speech.lis " , FLAG_SPEECH1 | FLAG_DEMO }
2009-02-28 10:46:33 +00:00
} ;
2006-11-12 19:05:51 +00:00
2004-12-10 17:55:03 +00:00
void SwordEngine : : showFileErrorMsg ( uint8 type , bool * fileExists ) {
char msg [ 1024 ] ;
int missCnt = 0 , missNum = 0 ;
2006-11-12 19:05:51 +00:00
2009-02-28 10:46:33 +00:00
if ( SwordEngine : : isMac ( ) ) {
2006-11-12 19:05:51 +00:00
for ( int i = 0 ; i < ARRAYSIZE ( _macCdFileList ) ; i + + )
if ( ! fileExists [ i ] ) {
missCnt + + ;
missNum = i ;
}
assert ( missCnt > 0 ) ; // this function shouldn't get called if there's nothing missing.
warning ( " %d files missing " , missCnt ) ;
int msgId = ( type = = TYPE_IMMED ) ? 0 : 2 ;
if ( missCnt = = 1 ) {
2022-10-23 15:27:58 +02:00
Common : : sprintf_s ( msg , errorMsgs [ msgId ] ,
2011-09-07 23:54:34 +02:00
_macCdFileList [ missNum ] . name , ( _macCdFileList [ missNum ] . flags & FLAG_CD2 ) ? 2 : 1 ) ;
2008-11-16 20:20:31 +00:00
warning ( " %s " , msg ) ;
2006-11-12 19:05:51 +00:00
} else {
2022-10-23 15:27:58 +02:00
char * pos = msg + Common : : sprintf_s ( msg , errorMsgs [ msgId + 1 ] , missCnt ) ;
2008-11-16 20:20:31 +00:00
warning ( " %s " , msg ) ;
2006-11-12 19:05:51 +00:00
for ( int i = 0 ; i < ARRAYSIZE ( _macCdFileList ) ; i + + )
if ( ! fileExists [ i ] ) {
warning ( " \" %s \" (CD %d) " , _macCdFileList [ i ] . name , ( _macCdFileList [ i ] . flags & FLAG_CD2 ) ? 2 : 1 ) ;
2022-10-23 15:27:58 +02:00
pos + = Common : : sprintf_s ( pos , sizeof ( msg ) - ( pos - msg ) ,
" \" %s \" (CD %d) \n " , _macCdFileList [ i ] . name , ( _macCdFileList [ i ] . flags & FLAG_CD2 ) ? 2 : 1 ) ;
2006-11-12 19:05:51 +00:00
}
2004-07-11 04:41:48 +00:00
}
2009-02-28 10:46:33 +00:00
} else if ( SwordEngine : : isPsx ( ) ) {
for ( int i = 0 ; i < ARRAYSIZE ( _psxCdFileList ) ; i + + )
if ( ! fileExists [ i ] ) {
missCnt + + ;
missNum = i ;
}
assert ( missCnt > 0 ) ; // this function shouldn't get called if there's nothing missing.
warning ( " %d files missing " , missCnt ) ;
int msgId = ( type = = TYPE_IMMED ) ? 0 : 2 ;
if ( missCnt = = 1 ) {
2022-10-23 15:27:58 +02:00
Common : : sprintf_s ( msg , errorMsgs [ msgId ] , _psxCdFileList [ missNum ] . name , 1 ) ;
2009-02-28 10:46:33 +00:00
warning ( " %s " , msg ) ;
} else {
2022-10-23 15:27:58 +02:00
char * pos = msg + Common : : sprintf_s ( msg , errorMsgs [ msgId + 1 ] , missCnt ) ;
2009-02-28 10:46:33 +00:00
warning ( " %s " , msg ) ;
for ( int i = 0 ; i < ARRAYSIZE ( _psxCdFileList ) ; i + + )
if ( ! fileExists [ i ] ) {
warning ( " \" %s \" " , _macCdFileList [ i ] . name ) ;
2022-10-23 15:27:58 +02:00
pos + = Common : : sprintf_s ( pos , sizeof ( msg ) - ( pos - msg ) ,
" \" %s \" \n " , _macCdFileList [ i ] . name ) ;
2009-02-28 10:46:33 +00:00
}
2009-05-24 15:17:42 +00:00
}
2004-12-10 17:55:03 +00:00
} else {
2006-11-12 19:05:51 +00:00
for ( int i = 0 ; i < ARRAYSIZE ( _pcCdFileList ) ; i + + )
2004-12-10 17:55:03 +00:00
if ( ! fileExists [ i ] ) {
2006-11-12 19:05:51 +00:00
missCnt + + ;
missNum = i ;
2004-12-10 17:55:03 +00:00
}
2006-11-12 19:05:51 +00:00
assert ( missCnt > 0 ) ; // this function shouldn't get called if there's nothing missing.
warning ( " %d files missing " , missCnt ) ;
int msgId = ( type = = TYPE_IMMED ) ? 0 : 2 ;
if ( missCnt = = 1 ) {
2022-10-23 15:27:58 +02:00
Common : : sprintf_s ( msg , errorMsgs [ msgId ] ,
2011-09-07 23:54:34 +02:00
_pcCdFileList [ missNum ] . name , ( _pcCdFileList [ missNum ] . flags & FLAG_CD2 ) ? 2 : 1 ) ;
2008-11-16 20:20:31 +00:00
warning ( " %s " , msg ) ;
2006-11-12 19:05:51 +00:00
} else {
2022-10-23 15:27:58 +02:00
char * pos = msg + Common : : sprintf_s ( msg , errorMsgs [ msgId + 1 ] , missCnt ) ;
2008-11-16 20:20:31 +00:00
warning ( " %s " , msg ) ;
2006-11-12 19:05:51 +00:00
for ( int i = 0 ; i < ARRAYSIZE ( _pcCdFileList ) ; i + + )
if ( ! fileExists [ i ] ) {
warning ( " \" %s \" (CD %d) " , _pcCdFileList [ i ] . name , ( _pcCdFileList [ i ] . flags & FLAG_CD2 ) ? 2 : 1 ) ;
2022-10-23 15:27:58 +02:00
pos + = Common : : sprintf_s ( pos , sizeof ( msg ) - ( pos - msg ) ,
" \" %s \" (CD %d) \n " , _pcCdFileList [ i ] . name , ( _pcCdFileList [ i ] . flags & FLAG_CD2 ) ? 2 : 1 ) ;
2006-11-12 19:05:51 +00:00
}
}
2004-10-14 06:36:05 +00:00
}
2004-12-10 17:55:03 +00:00
GUI : : MessageDialog dialog ( msg ) ;
dialog . runModal ( ) ;
if ( type = = TYPE_IMMED ) // we can't start without this file, so error() out.
2008-11-16 20:20:31 +00:00
error ( " %s " , msg ) ;
2004-12-10 17:55:03 +00:00
}
2004-10-14 06:36:05 +00:00
2009-11-02 21:54:57 +00:00
void SwordEngine : : checkCdFiles ( ) { // check if we're running from cd, hdd or what...
2004-12-10 17:55:03 +00:00
bool fileExists [ 30 ] ;
bool isFullVersion = false ; // default to demo version
2023-01-14 23:54:24 +01:00
bool missingTypes [ 8 ] = { false , false , false , false , false , false , false , false } ;
bool foundTypes [ 8 ] = { false , false , false , false , false , false , false , false } ;
2004-12-10 17:55:03 +00:00
bool cd2FilesFound = false ;
_systemVars . runningFromCd = false ;
_systemVars . playSpeech = true ;
// check all files and look out if we can find a file that wouldn't exist if this was the demo version
2009-02-28 10:46:33 +00:00
if ( SwordEngine : : isMac ( ) ) {
2006-11-12 19:05:51 +00:00
for ( int fcnt = 0 ; fcnt < ARRAYSIZE ( _macCdFileList ) ; fcnt + + ) {
if ( Common : : File : : exists ( _macCdFileList [ fcnt ] . name ) ) {
fileExists [ fcnt ] = true ;
flagsToBool ( foundTypes , _macCdFileList [ fcnt ] . flags ) ;
if ( ! ( _macCdFileList [ fcnt ] . flags & FLAG_DEMO ) )
isFullVersion = true ;
if ( _macCdFileList [ fcnt ] . flags & FLAG_CD2 )
cd2FilesFound = true ;
} else {
flagsToBool ( missingTypes , _macCdFileList [ fcnt ] . flags ) ;
fileExists [ fcnt ] = false ;
}
}
2009-02-28 10:46:33 +00:00
} else if ( SwordEngine : : isPsx ( ) ) {
for ( int fcnt = 0 ; fcnt < ARRAYSIZE ( _psxCdFileList ) ; fcnt + + ) {
if ( Common : : File : : exists ( _psxCdFileList [ fcnt ] . name ) ) {
fileExists [ fcnt ] = true ;
flagsToBool ( foundTypes , _psxCdFileList [ fcnt ] . flags ) ;
2011-09-07 23:54:34 +02:00
if ( ! ( _psxCdFileList [ fcnt ] . flags & FLAG_DEMO ) )
2009-06-08 12:37:24 +00:00
isFullVersion = true ;
2011-09-07 23:54:34 +02:00
cd2FilesFound = true ;
2009-02-28 10:46:33 +00:00
} else {
flagsToBool ( missingTypes , _psxCdFileList [ fcnt ] . flags ) ;
fileExists [ fcnt ] = false ;
}
}
2006-11-12 19:05:51 +00:00
} else {
for ( int fcnt = 0 ; fcnt < ARRAYSIZE ( _pcCdFileList ) ; fcnt + + ) {
if ( Common : : File : : exists ( _pcCdFileList [ fcnt ] . name ) ) {
fileExists [ fcnt ] = true ;
flagsToBool ( foundTypes , _pcCdFileList [ fcnt ] . flags ) ;
if ( ! ( _pcCdFileList [ fcnt ] . flags & FLAG_DEMO ) )
isFullVersion = true ;
if ( _pcCdFileList [ fcnt ] . flags & FLAG_CD2 )
cd2FilesFound = true ;
} else {
flagsToBool ( missingTypes , _pcCdFileList [ fcnt ] . flags ) ;
fileExists [ fcnt ] = false ;
}
2004-07-11 04:41:48 +00:00
}
2003-12-30 22:57:52 +00:00
}
2004-12-05 02:55:06 +00:00
2023-01-14 21:09:40 +01:00
if ( ( ( _features & ADGF_DEMO ) = = 0 ) ! = isFullVersion ) // shouldn't happen...
warning ( " Your Broken Sword 1 version looks like a %s version but you are starting it as a %s version " , isFullVersion ? " full " : " demo " , ( _features & ADGF_DEMO ) ? " demo " : " full " ) ;
2005-07-30 21:11:48 +00:00
2004-12-10 17:55:03 +00:00
if ( foundTypes [ TYPE_SPEECH1 ] ) // we found some kind of speech1 file (.clu, .cl3, .clv)
missingTypes [ TYPE_SPEECH1 ] = false ; // so we don't care if there's a different kind missing
if ( foundTypes [ TYPE_SPEECH2 ] ) // same for speech2
missingTypes [ TYPE_SPEECH2 ] = false ;
2011-09-07 23:54:34 +02:00
if ( isFullVersion ) // if this is the full version...
2004-12-10 17:55:03 +00:00
missingTypes [ TYPE_DEMO ] = false ; // then we don't need demo files...
2011-09-07 23:54:34 +02:00
else // and vice versa
2004-12-10 17:55:03 +00:00
missingTypes [ TYPE_SPEECH1 ] = missingTypes [ TYPE_SPEECH2 ] = missingTypes [ TYPE_CD1 ] = missingTypes [ TYPE_CD2 ] = false ;
bool somethingMissing = false ;
for ( int i = 0 ; i < 8 ; i + + )
somethingMissing | = missingTypes [ i ] ;
if ( somethingMissing ) { // okay, there *are* files missing
// first, update the fileExists[] array depending on our changed missingTypes
2009-02-28 10:46:33 +00:00
if ( SwordEngine : : isMac ( ) ) {
2006-11-12 19:05:51 +00:00
for ( int fileCnt = 0 ; fileCnt < ARRAYSIZE ( _macCdFileList ) ; fileCnt + + )
if ( ! fileExists [ fileCnt ] ) {
fileExists [ fileCnt ] = true ;
for ( int flagCnt = 0 ; flagCnt < 8 ; flagCnt + + )
if ( missingTypes [ flagCnt ] & & ( ( _macCdFileList [ fileCnt ] . flags & ( 1 < < flagCnt ) ) ! = 0 ) )
fileExists [ fileCnt ] = false ; // this is one of the files we were looking for
}
2009-02-28 10:46:33 +00:00
} else if ( SwordEngine : : isPsx ( ) ) {
for ( int fileCnt = 0 ; fileCnt < ARRAYSIZE ( _psxCdFileList ) ; fileCnt + + )
if ( ! fileExists [ fileCnt ] ) {
fileExists [ fileCnt ] = true ;
for ( int flagCnt = 0 ; flagCnt < 8 ; flagCnt + + )
if ( missingTypes [ flagCnt ] & & ( ( _psxCdFileList [ fileCnt ] . flags & ( 1 < < flagCnt ) ) ! = 0 ) )
fileExists [ fileCnt ] = false ; // this is one of the files we were looking for
}
2006-11-12 19:05:51 +00:00
} else {
for ( int fileCnt = 0 ; fileCnt < ARRAYSIZE ( _pcCdFileList ) ; fileCnt + + )
if ( ! fileExists [ fileCnt ] ) {
fileExists [ fileCnt ] = true ;
for ( int flagCnt = 0 ; flagCnt < 8 ; flagCnt + + )
if ( missingTypes [ flagCnt ] & & ( ( _pcCdFileList [ fileCnt ] . flags & ( 1 < < flagCnt ) ) ! = 0 ) )
fileExists [ fileCnt ] = false ; // this is one of the files we were looking for
}
}
2005-07-30 21:11:48 +00:00
if ( missingTypes [ TYPE_IMMED ] ) {
2004-12-10 17:55:03 +00:00
// important files missing, can't start the game without them
showFileErrorMsg ( TYPE_IMMED , fileExists ) ;
} else if ( ( ! missingTypes [ TYPE_CD1 ] ) & & ! cd2FilesFound ) {
/* we have all the data from cd one, but not a single one from CD2.
2011-09-07 23:54:34 +02:00
I ' m not sure how we should handle this , for now I ' ll just assume that the
user has set up the extrapath correctly and copied the necessary files to HDD .
A quite optimistic assumption , I ' d say . Maybe we should change this for the release
to warn the user ? */
2004-12-10 17:55:03 +00:00
warning ( " CD2 data files not found. I hope you know what you're doing and that \n "
2011-09-07 23:54:34 +02:00
" you have set up the extrapath and additional data correctly. \n "
" If you didn't, you should better read the ScummVM readme file " ) ;
2004-12-10 17:55:03 +00:00
_systemVars . runningFromCd = true ;
_systemVars . playSpeech = true ;
} else if ( missingTypes [ TYPE_CD1 ] | | missingTypes [ TYPE_CD2 ] ) {
// several files from CD1 both CDs are missing. we can probably start, but it'll crash sooner or later
showFileErrorMsg ( TYPE_CD1 , fileExists ) ;
} else if ( missingTypes [ TYPE_SPEECH1 ] | | missingTypes [ TYPE_SPEECH2 ] ) {
// not so important, but there won't be any voices
if ( missingTypes [ TYPE_SPEECH1 ] & & missingTypes [ TYPE_SPEECH2 ] )
warning ( " Unable to find the speech files. The game will work, but you won't hear any voice output. \n "
2011-09-07 23:54:34 +02:00
" Please copy the SPEECH.CLU files from both CDs and rename them to SPEECH1.CLU and SPEECH2.CLU, \n "
" corresponding to the CD number. \n "
" Please read the ScummVM Readme file for more information " ) ;
2004-12-10 17:55:03 +00:00
else
warning ( " Unable to find the speech file from CD %d. \n "
2011-09-07 23:54:34 +02:00
" You won't hear any voice output in that part of the game. \n "
" Please read the ScummVM Readme file for more information " , missingTypes [ TYPE_SPEECH1 ] ? 1 : 2 ) ;
2004-12-10 17:55:03 +00:00
} else if ( missingTypes [ TYPE_DEMO ] ) {
// for the demo version, we simply expect to have all files immediately
showFileErrorMsg ( TYPE_IMMED , fileExists ) ;
}
} // everything's fine, let's play.
/*if (!isFullVersion)
_systemVars . isDemo = true ;
*/
// make the demo flag depend on the Gamesettings for now, and not on what the datafiles look like
2023-01-14 21:09:40 +01:00
_systemVars . isDemo = ( _features & ADGF_DEMO ) ! = 0 ;
2020-09-01 16:53:27 +02:00
// Spanish demo has proper speech.clu and uses normal sound and var mapping
2023-01-14 23:54:24 +01:00
_systemVars . isSpanishDemo = ( _systemVars . isDemo & & Common : : parseLanguage ( ConfMan . get ( " language " ) ) = = Common : : ES_ESP ) ! = 0 ;
2003-12-30 22:57:52 +00:00
}
2008-11-06 17:05:54 +00:00
Common : : Error SwordEngine : : go ( ) {
2008-11-18 16:31:55 +00:00
_control - > checkForOldSaveGames ( ) ;
2010-10-29 16:53:46 +00:00
setTotalPlayTime ( 0 ) ;
2008-11-18 16:31:55 +00:00
2023-08-19 09:07:09 +02:00
_screen - > initFadePaletteServer ( ) ;
2023-08-18 13:32:53 +02:00
installTimerRoutines ( ) ;
2023-09-13 01:13:04 +02:00
bool startedFromGMM = false ;
2004-12-08 04:38:39 +00:00
uint16 startPos = ConfMan . getInt ( " boot_param " ) ;
2023-09-13 01:13:04 +02:00
2006-04-18 18:23:57 +00:00
if ( startPos ) {
2004-12-08 04:38:39 +00:00
_logic - > startPositions ( startPos ) ;
2006-04-18 18:23:57 +00:00
} else {
int saveSlot = ConfMan . getInt ( " save_slot " ) ;
2006-04-21 10:24:22 +00:00
// Savegames are numbered starting from 1 in the dialog window,
// but their filenames are numbered starting from 0.
2008-08-15 21:25:24 +00:00
if ( saveSlot > = 0 & & _control - > savegamesExist ( ) & & _control - > restoreGameFromFile ( saveSlot ) ) {
2006-04-18 18:23:57 +00:00
_control - > doRestore ( ) ;
2023-09-13 01:13:04 +02:00
startedFromGMM = true ;
_systemVars . controlPanelMode = CP_NORMAL ;
2006-04-18 18:23:57 +00:00
} else if ( _control - > savegamesExist ( ) ) {
2023-09-13 01:13:04 +02:00
_systemVars . snrStatus = SNR_MAINPANEL ;
2004-11-09 04:06:10 +00:00
_systemVars . controlPanelMode = CP_NEWGAME ;
2023-09-13 01:13:04 +02:00
_control - > getPlayerOptions ( ) ;
// If player clicked on "Start" (Restart)
// just ignore it - so game can start from 'startPos'
// (which will be '0' for normal game anyway)
if ( _systemVars . saveGameFlag = = SGF_RESTART )
_systemVars . saveGameFlag = SGF_DONE ;
2006-04-18 18:23:57 +00:00
}
2003-12-20 09:12:54 +00:00
}
2008-09-30 12:27:38 +00:00
while ( ! shouldQuit ( ) ) {
2023-09-13 01:13:04 +02:00
if ( _systemVars . saveGameFlag = = SGF_RESTORE ) {
debug ( 1 , " SwordEngine::go(): Restoring game " ) ;
if ( ! _control - > restoreGame ( ) )
warning ( " SwordEngine::go(): Couldn't restore game " ) ;
} else if ( _systemVars . saveGameFlag = = SGF_RESTART ) {
debug ( 1 , " SwordEngine::go(): Restarting game " ) ;
startPos = 0 ;
_logic - > startPositions ( startPos ) ;
} else if ( ! startedFromGMM ) { // START GAME
_logic - > startPositions ( startPos ) ;
startPos = 0 ;
}
mainLoop ( ) ;
2003-12-22 01:20:47 +00:00
2008-09-30 12:27:38 +00:00
if ( ! shouldQuit ( ) ) {
2004-11-09 04:06:10 +00:00
// the mainloop was left, we have to reinitialize.
reinitialize ( ) ;
}
}
2005-07-30 21:11:48 +00:00
2023-08-18 13:32:53 +02:00
uninstallTimerRoutines ( ) ;
2008-11-06 17:05:54 +00:00
return Common : : kNoError ;
2003-12-16 02:10:15 +00:00
}
2023-09-24 21:18:36 +02:00
void SwordEngine : : showDebugInfo ( ) {
Object * playerCompact = _objectMan - > fetchObject ( PLAYER ) ;
// Screen coordinates for game cycle string
int32 gameCycleX = Logic : : _scriptVars [ SCROLL_OFFSET_X ] + 130 ;
int32 gameCycleY = Logic : : _scriptVars [ SCROLL_OFFSET_Y ] + 125 ;
// Screen coordinates for mouse coordinates string
int32 mouseCoordsX = Logic : : _scriptVars [ SCROLL_OFFSET_X ] + 220 ;
int32 mouseCoordsY = Logic : : _scriptVars [ SCROLL_OFFSET_Y ] + 125 ;
// Screen coordinates for special item string
int32 specialItemX = Logic : : _scriptVars [ SCROLL_OFFSET_X ] + 350 ;
int32 specialItemY = Logic : : _scriptVars [ SCROLL_OFFSET_Y ] + 125 ;
// Screen coordinates for player coordinates string
int32 playerCoordsX = Logic : : _scriptVars [ SCROLL_OFFSET_X ] + 475 ;
int32 playerCoordsY = Logic : : _scriptVars [ SCROLL_OFFSET_Y ] + 125 ;
// Screen coordinates for Paris flag string
int32 parisFlagX = Logic : : _scriptVars [ SCROLL_OFFSET_X ] + 590 ;
int32 parisFlagY = Logic : : _scriptVars [ SCROLL_OFFSET_Y ] + 125 ;
// Screen coordinates for player's script level string
int32 scriptLevelX = Logic : : _scriptVars [ SCROLL_OFFSET_X ] + 660 ;
int32 scriptLevelY = Logic : : _scriptVars [ SCROLL_OFFSET_Y ] + 125 ;
// Screen coordinates for the talk flag string
int32 talkFlagX = Logic : : _scriptVars [ SCROLL_OFFSET_X ] + 720 ;
int32 talkFlagY = Logic : : _scriptVars [ SCROLL_OFFSET_Y ] + 125 ;
// Screen coordinates for FPS counter string
int32 fpsX = Logic : : _scriptVars [ SCROLL_OFFSET_X ] + 130 ;
int32 fpsY = Logic : : _scriptVars [ SCROLL_OFFSET_Y ] + 145 ;
// Screen coordinates for game speed string
int32 gameSpeedX = Logic : : _scriptVars [ SCROLL_OFFSET_X ] + 220 ;
int32 gameSpeedY = Logic : : _scriptVars [ SCROLL_OFFSET_Y ] + 145 ;
// Screen coordinates for screen number string
int32 screenX = Logic : : _scriptVars [ SCROLL_OFFSET_X ] + 350 ;
int32 screenY = Logic : : _scriptVars [ SCROLL_OFFSET_Y ] + 145 ;
// Screen coordinates for current CD string
int32 currentCDX = Logic : : _scriptVars [ SCROLL_OFFSET_X ] + 475 ;
int32 currentCDY = Logic : : _scriptVars [ SCROLL_OFFSET_Y ] + 145 ;
// Screen coordinates for the end sequence phase string
int32 endSceneX = Logic : : _scriptVars [ SCROLL_OFFSET_X ] + 590 ;
int32 endSceneY = Logic : : _scriptVars [ SCROLL_OFFSET_Y ] + 145 ;
// Screen coordinates for the current text line number string
int32 textNoX = Logic : : _scriptVars [ SCROLL_OFFSET_X ] + 130 ;
int32 textNoY = Logic : : _scriptVars [ SCROLL_OFFSET_Y ] + 165 ;
// Screen coordinates for debug flags string
int32 debugFlagsX = Logic : : _scriptVars [ SCROLL_OFFSET_X ] + 130 ;
int32 debugFlagsY = Logic : : _scriptVars [ SCROLL_OFFSET_Y ] + 185 ;
// Screen coordinates for the paused message string
int32 pausedX = Logic : : _scriptVars [ SCROLL_OFFSET_X ] + 400 ;
int32 pausedY = Logic : : _scriptVars [ SCROLL_OFFSET_Y ] + 315 ;
2023-10-17 00:26:46 +02:00
if ( SwordEngine : : isPsx ( ) ) {
pausedX + = 20 ;
pausedY - = 16 ;
}
2023-09-24 21:18:36 +02:00
uint8 buf [ 255 ] ;
if ( _systemVars . gamePaused ) {
Common : : sprintf_s ( buf , " %s " , _control - > getPauseString ( ) ) ;
_screen - > printDebugLine ( buf , ' ' , pausedX , pausedY ) ;
}
if ( ( _systemVars . displayDebugText ) & & ( ! _systemVars . isDemo ) ) {
// Game cycle
Common : : sprintf_s ( buf , " %d " , _systemVars . gameCycle ) ;
_screen - > printDebugLine ( buf , ' ' , gameCycleX , gameCycleY ) ;
// Mouse coordinates
Common : : sprintf_s ( buf , " m %d,%d " , Logic : : _scriptVars [ MOUSE_X ] , Logic : : _scriptVars [ MOUSE_Y ] ) ;
_screen - > printDebugLine ( buf , ' ' , mouseCoordsX , mouseCoordsY ) ;
// Special item
Common : : sprintf_s ( buf , " id %d " , Logic : : _scriptVars [ SPECIAL_ITEM ] ) ;
_screen - > printDebugLine ( buf , ' ' , specialItemX , specialItemY ) ;
// Player coordinates
Common : : sprintf_s ( buf , " G %d,%d " , playerCompact - > o_xcoord , playerCompact - > o_ycoord ) ;
_screen - > printDebugLine ( buf , ' ' , playerCoordsX , playerCoordsY ) ;
// Paris status flag
Common : : sprintf_s ( buf , " pf %d " , Logic : : _scriptVars [ PARIS_FLAG ] ) ;
_screen - > printDebugLine ( buf , ' ' , parisFlagX , parisFlagY ) ;
// Player script level
Common : : sprintf_s ( buf , " lv %d " , playerCompact - > o_tree . o_script_level ) ;
_screen - > printDebugLine ( buf , ' ' , scriptLevelX , scriptLevelY ) ;
// Talk flag
Common : : sprintf_s ( buf , " tf %d " , Logic : : _scriptVars [ TALK_FLAG ] ) ;
_screen - > printDebugLine ( buf , ' ' , talkFlagX , talkFlagY ) ;
// Frames per second
Common : : sprintf_s ( buf , " %u fps " , _systemVars . framesPerSecondCounter ) ;
_screen - > printDebugLine ( buf , ' ' , fpsX , fpsY ) ;
// Debug game speed (based on pressing keys '1' & '4')
if ( _systemVars . slowMode ) {
Common : : sprintf_s ( buf , " (slow) " ) ;
} else if ( _systemVars . fastMode ) {
Common : : sprintf_s ( buf , " (fast) " ) ;
} else {
Common : : sprintf_s ( buf , " (norm) " ) ;
}
_screen - > printDebugLine ( buf , ' ' , gameSpeedX , gameSpeedY ) ;
// Screen number
Common : : sprintf_s ( buf , " screen %d " , Logic : : _scriptVars [ SCREEN ] ) ;
_screen - > printDebugLine ( buf , ' ' , screenX , screenY ) ;
// CD in use
Common : : sprintf_s ( buf , " CD-%d " , _systemVars . currentCD ) ;
_screen - > printDebugLine ( buf , ' ' , currentCDX , currentCDY ) ;
// End sequence scene number
if ( Logic : : _scriptVars [ END_SCENE ] ) {
Common : : sprintf_s ( buf , " scene %d " , Logic : : _scriptVars [ END_SCENE ] ) ;
_screen - > printDebugLine ( buf , ' ' , endSceneX , endSceneY ) ;
}
// Debug flags
if ( ( Logic : : _scriptVars [ DEBUG_FLAG_1 ] > 0 ) | | ( Logic : : _scriptVars [ DEBUG_FLAG_2 ] > 0 ) | | ( Logic : : _scriptVars [ DEBUG_FLAG_3 ] > 0 ) ) {
Common : : sprintf_s ( buf , " debug flags: %d, %d, %d " ,
Logic : : _scriptVars [ DEBUG_FLAG_1 ] ,
Logic : : _scriptVars [ DEBUG_FLAG_2 ] ,
Logic : : _scriptVars [ DEBUG_FLAG_3 ] ) ;
_screen - > printDebugLine ( buf , ' ' , debugFlagsX , debugFlagsY ) ;
}
}
if ( _systemVars . displayDebugText ) {
// Text line number
if ( _logic - > canShowDebugTextNumber ( ) ) {
Common : : sprintf_s ( buf , " TEXT %d " , _systemVars . textNumber ) ;
_screen - > printDebugLine ( buf , ' ' , textNoX , textNoY ) ;
}
}
if ( _systemVars . displayDebugGrid ) {
_logic - > plotRouteGrid ( playerCompact ) ;
2023-09-24 21:25:49 +02:00
_screen - > fullRefresh ( true ) ;
2023-09-24 21:18:36 +02:00
}
if ( _systemVars . displayDebugMouse ) {
// Draw a cross shaped cursor under the mouse cursor
_screen - > plotPoint ( Logic : : _scriptVars [ MOUSE_X ] - 128 , Logic : : _scriptVars [ MOUSE_Y ] - 128 , 255 ) ;
_screen - > plotPoint ( Logic : : _scriptVars [ MOUSE_X ] - 130 , Logic : : _scriptVars [ MOUSE_Y ] - 128 , 255 ) ;
_screen - > plotPoint ( Logic : : _scriptVars [ MOUSE_X ] - 128 , Logic : : _scriptVars [ MOUSE_Y ] - 130 , 255 ) ;
_screen - > plotPoint ( Logic : : _scriptVars [ MOUSE_X ] - 128 , Logic : : _scriptVars [ MOUSE_Y ] - 126 , 255 ) ;
_screen - > plotPoint ( Logic : : _scriptVars [ MOUSE_X ] - 126 , Logic : : _scriptVars [ MOUSE_Y ] - 128 , 255 ) ;
// Draw a cross shaped cursor on the player coordinates
_screen - > plotPoint ( playerCompact - > o_xcoord - 128 , playerCompact - > o_ycoord - 128 , 255 ) ;
_screen - > plotPoint ( playerCompact - > o_xcoord - 130 , playerCompact - > o_ycoord - 128 , 255 ) ;
_screen - > plotPoint ( playerCompact - > o_xcoord - 128 , playerCompact - > o_ycoord - 130 , 255 ) ;
_screen - > plotPoint ( playerCompact - > o_xcoord - 128 , playerCompact - > o_ycoord - 126 , 255 ) ;
_screen - > plotPoint ( playerCompact - > o_xcoord - 126 , playerCompact - > o_ycoord - 128 , 255 ) ;
2023-09-24 21:25:49 +02:00
_screen - > fullRefresh ( true ) ;
2023-09-24 21:18:36 +02:00
}
}
2023-09-28 11:02:04 +02:00
void SwordEngine : : setMenuToTargetState ( ) {
_menu - > setToTargetState ( ) ;
}
2009-11-02 21:54:57 +00:00
void SwordEngine : : checkCd ( ) {
2004-01-11 15:47:41 +00:00
uint8 needCd = _cdList [ Logic : : _scriptVars [ NEW_SCREEN ] ] ;
2004-01-06 12:19:02 +00:00
if ( _systemVars . runningFromCd ) { // are we running from cd?
if ( needCd = = 0 ) { // needCd == 0 means we can use either CD1 or CD2.
if ( _systemVars . currentCD = = 0 ) {
_systemVars . currentCD = 1 ; // if there is no CD currently inserted, ask for CD1.
2023-09-13 01:13:04 +02:00
askForCd ( ) ;
2004-01-06 12:19:02 +00:00
} // else: there is already a cd inserted and we don't care if it's cd1 or cd2.
} else if ( needCd ! = _systemVars . currentCD ) { // we need a different CD than the one in drive.
_sound - > closeCowSystem ( ) ; // close music and sound files before changing CDs
_systemVars . currentCD = needCd ; // askForCd will ask the player to insert _systemVars.currentCd,
2023-09-13 01:13:04 +02:00
askForCd ( ) ; // so it has to be updated before calling it.
2003-12-30 22:57:52 +00:00
}
2011-09-07 23:54:34 +02:00
} else { // we're running from HDD, we don't have to care about music files and Sound will take care of
2004-01-11 15:47:41 +00:00
if ( needCd ) // switching sound.clu files on Sound::newScreen by itself, so there's nothing to be done.
2004-01-06 12:19:02 +00:00
_systemVars . currentCD = needCd ;
else if ( _systemVars . currentCD = = 0 )
_systemVars . currentCD = 1 ;
}
2003-12-20 20:20:53 +00:00
}
2023-09-13 01:13:04 +02:00
void SwordEngine : : askForCd ( ) {
char buf [ 255 ] ;
_control - > askForCdMessage ( SwordEngine : : _systemVars . currentCD , false ) ;
_screen - > fnSetFadeTargetPalette ( 0 , 1 , 0 , BORDER_BLACK ) ; // Set colour 0 to black - for screen borders
_screen - > fnSetFadeTargetPalette ( 193 , 1 , 0 , TEXT_WHITE ) ; // Set colours 193 to white - for letters
while ( ! shouldQuit ( ) ) {
_screen - > startFadePaletteUp ( 1 ) ;
uint32 startTime = _system - > getMillis ( ) ;
while ( _screen - > stillFading ( ) ) {
if ( _vblCount > = _rate )
_vblCount = 0 ;
pollInput ( 0 ) ;
// In the remote event that this wait cycle gets
// stuck during debugging, trigger a timeout
if ( _system - > getMillis ( ) - startTime > 1000 )
break ;
}
while ( _keyPressed . keycode = = Common : : KEYCODE_INVALID & & ! shouldQuit ( ) ) {
pollInput ( 0 ) ;
}
2023-10-03 13:27:44 +02:00
startFadePaletteDown ( 1 ) ;
2023-09-13 01:13:04 +02:00
startTime = _system - > getMillis ( ) ;
while ( _screen - > stillFading ( ) ) {
if ( _vblCount > = _rate )
_vblCount = 0 ;
pollInput ( 0 ) ;
// In the remote event that this wait cycle gets
// stuck during debugging, trigger a timeout
if ( _system - > getMillis ( ) - startTime > 1000 )
break ;
}
startTime = _system - > getMillis ( ) ;
while ( _system - > getMillis ( ) - startTime < 500 ) {
pollInput ( 0 ) ;
} ;
_keyPressed . reset ( ) ;
// At this point the original code sets colors 1 to 180 to grey;
// the only visible effect of this is that the screen flashes when
// loading a save state. It's not clear what the original wanted to do.
// for (int i = 1; i < 180; i++) {
// SetPalette(i, 1, _grey);
// }
Common : : sprintf_s ( buf , " cd%d.id " , SwordEngine : : _systemVars . currentCD ) ;
if ( Common : : File : : exists ( buf ) )
break ;
_control - > askForCdMessage ( SwordEngine : : _systemVars . currentCD , true ) ;
}
}
2009-11-02 21:54:57 +00:00
uint8 SwordEngine : : mainLoop ( ) {
2007-06-22 22:19:17 +00:00
_keyPressed . reset ( ) ;
2023-09-23 13:21:27 +02:00
_systemVars . gameCycle = 1 ;
2003-12-22 01:20:47 +00:00
2023-09-13 01:13:04 +02:00
do {
if ( shouldQuit ( ) )
break ;
2023-10-01 09:33:33 +02:00
if ( Logic : : _scriptVars [ NEW_SCREEN ] > 50 )
_objectMan - > mainLoopPatch ( ) ;
2003-12-20 20:20:53 +00:00
checkCd ( ) ;
2004-01-11 15:47:41 +00:00
_screen - > newScreen ( Logic : : _scriptVars [ NEW_SCREEN ] ) ;
_logic - > newScreen ( Logic : : _scriptVars [ NEW_SCREEN ] ) ;
_sound - > newScreen ( Logic : : _scriptVars [ NEW_SCREEN ] ) ;
Logic : : _scriptVars [ SCREEN ] = Logic : : _scriptVars [ NEW_SCREEN ] ;
2005-07-30 21:11:48 +00:00
2003-12-16 02:10:15 +00:00
do {
2004-01-07 19:08:59 +00:00
uint32 newTime ;
2023-08-18 13:32:53 +02:00
uint32 frameTime = _system - > getMillis ( ) ;
2004-01-07 19:08:59 +00:00
bool scrollFrameShown = false ;
2023-09-13 01:13:04 +02:00
_systemVars . saveGameFlag = SGF_DONE ;
2023-09-23 13:21:27 +02:00
_systemVars . gameCycle + + ;
2003-12-16 02:10:15 +00:00
_logic - > engine ( ) ;
2023-10-04 12:47:03 +02:00
_sound - > setCrossFadeIncrement ( ) ;
2003-12-16 02:10:15 +00:00
_logic - > updateScreenParams ( ) ; // sets scrolling
2003-12-21 17:34:44 +00:00
_screen - > draw ( ) ;
2023-09-24 21:18:36 +02:00
showDebugInfo ( ) ;
2003-12-16 02:10:15 +00:00
_mouse - > animate ( ) ;
2023-08-18 13:32:53 +02:00
if ( ! Logic : : _scriptVars [ NEW_PALETTE ] ) {
newTime = _system - > getMillis ( ) ;
2023-08-19 18:20:54 +02:00
if ( ( int32 ) ( newTime - frameTime ) < _targetFrameTime / 2 ) {
2023-08-18 13:32:53 +02:00
scrollFrameShown = _screen - > showScrollFrame ( ) ;
2023-08-19 18:20:54 +02:00
pollInput ( ( _targetFrameTime / 2 ) - ( _system - > getMillis ( ) - frameTime ) ) ;
2023-08-18 13:32:53 +02:00
}
2023-09-23 13:21:27 +02:00
_mainLoopFrameCount + + ;
2004-01-07 19:08:59 +00:00
}
2003-12-22 23:21:28 +00:00
2023-08-18 13:32:53 +02:00
_sound - > engine ( ) ;
2004-09-28 20:19:37 +00:00
newTime = _system - > getMillis ( ) ;
2023-08-19 18:20:54 +02:00
if ( ( ( int32 ) ( newTime - frameTime ) < _targetFrameTime ) | | ( ! scrollFrameShown ) )
2004-01-07 19:08:59 +00:00
_screen - > updateScreen ( ) ;
2023-09-23 13:21:27 +02:00
_mainLoopFrameCount + + ;
2023-08-19 18:20:54 +02:00
pollInput ( ( _targetFrameTime ) - ( _system - > getMillis ( ) - frameTime ) ) ;
2023-08-18 13:32:53 +02:00
2023-08-19 09:07:09 +02:00
_vblCount = 0 ; // Reset the vBlank counter for the other timers...
2003-12-16 02:10:15 +00:00
2023-09-23 13:21:27 +02:00
// Calculation for the frames per second counter for the debug text
if ( _ticker > 5000 )
_ticker = 0 ;
if ( _ticker > 1000 ) {
_systemVars . framesPerSecondCounter = _mainLoopFrameCount ;
_mainLoopFrameCount = 0 ;
_ticker - = 1000 ;
}
2007-11-28 15:00:41 +00:00
_mouse - > engine ( _mouseCoord . x , _mouseCoord . y , _mouseState ) ;
2003-12-22 01:20:47 +00:00
2023-09-13 01:13:04 +02:00
checkKeys ( ) ;
if ( _systemVars . saveGameFlag = = SGF_SAVE ) {
_control - > getPlayerOptions ( ) ;
debug ( 1 , " SwordEngine::mainLoop(): Returned to mainloop() from getPlayerOptions() " ) ;
}
2010-11-08 12:22:58 +00:00
2007-06-22 22:00:46 +00:00
_mouseState = 0 ;
2007-06-22 22:19:17 +00:00
_keyPressed . reset ( ) ;
2023-08-18 13:32:53 +02:00
2023-09-13 01:13:04 +02:00
} while ( ( Logic : : _scriptVars [ SCREEN ] = = Logic : : _scriptVars [ NEW_SCREEN ] ) & &
( _systemVars . saveGameFlag = = SGF_DONE | | _systemVars . saveGameFlag = = SGF_SAVE ) & &
( ! shouldQuit ( ) ) ) ;
2003-12-28 19:03:35 +00:00
2023-09-13 01:13:04 +02:00
if ( ( Logic : : _scriptVars [ SCREEN ] ! = 53 ) & & ! shouldQuit ( ) ) {
2023-10-03 13:27:44 +02:00
startFadePaletteDown ( 1 ) ;
2003-12-16 02:10:15 +00:00
}
2023-08-18 13:32:53 +02:00
_screen - > quitScreen ( ) ; // Close graphic resources
2023-08-19 09:07:09 +02:00
waitForFade ( ) ;
2023-08-18 13:32:53 +02:00
2023-10-02 17:03:11 +02:00
_sound - > clearAllFx ( ) ; // Purge the sound AFTER they've been faded
2023-08-18 13:32:53 +02:00
_objectMan - > closeSection ( Logic : : _scriptVars [ SCREEN ] ) ; // Close the section that PLAYER has just left, if it's empty now
2023-09-13 01:13:04 +02:00
} while ( ( _systemVars . saveGameFlag < SGF_RESTORE ) & & ( ! shouldQuit ( ) ) ) ;
return 0 ;
2003-12-16 02:10:15 +00:00
}
2023-08-19 09:07:09 +02:00
void SwordEngine : : waitForFade ( ) {
2023-08-20 19:09:41 +02:00
uint32 startTime = _system - > getMillis ( ) ;
2023-08-19 09:07:09 +02:00
while ( _screen - > stillFading ( ) ) { // This indirectly also waits for FX to be faded
if ( _vblCount > = _rate )
_vblCount = 0 ;
pollInput ( 0 ) ;
2023-08-20 19:09:41 +02:00
// In the remote event that this wait cycle gets
// stuck during debugging, trigger a timeout
if ( _system - > getMillis ( ) - startTime > 2000 )
break ;
2023-08-19 09:07:09 +02:00
}
}
2023-08-18 13:32:53 +02:00
void SwordEngine : : pollInput ( uint32 delay ) { //copied and mutilated from sky.cpp
2003-12-16 02:10:15 +00:00
2007-03-17 19:02:05 +00:00
Common : : Event event ;
2004-09-28 20:19:37 +00:00
uint32 start = _system - > getMillis ( ) ;
2003-12-16 02:10:15 +00:00
do {
2007-04-01 17:36:13 +00:00
while ( _eventMan - > pollEvent ( event ) ) {
2004-12-05 17:42:20 +00:00
switch ( event . type ) {
2007-03-17 19:02:05 +00:00
case Common : : EVENT_KEYDOWN :
2007-06-22 22:00:46 +00:00
_keyPressed = event . kbd ;
2003-12-16 02:10:15 +00:00
break ;
2007-03-17 19:02:05 +00:00
case Common : : EVENT_MOUSEMOVE :
2007-11-28 15:00:41 +00:00
_mouseCoord = event . mouse ;
2003-12-16 02:10:15 +00:00
break ;
2007-03-17 19:02:05 +00:00
case Common : : EVENT_LBUTTONDOWN :
2003-12-16 02:10:15 +00:00
_mouseState | = BS1L_BUTTON_DOWN ;
2007-11-28 15:00:41 +00:00
_mouseCoord = event . mouse ;
2003-12-16 02:10:15 +00:00
break ;
2007-03-17 19:02:05 +00:00
case Common : : EVENT_RBUTTONDOWN :
2003-12-16 02:10:15 +00:00
_mouseState | = BS1R_BUTTON_DOWN ;
2007-11-28 15:00:41 +00:00
_mouseCoord = event . mouse ;
2003-12-17 01:47:47 +00:00
break ;
2007-03-17 19:02:05 +00:00
case Common : : EVENT_LBUTTONUP :
2003-12-17 01:47:47 +00:00
_mouseState | = BS1L_BUTTON_UP ;
2007-11-28 15:00:41 +00:00
_mouseCoord = event . mouse ;
2003-12-17 01:47:47 +00:00
break ;
2007-03-17 19:02:05 +00:00
case Common : : EVENT_RBUTTONUP :
2003-12-17 01:47:47 +00:00
_mouseState | = BS1R_BUTTON_UP ;
2007-11-28 15:00:41 +00:00
_mouseCoord = event . mouse ;
2003-12-16 02:10:15 +00:00
break ;
default :
break ;
}
}
2005-10-12 19:41:57 +00:00
2023-10-04 22:51:30 +02:00
_sound - > updateMusicStreaming ( ) ;
2023-10-04 12:47:03 +02:00
2023-09-25 09:28:56 +02:00
_screen - > _screenAccessMutex . lock ( ) ;
2006-04-18 00:20:07 +00:00
_system - > updateScreen ( ) ;
2023-09-25 09:28:56 +02:00
_screen - > _screenAccessMutex . unlock ( ) ;
2006-04-18 00:20:07 +00:00
2023-08-18 13:32:53 +02:00
if ( delay > 0 )
2004-11-09 04:06:10 +00:00
_system - > delayMillis ( 10 ) ;
2005-10-12 19:41:57 +00:00
2023-08-18 13:32:53 +02:00
} while ( _system - > getMillis ( ) < start + delay ) ;
2003-12-16 02:10:15 +00:00
}
2004-01-11 15:47:41 +00:00
2008-11-18 16:31:55 +00:00
bool SwordEngine : : mouseIsActive ( ) {
return Logic : : _scriptVars [ MOUSE_STATUS ] & 1 ;
}
2009-03-03 20:05:00 +00:00
// The following function is needed to restore proper status after GMM load game
2009-11-02 21:54:57 +00:00
void SwordEngine : : reinitRes ( ) {
2009-03-03 21:33:45 +00:00
checkCd ( ) ; // Reset currentCD var to correct value
2009-03-03 20:05:00 +00:00
_screen - > newScreen ( Logic : : _scriptVars [ NEW_SCREEN ] ) ;
_logic - > newScreen ( Logic : : _scriptVars [ NEW_SCREEN ] ) ;
_sound - > newScreen ( Logic : : _scriptVars [ NEW_SCREEN ] ) ;
Logic : : _scriptVars [ SCREEN ] = Logic : : _scriptVars [ NEW_SCREEN ] ;
2014-09-13 18:40:30 +01:00
_logic - > engine ( ) ;
_logic - > updateScreenParams ( ) ;
2009-03-03 20:05:00 +00:00
_screen - > fullRefresh ( ) ;
_screen - > draw ( ) ;
}
2023-08-18 13:32:53 +02:00
void SwordEngine : : updateTopMenu ( ) {
_menu - > refresh ( MENU_TOP ) ;
}
void SwordEngine : : updateBottomMenu ( ) {
_menu - > refresh ( MENU_BOT ) ;
}
2023-08-19 09:07:09 +02:00
void SwordEngine : : fadePaletteStep ( ) {
_screen - > fadePalette ( ) ;
}
void SwordEngine : : startFadePaletteDown ( int speed ) {
_screen - > startFadePaletteDown ( speed ) ;
2023-10-03 18:56:07 +02:00
_sound - > fadeFxDown ( speed ) ;
2023-08-19 09:07:09 +02:00
}
void SwordEngine : : startFadePaletteUp ( int speed ) {
_screen - > startFadePaletteUp ( speed ) ;
2023-10-03 18:56:07 +02:00
_sound - > fadeFxUp ( speed ) ;
2023-08-19 09:07:09 +02:00
}
2023-08-18 13:32:53 +02:00
static void vblCallback ( void * refCon ) {
SwordEngine * vm = ( SwordEngine * ) refCon ;
2023-09-23 13:21:27 +02:00
vm - > _ticker + = 10 ;
2023-08-18 13:32:53 +02:00
vm - > _inTimer + + ;
if ( vm - > _inTimer = = 0 ) {
vm - > _vblCount + + ;
vm - > _vbl60HzUSecElapsed + = TIMER_USEC ;
2023-09-28 11:02:04 +02:00
if ( ! vm - > screenIsFading ( ) ) {
if ( ( vm - > _vblCount = = 1 ) | | ( vm - > _vblCount = = 5 ) ) {
vm - > updateTopMenu ( ) ;
}
2023-08-18 13:32:53 +02:00
2023-09-28 11:02:04 +02:00
if ( ( vm - > _vblCount = = 3 ) | | ( vm - > _vblCount = = 7 ) ) {
vm - > updateBottomMenu ( ) ;
}
2023-10-08 22:47:39 +02:00
} else if ( vm - > fadeDirectionIsUp ( ) ) {
2023-09-28 11:02:04 +02:00
// This is an optimization for all the locks introduced
// with the fade palette changes: we disable the menu
// updates whenever the palette is fading, and we bring
// the menu to its target state.
vm - > setMenuToTargetState ( ) ;
2023-08-18 13:32:53 +02:00
}
if ( vm - > _vbl60HzUSecElapsed > = PALETTE_FADE_USEC ) {
vm - > _vbl60HzUSecElapsed - = PALETTE_FADE_USEC ;
2023-08-19 09:07:09 +02:00
vm - > fadePaletteStep ( ) ;
2023-08-18 13:32:53 +02:00
}
}
vm - > _inTimer - - ;
}
2023-09-28 11:02:04 +02:00
bool SwordEngine : : screenIsFading ( ) {
return _screen - > stillFading ( ) ! = 0 ;
}
2023-10-08 22:47:39 +02:00
bool SwordEngine : : fadeDirectionIsUp ( ) {
return _screen - > stillFading ( ) = = 1 ;
}
2023-08-18 13:32:53 +02:00
void SwordEngine : : installTimerRoutines ( ) {
debug ( 2 , " SwordEngine::installTimerRoutines(): Installing timers... " ) ;
2023-09-23 13:21:27 +02:00
_ticker = 0 ;
2023-08-18 13:32:53 +02:00
getTimerManager ( ) - > installTimerProc ( & vblCallback , 1000000 / TIMER_RATE , this , " AILTimer " ) ;
2023-10-02 18:13:36 +02:00
_sound - > installFadeTimer ( ) ;
2023-08-18 13:32:53 +02:00
}
void SwordEngine : : uninstallTimerRoutines ( ) {
debug ( 2 , " SwordEngine::uninstallTimerRoutines(): Uninstalling timers... " ) ;
getTimerManager ( ) - > removeTimerProc ( & vblCallback ) ;
2023-10-02 18:13:36 +02:00
_sound - > uninstallFadeTimer ( ) ;
2023-08-18 13:32:53 +02:00
}
2004-01-11 15:47:41 +00:00
} // End of namespace Sword1