aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm/scumm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/scumm/scumm.cpp')
-rw-r--r--engines/scumm/scumm.cpp104
1 files changed, 73 insertions, 31 deletions
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 0a5338374e..0f01e39459 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -71,6 +71,7 @@
#include "scumm/he/cup_player_he.h"
#include "scumm/util.h"
#include "scumm/verbs.h"
+#include "scumm/imuse/pcspk.h"
#include "backends/audiocd/audiocd.h"
@@ -114,17 +115,18 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
_rnd("scumm")
{
- if (_game.heversion > 0) {
- _gdi = new GdiHE(this);
- } else if (_game.platform == Common::kPlatformNES) {
- _gdi = new GdiNES(this);
#ifdef USE_RGB_COLOR
- } else if (_game.features & GF_16BIT_COLOR) {
+ if (_game.features & GF_16BIT_COLOR) {
if (_game.platform == Common::kPlatformPCEngine)
_gdi = new GdiPCEngine(this);
- else
- _gdi = new Gdi16Bit(this);
+ else if (_game.heversion > 0)
+ _gdi = new GdiHE16bit(this);
+ } else
#endif
+ if (_game.heversion > 0) {
+ _gdi = new GdiHE(this);
+ } else if (_game.platform == Common::kPlatformNES) {
+ _gdi = new GdiNES(this);
} else if (_game.version <= 1) {
_gdi = new GdiV1(this);
} else if (_game.version == 2) {
@@ -260,7 +262,7 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
_switchRoomEffect2 = 0;
_switchRoomEffect = 0;
- _bytesPerPixelOutput = _bytesPerPixel = 1;
+ _bytesPerPixel = 1;
_doEffect = false;
_snapScroll = false;
_currentLights = 0;
@@ -282,8 +284,9 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
_16BitPalette = NULL;
#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
_townsScreen = 0;
+#ifdef USE_RGB_COLOR
_cjkFont = 0;
- _cjkChar = 0;
+#endif
#endif
_shadowPalette = NULL;
_shadowPaletteSize = 0;
@@ -328,7 +331,7 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
memset(&_cyclRects, 0, 16 * sizeof(Common::Rect));
_numCyclRects = 0;
#endif
-
+
//
// Init all VARS to 0xFF
//
@@ -545,24 +548,25 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
_screenHeight = 200;
}
- _bytesPerPixelOutput = _bytesPerPixel = (_game.features & GF_16BIT_COLOR) ? 2 : 1;
+ _bytesPerPixel = (_game.features & GF_16BIT_COLOR) ? 2 : 1;
+ uint8 sizeMult = _bytesPerPixel;
#ifdef USE_RGB_COLOR
#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
if (_game.platform == Common::kPlatformFMTowns)
- _bytesPerPixelOutput = 2;
+ sizeMult = 2;
#endif
#endif
// Allocate gfx compositing buffer (not needed for V7/V8 games).
if (_game.version < 7)
- _compositeBuf = (byte *)malloc(_screenWidth * _screenHeight * _bytesPerPixelOutput);
+ _compositeBuf = (byte *)malloc(_screenWidth * _screenHeight * sizeMult);
else
_compositeBuf = 0;
_herculesBuf = 0;
if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) {
- _herculesBuf = (byte *)malloc(Common::kHercW * Common::kHercH);
+ _herculesBuf = (byte *)malloc(kHercWidth * kHercHeight);
}
// Add debug levels
@@ -589,7 +593,7 @@ ScummEngine::~ScummEngine() {
delete _actors[i];
delete[] _actors;
}
-
+
delete[] _sortedActors;
delete[] _2byteFontPtr;
@@ -631,8 +635,10 @@ ScummEngine::~ScummEngine() {
#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
delete _townsScreen;
+#ifdef USE_RGB_COLOR
delete _cjkFont;
#endif
+#endif
delete _debugger;
@@ -1138,7 +1144,7 @@ Common::Error ScummEngine::init() {
// Initialize backend
if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) {
- initGraphics(Common::kHercW, Common::kHercH, true);
+ initGraphics(kHercWidth, kHercHeight, true);
} else {
int screenWidth = _screenWidth;
int screenHeight = _screenHeight;
@@ -1148,16 +1154,37 @@ Common::Error ScummEngine::init() {
screenWidth *= _textSurfaceMultiplier;
screenHeight *= _textSurfaceMultiplier;
}
- if (_game.features & GF_16BIT_COLOR
+ if (_game.features & GF_16BIT_COLOR
#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
|| _game.platform == Common::kPlatformFMTowns
#endif
) {
#ifdef USE_RGB_COLOR
- Graphics::PixelFormat format = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);
- initGraphics(screenWidth, screenHeight, screenWidth > 320, &format);
- if (format != _system->getScreenFormat())
- return Common::kUnsupportedColorMode;
+ _outputPixelFormat = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);
+
+ if (_game.platform != Common::kPlatformFMTowns && _game.platform != Common::kPlatformPCEngine) {
+ initGraphics(screenWidth, screenHeight, screenWidth > 320, &_outputPixelFormat);
+ if (_outputPixelFormat != _system->getScreenFormat())
+ return Common::kUnsupportedColorMode;
+ } else {
+ Common::List<Graphics::PixelFormat> tryModes = _system->getSupportedFormats();
+ for (Common::List<Graphics::PixelFormat>::iterator g = tryModes.begin(); g != tryModes.end(); ++g) {
+ if (g->bytesPerPixel != 2 || g->aBits()) {
+ g = tryModes.erase(g);
+ g--;
+ }
+
+ if (*g == _outputPixelFormat) {
+ tryModes.clear();
+ tryModes.push_back(_outputPixelFormat);
+ break;
+ }
+ }
+
+ initGraphics(screenWidth, screenHeight, screenWidth > 320, tryModes);
+ if (_system->getScreenFormat().bytesPerPixel != 2)
+ return Common::kUnsupportedColorMode;
+ }
#else
if (_game.platform == Common::kPlatformFMTowns && _game.version == 3) {
warning("Starting game without the required 16bit color support.\nYou may experience color glitches");
@@ -1169,12 +1196,14 @@ Common::Error ScummEngine::init() {
} else {
#ifdef DISABLE_TOWNS_DUAL_LAYER_MODE
if (_game.platform == Common::kPlatformFMTowns && _game.version == 5)
- error("This game requires dual graphics layer support which is disabled in this build");
+ return Common::Error(Common::kUnsupportedColorMode, "This game requires dual graphics layer support which is disabled in this build");
#endif
initGraphics(screenWidth, screenHeight, (screenWidth > 320));
}
}
+ _outputPixelFormat = _system->getScreenFormat();
+
setupScumm();
readIndexFile();
@@ -1283,7 +1312,7 @@ void ScummEngine::setupScumm() {
_res->setHeapThreshold(400000, maxHeapThreshold);
free(_compositeBuf);
- _compositeBuf = (byte *)malloc(_screenWidth * _textSurfaceMultiplier * _screenHeight * _textSurfaceMultiplier * _bytesPerPixelOutput);
+ _compositeBuf = (byte *)malloc(_screenWidth * _textSurfaceMultiplier * _screenHeight * _textSurfaceMultiplier * _outputPixelFormat.bytesPerPixel);
}
#ifdef ENABLE_SCUMM_7_8
@@ -1325,13 +1354,23 @@ void ScummEngine::setupCharsetRenderer() {
_charset = new CharsetRendererPCE(this);
else
#endif
+ if (_game.platform == Common::kPlatformFMTowns)
+ _charset = new CharsetRendererTownsV3(this);
+ else
_charset = new CharsetRendererV3(this);
#ifdef ENABLE_SCUMM_7_8
} else if (_game.version == 8) {
_charset = new CharsetRendererNut(this);
#endif
} else {
- _charset = new CharsetRendererClassic(this);
+#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);
}
}
@@ -1364,8 +1403,7 @@ void ScummEngine::resetScumm() {
#ifdef USE_RGB_COLOR
if (_game.features & GF_16BIT_COLOR
#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
-
- || _game.platform == Common::kPlatformFMTowns
+ || (_game.platform == Common::kPlatformFMTowns)
#endif
)
_16BitPalette = (uint16 *)calloc(512, sizeof(uint16));
@@ -1374,8 +1412,8 @@ void ScummEngine::resetScumm() {
#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
if (_game.platform == Common::kPlatformFMTowns) {
delete _townsScreen;
- _townsScreen = new TownsScreen(_system, _screenWidth * _textSurfaceMultiplier, _screenHeight * _textSurfaceMultiplier, _bytesPerPixelOutput);
- _townsScreen->setupLayer(0, _screenWidth, _screenHeight, (_bytesPerPixelOutput == 2) ? 32767 : 256);
+ _townsScreen = new TownsScreen(_system, _screenWidth * _textSurfaceMultiplier, _screenHeight * _textSurfaceMultiplier, _outputPixelFormat);
+ _townsScreen->setupLayer(0, _screenWidth, _screenHeight, (_outputPixelFormat.bytesPerPixel == 2) ? 32767 : 256);
_townsScreen->setupLayer(1, _screenWidth * _textSurfaceMultiplier, _screenHeight * _textSurfaceMultiplier, 16, _textPalette);
}
#endif
@@ -1833,18 +1871,20 @@ void ScummEngine::setupMusic(int midi) {
MidiDriver *nativeMidiDriver = 0;
MidiDriver *adlibMidiDriver = 0;
- if (_musicType != MDT_ADLIB && _musicType != MDT_TOWNS)
+ if (_musicType != MDT_ADLIB && _musicType != MDT_TOWNS && _musicType != MDT_PCSPK)
nativeMidiDriver = MidiDriver::createMidi(dev);
if (nativeMidiDriver != NULL && _native_mt32)
nativeMidiDriver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE);
- bool multi_midi = ConfMan.getBool("multi_midi") && _musicType != MDT_NONE && (midi & MDT_ADLIB);
+ bool multi_midi = ConfMan.getBool("multi_midi") && _musicType != MDT_NONE && _musicType != MDT_PCSPK && (midi & MDT_ADLIB);
if (_musicType == MDT_ADLIB || _musicType == MDT_TOWNS || multi_midi) {
adlibMidiDriver = MidiDriver::createMidi(MidiDriver::detectDevice(_musicType == MDT_TOWNS ? MDT_TOWNS : MDT_ADLIB));
adlibMidiDriver->property(MidiDriver::PROP_OLD_ADLIB, (_game.features & GF_SMALL_HEADER) ? 1 : 0);
+ } else if (_musicType == MDT_PCSPK) {
+ adlibMidiDriver = new PcSpkDriver(_mixer);
}
_imuse = IMuse::create(_system, nativeMidiDriver, adlibMidiDriver);
-
+
if (_game.platform == Common::kPlatformFMTowns) {
_musicEngine = _townsPlayer = new Player_Towns_v2(this, _mixer, _imuse, true);
if (!_townsPlayer->init())
@@ -1869,6 +1909,8 @@ void ScummEngine::setupMusic(int midi) {
_imuse->property(IMuse::PROP_LIMIT_PLAYERS, 1);
_imuse->property(IMuse::PROP_RECYCLE_PLAYERS, 1);
}
+ if (_musicType == MDT_PCSPK)
+ _imuse->property(IMuse::PROP_PC_SPEAKER, 1);
}
}
}