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 .
2001-10-09 14:30:12 +00:00
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
* of the License , or ( at your option ) any later version .
2014-02-18 01:34:24 +00:00
*
2001-10-09 14:30:12 +00:00
* 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 .
2014-02-18 01:34:24 +00:00
*
2001-10-09 14:30:12 +00:00
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
2005-10-18 01:30:26 +00:00
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
2001-10-09 14:30:12 +00:00
*
*/
2003-10-08 21:59:23 +00:00
# include "common/config-manager.h"
2010-05-04 11:59:22 +00:00
# include "common/debug-channels.h"
2003-12-13 00:20:01 +00:00
# include "common/md5.h"
2007-03-17 00:53:21 +00:00
# include "common/events.h"
2005-01-10 22:06:49 +00:00
# include "common/system.h"
2010-09-15 23:25:46 +00:00
# include "common/translation.h"
2003-09-11 10:32:15 +00:00
2010-05-04 11:58:12 +00:00
# include "engines/util.h"
2002-11-30 16:47:16 +00:00
# include "gui/message.h"
2010-11-16 10:19:01 +00:00
# include "gui/gui-manager.h"
2003-06-05 02:44:18 +00:00
2006-05-25 22:51:42 +00:00
# include "graphics/cursorman.h"
2005-05-14 23:28:22 +00:00
# include "scumm/akos.h"
2003-09-11 10:32:15 +00:00
# include "scumm/charset.h"
# include "scumm/costume.h"
# include "scumm/debugger.h"
# include "scumm/dialogs.h"
2006-03-03 15:16:02 +00:00
# include "scumm/file.h"
2007-08-08 23:31:21 +00:00
# include "scumm/file_nes.h"
2006-02-20 20:57:26 +00:00
# include "scumm/imuse/imuse.h"
2005-05-14 23:28:22 +00:00
# include "scumm/imuse_digi/dimuse.h"
2006-03-05 12:15:39 +00:00
# include "scumm/smush/smush_mixer.h"
2006-10-10 12:16:21 +00:00
# include "scumm/smush/smush_player.h"
2013-11-01 12:53:43 +00:00
# include "scumm/players/player_towns.h"
2005-05-14 23:28:22 +00:00
# include "scumm/insane/insane.h"
2006-05-08 10:21:17 +00:00
# include "scumm/he/animation_he.h"
2006-02-15 00:57:50 +00:00
# include "scumm/he/intern_he.h"
# include "scumm/he/logic_he.h"
2006-04-23 18:52:39 +00:00
# include "scumm/he/sound_he.h"
2006-09-17 22:22:50 +00:00
# include "scumm/object.h"
2013-11-01 12:53:43 +00:00
# include "scumm/players/player_ad.h"
# include "scumm/players/player_nes.h"
# include "scumm/players/player_sid.h"
# include "scumm/players/player_pce.h"
# include "scumm/players/player_apple2.h"
# include "scumm/players/player_v1.h"
# include "scumm/players/player_v2.h"
# include "scumm/players/player_v2cms.h"
# include "scumm/players/player_v2a.h"
# include "scumm/players/player_v3a.h"
# include "scumm/players/player_v3m.h"
# include "scumm/players/player_v4a.h"
# include "scumm/players/player_v5m.h"
2011-05-11 14:03:50 +00:00
# include "scumm/resource.h"
2006-02-15 18:48:49 +00:00
# include "scumm/he/resource_he.h"
2009-03-20 16:33:58 +00:00
# include "scumm/scumm_v0.h"
# include "scumm/scumm_v8.h"
2005-10-22 23:08:14 +00:00
# include "scumm/sound.h"
2006-03-12 18:06:22 +00:00
# include "scumm/imuse/sysex.h"
2006-02-15 00:57:50 +00:00
# include "scumm/he/sprite_he.h"
2006-11-06 13:40:24 +00:00
# include "scumm/he/cup_player_he.h"
2005-05-14 22:56:41 +00:00
# include "scumm/util.h"
2003-09-11 10:32:15 +00:00
# include "scumm/verbs.h"
2011-07-08 02:43:45 +00:00
# include "scumm/imuse/pcspk.h"
2012-09-19 23:32:49 +00:00
# include "scumm/imuse/mac_m68k.h"
2003-09-11 10:32:15 +00:00
2010-11-08 23:07:42 +00:00
# include "backends/audiocd/audiocd.h"
2011-02-09 01:09:01 +00:00
# include "audio/mixer.h"
2003-06-05 02:44:18 +00:00
2005-05-10 22:56:25 +00:00
using Common : : File ;
2003-10-03 18:33:57 +00:00
namespace Scumm {
2002-08-18 17:48:18 +00:00
// Use g_scumm from error() ONLY
2003-10-02 22:42:03 +00:00
ScummEngine * g_scumm = 0 ;
2002-08-18 17:48:18 +00:00
2006-02-12 20:51:56 +00:00
2007-02-04 12:41:49 +00:00
struct dbgChannelDesc {
const char * channel , * desc ;
uint32 flag ;
} ;
// Debug channel lookup table for Debugger console
static const dbgChannelDesc debugChannels [ ] = {
{ " SCRIPTS " , " Track script execution " , DEBUG_SCRIPTS } ,
{ " OPCODES " , " Track opcode execution " , DEBUG_OPCODES } ,
{ " IMUSE " , " Track iMUSE events " , DEBUG_IMUSE } ,
{ " RESOURCE " , " Track resource loading/management " , DEBUG_RESOURCE } ,
{ " VARS " , " Track variable changes " , DEBUG_VARS } ,
{ " ACTORS " , " Actor-related debug " , DEBUG_ACTORS } ,
{ " SOUND " , " Sound related debug " , DEBUG_SOUND } ,
{ " INSANE " , " Track INSANE " , DEBUG_INSANE } ,
{ " SMUSH " , " Track SMUSH " , DEBUG_SMUSH }
} ;
2006-04-23 17:33:16 +00:00
ScummEngine : : ScummEngine ( OSystem * syst , const DetectorResult & dr )
2003-11-10 01:04:12 +00:00
: Engine ( syst ) ,
2006-04-23 17:33:16 +00:00
_game ( dr . game ) ,
_filenamePattern ( dr . fp ) ,
_language ( dr . language ) ,
2005-09-22 22:55:01 +00:00
_debugger ( 0 ) ,
_currentScript ( 0xFF ) , // Let debug() work on init stage
2011-05-16 14:35:10 +00:00
_messageDialog ( 0 ) , _pauseDialog ( 0 ) , _versionDialog ( 0 ) ,
_rnd ( " scumm " )
{
2002-08-18 18:39:42 +00:00
2009-11-22 11:43:12 +00:00
# ifdef USE_RGB_COLOR
2011-06-18 17:44:18 +00:00
if ( _game . features & GF_16BIT_COLOR ) {
2009-11-22 11:43:12 +00:00
if ( _game . platform = = Common : : kPlatformPCEngine )
_gdi = new GdiPCEngine ( this ) ;
2011-06-18 17:44:18 +00:00
else if ( _game . heversion > 0 )
_gdi = new GdiHE16bit ( this ) ;
} else
2009-11-22 11:43:12 +00:00
# endif
2011-06-18 17:44:18 +00:00
if ( _game . heversion > 0 ) {
_gdi = new GdiHE ( this ) ;
} else if ( _game . platform = = Common : : kPlatformNES ) {
_gdi = new GdiNES ( this ) ;
2006-09-18 22:06:39 +00:00
} else if ( _game . version < = 1 ) {
_gdi = new GdiV1 ( this ) ;
} else if ( _game . version = = 2 ) {
_gdi = new GdiV2 ( this ) ;
2006-09-18 21:20:21 +00:00
} else {
_gdi = new Gdi ( this ) ;
}
2006-09-17 20:36:48 +00:00
_res = new ResourceManager ( this ) ;
2007-09-19 08:40:12 +00:00
2007-02-14 21:59:57 +00:00
// Convert MD5 checksum back into a digest
for ( int i = 0 ; i < 16 ; + + i ) {
char tmpStr [ 3 ] = " 00 " ;
uint tmpVal ;
tmpStr [ 0 ] = dr . md5 [ 2 * i ] ;
tmpStr [ 1 ] = dr . md5 [ 2 * i + 1 ] ;
2010-10-18 16:00:07 +00:00
int res = sscanf ( tmpStr , " %x " , & tmpVal ) ;
assert ( res = = 1 ) ;
2007-02-14 21:59:57 +00:00
_gameMD5 [ i ] = ( byte ) tmpVal ;
}
2007-09-19 08:40:12 +00:00
2006-10-07 15:37:03 +00:00
_fileHandle = 0 ;
2007-09-19 08:40:12 +00:00
2004-09-20 22:04:06 +00:00
// Init all vars
2003-04-30 13:23:31 +00:00
_imuse = NULL ;
_imuseDigital = NULL ;
2003-10-12 17:33:29 +00:00
_musicEngine = NULL ;
2010-08-18 21:38:43 +00:00
_townsPlayer = NULL ;
2003-04-30 13:23:31 +00:00
_verbs = NULL ;
_objs = NULL ;
2003-06-08 12:11:14 +00:00
_sound = NULL ;
2003-04-30 13:23:31 +00:00
memset ( & vm , 0 , sizeof ( vm ) ) ;
_pauseDialog = NULL ;
2004-07-20 11:30:15 +00:00
_versionDialog = NULL ;
2003-04-30 13:23:31 +00:00
_fastMode = 0 ;
2011-06-13 01:00:03 +00:00
_actors = _sortedActors = NULL ;
2004-08-02 06:21:00 +00:00
_arraySlot = NULL ;
2003-04-30 13:23:31 +00:00
_inventory = NULL ;
_newNames = NULL ;
2003-05-08 15:48:50 +00:00
_scummVars = NULL ;
2004-08-26 23:15:39 +00:00
_roomVars = NULL ;
2003-04-30 13:23:31 +00:00
_varwatch = 0 ;
_bitVars = NULL ;
_numVariables = 0 ;
_numBitVariables = 0 ;
2004-08-26 23:30:28 +00:00
_numRoomVariables = 0 ;
2003-04-30 13:23:31 +00:00
_numLocalObjects = 0 ;
_numGlobalObjects = 0 ;
_numArray = 0 ;
_numVerbs = 0 ;
_numFlObject = 0 ;
_numInventory = 0 ;
_numRooms = 0 ;
_numScripts = 0 ;
_numSounds = 0 ;
_numCharsets = 0 ;
_numNewNames = 0 ;
_numGlobalScripts = 0 ;
_numCostumes = 0 ;
2004-06-30 06:46:32 +00:00
_numImages = 0 ;
2004-09-30 06:39:39 +00:00
_numLocalScripts = 60 ;
2004-09-08 05:58:36 +00:00
_numSprites = 0 ;
_numTalkies = 0 ;
2004-10-01 11:25:25 +00:00
_numPalettes = 0 ;
2004-10-04 02:23:02 +00:00
_numUnk = 0 ;
2003-04-30 13:23:31 +00:00
_curPalIndex = 0 ;
_currentRoom = 0 ;
_egoPositioned = false ;
2005-04-20 23:33:35 +00:00
_mouseAndKeyboardStat = 0 ;
2003-04-30 13:23:31 +00:00
_leftBtnPressed = 0 ;
_rightBtnPressed = 0 ;
2009-07-29 20:35:50 +00:00
_lastInputScriptTime = 0 ;
2003-04-30 13:23:31 +00:00
_bootParam = 0 ;
_dumpScripts = false ;
2014-05-13 14:14:54 +00:00
_debugMode = false ;
2003-04-30 13:23:31 +00:00
_objectOwnerTable = NULL ;
_objectRoomTable = NULL ;
_objectStateTable = NULL ;
_numObjectsInRoom = 0 ;
_userPut = 0 ;
2003-05-21 07:22:43 +00:00
_userState = 0 ;
2005-04-03 15:06:08 +00:00
_resourceHeaderSize = 8 ;
2003-04-30 13:23:31 +00:00
_saveLoadFlag = 0 ;
_saveLoadSlot = 0 ;
_lastSaveTime = 0 ;
2004-01-31 22:12:35 +00:00
_saveTemporaryState = false ;
2005-01-29 15:49:57 +00:00
memset ( _localScriptOffsets , 0 , sizeof ( _localScriptOffsets ) ) ;
2003-04-30 13:23:31 +00:00
_scriptPointer = NULL ;
_scriptOrgPointer = NULL ;
_opcode = 0 ;
2003-09-11 10:32:15 +00:00
vm . numNestedScripts = 0 ;
2003-04-30 13:23:31 +00:00
_lastCodePtr = NULL ;
_scummStackPos = 0 ;
2004-01-08 20:37:26 +00:00
memset ( _vmStack , 0 , sizeof ( _vmStack ) ) ;
2003-04-30 13:23:31 +00:00
_fileOffset = 0 ;
2003-06-09 01:06:29 +00:00
memset ( _resourceMapper , 0 , sizeof ( _resourceMapper ) ) ;
2003-04-30 13:23:31 +00:00
_lastLoadedRoom = 0 ;
_roomResource = 0 ;
OF_OWNER_ROOM = 0 ;
_verbMouseOver = 0 ;
_classData = NULL ;
_actorToPrintStrFor = 0 ;
_sentenceNum = 0 ;
2003-06-09 01:06:29 +00:00
memset ( _sentence , 0 , sizeof ( _sentence ) ) ;
memset ( _string , 0 , sizeof ( _string ) ) ;
2003-04-30 13:23:31 +00:00
_screenB = 0 ;
_screenH = 0 ;
2003-05-10 21:49:59 +00:00
_roomHeight = 0 ;
_roomWidth = 0 ;
_screenHeight = 0 ;
_screenWidth = 0 ;
2007-09-08 11:15:27 +00:00
memset ( _virtscr , 0 , sizeof ( _virtscr ) ) ;
2003-06-09 01:06:29 +00:00
memset ( & camera , 0 , sizeof ( CameraData ) ) ;
memset ( _colorCycle , 0 , sizeof ( _colorCycle ) ) ;
2005-11-01 13:55:53 +00:00
memset ( _colorUsedByCycle , 0 , sizeof ( _colorUsedByCycle ) ) ;
2003-04-30 13:23:31 +00:00
_ENCD_offs = 0 ;
_EXCD_offs = 0 ;
_CLUT_offs = 0 ;
2004-08-22 06:16:16 +00:00
_EPAL_offs = 0 ;
2003-04-30 13:23:31 +00:00
_IM00_offs = 0 ;
_PALS_offs = 0 ;
_fullRedraw = false ;
2004-09-18 22:42:45 +00:00
_bgNeedsRedraw = false ;
2003-04-30 13:23:31 +00:00
_screenEffectFlag = false ;
_completeScreenRedraw = false ;
2006-06-21 10:28:09 +00:00
_disableFadeInEffect = false ;
2003-06-09 01:06:29 +00:00
memset ( & _cursor , 0 , sizeof ( _cursor ) ) ;
memset ( _grabbedCursor , 0 , sizeof ( _grabbedCursor ) ) ;
2003-04-30 13:23:31 +00:00
_currentCursor = 0 ;
_newEffect = 0 ;
_switchRoomEffect2 = 0 ;
_switchRoomEffect = 0 ;
2004-11-09 10:26:33 +00:00
2011-06-15 20:01:24 +00:00
_bytesPerPixel = 1 ;
2003-04-30 13:23:31 +00:00
_doEffect = false ;
2009-03-10 00:26:40 +00:00
_snapScroll = false ;
2005-03-25 01:27:28 +00:00
_shakeEnabled = false ;
2003-04-30 13:23:31 +00:00
_shakeFrame = 0 ;
_screenStartStrip = 0 ;
_screenEndStrip = 0 ;
_screenTop = 0 ;
_drawObjectQueNr = 0 ;
2003-06-09 01:06:29 +00:00
memset ( _drawObjectQue , 0 , sizeof ( _drawObjectQue ) ) ;
2003-04-30 13:23:31 +00:00
_palManipStart = 0 ;
_palManipEnd = 0 ;
_palManipCounter = 0 ;
_palManipPalette = NULL ;
_palManipIntermediatePal = NULL ;
2003-06-09 01:06:29 +00:00
memset ( gfxUsageBits , 0 , sizeof ( gfxUsageBits ) ) ;
2005-06-02 14:40:13 +00:00
_hePalettes = NULL ;
2009-06-04 01:05:47 +00:00
_hePaletteSlot = 0 ;
2009-10-27 09:44:13 +00:00
_16BitPalette = NULL ;
2010-10-05 19:04:52 +00:00
# ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
_townsScreen = 0 ;
2011-07-09 21:57:25 +00:00
# ifdef USE_RGB_COLOR
2010-10-17 13:08:00 +00:00
_cjkFont = 0 ;
2011-07-09 21:57:25 +00:00
# endif
2011-02-20 11:03:44 +00:00
# endif
2003-04-30 13:23:31 +00:00
_shadowPalette = NULL ;
_shadowPaletteSize = 0 ;
2011-08-26 03:51:08 +00:00
_verbPalette = NULL ;
2003-06-09 01:06:29 +00:00
memset ( _currentPalette , 0 , sizeof ( _currentPalette ) ) ;
2005-04-19 04:12:49 +00:00
memset ( _darkenPalette , 0 , sizeof ( _darkenPalette ) ) ;
2004-08-16 02:38:02 +00:00
memset ( _HEV7ActorPalette , 0 , sizeof ( _HEV7ActorPalette ) ) ;
2003-04-30 13:23:31 +00:00
_palDirtyMin = 0 ;
_palDirtyMax = 0 ;
_haveMsg = 0 ;
2005-11-02 21:47:44 +00:00
_haveActorSpeechMsg = false ;
2003-04-30 13:23:31 +00:00
_useTalkAnims = false ;
_defaultTalkDelay = 0 ;
2003-07-15 10:16:45 +00:00
_saveSound = 0 ;
2003-06-09 01:06:29 +00:00
memset ( _extraBoxFlags , 0 , sizeof ( _extraBoxFlags ) ) ;
memset ( _scaleSlots , 0 , sizeof ( _scaleSlots ) ) ;
2003-04-30 13:23:31 +00:00
_charset = NULL ;
_charsetColor = 0 ;
2003-06-09 01:06:29 +00:00
memset ( _charsetColorMap , 0 , sizeof ( _charsetColorMap ) ) ;
memset ( _charsetData , 0 , sizeof ( _charsetData ) ) ;
2003-04-30 13:23:31 +00:00
_charsetBufPos = 0 ;
2003-06-09 01:06:29 +00:00
memset ( _charsetBuffer , 0 , sizeof ( _charsetBuffer ) ) ;
2003-12-14 04:43:04 +00:00
_copyProtection = false ;
2005-03-12 00:47:17 +00:00
_voiceMode = 0 ;
2003-04-30 13:23:31 +00:00
_talkDelay = 0 ;
2005-03-25 00:37:14 +00:00
_NES_lastTalkingActor = 0 ;
_NES_talkColor = 0 ;
2003-04-30 13:23:31 +00:00
_keepText = false ;
2015-06-09 01:58:59 +00:00
_msgCount = 0 ;
2005-03-27 01:07:22 +00:00
_costumeLoader = NULL ;
2003-06-14 13:38:22 +00:00
_costumeRenderer = NULL ;
2003-06-14 12:24:42 +00:00
_2byteFontPtr = 0 ;
2004-10-12 17:05:16 +00:00
_V1TalkingActor = 0 ;
2005-03-24 03:22:32 +00:00
_NESStartStrip = 0 ;
2003-04-30 13:23:31 +00:00
2004-08-24 00:58:28 +00:00
_skipDrawObject = 0 ;
2004-07-03 23:58:30 +00:00
2010-10-05 19:04:52 +00:00
# ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
_townsPaletteFlags = 0 ;
_townsClearLayerFlag = 1 ;
_townsActiveLayerFlags = 3 ;
memset ( & _curStringRect , - 1 , sizeof ( Common : : Rect ) ) ;
memset ( & _cyclRects , 0 , 16 * sizeof ( Common : : Rect ) ) ;
_numCyclRects = 0 ;
2010-10-05 19:04:52 +00:00
# endif
2011-06-19 22:59:48 +00:00
2003-05-08 15:48:50 +00:00
//
// Init all VARS to 0xFF
//
VAR_KEYPRESS = 0xFF ;
2004-01-09 22:10:32 +00:00
VAR_SYNC = 0xFF ;
2003-05-08 15:48:50 +00:00
VAR_EGO = 0xFF ;
VAR_CAMERA_POS_X = 0xFF ;
VAR_HAVE_MSG = 0xFF ;
VAR_ROOM = 0xFF ;
VAR_OVERRIDE = 0xFF ;
VAR_MACHINE_SPEED = 0xFF ;
VAR_ME = 0xFF ;
VAR_NUM_ACTOR = 0xFF ;
VAR_CURRENT_LIGHTS = 0xFF ;
VAR_CURRENTDRIVE = 0xFF ; // How about merging this with VAR_CURRENTDISK?
VAR_CURRENTDISK = 0xFF ;
VAR_TMR_1 = 0xFF ;
VAR_TMR_2 = 0xFF ;
VAR_TMR_3 = 0xFF ;
VAR_MUSIC_TIMER = 0xFF ;
VAR_ACTOR_RANGE_MIN = 0xFF ;
VAR_ACTOR_RANGE_MAX = 0xFF ;
VAR_CAMERA_MIN_X = 0xFF ;
VAR_CAMERA_MAX_X = 0xFF ;
VAR_TIMER_NEXT = 0xFF ;
VAR_VIRT_MOUSE_X = 0xFF ;
VAR_VIRT_MOUSE_Y = 0xFF ;
VAR_ROOM_RESOURCE = 0xFF ;
VAR_LAST_SOUND = 0xFF ;
VAR_CUTSCENEEXIT_KEY = 0xFF ;
VAR_OPTIONS_KEY = 0xFF ;
VAR_TALK_ACTOR = 0xFF ;
VAR_CAMERA_FAST_X = 0xFF ;
VAR_SCROLL_SCRIPT = 0xFF ;
VAR_ENTRY_SCRIPT = 0xFF ;
VAR_ENTRY_SCRIPT2 = 0xFF ;
VAR_EXIT_SCRIPT = 0xFF ;
VAR_EXIT_SCRIPT2 = 0xFF ;
VAR_VERB_SCRIPT = 0xFF ;
VAR_SENTENCE_SCRIPT = 0xFF ;
2003-06-14 12:23:30 +00:00
VAR_INVENTORY_SCRIPT = 0xFF ;
2003-05-08 15:48:50 +00:00
VAR_CUTSCENE_START_SCRIPT = 0xFF ;
VAR_CUTSCENE_END_SCRIPT = 0xFF ;
VAR_CHARINC = 0xFF ;
2003-05-14 13:30:52 +00:00
VAR_CHARCOUNT = 0xFF ;
2003-05-08 15:48:50 +00:00
VAR_WALKTO_OBJ = 0xFF ;
VAR_DEBUGMODE = 0xFF ;
VAR_HEAPSPACE = 0xFF ;
VAR_RESTART_KEY = 0xFF ;
VAR_PAUSE_KEY = 0xFF ;
VAR_MOUSE_X = 0xFF ;
VAR_MOUSE_Y = 0xFF ;
VAR_TIMER = 0xFF ;
2008-01-05 23:05:16 +00:00
VAR_TIMER_TOTAL = 0xFF ;
2003-05-08 15:48:50 +00:00
VAR_SOUNDCARD = 0xFF ;
VAR_VIDEOMODE = 0xFF ;
2003-11-03 23:26:13 +00:00
VAR_MAINMENU_KEY = 0xFF ;
2003-05-08 15:48:50 +00:00
VAR_FIXEDDISK = 0xFF ;
VAR_CURSORSTATE = 0xFF ;
VAR_USERPUT = 0xFF ;
VAR_SOUNDRESULT = 0xFF ;
VAR_TALKSTOP_KEY = 0xFF ;
2004-07-24 04:36:54 +00:00
VAR_FADE_DELAY = 0xFF ;
2003-06-12 16:38:43 +00:00
VAR_NOSUBTITLES = 0xFF ;
2003-05-08 15:48:50 +00:00
VAR_SOUNDPARAM = 0xFF ;
VAR_SOUNDPARAM2 = 0xFF ;
VAR_SOUNDPARAM3 = 0xFF ;
2006-08-20 00:43:34 +00:00
VAR_INPUTMODE = 0xFF ;
2004-07-24 11:15:59 +00:00
VAR_MEMORY_PERFORMANCE = 0xFF ;
2006-05-13 17:30:04 +00:00
2004-07-24 11:15:59 +00:00
VAR_VIDEO_PERFORMANCE = 0xFF ;
2003-05-08 15:48:50 +00:00
VAR_ROOM_FLAG = 0xFF ;
VAR_GAME_LOADED = 0xFF ;
VAR_NEW_ROOM = 0xFF ;
2004-07-22 04:13:46 +00:00
VAR_VERSION_KEY = 0xFF ;
2003-05-08 15:48:50 +00:00
VAR_V5_TALK_STRING_Y = 0xFF ;
2004-10-04 14:28:43 +00:00
VAR_ROOM_WIDTH = 0xFF ;
VAR_ROOM_HEIGHT = 0xFF ;
2005-05-09 02:38:58 +00:00
VAR_SUBTITLES = 0xFF ;
2003-05-08 15:48:50 +00:00
VAR_V6_EMSSPACE = 0xFF ;
VAR_CAMERA_POS_Y = 0xFF ;
VAR_CAMERA_MIN_Y = 0xFF ;
VAR_CAMERA_MAX_Y = 0xFF ;
VAR_CAMERA_THRESHOLD_X = 0xFF ;
VAR_CAMERA_THRESHOLD_Y = 0xFF ;
VAR_CAMERA_SPEED_X = 0xFF ;
VAR_CAMERA_SPEED_Y = 0xFF ;
VAR_CAMERA_ACCEL_X = 0xFF ;
VAR_CAMERA_ACCEL_Y = 0xFF ;
VAR_CAMERA_DEST_X = 0xFF ;
VAR_CAMERA_DEST_Y = 0xFF ;
VAR_CAMERA_FOLLOWED_ACTOR = 0xFF ;
VAR_LEFTBTN_DOWN = 0xFF ;
VAR_RIGHTBTN_DOWN = 0xFF ;
VAR_LEFTBTN_HOLD = 0xFF ;
VAR_RIGHTBTN_HOLD = 0xFF ;
2005-11-10 23:09:20 +00:00
2003-05-13 17:51:56 +00:00
VAR_SAVELOAD_SCRIPT = 0xFF ;
VAR_SAVELOAD_SCRIPT2 = 0xFF ;
2003-05-08 15:48:50 +00:00
VAR_DEFAULT_TALK_DELAY = 0xFF ;
VAR_CHARSET_MASK = 0xFF ;
VAR_CUSTOMSCALETABLE = 0xFF ;
VAR_V6_SOUNDMODE = 0xFF ;
2003-05-17 18:42:31 +00:00
VAR_ACTIVE_VERB = 0xFF ;
VAR_ACTIVE_OBJECT1 = 0xFF ;
VAR_ACTIVE_OBJECT2 = 0xFF ;
VAR_VERB_ALLOWED = 0xFF ;
2003-05-17 10:04:30 +00:00
2004-02-20 15:04:51 +00:00
VAR_BLAST_ABOVE_TEXT = 0xFF ;
2004-02-22 03:08:18 +00:00
VAR_VOICE_MODE = 0xFF ;
2004-07-04 06:14:18 +00:00
VAR_MUSIC_BUNDLE_LOADED = 0xFF ;
VAR_VOICE_BUNDLE_LOADED = 0xFF ;
2004-02-20 15:04:51 +00:00
2006-01-14 10:09:50 +00:00
VAR_REDRAW_ALL_ACTORS = 0xFF ;
2005-04-21 03:29:31 +00:00
VAR_SKIP_RESET_TALK_ACTOR = 0xFF ;
2006-01-14 10:09:50 +00:00
2004-09-10 10:39:10 +00:00
VAR_SOUND_CHANNEL = 0xFF ;
2006-01-15 08:37:01 +00:00
VAR_TALK_CHANNEL = 0xFF ;
2006-01-05 07:06:47 +00:00
VAR_SOUNDCODE_TMR = 0xFF ;
2006-01-15 08:37:01 +00:00
VAR_RESERVED_SOUND_CHANNELS = 0xFF ;
2004-09-10 10:39:10 +00:00
2006-01-14 05:32:11 +00:00
VAR_MAIN_SCRIPT = 0xFF ;
2006-01-14 10:09:50 +00:00
2005-02-28 13:23:10 +00:00
VAR_NUM_SCRIPT_CYCLES = 0xFF ;
VAR_SCRIPT_CYCLE = 0xFF ;
2014-08-19 23:26:39 +00:00
VAR_QUIT_SCRIPT = 0xFF ;
2004-09-04 23:35:14 +00:00
VAR_NUM_GLOBAL_OBJS = 0xFF ;
2002-08-18 17:48:18 +00:00
// Use g_scumm from error() ONLY
g_scumm = this ;
2003-10-13 12:56:53 +00:00
// Read settings from the detector & config manager
2005-04-24 12:21:53 +00:00
_debugMode = ( gDebugLevel > = 0 ) ;
2006-04-15 13:50:44 +00:00
_dumpScripts = ConfMan . getBool ( " dump_scripts " ) ;
2003-10-08 21:59:23 +00:00
_bootParam = ConfMan . getInt ( " boot_param " ) ;
2005-07-16 17:10:50 +00:00
// Boot params often need debugging switched on to work
if ( _bootParam )
_debugMode = true ;
2003-10-12 19:10:17 +00:00
2003-12-11 06:08:43 +00:00
_copyProtection = ConfMan . getBool ( " copy_protection " ) ;
2006-04-23 00:08:18 +00:00
if ( ConfMan . getBool ( " demo_mode " ) )
_game . features | = GF_DEMO ;
2003-12-02 08:12:39 +00:00
if ( ConfMan . hasKey ( " nosubtitles " ) ) {
2010-11-01 21:37:47 +00:00
// We replaced nosubtitles *ages* ago. Just convert it silently
debug ( " Configuration key 'nosubtitles' is deprecated. Converting to 'subtitles' " ) ;
2003-12-27 15:22:59 +00:00
if ( ! ConfMan . hasKey ( " subtitles " ) )
2006-04-16 19:23:14 +00:00
ConfMan . setBool ( " subtitles " , ! ConfMan . getBool ( " nosubtitles " ) ) ;
2003-12-02 08:12:39 +00:00
}
2005-03-12 00:47:17 +00:00
// Make sure that at least subtitles are enabled
if ( ConfMan . getBool ( " speech_mute " ) & & ! ConfMan . getBool ( " subtitles " ) )
2006-04-16 19:23:14 +00:00
ConfMan . setBool ( " subtitles " , true ) ;
2005-03-12 00:47:17 +00:00
// TODO Detect subtitle only versions of scumm6 games
if ( ConfMan . getBool ( " speech_mute " ) )
_voiceMode = 2 ;
else
_voiceMode = ConfMan . getBool ( " subtitles " ) ;
2005-02-20 00:17:22 +00:00
if ( ConfMan . hasKey ( " render_mode " ) ) {
2006-10-15 00:50:22 +00:00
_renderMode = Common : : parseRenderMode ( ConfMan . get ( " render_mode " ) ) ;
2005-02-20 00:17:22 +00:00
} else {
_renderMode = Common : : kRenderDefault ;
}
2007-07-08 21:39:46 +00:00
// Check some render mode restrictions
2006-05-29 12:45:11 +00:00
if ( _game . version < = 1 )
2005-02-20 01:50:18 +00:00
_renderMode = Common : : kRenderDefault ;
2005-02-20 00:17:22 +00:00
switch ( _renderMode ) {
2005-03-02 21:46:51 +00:00
case Common : : kRenderHercA :
case Common : : kRenderHercG :
2006-02-20 16:51:30 +00:00
if ( _game . version > 2 & & _game . id ! = GID_MONKEY_EGA )
2005-02-20 00:17:22 +00:00
_renderMode = Common : : kRenderDefault ;
break ;
case Common : : kRenderCGA :
case Common : : kRenderEGA :
2005-03-07 00:39:48 +00:00
case Common : : kRenderAmiga :
2010-01-25 01:39:44 +00:00
if ( ( _game . version > = 4 & & ! ( _game . features & GF_16COLOR )
2009-08-02 01:00:56 +00:00
& & ! ( _game . platform = = Common : : kPlatformAmiga & & _renderMode = = Common : : kRenderEGA ) )
2009-06-30 17:41:24 +00:00
| | ( _game . features & GF_OLD256 ) )
2005-03-07 00:39:48 +00:00
_renderMode = Common : : kRenderDefault ;
break ;
2005-02-20 00:17:22 +00:00
default :
break ;
}
2003-05-13 23:33:01 +00:00
_hexdumpScripts = false ;
_showStack = false ;
2002-11-13 15:44:33 +00:00
2006-02-20 16:51:30 +00:00
if ( _game . platform = = Common : : kPlatformFMTowns & & _game . version = = 3 ) { // FM-TOWNS V3 games use 320x240
2003-05-10 21:49:59 +00:00
_screenWidth = 320 ;
_screenHeight = 240 ;
2006-02-20 16:51:30 +00:00
} else if ( _game . version = = 8 | | _game . heversion > = 71 ) {
2006-02-18 00:12:36 +00:00
// COMI uses 640x480. Likewise starting from version 7.1, HE games use
// 640x480, too.
2003-05-10 21:49:59 +00:00
_screenWidth = 640 ;
_screenHeight = 480 ;
2006-02-20 16:51:30 +00:00
} else if ( _game . platform = = Common : : kPlatformNES ) {
2005-03-24 21:34:35 +00:00
_screenWidth = 256 ;
2003-08-14 11:40:50 +00:00
_screenHeight = 240 ;
2002-08-18 17:48:18 +00:00
} else {
2003-05-10 21:49:59 +00:00
_screenWidth = 320 ;
_screenHeight = 200 ;
2002-08-18 17:48:18 +00:00
}
2011-06-15 20:01:24 +00:00
_bytesPerPixel = ( _game . features & GF_16BIT_COLOR ) ? 2 : 1 ;
uint8 sizeMult = _bytesPerPixel ;
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
# ifdef USE_RGB_COLOR
2010-10-05 19:04:52 +00:00
# ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
if ( _game . platform = = Common : : kPlatformFMTowns )
2011-06-15 20:01:24 +00:00
sizeMult = 2 ;
2010-10-05 19:04:52 +00:00
# endif
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
# endif
2009-06-04 01:05:47 +00:00
2007-07-08 22:13:50 +00:00
// Allocate gfx compositing buffer (not needed for V7/V8 games).
if ( _game . version < 7 )
2011-06-15 20:01:24 +00:00
_compositeBuf = ( byte * ) malloc ( _screenWidth * _screenHeight * sizeMult ) ;
2007-07-08 22:13:50 +00:00
else
_compositeBuf = 0 ;
2005-03-25 01:52:20 +00:00
2005-03-25 01:59:47 +00:00
_herculesBuf = 0 ;
2005-03-25 01:52:20 +00:00
if ( _renderMode = = Common : : kRenderHercA | | _renderMode = = Common : : kRenderHercG ) {
2011-06-21 14:57:42 +00:00
_herculesBuf = ( byte * ) malloc ( kHercWidth * kHercHeight ) ;
2005-03-25 01:52:20 +00:00
}
2007-02-04 12:41:49 +00:00
2007-09-19 08:40:12 +00:00
// Add debug levels
2007-02-04 12:41:49 +00:00
for ( int i = 0 ; i < ARRAYSIZE ( debugChannels ) ; + + i )
2010-04-27 21:40:52 +00:00
DebugMan . addDebugChannel ( debugChannels [ i ] . flag , debugChannels [ i ] . channel , debugChannels [ i ] . desc ) ;
2007-09-19 13:55:05 +00:00
2010-05-26 19:54:50 +00:00
# ifndef DISABLE_HELP
// Create custom GMM dialog providing a help subdialog
assert ( ! _mainMenuDialog ) ;
_mainMenuDialog = new ScummMenuDialog ( this ) ;
# endif
2002-08-14 00:01:39 +00:00
}
2007-02-04 12:41:49 +00:00
2003-10-02 22:42:03 +00:00
ScummEngine : : ~ ScummEngine ( ) {
2010-04-27 21:40:52 +00:00
DebugMan . clearAllDebugChannels ( ) ;
2007-02-04 12:41:49 +00:00
2009-08-01 23:02:45 +00:00
delete _musicEngine ;
2004-01-14 16:00:24 +00:00
2003-10-03 13:43:07 +00:00
_mixer - > stopAll ( ) ;
2003-11-08 21:59:32 +00:00
2011-06-13 01:00:03 +00:00
if ( _actors ) {
for ( int i = 0 ; i < _numActors ; + + i )
delete _actors [ i ] ;
delete [ ] _actors ;
}
2011-06-19 22:59:48 +00:00
2008-05-07 14:31:45 +00:00
delete [ ] _sortedActors ;
2003-11-08 21:59:32 +00:00
2010-03-04 17:24:47 +00:00
delete [ ] _2byteFontPtr ;
2002-12-25 21:42:22 +00:00
delete _charset ;
2009-03-10 00:26:40 +00:00
delete _messageDialog ;
2002-12-25 21:42:22 +00:00
delete _pauseDialog ;
2004-07-20 11:30:15 +00:00
delete _versionDialog ;
2005-03-30 21:59:12 +00:00
delete _fileHandle ;
2002-09-19 21:45:56 +00:00
2002-08-14 20:43:56 +00:00
delete _sound ;
2003-04-30 13:23:31 +00:00
2005-03-27 01:07:22 +00:00
delete _costumeLoader ;
2003-06-14 13:38:22 +00:00
delete _costumeRenderer ;
2003-06-05 02:44:18 +00:00
2007-01-28 20:11:31 +00:00
_textSurface . free ( ) ;
2003-06-15 00:33:16 +00:00
free ( _shadowPalette ) ;
2011-08-26 03:51:08 +00:00
free ( _verbPalette ) ;
2005-04-10 00:51:47 +00:00
free ( _palManipPalette ) ;
free ( _palManipIntermediatePal ) ;
2005-07-30 21:11:48 +00:00
2003-06-25 23:25:52 +00:00
free ( _objectStateTable ) ;
free ( _objectRoomTable ) ;
free ( _objectOwnerTable ) ;
free ( _inventory ) ;
free ( _verbs ) ;
free ( _objs ) ;
2004-10-18 14:37:38 +00:00
free ( _roomVars ) ;
2003-06-25 23:25:52 +00:00
free ( _scummVars ) ;
free ( _bitVars ) ;
free ( _newNames ) ;
free ( _classData ) ;
2004-10-18 14:37:38 +00:00
free ( _arraySlot ) ;
2003-06-25 23:25:52 +00:00
2005-03-25 01:52:20 +00:00
free ( _compositeBuf ) ;
free ( _herculesBuf ) ;
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
free ( _16BitPalette ) ;
2010-10-05 19:04:52 +00:00
# ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
delete _townsScreen ;
2011-07-09 21:57:25 +00:00
# ifdef USE_RGB_COLOR
2010-10-17 13:08:00 +00:00
delete _cjkFont ;
2011-07-09 21:57:25 +00:00
# endif
2011-02-20 11:03:44 +00:00
# endif
2005-03-25 01:52:20 +00:00
2003-10-12 17:49:52 +00:00
delete _debugger ;
2007-09-19 08:40:12 +00:00
2006-09-17 20:36:48 +00:00
delete _res ;
2006-09-17 20:22:47 +00:00
delete _gdi ;
2002-08-14 00:01:39 +00:00
}
2007-02-04 12:41:49 +00:00
2006-04-23 17:58:52 +00:00
ScummEngine_v5 : : ScummEngine_v5 ( OSystem * syst , const DetectorResult & dr )
: ScummEngine ( syst , dr ) {
2008-01-02 18:59:15 +00:00
// All "classic" games (V5 and older) encrypted their data files
// with exception of the GF_OLD256 games and the PC-Engine version
// of Loom.
2009-10-21 12:59:10 +00:00
if ( ! ( _game . features & GF_OLD256 ) )
2008-01-02 18:59:15 +00:00
_game . features | = GF_USE_KEY ;
2008-01-02 18:44:20 +00:00
resetCursors ( ) ;
2006-04-29 13:01:35 +00:00
// Setup flashlight
memset ( & _flashlight , 0 , sizeof ( _flashlight ) ) ;
_flashlight . xStrips = 7 ;
_flashlight . yStrips = 7 ;
_flashlight . buffer = NULL ;
2010-08-11 12:49:16 +00:00
memset ( _saveLoadVarsFilename , 0 , sizeof ( _saveLoadVarsFilename ) ) ;
_resultVarNumber = 0 ;
2006-04-23 17:58:52 +00:00
}
2006-04-23 17:33:16 +00:00
ScummEngine_v4 : : ScummEngine_v4 ( OSystem * syst , const DetectorResult & dr )
: ScummEngine_v5 ( syst , dr ) {
2005-04-03 15:06:08 +00:00
_resourceHeaderSize = 6 ;
2007-02-14 23:29:13 +00:00
_game . features | = GF_SMALL_HEADER ;
2005-04-03 15:06:08 +00:00
}
2006-04-23 17:33:16 +00:00
ScummEngine_v3 : : ScummEngine_v3 ( OSystem * syst , const DetectorResult & dr )
: ScummEngine_v4 ( syst , dr ) {
2007-02-14 23:29:13 +00:00
// All v3 and older games only used 16 colors with exception of the GF_OLD256 games.
if ( ! ( _game . features & GF_OLD256 ) )
_game . features | = GF_16COLOR ;
2009-03-16 04:45:12 +00:00
_savePreparedSavegame = NULL ;
}
ScummEngine_v3 : : ~ ScummEngine_v3 ( ) {
delete _savePreparedSavegame ;
2005-04-03 15:06:08 +00:00
}
2006-04-23 17:33:16 +00:00
ScummEngine_v3old : : ScummEngine_v3old ( OSystem * syst , const DetectorResult & dr )
: ScummEngine_v3 ( syst , dr ) {
2005-04-03 15:06:08 +00:00
_resourceHeaderSize = 4 ;
2007-02-14 23:29:13 +00:00
_game . features | = GF_OLD_BUNDLE ;
2005-04-03 15:06:08 +00:00
}
2006-04-23 17:33:16 +00:00
ScummEngine_v2 : : ScummEngine_v2 ( OSystem * syst , const DetectorResult & dr )
: ScummEngine_v3old ( syst , dr ) {
2006-03-02 01:17:41 +00:00
2009-07-28 23:19:33 +00:00
_inventoryOffset = 0 ;
2006-03-02 01:17:41 +00:00
VAR_SENTENCE_VERB = 0xFF ;
VAR_SENTENCE_OBJECT1 = 0xFF ;
VAR_SENTENCE_OBJECT2 = 0xFF ;
VAR_SENTENCE_PREPOSITION = 0xFF ;
VAR_BACKUP_VERB = 0xFF ;
VAR_CLICK_AREA = 0xFF ;
VAR_CLICK_VERB = 0xFF ;
VAR_CLICK_OBJECT = 0xFF ;
2005-04-03 15:06:08 +00:00
}
2007-02-25 11:38:19 +00:00
ScummEngine_v0 : : ScummEngine_v0 ( OSystem * syst , const DetectorResult & dr )
2006-04-23 17:33:16 +00:00
: ScummEngine_v2 ( syst , dr ) {
2014-12-07 08:53:27 +00:00
_drawDemo = false ;
2005-10-02 13:21:49 +00:00
_currentMode = 0 ;
2012-02-04 14:40:36 +00:00
_currentLights = 0 ;
2009-07-25 06:27:41 +00:00
2012-01-07 19:06:26 +00:00
_activeVerb = kVerbNone ;
2012-01-15 20:43:21 +00:00
_activeObject = 0 ;
_activeObject2 = 0 ;
2012-01-08 22:51:13 +00:00
_cmdVerb = kVerbNone ;
2012-01-15 20:43:21 +00:00
_cmdObject = 0 ;
_cmdObject2 = 0 ;
2010-09-18 14:18:48 +00:00
2012-01-09 22:21:08 +00:00
VAR_ACTIVE_OBJECT2 = 0xFF ;
2010-09-18 14:18:48 +00:00
VAR_IS_SOUND_RUNNING = 0xFF ;
VAR_ACTIVE_VERB = 0xFF ;
2014-12-07 08:53:27 +00:00
if ( strcmp ( dr . fp . pattern , " maniacdemo.d64 " ) = = 0 )
_game . features | = GF_DEMO ;
2005-05-18 02:32:25 +00:00
}
2006-04-23 17:33:16 +00:00
ScummEngine_v6 : : ScummEngine_v6 ( OSystem * syst , const DetectorResult & dr )
: ScummEngine ( syst , dr ) {
2005-04-28 22:34:56 +00:00
_blastObjectQueuePos = 0 ;
memset ( _blastObjectQueue , 0 , sizeof ( _blastObjectQueue ) ) ;
_blastTextQueuePos = 0 ;
memset ( _blastTextQueue , 0 , sizeof ( _blastTextQueue ) ) ;
2006-04-29 16:51:29 +00:00
memset ( _akosQueue , 0 , sizeof ( _akosQueue ) ) ;
_akosQueuePos = 0 ;
2006-11-04 22:59:56 +00:00
_curActor = 0 ;
_curVerb = 0 ;
_curVerbSlot = 0 ;
2008-01-02 21:15:23 +00:00
_forcedWaitForMessage = false ;
2009-07-15 02:06:26 +00:00
_skipVideo = false ;
2008-01-02 21:15:23 +00:00
2004-06-27 13:33:03 +00:00
VAR_VIDEONAME = 0xFF ;
VAR_RANDOM_NR = 0xFF ;
VAR_STRING2DRAW = 0xFF ;
VAR_TIMEDATE_YEAR = 0xFF ;
VAR_TIMEDATE_MONTH = 0xFF ;
VAR_TIMEDATE_DAY = 0xFF ;
VAR_TIMEDATE_HOUR = 0xFF ;
VAR_TIMEDATE_MINUTE = 0xFF ;
VAR_TIMEDATE_SECOND = 0xFF ;
}
2006-04-23 19:41:54 +00:00
ScummEngine_v60he : : ScummEngine_v60he ( OSystem * syst , const DetectorResult & dr )
: ScummEngine_v6 ( syst , dr ) {
2006-04-26 14:05:09 +00:00
memset ( _hInFileTable , 0 , sizeof ( _hInFileTable ) ) ;
memset ( _hOutFileTable , 0 , sizeof ( _hOutFileTable ) ) ;
2011-04-05 09:36:38 +00:00
_actorClipOverride . top = 0 ;
_actorClipOverride . bottom = 480 ;
_actorClipOverride . left = 0 ;
_actorClipOverride . right = 640 ;
2006-04-23 19:41:54 +00:00
memset ( _heTimers , 0 , sizeof ( _heTimers ) ) ;
2007-02-14 23:29:13 +00:00
if ( _game . heversion > = 61 )
_game . features | = GF_NEW_COSTUMES ;
2006-04-23 19:41:54 +00:00
}
2006-04-26 14:05:09 +00:00
ScummEngine_v60he : : ~ ScummEngine_v60he ( ) {
for ( int i = 0 ; i < 17 ; + + i ) {
delete _hInFileTable [ i ] ;
delete _hOutFileTable [ i ] ;
}
}
2006-04-23 17:33:16 +00:00
ScummEngine_v70he : : ScummEngine_v70he ( OSystem * syst , const DetectorResult & dr )
: ScummEngine_v60he ( syst , dr ) {
2010-01-28 00:28:08 +00:00
if ( _game . platform = = Common : : kPlatformMacintosh & & ( _game . heversion > = 72 & & _game . heversion < = 74 ) )
2005-05-18 15:57:16 +00:00
_resExtractor = new MacResExtractor ( this ) ;
else
_resExtractor = new Win32ResExtractor ( this ) ;
2004-09-29 21:45:52 +00:00
2011-04-05 10:10:05 +00:00
_heV7DiskOffsets = NULL ;
2005-04-17 22:59:43 +00:00
_heV7RoomOffsets = NULL ;
2011-04-05 11:44:50 +00:00
_heV7RoomIntOffsets = NULL ;
2005-04-17 22:59:43 +00:00
2004-09-29 21:45:52 +00:00
_heSndSoundId = 0 ;
_heSndOffset = 0 ;
_heSndChannel = 0 ;
2004-10-10 01:52:35 +00:00
_heSndFlags = 0 ;
2004-09-29 21:45:52 +00:00
_heSndSoundFreq = 0 ;
2005-04-20 23:13:11 +00:00
2006-09-17 22:22:50 +00:00
_numStoredFlObjects = 0 ;
_storedFlObjects = ( ObjectData * ) calloc ( 100 , sizeof ( ObjectData ) ) ;
2005-04-20 23:13:11 +00:00
VAR_NUM_SOUND_CHANNELS = 0xFF ;
2004-06-28 11:38:26 +00:00
}
2005-04-17 22:59:43 +00:00
ScummEngine_v70he : : ~ ScummEngine_v70he ( ) {
2005-09-08 19:26:43 +00:00
delete _resExtractor ;
2005-04-17 22:59:43 +00:00
free ( _heV7DiskOffsets ) ;
free ( _heV7RoomOffsets ) ;
2011-04-05 11:44:50 +00:00
free ( _heV7RoomIntOffsets ) ;
2006-01-11 00:18:32 +00:00
free ( _storedFlObjects ) ;
2005-04-17 22:59:43 +00:00
}
2008-05-06 03:00:26 +00:00
# ifdef ENABLE_HE
2006-04-23 17:33:16 +00:00
ScummEngine_v71he : : ScummEngine_v71he ( OSystem * syst , const DetectorResult & dr )
: ScummEngine_v70he ( syst , dr ) {
2005-05-15 09:46:34 +00:00
_auxBlocksNum = 0 ;
memset ( _auxBlocks , 0 , sizeof ( _auxBlocks ) ) ;
_auxEntriesNum = 0 ;
memset ( _auxEntries , 0 , sizeof ( _auxEntries ) ) ;
2007-12-27 11:40:29 +00:00
_wiz = new Wiz ( this ) ;
2007-12-28 00:08:23 +00:00
_skipProcessActors = 0 ;
2007-12-28 00:18:06 +00:00
VAR_WIZ_TCOLOR = 0xFF ;
2007-12-27 11:40:29 +00:00
}
ScummEngine_v71he : : ~ ScummEngine_v71he ( ) {
delete _wiz ;
2005-05-15 09:46:34 +00:00
}
2006-04-23 17:33:16 +00:00
ScummEngine_v72he : : ScummEngine_v72he ( OSystem * syst , const DetectorResult & dr )
: ScummEngine_v71he ( syst , dr ) {
2005-04-20 20:34:44 +00:00
VAR_NUM_ROOMS = 0xFF ;
VAR_NUM_SCRIPTS = 0xFF ;
VAR_NUM_SOUNDS = 0xFF ;
VAR_NUM_COSTUMES = 0xFF ;
VAR_NUM_IMAGES = 0xFF ;
VAR_NUM_CHARSETS = 0xFF ;
2010-05-12 05:01:58 +00:00
VAR_SOUND_ENABLED = 0xFF ;
2005-04-20 20:34:44 +00:00
VAR_POLYGONS_ONLY = 0xFF ;
2007-10-28 12:57:25 +00:00
VAR_MOUSE_STATE = 0xFF ;
2010-01-26 08:31:27 +00:00
VAR_PLATFORM = 0xFF ;
2005-04-20 20:34:44 +00:00
}
2006-04-23 17:33:16 +00:00
ScummEngine_v80he : : ScummEngine_v80he ( OSystem * syst , const DetectorResult & dr )
: ScummEngine_v72he ( syst , dr ) {
2006-01-05 07:06:47 +00:00
_heSndResId = 0 ;
_curSndId = 0 ;
2006-01-06 23:54:42 +00:00
_sndPtrOffs = 0 ;
_sndTmrOffs = 0 ;
2009-01-05 06:45:42 +00:00
_sndDataSize = 0 ;
2006-01-16 11:36:16 +00:00
2006-07-08 10:28:35 +00:00
VAR_PLATFORM_VERSION = 0xFF ;
2006-01-16 11:36:16 +00:00
VAR_CURRENT_CHARSET = 0xFF ;
2009-07-13 07:55:11 +00:00
VAR_KEY_STATE = 0xFF ;
2006-01-16 11:36:16 +00:00
VAR_COLOR_DEPTH = 0xFF ;
2005-04-26 15:13:04 +00:00
}
2006-04-23 17:33:16 +00:00
ScummEngine_v90he : : ScummEngine_v90he ( OSystem * syst , const DetectorResult & dr )
: ScummEngine_v80he ( syst , dr ) {
2006-11-02 10:01:32 +00:00
_moviePlay = new MoviePlayer ( this , _mixer ) ;
2005-05-23 09:30:43 +00:00
_sprite = new Sprite ( this ) ;
2006-01-16 11:36:16 +00:00
2006-05-08 11:04:51 +00:00
memset ( _videoParams . filename , 0 , sizeof ( _videoParams . filename ) ) ;
_videoParams . status = 0 ;
_videoParams . flags = 0 ;
_videoParams . unk2 = 0 ;
_videoParams . wizResNum = 0 ;
2006-01-16 11:36:16 +00:00
VAR_NUM_SPRITE_GROUPS = 0xFF ;
VAR_NUM_SPRITES = 0xFF ;
VAR_NUM_PALETTES = 0xFF ;
VAR_NUM_UNK = 0xFF ;
VAR_U32_VERSION = 0xFF ;
VAR_U32_ARRAY_UNK = 0xFF ;
2005-05-23 09:30:43 +00:00
}
2005-05-08 03:08:11 +00:00
ScummEngine_v90he : : ~ ScummEngine_v90he ( ) {
2006-05-08 10:21:17 +00:00
delete _moviePlay ;
2005-09-08 19:26:43 +00:00
delete _sprite ;
2006-02-20 16:51:30 +00:00
if ( _game . heversion > = 98 ) {
2005-05-08 03:08:11 +00:00
delete _logicHE ;
}
2006-02-20 16:51:30 +00:00
if ( _game . heversion > = 99 ) {
2006-01-27 06:05:03 +00:00
free ( _hePalettes ) ;
}
2005-05-08 03:08:11 +00:00
}
2006-11-06 13:40:24 +00:00
ScummEngine_vCUPhe : : ScummEngine_vCUPhe ( OSystem * syst , const DetectorResult & dr ) : Engine ( syst ) {
_syst = syst ;
_game = dr . game ;
_filenamePattern = dr . fp ,
2007-09-19 08:40:12 +00:00
2006-11-06 13:40:24 +00:00
_cupPlayer = new CUP_Player ( syst , this , _mixer ) ;
}
ScummEngine_vCUPhe : : ~ ScummEngine_vCUPhe ( ) {
delete _cupPlayer ;
}
2009-03-01 04:30:55 +00:00
Common : : Error ScummEngine_vCUPhe : : run ( ) {
2008-11-14 22:08:10 +00:00
initGraphics ( CUP_Player : : kDefaultVideoWidth , CUP_Player : : kDefaultVideoHeight , true ) ;
2006-11-06 13:40:24 +00:00
2007-01-21 22:08:02 +00:00
if ( _cupPlayer - > open ( _filenamePattern . pattern ) ) {
_cupPlayer - > play ( ) ;
_cupPlayer - > close ( ) ;
}
2008-11-06 17:05:54 +00:00
return Common : : kNoError ;
2006-11-06 13:40:24 +00:00
}
void ScummEngine_vCUPhe : : parseEvents ( ) {
2007-03-17 19:02:05 +00:00
Common : : Event event ;
2007-09-19 08:40:12 +00:00
2007-04-01 17:36:13 +00:00
while ( _eventMan - > pollEvent ( event ) ) {
2008-09-01 23:37:24 +00:00
#if 0
2006-11-06 13:40:24 +00:00
switch ( event . type ) {
default :
break ;
}
2008-09-01 23:37:24 +00:00
# endif
2006-11-06 13:40:24 +00:00
}
}
2005-05-14 14:06:37 +00:00
# endif
2005-05-08 03:08:11 +00:00
2008-05-06 03:00:26 +00:00
# ifdef ENABLE_SCUMM_7_8
2006-04-23 17:33:16 +00:00
ScummEngine_v7 : : ScummEngine_v7 ( OSystem * syst , const DetectorResult & dr )
: ScummEngine_v6 ( syst , dr ) {
2006-05-31 10:48:40 +00:00
_verbLineSpacing = 10 ;
2006-10-07 13:57:06 +00:00
_smushFrameRate = 0 ;
_smushVideoShouldFinish = false ;
2006-10-07 17:42:32 +00:00
_smushActive = false ;
2006-10-07 13:57:06 +00:00
_smixer = NULL ;
2006-10-10 12:16:21 +00:00
_splayer = NULL ;
2006-10-07 13:57:06 +00:00
2005-04-28 22:17:23 +00:00
_existLanguageFile = false ;
_languageBuffer = NULL ;
_languageIndex = NULL ;
2005-11-02 21:47:44 +00:00
clearSubtitleQueue ( ) ;
2007-02-14 23:29:13 +00:00
_game . features | = GF_NEW_COSTUMES ;
2005-04-28 22:17:23 +00:00
}
ScummEngine_v7 : : ~ ScummEngine_v7 ( ) {
2006-10-07 13:57:06 +00:00
if ( _smixer ) {
_smixer - > stop ( ) ;
delete _smixer ;
}
2006-10-10 12:16:21 +00:00
if ( _splayer ) {
_splayer - > release ( ) ;
delete _splayer ;
}
2006-10-07 13:57:06 +00:00
2008-03-26 19:29:33 +00:00
delete _insane ;
2005-04-28 22:17:23 +00:00
free ( _languageBuffer ) ;
free ( _languageIndex ) ;
}
2006-04-23 17:33:16 +00:00
ScummEngine_v8 : : ScummEngine_v8 ( OSystem * syst , const DetectorResult & dr )
: ScummEngine_v7 ( syst , dr ) {
2005-04-23 16:52:11 +00:00
_objectIDMap = 0 ;
2006-10-07 12:33:22 +00:00
_keyScriptKey = 0 ;
_keyScriptNo = 0 ;
2006-04-29 13:56:36 +00:00
VAR_LANGUAGE = 0xFF ;
2005-04-23 16:52:11 +00:00
}
ScummEngine_v8 : : ~ ScummEngine_v8 ( ) {
2008-05-07 14:31:45 +00:00
delete [ ] _objectIDMap ;
2005-04-23 16:52:11 +00:00
}
2005-05-14 22:56:41 +00:00
# endif
2005-04-23 16:52:11 +00:00
2003-07-19 18:18:01 +00:00
# pragma mark -
# pragma mark --- Initialization ---
# pragma mark -
2008-11-06 17:05:54 +00:00
Common : : Error ScummEngine : : init ( ) {
2003-07-19 18:18:01 +00:00
2010-05-04 11:56:52 +00:00
const Common : : FSNode gameDataDir ( ConfMan . get ( " path " ) ) ;
2006-10-07 15:37:03 +00:00
// Add default file directories.
if ( ( ( _game . platform = = Common : : kPlatformAmiga ) | | ( _game . platform = = Common : : kPlatformAtariST ) ) & & ( _game . version < = 4 ) ) {
// This is for the Amiga version of Indy3/Loom/Maniac/Zak
2010-05-04 11:56:52 +00:00
SearchMan . addSubDirectoryMatching ( gameDataDir , " rooms " ) ;
2006-10-07 15:37:03 +00:00
}
if ( ( _game . platform = = Common : : kPlatformMacintosh ) & & ( _game . version = = 3 ) ) {
// This is for the Mac version of Indy3/Loom
2010-05-04 11:56:52 +00:00
SearchMan . addSubDirectoryMatching ( gameDataDir , " rooms 1 " ) ;
SearchMan . addSubDirectoryMatching ( gameDataDir , " rooms 2 " ) ;
SearchMan . addSubDirectoryMatching ( gameDataDir , " rooms 3 " ) ;
2006-10-07 15:37:03 +00:00
}
2008-05-06 03:00:26 +00:00
# ifdef ENABLE_SCUMM_7_8
2006-10-07 15:37:03 +00:00
# ifdef MACOSX
2010-05-04 11:56:52 +00:00
if ( _game . version = = 8 & & ! memcmp ( gameDataDir . getPath ( ) . c_str ( ) , " /Volumes/MONKEY3_ " , 17 ) ) {
2006-10-07 15:37:03 +00:00
// Special case for COMI on Mac OS X. The mount points on OS X depend
// on the volume name. Hence if playing from CD, we'd get a problem.
// So if loading of a resource file fails, we fall back to the (fixed)
// CD mount points (/Volumes/MONKEY3_1 and /Volumes/MONKEY3_2).
//
// This check for whether we play from CD is very crude, though.
2009-09-23 00:15:00 +00:00
SearchMan . addSubDirectoryMatching ( Common : : FSNode ( " / " ) , " Volumes/MONKEY3_1/RESOURCE " ) ;
SearchMan . addSubDirectoryMatching ( Common : : FSNode ( " / " ) , " Volumes/MONKEY3_2 " ) ;
SearchMan . addSubDirectoryMatching ( Common : : FSNode ( " / " ) , " Volumes/MONKEY3_2/RESOURCE " ) ;
2006-10-07 15:37:03 +00:00
} else
# endif
2009-09-23 00:15:00 +00:00
if ( _game . version = = 8 )
2006-10-07 15:37:03 +00:00
// This is for COMI
2010-05-04 11:56:52 +00:00
SearchMan . addSubDirectoryMatching ( gameDataDir , " resource " ) ;
2006-10-07 15:37:03 +00:00
if ( _game . version = = 7 ) {
// This is for Full Throttle & The Dig
2010-05-04 11:56:52 +00:00
SearchMan . addSubDirectoryMatching ( gameDataDir , " video " ) ;
SearchMan . addSubDirectoryMatching ( gameDataDir , " data " ) ;
2006-10-07 15:37:03 +00:00
}
# endif
2014-07-02 21:13:33 +00:00
// Extra directories needed for the Steam versions
if ( _filenamePattern . genMethod = = kGenDiskNumSteam | | _filenamePattern . genMethod = = kGenRoomNumSteam ) {
if ( _game . platform = = Common : : kPlatformWindows ) {
switch ( _game . id ) {
case GID_INDY3 :
SearchMan . addSubDirectoryMatching ( gameDataDir , " indy3 " ) ;
break ;
case GID_INDY4 :
SearchMan . addSubDirectoryMatching ( gameDataDir , " atlantis " ) ;
break ;
case GID_LOOM :
SearchMan . addSubDirectoryMatching ( gameDataDir , " loom " ) ;
break ;
# ifdef ENABLE_SCUMM_7_8
case GID_DIG :
SearchMan . addSubDirectoryMatching ( gameDataDir , " dig " ) ;
SearchMan . addSubDirectoryMatching ( gameDataDir , " dig/video " ) ;
break ;
# endif
default :
break ;
}
} else {
SearchMan . addSubDirectoryMatching ( gameDataDir , " Contents " ) ;
SearchMan . addSubDirectoryMatching ( gameDataDir , " Contents/MacOS " ) ;
SearchMan . addSubDirectoryMatching ( gameDataDir , " Contents/Resources " ) ;
SearchMan . addSubDirectoryMatching ( gameDataDir , " Contents/Resources/video " ) ;
}
}
2006-10-07 15:37:03 +00:00
2008-01-28 00:14:17 +00:00
// The kGenUnchanged method is only used for 'container files', i.e. files
2006-10-07 15:37:03 +00:00
// that contain the real game files bundled together in an archive format.
2012-02-04 17:34:08 +00:00
// This is the case of the NES, v0 and Mac versions of certain games.
2006-10-07 15:37:03 +00:00
// Note: All of these can also occur in 'extracted' form, in which case they
// are treated like any other SCUMM game.
if ( _filenamePattern . genMethod = = kGenUnchanged ) {
if ( _game . platform = = Common : : kPlatformNES ) {
// We read data directly from NES ROM instead of extracting it with
// external tool
assert ( _game . id = = GID_MANIAC ) ;
_fileHandle = new ScummNESFile ( ) ;
_containerFile = _filenamePattern . pattern ;
2007-09-19 08:40:12 +00:00
2007-02-25 07:23:52 +00:00
_filenamePattern . pattern = " %.2d.LFL " ;
_filenamePattern . genMethod = kGenRoomNum ;
} else if ( _game . platform = = Common : : kPlatformApple2GS ) {
// Read data from Apple II disk images.
const char * tmpBuf1 , * tmpBuf2 ;
assert ( _game . id = = GID_MANIAC ) ;
tmpBuf1 = " maniac1.dsk " ;
tmpBuf2 = " maniac2.dsk " ;
2007-09-19 08:40:12 +00:00
2007-02-25 07:26:41 +00:00
_fileHandle = new ScummDiskImage ( tmpBuf1 , tmpBuf2 , _game ) ;
2007-02-25 07:23:52 +00:00
_containerFile = tmpBuf1 ;
2006-10-07 15:37:03 +00:00
_filenamePattern . pattern = " %.2d.LFL " ;
_filenamePattern . genMethod = kGenRoomNum ;
} else if ( _game . platform = = Common : : kPlatformC64 ) {
// Read data from C64 disk images.
const char * tmpBuf1 , * tmpBuf2 ;
assert ( _game . id = = GID_MANIAC | | _game . id = = GID_ZAK ) ;
if ( _game . id = = GID_MANIAC ) {
2014-12-07 08:53:27 +00:00
if ( _game . features & GF_DEMO ) {
tmpBuf1 = " maniacdemo.d64 " ;
tmpBuf2 = " maniacdemo.d64 " ;
} else {
tmpBuf1 = " maniac1.d64 " ;
tmpBuf2 = " maniac2.d64 " ;
}
2006-10-07 15:37:03 +00:00
} else {
tmpBuf1 = " zak1.d64 " ;
tmpBuf2 = " zak2.d64 " ;
}
2007-09-19 08:40:12 +00:00
2007-02-25 07:26:41 +00:00
_fileHandle = new ScummDiskImage ( tmpBuf1 , tmpBuf2 , _game ) ;
2006-10-07 15:37:03 +00:00
_containerFile = tmpBuf1 ;
_filenamePattern . pattern = " %.2d.LFL " ;
_filenamePattern . genMethod = kGenRoomNum ;
} else if ( _game . platform = = Common : : kPlatformMacintosh ) {
// The mac versions of Indy4, Sam&Max, DOTT, FT and The Dig used a
// special meta (container) file format to store the actual SCUMM data
2007-09-19 08:40:12 +00:00
// files. The rescumm utility used to be used to extract those files.
// While that is still possible, we now support reading those files
2006-10-07 15:37:03 +00:00
// directly. The first step is to check whether one of them is present
2007-09-19 08:40:12 +00:00
// (we do that here); the rest is handled by the ScummFile class and
2006-10-07 15:37:03 +00:00
// code in openResourceFile() (and in the Sound class, for MONSTER.SOU
// handling).
assert ( _game . version > = 5 & & _game . heversion = = 0 ) ;
_fileHandle = new ScummFile ( ) ;
_containerFile = _filenamePattern . pattern ;
2007-09-19 08:40:12 +00:00
2006-10-07 15:37:03 +00:00
// We now have to determine the correct _filenamePattern. To do this
2008-10-02 18:11:40 +00:00
// we simply hardcode the possibilities.
2006-10-07 15:37:03 +00:00
const char * p1 = 0 , * p2 = 0 ;
switch ( _game . id ) {
case GID_INDY4 :
p1 = " atlantis.%03d " ;
break ;
case GID_TENTACLE :
p1 = " tentacle.%03d " ;
p2 = " dottdemo.%03d " ;
break ;
case GID_SAMNMAX :
p1 = " samnmax.%03d " ;
p2 = " samdemo.%03d " ;
break ;
case GID_FT :
p1 = " ft.la%d " ;
p2 = " ftdemo.la%d " ;
break ;
case GID_DIG :
p1 = " dig.la%d " ;
break ;
default :
break ;
}
// Test which file name to use
_filenamePattern . genMethod = kGenDiskNum ;
if ( ! _fileHandle - > open ( _containerFile ) )
error ( " Couldn't open container file '%s' " , _containerFile . c_str ( ) ) ;
if ( ( _filenamePattern . pattern = p1 ) & & _fileHandle - > openSubFile ( generateFilename ( 0 ) ) ) {
// Found regular version
} else if ( ( _filenamePattern . pattern = p2 ) & & _fileHandle - > openSubFile ( generateFilename ( 0 ) ) ) {
// Found demo
_game . features | = GF_DEMO ;
} else
error ( " Couldn't find known subfile inside container file '%s' " , _containerFile . c_str ( ) ) ;
2007-09-19 08:40:12 +00:00
2006-10-07 15:37:03 +00:00
_fileHandle - > close ( ) ;
} else {
2006-11-06 13:40:24 +00:00
error ( " kGenUnchanged used with unsupported platform " ) ;
2006-10-07 15:37:03 +00:00
}
} else {
2014-07-02 21:13:33 +00:00
if ( _filenamePattern . genMethod = = kGenDiskNumSteam | | _filenamePattern . genMethod = = kGenRoomNumSteam ) {
// Steam game versions have the index file embedded in the main executable
2014-07-05 12:08:24 +00:00
const SteamIndexFile * indexFile = lookUpSteamIndexFile ( _filenamePattern . pattern , _game . platform ) ;
if ( ! indexFile | | indexFile - > id ! = _game . id ) {
error ( " Couldn't find index file description for Steam version " ) ;
} else {
_fileHandle = new ScummSteamFile ( * indexFile ) ;
}
2014-07-02 21:13:33 +00:00
} else {
// Regular access, no container file involved
_fileHandle = new ScummFile ( ) ;
}
2006-10-07 15:37:03 +00:00
}
2007-09-19 08:40:12 +00:00
2014-07-02 21:13:33 +00:00
// Steam Win and Mac versions share the same DOS data files. We show Windows or Mac
// for the platform the detector, but internally we force the platform to DOS, so that
// the code for handling the original DOS data files is used.
if ( _filenamePattern . genMethod = = kGenDiskNumSteam | | _filenamePattern . genMethod = = kGenRoomNumSteam )
_game . platform = Common : : kPlatformDOS ;
2007-07-10 00:39:12 +00:00
// Load CJK font, if present
// Load it earlier so _useCJKMode variable could be set
loadCJKFont ( ) ;
2004-11-15 03:57:22 +00:00
// Initialize backend
2008-11-14 22:08:10 +00:00
if ( _renderMode = = Common : : kRenderHercA | | _renderMode = = Common : : kRenderHercG ) {
2011-06-21 14:57:42 +00:00
initGraphics ( kHercWidth , kHercHeight , true ) ;
2009-11-22 08:20:20 +00:00
} else {
int screenWidth = _screenWidth ;
int screenHeight = _screenHeight ;
if ( _useCJKMode ) {
// CJK FT and DIG use usual NUT fonts, not FM-TOWNS ROM, so
// there is no text surface for them. This takes that into account
screenWidth * = _textSurfaceMultiplier ;
screenHeight * = _textSurfaceMultiplier ;
}
2011-06-19 22:59:48 +00:00
if ( _game . features & GF_16BIT_COLOR
2010-10-05 19:04:52 +00:00
# ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
| | _game . platform = = Common : : kPlatformFMTowns
# endif
) {
2009-08-21 18:16:37 +00:00
# ifdef USE_RGB_COLOR
2011-06-19 22:59:48 +00:00
_outputPixelFormat = Graphics : : PixelFormat ( 2 , 5 , 5 , 5 , 0 , 10 , 5 , 0 , 0 ) ;
2011-06-16 18:51:09 +00:00
if ( _game . platform ! = Common : : kPlatformFMTowns & & _game . platform ! = Common : : kPlatformPCEngine ) {
2011-06-15 20:01:24 +00:00
initGraphics ( screenWidth , screenHeight , screenWidth > 320 , & _outputPixelFormat ) ;
2011-06-16 18:51:09 +00:00
if ( _outputPixelFormat ! = _system - > getScreenFormat ( ) )
return Common : : kUnsupportedColorMode ;
} else {
2011-06-19 22:59:48 +00:00
Common : : List < Graphics : : PixelFormat > tryModes = _system - > getSupportedFormats ( ) ;
2011-11-01 22:56:51 +00:00
for ( Common : : List < Graphics : : PixelFormat > : : iterator g = tryModes . begin ( ) ; g ! = tryModes . end ( ) ; + + g ) {
2011-06-16 19:31:45 +00:00
if ( g - > bytesPerPixel ! = 2 | | g - > aBits ( ) ) {
2011-11-01 22:56:51 +00:00
g = tryModes . reverse_erase ( g ) ;
2011-11-01 14:54:15 +00:00
} else if ( * g = = _outputPixelFormat ) {
2011-06-16 18:51:09 +00:00
tryModes . clear ( ) ;
tryModes . push_back ( _outputPixelFormat ) ;
break ;
}
}
2011-06-19 22:59:48 +00:00
2011-06-16 18:51:09 +00:00
initGraphics ( screenWidth , screenHeight , screenWidth > 320 , tryModes ) ;
if ( _system - > getScreenFormat ( ) . bytesPerPixel ! = 2 )
return Common : : kUnsupportedColorMode ;
2011-06-15 15:12:17 +00:00
}
2009-06-15 13:23:26 +00:00
# else
2010-10-02 13:25:50 +00:00
if ( _game . platform = = Common : : kPlatformFMTowns & & _game . version = = 3 ) {
warning ( " Starting game without the required 16bit color support. \n You may experience color glitches " ) ;
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
initGraphics ( screenWidth , screenHeight , ( screenWidth > 320 ) ) ;
} else {
2011-04-18 16:20:40 +00:00
return Common : : Error ( Common : : kUnsupportedColorMode , " 16bit color support is required for this game " ) ;
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
}
2009-06-11 05:56:00 +00:00
# endif
2009-11-22 08:20:20 +00:00
} else {
2010-10-05 19:04:52 +00:00
# ifdef DISABLE_TOWNS_DUAL_LAYER_MODE
if ( _game . platform = = Common : : kPlatformFMTowns & & _game . version = = 5 )
2011-06-16 18:51:09 +00:00
return Common : : Error ( Common : : kUnsupportedColorMode , " This game requires dual graphics layer support which is disabled in this build " ) ;
2010-10-05 19:04:52 +00:00
# endif
2009-11-22 08:20:20 +00:00
initGraphics ( screenWidth , screenHeight , ( screenWidth > 320 ) ) ;
}
2008-11-14 22:08:10 +00:00
}
2004-11-15 03:57:22 +00:00
2011-06-15 20:01:24 +00:00
_outputPixelFormat = _system - > getScreenFormat ( ) ;
2006-04-29 16:24:39 +00:00
setupScumm ( ) ;
readIndexFile ( ) ;
2006-05-29 18:30:27 +00:00
// Create the debugger now that _numVariables has been set
_debugger = new ScummDebugger ( this ) ;
2006-04-29 16:24:39 +00:00
resetScumm ( ) ;
resetScummVars ( ) ;
2007-02-19 09:46:45 +00:00
if ( _game . version > = 5 & & _game . version < = 7 )
2006-04-29 16:24:39 +00:00
_sound - > setupSound ( ) ;
2008-06-30 17:44:21 +00:00
syncSoundSettings ( ) ;
2006-04-30 20:35:43 +00:00
2008-11-06 17:05:54 +00:00
return Common : : kNoError ;
2006-04-29 16:24:39 +00:00
}
void ScummEngine : : setupScumm ( ) {
2005-06-14 08:54:11 +00:00
// On some systems it's not safe to run CD audio games from the CD.
2014-07-02 21:13:33 +00:00
if ( _game . features & GF_AUDIOTRACKS & & ! Common : : File : : exists ( " CDDA.SOU " ) ) {
2005-06-14 08:54:11 +00:00
checkCD ( ) ;
2007-09-19 08:40:12 +00:00
2006-04-29 13:56:36 +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 ) ;
2006-04-29 13:56:36 +00:00
}
2004-11-15 03:57:22 +00:00
// Create the sound manager
2006-04-23 18:52:39 +00:00
if ( _game . heversion > 0 )
2006-10-21 12:44:10 +00:00
_sound = new SoundHE ( this , _mixer ) ;
2006-04-23 18:52:39 +00:00
else
2006-10-21 12:44:10 +00:00
_sound = new Sound ( this , _mixer ) ;
2005-07-30 21:11:48 +00:00
2004-11-15 03:57:22 +00:00
// Setup the music engine
2006-02-20 16:51:30 +00:00
setupMusic ( _game . midi ) ;
2004-11-15 03:57:22 +00:00
// Load localization data, if present
loadLanguageBundle ( ) ;
// Create the charset renderer
2006-04-29 16:24:39 +00:00
setupCharsetRenderer ( ) ;
2004-11-15 03:57:22 +00:00
2007-01-28 20:11:31 +00:00
// Create and clear the text surface
2011-04-17 14:30:59 +00:00
_textSurface . create ( _screenWidth * _textSurfaceMultiplier , _screenHeight * _textSurfaceMultiplier , Graphics : : PixelFormat : : createFormatCLUT8 ( ) ) ;
2007-01-28 20:11:31 +00:00
clearTextSurface ( ) ;
2004-11-15 03:57:22 +00:00
// Create the costume renderer
2006-04-29 16:24:39 +00:00
setupCostumeRenderer ( ) ;
2004-11-15 03:57:22 +00:00
// Load game from specified slot, if any
if ( ConfMan . hasKey ( " save_slot " ) ) {
requestLoad ( ConfMan . getInt ( " save_slot " ) ) ;
2011-12-24 20:09:46 +00:00
} else if ( ! ConfMan . hasKey ( " boot_param " ) & & _game . id = = GID_LOOM & & _game . platform = = Common : : kPlatformFMTowns ) {
// In case we run the Loom FM-Towns version and have no boot parameter
// nor start save game supplied we will show our own custom difficulty
// selection dialog, since the original does not have any.
LoomTownsDifficultyDialog difficultyDialog ;
runDialog ( difficultyDialog ) ;
int difficulty = difficultyDialog . getSelectedDifficulty ( ) ;
if ( difficulty ! = - 1 )
_bootParam = difficulty ;
2004-11-15 03:57:22 +00:00
}
2011-05-11 16:19:05 +00:00
_res - > allocResTypeData ( rtBuffer , 0 , 10 , kDynamicResTypeMode ) ;
2003-07-19 18:18:01 +00:00
setupScummVars ( ) ;
setupOpcodes ( ) ;
2006-02-20 16:51:30 +00:00
if ( _game . version = = 8 )
2005-05-11 14:21:07 +00:00
_numActors = 80 ;
2006-02-20 16:51:30 +00:00
else if ( _game . version = = 7 )
2005-05-11 14:21:07 +00:00
_numActors = 30 ;
2006-02-20 16:51:30 +00:00
else if ( _game . id = = GID_SAMNMAX )
2005-05-13 06:32:01 +00:00
_numActors = 30 ;
2006-02-20 16:51:30 +00:00
else if ( _game . id = = GID_MANIAC )
2005-05-11 14:21:07 +00:00
_numActors = 25 ;
2006-02-20 16:51:30 +00:00
else if ( _game . heversion > = 80 )
2005-05-11 14:39:04 +00:00
_numActors = 62 ;
2006-02-20 16:51:30 +00:00
else if ( _game . heversion > = 72 )
2005-05-11 14:32:21 +00:00
_numActors = 30 ;
2005-07-30 21:11:48 +00:00
else
2005-05-11 14:21:07 +00:00
_numActors = 13 ;
2006-02-20 16:51:30 +00:00
if ( _game . version > = 7 )
2003-07-19 18:18:01 +00:00
OF_OWNER_ROOM = 0xFF ;
else
OF_OWNER_ROOM = 0x0F ;
2006-02-20 16:51:30 +00:00
// if (_game.id==GID_MONKEY2 && _bootParam == 0)
2003-07-19 18:18:01 +00:00
// _bootParam = 10001;
2006-02-20 16:51:30 +00:00
if ( ! _copyProtection & & _game . id = = GID_INDY4 & & _bootParam = = 0 ) {
2003-07-19 18:18:01 +00:00
_bootParam = - 7873 ;
}
2006-02-20 16:51:30 +00:00
if ( ! _copyProtection & & _game . id = = GID_SAMNMAX & & _bootParam = = 0 ) {
2004-09-18 05:00:38 +00:00
_bootParam = - 1 ;
}
2006-09-09 18:20:28 +00:00
int maxHeapThreshold = - 1 ;
2007-09-01 19:13:04 +00:00
2009-06-03 06:34:39 +00:00
if ( _game . features & GF_16BIT_COLOR ) {
2009-06-04 01:05:47 +00:00
// 16bit color games require double the memory, due to increased resource sizes.
2009-06-03 06:34:39 +00:00
maxHeapThreshold = 12 * 1024 * 1024 ;
} else if ( _game . features & GF_NEW_COSTUMES ) {
2005-06-02 14:40:13 +00:00
// Since the new costumes are very big, we increase the heap limit, to avoid having
// to constantly reload stuff from the data files.
2006-09-09 18:20:28 +00:00
maxHeapThreshold = 6 * 1024 * 1024 ;
2005-06-02 14:40:13 +00:00
} else {
2006-09-09 18:20:28 +00:00
maxHeapThreshold = 550000 ;
2005-06-02 14:40:13 +00:00
}
2007-09-01 19:13:04 +00:00
2006-09-17 20:36:48 +00:00
_res - > setHeapThreshold ( 400000 , maxHeapThreshold ) ;
2005-06-02 14:40:13 +00:00
2008-03-26 19:29:33 +00:00
free ( _compositeBuf ) ;
2011-06-15 20:01:24 +00:00
_compositeBuf = ( byte * ) malloc ( _screenWidth * _textSurfaceMultiplier * _screenHeight * _textSurfaceMultiplier * _outputPixelFormat . bytesPerPixel ) ;
2006-04-29 16:24:39 +00:00
}
2004-01-14 10:02:33 +00:00
2008-05-06 03:00:26 +00:00
# ifdef ENABLE_SCUMM_7_8
2006-10-07 13:57:06 +00:00
void ScummEngine_v7 : : setupScumm ( ) {
2009-05-10 06:46:24 +00:00
if ( _game . id = = GID_DIG & & ( _game . features & GF_DEMO ) )
_smushFrameRate = 15 ;
else
_smushFrameRate = ( _game . id = = GID_FT ) ? 10 : 12 ;
2009-05-10 06:24:58 +00:00
2009-09-26 09:31:05 +00:00
int dimuseTempo = CLIP ( ConfMan . getInt ( " dimuse_tempo " ) , 10 , 100 ) ;
ConfMan . setInt ( " dimuse_tempo " , dimuseTempo ) ;
ConfMan . flushToDisk ( ) ;
_musicEngine = _imuseDigital = new IMuseDigital ( this , _mixer , dimuseTempo ) ;
2006-10-07 13:57:06 +00:00
ScummEngine : : setupScumm ( ) ;
// Create FT INSANE object
if ( _game . id = = GID_FT )
2006-10-21 12:44:10 +00:00
_insane = new Insane ( this ) ;
2006-10-07 13:57:06 +00:00
else
_insane = 0 ;
_smixer = new SmushMixer ( _mixer ) ;
2006-10-10 12:16:21 +00:00
_splayer = new SmushPlayer ( this ) ;
2006-10-07 13:57:06 +00:00
}
# endif
2006-04-29 16:24:39 +00:00
void ScummEngine : : setupCharsetRenderer ( ) {
2009-11-22 08:20:20 +00:00
if ( _game . version < = 2 ) {
if ( _game . platform = = Common : : kPlatformNES )
_charset = new CharsetRendererNES ( this ) ;
else
_charset = new CharsetRendererV2 ( this , _language ) ;
} else if ( _game . version = = 3 ) {
2009-11-22 11:43:12 +00:00
# ifdef USE_RGB_COLOR
2009-11-22 08:20:20 +00:00
if ( _game . platform = = Common : : kPlatformPCEngine )
_charset = new CharsetRendererPCE ( this ) ;
else
2009-11-22 11:43:12 +00:00
# endif
2011-07-07 14:33:14 +00:00
if ( _game . platform = = Common : : kPlatformFMTowns )
_charset = new CharsetRendererTownsV3 ( this ) ;
else
2009-11-22 08:20:20 +00:00
_charset = new CharsetRendererV3 ( this ) ;
2008-05-06 03:00:26 +00:00
# ifdef ENABLE_SCUMM_7_8
2009-11-22 08:20:20 +00:00
} else if ( _game . version = = 8 ) {
2006-04-29 16:24:39 +00:00
_charset = new CharsetRendererNut ( this ) ;
# endif
2009-11-22 08:20:20 +00:00
} else {
2011-07-07 14:33:14 +00:00
# ifdef USE_RGB_COLOR
# ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
if ( _game . platform = = Common : : kPlatformFMTowns )
_charset = new CharsetRendererTownsClassic ( this ) ;
else
# endif
# endif
_charset = new CharsetRendererClassic ( this ) ;
2009-11-22 08:20:20 +00:00
}
2003-07-19 18:18:01 +00:00
}
2006-04-29 16:24:39 +00:00
void ScummEngine : : setupCostumeRenderer ( ) {
if ( _game . features & GF_NEW_COSTUMES ) {
_costumeRenderer = new AkosRenderer ( this ) ;
_costumeLoader = new AkosCostumeLoader ( this ) ;
2006-05-29 12:45:11 +00:00
} else if ( _game . version = = 0 ) {
2012-02-04 17:34:08 +00:00
_costumeRenderer = new V0CostumeRenderer ( this ) ;
_costumeLoader = new V0CostumeLoader ( this ) ;
2006-04-29 16:24:39 +00:00
} else if ( _game . platform = = Common : : kPlatformNES ) {
_costumeRenderer = new NESCostumeRenderer ( this ) ;
_costumeLoader = new NESCostumeLoader ( this ) ;
2009-11-22 11:43:12 +00:00
# ifdef USE_RGB_COLOR
2009-10-21 12:59:10 +00:00
} else if ( _game . platform = = Common : : kPlatformPCEngine ) {
_costumeRenderer = new PCEngineCostumeRenderer ( this ) ;
2009-10-25 14:20:47 +00:00
_costumeLoader = new ClassicCostumeLoader ( this ) ;
2009-11-22 11:43:12 +00:00
# endif
2006-04-29 16:24:39 +00:00
} else {
_costumeRenderer = new ClassicCostumeRenderer ( this ) ;
_costumeLoader = new ClassicCostumeLoader ( this ) ;
}
}
void ScummEngine : : resetScumm ( ) {
2001-10-09 14:30:12 +00:00
int i ;
2006-04-29 16:24:39 +00:00
debug ( 9 , " resetScumm " ) ;
2001-11-26 19:57:57 +00:00
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
# ifdef USE_RGB_COLOR
2010-10-05 19:04:52 +00:00
if ( _game . features & GF_16BIT_COLOR
# ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
2011-06-15 20:01:24 +00:00
| | ( _game . platform = = Common : : kPlatformFMTowns )
2010-10-05 19:04:52 +00:00
# endif
)
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
_16BitPalette = ( uint16 * ) calloc ( 512 , sizeof ( uint16 ) ) ;
# endif
2011-08-26 03:51:08 +00:00
// Indy4 Amiga needs another palette map for the verb area.
if ( _game . platform = = Common : : kPlatformAmiga & & _game . id = = GID_INDY4 & & ! _verbPalette )
_verbPalette = ( uint8 * ) calloc ( 256 , 1 ) ;
2010-10-05 19:04:52 +00:00
# ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
if ( _game . platform = = Common : : kPlatformFMTowns ) {
delete _townsScreen ;
2011-06-15 20:01:24 +00:00
_townsScreen = new TownsScreen ( _system , _screenWidth * _textSurfaceMultiplier , _screenHeight * _textSurfaceMultiplier , _outputPixelFormat ) ;
_townsScreen - > setupLayer ( 0 , _screenWidth , _screenHeight , ( _outputPixelFormat . bytesPerPixel = = 2 ) ? 32767 : 256 ) ;
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
_townsScreen - > setupLayer ( 1 , _screenWidth * _textSurfaceMultiplier , _screenHeight * _textSurfaceMultiplier , 16 , _textPalette ) ;
}
2010-10-05 19:04:52 +00:00
# endif
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
2006-05-29 12:45:11 +00:00
if ( _game . version = = 0 ) {
initScreens ( 8 , 144 ) ;
} else if ( ( _game . id = = GID_MANIAC ) & & ( _game . version < = 1 ) & & ! ( _game . platform = = Common : : kPlatformNES ) ) {
initScreens ( 16 , 152 ) ;
2006-02-20 16:51:30 +00:00
} else if ( _game . version > = 7 | | _game . heversion > = 71 ) {
2004-01-04 14:49:14 +00:00
initScreens ( 0 , _screenHeight ) ;
2002-12-26 01:47:40 +00:00
} else {
2004-01-04 14:49:14 +00:00
initScreens ( 16 , 144 ) ;
2002-12-26 01:47:40 +00:00
}
2005-04-10 00:51:47 +00:00
_palManipCounter = 0 ;
2003-10-13 12:17:26 +00:00
for ( i = 0 ; i < 256 ; i + + )
_roomPalette [ i ] = i ;
2006-04-29 16:24:39 +00:00
resetPalette ( ) ;
2006-02-20 16:51:30 +00:00
if ( _game . version = = 1 ) {
} else if ( _game . features & GF_16COLOR ) {
2003-10-13 12:17:26 +00:00
for ( i = 0 ; i < 16 ; i + + )
2003-07-11 14:54:16 +00:00
_shadowPalette [ i ] = i ;
2003-04-08 20:10:51 +00:00
}
2003-05-30 14:29:07 +00:00
2006-02-27 12:00:10 +00:00
if ( _game . version > = 4 & & _game . version < = 7 )
2002-04-11 17:19:16 +00:00
loadCharset ( 1 ) ;
2005-07-30 21:11:48 +00:00
2006-02-20 16:51:30 +00:00
if ( _game . features & GF_OLD_BUNDLE )
2006-02-27 12:00:10 +00:00
loadCharset ( 0 ) ;
2001-12-27 17:51:58 +00:00
2001-10-09 14:30:12 +00:00
setShake ( 0 ) ;
2006-04-29 16:24:39 +00:00
_cursor . animate = 1 ;
2005-07-30 21:11:48 +00:00
2002-12-29 19:54:11 +00:00
// Allocate and Initialize actors
2007-03-12 12:11:59 +00:00
Actor : : kInvalidBox = ( ( _game . features & GF_SMALL_HEADER ) ? kOldInvalidBox : kNewInavlidBox ) ;
2006-12-25 15:03:36 +00:00
_actors = new Actor * [ _numActors ] ;
2005-04-30 22:01:16 +00:00
_sortedActors = new Actor * [ _numActors ] ;
2006-12-25 15:03:36 +00:00
for ( i = 0 ; i < _numActors ; + + i ) {
2006-12-25 15:37:20 +00:00
if ( _game . version = = 0 )
2012-02-04 17:34:08 +00:00
_actors [ i ] = new Actor_v0 ( this , i ) ;
2007-03-10 13:53:11 +00:00
else if ( _game . version < = 2 )
2007-03-12 12:11:59 +00:00
_actors [ i ] = new Actor_v2 ( this , i ) ;
2007-03-10 13:53:11 +00:00
else if ( _game . version = = 3 )
2007-03-12 12:11:59 +00:00
_actors [ i ] = new Actor_v3 ( this , i ) ;
2008-09-25 08:06:18 +00:00
else if ( _game . heversion ! = 0 )
_actors [ i ] = new ActorHE ( this , i ) ;
2006-12-25 15:37:20 +00:00
else
2007-03-12 12:11:59 +00:00
_actors [ i ] = new Actor ( this , i ) ;
2007-01-05 23:33:13 +00:00
_actors [ i ] - > initActor ( - 1 ) ;
2005-07-30 21:11:48 +00:00
2003-06-07 04:24:57 +00:00
// this is from IDB
2006-05-29 12:45:11 +00:00
if ( ( _game . version < = 1 ) | | ( _game . id = = GID_MANIAC & & ( _game . features & GF_DEMO ) ) )
2006-12-25 15:03:36 +00:00
_actors [ i ] - > setActorCostume ( i ) ;
2001-10-09 14:30:12 +00:00
}
2003-03-06 17:58:13 +00:00
2006-05-29 12:45:11 +00:00
if ( _game . id = = GID_MANIAC & & _game . version < = 1 ) {
2006-04-29 16:24:39 +00:00
resetV1ActorTalkColor ( ) ;
2006-04-23 00:08:18 +00:00
} else if ( _game . id = = GID_MANIAC & & _game . version = = 2 & & ( _game . features & GF_DEMO ) ) {
2004-07-26 15:14:10 +00:00
// HACK Some palette changes needed for demo script
2004-08-21 22:33:23 +00:00
// in Maniac Mansion (Enhanced)
2006-12-25 15:03:36 +00:00
_actors [ 3 ] - > setPalette ( 3 , 1 ) ;
_actors [ 9 ] - > _talkColor = 15 ;
_actors [ 10 ] - > _talkColor = 7 ;
_actors [ 11 ] - > _talkColor = 2 ;
_actors [ 13 ] - > _talkColor = 5 ;
_actors [ 23 ] - > _talkColor = 14 ;
2004-03-04 03:08:42 +00:00
}
2003-09-11 10:32:15 +00:00
vm . numNestedScripts = 0 ;
2001-10-09 14:30:12 +00:00
vm . cutSceneStackPointer = 0 ;
memset ( vm . cutScenePtr , 0 , sizeof ( vm . cutScenePtr ) ) ;
memset ( vm . cutSceneData , 0 , sizeof ( vm . cutSceneData ) ) ;
2003-12-26 23:11:35 +00:00
for ( i = 0 ; i < _numVerbs ; i + + ) {
2001-10-16 10:01:48 +00:00
_verbs [ i ] . verbid = 0 ;
2004-01-15 19:25:17 +00:00
_verbs [ i ] . curRect . right = _screenWidth - 1 ;
_verbs [ i ] . oldRect . left = - 1 ;
2001-10-16 10:01:48 +00:00
_verbs [ i ] . type = 0 ;
_verbs [ i ] . color = 2 ;
_verbs [ i ] . hicolor = 0 ;
_verbs [ i ] . charset_nr = 1 ;
_verbs [ i ] . curmode = 0 ;
_verbs [ i ] . saveid = 0 ;
2002-04-11 17:19:16 +00:00
_verbs [ i ] . center = 0 ;
2001-10-16 10:01:48 +00:00
_verbs [ i ] . key = 0 ;
2001-10-09 14:30:12 +00:00
}
2007-02-10 02:05:59 +00:00
if ( _game . version > = 7 ) {
2004-08-06 02:10:23 +00:00
VAR ( VAR_CAMERA_THRESHOLD_X ) = 100 ;
VAR ( VAR_CAMERA_THRESHOLD_Y ) = 70 ;
VAR ( VAR_CAMERA_ACCEL_X ) = 100 ;
VAR ( VAR_CAMERA_ACCEL_Y ) = 100 ;
2006-02-26 06:15:13 +00:00
} else {
2006-02-20 16:51:30 +00:00
if ( _game . platform = = Common : : kPlatformNES ) {
2005-03-21 23:51:48 +00:00
camera . _leftTrigger = 6 ; // 6
camera . _rightTrigger = 21 ; // 25
2005-03-15 04:24:49 +00:00
} else {
camera . _leftTrigger = 10 ;
2006-02-20 16:51:30 +00:00
camera . _rightTrigger = ( _game . heversion > = 71 ) ? 70 : 30 ;
2005-03-15 04:24:49 +00:00
}
2002-03-05 23:41:41 +00:00
camera . _mode = 0 ;
2002-04-11 17:19:16 +00:00
}
2001-10-09 14:30:12 +00:00
camera . _follows = 0 ;
2007-09-08 11:15:27 +00:00
_virtscr [ 0 ] . xstart = 0 ;
2001-10-09 14:30:12 +00:00
2003-05-15 22:41:35 +00:00
_mouse . x = 104 ;
_mouse . y = 56 ;
2001-10-09 14:30:12 +00:00
_ENCD_offs = 0 ;
_EXCD_offs = 0 ;
_currentScript = 0xFF ;
2001-11-26 19:57:57 +00:00
_sentenceNum = 0 ;
2001-10-09 14:30:12 +00:00
_currentRoom = 0 ;
_numObjectsInRoom = 0 ;
_actorToPrintStrFor = 0 ;
2002-12-26 00:21:19 +00:00
_charsetBufPos = 0 ;
2001-10-09 14:30:12 +00:00
_haveMsg = 0 ;
2005-11-02 21:47:44 +00:00
_haveActorSpeechMsg = false ;
2001-10-09 14:30:12 +00:00
2002-03-06 10:03:00 +00:00
_varwatch = - 1 ;
2001-10-09 14:30:12 +00:00
_screenStartStrip = 0 ;
2004-02-21 06:44:10 +00:00
_defaultTalkDelay = 3 ;
2001-10-09 14:30:12 +00:00
_talkDelay = 0 ;
_keepText = false ;
2007-01-28 20:11:31 +00:00
_nextLeft = 0 ;
_nextTop = 0 ;
2001-10-09 14:30:12 +00:00
2002-12-04 13:36:27 +00:00
_currentCursor = 0 ;
2002-12-04 22:31:36 +00:00
_cursor . state = 0 ;
2001-10-09 14:30:12 +00:00
_userPut = 0 ;
2002-04-11 17:19:16 +00:00
2001-10-09 14:30:12 +00:00
_newEffect = 129 ;
2001-11-09 18:54:15 +00:00
_fullRedraw = true ;
2001-10-09 14:30:12 +00:00
clearDrawObjectQueue ( ) ;
2006-02-20 16:51:30 +00:00
if ( _game . platform = = Common : : kPlatformNES )
2005-03-16 03:20:32 +00:00
decodeNESBaseTiles ( ) ;
2005-03-14 21:13:35 +00:00
2002-04-11 17:19:16 +00:00
for ( i = 0 ; i < 6 ; i + + ) {
2006-02-20 16:51:30 +00:00
if ( _game . version = = 3 ) { // FIXME - what is this?
2004-04-05 23:54:58 +00:00
_string [ i ] . _default . xpos = 0 ;
_string [ i ] . _default . ypos = 0 ;
2002-02-19 22:36:09 +00:00
} else {
2004-04-05 23:54:58 +00:00
_string [ i ] . _default . xpos = 2 ;
_string [ i ] . _default . ypos = 5 ;
2002-02-19 22:36:09 +00:00
}
2004-04-05 23:54:58 +00:00
_string [ i ] . _default . right = _screenWidth - 1 ;
2005-03-18 15:04:37 +00:00
_string [ i ] . _default . height = 0 ;
2004-04-05 23:54:58 +00:00
_string [ i ] . _default . color = 0xF ;
_string [ i ] . _default . center = 0 ;
_string [ i ] . _default . charset = 0 ;
2001-10-09 14:30:12 +00:00
}
2003-12-05 00:02:01 +00:00
// all keys are released
for ( i = 0 ; i < 512 ; i + + )
_keyDownMap [ i ] = false ;
2004-09-28 20:19:37 +00:00
_lastSaveTime = _system - > getMillis ( ) ;
2004-09-26 07:30:29 +00:00
}
2004-09-13 23:24:36 +00:00
2007-02-25 11:38:19 +00:00
void ScummEngine_v0 : : resetScumm ( ) {
2006-04-29 16:24:39 +00:00
ScummEngine_v2 : : resetScumm ( ) ;
2007-03-06 07:09:18 +00:00
resetVerbs ( ) ;
2005-10-02 13:21:49 +00:00
}
2006-04-29 16:24:39 +00:00
void ScummEngine_v2 : : resetScumm ( ) {
2009-03-16 04:45:12 +00:00
ScummEngine_v3 : : resetScumm ( ) ;
2004-09-13 23:24:36 +00:00
2006-02-20 16:51:30 +00:00
if ( _game . platform = = Common : : kPlatformNES ) {
2005-03-22 00:46:48 +00:00
initNESMouseOver ( ) ;
2005-03-21 00:27:39 +00:00
_switchRoomEffect2 = _switchRoomEffect = 6 ;
} else {
2005-03-22 00:46:48 +00:00
initV2MouseOver ( ) ;
2005-03-21 00:27:39 +00:00
// Seems in V2 there was only a single room effect (iris),
// so we set that here.
_switchRoomEffect2 = 1 ;
_switchRoomEffect = 5 ;
}
2005-10-15 06:41:48 +00:00
_inventoryOffset = 0 ;
2001-10-09 14:30:12 +00:00
}
2009-03-16 04:45:12 +00:00
void ScummEngine_v3 : : resetScumm ( ) {
ScummEngine_v4 : : resetScumm ( ) ;
2009-10-27 09:17:09 +00:00
if ( _game . id = = GID_LOOM & & _game . platform = = Common : : kPlatformPCEngine ) {
// Load tile set and palette for the distaff
byte * roomptr = getResourceAddress ( rtRoom , 90 ) ;
assert ( roomptr ) ;
2011-04-12 14:53:15 +00:00
const byte * palPtr = findResourceData ( MKTAG ( ' C ' , ' L ' , ' U ' , ' T ' ) , roomptr ) ;
2009-10-27 09:17:09 +00:00
assert ( palPtr - 4 ) ;
setPCEPaletteFromPtr ( palPtr ) ;
_gdi - > _distaff = true ;
_gdi - > loadTiles ( roomptr ) ;
_gdi - > _distaff = false ;
}
2009-10-26 09:11:18 +00:00
2009-03-16 04:45:12 +00:00
delete _savePreparedSavegame ;
_savePreparedSavegame = NULL ;
}
2006-04-29 16:24:39 +00:00
void ScummEngine_v4 : : resetScumm ( ) {
ScummEngine : : resetScumm ( ) ;
2006-03-19 02:50:51 +00:00
// WORKAROUND for bug in boot script of Loom (CD)
2007-09-19 08:40:12 +00:00
// The boot script sets the characters of string 21,
2006-03-19 02:50:51 +00:00
// before creating the string.resource.
if ( _game . id = = GID_LOOM ) {
2006-09-17 20:36:48 +00:00
_res - > createResource ( rtString , 21 , 12 ) ;
2006-03-19 02:50:51 +00:00
}
}
2006-04-29 16:24:39 +00:00
void ScummEngine_v6 : : resetScumm ( ) {
ScummEngine : : resetScumm ( ) ;
2005-07-19 17:53:55 +00:00
setDefaultCursor ( ) ;
2004-10-13 08:08:45 +00:00
}
2006-04-29 16:24:39 +00:00
void ScummEngine_v60he : : resetScumm ( ) {
ScummEngine_v6 : : resetScumm ( ) ;
2004-09-18 20:29:13 +00:00
// HACK cursor hotspot is wrong
2005-07-30 21:11:48 +00:00
// Original games used
2004-09-18 20:29:13 +00:00
// setCursorHotspot(8, 7);
2006-02-20 16:51:30 +00:00
if ( _game . id = = GID_FUNPACK )
2004-09-18 20:29:13 +00:00
setCursorHotspot ( 16 , 16 ) ;
2004-09-26 07:30:29 +00:00
}
2008-05-06 03:00:26 +00:00
# ifdef ENABLE_HE
2006-04-29 16:24:39 +00:00
void ScummEngine_v72he : : resetScumm ( ) {
ScummEngine_v60he : : resetScumm ( ) ;
2005-04-13 10:34:47 +00:00
_stringLength = 1 ;
memset ( _stringBuffer , 0 , sizeof ( _stringBuffer ) ) ;
}
2006-04-29 16:24:39 +00:00
void ScummEngine_v90he : : resetScumm ( ) {
ScummEngine_v72he : : resetScumm ( ) ;
2004-10-13 09:18:17 +00:00
_heObject = 0 ;
_heObjectNum = 0 ;
_hePaletteNum = 0 ;
2005-05-23 11:50:36 +00:00
_sprite - > resetTables ( 0 ) ;
2004-09-26 15:29:58 +00:00
memset ( & _wizParams , 0 , sizeof ( _wizParams ) ) ;
2005-04-20 03:13:06 +00:00
2011-08-17 06:26:49 +00:00
if ( _game . heversion > = 98 )
_logicHE = LogicHE : : makeLogicHE ( this ) ;
2004-09-26 15:29:58 +00:00
}
2006-04-29 16:24:39 +00:00
void ScummEngine_v99he : : resetScumm ( ) {
2008-12-29 10:03:34 +00:00
byte * data ;
Common : : String ininame = _targetName + " .ini " ;
int len ;
2006-04-29 16:24:39 +00:00
ScummEngine_v90he : : resetScumm ( ) ;
2005-04-07 11:15:10 +00:00
2009-06-04 01:05:47 +00:00
_hePaletteSlot = ( _game . features & GF_16BIT_COLOR ) ? 1280 : 1024 ;
_hePalettes = ( uint8 * ) malloc ( ( _numPalettes + 1 ) * _hePaletteSlot ) ;
memset ( _hePalettes , 0 , ( _numPalettes + 1 ) * _hePaletteSlot ) ;
2005-04-08 00:38:12 +00:00
// Array 129 is set to base name
2008-12-29 10:03:34 +00:00
len = strlen ( _filenamePattern . pattern ) ;
data = defineArray ( 129 , kStringArray , 0 , 0 , 0 , len ) ;
2006-10-20 19:44:27 +00:00
memcpy ( data , _filenamePattern . pattern , len ) ;
2008-12-29 10:03:34 +00:00
// Array 132 is set to game path
data = defineArray ( 132 , kStringArray , 0 , 0 , 0 , 0 ) ;
// Array 137 is set to Windows directory, plus INI file
len = strlen ( ininame . c_str ( ) ) ;
data = defineArray ( 137 , kStringArray , 0 , 0 , 0 , len ) ;
memcpy ( data , ininame . c_str ( ) , len ) ;
2005-04-07 11:15:10 +00:00
}
2008-09-06 01:02:45 +00:00
void ScummEngine_v100he : : resetScumm ( ) {
ScummEngine_v99he : : resetScumm ( ) ;
memset ( _debugInputBuffer , 0 , sizeof ( _debugInputBuffer ) ) ;
}
2005-05-14 14:06:37 +00:00
# endif
2005-04-07 11:15:10 +00:00
2004-09-20 22:04:06 +00:00
void ScummEngine : : setupMusic ( int midi ) {
2010-06-21 21:36:36 +00:00
MidiDriver : : DeviceHandle dev = MidiDriver : : detectDevice ( midi ) ;
_native_mt32 = ( ( MidiDriver : : getMusicType ( dev ) = = MT_MT32 ) | | ConfMan . getBool ( " native_mt32 " ) ) ;
2007-09-19 08:40:12 +00:00
2010-06-21 21:36:36 +00:00
switch ( MidiDriver : : getMusicType ( dev ) ) {
case MT_NULL :
2011-08-05 12:33:42 +00:00
_sound - > _musicType = MDT_NONE ;
2005-12-30 14:18:21 +00:00
break ;
2010-06-21 21:36:36 +00:00
case MT_PCSPK :
2011-08-05 12:33:42 +00:00
_sound - > _musicType = MDT_PCSPK ;
2010-08-11 15:09:07 +00:00
break ;
2010-08-11 14:32:33 +00:00
case MT_PCJR :
2011-08-05 12:33:42 +00:00
_sound - > _musicType = MDT_PCJR ;
2005-12-30 14:18:21 +00:00
break ;
2011-08-05 20:46:26 +00:00
case MT_CMS :
2011-08-06 10:39:37 +00:00
_sound - > _musicType = MDT_CMS ;
2009-06-06 18:21:49 +00:00
break ;
2010-06-21 21:36:36 +00:00
case MT_TOWNS :
2011-08-05 12:33:42 +00:00
_sound - > _musicType = MDT_TOWNS ;
2005-12-30 14:18:21 +00:00
break ;
2010-06-21 21:36:36 +00:00
case MT_ADLIB :
2011-08-05 12:33:42 +00:00
_sound - > _musicType = MDT_ADLIB ;
2005-12-30 14:18:21 +00:00
break ;
2010-08-11 18:54:56 +00:00
case MT_C64 :
2011-08-05 12:33:42 +00:00
_sound - > _musicType = MDT_C64 ;
2010-08-11 18:54:56 +00:00
break ;
case MT_APPLEIIGS :
2011-08-05 12:33:42 +00:00
_sound - > _musicType = MDT_APPLEIIGS ;
2010-08-11 18:54:56 +00:00
break ;
2005-12-30 14:18:21 +00:00
default :
2011-08-05 12:33:42 +00:00
_sound - > _musicType = MDT_MIDI ;
2005-12-30 14:18:21 +00:00
break ;
}
2007-04-29 18:26:27 +00:00
if ( ( _game . id = = GID_MONKEY_EGA | | ( _game . id = = GID_LOOM & & _game . version = = 3 ) )
2013-05-02 22:26:58 +00:00
& & ( _game . platform = = Common : : kPlatformDOS ) & & _sound - > _musicType = = MDT_MIDI ) {
2007-04-29 18:26:27 +00:00
Common : : String fileName ;
bool missingFile = false ;
if ( _game . id = = GID_LOOM ) {
Common : : File f ;
// The Roland Update does have an 85.LFL, but we don't
// test for it since the demo doesn't have it.
for ( char c = ' 2 ' ; c < = ' 4 ' ; c + + ) {
fileName = " 8 " ;
fileName + = c ;
fileName + = " .LFL " ;
if ( ! Common : : File : : exists ( fileName ) ) {
missingFile = true ;
break ;
}
}
} else if ( _game . id = = GID_MONKEY_EGA ) {
fileName = " DISK09.LEC " ;
if ( ! Common : : File : : exists ( fileName ) ) {
missingFile = true ;
}
}
if ( missingFile ) {
GUI : : MessageDialog dialog (
2011-06-13 21:19:18 +00:00
Common : : String : : format (
_ ( " Native MIDI support requires the Roland Upgrade from LucasArts, \n "
" but %s is missing. Using AdLib instead. " ) , fileName . c_str ( ) ) ,
2011-06-13 21:21:43 +00:00
_ ( " OK " ) ) ;
2007-04-29 18:26:27 +00:00
dialog . runModal ( ) ;
2011-08-05 12:33:42 +00:00
_sound - > _musicType = MDT_ADLIB ;
2007-04-29 18:26:27 +00:00
}
}
2007-09-19 08:40:12 +00:00
2007-02-11 03:01:28 +00:00
// DOTT + SAM use General MIDI, so they shouldn't use GS settings
if ( ( _game . id = = GID_TENTACLE ) | | ( _game . id = = GID_SAMNMAX ) )
2005-04-13 00:11:49 +00:00
_enable_gs = false ;
2005-07-30 21:11:48 +00:00
else
2005-04-13 00:11:49 +00:00
_enable_gs = ConfMan . getBool ( " enable_gs " ) ;
2003-04-22 04:40:30 +00:00
2004-09-20 22:04:06 +00:00
/* Bind the mixer to the system => mixer will be invoked
* automatically when samples need to be generated */
if ( ! _mixer - > isReady ( ) ) {
2006-11-01 17:46:00 +00:00
warning ( " Sound mixer initialization failed " ) ;
2011-08-05 12:33:42 +00:00
if ( _sound - > _musicType = = MDT_ADLIB | | _sound - > _musicType = = MDT_PCSPK | | _sound - > _musicType = = MDT_PCJR | | _sound - > _musicType = = MDT_CMS ) {
2010-06-21 21:36:36 +00:00
dev = 0 ;
2011-08-05 12:33:42 +00:00
_sound - > _musicType = MDT_NONE ;
2009-05-31 10:02:16 +00:00
warning ( " MIDI driver depends on sound mixer, switching to null MIDI driver " ) ;
2003-12-26 07:31:39 +00:00
}
2003-06-07 00:13:26 +00:00
}
2004-09-20 22:04:06 +00:00
// Init iMuse
2007-02-10 02:05:59 +00:00
if ( _game . version > = 7 ) {
2006-10-07 13:57:06 +00:00
// Setup for digital iMuse is performed in another place
2009-02-16 06:23:41 +00:00
} else if ( _game . platform = = Common : : kPlatformApple2GS & & _game . version = = 0 ) {
2011-10-09 10:47:47 +00:00
_musicEngine = new Player_AppleII ( this , _mixer ) ;
2009-02-16 06:23:41 +00:00
} else if ( _game . platform = = Common : : kPlatformC64 & & _game . version < = 1 ) {
2010-02-26 17:42:40 +00:00
# ifndef DISABLE_SID
2009-11-26 00:31:19 +00:00
_musicEngine = new Player_SID ( this , _mixer ) ;
2010-02-26 17:42:40 +00:00
# endif
2009-02-16 06:23:41 +00:00
} else if ( _game . platform = = Common : : kPlatformNES & & _game . version = = 1 ) {
2010-08-03 11:25:20 +00:00
# ifndef DISABLE_NES_APU
2006-10-21 12:44:10 +00:00
_musicEngine = new Player_NES ( this , _mixer ) ;
2010-08-03 11:25:20 +00:00
# endif
2009-02-16 06:23:41 +00:00
} else if ( _game . platform = = Common : : kPlatformAmiga & & _game . version = = 2 ) {
2006-10-21 12:44:10 +00:00
_musicEngine = new Player_V2A ( this , _mixer ) ;
2009-02-16 06:23:41 +00:00
} else if ( _game . platform = = Common : : kPlatformAmiga & & _game . version = = 3 ) {
2006-10-21 12:44:10 +00:00
_musicEngine = new Player_V3A ( this , _mixer ) ;
2009-11-24 00:15:10 +00:00
# ifdef USE_RGB_COLOR
2009-02-16 06:23:41 +00:00
} else if ( _game . platform = = Common : : kPlatformPCEngine & & _game . version = = 3 ) {
2009-11-23 23:17:15 +00:00
_musicEngine = new Player_PCE ( this , _mixer ) ;
2009-11-24 00:15:10 +00:00
# endif
2009-02-16 06:23:41 +00:00
} else if ( _game . platform = = Common : : kPlatformAmiga & & _game . version < = 4 ) {
2009-06-12 20:10:27 +00:00
_musicEngine = new Player_V4A ( this , _mixer ) ;
2012-11-13 21:49:12 +00:00
} else if ( _game . platform = = Common : : kPlatformMacintosh & & _game . id = = GID_LOOM ) {
_musicEngine = new Player_V3M ( this , _mixer ) ;
2012-11-14 20:20:40 +00:00
( ( Player_V3M * ) _musicEngine ) - > init ( ) ;
2012-11-11 12:56:06 +00:00
} else if ( _game . platform = = Common : : kPlatformMacintosh & & _game . id = = GID_MONKEY ) {
_musicEngine = new Player_V5M ( this , _mixer ) ;
2012-11-14 20:20:40 +00:00
( ( Player_V5M * ) _musicEngine ) - > init ( ) ;
2009-02-16 06:23:41 +00:00
} else if ( _game . id = = GID_MANIAC & & _game . version = = 1 ) {
2010-06-21 21:36:36 +00:00
_musicEngine = new Player_V1 ( this , _mixer , MidiDriver : : getMusicType ( dev ) ! = MT_PCSPK ) ;
2006-02-20 16:51:30 +00:00
} else if ( _game . version < = 2 ) {
2010-06-21 21:36:36 +00:00
_musicEngine = new Player_V2 ( this , _mixer , MidiDriver : : getMusicType ( dev ) ! = MT_PCSPK ) ;
2011-08-05 12:33:42 +00:00
} else if ( ( _sound - > _musicType = = MDT_PCSPK | | _sound - > _musicType = = MDT_PCJR ) & & ( _game . version > 2 & & _game . version < = 4 ) ) {
2010-06-21 21:36:36 +00:00
_musicEngine = new Player_V2 ( this , _mixer , MidiDriver : : getMusicType ( dev ) ! = MT_PCSPK ) ;
2011-08-05 12:33:42 +00:00
} else if ( _sound - > _musicType = = MDT_CMS ) {
2009-06-06 18:21:49 +00:00
_musicEngine = new Player_V2CMS ( this , _mixer ) ;
2010-04-04 09:36:10 +00:00
} else if ( _game . platform = = Common : : kPlatform3DO & & _game . heversion < = 62 ) {
2009-02-16 06:23:41 +00:00
// 3DO versions use digital music and sound samples.
2010-08-18 21:38:43 +00:00
} else if ( _game . platform = = Common : : kPlatformFMTowns & & ( _game . version = = 3 | | _game . id = = GID_MONKEY ) ) {
2010-10-05 19:04:52 +00:00
_musicEngine = _townsPlayer = new Player_Towns_v1 ( this , _mixer ) ;
2010-08-18 21:38:43 +00:00
if ( ! _townsPlayer - > init ( ) )
2010-09-18 10:55:16 +00:00
error ( " Failed to initialize FM-Towns audio driver " ) ;
2013-05-02 22:58:32 +00:00
} else if ( _game . platform = = Common : : kPlatformDOS & & ( _sound - > _musicType = = MDT_ADLIB ) & & ( _game . id = = GID_LOOM | | _game . id = = GID_INDY3 ) ) {
// For Indy3 DOS and Loom DOS we use an implementation of the original
// AD player when AdLib is selected. This fixes sound effects in those
// games (see for example bug #2027877 "INDY3: Non-Looping Sound
// Effects"). The player itself is also used in Monkey Island DOS
// EGA/VGA. However, we support multi MIDI for that game and we cannot
// support this with the Player_AD code at the moment. The reason here
// is that multi MIDI is supported internally by our iMuse output.
2015-07-19 15:08:08 +00:00
_musicEngine = new Player_AD ( this ) ;
2010-04-04 09:36:10 +00:00
} else if ( _game . version > = 3 & & _game . heversion < = 62 ) {
2005-12-30 14:18:21 +00:00
MidiDriver * nativeMidiDriver = 0 ;
MidiDriver * adlibMidiDriver = 0 ;
2011-08-05 12:33:42 +00:00
bool multi_midi = ConfMan . getBool ( " multi_midi " ) & & _sound - > _musicType ! = MDT_NONE & & _sound - > _musicType ! = MDT_PCSPK & & ( midi & MDT_ADLIB ) ;
2012-09-20 01:48:48 +00:00
bool useOnlyNative = false ;
2012-09-20 15:58:04 +00:00
if ( isMacM68kIMuse ( ) ) {
2012-09-20 01:48:48 +00:00
// We setup this driver as native MIDI driver to avoid playback
// of the Mac music via a selected MIDI device.
nativeMidiDriver = new MacM68kDriver ( _mixer ) ;
2012-09-19 23:32:49 +00:00
// The Mac driver is never MT-32.
_native_mt32 = false ;
2012-09-20 01:48:48 +00:00
// Ignore non-native drivers. This also ignores the multi MIDI setting.
useOnlyNative = true ;
} else if ( _sound - > _musicType ! = MDT_ADLIB & & _sound - > _musicType ! = MDT_TOWNS & & _sound - > _musicType ! = MDT_PCSPK ) {
nativeMidiDriver = MidiDriver : : createMidi ( dev ) ;
}
if ( nativeMidiDriver ! = NULL & & _native_mt32 )
nativeMidiDriver - > property ( MidiDriver : : PROP_CHANNEL_MASK , 0x03FE ) ;
if ( ! useOnlyNative ) {
if ( _sound - > _musicType = = MDT_ADLIB | | _sound - > _musicType = = MDT_TOWNS | | multi_midi ) {
adlibMidiDriver = MidiDriver : : createMidi ( MidiDriver : : detectDevice ( _sound - > _musicType = = MDT_TOWNS ? MDT_TOWNS : MDT_ADLIB ) ) ;
adlibMidiDriver - > property ( MidiDriver : : PROP_OLD_ADLIB , ( _game . features & GF_SMALL_HEADER ) ? 1 : 0 ) ;
2012-09-30 23:51:04 +00:00
// Try to use OPL3 mode for Sam&Max when possible.
adlibMidiDriver - > property ( MidiDriver : : PROP_SCUMM_OPL3 , ( _game . id = = GID_SAMNMAX ) ? 1 : 0 ) ;
2012-09-20 01:48:48 +00:00
} else if ( _sound - > _musicType = = MDT_PCSPK ) {
adlibMidiDriver = new PcSpkDriver ( _mixer ) ;
}
2011-04-30 13:56:18 +00:00
}
2004-11-27 14:53:37 +00:00
2010-10-07 19:23:49 +00:00
_imuse = IMuse : : create ( _system , nativeMidiDriver , adlibMidiDriver ) ;
2011-06-19 22:59:48 +00:00
2010-10-07 19:23:49 +00:00
if ( _game . platform = = Common : : kPlatformFMTowns ) {
2011-04-30 13:56:18 +00:00
_musicEngine = _townsPlayer = new Player_Towns_v2 ( this , _mixer , _imuse , true ) ;
2010-10-07 19:23:49 +00:00
if ( ! _townsPlayer - > init ( ) )
2011-04-30 13:56:18 +00:00
error ( " ScummEngine::setupMusic(): Failed to initialize FM-Towns audio driver " ) ;
2010-10-07 19:23:49 +00:00
} else {
_musicEngine = _imuse ;
}
2004-09-20 22:04:06 +00:00
if ( _imuse ) {
2006-03-12 18:06:22 +00:00
_imuse - > addSysexHandler
( /*IMUSE_SYSEX_ID*/ 0x7D ,
( _game . id = = GID_SAMNMAX ) ? sysexHandler_SamNMax : sysexHandler_Scumm ) ;
2006-03-05 21:30:44 +00:00
_imuse - > property ( IMuse : : PROP_GAME_ID , _game . id ) ;
2004-09-20 22:04:06 +00:00
if ( ConfMan . hasKey ( " tempo " ) )
_imuse - > property ( IMuse : : PROP_TEMPO_BASE , ConfMan . getInt ( " tempo " ) ) ;
2011-03-23 10:27:58 +00:00
if ( midi ! = MDT_NONE ) {
2007-02-11 03:01:28 +00:00
_imuse - > property ( IMuse : : PROP_NATIVE_MT32 , _native_mt32 ) ;
2010-06-21 21:36:36 +00:00
if ( MidiDriver : : getMusicType ( dev ) ! = MT_MT32 ) // MT-32 Emulation shouldn't be GM/GS initialized
2007-02-11 03:01:28 +00:00
_imuse - > property ( IMuse : : PROP_GS , _enable_gs ) ;
}
2011-03-23 10:27:58 +00:00
if ( _game . heversion > = 60 ) {
2004-09-20 22:04:06 +00:00
_imuse - > property ( IMuse : : PROP_LIMIT_PLAYERS , 1 ) ;
_imuse - > property ( IMuse : : PROP_RECYCLE_PLAYERS , 1 ) ;
}
2011-08-05 12:33:42 +00:00
if ( _sound - > _musicType = = MDT_PCSPK )
2011-07-10 03:21:25 +00:00
_imuse - > property ( IMuse : : PROP_PC_SPEAKER , 1 ) ;
2004-09-20 22:04:06 +00:00
}
2004-07-15 23:15:13 +00:00
}
2003-03-06 17:58:13 +00:00
}
2001-10-09 14:30:12 +00:00
2008-06-30 17:44:21 +00:00
void ScummEngine : : syncSoundSettings ( ) {
2011-03-19 14:08:37 +00:00
Engine : : syncSoundSettings ( ) ;
2004-11-28 21:24:02 +00:00
// Sync the engine with the config manager
int soundVolumeMusic = ConfMan . getInt ( " music_volume " ) ;
int soundVolumeSfx = ConfMan . getInt ( " sfx_volume " ) ;
2010-08-25 07:40:52 +00:00
bool mute = false ;
if ( ConfMan . hasKey ( " mute " ) ) {
mute = ConfMan . getBool ( " mute " ) ;
if ( mute )
2011-03-19 14:08:37 +00:00
soundVolumeMusic = soundVolumeSfx = 0 ;
2010-08-25 07:40:52 +00:00
}
2004-11-28 21:24:02 +00:00
if ( _musicEngine ) {
2004-12-25 23:43:05 +00:00
_musicEngine - > setMusicVolume ( soundVolumeMusic ) ;
2004-11-28 21:24:02 +00:00
}
2010-08-18 21:38:43 +00:00
if ( _townsPlayer ) {
_townsPlayer - > setSfxVolume ( soundVolumeSfx ) ;
}
2006-04-29 23:09:40 +00:00
if ( ConfMan . getBool ( " speech_mute " ) )
_voiceMode = 2 ;
else
_voiceMode = ConfMan . getBool ( " subtitles " ) ;
if ( VAR_VOICE_MODE ! = 0xFF )
VAR ( VAR_VOICE_MODE ) = _voiceMode ;
2006-05-13 17:30:04 +00:00
2009-01-11 06:51:17 +00:00
if ( ConfMan . hasKey ( " talkspeed " , _targetName ) ) {
2009-02-13 10:04:17 +00:00
_defaultTalkDelay = getTalkSpeed ( ) ;
2009-01-11 06:51:17 +00:00
if ( VAR_CHARINC ! = 0xFF )
VAR ( VAR_CHARINC ) = _defaultTalkDelay ;
}
2012-05-31 01:39:54 +00:00
// Backyard Baseball 2003 uses a unique subtitle variable,
// rather than VAR_SUBTITLES
if ( _game . id = = GID_BASEBALL2003 ) {
_scummVars [ 632 ] = ConfMan . getBool ( " subtitles " ) ;
}
2004-11-28 21:24:02 +00:00
}
2009-02-13 10:04:17 +00:00
void ScummEngine : : setTalkSpeed ( int talkspeed ) {
ConfMan . setInt ( " talkspeed " , ( talkspeed * 255 + 9 / 2 ) / 9 ) ;
2006-05-13 17:30:04 +00:00
}
2009-02-13 10:04:17 +00:00
int ScummEngine : : getTalkSpeed ( ) {
return ( ConfMan . getInt ( " talkspeed " ) * 9 + 255 / 2 ) / 255 ;
2006-05-13 17:30:04 +00:00
}
2004-11-28 21:24:02 +00:00
2004-09-20 22:04:06 +00:00
2003-07-19 18:18:01 +00:00
# pragma mark -
# pragma mark --- Main loop ---
# pragma mark -
2008-11-06 17:05:54 +00:00
Common : : Error ScummEngine : : go ( ) {
2010-10-27 22:52:02 +00:00
setTotalPlayTime ( ) ;
2005-10-01 21:13:38 +00:00
2004-11-23 09:36:46 +00:00
// If requested, load a save game instead of running the boot script
if ( _saveLoadFlag ! = 2 | | ! loadState ( _saveLoadSlot , _saveTemporaryState ) ) {
_saveLoadFlag = 0 ;
2006-10-07 11:54:50 +00:00
runBootscript ( ) ;
2004-11-23 09:36:46 +00:00
} else {
_saveLoadFlag = 0 ;
}
2008-01-11 22:12:06 +00:00
int diff = 0 ; // Duration of one loop iteration
2003-07-19 18:18:01 +00:00
2008-09-30 12:27:38 +00:00
while ( ! shouldQuit ( ) ) {
2003-07-19 18:18:01 +00:00
2010-07-17 18:38:42 +00:00
_debugger - > onFrame ( ) ;
2007-09-19 08:40:12 +00:00
2006-10-07 11:54:50 +00:00
// Randomize the PRNG by calling it at regular intervals. This ensures
// that it will be in a different state each time you run the program.
_rnd . getRandomNumber ( 2 ) ;
2007-09-19 08:40:12 +00:00
2008-01-11 22:12:06 +00:00
// Notify the script about how much time has passed, in ticks (60 ticks per second)
if ( VAR_TIMER ! = 0xFF )
VAR ( VAR_TIMER ) = diff * 60 / 1000 ;
if ( VAR_TIMER_TOTAL ! = 0xFF )
VAR ( VAR_TIMER_TOTAL ) + = diff * 60 / 1000 ;
2003-07-19 18:18:01 +00:00
2008-01-11 22:12:06 +00:00
// Determine how long to wait before the next loop iteration should start
int delta = ( VAR_TIMER_NEXT ! = 0xFF ) ? VAR ( VAR_TIMER_NEXT ) : 4 ;
2006-04-29 13:01:35 +00:00
if ( delta < 1 ) // Ensure we don't get into an endless loop
2003-07-19 18:18:01 +00:00
delta = 1 ; // by not decreasing sleepers.
2012-09-26 02:17:31 +00:00
// WORKAROUND: walking speed in the original v0/v1 interpreter
2012-01-17 21:52:59 +00:00
// is sometimes slower (e.g. during scrolling) than in ScummVM.
// This is important for the door-closing action in the dungeon,
2012-09-26 02:17:31 +00:00
// otherwise (delta < 6) a single kid is able to escape.
if ( ( _game . version = = 0 & & isScriptRunning ( 132 ) ) | |
2012-01-17 21:52:59 +00:00
( _game . version = = 1 & & isScriptRunning ( 137 ) ) )
delta = 6 ;
2008-01-11 22:12:06 +00:00
// Wait...
waitForTimer ( delta * 1000 / 60 - diff ) ;
// Start the stop watch!
diff = _system - > getMillis ( ) ;
// Run the main loop
scummLoop ( delta ) ;
// Halt the stop watch and compute how much time this iteration took.
diff = _system - > getMillis ( ) - diff ;
2008-09-30 12:27:38 +00:00
if ( shouldQuit ( ) ) {
2003-07-19 18:18:01 +00:00
// TODO: Maybe perform an autosave on exit?
2014-08-19 23:26:39 +00:00
runQuitScript ( ) ;
2003-07-19 18:18:01 +00:00
}
}
2005-07-30 21:11:48 +00:00
2008-11-06 17:05:54 +00:00
return Common : : kNoError ;
2003-07-19 18:18:01 +00:00
}
2003-10-02 22:42:03 +00:00
void ScummEngine : : waitForTimer ( int msec_delay ) {
2003-07-19 18:18:01 +00:00
uint32 start_time ;
if ( _fastMode & 2 )
msec_delay = 0 ;
else if ( _fastMode & 1 )
msec_delay = 10 ;
2004-09-28 20:19:37 +00:00
start_time = _system - > getMillis ( ) ;
2003-07-19 18:18:01 +00:00
2008-09-30 12:27:38 +00:00
while ( ! shouldQuit ( ) ) {
2003-07-19 18:18:01 +00:00
_sound - > updateCD ( ) ; // Loop CD Audio if needed
2006-01-28 16:30:39 +00:00
parseEvents ( ) ;
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
2010-10-05 19:04:52 +00:00
# ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
if ( _townsScreen )
_townsScreen - > update ( ) ;
2010-10-05 19:04:52 +00:00
# endif
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
2006-04-17 23:45:48 +00:00
_system - > updateScreen ( ) ;
2004-09-28 20:19:37 +00:00
if ( _system - > getMillis ( ) > = start_time + msec_delay )
2003-07-19 18:18:01 +00:00
break ;
2004-09-28 20:19:37 +00:00
_system - > delayMillis ( 10 ) ;
2001-10-09 14:30:12 +00:00
}
}
2010-09-18 14:18:48 +00:00
void ScummEngine_v0 : : scummLoop ( int delta ) {
VAR ( VAR_IS_SOUND_RUNNING ) = ( _sound - > _lastSound & & _sound - > isSoundRunning ( _sound - > _lastSound ) ! = 0 ) ;
ScummEngine : : scummLoop ( delta ) ;
}
2008-01-11 22:12:06 +00:00
void ScummEngine : : scummLoop ( int delta ) {
2006-06-22 13:04:19 +00:00
if ( _game . version > = 3 ) {
2003-05-08 15:58:30 +00:00
VAR ( VAR_TMR_1 ) + = delta ;
VAR ( VAR_TMR_2 ) + = delta ;
VAR ( VAR_TMR_3 ) + = delta ;
2006-06-22 13:04:19 +00:00
if ( ( _game . id = = GID_INDY3 & & _game . platform ! = Common : : kPlatformMacintosh ) | |
_game . id = = GID_ZAK ) {
// Amiga/PC versions of Indy3 set three extra timers
2004-09-29 09:42:36 +00:00
// FM-TOWNS version of Zak sets three extra timers
2004-07-18 11:46:50 +00:00
VAR ( 39 ) + = delta ;
VAR ( 40 ) + = delta ;
VAR ( 41 ) + = delta ;
}
2003-05-08 15:58:30 +00:00
}
2001-10-09 14:30:12 +00:00
2001-11-09 18:54:15 +00:00
if ( delta > 15 )
delta = 15 ;
2001-10-23 19:51:50 +00:00
2001-11-09 18:54:15 +00:00
decreaseScriptDelay ( delta ) ;
2001-11-05 19:21:49 +00:00
2004-07-14 08:55:31 +00:00
_talkDelay - = delta ;
if ( _talkDelay < 0 )
_talkDelay = 0 ;
2001-11-09 18:54:15 +00:00
2003-07-12 12:16:17 +00:00
// Record the current ego actor before any scripts (including input scripts)
// get a chance to run.
int oldEgo = 0 ;
if ( VAR_EGO ! = 0xFF )
oldEgo = VAR ( VAR_EGO ) ;
2003-09-10 00:28:26 +00:00
// In V1-V3 games, CHARSET_1 is called much earlier than in newer games.
// See also bug #770042 for a case were this makes a difference.
2006-02-20 16:51:30 +00:00
if ( _game . version < = 3 )
2003-09-10 00:28:26 +00:00
CHARSET_1 ( ) ;
2006-10-07 17:42:32 +00:00
processInput ( ) ;
2007-09-19 08:40:12 +00:00
2006-04-29 12:44:06 +00:00
scummLoop_updateScummVars ( ) ;
2001-11-09 18:54:15 +00:00
2006-02-20 16:51:30 +00:00
if ( _game . features & GF_AUDIOTRACKS ) {
2003-05-01 00:04:05 +00:00
// Covered automatically by the Sound class
2005-09-24 05:26:12 +00:00
} else if ( VAR_MUSIC_TIMER ! = 0xFF ) {
if ( _musicEngine ) {
// The music engine generates the timer data for us.
VAR ( VAR_MUSIC_TIMER ) = _musicEngine - > getMusicTimer ( ) ;
2002-04-19 21:06:50 +00:00
}
}
2001-11-09 18:54:15 +00:00
2005-11-23 19:11:33 +00:00
// Trigger autosave if necessary.
2009-07-23 10:54:12 +00:00
if ( ! _saveLoadFlag & & shouldPerformAutoSave ( _lastSaveTime ) & & canSaveGameStateCurrently ( ) ) {
2002-11-10 14:59:15 +00:00
_saveLoadSlot = 0 ;
2011-06-02 12:11:38 +00:00
_saveLoadDescription = Common : : String : : format ( " Autosave %d " , _saveLoadSlot ) ;
2002-11-10 14:59:15 +00:00
_saveLoadFlag = 1 ;
2004-01-31 22:12:35 +00:00
_saveTemporaryState = false ;
2002-11-10 14:59:15 +00:00
}
2002-04-20 04:09:02 +00:00
2003-06-06 21:59:56 +00:00
if ( VAR_GAME_LOADED ! = 0xFF )
2003-05-08 15:48:50 +00:00
VAR ( VAR_GAME_LOADED ) = 0 ;
2003-03-04 03:18:12 +00:00
load_game :
2006-04-29 12:44:06 +00:00
scummLoop_handleSaveLoad ( ) ;
2003-01-02 08:39:33 +00:00
2001-11-09 18:54:15 +00:00
if ( _completeScreenRedraw ) {
2007-01-28 20:11:31 +00:00
clearCharsetMask ( ) ;
2002-12-25 21:04:47 +00:00
_charset - > _hasMask = false ;
2004-09-19 06:02:59 +00:00
// HACK as in game save stuff isn't supported currently
2006-02-20 16:51:30 +00:00
if ( _game . id = = GID_LOOM ) {
2013-05-01 05:47:56 +00:00
int args [ NUM_SCRIPT_LOCAL ] ;
2006-04-29 12:44:06 +00:00
uint var ;
2004-09-19 06:02:59 +00:00
memset ( args , 0 , sizeof ( args ) ) ;
args [ 0 ] = 2 ;
2006-02-20 16:51:30 +00:00
if ( _game . platform = = Common : : kPlatformMacintosh )
2006-04-29 12:44:06 +00:00
var = 105 ;
2009-10-27 09:29:47 +00:00
// 256 color CD version and PC engine version
else if ( _game . platform = = Common : : kPlatformPCEngine | | _game . version = = 4 )
2006-04-29 12:44:06 +00:00
var = 150 ;
2004-09-19 06:02:59 +00:00
else
2008-01-28 00:14:17 +00:00
var = 100 ;
2006-02-20 16:51:30 +00:00
byte restoreScript = ( _game . platform = = Common : : kPlatformFMTowns ) ? 17 : 18 ;
2004-09-19 06:02:59 +00:00
// if verbs should be shown restore them
2006-04-29 12:44:06 +00:00
if ( VAR ( var ) = = 2 )
2004-09-19 06:02:59 +00:00
runScript ( restoreScript , 0 , 0 , args ) ;
2006-02-20 16:51:30 +00:00
} else if ( _game . version > 3 ) {
2004-09-19 06:02:59 +00:00
for ( int i = 0 ; i < _numVerbs ; i + + )
drawVerb ( i , 0 ) ;
} else {
redrawVerbs ( ) ;
}
2005-04-28 01:04:42 +00:00
handleMouseOver ( false ) ;
2004-09-19 06:02:59 +00:00
2005-05-29 17:31:27 +00:00
_completeScreenRedraw = false ;
2001-11-09 18:54:15 +00:00
_fullRedraw = true ;
}
2001-10-09 14:30:12 +00:00
2006-02-20 16:51:30 +00:00
if ( _game . heversion > = 80 ) {
2006-09-01 12:06:51 +00:00
( ( SoundHE * ) _sound ) - > processSoundCode ( ) ;
2006-01-05 07:06:47 +00:00
}
2001-11-09 18:54:15 +00:00
runAllScripts ( ) ;
checkExecVerbs ( ) ;
2002-12-09 01:27:40 +00:00
checkAndRunSentenceScript ( ) ;
2001-10-09 14:30:12 +00:00
2008-09-30 12:27:38 +00:00
if ( shouldQuit ( ) )
2008-01-11 22:12:06 +00:00
return ;
2003-06-09 01:32:36 +00:00
2003-03-04 03:18:12 +00:00
// HACK: If a load was requested, immediately perform it. This avoids
// drawing the current room right after the load is request but before
2003-06-09 01:06:29 +00:00
// it is performed. That was annoying esp. if you loaded while a SMUSH
2003-03-04 03:18:12 +00:00
// cutscene was playing.
if ( _saveLoadFlag & & _saveLoadFlag ! = 1 ) {
goto load_game ;
}
2005-07-30 21:11:48 +00:00
2010-10-05 19:04:52 +00:00
# ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
towns_processPalCycleField ( ) ;
2010-10-05 19:04:52 +00:00
# endif
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
2002-04-11 17:19:16 +00:00
if ( _currentRoom = = 0 ) {
2006-02-20 16:51:30 +00:00
if ( _game . version > 3 )
2003-09-10 00:28:26 +00:00
CHARSET_1 ( ) ;
2001-11-09 18:54:15 +00:00
drawDirtyScreenParts ( ) ;
} else {
2001-10-09 14:30:12 +00:00
walkActors ( ) ;
moveCamera ( ) ;
2005-04-27 14:30:32 +00:00
updateObjectStates ( ) ;
2006-02-20 16:51:30 +00:00
if ( _game . version > 3 )
2003-09-10 00:28:26 +00:00
CHARSET_1 ( ) ;
2002-08-20 02:13:41 +00:00
2006-04-29 12:44:06 +00:00
scummLoop_handleDrawing ( ) ;
2002-10-01 09:27:09 +00:00
2006-04-29 12:44:06 +00:00
scummLoop_handleActors ( ) ;
2005-07-30 21:11:48 +00:00
2002-09-19 21:45:56 +00:00
_fullRedraw = false ;
2005-02-24 04:04:17 +00:00
2006-04-29 12:44:06 +00:00
scummLoop_handleEffects ( ) ;
2001-11-09 18:54:15 +00:00
2006-01-14 05:32:11 +00:00
if ( VAR_MAIN_SCRIPT ! = 0xFF & & VAR ( VAR_MAIN_SCRIPT ) ! = 0 ) {
runScript ( VAR ( VAR_MAIN_SCRIPT ) , 0 , 0 , 0 ) ;
}
2005-04-28 22:34:56 +00:00
// Handle mouse over effects (for verbs).
2005-04-28 01:04:42 +00:00
handleMouseOver ( oldEgo ! = VAR ( VAR_EGO ) ) ;
2004-07-03 13:32:56 +00:00
2005-04-28 22:34:56 +00:00
// Render everything to the screen.
2006-07-06 11:40:50 +00:00
updatePalette ( ) ;
2001-11-09 18:54:15 +00:00
drawDirtyScreenParts ( ) ;
2001-10-09 14:30:12 +00:00
2006-04-29 12:44:06 +00:00
// FIXME / TODO: Try to move the following to scummLoop_handleSound or
// scummLoop_handleActors (but watch out for regressions!)
2006-02-20 16:51:30 +00:00
if ( _game . version < = 5 )
2001-10-23 19:51:50 +00:00
playActorSounds ( ) ;
2001-11-09 18:54:15 +00:00
}
2006-04-29 12:44:06 +00:00
scummLoop_handleSound ( ) ;
2004-03-02 20:35:48 +00:00
2003-07-02 00:49:03 +00:00
camera . _last = camera . _cur ;
2006-09-17 20:36:48 +00:00
_res - > increaseExpireCounter ( ) ;
2002-04-11 17:19:16 +00:00
2002-04-12 21:26:59 +00:00
animateCursor ( ) ;
2005-07-30 21:11:48 +00:00
2002-04-12 21:26:59 +00:00
/* show or hide mouse */
2006-05-25 22:51:42 +00:00
CursorMan . showMouse ( _cursor . state > 0 ) ;
2001-11-09 18:54:15 +00:00
}
2008-05-06 03:00:26 +00:00
# ifdef ENABLE_HE
2008-01-11 22:12:06 +00:00
void ScummEngine_v90he : : scummLoop ( int delta ) {
2006-10-07 11:54:50 +00:00
_moviePlay - > handleNextFrame ( ) ;
if ( _game . heversion > = 98 ) {
_logicHE - > startOfFrame ( ) ;
}
2008-01-11 22:12:06 +00:00
ScummEngine : : scummLoop ( delta ) ;
2007-09-19 08:40:12 +00:00
2006-10-07 11:54:50 +00:00
_sprite - > updateImages ( ) ;
if ( _game . heversion > = 98 ) {
_logicHE - > endOfFrame ( ) ;
}
}
# endif
2006-04-29 12:44:06 +00:00
void ScummEngine : : scummLoop_updateScummVars ( ) {
2007-02-10 02:05:59 +00:00
if ( _game . version > = 7 ) {
2006-04-29 12:44:06 +00:00
VAR ( VAR_CAMERA_POS_X ) = camera . _cur . x ;
VAR ( VAR_CAMERA_POS_Y ) = camera . _cur . y ;
2010-06-15 10:46:23 +00:00
} else if ( _game . platform = = Common : : kPlatformNES ) {
2010-09-25 20:50:13 +00:00
#if 0
2010-06-15 10:46:23 +00:00
// WORKAROUND:
// Since there are 2 2-stripes wide borders in MM NES screen,
// we have to compensate for it here. This fixes paning effects.
// Fixes bug #1328120: "MANIACNES: Screen width incorrect, camera halts sometimes"
2010-08-25 07:41:54 +00:00
// But do not do it when only scrolling right to left, since otherwise Ed will not show
// up on the doorbell (Bug #3039004)
if ( VAR ( VAR_CAMERA_POS_X ) < ( camera . _cur . x > > V12_X_SHIFT ) + 2 )
VAR ( VAR_CAMERA_POS_X ) = ( camera . _cur . x > > V12_X_SHIFT ) + 2 ;
else
2010-09-25 20:50:13 +00:00
# endif
2010-08-25 07:41:54 +00:00
VAR ( VAR_CAMERA_POS_X ) = ( camera . _cur . x > > V12_X_SHIFT ) ;
2006-04-29 12:44:06 +00:00
} else if ( _game . version < = 2 ) {
2007-02-15 18:12:29 +00:00
VAR ( VAR_CAMERA_POS_X ) = camera . _cur . x > > V12_X_SHIFT ;
2006-04-29 12:44:06 +00:00
} else {
VAR ( VAR_CAMERA_POS_X ) = camera . _cur . x ;
}
if ( _game . version < = 7 )
VAR ( VAR_HAVE_MSG ) = _haveMsg ;
2006-05-29 12:45:11 +00:00
if ( _game . version > = 3 ) {
VAR ( VAR_VIRT_MOUSE_X ) = _virtualMouse . x ;
VAR ( VAR_VIRT_MOUSE_Y ) = _virtualMouse . y ;
VAR ( VAR_MOUSE_X ) = _mouse . x ;
VAR ( VAR_MOUSE_Y ) = _mouse . y ;
if ( VAR_DEBUGMODE ! = 0xFF ) {
// This is NOT for the Mac version of Indy3/Loom
2014-05-13 14:14:54 +00:00
VAR ( VAR_DEBUGMODE ) = ( _debugMode ? 1 : 0 ) ;
2006-05-29 12:45:11 +00:00
}
} else if ( _game . version > = 1 ) {
2007-02-15 11:56:17 +00:00
// We use shifts below instead of dividing by V12_X_MULTIPLIER resp.
// V12_Y_MULTIPLIER to handle negative coordinates correctly.
// This fixes e.g. bugs #1328131 and #1537595.
2007-02-15 18:12:29 +00:00
VAR ( VAR_VIRT_MOUSE_X ) = _virtualMouse . x > > V12_X_SHIFT ;
VAR ( VAR_VIRT_MOUSE_Y ) = _virtualMouse . y > > V12_Y_SHIFT ;
2006-04-29 12:44:06 +00:00
// Adjust mouse coordinates as narrow rooms in NES are centered
if ( _game . platform = = Common : : kPlatformNES & & _NESStartStrip > 0 ) {
VAR ( VAR_VIRT_MOUSE_X ) - = 2 ;
if ( VAR ( VAR_VIRT_MOUSE_X ) < 0 )
VAR ( VAR_VIRT_MOUSE_X ) = 0 ;
}
}
}
void ScummEngine : : scummLoop_handleSaveLoad ( ) {
if ( _saveLoadFlag ) {
bool success ;
const char * errMsg = 0 ;
2006-12-11 05:19:57 +00:00
if ( _game . version = = 8 & & _saveTemporaryState )
VAR ( VAR_GAME_LOADED ) = 0 ;
2013-07-16 02:52:03 +00:00
Common : : String filename ;
2006-04-29 12:44:06 +00:00
if ( _saveLoadFlag = = 1 ) {
2013-07-16 02:52:03 +00:00
success = saveState ( _saveLoadSlot , _saveTemporaryState , filename ) ;
2006-04-29 12:44:06 +00:00
if ( ! success )
2010-09-15 23:25:46 +00:00
errMsg = _ ( " Failed to save game state to file: \n \n %s " ) ;
2006-04-29 12:44:06 +00:00
2006-12-11 05:19:57 +00:00
if ( success & & _saveTemporaryState & & VAR_GAME_LOADED ! = 0xFF & & _game . version < = 7 )
2006-04-29 12:44:06 +00:00
VAR ( VAR_GAME_LOADED ) = 201 ;
} else {
2013-07-16 02:52:03 +00:00
success = loadState ( _saveLoadSlot , _saveTemporaryState , filename ) ;
2006-04-29 12:44:06 +00:00
if ( ! success )
2010-09-15 23:25:46 +00:00
errMsg = _ ( " Failed to load game state from file: \n \n %s " ) ;
2006-04-29 12:44:06 +00:00
2006-12-11 05:19:57 +00:00
if ( success & & _saveTemporaryState & & VAR_GAME_LOADED ! = 0xFF )
VAR ( VAR_GAME_LOADED ) = ( _game . version = = 8 ) ? 1 : 203 ;
2006-04-29 12:44:06 +00:00
}
if ( ! success ) {
2008-09-14 21:34:49 +00:00
displayMessage ( 0 , errMsg , filename . c_str ( ) ) ;
2006-04-29 12:44:06 +00:00
} else if ( _saveLoadFlag = = 1 & & _saveLoadSlot ! = 0 & & ! _saveTemporaryState ) {
// Display "Save successful" message, except for auto saves
char buf [ 256 ] ;
2010-09-15 23:25:46 +00:00
snprintf ( buf , sizeof ( buf ) , _ ( " Successfully saved game state in file: \n \n %s " ) , filename . c_str ( ) ) ;
2006-04-29 12:44:06 +00:00
GUI : : TimedMessageDialog dialog ( buf , 1500 ) ;
runDialog ( dialog ) ;
}
if ( success & & _saveLoadFlag ! = 1 )
clearClickedStatus ( ) ;
_saveLoadFlag = 0 ;
_lastSaveTime = _system - > getMillis ( ) ;
}
}
2009-04-19 01:01:54 +00:00
void ScummEngine_v4 : : scummLoop_handleSaveLoad ( ) {
2009-03-24 23:30:48 +00:00
// copy saveLoadFlag as handleSaveLoad() resets it
byte saveLoad = _saveLoadFlag ;
2009-03-23 22:34:53 +00:00
2009-04-19 01:01:54 +00:00
ScummEngine_v5 : : scummLoop_handleSaveLoad ( ) ;
2009-03-23 22:34:53 +00:00
// update IQ points after loading
if ( saveLoad = = 2 ) {
if ( _game . id = = GID_INDY3 )
updateIQPoints ( ) ;
2009-04-19 01:01:54 +00:00
}
}
void ScummEngine_v5 : : scummLoop_handleSaveLoad ( ) {
// copy saveLoadFlag as handleSaveLoad() resets it
byte saveLoad = _saveLoadFlag ;
ScummEngine : : scummLoop_handleSaveLoad ( ) ;
// update IQ points after loading
if ( saveLoad = = 2 ) {
2009-03-23 22:34:53 +00:00
if ( _game . id = = GID_INDY4 )
runScript ( 145 , 0 , 0 , 0 ) ;
}
}
2008-05-06 03:00:26 +00:00
# ifdef ENABLE_SCUMM_7_8
2006-12-11 00:40:10 +00:00
void ScummEngine_v8 : : scummLoop_handleSaveLoad ( ) {
ScummEngine : : scummLoop_handleSaveLoad ( ) ;
removeBlastObjects ( ) ;
}
# endif
2006-04-29 12:44:06 +00:00
void ScummEngine : : scummLoop_handleDrawing ( ) {
2006-04-29 13:01:35 +00:00
if ( camera . _cur ! = camera . _last | | _bgNeedsRedraw | | _fullRedraw ) {
2006-04-29 12:44:06 +00:00
redrawBGAreas ( ) ;
}
processDrawQue ( ) ;
2006-04-29 13:01:35 +00:00
}
2006-04-29 12:44:06 +00:00
2008-05-06 03:00:26 +00:00
# ifdef ENABLE_SCUMM_7_8
2006-04-29 13:01:35 +00:00
void ScummEngine_v7 : : scummLoop_handleDrawing ( ) {
ScummEngine_v6 : : scummLoop_handleDrawing ( ) ;
2006-04-29 12:44:06 +00:00
// Full Throttle always redraws verbs and draws verbs before actors
if ( _game . version > = 7 )
redrawVerbs ( ) ;
2006-04-29 13:01:35 +00:00
}
# endif
2006-04-29 12:44:06 +00:00
2008-05-06 03:00:26 +00:00
# ifdef ENABLE_HE
2006-04-29 13:01:35 +00:00
void ScummEngine_v90he : : scummLoop_handleDrawing ( ) {
ScummEngine_v80he : : scummLoop_handleDrawing ( ) ;
if ( _game . heversion > = 99 )
_fullRedraw = false ;
2006-04-29 12:44:06 +00:00
if ( _game . heversion > = 90 ) {
2006-04-29 13:01:35 +00:00
_sprite - > resetBackground ( ) ;
_sprite - > sortActiveSprites ( ) ;
2006-04-29 12:44:06 +00:00
}
2006-04-29 13:01:35 +00:00
}
2006-04-29 12:44:06 +00:00
# endif
2006-04-29 13:01:35 +00:00
void ScummEngine_v6 : : scummLoop_handleActors ( ) {
setActorRedrawFlags ( ) ;
resetActorBgs ( ) ;
processActors ( ) ;
2006-04-29 12:44:06 +00:00
}
2006-04-29 13:01:35 +00:00
void ScummEngine_v5 : : scummLoop_handleActors ( ) {
2006-04-29 12:44:06 +00:00
setActorRedrawFlags ( ) ;
resetActorBgs ( ) ;
if ( ! ( getCurrentLights ( ) & LIGHTMODE_room_lights_on ) & &
getCurrentLights ( ) & LIGHTMODE_flashlight_on ) {
drawFlashlight ( ) ;
setActorRedrawFlags ( ) ;
}
processActors ( ) ;
}
void ScummEngine : : scummLoop_handleEffects ( ) {
2010-04-04 09:36:10 +00:00
if ( _game . version > = 4 & & _game . heversion < = 62 )
2006-04-29 12:44:06 +00:00
cyclePalette ( ) ;
palManipulate ( ) ;
if ( _doEffect ) {
_doEffect = false ;
fadeIn ( _newEffect ) ;
clearClickedStatus ( ) ;
}
}
void ScummEngine : : scummLoop_handleSound ( ) {
_sound - > processSound ( ) ;
2006-04-29 13:01:35 +00:00
}
2006-04-29 12:44:06 +00:00
2008-05-06 03:00:26 +00:00
# ifdef ENABLE_SCUMM_7_8
2006-04-29 13:01:35 +00:00
void ScummEngine_v7 : : scummLoop_handleSound ( ) {
ScummEngine_v6 : : scummLoop_handleSound ( ) ;
2006-04-29 12:44:06 +00:00
if ( _imuseDigital ) {
_imuseDigital - > flushTracks ( ) ;
2008-01-13 23:44:52 +00:00
// In CoMI and the Dig the full (non-demo) version invoke IMuseDigital::refreshScripts
if ( ( _game . id = = GID_DIG | | _game . id = = GID_CMI ) & & ! ( _game . features & GF_DEMO ) )
2006-04-29 12:44:06 +00:00
_imuseDigital - > refreshScripts ( ) ;
}
if ( _smixer ) {
_smixer - > flush ( ) ;
}
}
2006-04-29 13:01:35 +00:00
# endif
2006-04-29 12:44:06 +00:00
2003-07-19 18:18:01 +00:00
# pragma mark -
# pragma mark --- SCUMM ---
# pragma mark -
2006-04-23 19:41:54 +00:00
int ScummEngine_v60he : : getHETimer ( int timer ) {
2006-09-16 13:38:43 +00:00
assertRange ( 1 , timer , 15 , " getHETimer: Timer " ) ;
2006-01-05 07:06:47 +00:00
int time = _system - > getMillis ( ) - _heTimers [ timer ] ;
return time ;
}
2006-04-23 19:41:54 +00:00
void ScummEngine_v60he : : setHETimer ( int timer ) {
2006-09-16 13:38:43 +00:00
assertRange ( 1 , timer , 15 , " setHETimer: Timer " ) ;
2006-01-05 07:06:47 +00:00
_heTimers [ timer ] = _system - > getMillis ( ) ;
}
2003-10-02 22:42:03 +00:00
void ScummEngine : : pauseGame ( ) {
2003-07-19 18:18:01 +00:00
pauseDialog ( ) ;
2001-10-09 14:30:12 +00:00
}
2003-10-02 22:42:03 +00:00
void ScummEngine : : restart ( ) {
2011-05-13 12:33:22 +00:00
// FIXME: This function *leaks memory*, and quite a lot so. For example,
// we re-init the resource manager, which causes readMAXS() to be called
// again, which allocates some memory. There are many other leaks, though.
2002-04-11 17:19:16 +00:00
2011-05-13 12:33:22 +00:00
// TODO: We should also probably be reinitting a lot more stuff.
// Fingolfin seez: An alternate way to implement restarting would be to create
// a save state right after startup ... to this end we could introduce a SaveFile
// subclass which is implemented using a memory buffer (i.e. no actual file is
// created). Then to restart we just have to load that pseudo save state.
2004-09-20 22:04:06 +00:00
2003-07-19 18:18:01 +00:00
int i ;
2002-04-11 17:19:16 +00:00
2003-07-19 18:18:01 +00:00
// Reset some stuff
_currentRoom = 0 ;
_currentScript = 0xFF ;
killAllScriptsExceptCurrent ( ) ;
setShake ( 0 ) ;
_sound - > stopAllSounds ( ) ;
2003-06-02 05:38:45 +00:00
2003-09-11 10:32:15 +00:00
// Clear the script variables
2004-09-10 02:03:31 +00:00
for ( i = 0 ; i < _numVariables ; i + + )
2003-06-02 05:38:45 +00:00
_scummVars [ i ] = 0 ;
// Empty inventory
2007-12-26 23:06:22 +00:00
for ( i = 1 ; i < _numGlobalObjects ; i + + )
2003-06-02 05:38:45 +00:00
clearOwnerOf ( i ) ;
2006-02-04 23:51:25 +00:00
readIndexFile ( ) ;
// Reinit scumm variables
2006-04-29 16:24:39 +00:00
resetScumm ( ) ;
resetScummVars ( ) ;
2006-02-04 23:51:25 +00:00
// Reinit sound engine
2007-02-19 09:46:45 +00:00
if ( _game . version > = 5 & & _game . version < = 7 )
2006-02-04 23:51:25 +00:00
_sound - > setupSound ( ) ;
2002-10-19 22:35:22 +00:00
2003-07-19 18:18:01 +00:00
// Re-run bootscript
2006-10-07 11:54:50 +00:00
runBootscript ( ) ;
}
void ScummEngine : : runBootscript ( ) {
2013-05-01 05:47:56 +00:00
int args [ NUM_SCRIPT_LOCAL ] ;
2004-02-24 10:52:40 +00:00
memset ( args , 0 , sizeof ( args ) ) ;
2005-07-30 21:11:48 +00:00
args [ 0 ] = _bootParam ;
2014-12-07 08:53:27 +00:00
if ( _game . id = = GID_MANIAC & & ( _game . features & GF_DEMO ) & & ( _game . platform ! = Common : : kPlatformC64 ) )
2004-02-24 10:52:40 +00:00
runScript ( 9 , 0 , 0 , args ) ;
else
runScript ( 1 , 0 , 0 , args ) ;
2003-07-19 18:18:01 +00:00
}
2002-04-12 21:26:59 +00:00
2008-05-06 03:00:26 +00:00
# ifdef ENABLE_HE
2006-10-07 11:54:50 +00:00
void ScummEngine_v90he : : runBootscript ( ) {
if ( _game . heversion > = 98 ) {
_logicHE - > initOnce ( ) ;
_logicHE - > beforeBootScript ( ) ;
}
ScummEngine : : runBootscript ( ) ;
}
# endif
2014-12-30 02:45:14 +00:00
bool ScummEngine : : startManiac ( ) {
Common : : String currentPath = ConfMan . get ( " path " ) ;
Common : : String maniacTarget ;
2014-12-30 09:54:49 +00:00
if ( ! ConfMan . hasKey ( " easter_egg " ) ) {
// Look for a game with a game path pointing to a 'Maniac' directory
// as a subdirectory to the current game.
Common : : ConfigManager : : DomainMap : : iterator iter = ConfMan . beginGameDomains ( ) ;
for ( ; iter ! = ConfMan . endGameDomains ( ) ; + + iter ) {
Common : : ConfigManager : : Domain & dom = iter - > _value ;
2016-03-09 22:37:10 +00:00
Common : : String path = dom . getVal ( " path " ) ;
2014-12-30 09:54:49 +00:00
2016-03-09 22:37:10 +00:00
if ( path . hasPrefix ( currentPath ) ) {
2016-03-09 22:37:47 +00:00
path . erase ( 0 , currentPath . size ( ) ) ;
// Do a case-insensitive non-path-mode match of the remainder.
// While strictly speaking it's too broad, this matchString
// ignores the presence or absence of trailing path separators
// in either currentPath or path.
if ( path . matchString ( " *maniac* " , true , false ) ) {
2016-03-09 22:37:10 +00:00
maniacTarget = iter - > _key ;
break ;
2014-12-30 09:54:49 +00:00
}
2014-12-30 02:45:14 +00:00
}
}
2014-12-30 09:54:49 +00:00
} else {
maniacTarget = ConfMan . get ( " easter_egg " ) ;
2014-12-30 02:45:14 +00:00
}
if ( ! maniacTarget . empty ( ) ) {
// Request a temporary save game to be made.
_saveLoadFlag = 1 ;
_saveLoadSlot = 100 ;
_saveTemporaryState = true ;
// Set up the chanined games to Maniac Mansion, and then back
// to the current game again with that save slot.
2014-12-30 09:47:51 +00:00
ChainedGamesMan . push ( maniacTarget ) ;
ChainedGamesMan . push ( ConfMan . getActiveDomainName ( ) , 100 ) ;
2014-12-30 02:45:14 +00:00
// Force a return to the launcher. This will start the first
// chained game.
Common : : EventManager * eventMan = g_system - > getEventManager ( ) ;
Common : : Event event ;
event . type = Common : : EVENT_RTL ;
eventMan - > pushEvent ( event ) ;
return true ;
} else {
displayMessage ( 0 , " %s " , _ ( " Usually, Maniac Mansion would start now. But for that to work, the game files for Maniac Mansion have to be in the 'Maniac' directory inside the Tentacle game directory, and the game has to be added to ScummVM. " ) ) ;
return false ;
}
2003-07-19 18:18:01 +00:00
}
2002-07-28 01:40:24 +00:00
2003-07-19 18:18:01 +00:00
# pragma mark -
# pragma mark --- GUI ---
# pragma mark -
2002-08-08 11:14:45 +00:00
2007-06-30 22:22:25 +00:00
void ScummEngine : : pauseEngineIntern ( bool pause ) {
if ( pause ) {
2007-06-30 18:22:21 +00:00
// Pause sound & video
_oldSoundsPaused = _sound - > _soundsPaused ;
_sound - > pauseSounds ( true ) ;
2007-09-19 08:40:12 +00:00
2007-06-30 22:22:25 +00:00
} else {
2007-06-30 18:22:21 +00:00
// Update the screen to make it less likely that the player will see a
// brief cursor palette glitch when the GUI is disabled.
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
2010-10-05 19:04:52 +00:00
# ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
if ( _townsScreen )
_townsScreen - > update ( ) ;
2010-10-05 19:04:52 +00:00
# endif
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
2007-06-30 18:22:21 +00:00
_system - > updateScreen ( ) ;
2002-10-19 22:35:22 +00:00
2007-06-30 18:22:21 +00:00
// Resume sound & video
_sound - > pauseSounds ( _oldSoundsPaused ) ;
}
}
int ScummEngine : : runDialog ( Dialog & dialog ) {
// Pause engine
pauseEngine ( true ) ;
// Open & run the dialog
int result = dialog . runModal ( ) ;
2005-07-30 21:11:48 +00:00
2007-06-30 18:22:21 +00:00
// Resume engine
pauseEngine ( false ) ;
2005-10-01 21:13:38 +00:00
2003-07-19 18:18:01 +00:00
// Return the result
return result ;
2002-04-12 21:26:59 +00:00
}
2002-04-11 17:19:16 +00:00
2008-05-06 03:00:26 +00:00
# ifdef ENABLE_SCUMM_7_8
2006-10-07 13:57:06 +00:00
int ScummEngine_v7 : : runDialog ( Dialog & dialog ) {
2006-11-13 19:46:52 +00:00
_splayer - > pause ( ) ;
2006-10-07 13:57:06 +00:00
int result = ScummEngine : : runDialog ( dialog ) ;
2006-11-13 19:46:52 +00:00
_splayer - > unpause ( ) ;
2006-10-07 13:57:06 +00:00
return result ;
}
2006-10-25 20:12:52 +00:00
# endif
2006-10-07 13:57:06 +00:00
2009-03-10 00:26:40 +00:00
void ScummEngine : : messageDialog ( const char * message ) {
if ( ! _messageDialog )
_messageDialog = new InfoDialog ( this , message ) ;
2009-03-10 00:44:33 +00:00
( ( InfoDialog * ) _messageDialog ) - > setInfoText ( message ) ;
2009-03-10 00:26:40 +00:00
runDialog ( * _messageDialog ) ;
}
2003-10-02 22:42:03 +00:00
void ScummEngine : : pauseDialog ( ) {
2003-07-19 18:18:01 +00:00
if ( ! _pauseDialog )
2006-03-01 04:32:44 +00:00
_pauseDialog = new PauseDialog ( this , 4 ) ;
2003-09-11 10:32:15 +00:00
runDialog ( * _pauseDialog ) ;
2003-07-19 18:18:01 +00:00
}
2003-06-08 12:11:14 +00:00
2004-07-20 11:30:15 +00:00
void ScummEngine : : versionDialog ( ) {
if ( ! _versionDialog )
2006-03-01 04:32:44 +00:00
_versionDialog = new PauseDialog ( this , 1 ) ;
2004-07-20 11:30:15 +00:00
runDialog ( * _versionDialog ) ;
2002-03-21 00:40:18 +00:00
}
2002-03-23 20:34:47 +00:00
2005-04-17 22:40:45 +00:00
void ScummEngine : : confirmExitDialog ( ) {
2006-03-01 04:32:44 +00:00
ConfirmDialog d ( this , 6 ) ;
2003-07-28 01:36:16 +00:00
2005-04-17 22:40:45 +00:00
if ( runDialog ( d ) ) {
2008-07-11 01:22:37 +00:00
quitGame ( ) ;
2003-07-28 01:36:16 +00:00
}
}
2005-04-17 22:40:45 +00:00
void ScummEngine : : confirmRestartDialog ( ) {
2006-03-01 04:32:44 +00:00
ConfirmDialog d ( this , 5 ) ;
2003-12-14 15:04:05 +00:00
2005-04-17 22:40:45 +00:00
if ( runDialog ( d ) ) {
2003-12-14 15:04:05 +00:00
restart ( ) ;
}
}
2004-03-28 13:28:44 +00:00
char ScummEngine : : displayMessage ( const char * altButton , const char * message , . . . ) {
2004-11-09 10:26:33 +00:00
char buf [ STRINGBUFLEN ] ;
2003-07-19 18:18:01 +00:00
va_list va ;
2003-03-06 17:58:13 +00:00
2003-07-19 18:18:01 +00:00
va_start ( va , message ) ;
2005-04-09 01:52:44 +00:00
vsnprintf ( buf , STRINGBUFLEN , message , va ) ;
2003-07-19 18:18:01 +00:00
va_end ( va ) ;
2002-03-23 20:34:47 +00:00
2004-02-05 22:39:13 +00:00
GUI : : MessageDialog dialog ( buf , " OK " , altButton ) ;
2003-09-11 10:32:15 +00:00
return runDialog ( dialog ) ;
2003-07-19 18:18:01 +00:00
}
2002-12-29 19:54:11 +00:00
2006-02-25 19:20:51 +00:00
2003-07-19 18:18:01 +00:00
# pragma mark -
# pragma mark --- Miscellaneous ---
# pragma mark -
2002-03-23 20:34:47 +00:00
2006-09-16 19:31:23 +00:00
GUI : : Debugger * ScummEngine : : getDebugger ( ) {
return _debugger ;
}
2005-04-10 12:59:17 +00:00
2008-11-15 03:16:41 +00:00
void ScummEngine : : errorString ( const char * buf1 , char * buf2 , int buf2Size ) {
2003-07-19 18:18:01 +00:00
if ( _currentScript ! = 0xFF ) {
2008-11-15 03:16:41 +00:00
snprintf ( buf2 , buf2Size , " (%d:%d:0x%lX): %s " , _roomResource ,
2006-11-07 20:55:05 +00:00
vm . slot [ _currentScript ] . number , ( long ) ( _scriptPointer - _scriptOrgPointer ) , buf1 ) ;
2003-07-19 18:18:01 +00:00
} else {
2008-11-15 14:15:17 +00:00
strncpy ( buf2 , buf1 , buf2Size ) ;
if ( buf2Size > 0 )
buf2 [ buf2Size - 1 ] = ' \0 ' ;
2003-07-19 18:18:01 +00:00
}
}
2002-03-23 20:34:47 +00:00
2005-01-29 17:58:47 +00:00
2003-10-03 18:33:57 +00:00
} // End of namespace Scumm