diff options
Diffstat (limited to 'engines/tinsel')
55 files changed, 749 insertions, 683 deletions
diff --git a/engines/tinsel/actors.cpp b/engines/tinsel/actors.cpp index 7a1f9fbf55..9ec253e512 100644 --- a/engines/tinsel/actors.cpp +++ b/engines/tinsel/actors.cpp @@ -44,6 +44,7 @@ #include "tinsel/tinsel.h" #include "tinsel/token.h" +#include "common/textconsole.h" #include "common/util.h" namespace Tinsel { @@ -108,7 +109,7 @@ struct ACTORINFO { bool bEscOn; int escEvent; - COLORREF textColour; // Text colour + COLORREF textColor; // Text color SCNHANDLE playFilm; // revert to this after talks SCNHANDLE talkFilm; // this be deleted in the future! @@ -140,7 +141,7 @@ typedef TAGACTOR *PTAGACTOR; static ACTORINFO *actorInfo = NULL; -static COLORREF defaultColour = 0; // Text colour +static COLORREF defaultColor = 0; // Text color static bool bActorsOn = false; @@ -479,13 +480,13 @@ void DropActors() { for (int i = 0; i < NumActors; i++) { if (TinselV2) { - // Save text colour - COLORREF tColour = actorInfo[i].textColour; + // Save text color + COLORREF tColor = actorInfo[i].textColor; memset(&actorInfo[i], 0, sizeof(ACTORINFO)); - // Restor text colour - actorInfo[i].textColour = tColour; + // Restor text color + actorInfo[i].textColor = tColor; // Clear extra arrays memset(zFactors, 0, NumActors); @@ -1278,7 +1279,7 @@ void SetMoverZ(PMOVER pMover, int y, int32 zFactor) { /** * Stores actor's attributes. - * Currently only the speech colours. + * Currently only the speech colors. */ void storeActorAttr(int ano, int r1, int g1, int b1) { assert((ano > 0 && ano <= NumActors) || ano == -1); // illegal actor number @@ -1288,36 +1289,36 @@ void storeActorAttr(int ano, int r1, int g1, int b1) { if (b1 > MAX_INTENSITY) b1 = MAX_INTENSITY; // } if (ano == -1) - defaultColour = TINSEL_RGB(r1, g1, b1); + defaultColor = TINSEL_RGB(r1, g1, b1); else - actorInfo[ano - 1].textColour = TINSEL_RGB(r1, g1, b1); + actorInfo[ano - 1].textColor = TINSEL_RGB(r1, g1, b1); } /** - * Called from ActorRGB() - Stores actor's speech colour. + * Called from ActorRGB() - Stores actor's speech color. */ -void SetActorRGB(int ano, COLORREF colour) { +void SetActorRGB(int ano, COLORREF color) { assert(ano >= 0 && ano <= NumActors); if (ano) - actorInfo[ano - 1].textColour = TO_LE_32(colour); + actorInfo[ano - 1].textColor = TO_LE_32(color); else - defaultColour = TO_LE_32(colour); + defaultColor = TO_LE_32(color); } /** - * Get the actor's stored speech colour. + * Get the actor's stored speech color. * @param ano Actor Id */ COLORREF GetActorRGB(int ano) { // Not used in JAPAN version assert((ano >= -1) && (ano <= NumActors)); // illegal actor number - if ((ano == -1) || !actorInfo[ano - 1].textColour) - return defaultColour; + if ((ano == -1) || !actorInfo[ano - 1].textColor) + return defaultColor; else - return actorInfo[ano - 1].textColour; + return actorInfo[ano - 1].textColor; } /** diff --git a/engines/tinsel/actors.h b/engines/tinsel/actors.h index fbad5d9955..2be42b00e6 100644 --- a/engines/tinsel/actors.h +++ b/engines/tinsel/actors.h @@ -109,7 +109,7 @@ void ActorEvent(int ano, TINSEL_EVENT event, PLR_EVENT be); void storeActorAttr(int ano, int r1, int g1, int b1); COLORREF GetActorRGB(int ano); -void SetActorRGB(int ano, COLORREF colour); +void SetActorRGB(int ano, COLORREF color); void SetActorZfactor(int ano, uint32 zFactor); uint32 GetActorZfactor(int ano); diff --git a/engines/tinsel/adpcm.cpp b/engines/tinsel/adpcm.cpp new file mode 100644 index 0000000000..530395d754 --- /dev/null +++ b/engines/tinsel/adpcm.cpp @@ -0,0 +1,171 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "common/stream.h" +#include "common/util.h" + +#include "tinsel/adpcm.h" + +namespace Tinsel { + +static const double TinselFilterTable[4][2] = { + {0, 0 }, + {0.9375, 0}, + {1.796875, -0.8125}, + {1.53125, -0.859375} +}; + +void Tinsel_ADPCMStream::readBufferTinselHeader() { + uint8 start = _stream->readByte(); + uint8 filterVal = (start & 0xC0) >> 6; + + if ((start & 0x20) != 0) { + //Lower 6 bit are negative + + // Negate + start = ~(start | 0xC0) + 1; + + _status.predictor = (unsigned long long int)1 << start; + } else { + // Lower 6 bit are positive + + // Truncate + start &= 0x1F; + + _status.predictor = ((double) 1.0) / ((unsigned long long int)1 << start); + } + + _status.K0 = TinselFilterTable[filterVal][0]; + _status.K1 = TinselFilterTable[filterVal][1]; +} + +int16 Tinsel_ADPCMStream::decodeTinsel(int16 code, double eVal) { + double sample; + + sample = (double) code; + sample *= eVal * _status.predictor; + sample += (_status.d0 * _status.K0) + (_status.d1 * _status.K1); + + _status.d1 = _status.d0; + _status.d0 = sample; + + return (int16) CLIP<double>(sample, -32768.0, 32767.0); +} + +int Tinsel4_ADPCMStream::readBuffer(int16 *buffer, const int numSamples) { + int samples; + uint16 data; + const double eVal = 1.142822265; + + samples = 0; + + assert(numSamples % 2 == 0); + + while (samples < numSamples && !_stream->eos() && _stream->pos() < _endpos) { + if (_blockPos[0] == _blockAlign) { + readBufferTinselHeader(); + _blockPos[0] = 0; + } + + for (; samples < numSamples && _blockPos[0] < _blockAlign && !_stream->eos() && _stream->pos() < _endpos; samples += 2, _blockPos[0]++) { + // Read 1 byte = 8 bits = two 4 bit blocks + data = _stream->readByte(); + buffer[samples] = decodeTinsel((data << 8) & 0xF000, eVal); + buffer[samples+1] = decodeTinsel((data << 12) & 0xF000, eVal); + } + } + + return samples; +} + +int Tinsel6_ADPCMStream::readBuffer(int16 *buffer, const int numSamples) { + int samples; + const double eVal = 1.032226562; + + samples = 0; + + while (samples < numSamples && !_stream->eos() && _stream->pos() < _endpos) { + if (_blockPos[0] == _blockAlign) { + readBufferTinselHeader(); + _blockPos[0] = 0; + _chunkPos = 0; + } + + for (; samples < numSamples && _blockPos[0] < _blockAlign && !_stream->eos() && _stream->pos() < _endpos; samples++, _chunkPos = (_chunkPos + 1) % 4) { + + switch (_chunkPos) { + case 0: + _chunkData = _stream->readByte(); + buffer[samples] = decodeTinsel((_chunkData << 8) & 0xFC00, eVal); + break; + case 1: + _chunkData = (_chunkData << 8) | (_stream->readByte()); + buffer[samples] = decodeTinsel((_chunkData << 6) & 0xFC00, eVal); + _blockPos[0]++; + break; + case 2: + _chunkData = (_chunkData << 8) | (_stream->readByte()); + buffer[samples] = decodeTinsel((_chunkData << 4) & 0xFC00, eVal); + _blockPos[0]++; + break; + case 3: + _chunkData = (_chunkData << 8); + buffer[samples] = decodeTinsel((_chunkData << 2) & 0xFC00, eVal); + _blockPos[0]++; + break; + } + + } + + } + + return samples; +} + +int Tinsel8_ADPCMStream::readBuffer(int16 *buffer, const int numSamples) { + int samples; + byte data; + const double eVal = 1.007843258; + + samples = 0; + + while (samples < numSamples && !_stream->eos() && _stream->pos() < _endpos) { + if (_blockPos[0] == _blockAlign) { + readBufferTinselHeader(); + _blockPos[0] = 0; + } + + for (; samples < numSamples && _blockPos[0] < _blockAlign && !_stream->eos() && _stream->pos() < _endpos; samples++, _blockPos[0]++) { + // Read 1 byte = 8 bits = one 8 bit block + data = _stream->readByte(); + buffer[samples] = decodeTinsel(data << 8, eVal); + } + } + + return samples; +} + + +} // End of namespace Tinsel diff --git a/engines/tinsel/adpcm.h b/engines/tinsel/adpcm.h new file mode 100644 index 0000000000..79d537eef6 --- /dev/null +++ b/engines/tinsel/adpcm.h @@ -0,0 +1,105 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef TINSEL_ADPCM_H +#define TINSEL_ADPCM_H + +#include "audio/decoders/adpcm_intern.h" + +namespace Tinsel { + +class Tinsel_ADPCMStream : public Audio::ADPCMStream { +protected: + struct { + // Tinsel + double predictor; + double K0, K1; + double d0, d1; + } _status; + + void reset() { + ADPCMStream::reset(); + memset(&_status, 0, sizeof(_status)); + } + + int16 decodeTinsel(int16, double); + void readBufferTinselHeader(); + +public: + Tinsel_ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, uint32 size, int rate, int channels, uint32 blockAlign) + : ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) { + + if (blockAlign == 0) + error("Tinsel_ADPCMStream(): blockAlign isn't specified"); + + if (channels != 1) + error("Tinsel_ADPCMStream(): Tinsel ADPCM only supports mono"); + + memset(&_status, 0, sizeof(_status)); + } + +}; + +class Tinsel4_ADPCMStream : public Tinsel_ADPCMStream { +public: + Tinsel4_ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, uint32 size, int rate, int channels, uint32 blockAlign) + : Tinsel_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) {} + + virtual int readBuffer(int16 *buffer, const int numSamples); +}; + +class Tinsel6_ADPCMStream : public Tinsel_ADPCMStream { +protected: + uint8 _chunkPos; + uint16 _chunkData; + + void reset() { + ADPCMStream::reset(); + _chunkPos = 0; + _chunkData = 0; + } + +public: + Tinsel6_ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, uint32 size, int rate, int channels, uint32 blockAlign) + : Tinsel_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) { + _chunkPos = 0; + _chunkData = 0; + } + + virtual int readBuffer(int16 *buffer, const int numSamples); +}; + +class Tinsel8_ADPCMStream : public Tinsel_ADPCMStream { +public: + Tinsel8_ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, uint32 size, int rate, int channels, uint32 blockAlign) + : Tinsel_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) {} + + virtual int readBuffer(int16 *buffer, const int numSamples); +}; + + +} // End of namespace Tinsel + +#endif diff --git a/engines/tinsel/anim.cpp b/engines/tinsel/anim.cpp index 37d8de925e..61c8b67624 100644 --- a/engines/tinsel/anim.cpp +++ b/engines/tinsel/anim.cpp @@ -31,6 +31,7 @@ #include "tinsel/sched.h" #include "tinsel/tinsel.h" +#include "common/textconsole.h" #include "common/util.h" namespace Tinsel { diff --git a/engines/tinsel/background.cpp b/engines/tinsel/background.cpp index 560216aadb..dfff093c09 100644 --- a/engines/tinsel/background.cpp +++ b/engines/tinsel/background.cpp @@ -39,9 +39,6 @@ namespace Tinsel { // current background const BACKGND *pCurBgnd = NULL; -// FIXME: Not yet used -static bool bEntireRedraw; - /** * Called to initialise a background. * @param pBgnd Pointer to data struct for current background @@ -54,8 +51,8 @@ void InitBackground(const BACKGND *pBgnd) { // set current background pCurBgnd = pBgnd; - // init background sky colour - SetBgndColour(pBgnd->rgbSkyColour); + // init background sky color + SetBgndColor(pBgnd->rgbSkyColor); // start of playfield array pPlayfield = pBgnd->fieldArray; @@ -130,11 +127,11 @@ void PlayfieldGetPos(int which, int *pXpos, int *pYpos) { } /** - * Returns the x position of the centre of the specified playfield + * Returns the x position of the center of the specified playfield * @param which Which playfield */ -int PlayfieldGetCentreX(int which) { +int PlayfieldGetCenterX(int which) { PLAYFIELD *pPlayfield; // pointer to relavent playfield // make sure there is a background @@ -257,9 +254,4 @@ void DrawBackgnd() { ResetClipRect(); } -void ForceEntireRedraw() { - bEntireRedraw = true; -} - - } // End of namespace Tinsel diff --git a/engines/tinsel/background.h b/engines/tinsel/background.h index 81b490488e..06789e50bf 100644 --- a/engines/tinsel/background.h +++ b/engines/tinsel/background.h @@ -60,7 +60,7 @@ struct PLAYFIELD { /** multi-playfield background structure - a backgnd is a container of playfields */ struct BACKGND { - COLORREF rgbSkyColour; ///< background sky colour + COLORREF rgbSkyColor; ///< background sky color Common::Point ptInitWorld; ///< initial world position Common::Rect rcScrollLimits; ///< scroll limits int refreshRate; ///< background update process refresh rate @@ -93,7 +93,7 @@ void PlayfieldGetPos( // Returns the xy position of the specified playfield in int *pXpos, // returns current x position int *pYpos); // returns current y position -int PlayfieldGetCentreX( // Returns the xy position of the specified playfield in the current background +int PlayfieldGetCenterX( // Returns the xy position of the specified playfield in the current background int which); // which playfield OBJECT *GetPlayfieldList( // Returns the display list for the specified playfield @@ -110,8 +110,6 @@ OBJECT *GetBgObject(); SCNHANDLE BgPal(); -void ForceEntireRedraw(); - int BgWidth(); int BgHeight(); diff --git a/engines/tinsel/bg.cpp b/engines/tinsel/bg.cpp index 68653b16f4..0e67c3a06e 100644 --- a/engines/tinsel/bg.cpp +++ b/engines/tinsel/bg.cpp @@ -40,6 +40,7 @@ #include "tinsel/tinlib.h" // For Control() #include "tinsel/tinsel.h" +#include "common/textconsole.h" #include "common/util.h" namespace Tinsel { @@ -158,7 +159,7 @@ static void BGmainProcess(CORO_PARAM, const void *param) { FadeInFast(NULL); bDoFadeIn = false; } else if (TinselV2) - PokeInTagColour(); + PokeInTagColor(); for (;;) { for (int i = 0; i < bgReels; i++) { diff --git a/engines/tinsel/bmv.cpp b/engines/tinsel/bmv.cpp index 3f56288aca..793febdc21 100644 --- a/engines/tinsel/bmv.cpp +++ b/engines/tinsel/bmv.cpp @@ -44,6 +44,8 @@ #include "audio/decoders/raw.h" +#include "common/textconsole.h" + namespace Tinsel { //----------------- LOCAL DEFINES ---------------------------- @@ -81,7 +83,7 @@ namespace Tinsel { #define BIT0 0x01 #define CD_XSCR 0x04 // Screen has a scroll offset -#define CD_CMAP 0x08 // Colour map is included +#define CD_CMAP 0x08 // Color map is included #define CD_CMND 0x10 // Command is included #define CD_AUDIO 0x20 // Audio data is included #define CD_EXTEND 0x40 // Extended modes "A"-"z" @@ -350,7 +352,7 @@ BMVPlayer::BMVPlayer() { memset(texts, 0, sizeof(texts)); - talkColour = 0; + talkColor = 0; bigProblemCount = 0; bIsText = 0; movieTick = 0; @@ -382,8 +384,8 @@ void BMVPlayer::MoviePalette(int paletteOffset) { UpdateDACqueue(1, 255, &moviePal[1]); // Don't clobber talk - if (talkColour != 0) - SetTextPal(talkColour); + if (talkColor != 0) + SetTextPal(talkColor); } void BMVPlayer::InitialiseMovieSound() { @@ -490,7 +492,7 @@ void BMVPlayer::BmvDrawText(bool bDraw) { |-------------------------------------------------------| \*-----------------------------------------------------*/ -void BMVPlayer::MovieText(CORO_PARAM, int stringId, int x, int y, int fontId, COLORREF *pTalkColour, int duration) { +void BMVPlayer::MovieText(CORO_PARAM, int stringId, int x, int y, int fontId, COLORREF *pTalkColor, int duration) { SCNHANDLE hFont; int index; @@ -502,8 +504,8 @@ void BMVPlayer::MovieText(CORO_PARAM, int stringId, int x, int y, int fontId, CO } else { // It's a 'talk' - if (pTalkColour != NULL) - SetTextPal(*pTalkColour); + if (pTalkColor != NULL) + SetTextPal(*pTalkColor); hFont = GetTalkFontHandle(); index = 1; } @@ -519,7 +521,7 @@ void BMVPlayer::MovieText(CORO_PARAM, int stringId, int x, int y, int fontId, CO 0, x, y, hFont, - TXT_CENTRE, 0); + TXT_CENTER, 0); KeepOnScreen(texts[index].pText, &x, &y); } @@ -541,13 +543,13 @@ int BMVPlayer::MovieCommand(char cmd, int commandOffset) { } else { if (_vm->_config->_useSubtitles) { TALK_CMD *pCmd = (TALK_CMD *)(bigBuffer + commandOffset); - talkColour = TINSEL_RGB(pCmd->r, pCmd->g, pCmd->b); + talkColor = TINSEL_RGB(pCmd->r, pCmd->g, pCmd->b); MovieText(nullContext, (int16)READ_LE_UINT16(&pCmd->stringId), (int16)READ_LE_UINT16(&pCmd->x), (int16)READ_LE_UINT16(&pCmd->y), 0, - &talkColour, + &talkColor, pCmd->duration); } return sz_CMD_TALK_pkt; @@ -693,7 +695,7 @@ void BMVPlayer::InitialiseBMV() { bFileEnd = false; blobsInBuffer = 0; memset(texts, 0, sizeof(texts)); - talkColour = 0; + talkColor = 0; bigProblemCount = 0; movieTick = 0; @@ -1025,7 +1027,6 @@ bool BMVPlayer::DoSoundFrame() { void BMVPlayer::CopyMovieToScreen() { // Not if not up and running yet! if (!screenBuffer || (currentFrame == 0)) { - ForceEntireRedraw(); DrawBackgnd(); return; } @@ -1046,21 +1047,6 @@ void BMVPlayer::CopyMovieToScreen() { } /** - * LookAtBuffers - */ -void BMVPlayer::LookAtBuffers() { - // FIXME: What's the point of this function??? - // Maybe to ensure the relevant data is loaded into cache by the CPU? - static int junk; // FIXME: Avoid non-const global vars - int i; - - if (bigBuffer) { - for (i = 0; i < NUM_SLOTS; i++) - junk += bigBuffer[i*SLOT_SIZE]; - } -} - -/** * Handles playback of any active movie. Called from the foreground 24 times a second. */ void BMVPlayer::FettleBMV() { @@ -1078,8 +1064,6 @@ void BMVPlayer::FettleBMV() { return; } - LookAtBuffers(); - if (!stream.isOpen()) { int i; diff --git a/engines/tinsel/bmv.h b/engines/tinsel/bmv.h index 2644504cab..d90d68fc13 100644 --- a/engines/tinsel/bmv.h +++ b/engines/tinsel/bmv.h @@ -96,7 +96,7 @@ class BMVPlayer { int dieFrame; } texts[2]; - COLORREF talkColour; + COLORREF talkColor; int bigProblemCount; @@ -143,7 +143,7 @@ private: void MovieAudio(int audioOffset, int blobs); void FettleMovieText(); void BmvDrawText(bool bDraw); - void MovieText(CORO_PARAM, int stringId, int x, int y, int fontId, COLORREF *pTalkColour, int duration); + void MovieText(CORO_PARAM, int stringId, int x, int y, int fontId, COLORREF *pTalkColor, int duration); int MovieCommand(char cmd, int commandOffset); int FollowingPacket(int thisPacket, bool bReallyImportant); void LoadSlots(int number); @@ -151,7 +151,6 @@ private: bool MaintainBuffer(); bool DoBMVFrame(); bool DoSoundFrame(); - void LookAtBuffers(); }; diff --git a/engines/tinsel/detection.cpp b/engines/tinsel/detection.cpp index 22e8806e7e..70bf398baf 100644 --- a/engines/tinsel/detection.cpp +++ b/engines/tinsel/detection.cpp @@ -280,11 +280,9 @@ const ADGameDescription *TinselMetaEngine::fallbackDetect(const Common::FSList & ADGameDescList matched; int maxFilesMatched = 0; - bool gotAnyMatchesWithAllFiles = false; // MD5 based matching - uint i; - for (i = 0, g = &Tinsel::gameDescriptions[0]; g->desc.gameid != 0; ++g) { + for (g = &Tinsel::gameDescriptions[0]; g->desc.gameid != 0; ++g) { if (strcmp(g->desc.gameid, "dw2") != 0) continue; @@ -327,9 +325,6 @@ const ADGameDescription *TinselMetaEngine::fallbackDetect(const Common::FSList & } } - if (allFilesPresent) - gotAnyMatchesWithAllFiles = true; - if (!fileMissing) { // Count the number of matching files. Then, only keep those // entries which match a maximal amount of files. diff --git a/engines/tinsel/dialogs.cpp b/engines/tinsel/dialogs.cpp index 73cad7a68f..281dd2da55 100644 --- a/engines/tinsel/dialogs.cpp +++ b/engines/tinsel/dialogs.cpp @@ -62,6 +62,8 @@ #include "tinsel/tinsel.h" // For engine access #include "tinsel/token.h" +#include "common/textconsole.h" + namespace Tinsel { //----------------- EXTERNAL GLOBAL DATA -------------------- @@ -259,7 +261,7 @@ enum PARTS_INDEX { #define MD_XLBUTR (TinselV2 ? 26 : 10) #define MD_XRBUTL (TinselV2 ? 173 : 105) #define MD_XRBUTR (TinselV2 ? 195 : 114) -#define ROTX1 60 // Rotate button's offsets from the centre +#define ROTX1 60 // Rotate button's offsets from the center // Number of objects that makes up an empty window #define MAX_WCOMP 21 // 4 corners + (3+3) sides + (2+2) extra sides @@ -449,7 +451,7 @@ static bool bMoveOnUnHide; // Set before start of conversation //----- Data pertinant to configure (incl. load/save game) ----- -#define COL_MAINBOX TBLUE1 // Base blue colour +#define COL_MAINBOX TBLUE1 // Base blue color #define COL_BOX TBLUE1 #define COL_HILIGHT TBLUE4 @@ -1639,7 +1641,7 @@ static void Select(int i, bool force) { switch (cd.box[i].boxType) { case RGROUP: iconArray[HL2] = RectangleObject(BgPal(), - (TinselV2 ? HighlightColour() : COL_HILIGHT), cd.box[i].w, cd.box[i].h); + (TinselV2 ? HighlightColor() : COL_HILIGHT), cd.box[i].w, cd.box[i].h); MultiInsertObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL2]); MultiSetAniXY(iconArray[HL2], InvD[ino].inventoryX + cd.box[i].xpos, @@ -2239,7 +2241,7 @@ static int WhichMenuBox(int curX, int curY, bool bSlides) { /***/ /**************************************************************************/ -#define ROTX1 60 // Rotate button's offsets from the centre +#define ROTX1 60 // Rotate button's offsets from the center /** * InvBoxes @@ -2277,7 +2279,7 @@ static void InvBoxes(bool InBody, int curX, int curY) { cd.box[cd.pointBox].boxType == AATBUT || cd.box[cd.pointBox].boxType == AABUT) { iconArray[HL1] = RectangleObject(BgPal(), - (TinselV2 ? HighlightColour() : COL_HILIGHT), + (TinselV2 ? HighlightColor() : COL_HILIGHT), cd.box[cd.pointBox].w, cd.box[cd.pointBox].h); MultiInsertObject(GetPlayfieldList(FIELD_STATUS), iconArray[HL1]); MultiSetAniXY(iconArray[HL1], @@ -2638,14 +2640,14 @@ static void AddBackground(OBJECT **rect, OBJECT **title, int extraH, int extraV, LoadStringRes(InvD[ino].hInvTitle, TextBufferAddr(), TBUFSZ); *title = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0, InvD[ino].inventoryX + width/2, InvD[ino].inventoryY + M_TOFF, - GetTagFontHandle(), TXT_CENTRE); + GetTagFontHandle(), TXT_CENTER); assert(*title); // Inventory title string produced NULL text MultiSetZPosition(*title, Z_INV_HTEXT); } else if (textFrom == FROM_STRING && cd.ixHeading != NO_HEADING) { LoadStringRes(configStrings[cd.ixHeading], TextBufferAddr(), TBUFSZ); *title = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0, InvD[ino].inventoryX + width/2, InvD[ino].inventoryY + M_TOFF, - GetTagFontHandle(), TXT_CENTRE); + GetTagFontHandle(), TXT_CENTER); assert(*title); // Inventory title string produced NULL text MultiSetZPosition(*title, Z_INV_HTEXT); } @@ -2669,7 +2671,7 @@ static void AddTitle(POBJECT *title, int extraH) { LoadStringRes(InvD[ino].hInvTitle, TextBufferAddr(), TBUFSZ); *title = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0, InvD[ino].inventoryX + (width/2)+NM_BG_POS_X, InvD[ino].inventoryY + NM_TOFF, - GetTagFontHandle(), TXT_CENTRE, 0); + GetTagFontHandle(), TXT_CENTER, 0); assert(*title); MultiSetZPosition(*title, Z_INV_HTEXT); } @@ -2736,7 +2738,7 @@ static void AddBox(int *pi, const int i) { break; // Give us a box - iconArray[*pi] = RectangleObject(BgPal(), TinselV2 ? BoxColour() : COL_BOX, + iconArray[*pi] = RectangleObject(BgPal(), TinselV2 ? BoxColor() : COL_BOX, cd.box[i].w, cd.box[i].h); MultiInsertObject(GetPlayfieldList(FIELD_STATUS), iconArray[*pi]); MultiSetAniXY(iconArray[*pi], x, y); @@ -2758,9 +2760,9 @@ static void AddBox(int *pi, const int i) { iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), cd.box[i].boxText, 0, #ifdef JAPAN // Note: it never seems to go here! - x + cd.box[i].w/2, y+2, GetTagFontHandle(), TXT_CENTRE); + x + cd.box[i].w/2, y+2, GetTagFontHandle(), TXT_CENTER); #else - x + cd.box[i].w / 2, y + TYOFF, GetTagFontHandle(), TXT_CENTRE); + x + cd.box[i].w / 2, y + TYOFF, GetTagFontHandle(), TXT_CENTER); #endif } @@ -2787,9 +2789,9 @@ static void AddBox(int *pi, const int i) { iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0, #ifdef JAPAN - x + cd.box[i].w/2, y+2, GetTagFontHandle(), TXT_CENTRE); + x + cd.box[i].w/2, y+2, GetTagFontHandle(), TXT_CENTER); #else - x + cd.box[i].w / 2, y + TYOFF, GetTagFontHandle(), TXT_CENTRE); + x + cd.box[i].w / 2, y + TYOFF, GetTagFontHandle(), TXT_CENTER); #endif MultiSetZPosition(iconArray[*pi], Z_INV_ITEXT); *pi += 1; @@ -2870,7 +2872,7 @@ static void AddBox(int *pi, const int i) { if (cd.box[i].boxType == TOGGLE2) { iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0, x + cd.box[i].w / 2, y + TOG2_YOFF, - GetTagFontHandle(), TXT_CENTRE, 0); + GetTagFontHandle(), TXT_CENTER, 0); } else { iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0, x + MDTEXT_XOFF, y + MDTEXT_YOFF, @@ -2934,7 +2936,7 @@ static void AddBox(int *pi, const int i) { LoadStringRes(SysString(cd.box[i].ixText), TextBufferAddr(), TBUFSZ); iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0, x + cd.box[i].w / 2, y + TOG2_YOFF, - GetTagFontHandle(), TXT_CENTRE, 0); + GetTagFontHandle(), TXT_CENTER, 0); MultiSetZPosition(iconArray[*pi], Z_INV_ITEXT); *pi += 1; } @@ -2945,7 +2947,7 @@ static void AddBox(int *pi, const int i) { LoadStringRes(LanguageDesc(displayedLanguage), TextBufferAddr(), TBUFSZ); iconArray[*pi] = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0, - x + cd.box[i].w / 2, y + ROT_YOFF, GetTagFontHandle(), TXT_CENTRE, 0); + x + cd.box[i].w / 2, y + ROT_YOFF, GetTagFontHandle(), TXT_CENTER, 0); MultiSetZPosition(iconArray[*pi], Z_INV_ITEXT); *pi += 1; @@ -3683,15 +3685,15 @@ extern void HideConversation(bool bHide) { /* * First time, position it appropriately */ - int left, centre; + int left, center; int x, y, deltay; // Only do it once per conversation bMoveOnUnHide = false; - // Current centre of the window + // Current center of the window left = MultiLeftmost(RectObject); - centre = (MultiRightmost(RectObject) + left) / 2; + center = (MultiRightmost(RectObject) + left) / 2; // Get the x-offset for the conversation window if (thisConvActor) { @@ -3731,12 +3733,12 @@ extern void HideConversation(bool bHide) { // Move it all for (i = 0; objArray[i] && i < MAX_WCOMP; i++) { - MultiMoveRelXY(objArray[i], x - centre, deltay); + MultiMoveRelXY(objArray[i], x - center, deltay); } for (i = 0; iconArray[i] && i < MAX_ICONS; i++) { - MultiMoveRelXY(iconArray[i], x - centre, deltay); + MultiMoveRelXY(iconArray[i], x - center, deltay); } - InvD[INV_CONV].inventoryX += x - centre; + InvD[INV_CONV].inventoryX += x - center; /* * Now positioned as worked out diff --git a/engines/tinsel/dialogs.h b/engines/tinsel/dialogs.h index a256ed73e8..f81a59a0b7 100644 --- a/engines/tinsel/dialogs.h +++ b/engines/tinsel/dialogs.h @@ -32,7 +32,7 @@ #include "tinsel/events.h" // for PLR_EVENT, PLR_EVENT namespace Common { - class Serializer; +class Serializer; } namespace Tinsel { diff --git a/engines/tinsel/drives.cpp b/engines/tinsel/drives.cpp index 6e30caf006..d252e45cf5 100644 --- a/engines/tinsel/drives.cpp +++ b/engines/tinsel/drives.cpp @@ -24,9 +24,7 @@ * CD/drive handling functions */ -#include "common/config-manager.h" -#include "common/substream.h" -#include "gui/message.h" +#include "common/textconsole.h" #include "tinsel/drives.h" #include "tinsel/scene.h" #include "tinsel/tinsel.h" @@ -38,7 +36,6 @@ namespace Tinsel { // FIXME: Avoid non-const global vars char currentCD = '1'; -static uint32 cdFlags[] = { fCd1, fCd2, fCd3, fCd4, fCd5, fCd6, fCd7, fCd8 }; static bool bChangingCD = false; static char nextCD = '\0'; @@ -75,6 +72,8 @@ int GetCurrentCD() { return (currentCD - '1' + 1); } +static const uint32 cdFlags[] = { fCd1, fCd2, fCd3, fCd4, fCd5, fCd6, fCd7, fCd8 }; + void SetCD(int flags) { if (flags & cdFlags[currentCD - '1']) return; diff --git a/engines/tinsel/dw.h b/engines/tinsel/dw.h index 8bd7ca1a4e..aed4c50408 100644 --- a/engines/tinsel/dw.h +++ b/engines/tinsel/dw.h @@ -42,8 +42,6 @@ typedef int HPOLYGON; #define LF_CHAR '\x0a' // line feed // file names -#define SAMPLE_FILE "english.smp" // all samples -#define SAMPLE_INDEX "english.idx" // sample index filename #define MIDI_FILE "midi.dat" // all MIDI sequences #define INDEX_FILENAME "index" // name of index file #define PSX_INDEX_FILENAME "index.dat" // name of index file in psx version diff --git a/engines/tinsel/faders.cpp b/engines/tinsel/faders.cpp index a82285b12f..99a8b9ff14 100644 --- a/engines/tinsel/faders.cpp +++ b/engines/tinsel/faders.cpp @@ -37,7 +37,7 @@ namespace Tinsel { /** structure used by the "FadeProcess" process */ struct FADE { - const long *pColourMultTable; // list of fixed point colour multipliers - terminated with negative entry + const long *pColorMultTable; // list of fixed point color multipliers - terminated with negative entry PALQ *pPalQ; // palette queue entry to fade }; @@ -46,42 +46,42 @@ struct FADE { //const long fadein[] = {0, 0x1000, 0x3000, 0x5000, 0x7000, 0x9000, 0xb000, 0xd000, 0x10000L, -1}; /** - * Scale 'colour' by the fixed point colour multiplier 'colourMult' - * @param colour Colour to scale - * @param colourMult Fixed point multiplier + * Scale 'color' by the fixed point color multiplier 'colorMult' + * @param color Color to scale + * @param colorMult Fixed point multiplier */ -static COLORREF ScaleColour(COLORREF colour, uint32 colourMult) { +static COLORREF ScaleColor(COLORREF color, uint32 colorMult) { // apply multiplier to RGB components - uint32 red = ((TINSEL_GetRValue(colour) * colourMult) << 8) >> 24; - uint32 green = ((TINSEL_GetGValue(colour) * colourMult) << 8) >> 24; - uint32 blue = ((TINSEL_GetBValue(colour) * colourMult) << 8) >> 24; + uint32 red = ((TINSEL_GetRValue(color) * colorMult) << 8) >> 24; + uint32 green = ((TINSEL_GetGValue(color) * colorMult) << 8) >> 24; + uint32 blue = ((TINSEL_GetBValue(color) * colorMult) << 8) >> 24; - // return new colour + // return new color return TINSEL_RGB(red, green, blue); } /** - * Applies the fixed point multiplier 'mult' to all colours in - * 'pOrig' to produce 'pNew'. Each colour in the palette will be + * Applies the fixed point multiplier 'mult' to all colors in + * 'pOrig' to produce 'pNew'. Each color in the palette will be * multiplied by 'mult'. * @param pNew Pointer to new palette * @param pOrig Pointer to original palette - * @param numColours Number of colours in the above palettes + * @param numColors Number of colors in the above palettes * @param mult Fixed point multiplier */ -static void FadePalette(COLORREF *pNew, COLORREF *pOrig, int numColours, uint32 mult) { - for (int i = 0; i < numColours; i++, pNew++, pOrig++) { +static void FadePalette(COLORREF *pNew, COLORREF *pOrig, int numColors, uint32 mult) { + for (int i = 0; i < numColors; i++, pNew++, pOrig++) { if (!TinselV2) // apply multiplier to RGB components - *pNew = ScaleColour(*pOrig, mult); - else if (i == (TalkColour() - 1)) { - *pNew = GetTalkColourRef(); - *pNew = ScaleColour(*pNew, mult); - } else if (SysVar(SV_TAGCOLOUR) && i == (SysVar(SV_TAGCOLOUR) - 1)) { + *pNew = ScaleColor(*pOrig, mult); + else if (i == (TalkColor() - 1)) { + *pNew = GetTalkColorRef(); + *pNew = ScaleColor(*pNew, mult); + } else if (SysVar(SV_TAGCOLOR) && i == (SysVar(SV_TAGCOLOR) - 1)) { *pNew = GetTagColorRef(); - *pNew = ScaleColour(*pNew, mult); + *pNew = ScaleColor(*pNew, mult); } else { - *pNew = ScaleColour(*pOrig, mult); + *pNew = ScaleColor(*pOrig, mult); } } } @@ -94,8 +94,8 @@ static void FadePalette(COLORREF *pNew, COLORREF *pOrig, int numColours, uint32 static void FadeProcess(CORO_PARAM, const void *param) { // COROUTINE CORO_BEGIN_CONTEXT; - COLORREF fadeRGB[MAX_COLOURS]; // local copy of palette - const long *pColMult; // pointer to colour multiplier table + COLORREF fadeRGB[MAX_COLORS]; // local copy of palette + const long *pColMult; // pointer to color multiplier table PALETTE *pPalette; // pointer to palette CORO_END_CONTEXT(_ctx); @@ -111,19 +111,19 @@ static void FadeProcess(CORO_PARAM, const void *param) { // get pointer to palette - reduce pointer indirection a bit _ctx->pPalette = (PALETTE *)LockMem(pFade->pPalQ->hPal); - for (_ctx->pColMult = pFade->pColourMultTable; *_ctx->pColMult >= 0; _ctx->pColMult++) { + for (_ctx->pColMult = pFade->pColorMultTable; *_ctx->pColMult >= 0; _ctx->pColMult++) { // go through all multipliers in table - until a negative entry // fade palette using next multiplier if (TinselV2) FadePalette(_ctx->fadeRGB, pFade->pPalQ->palRGB, - pFade->pPalQ->numColours, (uint32) *_ctx->pColMult); + pFade->pPalQ->numColors, (uint32) *_ctx->pColMult); else FadePalette(_ctx->fadeRGB, _ctx->pPalette->palRGB, - FROM_LE_32(_ctx->pPalette->numColours), (uint32) *_ctx->pColMult); + FROM_LE_32(_ctx->pPalette->numColors), (uint32) *_ctx->pColMult); // send new palette to video DAC - UpdateDACqueue(pFade->pPalQ->posInDAC, FROM_LE_32(_ctx->pPalette->numColours), _ctx->fadeRGB); + UpdateDACqueue(pFade->pPalQ->posInDAC, FROM_LE_32(_ctx->pPalette->numColors), _ctx->fadeRGB); // allow time for video DAC to be updated CORO_SLEEP(1); @@ -139,7 +139,7 @@ static void FadeProcess(CORO_PARAM, const void *param) { /** * Generic palette fader/unfader. Creates a 'FadeProcess' process * for each palette that is to fade. - * @param multTable Fixed point colour multiplier table + * @param multTable Fixed point color multiplier table * @param noFadeTable List of palettes not to fade */ static void Fader(const long multTable[], SCNHANDLE noFadeTable[]) { @@ -175,7 +175,7 @@ static void Fader(const long multTable[], SCNHANDLE noFadeTable[]) { FADE fade; // fill in FADE struct - fade.pColourMultTable = multTable; + fade.pColorMultTable = multTable; fade.pPalQ = pPal; // create a fader process for this palette @@ -210,7 +210,7 @@ void FadeOutFast(SCNHANDLE noFadeTable[]) { } /** - * Fades a list of palettes from black to their current colours. + * Fades a list of palettes from black to their current colors. * 'noFadeTable' is a NULL terminated list of palettes not to fade. */ void FadeInMedium(SCNHANDLE noFadeTable[]) { @@ -223,7 +223,7 @@ void FadeInMedium(SCNHANDLE noFadeTable[]) { } /** - * Fades a list of palettes from black to their current colours. + * Fades a list of palettes from black to their current colors. * @param noFadeTable A NULL terminated list of palettes not to fade. */ void FadeInFast(SCNHANDLE noFadeTable[]) { @@ -234,10 +234,10 @@ void FadeInFast(SCNHANDLE noFadeTable[]) { Fader(fadein, noFadeTable); } -void PokeInTagColour() { - if (SysVar(SV_TAGCOLOUR)) { +void PokeInTagColor() { + if (SysVar(SV_TAGCOLOR)) { const COLORREF c = GetActorRGB(-1); - UpdateDACqueue(SysVar(SV_TAGCOLOUR), c); + UpdateDACqueue(SysVar(SV_TAGCOLOR), c); } } diff --git a/engines/tinsel/faders.h b/engines/tinsel/faders.h index e77bff2661..b30a26d893 100644 --- a/engines/tinsel/faders.h +++ b/engines/tinsel/faders.h @@ -50,7 +50,7 @@ void FadeOutMedium(SCNHANDLE noFadeTable[]); void FadeOutFast(SCNHANDLE noFadeTable[]); void FadeInMedium(SCNHANDLE noFadeTable[]); void FadeInFast(SCNHANDLE noFadeTable[]); -void PokeInTagColour(); +void PokeInTagColor(); } // End of namespace Tinsel diff --git a/engines/tinsel/font.cpp b/engines/tinsel/font.cpp index 4c76d12400..f57a6d5d54 100644 --- a/engines/tinsel/font.cpp +++ b/engines/tinsel/font.cpp @@ -118,10 +118,10 @@ void FettleFontPal(SCNHANDLE fontPal) { else pImg->hImgPal = 0; - if (TinselV2 && SysVar(SV_TAGCOLOUR)) { + if (TinselV2 && SysVar(SV_TAGCOLOR)) { const COLORREF c = GetActorRGB(-1); SetTagColorRef(c); - UpdateDACqueue(SysVar(SV_TAGCOLOUR), c); + UpdateDACqueue(SysVar(SV_TAGCOLOR), c); } } diff --git a/engines/tinsel/graphics.cpp b/engines/tinsel/graphics.cpp index aefc6e6144..bdcd3207f9 100644 --- a/engines/tinsel/graphics.cpp +++ b/engines/tinsel/graphics.cpp @@ -32,6 +32,8 @@ #include "tinsel/tinsel.h" #include "tinsel/scn.h" +#include "common/textconsole.h" + namespace Tinsel { //----------------- LOCAL DEFINES -------------------- @@ -41,7 +43,7 @@ namespace Tinsel { #define CHAR_WIDTH 4 #define CHAR_HEIGHT 4 -extern uint8 transPalette[MAX_COLOURS]; +extern uint8 transPalette[MAX_COLORS]; //----------------- SUPPORT FUNCTIONS --------------------- @@ -175,14 +177,14 @@ static void t0WrtNonZero(DRAWOBJECT *pObj, uint8 *srcP, uint8 *destP, bool apply x += clipAmount; if (repeatFlag) { - // Repeat of a given colour - uint8 colour = (numBytes >> 8) & 0xff; + // Repeat of a given color + uint8 color = (numBytes >> 8) & 0xff; int runLength = (numBytes & 0xff) - clipAmount; int rptLength = MAX(MIN(runLength, pObj->width - rightClip - x), 0); if (yClip == 0) { - if (colour != 0) - memset(tempDest, colour, rptLength); + if (color != 0) + memset(tempDest, color, rptLength); tempDest += rptLength; } @@ -470,18 +472,18 @@ static void t2WrtNonZero(DRAWOBJECT *pObj, uint8 *srcP, uint8 *destP, bool apply x+= clipAmount; int runLength = numBytes - clipAmount; - uint8 colour = *srcP++; + uint8 color = *srcP++; - if ((yClip == 0) && (runLength > 0) && (colour != 0)) { + if ((yClip == 0) && (runLength > 0) && (color != 0)) { runLength = MIN(runLength, pObj->width - rightClip - x); if (runLength > 0) { // Non-transparent run length - colour += pObj->constant; + color += pObj->constant; if (horizFlipped) - Common::set_to(tempP - runLength + 1, tempP + 1, colour); + Common::set_to(tempP - runLength + 1, tempP + 1, color); else - Common::set_to(tempP, tempP + runLength, colour); + Common::set_to(tempP, tempP + runLength, color); } } @@ -521,7 +523,7 @@ static void t2WrtNonZero(DRAWOBJECT *pObj, uint8 *srcP, uint8 *destP, bool apply } /** - * Fill the destination area with a constant colour + * Fill the destination area with a constant color */ static void WrtConst(DRAWOBJECT *pObj, uint8 *destP, bool applyClipping) { if (applyClipping) { @@ -595,11 +597,11 @@ static void WrtAll(DRAWOBJECT *pObj, uint8 *srcP, uint8 *destP, bool applyClippi */ static void PackedWrtNonZero(DRAWOBJECT *pObj, uint8 *srcP, uint8 *destP, bool applyClipping, bool horizFlipped, int packingType) { - uint8 numColours = 0; - uint8 *colourTable = NULL; + uint8 numColors = 0; + uint8 *colorTable = NULL; int topClip = 0; int xOffset = 0; - int numBytes, colour; + int numBytes, color; int v; if (_vm->getLanguage() == Common::RU_RUS) { @@ -625,10 +627,10 @@ static void PackedWrtNonZero(DRAWOBJECT *pObj, uint8 *srcP, uint8 *destP, } if (packingType == 3) { - // Variable colours - numColours = *srcP++; - colourTable = srcP; - srcP += numColours; + // Variable colors + numColors = *srcP++; + colorTable = srcP; + srcP += numColors; } for (int y = 0; y < pObj->height; ++y) { @@ -646,7 +648,7 @@ static void PackedWrtNonZero(DRAWOBJECT *pObj, uint8 *srcP, uint8 *destP, int x = 0; while (x < pObj->width) { - // Get next run size and colour to use + // Get next run size and color to use for (;;) { if (xOffset > 0) { x += xOffset; @@ -663,9 +665,9 @@ static void PackedWrtNonZero(DRAWOBJECT *pObj, uint8 *srcP, uint8 *destP, v = *srcP++; numBytes = v & 0xf; // No. bytes 1-15 if (packingType == 3) - colour = colourTable[v >> 4]; + color = colorTable[v >> 4]; else - colour = pObj->baseCol + (v >> 4); + color = pObj->baseCol + (v >> 4); if (numBytes != 0) break; @@ -693,7 +695,7 @@ static void PackedWrtNonZero(DRAWOBJECT *pObj, uint8 *srcP, uint8 *destP, while (numBytes-- > 0) { if ((topClip == 0) && (x < (pObj->width - rightClip))) { - *tempP = colour; + *tempP = color; if (horizFlipped) --tempP; else ++tempP; } ++x; @@ -830,7 +832,7 @@ void DrawObject(DRAWOBJECT *pObj) { int packType = pObj->flags >> 14; if (packType == 0) { - // No colour packing + // No color packing switch (typeId) { case 0x01: case 0x11: @@ -865,7 +867,7 @@ void DrawObject(DRAWOBJECT *pObj) { } else { // 1 = 16 from 240 // 2 = 16 from 224 - // 3 = variable colour + // 3 = variable color if (packType == 1) pObj->baseCol = 0xF0; else if (packType == 2) pObj->baseCol = 0xE0; diff --git a/engines/tinsel/graphics.h b/engines/tinsel/graphics.h index 8b8bb6488d..de16082441 100644 --- a/engines/tinsel/graphics.h +++ b/engines/tinsel/graphics.h @@ -43,7 +43,7 @@ struct DRAWOBJECT { int transOffset; // transparent character offset int flags; // object flags - see above for list PALQ *pPal; // objects palette Q position - int constant; // which colour in palette for monochrome objects + int constant; // which color in palette for monochrome objects int width; // width of object int height; // height of object SCNHANDLE hBits; // image bitmap handle diff --git a/engines/tinsel/handle.cpp b/engines/tinsel/handle.cpp index a48fd2ca1f..6f5f92c969 100644 --- a/engines/tinsel/handle.cpp +++ b/engines/tinsel/handle.cpp @@ -27,6 +27,7 @@ #define BODGE #include "common/file.h" +#include "common/textconsole.h" #include "tinsel/drives.h" #include "tinsel/dw.h" @@ -65,8 +66,6 @@ enum { fLoaded = 0x20000000L ///< set when file data has been loaded }; #define FSIZE_MASK 0x00FFFFFFL ///< mask to isolate the filesize -#define MALLOC_MASK 0xFF000000L ///< mask to isolate the memory allocation flags -//#define HANDLEMASK 0xFF800000L ///< get handle of address //----------------- LOCAL GLOBAL DATA -------------------- @@ -80,7 +79,6 @@ static uint numHandles = 0; static uint32 cdPlayHandle = (uint32)-1; -static int cdPlayFileNum, cdPlaySceneNum; static SCNHANDLE cdBaseHandle = 0, cdTopHandle = 0; static Common::File *cdGraphStream = 0; @@ -235,7 +233,7 @@ void LoadCDGraphData(MEMHANDLE *pH) { // clear the loading flag // pH->filesize &= ~fLoading; - if (bytes != ((cdTopHandle-cdBaseHandle) & OFFSETMASK)) + if (bytes != ((cdTopHandle - cdBaseHandle) & OFFSETMASK)) // file is corrupt error(FILE_READ_ERROR, "CD play file"); } @@ -248,7 +246,7 @@ void LoadCDGraphData(MEMHANDLE *pH) { * @param next Handle of end of range + 1 */ void LoadExtraGraphData(SCNHANDLE start, SCNHANDLE next) { - if (cdPlayFileNum == cdPlaySceneNum && start == cdBaseHandle) + if (start == cdBaseHandle) return; OpenCDGraphFile(); @@ -264,7 +262,6 @@ void LoadExtraGraphData(SCNHANDLE start, SCNHANDLE next) { } void SetCdPlaySceneDetails(int fileNum, const char *fileName) { - cdPlaySceneNum = fileNum; strcpy(szCdPlayFile, fileName); } diff --git a/engines/tinsel/mareels.cpp b/engines/tinsel/mareels.cpp index cf28749e76..5d9672972a 100644 --- a/engines/tinsel/mareels.cpp +++ b/engines/tinsel/mareels.cpp @@ -28,6 +28,7 @@ #include "tinsel/pcode.h" // For D_UP, D_DOWN #include "tinsel/rince.h" +#include "common/textconsole.h" #include "common/util.h" namespace Tinsel { diff --git a/engines/tinsel/module.mk b/engines/tinsel/module.mk index 2778cec3df..2ab94b830a 100644 --- a/engines/tinsel/module.mk +++ b/engines/tinsel/module.mk @@ -2,6 +2,7 @@ MODULE := engines/tinsel MODULE_OBJS := \ actors.o \ + adpcm.o \ anim.o \ background.o \ bg.o \ diff --git a/engines/tinsel/move.cpp b/engines/tinsel/move.cpp index 5b9e650689..5fc555f9b0 100644 --- a/engines/tinsel/move.cpp +++ b/engines/tinsel/move.cpp @@ -584,7 +584,7 @@ static void SetMoverUltDest(PMOVER pActor, int x, int y) { * If in a neighbouring path to the final destination, if the target path * is a follow nodes path, head for the end node, otherwise head straight * for the target. - * Otherwise, head towards the pseudo-centre or end node of the first + * Otherwise, head towards the pseudo-center or end node of the first * en-route path. */ static void SetMoverIntDest(PMOVER pMover, int x, int y) { @@ -636,7 +636,7 @@ static void SetMoverIntDest(PMOVER pMover, int x, int y) { } else if (hIpath != NOPOLY) { /* Head for an en-route path */ if (PolySubtype(hIpath) != NODE) { - /* En-route path is normal - head for pseudo centre. */ + /* En-route path is normal - head for pseudo center. */ if (CanGetThere(pMover, x, y) == GT_OK) { pMover->ItargetX = x; pMover->ItargetY = y; @@ -644,8 +644,8 @@ static void SetMoverIntDest(PMOVER pMover, int x, int y) { // make damn sure that Itarget is in hIpath pMover->hIpath = InPolygon(x, y, PATH); } else { - pMover->ItargetX = PolyCentreX(hIpath); - pMover->ItargetY = PolyCentreY(hIpath); + pMover->ItargetX = PolyCenterX(hIpath); + pMover->ItargetY = PolyCenterY(hIpath); if (TinselV2) // make damn sure that Itarget is in hIpath pMover->hIpath = InPolygon(pMover->ItargetX, pMover->ItargetY, PATH); @@ -943,12 +943,12 @@ static void SetNextDest(PMOVER pMover) { assert(hPath == pMover->hIpath); if (pMover->InDifficulty == NO_PROB) { - x = PolyCentreX(hPath); - y = PolyCentreY(hPath); + x = PolyCenterX(hPath); + y = PolyCenterY(hPath); SetMoverDest(pMover, x, y); - pMover->InDifficulty = TRY_CENTRE; + pMover->InDifficulty = TRY_CENTER; pMover->over = false; - } else if (pMover->InDifficulty == TRY_CENTRE) { + } else if (pMover->InDifficulty == TRY_CENTER) { NearestCorner(&x, &y, pMover->hCpath, pMover->hIpath); SetMoverDest(pMover, x, y); pMover->InDifficulty = TRY_CORNER; @@ -986,7 +986,7 @@ static void SetNextDest(PMOVER pMover) { !IsAdjacentPath(pMover->hCpath, pMover->hIpath)) { /*---------------------------------------------------------- If just entering a follow nodes polygon, go to first node.| - Else if just going to pass through, go to pseudo-centre. | + Else if just going to pass through, go to pseudo-center. | ----------------------------------------------------------*/ if (PolySubtype(hPath) == NODE && pMover->hFnpath != hPath && pMover->npstatus != LEAVING) { int node = NearestEndNode(hPath, x, y); @@ -995,7 +995,7 @@ static void SetNextDest(PMOVER pMover) { pMover->over = true; } else if (!IsInPolygon(pMover->ItargetX, pMover->ItargetY, hPath) && !IsInPolygon(pMover->ItargetX, pMover->ItargetY, pMover->hCpath)) { - SetMoverDest(pMover, PolyCentreX(hPath), PolyCentreY(hPath)); + SetMoverDest(pMover, PolyCenterX(hPath), PolyCenterY(hPath)); pMover->over = true; } else { SetMoverDest(pMover, pMover->ItargetX, pMover->ItargetY); @@ -1258,8 +1258,8 @@ static void SetOffWithinNodePath(PMOVER pMover, HPOLYGON StartPath, HPOLYGON Des endnode = NearestEndNode(StartPath, targetX, targetY); } else { if (PolySubtype(hIpath) != NODE) { - x = PolyCentreX(hIpath); - y = PolyCentreY(hIpath); + x = PolyCenterX(hIpath); + y = PolyCenterY(hIpath); endnode = NearestEndNode(StartPath, x, y); } else { endnode = NearEndNode(StartPath, hIpath); @@ -1278,7 +1278,7 @@ static void SetOffWithinNodePath(PMOVER pMover, HPOLYGON StartPath, HPOLYGON Des { // could go for its end node if it's an NPATH // but we probably will when we hit it anyway! - SetMoverDest(pMover, PolyCentreX(hIpath), PolyCentreY(hIpath)); + SetMoverDest(pMover, PolyCenterX(hIpath), PolyCenterY(hIpath)); } } } else @@ -1500,7 +1500,7 @@ static void EnteringNewPath(PMOVER pMover, HPOLYGON hPath, int x, int y) { assert(hIpath != NOPOLY); // No path on the way if (PolySubtype(hIpath) != NODE) { - lastnode = NearestEndNode(hPath, PolyCentreX(hIpath), PolyCentreY(hIpath)); + lastnode = NearestEndNode(hPath, PolyCenterX(hIpath), PolyCenterY(hIpath)); } else { lastnode = NearEndNode(hPath, hIpath); } diff --git a/engines/tinsel/music.cpp b/engines/tinsel/music.cpp index 29d4dbc92d..12bcff829b 100644 --- a/engines/tinsel/music.cpp +++ b/engines/tinsel/music.cpp @@ -38,6 +38,7 @@ #include "common/file.h" #include "common/memstream.h" +#include "tinsel/adpcm.h" #include "tinsel/config.h" #include "tinsel/sound.h" #include "tinsel/music.h" @@ -65,10 +66,6 @@ struct SOUND_BUFFER { // FIXME: Avoid non-const global vars -// get set when music driver is installed -//static MDI_DRIVER *mDriver; -//static HSEQUENCE mSeqHandle; - // MIDI buffer static SOUND_BUFFER midiBuffer = { 0, 0 }; @@ -115,26 +112,6 @@ static const int enhancedAudioSCNVersion[] = { 97, 98, 99, 99 // 151-154 }; -// TODO. This mapping is wrong -static const int enhancedAudioSCNVersionALT[] = { - 301, 302, 2, 1, 1, 301, 302, 3, 3, 4, // 1-10 - 4, 5, 6, 1, 7, 8, 9, 10, 8, 11, // 11-20 - 11, 12, 13, 13, 13, 13, 13, 14, 13, 13, // 21-30 - 15, 16, 17, 15, 18, 19, 20, 338, 21, 21, // 31-40 - 341, 342, 22, 22, 23, 24, 25, 26, 27, 28, // 41-50 - 29, 30, 31, 32, 33, 34, 35, 35, 36, 37, // 51-60 - 38, 39, 39, 39, 39, 40, 39, 41, 41, 42, // 61-70 - 43, 42, 44, 45, 41, 46, 48, 47, 48, 49, // 71-80 - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, // 81-90 - 60, 61, 62, 63, 61, 64, 65, 66, 67, 68, // 91-100 - 69, 70, 68, 71, 72, 73, 74, 75, 12, 76, // 101-110 - 77, 78, 79, 80, 4, 4, 82, 83, 77, 4, // 111-120 - 84, 85, 86, 3124, 88, 89, 90, 88, 2, 2, // 121-130 - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 131-140 - 3142, 91, 92, 93, 94, 94, 95, 96, 52, 4, // 141-150 - 97, 98, 99 // 151-153 -}; - int GetTrackNumber(SCNHANDLE hMidi) { for (int i = 0; i < ARRAYSIZE(midiOffsets); i++) if (midiOffsets[i] == hMidi) @@ -172,18 +149,18 @@ bool PlayMidiSequence(uint32 dwFileOffset, bool bLoop) { // the index and length of the last tune loaded static uint32 dwLastMidiIndex = 0; // FIXME: Avoid non-const global vars - //static uint32 dwLastSeqLen; - uint32 dwSeqLen = 0; // length of the sequence // Support for external music from the music enhancement project if (_vm->getFeatures() & GF_ENHANCED_AUDIO_SUPPORT) { int trackNumber = GetTrackNumber(dwFileOffset); + // Track 8 has been removed in the German CD re-release "Neon Edition" + if ((_vm->getFeatures() & GF_ALT_MIDI) && trackNumber >= 8) + trackNumber++; + int track = 0; if (trackNumber >= 0) { - if (_vm->getFeatures() & GF_ALT_MIDI) - track = enhancedAudioSCNVersionALT[trackNumber]; - else if (_vm->getFeatures() & GF_SCNFILES) + if (_vm->getFeatures() & GF_SCNFILES) track = enhancedAudioSCNVersion[trackNumber]; else track = enhancedAudioGRAVersion[trackNumber]; @@ -404,112 +381,43 @@ void DeleteMidiBuffer() { midiBuffer.pDat = NULL; } -MidiMusicPlayer::MidiMusicPlayer(MidiDriver *driver) : _parser(0), _driver(driver), _looping(false), _isPlaying(false) { - memset(_channel, 0, sizeof(_channel)); - memset(_channelVolume, 0, sizeof(_channelVolume)); - _masterVolume = 0; - this->open(); - _xmidiParser = MidiParser::createParser_XMIDI(); -} - -MidiMusicPlayer::~MidiMusicPlayer() { - _driver->setTimerCallback(NULL, NULL); - stop(); - this->close(); - _xmidiParser->setMidiDriver(NULL); - delete _xmidiParser; -} - -void MidiMusicPlayer::setVolume(int volume) { - _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, volume); - - if (_masterVolume == volume) - return; +MidiMusicPlayer::MidiMusicPlayer() { + MidiPlayer::createDriver(); - _masterVolume = volume; - - Common::StackLock lock(_mutex); + int ret = _driver->open(); + if (ret == 0) { + if (_nativeMT32) + _driver->sendMT32Reset(); + else + _driver->sendGMReset(); - for (int i = 0; i < 16; ++i) { - if (_channel[i]) { - _channel[i]->volume(_channelVolume[i] * _masterVolume / 255); - } + _driver->setTimerCallback(this, &timerCallback); } } -int MidiMusicPlayer::open() { - // Don't ever call open without first setting the output driver! - if (!_driver) - return 255; - - int ret = _driver->open(); - if (ret) - return ret; - - _driver->setTimerCallback(this, &onTimer); - return 0; -} +void MidiMusicPlayer::setVolume(int volume) { + _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, volume); -void MidiMusicPlayer::close() { - stop(); - if (_driver) - _driver->close(); - _driver = 0; + Audio::MidiPlayer::setVolume(volume); } void MidiMusicPlayer::send(uint32 b) { - byte channel = (byte)(b & 0x0F); - if ((b & 0xFFF0) == 0x07B0) { - // Adjust volume changes by master volume - byte volume = (byte)((b >> 16) & 0x7F); - _channelVolume[channel] = volume; - volume = volume * _masterVolume / 255; - b = (b & 0xFF00FFFF) | (volume << 16); - } else if ((b & 0xFFF0) == 0x007BB0) { - // Only respond to All Notes Off if this channel - // has currently been allocated - if (!_channel[b & 0x0F]) - return; - } - - if (!_channel[channel]) - _channel[channel] = (channel == 9) ? _driver->getPercussionChannel() : _driver->allocateChannel(); - - if (_channel[channel]) { - _channel[channel]->send(b); + Audio::MidiPlayer::send(b); + byte channel = (byte)(b & 0x0F); + if (_channelsTable[channel]) { if ((b & 0xFFF0) == 0x0079B0) { // We've just Reset All Controllers, so we need to // re-adjust the volume. Otherwise, volume is reset to // default whenever the music changes. - _channel[channel]->send(0x000007B0 | (((_channelVolume[channel] * _masterVolume) / 255) << 16) | channel); + _channelsTable[channel]->send(0x000007B0 | (((_channelsVolume[channel] * _masterVolume) / 255) << 16) | channel); } } } -void MidiMusicPlayer::metaEvent(byte type, byte *data, uint16 length) { - switch (type) { - case 0x2F: // End of Track - if (_looping) - _parser->jumpToTick(0); - else - stop(); - break; - default: - //warning("Unhandled meta event: %02x", type); - break; - } -} - -void MidiMusicPlayer::onTimer(void *refCon) { - MidiMusicPlayer *music = (MidiMusicPlayer *)refCon; - Common::StackLock lock(music->_mutex); - - if (music->_isPlaying) - music->_parser->onTimer(); -} - void MidiMusicPlayer::playXMIDI(byte *midiData, uint32 size, bool loop) { + Common::StackLock lock(_mutex); + if (_isPlaying) return; @@ -527,8 +435,8 @@ void MidiMusicPlayer::playXMIDI(byte *midiData, uint32 size, bool loop) { // Load XMID resource data - if (_xmidiParser->loadMusic(midiData, size)) { - MidiParser *parser = _xmidiParser; + MidiParser *parser = MidiParser::createParser_XMIDI(); + if (parser->loadMusic(midiData, size)) { parser->setTrack(0); parser->setMidiDriver(this); parser->setTimerRate(getBaseTempo()); @@ -537,18 +445,10 @@ void MidiMusicPlayer::playXMIDI(byte *midiData, uint32 size, bool loop) { _parser = parser; - _looping = loop; + _isLooping = loop; _isPlaying = true; - } -} - -void MidiMusicPlayer::stop() { - Common::StackLock lock(_mutex); - - _isPlaying = false; - if (_parser) { - _parser->unloadMusic(); - _parser = NULL; + } else { + delete parser; } } @@ -566,7 +466,6 @@ PCMMusicPlayer::PCMMusicPlayer() { _silenceSamples = 0; _curChunk = 0; - _fileName = 0; _state = S_IDLE; _mState = S_IDLE; _scriptNum = -1; @@ -589,15 +488,13 @@ PCMMusicPlayer::PCMMusicPlayer() { PCMMusicPlayer::~PCMMusicPlayer() { _vm->_mixer->stopHandle(_handle); - - delete[] _fileName; } void PCMMusicPlayer::startPlay(int id) { - if (!_fileName) + if (_filename.empty()) return; - debugC(DEBUG_DETAILED, kTinselDebugMusic, "Playing PCM music %s, index %d", _fileName, id); + debugC(DEBUG_DETAILED, kTinselDebugMusic, "Playing PCM music %s, index %d", _filename.c_str(), id); Common::StackLock slock(_mutex); @@ -712,8 +609,7 @@ void PCMMusicPlayer::setMusicSceneDetails(SCNHANDLE hScript, _hScript = hScript; _hSegment = hSegment; - _fileName = new char[strlen(fileName) + 1]; - strcpy(_fileName, fileName); + _filename = fileName; // Start scene with music not dimmed _dimmed = false; @@ -869,19 +765,19 @@ bool PCMMusicPlayer::getNextChunk() { sampleLength = FROM_LE_32(musicSegments[snum].sampleLength); sampleCLength = (((sampleLength + 63) & ~63)*33)/64; - if (!file.open(_fileName)) - error(CANNOT_FIND_FILE, _fileName); + if (!file.open(_filename)) + error(CANNOT_FIND_FILE, _filename.c_str()); file.seek(sampleOffset); if (file.eos() || file.err() || (uint32)file.pos() != sampleOffset) - error(FILE_IS_CORRUPT, _fileName); + error(FILE_IS_CORRUPT, _filename.c_str()); buffer = (byte *) malloc(sampleCLength); assert(buffer); // read all of the sample if (file.read(buffer, sampleCLength) != sampleCLength) - error(FILE_IS_CORRUPT, _fileName); + error(FILE_IS_CORRUPT, _filename.c_str()); debugC(DEBUG_DETAILED, kTinselDebugMusic, "Creating ADPCM music chunk with size %d, " "offset %d (script %d.%d)", sampleCLength, sampleOffset, @@ -890,8 +786,8 @@ bool PCMMusicPlayer::getNextChunk() { sampleStream = new Common::MemoryReadStream(buffer, sampleCLength, DisposeAfterUse::YES); delete _curChunk; - _curChunk = makeADPCMStream(sampleStream, DisposeAfterUse::YES, sampleCLength, - Audio::kADPCMTinsel8, 22050, 1, 32); + _curChunk = new Tinsel8_ADPCMStream(sampleStream, DisposeAfterUse::YES, sampleCLength, + 22050, 1, 32); _state = S_MID; return true; diff --git a/engines/tinsel/music.h b/engines/tinsel/music.h index e2a3b4c2c1..9003e60078 100644 --- a/engines/tinsel/music.h +++ b/engines/tinsel/music.h @@ -28,12 +28,13 @@ #ifndef TINSEL_MUSIC_H #define TINSEL_MUSIC_H -#include "audio/mididrv.h" -#include "audio/midiparser.h" +#include "audio/midiplayer.h" #include "audio/audiostream.h" #include "audio/mixer.h" #include "common/mutex.h" +class MidiParser; + namespace Tinsel { bool PlayMidiSequence( // Plays the specified MIDI sequence through the sound driver @@ -60,57 +61,24 @@ SCNHANDLE GetTrackOffset(int trackNumber); void dumpMusic(); -class MidiMusicPlayer : public MidiDriver { +class MidiMusicPlayer : public Audio::MidiPlayer { public: - MidiMusicPlayer(MidiDriver *driver); - ~MidiMusicPlayer(); - - bool isPlaying() { return _isPlaying; } - void setPlaying(bool playing) { _isPlaying = playing; } + MidiMusicPlayer(); - void setVolume(int volume); - int getVolume() { return _masterVolume; } + virtual void setVolume(int volume); void playXMIDI(byte *midiData, uint32 size, bool loop); - void stop(); +// void stop(); void pause(); void resume(); - void setLoop(bool loop) { _looping = loop; } - //MidiDriver interface implementation - int open(); - void close(); - void send(uint32 b); - - void metaEvent(byte type, byte *data, uint16 length); - - void setTimerCallback(void *timerParam, void (*timerProc)(void *)) { } + // MidiDriver_BASE interface implementation + virtual void send(uint32 b); // The original sets the "sequence timing" to 109 Hz, whatever that // means. The default is 120. - uint32 getBaseTempo() { return _driver ? (109 * _driver->getBaseTempo()) / 120 : 0; } - - //Channel allocation functions - MidiChannel *allocateChannel() { return 0; } - MidiChannel *getPercussionChannel() { return 0; } - - MidiParser *_parser; - Common::Mutex _mutex; - -protected: - - static void onTimer(void *data); - - MidiChannel *_channel[16]; - MidiDriver *_driver; - MidiParser *_xmidiParser; - byte _channelVolume[16]; - - bool _isPlaying; - bool _looping; - byte _masterVolume; }; class PCMMusicPlayer : public Audio::AudioStream { @@ -180,7 +148,7 @@ protected: int32 _scriptIndex; SCNHANDLE _hScript; SCNHANDLE _hSegment; - char *_fileName; + Common::String _filename; uint8 _volume; diff --git a/engines/tinsel/object.cpp b/engines/tinsel/object.cpp index bf31cdfa25..ad02a614a5 100644 --- a/engines/tinsel/object.cpp +++ b/engines/tinsel/object.cpp @@ -32,6 +32,8 @@ #include "tinsel/text.h" #include "tinsel/tinsel.h" +#include "common/textconsole.h" + #define OID_EFFECTS 0x2000 // generic special effects object id namespace Tinsel { @@ -482,11 +484,11 @@ void AnimateObject(OBJECT *pAniObj, SCNHANDLE hNewImg) { * Creates a rectangle object of the given dimensions and returns * a pointer to the object. * @param hPal Palette for the rectangle object - * @param colour Which colour offset from the above palette + * @param color Which color offset from the above palette * @param width Width of rectangle * @param height Height of rectangle */ -OBJECT *RectangleObject(SCNHANDLE hPal, int colour, int width, int height) { +OBJECT *RectangleObject(SCNHANDLE hPal, int color, int width, int height) { // template for initialising the rectangle object static const OBJ_INIT rectObj = {0, DMA_CONST, OID_EFFECTS, 0, 0, 0}; PALQ *pPalQ; // palette queue pointer @@ -503,8 +505,8 @@ OBJECT *RectangleObject(SCNHANDLE hPal, int colour, int width, int height) { // assign palette to object pRect->pPal = pPalQ; - // set colour in the palette - pRect->constant = colour; + // set color in the palette + pRect->constant = color; // set rectangle width pRect->width = width; diff --git a/engines/tinsel/object.h b/engines/tinsel/object.h index a000dee72c..9f10c06cd2 100644 --- a/engines/tinsel/object.h +++ b/engines/tinsel/object.h @@ -87,7 +87,7 @@ struct OBJECT { Common::Rect rcPrev; ///< previous screen coordinates of object bounding rectangle int flags; ///< object flags - see above for list PALQ *pPal; ///< objects palette Q position - int constant; ///< which colour in palette for monochrome objects + int constant; ///< which color in palette for monochrome objects int width; ///< width of object int height; ///< height of object SCNHANDLE hBits; ///< image bitmap handle @@ -184,7 +184,7 @@ void HideObject( // Hides a object by giving it a "NullImage" image pointer OBJECT *RectangleObject( // create a rectangle object of the given dimensions SCNHANDLE hPal, // palette for the rectangle object - int colour, // which colour offset from the above palette + int color, // which color offset from the above palette int width, // width of rectangle int height); // height of rectangle diff --git a/engines/tinsel/palette.cpp b/engines/tinsel/palette.cpp index a0ceec54eb..0877337603 100644 --- a/engines/tinsel/palette.cpp +++ b/engines/tinsel/palette.cpp @@ -32,6 +32,8 @@ #include "tinsel/tinsel.h" #include "common/system.h" +#include "common/textconsole.h" +#include "graphics/palette.h" namespace Tinsel { @@ -41,12 +43,12 @@ namespace Tinsel { struct VIDEO_DAC_Q { union { SCNHANDLE hRGBarray; ///< handle of palette or - COLORREF *pRGBarray; ///< list of palette colours + COLORREF *pRGBarray; ///< list of palette colors COLORREF singleRGB; } pal; bool bHandle; ///< when set - use handle of palette int destDACindex; ///< start index of palette in video DAC - int numColours; ///< number of colours in "hRGBarray" + int numColors; ///< number of colors in "hRGBarray" }; @@ -67,13 +69,13 @@ static VIDEO_DAC_Q vidDACdata[VDACQLENGTH]; /** video DAC transfer Q head pointer */ static VIDEO_DAC_Q *pDAChead; -/** colour index of the 4 colours used for the translucent palette */ +/** color index of the 4 colors used for the translucent palette */ #define COL_HILIGHT TBLUE1 /** the translucent palette lookup table */ -uint8 transPalette[MAX_COLOURS]; // used in graphics.cpp +uint8 transPalette[MAX_COLORS]; // used in graphics.cpp -uint8 ghostPalette[MAX_COLOURS]; +uint8 ghostPalette[MAX_COLORS]; static int translucentIndex = 228; @@ -111,7 +113,7 @@ void psxPaletteMapper(PALQ *originalPal, uint8 *psxClut, byte *mapperTable) { } // Check for correspondent color - for (uint i = 0; (i < FROM_LE_32(pal->numColours)) && !colorFound; i++) { + for (uint i = 0; (i < FROM_LE_32(pal->numColors)) && !colorFound; i++) { // get R G B values in the same way as psx format converters uint16 psxEquivalent = TINSEL_PSX_RGB(TINSEL_GetRValue(pal->palRGB[i]) >> 3, TINSEL_GetGValue(pal->palRGB[i]) >> 3, TINSEL_GetBValue(pal->palRGB[i]) >> 3); @@ -138,15 +140,15 @@ void PalettesToVideoDAC() { // while Q is not empty while (pDAChead != pDACtail) { const PALETTE *pPalette; // pointer to hardware palette - const COLORREF *pColours; // pointer to list of RGB triples + const COLORREF *pColors; // pointer to list of RGB triples #ifdef DEBUG // make sure palette does not overlap - assert(pDACtail->destDACindex + pDACtail->numColours <= MAX_COLOURS); + assert(pDACtail->destDACindex + pDACtail->numColors <= MAX_COLORS); #else // make sure palette does not overlap - if (pDACtail->destDACindex + pDACtail->numColours > MAX_COLOURS) - pDACtail->numColours = MAX_COLOURS - pDACtail->destDACindex; + if (pDACtail->destDACindex + pDACtail->numColors > MAX_COLORS) + pDACtail->numColors = MAX_COLORS - pDACtail->destDACindex; #endif if (pDACtail->bHandle) { @@ -156,23 +158,23 @@ void PalettesToVideoDAC() { pPalette = (const PALETTE *)LockMem(pDACtail->pal.hRGBarray); // get RGB pointer - pColours = pPalette->palRGB; - } else if (pDACtail->numColours == 1) { + pColors = pPalette->palRGB; + } else if (pDACtail->numColors == 1) { // we are using a single color palette - pColours = &pDACtail->pal.singleRGB; + pColors = &pDACtail->pal.singleRGB; } else { // we are using a palette pointer - pColours = pDACtail->pal.pRGBarray; + pColors = pDACtail->pal.pRGBarray; } - for (int i = 0; i < pDACtail->numColours; ++i) { - pal[i * 3 + 0] = TINSEL_GetRValue(pColours[i]); - pal[i * 3 + 1] = TINSEL_GetGValue(pColours[i]); - pal[i * 3 + 2] = TINSEL_GetBValue(pColours[i]); + for (int i = 0; i < pDACtail->numColors; ++i) { + pal[i * 3 + 0] = TINSEL_GetRValue(pColors[i]); + pal[i * 3 + 1] = TINSEL_GetGValue(pColors[i]); + pal[i * 3 + 2] = TINSEL_GetBValue(pColors[i]); } // update the system palette - g_system->getPaletteManager()->setPalette(pal, pDACtail->destDACindex, pDACtail->numColours); + g_system->getPaletteManager()->setPalette(pal, pDACtail->destDACindex, pDACtail->numColors); // update tail pointer pDACtail++; @@ -216,15 +218,15 @@ void PaletteStats() { /** * Places a palette in the video DAC queue. * @param posInDAC Position in video DAC - * @param numColours Number of colours in palette + * @param numColors Number of colors in palette * @param hPalette Handle to palette */ -void UpdateDACqueueHandle(int posInDAC, int numColours, SCNHANDLE hPalette) { +void UpdateDACqueueHandle(int posInDAC, int numColors, SCNHANDLE hPalette) { // check Q overflow assert(pDAChead < vidDACdata + VDACQLENGTH); pDAChead->destDACindex = posInDAC & ~PALETTE_MOVED; // set index in video DAC - pDAChead->numColours = numColours; // set number of colours + pDAChead->numColors = numColors; // set number of colors pDAChead->pal.hRGBarray = hPalette; // set handle of palette pDAChead->bHandle = true; // we are using a palette handle @@ -240,19 +242,19 @@ void UpdateDACqueueHandle(int posInDAC, int numColours, SCNHANDLE hPalette) { /** * Places a palette in the video DAC queue. * @param posInDAC Position in video DAC - * @param numColours Number of colours in palette - * @param pColours List of RGB triples + * @param numColors Number of colors in palette + * @param pColors List of RGB triples */ -void UpdateDACqueue(int posInDAC, int numColours, COLORREF *pColours) { +void UpdateDACqueue(int posInDAC, int numColors, COLORREF *pColors) { // check Q overflow assert(pDAChead < vidDACdata + NUM_PALETTES); pDAChead->destDACindex = posInDAC & ~PALETTE_MOVED; // set index in video DAC - pDAChead->numColours = numColours; // set number of colours - if (numColours == 1) - pDAChead->pal.singleRGB = *pColours; // set single color of which the "palette" consists + pDAChead->numColors = numColors; // set number of colors + if (numColors == 1) + pDAChead->pal.singleRGB = *pColors; // set single color of which the "palette" consists else - pDAChead->pal.pRGBarray = pColours; // set addr of palette + pDAChead->pal.pRGBarray = pColors; // set addr of palette pDAChead->bHandle = false; // we are not using a palette handle // update head pointer @@ -275,7 +277,7 @@ void UpdateDACqueue(int posInDAC, COLORREF color) { assert(pDAChead < vidDACdata + NUM_PALETTES); pDAChead->destDACindex = posInDAC & ~PALETTE_MOVED; // set index in video DAC - pDAChead->numColours = 1; // set number of colours + pDAChead->numColors = 1; // set number of colors pDAChead->pal.singleRGB = color; // set single color of which the "palette" consists pDAChead->bHandle = false; // we are not using a palette handle @@ -294,7 +296,7 @@ void UpdateDACqueue(int posInDAC, COLORREF color) { */ PALQ *AllocPalette(SCNHANDLE hNewPal) { PALQ *pPrev, *p; // walks palAllocData - int iDAC; // colour index in video DAC + int iDAC; // color index in video DAC PALQ *pNxtPal; // next PALQ struct in palette allocator PALETTE *pNewPal; @@ -311,7 +313,7 @@ PALQ *AllocPalette(SCNHANDLE hNewPal) { } // search all structs in palette allocator - find a free slot - iDAC = FGND_DAC_INDEX; // init DAC index to first available foreground colour + iDAC = FGND_DAC_INDEX; // init DAC index to first available foreground color for (p = palAllocData; p < palAllocData + NUM_PALETTES; p++) { if (p->hPal == 0) { @@ -319,11 +321,11 @@ PALQ *AllocPalette(SCNHANDLE hNewPal) { p->objCount = 1; // init number of objects using palette p->posInDAC = iDAC; // set palettes start pos in video DAC p->hPal = hNewPal; // set hardware palette data - p->numColours = FROM_LE_32(pNewPal->numColours); // set number of colours in palette + p->numColors = FROM_LE_32(pNewPal->numColors); // set number of colors in palette if (TinselV2) - // Copy all the colours - memcpy(p->palRGB, pNewPal->palRGB, p->numColours * sizeof(COLORREF)); + // Copy all the colors + memcpy(p->palRGB, pNewPal->palRGB, p->numColors * sizeof(COLORREF)); #ifdef DEBUG // one more palette in use @@ -333,30 +335,30 @@ PALQ *AllocPalette(SCNHANDLE hNewPal) { // Q the change to the video DAC if (TinselV2) - UpdateDACqueue(p->posInDAC, p->numColours, p->palRGB); + UpdateDACqueue(p->posInDAC, p->numColors, p->palRGB); else - UpdateDACqueueHandle(p->posInDAC, p->numColours, p->hPal); + UpdateDACqueueHandle(p->posInDAC, p->numColors, p->hPal); // move all palettes after this one down (if necessary) for (pPrev = p, pNxtPal = pPrev + 1; pNxtPal < palAllocData + NUM_PALETTES; pNxtPal++) { if (pNxtPal->hPal != 0) { // palette slot is in use - if (pNxtPal->posInDAC >= pPrev->posInDAC + pPrev->numColours) + if (pNxtPal->posInDAC >= pPrev->posInDAC + pPrev->numColors) // no need to move palettes down break; // move palette down - indicate change pNxtPal->posInDAC = (pPrev->posInDAC - + pPrev->numColours) | PALETTE_MOVED; + + pPrev->numColors) | PALETTE_MOVED; // Q the palette change in position to the video DAC if (!TinselV2) UpdateDACqueueHandle(pNxtPal->posInDAC, - pNxtPal->numColours, + pNxtPal->numColors, pNxtPal->hPal); else if (!pNxtPal->bFading) UpdateDACqueue(pNxtPal->posInDAC, - pNxtPal->numColours, + pNxtPal->numColors, pNxtPal->palRGB); // update previous palette to current palette @@ -369,7 +371,7 @@ PALQ *AllocPalette(SCNHANDLE hNewPal) { } // set new DAC index - iDAC = p->posInDAC + p->numColours; + iDAC = p->posInDAC + p->numColors; } // no free palettes @@ -431,43 +433,43 @@ void SwapPalette(PALQ *pPalQ, SCNHANDLE hNewPal) { // validate palette Q pointer assert(pPalQ >= palAllocData && pPalQ <= palAllocData + NUM_PALETTES - 1); - if (pPalQ->numColours >= (int)FROM_LE_32(pNewPal->numColours)) { + if (pPalQ->numColors >= (int)FROM_LE_32(pNewPal->numColors)) { // new palette will fit the slot // install new palette pPalQ->hPal = hNewPal; if (TinselV2) { - pPalQ->numColours = FROM_LE_32(pNewPal->numColours); + pPalQ->numColors = FROM_LE_32(pNewPal->numColors); - // Copy all the colours - memcpy(pPalQ->palRGB, pNewPal->palRGB, FROM_LE_32(pNewPal->numColours) * sizeof(COLORREF)); + // Copy all the colors + memcpy(pPalQ->palRGB, pNewPal->palRGB, FROM_LE_32(pNewPal->numColors) * sizeof(COLORREF)); if (!pPalQ->bFading) // Q the change to the video DAC - UpdateDACqueue(pPalQ->posInDAC, FROM_LE_32(pNewPal->numColours), pPalQ->palRGB); + UpdateDACqueue(pPalQ->posInDAC, FROM_LE_32(pNewPal->numColors), pPalQ->palRGB); } else { // Q the change to the video DAC - UpdateDACqueueHandle(pPalQ->posInDAC, FROM_LE_32(pNewPal->numColours), hNewPal); + UpdateDACqueueHandle(pPalQ->posInDAC, FROM_LE_32(pNewPal->numColors), hNewPal); } } else { - // # colours are different - will have to update all following palette entries + // # colors are different - will have to update all following palette entries assert(!TinselV2); // Fatal error for Tinsel 2 PALQ *pNxtPalQ; // next palette queue position for (pNxtPalQ = pPalQ + 1; pNxtPalQ < palAllocData + NUM_PALETTES; pNxtPalQ++) { - if (pNxtPalQ->posInDAC >= pPalQ->posInDAC + pPalQ->numColours) + if (pNxtPalQ->posInDAC >= pPalQ->posInDAC + pPalQ->numColors) // no need to move palettes down break; // move palette down pNxtPalQ->posInDAC = (pPalQ->posInDAC - + pPalQ->numColours) | PALETTE_MOVED; + + pPalQ->numColors) | PALETTE_MOVED; // Q the palette change in position to the video DAC UpdateDACqueueHandle(pNxtPalQ->posInDAC, - pNxtPalQ->numColours, + pNxtPalQ->numColors, pNxtPalQ->hPal); // update previous palette to current palette @@ -501,12 +503,12 @@ PALQ *GetNextPalette(PALQ *pStrtPal) { } /** - * Sets the current background colour. - * @param colour Colour to set the background to + * Sets the current background color. + * @param color Color to set the background to */ -void SetBgndColour(COLORREF colour) { - // update background colour struct by queuing the change to the video DAC - UpdateDACqueue(BGND_DAC_INDEX, colour); +void SetBgndColor(COLORREF color) { + // update background color struct by queuing the change to the video DAC + UpdateDACqueue(BGND_DAC_INDEX, color); } /** @@ -544,23 +546,23 @@ void CreateTranslucentPalette(SCNHANDLE hPalette) { // get a pointer to the palette PALETTE *pPal = (PALETTE *)LockMem(hPalette); - // leave background colour alone + // leave background color alone transPalette[0] = 0; - for (uint i = 0; i < FROM_LE_32(pPal->numColours); i++) { - // get the RGB colour model values + for (uint i = 0; i < FROM_LE_32(pPal->numColors); i++) { + // get the RGB color model values uint8 red = TINSEL_GetRValue(pPal->palRGB[i]); uint8 green = TINSEL_GetGValue(pPal->palRGB[i]); uint8 blue = TINSEL_GetBValue(pPal->palRGB[i]); - // calculate the Value field of the HSV colour model + // calculate the Value field of the HSV color model unsigned val = (red > green) ? red : green; val = (val > blue) ? val : blue; - // map the Value field to one of the 4 colours reserved for the translucent palette + // map the Value field to one of the 4 colors reserved for the translucent palette val /= 63; transPalette[i + 1] = (uint8)((val == 0) ? 0 : val + - (TinselV2 ? TranslucentColour() : COL_HILIGHT) - 1); + (TinselV2 ? TranslucentColor() : COL_HILIGHT) - 1); } } @@ -572,20 +574,20 @@ void CreateGhostPalette(SCNHANDLE hPalette) { PALETTE *pPal = (PALETTE *)LockMem(hPalette); int i; - // leave background colour alone + // leave background color alone ghostPalette[0] = 0; - for (i = 0; i < (int)FROM_LE_32(pPal->numColours); i++) { - // get the RGB colour model values + for (i = 0; i < (int)FROM_LE_32(pPal->numColors); i++) { + // get the RGB color model values uint8 red = TINSEL_GetRValue(pPal->palRGB[i]); uint8 green = TINSEL_GetGValue(pPal->palRGB[i]); uint8 blue = TINSEL_GetBValue(pPal->palRGB[i]); - // calculate the Value field of the HSV colour model + // calculate the Value field of the HSV color model unsigned val = (red > green) ? red : green; val = (val > blue) ? val : blue; - // map the Value field to one of the 4 colours reserved for the translucent palette + // map the Value field to one of the 4 colors reserved for the translucent palette val /= 64; assert(/*val >= 0 &&*/ val <= 3); ghostPalette[i + 1] = (uint8)(val + SysVar(ISV_GHOST_BASE)); @@ -594,25 +596,25 @@ void CreateGhostPalette(SCNHANDLE hPalette) { /** - * Returns an adjusted colour RGB - * @param colour Colour to scale + * Returns an adjusted color RGB + * @param color Color to scale */ -static COLORREF DimColour(COLORREF colour, int factor) { +static COLORREF DimColor(COLORREF color, int factor) { uint32 red, green, blue; if (factor == 10) { // No change - return colour; + return color; } else if (factor == 0) { // No brightness return 0; } else { // apply multiplier to RGB components - red = TINSEL_GetRValue(colour) * factor / 10; - green = TINSEL_GetGValue(colour) * factor / 10; - blue = TINSEL_GetBValue(colour) * factor / 10; + red = TINSEL_GetRValue(color) * factor / 10; + green = TINSEL_GetGValue(color) * factor / 10; + blue = TINSEL_GetBValue(color) * factor / 10; - // return new colour + // return new color return TINSEL_RGB(red, green, blue); } } @@ -620,10 +622,10 @@ static COLORREF DimColour(COLORREF colour, int factor) { /** * DimPartPalette */ -void DimPartPalette(SCNHANDLE hDimPal, int startColour, int length, int brightness) { +void DimPartPalette(SCNHANDLE hDimPal, int startColor, int length, int brightness) { PALQ *pPalQ; PALETTE *pDimPal; - int iColour; + int iColor; pPalQ = FindPalette(hDimPal); assert(pPalQ); @@ -631,42 +633,42 @@ void DimPartPalette(SCNHANDLE hDimPal, int startColour, int length, int brightne // get pointer to dim palette pDimPal = (PALETTE *)LockMem(hDimPal); - // Adjust for the fact that palettes don't contain colour 0 - startColour -= 1; + // Adjust for the fact that palettes don't contain color 0 + startColor -= 1; // Check some other things - if (startColour + length > pPalQ->numColours) - error("DimPartPalette(): colour overrun"); + if (startColor + length > pPalQ->numColors) + error("DimPartPalette(): color overrun"); - for (iColour = startColour; iColour < startColour + length; iColour++) { - pPalQ->palRGB[iColour] = DimColour(pDimPal->palRGB[iColour], brightness); + for (iColor = startColor; iColor < startColor + length; iColor++) { + pPalQ->palRGB[iColor] = DimColor(pDimPal->palRGB[iColor], brightness); } if (!pPalQ->bFading) { // Q the change to the video DAC - UpdateDACqueue(pPalQ->posInDAC + startColour, length, &pPalQ->palRGB[startColour]); + UpdateDACqueue(pPalQ->posInDAC + startColor, length, &pPalQ->palRGB[startColor]); } } -int TranslucentColour() { +int TranslucentColor() { return translucentIndex; } -int HighlightColour() { +int HighlightColor() { UpdateDACqueue(talkIndex, (COLORREF)SysVar(SYS_HighlightRGB)); return talkIndex; } -int TalkColour() { +int TalkColor() { return TinselV2 ? talkIndex : TALKFONT_COL; } -void SetTalkColourRef(COLORREF colRef) { +void SetTalkColorRef(COLORREF colRef) { talkColRef = colRef; } -COLORREF GetTalkColourRef() { +COLORREF GetTalkColorRef() { return talkColRef; } diff --git a/engines/tinsel/palette.h b/engines/tinsel/palette.h index 9743ee53aa..694eff504d 100644 --- a/engines/tinsel/palette.h +++ b/engines/tinsel/palette.h @@ -42,14 +42,14 @@ typedef uint32 COLORREF; #define TINSEL_PSX_RGB(r,g,b) ((uint16)(((uint8)(r))|((uint16)(g)<<5)|(((uint16)(b))<<10))) enum { - MAX_COLOURS = 256, ///< maximum number of colours - for VGA 256 + MAX_COLORS = 256, ///< maximum number of colors - for VGA 256 BITS_PER_PIXEL = 8, ///< number of bits per pixel for VGA 256 MAX_INTENSITY = 255, ///< the biggest value R, G or B can have NUM_PALETTES = 32, ///< number of palettes // Discworld has some fixed apportioned bits in the palette. - BGND_DAC_INDEX = 0, ///< index of background colour in Video DAC - FGND_DAC_INDEX = 1, ///< index of first foreground colour in Video DAC + BGND_DAC_INDEX = 0, ///< index of background color in Video DAC + FGND_DAC_INDEX = 1, ///< index of first foreground color in Video DAC TBLUE1 = 228, ///< Blue used in translucent rectangles TBLUE2 = 229, ///< Blue used in translucent rectangles TBLUE3 = 230, ///< Blue used in translucent rectangles @@ -57,7 +57,7 @@ enum { TALKFONT_COL = 233 }; -// some common colours +// some common colors #define BLACK (TINSEL_RGB(0, 0, 0)) #define WHITE (TINSEL_RGB(MAX_INTENSITY, MAX_INTENSITY, MAX_INTENSITY)) @@ -73,8 +73,8 @@ enum { /** hardware palette structure */ struct PALETTE { - int32 numColours; ///< number of colours in the palette - COLORREF palRGB[MAX_COLOURS]; ///< actual palette colours + int32 numColors; ///< number of colors in the palette + COLORREF palRGB[MAX_COLORS]; ///< actual palette colors } PACKED_STRUCT; #include "common/pack-end.h" // END STRUCT PACKING @@ -85,10 +85,10 @@ struct PALQ { SCNHANDLE hPal; ///< handle to palette data struct int objCount; ///< number of objects using this palette int posInDAC; ///< palette position in the video DAC - int numColours; ///< number of colours in the palette + int numColors; ///< number of colors in the palette // Discworld 2 fields bool bFading; // Whether or not fading - COLORREF palRGB[MAX_COLOURS]; // actual palette colours + COLORREF palRGB[MAX_COLORS]; // actual palette colors }; #define PALETTE_MOVED 0x8000 // when this bit is set in the "posInDAC" @@ -114,13 +114,13 @@ void PalettesToVideoDAC(); // Update the video DAC with palettes currently the t void UpdateDACqueueHandle( int posInDAC, // position in video DAC - int numColours, // number of colours in palette + int numColors, // number of colors in palette SCNHANDLE hPalette); // handle to palette void UpdateDACqueue( // places a palette in the video DAC queue int posInDAC, // position in video DAC - int numColours, // number of colours in palette - COLORREF *pColours); // list of RGB tripples + int numColors, // number of colors in palette + COLORREF *pColors); // list of RGB tripples void UpdateDACqueue(int posInDAC, COLORREF color); @@ -140,10 +140,10 @@ void SwapPalette( // swaps palettes at the specified palette queue position PALQ *GetNextPalette( // returns the next palette in the queue PALQ *pStrtPal); // queue position to start from - when NULL will start from beginning of queue -COLORREF GetBgndColour(); // returns current background colour +COLORREF GetBgndColor(); // returns current background color -void SetBgndColour( // sets current background colour - COLORREF colour); // colour to set the background to +void SetBgndColor( // sets current background color + COLORREF color); // color to set the background to void FadingPalette(PALQ *pPalQ, bool bFading); @@ -155,22 +155,22 @@ void NoFadingPalettes(); // All fading processes have just been killed void DimPartPalette( SCNHANDLE hPal, - int startColour, + int startColor, int length, int brightness); // 0 = black, 10 == 100% -int TranslucentColour(); +int TranslucentColor(); -#define BoxColour TranslucentColour +#define BoxColor TranslucentColor -int HighlightColour(); +int HighlightColor(); -int TalkColour(); +int TalkColor(); -void SetTalkColourRef(COLORREF colRef); +void SetTalkColorRef(COLORREF colRef); -COLORREF GetTalkColourRef(); +COLORREF GetTalkColorRef(); void SetTagColorRef(COLORREF colRef); diff --git a/engines/tinsel/pcode.cpp b/engines/tinsel/pcode.cpp index ccd86d7ed7..a1cc02a832 100644 --- a/engines/tinsel/pcode.cpp +++ b/engines/tinsel/pcode.cpp @@ -36,6 +36,7 @@ #include "tinsel/tinlib.h" // Library routines #include "tinsel/tinsel.h" +#include "common/textconsole.h" #include "common/util.h" namespace Tinsel { diff --git a/engines/tinsel/pcode.h b/engines/tinsel/pcode.h index f3690e9257..f31f2eb5c6 100644 --- a/engines/tinsel/pcode.h +++ b/engines/tinsel/pcode.h @@ -31,7 +31,7 @@ #include "tinsel/sched.h" // for PROCESS namespace Common { - class Serializer; +class Serializer; } namespace Tinsel { diff --git a/engines/tinsel/pdisplay.cpp b/engines/tinsel/pdisplay.cpp index 38748b703b..5022f4757a 100644 --- a/engines/tinsel/pdisplay.cpp +++ b/engines/tinsel/pdisplay.cpp @@ -44,6 +44,8 @@ #include "tinsel/text.h" #include "tinsel/tinsel.h" +#include "common/textconsole.h" + namespace Tinsel { //----------------- EXTERNAL GLOBAL DATA -------------------- @@ -59,8 +61,8 @@ extern int newestString; // The overrun counter, in STRRES.C #define LPOSX 295 // X-co-ord of lead actor's position display #define CPOSX 24 // X-co-ord of cursor's position display -#define OPOSX SCRN_CENTRE_X // X-co-ord of overrun counter's display -#define SPOSX SCRN_CENTRE_X // X-co-ord of string numbner's display +#define OPOSX SCRN_CENTER_X // X-co-ord of overrun counter's display +#define SPOSX SCRN_CENTER_X // X-co-ord of string numbner's display #define POSY 0 // Y-co-ord of these position displays @@ -158,7 +160,7 @@ void CursorPositionProcess(CORO_PARAM, const void *) { // New text objects sprintf(PositionString, "%d %d", aniX + Loffset, aniY + Toffset); _ctx->cpText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), PositionString, - 0, CPOSX, POSY, GetTagFontHandle(), TXT_CENTRE); + 0, CPOSX, POSY, GetTagFontHandle(), TXT_CENTER); if (DispPath) { HPOLYGON hp = InPolygon(aniX + Loffset, aniY + Toffset, PATH); if (hp == NOPOLY) @@ -190,7 +192,7 @@ void CursorPositionProcess(CORO_PARAM, const void *) { sprintf(PositionString, "%d", Overrun); _ctx->opText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), PositionString, - 0, OPOSX, POSY, GetTagFontHandle(), TXT_CENTRE); + 0, OPOSX, POSY, GetTagFontHandle(), TXT_CENTER); // update previous value _ctx->prevOver = Overrun; @@ -216,7 +218,7 @@ void CursorPositionProcess(CORO_PARAM, const void *) { // create new text object list sprintf(PositionString, "%d %d", aniX, aniY); _ctx->rpText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), PositionString, - 0, LPOSX, POSY, GetTagFontHandle(), TXT_CENTRE); + 0, LPOSX, POSY, GetTagFontHandle(), TXT_CENTER); // update previous position _ctx->prevlX = aniX; @@ -235,7 +237,7 @@ void CursorPositionProcess(CORO_PARAM, const void *) { sprintf(PositionString, "String: %d", newestString); _ctx->spText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), PositionString, - 0, SPOSX, POSY+10, GetTalkFontHandle(), TXT_CENTRE); + 0, SPOSX, POSY+10, GetTalkFontHandle(), TXT_CENTER); // update previous value _ctx->prevString = newestString; @@ -411,7 +413,7 @@ static bool ActorTag(int curX, int curY, HotSpotTag *pTag, OBJECT **ppText) { // May have buggered cursor EndCursorFollowed(); *ppText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), tagBuffer, - 0, tagX, tagY, GetTagFontHandle(), TXT_CENTRE, 0); + 0, tagX, tagY, GetTagFontHandle(), TXT_CENTER, 0); assert(*ppText); MultiSetZPosition(*ppText, Z_TAG_TEXT); } else @@ -456,7 +458,7 @@ static bool ActorTag(int curX, int curY, HotSpotTag *pTag, OBJECT **ppText) { PlayfieldGetPos(FIELD_WORLD, &tagX, &tagY); LoadStringRes(GetActorTag(ano), TextBufferAddr(), TBUFSZ); *ppText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), - 0, xtext - tagX, ytext - tagY, GetTagFontHandle(), TXT_CENTRE); + 0, xtext - tagX, ytext - tagY, GetTagFontHandle(), TXT_CENTER); assert(*ppText); // Actor tag string produced NULL text MultiSetZPosition(*ppText, Z_TAG_TEXT); } else { @@ -561,7 +563,7 @@ static bool PolyTag(HotSpotTag *pTag, OBJECT **ppText) { *ppText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0, tagx - Loffset, tagy - Toffset, - GetTagFontHandle(), TXT_CENTRE, 0); + GetTagFontHandle(), TXT_CENTER, 0); } else if (TinselV2) { // Bugger cursor const char *tagPtr = TextBufferAddr(); @@ -570,12 +572,12 @@ static bool PolyTag(HotSpotTag *pTag, OBJECT **ppText) { GetCursorXYNoWait(&curX, &curY, false); *ppText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), - 0, curX, curY, GetTagFontHandle(), TXT_CENTRE, 0); + 0, curX, curY, GetTagFontHandle(), TXT_CENTER, 0); } else { // Handle displaying the tag text on-screen *ppText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0, tagx - Loffset, tagy - Toffset, - GetTagFontHandle(), TXT_CENTRE); + GetTagFontHandle(), TXT_CENTER); assert(*ppText); // Polygon tag string produced NULL text } diff --git a/engines/tinsel/pid.h b/engines/tinsel/pid.h index 786ccc6327..d6f87bdf98 100644 --- a/engines/tinsel/pid.h +++ b/engines/tinsel/pid.h @@ -32,11 +32,11 @@ namespace Tinsel { #define PID_DESTROY 0x8000 // process id of any process that is to be destroyed between scenes #define PID_EFFECTS (0x0010 | PID_DESTROY) // generic special effects process id -#define PID_FLASH (PID_EFFECTS + 1) // flash colour process -#define PID_CYCLE (PID_EFFECTS + 2) // cycle colour range process +#define PID_FLASH (PID_EFFECTS + 1) // flash color process +#define PID_CYCLE (PID_EFFECTS + 2) // cycle color range process #define PID_MORPH (PID_EFFECTS + 3) // morph process #define PID_FADER (PID_EFFECTS + 4) // fader process -#define PID_FADE_BGND (PID_EFFECTS + 5) // fade background colour process +#define PID_FADE_BGND (PID_EFFECTS + 5) // fade background color process #define PID_BACKGND (0x0020 | PID_DESTROY) // background update process id diff --git a/engines/tinsel/polygons.cpp b/engines/tinsel/polygons.cpp index 1620881b01..f49dddeef4 100644 --- a/engines/tinsel/polygons.cpp +++ b/engines/tinsel/polygons.cpp @@ -34,6 +34,7 @@ #include "tinsel/tinsel.h" #include "tinsel/token.h" +#include "common/textconsole.h" #include "common/util.h" namespace Tinsel { @@ -98,10 +99,10 @@ struct POLYGON { /* * Internal derived data for speed and conveniance - * set up by PseudoCentre() + * set up by PseudoCenter() */ - int pcentrex; // Pseudo-centre - int pcentrey; // + int pcenterx; // Pseudo-center + int pcentery; // /** * List of adjacent polygons. For Path polygons only. @@ -1624,34 +1625,34 @@ static PPOLYGON CommonInits(PTYPE polyType, int pno, const Poly &ptp, bool bRest } /** - * Calculate a point approximating to the centre of a polygon. + * Calculate a point approximating to the center of a polygon. * Not very sophisticated. */ -static void PseudoCentre(POLYGON *p) { - p->pcentrex = (p->cx[0] + p->cx[1] + p->cx[2] + p->cx[3])/4; - p->pcentrey = (p->cy[0] + p->cy[1] + p->cy[2] + p->cy[3])/4; +static void PseudoCenter(POLYGON *p) { + p->pcenterx = (p->cx[0] + p->cx[1] + p->cx[2] + p->cx[3])/4; + p->pcentery = (p->cy[0] + p->cy[1] + p->cy[2] + p->cy[3])/4; - if (!IsInPolygon(p->pcentrex, p->pcentrey, PolygonIndex(p))) { + if (!IsInPolygon(p->pcenterx, p->pcentery, PolygonIndex(p))) { int i, top = 0, bot = 0; for (i = p->ptop; i <= p->pbottom; i++) { - if (IsInPolygon(p->pcentrex, i, PolygonIndex(p))) { + if (IsInPolygon(p->pcenterx, i, PolygonIndex(p))) { top = i; break; } } for (i = p->pbottom; i >= p->ptop; i--) { - if (IsInPolygon(p->pcentrex, i, PolygonIndex(p))) { + if (IsInPolygon(p->pcenterx, i, PolygonIndex(p))) { bot = i; break; } } - p->pcentrex = (top+bot)/2; + p->pcenterx = (top+bot)/2; } #ifdef DEBUG - // assert(IsInPolygon(p->pcentrex, p->pcentrey, PolygonIndex(p))); // Pseudo-centre is not in path - if (!IsInPolygon(p->pcentrex, p->pcentrey, PolygonIndex(p))) { - sprintf(TextBufferAddr(), "Pseudo-centre is not in path (starting (%d, %d)) - polygon reversed?", + // assert(IsInPolygon(p->pcenterx, p->pcentery, PolygonIndex(p))); // Pseudo-center is not in path + if (!IsInPolygon(p->pcenterx, p->pcentery, PolygonIndex(p))) { + sprintf(TextBufferAddr(), "Pseudo-center is not in path (starting (%d, %d)) - polygon reversed?", p->cx[0], p->cy[0]); error(TextBufferAddr()); } @@ -1673,7 +1674,7 @@ static void InitPath(const Poly &ptp, bool NodePath, int pno, bool bRestart) { p->subtype = NodePath ? NODE : NORMAL; - PseudoCentre(p); + PseudoCenter(p); } @@ -1918,16 +1919,16 @@ int PolySubtype(HPOLYGON hp) { return Polys[hp]->subtype; } -int PolyCentreX(HPOLYGON hp) { +int PolyCenterX(HPOLYGON hp) { CHECK_HP(hp, "Out of range polygon handle (27)"); - return Polys[hp]->pcentrex; + return Polys[hp]->pcenterx; } -int PolyCentreY(HPOLYGON hp) { +int PolyCenterY(HPOLYGON hp) { CHECK_HP(hp, "Out of range polygon handle (28)"); - return Polys[hp]->pcentrey; + return Polys[hp]->pcentery; } int PolyCornerX(HPOLYGON hp, int n) { diff --git a/engines/tinsel/polygons.h b/engines/tinsel/polygons.h index 4be1dabf98..cf8f9e98c2 100644 --- a/engines/tinsel/polygons.h +++ b/engines/tinsel/polygons.h @@ -127,8 +127,8 @@ void RestorePolygonStuff(POLY_VOLATILE *sps); PTYPE PolyType(HPOLYGON hp); // ->type int PolySubtype(HPOLYGON hp); // ->subtype -int PolyCentreX(HPOLYGON hp); // ->pcentrex -int PolyCentreY(HPOLYGON hp); // ->pcentrey +int PolyCenterX(HPOLYGON hp); // ->pcenterx +int PolyCenterY(HPOLYGON hp); // ->pcentery int PolyCornerX(HPOLYGON hp, int n); // ->cx[n] int PolyCornerY(HPOLYGON hp, int n); // ->cy[n] PSTATE PolyPointState(HPOLYGON hp); // ->pointState diff --git a/engines/tinsel/rince.cpp b/engines/tinsel/rince.cpp index 6ea1dd7464..38ac0a2ce6 100644 --- a/engines/tinsel/rince.cpp +++ b/engines/tinsel/rince.cpp @@ -47,6 +47,7 @@ #include "tinsel/tinsel.h" #include "tinsel/token.h" +#include "common/textconsole.h" #include "common/util.h" namespace Tinsel { @@ -60,8 +61,8 @@ static MOVER Movers[MAX_MOVERS]; // FIXME: Avoid non-const global vars /** * Called from ActorPalette(), normally once just after the beginning of time. */ -void StoreMoverPalette(PMOVER pMover, int startColour, int length) { - pMover->startColour = startColour; +void StoreMoverPalette(PMOVER pMover, int startColor, int length) { + pMover->startColor = startColor; pMover->paletteLength = length; } @@ -88,7 +89,7 @@ static void CheckBrightness(PMOVER pMover) { pMover->brightness--; // ramp down DimPartPalette(BgPal(), - pMover->startColour, + pMover->startColor, pMover->paletteLength, pMover->brightness); } @@ -107,7 +108,7 @@ void MoverBrightness(PMOVER pMover, int brightness) { assert(BgPal()); // Do it all immediately - DimPartPalette(BgPal(), pMover->startColour, pMover->paletteLength, brightness); + DimPartPalette(BgPal(), pMover->startColor, pMover->paletteLength, brightness); // The actor is probably hidden at this point, pMover->brightness = brightness; @@ -924,7 +925,7 @@ void SaveMovers(SAVED_MOVER *sMoverInfo) { if (TinselV2) { sMoverInfo[i].bHidden = Movers[i].bHidden; sMoverInfo[i].brightness = Movers[i].brightness; - sMoverInfo[i].startColour = Movers[i].startColour; + sMoverInfo[i].startColor = Movers[i].startColor; sMoverInfo[i].paletteLength = Movers[i].paletteLength; } diff --git a/engines/tinsel/rince.h b/engines/tinsel/rince.h index 57eac00fa4..5d09a1e945 100644 --- a/engines/tinsel/rince.h +++ b/engines/tinsel/rince.h @@ -38,7 +38,7 @@ struct PROCESS; enum NPS {NOT_IN, GOING_UP, GOING_DOWN, LEAVING, ENTERING}; -enum IND {NO_PROB, TRY_CENTRE, TRY_CORNER, TRY_NEXTCORNER}; +enum IND {NO_PROB, TRY_CENTER, TRY_CORNER, TRY_NEXTCORNER}; enum DIRECTION { LEFTREEL, RIGHTREEL, FORWARD, AWAY }; @@ -119,7 +119,7 @@ struct MOVER { int32 zOverride; bool bHidden; int brightness; // Current brightness - int startColour; + int startColor; int paletteLength; HPOLYGON hRpath; // Recent path }; @@ -140,7 +140,7 @@ void MoverProcessCreate(int X, int Y, int id, PMOVER pMover); enum AR_FUNCTION { AR_NORMAL, AR_PUSHREEL, AR_POPREEL, AR_WALKREEL }; -void StoreMoverPalette(PMOVER pMover, int startColour, int length); +void StoreMoverPalette(PMOVER pMover, int startColor, int length); void MoverBrightness(PMOVER pMover, int brightness); @@ -204,7 +204,7 @@ struct SAVED_MOVER { bool bActive; bool bHidden; int brightness; - int startColour; + int startColor; int paletteLength; }; diff --git a/engines/tinsel/saveload.cpp b/engines/tinsel/saveload.cpp index c965666e84..b6935d41ab 100644 --- a/engines/tinsel/saveload.cpp +++ b/engines/tinsel/saveload.cpp @@ -36,6 +36,7 @@ #include "common/serializer.h" #include "common/savefile.h" +#include "common/textconsole.h" #include "gui/message.h" @@ -77,9 +78,6 @@ SRSTATE SRstate = SR_IDLE; // in DOS_DW.C extern void syncSCdata(Common::Serializer &s); -// in DOS_MAIN.C -//char HardDriveLetter(); - // in PCODE.C extern void syncGlobInfo(Common::Serializer &s); @@ -186,7 +184,7 @@ static void syncSavedMover(Common::Serializer &s, SAVED_MOVER &sm) { s.syncAsByte(sm.bHidden); s.syncAsSint32LE(sm.brightness); - s.syncAsSint32LE(sm.startColour); + s.syncAsSint32LE(sm.startColor); s.syncAsSint32LE(sm.paletteLength); } } @@ -283,32 +281,6 @@ static void syncSavedData(Common::Serializer &s, SAVED_DATA &sd) { } } - -/** - * Called when saving a game to a new file. - * Generates a new, unique, filename. - */ -static char *NewName() { - static char result[FNAMELEN]; // FIXME: Avoid non-const global vars - int i; - int ano = 1; // Allocated number - - while (1) { - Common::String fname = _vm->getSavegameFilename(ano); - strcpy(result, fname.c_str()); - - for (i = 0; i < numSfiles; i++) - if (!strcmp(savedFiles[i].name, result)) - break; - - if (i == numSfiles) - break; - ano++; - } - - return result; -} - /** * Compare two TimeDate structs to see which one was earlier. * Returns 0 if they are equal, a negative value if a is lower / first, and @@ -498,19 +470,37 @@ static bool DoRestore() { */ static void DoSave() { Common::OutSaveFile *f; - const char *fname; + char tmpName[FNAMELEN]; // Next getList() must do its stuff again NeedLoad = true; - if (SaveSceneName == NULL) - SaveSceneName = NewName(); + if (SaveSceneName == NULL) { + // Generate a new unique save name + int i; + int ano = 1; // Allocated number + + while (1) { + Common::String fname = _vm->getSavegameFilename(ano); + strcpy(tmpName, fname.c_str()); + + for (i = 0; i < numSfiles; i++) + if (!strcmp(savedFiles[i].name, tmpName)) + break; + + if (i == numSfiles) + break; + ano++; + } + + SaveSceneName = tmpName; + } + + if (SaveSceneDesc[0] == 0) SaveSceneDesc = "unnamed"; - fname = SaveSceneName; - - f = _vm->getSaveFileMan()->openForSaving(fname); + f = _vm->getSaveFileMan()->openForSaving(SaveSceneName); Common::Serializer s(0, f); if (f == NULL) @@ -537,12 +527,14 @@ static void DoSave() { f->finalize(); delete f; + SaveSceneName = NULL; // Invalidate save name return; save_failure: if (f) { delete f; - _vm->getSaveFileMan()->removeSavefile(fname); + _vm->getSaveFileMan()->removeSavefile(SaveSceneName); + SaveSceneName = NULL; // Invalidate save name } GUI::MessageDialog dialog("Failed to save game state to file."); dialog.runModal(); diff --git a/engines/tinsel/savescn.cpp b/engines/tinsel/savescn.cpp index a3fe393b79..aa359d281f 100644 --- a/engines/tinsel/savescn.cpp +++ b/engines/tinsel/savescn.cpp @@ -48,6 +48,8 @@ #include "tinsel/tinlib.h" #include "tinsel/token.h" +#include "common/textconsole.h" + namespace Tinsel { //----------------- EXTERN FUNCTIONS -------------------- @@ -226,7 +228,7 @@ static void SortMAProcess(CORO_PARAM, const void *) { } ActorPalette(rsd->SavedMoverInfo[_ctx->i].actorID, - rsd->SavedMoverInfo[_ctx->i].startColour, rsd->SavedMoverInfo[_ctx->i].paletteLength); + rsd->SavedMoverInfo[_ctx->i].startColor, rsd->SavedMoverInfo[_ctx->i].paletteLength); if (rsd->SavedMoverInfo[_ctx->i].brightness != BOGUS_BRIGHTNESS) ActorBrightness(rsd->SavedMoverInfo[_ctx->i].actorID, rsd->SavedMoverInfo[_ctx->i].brightness); diff --git a/engines/tinsel/scene.cpp b/engines/tinsel/scene.cpp index 8f0f4771e3..b82bac32cc 100644 --- a/engines/tinsel/scene.cpp +++ b/engines/tinsel/scene.cpp @@ -51,6 +51,7 @@ #include "tinsel/sysvar.h" #include "tinsel/token.h" +#include "common/textconsole.h" namespace Tinsel { @@ -112,15 +113,11 @@ struct ENTRANCE_STRUC { static bool ShowPosition = false; // Set when showpos() has been called #endif -SCNHANDLE newestScene = 0; - int sceneCtr = 0; static int initialMyEscape; static SCNHANDLE SceneHandle = 0; // Current scene handle - stored in case of Save_Scene() -static bool bWatchingOut = false; - SCENE_STRUC tempStruc; struct TP_INIT { @@ -180,9 +177,6 @@ static void SceneTinselProcess(CORO_PARAM, const void *param) { _ctx->myEscape); CORO_INVOKE_1(Interpret, _ctx->pic); - if (_ctx->pInit->event == CLOSEDOWN || _ctx->pInit->event == LEAVE_T2) - bWatchingOut = false; - CORO_END_CODE; } @@ -193,9 +187,6 @@ static void SceneTinselProcess(CORO_PARAM, const void *param) { void SendSceneTinselProcess(TINSEL_EVENT event) { SCENE_STRUC *ss; - if (event == CLOSEDOWN || event == LEAVE_T2) - bWatchingOut = true; - if (SceneHandle != (SCNHANDLE)NULL) { ss = (SCENE_STRUC *) FindChunk(SceneHandle, CHUNK_SCENE); @@ -206,11 +197,8 @@ void SendSceneTinselProcess(TINSEL_EVENT event) { init.hTinselCode = ss->hSceneScript; g_scheduler->createProcess(PID_TCODE, SceneTinselProcess, &init, sizeof(init)); - } else if (event == CLOSEDOWN) - bWatchingOut = false; + } } - else if (event == CLOSEDOWN) - bWatchingOut = false; } @@ -249,9 +237,6 @@ static void LoadScene(SCNHANDLE scene, int entry) { assert(ss != NULL); if (TinselV2) { - // Handle to scene description - newestScene = FROM_LE_32(ss->hSceneDesc); - // Music stuff char *cptr = (char *)FindChunk(scene, CHUNK_MUSIC_FILENAME); assert(cptr); @@ -397,7 +382,7 @@ void PrimeBackground() { // structure for background static const BACKGND backgnd = { - BLACK, // sky colour + BLACK, // sky color Common::Point(0, 0), // initial world pos Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), // scroll limits 0, // no background update process diff --git a/engines/tinsel/sched.cpp b/engines/tinsel/sched.cpp index 427e28826f..37c04abd22 100644 --- a/engines/tinsel/sched.cpp +++ b/engines/tinsel/sched.cpp @@ -30,6 +30,7 @@ #include "tinsel/polygons.h" #include "tinsel/sched.h" +#include "common/textconsole.h" #include "common/util.h" namespace Tinsel { diff --git a/engines/tinsel/scn.cpp b/engines/tinsel/scn.cpp index 17ae7c8687..20d75b6b93 100644 --- a/engines/tinsel/scn.cpp +++ b/engines/tinsel/scn.cpp @@ -24,9 +24,6 @@ * A (some would say very) small collection of utility functions. */ -#include "common/endian.h" -#include "common/util.h" - #include "tinsel/dw.h" #include "tinsel/film.h" #include "tinsel/handle.h" diff --git a/engines/tinsel/sound.cpp b/engines/tinsel/sound.cpp index 5fc2820986..ec42ca5da4 100644 --- a/engines/tinsel/sound.cpp +++ b/engines/tinsel/sound.cpp @@ -26,6 +26,7 @@ #include "tinsel/sound.h" +#include "tinsel/adpcm.h" #include "tinsel/dw.h" #include "tinsel/config.h" #include "tinsel/music.h" @@ -34,9 +35,7 @@ #include "tinsel/sysvar.h" #include "tinsel/background.h" -#include "common/config-manager.h" #include "common/endian.h" -#include "common/file.h" #include "common/memstream.h" #include "common/system.h" @@ -130,13 +129,9 @@ bool SoundManager::playSample(int id, Audio::Mixer::SoundType type, Audio::Sound error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage)); // FIXME: Should set this in a different place ;) - bool mute = false; - if (ConfMan.hasKey("mute")) - mute = ConfMan.getBool("mute"); - - _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, mute ? 0 : _vm->_config->_soundVolume); + _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, _vm->_config->_soundVolume); //_vm->_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, soundVolumeMusic); - _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, mute ? 0 : _vm->_config->_voiceVolume); + _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, _vm->_config->_voiceVolume); Audio::AudioStream *sampleStream = 0; @@ -319,18 +314,14 @@ bool SoundManager::playSample(int id, int sub, bool bLooped, int x, int y, int p #endif break; default: - sampleStream = Audio::makeADPCMStream(compressedStream, DisposeAfterUse::YES, sampleLen, Audio::kADPCMTinsel6, 22050, 1, 24); + sampleStream = new Tinsel6_ADPCMStream(compressedStream, DisposeAfterUse::YES, sampleLen, 22050, 1, 24); break; } // FIXME: Should set this in a different place ;) - bool mute = false; - if (ConfMan.hasKey("mute")) - mute = ConfMan.getBool("mute"); - - _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, mute ? 0 : _vm->_config->_soundVolume); + _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, _vm->_config->_soundVolume); //_vm->_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, soundVolumeMusic); - _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, mute ? 0 : _vm->_config->_voiceVolume); + _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, _vm->_config->_voiceVolume); curChan->sampleNum = id; curChan->subSample = sub; @@ -363,8 +354,8 @@ bool SoundManager::offscreenChecks(int x, int &y) { if (x == -1) return true; - // convert x to offset from screen centre - x -= PlayfieldGetCentreX(FIELD_WORLD); + // convert x to offset from screen center + x -= PlayfieldGetCenterX(FIELD_WORLD); if (x < -SCREEN_WIDTH || x > SCREEN_WIDTH) { // A long way offscreen, ignore it @@ -384,7 +375,7 @@ int8 SoundManager::getPan(int x) { if (x == -1) return 0; - x -= PlayfieldGetCentreX(FIELD_WORLD); + x -= PlayfieldGetCenterX(FIELD_WORLD); if (x == 0) return 0; @@ -530,17 +521,17 @@ void SoundManager::openSampleFiles() { // Detect format of soundfile by looking at 1st sample-index switch (TO_BE_32(_sampleIndex[0])) { - case MKID_BE('MP3 '): + case MKTAG('M','P','3',' '): debugC(DEBUG_DETAILED, kTinselDebugSound, "Detected MP3 sound-data"); _soundMode = kMP3Mode; break; - case MKID_BE('OGG '): + case MKTAG('O','G','G',' '): debugC(DEBUG_DETAILED, kTinselDebugSound, "Detected OGG sound-data"); _soundMode = kVorbisMode; break; - case MKID_BE('FLAC'): + case MKTAG('F','L','A','C'): debugC(DEBUG_DETAILED, kTinselDebugSound, "Detected FLAC sound-data"); _soundMode = kFLACMode; break; diff --git a/engines/tinsel/strres.cpp b/engines/tinsel/strres.cpp index aa303a5391..2dc0e833d1 100644 --- a/engines/tinsel/strres.cpp +++ b/engines/tinsel/strres.cpp @@ -31,6 +31,7 @@ #include "tinsel/scn.h" #include "common/file.h" #include "common/endian.h" +#include "common/textconsole.h" #include "gui/message.h" diff --git a/engines/tinsel/sysvar.cpp b/engines/tinsel/sysvar.cpp index 7003d34feb..ad795fd219 100644 --- a/engines/tinsel/sysvar.cpp +++ b/engines/tinsel/sysvar.cpp @@ -31,6 +31,8 @@ #include "tinsel/sysvar.h" #include "tinsel/tinsel.h" +#include "common/textconsole.h" + namespace Tinsel { // Return for SYS_Platform @@ -77,7 +79,7 @@ static int systemVars[SV_TOPVALID] = { 2, // Speech Delay 2, // Music dim factor - 0, // if set, default actor's text colour gets poked in here + 0, // if set, default actor's text color gets poked in here 0, // user 1 0, // user 2 @@ -103,7 +105,7 @@ static int systemVars[SV_TOPVALID] = { 0, // ISV_GHOST_ACTOR 0, // ISV_GHOST_BASE - 0 // ISV_GHOST_COLOUR + 0 // ISV_GHOST_COLOR }; static SCNHANDLE systemStrings[SS_MAX_VALID]; // FIXME: Avoid non-const global vars diff --git a/engines/tinsel/sysvar.h b/engines/tinsel/sysvar.h index e407e6ffa3..4cdb1364b4 100644 --- a/engines/tinsel/sysvar.h +++ b/engines/tinsel/sysvar.h @@ -60,7 +60,7 @@ typedef enum { SV_DEFAULT_INV, SV_SPEECHDELAY, // Delay 'twixt text/animation and sample SV_MUSICDIMFACTOR, // dimVolume = volume - volume/SV_MDF - SV_TAGCOLOUR, // if set, default actor's text colour gets poked in here + SV_TAGCOLOR, // if set, default actor's text color gets poked in here SV_USER1, SV_USER2, @@ -85,7 +85,7 @@ typedef enum { SV_DEFAULT_INV, ISV_NO_BLOCKING, ISV_GHOST_ACTOR, ISV_GHOST_BASE, - ISV_GHOST_COLOUR, + ISV_GHOST_COLOR, SV_TOPVALID } SYSVARS; diff --git a/engines/tinsel/text.cpp b/engines/tinsel/text.cpp index d2939281eb..3652d6ed3e 100644 --- a/engines/tinsel/text.cpp +++ b/engines/tinsel/text.cpp @@ -78,8 +78,8 @@ int StringLengthPix(char *szStr, const FONT *pFont) { * @param mode Mode flags for the string */ int JustifyText(char *szStr, int xPos, const FONT *pFont, int mode) { - if (mode & TXT_CENTRE) { - // centre justify the text + if (mode & TXT_CENTER) { + // center justify the text // adjust x positioning by half the length of line in pixels xPos -= StringLengthPix(szStr, pFont) / 2; @@ -100,14 +100,14 @@ int JustifyText(char *szStr, int xPos, const FONT *pFont, int mode) { * of the list is returned. * @param pList Object list to add text to * @param szStr String to output - * @param colour Colour for monochrome text + * @param color Color for monochrome text * @param xPos X position of string * @param yPos Y position of string * @param hFont Which font to use * @param mode Mode flags for the string * @param sleepTime Sleep time between each character (if non-zero) */ -OBJECT *ObjectTextOut(OBJECT *pList, char *szStr, int colour, +OBJECT *ObjectTextOut(OBJECT *pList, char *szStr, int color, int xPos, int yPos, SCNHANDLE hFont, int mode, int sleepTime) { int xJustify; // x position of text after justification int yOffset; // offset to next line of text @@ -183,8 +183,8 @@ OBJECT *ObjectTextOut(OBJECT *pList, char *szStr, int colour, if (mode & TXT_ABSOLUTE) pChar->flags |= DMA_ABS; - // set characters colour - only effective for mono fonts - pChar->constant = colour; + // set characters color - only effective for mono fonts + pChar->constant = color; // get Y animation offset GetAniOffset(hImg, pChar->flags, &aniX, &aniY); diff --git a/engines/tinsel/text.h b/engines/tinsel/text.h index a849e286ec..ea804f58d7 100644 --- a/engines/tinsel/text.h +++ b/engines/tinsel/text.h @@ -34,7 +34,7 @@ namespace Tinsel { /** text mode flags - defaults to left justify */ enum { - TXT_CENTRE = 0x0001, ///< centre justify text + TXT_CENTER = 0x0001, ///< center justify text TXT_RIGHT = 0x0002, ///< right justify text TXT_SHADOW = 0x0004, ///< shadow each character TXT_ABSOLUTE = 0x0008 ///< position of text is absolute (only for object text) @@ -72,7 +72,7 @@ struct FONT { struct TEXTOUT { OBJECT *pList; ///< object list to add text to char *szStr; ///< string to output - int colour; ///< colour for monochrome text + int color; ///< color for monochrome text int xPos; ///< x position of string int yPos; ///< y position of string SCNHANDLE hFont; ///< which font to use @@ -91,14 +91,14 @@ struct TEXTOUT { * of the list is returned. * @param pList object list to add text to * @param szStr string to output - * @param colour colour for monochrome text + * @param color color for monochrome text * @param xPos x position of string * @param yPos y position of string * @param hFont which font to use * @param mode mode flags for the string * @param sleepTime Sleep time between each character (if non-zero) */ -OBJECT *ObjectTextOut(OBJECT *pList, char *szStr, int colour, +OBJECT *ObjectTextOut(OBJECT *pList, char *szStr, int color, int xPos, int yPos, SCNHANDLE hFont, int mode, int sleepTime = 0); OBJECT *ObjectTextOutIndirect( // output a string of text diff --git a/engines/tinsel/timers.cpp b/engines/tinsel/timers.cpp index 5f15cd9d3b..c1a4cd0ff5 100644 --- a/engines/tinsel/timers.cpp +++ b/engines/tinsel/timers.cpp @@ -31,7 +31,7 @@ #include "tinsel/timers.h" #include "tinsel/dw.h" #include "common/serializer.h" - +#include "common/textconsole.h" #include "common/system.h" namespace Tinsel { diff --git a/engines/tinsel/timers.h b/engines/tinsel/timers.h index 022604b662..1456d9a1d5 100644 --- a/engines/tinsel/timers.h +++ b/engines/tinsel/timers.h @@ -31,7 +31,7 @@ #include "tinsel/dw.h" namespace Common { - class Serializer; +class Serializer; } namespace Tinsel { diff --git a/engines/tinsel/tinlib.cpp b/engines/tinsel/tinlib.cpp index 40418dcc43..afd409ce27 100644 --- a/engines/tinsel/tinlib.cpp +++ b/engines/tinsel/tinlib.cpp @@ -70,6 +70,7 @@ #include "tinsel/tinsel.h" #include "tinsel/token.h" +#include "common/textconsole.h" namespace Tinsel { @@ -84,7 +85,7 @@ extern bool bNoPause; // In DOS_MAIN.C // TODO/FIXME: From dos_main.c: "Only used on PSX so far" -int clRunMode = 0; +//int clRunMode = 0; //----------------- EXTERNAL FUNCTIONS --------------------- @@ -426,11 +427,11 @@ static void ScrollMonitorProcess(CORO_PARAM, const void *param) { /** * NOT A LIBRARY FUNCTION * - * Poke supplied colour into the DAC queue. + * Poke supplied color into the DAC queue. */ void SetTextPal(COLORREF col) { - SetTalkColourRef(col); - UpdateDACqueue(TalkColour(), col); + SetTalkColorRef(col); + UpdateDACqueue(TalkColor(), col); } /** @@ -522,7 +523,7 @@ void TinGetVersion(WHICH_VER which, char *buffer, int length) { /** * Set actor's attributes. - * - currently only the text colour. + * - currently only the text color. */ static void ActorAttr(int actor, int r1, int g1, int b1) { storeActorAttr(actor, r1, g1, b1); @@ -553,11 +554,11 @@ static int ActorDirection(int actor) { /** * Set actor's palette details for path brightnesses */ -void ActorPalette(int actor, int startColour, int length) { +void ActorPalette(int actor, int startColor, int length) { PMOVER pMover = GetMover(actor); assert(pMover); - StoreMoverPalette(pMover, startColour, length); + StoreMoverPalette(pMover, startColor, length); } /** @@ -568,10 +569,10 @@ static void ActorPriority(int actor, int zFactor) { } /** - * Set actor's text colour. + * Set actor's text color. */ -static void ActorRGB(int actor, COLORREF colour) { - SetActorRGB(actor, colour); +static void ActorRGB(int actor, COLORREF color) { + SetActorRGB(actor, color); } /** @@ -1196,9 +1197,9 @@ static int GetInvLimit(int invno) { /** * Ghost */ -static void Ghost(int actor, int tColour, int tPalOffset) { +static void Ghost(int actor, int tColor, int tPalOffset) { SetSysVar(ISV_GHOST_ACTOR, actor); - SetSysVar(ISV_GHOST_COLOUR, tColour); + SetSysVar(ISV_GHOST_COLOR, tColor); SetSysVar(ISV_GHOST_BASE, tPalOffset); CreateGhostPalette(BgPal()); } @@ -1952,7 +1953,7 @@ static void Print(CORO_PARAM, int x, int y, SCNHANDLE text, int time, bool bSust PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); _ctx->pText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0, x - Loffset, y - Toffset, GetTagFontHandle(), - TXT_CENTRE, 0); + TXT_CENTER, 0); assert(_ctx->pText); // Adjust x, y, or z if necessary @@ -1965,7 +1966,7 @@ static void Print(CORO_PARAM, int x, int y, SCNHANDLE text, int time, bool bSust PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); _ctx->pText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0, x - Loffset, y - Toffset, - TinselV2 ? GetTagFontHandle() : GetTalkFontHandle(), TXT_CENTRE); + TinselV2 ? GetTagFontHandle() : GetTalkFontHandle(), TXT_CENTER); assert(_ctx->pText); // string produced NULL text if (IsTopWindow()) MultiSetZPosition(_ctx->pText, Z_TOPW_TEXT); @@ -2128,7 +2129,7 @@ static void PrintObj(CORO_PARAM, const SCNHANDLE hText, const INV_OBJECT *pinvo, LoadStringRes(hText, TextBufferAddr(), TBUFSZ); _ctx->pText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), - 0, _ctx->textx, _ctx->texty, GetTagFontHandle(), TXT_CENTRE); + 0, _ctx->textx, _ctx->texty, GetTagFontHandle(), TXT_CENTER); assert(_ctx->pText); // PrintObj() string produced NULL text MultiSetZPosition(_ctx->pText, Z_INV_ITEXT); @@ -2181,7 +2182,7 @@ static void PrintObj(CORO_PARAM, const SCNHANDLE hText, const INV_OBJECT *pinvo, LoadStringRes(hText, TextBufferAddr(), TBUFSZ); _ctx->pText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0, _ctx->textx, _ctx->texty, GetTagFontHandle(), - TXT_CENTRE, 0); + TXT_CENTER, 0); assert(_ctx->pText); KeepOnScreen(_ctx->pText, &_ctx->textx, &_ctx->texty); @@ -2297,7 +2298,7 @@ static void PrintObjPointed(CORO_PARAM, const SCNHANDLE text, const INV_OBJECT * // Re-display in the same place LoadStringRes(text, TextBufferAddr(), TBUFSZ); pText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), - 0, textx, texty, GetTagFontHandle(), TXT_CENTRE); + 0, textx, texty, GetTagFontHandle(), TXT_CENTER); assert(pText); // PrintObj() string produced NULL text MultiSetZPosition(pText, Z_INV_ITEXT); } @@ -2490,7 +2491,7 @@ void ResumeLastGame() { * Returns the current run mode */ static int RunMode() { - return clRunMode; + return 0; //clRunMode; } /** @@ -3367,7 +3368,7 @@ static void TalkOrSay(CORO_PARAM, SPEECH_TYPE speechType, SCNHANDLE hText, int x _ctx->pText = ObjectTextOut(GetPlayfieldList(FIELD_STATUS), TextBufferAddr(), 0, _ctx->x - _ctx->Loffset, _ctx->y - _ctx->Toffset, - GetTalkFontHandle(), TXT_CENTRE); + GetTalkFontHandle(), TXT_CENTER); assert(_ctx->pText); // talk() string produced NULL text; if (IsTopWindow()) @@ -3595,12 +3596,12 @@ static void TalkPaletteIndex(unsigned index) { /** * Set talk font's palette entry. */ -static void TalkRGB(COLORREF colour, int myescEvent) { +static void TalkRGB(COLORREF color, int myescEvent) { // Don't do it if it's not wanted if (myescEvent && myescEvent != GetEscEvents()) return; - SetTextPal(colour); + SetTextPal(color); } /** diff --git a/engines/tinsel/tinlib.h b/engines/tinsel/tinlib.h index 11e59f380d..7bd2a19d55 100644 --- a/engines/tinsel/tinlib.h +++ b/engines/tinsel/tinlib.h @@ -48,7 +48,7 @@ void TinGetVersion(WHICH_VER which, char *buffer, int length); // Library functions in TINLIB.C void ActorBrightness(int actor, int brightness); -void ActorPalette(int actor, int startColour, int length); +void ActorPalette(int actor, int startColor, int length); void Control(int param); void HookScene(SCNHANDLE scene, int entrance, int transition); void NewScene(CORO_PARAM, SCNHANDLE scene, int entrance, int transition); diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp index 23335539d1..20d4f1d31a 100644 --- a/engines/tinsel/tinsel.cpp +++ b/engines/tinsel/tinsel.cpp @@ -29,22 +29,14 @@ #include "common/events.h" #include "common/EventRecorder.h" #include "common/keyboard.h" -#include "common/file.h" #include "common/fs.h" -#include "common/savefile.h" #include "common/config-manager.h" #include "common/serializer.h" -#include "common/stream.h" #include "backends/audiocd/audiocd.h" #include "engines/util.h" -#include "graphics/cursorman.h" - -#include "base/plugins.h" -#include "base/version.h" - #include "tinsel/actors.h" #include "tinsel/background.h" #include "tinsel/bmv.h" @@ -218,14 +210,17 @@ void KeyboardProcess(CORO_PARAM, const void *) { continue; #endif + case Common::KEYCODE_1: case Common::KEYCODE_F1: // Options dialog ProcessKeyEvent(PLR_MENU); continue; + case Common::KEYCODE_5: case Common::KEYCODE_F5: // Save game ProcessKeyEvent(PLR_SAVE); continue; + case Common::KEYCODE_7: case Common::KEYCODE_F7: // Load game ProcessKeyEvent(PLR_LOAD); @@ -856,25 +851,8 @@ TinselEngine::TinselEngine(OSystem *syst, const TinselGameDescription *gameDesc) if (cd_num >= 0) _system->getAudioCDManager()->openCD(cd_num); - MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB | MDT_PREFER_GM); - bool native_mt32 = ((MidiDriver::getMusicType(dev) == MT_MT32) || ConfMan.getBool("native_mt32")); - //bool adlib = (MidiDriver::getMusicType(dev) == MT_ADLIB); - - _driver = MidiDriver::createMidi(dev); - if (native_mt32) - _driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE); - - _midiMusic = new MidiMusicPlayer(_driver); + _midiMusic = new MidiMusicPlayer(); _pcmMusic = new PCMMusicPlayer(); - //_midiMusic->setNativeMT32(native_mt32); - //_midiMusic->setAdLib(adlib); - - if (native_mt32) - _driver->sendMT32Reset(); - else - _driver->sendGMReset(); - - _musicVolume = ConfMan.getInt("music_volume"); _sound = new SoundManager(this); @@ -896,7 +874,6 @@ TinselEngine::~TinselEngine() { delete _midiMusic; delete _pcmMusic; delete _console; - delete _driver; _screenSurface.free(); FreeSaveScenes(); FreeTextBuffer(); @@ -926,10 +903,10 @@ Common::Error TinselEngine::run() { #else initGraphics(640, 432, true); #endif - _screenSurface.create(640, 432, 1); + _screenSurface.create(640, 432, Graphics::PixelFormat::createFormatCLUT8()); } else { initGraphics(320, 200, false); - _screenSurface.create(320, 200, 1); + _screenSurface.create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); } g_eventRec.registerRandomSource(_random, "tinsel"); @@ -987,7 +964,7 @@ Common::Error TinselEngine::run() { // errors when loading the save state. if (ConfMan.hasKey("save_slot")) { - if (loadGameState(ConfMan.getInt("save_slot")) == Common::kNoError) + if (loadGameState(ConfMan.getInt("save_slot")).getCode() == Common::kNoError) loadingFromGMM = true; } diff --git a/engines/tinsel/tinsel.h b/engines/tinsel/tinsel.h index 009f6fe26d..35ea43074c 100644 --- a/engines/tinsel/tinsel.h +++ b/engines/tinsel/tinsel.h @@ -125,8 +125,8 @@ typedef bool (*KEYFPTR)(const Common::KeyState &); #define SCREEN_WIDTH (_vm->screen().w) // PC screen dimensions #define SCREEN_HEIGHT (_vm->screen().h) -#define SCRN_CENTRE_X ((SCREEN_WIDTH - 1) / 2) // screen centre x -#define SCRN_CENTRE_Y ((SCREEN_HEIGHT - 1) / 2) // screen centre y +#define SCRN_CENTER_X ((SCREEN_WIDTH - 1) / 2) // screen center x +#define SCRN_CENTER_Y ((SCREEN_HEIGHT - 1) / 2) // screen center y #define UNUSED_LINES 48 #define EXTRA_UNUSED_LINES 3 //#define SCREEN_BOX_HEIGHT1 (SCREEN_HEIGHT - UNUSED_LINES) @@ -219,9 +219,6 @@ public: RectList _clipRects; private: - //MidiMusicPlayer *_midiMusic; - int _musicVolume; - void NextGameCycle(); void CreateConstProcesses(); void RestartGame(); |