2007-05-30 21:56:52 +00:00
|
|
|
/* 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.
|
2005-08-19 22:12:09 +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
|
2008-01-05 12:45:14 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2005-08-19 22:12:09 +00:00
|
|
|
* 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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-08-19 22:12:09 +00:00
|
|
|
*
|
2006-02-09 12:19:53 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2005-08-19 22:12:09 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-02-20 17:33:54 +00:00
|
|
|
#ifndef KYRA_SCREEN_H
|
|
|
|
#define KYRA_SCREEN_H
|
2005-08-19 22:12:09 +00:00
|
|
|
|
|
|
|
#include "common/util.h"
|
|
|
|
|
2007-10-12 01:26:27 +00:00
|
|
|
#include "kyra/util.h"
|
|
|
|
|
2005-08-19 22:12:09 +00:00
|
|
|
class OSystem;
|
|
|
|
|
|
|
|
namespace Kyra {
|
|
|
|
|
2007-10-12 01:26:27 +00:00
|
|
|
typedef Functor0<void> UpdateFunctor;
|
|
|
|
|
2005-08-19 22:12:09 +00:00
|
|
|
class KyraEngine;
|
2006-01-06 10:45:42 +00:00
|
|
|
struct Rect;
|
2005-08-19 22:12:09 +00:00
|
|
|
|
2005-08-31 20:14:20 +00:00
|
|
|
struct ScreenDim {
|
|
|
|
uint16 sx;
|
|
|
|
uint16 sy;
|
|
|
|
uint16 w;
|
|
|
|
uint16 h;
|
|
|
|
uint16 unk8;
|
|
|
|
uint16 unkA;
|
|
|
|
uint16 unkC;
|
|
|
|
uint16 unkE;
|
|
|
|
};
|
|
|
|
|
2005-09-08 19:09:52 +00:00
|
|
|
struct Font {
|
|
|
|
uint8 *fontData;
|
|
|
|
uint8 *charWidthTable;
|
2006-05-21 15:02:12 +00:00
|
|
|
uint16 charSizeOffset;
|
2005-09-08 19:09:52 +00:00
|
|
|
uint16 charBitmapOffset;
|
|
|
|
uint16 charWidthTableOffset;
|
|
|
|
uint16 charHeightTableOffset;
|
|
|
|
};
|
|
|
|
|
2005-08-19 22:12:09 +00:00
|
|
|
class Screen {
|
2007-07-29 16:31:29 +00:00
|
|
|
friend class Debugger_v1;
|
2005-08-19 22:12:09 +00:00
|
|
|
public:
|
|
|
|
|
2005-09-08 19:09:52 +00:00
|
|
|
enum {
|
|
|
|
SCREEN_W = 320,
|
|
|
|
SCREEN_H = 200,
|
|
|
|
SCREEN_PAGE_SIZE = 320 * 200 + 1024,
|
2007-02-12 18:01:51 +00:00
|
|
|
SCREEN_OVL_SJIS_SIZE = 640 * 400,
|
|
|
|
SCREEN_PAGE_NUM = 16,
|
2008-01-12 07:59:39 +00:00
|
|
|
SCREEN_OVLS_NUM = 4
|
2005-09-08 19:09:52 +00:00
|
|
|
};
|
|
|
|
|
2005-10-18 20:38:30 +00:00
|
|
|
enum CopyRegionFlags {
|
|
|
|
CR_X_FLIPPED = 0x01,
|
2006-04-17 19:52:31 +00:00
|
|
|
CR_CLIPPED = 0x02,
|
|
|
|
CR_NO_P_CHECK = 0x04
|
2005-10-18 20:38:30 +00:00
|
|
|
};
|
|
|
|
|
2005-09-08 19:09:52 +00:00
|
|
|
enum DrawShapeFlags {
|
|
|
|
DSF_X_FLIPPED = 0x01,
|
|
|
|
DSF_Y_FLIPPED = 0x02,
|
|
|
|
DSF_SCALE = 0x04,
|
|
|
|
DSF_WND_COORDS = 0x10,
|
|
|
|
DSF_CENTER = 0x20
|
|
|
|
};
|
|
|
|
|
|
|
|
enum FontId {
|
|
|
|
FID_6_FNT = 0,
|
|
|
|
FID_8_FNT,
|
2006-01-07 23:55:50 +00:00
|
|
|
FID_CRED6_FNT,
|
|
|
|
FID_CRED8_FNT,
|
2006-07-30 07:51:11 +00:00
|
|
|
FID_BOOKFONT_FNT,
|
2006-08-27 12:30:38 +00:00
|
|
|
FID_GOLDFONT_FNT,
|
2005-09-08 19:09:52 +00:00
|
|
|
FID_NUM
|
|
|
|
};
|
|
|
|
|
2005-08-19 22:12:09 +00:00
|
|
|
Screen(KyraEngine *vm, OSystem *system);
|
2007-07-29 16:31:29 +00:00
|
|
|
virtual ~Screen();
|
2005-08-19 22:12:09 +00:00
|
|
|
|
2006-05-03 13:40:21 +00:00
|
|
|
bool init();
|
|
|
|
|
2005-08-19 22:12:09 +00:00
|
|
|
void updateScreen();
|
2007-02-11 01:38:15 +00:00
|
|
|
|
2007-09-23 23:37:01 +00:00
|
|
|
// debug functions
|
|
|
|
bool queryScreenDebug() const { return _debugEnabled; }
|
|
|
|
bool enableScreenDebug(bool enable);
|
|
|
|
|
2007-02-11 01:38:15 +00:00
|
|
|
// page cur. functions
|
2005-08-19 22:12:09 +00:00
|
|
|
int setCurPage(int pageNum);
|
2007-02-11 01:38:15 +00:00
|
|
|
|
|
|
|
void copyFromCurPageBlock(int x, int y, int w, int h, const uint8 *src);
|
|
|
|
void copyCurPageBlock(int x, int y, int w, int h, uint8 *dst);
|
|
|
|
|
2005-08-19 22:12:09 +00:00
|
|
|
void clearCurPage();
|
2007-02-11 01:38:15 +00:00
|
|
|
|
|
|
|
// page 0 functions
|
|
|
|
void copyToPage0(int y, int h, uint8 page, uint8 *seqBuf);
|
|
|
|
void shakeScreen(int times);
|
|
|
|
|
|
|
|
// page functions
|
|
|
|
void copyRegion(int x1, int y1, int x2, int y2, int w, int h, int srcPage, int dstPage, int flags=0);
|
|
|
|
void copyPage(uint8 srcPage, uint8 dstPage);
|
|
|
|
|
|
|
|
void copyRegionToBuffer(int pageNum, int x, int y, int w, int h, uint8 *dest);
|
|
|
|
void copyBlockToPage(int pageNum, int x, int y, int w, int h, const uint8 *src);
|
|
|
|
|
|
|
|
void shuffleScreen(int sx, int sy, int w, int h, int srcPage, int dstPage, int ticks, bool transparent);
|
|
|
|
void fillRect(int x1, int y1, int x2, int y2, uint8 color, int pageNum = -1);
|
|
|
|
|
|
|
|
void clearPage(int pageNum);
|
|
|
|
|
2005-09-02 11:12:09 +00:00
|
|
|
uint8 getPagePixel(int pageNum, int x, int y);
|
|
|
|
void setPagePixel(int pageNum, int x, int y, uint8 color);
|
2007-02-11 01:38:15 +00:00
|
|
|
|
|
|
|
const uint8 *getCPagePtr(int pageNum) const;
|
|
|
|
uint8 *getPageRect(int pageNum, int x, int y, int w, int h);
|
|
|
|
|
|
|
|
// palette handling
|
2007-10-12 01:26:27 +00:00
|
|
|
void fadeFromBlack(int delay=0x54, const UpdateFunctor *upFunc = 0);
|
|
|
|
void fadeToBlack(int delay=0x54, const UpdateFunctor *upFunc = 0);
|
2007-02-11 01:38:15 +00:00
|
|
|
|
2007-10-12 01:26:27 +00:00
|
|
|
void fadePalette(const uint8 *palData, int delay, const UpdateFunctor *upFunc = 0);
|
2007-02-11 01:38:15 +00:00
|
|
|
|
2006-03-18 04:41:34 +00:00
|
|
|
void setPaletteIndex(uint8 index, uint8 red, uint8 green, uint8 blue);
|
2005-08-19 22:12:09 +00:00
|
|
|
void setScreenPalette(const uint8 *palData);
|
2007-02-11 01:38:15 +00:00
|
|
|
uint8 *getPalette(int num);
|
|
|
|
|
|
|
|
// gui specific (processing on _curPage)
|
2006-09-15 16:04:32 +00:00
|
|
|
void drawLine(bool vertical, int x, int y, int length, int color);
|
2006-01-13 03:27:01 +00:00
|
|
|
void drawClippedLine(int x1, int y1, int x2, int y2, int color);
|
2006-01-22 09:34:12 +00:00
|
|
|
void drawShadedBox(int x1, int y1, int x2, int y2, int color1, int color2);
|
|
|
|
void drawBox(int x1, int y1, int x2, int y2, int color);
|
2007-02-11 01:38:15 +00:00
|
|
|
|
|
|
|
// font/text handling
|
2006-07-16 19:44:39 +00:00
|
|
|
bool loadFont(FontId fontId, const char *filename);
|
2005-09-08 19:09:52 +00:00
|
|
|
FontId setFont(FontId fontId);
|
2007-02-11 01:38:15 +00:00
|
|
|
|
2006-05-18 22:46:34 +00:00
|
|
|
int getFontHeight() const;
|
2006-05-21 15:02:12 +00:00
|
|
|
int getFontWidth() const;
|
2007-02-11 01:38:15 +00:00
|
|
|
|
2007-02-12 18:01:51 +00:00
|
|
|
int getCharWidth(uint16 c) const;
|
2005-08-19 22:12:09 +00:00
|
|
|
int getTextWidth(const char *str) const;
|
2007-02-11 01:38:15 +00:00
|
|
|
|
2005-08-19 22:12:09 +00:00
|
|
|
void printText(const char *str, int x, int y, uint8 color1, uint8 color2);
|
2007-02-11 01:38:15 +00:00
|
|
|
|
|
|
|
void setTextColorMap(const uint8 *cmap);
|
|
|
|
void setTextColor(const uint8 *cmap, int a, int b);
|
|
|
|
|
2007-07-29 16:33:11 +00:00
|
|
|
virtual void setScreenDim(int dim);
|
2007-02-11 01:38:15 +00:00
|
|
|
|
|
|
|
// shape handling
|
2005-10-22 12:59:16 +00:00
|
|
|
uint8 *encodeShape(int x, int y, int w, int h, int flags);
|
2006-05-28 12:19:45 +00:00
|
|
|
|
2007-02-11 01:38:15 +00:00
|
|
|
int setNewShapeHeight(uint8 *shape, int height);
|
|
|
|
int resetShapeHeight(uint8 *shape);
|
2006-03-20 19:01:39 +00:00
|
|
|
|
2007-07-29 16:33:11 +00:00
|
|
|
virtual void drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int sd, int flags, ...);
|
2007-02-11 01:38:15 +00:00
|
|
|
|
|
|
|
// mouse handling
|
2005-10-22 00:24:07 +00:00
|
|
|
void hideMouse();
|
|
|
|
void showMouse();
|
2007-02-11 01:38:15 +00:00
|
|
|
void setMouseCursor(int x, int y, byte *shape);
|
|
|
|
|
|
|
|
// rect handling
|
2007-07-29 16:33:11 +00:00
|
|
|
virtual int getRectSize(int w, int h);
|
2007-02-11 01:38:15 +00:00
|
|
|
|
|
|
|
void rectClip(int &x, int &y, int w, int h);
|
|
|
|
|
|
|
|
void addBitBlitRect(int x, int y, int w, int h);
|
|
|
|
void bitBlitRects();
|
|
|
|
|
|
|
|
// misc
|
|
|
|
void loadBitmap(const char *filename, int tempPage, int dstPage, uint8 *palData);
|
|
|
|
|
2007-03-07 20:31:19 +00:00
|
|
|
void loadPalette(const char *filename, uint8 *palData);
|
|
|
|
void loadPalette(const byte *data, uint8 *palData, int bytes);
|
|
|
|
|
2007-02-11 01:38:15 +00:00
|
|
|
void setAnimBlockPtr(int size);
|
|
|
|
|
2005-10-22 00:24:07 +00:00
|
|
|
void setShapePages(int page1, int page2);
|
2005-11-01 14:19:50 +00:00
|
|
|
|
|
|
|
byte getShapeFlag1(int x, int y);
|
2005-12-08 17:19:18 +00:00
|
|
|
byte getShapeFlag2(int x, int y);
|
2006-01-14 21:14:27 +00:00
|
|
|
|
|
|
|
void savePageToDisk(const char *file, int page);
|
|
|
|
void loadPageFromDisk(const char *file, int page);
|
2006-01-22 09:34:12 +00:00
|
|
|
void deletePageFromDisk(int page);
|
2005-10-03 20:21:18 +00:00
|
|
|
|
2006-02-09 07:37:19 +00:00
|
|
|
void blockInRegion(int x, int y, int width, int height);
|
|
|
|
void blockOutRegion(int x, int y, int width, int height);
|
|
|
|
|
|
|
|
void copyBackgroundBlock(int x, int page, int flag);
|
|
|
|
void copyBackgroundBlock2(int x);
|
2007-02-11 01:38:15 +00:00
|
|
|
|
2007-07-29 16:33:11 +00:00
|
|
|
// kyra1 specific?
|
2006-02-09 07:37:19 +00:00
|
|
|
int getDrawLayer(int x, int y);
|
|
|
|
int getDrawLayer2(int x, int y, int height);
|
|
|
|
|
2005-08-19 22:12:09 +00:00
|
|
|
int _charWidth;
|
2005-09-08 19:09:52 +00:00
|
|
|
int _charOffset;
|
2005-08-19 22:12:09 +00:00
|
|
|
int _curPage;
|
2005-09-08 19:09:52 +00:00
|
|
|
uint8 *_currentPalette;
|
2005-10-29 18:37:40 +00:00
|
|
|
uint8 *_shapePages[2];
|
2006-04-17 17:39:08 +00:00
|
|
|
FontId _currentFont;
|
2006-09-10 13:52:17 +00:00
|
|
|
bool _disableScreen;
|
2005-08-31 20:14:20 +00:00
|
|
|
|
2006-01-07 23:55:50 +00:00
|
|
|
const ScreenDim *_curDim;
|
|
|
|
|
2005-12-24 18:00:35 +00:00
|
|
|
static const ScreenDim _screenDimTable[];
|
|
|
|
static const int _screenDimTableCount;
|
2006-05-18 22:46:34 +00:00
|
|
|
|
2007-02-11 01:38:15 +00:00
|
|
|
// decoding functions
|
|
|
|
static void decodeFrame3(const uint8 *src, uint8 *dst, uint32 size);
|
2007-02-17 07:49:12 +00:00
|
|
|
static uint decodeFrame4(const uint8 *src, uint8 *dst, uint32 dstSize);
|
2007-03-12 20:43:56 +00:00
|
|
|
static void decodeFrameDelta(uint8 *dst, const uint8 *src, bool noXor = false);
|
2007-02-11 01:38:15 +00:00
|
|
|
static void decodeFrameDeltaPage(uint8 *dst, const uint8 *src, const int pitch, bool noXor);
|
2007-03-18 12:08:13 +00:00
|
|
|
static void convertAmigaGfx(uint8 *data, int w, int h, bool offscreen = true);
|
2007-03-16 23:08:59 +00:00
|
|
|
static void convertAmigaMsc(uint8 *data);
|
2007-02-11 01:38:15 +00:00
|
|
|
|
2007-07-29 16:31:29 +00:00
|
|
|
protected:
|
2006-09-10 13:26:00 +00:00
|
|
|
uint8 *getPagePtr(int pageNum);
|
2007-02-01 13:10:49 +00:00
|
|
|
void updateDirtyRects();
|
2007-02-12 18:01:51 +00:00
|
|
|
void updateDirtyRectsOvl();
|
|
|
|
|
|
|
|
void scale2x(byte *dst, int dstPitch, const byte *src, int srcPitch, int w, int h);
|
|
|
|
void mergeOverlay(int x, int y, int w, int h);
|
|
|
|
|
|
|
|
// overlay specific
|
|
|
|
byte *getOverlayPtr(int pageNum);
|
|
|
|
void clearOverlayPage(int pageNum);
|
|
|
|
void clearOverlayRect(int pageNum, int x, int y, int w, int h);
|
|
|
|
void copyOverlayRegion(int x, int y, int x2, int y2, int w, int h, int srcPage, int dstPage);
|
|
|
|
|
|
|
|
// font/text specific
|
|
|
|
void drawCharANSI(uint8 c, int x, int y);
|
|
|
|
void drawCharSJIS(uint16 c, int x, int y);
|
|
|
|
|
|
|
|
enum {
|
|
|
|
SJIS_CHARSIZE = 18,
|
|
|
|
SJIS_CHARS = 8192
|
|
|
|
};
|
2006-09-10 13:26:00 +00:00
|
|
|
|
2005-10-22 12:59:16 +00:00
|
|
|
int16 encodeShapeAndCalculateSize(uint8 *from, uint8 *to, int size);
|
|
|
|
void restoreMouseRect();
|
|
|
|
void copyMouseToScreen();
|
2006-09-15 16:04:32 +00:00
|
|
|
void copyScreenFromRect(int x, int y, int w, int h, const uint8 *ptr);
|
2005-10-22 00:24:07 +00:00
|
|
|
void copyScreenToRect(int x, int y, int w, int h, uint8 *ptr);
|
2005-08-19 22:12:09 +00:00
|
|
|
|
2007-03-12 20:43:56 +00:00
|
|
|
template<bool noXor> static void wrapped_decodeFrameDelta(uint8 *dst, const uint8 *src);
|
2007-01-06 18:52:30 +00:00
|
|
|
template<bool noXor> static void wrapped_decodeFrameDeltaPage(uint8 *dst, const uint8 *src, const int pitch);
|
|
|
|
|
2005-08-19 22:12:09 +00:00
|
|
|
uint8 *_pagePtrs[16];
|
2007-02-12 18:01:51 +00:00
|
|
|
uint8 *_sjisOverlayPtrs[SCREEN_OVLS_NUM];
|
|
|
|
|
|
|
|
bool _useOverlays;
|
|
|
|
bool _useSJIS;
|
|
|
|
|
|
|
|
uint8 *_sjisFontData;
|
|
|
|
uint8 *_sjisTempPage;
|
|
|
|
uint8 *_sjisTempPage2;
|
|
|
|
uint8 *_sjisSourceChar;
|
|
|
|
|
2006-01-14 21:14:27 +00:00
|
|
|
uint8 *_saveLoadPage[8];
|
2007-05-22 13:44:41 +00:00
|
|
|
uint8 *_saveLoadPageOvl[8];
|
2007-02-12 18:01:51 +00:00
|
|
|
|
2005-09-08 19:09:52 +00:00
|
|
|
uint8 *_screenPalette;
|
2007-03-23 16:24:28 +00:00
|
|
|
uint8 *_palettes[6];
|
2007-02-12 18:01:51 +00:00
|
|
|
|
2005-09-08 19:09:52 +00:00
|
|
|
Font _fonts[FID_NUM];
|
|
|
|
uint8 _textColorsMap[16];
|
2007-02-12 18:01:51 +00:00
|
|
|
|
2005-08-31 20:14:20 +00:00
|
|
|
uint8 *_decodeShapeBuffer;
|
|
|
|
int _decodeShapeBufferSize;
|
2007-02-12 18:01:51 +00:00
|
|
|
|
2005-09-08 19:09:52 +00:00
|
|
|
uint8 *_animBlockPtr;
|
|
|
|
int _animBlockSize;
|
2007-02-12 18:01:51 +00:00
|
|
|
|
2005-11-18 23:55:31 +00:00
|
|
|
int _mouseLockCount;
|
2006-01-06 10:45:42 +00:00
|
|
|
|
|
|
|
Rect *_bitBlitRects;
|
|
|
|
int _bitBlitNum;
|
2006-02-09 07:37:19 +00:00
|
|
|
uint8 *_unkPtr1, *_unkPtr2;
|
2006-09-15 16:04:32 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
kMaxDirtyRects = 50
|
|
|
|
};
|
|
|
|
|
|
|
|
bool _forceFullUpdate;
|
|
|
|
int _numDirtyRects;
|
|
|
|
Rect *_dirtyRects;
|
|
|
|
|
|
|
|
void addDirtyRect(int x, int y, int w, int h);
|
2005-09-08 19:09:52 +00:00
|
|
|
|
2005-08-19 22:12:09 +00:00
|
|
|
OSystem *_system;
|
|
|
|
KyraEngine *_vm;
|
2007-09-23 23:37:01 +00:00
|
|
|
|
|
|
|
// init
|
|
|
|
virtual void setResolution();
|
|
|
|
|
|
|
|
// debug
|
|
|
|
bool _debugEnabled;
|
2005-08-19 22:12:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Kyra
|
|
|
|
|
|
|
|
#endif
|
2007-04-15 16:41:20 +00:00
|
|
|
|