24 #ifndef SWORD2_SCREEN_H 25 #define SWORD2_SCREEN_H 27 #include "common/rect.h" 28 #include "common/stream.h" 30 #define MAX_bgp0_sprites 6 31 #define MAX_bgp1_sprites 6 32 #define MAX_back_sprites 30 33 #define MAX_sort_sprites 30 34 #define MAX_fore_sprites 30 35 #define MAX_fgp0_sprites 6 36 #define MAX_fgp1_sprites 6 38 #define PALTABLESIZE (64 * 64 * 64) 41 #define BLOCKHEIGHT 64 45 #define RENDERWIDE 640 46 #define RENDERDEEP (480 - (MENUDEEP * 2)) 49 #define SCALE_MAXWIDTH 512 50 #define SCALE_MAXHEIGHT 512 68 RDSPR_SHADOW = 0x0010,
69 RDSPR_DISPLAYALIGN = 0x0020,
70 RDSPR_NOCOMPRESSION = 0x0040,
71 RDSPR_EDGEBLEND = 0x0080,
77 RDSPR_RLE256 = 0x0100,
78 RDSPR_RLE256FAST = 0x0200
100 RDBLTFX_SPRITEBLEND = 0x01,
101 RDBLTFX_SHADOWBLEND = 0x02,
102 RDBLTFX_EDGEBLEND = 0x04
112 uint16 scaled_height;
114 uint32 anim_resource;
133 uint16 scroll_offset_x;
134 uint16 scroll_offset_y;
135 uint16 max_scroll_offset_x;
136 uint16 max_scroll_offset_y;
145 uint32 background_layer_id;
148 uint16 number_of_layers;
176 byte data[BLOCKWIDTH * BLOCKHEIGHT];
191 void read(
const byte *addr);
192 void write(byte *addr);
214 bool _needFullRedraw;
223 int16 _scrollXTarget;
224 int16 _scrollYTarget;
228 int16 _parallaxScrollX;
230 int16 _parallaxScrollY;
241 byte _palette[256 * 3];
242 byte _paletteMatch[PALTABLESIZE];
245 int32 _fadeStartTime;
246 int32 _fadeTotalTime;
256 int32 _renderAverageTime;
257 int32 _framesPerGameCycle;
260 void startNewPalette();
262 void resetRenderEngine();
264 void startRenderCycle();
265 bool endRenderCycle();
270 uint16 _sortOrder[MAX_sort_sprites];
288 void drawBackPar0Frames();
289 void drawBackPar1Frames();
290 void drawBackFrames();
291 void drawSortFrames(byte *file);
292 void drawForeFrames();
293 void drawForePar0Frames();
294 void drawForePar1Frames();
296 void processLayer(byte *file, uint32 layer_number);
297 void processImage(
BuildUnit *build_unit);
299 uint8 _scrollFraction;
307 uint32 _lastPaletteRes;
310 uint32 _largestLayerArea;
311 uint32 _largestSpriteArea;
312 char _largestLayerInfo[128];
313 char _largestSpriteInfo[128];
315 void registerFrame(byte *ob_mouse, byte *ob_graph, byte *ob_mega,
BuildUnit *build_unit);
317 void mirrorSprite(byte *dst, byte *src, int16 w, int16 h);
318 int32 decompressRLE256(byte *dst, byte *src, int32 decompSize);
319 void unwindRaw16(byte *dst, byte *src, uint16 blockSize, byte *colTable);
320 int32 decompressRLE16(byte *dst, byte *src, int32 decompSize, byte *colTable);
321 void renderParallax(byte *ptr, int16 layer);
324 void markAsDirty(int16 x0, int16 y0, int16 x1, int16 y1);
326 uint8 _xBlocks[MAXLAYERS];
327 uint8 _yBlocks[MAXLAYERS];
333 byte *_psxScrCache[3];
334 bool _psxCacheEnabled[3];
340 uint16 _xScale[SCALE_MAXWIDTH];
341 uint16 _yScale[SCALE_MAXHEIGHT];
350 uint32 _pauseStartTick;
358 void pauseScreen(
bool pause);
360 int8 getRenderLevel();
361 void setRenderLevel(int8 level);
363 byte *getScreen() {
return _buffer; }
364 byte *getPalette() {
return _palette; }
365 ScreenInfo *getScreenInfo() {
return &_thisScreen; }
367 int16 getScreenWide() {
return _screenWide; }
368 int16 getScreenDeep() {
return _screenDeep; }
370 uint32 getCurBgp0() {
return _curBgp0; }
371 uint32 getCurBgp1() {
return _curBgp1; }
372 uint32 getCurBack() {
return _curBack; }
373 uint32 getCurSort() {
return _curSort; }
374 uint32 getCurFore() {
return _curFore; }
375 uint32 getCurFgp0() {
return _curFgp0; }
376 uint32 getCurFgp1() {
return _curFgp1; }
378 uint32 getFps() {
return _fps; }
380 uint32 getLargestLayerArea() {
return _largestLayerArea; }
381 uint32 getLargestSpriteArea() {
return _largestSpriteArea; }
382 char *getLargestLayerInfo() {
return _largestLayerInfo; }
383 char *getLargestSpriteInfo() {
return _largestSpriteInfo; }
385 void setNeedFullRedraw();
389 void resetRenderLists();
391 void setLocationMetrics(uint16 w, uint16 h);
392 int32 initializeBackgroundLayer(byte *parallax);
393 int32 initializePsxParallaxLayer(byte *parallax);
394 int32 initializePsxBackgroundLayer(byte *parallax);
395 void closeBackgroundLayer();
397 void initializeRenderCycle();
399 void initBackground(int32 res, int32 new_palette);
400 void initPsxBackground(int32 res, int32 new_palette);
401 void registerFrame(byte *ob_mouse, byte *ob_graph, byte *ob_mega);
403 void setScrollFraction(uint8 f) { _scrollFraction = f; }
404 void setScrollTarget(int16 x, int16 y);
407 void setFullPalette(int32 palRes);
408 void setPalette(int16 startEntry, int16 noEntries, byte *palette, uint8 setNow);
409 void setSystemPalette(
const byte *colors, uint start, uint num);
410 uint8 quickMatch(uint8 r, uint8 g, uint8 b);
411 int32 fadeUp(
float time = 0.75f);
412 int32 fadeDown(
float time = 0.75f);
413 uint8 getFadeStatus();
414 void dimPalette(
bool dim);
418 void updateDisplay(
bool redrawScene =
true);
420 void displayMsg(byte *text,
int time);
422 int32 createSurface(
SpriteInfo *s, byte **surface);
424 void deleteSurface(byte *surface);
427 void scaleImageFast(byte *dst, uint16 dstPitch, uint16 dstWidth,
428 uint16 dstHeight, byte *src, uint16 srcPitch, uint16 srcWidth,
430 void scaleImageGood(byte *dst, uint16 dstPitch, uint16 dstWidth,
431 uint16 dstHeight, byte *src, uint16 srcPitch, uint16 srcWidth,
432 uint16 srcHeight, byte *backBuf, int16 bbXPos, int16 bbYPos);
437 int32 closeLightMask();
441 void plotPoint(
int x,
int y, uint8 color);
442 void drawLine(
int x0,
int y0,
int x1,
int y1, uint8 color);
448 static uint32 decompressHIF(byte *src, byte *dst, uint32 *skipData =
nullptr);
450 static void resizePsxSprite(byte *dst, byte *src, uint16 destW, uint16 destH);
453 static void recomposePsxSprite(
SpriteInfo *s);
454 static void recomposeCompPsxSprite(
SpriteInfo *s);
457 void setPsxScrCache(byte *psxScrCache, uint8 level);
458 byte *getPsxScrCache(uint8 level);
459 bool getPsxScrCacheStatus(uint8 level);
460 void flushPsxScrCache();
Definition: animation.h:37