aboutsummaryrefslogtreecommitdiff
path: root/engines/lab
diff options
context:
space:
mode:
authorStrangerke2015-12-14 12:40:19 +0100
committerWillem Jan Palenstijn2015-12-23 21:34:04 +0100
commit21e6f40301f358e8c16b3ed6ff32698cc5be6e9c (patch)
tree76417c4c4f93f28f74b59dc1c25309053ecdc45f /engines/lab
parentcbf4c876e52300cf1a8d54a166ceed3bebeb3016 (diff)
downloadscummvm-rg350-21e6f40301f358e8c16b3ed6ff32698cc5be6e9c.tar.gz
scummvm-rg350-21e6f40301f358e8c16b3ed6ff32698cc5be6e9c.tar.bz2
scummvm-rg350-21e6f40301f358e8c16b3ed6ff32698cc5be6e9c.zip
LAB: Fix a regression related to random number generation, some renaming
Diffstat (limited to 'engines/lab')
-rw-r--r--engines/lab/dispman.cpp56
-rw-r--r--engines/lab/dispman.h64
-rw-r--r--engines/lab/lab.cpp2
-rw-r--r--engines/lab/lab.h1
-rw-r--r--engines/lab/processroom.cpp2
-rw-r--r--engines/lab/utils.cpp8
-rw-r--r--engines/lab/utils.h11
7 files changed, 75 insertions, 69 deletions
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 9aa1834307..9a3d6869c6 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -48,7 +48,7 @@ DisplayMan::DisplayMan(LabEngine *vm) : _vm(vm) {
_doNotDrawMessage = false;
_screenBytesPerPage = 65536;
- _curapen = 0;
+ _curPen = 0;
_curBitmap = nullptr;
_displayBuffer = nullptr;
_currentDisplayBuffer = nullptr;
@@ -179,7 +179,7 @@ void DisplayMan::getLine(TextFont *tf, char *lineBuffer, const char **mainBuffer
* each line less than 255 characters.
*/
uint32 DisplayMan::flowText(
- void *font, // the TextAttr pointer
+ TextFont *font, // the TextAttr pointer
int16 spacing, // How much vertical spacing between the lines
byte pencolor, // pen number to use for text
byte backpen, // the background color
@@ -200,7 +200,7 @@ uint32 DisplayMan::flowText(
setAPen(pencolor);
- TextFont *msgFont = (TextFont *)font;
+ TextFont *msgFont = font;
uint16 fontheight = textHeight(msgFont) + spacing;
uint16 numlines = (y2 - y1 + 1) / fontheight;
uint16 width = x2 - x1 + 1;
@@ -242,7 +242,7 @@ uint32 DisplayMan::flowText(
}
uint32 DisplayMan::flowTextScaled(
- void *font, // the TextAttr pointer
+ TextFont *font, // the TextAttr pointer
int16 spacing, // How much vertical spacing between the lines
byte penColor, // pen number to use for text
byte backPen, // the background color
@@ -262,7 +262,7 @@ uint32 DisplayMan::flowTextScaled(
* Calls flowText, but flows it to memory. Same restrictions as flowText.
*/
uint32 DisplayMan::flowTextToMem(Image *destIm,
- void *font, // the TextAttr pointer
+ TextFont *font, // the TextAttr pointer
int16 spacing, // How much vertical spacing between the lines
byte pencolor, // pen number to use for text
byte backpen, // the background color
@@ -470,8 +470,8 @@ void DisplayMan::setUpScreens() {
/**
* Sets the pen number to use on all the drawing operations.
*/
-void DisplayMan::setAPen(byte pennum) {
- _curapen = pennum;
+void DisplayMan::setAPen(byte penNum) {
+ _curPen = penNum;
}
/**
@@ -495,7 +495,7 @@ void DisplayMan::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
int ww = w;
while (ww-- > 0) {
- *dd++ = _curapen;
+ *dd++ = _curPen;
}
d += _screenWidth;
@@ -567,7 +567,7 @@ void DisplayMan::setAmigaPal(uint16 *pal, uint16 numColors) {
/**
* Writes any number of the 256 color registers.
* first: the number of the first color register to write.
- * numreg: the number of registers to write
+ * numReg: the number of registers to write
* buf: a char pointer which contains the selected color registers.
* Each value representing a color register occupies 3 bytes in
* the array. The order is red, green then blue. The first byte
@@ -575,21 +575,19 @@ void DisplayMan::setAmigaPal(uint16 *pal, uint16 numColors) {
* The length of the buffer is 3 times the number of registers
* selected.
*/
-void DisplayMan::writeColorRegs(byte *buf, uint16 first, uint16 numreg) {
+void DisplayMan::writeColorRegs(byte *buf, uint16 first, uint16 numReg) {
byte tmp[256 * 3];
- for (int i = 0; i < 256 * 3; i++) {
+ for (int i = 0; i < 256 * 3; i++)
tmp[i] = buf[i] * 4;
- }
-
- g_system->getPaletteManager()->setPalette(tmp, first, numreg);
- memcpy(&(_curvgapal[first * 3]), buf, numreg * 3);
+ g_system->getPaletteManager()->setPalette(tmp, first, numReg);
+ memcpy(&(_curvgapal[first * 3]), buf, numReg * 3);
}
-void DisplayMan::setPalette(void *cmap, uint16 numcolors) {
- if (memcmp(cmap, _curvgapal, numcolors * 3) != 0)
- writeColorRegs((byte *)cmap, 0, numcolors);
+void DisplayMan::setPalette(void *cmap, uint16 numColors) {
+ if (memcmp(cmap, _curvgapal, numColors * 3) != 0)
+ writeColorRegs((byte *)cmap, 0, numColors);
}
/**
@@ -605,7 +603,7 @@ byte *DisplayMan::getCurrentDrawingBuffer() {
/**
* Overlays a region on the screen using the desired pen color.
*/
-void DisplayMan::overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+void DisplayMan::overlayRect(uint16 penColor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
int w = x2 - x1 + 1;
int h = y2 - y1 + 1;
@@ -628,7 +626,7 @@ void DisplayMan::overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, u
}
while (ww > 0) {
- *dd = pencolor;
+ *dd = penColor;
dd += 2;
ww -= 2;
}
@@ -642,24 +640,24 @@ void DisplayMan::overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, u
/**
* Closes a font and frees all memory associated with it.
*/
-void DisplayMan::closeFont(TextFont *tf) {
- if (tf) {
- if (tf->_data && tf->_dataLength)
- delete[] tf->_data;
+void DisplayMan::closeFont(TextFont *font) {
+ if (font) {
+ if (font->_data && font->_dataLength)
+ delete[] font->_data;
- delete tf;
+ delete font;
}
}
/**
* Returns the length of a text in the specified font.
*/
-uint16 DisplayMan::textLength(TextFont *tf, const char *text, uint16 numchars) {
+uint16 DisplayMan::textLength(TextFont *font, const char *text, uint16 numChars) {
uint16 length = 0;
- if (tf) {
- for (uint16 i = 0; i < numchars; i++) {
- length += tf->_widths[(uint)*text];
+ if (font) {
+ for (uint16 i = 0; i < numChars; i++) {
+ length += font->_widths[(uint)*text];
text++;
}
}
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index 8b77dc8ab8..7ed2e67687 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -64,7 +64,7 @@ private:
uint16 fadeNumOut(uint16 num, uint16 res, uint16 counter);
void getWord(char *wordBuffer, const char *mainBuffer, uint16 *wordWidth);
- byte _curapen;
+ byte _curPen;
byte *_curBitmap;
byte _curvgapal[256 * 3];
@@ -94,58 +94,58 @@ public:
void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
void rectFillScaled(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
// Window text stuff
- uint32 flowText(void *font, // the TextAttr pointer
- int16 spacing, // How much vertical spacing between the lines
- byte pencolor, // pen number to use for text
- byte backpen, // the background color
- bool fillback, // Whether to fill the background
- bool centerh, // Whether to center the text horizontally
- bool centerv, // Whether to center the text vertically
- bool output, // Whether to output any text
+ uint32 flowText(TextFont *font, // the TextAttr pointer
+ int16 spacing, // How much vertical spacing between the lines
+ byte pencolor, // pen number to use for text
+ byte backpen, // the background color
+ bool fillback, // Whether to fill the background
+ bool centerh, // Whether to center the text horizontally
+ bool centerv, // Whether to center the text vertically
+ bool output, // Whether to output any text
uint16 x1, uint16 y1, // Cords
uint16 x2, uint16 y2,
const char *text); // The text itself
uint32 flowTextScaled(
- void *font, // the TextAttr pointer
- int16 spacing, // How much vertical spacing between the lines
- byte pencolor, // pen number to use for text
- byte backpen, // the background color
- bool fillback, // Whether to fill the background
- bool centerh, // Whether to center the text horizontally
- bool centerv, // Whether to center the text vertically
- bool output, // Whether to output any text
+ TextFont *font, // the TextAttr pointer
+ int16 spacing, // How much vertical spacing between the lines
+ byte pencolor, // pen number to use for text
+ byte backpen, // the background color
+ bool fillback, // Whether to fill the background
+ bool centerh, // Whether to center the text horizontally
+ bool centerv, // Whether to center the text vertically
+ bool output, // Whether to output any text
uint16 x1, uint16 y1, // Cords
uint16 x2, uint16 y2,
const char *text); // The text itself
uint32 flowTextToMem(Image *destIm,
- void *font, // the TextAttr pointer
- int16 spacing, // How much vertical spacing between the lines
- byte pencolor, // pen number to use for text
- byte backpen, // the background color
- bool fillback, // Whether to fill the background
- bool centerh, // Whether to center the text horizontally
- bool centerv, // Whether to center the text vertically
- bool output, // Whether to output any text
+ TextFont *font, // the TextAttr pointer
+ int16 spacing, // How much vertical spacing between the lines
+ byte pencolor, // pen number to use for text
+ byte backpen, // the background color
+ bool fillback, // Whether to fill the background
+ bool centerh, // Whether to center the text horizontally
+ bool centerv, // Whether to center the text vertically
+ bool output, // Whether to output any text
uint16 x1, uint16 y1, // Cords
uint16 x2, uint16 y2,
- const char *str); // The text itself
+ const char *str); // The text itself
void drawHLine(uint16 x, uint16 y1, uint16 y2);
void drawVLine(uint16 x1, uint16 y, uint16 x2);
void screenUpdate();
- void createScreen(bool HiRes);
+ void createScreen(bool hiRes);
void setAmigaPal(uint16 *pal, uint16 numColors);
- void writeColorRegs(byte *buf, uint16 first, uint16 numreg);
- void setPalette(void *cmap, uint16 numcolors);
- void overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+ void writeColorRegs(byte *buf, uint16 first, uint16 numReg);
+ void setPalette(void *cmap, uint16 numColors);
+ void overlayRect(uint16 penColor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
byte *getCurrentDrawingBuffer();
void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer);
void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer);
void fade(bool fadein, uint16 res);
- void closeFont(TextFont *tf);
- uint16 textLength(TextFont *tf, const char *text, uint16 numchars);
+ void closeFont(TextFont *font);
+ uint16 textLength(TextFont *font, const char *text, uint16 numChars);
uint16 textHeight(TextFont *tf);
void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numchars);
void getLine(TextFont *tf, char *lineBuffer, const char **mainBuffer, uint16 lineWidth);
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 1decad0000..016dd72e0a 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -48,7 +48,7 @@
namespace Lab {
LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
- : Engine(syst), _gameDescription(gameDesc), _extraGameFeatures(0), _rnd("lab") {
+ : Engine(syst), _gameDescription(gameDesc), _extraGameFeatures(0) {
_lastWaitTOFTicks = 0;
_isHiRes = false;
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 756f6e1a36..322a921757 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -136,7 +136,6 @@ private:
Image *_journalBackImage;
Image *_screenImage;
TextFont *_journalFont;
- Common::RandomSource _rnd;
public:
bool _alternate;
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index e95b67604e..dc1b149592 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -359,7 +359,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
case SHOWMESSAGES: {
char **str = (char **)actionList->_data;
_graphics->_doNotDrawMessage = false;
- _graphics->drawMessage(str[_rnd.getRandomNumber(actionList->_param1)]);
+ _graphics->drawMessage(str[_utils->getRandom(actionList->_param1)]);
_graphics->_doNotDrawMessage = true;
}
break;
diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp
index ec69d81f46..f20a42cc01 100644
--- a/engines/lab/utils.cpp
+++ b/engines/lab/utils.cpp
@@ -34,7 +34,7 @@
#include "lab/utils.h"
namespace Lab {
-Utils::Utils(LabEngine *vm) : _vm(vm) {
+Utils::Utils(LabEngine *vm) : _vm(vm), _rnd("lab") {
_dataBytesPerRow = 0;
}
@@ -427,4 +427,10 @@ void Utils::setBytesPerRow(int num) {
_dataBytesPerRow = num;
}
+uint16 Utils::getRandom(uint16 max) {
+ if (max > 1)
+ return _rnd.getRandomNumber(max - 1);
+ else
+ return 0;
+}
} // End of namespace Lab
diff --git a/engines/lab/utils.h b/engines/lab/utils.h
index b0aa58f795..0c4118e7bc 100644
--- a/engines/lab/utils.h
+++ b/engines/lab/utils.h
@@ -40,13 +40,15 @@ private:
void unDiffByteByte(byte *dest, byte *diff);
void unDiffByteWord(uint16 *dest, uint16 *diff);
- void VUnDiffByteByte(byte *Dest, byte *diff, uint16 bytesperrow);
- void VUnDiffByteWord(uint16 *Dest, uint16 *diff, uint16 bytesperrow);
- void VUnDiffByteLong(uint32 *Dest, uint32 *diff, uint16 bytesperrow);
+ void VUnDiffByteByte(byte *dest, byte *diff, uint16 bytesPerRow);
+ void VUnDiffByteWord(uint16 *dest, uint16 *diff, uint16 bytesPerRow);
+ void VUnDiffByteLong(uint32 *dest, uint32 *diff, uint16 bytesPerRow);
public:
Utils(LabEngine *vm);
+ Common::RandomSource _rnd;
+
uint16 scaleX(uint16 x);
uint16 scaleY(uint16 y);
int16 vgaScaleX(int16 x);
@@ -55,10 +57,11 @@ public:
uint16 mapScaleX(uint16 x);
uint16 mapScaleY(uint16 y);
Common::Point vgaUnscale(Common::Point pos);
- void unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesperrow, bool isV);
+ void unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesPerRow, bool isV);
void runLengthDecode(byte *dest, byte *source);
void VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow);
void setBytesPerRow(int num);
+ uint16 getRandom(uint16 max);
};