25#include "common/system.h"
26#include "common/list.h"
28#include "graphics/surface.h"
38#define BMCOMP_RAW256 1
39#define BMCOMP_TOWNS_2 2
40#define BMCOMP_TOWNS_3 3
41#define BMCOMP_TOWNS_4 4
42#define BMCOMP_TOWNS_7 7
43#define BMCOMP_TRLE8BIT 8
44#define BMCOMP_RLE8BIT 9
46#define BMCOMP_PIX32 10
48#define BMCOMP_ZIGZAG_V0 10
49#define BMCOMP_ZIGZAG_V4 14
50#define BMCOMP_ZIGZAG_V5 15
51#define BMCOMP_ZIGZAG_V6 16
52#define BMCOMP_ZIGZAG_V7 17
53#define BMCOMP_ZIGZAG_V8 18
55#define BMCOMP_ZIGZAG_H0 20
56#define BMCOMP_ZIGZAG_H4 24
57#define BMCOMP_ZIGZAG_H5 25
58#define BMCOMP_ZIGZAG_H6 26
59#define BMCOMP_ZIGZAG_H7 27
60#define BMCOMP_ZIGZAG_H8 28
62#define BMCOMP_ZIGZAG_VT0 30
63#define BMCOMP_ZIGZAG_VT4 34
64#define BMCOMP_ZIGZAG_VT5 35
65#define BMCOMP_ZIGZAG_VT6 36
66#define BMCOMP_ZIGZAG_VT7 37
67#define BMCOMP_ZIGZAG_VT8 38
69#define BMCOMP_ZIGZAG_HT0 40
70#define BMCOMP_ZIGZAG_HT4 44
71#define BMCOMP_ZIGZAG_HT5 45
72#define BMCOMP_ZIGZAG_HT6 46
73#define BMCOMP_ZIGZAG_HT7 47
74#define BMCOMP_ZIGZAG_HT8 48
76#define BMCOMP_MAJMIN_H0 60
77#define BMCOMP_MAJMIN_H4 64
78#define BMCOMP_MAJMIN_H5 65
79#define BMCOMP_MAJMIN_H6 66
80#define BMCOMP_MAJMIN_H7 67
81#define BMCOMP_MAJMIN_H8 68
83#define BMCOMP_MAJMIN_HT0 80
84#define BMCOMP_MAJMIN_HT4 84
85#define BMCOMP_MAJMIN_HT5 85
86#define BMCOMP_MAJMIN_HT6 86
87#define BMCOMP_MAJMIN_HT7 87
88#define BMCOMP_MAJMIN_HT8 88
90#define BMCOMP_RMAJMIN_H0 100
91#define BMCOMP_RMAJMIN_H4 104
92#define BMCOMP_RMAJMIN_H5 105
93#define BMCOMP_RMAJMIN_H6 106
94#define BMCOMP_RMAJMIN_H7 107
95#define BMCOMP_RMAJMIN_H8 108
97#define BMCOMP_RMAJMIN_HT0 120
98#define BMCOMP_RMAJMIN_HT4 124
99#define BMCOMP_RMAJMIN_HT5 125
100#define BMCOMP_RMAJMIN_HT6 126
101#define BMCOMP_RMAJMIN_HT7 127
102#define BMCOMP_RMAJMIN_HT8 128
104#define BMCOMP_NMAJMIN_H0 130
105#define BMCOMP_NMAJMIN_H4 134
106#define BMCOMP_NMAJMIN_H5 135
107#define BMCOMP_NMAJMIN_H6 136
108#define BMCOMP_NMAJMIN_H7 137
109#define BMCOMP_NMAJMIN_H8 138
111#define BMCOMP_NMAJMIN_HT0 140
112#define BMCOMP_NMAJMIN_HT4 144
113#define BMCOMP_NMAJMIN_HT5 145
114#define BMCOMP_NMAJMIN_HT6 146
115#define BMCOMP_NMAJMIN_HT7 147
116#define BMCOMP_NMAJMIN_HT8 148
118#define BMCOMP_TPIX256 149
120#define BMCOMP_SOLID_COLOR_FILL 150
122#define BMCOMP_CUSTOM_RU_TR 143
125enum HerculesDimensions {
132 kNormalCameraMode = 1,
133 kFollowActorCameraMode = 2,
134 kPanningCameraMode = 3
143 int _leftTrigger, _rightTrigger;
144 byte _follows, _mode;
149 _dest.
x = _dest.
y = 0;
150 _accel.
x = _accel.
y = 0;
151 _last.
x = _last.
y = 0;
165 kBannerVirtScreen = 3
263 for (
int i = 0; i < 80 + 1; i++) {
273 byte *getBackPixels(
int x,
int y)
const {
289#define CHARSET_MASK_TRANSPARENCY 0xFD
290#define CHARSET_MASK_TRANSPARENCY_32 0xFDFDFDFD
298 byte _transparentColor;
299 byte _decomp_shr, _decomp_mask;
300 uint32 _vertStripNextInc;
302 bool _zbufferDisabled;
317 bool decompressBitmap(
byte *dst,
int dstPitch,
const byte *src,
int numLinesToProcess);
319 void drawStripEGA(
byte *dst,
int dstPitch,
const byte *src,
int height)
const;
321 void drawStripComplex(
byte *dst,
int dstPitch,
const byte *src,
int height,
const bool transpCheck)
const;
322 void drawStripBasicH(
byte *dst,
int dstPitch,
const byte *src,
int height,
const bool transpCheck)
const;
323 void drawStripBasicV(
byte *dst,
int dstPitch,
const byte *src,
int height,
const bool transpCheck)
const;
325 void drawStripRaw(
byte *dst,
int dstPitch,
const byte *src,
int height,
const bool transpCheck)
const;
326 void unkDecode8(
byte *dst,
int dstPitch,
const byte *src,
int height)
const;
327 void unkDecode9(
byte *dst,
int dstPitch,
const byte *src,
int height)
const;
328 void unkDecode10(
byte *dst,
int dstPitch,
const byte *src,
int height)
const;
329 void unkDecode11(
byte *dst,
int dstPitch,
const byte *src,
int height)
const;
330 void drawStrip3DO(
byte *dst,
int dstPitch,
const byte *src,
int height,
const bool transpCheck)
const;
332 void drawStripHE(
byte *dst,
int dstPitch,
const byte *src,
int width,
int height,
const bool transpCheck)
const;
333 virtual void writeRoomColor(
byte *dst,
byte color)
const;
336 void decompressMaskImgOr(
byte *dst,
const byte *src,
int height)
const;
337 void decompressMaskImg(
byte *dst,
const byte *src,
int height)
const;
340 int getZPlanes(
const byte *smap_ptr,
const byte *zplane_list[9],
bool bmapImage)
const;
342 virtual bool drawStrip(
byte *dstPtr,
VirtScreen *vs,
343 int x,
int y,
const int width,
const int height,
344 int stripnr,
const byte *smap_ptr);
346 virtual void decodeMask(
int x,
int y,
const int width,
const int height,
347 int stripnr,
int numzbuf,
const byte *zplane_list[9],
348 bool transpStrip,
byte flag);
350 virtual void prepareDrawBitmap(
const byte *ptr,
VirtScreen *vs,
351 const int x,
const int y,
const int width,
const int height,
352 int stripnr,
int numstrip);
358 virtual void setRenderModeColorMap(
const byte *map) {}
359 virtual byte remapColorToRenderMode(
byte col)
const {
return col; }
362 virtual void roomChanged(
byte *roomptr);
363 virtual void loadTiles(
byte *roomptr);
364 void setTransparentColor(
byte transparentColor) { _transparentColor = transparentColor; }
366 void drawBitmap(
const byte *ptr, VirtScreen *vs,
int x,
int y,
const int width,
const int height,
367 int stripnr,
int numstrip,
byte flag);
370 void drawBMAPBg(
const byte *ptr, VirtScreen *vs);
371 void drawBMAPObject(
const byte *ptr, VirtScreen *vs,
int obj,
int x,
int y,
int w,
int h);
374 byte *getMaskBuffer(
int x,
int y,
int z);
375 void disableZBuffer() { _zbufferDisabled =
true; }
376 void enableZBuffer() { _zbufferDisabled =
false; }
378 void resetBackground(
int top,
int bottom,
int strip);
380 enum DrawBitmapFlags {
381 dbAllowMaskOr = 1 << 0,
382 dbDrawMaskOnAll = 1 << 1,
383 dbObjectMode = 2 << 2
389 const byte *_tmskPtr;
392 void decompressTMSK(
byte *dst,
const byte *tmsk,
const byte *src,
int height)
const;
394 void decodeMask(
int x,
int y,
const int width,
const int height,
395 int stripnr,
int numzbuf,
const byte *zplane_list[9],
396 bool transpStrip,
byte flag)
override;
398 void prepareDrawBitmap(
const byte *ptr,
VirtScreen *vs,
399 const int x,
const int y,
const int width,
const int height,
400 int stripnr,
int numstrip)
override;
408 byte nametable[16][64], nametableObj[16][64];
409 byte attributes[64], attributesObj[64];
410 byte masktable[16][8], masktableObj[16][8];
416 void decodeNESGfx(
const byte *room);
417 void decodeNESObject(
const byte *ptr,
int xpos,
int ypos,
int width,
int height);
419 void drawStripNES(
byte *dst,
byte *mask,
int dstPitch,
int stripnr,
int top,
int height);
420 void drawStripNESMask(
byte *dst,
int stripnr,
int top,
int height)
const;
423 int x,
int y,
const int width,
const int height,
424 int stripnr,
const byte *smap_ptr)
override;
426 void decodeMask(
int x,
int y,
const int width,
const int height,
427 int stripnr,
int numzbuf,
const byte *zplane_list[9],
428 bool transpStrip,
byte flag)
override;
430 void prepareDrawBitmap(
const byte *ptr,
VirtScreen *vs,
431 const int x,
const int y,
const int width,
const int height,
432 int stripnr,
int numstrip)
override;
437 void roomChanged(
byte *roomptr)
override;
441class GdiPCEngine :
public Gdi {
444 uint16 nametable[4096], nametableObj[512];
445 byte colortable[4096], colortableObj[512];
446 uint16 masktable[4096], masktableObj[512];
450 byte *roomTiles, *staffTiles;
455 void decodePCEngineGfx(
const byte *room);
456 void decodeStrip(
const byte *ptr, uint16 *tiles,
byte *colors, uint16 *masks,
int numRows,
bool isObject);
457 void setTileData(
byte *tile,
int index,
byte byte0,
byte byte1);
458 void decodePCEngineTileData(
const byte *ptr);
459 void decodePCEngineMaskData(
const byte *ptr);
460 void decodePCEngineObject(
const byte *ptr,
int xpos,
int ypos,
int width,
int height);
462 void drawStripPCEngine(
byte *dst,
byte *mask,
int dstPitch,
int stripnr,
int top,
int height);
463 void drawStripPCEngineMask(
byte *dst,
int stripnr,
int top,
int height)
const;
465 bool drawStrip(
byte *dstPtr, VirtScreen *vs,
466 int x,
int y,
const int width,
const int height,
467 int stripnr,
const byte *smap_ptr)
override;
469 void decodeMask(
int x,
int y,
const int width,
const int height,
470 int stripnr,
int numzbuf,
const byte *zplane_list[9],
471 bool transpStrip,
byte flag)
override;
473 void prepareDrawBitmap(
const byte *ptr, VirtScreen *vs,
474 const int x,
const int y,
const int width,
const int height,
475 int stripnr,
int numstrip)
override;
478 GdiPCEngine(ScummEngine *vm);
479 ~GdiPCEngine()
override;
481 void loadTiles(
byte *roomptr)
override;
482 void roomChanged(
byte *roomptr)
override;
491 byte charMap[2048], objectMap[2048], picMap[4096], colorMap[4096];
492 byte maskMap[4096], maskChar[4096];
495 const byte *_colorMap = 0;
498 void decodeV1Gfx(
const byte *src,
byte *dst,
int size)
const;
500 void drawStripV1Object(
byte *dst,
int dstPitch,
int stripnr,
int width,
int height);
501 void drawStripV1Background(
byte *dst,
int dstPitch,
int stripnr,
int height);
502 void drawStripV1Mask(
byte *dst,
int stripnr,
int width,
int height)
const;
505 int x,
int y,
const int width,
const int height,
506 int stripnr,
const byte *smap_ptr)
override;
508 void decodeMask(
int x,
int y,
const int width,
const int height,
509 int stripnr,
int numzbuf,
const byte *zplane_list[9],
510 bool transpStrip,
byte flag)
override;
512 void prepareDrawBitmap(
const byte *ptr,
VirtScreen *vs,
513 const int x,
const int y,
const int width,
const int height,
514 int stripnr,
int numstrip)
override;
519 void setRenderModeColorMap(
const byte *map)
override;
520 byte remapColorToRenderMode(
byte col)
const override;
522 void roomChanged(
byte *roomptr)
override;
531 StripTable *generateStripTable(
const byte *src,
int width,
int height, StripTable *table)
const;
534 int x,
int y,
const int width,
const int height,
535 int stripnr,
const byte *smap_ptr)
override;
537 void decodeMask(
int x,
int y,
const int width,
const int height,
538 int stripnr,
int numzbuf,
const byte *zplane_list[9],
539 bool transpStrip,
byte flag)
override;
541 void prepareDrawBitmap(
const byte *ptr,
VirtScreen *vs,
542 const int x,
const int y,
const int width,
const int height,
543 int stripnr,
int numstrip)
override;
549 void roomChanged(
byte *roomptr)
override;
553class GdiHE16bit :
public GdiHE {
555 void writeRoomColor(
byte *dst,
byte color)
const override;
561#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
567 kFullRedraw = (kDirtyRectsMax + 1)
573 void setupLayer(
int layer,
int width,
int height,
int scaleW,
int scaleH,
int numCol,
void *srcPal = 0);
574 void clearLayer(
int layer);
575 void fillRect(
int layer,
int x,
int y,
int w,
int h,
int col);
576 void swapAreaWithBuffer(
int layer,
int x,
int y,
int w,
int h,
byte *buffer);
577 void addDirtyRect(
int x,
int y,
int w,
int h);
578 void toggleLayers(
int flags);
579 void scrollLayer(
int layer,
int offset,
int top,
int bottom,
bool fast);
581 bool isScrolling(
int layer,
int direction,
int threshold = 0)
const {
582 return (layer & ~1) ? false :
583 (direction == 0 ? (_layers[layer].scrollRemainder != threshold) :
584 (direction == 1 ? (_layers[layer].scrollRemainder > threshold) : (_layers[layer].scrollRemainder < threshold)));
587 uint8 *getLayerPixels(
int layer,
int x,
int y)
const;
588 int getLayerPitch(
int layer)
const { assert (layer >= 0 && layer < 2);
return _layers[layer].pitch; }
589 int getLayerWidth(
int layer)
const { assert (layer >= 0 && layer < 2);
return _layers[layer].width; }
590 int getLayerHeight(
int layer)
const { assert (layer >= 0 && layer < 2);
return _layers[layer].height; }
591 int getLayerBpp(
int layer)
const { assert (layer >= 0 && layer < 2);
return _layers[layer].bpp; }
592 int getLayerScaleW(
int layer)
const { assert (layer >= 0 && layer < 2);
return _layers[layer].scaleW; }
593 int getLayerScaleH(
int layer)
const { assert (layer >= 0 && layer < 2);
return _layers[layer].scaleH; }
596 struct TownsScreenLayer {
597 uint8 *pixels =
nullptr;
598 uint8 *palette =
nullptr;
607 int scrollRemainder = 0;
608 bool onBottom =
false;
609 bool enabled =
false;
611 uint16 *bltTmpPal=
nullptr;
614 template<
typename dstPixelType,
typename srcPixelType,
int scaleW,
int scaleH,
bool col4bit>
void transferRect(uint8 *dst,
int pitch, TownsScreenLayer *l,
int x,
int y,
int w,
int h);
615 template<
typename dstPixelType>
void updateScreenBuffer();
618 void update16BitPalette();
619 uint16 calc16BitColor(
const uint8 *palEntry);
624 bool _semiSmoothScroll;
647 void setupBitReader(
byte shift,
const byte *src);
648 void skipData(int32 numSkip);
649 void decodeLine(
byte *buf, int32 numBytes, int32 dir);
650 inline byte readBits(
byte n);
bool _distaff
Definition: gfx.h:309
bool _objectMode
Definition: gfx.h:305
struct Scumm::GdiV1::@1122 _V1
StripTable * _roomStrips
Definition: gfx.h:528
#define ARRAYSIZE(x)
Definition: util.h:114
VirtScreenNumber
Definition: gfx.h:161
void * pixels
Definition: surface.h:89
int32 pitch
Definition: surface.h:83
const void * getPixels() const
Definition: surface.h:110
PixelFormat format
Definition: surface.h:95
bool hasTwoBuffers
Definition: gfx.h:213
uint16 topline
Definition: gfx.h:196
byte * backBuf
Definition: gfx.h:223
uint16 xstart
Definition: gfx.h:203
void setDirtyRange(int top, int bottom)
Definition: gfx.h:262
VirtScreenNumber number
Definition: gfx.h:190
uint16 bdirty[80+1]
Definition: gfx.h:241
uint16 tdirty[80+1]
Definition: gfx.h:232