aboutsummaryrefslogtreecommitdiff
path: root/engines/agi/picture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/agi/picture.cpp')
-rw-r--r--engines/agi/picture.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/engines/agi/picture.cpp b/engines/agi/picture.cpp
index 9a16d4ab20..cd8ef83de0 100644
--- a/engines/agi/picture.cpp
+++ b/engines/agi/picture.cpp
@@ -86,7 +86,7 @@ void PictureMgr::putVirtPixel(int x, int y) {
if (x < 0 || y < 0 || x >= _WIDTH || y >= _HEIGHT)
return;
- p = &_vm->_game.sbuf[y * _WIDTH + x];
+ p = &_vm->_game.sbuf16c[y * _WIDTH + x];
if (priOn)
*p = (priColour << 4) | (*p & 0x0f);
@@ -281,7 +281,7 @@ INLINE int PictureMgr::isOkFillHere(int x, int y) {
if (!scrOn && !priOn)
return false;
- p = _vm->_game.sbuf[y * _WIDTH + x];
+ p = _vm->_game.sbuf16c[y * _WIDTH + x];
if (!priOn && scrOn && scrColour != 15)
return (p & 0x0f) == 15;
@@ -619,8 +619,9 @@ uint8 *PictureMgr::convertV3Pic(uint8 *src, uint32 len) {
* drawing.
* @param n AGI picture resource number
* @param clear clear AGI screen before drawing
+ * @param agi256 load an AGI256 picture resource
*/
-int PictureMgr::decodePicture(int n, int clear) {
+int PictureMgr::decodePicture(int n, int clear, bool agi256) {
debugC(8, kDebugLevelResources, "(%d)", n);
patCode = 0;
@@ -633,10 +634,21 @@ int PictureMgr::decodePicture(int n, int clear) {
flen = _vm->_game.dirPic[n].len;
foffs = 0;
- if (clear)
- memset(_vm->_game.sbuf, 0x4f, _WIDTH * _HEIGHT);
+ if (clear && !agi256) // 256 color pictures should always fill the whole screen, so no clearing for them.
+ memset(_vm->_game.sbuf16c, 0x4f, _WIDTH * _HEIGHT); // Clear 16 color AGI screen (Priority 4, color white).
- drawPicture();
+ if (!agi256) {
+ drawPicture(); // Draw 16 color picture.
+ } else {
+ const uint32 maxFlen = _WIDTH * _HEIGHT;
+ memcpy(_vm->_game.sbuf256c, data, MIN(flen, maxFlen)); // Draw 256 color picture.
+
+ if (flen < maxFlen) {
+ warning("Undersized AGI256 picture resource %d, using it anyway. Filling rest with white.", n);
+ memset(_vm->_game.sbuf256c + flen, 0x0f, maxFlen - flen); // Fill missing area with white.
+ } else if (flen > maxFlen)
+ warning("Oversized AGI256 picture resource %d, decoding only %ux%u part of it", n, _WIDTH, _HEIGHT);
+ }
if (clear)
_vm->clearImageStack();