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;
245 bool _activeHiresView;
250 byte *_hiresGlyphBuffer;
256 int16 _upscaledHeightMapping[SCI_SCREEN_UPSCALEDMAXHEIGHT + 1];
257 int16 _upscaledWidthMapping[SCI_SCREEN_UPSCALEDMAXWIDTH + 1];
263 bool _fontIsUpscaled;
268 void putPixel(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control) {
269 if (_upscaledHires == GFX_SCREEN_UPSCALED_480x300) {
270 putPixel480x300(x, y, drawMask, color, priority, control);
275 const int offset = y * _width + x;
277 if (drawMask & GFX_SCREEN_MASK_VISUAL) {
278 _visualScreen[offset] = color;
279 if (_paletteMapScreen)
280 _paletteMapScreen[offset] = _curPaletteMapValue;
282 switch (_upscaledHires) {
283 case GFX_SCREEN_UPSCALED_DISABLED:
284 _displayScreen[offset] = color;
287 case GFX_SCREEN_UPSCALED_640x400:
288 putScaledPixelOnDisplay(x, y, color);
294 if (drawMask & GFX_SCREEN_MASK_PRIORITY) {
295 _priorityScreen[offset] = priority;
297 if (drawMask & GFX_SCREEN_MASK_CONTROL) {
298 _controlScreen[offset] = control;
302 void putPixel480x300(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control) {
303 const int offset = ((y * 3) / 2 * _width) + ((x * 3) / 2);
307 if (drawMask & GFX_SCREEN_MASK_VISUAL) {
308 putPixel480x300Worker(x, y, offset, _visualScreen, color);
309 putPixel480x300Worker(x, y, offset, _displayScreen, color);
311 if (drawMask & GFX_SCREEN_MASK_PRIORITY) {
312 putPixel480x300Worker(x, y, offset, _priorityScreen, priority);
314 if (drawMask & GFX_SCREEN_MASK_CONTROL) {
315 putPixel480x300Worker(x, y, offset, _controlScreen, control);
318 void putPixel480x300Worker(int16 x, int16 y,
int offset, byte *screen, byte byteToSet) {
319 screen[offset] = byteToSet;
321 screen[offset + 1] = byteToSet;
323 screen[offset + _width] = byteToSet;
324 if ((x & 1) && (y & 1))
325 screen[offset + _width + 1] = byteToSet;
329 void vectorPutPixel(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control) {
330 switch (_upscaledHires) {
331 case GFX_SCREEN_UPSCALED_640x400:
333 putPixel(x, y, drawMask, color, priority, control);
342 int offset = y * _width + x;
344 if (drawMask & GFX_SCREEN_MASK_VISUAL) {
345 _visualScreen[offset] = color;
346 _displayScreen[offset] = color;
347 if (_paletteMapScreen)
348 _paletteMapScreen[offset] = _curPaletteMapValue;
351 if (drawMask & GFX_SCREEN_MASK_PRIORITY) {
352 _priorityScreen[offset] = priority;
354 if (drawMask & GFX_SCREEN_MASK_CONTROL) {
355 _controlScreen[offset] = control;
365 int offset = y * _displayWidth + x;
366 _displayScreen[offset] = color;
370 void putScaledPixelOnDisplay(int16 x, int16 y, byte color) {
371 int displayOffset = 0;
373 switch (_upscaledHires) {
374 case GFX_SCREEN_UPSCALED_640x400:
375 displayOffset = (y * 2) * _displayWidth + x * 2;
377 _displayScreen[displayOffset] = color;
378 _displayScreen[displayOffset + 1] = color;
379 _displayScreen[displayOffset + _displayWidth] = color;
380 _displayScreen[displayOffset + _displayWidth + 1] = color;
394 int16 actualY = startingY + y;
395 if (_fontIsUpscaled) {
399 if (_upscaledHires == GFX_SCREEN_UPSCALED_480x300) {
400 putPixel480x300(x, actualY, GFX_SCREEN_MASK_VISUAL, color, 0, 0);
404 int offset = actualY * _width + x;
406 _visualScreen[offset] = color;
407 switch (_upscaledHires) {
408 case GFX_SCREEN_UPSCALED_DISABLED:
409 _displayScreen[offset] = color;
411 case GFX_SCREEN_UPSCALED_640x400: {
413 int displayOffset = (_upscaledHeightMapping[startingY] + y * 2) * _displayWidth + x * 2;
414 _displayScreen[displayOffset] = color;
415 _displayScreen[displayOffset + 1] = color;
416 displayOffset += _displayWidth;
417 _displayScreen[displayOffset] = color;
418 _displayScreen[displayOffset + 1] = color;
422 putScaledPixelOnDisplay(x, actualY, color);
428 byte getPixel(byte *screen, int16 x, int16 y) {
429 switch (_upscaledHires) {
430 case GFX_SCREEN_UPSCALED_480x300: {
431 int offset = ((y * 3) / 2) * _width + ((y * 3) / 2);
433 return screen[offset];
439 return screen[y * _width + x];
442 byte getVisual(int16 x, int16 y) {
443 return getPixel(_visualScreen, x, y);
445 byte getPriority(int16 x, int16 y) {
446 return getPixel(_priorityScreen, x, y);
448 byte getControl(int16 x, int16 y) {
449 return getPixel(_controlScreen, x, y);
453 byte vectorGetPixel(byte *screen, int16 x, int16 y) {
454 return screen[y * _width + x];
457 byte vectorGetVisual(int16 x, int16 y) {
458 return vectorGetPixel(_visualScreen, x, y);
460 byte vectorGetPriority(int16 x, int16 y) {
461 return vectorGetPixel(_priorityScreen, x, y);
463 byte vectorGetControl(int16 x, int16 y) {
464 return vectorGetPixel(_controlScreen, x, y);
467 void vectorAdjustCoordinate(int16 *x, int16 *y) {
468 switch (_upscaledHires) {
469 case GFX_SCREEN_UPSCALED_480x300:
478 bool hasActiveHiresView()
const {
return _activeHiresView; }
479 void toggleActiveHiresView(
bool toggle) { _activeHiresView = toggle; }
484 #endif // SCI_GRAPHICS_SCREEN_H void putPixelOnDisplay(int16 x, int16 y, byte color)
Definition: screen.h:364
void putFontPixel(int16 startingY, int16 x, int16 y, byte color)
Definition: screen.h:393
RenderMode
Definition: rendermode.h:48
Definition: resource.h:327
Definition: gfxdrivers.h:37
Definition: helpers.h:269