[Scummvm-git-logs] scummvm master -> 6a7d0d63632ef44fc54d39a0a2398d25bed3b6d1
mgerhardy
martin.gerhardy at gmail.com
Mon Nov 16 20:24:36 UTC 2020
This automated email contains information about 18 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
ba69546e91 TWINE: added BonusParameter struct
bace236b67 TWINE: replaced magic values with sprite constants
91965d5c11 TWINE: name a few unknown members
d3d283b351 TWINE: reduced code duplication in bonus handling
19d91fbf7f TWINE: reduced scope
ff6ae1397b TWINE: more sprite id defines
5f0c807a05 TWINE: replaced magic number
cde33bd76f TWINE: fixed free camera movement in other scenes
29a7323464 TWINE: renamed member of drawlist
b33f58bf2c TWINE: extended comment
37cdcae625 TWINE: reduced scope
df75fac95f TWINE: removed screenLookupTable
b27953f9f7 TWINE: renamed to lowercase
bd3cf29205 TWINE: reduced code duplication
e9bb99d3ab TWINE: Reduced scope + minor cleanup
207ce744df TWINE: renamed member for bitfield
74a8d20e8e TWINE: resource loading error check
6a7d0d6363 TWINE: fixed some missing actor in scene parsing
Commit: ba69546e91d22bc73e5c3861df2258e5f2b93120
https://github.com/scummvm/scummvm/commit/ba69546e91d22bc73e5c3861df2258e5f2b93120
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-16T21:23:03+01:00
Commit Message:
TWINE: added BonusParameter struct
Changed paths:
engines/twine/actor.cpp
engines/twine/actor.h
engines/twine/scene.cpp
engines/twine/script_life_v1.cpp
engines/twine/twine.cpp
diff --git a/engines/twine/actor.cpp b/engines/twine/actor.cpp
index 85ea2c2a23..d1ebe767f5 100644
--- a/engines/twine/actor.cpp
+++ b/engines/twine/actor.cpp
@@ -402,6 +402,7 @@ void Actor::resetActor(int16 actorIdx) {
memset(&actor->staticFlags, 0, sizeof(StaticFlagsStruct));
memset(&actor->dynamicFlags, 0, sizeof(DynamicFlagsStruct));
+ memset(&actor->bonusParameter, 0, sizeof(BonusParameter));
actor->life = 50;
actor->armor = 1;
@@ -481,12 +482,21 @@ void Actor::processActorExtraBonus(int32 actorIdx) { // GiveExtraBonus
ActorStruct *actor = _engine->_scene->getActor(actorIdx);
int32 numBonus = 0;
-
- int8 bonusTable[8];
- for (int32 a = 0; a < 5; a++) {
- if (actor->bonusParameter & (1 << (a + 4))) {
- bonusTable[numBonus++] = a;
- }
+ int8 bonusTable[5];
+ if (actor->bonusParameter.kashes) {
+ bonusTable[numBonus++] = 0; // kashes
+ }
+ if (actor->bonusParameter.lifepoints) {
+ bonusTable[numBonus++] = 1; // lifepoints
+ }
+ if (actor->bonusParameter.magicpoints) {
+ bonusTable[numBonus++] = 2; // magicpoints
+ }
+ if (actor->bonusParameter.key) {
+ bonusTable[numBonus++] = 3; // key
+ }
+ if (actor->bonusParameter.cloverleaf) {
+ bonusTable[numBonus++] = 4; // cloverleaf
}
if (numBonus == 0) {
@@ -501,15 +511,14 @@ void Actor::processActorExtraBonus(int32 actorIdx) { // GiveExtraBonus
if (!_engine->_gameState->magicLevelIdx && currentBonus == 2) {
currentBonus = 1;
}
- currentBonus += 3;
-
+ int8 bonusSprite = currentBonus + 3;
if (actor->dynamicFlags.bIsDead) {
- _engine->_extra->addExtraBonus(actor->x, actor->y, actor->z, 0x100, 0, currentBonus, actor->bonusAmount);
+ _engine->_extra->addExtraBonus(actor->x, actor->y, actor->z, 0x100, 0, bonusSprite, actor->bonusAmount);
// FIXME add constant for sample index
_engine->_sound->playSample(Samples::ItemPopup, 0x1000, 1, actor->x, actor->y, actor->z, actorIdx);
} else {
int32 angle = _engine->_movements->getAngleAndSetTargetActorDistance(actor->x, actor->z, _engine->_scene->sceneHero->x, _engine->_scene->sceneHero->z);
- _engine->_extra->addExtraBonus(actor->x, actor->y + actor->boudingBox.y.topRight, actor->z, 200, angle, currentBonus, actor->bonusAmount);
+ _engine->_extra->addExtraBonus(actor->x, actor->y + actor->boudingBox.y.topRight, actor->z, 200, angle, bonusSprite, actor->bonusAmount);
// FIXME add constant for sample index
_engine->_sound->playSample(Samples::ItemPopup, 0x1000, 1, actor->x, actor->y + actor->boudingBox.y.topRight, actor->z, actorIdx);
}
diff --git a/engines/twine/actor.h b/engines/twine/actor.h
index 9a749e11eb..9d2b17aefd 100644
--- a/engines/twine/actor.h
+++ b/engines/twine/actor.h
@@ -102,6 +102,19 @@ struct DynamicFlagsStruct {
uint16 bUnk8000 : 1; // 0x8000 unused
};
+struct BonusParameter {
+ uint16 unk1 : 1;
+ uint16 unk2 : 1;
+ uint16 unk3 : 1;
+ uint16 unk4 : 1;
+ uint16 kashes : 1;
+ uint16 lifepoints : 1;
+ uint16 magicpoints : 1;
+ uint16 key : 1;
+ uint16 cloverleaf : 1;
+ uint16 unused : 7;
+};
+
/** Actors structure */
class ActorStruct {
private:
@@ -130,7 +143,7 @@ public:
int32 z = 0;
int32 strengthOfHit = 0; // field_66
int32 hitBy = 0;
- int32 bonusParameter = 0; // field_10
+ BonusParameter bonusParameter; // field_10
int32 angle = 0;
int32 speed = 0;
ControlMode controlMode = ControlMode::kNoMove;
diff --git a/engines/twine/scene.cpp b/engines/twine/scene.cpp
index 9db9262963..048beace51 100644
--- a/engines/twine/scene.cpp
+++ b/engines/twine/scene.cpp
@@ -166,8 +166,7 @@ bool Scene::loadSceneLBA1() {
act->z = stream.readUint16LE();
act->collisionZ = act->z;
act->strengthOfHit = stream.readByte();
- act->bonusParameter = stream.readUint16LE();
- act->bonusParameter &= 0xFE;
+ *(uint16*)&act->bonusParameter = stream.readUint16LE() & 0xFE;
act->angle = stream.readUint16LE();
act->speed = stream.readUint16LE();
act->controlMode = (ControlMode)stream.readUint16LE();
diff --git a/engines/twine/script_life_v1.cpp b/engines/twine/script_life_v1.cpp
index f019d698ff..9a47d62216 100644
--- a/engines/twine/script_life_v1.cpp
+++ b/engines/twine/script_life_v1.cpp
@@ -21,6 +21,7 @@
*/
#include "twine/script_life_v1.h"
+#include "common/memstream.h"
#include "common/stream.h"
#include "twine/actor.h"
#include "twine/animations.h"
@@ -39,7 +40,6 @@
#include "twine/resources.h"
#include "twine/scene.h"
#include "twine/screens.h"
-#include "common/memstream.h"
#include "twine/sound.h"
#include "twine/text.h"
#include "twine/twine.h"
@@ -880,12 +880,12 @@ static int32 lSET_DOOR_DOWN(TwinEEngine *engine, LifeScriptContext &ctx) {
static int32 lGIVE_BONUS(TwinEEngine *engine, LifeScriptContext &ctx) {
int32 flag = ctx.stream.readByte();
- if (ctx.actor->bonusParameter & 0x1F0) {
+ if (ctx.actor->bonusParameter.cloverleaf || ctx.actor->bonusParameter.kashes || ctx.actor->bonusParameter.key || ctx.actor->bonusParameter.lifepoints || ctx.actor->bonusParameter.magicpoints) {
engine->_actor->processActorExtraBonus(ctx.actorIdx);
}
if (flag != 0) {
- ctx.actor->bonusParameter |= 1;
+ ctx.actor->bonusParameter.unk1 = 1;
}
return 0;
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 8c00533e83..e5a8586b38 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -703,7 +703,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
}
}
- if (actor->bonusParameter & 0x1F0 && !(actor->bonusParameter & 1)) {
+ if (!actor->bonusParameter.unk1 && (actor->bonusParameter.cloverleaf || actor->bonusParameter.kashes || actor->bonusParameter.key || actor->bonusParameter.lifepoints || actor->bonusParameter.magicpoints)) {
_actor->processActorExtraBonus(a);
}
}
@@ -756,8 +756,8 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
} else {
const int32 rnd = getRandomNumber(2000) + 3096;
_sound->playSample(Samples::Explode, rnd, 1, actor->x, actor->y, actor->z, a);
- if (actor->bonusParameter & 0x1F0) {
- if (!(actor->bonusParameter & 1)) {
+ if (actor->bonusParameter.cloverleaf || actor->bonusParameter.kashes || actor->bonusParameter.key || actor->bonusParameter.lifepoints || actor->bonusParameter.magicpoints) {
+ if (!actor->bonusParameter.unk1) {
_actor->processActorExtraBonus(a);
}
actor->life = 0;
Commit: bace236b67c4fc40e1bcf30c944fbb57b313df2f
https://github.com/scummvm/scummvm/commit/bace236b67c4fc40e1bcf30c944fbb57b313df2f
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-16T21:23:03+01:00
Commit Message:
TWINE: replaced magic values with sprite constants
Changed paths:
engines/twine/actor.cpp
diff --git a/engines/twine/actor.cpp b/engines/twine/actor.cpp
index d1ebe767f5..3f6ff70227 100644
--- a/engines/twine/actor.cpp
+++ b/engines/twine/actor.cpp
@@ -482,21 +482,21 @@ void Actor::processActorExtraBonus(int32 actorIdx) { // GiveExtraBonus
ActorStruct *actor = _engine->_scene->getActor(actorIdx);
int32 numBonus = 0;
- int8 bonusTable[5];
+ int8 bonusSprites[5];
if (actor->bonusParameter.kashes) {
- bonusTable[numBonus++] = 0; // kashes
+ bonusSprites[numBonus++] = SPRITEHQR_KASHES;
}
if (actor->bonusParameter.lifepoints) {
- bonusTable[numBonus++] = 1; // lifepoints
+ bonusSprites[numBonus++] = SPRITEHQR_LIFEPOINTS;
}
if (actor->bonusParameter.magicpoints) {
- bonusTable[numBonus++] = 2; // magicpoints
+ bonusSprites[numBonus++] = SPRITEHQR_MAGICPOINTS;
}
if (actor->bonusParameter.key) {
- bonusTable[numBonus++] = 3; // key
+ bonusSprites[numBonus++] = SPRITEHQR_KEY;
}
if (actor->bonusParameter.cloverleaf) {
- bonusTable[numBonus++] = 4; // cloverleaf
+ bonusSprites[numBonus++] = SPRITEHQR_CLOVERLEAF;
}
if (numBonus == 0) {
@@ -506,12 +506,11 @@ void Actor::processActorExtraBonus(int32 actorIdx) { // GiveExtraBonus
const int bonusIndex = _engine->getRandomNumber(numBonus);
assert(bonusIndex >= 0);
assert(bonusIndex < numBonus);
- int8 currentBonus = bonusTable[bonusIndex];
+ int8 bonusSprite = bonusSprites[bonusIndex];
// if bonus is magic an no magic level yet, then give life points
- if (!_engine->_gameState->magicLevelIdx && currentBonus == 2) {
- currentBonus = 1;
+ if (!_engine->_gameState->magicLevelIdx && bonusSprite == SPRITEHQR_MAGICPOINTS) {
+ bonusSprite = SPRITEHQR_KASHES;
}
- int8 bonusSprite = currentBonus + 3;
if (actor->dynamicFlags.bIsDead) {
_engine->_extra->addExtraBonus(actor->x, actor->y, actor->z, 0x100, 0, bonusSprite, actor->bonusAmount);
// FIXME add constant for sample index
Commit: 91965d5c118ad59c61b230e0d49c14f0bdec7b9d
https://github.com/scummvm/scummvm/commit/91965d5c118ad59c61b230e0d49c14f0bdec7b9d
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-16T21:23:03+01:00
Commit Message:
TWINE: name a few unknown members
Changed paths:
engines/twine/movements.h
engines/twine/renderer.h
diff --git a/engines/twine/movements.h b/engines/twine/movements.h
index 9a46c8c5e8..752c0e02e8 100644
--- a/engines/twine/movements.h
+++ b/engines/twine/movements.h
@@ -165,11 +165,11 @@ public:
/**
* Rotate actor with a given angle
- * @param X Actor current X coordinate
- * @param Z Actor current Z coordinate
+ * @param x Actor current X coordinate
+ * @param z Actor current Z coordinate
* @param angle Actor angle to rotate
*/
- void rotateActor(int32 X, int32 Z, int32 angle);
+ void rotateActor(int32 x, int32 z, int32 angle);
/**
* Get distance value in 2D
diff --git a/engines/twine/renderer.h b/engines/twine/renderer.h
index fd5dab600e..896bb5a069 100644
--- a/engines/twine/renderer.h
+++ b/engines/twine/renderer.h
@@ -111,12 +111,12 @@ private:
struct bodyHeaderStruct {
int16 bodyFlag = 0;
- int16 unk0 = 0;
- int16 unk1 = 0;
- int16 bottomleft = 0;
- int16 topright = 0;
- int16 unk4 = 0;
- int16 unk5 = 0;
+ int16 minsx = 0;
+ int16 maxsx = 0;
+ int16 minsy = 0;
+ int16 maxsy = 0;
+ int16 minsz = 0;
+ int16 maxsz = 0;
int16 offsetToData = 0;
int8 *ptrToKeyFrame = nullptr;
int32 keyFrameTime = 0;
Commit: d3d283b35154db62b02efaabeeed633715de6533
https://github.com/scummvm/scummvm/commit/d3d283b35154db62b02efaabeeed633715de6533
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-16T21:23:03+01:00
Commit Message:
TWINE: reduced code duplication in bonus handling
Changed paths:
engines/twine/actor.cpp
engines/twine/actor.h
engines/twine/extra.cpp
engines/twine/extra.h
engines/twine/scene.cpp
engines/twine/scene.h
diff --git a/engines/twine/actor.cpp b/engines/twine/actor.cpp
index 3f6ff70227..49c20ab90e 100644
--- a/engines/twine/actor.cpp
+++ b/engines/twine/actor.cpp
@@ -481,36 +481,10 @@ void Actor::processActorCarrier(int32 actorIdx) { // CheckCarrier
void Actor::processActorExtraBonus(int32 actorIdx) { // GiveExtraBonus
ActorStruct *actor = _engine->_scene->getActor(actorIdx);
- int32 numBonus = 0;
- int8 bonusSprites[5];
- if (actor->bonusParameter.kashes) {
- bonusSprites[numBonus++] = SPRITEHQR_KASHES;
- }
- if (actor->bonusParameter.lifepoints) {
- bonusSprites[numBonus++] = SPRITEHQR_LIFEPOINTS;
- }
- if (actor->bonusParameter.magicpoints) {
- bonusSprites[numBonus++] = SPRITEHQR_MAGICPOINTS;
- }
- if (actor->bonusParameter.key) {
- bonusSprites[numBonus++] = SPRITEHQR_KEY;
- }
- if (actor->bonusParameter.cloverleaf) {
- bonusSprites[numBonus++] = SPRITEHQR_CLOVERLEAF;
- }
-
- if (numBonus == 0) {
+ const int bonusSprite = _engine->_extra->getBonusSprite(actor->bonusParameter);
+ if (bonusSprite == -1) {
return;
}
-
- const int bonusIndex = _engine->getRandomNumber(numBonus);
- assert(bonusIndex >= 0);
- assert(bonusIndex < numBonus);
- int8 bonusSprite = bonusSprites[bonusIndex];
- // if bonus is magic an no magic level yet, then give life points
- if (!_engine->_gameState->magicLevelIdx && bonusSprite == SPRITEHQR_MAGICPOINTS) {
- bonusSprite = SPRITEHQR_KASHES;
- }
if (actor->dynamicFlags.bIsDead) {
_engine->_extra->addExtraBonus(actor->x, actor->y, actor->z, 0x100, 0, bonusSprite, actor->bonusAmount);
// FIXME add constant for sample index
diff --git a/engines/twine/actor.h b/engines/twine/actor.h
index 9d2b17aefd..12f9881d3b 100644
--- a/engines/twine/actor.h
+++ b/engines/twine/actor.h
@@ -102,6 +102,16 @@ struct DynamicFlagsStruct {
uint16 bUnk8000 : 1; // 0x8000 unused
};
+/**
+ * Bonus type flags - a bitfield value, of which the bits mean:
+ * bit 8: clover leaf,
+ * bit 7: small key,
+ * bit 6: magic,
+ * bit 5: life,
+ * bit 4: money,
+ * If more than one type of bonus is selected, the actual type of bonus
+ * will be chosen randomly each time player uses Action.
+ */
struct BonusParameter {
uint16 unk1 : 1;
uint16 unk2 : 1;
diff --git a/engines/twine/extra.cpp b/engines/twine/extra.cpp
index ebb005f7cd..37002c426d 100644
--- a/engines/twine/extra.cpp
+++ b/engines/twine/extra.cpp
@@ -218,6 +218,41 @@ void Extra::addExtraSpecial(int32 x, int32 y, int32 z, ExtraSpecialType type) {
}
}
+int Extra::getBonusSprite(BonusParameter bonusParameter) const {
+ int numBonus = 0;
+ int8 bonusSprites[5];
+ if (bonusParameter.kashes) {
+ bonusSprites[numBonus++] = SPRITEHQR_KASHES;
+ }
+ if (bonusParameter.lifepoints) {
+ bonusSprites[numBonus++] = SPRITEHQR_LIFEPOINTS;
+ }
+ if (bonusParameter.magicpoints) {
+ bonusSprites[numBonus++] = SPRITEHQR_MAGICPOINTS;
+ }
+ if (bonusParameter.key) {
+ bonusSprites[numBonus++] = SPRITEHQR_KEY;
+ }
+ if (bonusParameter.cloverleaf) {
+ bonusSprites[numBonus++] = SPRITEHQR_CLOVERLEAF;
+ }
+
+ if (numBonus == 0) {
+ return -1;
+ }
+
+ const int bonusIndex = _engine->getRandomNumber(numBonus);
+ assert(bonusIndex >= 0);
+ assert(bonusIndex < numBonus);
+ int8 bonusSprite = bonusSprites[bonusIndex];
+ // if bonus is magic an no magic level yet, then give life points
+ if (!_engine->_gameState->magicLevelIdx && bonusSprite == SPRITEHQR_MAGICPOINTS) {
+ bonusSprite = SPRITEHQR_KASHES;
+ }
+
+ return bonusSprite;
+}
+
int32 Extra::addExtraBonus(int32 x, int32 y, int32 z, int32 param, int32 angle, int32 type, int32 bonusAmount) { // ExtraBonus
int32 i;
diff --git a/engines/twine/extra.h b/engines/twine/extra.h
index c37de565f2..8161b73cbc 100644
--- a/engines/twine/extra.h
+++ b/engines/twine/extra.h
@@ -90,6 +90,8 @@ public:
void drawExtraSpecial(int32 extraIdx, int32 x, int32 y);
+ int getBonusSprite(BonusParameter bonusParameter) const;
+
/** Process extras */
void processExtras();
};
diff --git a/engines/twine/scene.cpp b/engines/twine/scene.cpp
index 048beace51..a015380aa3 100644
--- a/engines/twine/scene.cpp
+++ b/engines/twine/scene.cpp
@@ -398,34 +398,22 @@ void Scene::processEnvironmentSound() {
}
void Scene::processZoneExtraBonus(ZoneStruct *zone) {
- // bonus not used yet
if (zone->infoData.Bonus.used) {
return;
}
- int8 bonusTable[8];
- int32 numBonus = 0;
- for (int32 a = 0; a < 5; a++) {
- if (zone->infoData.Bonus.typesFlag & (1 << (a + 4))) {
- bonusTable[numBonus++] = a;
- }
- }
- if (numBonus) {
- int8 currentBonus = bonusTable[_engine->getRandomNumber(numBonus)];
-
- // if bonus is magic an no magic level yet, then give life points
- if (!_engine->_gameState->magicLevelIdx && currentBonus == 2) {
- currentBonus = 1;
- }
+ const int bonusSprite = _engine->_extra->getBonusSprite(zone->infoData.Bonus.typesFlag);
+ if (bonusSprite == -1) {
+ return;
+ }
- const int16 amount = zone->infoData.Bonus.amount;
- const int32 angle = _engine->_movements->getAngleAndSetTargetActorDistance(ABS(zone->topRight.x + zone->bottomLeft.x) / 2, ABS(zone->topRight.z + zone->bottomLeft.z) / 2, sceneHero->x, sceneHero->z);
- const int32 index = _engine->_extra->addExtraBonus(ABS(zone->topRight.x + zone->bottomLeft.x) / 2, zone->topRight.y, ABS(zone->topRight.z + zone->bottomLeft.z) / 2, 180, angle, currentBonus + 3, amount);
+ const int16 amount = zone->infoData.Bonus.amount;
+ const int32 angle = _engine->_movements->getAngleAndSetTargetActorDistance(ABS(zone->topRight.x + zone->bottomLeft.x) / 2, ABS(zone->topRight.z + zone->bottomLeft.z) / 2, sceneHero->x, sceneHero->z);
+ const int32 index = _engine->_extra->addExtraBonus(ABS(zone->topRight.x + zone->bottomLeft.x) / 2, zone->topRight.y, ABS(zone->topRight.z + zone->bottomLeft.z) / 2, 180, angle, bonusSprite, amount);
- if (index != -1) {
- _engine->_extra->extraList[index].type |= 0x400;
- zone->infoData.Bonus.used = 1; // set as used
- }
+ if (index != -1) {
+ _engine->_extra->extraList[index].type |= 0x400;
+ zone->infoData.Bonus.used = 1; // set as used
}
}
diff --git a/engines/twine/scene.h b/engines/twine/scene.h
index 0628a5bb86..8f595ca77f 100644
--- a/engines/twine/scene.h
+++ b/engines/twine/scene.h
@@ -80,17 +80,7 @@ struct ZoneStruct {
} DisplayText;
struct {
int16 info0;
- /**
- * Bonus type flags - a bitfield value, of which the bits mean:
- * bit 8: clover leaf,
- * bit 7: small key,
- * bit 6: magic,
- * bit 5: life,
- * bit 4: money,
- * If more than one type of bonus is selected, the actual type of bonus
- * will be chosen randomly each time player uses Action.
- */
- int16 typesFlag;
+ BonusParameter typesFlag;
int16 amount;
/**
* Already used
Commit: 19d91fbf7fc4353ed2b64c70d5e32f22fe293144
https://github.com/scummvm/scummvm/commit/19d91fbf7fc4353ed2b64c70d5e32f22fe293144
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-16T21:23:03+01:00
Commit Message:
TWINE: reduced scope
Changed paths:
engines/twine/extra.cpp
engines/twine/scene.cpp
diff --git a/engines/twine/extra.cpp b/engines/twine/extra.cpp
index 37002c426d..291b79638e 100644
--- a/engines/twine/extra.cpp
+++ b/engines/twine/extra.cpp
@@ -254,9 +254,7 @@ int Extra::getBonusSprite(BonusParameter bonusParameter) const {
}
int32 Extra::addExtraBonus(int32 x, int32 y, int32 z, int32 param, int32 angle, int32 type, int32 bonusAmount) { // ExtraBonus
- int32 i;
-
- for (i = 0; i < EXTRA_MAX_ENTRIES; i++) {
+ for (int32 i = 0; i < EXTRA_MAX_ENTRIES; i++) {
ExtraListStruct *extra = &extraList[i];
if (extra->info0 != -1) {
continue;
@@ -286,9 +284,7 @@ int32 Extra::addExtraBonus(int32 x, int32 y, int32 z, int32 param, int32 angle,
}
int32 Extra::addExtraThrow(int32 actorIdx, int32 x, int32 y, int32 z, int32 sprite, int32 var2, int32 var3, int32 var4, int32 var5, int32 strengthOfHit) { // ThrowExtra
- int32 i;
-
- for (i = 0; i < EXTRA_MAX_ENTRIES; i++) {
+ for (int32 i = 0; i < EXTRA_MAX_ENTRIES; i++) {
ExtraListStruct *extra = &extraList[i];
if (extra->info0 != -1) {
continue;
@@ -314,9 +310,7 @@ int32 Extra::addExtraThrow(int32 actorIdx, int32 x, int32 y, int32 z, int32 spri
}
int32 Extra::addExtraAiming(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx, int32 targetActorIdx, int32 maxSpeed, int32 strengthOfHit) { // ExtraSearch
- int32 i;
-
- for (i = 0; i < EXTRA_MAX_ENTRIES; i++) {
+ for (int32 i = 0; i < EXTRA_MAX_ENTRIES; i++) {
ExtraListStruct *extra = &extraList[i];
if (extra->info0 != -1) {
continue;
@@ -343,9 +337,7 @@ int32 Extra::addExtraAiming(int32 actorIdx, int32 x, int32 y, int32 z, int32 spr
// cseg01:00018168
int32 Extra::findExtraKey() {
- int32 i;
-
- for (i = 0; i < EXTRA_MAX_ENTRIES; i++) {
+ for (int32 i = 0; i < EXTRA_MAX_ENTRIES; i++) {
ExtraListStruct *extra = &extraList[i];
if (extra->info0 == SPRITEHQR_KEY) {
return i;
@@ -357,9 +349,7 @@ int32 Extra::findExtraKey() {
// cseg01:00018250
int32 Extra::addExtraAimingAtKey(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx, int32 extraIdx) { // addMagicBallAimingAtKey
- int32 i;
-
- for (i = 0; i < EXTRA_MAX_ENTRIES; i++) {
+ for (int32 i = 0; i < EXTRA_MAX_ENTRIES; i++) {
ExtraListStruct *extra = &extraList[i];
if (extra->info0 != -1) {
continue;
diff --git a/engines/twine/scene.cpp b/engines/twine/scene.cpp
index a015380aa3..b2ab03b25b 100644
--- a/engines/twine/scene.cpp
+++ b/engines/twine/scene.cpp
@@ -378,7 +378,7 @@ void Scene::processEnvironmentSound() {
samplePlayed = 0;
}
- int16 sampleIdx = sampleAmbiance[currentAmb];
+ const int16 sampleIdx = sampleAmbiance[currentAmb];
if (sampleIdx != -1) {
int16 decal = sampleRound[currentAmb];
int16 repeat = sampleRepeat[currentAmb];
Commit: ff6ae1397b8813f372998b0b3173b5c3f0cbb1e9
https://github.com/scummvm/scummvm/commit/ff6ae1397b8813f372998b0b3173b5c3f0cbb1e9
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-16T21:23:03+01:00
Commit Message:
TWINE: more sprite id defines
Changed paths:
engines/twine/resources.h
diff --git a/engines/twine/resources.h b/engines/twine/resources.h
index 2fac100477..97ac8b2baf 100644
--- a/engines/twine/resources.h
+++ b/engines/twine/resources.h
@@ -91,6 +91,28 @@ namespace TwinE {
#define SPRITEHQR_MAGICBALL_GREEN 42
#define SPRITEHQR_MAGICBALL_RED 43
#define SPRITEHQR_MAGICBALL_YELLOW_TRANS 44
+#define SPRITEHQR_EXPLOSION_FIRST_FRAME 97 // 7 frames
+#define SPRITEHQR_FENCE_1 18
+#define SPRITEHQR_FENCE_2 19
+#define SPRITEHQR_FENCE_3 22
+#define SPRITEHQR_FENCE_4 23
+#define SPRITEHQR_FENCE_METAL 35
+#define SPRITEHQR_FENCE_METAL_2 54
+#define SPRITEHQR_FENCE_METAL_3 83
+#define SPRITEHQR_MUSHROOM 92
+#define SPRITEHQR_DOOR_WODDEN_1 31
+#define SPRITEHQR_DOOR_WODDEN_2 32
+#define SPRITEHQR_DOOR_PRISON_WODDEN 37
+#define SPRITEHQR_DOOR_PADLOCK 58
+#define SPRITEHQR_DOOR_BRICKED_UP 76
+#define SPRITEHQR_DOOR_1 104
+#define SPRITEHQR_DOOR_2 107
+#define SPRITEHQR_DOOR_3 24
+#define SPRITEHQR_DOOR_4 11
+#define SPRITEHQR_DOOR_5 12
+#define SPRITEHQR_DOOR_PRISON_GRID 15
+#define SPRITEHQR_DOOR_PRISON_HARMED 16
+#define SPRITEHQR_DOOR_PRISON_WITH_F_LETTER 17
#define SPRITEHQR_MAGICBALL_GREEN_TRANS 109
#define SPRITEHQR_MAGICBALL_RED_TRANS 110
Commit: 5f0c807a0528f299759d123c4a078149cde2ecae
https://github.com/scummvm/scummvm/commit/5f0c807a0528f299759d123c4a078149cde2ecae
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-16T21:23:03+01:00
Commit Message:
TWINE: replaced magic number
Changed paths:
engines/twine/extra.cpp
engines/twine/extra.h
diff --git a/engines/twine/extra.cpp b/engines/twine/extra.cpp
index 291b79638e..abc3d23aec 100644
--- a/engines/twine/extra.cpp
+++ b/engines/twine/extra.cpp
@@ -105,13 +105,13 @@ static const int16 explodeCloudShapeTable[] = {
Extra::Extra(TwinEEngine *engine) : _engine(engine) {}
-int32 Extra::addExtra(int32 actorIdx, int32 x, int32 y, int32 z, int32 info0, int32 targetActor, int32 maxSpeed, int32 strengthOfHit) {
+int32 Extra::addExtra(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx, int32 targetActor, int32 maxSpeed, int32 strengthOfHit) {
for (int32 i = 0; i < EXTRA_MAX_ENTRIES; i++) {
ExtraListStruct *extra = &extraList[i];
if (extra->info0 != -1) {
continue;
}
- extra->info0 = info0;
+ extra->info0 = spriteIdx;
extra->type = 0x80;
extra->info1 = 0;
extra->x = x;
@@ -136,7 +136,7 @@ int32 Extra::addExtraExplode(int32 x, int32 y, int32 z) {
if (extra->info0 != -1) {
continue;
}
- extra->info0 = 0x61;
+ extra->info0 = SPRITEHQR_EXPLOSION_FIRST_FRAME;
extra->type = 0x1001;
extra->info1 = 0;
extra->x = x;
@@ -283,13 +283,13 @@ int32 Extra::addExtraBonus(int32 x, int32 y, int32 z, int32 param, int32 angle,
return -1;
}
-int32 Extra::addExtraThrow(int32 actorIdx, int32 x, int32 y, int32 z, int32 sprite, int32 var2, int32 var3, int32 var4, int32 var5, int32 strengthOfHit) { // ThrowExtra
+int32 Extra::addExtraThrow(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx, int32 var2, int32 var3, int32 var4, int32 var5, int32 strengthOfHit) { // ThrowExtra
for (int32 i = 0; i < EXTRA_MAX_ENTRIES; i++) {
ExtraListStruct *extra = &extraList[i];
if (extra->info0 != -1) {
continue;
}
- extra->info0 = sprite;
+ extra->info0 = spriteIdx;
extra->type = 0x210C;
extra->x = x;
extra->y = y;
diff --git a/engines/twine/extra.h b/engines/twine/extra.h
index 8161b73cbc..1c4634ab15 100644
--- a/engines/twine/extra.h
+++ b/engines/twine/extra.h
@@ -69,7 +69,7 @@ public:
Extra(TwinEEngine *engine);
ExtraListStruct extraList[EXTRA_MAX_ENTRIES];
- int32 addExtra(int32 actorIdx, int32 x, int32 y, int32 z, int32 info0, int32 targetActor, int32 maxSpeed, int32 strengthOfHit);
+ int32 addExtra(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx, int32 targetActor, int32 maxSpeed, int32 strengthOfHit);
/**
* Add extra explosion
@@ -84,7 +84,7 @@ public:
void addExtraSpecial(int32 x, int32 y, int32 z, ExtraSpecialType type);
int32 addExtraBonus(int32 x, int32 y, int32 z, int32 param, int32 angle, int32 type, int32 bonusAmount);
- int32 addExtraThrow(int32 actorIdx, int32 x, int32 y, int32 z, int32 sprite, int32 var2, int32 var3, int32 var4, int32 var5, int32 strengthOfHit);
+ int32 addExtraThrow(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx, int32 var2, int32 var3, int32 var4, int32 var5, int32 strengthOfHit);
int32 addExtraAiming(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx, int32 targetActorIdx, int32 maxSpeed, int32 strengthOfHit);
void addExtraThrowMagicball(int32 x, int32 y, int32 z, int32 param1, int32 angle, int32 param2, int32 param3);
Commit: cde33bd76f50b1d38572f11114dc637dfeb775dd
https://github.com/scummvm/scummvm/commit/cde33bd76f50b1d38572f11114dc637dfeb775dd
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-16T21:23:04+01:00
Commit Message:
TWINE: fixed free camera movement in other scenes
Changed paths:
engines/twine/debug_grid.cpp
engines/twine/redraw.cpp
engines/twine/scene.cpp
diff --git a/engines/twine/debug_grid.cpp b/engines/twine/debug_grid.cpp
index 17bcb900d2..896e635b38 100644
--- a/engines/twine/debug_grid.cpp
+++ b/engines/twine/debug_grid.cpp
@@ -39,8 +39,6 @@ void DebugGrid::changeGridCamera() {
return;
}
- ScopedKeyMap scopedKeyMap(_engine, mainKeyMapId);
-
if (_engine->_input->isActionActive(TwinEActionType::DebugGridCameraPressUp)) {
_engine->_grid->newCameraZ--;
_engine->_redraw->reqBgRedraw = true;
diff --git a/engines/twine/redraw.cpp b/engines/twine/redraw.cpp
index bd20617062..04e3de9364 100644
--- a/engines/twine/redraw.cpp
+++ b/engines/twine/redraw.cpp
@@ -437,6 +437,7 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
// Drawing unknown
else if (flags < 0x1000) {
// TODO reverse this part of the code
+ warning("Not yet reversed part of the rendering code");
}
// Drawing sprite actors
else if (flags == 0x1000) {
diff --git a/engines/twine/scene.cpp b/engines/twine/scene.cpp
index b2ab03b25b..3557f1c23d 100644
--- a/engines/twine/scene.cpp
+++ b/engines/twine/scene.cpp
@@ -26,6 +26,7 @@
#include "common/util.h"
#include "twine/actor.h"
#include "twine/animations.h"
+#include "twine/debug_grid.h"
#include "twine/extra.h"
#include "twine/gamestate.h"
#include "twine/grid.h"
@@ -449,7 +450,7 @@ void Scene::processActorZones(int32 actorIdx) {
}
break;
case kCamera:
- if (currentlyFollowedActor == actorIdx) {
+ if (currentlyFollowedActor == actorIdx && !_engine->_debugGrid->useFreeCamera) {
_engine->disableScreenRecenter = true;
if (_engine->_grid->newCameraX != zone->infoData.CameraView.x || _engine->_grid->newCameraY != zone->infoData.CameraView.y || _engine->_grid->newCameraZ != zone->infoData.CameraView.z) {
_engine->_grid->newCameraX = zone->infoData.CameraView.x;
Commit: 29a732346457e5fd2609367c779b67482d56cd2a
https://github.com/scummvm/scummvm/commit/29a732346457e5fd2609367c779b67482d56cd2a
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-16T21:23:04+01:00
Commit Message:
TWINE: renamed member of drawlist
Changed paths:
engines/twine/redraw.cpp
engines/twine/redraw.h
diff --git a/engines/twine/redraw.cpp b/engines/twine/redraw.cpp
index 04e3de9364..1dba2f3651 100644
--- a/engines/twine/redraw.cpp
+++ b/engines/twine/redraw.cpp
@@ -294,7 +294,7 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
drawList[drawListPos].x = _engine->_actor->shadowX;
drawList[drawListPos].y = _engine->_actor->shadowY;
drawList[drawListPos].z = _engine->_actor->shadowZ;
- drawList[drawListPos].field_A = 2;
+ drawList[drawListPos].offset = 2;
drawListPos++;
}
}
@@ -330,7 +330,7 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
drawList[drawListPos].x = _engine->_actor->shadowX;
drawList[drawListPos].y = _engine->_actor->shadowY;
drawList[drawListPos].z = _engine->_actor->shadowZ;
- drawList[drawListPos].field_A = 0;
+ drawList[drawListPos].offset = 0;
drawListPos++;
}
}
@@ -409,7 +409,7 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
_engine->_renderer->projectPositionOnScreen(shadow.x - _engine->_grid->cameraX, shadow.y - _engine->_grid->cameraY, shadow.z - _engine->_grid->cameraZ);
int32 spriteWidth, spriteHeight;
- _engine->_grid->getSpriteSize(shadow.field_A, &spriteWidth, &spriteHeight, _engine->_resources->spriteShadowPtr);
+ _engine->_grid->getSpriteSize(shadow.offset, &spriteWidth, &spriteHeight, _engine->_resources->spriteShadowPtr);
// calculate sprite size and position on screen
renderLeft = _engine->_renderer->projPosX - (spriteWidth / 2);
@@ -420,7 +420,7 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
_engine->_interface->setClip(renderLeft, renderTop, renderRight, renderBottom);
if (_engine->_interface->textWindowLeft <= _engine->_interface->textWindowRight && _engine->_interface->textWindowTop <= _engine->_interface->textWindowBottom) {
- _engine->_grid->drawSprite(shadow.field_A, renderLeft, renderTop, _engine->_resources->spriteShadowPtr);
+ _engine->_grid->drawSprite(shadow.offset, renderLeft, renderTop, _engine->_resources->spriteShadowPtr);
}
const int32 tmpX = (shadow.x + 0x100) >> 9;
diff --git a/engines/twine/redraw.h b/engines/twine/redraw.h
index 9f5a1ae906..f352319165 100644
--- a/engines/twine/redraw.h
+++ b/engines/twine/redraw.h
@@ -63,7 +63,7 @@ private:
uint16 x = 0;
uint16 y = 0;
uint16 z = 0;
- uint16 field_A = 0;
+ uint16 offset = 0;
uint16 field_C = 0;
uint16 field_E = 0;
uint16 field_10 = 0;
Commit: b33f58bf2c63de92e770c024d8b01e946a265aac
https://github.com/scummvm/scummvm/commit/b33f58bf2c63de92e770c024d8b01e946a265aac
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-16T21:23:04+01:00
Commit Message:
TWINE: extended comment
Changed paths:
engines/twine/redraw.cpp
diff --git a/engines/twine/redraw.cpp b/engines/twine/redraw.cpp
index 1dba2f3651..c6545e7fda 100644
--- a/engines/twine/redraw.cpp
+++ b/engines/twine/redraw.cpp
@@ -439,7 +439,7 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
// TODO reverse this part of the code
warning("Not yet reversed part of the rendering code");
}
- // Drawing sprite actors
+ // Drawing sprite actors, doors and entities
else if (flags == 0x1000) {
const uint8 *spritePtr = _engine->_resources->spriteTable[actor2->entity];
Commit: 37cdcae625e0d50738aca900b56d751f6f36c3b2
https://github.com/scummvm/scummvm/commit/37cdcae625e0d50738aca900b56d751f6f36c3b2
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-16T21:23:04+01:00
Commit Message:
TWINE: reduced scope
Changed paths:
engines/twine/debug.cpp
diff --git a/engines/twine/debug.cpp b/engines/twine/debug.cpp
index 2b4edc3eb2..23ed4a70ea 100644
--- a/engines/twine/debug.cpp
+++ b/engines/twine/debug.cpp
@@ -73,8 +73,9 @@ void Debug::debugDrawWindowButtons(int32 w) {
int32 textTop = debugWindows[w].debugButtons[b].textTop;
int32 isActive = debugWindows[w].debugButtons[b].isActive;
int8 color = debugWindows[w].debugButtons[b].color;
- if (isActive > 0)
+ if (isActive > 0) {
color = debugWindows[w].debugButtons[b].activeColor;
+ }
debugDrawButton(left, top, right, bottom, text, textLeft, textTop, isActive, color);
}
@@ -90,9 +91,7 @@ void Debug::debugDrawWindow(int32 w) {
debugDrawWindowBox(left, top, right, bottom, alpha);
if (debugWindows[w].numLines > 0) {
- int32 l;
-
- for (l = 0; l < debugWindows[w].numLines; l++) {
+ for (int32 l = 0; l < debugWindows[w].numLines; l++) {
_engine->drawText(left + 10, top + l * 20 + 5, debugWindows[w].text[l], 0);
}
}
@@ -103,15 +102,14 @@ void Debug::debugDrawWindow(int32 w) {
}
int32 Debug::debugTypeUseMenu(int32 type) {
- int32 w, b;
-
- for (w = 0; w < numDebugWindows; w++) {
+ for (int32 w = 0; w < numDebugWindows; w++) {
if (debugWindows[w].isActive > 0) {
- for (b = 0; b < debugWindows[w].numButtons; b++) {
+ for (int32 b = 0; b < debugWindows[w].numButtons; b++) {
if (debugWindows[w].debugButtons[b].type == type) {
int submenu = debugWindows[w].debugButtons[b].submenu;
- if (submenu > 0)
+ if (submenu > 0) {
debugWindows[submenu].isActive = !debugWindows[submenu].isActive;
+ }
return submenu;
}
}
@@ -121,10 +119,9 @@ int32 Debug::debugTypeUseMenu(int32 type) {
}
void Debug::debugResetButtonsState() {
- int w, b;
- for (w = 0; w < numDebugWindows; w++) {
+ for (int32 w = 0; w < numDebugWindows; w++) {
if (debugWindows[w].isActive > 0) {
- for (b = 0; b < debugWindows[w].numButtons; b++) {
+ for (int32 b = 0; b < debugWindows[w].numButtons; b++) {
if (debugWindows[w].debugButtons[b].type <= -1)
debugWindows[w].debugButtons[b].isActive = 0;
}
@@ -133,11 +130,9 @@ void Debug::debugResetButtonsState() {
}
void Debug::debugRefreshButtons(int32 type) {
- int32 w, b;
-
- for (w = 0; w < numDebugWindows; w++) {
+ for (int32 w = 0; w < numDebugWindows; w++) {
if (debugWindows[w].isActive > 0) {
- for (b = 0; b < debugWindows[w].numButtons; b++) {
+ for (int32 b = 0; b < debugWindows[w].numButtons; b++) {
if (debugWindows[w].debugButtons[b].type == type) {
int32 left = debugWindows[w].debugButtons[b].left;
int32 top = debugWindows[w].debugButtons[b].top;
@@ -163,9 +158,7 @@ void Debug::debugRefreshButtons(int32 type) {
}
void Debug::debugDrawWindows() {
- int32 w;
-
- for (w = 0; w < numDebugWindows; w++) {
+ for (int32 w = 0; w < numDebugWindows; w++) {
if (debugWindows[w].isActive > 0) {
debugDrawWindow(w);
}
@@ -173,11 +166,9 @@ void Debug::debugDrawWindows() {
}
void Debug::debugResetButton(int32 type) {
- int32 w, b;
-
- for (w = 0; w < numDebugWindows; w++) {
+ for (int32 w = 0; w < numDebugWindows; w++) {
if (debugWindows[w].isActive > 0) {
- for (b = 0; b < debugWindows[w].numButtons; b++) {
+ for (int32 b = 0; b < debugWindows[w].numButtons; b++) {
if (debugWindows[w].debugButtons[b].type == type) {
int submenu = debugWindows[w].debugButtons[b].submenu;
debugWindows[w].debugButtons[b].isActive = 0;
Commit: df75fac95f8b46fa20f610e15171df258f458005
https://github.com/scummvm/scummvm/commit/df75fac95f8b46fa20f610e15171df258f458005
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-16T21:23:04+01:00
Commit Message:
TWINE: removed screenLookupTable
Changed paths:
engines/twine/debug.cpp
engines/twine/gamestate.cpp
engines/twine/grid.cpp
engines/twine/grid.h
engines/twine/interface.cpp
engines/twine/interface.h
engines/twine/menu.cpp
engines/twine/menuoptions.cpp
engines/twine/redraw.cpp
engines/twine/text.cpp
engines/twine/twine.cpp
engines/twine/twine.h
diff --git a/engines/twine/debug.cpp b/engines/twine/debug.cpp
index 23ed4a70ea..7aace2d257 100644
--- a/engines/twine/debug.cpp
+++ b/engines/twine/debug.cpp
@@ -35,9 +35,9 @@
namespace TwinE {
-void Debug::debugFillButton(int32 X, int32 Y, int32 width, int32 height, int8 color) {
- uint8 *ptr = (uint8*)_engine->frontVideoBuffer.getPixels() + _engine->screenLookupTable[Y] + X;
- int32 offset = 640 - width;
+void Debug::debugFillButton(int32 x, int32 y, int32 width, int32 height, int8 color) {
+ uint8 *ptr = (uint8*)_engine->frontVideoBuffer.getBasePtr(x, y);
+ int32 offset = SCREEN_WIDTH - width;
for (int32 i = 0; i < height; i++) {
for (int32 j = 0; j < width; j++) {
diff --git a/engines/twine/gamestate.cpp b/engines/twine/gamestate.cpp
index 193aa9a02c..936200969b 100644
--- a/engines/twine/gamestate.cpp
+++ b/engines/twine/gamestate.cpp
@@ -459,7 +459,7 @@ void GameState::processGameoverAnimation() {
const int32 avg = _engine->_collision->getAverageValue(40000, 3200, 500, _engine->lbaTime - startLbaTime);
const int32 cdot = _engine->_screens->crossDot(1, 1024, 100, (_engine->lbaTime - startLbaTime) % 100);
- _engine->_interface->blitBox(left, top, right, bottom, (int8 *)_engine->workVideoBuffer.getPixels(), 120, 120, (int8 *)_engine->frontVideoBuffer.getPixels());
+ _engine->_interface->blitBox(left, top, right, bottom, _engine->workVideoBuffer, 120, 120, _engine->frontVideoBuffer);
_engine->_renderer->setCameraAngle(0, 0, 0, 0, -cdot, 0, avg);
_engine->_renderer->renderIsoModel(0, 0, 0, 0, 0, 0, gameOverPtr);
_engine->copyBlockPhys(left, top, right, bottom);
@@ -469,7 +469,7 @@ void GameState::processGameoverAnimation() {
}
_engine->_sound->playSample(Samples::Explode, _engine->getRandomNumber(2000) + 3096);
- _engine->_interface->blitBox(left, top, right, bottom, (int8 *)_engine->workVideoBuffer.getPixels(), 120, 120, (int8 *)_engine->frontVideoBuffer.getPixels());
+ _engine->_interface->blitBox(left, top, right, bottom, _engine->workVideoBuffer, 120, 120, _engine->frontVideoBuffer);
_engine->_renderer->setCameraAngle(0, 0, 0, 0, 0, 0, 3200);
_engine->_renderer->renderIsoModel(0, 0, 0, 0, 0, 0, gameOverPtr);
_engine->copyBlockPhys(left, top, right, bottom);
diff --git a/engines/twine/grid.cpp b/engines/twine/grid.cpp
index 39225bfacf..71638ba6b8 100644
--- a/engines/twine/grid.cpp
+++ b/engines/twine/grid.cpp
@@ -51,7 +51,7 @@ Grid::~Grid() {
}
}
-void Grid::copyGridMask(int32 index, int32 x, int32 y, const uint8 *buffer) {
+void Grid::copyGridMask(int32 index, int32 x, int32 y, const Graphics::ManagedSurface& buffer) {
uint8 *ptr = brickMaskTable[index];
int32 left = x + *(ptr + 2);
@@ -106,8 +106,8 @@ void Grid::copyGridMask(int32 index, int32 x, int32 y, const uint8 *buffer) {
}
}
- uint8 *outPtr = (uint8 *)_engine->frontVideoBuffer.getPixels() + _engine->screenLookupTable[absY] + left;
- const uint8 *inPtr = buffer + _engine->screenLookupTable[absY] + left;
+ uint8 *outPtr = (uint8 *)_engine->frontVideoBuffer.getBasePtr(left, absY);
+ const uint8 *inPtr = (const uint8*)buffer.getBasePtr(left, absY);
do {
int32 vc3 = *(ptr++);
@@ -154,7 +154,7 @@ void Grid::drawOverModelActor(int32 x, int32 y, int32 z) {
if (currBrickEntry->posY + 38 > _engine->_interface->textWindowTop && currBrickEntry->posY <= _engine->_interface->textWindowBottom && currBrickEntry->y >= y) {
if (currBrickEntry->x + currBrickEntry->z > z + x) {
- copyGridMask(currBrickEntry->index, (j * 24) - 24, currBrickEntry->posY, (uint8 *)_engine->workVideoBuffer.getPixels());
+ copyGridMask(currBrickEntry->index, (j * 24) - 24, currBrickEntry->posY, _engine->workVideoBuffer);
}
}
}
@@ -171,11 +171,11 @@ void Grid::drawOverSpriteActor(int32 x, int32 y, int32 z) {
if (currBrickEntry->posY + 38 > _engine->_interface->textWindowTop && currBrickEntry->posY <= _engine->_interface->textWindowBottom && currBrickEntry->y >= y) {
if ((currBrickEntry->x == x) && (currBrickEntry->z == z)) {
- copyGridMask(currBrickEntry->index, (j * 24) - 24, currBrickEntry->posY, (uint8 *)_engine->workVideoBuffer.getPixels());
+ copyGridMask(currBrickEntry->index, (j * 24) - 24, currBrickEntry->posY, _engine->workVideoBuffer);
}
if ((currBrickEntry->x > x) || (currBrickEntry->z > z)) {
- copyGridMask(currBrickEntry->index, (j * 24) - 24, currBrickEntry->posY, (uint8 *)_engine->workVideoBuffer.getPixels());
+ copyGridMask(currBrickEntry->index, (j * 24) - 24, currBrickEntry->posY, _engine->workVideoBuffer);
}
}
}
@@ -490,7 +490,7 @@ void Grid::drawBrickSprite(int32 index, int32 posX, int32 posY, const uint8 *ptr
right++;
bottom++;
- uint8 *outPtr = (uint8 *)_engine->frontVideoBuffer.getPixels() + _engine->screenLookupTable[top] + left;
+ uint8 *outPtr = (uint8 *)_engine->frontVideoBuffer.getBasePtr(left, top);
int32 offset = -((right - left) - SCREEN_WIDTH);
diff --git a/engines/twine/grid.h b/engines/twine/grid.h
index ef2351aa4d..a133cd519c 100644
--- a/engines/twine/grid.h
+++ b/engines/twine/grid.h
@@ -26,6 +26,10 @@
#include "common/scummsys.h"
#include "twine/shared.h"
+namespace Graphics {
+class ManagedSurface;
+}
+
namespace TwinE {
/** Block fragment entry */
@@ -128,7 +132,7 @@ private:
* @param y grid Y coordinate
* @param buffer work video buffer
*/
- void copyGridMask(int32 index, int32 x, int32 y, const uint8 *buffer);
+ void copyGridMask(int32 index, int32 x, int32 y, const Graphics::ManagedSurface& buffer);
/** Table with all loaded bricks */
uint8 *brickTable[NUM_BRICKS]{nullptr};
diff --git a/engines/twine/interface.cpp b/engines/twine/interface.cpp
index acd502abfa..c8bd96fc81 100644
--- a/engines/twine/interface.cpp
+++ b/engines/twine/interface.cpp
@@ -21,6 +21,7 @@
*/
#include "twine/interface.h"
+#include "graphics/managed_surface.h"
#include "twine/twine.h"
namespace TwinE {
@@ -112,7 +113,7 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in
endHeight = -endHeight;
}
- out = (uint8*)_engine->frontVideoBuffer.getPixels() + _engine->screenLookupTable[startHeight] + startWidth;
+ out = (uint8*)_engine->frontVideoBuffer.getBasePtr(startWidth, startHeight);
int16 color = currentLineColor;
if (endWidth < endHeight) { // significant slope
@@ -152,9 +153,9 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in
}
}
-void Interface::blitBox(int32 left, int32 top, int32 right, int32 bottom, const int8 *source, int32 leftDest, int32 topDest, int8 *dest) {
- const int8 *s = _engine->screenLookupTable[top] + source + left;
- int8 *d = _engine->screenLookupTable[topDest] + dest + leftDest;
+void Interface::blitBox(int32 left, int32 top, int32 right, int32 bottom, const Graphics::ManagedSurface &source, int32 leftDest, int32 topDest, Graphics::ManagedSurface &dest) {
+ const int8 *s = (const int8 *)source.getBasePtr(left, top);
+ int8 *d = (int8 *)dest.getBasePtr(left, top);
int32 width = right - left + 1;
int32 height = bottom - top + 1;
@@ -202,7 +203,7 @@ void Interface::drawTransparentBox(int32 left, int32 top, int32 right, int32 bot
bottom = SCREEN_TEXTLIMIT_BOTTOM;
}
- uint8 *pos = (uint8*)_engine->frontVideoBuffer.getPixels() + _engine->screenLookupTable[top] + left;
+ uint8 *pos = (uint8*)_engine->frontVideoBuffer.getBasePtr(left, top);
const int32 height = bottom - top;
int32 height2 = height + 1;
const int32 width = right - left + 1;
@@ -245,7 +246,7 @@ void Interface::drawSplittedBox(int32 left, int32 top, int32 right, int32 bottom
// cropping
int32 offset = -((right - left) - SCREEN_WIDTH);
- uint8 *ptr = (uint8*)_engine->frontVideoBuffer.getPixels() + _engine->screenLookupTable[top] + left;
+ uint8 *ptr = (uint8*)_engine->frontVideoBuffer.getBasePtr(left, top);
for (int32 x = top; x < bottom; x++) {
for (int32 y = left; y < right; y++) {
diff --git a/engines/twine/interface.h b/engines/twine/interface.h
index d0e848dba7..269e07229c 100644
--- a/engines/twine/interface.h
+++ b/engines/twine/interface.h
@@ -25,6 +25,10 @@
#include "common/scummsys.h"
+namespace Graphics {
+class ManagedSurface;
+}
+
namespace TwinE {
/** Screen top limit to display the texts */
@@ -75,7 +79,7 @@ public:
* @param topDest start height to draw the button in destination buffer
* @param dest destination screen buffer, in this case front buffer
*/
- void blitBox(int32 left, int32 top, int32 right, int32 bottom, const int8 *source, int32 leftDest, int32 topDest, int8 *dest);
+ void blitBox(int32 left, int32 top, int32 right, int32 bottom, const Graphics::ManagedSurface &source, int32 leftDest, int32 topDest, Graphics::ManagedSurface &dest);
/**
* Draws inside buttons transparent area
diff --git a/engines/twine/menu.cpp b/engines/twine/menu.cpp
index edb51e851b..f09f08266d 100644
--- a/engines/twine/menu.cpp
+++ b/engines/twine/menu.cpp
@@ -221,7 +221,7 @@ void Menu::processPlasmaEffect(int32 left, int32 top, int32 color) {
plasmaEffectRenderFrame();
const uint8 *in = plasmaEffectPtr + 5 * PLASMA_WIDTH;
- uint8 *out = (uint8 *)_engine->frontVideoBuffer.getPixels() + _engine->screenLookupTable[top] + left;
+ uint8 *out = (uint8 *)_engine->frontVideoBuffer.getBasePtr(left, top);
for (int32 y = 0; y < PLASMA_HEIGHT / 2; y++) {
for (int32 x = 0; x < PLASMA_WIDTH; x++) {
@@ -294,7 +294,7 @@ void Menu::drawButtonGfx(const MenuSettings *menuSettings, int32 width, int32 to
}
}
} else {
- _engine->_interface->blitBox(left, top, right, bottom, (const int8 *)_engine->workVideoBuffer.getPixels(), left, top, (int8 *)_engine->frontVideoBuffer.getPixels());
+ _engine->_interface->blitBox(left, top, right, bottom, _engine->workVideoBuffer, left, top, _engine->frontVideoBuffer);
_engine->_interface->drawTransparentBox(left, top, right, bottom, 4);
}
diff --git a/engines/twine/menuoptions.cpp b/engines/twine/menuoptions.cpp
index fab3cf59b5..58d8a51835 100644
--- a/engines/twine/menuoptions.cpp
+++ b/engines/twine/menuoptions.cpp
@@ -137,7 +137,7 @@ void MenuOptions::drawSelectableCharacter(int32 x, int32 y, bool selected) {
if (selected) {
_engine->_interface->drawSplittedBox(left, top, right, bottom, 91);
} else {
- _engine->_interface->blitBox(left, top, right, bottom, (const int8 *)_engine->workVideoBuffer.getPixels(), left, top, (int8 *)_engine->frontVideoBuffer.getPixels());
+ _engine->_interface->blitBox(left, top, right, bottom, _engine->workVideoBuffer, left, top, _engine->frontVideoBuffer);
_engine->_interface->drawTransparentBox(left, top, right, bottom, 4);
}
diff --git a/engines/twine/redraw.cpp b/engines/twine/redraw.cpp
index c6545e7fda..720de77370 100644
--- a/engines/twine/redraw.cpp
+++ b/engines/twine/redraw.cpp
@@ -154,7 +154,7 @@ void Redraw::blitBackgroundAreas() {
const RedrawStruct *currentArea = currentRedrawList;
for (int32 i = 0; i < numOfRedrawBox; i++) {
- _engine->_interface->blitBox(currentArea->left, currentArea->top, currentArea->right, currentArea->bottom, (const int8 *)_engine->workVideoBuffer.getPixels(), currentArea->left, currentArea->top, (int8 *)_engine->frontVideoBuffer.getPixels());
+ _engine->_interface->blitBox(currentArea->left, currentArea->top, currentArea->right, currentArea->bottom, _engine->workVideoBuffer, currentArea->left, currentArea->top, _engine->frontVideoBuffer);
currentArea++;
}
}
@@ -395,7 +395,7 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
addRedrawArea(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, renderRight, renderBottom);
if (actor2->staticFlags.bIsBackgrounded && bgRedraw == 1) {
- _engine->_interface->blitBox(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, renderRight, renderBottom, (const int8 *)_engine->frontVideoBuffer.getPixels(), _engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, (int8 *)_engine->workVideoBuffer.getPixels());
+ _engine->_interface->blitBox(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, renderRight, renderBottom, _engine->frontVideoBuffer, _engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, _engine->workVideoBuffer);
}
}
}
@@ -484,7 +484,7 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
addRedrawArea(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, _engine->_interface->textWindowRight, _engine->_interface->textWindowBottom);
if (actor2->staticFlags.bIsBackgrounded && bgRedraw == 1) {
- _engine->_interface->blitBox(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, _engine->_interface->textWindowRight, _engine->_interface->textWindowBottom, (const int8 *)_engine->frontVideoBuffer.getPixels(), _engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, (int8 *)_engine->workVideoBuffer.getPixels());
+ _engine->_interface->blitBox(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, _engine->_interface->textWindowRight, _engine->_interface->textWindowBottom, _engine->frontVideoBuffer, _engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, _engine->workVideoBuffer);
}
// show clipping area
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 68e3a04e06..c3076a0499 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -162,7 +162,7 @@ void Text::drawCharacter(int32 x, int32 y, uint8 character) { // drawCharacter
const uint8 usedColor = dialTextColor;
- uint8 *screen2 = (uint8 *)_engine->frontVideoBuffer.getPixels() + _engine->screenLookupTable[y] + x;
+ uint8 *screen2 = (uint8 *)_engine->frontVideoBuffer.getBasePtr(x, y);
int32 tempX = x;
int32 tempY = y;
@@ -278,7 +278,7 @@ int32 Text::getTextSize(const char *dialogue) { // SizeFont
}
void Text::initDialogueBox() { // InitDialWindow
- _engine->_interface->blitBox(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom, (const int8 *)_engine->workVideoBuffer.getPixels(), dialTextBoxLeft, dialTextBoxTop, (int8 *)_engine->frontVideoBuffer.getPixels());
+ _engine->_interface->blitBox(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom, _engine->workVideoBuffer, dialTextBoxLeft, dialTextBoxTop, _engine->frontVideoBuffer);
if (newGameVar4 != 0) {
_engine->_menu->drawBox(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom);
@@ -287,11 +287,11 @@ void Text::initDialogueBox() { // InitDialWindow
_engine->copyBlockPhys(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom);
printText8Var3 = 0;
- _engine->_interface->blitBox(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom, (const int8 *)_engine->frontVideoBuffer.getPixels(), dialTextBoxLeft, dialTextBoxTop, (int8 *)_engine->workVideoBuffer.getPixels());
+ _engine->_interface->blitBox(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom, _engine->frontVideoBuffer, dialTextBoxLeft, dialTextBoxTop, _engine->workVideoBuffer);
}
void Text::initInventoryDialogueBox() { // SecondInitDialWindow
- _engine->_interface->blitBox(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom, (const int8 *)_engine->workVideoBuffer.getPixels(), dialTextBoxLeft, dialTextBoxTop, (int8 *)_engine->frontVideoBuffer.getPixels());
+ _engine->_interface->blitBox(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom, _engine->workVideoBuffer, dialTextBoxLeft, dialTextBoxTop, _engine->frontVideoBuffer);
_engine->copyBlockPhys(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom);
printText8Var3 = 0;
}
@@ -525,7 +525,7 @@ int Text::printText10() {
return 0;
}
if (printText8Var6 != 0) {
- _engine->_interface->blitBox(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom, (const int8 *)_engine->workVideoBuffer.getPixels(), dialTextBoxLeft, dialTextBoxTop, (int8 *)_engine->frontVideoBuffer.getPixels());
+ _engine->_interface->blitBox(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom, _engine->workVideoBuffer, dialTextBoxLeft, dialTextBoxTop, _engine->frontVideoBuffer);
_engine->copyBlockPhys(dialTextBoxLeft, dialTextBoxTop, dialTextBoxRight, dialTextBoxBottom);
printText8Var3 = 0;
printText8Var6 = 0;
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index e5a8586b38..794d1c3925 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -265,14 +265,6 @@ void TwinEEngine::allocVideoMemory() {
workVideoBuffer.create(SCREEN_WIDTH, SCREEN_HEIGHT, format);
frontVideoBuffer.create(SCREEN_WIDTH, SCREEN_HEIGHT, format);
- int32 j = 0;
- int32 k = 0;
- for (int32 i = SCREEN_HEIGHT; i > 0; i--) {
- screenLookupTable[j] = k;
- j++;
- k += SCREEN_WIDTH;
- }
-
// initVideoVar1 = -1;
}
diff --git a/engines/twine/twine.h b/engines/twine/twine.h
index 528931bb0a..92795b52e4 100644
--- a/engines/twine/twine.h
+++ b/engines/twine/twine.h
@@ -249,9 +249,6 @@ public:
/** Main game video buffer */
Graphics::ManagedSurface frontVideoBuffer;
- /** temporary screen table */
- int32 screenLookupTable[2000]{0};
-
int32 loopInventoryItem = 0;
int32 loopActorStep = 0;
Commit: b27953f9f75ed7380e15e41993bd963816f76c14
https://github.com/scummvm/scummvm/commit/b27953f9f75ed7380e15e41993bd963816f76c14
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-16T21:23:04+01:00
Commit Message:
TWINE: renamed to lowercase
Changed paths:
engines/twine/renderer.cpp
diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index a0369200eb..1da3391da9 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -83,10 +83,10 @@ void Renderer::setBaseTranslation(int32 x, int32 y, int32 z) {
baseTransPosZ = z;
}
-void Renderer::setOrthoProjection(int32 X, int32 Y, int32 Z) {
- orthoProjX = X;
- orthoProjY = Y;
- orthoProjZ = Z;
+void Renderer::setOrthoProjection(int32 x, int32 y, int32 z) {
+ orthoProjX = x;
+ orthoProjY = y;
+ orthoProjZ = z;
isUsingOrhoProjection = true;
}
Commit: bd3cf292058fd1eab90366c0d32f50a5ebc0b3d9
https://github.com/scummvm/scummvm/commit/bd3cf292058fd1eab90366c0d32f50a5ebc0b3d9
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-16T21:23:04+01:00
Commit Message:
TWINE: reduced code duplication
Changed paths:
engines/twine/renderer.cpp
diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index 1da3391da9..1ab45a0693 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -314,9 +314,10 @@ void Renderer::processTranslatedElement(int32 *targetMatrix, const uint8 *points
dest[i] = baseMatrix[i];
}
} else { // dependent
- destX = computedPoints[(elemPtr->basePoint) / 6].x;
- destY = computedPoints[(elemPtr->basePoint) / 6].y;
- destZ = computedPoints[(elemPtr->basePoint) / 6].z;
+ const int pointsIdx = elemPtr->basePoint / 6;
+ destX = computedPoints[pointsIdx].x;
+ destY = computedPoints[pointsIdx].y;
+ destZ = computedPoints[pointsIdx].z;
const int32 *source = &matricesTable[elemPtr->baseElement / sizeof(int32)];
int32 *dest = targetMatrix;
Commit: e9bb99d3ab722af2d040fcded5474a821b7a5325
https://github.com/scummvm/scummvm/commit/e9bb99d3ab722af2d040fcded5474a821b7a5325
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-16T21:23:04+01:00
Commit Message:
TWINE: Reduced scope + minor cleanup
Changed paths:
engines/twine/interface.cpp
engines/twine/menu.cpp
engines/twine/script_life_v1.cpp
diff --git a/engines/twine/interface.cpp b/engines/twine/interface.cpp
index c8bd96fc81..1527837517 100644
--- a/engines/twine/interface.cpp
+++ b/engines/twine/interface.cpp
@@ -52,7 +52,6 @@ int32 Interface::checkClipping(int32 x, int32 y) {
// TODO: check if Graphics::drawLine() works here
void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, int32 endHeight, int32 lineColor) {
int32 currentLineColor = lineColor;
- uint8 *out;
// draw line from left to right
if (startWidth > endWidth) {
@@ -69,8 +68,8 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in
int32 outcode0 = checkClipping(startWidth, startHeight);
int32 outcode1 = checkClipping(endWidth, endHeight);
- while ((outcode0 | outcode1) != 0) {
- if ((outcode0 & outcode1) != 0 && outcode0 != INSIDE) {
+ while ((outcode0 | outcode1) != INSIDE) {
+ if ((outcode0 & outcode1) != INSIDE && outcode0 != INSIDE) {
return; // Reject lines which are behind one clipping plane
}
@@ -113,7 +112,7 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in
endHeight = -endHeight;
}
- out = (uint8*)_engine->frontVideoBuffer.getBasePtr(startWidth, startHeight);
+ uint8 *out = (uint8*)_engine->frontVideoBuffer.getBasePtr(startWidth, startHeight);
int16 color = currentLineColor;
if (endWidth < endHeight) { // significant slope
diff --git a/engines/twine/menu.cpp b/engines/twine/menu.cpp
index f09f08266d..38e93f6925 100644
--- a/engines/twine/menu.cpp
+++ b/engines/twine/menu.cpp
@@ -1043,7 +1043,7 @@ void Menu::processInventoryMenu() {
if (bx == 3) {
_engine->_text->initInventoryDialogueBox();
- if (_engine->_gameState->gameFlags[inventorySelectedItem] == 1 && !_engine->_gameState->gameFlags[GAMEFLAG_INVENTORY_DISABLED] && inventorySelectedItem < NUM_INVENTORY_ITEMS) {
+ if (inventorySelectedItem < NUM_INVENTORY_ITEMS && _engine->_gameState->gameFlags[inventorySelectedItem] == 1 && !_engine->_gameState->gameFlags[GAMEFLAG_INVENTORY_DISABLED]) {
_engine->_text->initText(inventorySelectedItem + 100);
} else {
_engine->_text->initText(128);
@@ -1065,7 +1065,7 @@ void Menu::processInventoryMenu() {
_engine->_text->initInventoryDialogueBox();
bx = 0;
} else {
- if (_engine->_gameState->gameFlags[inventorySelectedItem] == 1 && !_engine->_gameState->gameFlags[GAMEFLAG_INVENTORY_DISABLED] && inventorySelectedItem < NUM_INVENTORY_ITEMS) {
+ if (inventorySelectedItem < NUM_INVENTORY_ITEMS && _engine->_gameState->gameFlags[inventorySelectedItem] == 1 && !_engine->_gameState->gameFlags[GAMEFLAG_INVENTORY_DISABLED]) {
_engine->_text->initInventoryDialogueBox();
_engine->_text->initText(inventorySelectedItem + 100);
}
@@ -1074,7 +1074,7 @@ void Menu::processInventoryMenu() {
drawItem(inventorySelectedItem);
- if (_engine->_input->toggleActionIfActive(TwinEActionType::UIEnter) && _engine->_gameState->gameFlags[inventorySelectedItem] == 1 && !_engine->_gameState->gameFlags[GAMEFLAG_INVENTORY_DISABLED] && inventorySelectedItem < NUM_INVENTORY_ITEMS) {
+ if (inventorySelectedItem < NUM_INVENTORY_ITEMS && _engine->_input->toggleActionIfActive(TwinEActionType::UIEnter) && _engine->_gameState->gameFlags[inventorySelectedItem] == 1 && !_engine->_gameState->gameFlags[GAMEFLAG_INVENTORY_DISABLED]) {
_engine->loopInventoryItem = inventorySelectedItem;
inventorySelectedColor = 91;
drawItem(inventorySelectedItem);
diff --git a/engines/twine/script_life_v1.cpp b/engines/twine/script_life_v1.cpp
index 9a47d62216..bc8e095734 100644
--- a/engines/twine/script_life_v1.cpp
+++ b/engines/twine/script_life_v1.cpp
@@ -229,9 +229,7 @@ static int32 processLifeConditions(TwinEEngine *engine, LifeScriptContext &ctx)
}
if (!targetActorIdx) {
- int32 heroAngle;
-
- heroAngle = ctx.actor->angle + 0x480 - newAngle + 0x400;
+ int32 heroAngle = ctx.actor->angle + 0x480 - newAngle + 0x400;
heroAngle &= 0x3FF;
if (ABS(heroAngle) > 0x100) {
@@ -241,9 +239,7 @@ static int32 processLifeConditions(TwinEEngine *engine, LifeScriptContext &ctx)
}
} else {
if (engine->_actor->heroBehaviour == HeroBehaviourType::kDiscrete) {
- int32 heroAngle;
-
- heroAngle = ctx.actor->angle + 0x480 - newAngle + 0x400;
+ int32 heroAngle = ctx.actor->angle + 0x480 - newAngle + 0x400;
heroAngle &= 0x3FF;
if (ABS(heroAngle) > 0x100) {
Commit: 207ce744dfb6b4f7fbe55a230cbda4ce2398be7b
https://github.com/scummvm/scummvm/commit/207ce744dfb6b4f7fbe55a230cbda4ce2398be7b
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-16T21:23:04+01:00
Commit Message:
TWINE: renamed member for bitfield
found in lba2remake
Changed paths:
engines/twine/actor.h
engines/twine/scene.cpp
diff --git a/engines/twine/actor.h b/engines/twine/actor.h
index 12f9881d3b..7bd1e2d0da 100644
--- a/engines/twine/actor.h
+++ b/engines/twine/actor.h
@@ -70,7 +70,7 @@ struct StaticFlagsStruct {
uint16 bCanBePushed : 1; // 0x0010
uint16 bComputeLowCollision : 1; // 0x0020
uint16 bCanDrown : 1; // 0x0040
- uint16 bUnk80 : 1; // 0x0080
+ uint16 bComputeCollisionWithFloor : 1; // 0x0080
uint16 bUnk0100 : 1; // 0x0100
uint16 bIsHidden : 1; // 0x0200
uint16 bIsSpriteActor : 1; // 0x0400
diff --git a/engines/twine/scene.cpp b/engines/twine/scene.cpp
index 3557f1c23d..2015176494 100644
--- a/engines/twine/scene.cpp
+++ b/engines/twine/scene.cpp
@@ -65,7 +65,7 @@ void Scene::setActorStaticFlags(int32 actorIdx, uint16 staticFlags) {
_sceneActors[actorIdx].staticFlags.bCanDrown = 1;
}
if (staticFlags & 0x80) {
- _sceneActors[actorIdx].staticFlags.bUnk80 = 1;
+ _sceneActors[actorIdx].staticFlags.bComputeCollisionWithFloor = 1;
}
if (staticFlags & 0x100) {
Commit: 74a8d20e8ed13963b5bf1fb6a622fb04466b2a0e
https://github.com/scummvm/scummvm/commit/74a8d20e8ed13963b5bf1fb6a622fb04466b2a0e
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-16T21:23:04+01:00
Commit Message:
TWINE: resource loading error check
Changed paths:
engines/twine/grid.cpp
diff --git a/engines/twine/grid.cpp b/engines/twine/grid.cpp
index 71638ba6b8..b84dc041fd 100644
--- a/engines/twine/grid.cpp
+++ b/engines/twine/grid.cpp
@@ -431,7 +431,10 @@ bool Grid::initGrid(int32 index) {
}
// load layouts from file
- HQR::getAllocEntry(¤tBll, Resources::HQR_LBA_BLL_FILE, index);
+ if (HQR::getAllocEntry(¤tBll, Resources::HQR_LBA_BLL_FILE, index) == 0) {
+ warning("Failed to load block library index: %i", index);
+ return false;
+ }
loadGridBricks(currentGridSize);
Commit: 6a7d0d63632ef44fc54d39a0a2398d25bed3b6d1
https://github.com/scummvm/scummvm/commit/6a7d0d63632ef44fc54d39a0a2398d25bed3b6d1
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-16T21:23:04+01:00
Commit Message:
TWINE: fixed some missing actor in scene parsing
Changed paths:
engines/twine/scene.cpp
diff --git a/engines/twine/scene.cpp b/engines/twine/scene.cpp
index 2015176494..b31dff4938 100644
--- a/engines/twine/scene.cpp
+++ b/engines/twine/scene.cpp
@@ -171,10 +171,10 @@ bool Scene::loadSceneLBA1() {
act->angle = stream.readUint16LE();
act->speed = stream.readUint16LE();
act->controlMode = (ControlMode)stream.readUint16LE();
- act->info0 = stream.readUint16LE();
- act->info1 = stream.readUint16LE();
- act->info2 = stream.readUint16LE();
- act->info3 = stream.readUint16LE();
+ act->info0 = stream.readSint16LE();
+ act->info1 = stream.readSint16LE();
+ act->info2 = stream.readSint16LE();
+ act->info3 = stream.readSint16LE();
act->followedActor = act->info3;
act->bonusAmount = stream.readByte();
act->talkColor = stream.readByte();
More information about the Scummvm-git-logs
mailing list