aboutsummaryrefslogtreecommitdiff
path: root/scumm/smush
diff options
context:
space:
mode:
authorMax Horn2003-03-13 01:49:54 +0000
committerMax Horn2003-03-13 01:49:54 +0000
commitf6b03c0aba8867201612b2036c3a05e1ecfc8773 (patch)
treeb639c286b6f63e6bb8eae50b68232c729279e4b3 /scumm/smush
parent4c6e8dc695aeb8440414f06f86f9b834ac683962 (diff)
downloadscummvm-rg350-f6b03c0aba8867201612b2036c3a05e1ecfc8773.tar.gz
scummvm-rg350-f6b03c0aba8867201612b2036c3a05e1ecfc8773.tar.bz2
scummvm-rg350-f6b03c0aba8867201612b2036c3a05e1ecfc8773.zip
char* -> byte*; if something is declared 'private' and then subclasses have to hack around that (BaseRenderer vs. ScummRenderer) that's usually a hint that it was not the right choice to make it private; don't use so many accessors for no good reasons
svn-id: r6808
Diffstat (limited to 'scumm/smush')
-rw-r--r--scumm/smush/brenderer.cpp4
-rw-r--r--scumm/smush/brenderer.h9
-rw-r--r--scumm/smush/frenderer.cpp28
-rw-r--r--scumm/smush/frenderer.h14
-rw-r--r--scumm/smush/player.h2
-rw-r--r--scumm/smush/renderer.h2
-rw-r--r--scumm/smush/scumm_renderer.cpp18
-rw-r--r--scumm/smush/scumm_renderer.h9
8 files changed, 38 insertions, 48 deletions
diff --git a/scumm/smush/brenderer.cpp b/scumm/smush/brenderer.cpp
index c2969ba1d9..45bd5be167 100644
--- a/scumm/smush/brenderer.cpp
+++ b/scumm/smush/brenderer.cpp
@@ -51,12 +51,12 @@ bool BaseRenderer::initFrame(const Point &p) {
_width = p.getX();
_height = p.getY();
assert(_width && _height);
- _data = new char[_width * _height];
+ _data = new byte[_width * _height];
if(!_data) error("base_renderer unable to allocate frame buffer");
return true;
}
-char *BaseRenderer::lockFrame(int32 frame) {
+byte *BaseRenderer::lockFrame(int32 frame) {
_frame = frame;
if(!_data) error("no allocated image buffer in lock_frame");
return _data;
diff --git a/scumm/smush/brenderer.h b/scumm/smush/brenderer.h
index 288e673d18..0db860297a 100644
--- a/scumm/smush/brenderer.h
+++ b/scumm/smush/brenderer.h
@@ -33,9 +33,9 @@
creation of subclasses of ::renderer is easier.
*/
class BaseRenderer : public Renderer {
-private:
+protected:
Palette _pal; //!< The current palette
- char *_data; //!< The current frame buffer
+ byte *_data; //!< The current frame buffer
int32 _frame; //!< The current frame number
int32 _nbframes; //!< The number of frames in the animation
int32 _width; //!< The current frame's width
@@ -47,9 +47,6 @@ protected:
protected:
const char *getFilename() const { return _fname; }; //!< accessor for animation filename
int32 getNbframes() const { return _nbframes; }; //!< accessor for number of frames
- virtual int32 getWidth() const { return _width; }; //!< accessor for current width
- virtual int32 getHeight() const { return _height; }; //!< accessor for current height
- virtual const char *data() const { return _data; }; //!< accessor for current frame buffer
void clean(); //!< memory cleanup (deletes frame buffer)
void setFrame(int32 f) { _frame = f; }; //!< allows to change the frame number
public:
@@ -58,7 +55,7 @@ public:
virtual ~BaseRenderer();
virtual bool initFrame(const Point &size);
- virtual char *lockFrame(int32 frame);
+ virtual byte *lockFrame(int32 frame);
virtual bool unlockFrame();
virtual bool flipFrame();
virtual bool setPalette(const Palette &pal);
diff --git a/scumm/smush/frenderer.cpp b/scumm/smush/frenderer.cpp
index dc43844c11..761d504f74 100644
--- a/scumm/smush/frenderer.cpp
+++ b/scumm/smush/frenderer.cpp
@@ -42,11 +42,11 @@ FontRenderer::~FontRenderer() {
}
void FontRenderer::save(int32 frame) {
- _chars[_nbChars].width = getWidth();
- _chars[_nbChars].height = getHeight();
- int size = getWidth() * getHeight();
- _chars[_nbChars].chr = new char[size];
- memcpy(_chars[_nbChars].chr, data(), size);
+ _chars[_nbChars].width = _width;
+ _chars[_nbChars].height = _height;
+ int size = _width * _height;
+ _chars[_nbChars].chr = new byte[size];
+ memcpy(_chars[_nbChars].chr, _data, size);
_nbChars++;
}
@@ -83,11 +83,11 @@ int32 FontRenderer::stringHeight(const char *str) const {
return ret;
}
-int32 FontRenderer::drawChar(char *buffer, const Point &size, int32 x, int32 y, int32 chr) const {
+int32 FontRenderer::drawChar(byte *buffer, const Point &size, int32 x, int32 y, int32 chr) const {
int32 w = _chars[chr].width;
int32 h = _chars[chr].height;
- char *src = _chars[chr].chr;
- char *dst = buffer + size.getX() * y + x;
+ byte *src = _chars[chr].chr;
+ byte *dst = buffer + size.getX() * y + x;
if(_original) {
for(int32 j = 0; j < h; j++) {
@@ -104,7 +104,7 @@ int32 FontRenderer::drawChar(char *buffer, const Point &size, int32 x, int32 y,
for(int32 i = 0; i < w; i++) {
char value = *src++;
if(value == -color) {
- dst[i] = -1;
+ dst[i] = 0xFF;
} else if(value == -31) {
dst[i] = 0;
} else if(value) {
@@ -151,12 +151,12 @@ static char **split(const char *str, char sep) {
return ret;
}
-void FontRenderer::drawSubstring(const byte *str, char *buffer, const Point &size, int32 x, int32 y) const {
+void FontRenderer::drawSubstring(const byte *str, byte *buffer, const Point &size, int32 x, int32 y) const {
for(int32 i = 0; str[i] != 0; i++)
x += drawChar(buffer, size, x, y, str[i]);
}
-bool FontRenderer::drawStringAbsolute(const char *str, char *buffer, const Point &size, int32 x, int32 y) const {
+bool FontRenderer::drawStringAbsolute(const char *str, byte *buffer, const Point &size, int32 x, int32 y) const {
debug(9, "FontRenderer::drawStringAbsolute(%s, %d, %d)", str, x, y);
while(str) {
char line[256];
@@ -175,7 +175,7 @@ bool FontRenderer::drawStringAbsolute(const char *str, char *buffer, const Point
return true;
}
-bool FontRenderer::drawStringCentered(const char *str, char *buffer, const Point &size, int32 y, int32 xmin, int32 width, int32 offset) const {
+bool FontRenderer::drawStringCentered(const char *str, byte *buffer, const Point &size, int32 y, int32 xmin, int32 width, int32 offset) const {
debug(9, "FontRenderer::drawStringCentered(%s, %d, %d)", str, xmin, y);
if ((strchr(str, '\n') != 0)) {
char *j = strchr(str, '\n');
@@ -253,7 +253,7 @@ bool FontRenderer::drawStringCentered(const char *str, char *buffer, const Point
return true;
}
-bool FontRenderer::drawStringWrap(const char *str, char *buffer, const Point &size, int32 x, int32 y, int32 width) const {
+bool FontRenderer::drawStringWrap(const char *str, byte *buffer, const Point &size, int32 x, int32 y, int32 width) const {
debug(9, "FontRenderer::drawStringWrap(%s, %d, %d)", str, x, y);
if ((strchr(str, '\n') != 0)) {
char *j = strchr(str, '\n');
@@ -328,7 +328,7 @@ bool FontRenderer::drawStringWrap(const char *str, char *buffer, const Point &si
return true;
}
-bool FontRenderer::drawStringWrapCentered(const char *str, char *buffer, const Point &size, int32 x, int32 y, int32 width) const {
+bool FontRenderer::drawStringWrapCentered(const char *str, byte *buffer, const Point &size, int32 x, int32 y, int32 width) const {
int32 max_substr_width = 0;
debug(9, "FontRenderer::drawStringWrapCentered(%s, %d, %d)", str, x, y);
if ((strchr(str, '\n') != 0)) {
diff --git a/scumm/smush/frenderer.h b/scumm/smush/frenderer.h
index 4c62abc629..8d31a1e87e 100644
--- a/scumm/smush/frenderer.h
+++ b/scumm/smush/frenderer.h
@@ -55,7 +55,7 @@ private:
struct {
int32 width;
int32 height;
- char *chr;
+ byte *chr;
} _chars[256]; //!< array that contains the size of the different frames (i.e. characters) of the font.
public:
/*! @brief font_renderer constructor
@@ -107,7 +107,7 @@ protected:
@return the width of the character
*/
- int32 drawChar(char *buffer, const Point &size, int32 x, int32 y, int32 c) const;
+ int32 drawChar(byte *buffer, const Point &size, int32 x, int32 y, int32 c) const;
/*! @brief draw a string in the given frame buffer.
@param str the string to draw.
@@ -118,7 +118,7 @@ protected:
@bug This method does not clip. This is not really a bug, as it should always be correctly called, but some asserts would be welcome.
*/
- void drawSubstring(const byte *str, char *buffer, const Point &size, int32 x, int32 y) const;
+ void drawSubstring(const byte *str, byte *buffer, const Point &size, int32 x, int32 y) const;
public:
/*! @brief change the programmable color of the font.
@@ -146,9 +146,9 @@ public:
@return \c true if everything went fine, \c false otherwise
*/
- bool drawStringCentered(const char *str, char *buffer, const Point &size, int32 y, int32 xmin, int32 width, int32 offset) const;
- bool drawStringWrap(const char *str, char *buffer, const Point &size, int32 x, int32 y, int32 width) const;
- bool drawStringWrapCentered(const char *str, char *buffer, const Point &size, int32 x, int32 y, int32 width) const;
+ bool drawStringCentered(const char *str, byte *buffer, const Point &size, int32 y, int32 xmin, int32 width, int32 offset) const;
+ bool drawStringWrap(const char *str, byte *buffer, const Point &size, int32 x, int32 y, int32 width) const;
+ bool drawStringWrapCentered(const char *str, byte *buffer, const Point &size, int32 x, int32 y, int32 width) const;
/*! @brief draw a string at an absolute position.
@param str the string to draw.
@@ -159,7 +159,7 @@ public:
@return \c true if everything went fine, \c false otherwise
*/
- bool drawStringAbsolute(const char *str, char *buffer, const Point &size, int32 x, int32 y) const;
+ bool drawStringAbsolute(const char *str, byte *buffer, const Point &size, int32 x, int32 y) const;
};
#endif
diff --git a/scumm/smush/player.h b/scumm/smush/player.h
index 4d943764e3..60311b88f7 100644
--- a/scumm/smush/player.h
+++ b/scumm/smush/player.h
@@ -69,7 +69,7 @@ private:
bool _bgmusic; //!< should the player output the background music ?
bool _voices; //!< should the player output the voice ?
bool _skips[37]; //!< mapping of frame object identifier to show or hide
- char *_curBuffer; //!< pointer to the current frame
+ byte *_curBuffer; //!< pointer to the current frame
int32 _IACTchannel;
byte _IACToutput[4096];
int32 _IACTpos;
diff --git a/scumm/smush/renderer.h b/scumm/smush/renderer.h
index 14cd119acd..724b0eb6d1 100644
--- a/scumm/smush/renderer.h
+++ b/scumm/smush/renderer.h
@@ -77,7 +77,7 @@ public:
@return a pointer to the frame buffer to output data to.
*/
- virtual char *lockFrame(int32 frame) = 0;
+ virtual byte *lockFrame(int32 frame) = 0;
/*! @brief unlock a frame buffer
This is called by the animation player when a frame has been decoded.
diff --git a/scumm/smush/scumm_renderer.cpp b/scumm/smush/scumm_renderer.cpp
index a3721ce0cd..998b60ed22 100644
--- a/scumm/smush/scumm_renderer.cpp
+++ b/scumm/smush/scumm_renderer.cpp
@@ -28,7 +28,6 @@
#include "scumm/scumm.h"
#include "scumm/sound.h"
#include "scumm/imuse.h"
-#include "scumm/actor.h"
class ScummMixer : public Mixer {
private:
@@ -188,9 +187,9 @@ bool ScummMixer::stop() {
debug(9, "ScummMixer::stop()");
for(int i = _mixer->_beginSlots; i < SoundMixer::NUM_CHANNELS; i++) {
if(_channels[i].id != -1) {
- delete _channels[i].chan;
- _channels[i].id = -1;
- _channels[i].chan = 0;
+ delete _channels[i].chan;
+ _channels[i].id = -1;
+ _channels[i].chan = 0;
}
}
return true;
@@ -214,7 +213,7 @@ bool ScummRenderer::initFrame(const Point &p) {
_width = p.getX();
_height = p.getY();
assert(_width && _height);
- _data = (char *)_scumm->virtscr[0].screenPtr + _scumm->virtscr[0].xstart;
+ _data = _scumm->virtscr[0].screenPtr + _scumm->virtscr[0].xstart;
return true;
}
@@ -223,7 +222,7 @@ void ScummRenderer::clean() {
_width = _height = 0;
}
-char *ScummRenderer::lockFrame(int32 frame) {
+byte *ScummRenderer::lockFrame(int32 frame) {
_frame = frame;
if(!_data) error("no allocated image buffer in lock_frame");
return _data;
@@ -241,6 +240,7 @@ Mixer *ScummRenderer::getMixer() {
}
ScummRenderer::~ScummRenderer() {
+ clean();
_scumm->_insaneState = false;
_scumm->exitCutscene();
if(_smixer) {
@@ -294,14 +294,14 @@ bool ScummRenderer::setPalette(const Palette &pal) {
}
void ScummRenderer::save(int32 frame) {
- int width = MIN(getWidth(), _scumm->_realWidth);
- int height = MIN(getHeight(), _scumm->_realHeight);
+ int width = MIN(_width, _scumm->_realWidth);
+ int height = MIN(_height, _scumm->_realHeight);
// In theory, this will always be true. In reality, there may be
// several pending updates because the computer wasn't fast enough to
// process them all. In that case, skip the frame to catch up.
if (--_pending_updates <= 0) {
- _scumm->_system->copy_rect((const byte *)data(), getWidth(), 0, 0, width, height);
+ _scumm->_system->copy_rect(_data, _width, 0, 0, width, height);
_scumm->_system->update_screen();
} else {
warning("ScummRenderer: Skipping frame %d to catch up", getFrame());
diff --git a/scumm/smush/scumm_renderer.h b/scumm/smush/scumm_renderer.h
index c4a7274854..4f43051e0e 100644
--- a/scumm/smush/scumm_renderer.h
+++ b/scumm/smush/scumm_renderer.h
@@ -46,21 +46,14 @@ private:
ScummMixer *_smixer;
uint32 _insaneSpeed;
volatile int _pending_updates;
- int32 _width; //!< The current frame's width
- int32 _height; //!< The current frame's height
- int32 _frame; //!< The current frame number
- char *_data; //!< The current frame buffer
public:
ScummRenderer(Scumm *scumm, uint32 speed);
virtual ~ScummRenderer();
- virtual int32 getWidth() const { return _width; }; //!< accessor for current width
- virtual int32 getHeight() const { return _height; }; //!< accessor for current height
- virtual const char *data() const { return _data; }; //!< accessor for current frame buffer
virtual bool wait(int32 ms);
bool update();
protected:
virtual bool initFrame(const Point &size);
- virtual char *lockFrame(int32 frame);
+ virtual byte *lockFrame(int32 frame);
virtual void clean();
virtual bool startDecode(const char *fname, int32 version, int32 nbframes);
virtual bool setPalette(const Palette & pal);