From 0e46c809d10dcd8fd766d7adcb966785e7955f5b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 18 Feb 2014 20:08:58 -0500 Subject: MADS: Initial implementation of MSurface class and dependant classes --- engines/mads/msurface.h | 185 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 engines/mads/msurface.h (limited to 'engines/mads/msurface.h') diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h new file mode 100644 index 0000000000..9bb651b02b --- /dev/null +++ b/engines/mads/msurface.h @@ -0,0 +1,185 @@ +/* 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. + * + */ + +#ifndef MADS_MSURFACE_H +#define MADS_MSURFACE_H + +#include "common/scummsys.h" +#include "common/rect.h" +#include "graphics/surface.h" +#include "mads/palette.h" + +namespace MADS { + +class MADSEngine; +class MSprite; + +struct SpriteInfo { + MSprite *sprite; + int hotX, hotY; + int width, height; + int scaleX, scaleY; + uint8 encoding; + byte *inverseColorTable; + RGB8 *palette; +}; + +class MSurface : public Graphics::Surface { +public: + static MADSEngine *_vm; + + /** + * Sets the engine reference + */ + static void setVm(MADSEngine *vm) { _vm = vm; } + + /** + * Create a new surface the same size as the screen. + * @param isScreen Set to true for the screen surface + */ + static MSurface *init(bool isScreen = false); + + /** + * Create a surface + */ + static MSurface *init(int w, int h); +private: + byte _color; + bool _isScreen; +protected: + MSurface(bool isScreen = false); + MSurface(int w, int h); +public: + void create(int w, int h) { + Graphics::Surface::create(w, h, Graphics::PixelFormat::createFormatCLUT8()); + } + + void setColor(byte value) { _color = value; } + byte getColor() { return _color; } + void vLine(int x, int y1, int y2); + void hLine(int x1, int x2, int y); + void vLineXor(int x, int y1, int y2); + void hLineXor(int x1, int x2, int y); + void line(int x1, int y1, int x2, int y2, byte color); + void frameRect(int x1, int y1, int x2, int y2); + void fillRect(int x1, int y1, int x2, int y2); + + static int scaleValue(int value, int scale, int err); + void drawSprite(int x, int y, SpriteInfo &info, const Common::Rect &clipRect); + + // Surface methods + int width() { return w; } + int height() { return h; } + void setSize(int sizeX, int sizeY); + byte *getData(); + byte *getBasePtr(int x, int y); + void freeData(); + void empty(); + void frameRect(const Common::Rect &r, uint8 color); + void fillRect(const Common::Rect &r, uint8 color); + void copyFrom(MSurface *src, const Common::Rect &srcBounds, int destX, int destY, + int transparentColor = -1); + + void update() { + if (_isScreen) { + g_system->copyRectToScreen((const byte *)pixels, pitch, 0, 0, w, h); + g_system->updateScreen(); + } + } + + // copyTo methods + void copyTo(MSurface *dest, int transparentColor = -1) { + dest->copyFrom(this, Common::Rect(width(), height()), 0, 0, transparentColor); + } + void copyTo(MSurface *dest, int x, int y, int transparentColor = -1) { + dest->copyFrom(this, Common::Rect(width(), height()), x, y, transparentColor); + } + void copyTo(MSurface *dest, const Common::Rect &srcBounds, int destX, int destY, + int transparentColor = -1) { + dest->copyFrom(this, srcBounds, destX, destY, transparentColor); + } + + void translate(RGBList *list, bool isTransparent = false); + + // Base virtual methods + virtual void loadBackground(const Common::String &sceneName) {} + virtual void loadBackground(int roomNumber, RGBList **palData) = 0; + virtual void loadBackground(Common::SeekableReadStream *source, RGBList **palData) {} + virtual void loadCodes(Common::SeekableReadStream *source) = 0; + virtual void loadInterface(int index, RGBList **palData) {} +}; + +class MSurfaceMADS: public MSurface { + friend class MSurface; +protected: + MSurfaceMADS(bool isScreen = false): MSurface(isScreen) {} + MSurfaceMADS(int w, int h): MSurface(w, h) {} +public: + virtual void loadCodes(Common::SeekableReadStream *source); + virtual void loadBackground(const Common::String &sceneName) {} + virtual void loadBackground(int roomNumber, RGBList **palData); + virtual void loadInterface(int index, RGBList **palData); +}; + +class MSurfaceNebular: public MSurfaceMADS { + friend class MSurface; +protected: + MSurfaceNebular(bool isScreen = false): MSurfaceMADS(isScreen) {} + MSurfaceNebular(int w, int h): MSurfaceMADS(w, h) {} +private: + void loadBackgroundStream(Common::SeekableReadStream *source, RGBList **palData); +public: + virtual void loadBackground(int roomNumber, RGBList **palData); +}; + +class MSurfaceM4: public MSurface { + friend class MSurface; +protected: + MSurfaceM4(bool isScreen = false): MSurface(isScreen) {} + MSurfaceM4(int w, int h): MSurface(w, h) {} + + void loadBackgroundStream(Common::SeekableReadStream *source); +public: + virtual void loadCodes(Common::SeekableReadStream *source); + virtual void loadBackground(int roomNumber, RGBList **palData); +}; + +class MSurfaceRiddle: public MSurfaceM4 { + friend class MSurface; +protected: + MSurfaceRiddle(bool isScreen = false): MSurfaceM4(isScreen) {} + MSurfaceRiddle(int w, int h): MSurfaceM4(w, h) {} +public: + virtual void loadBackground(const Common::String &sceneName); +}; +/* + void rexLoadBackground(Common::SeekableReadStream *source, RGBList **palData = NULL); + void madsLoadBackground(int roomNumber, RGBList **palData = NULL); + void m4LoadBackground(Common::SeekableReadStream *source); + + void madsloadInterface(int index, RGBList **palData); + + */ + +} // End of namespace MADS + +#endif /* MADS_MSURFACE_H */ -- cgit v1.2.3 From 97087e8cd1aee602217c36f1c71d4ca3f74e0e40 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 18 Feb 2014 23:56:41 -0500 Subject: MADS: Fix warnings identified by gcc --- engines/mads/msurface.h | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'engines/mads/msurface.h') diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index 9bb651b02b..21b0cbcd2f 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -69,6 +69,8 @@ protected: MSurface(bool isScreen = false); MSurface(int w, int h); public: + virtual ~MSurface() {} + void create(int w, int h) { Graphics::Surface::create(w, h, Graphics::PixelFormat::createFormatCLUT8()); } @@ -155,7 +157,7 @@ class MSurfaceM4: public MSurface { friend class MSurface; protected: MSurfaceM4(bool isScreen = false): MSurface(isScreen) {} - MSurfaceM4(int w, int h): MSurface(w, h) {} + MSurfaceM4(int widthVal, int heightVal): MSurface(widthVal, heightVal) {} void loadBackgroundStream(Common::SeekableReadStream *source); public: @@ -167,18 +169,10 @@ class MSurfaceRiddle: public MSurfaceM4 { friend class MSurface; protected: MSurfaceRiddle(bool isScreen = false): MSurfaceM4(isScreen) {} - MSurfaceRiddle(int w, int h): MSurfaceM4(w, h) {} + MSurfaceRiddle(int widthVal, int heightVal): MSurfaceM4(widthVal, heightVal) {} public: virtual void loadBackground(const Common::String &sceneName); }; -/* - void rexLoadBackground(Common::SeekableReadStream *source, RGBList **palData = NULL); - void madsLoadBackground(int roomNumber, RGBList **palData = NULL); - void m4LoadBackground(Common::SeekableReadStream *source); - - void madsloadInterface(int index, RGBList **palData); - - */ } // End of namespace MADS -- cgit v1.2.3 From 5c565797e5516de97686650be8cc810007111641 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 19 Feb 2014 20:22:06 -0500 Subject: MADS: Extra cleanup and commenting for MSurface methods --- engines/mads/msurface.h | 186 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 157 insertions(+), 29 deletions(-) (limited to 'engines/mads/msurface.h') diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index 21b0cbcd2f..05777d3b8f 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -33,6 +33,9 @@ namespace MADS { class MADSEngine; class MSprite; +/** + * Basic sprite information + */ struct SpriteInfo { MSprite *sprite; int hotX, hotY; @@ -43,6 +46,9 @@ struct SpriteInfo { RGB8 *palette; }; +/* + * MADS graphics surface + */ class MSurface : public Graphics::Surface { public: static MADSEngine *_vm; @@ -61,46 +67,126 @@ public: /** * Create a surface */ - static MSurface *init(int w, int h); + static MSurface *init(int width, int height); private: byte _color; bool _isScreen; protected: + /** + * Basic constructor + */ MSurface(bool isScreen = false); - MSurface(int w, int h); + + /** + * Constructor for a surface with fixed dimensions + */ + MSurface(int width, int height); +public: + /** + * Helper method for calculating new dimensions when scaling a sprite + */ + static int scaleValue(int value, int scale, int err); public: virtual ~MSurface() {} - void create(int w, int h) { - Graphics::Surface::create(w, h, Graphics::PixelFormat::createFormatCLUT8()); + /** + * Reinitialises a surface to have a given set of dimensions + */ + void setSize(int width, int height) { + Graphics::Surface::create(width, height, Graphics::PixelFormat::createFormatCLUT8()); } + /** + * Sets the color used for drawing on the surface + */ void setColor(byte value) { _color = value; } - byte getColor() { return _color; } + + /** + * Returns the currently active color + */ + byte getColor() const { return _color; } + + /** + * Draws a vertical line using the currently set color + */ void vLine(int x, int y1, int y2); + + /** + * Draws a horizontal line using the currently set color + */ void hLine(int x1, int x2, int y); + + /** + * Draws a vertical line using an Xor on each pixel + */ void vLineXor(int x, int y1, int y2); + + /** + * Draws a horizontal line using an Xor on each pixel + */ void hLineXor(int x1, int x2, int y); + + /** + * Draws an arbitrary line on the screen using a specified color + */ void line(int x1, int y1, int x2, int y2, byte color); + + /** + * Draws a rectangular frame using the currently set color + */ void frameRect(int x1, int y1, int x2, int y2); - void fillRect(int x1, int y1, int x2, int y2); - static int scaleValue(int value, int scale, int err); - void drawSprite(int x, int y, SpriteInfo &info, const Common::Rect &clipRect); - - // Surface methods - int width() { return w; } - int height() { return h; } - void setSize(int sizeX, int sizeY); - byte *getData(); - byte *getBasePtr(int x, int y); - void freeData(); - void empty(); + /** + * Draws a rectangular frame using a specified color + */ void frameRect(const Common::Rect &r, uint8 color); + + /** + * Draws a filled in box using the currently set color + */ + void fillRect(int x1, int y1, int x2, int y2); + + /** + * Draws a filled in box using a specified color + */ void fillRect(const Common::Rect &r, uint8 color); - void copyFrom(MSurface *src, const Common::Rect &srcBounds, int destX, int destY, - int transparentColor = -1); + /** + * Draws a sprite + * @param pt Position to draw sprite at + * @param info General sprite details + * @param clipRect Clipping rectangle to constrain sprite drawing within + */ + void drawSprite(const Common::Point &pt, SpriteInfo &info, const Common::Rect &clipRect); + + /** + * Returns the width of the surface + */ + int getWidth() const { return w; } + + /** + * Returns the height of the surface + */ + int getHeight() const { return h; } + + /** + * Returns a pointer to the surface data + */ + byte *getData() { return (byte *)Graphics::Surface::getPixels(); } + + /** + * Returns a pointer to a given position within the surface + */ + byte *getBasePtr(int x, int y) { return (byte *)Graphics::Surface::getBasePtr(x, y); } + + /** + * Clears the surface + */ + void empty(); + + /** + * Updates the surface. If it's the screen surface, copies it to the physical screen. + */ void update() { if (_isScreen) { g_system->copyRectToScreen((const byte *)pixels, pitch, 0, 0, w, h); @@ -108,25 +194,67 @@ public: } } - // copyTo methods + /** + * Copys a sub-section of another surface into the current one. + * @param src Source surface + * @param srcBounds Area of source surface to copy + * @param destPos Destination position to draw in current surface + * @param transparentColor Transparency palette index + */ + void copyFrom(MSurface *src, const Common::Rect &srcBounds, const Common::Point &destPos, + int transparentColor = -1); + + /** + * Copies the surface to a given destination surface + */ void copyTo(MSurface *dest, int transparentColor = -1) { - dest->copyFrom(this, Common::Rect(width(), height()), 0, 0, transparentColor); + dest->copyFrom(this, Common::Rect(w, h), Common::Point(), transparentColor); } - void copyTo(MSurface *dest, int x, int y, int transparentColor = -1) { - dest->copyFrom(this, Common::Rect(width(), height()), x, y, transparentColor); + + /** + * Copies the surface to a given destination surface + */ + void copyTo(MSurface *dest, const Common::Point &pt, int transparentColor = -1) { + dest->copyFrom(this, Common::Rect(w, h), pt, transparentColor); } - void copyTo(MSurface *dest, const Common::Rect &srcBounds, int destX, int destY, + + /** + * Copies the surface to a given destination surface + */ + void copyTo(MSurface *dest, const Common::Rect &srcBounds, const Common::Point &destPos, int transparentColor = -1) { - dest->copyFrom(this, srcBounds, destX, destY, transparentColor); + dest->copyFrom(this, srcBounds, destPos, transparentColor); } + /** + * Translates the data of a surface using a specified RGBList translation matrix. + */ void translate(RGBList *list, bool isTransparent = false); // Base virtual methods + /** + * Loads a background by scene name + */ virtual void loadBackground(const Common::String &sceneName) {} + + /** + * Load background by room number + */ virtual void loadBackground(int roomNumber, RGBList **palData) = 0; + + /** + * Load background from a passed stream + */ virtual void loadBackground(Common::SeekableReadStream *source, RGBList **palData) {} + + /** + * Load scene codes from a passed stream + */ virtual void loadCodes(Common::SeekableReadStream *source) = 0; + + /** + * Load a given user interface by index + */ virtual void loadInterface(int index, RGBList **palData) {} }; @@ -134,7 +262,7 @@ class MSurfaceMADS: public MSurface { friend class MSurface; protected: MSurfaceMADS(bool isScreen = false): MSurface(isScreen) {} - MSurfaceMADS(int w, int h): MSurface(w, h) {} + MSurfaceMADS(int width, int height): MSurface(width, height) {} public: virtual void loadCodes(Common::SeekableReadStream *source); virtual void loadBackground(const Common::String &sceneName) {} @@ -146,7 +274,7 @@ class MSurfaceNebular: public MSurfaceMADS { friend class MSurface; protected: MSurfaceNebular(bool isScreen = false): MSurfaceMADS(isScreen) {} - MSurfaceNebular(int w, int h): MSurfaceMADS(w, h) {} + MSurfaceNebular(int width, int height): MSurfaceMADS(width, height) {} private: void loadBackgroundStream(Common::SeekableReadStream *source, RGBList **palData); public: @@ -157,7 +285,7 @@ class MSurfaceM4: public MSurface { friend class MSurface; protected: MSurfaceM4(bool isScreen = false): MSurface(isScreen) {} - MSurfaceM4(int widthVal, int heightVal): MSurface(widthVal, heightVal) {} + MSurfaceM4(int width, int height): MSurface(width, height) {} void loadBackgroundStream(Common::SeekableReadStream *source); public: @@ -169,7 +297,7 @@ class MSurfaceRiddle: public MSurfaceM4 { friend class MSurface; protected: MSurfaceRiddle(bool isScreen = false): MSurfaceM4(isScreen) {} - MSurfaceRiddle(int widthVal, int heightVal): MSurfaceM4(widthVal, heightVal) {} + MSurfaceRiddle(int width, int height): MSurfaceM4(width, height) {} public: virtual void loadBackground(const Common::String &sceneName); }; -- cgit v1.2.3 From c687d3f64cc5ac6ec09539129c5f8b0d3a7148ad Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 19 Feb 2014 21:28:54 -0500 Subject: MADS: Cleanup of palette code, updated old-style 4 byte RGB usage to 3 bytes --- engines/mads/msurface.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/msurface.h') diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index 05777d3b8f..fe6d1f22b4 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -43,7 +43,7 @@ struct SpriteInfo { int scaleX, scaleY; uint8 encoding; byte *inverseColorTable; - RGB8 *palette; + byte *palette; }; /* -- cgit v1.2.3 From 488bf66c3e451a65ab14a387f681fb91aa5c6253 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 19 Feb 2014 21:56:38 -0500 Subject: MADS: Fix memory leaks in MSurface --- engines/mads/msurface.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'engines/mads/msurface.h') diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index fe6d1f22b4..42c56e9393 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -87,14 +87,15 @@ public: */ static int scaleValue(int value, int scale, int err); public: - virtual ~MSurface() {} + /** + * Destructor + */ + virtual ~MSurface(); /** * Reinitialises a surface to have a given set of dimensions */ - void setSize(int width, int height) { - Graphics::Surface::create(width, height, Graphics::PixelFormat::createFormatCLUT8()); - } + void setSize(int width, int height); /** * Sets the color used for drawing on the surface -- cgit v1.2.3 From 3df12371873cb8e3380422aa3095e367408526af Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 22 Feb 2014 14:20:34 -0500 Subject: MADS: Removed M4-specific code. Keeping engine MADS-specific for now --- engines/mads/msurface.h | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'engines/mads/msurface.h') diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index 42c56e9393..940c5b5704 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -282,27 +282,6 @@ public: virtual void loadBackground(int roomNumber, RGBList **palData); }; -class MSurfaceM4: public MSurface { - friend class MSurface; -protected: - MSurfaceM4(bool isScreen = false): MSurface(isScreen) {} - MSurfaceM4(int width, int height): MSurface(width, height) {} - - void loadBackgroundStream(Common::SeekableReadStream *source); -public: - virtual void loadCodes(Common::SeekableReadStream *source); - virtual void loadBackground(int roomNumber, RGBList **palData); -}; - -class MSurfaceRiddle: public MSurfaceM4 { - friend class MSurface; -protected: - MSurfaceRiddle(bool isScreen = false): MSurfaceM4(isScreen) {} - MSurfaceRiddle(int width, int height): MSurfaceM4(width, height) {} -public: - virtual void loadBackground(const Common::String &sceneName); -}; - } // End of namespace MADS #endif /* MADS_MSURFACE_H */ -- cgit v1.2.3 From 6c354bccf253118d459f92f16d8f702ae07806fb Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 22 Feb 2014 17:25:30 -0500 Subject: MADS: Implemented more logic for dialog display --- engines/mads/msurface.h | 51 +++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 21 deletions(-) (limited to 'engines/mads/msurface.h') diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index 940c5b5704..2e4ca7e728 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -59,10 +59,9 @@ public: static void setVm(MADSEngine *vm) { _vm = vm; } /** - * Create a new surface the same size as the screen. - * @param isScreen Set to true for the screen surface + * Create a new surface. */ - static MSurface *init(bool isScreen = false); + static MSurface *init(); /** * Create a surface @@ -70,12 +69,11 @@ public: static MSurface *init(int width, int height); private: byte _color; - bool _isScreen; protected: /** * Basic constructor */ - MSurface(bool isScreen = false); + MSurface(); /** * Constructor for a surface with fixed dimensions @@ -129,28 +127,37 @@ public: /** * Draws an arbitrary line on the screen using a specified color + * @param startPos Starting position + * @param endPos Ending position + * @param color Color to use */ - void line(int x1, int y1, int x2, int y2, byte color); + void line(const Common::Point &startPos, const Common::Point &endPos, byte color); /** * Draws a rectangular frame using the currently set color + * @param r Bounds for rectangle */ - void frameRect(int x1, int y1, int x2, int y2); + void frameRect(const Common::Rect &r); /** - * Draws a rectangular frame using a specified color + * Draws a rectangular frame using the currently set color + * @param r Bounds for rectangle + * @param color Color to use */ - void frameRect(const Common::Rect &r, uint8 color); + void frameRect(const Common::Rect &r, byte color); /** * Draws a filled in box using the currently set color + * @param r Bounds for rectangle */ - void fillRect(int x1, int y1, int x2, int y2); + void fillRect(const Common::Rect &r); /** - * Draws a filled in box using a specified color + * Draws a filled in box using the currently set color + * @param r Bounds for rectangle + * @param color Color to use */ - void fillRect(const Common::Rect &r, uint8 color); + void fillRect(const Common::Rect &r, byte color); /** * Draws a sprite @@ -170,6 +177,13 @@ public: */ int getHeight() const { return h; } + /** + * Returns the size of the surface as a Rect + */ + Common::Rect getBounds() const { + return Common::Rect(0, 0, w, h); + } + /** * Returns a pointer to the surface data */ @@ -186,14 +200,9 @@ public: void empty(); /** - * Updates the surface. If it's the screen surface, copies it to the physical screen. + * Updates the screen with the contents of the surface */ - void update() { - if (_isScreen) { - g_system->copyRectToScreen((const byte *)pixels, pitch, 0, 0, w, h); - g_system->updateScreen(); - } - } + void updateScreen(); /** * Copys a sub-section of another surface into the current one. @@ -262,7 +271,7 @@ public: class MSurfaceMADS: public MSurface { friend class MSurface; protected: - MSurfaceMADS(bool isScreen = false): MSurface(isScreen) {} + MSurfaceMADS(): MSurface() {} MSurfaceMADS(int width, int height): MSurface(width, height) {} public: virtual void loadCodes(Common::SeekableReadStream *source); @@ -274,7 +283,7 @@ public: class MSurfaceNebular: public MSurfaceMADS { friend class MSurface; protected: - MSurfaceNebular(bool isScreen = false): MSurfaceMADS(isScreen) {} + MSurfaceNebular(): MSurfaceMADS() {} MSurfaceNebular(int width, int height): MSurfaceMADS(width, height) {} private: void loadBackgroundStream(Common::SeekableReadStream *source, RGBList **palData); -- cgit v1.2.3 From 1d80edb2dd092b7e91805f359f0e2a7d470ed7c4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 23 Feb 2014 13:39:53 -0500 Subject: MADS: Fixes for the display of dialogs --- engines/mads/msurface.h | 58 ------------------------------------------------- 1 file changed, 58 deletions(-) (limited to 'engines/mads/msurface.h') diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index 2e4ca7e728..3904aa1e92 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -67,8 +67,6 @@ public: * Create a surface */ static MSurface *init(int width, int height); -private: - byte _color; protected: /** * Basic constructor @@ -95,36 +93,6 @@ public: */ void setSize(int width, int height); - /** - * Sets the color used for drawing on the surface - */ - void setColor(byte value) { _color = value; } - - /** - * Returns the currently active color - */ - byte getColor() const { return _color; } - - /** - * Draws a vertical line using the currently set color - */ - void vLine(int x, int y1, int y2); - - /** - * Draws a horizontal line using the currently set color - */ - void hLine(int x1, int x2, int y); - - /** - * Draws a vertical line using an Xor on each pixel - */ - void vLineXor(int x, int y1, int y2); - - /** - * Draws a horizontal line using an Xor on each pixel - */ - void hLineXor(int x1, int x2, int y); - /** * Draws an arbitrary line on the screen using a specified color * @param startPos Starting position @@ -133,32 +101,6 @@ public: */ void line(const Common::Point &startPos, const Common::Point &endPos, byte color); - /** - * Draws a rectangular frame using the currently set color - * @param r Bounds for rectangle - */ - void frameRect(const Common::Rect &r); - - /** - * Draws a rectangular frame using the currently set color - * @param r Bounds for rectangle - * @param color Color to use - */ - void frameRect(const Common::Rect &r, byte color); - - /** - * Draws a filled in box using the currently set color - * @param r Bounds for rectangle - */ - void fillRect(const Common::Rect &r); - - /** - * Draws a filled in box using the currently set color - * @param r Bounds for rectangle - * @param color Color to use - */ - void fillRect(const Common::Rect &r, byte color); - /** * Draws a sprite * @param pt Position to draw sprite at -- cgit v1.2.3 From c49d7196fcabf18d9e97711f67b864808ca7848a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 25 Feb 2014 23:10:51 -0500 Subject: MADS: In progress implementation of loadScene --- engines/mads/msurface.h | 73 +++++-------------------------------------------- 1 file changed, 7 insertions(+), 66 deletions(-) (limited to 'engines/mads/msurface.h') diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index 3904aa1e92..209ac97d58 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -50,24 +50,19 @@ struct SpriteInfo { * MADS graphics surface */ class MSurface : public Graphics::Surface { -public: +private: static MADSEngine *_vm; - +public: /** - * Sets the engine reference + * Sets the engine refrence used all surfaces */ static void setVm(MADSEngine *vm) { _vm = vm; } /** - * Create a new surface. - */ - static MSurface *init(); - - /** - * Create a surface + * Helper method for calculating new dimensions when scaling a sprite */ - static MSurface *init(int width, int height); -protected: + static int scaleValue(int value, int scale, int err); +public: /** * Basic constructor */ @@ -77,12 +72,7 @@ protected: * Constructor for a surface with fixed dimensions */ MSurface(int width, int height); -public: - /** - * Helper method for calculating new dimensions when scaling a sprite - */ - static int scaleValue(int value, int scale, int err); -public: + /** * Destructor */ @@ -182,55 +172,6 @@ public: * Translates the data of a surface using a specified RGBList translation matrix. */ void translate(RGBList *list, bool isTransparent = false); - - // Base virtual methods - /** - * Loads a background by scene name - */ - virtual void loadBackground(const Common::String &sceneName) {} - - /** - * Load background by room number - */ - virtual void loadBackground(int roomNumber, RGBList **palData) = 0; - - /** - * Load background from a passed stream - */ - virtual void loadBackground(Common::SeekableReadStream *source, RGBList **palData) {} - - /** - * Load scene codes from a passed stream - */ - virtual void loadCodes(Common::SeekableReadStream *source) = 0; - - /** - * Load a given user interface by index - */ - virtual void loadInterface(int index, RGBList **palData) {} -}; - -class MSurfaceMADS: public MSurface { - friend class MSurface; -protected: - MSurfaceMADS(): MSurface() {} - MSurfaceMADS(int width, int height): MSurface(width, height) {} -public: - virtual void loadCodes(Common::SeekableReadStream *source); - virtual void loadBackground(const Common::String &sceneName) {} - virtual void loadBackground(int roomNumber, RGBList **palData); - virtual void loadInterface(int index, RGBList **palData); -}; - -class MSurfaceNebular: public MSurfaceMADS { - friend class MSurface; -protected: - MSurfaceNebular(): MSurfaceMADS() {} - MSurfaceNebular(int width, int height): MSurfaceMADS(width, height) {} -private: - void loadBackgroundStream(Common::SeekableReadStream *source, RGBList **palData); -public: - virtual void loadBackground(int roomNumber, RGBList **palData); }; } // End of namespace MADS -- cgit v1.2.3 From badb8d97444767b7d8fea0f877ac044249696a5f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 28 Feb 2014 20:37:42 -0500 Subject: MADS: More work implementing scene info loading --- engines/mads/msurface.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/mads/msurface.h') diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index 209ac97d58..7f4cec3c1c 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -169,9 +169,9 @@ public: } /** - * Translates the data of a surface using a specified RGBList translation matrix. + * Translates the pixels of an image used the passed palette with RGB mapping */ - void translate(RGBList *list, bool isTransparent = false); + void translate(Common::Array &palette); }; } // End of namespace MADS -- cgit v1.2.3 From 23ebeec600f8210601dd45fc42c21a596fa6d127 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 5 Mar 2014 07:27:39 -0500 Subject: MADS: Further implementation of drawElements --- engines/mads/msurface.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'engines/mads/msurface.h') diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index 7f4cec3c1c..7043cd4eff 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -131,11 +131,6 @@ public: */ void empty(); - /** - * Updates the screen with the contents of the surface - */ - void updateScreen(); - /** * Copys a sub-section of another surface into the current one. * @param src Source surface -- cgit v1.2.3 From d98f890029936dfa8139cf8dce4756ec92bc2568 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 5 Mar 2014 09:04:53 -0500 Subject: MADS: Completed implementing drawElements and support methods --- engines/mads/msurface.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'engines/mads/msurface.h') diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index 7043cd4eff..c797033859 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -126,6 +126,11 @@ public: */ byte *getBasePtr(int x, int y) { return (byte *)Graphics::Surface::getBasePtr(x, y); } + /** + * Returns a pointer to a given position within the surface + */ + const byte *getBasePtr(int x, int y) const { return (const byte *)Graphics::Surface::getBasePtr(x, y); } + /** * Clears the surface */ @@ -141,6 +146,17 @@ public: void copyFrom(MSurface *src, const Common::Rect &srcBounds, const Common::Point &destPos, int transparentColor = -1); + /** + * Copys a sub-section of another surface into the current one. + * @param src Source surface + * @param destPos Destination position to draw in current surface + * @param depth Depth of sprite + * @param depthSurface Depth surface to use with sprite depth + * @param transparentColor Transparency palette index + */ + void copyFrom(MSurface *src, const Common::Point &destPos, int depth, MSurface *depthSurface, + int scale, int transparentColor = -1); + /** * Copies the surface to a given destination surface */ @@ -167,6 +183,11 @@ public: * Translates the pixels of an image used the passed palette with RGB mapping */ void translate(Common::Array &palette); + + /** + * Create a new surface which is a flipped horizontal copy of the current one + */ + MSurface *flipHorizontal() const; }; } // End of namespace MADS -- cgit v1.2.3 From a0e955d8d327afa83ad96fe1ce765eeba0ce561f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 5 Mar 2014 20:45:02 -0500 Subject: MADS: More Animation class implementation --- engines/mads/msurface.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'engines/mads/msurface.h') diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index c797033859..bd8142fd1a 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -179,6 +179,18 @@ public: dest->copyFrom(this, srcBounds, destPos, transparentColor); } + /** + * Scroll the screen horizontally by a given amount + * @param xAmount Horizontal amount + */ + void scrollX(int xAmount); + + /** + * Scroll the screen vertically by a given amount + * @param yAmount Vertical amount + */ + void scrollY(int yAmount); + /** * Translates the pixels of an image used the passed palette with RGB mapping */ -- cgit v1.2.3 From a77ed90618664e50705b3e59dd2111faec2f5f39 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 6 Mar 2014 22:31:41 -0500 Subject: MADS: Implementing support methods needed for scene 804 initialisation --- engines/mads/msurface.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'engines/mads/msurface.h') diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index bd8142fd1a..96994170aa 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -202,6 +202,21 @@ public: MSurface *flipHorizontal() const; }; +class DepthSurface : public MSurface { +private: + MADSEngine *_vm; +public: + /** + * Constructor + */ + DepthSurface(MADSEngine *vm) : _vm(vm) {} + + /** + * Returns the depth at a given position + */ + int getDepth(const Common::Point &pt); +}; + } // End of namespace MADS #endif /* MADS_MSURFACE_H */ -- cgit v1.2.3 From 680b5a4487a6c1b08f79c4a657b63715e69240de Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 10 Mar 2014 00:00:39 -0400 Subject: MADS: In progress implementation of PaletteUsage::process --- engines/mads/msurface.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/msurface.h') diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index 96994170aa..d5b8741188 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -50,7 +50,7 @@ struct SpriteInfo { * MADS graphics surface */ class MSurface : public Graphics::Surface { -private: +protected: static MADSEngine *_vm; public: /** -- cgit v1.2.3 From ca6cf0eaf2692ac5c787b86e193e8e6980d2b7ee Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 15 Mar 2014 18:52:44 -0400 Subject: MADS: Fix display of user interface during animation --- engines/mads/msurface.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'engines/mads/msurface.h') diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index d5b8741188..37ab305fb0 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -50,6 +50,8 @@ struct SpriteInfo { * MADS graphics surface */ class MSurface : public Graphics::Surface { +private: + bool _freeFlag; protected: static MADSEngine *_vm; public: @@ -83,6 +85,12 @@ public: */ void setSize(int width, int height); + /** + * Sets the pixels the surface is associated with + * @remarks The surface will not free the data block + */ + void setPixels(byte *pData, int horizSize, int vertSize); + /** * Draws an arbitrary line on the screen using a specified color * @param startPos Starting position -- cgit v1.2.3 From f3415b762eede6481cbfcb48faecfec505150eab Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 16 Mar 2014 14:53:10 -0400 Subject: MADS: Implemented lots of Player methods --- engines/mads/msurface.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/mads/msurface.h') diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index 37ab305fb0..7cf2bbe15b 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -223,6 +223,10 @@ public: * Returns the depth at a given position */ int getDepth(const Common::Point &pt); + + /** + */ + int getDepthHighBit(const Common::Point &pt); }; } // End of namespace MADS -- cgit v1.2.3 From 58378a0965dd2a0631973786500b0fd171b8f680 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 19 Apr 2014 19:20:57 -0400 Subject: MADS: Implemented MSurface::mergeFrom method --- engines/mads/msurface.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'engines/mads/msurface.h') diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index 7cf2bbe15b..f590bac2e5 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -187,6 +187,14 @@ public: dest->copyFrom(this, srcBounds, destPos, transparentColor); } + /** + * Merges a sub-section of another surface into the current one. + * @param src Source surface + * @param srcBounds Area to copy/merge from + * @param destPos Destination position to draw in current surface + */ + void mergeFrom(MSurface *src, const Common::Rect &srcBounds, const Common::Point &destPos); + /** * Scroll the screen horizontally by a given amount * @param xAmount Horizontal amount -- cgit v1.2.3 From ff70186855bec22fe77043d89917b189218ff856 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 21 Apr 2014 19:12:28 -0400 Subject: MADS: Improve background user interface sprite animations --- engines/mads/msurface.h | 8 -------- 1 file changed, 8 deletions(-) (limited to 'engines/mads/msurface.h') diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index f590bac2e5..7cf2bbe15b 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -187,14 +187,6 @@ public: dest->copyFrom(this, srcBounds, destPos, transparentColor); } - /** - * Merges a sub-section of another surface into the current one. - * @param src Source surface - * @param srcBounds Area to copy/merge from - * @param destPos Destination position to draw in current surface - */ - void mergeFrom(MSurface *src, const Common::Rect &srcBounds, const Common::Point &destPos); - /** * Scroll the screen horizontally by a given amount * @param xAmount Horizontal amount -- cgit v1.2.3 From b7dd01fdefd910c3c0f6291145ceab4060ae1a70 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 8 May 2014 11:43:23 +0300 Subject: MADS: Remove trailing whitespace --- engines/mads/msurface.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/mads/msurface.h') diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index 7cf2bbe15b..060a7ab540 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -63,7 +63,7 @@ public: /** * Helper method for calculating new dimensions when scaling a sprite */ - static int scaleValue(int value, int scale, int err); + static int scaleValue(int value, int scale, int err); public: /** * Basic constructor @@ -128,7 +128,7 @@ public: * Returns a pointer to the surface data */ byte *getData() { return (byte *)Graphics::Surface::getPixels(); } - + /** * Returns a pointer to a given position within the surface */ @@ -168,8 +168,8 @@ public: /** * Copies the surface to a given destination surface */ - void copyTo(MSurface *dest, int transparentColor = -1) { - dest->copyFrom(this, Common::Rect(w, h), Common::Point(), transparentColor); + void copyTo(MSurface *dest, int transparentColor = -1) { + dest->copyFrom(this, Common::Rect(w, h), Common::Point(), transparentColor); } /** -- cgit v1.2.3 From 8abcbf3fb08fbca6f0cfdb9eabd22cf56e83b440 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 11 May 2014 18:08:31 -0400 Subject: MADS: Refactoring of dialog classes, more implementation of PictureDialog --- engines/mads/msurface.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'engines/mads/msurface.h') diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index 060a7ab540..fbd927084a 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -204,6 +204,11 @@ public: */ void translate(Common::Array &palette); + /** + * Translates the pixels of an image used the passed palette with RGB mapping + */ + void translate(byte map[PALETTE_COUNT]); + /** * Create a new surface which is a flipped horizontal copy of the current one */ -- cgit v1.2.3 From ea19581ae30bed434da8c9426c7b6defd702fc88 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 25 May 2014 13:23:05 -0400 Subject: MADS: Standardised on passing depth surfaces as DepthSurface --- engines/mads/msurface.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/mads/msurface.h') diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index fbd927084a..e3cf89d649 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -32,6 +32,7 @@ namespace MADS { class MADSEngine; class MSprite; +class DepthSurface; /** * Basic sprite information @@ -162,7 +163,7 @@ public: * @param depthSurface Depth surface to use with sprite depth * @param transparentColor Transparency palette index */ - void copyFrom(MSurface *src, const Common::Point &destPos, int depth, MSurface *depthSurface, + void copyFrom(MSurface *src, const Common::Point &destPos, int depth, DepthSurface *depthSurface, int scale, int transparentColor = -1); /** -- cgit v1.2.3 From 9099b36caa88d7675a03fb0bd283acf4e1122474 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 27 May 2014 00:58:25 +0200 Subject: MADS: initialise -> initialize. --- engines/mads/msurface.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/msurface.h') diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index e3cf89d649..8ad0b1cda4 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -82,7 +82,7 @@ public: virtual ~MSurface(); /** - * Reinitialises a surface to have a given set of dimensions + * Reinitializes a surface to have a given set of dimensions */ void setSize(int width, int height); -- cgit v1.2.3 From 06387c25d8e908f174d081769b94dd0625e00b58 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 29 May 2014 21:35:59 -0400 Subject: MADS: Fix positioning of teleporter window backgrounds --- engines/mads/msurface.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'engines/mads/msurface.h') diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index 8ad0b1cda4..985a097d4a 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -161,11 +161,26 @@ public: * @param destPos Destination position to draw in current surface * @param depth Depth of sprite * @param depthSurface Depth surface to use with sprite depth + * @param scale Scale for image * @param transparentColor Transparency palette index */ void copyFrom(MSurface *src, const Common::Point &destPos, int depth, DepthSurface *depthSurface, int scale, int transparentColor = -1); + /** + * Copys a sub-section of another surface into the current one, taking into + * account variation in the destination copy position based on item size + * and scaling. + * @param src Source surface + * @param destPos Destination position to draw in current surface + * @param depth Depth of sprite + * @param depthSurface Depth surface to use with sprite depth + * @param scale Scale for image + * @param transparentColor Transparency palette index + */ + void copyFromScaled(MSurface *src, const Common::Point &destPos, int depth, DepthSurface *depthSurface, + int scale, int transparentColor = -1); + /** * Copies the surface to a given destination surface */ -- cgit v1.2.3 From 7d24e1471c445fbf49b3efbb8d046eb26db849cd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 31 May 2014 18:21:11 -0400 Subject: MADS: Merge copyFromScaled into the existing copyFrom method --- engines/mads/msurface.h | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'engines/mads/msurface.h') diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index 985a097d4a..dec36e7caf 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -167,20 +167,6 @@ public: void copyFrom(MSurface *src, const Common::Point &destPos, int depth, DepthSurface *depthSurface, int scale, int transparentColor = -1); - /** - * Copys a sub-section of another surface into the current one, taking into - * account variation in the destination copy position based on item size - * and scaling. - * @param src Source surface - * @param destPos Destination position to draw in current surface - * @param depth Depth of sprite - * @param depthSurface Depth surface to use with sprite depth - * @param scale Scale for image - * @param transparentColor Transparency palette index - */ - void copyFromScaled(MSurface *src, const Common::Point &destPos, int depth, DepthSurface *depthSurface, - int scale, int transparentColor = -1); - /** * Copies the surface to a given destination surface */ -- cgit v1.2.3 From 8f20ebb610b9f6be0a4ef8d417318b3e6f0c965f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 31 May 2014 21:10:29 -0400 Subject: MADS: Fix positioning and clipping of flipped scaled images --- engines/mads/msurface.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/mads/msurface.h') diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index dec36e7caf..ef2bbd6784 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -162,10 +162,11 @@ public: * @param depth Depth of sprite * @param depthSurface Depth surface to use with sprite depth * @param scale Scale for image + * @param flipped Flag for whether image is to be flipped * @param transparentColor Transparency palette index */ void copyFrom(MSurface *src, const Common::Point &destPos, int depth, DepthSurface *depthSurface, - int scale, int transparentColor = -1); + int scale, bool flipped, int transparentColor = -1); /** * Copies the surface to a given destination surface -- cgit v1.2.3