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" 34 #include "common/rendermode.h" 39 SCI_SCREEN_UPSCALEDMAXHEIGHT = 200,
40 SCI_SCREEN_UPSCALEDMAXWIDTH = 320
43 enum GfxScreenUpscaledMode {
44 GFX_SCREEN_UPSCALED_DISABLED = 0,
45 GFX_SCREEN_UPSCALED_480x300 = 1,
46 GFX_SCREEN_UPSCALED_640x400 = 2
50 GFX_SCREEN_MASK_VISUAL = 1,
51 GFX_SCREEN_MASK_PRIORITY = 2,
52 GFX_SCREEN_MASK_CONTROL = 4,
53 GFX_SCREEN_MASK_ALL = GFX_SCREEN_MASK_VISUAL|GFX_SCREEN_MASK_PRIORITY|GFX_SCREEN_MASK_CONTROL
57 DITHERED_BG_COLORS_SIZE = 256
75 uint16 getWidth() {
return _width; }
76 uint16 getHeight() {
return _height; }
77 uint16 getScriptWidth() {
return _scriptWidth; }
78 uint16 getScriptHeight() {
return _scriptHeight; }
79 uint16 getDisplayWidth() {
return _displayWidth; }
80 uint16 getDisplayHeight() {
return _displayHeight; }
81 byte getColorWhite() {
return _colorWhite; }
82 byte getColorDefaultVectorData() {
return _colorDefaultVectorData; }
84 void clearForRestoreGame();
86 void kernelSyncWithFramebuffer();
88 void copyHiResRectToScreen(
const byte *srcBuffer,
int pitch,
int x,
int y,
int w,
int h,
const byte *colorMap);
89 void copyRectToScreen(
const Common::Rect &rect, int16 x, int16 y);
92 void bakCreateBackup();
93 void bakCopyRectToScreen(
const Common::Rect &rect, int16 x, int16 y);
97 void copyVideoFrameToScreen(
const byte *buffer,
int pitch,
const Common::Rect &rect);
101 void vectorPutLinePixel(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control);
102 void vectorPutLinePixel480x300(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control);
105 void vectorAdjustLineCoordinates(int16 *left, int16 *top, int16 *right, int16 *bottom, byte drawMask, byte color, byte priority, byte control);
106 byte vectorIsFillMatch(int16 x, int16 y, byte screenMask, byte checkForColor, byte checkForPriority, byte checkForControl,
bool isEGA);
108 byte getDrawingMask(byte color, byte prio, byte control);
110 void drawLine(int16 left, int16 top, int16 right, int16 bottom, byte color, byte prio, byte control) {
114 GfxScreenUpscaledMode getUpscaledHires()
const {
115 return _upscaledHires;
118 bool isUnditheringEnabled()
const {
119 return _unditheringEnabled;
121 void enableUndithering(
bool flag);
123 void putMacChar(
const Graphics::Font *commonFont, int16 x, int16 y, uint16 chr, byte color);
124 void putKanjiChar(Graphics::FontSJIS *commonFont, int16 x, int16 y, uint16 chr, byte color);
128 void bitsSave(
Common::Rect rect, byte mask, byte *memoryPtr);
129 void bitsGetRect(
const byte *memoryPtr,
Common::Rect *destRect);
130 void bitsRestore(
const byte *memoryPtr);
134 void adjustToUpscaledCoordinates(int16 &y, int16 &x);
135 void adjustBackUpscaledCoordinates(int16 &y, int16 &x);
137 void dither(
bool addToFlag);
140 void ditherForceDitheredColor(byte color);
141 int16 *unditherGetDitheredBgColors();
143 void debugShowMap(
int mapNo);
146 int _picNotValidSci11;
148 int16 kernelPicNotValid(int16 newPicNotValid);
149 void kernelShakeScreen(uint16 shakeCount, uint16 direction);
151 void setFontIsUpscaled(
bool isUpscaled) { _fontIsUpscaled = isUpscaled; }
152 bool fontIsUpscaled()
const {
return _fontIsUpscaled; }
154 void grabPalette(byte *buffer, uint start, uint num)
const;
155 void setPalette(
const byte *buffer, uint start, uint num,
bool update =
true);
157 byte getCurPaletteMapValue()
const {
return _curPaletteMapValue; }
158 void setCurPaletteMapValue(byte val) { _curPaletteMapValue = val; }
159 void setPaletteMods(
const PaletteMod *mods,
unsigned int count);
160 bool paletteModsEnabled()
const {
return _paletteModsEnabled; }
162 GfxDriver *gfxDriver()
const {
return _gfxDrv; }
169 uint16 _scriptHeight;
170 uint16 _displayWidth;
171 uint16 _displayHeight;
175 byte _colorDefaultVectorData;
177 void bitsRestoreScreen(
Common::Rect rect,
const byte *&memoryPtr, byte *screen, uint16 screenWidth);
178 void bitsRestoreDisplayScreen(
Common::Rect rect,
const byte *&memoryPtr, byte *screen);
179 void bitsSaveScreen(
Common::Rect rect,
const byte *screen, uint16 screenWidth, byte *&memoryPtr);
180 void bitsSaveDisplayScreen(
Common::Rect rect,
const byte *screen, byte *&memoryPtr);
182 void setShakePos(uint16 shakeXOffset, uint16 shakeYOffset);
187 bool _unditheringEnabled;
188 int16 _ditheredPicColors[DITHERED_BG_COLORS_SIZE];
194 byte *_priorityScreen;
195 byte *_controlScreen;
202 byte *_displayScreen;
212 byte *_paletteMapScreen;
213 byte _curPaletteMapValue;
215 bool _paletteModsEnabled;
219 void displayRect(
const Common::Rect &rect,
int x,
int y);
233 GfxScreenUpscaledMode _upscaledHires;
238 byte *_hiresGlyphBuffer;
244 int16 _upscaledHeightMapping[SCI_SCREEN_UPSCALEDMAXHEIGHT + 1];
245 int16 _upscaledWidthMapping[SCI_SCREEN_UPSCALEDMAXWIDTH + 1];
251 bool _fontIsUpscaled;
256 void putPixel(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control) {
257 if (_upscaledHires == GFX_SCREEN_UPSCALED_480x300) {
258 putPixel480x300(x, y, drawMask, color, priority, control);
263 const int offset = y * _width + x;
265 if (drawMask & GFX_SCREEN_MASK_VISUAL) {
266 _visualScreen[offset] = color;
267 if (_paletteMapScreen)
268 _paletteMapScreen[offset] = _curPaletteMapValue;
270 switch (_upscaledHires) {
271 case GFX_SCREEN_UPSCALED_DISABLED:
272 _displayScreen[offset] = color;
275 case GFX_SCREEN_UPSCALED_640x400:
276 putScaledPixelOnDisplay(x, y, color);
282 if (drawMask & GFX_SCREEN_MASK_PRIORITY) {
283 _priorityScreen[offset] = priority;
285 if (drawMask & GFX_SCREEN_MASK_CONTROL) {
286 _controlScreen[offset] = control;
290 void putPixel480x300(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control) {
291 const int offset = ((y * 3) / 2 * _width) + ((x * 3) / 2);
295 if (drawMask & GFX_SCREEN_MASK_VISUAL) {
296 putPixel480x300Worker(x, y, offset, _visualScreen, color);
297 putPixel480x300Worker(x, y, offset, _displayScreen, color);
299 if (drawMask & GFX_SCREEN_MASK_PRIORITY) {
300 putPixel480x300Worker(x, y, offset, _priorityScreen, priority);
302 if (drawMask & GFX_SCREEN_MASK_CONTROL) {
303 putPixel480x300Worker(x, y, offset, _controlScreen, control);
306 void putPixel480x300Worker(int16 x, int16 y,
int offset, byte *screen, byte byteToSet) {
307 screen[offset] = byteToSet;
309 screen[offset + 1] = byteToSet;
311 screen[offset + _width] = byteToSet;
312 if ((x & 1) && (y & 1))
313 screen[offset + _width + 1] = byteToSet;
317 void vectorPutPixel(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control) {
318 switch (_upscaledHires) {
319 case GFX_SCREEN_UPSCALED_640x400:
321 putPixel(x, y, drawMask, color, priority, control);
330 int offset = y * _width + x;
332 if (drawMask & GFX_SCREEN_MASK_VISUAL) {
333 _visualScreen[offset] = color;
334 _displayScreen[offset] = color;
335 if (_paletteMapScreen)
336 _paletteMapScreen[offset] = _curPaletteMapValue;
339 if (drawMask & GFX_SCREEN_MASK_PRIORITY) {
340 _priorityScreen[offset] = priority;
342 if (drawMask & GFX_SCREEN_MASK_CONTROL) {
343 _controlScreen[offset] = control;
353 int offset = y * _displayWidth + x;
354 _displayScreen[offset] = color;
358 void putScaledPixelOnDisplay(int16 x, int16 y, byte color) {
359 int displayOffset = 0;
361 switch (_upscaledHires) {
362 case GFX_SCREEN_UPSCALED_640x400:
363 displayOffset = (y * 2) * _displayWidth + x * 2;
365 _displayScreen[displayOffset] = color;
366 _displayScreen[displayOffset + 1] = color;
367 _displayScreen[displayOffset + _displayWidth] = color;
368 _displayScreen[displayOffset + _displayWidth + 1] = color;
382 int16 actualY = startingY + y;
383 if (_fontIsUpscaled) {
387 if (_upscaledHires == GFX_SCREEN_UPSCALED_480x300) {
388 putPixel480x300(x, actualY, GFX_SCREEN_MASK_VISUAL, color, 0, 0);
392 int offset = actualY * _width + x;
394 _visualScreen[offset] = color;
395 switch (_upscaledHires) {
396 case GFX_SCREEN_UPSCALED_DISABLED:
397 _displayScreen[offset] = color;
399 case GFX_SCREEN_UPSCALED_640x400: {
401 int displayOffset = (_upscaledHeightMapping[startingY] + y * 2) * _displayWidth + x * 2;
402 _displayScreen[displayOffset] = color;
403 _displayScreen[displayOffset + 1] = color;
404 displayOffset += _displayWidth;
405 _displayScreen[displayOffset] = color;
406 _displayScreen[displayOffset + 1] = color;
410 putScaledPixelOnDisplay(x, actualY, color);
416 byte getPixel(byte *screen, int16 x, int16 y) {
417 switch (_upscaledHires) {
418 case GFX_SCREEN_UPSCALED_480x300: {
419 int offset = ((y * 3) / 2) * _width + ((y * 3) / 2);
421 return screen[offset];
427 return screen[y * _width + x];
430 byte getVisual(int16 x, int16 y) {
431 return getPixel(_visualScreen, x, y);
433 byte getPriority(int16 x, int16 y) {
434 return getPixel(_priorityScreen, x, y);
436 byte getControl(int16 x, int16 y) {
437 return getPixel(_controlScreen, x, y);
441 byte vectorGetPixel(byte *screen, int16 x, int16 y) {
442 return screen[y * _width + x];
445 byte vectorGetVisual(int16 x, int16 y) {
446 return vectorGetPixel(_visualScreen, x, y);
448 byte vectorGetPriority(int16 x, int16 y) {
449 return vectorGetPixel(_priorityScreen, x, y);
451 byte vectorGetControl(int16 x, int16 y) {
452 return vectorGetPixel(_controlScreen, x, y);
455 void vectorAdjustCoordinate(int16 *x, int16 *y) {
456 switch (_upscaledHires) {
457 case GFX_SCREEN_UPSCALED_480x300:
469 #endif // SCI_GRAPHICS_SCREEN_H void putPixelOnDisplay(int16 x, int16 y, byte color)
Definition: screen.h:352
void putFontPixel(int16 startingY, int16 x, int16 y, byte color)
Definition: screen.h:381
RenderMode
Definition: rendermode.h:48
Definition: resource.h:327
Definition: gfxdrivers.h:37
Definition: helpers.h:269