Move actors to the first frame on entering a room.
[scummvm-innocent.git] / engines / sword1 / screen.h
blob72a55b94d379dc8707378ca5c343d5b4a2eba368
1 /* ScummVM - Graphic Adventure Engine
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * $URL$
22 * $Id$
26 #ifndef SWORD1_SCREEN_H
27 #define SWORD1_SCREEN_H
29 #include "sword1/sworddefs.h"
31 class OSystem;
33 namespace Sword1 {
35 #define MAX_FORE 20
36 #define MAX_BACK 20
37 #define MAX_SORT 20
39 struct SortSpr {
40 int32 id, y;
43 struct RoomDef {
44 int totalLayers;
45 int sizeX;
46 int sizeY;
47 int gridWidth; //number of 16*16 grid blocks across - including off screen edges.
48 uint32 layers[4];
49 uint32 grids[3];
50 uint32 palettes[2];
51 uint32 parallax[2];
54 struct PSXDataCache { // Cache for PSX screen, to avoid decompressing background at every screen update
55 uint8 *decodedBackground;
56 uint8 *extPlxCache; // If this screen requires an external parallax, save it here
59 #define SCRNGRID_X 16
60 #define SCRNGRID_Y 8
61 #define SHRINK_BUFFER_SIZE 50000
62 #define RLE_BUFFER_SIZE 50000
64 #define FLASH_RED 0
65 #define FLASH_BLUE 1
66 #define BORDER_YELLOW 2
67 #define BORDER_GREEN 3
68 #define BORDER_PURPLE 4
69 #define BORDER_BLACK 5
71 class ResMan;
72 class ObjectMan;
73 class Text; // Text objects use sprites that are created internally at run-time
74 // the buffer belongs to Text, so we need a reference here.
76 class Screen {
77 public:
78 Screen(OSystem *system, ResMan *pResMan, ObjectMan *pObjMan);
79 ~Screen(void);
80 void clearScreen(void);
81 void useTextManager(Text *pTextMan);
82 void draw(void);
84 void quitScreen(void);
85 void newScreen(uint32 screen);
87 void setScrolling(int16 offsetX, int16 offsetY);
88 void addToGraphicList(uint8 listId, uint32 objId);
90 void fadeDownPalette(void);
91 void fadeUpPalette(void);
92 void fnSetPalette(uint8 start, uint16 length, uint32 id, bool fadeUp);
93 bool stillFading(void);
94 void fullRefresh(void);
96 bool showScrollFrame(void);
97 void updateScreen(void);
98 void showFrame(uint16 x, uint16 y, uint32 resId, uint32 frameNo, const byte *fadeMask = NULL, int8 fadeStatus = 0);
100 void fnSetParallax(uint32 screen, uint32 resId);
101 void fnFlash(uint8 color);
102 void fnBorder(uint8 color);
104 static void decompressHIF(uint8 *src, uint8 *dest);
106 private:
107 // for router debugging
108 void drawLine(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
109 void vline(uint16 x, uint16 y1, uint16 y2);
110 void hline(uint16 x1, uint16 x2, uint16 y);
111 void bsubline_1(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
112 void bsubline_2(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
113 void bsubline_3(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
114 void bsubline_4(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
116 void verticalMask(uint16 x, uint16 y, uint16 bWidth, uint16 bHeight);
117 void blitBlockClear(uint16 x, uint16 y, uint8 *data);
118 void renderParallax(uint8 *data);
119 void processImage(uint32 id);
120 void spriteClipAndSet(uint16 *pSprX, uint16 *pSprY, uint16 *sprWidth, uint16 *sprHeight, uint16 *incr);
121 void drawSprite(uint8 *sprData, uint16 sprX, uint16 sprY, uint16 sprWidth, uint16 sprHeight, uint16 sprPitch);
122 void drawPsxHalfShrinkedSprite(uint8 *sprData, uint16 sprX, uint16 sprY, uint16 sprWidth, uint16 sprHeight, uint16 sprPitch);
123 void drawPsxFullShrinkedSprite(uint8 *sprData, uint16 sprX, uint16 sprY, uint16 sprWidth, uint16 sprHeight, uint16 sprPitch);
124 uint8* psxBackgroundToIndexed(uint8 *psxBackground, uint32 bakXres, uint32 bakYres);
125 uint8* psxShrinkedBackgroundToIndexed(uint8 *psxBackground, uint32 bakXres, uint32 bakYres);
126 void fetchPsxParallaxSize(uint8 *psxParallax, uint16 *paraSizeX, uint16 *paraSizeY);
127 void drawPsxParallax(uint8 *psxParallax, uint16 paraScrlX, uint16 scrnScrlX, uint16 scrnWidth);
128 void decompressRLE7(uint8 *src, uint32 compSize, uint8 *dest);
129 void decompressRLE0(uint8 *src, uint32 compSize, uint8 *dest);
130 void decompressTony(uint8 *src, uint32 compSize, uint8 *dest);
131 void fastShrink(uint8 *src, uint32 width, uint32 height, uint32 scale, uint8 *dest);
132 int32 inRange(int32 a, int32 b, int32 c);
133 void fadePalette(void);
135 void flushPsxCache(void);
137 OSystem *_system;
138 ResMan *_resMan;
139 ObjectMan *_objMan;
140 Text *_textMan;
142 uint16 _currentScreen;
143 uint8 *_screenBuf;
144 uint8 *_screenGrid;
145 uint16 *_layerGrid[4];
146 uint8 *_layerBlocks[4];
147 uint8 *_parallax[2];
148 uint8 _rleBuffer[RLE_BUFFER_SIZE];
149 uint8 _shrinkBuffer[SHRINK_BUFFER_SIZE];
150 bool _fullRefresh;
151 bool _updatePalette;
152 uint16 _oldScrollX, _oldScrollY; // for drawing additional frames
154 PSXDataCache _psxCache; // Cache used for PSX backgrounds
156 uint32 _foreList[MAX_FORE];
157 uint32 _backList[MAX_BACK];
158 SortSpr _sortList[MAX_SORT];
159 uint8 _foreLength, _backLength, _sortLength;
160 uint16 _scrnSizeX, _scrnSizeY, _gridSizeX, _gridSizeY;
162 static RoomDef _roomDefTable[TOTAL_ROOMS]; // from ROOMS.C (not const, see fnSetParallax)
164 uint8 _targetPalette[256 * 4];
165 uint8 _currentPalette[256 * 4]; // for fading
166 uint8 _fadingStep;
167 int8 _fadingDirection; // 1 for fade up, -1 for fade down
168 bool _isBlack; // if the logic already faded down the palette, this is set to show the
169 // mainloop that no further fading is necessary.
172 } // End of namespace Sword1
174 #endif //BSSCREEN_H