aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStrangerke2016-09-07 21:09:35 +0200
committerStrangerke2016-09-07 21:09:35 +0200
commit878ae1a88253677d1bdd30efe74134c571e9623b (patch)
treed78541254c8b0f67b04ed99f88d7cf7a72b00266
parent4414995c29a8de9228346f948f8d6bea5a099ecb (diff)
downloadscummvm-rg350-878ae1a88253677d1bdd30efe74134c571e9623b.tar.gz
scummvm-rg350-878ae1a88253677d1bdd30efe74134c571e9623b.tar.bz2
scummvm-rg350-878ae1a88253677d1bdd30efe74134c571e9623b.zip
DM: More renaming and refactoring
-rw-r--r--engines/dm/sounds.cpp77
-rw-r--r--engines/dm/sounds.h6
-rw-r--r--engines/dm/text.cpp102
-rw-r--r--engines/dm/text.h3
4 files changed, 87 insertions, 101 deletions
diff --git a/engines/dm/sounds.cpp b/engines/dm/sounds.cpp
index 9affc78d4d..bcc333c7b0 100644
--- a/engines/dm/sounds.cpp
+++ b/engines/dm/sounds.cpp
@@ -36,10 +36,9 @@
#include "dm/dungeonman.h"
#include "dm/sounds.h"
-
namespace DM {
-SoundMan* SoundMan::getSoundMan(DMEngine* vm, const DMADGameDescription* gameVersion) {
+SoundMan *SoundMan::getSoundMan(DMEngine *vm, const DMADGameDescription *gameVersion) {
switch (gameVersion->_desc.platform) {
default:
warning("Unknown platform, using default Amiga SoundMan");
@@ -92,7 +91,7 @@ void SoundMan::initConstants() {
_sounds[i] = sounds[i];
}
-SoundMan::SoundMan(DMEngine* vm) : _vm(vm) {
+SoundMan::SoundMan(DMEngine *vm) : _vm(vm) {
initConstants();
}
@@ -132,8 +131,8 @@ void SoundMan::playPendingSound() {
}
}
-bool SoundMan::soundGetVolume(int16 mapX, int16 mapY, uint8* leftVolume, uint8* rightVolume) {
- static byte K0030_aauc_DistanceToSoundVolume[25][25] = {
+bool SoundMan::soundGetVolume(int16 mapX, int16 mapY, uint8 *leftVolume, uint8 *rightVolume) {
+ static byte distanceToSoundVolume[25][25] = {
{1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4},
{1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 5, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 4, 4, 4},
{1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 4, 5, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4},
@@ -160,66 +159,63 @@ bool SoundMan::soundGetVolume(int16 mapX, int16 mapY, uint8* leftVolume, uint8*
{1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3},
{1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3}};
- int16 L1678_i_RightVolumeColumnIndex = 0;
- int16 L1679_i_LineIndex = 0;
- int16 L1680_i_LeftVolumeColumnIndex = 0;
-
+ int16 lineIndex = 0;
+ int16 rightVolumeColumnIndex = 0;
switch (_vm->_dungeonMan->_partyDir) {
case kDirNorth:
- L1678_i_RightVolumeColumnIndex = mapX - _vm->_dungeonMan->_partyMapX;
- L1679_i_LineIndex = mapY - _vm->_dungeonMan->_partyMapY;
+ rightVolumeColumnIndex = mapX - _vm->_dungeonMan->_partyMapX;
+ lineIndex = mapY - _vm->_dungeonMan->_partyMapY;
break;
case kDirEast:
- L1678_i_RightVolumeColumnIndex = mapY - _vm->_dungeonMan->_partyMapY;
- L1679_i_LineIndex = -(mapX - _vm->_dungeonMan->_partyMapX);
+ rightVolumeColumnIndex = mapY - _vm->_dungeonMan->_partyMapY;
+ lineIndex = -(mapX - _vm->_dungeonMan->_partyMapX);
break;
case kDirSouth:
- L1678_i_RightVolumeColumnIndex = -(mapX - _vm->_dungeonMan->_partyMapX);
- L1679_i_LineIndex = -(mapY - _vm->_dungeonMan->_partyMapY);
+ rightVolumeColumnIndex = -(mapX - _vm->_dungeonMan->_partyMapX);
+ lineIndex = -(mapY - _vm->_dungeonMan->_partyMapY);
break;
case kDirWest:
- L1678_i_RightVolumeColumnIndex = -(mapY - _vm->_dungeonMan->_partyMapY);
- L1679_i_LineIndex = mapX - _vm->_dungeonMan->_partyMapX;
+ rightVolumeColumnIndex = -(mapY - _vm->_dungeonMan->_partyMapY);
+ lineIndex = mapX - _vm->_dungeonMan->_partyMapX;
break;
}
- if ((L1678_i_RightVolumeColumnIndex < -12) || (L1678_i_RightVolumeColumnIndex > 12)) { /* Sound is not audible if source is more than 12 squares away from the party */
+
+ if ((rightVolumeColumnIndex < -12) || (rightVolumeColumnIndex > 12)) /* Sound is not audible if source is more than 12 squares away from the party */
return false;
- }
- if ((L1679_i_LineIndex < -12) || (L1679_i_LineIndex > 12)) { /* Sound is not audible if source is more than 12 squares away from the party */
+
+ if ((lineIndex < -12) || (lineIndex > 12)) /* Sound is not audible if source is more than 12 squares away from the party */
return false;
- }
- L1680_i_LeftVolumeColumnIndex = -L1678_i_RightVolumeColumnIndex + 12;
- L1678_i_RightVolumeColumnIndex += 12;
- L1679_i_LineIndex += 12;
- *rightVolume = K0030_aauc_DistanceToSoundVolume[L1679_i_LineIndex][L1678_i_RightVolumeColumnIndex];
- *leftVolume = K0030_aauc_DistanceToSoundVolume[L1679_i_LineIndex][L1680_i_LeftVolumeColumnIndex];
+
+ int16 leftVolumeColumnIndex = -rightVolumeColumnIndex + 12;
+ rightVolumeColumnIndex += 12;
+ lineIndex += 12;
+ *rightVolume = distanceToSoundVolume[lineIndex][rightVolumeColumnIndex];
+ *leftVolume = distanceToSoundVolume[lineIndex][leftVolumeColumnIndex];
return true;
}
void SoundMan::requestPlay(uint16 soundIndex, int16 mapX, int16 mapY, uint16 mode) {
- Sound* sound;
- uint8 leftVolume, rightVolume;
-
if (mode && (_vm->_dungeonMan->_currMapIndex != _vm->_dungeonMan->_partyMapIndex))
return;
- sound = &_sounds[soundIndex];
+ Sound *sound = &_sounds[soundIndex];
if (mode > k1_soundModePlayIfPrioritized) { /* Add an event in the timeline to play the sound (mode - 1) ticks later */
- TimelineEvent event;
- setMapAndTime(event._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime + mode - 1);
- event._type = k20_TMEventTypePlaySound;
- event._priority = sound->_priority;
- event._C._soundIndex = soundIndex;
- event._B._location._mapX = mapX;
- event._B._location._mapY = mapY;
- _vm->_timeline->addEventGetEventIndex(&event);
+ TimelineEvent newEvent;
+ setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime + mode - 1);
+ newEvent._type = k20_TMEventTypePlaySound;
+ newEvent._priority = sound->_priority;
+ newEvent._C._soundIndex = soundIndex;
+ newEvent._B._location._mapX = mapX;
+ newEvent._B._location._mapY = mapY;
+ _vm->_timeline->addEventGetEventIndex(&newEvent);
return;
}
- if (!soundGetVolume(mapX, mapY, &leftVolume, &rightVolume)) {
+ uint8 leftVolume, rightVolume;
+ if (!soundGetVolume(mapX, mapY, &leftVolume, &rightVolume))
return;
- }
+
if (!mode) { /* Play the sound immediately */
play(soundIndex, sound->_period, leftVolume, rightVolume);
return;
@@ -227,5 +223,4 @@ void SoundMan::requestPlay(uint16 soundIndex, int16 mapX, int16 mapY, uint16 mod
_pendingSounds.push(PendingSound(leftVolume, rightVolume, soundIndex));
}
-
}
diff --git a/engines/dm/sounds.h b/engines/dm/sounds.h
index f50d481307..fc9561a0c8 100644
--- a/engines/dm/sounds.h
+++ b/engines/dm/sounds.h
@@ -37,7 +37,7 @@ namespace DM {
class SoundData {
public:
uint32 _byteCount;
- byte* _firstSample;
+ byte *_firstSample;
uint32 _sampleCount;
SoundData() : _byteCount(0), _firstSample(nullptr), _sampleCount(0) {}
}; // @ SOUND_DATA
@@ -67,7 +67,7 @@ class SoundMan {
DMEngine *_vm;
protected:
- SoundMan(DMEngine* vm);
+ SoundMan(DMEngine *vm);
public:
virtual ~SoundMan();
@@ -89,7 +89,7 @@ public:
class SoundMan_Atari: public SoundMan {
friend class SoundMan;
- SoundMan_Atari(DMEngine* vm): SoundMan(vm) {};
+ SoundMan_Atari(DMEngine *vm): SoundMan(vm) {};
public:
void loadSounds() override {} // @ F0503_SOUND_LoadAll
void requestPlay(uint16 P0088_ui_SoundIndex, int16 P0089_i_MapX, int16 P0090_i_MapY, uint16 P0091_ui_Mode) override {} // @ F0064_SOUND_RequestPlay_CPSD
diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp
index 52e83d1db2..00049bb878 100644
--- a/engines/dm/text.cpp
+++ b/engines/dm/text.cpp
@@ -31,11 +31,12 @@
namespace DM {
-TextMan::TextMan(DMEngine* vm) : _vm(vm) {
+TextMan::TextMan(DMEngine *vm) : _vm(vm) {
_messageAreaCursorColumn = 0;
_messageAreaCursorRow = 0;
for (uint16 i = 0; i < 4; ++i)
_messageAreaRowExpirationTime[i] = 0;
+
_bitmapMessageAreaNewRow = new byte[320 * 7];
_isScrolling = false;
_startedScrollingAt = -1;
@@ -47,11 +48,8 @@ TextMan::~TextMan() {
delete[] _messageAreaCopy;
}
-#define k5_LetterWidth 5
-#define k6_LetterHeight 6
-
-void TextMan::printTextToBitmap(byte* destBitmap, uint16 destByteWidth, int16 destX, int16 destY,
- Color textColor, Color bgColor, const char* text, uint16 destHeight) {
+void TextMan::printTextToBitmap(byte *destBitmap, uint16 destByteWidth, int16 destX, int16 destY,
+ Color textColor, Color bgColor, const char *text, uint16 destHeight) {
if ((destX -= 1) < 0) // fixes missalignment, to be checked
destX = 0;
if ((destY -= 4) < 0) // fixes missalignment, to be checked
@@ -65,9 +63,9 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destByteWidth, int16 de
byte *srcBitmap = _vm->_displayMan->getNativeBitmapOrGraphic(k557_FontGraphicIndice);
byte *tmp = _vm->_displayMan->_tmpBitmap;
- for (uint16 i = 0; i < (k5_LetterWidth + 1) * k6_LetterHeight * 128; ++i) {
+ for (uint16 i = 0; i < (k5_LetterWidth + 1) * k6_LetterHeight * 128; ++i)
tmp[i] = srcBitmap[i] ? textColor : bgColor;
- }
+
srcBitmap = tmp;
for (const char *begin = text, *end = text + textLength; begin != end; ++begin) {
@@ -77,6 +75,7 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destByteWidth, int16 de
}
if (nextY + k6_LetterHeight >= destHeight)
break;
+
uint16 srcX = (1 + 5) * *begin; // 1 + 5 is not the letter width, arbitrary choice of the unpacking code
Box box((nextX == destX) ? (nextX + 1) : nextX, nextX + k5_LetterWidth + 1, nextY, nextY + k6_LetterHeight - 1);
@@ -87,16 +86,16 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destByteWidth, int16 de
}
}
-void TextMan::printToLogicalScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char* text) {
+void TextMan::printToLogicalScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char *text) {
printTextToBitmap(_vm->_displayMan->_bitmapScreen, _vm->_displayMan->_screenWidth / 2, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight);
}
-void TextMan::printToViewport(int16 posX, int16 posY, Color textColor, const char* text, Color bgColor) {
+void TextMan::printToViewport(int16 posX, int16 posY, Color textColor, const char *text, Color bgColor) {
printTextToBitmap(_vm->_displayMan->_bitmapViewport, k112_byteWidthViewport, posX, posY, textColor, bgColor, text, k136_heightViewport);
}
-void TextMan::printWithTrailingSpaces(byte* destBitmap, int16 destByteWidth, int16 destX, int16 destY, Color textColor,
- Color bgColor, const char* text, int16 requiredTextLength, int16 destHeight) {
+void TextMan::printWithTrailingSpaces(byte *destBitmap, int16 destByteWidth, int16 destX, int16 destY, Color textColor,
+ Color bgColor, const char *text, int16 requiredTextLength, int16 destHeight) {
Common::String str = text;
for (int16 i = str.size(); i < requiredTextLength; ++i)
str += ' ';
@@ -107,10 +106,9 @@ void TextMan::printLineFeed() {
printMessage(k0_ColorBlack, "\n");
}
-void TextMan::printMessage(Color color, const char* string, bool printWithScroll) {
- uint16 L0031_ui_CharacterIndex;
- char L0033_ac_String[54];
-
+void TextMan::printMessage(Color color, const char *string, bool printWithScroll) {
+ uint16 characterIndex;
+ Common::String wrkString;
while (*string) {
if (*string == '\n') { /* New line */
@@ -119,59 +117,53 @@ void TextMan::printMessage(Color color, const char* string, bool printWithScroll
_messageAreaCursorColumn = 0;
createNewRow();
}
+ } else if (*string == ' ') {
+ string++;
+ if (_messageAreaCursorColumn != 53) {
+ printString(color, " "); // I'm not sure if this is like the original
+ }
} else {
- if (*string == ' ') {
- string++;
- if (_messageAreaCursorColumn != 53) {
- printString(color, " "); // I'm not sure if this is like the original
- }
- } else {
- L0031_ui_CharacterIndex = 0;
- do {
- L0033_ac_String[L0031_ui_CharacterIndex++] = *string++;
- } while (*string && (*string != ' ') && (*string != '\n')); /* End of string, space or New line */
- L0033_ac_String[L0031_ui_CharacterIndex] = '\0';
- if (_messageAreaCursorColumn + L0031_ui_CharacterIndex > 53) {
- _messageAreaCursorColumn = 2;
- createNewRow();
- }
- printString(color, L0033_ac_String);
+ characterIndex = 0;
+ do {
+ wrkString += *string++;
+ characterIndex++;
+ } while (*string && (*string != ' ') && (*string != '\n')); /* End of string, space or New line */
+ wrkString += '\0';
+ if (_messageAreaCursorColumn + characterIndex > 53) {
+ _messageAreaCursorColumn = 2;
+ createNewRow();
}
+ printString(color, wrkString.c_str());
}
}
}
void TextMan::createNewRow() {
- uint16 L0029_ui_RowIndex;
-
if (_messageAreaCursorRow == 3) {
isTextScrolling(&_textScroller, true);
memset(_bitmapMessageAreaNewRow, k0_ColorBlack, 320 * 7);
_isScrolling = true;
setScrollerCommand(&_textScroller, 1);
- for (L0029_ui_RowIndex = 0; L0029_ui_RowIndex < 3; L0029_ui_RowIndex++) {
- _messageAreaRowExpirationTime[L0029_ui_RowIndex] = _messageAreaRowExpirationTime[L0029_ui_RowIndex + 1];
- }
+ for (uint16 rowIndex = 0; rowIndex < 3; rowIndex++)
+ _messageAreaRowExpirationTime[rowIndex] = _messageAreaRowExpirationTime[rowIndex + 1];
+
_messageAreaRowExpirationTime[3] = -1;
- } else {
+ } else
_messageAreaCursorRow++;
- }
}
void TextMan::printString(Color color, const char* string) {
- int16 L0030_i_StringLength;
-
- L0030_i_StringLength = strlen(string);
- if (isTextScrolling(&_textScroller, false)) {
+ int16 stringLength = strlen(string);
+ if (isTextScrolling(&_textScroller, false))
printToLogicalScreen(_messageAreaCursorColumn * 6, (_messageAreaCursorRow * 7 - 1) + 177, color, k0_ColorBlack, string);
- } else {
+ else {
printTextToBitmap(_bitmapMessageAreaNewRow, k160_byteWidthScreen, _messageAreaCursorColumn * 6, 0, color, k0_ColorBlack, string, 7);
_isScrolling = true;
if (isTextScrolling(&_textScroller, false))
setScrollerCommand(&_textScroller, 1);
}
- _messageAreaCursorColumn += L0030_i_StringLength;
+ _messageAreaCursorColumn += stringLength;
_messageAreaRowExpirationTime[_messageAreaCursorRow] = _vm->_gameTime + 200;
}
@@ -183,21 +175,17 @@ void TextMan::initialize() {
}
void TextMan::moveCursor(int16 column, int16 row) {
- if (column < 0) {
+ if (column < 0)
column = 0;
- } else {
- if (column >= 53) {
- column = 52;
- }
- }
+ else if (column >= 53)
+ column = 52;
+
_messageAreaCursorColumn = column;
- if (row < 0) {
+ if (row < 0)
row = 0;
- } else {
- if (row >= 4) {
- row = 3;
- }
- }
+ else if (row >= 4)
+ row = 3;
+
_messageAreaCursorRow = row;
}
diff --git a/engines/dm/text.h b/engines/dm/text.h
index 2124834fdb..6a934247d8 100644
--- a/engines/dm/text.h
+++ b/engines/dm/text.h
@@ -37,6 +37,9 @@ struct TextScroller {
// Placeholder, empty for now
}; // @ Text_Scroller
+#define k5_LetterWidth 5
+#define k6_LetterHeight 6
+
class TextMan {
DMEngine *_vm;
int16 _messageAreaCursorColumn; // @ G0359_i_MessageAreaCursorColumn