[Scummvm-git-logs] scummvm master -> f77b3af2b5f07b7b2a165ee19e78a66665f45977
dreammaster
dreammaster at scummvm.org
Thu Jul 1 03:06:19 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
f77b3af2b5 AGS: Janitorial
Commit: f77b3af2b5f07b7b2a165ee19e78a66665f45977
https://github.com/scummvm/scummvm/commit/f77b3af2b5f07b7b2a165ee19e78a66665f45977
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-06-30T20:06:08-07:00
Commit Message:
AGS: Janitorial
Changed paths:
engines/ags/lib/allegro/error.h
engines/ags/lib/allegro/file.h
engines/ags/lib/allegro/surface.h
engines/ags/lib/allegro/system.h
diff --git a/engines/ags/lib/allegro/error.h b/engines/ags/lib/allegro/error.h
index 0dc5ca2d12..52131f6125 100644
--- a/engines/ags/lib/allegro/error.h
+++ b/engines/ags/lib/allegro/error.h
@@ -29,45 +29,45 @@ namespace AGS3 {
// Error codes
enum AllegroError {
-AL_NOERROR = 0,
-AL_EPERM = 1,
-AL_ENOENT = 2,
-AL_ESRCH = 3,
-AL_EINTR = 4,
-AL_EIO = 5,
-AL_ENXIO = 6,
-AL_E2BIG = 7,
-AL_ENOEXEC = 8,
-AL_EBADF = 9,
-AL_ECHILD = 10,
-AL_EAGAIN = 11,
-AL_ENOMEM = 12,
-AL_EACCES = 13,
-AL_EFAULT = 14,
-AL_EBUSY = 16,
-AL_EEXIST = 17,
-AL_EXDEV = 18,
-AL_ENODEV = 19,
-AL_ENOTDIR = 20,
-AL_EISDIR = 21,
-AL_EINVAL = 22,
-AL_ENFILE = 23,
-AL_EMFILE = 24,
-AL_ENOTTY = 25,
-AL_EFBIG = 27,
-AL_ENOSPC = 28,
-AL_ESPIPE = 29,
-AL_EROFS = 30,
-AL_EMLINK = 31,
-AL_EPIPE = 32,
-AL_EDOM = 33,
-AL_ERANGE = 34,
-AL_EDEADLK = 36,
-AL_ENAMETOOLONG = 38,
-AL_ENOLCK = 39,
-AL_ENOSYS = 40,
-AL_ENOTEMPTY = 41,
-AL_EILSEQ = 42
+ AL_NOERROR = 0,
+ AL_EPERM = 1,
+ AL_ENOENT = 2,
+ AL_ESRCH = 3,
+ AL_EINTR = 4,
+ AL_EIO = 5,
+ AL_ENXIO = 6,
+ AL_E2BIG = 7,
+ AL_ENOEXEC = 8,
+ AL_EBADF = 9,
+ AL_ECHILD = 10,
+ AL_EAGAIN = 11,
+ AL_ENOMEM = 12,
+ AL_EACCES = 13,
+ AL_EFAULT = 14,
+ AL_EBUSY = 16,
+ AL_EEXIST = 17,
+ AL_EXDEV = 18,
+ AL_ENODEV = 19,
+ AL_ENOTDIR = 20,
+ AL_EISDIR = 21,
+ AL_EINVAL = 22,
+ AL_ENFILE = 23,
+ AL_EMFILE = 24,
+ AL_ENOTTY = 25,
+ AL_EFBIG = 27,
+ AL_ENOSPC = 28,
+ AL_ESPIPE = 29,
+ AL_EROFS = 30,
+ AL_EMLINK = 31,
+ AL_EPIPE = 32,
+ AL_EDOM = 33,
+ AL_ERANGE = 34,
+ AL_EDEADLK = 36,
+ AL_ENAMETOOLONG = 38,
+ AL_ENOLCK = 39,
+ AL_ENOSYS = 40,
+ AL_ENOTEMPTY = 41,
+ AL_EILSEQ = 42
};
} // namespace AGS3
diff --git a/engines/ags/lib/allegro/file.h b/engines/ags/lib/allegro/file.h
index de270602e8..1fab2c3bd2 100644
--- a/engines/ags/lib/allegro/file.h
+++ b/engines/ags/lib/allegro/file.h
@@ -40,162 +40,162 @@ namespace AGS3 {
#define F_EXE_MAGIC 0x736C682BL /* magic number for appended data */
struct _al_normal_packfile_details {
-int hndl; /* DOS file handle */
-int flags; /* PACKFILE_FLAG_* constants */
-unsigned char *buf_pos; /* position in buffer */
-int buf_size; /* number of bytes in the buffer */
-long todo; /* number of bytes still on the disk */
-struct PACKFILE *parent; /* nested, parent file */
-struct LZSS_PACK_DATA *pack_data; /* for LZSS compression */
-struct LZSS_UNPACK_DATA *unpack_data; /* for LZSS decompression */
-char *filename; /* name of the file */
-char *passdata; /* encryption key data */
-char *passpos; /* current key position */
-unsigned char buf[F_BUF_SIZE]; /* the actual data buffer */
+ int hndl; /* DOS file handle */
+ int flags; /* PACKFILE_FLAG_* constants */
+ unsigned char *buf_pos; /* position in buffer */
+ int buf_size; /* number of bytes in the buffer */
+ long todo; /* number of bytes still on the disk */
+ struct PACKFILE *parent; /* nested, parent file */
+ struct LZSS_PACK_DATA *pack_data; /* for LZSS compression */
+ struct LZSS_UNPACK_DATA *unpack_data; /* for LZSS decompression */
+ char *filename; /* name of the file */
+ char *passdata; /* encryption key data */
+ char *passpos; /* current key position */
+ unsigned char buf[F_BUF_SIZE]; /* the actual data buffer */
};
struct PACKFILE_VTABLE {
-AL_METHOD(int, pf_fclose, (void *userdata));
-AL_METHOD(int, pf_getc, (void *userdata));
-AL_METHOD(int, pf_ungetc, (int c, void *userdata));
-AL_METHOD(long, pf_fread, (void *p, long n, void *userdata));
-AL_METHOD(int, pf_putc, (int c, void *userdata));
-AL_METHOD(long, pf_fwrite, (AL_CONST void *p, long n, void *userdata));
-AL_METHOD(int, pf_fseek, (void *userdata, int offset));
-AL_METHOD(int, pf_feof, (void *userdata));
-AL_METHOD(int, pf_ferror, (void *userdata));
+ AL_METHOD(int, pf_fclose, (void *userdata));
+ AL_METHOD(int, pf_getc, (void *userdata));
+ AL_METHOD(int, pf_ungetc, (int c, void *userdata));
+ AL_METHOD(long, pf_fread, (void *p, long n, void *userdata));
+ AL_METHOD(int, pf_putc, (int c, void *userdata));
+ AL_METHOD(long, pf_fwrite, (AL_CONST void *p, long n, void *userdata));
+ AL_METHOD(int, pf_fseek, (void *userdata, int offset));
+ AL_METHOD(int, pf_feof, (void *userdata));
+ AL_METHOD(int, pf_ferror, (void *userdata));
};
/**
* Allegro file class
*/
struct PACKFILE {
-virtual ~PACKFILE() {
- close();
-}
-
-virtual void close() {}
-virtual int pack_fseek(int offset) = 0;
-virtual int pack_getc() = 0;
-virtual int pack_putc(int c) = 0;
-virtual int pack_ungetc(int c) = 0;
-virtual long pack_fread(void *p, long n) = 0;
-virtual long pack_fwrite(AL_CONST void *p, long n) = 0;
-virtual int pack_feof() = 0;
-virtual int pack_ferror() = 0;
-virtual void *pack_get_userdata() const {
- return nullptr;
-}
-
-PACKFILE *pack_fopen_chunk(int pack);
-PACKFILE *pack_fclose_chunk();
-int pack_igetw();
-long pack_igetl();
-int pack_iputw(int w);
-long pack_iputl(long l);
-int pack_mgetw();
-long pack_mgetl();
-int pack_mputw(int w);
-long pack_mputl(long l);
-char *pack_fgets(char *p, int max);
-int pack_fputs(AL_CONST char *p);
-};
+ virtual ~PACKFILE() {
+ close();
+ }
+
+ virtual void close() {}
+ virtual int pack_fseek(int offset) = 0;
+ virtual int pack_getc() = 0;
+ virtual int pack_putc(int c) = 0;
+ virtual int pack_ungetc(int c) = 0;
+ virtual long pack_fread(void *p, long n) = 0;
+ virtual long pack_fwrite(AL_CONST void *p, long n) = 0;
+ virtual int pack_feof() = 0;
+ virtual int pack_ferror() = 0;
+ virtual void *pack_get_userdata() const {
+ return nullptr;
+ }
+
+ PACKFILE *pack_fopen_chunk(int pack);
+ PACKFILE *pack_fclose_chunk();
+ int pack_igetw();
+ long pack_igetl();
+ int pack_iputw(int w);
+ long pack_iputl(long l);
+ int pack_mgetw();
+ long pack_mgetl();
+ int pack_mputw(int w);
+ long pack_mputl(long l);
+ char *pack_fgets(char *p, int max);
+ int pack_fputs(AL_CONST char *p);
+ };
struct ScummVMPackFile : public PACKFILE {
public:
-Common::SeekableReadStream *_stream;
+ Common::SeekableReadStream *_stream;
-ScummVMPackFile(Common::SeekableReadStream *rs) : PACKFILE(), _stream(rs) {
-}
+ ScummVMPackFile(Common::SeekableReadStream *rs) : PACKFILE(), _stream(rs) {
+ }
-virtual ~ScummVMPackFile() {}
+ virtual ~ScummVMPackFile() {}
-void close() override {
- delete _stream;
- _stream = nullptr;
-}
+ void close() override {
+ delete _stream;
+ _stream = nullptr;
+ }
-int pack_fseek(int offset) override {
- return _stream->seek(offset, SEEK_CUR);
-}
+ int pack_fseek(int offset) override {
+ return _stream->seek(offset, SEEK_CUR);
+ }
-int pack_getc() override {
- return _stream->readByte();
-}
+ int pack_getc() override {
+ return _stream->readByte();
+ }
-int pack_putc(int c) override {
- error("pack_putc is not yet supported");
-}
+ int pack_putc(int c) override {
+ error("pack_putc is not yet supported");
+ }
-int pack_ungetc(int c) override {
- _stream->seek(-1, SEEK_CUR);
- return 0;
-}
+ int pack_ungetc(int c) override {
+ _stream->seek(-1, SEEK_CUR);
+ return 0;
+ }
-long pack_fread(void *p, long n) override {
- return _stream->read(p, n);
-}
+ long pack_fread(void *p, long n) override {
+ return _stream->read(p, n);
+ }
-long pack_fwrite(AL_CONST void *p, long n) override {
- error("pack_fwrite is not yet supported");
-}
+ long pack_fwrite(AL_CONST void *p, long n) override {
+ error("pack_fwrite is not yet supported");
+ }
-int pack_feof() override {
- return _stream->eos();
-}
+ int pack_feof() override {
+ return _stream->eos();
+ }
-int pack_ferror() override {
- return _stream->err();
-}
-};
+ int pack_ferror() override {
+ return _stream->err();
+ }
+ };
-struct VTablePackFile : public PACKFILE {
-AL_CONST PACKFILE_VTABLE *_vTable;
-void *_userData;
+ struct VTablePackFile : public PACKFILE {
+ AL_CONST PACKFILE_VTABLE *_vTable;
+ void *_userData;
-VTablePackFile(AL_CONST PACKFILE_VTABLE *vTable, void *userData) :
- _vTable(vTable), _userData(userData) {
-}
+ VTablePackFile(AL_CONST PACKFILE_VTABLE *vTable, void *userData) :
+ _vTable(vTable), _userData(userData) {
+ }
-void close() override {
- _vTable->pf_fclose(_userData);
-}
+ void close() override {
+ _vTable->pf_fclose(_userData);
+ }
-int pack_fseek(int offset) override {
- return _vTable->pf_fseek(_userData, offset);
-}
+ int pack_fseek(int offset) override {
+ return _vTable->pf_fseek(_userData, offset);
+ }
-int pack_getc() override {
- return _vTable->pf_getc(_userData);
-}
+ int pack_getc() override {
+ return _vTable->pf_getc(_userData);
+ }
-int pack_putc(int c) override {
- return _vTable->pf_putc(c, _userData);
-}
+ int pack_putc(int c) override {
+ return _vTable->pf_putc(c, _userData);
+ }
-int pack_ungetc(int c) override {
- return _vTable->pf_ungetc(c, _userData);
-}
+ int pack_ungetc(int c) override {
+ return _vTable->pf_ungetc(c, _userData);
+ }
-long pack_fread(void *p, long n) override {
- return _vTable->pf_fread(p, n, _userData);
-}
+ long pack_fread(void *p, long n) override {
+ return _vTable->pf_fread(p, n, _userData);
+ }
-long pack_fwrite(AL_CONST void *p, long n) override {
- return _vTable->pf_fwrite(p, n, _userData);
-}
+ long pack_fwrite(AL_CONST void *p, long n) override {
+ return _vTable->pf_fwrite(p, n, _userData);
+ }
-int pack_feof() override {
- return _vTable->pf_feof(_userData);
-}
+ int pack_feof() override {
+ return _vTable->pf_feof(_userData);
+ }
-int pack_ferror() override {
- return _vTable->pf_ferror(_userData);
-}
+ int pack_ferror() override {
+ return _vTable->pf_ferror(_userData);
+ }
-virtual void *pack_get_userdata() const override {
- return _userData;
-}
+ virtual void *pack_get_userdata() const override {
+ return _userData;
+ }
};
extern char *fix_filename_case(char *path);
diff --git a/engines/ags/lib/allegro/surface.h b/engines/ags/lib/allegro/surface.h
index 4a8b30cce2..b6d9f9c7d7 100644
--- a/engines/ags/lib/allegro/surface.h
+++ b/engines/ags/lib/allegro/surface.h
@@ -31,248 +31,248 @@ namespace AGS3 {
class BITMAP {
private:
-Graphics::ManagedSurface *_owner;
+ Graphics::ManagedSurface *_owner;
+ public:
+ uint16 &w, &h, &pitch;
+ Graphics::PixelFormat &format;
+ bool clip;
+ int ct, cb, cl, cr;
+ Common::Array<byte *> line;
public:
-uint16 &w, &h, &pitch;
-Graphics::PixelFormat &format;
-bool clip;
-int ct, cb, cl, cr;
-Common::Array<byte *> line;
-public:
-BITMAP(Graphics::ManagedSurface *owner);
-virtual ~BITMAP() {
-}
-
-Graphics::ManagedSurface &operator*() const {
- return *_owner;
-}
-Graphics::ManagedSurface &getSurface() {
- return *_owner;
-}
-const Graphics::ManagedSurface &getSurface() const {
- return *_owner;
-}
-
-unsigned char *getPixels() const {
- return (unsigned char *)_owner->getPixels();
-}
-
-unsigned char *getBasePtr(uint16 x, uint16 y) const {
- return (unsigned char *)_owner->getBasePtr(x, y);
-}
-
-uint getTransparentColor() const {
- // See allegro bitmap_mask_color
- // For paletted sprites this is 0.
- // For other color depths this is bright pink (RGB 255, 0, 255) with alpha set to 0.
- if (format.bytesPerPixel == 1)
- return 0;
- return format.ARGBToColor(0, 255, 0, 255);
-}
-
-inline const Common::Point getOffsetFromOwner() const {
- return _owner->getOffsetFromOwner();
-}
-
-int getpixel(int x, int y) const;
-
-void clear() {
- _owner->clear();
-}
-
-void makeOpaque();
+ BITMAP(Graphics::ManagedSurface *owner);
+ virtual ~BITMAP() {
+ }
-/**
- * Draws a solid filled in circle
- */
-void circlefill(int x, int y, int radius, int color);
+ Graphics::ManagedSurface &operator*() const {
+ return *_owner;
+ }
+ Graphics::ManagedSurface &getSurface() {
+ return *_owner;
+ }
+ const Graphics::ManagedSurface &getSurface() const {
+ return *_owner;
+ }
-/**
- * Fills an enclosed area starting at a given point
- */
-void floodfill(int x, int y, int color);
+ unsigned char *getPixels() const {
+ return (unsigned char *)_owner->getPixels();
+ }
-/**
- * Draw a horizontal line
- */
-void hLine(int x, int y, int x2, uint32 color) {
- _owner->hLine(x, y, x2, color);
-}
+ unsigned char *getBasePtr(uint16 x, uint16 y) const {
+ return (unsigned char *)_owner->getBasePtr(x, y);
+ }
-/**
- * Draw a vertical line.
- */
-void vLine(int x, int y, int y2, uint32 color) {
- _owner->vLine(x, y, y2, color);
-}
+ uint getTransparentColor() const {
+ // See allegro bitmap_mask_color
+ // For paletted sprites this is 0.
+ // For other color depths this is bright pink (RGB 255, 0, 255) with alpha set to 0.
+ if (format.bytesPerPixel == 1)
+ return 0;
+ return format.ARGBToColor(0, 255, 0, 255);
+ }
-/**
- * Draws the passed surface onto this one
- */
-void draw(const BITMAP *srcBitmap, const Common::Rect &srcRect,
- int dstX, int dstY, bool horizFlip, bool vertFlip,
- bool skipTrans, int srcAlpha, int tintRed = -1, int tintGreen = -1,
- int tintBlue = -1);
+ inline const Common::Point getOffsetFromOwner() const {
+ return _owner->getOffsetFromOwner();
+ }
-/**
- * Stretches and draws the passed surface onto this one
- */
-void stretchDraw(const BITMAP *srcBitmap, const Common::Rect &srcRect,
- const Common::Rect &destRect, bool skipTrans, int srcAlpha);
+ int getpixel(int x, int y) const;
-inline bool isSubBitmap() const {
- return _owner->disposeAfterUse() == DisposeAfterUse::NO;
-}
+ void clear() {
+ _owner->clear();
+ }
-private:
-// True color blender functions
-// In Allegro all the blender functions are of the form
-// unsigned int blender_func(unsigned long x, unsigned long y, unsigned long n)
-// when x is the sprite color, y the destination color, and n an alpha value
-
-void blendPixel(uint8 aSrc, uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &aDest, uint8 &rDest, uint8 &gDest, uint8 &bDest, uint32 alpha) const;
-
-
-inline void rgbBlend(uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &rDest, uint8 &gDest, uint8 &bDest, uint32 alpha) const {
- // Original logic has uint32 src and dst colors as RGB888
- // if (alpha)
- // ++alpha;
- // uint32 res = ((src & 0xFF00FF) - (dst & 0xFF00FF)) * alpha / 256 + dst;
- // dst &= 0x00FF00;
- // src &= 0x00FF00;
- // uint32 g = (src - dst) * alpha / 256 + dst;
- // return (res & 0xFF00FF) | (g & 0x00FF00)
- double sAlpha = (double)(alpha & 0xff) / 255.0;
- rDest = static_cast<uint8>(rSrc * sAlpha + rDest * (1. - sAlpha));
- gDest = static_cast<uint8>(gSrc * sAlpha + gDest * (1. - sAlpha));
- bDest = static_cast<uint8>(bSrc * sAlpha + bDest * (1. - sAlpha));
-}
-
-inline void argbBlend(uint32 aSrc, uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &aDest, uint8 &rDest, uint8 &gDest, uint8 &bDest) const {
- // Original logic has uint32 src and dst colors as ARGB8888
- // ++src_alpha;
- // uint32 dst_alpha = geta32(dst);
- // if (dst_alpha)
- // ++dst_alpha;
- // uint32 dst_g = (dst & 0x00FF00) * dst_alpha / 256;
- // dst = (dst & 0xFF00FF) * dst_alpha / 256;
- // dst_g = (((src & 0x00FF00) - (dst_g & 0x00FF00)) * src_alpha / 256 + dst_g) & 0x00FF00;
- // dst = (((src & 0xFF00FF) - (dst & 0xFF00FF)) * src_alpha / 256 + dst) & 0xFF00FF;
- // dst_alpha = 256 - (256 - src_alpha) * (256 - dst_alpha) / 256;
- // src_alpha = /* 256 * 256 == */ 0x10000 / dst_alpha;
- // dst_g = (dst_g * src_alpha / 256) & 0x00FF00;
- // dst = (dst * src_alpha / 256) & 0xFF00FF;
- // return dst | dst_g | (--dst_alpha << 24);
- double sAlpha = (double)(aSrc & 0xff) / 255.0;
- double dAlpha = (double)aDest / 255.0;
- dAlpha *= (1.0 - sAlpha);
- rDest = static_cast<uint8>((rSrc * sAlpha + rDest * dAlpha) / (sAlpha + dAlpha));
- gDest = static_cast<uint8>((gSrc * sAlpha + gDest * dAlpha) / (sAlpha + dAlpha));
- bDest = static_cast<uint8>((bSrc * sAlpha + bDest * dAlpha) / (sAlpha + dAlpha));
- aDest = static_cast<uint8>(255. * (sAlpha + dAlpha));
-}
-
-// kRgbToRgbBlender
-inline void blendRgbToRgb(uint8 aSrc, uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &aDest, uint8 &rDest, uint8 &gDest, uint8 &bDest, uint32 alpha) const {
- // Default mode for set_trans_blender
- rgbBlend(rSrc, gSrc, bSrc, rDest, gDest, bDest, alpha);
- // Original doesn't set alpha (so it is 0), but the function is not meant to be used
- // on bitmap with transparency. Should we set alpha to 0xff?
- aDest = 0;
-}
-
-// kAlphaPreservedBlenderMode
-inline void blendPreserveAlpha(uint8 aSrc, uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &aDest, uint8 &rDest, uint8 &gDest, uint8 &bDest, uint32 alpha) const {
- // Original blender function: _myblender_alpha_trans24
- // Like blendRgbToRgb, but result as the same alpha as destColor
- rgbBlend(rSrc, gSrc, bSrc, rDest, gDest, bDest, alpha);
- // Preserve value in aDest
-}
-
-// kArgbToArgbBlender
-inline void blendArgbToArgb(uint8 aSrc, uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &aDest, uint8 &rDest, uint8 &gDest, uint8 &bDest, uint32 alpha) const {
- // Original blender functions: _argb2argb_blender
- if (alpha == 0)
- alpha = aSrc;
- else
- alpha = aSrc * ((alpha & 0xff) + 1) / 256;
- if (alpha != 0)
- argbBlend(alpha, rSrc, gSrc, bSrc, aDest, rDest, gDest, bDest);
-}
-
-// kRgbToArgbBlender
-inline void blendRgbToArgb(uint8 aSrc, uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &aDest, uint8 &rDest, uint8 &gDest, uint8 &bDest, uint32 alpha) const {
- // Original blender function: _rgb2argb_blenders
- if (alpha == 0 || alpha == 0xff) {
+ void makeOpaque();
+
+ /**
+ * Draws a solid filled in circle
+ */
+ void circlefill(int x, int y, int radius, int color);
+
+ /**
+ * Fills an enclosed area starting at a given point
+ */
+ void floodfill(int x, int y, int color);
+
+ /**
+ * Draw a horizontal line
+ */
+ void hLine(int x, int y, int x2, uint32 color) {
+ _owner->hLine(x, y, x2, color);
+ }
+
+ /**
+ * Draw a vertical line.
+ */
+ void vLine(int x, int y, int y2, uint32 color) {
+ _owner->vLine(x, y, y2, color);
+ }
+
+ /**
+ * Draws the passed surface onto this one
+ */
+ void draw(const BITMAP *srcBitmap, const Common::Rect &srcRect,
+ int dstX, int dstY, bool horizFlip, bool vertFlip,
+ bool skipTrans, int srcAlpha, int tintRed = -1, int tintGreen = -1,
+ int tintBlue = -1);
+
+ /**
+ * Stretches and draws the passed surface onto this one
+ */
+ void stretchDraw(const BITMAP *srcBitmap, const Common::Rect &srcRect,
+ const Common::Rect &destRect, bool skipTrans, int srcAlpha);
+
+ inline bool isSubBitmap() const {
+ return _owner->disposeAfterUse() == DisposeAfterUse::NO;
+ }
+
+ private:
+ // True color blender functions
+ // In Allegro all the blender functions are of the form
+ // unsigned int blender_func(unsigned long x, unsigned long y, unsigned long n)
+ // when x is the sprite color, y the destination color, and n an alpha value
+
+ void blendPixel(uint8 aSrc, uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &aDest, uint8 &rDest, uint8 &gDest, uint8 &bDest, uint32 alpha) const;
+
+
+ inline void rgbBlend(uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &rDest, uint8 &gDest, uint8 &bDest, uint32 alpha) const {
+ // Original logic has uint32 src and dst colors as RGB888
+ // if (alpha)
+ // ++alpha;
+ // uint32 res = ((src & 0xFF00FF) - (dst & 0xFF00FF)) * alpha / 256 + dst;
+ // dst &= 0x00FF00;
+ // src &= 0x00FF00;
+ // uint32 g = (src - dst) * alpha / 256 + dst;
+ // return (res & 0xFF00FF) | (g & 0x00FF00)
+ double sAlpha = (double)(alpha & 0xff) / 255.0;
+ rDest = static_cast<uint8>(rSrc * sAlpha + rDest * (1. - sAlpha));
+ gDest = static_cast<uint8>(gSrc * sAlpha + gDest * (1. - sAlpha));
+ bDest = static_cast<uint8>(bSrc * sAlpha + bDest * (1. - sAlpha));
+ }
+
+ inline void argbBlend(uint32 aSrc, uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &aDest, uint8 &rDest, uint8 &gDest, uint8 &bDest) const {
+ // Original logic has uint32 src and dst colors as ARGB8888
+ // ++src_alpha;
+ // uint32 dst_alpha = geta32(dst);
+ // if (dst_alpha)
+ // ++dst_alpha;
+ // uint32 dst_g = (dst & 0x00FF00) * dst_alpha / 256;
+ // dst = (dst & 0xFF00FF) * dst_alpha / 256;
+ // dst_g = (((src & 0x00FF00) - (dst_g & 0x00FF00)) * src_alpha / 256 + dst_g) & 0x00FF00;
+ // dst = (((src & 0xFF00FF) - (dst & 0xFF00FF)) * src_alpha / 256 + dst) & 0xFF00FF;
+ // dst_alpha = 256 - (256 - src_alpha) * (256 - dst_alpha) / 256;
+ // src_alpha = /* 256 * 256 == */ 0x10000 / dst_alpha;
+ // dst_g = (dst_g * src_alpha / 256) & 0x00FF00;
+ // dst = (dst * src_alpha / 256) & 0xFF00FF;
+ // return dst | dst_g | (--dst_alpha << 24);
+ double sAlpha = (double)(aSrc & 0xff) / 255.0;
+ double dAlpha = (double)aDest / 255.0;
+ dAlpha *= (1.0 - sAlpha);
+ rDest = static_cast<uint8>((rSrc * sAlpha + rDest * dAlpha) / (sAlpha + dAlpha));
+ gDest = static_cast<uint8>((gSrc * sAlpha + gDest * dAlpha) / (sAlpha + dAlpha));
+ bDest = static_cast<uint8>((bSrc * sAlpha + bDest * dAlpha) / (sAlpha + dAlpha));
+ aDest = static_cast<uint8>(255. * (sAlpha + dAlpha));
+ }
+
+ // kRgbToRgbBlender
+ inline void blendRgbToRgb(uint8 aSrc, uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &aDest, uint8 &rDest, uint8 &gDest, uint8 &bDest, uint32 alpha) const {
+ // Default mode for set_trans_blender
+ rgbBlend(rSrc, gSrc, bSrc, rDest, gDest, bDest, alpha);
+ // Original doesn't set alpha (so it is 0), but the function is not meant to be used
+ // on bitmap with transparency. Should we set alpha to 0xff?
+ aDest = 0;
+ }
+
+ // kAlphaPreservedBlenderMode
+ inline void blendPreserveAlpha(uint8 aSrc, uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &aDest, uint8 &rDest, uint8 &gDest, uint8 &bDest, uint32 alpha) const {
+ // Original blender function: _myblender_alpha_trans24
+ // Like blendRgbToRgb, but result as the same alpha as destColor
+ rgbBlend(rSrc, gSrc, bSrc, rDest, gDest, bDest, alpha);
+ // Preserve value in aDest
+ }
+
+ // kArgbToArgbBlender
+ inline void blendArgbToArgb(uint8 aSrc, uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &aDest, uint8 &rDest, uint8 &gDest, uint8 &bDest, uint32 alpha) const {
+ // Original blender functions: _argb2argb_blender
+ if (alpha == 0)
+ alpha = aSrc;
+ else
+ alpha = aSrc * ((alpha & 0xff) + 1) / 256;
+ if (alpha != 0)
+ argbBlend(alpha, rSrc, gSrc, bSrc, aDest, rDest, gDest, bDest);
+ }
+
+ // kRgbToArgbBlender
+ inline void blendRgbToArgb(uint8 aSrc, uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &aDest, uint8 &rDest, uint8 &gDest, uint8 &bDest, uint32 alpha) const {
+ // Original blender function: _rgb2argb_blenders
+ if (alpha == 0 || alpha == 0xff) {
+ aDest = 0xff;
+ rDest = rSrc;
+ gDest = gSrc;
+ bDest = bSrc;
+ } else
+ argbBlend(alpha, rSrc, gSrc, bSrc, aDest, rDest, gDest, bDest);
+ }
+
+ // kArgbToRgbBlender
+ inline void blendArgbToRgb(uint8 aSrc, uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &aDest, uint8 &rDest, uint8 &gDest, uint8 &bDest, uint32 alpha) const {
+ // Original blender function: _argb2rgb_blender
+ if (alpha == 0)
+ alpha = aSrc;
+ else
+ alpha = aSrc * ((alpha & 0xff) + 1) / 256;
+ rgbBlend(rSrc, gSrc, bSrc, rDest, gDest, bDest, alpha);
+ // Original doesn't set alpha (so it is 0), but the function is not meant to be used
+ // on bitmap with transparency. Should we set alpha to 0xff?
+ aDest = 0;
+ }
+
+ // kOpaqueBlenderMode
+ inline void blendOpaque(uint8 aSrc, uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &aDest, uint8 &rDest, uint8 &gDest, uint8 &bDest, uint32 alpha) const {
+ // Original blender function: _opaque_alpha_blender
aDest = 0xff;
rDest = rSrc;
gDest = gSrc;
bDest = bSrc;
- } else
- argbBlend(alpha, rSrc, gSrc, bSrc, aDest, rDest, gDest, bDest);
-}
-
-// kArgbToRgbBlender
-inline void blendArgbToRgb(uint8 aSrc, uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &aDest, uint8 &rDest, uint8 &gDest, uint8 &bDest, uint32 alpha) const {
- // Original blender function: _argb2rgb_blender
- if (alpha == 0)
- alpha = aSrc;
- else
- alpha = aSrc * ((alpha & 0xff) + 1) / 256;
- rgbBlend(rSrc, gSrc, bSrc, rDest, gDest, bDest, alpha);
- // Original doesn't set alpha (so it is 0), but the function is not meant to be used
- // on bitmap with transparency. Should we set alpha to 0xff?
- aDest = 0;
-}
-
-// kOpaqueBlenderMode
-inline void blendOpaque(uint8 aSrc, uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &aDest, uint8 &rDest, uint8 &gDest, uint8 &bDest, uint32 alpha) const {
- // Original blender function: _opaque_alpha_blender
- aDest = 0xff;
- rDest = rSrc;
- gDest = gSrc;
- bDest = bSrc;
-}
-
-// kSourceAlphaBlender
-inline void blendSourceAlpha(uint8 aSrc, uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &aDest, uint8 &rDest, uint8 &gDest, uint8 &bDest, uint32 alpha) const {
- // Used after set_alpha_blender
- // Uses alpha from source. Result is fully opaque
- rgbBlend(rSrc, gSrc, bSrc, rDest, gDest, bDest, aSrc);
- // Original doesn't set alpha (so it is 0), but the function is not meant to be used
- // on bitmap with transparency. Should we set alpha to 0xff?
- aDest = 0;
-}
-
-// kAdditiveBlenderMode
-inline void blendAdditiveAlpha(uint8 aSrc, uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &aDest, uint8 &rDest, uint8 &gDest, uint8 &bDest, uint32 alpha) const {
- // Original blender function: _additive_alpha_copysrc_blender
- rDest = rSrc;
- gDest = gSrc;
- bDest = bSrc;
- uint32 a = (uint32)aSrc + (uint32)aDest;
- if (a > 0xff)
- aDest = 0xff;
- else
- aDest = static_cast<uint8>(a);
-}
-
-// kTintBlenderMode and kTintLightBlenderMode
-void blendTintSprite(uint8 aSrc, uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &aDest, uint8 &rDest, uint8 &gDest, uint8 &bDest, uint32 alpha, bool light) const;
-
-
-inline uint32 getColor(const byte *data, byte bpp) const {
- switch (bpp) {
- case 1:
- return *data;
- case 2:
- return *(const uint16 *)data;
- case 4:
- return *(const uint32 *)data;
- default:
- error("Unsupported format in BITMAP::getColor");
}
-}
+
+ // kSourceAlphaBlender
+ inline void blendSourceAlpha(uint8 aSrc, uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &aDest, uint8 &rDest, uint8 &gDest, uint8 &bDest, uint32 alpha) const {
+ // Used after set_alpha_blender
+ // Uses alpha from source. Result is fully opaque
+ rgbBlend(rSrc, gSrc, bSrc, rDest, gDest, bDest, aSrc);
+ // Original doesn't set alpha (so it is 0), but the function is not meant to be used
+ // on bitmap with transparency. Should we set alpha to 0xff?
+ aDest = 0;
+ }
+
+ // kAdditiveBlenderMode
+ inline void blendAdditiveAlpha(uint8 aSrc, uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &aDest, uint8 &rDest, uint8 &gDest, uint8 &bDest, uint32 alpha) const {
+ // Original blender function: _additive_alpha_copysrc_blender
+ rDest = rSrc;
+ gDest = gSrc;
+ bDest = bSrc;
+ uint32 a = (uint32)aSrc + (uint32)aDest;
+ if (a > 0xff)
+ aDest = 0xff;
+ else
+ aDest = static_cast<uint8>(a);
+ }
+
+ // kTintBlenderMode and kTintLightBlenderMode
+ void blendTintSprite(uint8 aSrc, uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &aDest, uint8 &rDest, uint8 &gDest, uint8 &bDest, uint32 alpha, bool light) const;
+
+
+ inline uint32 getColor(const byte *data, byte bpp) const {
+ switch (bpp) {
+ case 1:
+ return *data;
+ case 2:
+ return *(const uint16 *)data;
+ case 4:
+ return *(const uint32 *)data;
+ default:
+ error("Unsupported format in BITMAP::getColor");
+ }
+ }
};
/**
@@ -280,20 +280,20 @@ inline uint32 getColor(const byte *data, byte bpp) const {
*/
class Surface : public Graphics::ManagedSurface, public BITMAP {
public:
-Surface(int width, int height, const Graphics::PixelFormat &pixelFormat) :
- Graphics::ManagedSurface(width, height, pixelFormat), BITMAP(this) {
- // Allegro uses 255, 0, 255 RGB as the transparent color
- if (pixelFormat.bytesPerPixel == 2 || pixelFormat.bytesPerPixel == 4)
- setTransparentColor(pixelFormat.RGBToColor(255, 0, 255));
-}
-Surface(Graphics::ManagedSurface &surf, const Common::Rect &bounds) :
- Graphics::ManagedSurface(surf, bounds), BITMAP(this) {
- // Allegro uses 255, 0, 255 RGB as the transparent color
- if (surf.format.bytesPerPixel == 2 || surf.format.bytesPerPixel == 4)
- setTransparentColor(surf.format.RGBToColor(255, 0, 255));
-}
-~Surface() override {
-}
+ Surface(int width, int height, const Graphics::PixelFormat &pixelFormat) :
+ Graphics::ManagedSurface(width, height, pixelFormat), BITMAP(this) {
+ // Allegro uses 255, 0, 255 RGB as the transparent color
+ if (pixelFormat.bytesPerPixel == 2 || pixelFormat.bytesPerPixel == 4)
+ setTransparentColor(pixelFormat.RGBToColor(255, 0, 255));
+ }
+ Surface(Graphics::ManagedSurface &surf, const Common::Rect &bounds) :
+ Graphics::ManagedSurface(surf, bounds), BITMAP(this) {
+ // Allegro uses 255, 0, 255 RGB as the transparent color
+ if (surf.format.bytesPerPixel == 2 || surf.format.bytesPerPixel == 4)
+ setTransparentColor(surf.format.RGBToColor(255, 0, 255));
+ }
+ ~Surface() override {
+ }
};
BITMAP *create_bitmap(int width, int height);
diff --git a/engines/ags/lib/allegro/system.h b/engines/ags/lib/allegro/system.h
index d82dfcd729..6b1aed155f 100644
--- a/engines/ags/lib/allegro/system.h
+++ b/engines/ags/lib/allegro/system.h
@@ -55,81 +55,81 @@ int width, height, bpp;
};
struct GFX_MODE_LIST {
-int num_modes; /* number of gfx modes */
-GFX_MODE *mode; /* pointer to the actual mode list array */
+ int num_modes; /* number of gfx modes */
+ GFX_MODE *mode; /* pointer to the actual mode list array */
};
struct SYSTEM_DRIVER {
-int id;
-const char *name;
-const char *desc;
-const char *ascii_name;
-AL_METHOD(int, init, (void));
-AL_METHOD(void, exit, (void));
-AL_METHOD(void, get_executable_name, (char *output, int size));
-AL_METHOD(int, find_resource, (char *dest, const char *resource, int size));
-AL_METHOD(void, set_window_title, (const char *name));
-AL_METHOD(int, set_close_button_callback, (AL_METHOD(void, proc, (void))));
-AL_METHOD(void, message, (const char *msg));
-AL_METHOD(void, assert, (const char *msg));
-AL_METHOD(void, save_console_state, (void));
-AL_METHOD(void, restore_console_state, (void));
-AL_METHOD(BITMAP *, create_bitmap, (int color_depth, int width, int height));
-AL_METHOD(void, created_bitmap, (BITMAP *bmp));
-AL_METHOD(BITMAP *, create_sub_bitmap, (BITMAP *parent, int x, int y, int width, int height));
-AL_METHOD(void, created_sub_bitmap, (BITMAP *bmp, BITMAP *parent));
-AL_METHOD(int, destroy_bitmap, (BITMAP *bitmap));
-AL_METHOD(void, read_hardware_palette, (void));
-AL_METHOD(void, set_palette_range, (const RGB *p, int from, int to, int retracesync));
-AL_METHOD(struct GFX_VTABLE *, get_vtable, (int color_depth));
-AL_METHOD(int, set_display_switch_mode, (int mode));
-AL_METHOD(void, display_switch_lock, (int lock, int foreground));
-AL_METHOD(int, desktop_color_depth, (void));
-AL_METHOD(int, get_desktop_resolution, (int *width, int *height));
-AL_METHOD(void, get_gfx_safe_mode, (int *driver, struct GFX_MODE *mode));
-AL_METHOD(void, yield_timeslice, (void));
-AL_METHOD(void *, create_mutex, (void));
-AL_METHOD(void, destroy_mutex, (void *handle));
-AL_METHOD(void, lock_mutex, (void *handle));
-AL_METHOD(void, unlock_mutex, (void *handle));
+ int id;
+ const char *name;
+ const char *desc;
+ const char *ascii_name;
+ AL_METHOD(int, init, (void));
+ AL_METHOD(void, exit, (void));
+ AL_METHOD(void, get_executable_name, (char *output, int size));
+ AL_METHOD(int, find_resource, (char *dest, const char *resource, int size));
+ AL_METHOD(void, set_window_title, (const char *name));
+ AL_METHOD(int, set_close_button_callback, (AL_METHOD(void, proc, (void))));
+ AL_METHOD(void, message, (const char *msg));
+ AL_METHOD(void, assert, (const char *msg));
+ AL_METHOD(void, save_console_state, (void));
+ AL_METHOD(void, restore_console_state, (void));
+ AL_METHOD(BITMAP *, create_bitmap, (int color_depth, int width, int height));
+ AL_METHOD(void, created_bitmap, (BITMAP *bmp));
+ AL_METHOD(BITMAP *, create_sub_bitmap, (BITMAP *parent, int x, int y, int width, int height));
+ AL_METHOD(void, created_sub_bitmap, (BITMAP *bmp, BITMAP *parent));
+ AL_METHOD(int, destroy_bitmap, (BITMAP *bitmap));
+ AL_METHOD(void, read_hardware_palette, (void));
+ AL_METHOD(void, set_palette_range, (const RGB *p, int from, int to, int retracesync));
+ AL_METHOD(struct GFX_VTABLE *, get_vtable, (int color_depth));
+ AL_METHOD(int, set_display_switch_mode, (int mode));
+ AL_METHOD(void, display_switch_lock, (int lock, int foreground));
+ AL_METHOD(int, desktop_color_depth, (void));
+ AL_METHOD(int, get_desktop_resolution, (int *width, int *height));
+ AL_METHOD(void, get_gfx_safe_mode, (int *driver, struct GFX_MODE *mode));
+ AL_METHOD(void, yield_timeslice, (void));
+ AL_METHOD(void *, create_mutex, (void));
+ AL_METHOD(void, destroy_mutex, (void *handle));
+ AL_METHOD(void, lock_mutex, (void *handle));
+ AL_METHOD(void, unlock_mutex, (void *handle));
};
/* creates and manages the screen bitmap */
struct GFX_DRIVER {
-int id;
-AL_CONST char *name;
-AL_CONST char *desc;
-AL_CONST char *ascii_name;
-AL_METHOD(BITMAP *, init, (int w, int h, int v_w, int v_h, int color_depth));
-AL_METHOD(void, exit, (BITMAP *b));
-AL_METHOD(int, scroll, (int x, int y));
-AL_METHOD(void, vsync, (void));
-AL_METHOD(void, set_palette, (AL_CONST RGB *p, int from, int to, int retracesync));
-AL_METHOD(int, request_scroll, (int x, int y));
-AL_METHOD(int, poll_scroll, (void));
-AL_METHOD(void, enable_triple_buffer, (void));
-AL_METHOD(BITMAP *, create_video_bitmap, (int width, int height));
-AL_METHOD(void, destroy_video_bitmap, (BITMAP *bitmap));
-AL_METHOD(int, show_video_bitmap, (BITMAP *bitmap));
-AL_METHOD(int, request_video_bitmap, (BITMAP *bitmap));
-AL_METHOD(BITMAP *, create_system_bitmap, (int width, int height));
-AL_METHOD(void, destroy_system_bitmap, (BITMAP *bitmap));
-AL_METHOD(int, set_mouse_sprite, (BITMAP *sprite, int xfocus, int yfocus));
-AL_METHOD(int, show_mouse, (BITMAP *bmp, int x, int y));
-AL_METHOD(void, hide_mouse, (void));
-AL_METHOD(void, move_mouse, (int x, int y));
-AL_METHOD(void, drawing_mode, (void));
-AL_METHOD(void, save_video_state, (void));
-AL_METHOD(void, restore_video_state, (void));
-AL_METHOD(void, set_blender_mode, (int mode, int r, int g, int b, int a));
-AL_METHOD(GFX_MODE_LIST *, fetch_mode_list, (void));
-int w, h; /* physical (not virtual!) screen size */
-int linear; /* true if video memory is linear */
-long bank_size; /* bank size, in bytes */
-long bank_gran; /* bank granularity, in bytes */
-long vid_mem; /* video memory size, in bytes */
-long vid_phys_base; /* physical address of video memory */
-int windowed; /* true if driver runs windowed */
+ int id;
+ AL_CONST char *name;
+ AL_CONST char *desc;
+ AL_CONST char *ascii_name;
+ AL_METHOD(BITMAP *, init, (int w, int h, int v_w, int v_h, int color_depth));
+ AL_METHOD(void, exit, (BITMAP *b));
+ AL_METHOD(int, scroll, (int x, int y));
+ AL_METHOD(void, vsync, (void));
+ AL_METHOD(void, set_palette, (AL_CONST RGB *p, int from, int to, int retracesync));
+ AL_METHOD(int, request_scroll, (int x, int y));
+ AL_METHOD(int, poll_scroll, (void));
+ AL_METHOD(void, enable_triple_buffer, (void));
+ AL_METHOD(BITMAP *, create_video_bitmap, (int width, int height));
+ AL_METHOD(void, destroy_video_bitmap, (BITMAP *bitmap));
+ AL_METHOD(int, show_video_bitmap, (BITMAP *bitmap));
+ AL_METHOD(int, request_video_bitmap, (BITMAP *bitmap));
+ AL_METHOD(BITMAP *, create_system_bitmap, (int width, int height));
+ AL_METHOD(void, destroy_system_bitmap, (BITMAP *bitmap));
+ AL_METHOD(int, set_mouse_sprite, (BITMAP *sprite, int xfocus, int yfocus));
+ AL_METHOD(int, show_mouse, (BITMAP *bmp, int x, int y));
+ AL_METHOD(void, hide_mouse, (void));
+ AL_METHOD(void, move_mouse, (int x, int y));
+ AL_METHOD(void, drawing_mode, (void));
+ AL_METHOD(void, save_video_state, (void));
+ AL_METHOD(void, restore_video_state, (void));
+ AL_METHOD(void, set_blender_mode, (int mode, int r, int g, int b, int a));
+ AL_METHOD(GFX_MODE_LIST *, fetch_mode_list, (void));
+ int w, h; /* physical (not virtual!) screen size */
+ int linear; /* true if video memory is linear */
+ long bank_size; /* bank size, in bytes */
+ long bank_gran; /* bank granularity, in bytes */
+ long vid_mem; /* video memory size, in bytes */
+ long vid_phys_base; /* physical address of video memory */
+ int windowed; /* true if driver runs windowed */
};
extern void set_color_depth(int depth);
@@ -143,10 +143,10 @@ extern void destroy_gfx_mode_list(GFX_MODE_LIST *list);
inline void vsync() {}
inline int set_display_switch_callback(int dir, AL_METHOD(void, cb, (void))) {
-return 0;
+ return 0;
}
inline int set_display_switch_mode(int v) {
-return -1;
+ return -1;
}
} // namespace AGS3
More information about the Scummvm-git-logs
mailing list