[Scummvm-git-logs] scummvm master -> b1d860d66bab692a073ab45e48ff239fd45c896a
sev-
noreply at scummvm.org
Wed Sep 4 21:50:38 UTC 2024
This automated email contains information about 10 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
22cac63a68 QDENGINE: Implement grTileAnimation::find_closest_scale()
236ae276b7 QDENGINE: Implement grTileAnimation::wasFrameSizeChanged()
54c47b6e7f QDENGINE: Added QDA v106 code changes to grTileAnimation::drawFrame()
1e199c393f QDENGINE: Implemented grTileAnimation::drawFrame_scale()
6f62280387 QDENGINE: Initial code for grTileAnimation::decode_frame_data(()
7ac10db61d QDENGINE: Hooked left control button as default
6d716ee78a QDENGINE: More debug output on animation loading
b3dd95b2bd QDENGINE: Added more debug output on QDA load
e410466f23 QDENGINE: Further fixes to tile frame rendering. Still incorrect
b1d860d66b QDENGINE: Implemented tile dumping into .png files
Commit: 22cac63a687ae5920792f00f89fff525df6284e5
https://github.com/scummvm/scummvm/commit/22cac63a687ae5920792f00f89fff525df6284e5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-09-04T23:49:52+02:00
Commit Message:
QDENGINE: Implement grTileAnimation::find_closest_scale()
Changed paths:
engines/qdengine/system/graphics/gr_tile_animation.cpp
engines/qdengine/system/graphics/gr_tile_animation.h
diff --git a/engines/qdengine/system/graphics/gr_tile_animation.cpp b/engines/qdengine/system/graphics/gr_tile_animation.cpp
index e76358ad45f..ec680a91f65 100644
--- a/engines/qdengine/system/graphics/gr_tile_animation.cpp
+++ b/engines/qdengine/system/graphics/gr_tile_animation.cpp
@@ -330,4 +330,21 @@ void grTileAnimation::drawFrame(const Vect2i &position, int frame_index, float a
grDispatcher::instance()->putSpr_rot(position, _frameSize, buf, _hasAlpha, mode, angle);
}
+int grTileAnimation::find_closest_scale(float *scale) {
+ int idx = -1;
+ float temp = 1.0;
+
+ for (int i = 0; i < _scaleArray.size(); i++) {
+ if (fabs(*scale - _scaleArray[i]._scale) < fabs(*scale - temp)) {
+ idx = i;
+ temp = _scaleArray[i]._scale;
+ }
+ }
+
+ if (idx != -1)
+ *scale = *scale / temp;
+
+ return idx;
+}
+
} // namespace QDEngine
diff --git a/engines/qdengine/system/graphics/gr_tile_animation.h b/engines/qdengine/system/graphics/gr_tile_animation.h
index 8f8f8aa45ca..24abce564dd 100644
--- a/engines/qdengine/system/graphics/gr_tile_animation.h
+++ b/engines/qdengine/system/graphics/gr_tile_animation.h
@@ -77,6 +77,8 @@ public:
_progressHandlerContext = context;
}
+ int find_closest_scale(float *scale);
+
private:
grTileCompressionMethod _compression;
Commit: 236ae276b780331f769a7ed525c65c10091e6ed4
https://github.com/scummvm/scummvm/commit/236ae276b780331f769a7ed525c65c10091e6ed4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-09-04T23:49:52+02:00
Commit Message:
QDENGINE: Implement grTileAnimation::wasFrameSizeChanged()
Changed paths:
engines/qdengine/qdcore/qd_animation.cpp
engines/qdengine/system/graphics/gr_tile_animation.cpp
engines/qdengine/system/graphics/gr_tile_animation.h
diff --git a/engines/qdengine/qdcore/qd_animation.cpp b/engines/qdengine/qdcore/qd_animation.cpp
index cb4d0567db1..94634c3507a 100644
--- a/engines/qdengine/qdcore/qd_animation.cpp
+++ b/engines/qdengine/qdcore/qd_animation.cpp
@@ -148,7 +148,7 @@ void qdAnimation::redraw(int x, int y, int z, int mode) const {
mode |= GR_BLACK_FON;
if (tileAnimation()) {
- tileAnimation()->drawFrame(Vect2i(x, y), get_cur_frame_number(), mode);
+ tileAnimation()->drawFrame(Vect2i(x, y), get_cur_frame_number(), mode, -1);
} else if (const qdAnimationFrame *p = get_cur_frame())
p->redraw(x, y, z, mode);
}
diff --git a/engines/qdengine/system/graphics/gr_tile_animation.cpp b/engines/qdengine/system/graphics/gr_tile_animation.cpp
index ec680a91f65..5b91aa06646 100644
--- a/engines/qdengine/system/graphics/gr_tile_animation.cpp
+++ b/engines/qdengine/system/graphics/gr_tile_animation.cpp
@@ -277,7 +277,7 @@ bool grTileAnimation::load(Common::SeekableReadStream *fh, int version) {
return true;
}
-void grTileAnimation::drawFrame(const Vect2i &position, int32 frame_index, int32 mode) const {
+void grTileAnimation::drawFrame(const Vect2i &position, int32 frame_index, int32 mode, int closest_scale) const {
Vect2i pos0 = position - _frameSize / 2;
int32 dx = GR_TILE_SPRITE_SIZE_X;
@@ -330,6 +330,10 @@ void grTileAnimation::drawFrame(const Vect2i &position, int frame_index, float a
grDispatcher::instance()->putSpr_rot(position, _frameSize, buf, _hasAlpha, mode, angle);
}
+//////////////////////////////////////////////////////////////////////
+//// New version 105 & 106 code
+//////////////////////////////////////////////////////////////////////
+
int grTileAnimation::find_closest_scale(float *scale) {
int idx = -1;
float temp = 1.0;
@@ -347,4 +351,22 @@ int grTileAnimation::find_closest_scale(float *scale) {
return idx;
}
+bool grTileAnimation::wasFrameSizeChanged(int frame_index, int scaleIdx, float scale) {
+ int sx = _frameSizeArray[frame_index].x;
+ int sy = _frameSizeArray[frame_index].y;
+
+ float newScale;
+
+ if (scaleIdx == -1)
+ newScale = 1.0;
+ else
+ newScale = _scaleArray[scaleIdx]._scale;
+
+ if ((int)((float)sx * newScale * scale == sx) &&
+ (int)((float)sy * newScale * scale == sy))
+ return false;
+
+ return true;
+}
+
} // namespace QDEngine
diff --git a/engines/qdengine/system/graphics/gr_tile_animation.h b/engines/qdengine/system/graphics/gr_tile_animation.h
index 24abce564dd..43ec0e1b199 100644
--- a/engines/qdengine/system/graphics/gr_tile_animation.h
+++ b/engines/qdengine/system/graphics/gr_tile_animation.h
@@ -69,7 +69,7 @@ public:
bool load(Common::SeekableReadStream *fh, int version);
- void drawFrame(const Vect2i &position, int32 frame_index, int32 mode = 0) const;
+ void drawFrame(const Vect2i &position, int32 frame_index, int32 mode, int closest_scale) const;
void drawFrame(const Vect2i &position, int frame_index, float angle, int mode = 0) const;
static void setProgressHandler(CompressionProgressHandler handler, void *context) {
@@ -78,6 +78,7 @@ public:
}
int find_closest_scale(float *scale);
+ bool wasFrameSizeChanged(int frame_index, int scaleIdx, float scale);
private:
Commit: 54c47b6e7fafe5e4fd068e46a7e766c987d28a59
https://github.com/scummvm/scummvm/commit/54c47b6e7fafe5e4fd068e46a7e766c987d28a59
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-09-04T23:49:52+02:00
Commit Message:
QDENGINE: Added QDA v106 code changes to grTileAnimation::drawFrame()
Changed paths:
engines/qdengine/system/graphics/gr_tile_animation.cpp
diff --git a/engines/qdengine/system/graphics/gr_tile_animation.cpp b/engines/qdengine/system/graphics/gr_tile_animation.cpp
index 5b91aa06646..f046f800d59 100644
--- a/engines/qdengine/system/graphics/gr_tile_animation.cpp
+++ b/engines/qdengine/system/graphics/gr_tile_animation.cpp
@@ -278,29 +278,39 @@ bool grTileAnimation::load(Common::SeekableReadStream *fh, int version) {
}
void grTileAnimation::drawFrame(const Vect2i &position, int32 frame_index, int32 mode, int closest_scale) const {
- Vect2i pos0 = position - _frameSize / 2;
+ Vect2i frameSize = _frameSize;
+ Vect2i frameTileSize = _frameTileSize;
+ int numTiles = 0;
+
+ if (closest_scale != -1) {
+ frameSize = _scaleArray[closest_scale]._frameSize;
+ frameTileSize = _scaleArray[closest_scale]._pitch;
+ numTiles = _scaleArray[closest_scale]._numTiles;
+ }
+
+ Vect2i pos0 = position - frameSize / 2;
int32 dx = GR_TILE_SPRITE_SIZE_X;
int32 dy = GR_TILE_SPRITE_SIZE_Y;
if (mode & GR_FLIP_HORIZONTAL) {
- pos0.x += _frameSize.x - GR_TILE_SPRITE_SIZE_X;
+ pos0.x += frameSize.x - GR_TILE_SPRITE_SIZE_X;
dx = -dx;
}
if (mode & GR_FLIP_VERTICAL) {
- pos0.y += _frameSize.y - GR_TILE_SPRITE_SIZE_Y;
+ pos0.y += frameSize.y - GR_TILE_SPRITE_SIZE_Y;
dy = -dy;
}
// grDispatcher::instance()->Rectangle(position.x - _frameSize.x/2, position.y - _frameSize.y/2, _frameSize.x, _frameSize.y, 0xFFFFF, 0, GR_OUTLINED);
- const uint32 *index_ptr = &_frameIndex[0] + _frameTileSize.x * _frameTileSize.y * frame_index;
+ const uint32 *index_ptr = &_frameIndex[numTiles] + frameTileSize.x * frameTileSize.y * frame_index;
Vect2i pos = pos0;
- for (int32 i = 0; i < _frameTileSize.y; i++) {
+ for (int32 i = 0; i < frameTileSize.y; i++) {
pos.x = pos0.x;
- for (int32 j = 0; j < _frameTileSize.x; j++) {
+ for (int32 j = 0; j < frameTileSize.x; j++) {
grDispatcher::instance()->putTileSpr(pos.x, pos.y, getTile(*index_ptr++), _hasAlpha, mode);
pos.x += dx;
}
Commit: 1e199c393f4527ed62235ba340a3f3c39b762581
https://github.com/scummvm/scummvm/commit/1e199c393f4527ed62235ba340a3f3c39b762581
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-09-04T23:49:52+02:00
Commit Message:
QDENGINE: Implemented grTileAnimation::drawFrame_scale()
Changed paths:
engines/qdengine/qdcore/qd_animation.cpp
engines/qdengine/system/graphics/gr_tile_animation.cpp
engines/qdengine/system/graphics/gr_tile_animation.h
diff --git a/engines/qdengine/qdcore/qd_animation.cpp b/engines/qdengine/qdcore/qd_animation.cpp
index 94634c3507a..69ba5c8c7cf 100644
--- a/engines/qdengine/qdcore/qd_animation.cpp
+++ b/engines/qdengine/qdcore/qd_animation.cpp
@@ -168,6 +168,9 @@ void qdAnimation::redraw(int x, int y, int z, float scale, int mode) const {
if (check_flag(QD_ANIMATION_FLAG_BLACK_FON))
mode |= GR_BLACK_FON;
+ if (tileAnimation())
+ tileAnimation()->drawFrame_scale(Vect2i(x, y), get_cur_frame_number(), scale, mode);
+
if (const qdAnimationFrame *p = get_cur_frame(scale))
p->redraw(x, y, z, scale, mode);
}
diff --git a/engines/qdengine/system/graphics/gr_tile_animation.cpp b/engines/qdengine/system/graphics/gr_tile_animation.cpp
index f046f800d59..31fd2e36518 100644
--- a/engines/qdengine/system/graphics/gr_tile_animation.cpp
+++ b/engines/qdengine/system/graphics/gr_tile_animation.cpp
@@ -340,11 +340,37 @@ void grTileAnimation::drawFrame(const Vect2i &position, int frame_index, float a
grDispatcher::instance()->putSpr_rot(position, _frameSize, buf, _hasAlpha, mode, angle);
}
+void grTileAnimation::drawFrame_scale(const Vect2i &position, int frame_index, float scale, int mode) const {
+ float closest_scale = find_closest_scale(&scale);
+
+ if (wasFrameSizeChanged(frame_index, closest_scale, scale)) {
+ byte *data = decode_frame_data(frame_index, closest_scale);
+
+ Vect2i frameSize;
+
+ if (closest_scale == -1)
+ frameSize = _frameSize;
+ else
+ frameSize =_scaleArray[closest_scale]._frameSize;
+
+ int x = position.x - (int)((float)(frameSize.x / 2) * scale);
+ int y = position.y - (int)((float)(frameSize.y / 2) * scale);
+
+ grDispatcher::instance()->putSpr_a(x, y, frameSize.x, frameSize.y, data, mode, scale);
+ } else {
+ drawFrame(position, frame_index, mode, closest_scale);
+ }
+}
+
+byte *grTileAnimation::decode_frame_data(int frame_index, int closest_scale) const {
+ return nullptr;
+}
+
//////////////////////////////////////////////////////////////////////
//// New version 105 & 106 code
//////////////////////////////////////////////////////////////////////
-int grTileAnimation::find_closest_scale(float *scale) {
+int grTileAnimation::find_closest_scale(float *scale) const {
int idx = -1;
float temp = 1.0;
@@ -361,7 +387,7 @@ int grTileAnimation::find_closest_scale(float *scale) {
return idx;
}
-bool grTileAnimation::wasFrameSizeChanged(int frame_index, int scaleIdx, float scale) {
+bool grTileAnimation::wasFrameSizeChanged(int frame_index, int scaleIdx, float scale) const {
int sx = _frameSizeArray[frame_index].x;
int sy = _frameSizeArray[frame_index].y;
diff --git a/engines/qdengine/system/graphics/gr_tile_animation.h b/engines/qdengine/system/graphics/gr_tile_animation.h
index 43ec0e1b199..0b050b0e441 100644
--- a/engines/qdengine/system/graphics/gr_tile_animation.h
+++ b/engines/qdengine/system/graphics/gr_tile_animation.h
@@ -71,14 +71,16 @@ public:
void drawFrame(const Vect2i &position, int32 frame_index, int32 mode, int closest_scale) const;
void drawFrame(const Vect2i &position, int frame_index, float angle, int mode = 0) const;
+ void drawFrame_scale(const Vect2i &position, int frame_index, float scale, int mode) const;
static void setProgressHandler(CompressionProgressHandler handler, void *context) {
_progressHandler = handler;
_progressHandlerContext = context;
}
- int find_closest_scale(float *scale);
- bool wasFrameSizeChanged(int frame_index, int scaleIdx, float scale);
+ byte *decode_frame_data(int frame_index, int closest_scale) const;
+ int find_closest_scale(float *scale) const;
+ bool wasFrameSizeChanged(int frame_index, int scaleIdx, float scale) const;
private:
Commit: 6f62280387274bf37d5c0168074fb2ddc2492cec
https://github.com/scummvm/scummvm/commit/6f62280387274bf37d5c0168074fb2ddc2492cec
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-09-04T23:49:52+02:00
Commit Message:
QDENGINE: Initial code for grTileAnimation::decode_frame_data(()
Changed paths:
engines/qdengine/system/graphics/gr_tile_animation.cpp
diff --git a/engines/qdengine/system/graphics/gr_tile_animation.cpp b/engines/qdengine/system/graphics/gr_tile_animation.cpp
index 31fd2e36518..0fe932b3db1 100644
--- a/engines/qdengine/system/graphics/gr_tile_animation.cpp
+++ b/engines/qdengine/system/graphics/gr_tile_animation.cpp
@@ -363,7 +363,43 @@ void grTileAnimation::drawFrame_scale(const Vect2i &position, int frame_index, f
}
byte *grTileAnimation::decode_frame_data(int frame_index, int closest_scale) const {
- return nullptr;
+ Vect2i frameSize;
+
+ if (closest_scale == -1)
+ frameSize = _frameSize;
+ else
+ frameSize = _scaleArray[closest_scale]._frameSize;
+
+ Vect2i frameTileSize;
+ if (closest_scale == -1)
+ frameTileSize = _frameTileSize;
+ else
+ frameTileSize = _scaleArray[closest_scale]._pitch;
+
+ int numTiles;
+ if (closest_scale == -1)
+ numTiles = 0;
+ else
+ numTiles = _scaleArray[closest_scale]._numTiles;
+
+ byte *buf = (byte *)grDispatcher::instance()->temp_buffer(frameSize.x * frameSize.y * 4);
+
+ const uint32 *index_ptr = &_frameIndex[numTiles] + frameTileSize.x * frameTileSize.y * frame_index;
+
+ for (int i = 0; i < frameTileSize.y; i++) {
+ for (int j = 0; j < frameTileSize.x; j++) {
+ byte *buf_ptr = buf + (i * _frameSize.x + j) * 4;
+ const byte *data_ptr = (const byte *)getTile(*index_ptr++).data();
+ int dx = MIN(_frameSize.x - j * GR_TILE_SPRITE_SIZE_X, GR_TILE_SPRITE_SIZE_X) * 4;
+ for (int k = 0; k < GR_TILE_SPRITE_SIZE_Y; k++) {
+ memcpy(buf_ptr, data_ptr, dx);
+ data_ptr += GR_TILE_SPRITE_SIZE_X * 4;
+ buf_ptr += frameSize.x * 4;
+ }
+ }
+ }
+
+ return buf;
}
//////////////////////////////////////////////////////////////////////
Commit: 7ac10db61d1b20074b04370c4fd143733dd990fd
https://github.com/scummvm/scummvm/commit/7ac10db61d1b20074b04370c4fd143733dd990fd
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-09-04T23:50:17+02:00
Commit Message:
QDENGINE: Hooked left control button as default
Fixes keyboard checks in dogncat2
Changed paths:
engines/qdengine/system/input/keyboard_input.cpp
diff --git a/engines/qdengine/system/input/keyboard_input.cpp b/engines/qdengine/system/input/keyboard_input.cpp
index c30c3ec5f7c..7a0dd86ebca 100644
--- a/engines/qdengine/system/input/keyboard_input.cpp
+++ b/engines/qdengine/system/input/keyboard_input.cpp
@@ -159,7 +159,7 @@ static const int keyMapTable[] = {
Common::KEYCODE_RSHIFT, VK_RSHIFT,
Common::KEYCODE_LSHIFT, VK_LSHIFT,
Common::KEYCODE_RCTRL, VK_RCONTROL,
- Common::KEYCODE_LCTRL, VK_LCONTROL,
+ Common::KEYCODE_LCTRL, VK_CONTROL,
Common::KEYCODE_RALT, VK_RMENU,
Common::KEYCODE_LALT, VK_LMENU,
Common::KEYCODE_RMETA, VK_RWIN,
@@ -225,7 +225,7 @@ static const int unmappedTable[] {
VK_MBUTTON,
VK_SHIFT,
- VK_CONTROL,
+ VK_LCONTROL,
VK_EXECUTE,
VK_SNAPSHOT,
Commit: 6d716ee78af753ca9ec6d13099c9bedcf12e9e89
https://github.com/scummvm/scummvm/commit/6d716ee78af753ca9ec6d13099c9bedcf12e9e89
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-09-04T23:50:28+02:00
Commit Message:
QDENGINE: More debug output on animation loading
Changed paths:
engines/qdengine/system/graphics/gr_tile_animation.cpp
diff --git a/engines/qdengine/system/graphics/gr_tile_animation.cpp b/engines/qdengine/system/graphics/gr_tile_animation.cpp
index 0fe932b3db1..d882b9524fd 100644
--- a/engines/qdengine/system/graphics/gr_tile_animation.cpp
+++ b/engines/qdengine/system/graphics/gr_tile_animation.cpp
@@ -225,7 +225,9 @@ bool grTileAnimation::load(Common::SeekableReadStream *fh, int version) {
_scaleArray[i]._numTiles = _scaleArray[i - 1]._numTiles
+ _frameCount * _scaleArray[i - 1]._pitch.y * _scaleArray[i - 1]._pitch.x;
- debugCN(3, kDebugLoad, " %f ", _scaleArray[i]._scale);
+ debugCN(3, kDebugLoad, " %f, { %d x %d, [%d x %d], tiles: %d } ", _scaleArray[i]._scale,
+ _scaleArray[i]._frameSize.x, _scaleArray[i]._frameSize.y, _scaleArray[i]._pitch.x,
+ _scaleArray[i]._pitch.y, _scaleArray[i]._numTiles);
}
debugCN(3, kDebugLoad, "\n");
}
Commit: b3dd95b2bd3528778d498842d0b310801bc65cc7
https://github.com/scummvm/scummvm/commit/b3dd95b2bd3528778d498842d0b310801bc65cc7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-09-04T23:50:28+02:00
Commit Message:
QDENGINE: Added more debug output on QDA load
Changed paths:
engines/qdengine/system/graphics/gr_tile_animation.cpp
diff --git a/engines/qdengine/system/graphics/gr_tile_animation.cpp b/engines/qdengine/system/graphics/gr_tile_animation.cpp
index d882b9524fd..8b8af2a7ee2 100644
--- a/engines/qdengine/system/graphics/gr_tile_animation.cpp
+++ b/engines/qdengine/system/graphics/gr_tile_animation.cpp
@@ -186,9 +186,9 @@ void grTileAnimation::addFrame(const uint32 *frame_data) {
}
bool grTileAnimation::load(Common::SeekableReadStream *fh, int version) {
- int debugLevel = (version >= 105) ? 2 : 7;
+ int dL = (version >= 105) ? 2 : 7;
- debugC(debugLevel, kDebugLoad, "grTileAnimation::load(): pos start: %lu", fh->pos());
+ debugC(dL, kDebugLoad, "grTileAnimation::load(): pos start: %lu", fh->pos());
_frameCount = fh->readSint32LE();
_frameSize.x = fh->readSint32LE();
@@ -197,7 +197,7 @@ bool grTileAnimation::load(Common::SeekableReadStream *fh, int version) {
_frameTileSize.y = fh->readSint32LE();
uint32 size = fh->readUint32LE();
- debugC(debugLevel, kDebugLoad, "grTileAnimation::load(): frameCount: %d, frame: %d x %d, tile: %d x %d, comp: %d", _frameCount, _frameSize.x, _frameSize.y,
+ debugC(dL, kDebugLoad, "grTileAnimation::load(): frameCount: %d, frame: %d x %d, tile: %d x %d, comp: %d", _frameCount, _frameSize.x, _frameSize.y,
_frameTileSize.x, _frameTileSize.y, size);
_compression = grTileCompressionMethod(size);
@@ -206,9 +206,9 @@ bool grTileAnimation::load(Common::SeekableReadStream *fh, int version) {
size = fh->readUint32LE();
_scaleArray.resize(size);
- debugC(2, kDebugLoad, "grTileAnimation::load(): pos: %ld _scaleArray size: %u", fh->pos() - 4, size);
+ debugC(dL, kDebugLoad, "grTileAnimation::load(): pos: %ld _scaleArray size: %u", fh->pos() - 4, size);
- debugCN(3, kDebugLoad, " ");
+ debugCN(dL + 1, kDebugLoad, " ");
for (uint i = 0; i < size; i++) {
float scale = fh->readFloatLE();
@@ -220,16 +220,16 @@ bool grTileAnimation::load(Common::SeekableReadStream *fh, int version) {
_scaleArray[i]._pitch.y = (_scaleArray[i]._frameSize.y + 15) / 16;
if (i == 0)
- _scaleArray[i]._numTiles = _frameTileSize.x * _frameTileSize.y * _frameCount;
+ _scaleArray[i]._numTiles = 0; //_frameTileSize.x * _frameTileSize.y * _frameCount;
else
_scaleArray[i]._numTiles = _scaleArray[i - 1]._numTiles
+ _frameCount * _scaleArray[i - 1]._pitch.y * _scaleArray[i - 1]._pitch.x;
- debugCN(3, kDebugLoad, " %f, { %d x %d, [%d x %d], tiles: %d } ", _scaleArray[i]._scale,
+ debugCN(dL + 1, kDebugLoad, " %f, { %d x %d, [%d x %d], tiles: %d } ", _scaleArray[i]._scale,
_scaleArray[i]._frameSize.x, _scaleArray[i]._frameSize.y, _scaleArray[i]._pitch.x,
_scaleArray[i]._pitch.y, _scaleArray[i]._numTiles);
}
- debugCN(3, kDebugLoad, "\n");
+ debugCN(dL + 1, kDebugLoad, "\n");
}
_frameSizeArray.resize(_frameCount);
@@ -238,43 +238,58 @@ bool grTileAnimation::load(Common::SeekableReadStream *fh, int version) {
for (uint i = 0; i < _frameCount; i++)
_frameSizeArray[i] = _frameSize;
} else {
- debugC(2, kDebugLoad, "grTileAnimation::load(): pos: %ld _frameSizeArray size: %u", fh->pos() - 4, _frameCount);
+ debugC(dL, kDebugLoad, "grTileAnimation::load(): pos: %ld _frameSizeArray size: %u", fh->pos() - 4, _frameCount);
- debugCN(3, kDebugLoad, " ");
+ debugCN(dL + 1, kDebugLoad, " ");
for (uint i = 0; i < _frameCount; i++) {
_frameSizeArray[i].x = fh->readUint32LE();
_frameSizeArray[i].y = fh->readUint32LE();
- debugCN(3, kDebugLoad, " %d x %d, ", _frameSizeArray[i].x, _frameSizeArray[i].y);
+ debugCN(dL + 1, kDebugLoad, " %d x %d, ", _frameSizeArray[i].x, _frameSizeArray[i].y);
}
- debugCN(3, kDebugLoad, "\n");
+ debugCN(dL + 1, kDebugLoad, "\n");
}
size = fh->readUint32LE();
_frameIndex.resize(size);
- debugC(7, kDebugLoad, "grTileAnimation::load(): pos: %ld _frameIndex size: %u", fh->pos() - 4, size);
+ debugC(dL, kDebugLoad, "grTileAnimation::load(): pos: %ld _frameIndex size: %u", fh->pos() - 4, size);
- debugCN(8, kDebugLoad, " ");
+ debugCN(dL + 1, kDebugLoad, " ");
for (uint i = 0; i < size; i++) {
_frameIndex[i] = fh->readUint32LE();
- debugCN(8, kDebugLoad, " %d ", _frameIndex[i]);
+ debugCN(dL + 1, kDebugLoad, " %d ", _frameIndex[i]);
}
- debugCN(8, kDebugLoad, "\n");
+ debugCN(dL + 1, kDebugLoad, "\n");
size = fh->readUint32LE();
+
+ debugC(dL, kDebugLoad, "grTileAnimation::load(): pos: %ld _tileOffsets size: %u", fh->pos() - 4, size);
+
_tileOffsets.resize(size);
+
+ debugCN(dL, kDebugLoad, " ");
for (uint i = 0; i < size; i++) {
_tileOffsets[i] = fh->readUint32LE();
+ debugCN(dL + 1, kDebugLoad, " %d ", _tileOffsets[i]);
}
+ debugCN(dL + 1, kDebugLoad, "\n");
size = fh->readUint32LE();
+
+ debugC(dL, kDebugLoad, "grTileAnimation::load(): pos: %ld _tileData size: %u", fh->pos() - 4, size);
+
_tileData.resize(size);
+
+ debugCN(dL, kDebugLoad, " ");
+
for (uint i = 0; i < size; i++) {
_tileData[i] = fh->readUint32LE();
+ debugCN(dL + 1, kDebugLoad, " %08x ", _tileData[i]);
}
+ debugCN(dL + 1, kDebugLoad, "\n");
- debugC(debugLevel, kDebugLoad, " --> grTileAnimation::load(): pos: %ld remaining: %ld", fh->pos(), fh->size() - fh->pos());
+ debugC(dL + 1, kDebugLoad, " --> grTileAnimation::load(): pos: %ld remaining: %ld", fh->pos(), fh->size() - fh->pos());
return true;
}
@@ -343,7 +358,7 @@ void grTileAnimation::drawFrame(const Vect2i &position, int frame_index, float a
}
void grTileAnimation::drawFrame_scale(const Vect2i &position, int frame_index, float scale, int mode) const {
- float closest_scale = find_closest_scale(&scale);
+ int closest_scale = find_closest_scale(&scale);
if (wasFrameSizeChanged(frame_index, closest_scale, scale)) {
byte *data = decode_frame_data(frame_index, closest_scale);
@@ -364,6 +379,10 @@ void grTileAnimation::drawFrame_scale(const Vect2i &position, int frame_index, f
}
}
+//////////////////////////////////////////////////////////////////////
+//// New version 105 & 106 code
+//////////////////////////////////////////////////////////////////////
+
byte *grTileAnimation::decode_frame_data(int frame_index, int closest_scale) const {
Vect2i frameSize;
@@ -404,10 +423,6 @@ byte *grTileAnimation::decode_frame_data(int frame_index, int closest_scale) con
return buf;
}
-//////////////////////////////////////////////////////////////////////
-//// New version 105 & 106 code
-//////////////////////////////////////////////////////////////////////
-
int grTileAnimation::find_closest_scale(float *scale) const {
int idx = -1;
float temp = 1.0;
Commit: e410466f23e5f1c19a4d85bba09610527ac6d14b
https://github.com/scummvm/scummvm/commit/e410466f23e5f1c19a4d85bba09610527ac6d14b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-09-04T23:50:29+02:00
Commit Message:
QDENGINE: Further fixes to tile frame rendering. Still incorrect
Changed paths:
engines/qdengine/system/graphics/gr_tile_animation.cpp
diff --git a/engines/qdengine/system/graphics/gr_tile_animation.cpp b/engines/qdengine/system/graphics/gr_tile_animation.cpp
index 8b8af2a7ee2..6c96a339c25 100644
--- a/engines/qdengine/system/graphics/gr_tile_animation.cpp
+++ b/engines/qdengine/system/graphics/gr_tile_animation.cpp
@@ -220,7 +220,7 @@ bool grTileAnimation::load(Common::SeekableReadStream *fh, int version) {
_scaleArray[i]._pitch.y = (_scaleArray[i]._frameSize.y + 15) / 16;
if (i == 0)
- _scaleArray[i]._numTiles = 0; //_frameTileSize.x * _frameTileSize.y * _frameCount;
+ _scaleArray[i]._numTiles = _frameTileSize.x * _frameTileSize.y * _frameCount;
else
_scaleArray[i]._numTiles = _scaleArray[i - 1]._numTiles
+ _frameCount * _scaleArray[i - 1]._pitch.y * _scaleArray[i - 1]._pitch.x;
@@ -409,9 +409,9 @@ byte *grTileAnimation::decode_frame_data(int frame_index, int closest_scale) con
for (int i = 0; i < frameTileSize.y; i++) {
for (int j = 0; j < frameTileSize.x; j++) {
- byte *buf_ptr = buf + (i * _frameSize.x + j) * 4;
+ byte *buf_ptr = buf + (i * frameSize.x + j) * 4;
const byte *data_ptr = (const byte *)getTile(*index_ptr++).data();
- int dx = MIN(_frameSize.x - j * GR_TILE_SPRITE_SIZE_X, GR_TILE_SPRITE_SIZE_X) * 4;
+ int dx = MIN(frameSize.x - j * GR_TILE_SPRITE_SIZE_X, GR_TILE_SPRITE_SIZE_X) * 4;
for (int k = 0; k < GR_TILE_SPRITE_SIZE_Y; k++) {
memcpy(buf_ptr, data_ptr, dx);
data_ptr += GR_TILE_SPRITE_SIZE_X * 4;
Commit: b1d860d66bab692a073ab45e48ff239fd45c896a
https://github.com/scummvm/scummvm/commit/b1d860d66bab692a073ab45e48ff239fd45c896a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-09-04T23:50:29+02:00
Commit Message:
QDENGINE: Implemented tile dumping into .png files
Changed paths:
engines/qdengine/qdcore/qd_animation.cpp
engines/qdengine/system/graphics/gr_dispatcher.h
engines/qdengine/system/graphics/gr_tile_animation.cpp
engines/qdengine/system/graphics/gr_tile_animation.h
engines/qdengine/system/graphics/gr_tile_sprite.cpp
engines/qdengine/system/graphics/gr_tile_sprite.h
diff --git a/engines/qdengine/qdcore/qd_animation.cpp b/engines/qdengine/qdcore/qd_animation.cpp
index 69ba5c8c7cf..9e99558e88e 100644
--- a/engines/qdengine/qdcore/qd_animation.cpp
+++ b/engines/qdengine/qdcore/qd_animation.cpp
@@ -599,6 +599,8 @@ bool qdAnimation::qda_load(Common::Path fpath) {
debugC(1, kDebugLoad, "qdAnimation::qda_load() tileAnimation %s", transCyrillic(fpath.toString()));
_tileAnimation = new grTileAnimation;
_tileAnimation->load(fh, version);
+
+ //_tileAnimation->dumpTiles(fpath, 50);
}
init_size();
diff --git a/engines/qdengine/system/graphics/gr_dispatcher.h b/engines/qdengine/system/graphics/gr_dispatcher.h
index 7b349d02278..bfb8c371ed4 100644
--- a/engines/qdengine/system/graphics/gr_dispatcher.h
+++ b/engines/qdengine/system/graphics/gr_dispatcher.h
@@ -203,7 +203,7 @@ public:
void putSprMask_a(int x, int y, int sx, int sy, const byte *p, uint32 mask_color, int mask_alpha, int mode);
void putSprMask_a(int x, int y, int sx, int sy, const byte *p, uint32 mask_color, int mask_alpha, int mode, float scale);
- void putTileSpr(int x, int y, const grTileSprite &sprite, bool has_alpha, int mode);
+ void putTileSpr(int x, int y, const grTileSprite &sprite, bool has_alpha, int mode, Graphics::ManagedSurface *surface = nullptr);
void putChar(int x, int y, uint32 color, int font_sx, int font_sy, const byte *font_alpha, const grScreenRegion &char_region);
diff --git a/engines/qdengine/system/graphics/gr_tile_animation.cpp b/engines/qdengine/system/graphics/gr_tile_animation.cpp
index 6c96a339c25..105a7bc3869 100644
--- a/engines/qdengine/system/graphics/gr_tile_animation.cpp
+++ b/engines/qdengine/system/graphics/gr_tile_animation.cpp
@@ -22,6 +22,9 @@
#include "common/debug.h"
#include "common/file.h"
+#include "graphics/managed_surface.h"
+#include "image/png.h"
+
#include "qdengine/qdengine.h"
#include "qdengine/system/graphics/gr_dispatcher.h"
#include "qdengine/system/graphics/gr_tile_animation.h"
@@ -458,4 +461,40 @@ bool grTileAnimation::wasFrameSizeChanged(int frame_index, int scaleIdx, float s
return true;
}
+void grTileAnimation::dumpTiles(Common::Path basename, int tilesPerRow) {
+ Common::Path path = Common::Path(Common::String::format("dumps/%s.tiles.png", transCyrillic(basename.baseName())));
+
+ int w = tilesPerRow;
+ int h = (_tileOffsets.size() + tilesPerRow - 1) / tilesPerRow;
+
+ Graphics::ManagedSurface *dstSurf = new Graphics::ManagedSurface(w * (GR_TILE_SPRITE_SIZE_X + 1), h * (GR_TILE_SPRITE_SIZE_Y + 1), g_engine->_pixelformat);
+
+ int index = 0;
+
+ int x = 0, y = 0;
+ for (int32 i = 0; i < tilesPerRow; i++) {
+ x = 0;
+
+ for (int32 j = 0; j < tilesPerRow; j++) {
+ grDispatcher::instance()->putTileSpr(x, y, getTile(index++), _hasAlpha, 0, dstSurf);
+ x += GR_TILE_SPRITE_SIZE_X + 1;
+
+ if (index >= _tileOffsets.size())
+ break;
+ }
+
+ y += GR_TILE_SPRITE_SIZE_X + 1;
+ }
+
+ Common::DumpFile bitmapFile;
+ bitmapFile.open(path, true);
+ Image::writePNG(bitmapFile, *(dstSurf->surfacePtr()));
+ bitmapFile.close();
+
+ warning("Dumped tile %s of %d x %d", path.toString().c_str(), dstSurf->w, dstSurf->h);
+
+ delete dstSurf;
+}
+
+
} // namespace QDEngine
diff --git a/engines/qdengine/system/graphics/gr_tile_animation.h b/engines/qdengine/system/graphics/gr_tile_animation.h
index 0b050b0e441..03c51ca1e9e 100644
--- a/engines/qdengine/system/graphics/gr_tile_animation.h
+++ b/engines/qdengine/system/graphics/gr_tile_animation.h
@@ -23,6 +23,8 @@
#ifndef QDENGINE_SYSTEM_GRAPHICS_GR_TILE_ANIMATION_H
#define QDENGINE_SYSTEM_GRAPHICS_GR_TILE_ANIMATION_H
+#include "common/path.h"
+
#include "qdengine/xmath.h"
#include "qdengine/system/graphics/gr_tile_sprite.h"
@@ -82,6 +84,8 @@ public:
int find_closest_scale(float *scale) const;
bool wasFrameSizeChanged(int frame_index, int scaleIdx, float scale) const;
+ void dumpTiles(Common::Path baseName, int tilesPerRow);
+
private:
grTileCompressionMethod _compression;
diff --git a/engines/qdengine/system/graphics/gr_tile_sprite.cpp b/engines/qdengine/system/graphics/gr_tile_sprite.cpp
index 48541991c21..64f32745895 100644
--- a/engines/qdengine/system/graphics/gr_tile_sprite.cpp
+++ b/engines/qdengine/system/graphics/gr_tile_sprite.cpp
@@ -96,7 +96,7 @@ bool decodeRLE(const uint32 *in_data, uint32 *out_data) {
} // namespace tile_compress
-void grDispatcher::putTileSpr(int x, int y, const grTileSprite &sprite, bool has_alpha, int mode) {
+void grDispatcher::putTileSpr(int x, int y, const grTileSprite &sprite, bool has_alpha, int mode, Graphics::ManagedSurface *surf) {
int px = 0;
int py = 0;
@@ -119,11 +119,13 @@ void grDispatcher::putTileSpr(int x, int y, const grTileSprite &sprite, bool has
} else
dy = 1;
+ if (!surf)
+ surf = _screenBuf;
const byte *data_ptr = (const byte *)(sprite.data() + px + py * GR_TILE_SPRITE_SIZE_X);
for (int i = 0; i < psy; i++) {
- uint16 *scr_buf = reinterpret_cast<uint16 *>(_screenBuf->getBasePtr(x, y));
+ uint16 *scr_buf = reinterpret_cast<uint16 *>(surf->getBasePtr(x, y));
const byte *data_line = data_ptr;
for (int j = 0; j < psx; j++) {
diff --git a/engines/qdengine/system/graphics/gr_tile_sprite.h b/engines/qdengine/system/graphics/gr_tile_sprite.h
index 8d7e06f80a6..c2dcf81c9a3 100644
--- a/engines/qdengine/system/graphics/gr_tile_sprite.h
+++ b/engines/qdengine/system/graphics/gr_tile_sprite.h
@@ -22,7 +22,6 @@
#ifndef QDENGINE_SYSTEM_GRAPHICS_GR_TILE_SPRITE_H
#define QDENGINE_SYSTEM_GRAPHICS_GR_TILE_SPRITE_H
-
namespace QDEngine {
const int GR_TILE_SPRITE_SIZE_SHIFT = 4;
More information about the Scummvm-git-logs
mailing list