scummvm/engines/twine/renderer/redraw.h

171 lines
4.8 KiB
C
Raw Normal View History

/* 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 TWINE_REDRAW_H
#define TWINE_REDRAW_H
#include "common/scummsys.h"
2020-11-25 16:59:54 +01:00
#include "common/rect.h"
namespace TwinE {
#define OVERLAY_MAX_ENTRIES 10
2020-10-14 14:20:38 +02:00
enum class OverlayType {
2020-10-14 14:20:38 +02:00
koSprite = 0,
koNumber = 1,
koNumberRange = 2,
koInventoryItem = 3,
koText = 4
};
enum class OverlayPosType {
2020-10-14 14:20:38 +02:00
koNormal = 0,
koFollowActor = 1
};
/** Overlay list structure */
2020-10-21 11:23:09 +02:00
struct OverlayListStruct {
OverlayType type = OverlayType::koSprite;
int16 info0 = 0; // sprite/3d model entry | number | number range
int16 x = 0;
int16 y = 0;
2020-12-07 17:00:17 +01:00
int16 info1 = 0; // text = actor | total coins
OverlayPosType posType = OverlayPosType::koNormal;
int16 lifeTime = 0;
2020-10-21 11:23:09 +02:00
};
2020-10-14 14:20:38 +02:00
2021-01-17 00:04:44 +01:00
struct DrawListStruct {
int16 posValue = 0; // sorting value
2021-01-17 00:04:44 +01:00
uint32 type = 0;
uint16 actorIdx = 0;
uint16 x = 0;
uint16 y = 0;
uint16 z = 0;
uint16 offset = 0;
uint16 field_C = 0;
uint16 field_E = 0;
uint16 field_10 = 0;
};
class TwinEEngine;
class Redraw {
private:
TwinEEngine *_engine;
enum DrawListType {
DrawActorSprites = 0x1000,
DrawExtras = 0x1800,
DrawShadows = 0xC00
};
2020-11-25 18:20:38 +01:00
Common::Rect currentRedrawList[300];
Common::Rect nextRedrawList[300];
int16 overlayRotation = 0;
/**
* Add a certain region to the current redraw list array
2020-12-30 14:22:45 +01:00
* @param redrawArea redraw the region
*/
2020-12-30 14:22:45 +01:00
void addRedrawCurrentArea(const Common::Rect &redrawArea);
/** Move next regions to the current redraw list */
void moveNextAreas();
void updateOverlayTypePosition(int16 x1, int16 y1, int16 x2, int16 y2);
2020-12-13 22:51:09 +01:00
void processDrawListShadows(const DrawListStruct& drawCmd);
void processDrawListActors(const DrawListStruct& drawCmd, bool bgRedraw);
void processDrawListActorSprites(const DrawListStruct& drawCmd, bool bgRedraw);
void processDrawListExtras(const DrawListStruct& drawCmd);
2020-12-13 22:56:46 +01:00
int32 fillActorDrawingList(bool bgRedraw);
int32 fillExtraDrawingList(int32 drawListPos);
2020-12-13 14:09:31 +01:00
void processDrawList(int32 drawListPos, bool bgRedraw);
2020-12-13 15:27:43 +01:00
void renderOverlays();
2020-12-13 14:09:31 +01:00
public:
Redraw(TwinEEngine *engine) : _engine(engine) {}
2020-11-25 18:20:38 +01:00
/** Auxiliar object render position on screen */
Common::Rect renderRect { 0, 0, 0, 0 };
2020-10-22 12:42:57 +02:00
bool drawInGameTransBox = false;
/** Request background redraw */
2020-10-22 12:42:57 +02:00
bool reqBgRedraw = false;
/** Current number of redraw regions in the screen */
int32 currNumOfRedrawBox = 0; // fullRedrawVar8
/** Number of redraw regions in the screen */
int32 numOfRedrawBox = 0;
/** Save last actor that bubble dialog icon */
int32 bubbleActor = -1;
int32 bubbleSpriteIndex = 0;
OverlayListStruct overlayList[OVERLAY_MAX_ENTRIES];
void addOverlay(OverlayType type, int16 info0, int16 x, int16 y, int16 info1, OverlayPosType posType, int16 lifeTime);
/**
* Add a certain region to redraw list array
* @param left start width to redraw the region
* @param top start height to redraw the region
* @param right end width to redraw the region
* @param bottom end height to redraw the region
*/
void addRedrawArea(int32 left, int32 top, int32 right, int32 bottom);
2020-11-25 16:59:54 +01:00
void addRedrawArea(const Common::Rect &rect);
/**
* Flip currentRedrawList regions in the screen
* This only updates small areas in the screen so few CPU processor is used
*/
void flipRedrawAreas();
/** Blit/Update all screen regions in the currentRedrawList */
void blitBackgroundAreas();
/**
* This is responsible for the entire game screen redraw
* @param bgRedraw true if we want to redraw background grid, false if we want to update certain screen areas
*/
2020-11-26 22:23:30 +01:00
void redrawEngineActions(bool bgRedraw);
/** Draw dialogue sprite image */
void drawBubble(int32 actorIdx);
void zoomScreenScale();
2021-01-17 00:04:44 +01:00
/**
* Sort drawing list struct ordered as the first objects appear in the top left corner of the screen
* @param list drawing list variable which contains information of the drawing objects
* @param listSize number of drawing objects in the list
*/
void sortDrawingList(DrawListStruct *list, int32 listSize);
/** Draw list array to grab the necessary */
DrawListStruct drawList[150];
};
2020-10-14 14:20:38 +02:00
} // namespace TwinE
2020-10-14 14:20:38 +02:00
#endif