[Scummvm-git-logs] scummvm master -> e646c768290154a33fd0bc31d932cc6d5fe6913d
mgerhardy
noreply at scummvm.org
Sat Jul 26 05:30:48 UTC 2025
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
6222d301d5 TWINE: renamings to match original sources
e12af90f68 TWINE: renamed variables and fixed comments
e646c76829 TWINE: added test for rendering a sprite
Commit: 6222d301d5b71b16c6b477b930647e2ee640878d
https://github.com/scummvm/scummvm/commit/6222d301d5b71b16c6b477b930647e2ee640878d
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2025-07-26T07:30:42+02:00
Commit Message:
TWINE: renamings to match original sources
Changed paths:
engines/twine/menu/interface.h
engines/twine/renderer/screens.h
engines/twine/scene/grid.cpp
engines/twine/scene/grid.h
diff --git a/engines/twine/menu/interface.h b/engines/twine/menu/interface.h
index a2b60fd8be2..04ce3068a0f 100644
--- a/engines/twine/menu/interface.h
+++ b/engines/twine/menu/interface.h
@@ -40,6 +40,7 @@ private:
public:
Interface(TwinEEngine *engine);
+ // ClipXmin, ClipXmax, ClipYmin, ClipYmax
Common::Rect _clip { 0, 0, 0, 0 };
bool _animateTexture = false; // lba2: AnimateTexture
diff --git a/engines/twine/renderer/screens.h b/engines/twine/renderer/screens.h
index 837aa313bde..10505c7b612 100644
--- a/engines/twine/renderer/screens.h
+++ b/engines/twine/renderer/screens.h
@@ -140,7 +140,7 @@ public:
void copyScreen(const Graphics::ManagedSurface &source, Graphics::ManagedSurface &destination);
/** Clear front buffer screen */
- void clearScreen();
+ void clearScreen(); // Cls()
/** Init palettes */
void initPalettes();
diff --git a/engines/twine/scene/grid.cpp b/engines/twine/scene/grid.cpp
index d97ed856778..9457c9572b7 100644
--- a/engines/twine/scene/grid.cpp
+++ b/engines/twine/scene/grid.cpp
@@ -50,20 +50,20 @@ Grid::~Grid() {
for (int32 i = 0; i < ARRAYSIZE(_brickMaskTable); i++) {
free(_brickMaskTable[i]);
}
- for (int32 i = 0; i < ARRAYSIZE(_brickTable); i++) {
- free(_brickTable[i]);
+ for (int32 i = 0; i < ARRAYSIZE(_bufferBrick); i++) {
+ free(_bufferBrick[i]);
}
free(_currentGrid);
- free(_brickInfoBuffer);
- free(_bricksDataBuffer);
+ free(_nbBrickColon);
+ free(_listBrickColon);
}
void Grid::init(int32 w, int32 h) {
const int32 numbrickentries = (1 + (w + 24) / 24);
- const size_t brickDataBufferSize = numbrickentries * MAXBRICKS * sizeof(BrickEntry);
- _bricksDataBuffer = (BrickEntry *)malloc(brickDataBufferSize);
+ const size_t brickDataBufferSize = numbrickentries * MAX_BRICKS * sizeof(BrickEntry);
+ _listBrickColon = (BrickEntry *)malloc(brickDataBufferSize);
_brickInfoBufferSize = numbrickentries * sizeof(int16);
- _brickInfoBuffer = (int16 *)malloc(_brickInfoBufferSize);
+ _nbBrickColon = (int16 *)malloc(_brickInfoBufferSize);
}
void Grid::copyMask(int32 index, int32 x, int32 y, const Graphics::ManagedSurface &buffer) {
@@ -163,7 +163,7 @@ void Grid::copyMask(int32 index, int32 x, int32 y, const Graphics::ManagedSurfac
}
const BrickEntry* Grid::getBrickEntry(int32 j, int32 i) const {
- return &_bricksDataBuffer[j * MAXBRICKS + i];
+ return &_listBrickColon[j * MAX_BRICKS + i];
}
void Grid::drawOverBrick(int32 x, int32 y, int32 z) {
@@ -171,7 +171,7 @@ void Grid::drawOverBrick(int32 x, int32 y, int32 z) {
const int32 endCol = ((_engine->_interface->_clip.right + 24) / 24);
for (int32 col = startCol; col <= endCol; col++) {
- for (int32 i = 0; i < _brickInfoBuffer[col]; i++) {
+ for (int32 i = 0; i < _nbBrickColon[col]; i++) {
const BrickEntry *currBrickEntry = getBrickEntry(col, i);
if (currBrickEntry->posY + 38 > _engine->_interface->_clip.top && currBrickEntry->posY <= _engine->_interface->_clip.bottom && currBrickEntry->y >= y) {
@@ -188,7 +188,7 @@ void Grid::drawOverBrick3(int32 x, int32 y, int32 z) {
const int32 endCol = (_engine->_interface->_clip.right + 24) / 24;
for (int32 col = startCol; col <= endCol; col++) {
- for (int32 i = 0; i < _brickInfoBuffer[col]; i++) {
+ for (int32 i = 0; i < _nbBrickColon[col]; i++) {
const BrickEntry *currBrickEntry = getBrickEntry(col, i);
if (currBrickEntry->posY + 38 > _engine->_interface->_clip.top && currBrickEntry->posY <= _engine->_interface->_clip.bottom && currBrickEntry->y >= y) {
@@ -240,7 +240,7 @@ void Grid::processGridMask(const uint8 *buffer, uint8 *ptr) {
if (type == 2) {
opaquePixels += runLength;
buffer++;
- } else if (type == 1) {
+ } else if (type == 1) { // 0x40
opaquePixels += runLength;
buffer += runLength;
} else { // skip (type 3)
@@ -274,7 +274,7 @@ void Grid::createGridMask() {
free(_brickMaskTable[b]);
}
_brickMaskTable[b] = (uint8 *)malloc(_brickSizeTable[b]);
- processGridMask(_brickTable[b], _brickMaskTable[b]);
+ processGridMask(_bufferBrick[b], _brickMaskTable[b]);
}
}
@@ -325,11 +325,11 @@ void Grid::loadGridBricks() {
for (uint32 i = firstBrick; i <= lastBrick; i++) {
if (!_brickUsageTable[i]) {
- free(_brickTable[i]);
- _brickTable[i] = nullptr;
+ free(_bufferBrick[i]);
+ _bufferBrick[i] = nullptr;
continue;
}
- _brickSizeTable[i] = HQR::getAllocEntry(&_brickTable[i], Resources::HQR_LBA_BRK_FILE, i);
+ _brickSizeTable[i] = HQR::getAllocEntry(&_bufferBrick[i], Resources::HQR_LBA_BRK_FILE, i);
if (_brickSizeTable[i] == 0) {
warning("Failed to load isometric brick index %i", i);
}
@@ -464,8 +464,8 @@ bool Grid::initCellingGrid(int32 index) { // IncrustGrm
return true;
}
-bool Grid::drawBrick(int32 index, int32 posX, int32 posY) {
- return drawBrickSprite(posX, posY, _brickTable[index], false);
+bool Grid::drawGraph(int32 index, int32 posX, int32 posY) { // AffGraph
+ return drawBrickSprite(posX, posY, _bufferBrick[index], false);
}
bool Grid::drawSprite(int32 index, int32 posX, int32 posY, const uint8 *ptr) { // AffGraph
@@ -534,13 +534,13 @@ bool Grid::drawBrickSprite(int32 posX, int32 posY, const uint8 *ptr, bool isSpri
for (int32 run = 0; run < rleAmount; ++run) {
const uint8 rleMask = *ptr++;
const uint8 iterations = bits(rleMask, 0, 6) + 1;
- const uint8 type = bits(rleMask, 6, 2);
- if (type == 0) {
+ const uint8 opCode = bits(rleMask, 6, 2);
+ if (opCode == 0) {
x += iterations;
continue;
}
if (y < _engine->_interface->_clip.top || x >= _engine->_interface->_clip.right || x + iterations < _engine->_interface->_clip.left) {
- if (type == 1) {
+ if (opCode == 1) {
ptr += iterations;
} else {
++ptr;
@@ -548,7 +548,7 @@ bool Grid::drawBrickSprite(int32 posX, int32 posY, const uint8 *ptr, bool isSpri
x += iterations;
continue;
}
- if (type == 1) {
+ if (opCode == 1) { // 0x40
uint8 *out = (uint8 *)_engine->_frontVideoBuffer.getBasePtr(x, y);
for (uint8 i = 0; i < iterations; i++) {
if (x >= _engine->_interface->_clip.left && x < _engine->_interface->_clip.right) {
@@ -591,7 +591,7 @@ const uint8 *Grid::getBlockBufferGround(const IVec3 &pos, int32 &ground) {
int32 collisionY = collision.y;
while (collisionY) {
- if (READ_LE_INT16(ptr)) { // found the ground
+ if (READ_LE_INT16(ptr)) { // found the ground - sizeof(BlockEntry);
break;
}
collisionY--;
@@ -613,24 +613,24 @@ const BlockData *Grid::getBlockLibrary(int32 blockIdx) const {
return _currentBlockLibrary.getLayout(blockIdx - 1);
}
-void Grid::getBrickPos(int32 x, int32 y, int32 z, int32 &posx, int32 &posy) const {
+void Grid::map2Screen(int32 x, int32 y, int32 z, int32 &posx, int32 &posy) const {
posx = (x - z) * 24 + _engine->width() / 2 - SIZE_CUBE_X / 2;
posy = ((x + z) * 12) - (y * 15) + _engine->height() / 2 - SIZE_CUBE_Y;
}
-void Grid::drawColumnGrid(int32 blockIdx, int32 brickBlockIdx, int32 x, int32 y, int32 z) { // AffBrickBlock
+void Grid::drawBrickBlock(int32 blockIdx, int32 brickBlockIdx, int32 x, int32 y, int32 z) { // AffBrickBlock
const BlockDataEntry *blockPtr = getAdrBlock(blockIdx, brickBlockIdx);
const uint8 brickShape = blockPtr->brickShape;
const uint8 brickSound = blockPtr->brickType;
- const uint16 brickIdx = blockPtr->brickIdx;
- if (!brickIdx) {
+ const uint16 numBrick = blockPtr->brickIdx;
+ if (!numBrick) {
return;
}
int32 brickPixelPosX = 0;
int32 brickPixelPosY = 0;
- getBrickPos(x - _startCube.x, y - _startCube.y, z - _startCube.z, brickPixelPosX, brickPixelPosY);
+ map2Screen(x - _startCube.x, y - _startCube.y, z - _startCube.z, brickPixelPosX, brickPixelPosY);
if (brickPixelPosX < -24) {
return;
@@ -646,27 +646,27 @@ void Grid::drawColumnGrid(int32 blockIdx, int32 brickBlockIdx, int32 x, int32 y,
}
// draw the background brick
- drawBrick(brickIdx - 1, brickPixelPosX, brickPixelPosY);
+ drawGraph(numBrick - 1, brickPixelPosX, brickPixelPosY);
- int32 brickBuffIdx = (brickPixelPosX + 24) / 24;
+ int32 col = (brickPixelPosX + 24) / 24;
- if (_brickInfoBuffer[brickBuffIdx] >= MAXBRICKS) {
+ if (_nbBrickColon[col] >= MAX_BRICKS) {
warning("GRID: brick buffer exceeded");
return;
}
- BrickEntry *currBrickEntry = &_bricksDataBuffer[brickBuffIdx * MAXBRICKS + _brickInfoBuffer[brickBuffIdx]];
+ BrickEntry *pColonBrick = &_listBrickColon[col * MAX_BRICKS + _nbBrickColon[col]];
- currBrickEntry->x = x;
- currBrickEntry->y = y;
- currBrickEntry->z = z;
- currBrickEntry->posX = brickPixelPosX;
- currBrickEntry->posY = brickPixelPosY;
- currBrickEntry->index = brickIdx - 1;
- currBrickEntry->shape = brickShape;
- currBrickEntry->sound = brickSound;
+ pColonBrick->x = x;
+ pColonBrick->y = y;
+ pColonBrick->z = z;
+ pColonBrick->posX = brickPixelPosX;
+ pColonBrick->posY = brickPixelPosY;
+ pColonBrick->index = numBrick - 1;
+ pColonBrick->shape = brickShape;
+ pColonBrick->sound = brickSound;
- _brickInfoBuffer[brickBuffIdx]++;
+ _nbBrickColon[col]++;
}
void Grid::redrawGrid() { // AffGrille
@@ -678,7 +678,7 @@ void Grid::redrawGrid() { // AffGrille
_engine->_redraw->_projPosScreen.x = projPos.x;
_engine->_redraw->_projPosScreen.y = projPos.y;
- memset(_brickInfoBuffer, 0, _brickInfoBufferSize);
+ memset(_nbBrickColon, 0, _brickInfoBufferSize);
if (!_engine->_scene->_flagRenderGrid) {
return;
@@ -691,7 +691,7 @@ void Grid::redrawGrid() { // AffGrille
for (int32 y = 0; y < SIZE_CUBE_Y; y++) {
const BlockEntry entry = getBlockEntry(x, y, z);
if (entry.blockIdx) {
- drawColumnGrid(entry.blockIdx, entry.brickBlockIdx, x, y, z);
+ drawBrickBlock(entry.blockIdx, entry.brickBlockIdx, x, y, z);
}
}
}
@@ -700,9 +700,10 @@ void Grid::redrawGrid() { // AffGrille
BlockEntry Grid::getBlockEntry(int32 xmap, int32 ymap, int32 zmap) const {
const uint8 *pCube = _bufCube;
- pCube += xmap * SIZE_CUBE_Y * 2;
- pCube += ymap * 2;
- pCube += zmap * (SIZE_CUBE_X * SIZE_CUBE_Y * 2);
+ const int32 size = 2; // sizeof(BlockEntry);
+ pCube += xmap * SIZE_CUBE_Y * size;
+ pCube += ymap * size;
+ pCube += zmap * (SIZE_CUBE_X * SIZE_CUBE_Y * size);
BlockEntry entry;
entry.blockIdx = *pCube;
diff --git a/engines/twine/scene/grid.h b/engines/twine/scene/grid.h
index c7ba10669d0..2ce9eeea4d9 100644
--- a/engines/twine/scene/grid.h
+++ b/engines/twine/scene/grid.h
@@ -45,7 +45,7 @@ struct BlockEntry {
uint8 brickBlockIdx = 0;
};
/** Brick entry data */
-struct BrickEntry {
+struct BrickEntry { // T_COLONB
/** Brick X position in screen */
int16 x = 0; //z
/** Brick Y position in screen */
@@ -88,7 +88,7 @@ struct BrickEntry {
#define SCENE_SIZE_HALF (SIZE_BRICK_XZ * SIZE_CUBE_X / 2)
#define SCENE_SIZE_HALFF (SIZE_BRICK_XZ * SIZE_CUBE_X / 2.0f)
-#define MAXBRICKS 150
+#define MAX_BRICKS 150
class TwinEEngine;
@@ -104,14 +104,14 @@ private:
* @param y column y position
* @param z column z position
*/
- void drawColumnGrid(int32 blockIdx, int32 brickBlockIdx, int32 x, int32 y, int32 z);
+ void drawBrickBlock(int32 blockIdx, int32 brickBlockIdx, int32 x, int32 y, int32 z);
/**
* Get brick position in the screen
* @param x column x position in the current camera
* @param y column y position in the current camera
* @param z column z position in the current camera
*/
- void getBrickPos(int32 x, int32 y, int32 z, int32 &_brickPixelPosX, int32 &_brickPixelPosY) const;
+ void map2Screen(int32 x, int32 y, int32 z, int32 &_brickPixelPosX, int32 &_brickPixelPosY) const;
/**
* Create celling grid map from celling grid to block library buffer
* @param gridPtr celling grid buffer pointer
@@ -151,7 +151,7 @@ private:
void copyMask(int32 index, int32 x, int32 y, const Graphics::ManagedSurface &buffer);
/** Table with all loaded bricks */
- uint8 *_brickTable[NUM_BRICKS]{nullptr};
+ uint8 *_bufferBrick[NUM_BRICKS]{nullptr};
/** Table with all loaded bricks masks */
uint8 *_brickMaskTable[NUM_BRICKS]{nullptr};
/** Table with all loaded bricks sizes */
@@ -166,9 +166,9 @@ private:
BlockLibraryData _currentBlockLibrary;
/** Brick data buffer */
- BrickEntry *_bricksDataBuffer = nullptr;
+ BrickEntry *_listBrickColon = nullptr;
/** Brick info buffer */
- int16 *_brickInfoBuffer = nullptr;
+ int16 *_nbBrickColon = nullptr;
int32 _brickInfoBufferSize = 0;
/** Celling grid brick block buffer */
@@ -239,7 +239,7 @@ public:
* @param posX brick X position to draw
* @param posY brick Y position to draw
*/
- bool drawBrick(int32 index, int32 posX, int32 posY);
+ bool drawGraph(int32 index, int32 posX, int32 posY);
/**
* Draw sprite in the screen
Commit: e12af90f68fdd3f9c21c481b39cbf4df68b74da2
https://github.com/scummvm/scummvm/commit/e12af90f68fdd3f9c21c481b39cbf4df68b74da2
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2025-07-26T07:30:42+02:00
Commit Message:
TWINE: renamed variables and fixed comments
Changed paths:
engines/twine/scene/grid.cpp
engines/twine/scene/grid.h
diff --git a/engines/twine/scene/grid.cpp b/engines/twine/scene/grid.cpp
index 9457c9572b7..93e26831288 100644
--- a/engines/twine/scene/grid.cpp
+++ b/engines/twine/scene/grid.cpp
@@ -349,7 +349,7 @@ void Grid::decompColumn(const uint8 *gridEntry, uint32 gridEntrySize, uint8 *des
for (int32 i = 0; i < blockCount; i++) {
outstream.writeUint16LE(0);
}
- } else if (type == 1) {
+ } else if (type == 1) { // 0x40
for (int32 i = 0; i < blockCount; i++) {
outstream.writeUint16LE(stream.readUint16LE());
}
@@ -497,7 +497,7 @@ bool Grid::drawSprite(int32 posX, int32 posY, const SpriteData &ptr, int spriteI
}
// WARNING: Rewrite this function to have better performance
-bool Grid::drawBrickSprite(int32 posX, int32 posY, const uint8 *ptr, bool isSprite) {
+bool Grid::drawBrickSprite(int32 posX, int32 posY, const uint8 *pGraph, bool isSprite) { // AffGraph
if (_engine->_debugState->_disableGridRendering) {
return false;
}
@@ -505,34 +505,34 @@ bool Grid::drawBrickSprite(int32 posX, int32 posY, const uint8 *ptr, bool isSpri
return false;
}
- const int32 left = posX + *(ptr + 2);
+ const int32 left = posX + pGraph[2];
if (left >= _engine->_interface->_clip.right) {
return false;
}
- const int32 right = *ptr + left;
- if (right < _engine->_interface->_clip.left) {
+ const int32 top = posY + pGraph[3];
+ if (top >= _engine->_interface->_clip.bottom) {
return false;
}
- const int32 top = posY + *(ptr + 3);
- if (top >= _engine->_interface->_clip.bottom) {
+ const int32 right = pGraph[0] + left;
+ if (right < _engine->_interface->_clip.left) {
return false;
}
- const int32 bottom = (int32)*(ptr + 1) + top;
+ const int32 bottom = pGraph[1] + top;
if (bottom < _engine->_interface->_clip.top) {
return false;
}
const int32 maxY = MIN(bottom, (int32)_engine->_interface->_clip.bottom);
- ptr += 4;
+ pGraph += 4; // skip the header
int32 x = left;
//if (left >= textWindowLeft-2 && top >= textWindowTop-2 && right <= textWindowRight-2 && bottom <= textWindowBottom-2) // crop
{
for (int32 y = top; y < maxY; ++y) {
- const uint8 rleAmount = *ptr++;
+ const uint8 rleAmount = *pGraph++;
for (int32 run = 0; run < rleAmount; ++run) {
- const uint8 rleMask = *ptr++;
+ const uint8 rleMask = *pGraph++;
const uint8 iterations = bits(rleMask, 0, 6) + 1;
const uint8 opCode = bits(rleMask, 6, 2);
if (opCode == 0) {
@@ -541,9 +541,9 @@ bool Grid::drawBrickSprite(int32 posX, int32 posY, const uint8 *ptr, bool isSpri
}
if (y < _engine->_interface->_clip.top || x >= _engine->_interface->_clip.right || x + iterations < _engine->_interface->_clip.left) {
if (opCode == 1) {
- ptr += iterations;
+ pGraph += iterations;
} else {
- ++ptr;
+ ++pGraph;
}
x += iterations;
continue;
@@ -552,15 +552,15 @@ bool Grid::drawBrickSprite(int32 posX, int32 posY, const uint8 *ptr, bool isSpri
uint8 *out = (uint8 *)_engine->_frontVideoBuffer.getBasePtr(x, y);
for (uint8 i = 0; i < iterations; i++) {
if (x >= _engine->_interface->_clip.left && x < _engine->_interface->_clip.right) {
- *out = *ptr;
+ *out = *pGraph;
}
++out;
++x;
- ++ptr;
+ ++pGraph;
}
} else {
- const uint8 pixel = *ptr++;
+ const uint8 pixel = *pGraph++;
uint8 *out = (uint8 *)_engine->_frontVideoBuffer.getBasePtr(x, y);
for (uint8 i = 0; i < iterations; i++) {
if (x >= _engine->_interface->_clip.left && x < _engine->_interface->_clip.right) {
diff --git a/engines/twine/scene/grid.h b/engines/twine/scene/grid.h
index 2ce9eeea4d9..11b923c8f16 100644
--- a/engines/twine/scene/grid.h
+++ b/engines/twine/scene/grid.h
@@ -246,7 +246,7 @@ public:
* @param index sprite index to draw
* @param posX sprite X position to draw
* @param posY sprite Y position to draw
- * @param ptr sprite buffer pointer to draw
+ * @param spritePtr sprite buffer pointer to draw
*/
bool drawSprite(int32 index, int32 posX, int32 posY, const uint8 *spritePtr);
bool drawSprite(int32 posX, int32 posY, const SpriteData &ptr, int spriteIndex = 0);
@@ -255,10 +255,10 @@ public:
* Draw sprite or bricks in the screen according with the type
* @param posX sprite X position to draw
* @param posY sprite Y position to draw
- * @param ptr sprite buffer pointer to draw
+ * @param pGraph sprite buffer pointer to draw
* @param isSprite allows to identify if the sprite to display is brick or a single sprite
*/
- bool drawBrickSprite(int32 posX, int32 posY, const uint8 *spritePtr, bool isSprite);
+ bool drawBrickSprite(int32 posX, int32 posY, const uint8 *pGraph, bool isSprite);
/**
* Get block library
Commit: e646c768290154a33fd0bc31d932cc6d5fe6913d
https://github.com/scummvm/scummvm/commit/e646c768290154a33fd0bc31d932cc6d5fe6913d
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2025-07-26T07:30:42+02:00
Commit Message:
TWINE: added test for rendering a sprite
Changed paths:
A engines/twine/scene/graph.h
A test/engines/twine/gridtest.h
engines/twine/renderer/redraw.cpp
engines/twine/scene/grid.cpp
engines/twine/scene/grid.h
test/module.mk
diff --git a/engines/twine/renderer/redraw.cpp b/engines/twine/renderer/redraw.cpp
index 39c172164da..86c70df90d0 100644
--- a/engines/twine/renderer/redraw.cpp
+++ b/engines/twine/renderer/redraw.cpp
@@ -475,7 +475,7 @@ void Redraw::processDrawListActorSprites(const DrawListStruct &drawCmd, bool bgR
}
if (validClip) {
- _engine->_grid->drawSprite(0, renderRect.left, renderRect.top, spritePtr);
+ _engine->_grid->drawGraph(0, renderRect.left, renderRect.top, spritePtr);
actor->_workFlags.bWasDrawn = 1;
diff --git a/engines/twine/scene/graph.h b/engines/twine/scene/graph.h
new file mode 100644
index 00000000000..896ba5c81f8
--- /dev/null
+++ b/engines/twine/scene/graph.h
@@ -0,0 +1,115 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef TWINE_SCENE_GRAPH_H
+#define TWINE_SCENE_GRAPH_H
+
+#include "graphics/screen.h"
+#include "twine/shared.h"
+
+namespace TwinE {
+
+// WARNING: Rewrite this function to have better performance
+inline bool drawGraph(int32 posX, int32 posY, const uint8 *pGraph, bool isSprite, Graphics::Screen &frontVideoBuffer, const Common::Rect &clip) { // AffGraph
+ if (!clip.isValidRect()) {
+ return false;
+ }
+
+ const int32 left = posX + pGraph[2];
+ if (left >= clip.right) {
+ return false;
+ }
+ const int32 top = posY + pGraph[3];
+ if (top >= clip.bottom) {
+ return false;
+ }
+ const int32 right = pGraph[0] + left;
+ if (right < clip.left) {
+ return false;
+ }
+ const int32 bottom = pGraph[1] + top;
+ if (bottom < clip.top) {
+ return false;
+ }
+ const int32 maxY = MIN(bottom, (int32)clip.bottom);
+
+ pGraph += 4; // skip the header
+
+ int32 x = left;
+
+ // if (left >= textWindowLeft-2 && top >= textWindowTop-2 && right <= textWindowRight-2 && bottom <= textWindowBottom-2) // crop
+ {
+ for (int32 y = top; y < maxY; ++y) {
+ const uint8 rleAmount = *pGraph++;
+ for (int32 run = 0; run < rleAmount; ++run) {
+ const uint8 rleMask = *pGraph++;
+ const uint8 iterations = bits(rleMask, 0, 6) + 1;
+ const uint8 opCode = bits(rleMask, 6, 2);
+ if (opCode == 0) {
+ x += iterations;
+ continue;
+ }
+ if (y < clip.top || x >= clip.right || x + iterations < clip.left) {
+ if (opCode == 1) {
+ pGraph += iterations;
+ } else {
+ ++pGraph;
+ }
+ x += iterations;
+ continue;
+ }
+ if (opCode == 1) { // 0x40
+ uint8 *out = (uint8 *)frontVideoBuffer.getBasePtr(x, y);
+ for (uint8 i = 0; i < iterations; i++) {
+ if (x >= clip.left && x < clip.right) {
+ *out = *pGraph;
+ }
+
+ ++out;
+ ++x;
+ ++pGraph;
+ }
+ } else {
+ const uint8 pixel = *pGraph++;
+ uint8 *out = (uint8 *)frontVideoBuffer.getBasePtr(x, y);
+ for (uint8 i = 0; i < iterations; i++) {
+ if (x >= clip.left && x < clip.right) {
+ *out = pixel;
+ }
+
+ ++out;
+ ++x;
+ }
+ }
+ }
+ x = left;
+ }
+ }
+
+ Common::Rect rect(left, top, right, bottom);
+ frontVideoBuffer.addDirtyRect(rect);
+
+ return true;
+}
+
+} // namespace TwinE
+
+#endif // TWINE_SCENE_GRAPH_H
diff --git a/engines/twine/scene/grid.cpp b/engines/twine/scene/grid.cpp
index 93e26831288..8cec35ef901 100644
--- a/engines/twine/scene/grid.cpp
+++ b/engines/twine/scene/grid.cpp
@@ -19,7 +19,6 @@
*
*/
-#include "twine/scene/grid.h"
#include "common/endian.h"
#include "common/memstream.h"
#include "common/textconsole.h"
@@ -32,6 +31,8 @@
#include "twine/resources/resources.h"
#include "twine/scene/actor.h"
#include "twine/scene/collision.h"
+#include "twine/scene/graph.h"
+#include "twine/scene/grid.h"
#include "twine/scene/scene.h"
#include "twine/shared.h"
#include "twine/twine.h"
@@ -162,7 +163,7 @@ void Grid::copyMask(int32 index, int32 x, int32 y, const Graphics::ManagedSurfac
} while (--vSize);
}
-const BrickEntry* Grid::getBrickEntry(int32 j, int32 i) const {
+const BrickEntry *Grid::getBrickEntry(int32 j, int32 i) const {
return &_listBrickColon[j * MAX_BRICKS + i];
}
@@ -249,7 +250,7 @@ void Grid::processGridMask(const uint8 *buffer, uint8 *ptr) {
numOfBlock++;
opaquePixels = 0;
}
- *targetPtrPos++ = runLength; //write skip
+ *targetPtrPos++ = runLength; // write skip
numOfBlock++;
}
}
@@ -465,12 +466,12 @@ bool Grid::initCellingGrid(int32 index) { // IncrustGrm
}
bool Grid::drawGraph(int32 index, int32 posX, int32 posY) { // AffGraph
- return drawBrickSprite(posX, posY, _bufferBrick[index], false);
+ return drawGraph(posX, posY, _bufferBrick[index], false);
}
-bool Grid::drawSprite(int32 index, int32 posX, int32 posY, const uint8 *ptr) { // AffGraph
- ptr = ptr + READ_LE_INT32(ptr + index * 4);
- return drawBrickSprite(posX, posY, ptr, true);
+bool Grid::drawGraph(int32 index, int32 posX, int32 posY, const uint8 *ptr) { // AffGraph
+ ptr = ptr + READ_LE_INT32(ptr + index * 4); // GetGraph, GetMask
+ return drawGraph(posX, posY, ptr, true);
}
bool Grid::drawSprite(int32 posX, int32 posY, const SpriteData &ptr, int spriteIndex) {
@@ -496,98 +497,18 @@ bool Grid::drawSprite(int32 posX, int32 posY, const SpriteData &ptr, int spriteI
return true;
}
-// WARNING: Rewrite this function to have better performance
-bool Grid::drawBrickSprite(int32 posX, int32 posY, const uint8 *pGraph, bool isSprite) { // AffGraph
+bool Grid::drawGraph(int32 posX, int32 posY, const uint8 *pGraph, bool isSprite) {
if (_engine->_debugState->_disableGridRendering) {
return false;
}
- if (!_engine->_interface->_clip.isValidRect()) {
- return false;
- }
-
- const int32 left = posX + pGraph[2];
- if (left >= _engine->_interface->_clip.right) {
- return false;
- }
- const int32 top = posY + pGraph[3];
- if (top >= _engine->_interface->_clip.bottom) {
- return false;
- }
- const int32 right = pGraph[0] + left;
- if (right < _engine->_interface->_clip.left) {
- return false;
- }
- const int32 bottom = pGraph[1] + top;
- if (bottom < _engine->_interface->_clip.top) {
- return false;
- }
- const int32 maxY = MIN(bottom, (int32)_engine->_interface->_clip.bottom);
-
- pGraph += 4; // skip the header
-
- int32 x = left;
-
- //if (left >= textWindowLeft-2 && top >= textWindowTop-2 && right <= textWindowRight-2 && bottom <= textWindowBottom-2) // crop
- {
- for (int32 y = top; y < maxY; ++y) {
- const uint8 rleAmount = *pGraph++;
- for (int32 run = 0; run < rleAmount; ++run) {
- const uint8 rleMask = *pGraph++;
- const uint8 iterations = bits(rleMask, 0, 6) + 1;
- const uint8 opCode = bits(rleMask, 6, 2);
- if (opCode == 0) {
- x += iterations;
- continue;
- }
- if (y < _engine->_interface->_clip.top || x >= _engine->_interface->_clip.right || x + iterations < _engine->_interface->_clip.left) {
- if (opCode == 1) {
- pGraph += iterations;
- } else {
- ++pGraph;
- }
- x += iterations;
- continue;
- }
- if (opCode == 1) { // 0x40
- uint8 *out = (uint8 *)_engine->_frontVideoBuffer.getBasePtr(x, y);
- for (uint8 i = 0; i < iterations; i++) {
- if (x >= _engine->_interface->_clip.left && x < _engine->_interface->_clip.right) {
- *out = *pGraph;
- }
-
- ++out;
- ++x;
- ++pGraph;
- }
- } else {
- const uint8 pixel = *pGraph++;
- uint8 *out = (uint8 *)_engine->_frontVideoBuffer.getBasePtr(x, y);
- for (uint8 i = 0; i < iterations; i++) {
- if (x >= _engine->_interface->_clip.left && x < _engine->_interface->_clip.right) {
- *out = pixel;
- }
-
- ++out;
- ++x;
- }
- }
- }
- x = left;
- }
- }
-
- Common::Rect rect(left, top, right, bottom);
- _engine->_frontVideoBuffer.addDirtyRect(rect);
-
- return true;
+ const Common::Rect &clip = _engine->_interface->_clip;
+ TwineScreen &frontVideoBuffer = _engine->_frontVideoBuffer;
+ return TwinE::drawGraph(posX, posY, pGraph, isSprite, frontVideoBuffer, clip);
}
const uint8 *Grid::getBlockBufferGround(const IVec3 &pos, int32 &ground) {
const IVec3 &collision = updateCollisionCoordinates(pos.x, pos.y, pos.z);
- const uint8 *ptr = _bufCube
- + collision.y * 2
- + collision.x * SIZE_CUBE_Y * 2
- + collision.z * SIZE_CUBE_X * SIZE_CUBE_Y * 2;
+ const uint8 *ptr = _bufCube + collision.y * 2 + collision.x * SIZE_CUBE_Y * 2 + collision.z * SIZE_CUBE_X * SIZE_CUBE_Y * 2;
int32 collisionY = collision.y;
while (collisionY) {
@@ -604,7 +525,7 @@ const uint8 *Grid::getBlockBufferGround(const IVec3 &pos, int32 &ground) {
return ptr;
}
-const BlockDataEntry* Grid::getAdrBlock(int32 blockIdx, int32 brickIdx) const {
+const BlockDataEntry *Grid::getAdrBlock(int32 blockIdx, int32 brickIdx) const {
const BlockData *blockPtr = getBlockLibrary(blockIdx);
return &blockPtr->entries[brickIdx];
}
@@ -837,7 +758,7 @@ uint8 Grid::worldCodeBrick(int32 x, int32 y, int32 z) {
return code;
}
-void Grid::centerOnActor(const ActorStruct* actor) {
+void Grid::centerOnActor(const ActorStruct *actor) {
_startCube.x = (actor->_posObj.x + SIZE_BRICK_Y) / SIZE_BRICK_XZ;
_startCube.y = (actor->_posObj.y + SIZE_BRICK_Y) / SIZE_BRICK_Y;
_startCube.z = (actor->_posObj.z + SIZE_BRICK_Y) / SIZE_BRICK_XZ;
diff --git a/engines/twine/scene/grid.h b/engines/twine/scene/grid.h
index 11b923c8f16..74d7b0ec0ab 100644
--- a/engines/twine/scene/grid.h
+++ b/engines/twine/scene/grid.h
@@ -248,7 +248,7 @@ public:
* @param posY sprite Y position to draw
* @param spritePtr sprite buffer pointer to draw
*/
- bool drawSprite(int32 index, int32 posX, int32 posY, const uint8 *spritePtr);
+ bool drawGraph(int32 index, int32 posX, int32 posY, const uint8 *spritePtr);
bool drawSprite(int32 posX, int32 posY, const SpriteData &ptr, int spriteIndex = 0);
/**
@@ -258,7 +258,7 @@ public:
* @param pGraph sprite buffer pointer to draw
* @param isSprite allows to identify if the sprite to display is brick or a single sprite
*/
- bool drawBrickSprite(int32 posX, int32 posY, const uint8 *pGraph, bool isSprite);
+ bool drawGraph(int32 posX, int32 posY, const uint8 *pGraph, bool isSprite);
/**
* Get block library
diff --git a/test/engines/twine/gridtest.h b/test/engines/twine/gridtest.h
new file mode 100644
index 00000000000..84cbb42c14d
--- /dev/null
+++ b/test/engines/twine/gridtest.h
@@ -0,0 +1,116 @@
+#include "twine/scene/graph.h"
+#include <cxxtest/TestSuite.h>
+
+class GridTestSuite : public CxxTest::TestSuite {
+public:
+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 0xd1, 0x01, 0x42, 0x11, 0x11, 0xf0, 0x82, 0x11, 0x43, 0xd0, 0xd0, 0xf0, 0xf0, 0x07,
+ 0x0d, 0x09, 0x43, 0xd1, 0xd1, 0xd2, 0xd2, 0x83, 0x13, 0x40, 0xf2, 0x00, 0x41, 0xd2, 0x13, 0x03,
+ 0x41, 0x11, 0xd0, 0x00, 0x40, 0xf0, 0x83, 0x11, 0x43, 0xd0, 0xd0, 0xf0, 0xf0, 0x09, 0x09, 0x0b,
+ 0x43, 0xd1, 0xd1, 0xd2, 0xd2, 0x82, 0x13, 0x42, 0xf2, 0x13, 0x13, 0x03, 0x42, 0x11, 0x11, 0xf0,
+ 0x82, 0x11, 0x43, 0xd0, 0xd0, 0xf0, 0xf0, 0x0b, 0x09, 0x0d, 0x43, 0xd1, 0xd1, 0xd2, 0xd2, 0x83,
+ 0x13, 0x40, 0xf2, 0x01, 0x40, 0xf0, 0x83, 0x11, 0x43, 0xd0, 0xd0, 0xf0, 0xf0, 0x0d, 0x07, 0x0f,
+ 0x43, 0xd1, 0xd1, 0xd2, 0xd2, 0x82, 0x13, 0x41, 0xf2, 0xf0, 0x82, 0x11, 0x43, 0xd0, 0xd0, 0xf0,
+ 0xf0, 0x0f, 0x03, 0x11, 0x4b, 0xd1, 0xd1, 0xd2, 0xd2, 0x13, 0x13, 0x11, 0x11, 0xd0, 0xd0, 0xf0,
+ 0xf0, 0x11, 0x03, 0x13, 0x47, 0xd1, 0xd1, 0xd2, 0xd2, 0xd0, 0xd0, 0xf0, 0xf0, 0x13, 0x03, 0x15,
+ 0x43, 0xd1, 0xd1, 0xf0, 0xf0, 0x15};
+
+ screen.clear(0);
+ const Common::Rect &clip = screen.getBounds();
+ const int32 posX = 100;
+ const int32 posY = 100;
+ const bool isSprite = false;
+
+ bool result = TwinE::drawGraph(posX, posY, brick_326, isSprite, screen, clip);
+ TS_ASSERT_EQUALS(0, screen.getPixel(posX + 21, posY));
+ TS_ASSERT_EQUALS(0xd0, screen.getPixel(posX + 22, posY));
+ TS_ASSERT_EQUALS(0xf0, screen.getPixel(posX + 25, posY + 37));
+ TS_ASSERT_EQUALS(0, screen.getPixel(posX + 26, posY + 37));
+ // Common::DumpFile file;
+ // file.open("test_gridtest.png");
+ // Image::writePNG(file, screen, pal);
+ TS_ASSERT(result);
+ }
+};
diff --git a/test/module.mk b/test/module.mk
index 361612a804f..2c82c1c5216 100644
--- a/test/module.mk
+++ b/test/module.mk
@@ -45,6 +45,11 @@ endif
TEST_LIBS += engines/ultima/libultima.a
endif
+ifeq ($(ENABLE_TWINE), STATIC_PLUGIN)
+ TESTS += $(srcdir)/test/engines/twine/*.h
+ TEST_LIBS += engines/twine/libtwine.a
+endif
+
#
TEST_FLAGS := --runner=StdioPrinter --no-std --no-eh
TEST_CFLAGS := $(CFLAGS) -I$(srcdir)/test/cxxtest
More information about the Scummvm-git-logs
mailing list