22 #ifndef SCI_GRAPHICS_SCREEN_H 23 #define SCI_GRAPHICS_SCREEN_H 26 #include "sci/graphics/helpers.h" 27 #include "sci/graphics/view.h" 29 #include "graphics/font.h" 30 #include "graphics/sjis.h" 31 #include "graphics/korfont.h" 32 #include "graphics/pixelformat.h" 37 SCI_SCREEN_UPSCALEDMAXHEIGHT = 200,
38 SCI_SCREEN_UPSCALEDMAXWIDTH = 320
41 enum GfxScreenUpscaledMode {
42 GFX_SCREEN_UPSCALED_DISABLED = 0,
43 GFX_SCREEN_UPSCALED_480x300 = 1,
44 GFX_SCREEN_UPSCALED_640x400 = 2,
45 GFX_SCREEN_UPSCALED_640x440 = 3
49 GFX_SCREEN_MASK_VISUAL = 1,
50 GFX_SCREEN_MASK_PRIORITY = 2,
51 GFX_SCREEN_MASK_CONTROL = 4,
52 GFX_SCREEN_MASK_DISPLAY = 8,
53 GFX_SCREEN_MASK_ALL = GFX_SCREEN_MASK_VISUAL|GFX_SCREEN_MASK_PRIORITY|GFX_SCREEN_MASK_CONTROL
57 DITHERED_BG_COLORS_SIZE = 256
73 uint16 getWidth() {
return _width; }
74 uint16 getHeight() {
return _height; }
75 uint16 getScriptWidth() {
return _scriptWidth; }
76 uint16 getScriptHeight() {
return _scriptHeight; }
77 uint16 getDisplayWidth() {
return _displayWidth; }
78 uint16 getDisplayHeight() {
return _displayHeight; }
79 byte getColorWhite() {
return _colorWhite; }
80 byte getColorDefaultVectorData() {
return _colorDefaultVectorData; }
82 void clearForRestoreGame();
84 void kernelSyncWithFramebuffer();
87 void copyRectToScreen(
const Common::Rect &rect, int16 x, int16 y);
90 void bakCreateBackup();
91 void bakCopyRectToScreen(
const Common::Rect &rect, int16 x, int16 y);
95 void copyVideoFrameToScreen(
const byte *buffer,
int pitch,
const Common::Rect &rect,
bool is8bit);
99 void vectorPutLinePixel(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control);
100 void vectorPutLinePixel480x300(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control);
103 void vectorAdjustLineCoordinates(int16 *left, int16 *top, int16 *right, int16 *bottom, byte drawMask, byte color, byte priority, byte control);
104 byte vectorIsFillMatch(int16 x, int16 y, byte screenMask, byte checkForColor, byte checkForPriority, byte checkForControl,
bool isEGA);
106 byte getDrawingMask(byte color, byte prio, byte control);
108 void drawLine(int16 left, int16 top, int16 right, int16 bottom, byte color, byte prio, byte control) {
112 GfxScreenUpscaledMode getUpscaledHires()
const {
113 return _upscaledHires;
116 bool isUnditheringEnabled()
const {
117 return _unditheringEnabled;
119 void enableUndithering(
bool flag);
121 void putMacChar(
const Graphics::Font *commonFont, int16 x, int16 y, uint16 chr, byte color);
122 void putKanjiChar(Graphics::FontSJIS *commonFont, int16 x, int16 y, uint16 chr, byte color);
126 void bitsSave(
Common::Rect rect, byte mask, byte *memoryPtr);
127 void bitsGetRect(
const byte *memoryPtr,
Common::Rect *destRect);
128 void bitsRestore(
const byte *memoryPtr);
132 void adjustToUpscaledCoordinates(int16 &y, int16 &x);
133 void adjustBackUpscaledCoordinates(int16 &y, int16 &x);
135 void dither(
bool addToFlag);
138 void ditherForceDitheredColor(byte color);
139 int16 *unditherGetDitheredBgColors();
141 void debugShowMap(
int mapNo);
144 int _picNotValidSci11;
146 int16 kernelPicNotValid(int16 newPicNotValid);
147 void kernelShakeScreen(uint16 shakeCount, uint16 direction);
149 void setFontIsUpscaled(
bool isUpscaled) { _fontIsUpscaled = isUpscaled; }
150 bool fontIsUpscaled()
const {
return _fontIsUpscaled; }
152 void grabPalette(byte *buffer, uint start, uint num)
const;
153 void setPalette(
const byte *buffer, uint start, uint num,
bool update =
true);
155 byte getCurPaletteMapValue()
const {
return _curPaletteMapValue; }
156 void setCurPaletteMapValue(byte val) { _curPaletteMapValue = val; }
157 void setPaletteMods(
const PaletteMod *mods,
unsigned int count);
158 bool paletteModsEnabled()
const {
return _paletteModsEnabled; }
165 uint16 _scriptHeight;
166 uint16 _displayWidth;
167 uint16 _displayHeight;
173 byte _colorDefaultVectorData;
175 void bitsRestoreScreen(
Common::Rect rect,
const byte *&memoryPtr, byte *screen, uint16 screenWidth);
176 void bitsRestoreDisplayScreen(
Common::Rect rect,
const byte *&memoryPtr, byte *screen);
177 void bitsSaveScreen(
Common::Rect rect,
const byte *screen, uint16 screenWidth, byte *&memoryPtr);
178 void bitsSaveDisplayScreen(
Common::Rect rect,
const byte *screen, byte *&memoryPtr);
180 void setShakePos(uint16 shakeXOffset, uint16 shakeYOffset);
185 bool _unditheringEnabled;
186 int16 _ditheredPicColors[DITHERED_BG_COLORS_SIZE];
192 byte *_priorityScreen;
193 byte *_controlScreen;
200 byte *_displayScreen;
204 byte *_displayedScreen;
208 byte *_paletteMapScreen;
209 byte _curPaletteMapValue;
211 bool _paletteModsEnabled;
216 void displayRectRGB(
const Common::Rect &rect,
int x,
int y);
217 void displayRect(
const Common::Rect &rect,
int x,
int y);
232 GfxScreenUpscaledMode _upscaledHires;
238 int16 _upscaledHeightMapping[SCI_SCREEN_UPSCALEDMAXHEIGHT + 1];
239 int16 _upscaledWidthMapping[SCI_SCREEN_UPSCALEDMAXWIDTH + 1];
245 bool _fontIsUpscaled;
250 void putPixel(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control) {
251 if (_upscaledHires == GFX_SCREEN_UPSCALED_480x300) {
252 putPixel480x300(x, y, drawMask, color, priority, control);
257 const int offset = y * _width + x;
259 if (drawMask & GFX_SCREEN_MASK_VISUAL) {
260 _visualScreen[offset] = color;
261 if (_paletteMapScreen)
262 _paletteMapScreen[offset] = _curPaletteMapValue;
264 switch (_upscaledHires) {
265 case GFX_SCREEN_UPSCALED_DISABLED:
266 _displayScreen[offset] = color;
269 case GFX_SCREEN_UPSCALED_640x400:
270 case GFX_SCREEN_UPSCALED_640x440:
271 putScaledPixelOnDisplay(x, y, color);
277 if (drawMask & GFX_SCREEN_MASK_PRIORITY) {
278 _priorityScreen[offset] = priority;
280 if (drawMask & GFX_SCREEN_MASK_CONTROL) {
281 _controlScreen[offset] = control;
285 void putPixel480x300(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control) {
286 const int offset = ((y * 3) / 2 * _width) + ((x * 3) / 2);
290 if (drawMask & GFX_SCREEN_MASK_VISUAL) {
291 putPixel480x300Worker(x, y, offset, _visualScreen, color);
292 putPixel480x300Worker(x, y, offset, _displayScreen, color);
294 if (drawMask & GFX_SCREEN_MASK_PRIORITY) {
295 putPixel480x300Worker(x, y, offset, _priorityScreen, priority);
297 if (drawMask & GFX_SCREEN_MASK_CONTROL) {
298 putPixel480x300Worker(x, y, offset, _controlScreen, control);
301 void putPixel480x300Worker(int16 x, int16 y,
int offset, byte *screen, byte byteToSet) {
302 screen[offset] = byteToSet;
304 screen[offset + 1] = byteToSet;
306 screen[offset + _width] = byteToSet;
307 if ((x & 1) && (y & 1))
308 screen[offset + _width + 1] = byteToSet;
312 void vectorPutPixel(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control) {
313 switch (_upscaledHires) {
314 case GFX_SCREEN_UPSCALED_640x400:
315 case GFX_SCREEN_UPSCALED_640x440:
317 putPixel(x, y, drawMask, color, priority, control);
326 int offset = y * _width + x;
328 if (drawMask & GFX_SCREEN_MASK_VISUAL) {
329 _visualScreen[offset] = color;
330 _displayScreen[offset] = color;
331 if (_paletteMapScreen)
332 _paletteMapScreen[offset] = _curPaletteMapValue;
335 if (drawMask & GFX_SCREEN_MASK_PRIORITY) {
336 _priorityScreen[offset] = priority;
338 if (drawMask & GFX_SCREEN_MASK_CONTROL) {
339 _controlScreen[offset] = control;
349 int offset = y * _displayWidth + x;
350 _displayScreen[offset] = color;
354 void putScaledPixelOnDisplay(int16 x, int16 y, byte color) {
355 int displayOffset = 0;
357 switch (_upscaledHires) {
358 case GFX_SCREEN_UPSCALED_640x400:
359 displayOffset = (y * 2) * _displayWidth + x * 2;
361 _displayScreen[displayOffset] = color;
362 _displayScreen[displayOffset + 1] = color;
363 _displayScreen[displayOffset + _displayWidth] = color;
364 _displayScreen[displayOffset + _displayWidth + 1] = color;
367 case GFX_SCREEN_UPSCALED_640x440: {
368 int16 startY = (y * 11) / 5;
369 int16 endY = ((y + 1) * 11) / 5;
370 displayOffset = (startY * _displayWidth) + x * 2;
372 for (int16 curY = startY; curY < endY; curY++) {
373 _displayScreen[displayOffset] = color;
374 _displayScreen[displayOffset + 1] = color;
375 displayOffset += _displayWidth;
390 int16 actualY = startingY + y;
391 if (_fontIsUpscaled) {
395 if (_upscaledHires == GFX_SCREEN_UPSCALED_480x300) {
396 putPixel480x300(x, actualY, GFX_SCREEN_MASK_VISUAL, color, 0, 0);
400 int offset = actualY * _width + x;
402 _visualScreen[offset] = color;
403 switch (_upscaledHires) {
404 case GFX_SCREEN_UPSCALED_DISABLED:
405 _displayScreen[offset] = color;
407 case GFX_SCREEN_UPSCALED_640x400:
408 case GFX_SCREEN_UPSCALED_640x440: {
410 int displayOffset = (_upscaledHeightMapping[startingY] + y * 2) * _displayWidth + x * 2;
411 _displayScreen[displayOffset] = color;
412 _displayScreen[displayOffset + 1] = color;
413 displayOffset += _displayWidth;
414 _displayScreen[displayOffset] = color;
415 _displayScreen[displayOffset + 1] = color;
419 putScaledPixelOnDisplay(x, actualY, color);
425 byte getPixel(byte *screen, int16 x, int16 y) {
426 switch (_upscaledHires) {
427 case GFX_SCREEN_UPSCALED_480x300: {
428 int offset = ((y * 3) / 2) * _width + ((y * 3) / 2);
430 return screen[offset];
436 return screen[y * _width + x];
439 byte getVisual(int16 x, int16 y) {
440 return getPixel(_visualScreen, x, y);
442 byte getPriority(int16 x, int16 y) {
443 return getPixel(_priorityScreen, x, y);
445 byte getControl(int16 x, int16 y) {
446 return getPixel(_controlScreen, x, y);
450 byte vectorGetPixel(byte *screen, int16 x, int16 y) {
451 return screen[y * _width + x];
454 byte vectorGetVisual(int16 x, int16 y) {
455 return vectorGetPixel(_visualScreen, x, y);
457 byte vectorGetPriority(int16 x, int16 y) {
458 return vectorGetPixel(_priorityScreen, x, y);
460 byte vectorGetControl(int16 x, int16 y) {
461 return vectorGetPixel(_controlScreen, x, y);
464 void vectorAdjustCoordinate(int16 *x, int16 *y) {
465 switch (_upscaledHires) {
466 case GFX_SCREEN_UPSCALED_480x300:
478 #endif // SCI_GRAPHICS_SCREEN_H void putPixelOnDisplay(int16 x, int16 y, byte color)
Definition: screen.h:348
void putFontPixel(int16 startingY, int16 x, int16 y, byte color)
Definition: screen.h:389
Definition: resource.h:327
Definition: helpers.h:268