[Scummvm-cvs-logs] CVS: scummvm/scumm/smush brenderer.cpp,1.5,1.6 brenderer.h,1.8,1.9 frenderer.cpp,1.16,1.17 frenderer.h,1.11,1.12 player.h,1.14,1.15 renderer.h,1.7,1.8 scumm_renderer.cpp,1.28,1.29 scumm_renderer.h,1.12,1.13

Max Horn fingolfin at users.sourceforge.net
Wed Mar 12 17:50:17 CET 2003


Update of /cvsroot/scummvm/scummvm/scumm/smush
In directory sc8-pr-cvs1:/tmp/cvs-serv699

Modified Files:
	brenderer.cpp brenderer.h frenderer.cpp frenderer.h player.h 
	renderer.h scumm_renderer.cpp scumm_renderer.h 
Log Message:
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

Index: brenderer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/brenderer.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- brenderer.cpp	6 Mar 2003 21:46:34 -0000	1.5
+++ brenderer.cpp	13 Mar 2003 01:49:53 -0000	1.6
@@ -51,12 +51,12 @@
 	_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;

Index: brenderer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/brenderer.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- brenderer.h	12 Mar 2003 21:44:13 -0000	1.8
+++ brenderer.h	13 Mar 2003 01:49:53 -0000	1.9
@@ -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:
 	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 @@
 	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);

Index: frenderer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/frenderer.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- frenderer.cpp	6 Mar 2003 21:46:43 -0000	1.16
+++ frenderer.cpp	13 Mar 2003 01:49:53 -0000	1.17
@@ -42,11 +42,11 @@
 }
 
 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 @@
 	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 @@
 				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 @@
 	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 @@
 	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 @@
 	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 @@
 	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)) {

Index: frenderer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/frenderer.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- frenderer.h	13 Mar 2003 00:37:03 -0000	1.11
+++ frenderer.h	13 Mar 2003 01:49:53 -0000	1.12
@@ -55,7 +55,7 @@
 	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 @@
 
 		@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 @@
 
 		@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 @@
 
 		@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 @@
 
 		@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

Index: player.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/player.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- player.h	6 Mar 2003 21:46:45 -0000	1.14
+++ player.h	13 Mar 2003 01:49:53 -0000	1.15
@@ -69,7 +69,7 @@
 	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;

Index: renderer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/renderer.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- renderer.h	6 Mar 2003 21:46:45 -0000	1.7
+++ renderer.h	13 Mar 2003 01:49:53 -0000	1.8
@@ -77,7 +77,7 @@
 		
 		@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.

Index: scumm_renderer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/scumm_renderer.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- scumm_renderer.cpp	12 Mar 2003 21:44:17 -0000	1.28
+++ scumm_renderer.cpp	13 Mar 2003 01:49:54 -0000	1.29
@@ -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 @@
 	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 @@
 	_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 @@
 	_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 @@
 }
 
 ScummRenderer::~ScummRenderer() {
+	clean();
 	_scumm->_insaneState = false;
 	_scumm->exitCutscene();
 	if(_smixer) {
@@ -294,14 +294,14 @@
 }
 
 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());

Index: scumm_renderer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/scumm_renderer.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- scumm_renderer.h	12 Mar 2003 21:44:18 -0000	1.12
+++ scumm_renderer.h	13 Mar 2003 01:49:54 -0000	1.13
@@ -46,21 +46,14 @@
 	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);





More information about the Scummvm-git-logs mailing list