2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
2006-02-22 22:40:53 +00:00
|
|
|
*
|
2007-05-30 21:56:52 +00:00
|
|
|
* 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.
|
2006-02-22 22:40:53 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2006-12-03 18:29:58 +00:00
|
|
|
#ifndef CINE_GFX_H
|
|
|
|
#define CINE_GFX_H
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
#include "common/noncopyable.h"
|
2009-09-22 17:51:06 +00:00
|
|
|
#include "common/rect.h"
|
|
|
|
#include "common/stack.h"
|
2008-05-24 22:11:41 +00:00
|
|
|
#include "cine/object.h"
|
2012-08-14 03:12:07 +00:00
|
|
|
#include "cine/bg_list.h"
|
2008-05-24 22:11:41 +00:00
|
|
|
|
2006-02-25 00:26:14 +00:00
|
|
|
namespace Cine {
|
|
|
|
|
2009-06-11 18:32:35 +00:00
|
|
|
extern byte *collisionPage;
|
|
|
|
static const int kCollisionPageBgIdxAlias = 8;
|
|
|
|
|
2010-04-21 21:22:43 +00:00
|
|
|
/**
|
|
|
|
* Background with palette
|
2008-05-24 22:11:41 +00:00
|
|
|
*/
|
|
|
|
struct palBg {
|
|
|
|
byte *bg; ///< Background data
|
2009-06-08 20:46:21 +00:00
|
|
|
Cine::Palette pal; ///< Background color palette
|
2008-05-24 22:11:41 +00:00
|
|
|
char name[15]; ///< Background filename
|
2009-06-11 18:32:35 +00:00
|
|
|
|
|
|
|
/** @brief Default constructor. */
|
|
|
|
palBg() : bg(NULL), pal(), name() {
|
|
|
|
// Make sure the name is empty (Maybe this is not needed?)
|
|
|
|
memset(this->name, 0, sizeof(this->name));
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @brief Clears the struct (Releases allocated memory etc). */
|
|
|
|
void clear() {
|
|
|
|
// In Operation Stealth the 9th background is sometimes aliased to
|
|
|
|
// the collision page so we should take care not to double delete it
|
|
|
|
// (The collision page is deleted elsewhere).
|
|
|
|
if (this->bg != collisionPage) {
|
|
|
|
delete[] this->bg;
|
|
|
|
}
|
|
|
|
this->bg = NULL;
|
|
|
|
this->pal.clear();
|
|
|
|
memset(this->name, 0, sizeof(this->name));
|
|
|
|
}
|
2008-05-24 22:11:41 +00:00
|
|
|
};
|
|
|
|
|
2009-09-22 17:51:06 +00:00
|
|
|
class FWRenderer;
|
|
|
|
|
|
|
|
class Menu {
|
|
|
|
public:
|
|
|
|
enum Type {
|
|
|
|
kSelectionMenu,
|
|
|
|
kTextInputMenu
|
|
|
|
};
|
|
|
|
|
|
|
|
Menu(Type t) : _type(t) {}
|
|
|
|
virtual ~Menu() {}
|
|
|
|
|
|
|
|
Type getType() const { return _type; }
|
|
|
|
|
|
|
|
virtual void drawMenu(FWRenderer &r, bool top) = 0;
|
|
|
|
private:
|
|
|
|
const Type _type;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SelectionMenu : public Menu {
|
|
|
|
public:
|
2010-03-18 15:54:40 +00:00
|
|
|
SelectionMenu(Common::Point p, int width, Common::StringArray elements);
|
2009-09-22 17:51:06 +00:00
|
|
|
|
|
|
|
int getElementCount() const { return _elements.size(); }
|
|
|
|
|
|
|
|
void setSelection(int selection);
|
|
|
|
|
|
|
|
void drawMenu(FWRenderer &r, bool top);
|
|
|
|
private:
|
|
|
|
const Common::Point _pos;
|
|
|
|
const int _width;
|
2010-03-18 15:54:40 +00:00
|
|
|
const Common::StringArray _elements;
|
2009-09-22 17:51:06 +00:00
|
|
|
|
|
|
|
int _selection;
|
|
|
|
};
|
|
|
|
|
|
|
|
class TextInputMenu : public Menu {
|
|
|
|
public:
|
|
|
|
TextInputMenu(Common::Point p, int width, const char *info);
|
|
|
|
|
|
|
|
void setInput(const char *input, int cursor);
|
|
|
|
|
|
|
|
void drawMenu(FWRenderer &r, bool top);
|
|
|
|
private:
|
|
|
|
const Common::Point _pos;
|
|
|
|
const int _width;
|
|
|
|
const Common::String _info;
|
|
|
|
|
|
|
|
Common::String _input;
|
|
|
|
int _cursor;
|
|
|
|
};
|
|
|
|
|
2010-04-21 21:22:43 +00:00
|
|
|
/**
|
|
|
|
* Future Wars renderer
|
2008-05-24 22:11:41 +00:00
|
|
|
*
|
2009-09-22 17:51:06 +00:00
|
|
|
* Screen backbuffer is not cleared between frames.
|
2008-05-24 22:11:41 +00:00
|
|
|
*/
|
|
|
|
class FWRenderer : public Common::NonCopyable {
|
2009-09-22 17:51:06 +00:00
|
|
|
// TODO: Consider getting rid of this
|
|
|
|
friend class SelectionMenu;
|
|
|
|
friend class TextInputMenu;
|
2008-05-24 22:11:41 +00:00
|
|
|
private:
|
|
|
|
byte *_background; ///< Current background
|
|
|
|
char _bgName[13]; ///< Background filename
|
|
|
|
|
|
|
|
Common::String _cmd; ///< Player command string
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static const int _screenSize = 320 * 200; ///< Screen size
|
|
|
|
static const int _screenWidth = 320; ///< Screen width
|
|
|
|
static const int _screenHeight = 200; ///< Screen height
|
|
|
|
|
|
|
|
byte *_backBuffer; ///< Screen backbuffer
|
2009-06-08 20:46:21 +00:00
|
|
|
Cine::Palette _backupPal; ///< The backup color palette
|
|
|
|
Cine::Palette _activePal; ///< The active color palette
|
2009-09-22 17:51:06 +00:00
|
|
|
Common::Stack<Menu *> _menuStack; ///< All displayed menus
|
2008-05-24 22:11:41 +00:00
|
|
|
int _changePal; ///< Load active palette to video backend on next frame
|
2008-08-14 22:01:56 +00:00
|
|
|
bool _showCollisionPage; ///< Should we show the collision page instead of the back buffer? Used for debugging.
|
2008-05-24 22:11:41 +00:00
|
|
|
|
2009-09-20 23:34:48 +00:00
|
|
|
void fillSprite(const ObjectStruct &obj, uint8 color = 0);
|
|
|
|
void drawMaskedSprite(const ObjectStruct &obj, const byte *mask);
|
|
|
|
virtual void drawSprite(const ObjectStruct &obj);
|
2008-05-24 22:11:41 +00:00
|
|
|
|
|
|
|
void drawCommand();
|
2008-08-11 23:01:32 +00:00
|
|
|
void drawMessage(const char *str, int x, int y, int width, int color);
|
2008-05-24 22:11:41 +00:00
|
|
|
void drawPlainBox(int x, int y, int width, int height, byte color);
|
2009-09-21 01:15:34 +00:00
|
|
|
void drawTransparentBox(int x, int y, int width, int height);
|
2008-05-24 22:11:41 +00:00
|
|
|
void drawBorder(int x, int y, int width, int height, byte color);
|
|
|
|
void drawDoubleBorder(int x, int y, int width, int height, byte color);
|
|
|
|
virtual int drawChar(char character, int x, int y);
|
2012-09-06 22:19:23 +00:00
|
|
|
virtual int undrawChar(char character, int x, int y);
|
2008-05-24 22:11:41 +00:00
|
|
|
void drawLine(int x, int y, int width, int height, byte color);
|
|
|
|
void remaskSprite(byte *mask, Common::List<overlay>::iterator it);
|
|
|
|
virtual void drawBackground();
|
|
|
|
|
|
|
|
virtual void renderOverlay(const Common::List<overlay>::iterator &it);
|
|
|
|
void drawOverlays();
|
|
|
|
|
2009-09-22 17:51:06 +00:00
|
|
|
void blit();
|
2010-05-19 12:17:59 +00:00
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
public:
|
|
|
|
uint16 _messageBg; ///< Message box background color
|
|
|
|
uint16 _cmdY; ///< Player command string position on screen
|
|
|
|
|
|
|
|
FWRenderer();
|
|
|
|
virtual ~FWRenderer();
|
|
|
|
|
2009-08-25 23:11:17 +00:00
|
|
|
virtual bool initialize();
|
|
|
|
|
2010-04-21 21:22:43 +00:00
|
|
|
/** Test if renderer is ready to draw */
|
2008-05-24 22:11:41 +00:00
|
|
|
virtual bool ready() { return _background != NULL; }
|
|
|
|
|
|
|
|
virtual void clear();
|
|
|
|
|
|
|
|
void drawFrame();
|
2008-08-12 00:13:27 +00:00
|
|
|
void setCommand(Common::String cmd);
|
2008-05-24 22:11:41 +00:00
|
|
|
|
2012-08-14 03:12:07 +00:00
|
|
|
virtual void incrustMask(const BGIncrust &incrust, uint8 color = 0);
|
|
|
|
virtual void incrustSprite(const BGIncrust &incrust);
|
2008-05-24 22:11:41 +00:00
|
|
|
|
2008-10-22 20:45:25 +00:00
|
|
|
virtual void loadBg16(const byte *bg, const char *name, unsigned int idx = 0);
|
2008-05-24 22:11:41 +00:00
|
|
|
virtual void loadCt16(const byte *ct, const char *name);
|
2008-10-22 20:45:25 +00:00
|
|
|
virtual void loadBg256(const byte *bg, const char *name, unsigned int idx = 0);
|
2008-05-24 22:11:41 +00:00
|
|
|
virtual void loadCt256(const byte *ct, const char *name);
|
|
|
|
virtual void selectBg(unsigned int idx);
|
|
|
|
virtual void selectScrollBg(unsigned int idx);
|
|
|
|
virtual void setScroll(unsigned int shift);
|
2008-07-28 16:02:40 +00:00
|
|
|
virtual uint getScroll() const;
|
2008-05-24 22:11:41 +00:00
|
|
|
virtual void removeBg(unsigned int idx);
|
2008-07-27 22:50:36 +00:00
|
|
|
virtual void saveBgNames(Common::OutSaveFile &fHandle);
|
2008-08-06 20:41:53 +00:00
|
|
|
virtual const char *getBgName(uint idx = 0) const;
|
2008-05-24 22:11:41 +00:00
|
|
|
|
|
|
|
virtual void refreshPalette();
|
|
|
|
virtual void reloadPalette();
|
2010-06-15 10:17:18 +00:00
|
|
|
virtual void restorePalette(Common::SeekableReadStream &fHandle, int version);
|
2008-07-27 22:50:36 +00:00
|
|
|
virtual void savePalette(Common::OutSaveFile &fHandle);
|
2008-05-24 22:11:41 +00:00
|
|
|
virtual void rotatePalette(int a, int b, int c);
|
|
|
|
virtual void transformPalette(int first, int last, int r, int g, int b);
|
|
|
|
|
2009-09-22 17:51:06 +00:00
|
|
|
void pushMenu(Menu *menu);
|
|
|
|
Menu *popMenu();
|
|
|
|
void clearMenuStack();
|
2008-05-24 22:11:41 +00:00
|
|
|
|
|
|
|
virtual void fadeToBlack();
|
2008-08-14 22:01:56 +00:00
|
|
|
void showCollisionPage(bool state);
|
2010-05-19 12:17:59 +00:00
|
|
|
|
|
|
|
void drawString(const char *string, byte param);
|
|
|
|
int getStringWidth(const char *str);
|
2008-05-24 22:11:41 +00:00
|
|
|
};
|
|
|
|
|
2010-04-21 21:22:43 +00:00
|
|
|
/**
|
|
|
|
* Operation Stealth renderer
|
2008-05-24 22:11:41 +00:00
|
|
|
*/
|
|
|
|
class OSRenderer : public FWRenderer {
|
|
|
|
private:
|
2009-06-11 18:32:35 +00:00
|
|
|
Common::Array<palBg> _bgTable; ///< Table of backgrounds loaded into renderer (Maximum is 9)
|
2008-05-24 22:11:41 +00:00
|
|
|
unsigned int _currentBg; ///< Current background
|
|
|
|
unsigned int _scrollBg; ///< Current scroll background
|
|
|
|
unsigned int _bgShift; ///< Background shift
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2009-09-20 23:34:48 +00:00
|
|
|
void drawSprite(const ObjectStruct &obj);
|
2012-08-10 06:19:46 +00:00
|
|
|
void drawSprite(overlay *overlayPtr, const byte *spritePtr, int16 width, int16 height, byte *page, int16 x, int16 y, byte transparentColor, byte bpp);
|
2008-05-24 22:11:41 +00:00
|
|
|
int drawChar(char character, int x, int y);
|
|
|
|
void drawBackground();
|
|
|
|
void renderOverlay(const Common::List<overlay>::iterator &it);
|
|
|
|
|
|
|
|
public:
|
|
|
|
OSRenderer();
|
|
|
|
~OSRenderer();
|
|
|
|
|
2009-08-25 23:11:17 +00:00
|
|
|
bool initialize();
|
|
|
|
|
2010-04-21 21:22:43 +00:00
|
|
|
/** Test if renderer is ready to draw */
|
2008-05-24 22:11:41 +00:00
|
|
|
bool ready() { return _bgTable[_currentBg].bg != NULL; }
|
|
|
|
|
|
|
|
void clear();
|
|
|
|
|
2012-08-14 03:12:07 +00:00
|
|
|
void incrustMask(const BGIncrust &incrust, uint8 color = 0);
|
|
|
|
void incrustSprite(const BGIncrust &incrust);
|
2008-05-24 22:11:41 +00:00
|
|
|
|
2008-10-22 20:45:25 +00:00
|
|
|
void loadBg16(const byte *bg, const char *name, unsigned int idx = 0);
|
2008-05-24 22:11:41 +00:00
|
|
|
void loadCt16(const byte *ct, const char *name);
|
2008-10-22 20:45:25 +00:00
|
|
|
void loadBg256(const byte *bg, const char *name, unsigned int idx = 0);
|
2008-05-24 22:11:41 +00:00
|
|
|
void loadCt256(const byte *ct, const char *name);
|
|
|
|
void selectBg(unsigned int idx);
|
|
|
|
void selectScrollBg(unsigned int idx);
|
|
|
|
void setScroll(unsigned int shift);
|
2008-07-28 16:02:40 +00:00
|
|
|
uint getScroll() const;
|
2008-05-24 22:11:41 +00:00
|
|
|
void removeBg(unsigned int idx);
|
2008-07-27 22:50:36 +00:00
|
|
|
void saveBgNames(Common::OutSaveFile &fHandle);
|
2008-08-06 20:41:53 +00:00
|
|
|
const char *getBgName(uint idx = 0) const;
|
2008-05-24 22:11:41 +00:00
|
|
|
|
|
|
|
void reloadPalette();
|
2010-06-15 10:17:18 +00:00
|
|
|
void restorePalette(Common::SeekableReadStream &fHandle, int version);
|
2008-07-27 22:50:36 +00:00
|
|
|
void savePalette(Common::OutSaveFile &fHandle);
|
2008-05-24 22:11:41 +00:00
|
|
|
void transformPalette(int first, int last, int r, int g, int b);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2006-03-23 03:45:52 +00:00
|
|
|
void gfxDrawSprite(byte *src4, uint16 sw, uint16 sh, byte *dst4, int16 sx, int16 sy);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
extern FWRenderer *renderer;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-03-15 22:34:46 +00:00
|
|
|
void setMouseCursor(int cursor);
|
2006-03-23 03:45:52 +00:00
|
|
|
void gfxCopyPage(byte *source, byte *dest);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-03-23 03:45:52 +00:00
|
|
|
void transformPaletteRange(byte startColor, byte numColor, int8 r, int8 g, int8 b);
|
2009-11-02 21:54:57 +00:00
|
|
|
void gfxFlipPage();
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-04-07 20:24:40 +00:00
|
|
|
void gfxDrawMaskedSprite(const byte *ptr, const byte *msk, uint16 width, uint16 height, byte *page, int16 x, int16 y);
|
|
|
|
void gfxFillSprite(const byte *src4, uint16 sw, uint16 sh, byte *dst4, int16 sx, int16 sy, uint8 fillColor = 0);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-04-21 20:51:17 +00:00
|
|
|
void gfxUpdateSpriteMask(byte *destMask, int16 x, int16 y, int16 width, int16 height, const byte *maskPtr, int16 xm, int16 ym, int16 maskWidth, int16 maskHeight);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-03-23 03:45:52 +00:00
|
|
|
void gfxDrawLine(int16 x1, int16 y1, int16 x2, int16 y2, byte color, byte *page);
|
|
|
|
void gfxDrawPlainBox(int16 x1, int16 y1, int16 x2, int16 y2, byte color);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-03-23 03:45:52 +00:00
|
|
|
void gfxResetPage(byte *pagePtr);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-04-07 20:24:40 +00:00
|
|
|
int16 gfxGetBit(int16 x, int16 y, const byte *ptr, int16 width);
|
|
|
|
byte gfxGetColor(int16 x, int16 y, const byte *ptr, int16 width);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-03-23 03:45:52 +00:00
|
|
|
void gfxResetRawPage(byte *pageRaw);
|
2007-12-08 09:10:08 +00:00
|
|
|
void gfxConvertSpriteToRaw(byte *dst, const byte *src, uint16 w, uint16 h);
|
2012-09-06 18:28:19 +00:00
|
|
|
void gfxCopyRawPage(byte *source, byte *dest);
|
2006-03-23 03:45:52 +00:00
|
|
|
void gfxFlipRawPage(byte *frontBuffer);
|
2008-04-07 20:24:40 +00:00
|
|
|
void drawSpriteRaw(const byte *spritePtr, const byte *maskPtr, int16 width, int16 height, byte *page, int16 x, int16 y);
|
2006-03-23 03:45:52 +00:00
|
|
|
void gfxDrawPlainBoxRaw(int16 x1, int16 y1, int16 x2, int16 y2, byte color, byte *page);
|
2008-04-07 20:24:40 +00:00
|
|
|
void drawSpriteRaw2(const byte *spritePtr, byte transColor, int16 width, int16 height, byte *page, int16 x, int16 y);
|
|
|
|
void maskBgOverlay(const byte *spritePtr, const byte *maskPtr, int16 width, int16 height, byte *page, int16 x, int16 y);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
void fadeFromBlack();
|
|
|
|
void fadeToBlack();
|
2006-11-18 20:57:37 +00:00
|
|
|
|
2008-04-07 20:24:40 +00:00
|
|
|
// wtf?!
|
|
|
|
//void gfxDrawMaskedSprite(byte *param1, byte *param2, byte *param3, byte *param4, int16 param5);
|
2009-11-02 21:54:57 +00:00
|
|
|
void gfxWaitVBL();
|
|
|
|
void gfxRedrawMouseCursor();
|
2007-05-17 22:26:05 +00:00
|
|
|
|
|
|
|
void blitScreen(byte *frontBuffer, byte *backbuffer);
|
|
|
|
void blitRawScreen(byte *frontBuffer);
|
2009-11-02 21:54:57 +00:00
|
|
|
void flip();
|
2007-05-17 22:26:05 +00:00
|
|
|
|
2006-02-25 00:26:14 +00:00
|
|
|
} // End of namespace Cine
|
|
|
|
|
2006-02-22 22:40:53 +00:00
|
|
|
#endif
|