2001-10-09 14:30:12 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2001 Ludvig Strigeus
|
2002-03-20 17:51:07 +00:00
|
|
|
* Copyright (C) 2001/2002 The ScummVM project
|
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.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
2001-11-06 20:00:47 +00:00
|
|
|
* $Header$
|
2001-10-09 14:30:12 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "scumm.h"
|
2002-08-14 09:53:34 +00:00
|
|
|
#include "sound/mixer.h"
|
2002-04-19 11:05:46 +00:00
|
|
|
#include "sound/mididrv.h"
|
2002-08-29 23:45:15 +00:00
|
|
|
#include "scumm/sound.h"
|
2002-08-21 16:07:07 +00:00
|
|
|
#include "scumm/imuse.h"
|
2002-07-16 21:03:14 +00:00
|
|
|
#include "actor.h"
|
2002-07-27 21:06:50 +00:00
|
|
|
#include "debug.h"
|
2002-07-16 21:03:14 +00:00
|
|
|
#include "gameDetector.h"
|
2002-08-21 16:07:07 +00:00
|
|
|
#include "gui/gui.h"
|
|
|
|
#include "gui/newgui.h"
|
2002-07-16 21:03:14 +00:00
|
|
|
#include "object.h"
|
|
|
|
#include "resource.h"
|
2002-02-27 22:48:55 +00:00
|
|
|
#include "string.h"
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-07-20 08:00:42 +00:00
|
|
|
#ifdef _WIN32_WCE
|
|
|
|
extern void GraphicsOff(void);
|
|
|
|
#endif
|
|
|
|
|
2002-08-18 17:48:18 +00:00
|
|
|
// Use g_scumm from error() ONLY
|
|
|
|
Scumm *g_scumm = 0;
|
|
|
|
|
|
|
|
|
2002-08-14 20:43:56 +00:00
|
|
|
void autosave(Scumm * scumm)
|
2002-05-14 18:14:16 +00:00
|
|
|
{
|
2002-08-14 16:18:45 +00:00
|
|
|
scumm->_doAutosave = true;
|
2002-05-14 18:14:16 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::initRandSeeds()
|
|
|
|
{
|
2002-07-16 15:48:59 +00:00
|
|
|
_randSeed1 = 0xA943DE33;
|
|
|
|
_randSeed2 = 0x37A9ED29;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
uint Scumm::getRandomNumber(uint max)
|
|
|
|
{
|
2001-10-09 14:30:12 +00:00
|
|
|
/* TODO: my own random number generator */
|
2002-07-16 15:48:59 +00:00
|
|
|
_randSeed1 = 0xDEADBF03 * (_randSeed1 + 1);
|
2002-04-11 17:19:16 +00:00
|
|
|
_randSeed1 = (_randSeed1 >> 13) | (_randSeed1 << 19);
|
2002-07-15 01:38:52 +00:00
|
|
|
return _randSeed1 % (max + 1);
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
uint Scumm::getRandomNumberRng(uint min, uint max)
|
|
|
|
{
|
2002-07-15 01:38:52 +00:00
|
|
|
return getRandomNumber(max - min) + min;
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-18 17:48:18 +00:00
|
|
|
Scumm::Scumm (GameDetector *detector, OSystem *syst)
|
|
|
|
: Engine(detector, syst)
|
|
|
|
{
|
2002-08-18 18:39:42 +00:00
|
|
|
OSystem::Property prop;
|
|
|
|
|
2002-08-18 17:48:18 +00:00
|
|
|
// Use g_scumm from error() ONLY
|
|
|
|
g_scumm = this;
|
|
|
|
|
|
|
|
_debugMode = detector->_debugMode;
|
|
|
|
_bootParam = detector->_bootParam;
|
|
|
|
_exe_name = detector->_exe_name;
|
|
|
|
_gameId = detector->_gameId;
|
|
|
|
_gameText = detector->_gameText;
|
|
|
|
_features = detector->_features;
|
|
|
|
_soundCardType = detector->_soundCardType;
|
|
|
|
_noSubtitles = detector->_noSubtitles;
|
|
|
|
_cdrom = detector->_cdrom;
|
|
|
|
_defaultTalkDelay = detector->_talkSpeed;
|
|
|
|
_use_adlib = detector->_use_adlib;
|
|
|
|
|
|
|
|
if (_gameId == GID_ZAK256) { // FmTowns is 320x240
|
|
|
|
_realWidth = 320;
|
|
|
|
_realHeight = 240;
|
2002-08-31 19:26:04 +00:00
|
|
|
}
|
|
|
|
else if (_gameId == GID_CMI) {
|
2002-08-31 16:29:17 +00:00
|
|
|
_realWidth = 640;
|
|
|
|
_realHeight = 480;
|
2002-08-18 17:48:18 +00:00
|
|
|
} else {
|
|
|
|
_realWidth = 320;
|
|
|
|
_realHeight = 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
_gui = new Gui();
|
|
|
|
_gui->init(this);
|
|
|
|
|
2002-08-14 00:01:39 +00:00
|
|
|
_newgui = new NewGui(this);
|
2002-08-31 13:29:10 +00:00
|
|
|
_bundle = new Bundle();
|
2002-08-14 00:01:39 +00:00
|
|
|
_timer = new Timer(this);
|
2002-08-14 20:43:56 +00:00
|
|
|
_sound = new Sound(this);
|
2002-08-18 17:48:18 +00:00
|
|
|
|
|
|
|
_sound->_sound_volume_master = 0;
|
|
|
|
_sound->_sound_volume_sfx = detector->_sfx_volume;
|
|
|
|
_sound->_sound_volume_music = detector->_music_volume;
|
2002-08-18 18:39:42 +00:00
|
|
|
|
|
|
|
/* Initialize backend */
|
|
|
|
syst->init_size(_realWidth, _realHeight);
|
|
|
|
prop.cd_num = detector->_cdrom;
|
|
|
|
syst->property(OSystem::PROP_OPEN_CD, &prop);
|
|
|
|
|
|
|
|
/* Bind the mixer to the system => mixer will be invoked
|
|
|
|
* automatically when samples need to be generated */
|
2002-08-24 15:58:08 +00:00
|
|
|
if (!_mixer->bindToSystem(syst)) {
|
2002-08-18 18:39:42 +00:00
|
|
|
warning("Sound initialization failed");
|
|
|
|
if (detector->_use_adlib) {
|
|
|
|
_use_adlib = false;
|
|
|
|
detector->_use_adlib = false;
|
|
|
|
detector->_midi_driver = MD_NULL;
|
|
|
|
warning("Adlib music was selected, switching to midi null driver");
|
|
|
|
}
|
|
|
|
}
|
2002-08-24 15:58:08 +00:00
|
|
|
_mixer->setVolume(kDefaultSFXVolume);
|
|
|
|
_mixer->setMusicVolume(kDefaultMusicVolume);
|
2002-08-18 18:39:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Init iMuse
|
|
|
|
if (detector->_use_adlib) {
|
|
|
|
_imuse = IMuse::create_adlib(syst, _mixer);
|
|
|
|
} else {
|
|
|
|
_imuse = IMuse::create_midi(syst, detector->createMidi());
|
|
|
|
}
|
|
|
|
if (detector->_gameTempo != 0)
|
|
|
|
_imuse->property(IMuse::PROP_TEMPO_BASE, detector->_gameTempo);
|
|
|
|
_imuse->set_music_volume(_sound->_sound_volume_music);
|
|
|
|
|
|
|
|
|
|
|
|
// Load game from specified slot, if any
|
|
|
|
if (detector->_save_slot != -1) {
|
|
|
|
_saveLoadSlot = detector->_save_slot;
|
|
|
|
_saveLoadFlag = 2;
|
|
|
|
_saveLoadCompatible = false;
|
|
|
|
}
|
2002-08-14 00:01:39 +00:00
|
|
|
}
|
|
|
|
|
2002-08-18 17:48:18 +00:00
|
|
|
Scumm::~Scumm ()
|
|
|
|
{
|
2002-08-14 00:01:39 +00:00
|
|
|
delete [] _actors;
|
2002-08-18 17:48:18 +00:00
|
|
|
delete _gui;
|
2002-08-14 00:01:39 +00:00
|
|
|
delete _newgui;
|
|
|
|
delete _bundle;
|
|
|
|
delete _timer;
|
2002-08-14 20:43:56 +00:00
|
|
|
delete _sound;
|
2002-08-22 12:09:06 +00:00
|
|
|
delete _imuse;
|
2002-08-14 00:01:39 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::scummInit()
|
|
|
|
{
|
2001-10-09 14:30:12 +00:00
|
|
|
int i;
|
|
|
|
Actor *a;
|
|
|
|
|
2002-08-14 20:43:56 +00:00
|
|
|
tempMusic = 0;
|
2001-10-09 14:30:12 +00:00
|
|
|
debug(9, "scummInit");
|
2001-11-26 19:57:57 +00:00
|
|
|
|
2002-08-29 16:57:43 +00:00
|
|
|
if (_features & GF_OLD_BUNDLE)
|
|
|
|
_resourceHeaderSize = 2; // FIXME - to be rechecked
|
|
|
|
else if (_features & GF_SMALL_HEADER)
|
2002-04-11 17:19:16 +00:00
|
|
|
_resourceHeaderSize = 6;
|
|
|
|
else
|
|
|
|
_resourceHeaderSize = 8;
|
2002-02-12 18:20:37 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!(_features & GF_SMALL_NAMES))
|
|
|
|
loadCharset(1);
|
2001-12-27 17:51:58 +00:00
|
|
|
|
2002-08-31 16:29:17 +00:00
|
|
|
initScreens(0, 16, _realWidth, 144);
|
2001-10-09 14:30:12 +00:00
|
|
|
|
|
|
|
setShake(0);
|
2001-11-06 20:00:47 +00:00
|
|
|
setupCursor();
|
2002-08-04 16:30:59 +00:00
|
|
|
|
|
|
|
_timer->init();
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-05-15 10:25:00 +00:00
|
|
|
/* Allocate and initilise actors */
|
2002-07-16 21:03:14 +00:00
|
|
|
_actors = new Actor[MAX_ACTORS];
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 1, a = getFirstActor(); ++a, i < NUM_ACTORS; i++) {
|
2001-10-09 14:30:12 +00:00
|
|
|
a->number = i;
|
2002-05-15 10:25:00 +00:00
|
|
|
a->initActorClass(this);
|
2002-05-14 19:11:20 +00:00
|
|
|
a->initActor(1);
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2002-05-05 20:08:41 +00:00
|
|
|
|
2001-10-16 10:01:48 +00:00
|
|
|
_vars[VAR_CHARINC] = 4;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
|
|
|
_numNestedScripts = 0;
|
|
|
|
vm.cutSceneStackPointer = 0;
|
|
|
|
|
|
|
|
memset(vm.cutScenePtr, 0, sizeof(vm.cutScenePtr));
|
|
|
|
memset(vm.cutSceneData, 0, sizeof(vm.cutSceneData));
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 0; i < _maxVerbs; i++) {
|
2001-10-16 10:01:48 +00:00
|
|
|
_verbs[i].verbid = 0;
|
2002-08-31 16:29:17 +00:00
|
|
|
_verbs[i].right = _realWidth - 1;
|
2001-10-16 10:01:48 +00:00
|
|
|
_verbs[i].oldleft = -1;
|
|
|
|
_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
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!(_features & GF_AFTER_V7)) {
|
2002-03-05 23:41:41 +00:00
|
|
|
camera._leftTrigger = 10;
|
|
|
|
camera._rightTrigger = 30;
|
|
|
|
camera._mode = 0;
|
2002-04-11 17:19:16 +00:00
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
camera._follows = 0;
|
|
|
|
|
|
|
|
virtscr[0].xstart = 0;
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!(_features & GF_AFTER_V7)) {
|
2002-03-05 23:41:41 +00:00
|
|
|
_vars[VAR_V5_DRAWFLAGS] = 11;
|
|
|
|
_vars[VAR_59] = 3;
|
2002-07-13 14:07:37 +00:00
|
|
|
|
2002-08-23 22:40:26 +00:00
|
|
|
// Setup light
|
2002-07-13 14:07:37 +00:00
|
|
|
_vars[VAR_CURRENT_LIGHTS] = LIGHTMODE_actor_base | LIGHTMODE_actor_color | LIGHTMODE_screen;
|
2002-08-23 22:40:26 +00:00
|
|
|
_flashlightXStrips = 7;
|
|
|
|
_flashlightYStrips = 7;
|
2002-03-05 23:41:41 +00:00
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
|
|
|
|
mouse.x = 104;
|
|
|
|
mouse.y = 56;
|
|
|
|
|
|
|
|
_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;
|
|
|
|
|
|
|
|
charset._bufPos = 0;
|
|
|
|
_haveMsg = 0;
|
|
|
|
|
2002-03-06 10:03:00 +00:00
|
|
|
_varwatch = -1;
|
2001-10-09 14:30:12 +00:00
|
|
|
_screenStartStrip = 0;
|
|
|
|
|
2001-10-26 17:34:50 +00:00
|
|
|
_vars[VAR_TALK_ACTOR] = 0;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
|
|
|
_talkDelay = 0;
|
|
|
|
_keepText = false;
|
|
|
|
|
|
|
|
_cursorState = 0;
|
|
|
|
_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();
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 0; i < 6; i++) {
|
|
|
|
if (_features & GF_OLD256) {
|
2002-02-19 22:36:09 +00:00
|
|
|
string[i].t_xpos = 0;
|
|
|
|
string[i].t_ypos = 0;
|
|
|
|
} else {
|
|
|
|
string[i].t_xpos = 2;
|
|
|
|
string[i].t_ypos = 5;
|
|
|
|
}
|
2002-08-31 16:29:17 +00:00
|
|
|
string[i].t_right = _realWidth - 1;
|
2001-10-16 10:01:48 +00:00
|
|
|
string[i].t_color = 0xF;
|
|
|
|
string[i].t_center = 0;
|
|
|
|
string[i].t_charset = 0;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_numInMsgStack = 0;
|
|
|
|
|
2001-11-05 19:21:49 +00:00
|
|
|
createResource(rtTemp, 6, 500);
|
2001-10-09 14:30:12 +00:00
|
|
|
|
|
|
|
initScummVars();
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!(_features & GF_AFTER_V6))
|
2001-10-26 17:34:50 +00:00
|
|
|
_vars[VAR_V5_TALK_STRING_Y] = -0x50;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
getGraphicsPerformance();
|
2002-04-17 20:23:45 +00:00
|
|
|
|
|
|
|
#ifdef COMPRESSED_SOUND_FILE
|
2002-08-14 20:43:56 +00:00
|
|
|
_sound->_current_cache = 0;
|
2002-04-17 20:23:45 +00:00
|
|
|
#endif
|
2002-08-04 16:30:59 +00:00
|
|
|
|
|
|
|
_timer->installProcedure(&autosave, 5 * 60 * 1000);
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::initScummVars()
|
|
|
|
{
|
|
|
|
if (!(_features & GF_AFTER_V7)) {
|
2002-03-05 23:41:41 +00:00
|
|
|
_vars[VAR_CURRENTDRIVE] = _currentDrive;
|
|
|
|
_vars[VAR_FIXEDDISK] = checkFixedDisk();
|
|
|
|
_vars[VAR_SOUNDCARD] = _soundCardType;
|
|
|
|
_vars[VAR_VIDEOMODE] = 0x13;
|
|
|
|
_vars[VAR_HEAPSPACE] = 630;
|
|
|
|
_vars[VAR_MOUSEPRESENT] = _mousePresent;
|
|
|
|
_vars[VAR_SOUNDPARAM] = _soundParam;
|
|
|
|
_vars[VAR_SOUNDPARAM2] = _soundParam2;
|
|
|
|
_vars[VAR_SOUNDPARAM3] = _soundParam3;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_features & GF_AFTER_V6)
|
2002-03-05 23:41:41 +00:00
|
|
|
_vars[VAR_V6_EMSSPACE] = 10000;
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::checkRange(int max, int min, int no, const char *str)
|
|
|
|
{
|
2001-10-09 14:30:12 +00:00
|
|
|
if (no < min || no > max) {
|
2002-04-11 17:19:16 +00:00
|
|
|
error("Value %d is out of bounds (%d,%d) int script(%d) msg %s", no, min,
|
|
|
|
max, vm.slot[_curExecScript].number, str);
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
int Scumm::scummLoop(int delta)
|
|
|
|
{
|
|
|
|
static int counter = 0;
|
2002-03-16 18:03:28 +00:00
|
|
|
|
2002-03-14 22:45:22 +00:00
|
|
|
#ifndef _WIN32_WCE
|
2001-11-09 18:54:15 +00:00
|
|
|
if (_debugger)
|
|
|
|
_debugger->on_frame();
|
2002-03-14 22:45:22 +00:00
|
|
|
#endif
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2002-07-19 01:40:24 +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.
|
|
|
|
getRandomNumber(2);
|
|
|
|
|
2001-11-09 18:54:15 +00:00
|
|
|
_vars[VAR_TMR_1] += delta;
|
|
|
|
_vars[VAR_TMR_2] += delta;
|
|
|
|
_vars[VAR_TMR_3] += delta;
|
|
|
|
_vars[VAR_TMR_4] += delta;
|
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
|
|
|
|
2001-11-09 18:54:15 +00:00
|
|
|
_talkDelay -= delta;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_talkDelay < 0)
|
|
|
|
_talkDelay = 0;
|
2001-11-09 18:54:15 +00:00
|
|
|
|
|
|
|
processKbd();
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_features & GF_AFTER_V7) {
|
2002-03-06 00:18:22 +00:00
|
|
|
_vars[VAR_CAMERA_POS_X] = camera._cur.x;
|
|
|
|
_vars[VAR_CAMERA_POS_Y] = camera._cur.y;
|
|
|
|
} else {
|
|
|
|
_vars[VAR_CAMERA_POS_X] = camera._cur.x;
|
|
|
|
}
|
2002-06-02 12:07:12 +00:00
|
|
|
_vars[VAR_HAVE_MSG] = (_haveMsg == 0xFE) ? 0xFF : _haveMsg;
|
2001-11-09 18:54:15 +00:00
|
|
|
_vars[VAR_VIRT_MOUSE_X] = _virtual_mouse_x;
|
|
|
|
_vars[VAR_VIRT_MOUSE_Y] = _virtual_mouse_y;
|
|
|
|
_vars[VAR_MOUSE_X] = mouse.x;
|
|
|
|
_vars[VAR_MOUSE_Y] = mouse.y;
|
|
|
|
_vars[VAR_DEBUGMODE] = _debugMode;
|
|
|
|
|
2002-04-17 20:23:45 +00:00
|
|
|
if (_features & GF_AUDIOTRACKS) {
|
2002-04-07 01:40:38 +00:00
|
|
|
if (delta) {
|
|
|
|
if (++counter != 2)
|
2002-04-11 17:19:16 +00:00
|
|
|
_vars[VAR_MI1_TIMER] += 5;
|
2002-04-07 01:40:38 +00:00
|
|
|
else {
|
|
|
|
counter = 0;
|
2002-04-11 17:19:16 +00:00
|
|
|
_vars[VAR_MI1_TIMER] += 6;
|
2002-04-17 20:23:45 +00:00
|
|
|
}
|
2002-04-07 01:40:38 +00:00
|
|
|
}
|
2002-07-16 21:03:14 +00:00
|
|
|
} else if (_features & GF_OLD256) {
|
2002-04-20 04:09:02 +00:00
|
|
|
|
2002-04-24 04:26:09 +00:00
|
|
|
if(tempMusic == 3) {
|
2002-04-19 21:06:50 +00:00
|
|
|
tempMusic = 0;
|
|
|
|
_vars[VAR_MUSIC_FLAG]++;
|
2002-04-24 04:26:09 +00:00
|
|
|
} else {
|
2002-04-19 21:06:50 +00:00
|
|
|
tempMusic ++;
|
|
|
|
}
|
|
|
|
}
|
2001-11-09 18:54:15 +00:00
|
|
|
|
2002-04-20 04:09:02 +00:00
|
|
|
|
2001-11-09 18:54:15 +00:00
|
|
|
if (_saveLoadFlag) {
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_saveLoadFlag == 1) {
|
2001-11-09 18:54:15 +00:00
|
|
|
saveState(_saveLoadSlot, _saveLoadCompatible);
|
2002-07-14 03:01:36 +00:00
|
|
|
// Ender: Disabled for small_header games, as
|
|
|
|
// can overwrite game variables (eg, Zak256 cashcards)
|
2002-07-14 04:54:56 +00:00
|
|
|
if (_saveLoadCompatible && !(_features & GF_SMALL_HEADER))
|
|
|
|
_vars[VAR_GAME_LOADED] = 201;
|
2001-11-09 18:54:15 +00:00
|
|
|
} else {
|
|
|
|
loadState(_saveLoadSlot, _saveLoadCompatible);
|
2002-07-14 03:01:36 +00:00
|
|
|
// Ender: Disabled for small_header games, as
|
|
|
|
// can overwrite game variables (eg, Zak256 cashcards)
|
2002-07-14 04:54:56 +00:00
|
|
|
if (_saveLoadCompatible && !(_features & GF_SMALL_HEADER))
|
2001-11-09 18:54:15 +00:00
|
|
|
_vars[VAR_GAME_LOADED] = 203;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2001-11-09 18:54:15 +00:00
|
|
|
_saveLoadFlag = 0;
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-04-27 04:31:25 +00:00
|
|
|
if (_doAutosave) {
|
|
|
|
_saveLoadSlot = 0;
|
|
|
|
sprintf(_saveLoadName, "Autosave %d", _saveLoadSlot);
|
|
|
|
_saveLoadFlag = 1;
|
|
|
|
_saveLoadCompatible = false;
|
|
|
|
_doAutosave = false;
|
|
|
|
}
|
|
|
|
|
2001-11-09 18:54:15 +00:00
|
|
|
if (_completeScreenRedraw) {
|
|
|
|
_completeScreenRedraw = false;
|
|
|
|
gdi.clearUpperMask();
|
|
|
|
charset._hasMask = false;
|
|
|
|
redrawVerbs();
|
|
|
|
_fullRedraw = true;
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2001-11-09 18:54:15 +00:00
|
|
|
runAllScripts();
|
|
|
|
checkExecVerbs();
|
|
|
|
checkAndRunVar33();
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_currentRoom == 0) {
|
2001-11-09 18:54:15 +00:00
|
|
|
gdi._cursorActive = 0;
|
|
|
|
CHARSET_1();
|
|
|
|
drawDirtyScreenParts();
|
2002-08-14 20:43:56 +00:00
|
|
|
_sound->processSoundQues();
|
2001-12-27 17:51:58 +00:00
|
|
|
camera._last = camera._cur;
|
2001-11-09 18:54:15 +00:00
|
|
|
} else {
|
2001-10-09 14:30:12 +00:00
|
|
|
walkActors();
|
|
|
|
moveCamera();
|
|
|
|
fixObjectFlags();
|
|
|
|
CHARSET_1();
|
2002-08-20 02:13:41 +00:00
|
|
|
|
|
|
|
if (camera._cur.x != camera._last.x || _BgNeedsRedraw || _fullRedraw
|
|
|
|
|| (_features & GF_AFTER_V7 && camera._cur.y != camera._last.y)) {
|
|
|
|
redrawBGAreas();
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2002-08-20 02:13:41 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
processDrawQue();
|
|
|
|
setActorRedrawFlags();
|
|
|
|
resetActorBgs();
|
|
|
|
|
2002-07-13 14:07:37 +00:00
|
|
|
if (!(_vars[VAR_CURRENT_LIGHTS] & LIGHTMODE_screen) &&
|
|
|
|
_vars[VAR_CURRENT_LIGHTS] & LIGHTMODE_flashlight) {
|
2002-08-19 17:23:48 +00:00
|
|
|
drawFlashlight();
|
|
|
|
setActorRedrawFlags();
|
2002-07-13 14:07:37 +00:00
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2001-11-26 19:57:57 +00:00
|
|
|
processActors();
|
2001-10-09 14:30:12 +00:00
|
|
|
clear_fullRedraw();
|
|
|
|
cyclePalette();
|
|
|
|
palManipulate();
|
2001-11-09 18:54:15 +00:00
|
|
|
|
2001-10-26 17:34:50 +00:00
|
|
|
if (_doEffect) {
|
|
|
|
_doEffect = false;
|
2002-07-13 14:07:37 +00:00
|
|
|
fadeIn(_newEffect);
|
2001-10-09 14:30:12 +00:00
|
|
|
clearClickedStatus();
|
|
|
|
}
|
2001-11-09 18:54:15 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
if (_cursorState > 0) {
|
|
|
|
verbMouseOver(checkMouseOver(mouse.x, mouse.y));
|
|
|
|
}
|
|
|
|
|
2002-04-21 21:20:32 +00:00
|
|
|
drawBlastObjects();
|
2001-11-09 18:54:15 +00:00
|
|
|
drawDirtyScreenParts();
|
2002-04-21 21:20:32 +00:00
|
|
|
removeBlastObjects();
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!(_features & GF_AFTER_V6))
|
2001-10-23 19:51:50 +00:00
|
|
|
playActorSounds();
|
|
|
|
|
2002-08-14 20:43:56 +00:00
|
|
|
_sound->processSoundQues();
|
2001-12-27 17:51:58 +00:00
|
|
|
camera._last = camera._cur;
|
2001-11-09 18:54:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!(++_expire_counter)) {
|
|
|
|
increaseResourceCounter();
|
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2002-04-12 21:26:59 +00:00
|
|
|
animateCursor();
|
|
|
|
|
|
|
|
/* show or hide mouse */
|
|
|
|
_system->show_mouse(_cursorState > 0);
|
|
|
|
|
2001-11-09 18:54:15 +00:00
|
|
|
_vars[VAR_TIMER] = 0;
|
|
|
|
return _vars[VAR_TIMER_NEXT];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::startScene(int room, Actor * a, int objectNr)
|
|
|
|
{
|
|
|
|
int i, where;
|
2001-10-09 14:30:12 +00:00
|
|
|
Actor *at;
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
CHECK_HEAP debug(1, "Loading room %d", room);
|
2001-11-05 19:21:49 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
clearMsgQueue();
|
|
|
|
|
2002-07-13 14:07:37 +00:00
|
|
|
fadeOut(_switchRoomEffect2);
|
2001-10-09 14:30:12 +00:00
|
|
|
_newEffect = _switchRoomEffect;
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_currentScript != 0xFF) {
|
|
|
|
if (vm.slot[_currentScript].where == WIO_ROOM ||
|
|
|
|
vm.slot[_currentScript].where == WIO_FLOBJECT) {
|
|
|
|
if (vm.slot[_currentScript].cutsceneOverride != 0)
|
|
|
|
error("Object %d stopped with active cutscene/override in exit",
|
|
|
|
vm.slot[_currentScript].number);
|
2001-10-09 14:30:12 +00:00
|
|
|
_currentScript = 0xFF;
|
2002-04-11 17:19:16 +00:00
|
|
|
} else if (vm.slot[_currentScript].where == WIO_LOCAL) {
|
|
|
|
if (vm.slot[_currentScript].cutsceneOverride != 0)
|
|
|
|
error("Script %d stopped with active cutscene/override in exit",
|
|
|
|
vm.slot[_currentScript].number);
|
2001-10-09 14:30:12 +00:00
|
|
|
_currentScript = 0xFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-14 04:54:56 +00:00
|
|
|
if (!(_features & GF_SMALL_HEADER)) // Disable for SH games. Overwrites
|
2002-07-14 03:01:36 +00:00
|
|
|
_vars[VAR_NEW_ROOM] = room; // gamevars, eg Zak cashcards
|
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
runExitScript();
|
|
|
|
killScriptsAndResources();
|
2001-12-27 17:51:58 +00:00
|
|
|
clearEnqueue();
|
2001-10-09 14:30:12 +00:00
|
|
|
stopCycle(0);
|
2001-12-27 17:51:58 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 1, at = getFirstActor(); ++at, i < NUM_ACTORS; i++) {
|
2002-05-23 00:37:00 +00:00
|
|
|
at->hideActor();
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2001-12-27 17:51:58 +00:00
|
|
|
if (!(_features & GF_AFTER_V7)) {
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 0; i < 0x100; i++)
|
2001-12-27 17:51:58 +00:00
|
|
|
_shadowPalette[i] = i;
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
|
|
|
|
clearDrawObjectQueue();
|
|
|
|
|
2001-10-16 10:01:48 +00:00
|
|
|
_vars[VAR_ROOM] = room;
|
2002-06-07 16:36:01 +00:00
|
|
|
_fullRedraw = true;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2001-11-05 19:21:49 +00:00
|
|
|
increaseResourceCounter();
|
2001-10-09 14:30:12 +00:00
|
|
|
|
|
|
|
_currentRoom = room;
|
2001-10-16 10:01:48 +00:00
|
|
|
_vars[VAR_ROOM] = room;
|
2002-04-24 04:26:09 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
if (room >= 0x80)
|
2002-04-11 17:19:16 +00:00
|
|
|
_roomResource = _resourceMapper[room & 0x7F];
|
2001-10-09 14:30:12 +00:00
|
|
|
else
|
|
|
|
_roomResource = room;
|
|
|
|
|
2001-10-16 10:01:48 +00:00
|
|
|
_vars[VAR_ROOM_RESOURCE] = _roomResource;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (room != 0)
|
2001-10-09 14:30:12 +00:00
|
|
|
ensureResourceLoaded(1, room);
|
|
|
|
|
|
|
|
if (_currentRoom == 0) {
|
|
|
|
_ENCD_offs = _EXCD_offs = 0;
|
|
|
|
_numObjectsInRoom = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
initRoomSubBlocks();
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_features & GF_SMALL_HEADER)
|
|
|
|
loadRoomObjectsSmall();
|
|
|
|
else
|
|
|
|
loadRoomObjects();
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!(_features & GF_AFTER_V7)) {
|
2002-03-06 00:18:22 +00:00
|
|
|
camera._mode = CM_NORMAL;
|
2002-08-31 16:29:17 +00:00
|
|
|
camera._cur.x = camera._dest.x = _realWidth / 2;
|
|
|
|
camera._cur.y = camera._dest.y = _realHeight / 2;
|
2002-03-06 00:18:22 +00:00
|
|
|
}
|
2001-10-26 17:34:50 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_features & GF_AFTER_V6) {
|
2001-12-27 17:51:58 +00:00
|
|
|
_vars[VAR_V6_SCREEN_WIDTH] = _scrWidth;
|
2001-10-26 17:34:50 +00:00
|
|
|
_vars[VAR_V6_SCREEN_HEIGHT] = _scrHeight;
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_features & GF_AFTER_V7) {
|
2002-08-31 16:29:17 +00:00
|
|
|
_vars[VAR_CAMERA_MIN_X] = _realWidth / 2;
|
|
|
|
_vars[VAR_CAMERA_MAX_X] = _scrWidth - (_realWidth / 2);
|
|
|
|
_vars[VAR_CAMERA_MIN_Y] = _realHeight / 2;
|
|
|
|
_vars[VAR_CAMERA_MAX_Y] = _scrHeight - (_realHeight / 2);
|
|
|
|
setCameraAt(_realWidth / 2, _realHeight / 2);
|
2002-03-06 00:18:22 +00:00
|
|
|
} else {
|
2002-08-31 16:29:17 +00:00
|
|
|
_vars[VAR_CAMERA_MAX_X] = _scrWidth - (_realWidth / 2);
|
|
|
|
_vars[VAR_CAMERA_MIN_X] = _realWidth / 2;
|
2002-03-06 00:18:22 +00:00
|
|
|
}
|
2001-12-27 17:51:58 +00:00
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
if (_roomResource == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
2001-11-26 19:57:57 +00:00
|
|
|
memset(gfxUsageBits, 0, sizeof(gfxUsageBits));
|
2001-10-09 14:30:12 +00:00
|
|
|
|
|
|
|
if (a) {
|
2001-11-12 20:50:36 +00:00
|
|
|
where = whereIsObject(objectNr);
|
2002-04-11 17:19:16 +00:00
|
|
|
if (where != WIO_ROOM && where != WIO_FLOBJECT)
|
|
|
|
error("startScene: Object %d is not in room %d", objectNr,
|
|
|
|
_currentRoom);
|
2002-07-16 18:51:27 +00:00
|
|
|
int x, y, dir;
|
|
|
|
getObjectXYPos(objectNr, x, y, dir);
|
2002-07-18 15:45:10 +00:00
|
|
|
a->putActor(x, y, _currentRoom);
|
|
|
|
a->setDirection(dir + 180);
|
2001-10-09 14:30:12 +00:00
|
|
|
a->moving = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
showActors();
|
|
|
|
|
2001-10-26 17:34:50 +00:00
|
|
|
_egoPositioned = false;
|
|
|
|
runEntryScript();
|
2001-12-27 17:51:58 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!(_features & GF_AFTER_V7)) {
|
2002-03-06 00:18:22 +00:00
|
|
|
if (a && !_egoPositioned) {
|
2002-07-16 18:51:27 +00:00
|
|
|
int x, y;
|
|
|
|
getObjectXYPos(objectNr, x, y);
|
2002-07-18 15:45:10 +00:00
|
|
|
a->putActor(x, y, _currentRoom);
|
2002-03-06 00:18:22 +00:00
|
|
|
a->moving = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (camera._follows) {
|
|
|
|
Actor *a = derefActorSafe(camera._follows, "startScene: follows");
|
|
|
|
setCameraAt(a->x, a->y);
|
|
|
|
}
|
2001-12-27 17:51:58 +00:00
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2001-10-26 17:34:50 +00:00
|
|
|
_doEffect = true;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-04-12 21:26:59 +00:00
|
|
|
CHECK_HEAP;
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::initRoomSubBlocks()
|
|
|
|
{
|
|
|
|
int i, offs;
|
2001-10-09 14:30:12 +00:00
|
|
|
byte *ptr;
|
2002-04-11 17:19:16 +00:00
|
|
|
byte *roomptr, *searchptr;
|
2001-12-27 17:51:58 +00:00
|
|
|
RoomHeader *rmhd;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
|
|
|
_ENCD_offs = 0;
|
|
|
|
_EXCD_offs = 0;
|
2001-10-16 10:01:48 +00:00
|
|
|
_CLUT_offs = 0;
|
|
|
|
_PALS_offs = 0;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2001-11-05 19:21:49 +00:00
|
|
|
nukeResource(rtMatrix, 1);
|
|
|
|
nukeResource(rtMatrix, 2);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
|
|
|
for (i = 1; i < _maxScaleTable; i++)
|
2001-11-05 19:21:49 +00:00
|
|
|
nukeResource(rtScaleTable, i);
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2001-11-05 19:21:49 +00:00
|
|
|
roomptr = getResourceAddress(rtRoom, _roomResource);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
|
|
|
rmhd = (RoomHeader *)findResourceData(MKID('RMHD'), roomptr);
|
|
|
|
|
|
|
|
if (_features & GF_AFTER_V7) {
|
2002-03-05 20:13:47 +00:00
|
|
|
_scrWidth = READ_LE_UINT16(&(rmhd->v7.width));
|
|
|
|
_scrHeight = READ_LE_UINT16(&(rmhd->v7.height));
|
|
|
|
} else {
|
2002-04-11 17:19:16 +00:00
|
|
|
_scrWidth = READ_LE_UINT16(&(rmhd->old.width));
|
2002-03-05 20:13:47 +00:00
|
|
|
_scrHeight = READ_LE_UINT16(&(rmhd->old.height));
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
|
|
|
|
if (_features & GF_SMALL_HEADER)
|
|
|
|
_IM00_offs = findResourceData(MKID('IM00'), roomptr) - roomptr;
|
|
|
|
else
|
|
|
|
_IM00_offs =
|
|
|
|
findResource(MKID('IM00'),
|
|
|
|
findResource(MKID('RMIM'), roomptr)) - roomptr;
|
|
|
|
|
2001-12-27 17:51:58 +00:00
|
|
|
ptr = findResourceData(MKID('EXCD'), roomptr);
|
2001-10-09 14:30:12 +00:00
|
|
|
if (ptr) {
|
|
|
|
_EXCD_offs = ptr - roomptr;
|
|
|
|
#ifdef DUMP_SCRIPTS
|
2001-12-27 17:51:58 +00:00
|
|
|
dumpResource("exit-", _roomResource, ptr - 8);
|
2001-10-09 14:30:12 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2001-12-27 17:51:58 +00:00
|
|
|
ptr = findResourceData(MKID('ENCD'), roomptr);
|
2001-10-09 14:30:12 +00:00
|
|
|
if (ptr) {
|
|
|
|
_ENCD_offs = ptr - roomptr;
|
|
|
|
#ifdef DUMP_SCRIPTS
|
2001-12-27 17:51:58 +00:00
|
|
|
dumpResource("entry-", _roomResource, ptr - 8);
|
2001-10-09 14:30:12 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_features & GF_SMALL_HEADER) {
|
2002-02-12 21:28:07 +00:00
|
|
|
ptr = findResourceData(MKID('BOXD'), roomptr);
|
|
|
|
if (ptr) {
|
2002-04-11 17:19:16 +00:00
|
|
|
byte numOfBoxes = *(ptr);
|
|
|
|
int size;
|
2002-03-08 08:27:45 +00:00
|
|
|
if (_features & GF_OLD256)
|
2002-04-11 17:19:16 +00:00
|
|
|
size = numOfBoxes * (SIZEOF_BOX - 2) + 1;
|
2002-03-08 08:27:45 +00:00
|
|
|
else
|
|
|
|
size = numOfBoxes * SIZEOF_BOX + 1;
|
|
|
|
|
|
|
|
|
2002-02-12 21:28:07 +00:00
|
|
|
createResource(rtMatrix, 2, size);
|
|
|
|
memcpy(getResourceAddress(rtMatrix, 2), ptr, size);
|
|
|
|
ptr += size;
|
2002-04-11 17:19:16 +00:00
|
|
|
size = getResourceDataSize(ptr - size - 6) - size;
|
2002-02-25 17:29:51 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (size >= 0) { // do this :)
|
2002-02-22 16:59:24 +00:00
|
|
|
createResource(rtMatrix, 1, size);
|
|
|
|
memcpy(getResourceAddress(rtMatrix, 1), ptr, size);
|
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2002-02-12 21:28:07 +00:00
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
} else {
|
|
|
|
ptr = findResourceData(MKID('BOXD'), roomptr);
|
|
|
|
if (ptr) {
|
|
|
|
int size = getResourceDataSize(ptr);
|
2002-02-12 21:28:07 +00:00
|
|
|
createResource(rtMatrix, 2, size);
|
2002-04-11 17:19:16 +00:00
|
|
|
roomptr = getResourceAddress(rtRoom, _roomResource);
|
|
|
|
ptr = findResourceData(MKID('BOXD'), roomptr);
|
|
|
|
memcpy(getResourceAddress(rtMatrix, 2), ptr, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
ptr = findResourceData(MKID('BOXM'), roomptr);
|
|
|
|
if (ptr) {
|
|
|
|
int size = getResourceDataSize(ptr);
|
|
|
|
createResource(rtMatrix, 1, size);
|
|
|
|
roomptr = getResourceAddress(rtRoom, _roomResource);
|
|
|
|
ptr = findResourceData(MKID('BOXM'), roomptr);
|
|
|
|
memcpy(getResourceAddress(rtMatrix, 1), ptr, size);
|
|
|
|
}
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2001-12-27 17:51:58 +00:00
|
|
|
ptr = findResourceData(MKID('SCAL'), roomptr);
|
2001-10-09 14:30:12 +00:00
|
|
|
if (ptr) {
|
|
|
|
offs = ptr - roomptr;
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 1; i < _maxScaleTable; i++, offs += 8) {
|
2001-12-27 17:51:58 +00:00
|
|
|
int a = READ_LE_UINT16(roomptr + offs);
|
|
|
|
int b = READ_LE_UINT16(roomptr + offs + 2);
|
|
|
|
int c = READ_LE_UINT16(roomptr + offs + 4);
|
|
|
|
int d = READ_LE_UINT16(roomptr + offs + 6);
|
2001-10-09 14:30:12 +00:00
|
|
|
if (a || b || c || d) {
|
|
|
|
setScaleItem(i, b, a, d, c);
|
2001-11-05 19:21:49 +00:00
|
|
|
roomptr = getResourceAddress(rtRoom, _roomResource);
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-11-26 19:57:57 +00:00
|
|
|
memset(_localScriptList, 0, sizeof(_localScriptList));
|
|
|
|
|
|
|
|
searchptr = roomptr = getResourceAddress(rtRoom, _roomResource);
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_features & GF_SMALL_HEADER) {
|
|
|
|
while ((ptr = findResourceSmall(MKID('LSCR'), searchptr)) != NULL) {
|
2002-03-10 17:33:04 +00:00
|
|
|
int id = 0;
|
2002-04-11 17:19:16 +00:00
|
|
|
ptr += _resourceHeaderSize; /* skip tag & size */
|
2002-06-01 21:39:57 +00:00
|
|
|
id = ptr[0];
|
2002-04-11 17:19:16 +00:00
|
|
|
#ifdef DUMP_SCRIPTS
|
2002-02-12 21:28:07 +00:00
|
|
|
do {
|
|
|
|
char buf[32];
|
2002-04-11 17:19:16 +00:00
|
|
|
sprintf(buf, "room-%d-", _roomResource);
|
2002-02-12 21:28:07 +00:00
|
|
|
dumpResource(buf, id, ptr - 6);
|
|
|
|
} while (0);
|
2002-04-11 17:19:16 +00:00
|
|
|
#endif
|
2002-02-12 21:28:07 +00:00
|
|
|
_localScriptList[id - _numGlobalScripts] = ptr + 1 - roomptr;
|
|
|
|
searchptr = NULL;
|
|
|
|
}
|
|
|
|
} else {
|
2002-04-11 17:19:16 +00:00
|
|
|
while ((ptr = findResource(MKID('LSCR'), searchptr)) != NULL) {
|
|
|
|
int id = 0;
|
|
|
|
|
|
|
|
ptr += _resourceHeaderSize; /* skip tag & size */
|
2001-12-27 17:51:58 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_features & GF_AFTER_V7) {
|
2002-03-06 00:18:22 +00:00
|
|
|
id = READ_LE_UINT16(ptr);
|
|
|
|
checkRange(2050, 2000, id, "Invalid local script %d");
|
|
|
|
_localScriptList[id - _numGlobalScripts] = ptr + 2 - roomptr;
|
|
|
|
} else {
|
2002-04-11 17:19:16 +00:00
|
|
|
id = ptr[0];
|
|
|
|
_localScriptList[id - _numGlobalScripts] = ptr + 1 - roomptr;
|
2002-03-06 00:18:22 +00:00
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
#ifdef DUMP_SCRIPTS
|
2002-04-11 17:19:16 +00:00
|
|
|
do {
|
|
|
|
char buf[32];
|
|
|
|
sprintf(buf, "room-%d-", _roomResource);
|
|
|
|
dumpResource(buf, id, ptr - 8);
|
|
|
|
} while (0);
|
2001-10-09 14:30:12 +00:00
|
|
|
#endif
|
2002-04-11 17:19:16 +00:00
|
|
|
searchptr = NULL;
|
|
|
|
}
|
|
|
|
}
|
2002-02-12 21:28:07 +00:00
|
|
|
|
2002-08-29 20:01:27 +00:00
|
|
|
// FIXME - we could simply always call findResourceData here, it will
|
|
|
|
// do the right thing even if GF_SMALL_HEADER is set. But then, we have
|
|
|
|
// to change setPaletteFromPtr() (easy). The problematic bit is save game
|
|
|
|
// compatibility - _CLUT_offs is stored in the save game after all.
|
|
|
|
// Of course we could just decide to not use _CLUT_offs anymore, and change
|
|
|
|
// setPaletteFromRes() to invoke findResourceData() each time
|
|
|
|
// (and also getPalettePtr()).
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_features & GF_SMALL_HEADER)
|
2002-02-12 21:28:07 +00:00
|
|
|
ptr = findResourceSmall(MKID('CLUT'), roomptr);
|
|
|
|
else
|
2002-04-11 17:19:16 +00:00
|
|
|
ptr = findResourceData(MKID('CLUT'), roomptr);
|
2002-02-12 21:28:07 +00:00
|
|
|
|
2001-10-16 10:01:48 +00:00
|
|
|
if (ptr) {
|
|
|
|
_CLUT_offs = ptr - roomptr;
|
|
|
|
setPaletteFromRes();
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_features & GF_AFTER_V6) {
|
2001-11-26 19:57:57 +00:00
|
|
|
ptr = findResource(MKID('PALS'), roomptr);
|
2001-10-23 19:51:50 +00:00
|
|
|
if (ptr) {
|
|
|
|
_PALS_offs = ptr - roomptr;
|
|
|
|
setPalette(0);
|
|
|
|
}
|
2001-10-16 10:01:48 +00:00
|
|
|
}
|
2002-02-12 18:20:37 +00:00
|
|
|
|
2002-08-29 20:01:27 +00:00
|
|
|
ptr = findResourceData(MKID('CYCL'), roomptr);
|
2002-02-12 18:20:37 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (ptr)
|
2002-08-29 20:01:27 +00:00
|
|
|
initCycl(ptr);
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2001-12-27 17:51:58 +00:00
|
|
|
ptr = findResourceData(MKID('TRNS'), roomptr);
|
2001-10-09 14:30:12 +00:00
|
|
|
if (ptr)
|
2001-12-27 17:51:58 +00:00
|
|
|
gdi._transparency = ptr[0];
|
2001-10-09 14:30:12 +00:00
|
|
|
else
|
2001-10-26 17:34:50 +00:00
|
|
|
gdi._transparency = 255;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-04-23 23:58:31 +00:00
|
|
|
initBGBuffers(_scrHeight);
|
|
|
|
|
2001-11-26 19:57:57 +00:00
|
|
|
memset(_extraBoxFlags, 0, sizeof(_extraBoxFlags));
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::setScaleItem(int slot, int a, int b, int c, int d)
|
|
|
|
{
|
2001-10-09 14:30:12 +00:00
|
|
|
byte *ptr;
|
2002-04-11 17:19:16 +00:00
|
|
|
int cur, amounttoadd, i, tmp;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2001-11-05 19:21:49 +00:00
|
|
|
ptr = createResource(rtScaleTable, slot, 200);
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (a == c)
|
2001-10-09 14:30:12 +00:00
|
|
|
return;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
|
|
|
cur = (b - d) * a;
|
2001-10-09 14:30:12 +00:00
|
|
|
amounttoadd = d - b;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
|
|
|
for (i = 200; i > 0; i--) {
|
2001-10-09 14:30:12 +00:00
|
|
|
tmp = cur / (c - a) + b;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (tmp < 1)
|
|
|
|
tmp = 1;
|
|
|
|
if (tmp > 255)
|
|
|
|
tmp = 255;
|
2001-10-09 14:30:12 +00:00
|
|
|
*ptr++ = tmp;
|
|
|
|
cur += amounttoadd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::dumpResource(char *tag, int idx, byte *ptr)
|
|
|
|
{
|
2001-10-09 14:30:12 +00:00
|
|
|
char buf[256];
|
|
|
|
FILE *out;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
|
|
|
uint32 size;
|
|
|
|
if (_features & GF_SMALL_HEADER)
|
|
|
|
size = READ_LE_UINT32(ptr);
|
|
|
|
else
|
|
|
|
size = READ_BE_UINT32_UNALIGNED(ptr + 4);
|
|
|
|
|
2002-05-05 20:04:26 +00:00
|
|
|
#if defined(MACOS_CARBON)
|
2002-04-11 17:19:16 +00:00
|
|
|
sprintf(buf, ":dumps:%s%d.dmp", tag, idx);
|
|
|
|
#else
|
|
|
|
sprintf(buf, "dumps/%s%d.dmp", tag, idx);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
out = fopen(buf, "rb");
|
2001-10-09 14:30:12 +00:00
|
|
|
if (!out) {
|
|
|
|
out = fopen(buf, "wb");
|
|
|
|
if (!out)
|
|
|
|
return;
|
|
|
|
fwrite(ptr, size, 1, out);
|
|
|
|
}
|
|
|
|
fclose(out);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::clear_fullRedraw()
|
|
|
|
{
|
2001-10-09 14:30:12 +00:00
|
|
|
_fullRedraw = 0;
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::clearClickedStatus()
|
|
|
|
{
|
2001-10-09 14:30:12 +00:00
|
|
|
checkKeyHit();
|
|
|
|
_mouseButStat = 0;
|
|
|
|
_leftBtnPressed = 0;
|
|
|
|
_rightBtnPressed = 0;
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
int Scumm::checkKeyHit()
|
|
|
|
{
|
2001-10-09 14:30:12 +00:00
|
|
|
int a = _keyPressed;
|
|
|
|
_keyPressed = 0;
|
|
|
|
return a;
|
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
|
|
|
|
void Scumm::pauseGame(bool user)
|
|
|
|
{
|
2002-07-08 00:10:11 +00:00
|
|
|
//_gui->pause();
|
|
|
|
_newgui->pauseDialog();
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::setOptions()
|
|
|
|
{
|
2002-07-05 17:00:18 +00:00
|
|
|
_gui->options();
|
2002-07-08 00:10:11 +00:00
|
|
|
//_newgui->optionsDialog();
|
2002-03-14 16:49:59 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::shutDown(int i)
|
|
|
|
{
|
2001-10-09 14:30:12 +00:00
|
|
|
/* TODO: implement this */
|
|
|
|
warning("shutDown: not implemented");
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::processKbd()
|
|
|
|
{
|
2002-05-11 21:09:30 +00:00
|
|
|
int saveloadkey;
|
2001-10-09 14:30:12 +00:00
|
|
|
getKeyInput(0);
|
|
|
|
|
2002-05-11 21:09:30 +00:00
|
|
|
if (_features & GF_OLD256) /* FIXME: Support ingame screen */
|
|
|
|
saveloadkey = 319;
|
|
|
|
else
|
|
|
|
saveloadkey = _vars[VAR_SAVELOADDIALOG_KEY];
|
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
_virtual_mouse_x = mouse.x + virtscr[0].xstart;
|
2002-04-23 23:58:31 +00:00
|
|
|
|
2002-04-24 04:26:09 +00:00
|
|
|
|
|
|
|
|
2002-04-23 23:58:31 +00:00
|
|
|
if(_features & GF_AFTER_V7)
|
|
|
|
_virtual_mouse_y = mouse.y + camera._cur.y-100;
|
|
|
|
else
|
|
|
|
_virtual_mouse_y = mouse.y;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
|
|
|
if (!(_features & GF_OLD256))
|
|
|
|
_virtual_mouse_y += virtscr[0].topline;
|
2002-02-22 16:06:09 +00:00
|
|
|
else
|
2002-04-11 17:19:16 +00:00
|
|
|
_virtual_mouse_y -= 16;
|
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
if (_virtual_mouse_y < 0)
|
2002-04-11 17:19:16 +00:00
|
|
|
_virtual_mouse_y = -1;
|
2002-05-11 21:09:30 +00:00
|
|
|
|
2002-02-22 16:06:09 +00:00
|
|
|
if (_features & GF_OLD256) {
|
|
|
|
if (_virtual_mouse_y >= virtscr[0].height + virtscr[0].topline)
|
|
|
|
_virtual_mouse_y = -1;
|
|
|
|
} else {
|
|
|
|
if (_virtual_mouse_y >= virtscr[0].height)
|
|
|
|
_virtual_mouse_y = -1;
|
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
|
|
|
|
if (!_lastKeyHit)
|
|
|
|
return;
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_lastKeyHit == KEY_SET_OPTIONS) {
|
2002-03-14 16:49:59 +00:00
|
|
|
setOptions();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_lastKeyHit == _vars[VAR_RESTART_KEY]) {
|
2001-10-09 14:30:12 +00:00
|
|
|
warning("Restart not implemented");
|
2002-04-11 17:19:16 +00:00
|
|
|
// pauseGame(true);
|
2001-10-09 14:30:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_lastKeyHit == _vars[VAR_PAUSE_KEY]) {
|
2001-11-14 18:40:39 +00:00
|
|
|
pauseGame(true);
|
2001-10-09 14:30:12 +00:00
|
|
|
/* pause */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_lastKeyHit == _vars[VAR_CUTSCENEEXIT_KEY]) {
|
2002-03-25 14:22:09 +00:00
|
|
|
if (_insaneState) {
|
2002-04-11 17:19:16 +00:00
|
|
|
videoFinished = 1;
|
2002-03-25 14:22:09 +00:00
|
|
|
} else
|
|
|
|
exitCutscene();
|
2002-05-11 21:09:30 +00:00
|
|
|
} else if (_lastKeyHit == saveloadkey
|
2002-04-11 17:19:16 +00:00
|
|
|
&& _currentRoom != 0) {
|
|
|
|
if (_features & GF_AFTER_V7)
|
|
|
|
runScript(_vars[VAR_UNK_SCRIPT], 0, 0, 0);
|
2002-07-05 17:00:18 +00:00
|
|
|
_gui->saveLoadDialog();
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_features & GF_AFTER_V7)
|
|
|
|
runScript(_vars[VAR_UNK_SCRIPT_2], 0, 0, 0);
|
|
|
|
} else if (_lastKeyHit == _vars[VAR_TALKSTOP_KEY]) {
|
2001-10-09 14:30:12 +00:00
|
|
|
_talkDelay = 0;
|
2002-08-14 20:43:56 +00:00
|
|
|
if (_sound->_sfxMode == 2)
|
2001-11-14 18:40:39 +00:00
|
|
|
stopTalk();
|
2001-10-09 14:30:12 +00:00
|
|
|
return;
|
2002-07-02 18:08:35 +00:00
|
|
|
} else if (_lastKeyHit == '[') { // [, eg volume down
|
2002-08-14 20:43:56 +00:00
|
|
|
_sound->_sound_volume_master-=5;
|
|
|
|
if (_sound->_sound_volume_master < 0)
|
|
|
|
_sound->_sound_volume_master = 0;
|
|
|
|
_imuse->set_master_volume(_sound->_sound_volume_master);
|
2002-07-02 18:08:35 +00:00
|
|
|
} else if (_lastKeyHit == ']') { // ], eg volume down
|
2002-08-14 20:43:56 +00:00
|
|
|
_sound->_sound_volume_master+=5;
|
|
|
|
if (_sound->_sound_volume_master > 128)
|
|
|
|
_sound->_sound_volume_master = 128;
|
|
|
|
_imuse->set_master_volume(_sound->_sound_volume_master);
|
2002-07-02 18:08:35 +00:00
|
|
|
} else if (_lastKeyHit == '-') { // -, eg text speed down
|
2002-05-05 22:39:52 +00:00
|
|
|
_defaultTalkDelay+=5;
|
|
|
|
if (_defaultTalkDelay > 90)
|
|
|
|
_defaultTalkDelay = 90;
|
|
|
|
|
|
|
|
_vars[VAR_CHARINC] = _defaultTalkDelay / 20;
|
2002-07-02 18:08:35 +00:00
|
|
|
} else if (_lastKeyHit == '+') { // +, eg text speed up
|
2002-05-05 22:39:52 +00:00
|
|
|
_defaultTalkDelay-=5;
|
|
|
|
if (_defaultTalkDelay < 5)
|
|
|
|
_defaultTalkDelay = 5;
|
|
|
|
|
|
|
|
_vars[VAR_CHARINC] = _defaultTalkDelay / 20;
|
2002-07-05 17:00:18 +00:00
|
|
|
} else if (_lastKeyHit == 321) { // F7, display new GUI
|
|
|
|
_newgui->saveloadDialog();
|
2002-05-05 22:39:52 +00:00
|
|
|
}
|
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
_mouseButStat = _lastKeyHit;
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
int Scumm::getKeyInput(int a)
|
|
|
|
{
|
2001-10-09 14:30:12 +00:00
|
|
|
_mouseButStat = 0;
|
|
|
|
|
|
|
|
_lastKeyHit = checkKeyHit();
|
2002-04-11 17:19:16 +00:00
|
|
|
if (a == 0)
|
2001-10-09 14:30:12 +00:00
|
|
|
convertKeysToClicks();
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (mouse.x < 0)
|
|
|
|
mouse.x = 0;
|
2002-05-07 18:44:34 +00:00
|
|
|
if (mouse.x > _realWidth-1)
|
|
|
|
mouse.x = _realWidth-1;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (mouse.y < 0)
|
|
|
|
mouse.y = 0;
|
2002-05-07 18:44:34 +00:00
|
|
|
if (mouse.y > _realHeight-1)
|
|
|
|
mouse.y = _realHeight-1;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_leftBtnPressed & msClicked && _rightBtnPressed & msClicked) {
|
2001-10-09 14:30:12 +00:00
|
|
|
_mouseButStat = 0;
|
2001-10-16 10:01:48 +00:00
|
|
|
_lastKeyHit = _vars[VAR_CUTSCENEEXIT_KEY];
|
2002-04-11 17:19:16 +00:00
|
|
|
} else if (_leftBtnPressed & msClicked) {
|
2001-11-14 20:09:39 +00:00
|
|
|
_mouseButStat = MBS_LEFT_CLICK;
|
2002-04-11 17:19:16 +00:00
|
|
|
} else if (_rightBtnPressed & msClicked) {
|
2001-11-14 20:09:39 +00:00
|
|
|
_mouseButStat = MBS_RIGHT_CLICK;
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2001-12-27 17:51:58 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_features & GF_AFTER_V7) {
|
|
|
|
// _vars[VAR_LEFTBTN_DOWN] = (_leftBtnPressed&msClicked) != 0;
|
|
|
|
_vars[VAR_LEFTBTN_HOLD] = (_leftBtnPressed & msDown) != 0;
|
|
|
|
// _vars[VAR_RIGHTBTN_DOWN] = (_rightBtnPressed&msClicked) != 0;
|
|
|
|
_vars[VAR_RIGHTBTN_HOLD] = (_rightBtnPressed & msDown) != 0;
|
2002-03-06 00:18:22 +00:00
|
|
|
}
|
2001-12-27 17:51:58 +00:00
|
|
|
|
|
|
|
_leftBtnPressed &= ~msClicked;
|
|
|
|
_rightBtnPressed &= ~msClicked;
|
2001-10-09 14:30:12 +00:00
|
|
|
|
|
|
|
return _lastKeyHit;
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::convertKeysToClicks()
|
|
|
|
{
|
|
|
|
if (_lastKeyHit && _cursorState > 0) {
|
|
|
|
if (_lastKeyHit == 9) {
|
2001-11-14 20:09:39 +00:00
|
|
|
_mouseButStat = MBS_RIGHT_CLICK;
|
2002-04-11 17:19:16 +00:00
|
|
|
} else if (_lastKeyHit == 13) {
|
|
|
|
_mouseButStat = MBS_LEFT_CLICK;
|
2001-10-09 14:30:12 +00:00
|
|
|
} else
|
|
|
|
return;
|
|
|
|
_lastKeyHit = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-05-14 23:35:28 +00:00
|
|
|
Actor *Scumm::derefActor(int id)
|
|
|
|
{
|
2002-07-16 21:03:14 +00:00
|
|
|
return &_actors[id];
|
2002-05-14 23:35:28 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
Actor *Scumm::derefActorSafe(int id, const char *errmsg)
|
|
|
|
{
|
|
|
|
if (id < 1 || id >= NUM_ACTORS) {
|
2002-04-17 20:34:10 +00:00
|
|
|
if (_debugMode)
|
2002-04-17 20:23:45 +00:00
|
|
|
warning
|
|
|
|
("Invalid actor %d in %s (script %d, opcode 0x%x) - This is potentially a BIG problem.",
|
|
|
|
id, errmsg, vm.slot[_curExecScript].number, _opcode);
|
2002-04-11 17:19:16 +00:00
|
|
|
return NULL;
|
2002-03-05 09:58:12 +00:00
|
|
|
}
|
2001-10-09 14:30:12 +00:00
|
|
|
return derefActor(id);
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::makeCursorColorTransparent(int a)
|
|
|
|
{
|
|
|
|
int i, size;
|
2001-11-06 20:00:47 +00:00
|
|
|
|
|
|
|
size = _cursorWidth * _cursorHeight;
|
2001-10-16 10:01:48 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
for (i = 0; i < size; i++)
|
2001-11-06 20:00:47 +00:00
|
|
|
if (_grabbedCursor[i] == (byte)a)
|
|
|
|
_grabbedCursor[i] = 0xFF;
|
2002-04-12 21:26:59 +00:00
|
|
|
|
|
|
|
updateCursor();
|
2001-10-16 10:01:48 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::setStringVars(int slot)
|
|
|
|
{
|
2001-10-26 17:34:50 +00:00
|
|
|
StringTab *st = &string[slot];
|
|
|
|
st->xpos = st->t_xpos;
|
|
|
|
st->ypos = st->t_ypos;
|
|
|
|
st->center = st->t_center;
|
|
|
|
st->overhead = st->t_overhead;
|
2001-11-05 19:21:49 +00:00
|
|
|
st->no_talk_anim = st->t_no_talk_anim;
|
2001-10-26 17:34:50 +00:00
|
|
|
st->right = st->t_right;
|
|
|
|
st->color = st->t_color;
|
|
|
|
st->charset = st->t_charset;
|
2001-10-16 10:01:48 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::unkMiscOp9()
|
|
|
|
{
|
2001-10-16 10:01:48 +00:00
|
|
|
warning("stub unkMiscOp9()");
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::startManiac()
|
|
|
|
{
|
2001-10-16 10:01:48 +00:00
|
|
|
warning("stub startManiac()");
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void Scumm::destroy()
|
|
|
|
{
|
2001-11-05 19:21:49 +00:00
|
|
|
freeResources();
|
|
|
|
|
2001-11-26 19:57:57 +00:00
|
|
|
free(_objectStateTable);
|
|
|
|
free(_objectRoomTable);
|
|
|
|
free(_objectOwnerTable);
|
2001-11-05 19:21:49 +00:00
|
|
|
free(_inventory);
|
|
|
|
free(_arrays);
|
|
|
|
free(_verbs);
|
|
|
|
free(_objs);
|
|
|
|
free(_vars);
|
|
|
|
free(_bitVars);
|
|
|
|
free(_newNames);
|
|
|
|
free(_classData);
|
|
|
|
}
|
|
|
|
|
2002-07-22 18:11:48 +00:00
|
|
|
const int new_dir_table[4] = {
|
|
|
|
270,
|
|
|
|
90,
|
|
|
|
180,
|
|
|
|
0,
|
|
|
|
};
|
|
|
|
|
|
|
|
const int16 many_direction_tab[16] = {71, 109, 251, 289, -1, -1, -1, -1, 22, 72, 107, 157, 202, 252, 287, 337};
|
|
|
|
|
|
|
|
int newDirToOldDir(int dir)
|
2002-04-11 17:19:16 +00:00
|
|
|
{
|
|
|
|
if (dir >= 71 && dir <= 109)
|
2001-11-26 19:57:57 +00:00
|
|
|
return 1;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (dir >= 109 && dir <= 251)
|
2001-11-26 19:57:57 +00:00
|
|
|
return 2;
|
2002-04-11 17:19:16 +00:00
|
|
|
if (dir >= 251 && dir <= 289)
|
2001-11-26 19:57:57 +00:00
|
|
|
return 0;
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
|
2002-07-22 18:11:48 +00:00
|
|
|
int oldDirToNewDir(int dir)
|
2002-04-11 17:19:16 +00:00
|
|
|
{
|
2001-11-26 19:57:57 +00:00
|
|
|
return new_dir_table[dir];
|
|
|
|
}
|
|
|
|
|
2001-12-27 17:51:58 +00:00
|
|
|
|
2002-07-22 18:11:48 +00:00
|
|
|
int numSimpleDirDirections(int dirType)
|
2002-04-11 17:19:16 +00:00
|
|
|
{
|
2001-12-27 17:51:58 +00:00
|
|
|
return dirType ? 8 : 4;
|
|
|
|
}
|
|
|
|
|
2002-04-12 21:26:59 +00:00
|
|
|
|
2001-12-27 17:51:58 +00:00
|
|
|
/* Convert an angle to a simple direction */
|
2002-07-22 18:11:48 +00:00
|
|
|
int toSimpleDir(int dirType, int dir)
|
2002-04-11 17:19:16 +00:00
|
|
|
{
|
2002-07-02 20:56:17 +00:00
|
|
|
int num = dirType ? 8 : 4;
|
|
|
|
const int16 *dirtab = &many_direction_tab[dirType * 8];
|
|
|
|
for (int i = 1; i < num; i++, dirtab++) {
|
2001-12-27 17:51:58 +00:00
|
|
|
if (dir >= dirtab[0] && dir <= dirtab[1])
|
|
|
|
return i;
|
|
|
|
}
|
2001-11-26 19:57:57 +00:00
|
|
|
return 0;
|
2001-12-27 17:51:58 +00:00
|
|
|
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
|
2001-12-27 17:51:58 +00:00
|
|
|
/* Convert a simple direction to an angle */
|
2002-07-22 18:11:48 +00:00
|
|
|
int fromSimpleDir(int dirType, int dir)
|
2002-04-11 17:19:16 +00:00
|
|
|
{
|
|
|
|
if (!dirType)
|
2002-05-23 00:37:00 +00:00
|
|
|
return dir * 90;
|
|
|
|
else
|
|
|
|
return dir * 45;
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-22 18:11:48 +00:00
|
|
|
int normalizeAngle(int angle)
|
2002-04-11 17:19:16 +00:00
|
|
|
{
|
2002-05-22 12:24:48 +00:00
|
|
|
int temp;
|
|
|
|
|
|
|
|
temp = (angle + 360) % 360;
|
|
|
|
|
2002-07-02 20:56:17 +00:00
|
|
|
return toSimpleDir(1, temp) * 45;
|
2001-11-26 19:57:57 +00:00
|
|
|
}
|
2001-10-16 10:01:48 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void NORETURN CDECL error(const char *s, ...)
|
|
|
|
{
|
2001-10-09 14:30:12 +00:00
|
|
|
char buf[1024];
|
2002-07-20 08:00:42 +00:00
|
|
|
#if defined( USE_WINDBG ) || defined ( _WIN32_WCE )
|
2002-04-26 14:13:39 +00:00
|
|
|
char buf2[1024];
|
2002-07-20 08:00:42 +00:00
|
|
|
#if defined( _WIN32_WCE )
|
|
|
|
TCHAR buf2w[2048];
|
|
|
|
#endif
|
2002-04-26 14:13:39 +00:00
|
|
|
#endif
|
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
va_list va;
|
|
|
|
|
|
|
|
va_start(va, s);
|
|
|
|
vsprintf(buf, s, va);
|
|
|
|
va_end(va);
|
|
|
|
|
2002-04-12 21:26:59 +00:00
|
|
|
if (g_scumm && g_scumm->_currentScript != 0xFF) {
|
2002-04-12 10:34:46 +00:00
|
|
|
ScriptSlot *ss = &g_scumm->vm.slot[g_scumm->_currentScript];
|
2002-03-06 12:24:56 +00:00
|
|
|
fprintf(stderr, "Error(%d:%d:0x%X): %s!\n",
|
2002-04-12 10:34:46 +00:00
|
|
|
g_scumm->_roomResource,
|
2002-04-11 17:19:16 +00:00
|
|
|
ss->number,
|
2002-04-12 10:34:46 +00:00
|
|
|
g_scumm->_scriptPointer - g_scumm->_scriptOrgPointer, buf);
|
2002-07-20 08:00:42 +00:00
|
|
|
#if defined( USE_WINDBG ) || defined( _WIN32_WCE )
|
2002-04-26 14:13:39 +00:00
|
|
|
sprintf(buf2, "Error(%d:%d:0x%X): %s!\n",
|
|
|
|
g_scumm->_roomResource,
|
|
|
|
ss->number,
|
|
|
|
g_scumm->_scriptPointer - g_scumm->_scriptOrgPointer,
|
|
|
|
buf);
|
2002-07-20 08:00:42 +00:00
|
|
|
#if defined ( _WIN32_WCE )
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, buf2, strlen(buf2) + 1, buf2w, sizeof(buf2w));
|
|
|
|
GraphicsOff();
|
|
|
|
MessageBox(NULL, buf2w, TEXT("ScummVM error"), MB_OK);
|
|
|
|
#else
|
|
|
|
OutputDebugString(buf2);
|
|
|
|
#endif
|
2002-04-26 14:13:39 +00:00
|
|
|
#endif
|
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
} else {
|
2002-03-06 12:24:56 +00:00
|
|
|
fprintf(stderr, "Error: %s!\n", buf);
|
2002-07-20 08:00:42 +00:00
|
|
|
#if defined( USE_WINDBG ) || defined( _WIN32_WCE )
|
2002-04-26 14:13:39 +00:00
|
|
|
sprintf(&buf[strlen(buf)], "\n");
|
2002-07-20 08:00:42 +00:00
|
|
|
#if defined ( _WIN32_WCE )
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, buf, strlen(buf) + 1, buf2w, sizeof(buf2w));
|
|
|
|
GraphicsOff();
|
|
|
|
MessageBox(NULL, buf2w, TEXT("ScummVM error"), MB_OK);
|
|
|
|
#else
|
|
|
|
OutputDebugString(buf);
|
|
|
|
#endif
|
2002-04-26 14:13:39 +00:00
|
|
|
#endif
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
2002-03-06 12:24:56 +00:00
|
|
|
// Doesn't wait for any keypress!! Is it intended to?
|
2001-10-09 14:30:12 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void CDECL warning(const char *s, ...)
|
|
|
|
{
|
2001-10-09 14:30:12 +00:00
|
|
|
char buf[1024];
|
|
|
|
va_list va;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
|
|
|
va_start(va, s);
|
2001-10-09 14:30:12 +00:00
|
|
|
vsprintf(buf, s, va);
|
|
|
|
va_end(va);
|
|
|
|
|
|
|
|
fprintf(stderr, "WARNING: %s!\n", buf);
|
2002-04-26 14:13:39 +00:00
|
|
|
#if defined( USE_WINDBG )
|
|
|
|
sprintf(&buf[strlen(buf)], "\n");
|
|
|
|
OutputDebugString(buf);
|
|
|
|
#endif
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2002-04-26 14:13:39 +00:00
|
|
|
uint16 _debugLevel = 1;
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void CDECL debug(int level, const char *s, ...)
|
|
|
|
{
|
2001-10-09 14:30:12 +00:00
|
|
|
char buf[1024];
|
|
|
|
va_list va;
|
|
|
|
|
2002-04-26 14:13:39 +00:00
|
|
|
if (level > _debugLevel)
|
2001-10-09 14:30:12 +00:00
|
|
|
return;
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
va_start(va, s);
|
2001-10-09 14:30:12 +00:00
|
|
|
vsprintf(buf, s, va);
|
|
|
|
va_end(va);
|
|
|
|
printf("%s\n", buf);
|
2002-04-26 14:13:39 +00:00
|
|
|
|
|
|
|
#if defined( USE_WINDBG )
|
|
|
|
sprintf(&buf[strlen(buf)], "\n");
|
|
|
|
OutputDebugString(buf);
|
|
|
|
#endif
|
|
|
|
|
2001-10-09 14:30:12 +00:00
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
void checkHeap()
|
|
|
|
{
|
2001-10-16 12:20:22 +00:00
|
|
|
#if defined(WIN32)
|
2001-10-16 10:01:48 +00:00
|
|
|
if (_heapchk() != _HEAPOK) {
|
|
|
|
error("Heap is invalid!");
|
|
|
|
}
|
2001-10-16 12:20:22 +00:00
|
|
|
#endif
|
2001-10-09 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2002-04-19 11:05:46 +00:00
|
|
|
ScummDebugger g_debugger;
|
2002-04-12 21:26:59 +00:00
|
|
|
|
|
|
|
void Scumm::waitForTimer(int msec_delay) {
|
|
|
|
OSystem::Event event;
|
|
|
|
uint32 start_time;
|
|
|
|
|
|
|
|
if (_fastMode&2)
|
|
|
|
msec_delay = 0;
|
|
|
|
else if (_fastMode&1)
|
|
|
|
msec_delay = 10;
|
|
|
|
|
|
|
|
start_time = _system->get_msecs();
|
|
|
|
|
|
|
|
for(;;) {
|
|
|
|
while (_system->poll_event(&event)) {
|
2002-07-13 18:32:09 +00:00
|
|
|
|
2002-07-15 01:38:52 +00:00
|
|
|
// if newgui is running, copy event to EventList, and let the GUI handle it itself
|
|
|
|
// we might consider this approach for ScummLoop as well, and clean up the current mess
|
2002-07-18 20:26:35 +00:00
|
|
|
if (_newgui->isActive()) {
|
|
|
|
if (event.event_code == OSystem::EVENT_MOUSEMOVE) {
|
|
|
|
mouse.x = event.mouse.x;
|
|
|
|
mouse.y = event.mouse.y;
|
|
|
|
_system->set_mouse_pos(event.mouse.x, event.mouse.y);
|
|
|
|
_system->update_screen();
|
|
|
|
}
|
2002-07-15 01:38:52 +00:00
|
|
|
_newgui->handleEvent(event);
|
2002-07-18 20:26:35 +00:00
|
|
|
continue;
|
|
|
|
}
|
2002-07-15 01:38:52 +00:00
|
|
|
|
2002-04-12 21:26:59 +00:00
|
|
|
switch(event.event_code) {
|
|
|
|
case OSystem::EVENT_KEYDOWN:
|
2002-05-19 12:35:43 +00:00
|
|
|
if (event.kbd.keycode >= '0' && event.kbd.keycode<='9'
|
|
|
|
&& (event.kbd.flags == OSystem::KBD_SHIFT ||
|
|
|
|
event.kbd.flags == OSystem::KBD_CTRL)) {
|
|
|
|
_saveLoadSlot = event.kbd.keycode - '0';
|
|
|
|
sprintf(_saveLoadName, "Quicksave %d", _saveLoadSlot);
|
|
|
|
_saveLoadFlag = (event.kbd.flags == OSystem::KBD_SHIFT) ? 1 : 2;
|
|
|
|
_saveLoadCompatible = false;
|
2002-04-13 12:43:02 +00:00
|
|
|
} else if (event.kbd.flags==OSystem::KBD_CTRL) {
|
|
|
|
if (event.kbd.keycode=='f')
|
2002-04-12 21:26:59 +00:00
|
|
|
_fastMode ^= 1;
|
|
|
|
else if (event.kbd.keycode=='g')
|
|
|
|
_fastMode ^= 2;
|
2002-05-14 18:14:16 +00:00
|
|
|
else if ((event.kbd.keycode=='d') && (!_system->property(OSystem::PROP_GET_FULLSCREEN, 0)))
|
2002-04-19 11:05:46 +00:00
|
|
|
g_debugger.attach(this);
|
2002-04-12 21:26:59 +00:00
|
|
|
else if (event.kbd.keycode=='s')
|
|
|
|
resourceStats();
|
2002-07-18 20:26:35 +00:00
|
|
|
} else
|
2002-05-19 12:35:43 +00:00
|
|
|
_keyPressed = event.kbd.ascii; // Normal key press, pass on to the game.
|
2002-04-12 21:26:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case OSystem::EVENT_MOUSEMOVE:
|
|
|
|
mouse.x = event.mouse.x;
|
|
|
|
mouse.y = event.mouse.y;
|
|
|
|
_system->set_mouse_pos(event.mouse.x, event.mouse.y);
|
|
|
|
_system->update_screen();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OSystem::EVENT_LBUTTONDOWN:
|
|
|
|
_leftBtnPressed |= msClicked|msDown;
|
2002-04-21 21:56:41 +00:00
|
|
|
#ifdef _WIN32_WCE
|
|
|
|
mouse.x = event.mouse.x;
|
|
|
|
mouse.y = event.mouse.y;
|
|
|
|
#endif
|
2002-04-12 21:26:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case OSystem::EVENT_RBUTTONDOWN:
|
|
|
|
_rightBtnPressed |= msClicked|msDown;
|
2002-04-21 21:56:41 +00:00
|
|
|
#ifdef _WIN32_WCE
|
|
|
|
mouse.x = event.mouse.x;
|
|
|
|
mouse.y = event.mouse.y;
|
|
|
|
#endif
|
2002-04-12 21:26:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case OSystem::EVENT_LBUTTONUP:
|
|
|
|
_leftBtnPressed &= ~msDown;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OSystem::EVENT_RBUTTONUP:
|
|
|
|
_rightBtnPressed &= ~msDown;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-08-29 23:45:15 +00:00
|
|
|
_sound->updateCD(); // Loop CD Audio if needed
|
2002-04-12 21:26:59 +00:00
|
|
|
if (_system->get_msecs() >= start_time + msec_delay)
|
|
|
|
break;
|
|
|
|
_system->delay_msecs(10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Scumm::updatePalette() {
|
|
|
|
if (_palDirtyMax == -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int first = _palDirtyMin;
|
|
|
|
int num = _palDirtyMax - first + 1;
|
|
|
|
int i;
|
|
|
|
|
2002-07-28 01:40:24 +00:00
|
|
|
byte palette_colors[1024],*p = palette_colors;
|
|
|
|
|
2002-07-26 17:03:03 +00:00
|
|
|
// Sam & Max film noir mode
|
|
|
|
if (_gameId == GID_SAMNMAX && readVar(0x8000))
|
|
|
|
desaturatePalette();
|
2002-08-08 11:14:45 +00:00
|
|
|
|
|
|
|
for (i = _palDirtyMin; i <= _palDirtyMax; i++) {
|
|
|
|
byte *data;
|
|
|
|
|
|
|
|
if (_features & GF_SMALL_HEADER)
|
|
|
|
data = _currentPalette + _shadowPalette[i] * 3;
|
|
|
|
else
|
|
|
|
data = _currentPalette + i * 3;
|
|
|
|
|
|
|
|
*p++ = data[0];
|
|
|
|
*p++ = data[1];
|
|
|
|
*p++ = data[2];
|
|
|
|
*p++ = 0;
|
|
|
|
|
2002-04-12 21:26:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_system->set_palette(palette_colors, first, num);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2002-04-12 21:26:59 +00:00
|
|
|
_palDirtyMax = -1;
|
|
|
|
_palDirtyMin = 256;
|
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2002-04-12 21:26:59 +00:00
|
|
|
void Scumm::mainRun()
|
|
|
|
{
|
|
|
|
int delta = 0;
|
|
|
|
int last_time = _system->get_msecs();
|
|
|
|
int new_time;
|
|
|
|
|
|
|
|
for(;;) {
|
|
|
|
|
|
|
|
updatePalette();
|
|
|
|
|
|
|
|
_system->update_screen();
|
|
|
|
new_time = _system->get_msecs();
|
|
|
|
waitForTimer(delta * 15 + last_time - new_time);
|
|
|
|
last_time = _system->get_msecs();
|
2002-05-08 00:27:09 +00:00
|
|
|
if (_gui->isActive()) {
|
2002-04-15 17:16:10 +00:00
|
|
|
_gui->loop();
|
2002-04-12 21:26:59 +00:00
|
|
|
delta = 5;
|
2002-07-05 17:00:18 +00:00
|
|
|
} else if (_newgui->isActive()) {
|
|
|
|
_newgui->loop();
|
|
|
|
delta = 5;
|
2002-04-12 21:26:59 +00:00
|
|
|
} else {
|
|
|
|
delta = scummLoop(delta);
|
2002-05-08 09:09:39 +00:00
|
|
|
if (delta < 1) // Ensure we don't get into a loop
|
|
|
|
delta = 1; // by not decreasing sleepers.
|
2002-04-12 21:26:59 +00:00
|
|
|
}
|
|
|
|
}
|
2002-03-21 00:40:18 +00:00
|
|
|
}
|
2002-03-23 20:34:47 +00:00
|
|
|
|
|
|
|
void Scumm::launch()
|
|
|
|
{
|
|
|
|
charset._vm = this;
|
|
|
|
gdi._vm = this;
|
|
|
|
_fileHandle = NULL;
|
|
|
|
|
|
|
|
_maxHeapThreshold = 450000;
|
|
|
|
_minHeapThreshold = 400000;
|
|
|
|
|
2002-08-31 13:29:10 +00:00
|
|
|
// Create a primary virtual screen
|
2002-08-31 16:29:17 +00:00
|
|
|
_videoBuffer = (byte *)calloc((_realWidth + 8) * _realHeight, 1);
|
2002-04-11 17:19:16 +00:00
|
|
|
|
|
|
|
allocResTypeData(rtBuffer, MKID('NONE'), 10, "buffer", 0);
|
2002-08-31 16:29:17 +00:00
|
|
|
initVirtScreen(0, 0, 0, _realWidth, _realHeight, false, false);
|
2002-03-23 20:34:47 +00:00
|
|
|
|
|
|
|
if (_features & GF_AFTER_V7)
|
|
|
|
setupScummVarsNew();
|
|
|
|
else
|
|
|
|
setupScummVarsOld();
|
|
|
|
|
|
|
|
if ((_features & GF_AFTER_V7) || (_gameId == GID_SAMNMAX))
|
|
|
|
NUM_ACTORS = 30;
|
|
|
|
else
|
|
|
|
NUM_ACTORS = 13;
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (_features & GF_AFTER_V7)
|
2002-03-23 20:34:47 +00:00
|
|
|
OF_OWNER_ROOM = 0xFF;
|
|
|
|
else
|
|
|
|
OF_OWNER_ROOM = 0x0F;
|
2002-04-07 04:29:15 +00:00
|
|
|
|
2002-05-04 09:55:10 +00:00
|
|
|
// if (_gameId==GID_MONKEY2 && _bootParam == 0)
|
|
|
|
// _bootParam = 10001;
|
2002-04-11 17:19:16 +00:00
|
|
|
|
|
|
|
if (_gameId == GID_INDY4 && _bootParam == 0) {
|
2002-04-07 04:29:15 +00:00
|
|
|
_bootParam = -7873;
|
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2002-03-23 22:03:35 +00:00
|
|
|
readIndexFile();
|
2002-03-23 20:34:47 +00:00
|
|
|
|
|
|
|
initRandSeeds();
|
|
|
|
|
|
|
|
if (_features & GF_NEW_OPCODES)
|
|
|
|
setupOpcodes2();
|
|
|
|
else
|
|
|
|
setupOpcodes();
|
|
|
|
|
|
|
|
scummInit();
|
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
if (!(_features & GF_AFTER_V7))
|
2002-03-23 20:34:47 +00:00
|
|
|
_vars[VAR_VERSION] = 21;
|
|
|
|
|
|
|
|
_vars[VAR_DEBUGMODE] = _debugMode;
|
|
|
|
|
|
|
|
if (_gameId == GID_MONKEY)
|
|
|
|
_vars[74] = 1225;
|
|
|
|
|
2002-08-14 20:43:56 +00:00
|
|
|
_sound->setupSound();
|
2002-03-23 20:34:47 +00:00
|
|
|
|
2002-04-11 17:19:16 +00:00
|
|
|
runScript(1, 0, 0, &_bootParam);
|
2002-04-12 21:26:59 +00:00
|
|
|
}
|
2002-04-11 17:19:16 +00:00
|
|
|
|
2002-04-12 10:34:46 +00:00
|
|
|
void Scumm::go() {
|
|
|
|
launch();
|
|
|
|
setupGUIColors();
|
|
|
|
mainRun();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
byte Scumm::getDefaultGUIColor(int color)
|
|
|
|
{
|
|
|
|
/* FIXME: strange IF line? */
|
|
|
|
if ((_features & GF_AFTER_V7) || (_features & GF_SMALL_HEADER))
|
|
|
|
return 0;
|
|
|
|
if (_features & GF_AFTER_V6) {
|
|
|
|
if (color == 8)
|
|
|
|
color = 1;
|
|
|
|
return readArray(110, 0, color);
|
|
|
|
} else {
|
|
|
|
return getStringAddress(21)[color];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Scumm::setupGUIColors() {
|
|
|
|
|
|
|
|
/* FIXME: strange IF line? */
|
|
|
|
if (_gameId && !(_features & GF_SMALL_HEADER) && !(_features & GF_AFTER_V7)) {
|
2002-07-10 22:49:41 +00:00
|
|
|
_gui->_bgcolor = getDefaultGUIColor(0);
|
|
|
|
_gui->_color = getDefaultGUIColor(1);
|
|
|
|
_gui->_textcolor = getDefaultGUIColor(2);
|
|
|
|
_gui->_textcolorhi = getDefaultGUIColor(6);
|
|
|
|
_gui->_shadowcolor = getDefaultGUIColor(8);
|
2002-07-13 18:32:09 +00:00
|
|
|
|
|
|
|
_newgui->_bgcolor = _gui->_bgcolor;
|
|
|
|
_newgui->_color = _gui->_color;
|
|
|
|
_newgui->_textcolor = _gui->_textcolor;
|
|
|
|
_newgui->_textcolorhi = _gui->_textcolorhi;
|
|
|
|
_newgui->_shadowcolor = _gui->_shadowcolor;
|
2002-04-12 10:34:46 +00:00
|
|
|
}
|
|
|
|
}
|