[Scummvm-git-logs] scummvm master -> 37ab2d73a68e88718be47f3ba464acf85311aadb
peterkohaut
noreply at scummvm.org
Sat May 7 10:33:07 UTC 2022
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
eccf066b4b TINSEL: Remapping of Noir sysvars
91e2436650 TINSEL: Parsing of cameras & lights
37ab2d73a6 TINSEL: Start of groundplane
Commit: eccf066b4be851e1e5cd699af0955fbf126b69e9
https://github.com/scummvm/scummvm/commit/eccf066b4be851e1e5cd699af0955fbf126b69e9
Author: Peter Kohaut (peter.kohaut at gmail.com)
Date: 2022-05-07T12:30:52+02:00
Commit Message:
TINSEL: Remapping of Noir sysvars
Changed paths:
engines/tinsel/sysvar.h
diff --git a/engines/tinsel/sysvar.h b/engines/tinsel/sysvar.h
index ab10273d79d..efcbfa54ed6 100644
--- a/engines/tinsel/sysvar.h
+++ b/engines/tinsel/sysvar.h
@@ -77,19 +77,29 @@ typedef enum { SV_DEFAULT_INV,
SYS_Platform, // Hardware platform **READ ONLY**
SYS_Debug, // TRUE for debug build/'cheat'**READ ONLY**
- //SV_SPRITER_SCENE_ID = 0x2f // Noir, loaded scene
-
- ISV_DIVERT_ACTOR, // for DW2 = 0x28, for Noir = 0x32
- ISV_NO_BLOCKING,
- ISV_GHOST_ACTOR,
- ISV_GHOST_BASE,
- ISV_GHOST_COLOR,
-
- //SV_SPRITER_SCALE = 0x37 // Noir, scale used for 3D rendering
- //SV_SPRITER_OVERLAY = 0x38 // Noir, if additional model is loaded
+ ISV_DIVERT_ACTOR_T2 = 0x28,
+ ISV_NO_BLOCKING_T2 = 0x29,
+ ISV_GHOST_ACTOR_T2 = 0x2A,
+ ISV_GHOST_BASE_T2 = 0x2B,
+ ISV_GHOST_COLOR_T2 = 0x2C,
+
+ SV_SPRITER_SCENE_ID = 0x2F, // Noir, loaded scene
+ ISV_DIVERT_ACTOR_T3 = 0x32,
+ ISV_NO_BLOCKING_T3 = 0x33,
+ ISV_GHOST_ACTOR_T3 = 0x34,
+ ISV_GHOST_BASE_T3 = 0x35,
+ ISV_GHOST_COLOR_T3 = 0x36,
+ SV_SPRITER_SCALE = 0x37, // Noir, scale used for 3D rendering
+ SV_SPRITER_OVERLAY = 0x38, // Noir, if additional model is loaded
SV_TOPVALID } SYSVARS;
+#define ISV_DIVERT_ACTOR ((TinselVersion == 3) ? ISV_DIVERT_ACTOR_T3 : ISV_DIVERT_ACTOR_T2)
+#define ISV_NO_BLOCKING ((TinselVersion == 3) ? ISV_NO_BLOCKING_T3 : ISV_NO_BLOCKING_T2)
+#define ISV_GHOST_ACTOR ((TinselVersion == 3) ? ISV_GHOST_ACTOR_T3 : ISV_GHOST_ACTOR_T2)
+#define ISV_GHOST_BASE ((TinselVersion == 3) ? ISV_GHOST_BASE_T3 : ISV_GHOST_BASE_T2)
+#define ISV_GHOST_COLOR ((TinselVersion == 3) ? ISV_GHOST_COLOR_T3 : ISV_GHOST_COLOR_T2)
+
typedef enum {
// Main Menu
Commit: 91e2436650ff4a8564dbb06ab874f97236393caf
https://github.com/scummvm/scummvm/commit/91e2436650ff4a8564dbb06ab874f97236393caf
Author: Peter Kohaut (peter.kohaut at gmail.com)
Date: 2022-05-07T12:30:52+02:00
Commit Message:
TINSEL: Parsing of cameras & lights
Changed paths:
engines/tinsel/scene.cpp
engines/tinsel/scene.h
engines/tinsel/tinlib.cpp
diff --git a/engines/tinsel/scene.cpp b/engines/tinsel/scene.cpp
index 9af95d3a091..82fac9e9e9c 100644
--- a/engines/tinsel/scene.cpp
+++ b/engines/tinsel/scene.cpp
@@ -84,7 +84,11 @@ struct SCENE_STRUC {
int32 numProcess; // number of processes in this scene
SCNHANDLE hProcess; // handle to table of processes
SCNHANDLE hMusicScript; // handle to music script data - Tinsel 2 only
- SCNHANDLE hMusicSegment;// handle to music segments - Tinsel 2 only
+ SCNHANDLE hMusicSegment; // handle to music segments - Tinsel 2 only
+ int32 numCameras;
+ SCNHANDLE hCamera;
+ int32 numLights;
+ SCNHANDLE hLight;
} PACKED_STRUCT;
/** entrance structure - one per entrance */
@@ -96,6 +100,25 @@ struct ENTRANCE_STRUC {
uint32 flags;
} PACKED_STRUCT;
+/** camera strucutre, Noir only */
+struct CAMERA_STRUC {
+ int32 sceneId;
+ int32 rotX;
+ int32 rotY;
+ int32 rotZ;
+ int32 posX;
+ int32 posY;
+ int32 posZ;
+ int32 aperture;
+} PACKED_STRUCT;
+
+struct LIGHT_STRUC {
+ int32 sceneId;
+ int32 posX;
+ int32 posY;
+ int32 posZ;
+} PACKED_STRUCT;
+
#include "common/pack-end.h" // END STRUCT PACKING
@@ -114,6 +137,8 @@ static SCNHANDLE g_SceneHandle = 0; // Current scene handle - stored in case of
SCENE_STRUC g_tempStruc;
+static bool g_isViewSet = false;
+
struct TP_INIT {
SCNHANDLE hTinselCode; // Code
TINSEL_EVENT event; // Triggering event
@@ -124,57 +149,77 @@ void ResetVarsScene() {
g_initialMyEscape = 0;
g_SceneHandle = 0;
+ g_isViewSet = false;
memset(&g_tempStruc, 0, sizeof(SCENE_STRUC));
}
-SCENE_STRUC* parseV3Scene(const byte *pStruc) {
- memset(&g_tempStruc, 0, sizeof(SCENE_STRUC));
- Common::MemoryReadStream stream(pStruc, 84);
- g_tempStruc.defRefer = stream.readUint32LE();
- g_tempStruc.hSceneScript = stream.readUint32LE();
- g_tempStruc.hSceneDesc = stream.readUint32LE();
- g_tempStruc.numEntrance = stream.readUint32LE();
- g_tempStruc.hEntrance = stream.readUint32LE();
- stream.readUint32LE();
- stream.readUint32LE();
- stream.readUint32LE();
- stream.readUint32LE();
- g_tempStruc.numPoly = stream.readUint32LE();
- g_tempStruc.hPoly = stream.readUint32LE();
- g_tempStruc.numTaggedActor = stream.readUint32LE();
- g_tempStruc.hTaggedActor = stream.readUint32LE();
- g_tempStruc.numProcess = stream.readUint32LE();
- g_tempStruc.hProcess = stream.readUint32LE();
- g_tempStruc.hMusicScript = stream.readUint32LE();
- g_tempStruc.hMusicSegment = stream.readUint32LE();
- warning("TODO: Complete scene loading logic for Noir");
+SCENE_STRUC* parseSceneV1(const byte *p) {
+ g_tempStruc.numEntrance = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.numPoly = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.numTaggedActor = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.defRefer = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.hSceneScript = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.hEntrance = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.hPoly = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.hTaggedActor = READ_UINT32(p); p += sizeof(uint32);
return &g_tempStruc;
}
-const SCENE_STRUC *GetSceneStruc(const byte *pStruc) {
- if (TinselVersion == 2)
- return (const SCENE_STRUC *)pStruc;
- else if (TinselVersion == 3)
- return parseV3Scene(pStruc);
-
- // Copy appropriate fields into tempStruc, and return a pointer to it
- const byte *p = pStruc;
- memset(&g_tempStruc, 0, sizeof(SCENE_STRUC));
-
+SCENE_STRUC* parseSceneV2(const byte *p) {
+ g_tempStruc.defRefer = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.hSceneScript = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.hSceneDesc = READ_UINT32(p); p += sizeof(uint32);
g_tempStruc.numEntrance = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.hEntrance = READ_UINT32(p); p += sizeof(uint32);
g_tempStruc.numPoly = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.hPoly = READ_UINT32(p); p += sizeof(uint32);
g_tempStruc.numTaggedActor = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.hTaggedActor = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.numProcess = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.hProcess = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.hMusicScript = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.hMusicSegment = READ_UINT32(p); p += sizeof(uint32);
+
+ return &g_tempStruc;
+}
+
+SCENE_STRUC* parseSceneV3(const byte *p) {
g_tempStruc.defRefer = READ_UINT32(p); p += sizeof(uint32);
g_tempStruc.hSceneScript = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.hSceneDesc = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.numEntrance = READ_UINT32(p); p += sizeof(uint32);
g_tempStruc.hEntrance = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.numCameras = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.hCamera = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.numLights = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.hLight = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.numPoly = READ_UINT32(p); p += sizeof(uint32);
g_tempStruc.hPoly = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.numTaggedActor = READ_UINT32(p); p += sizeof(uint32);
g_tempStruc.hTaggedActor = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.numProcess = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.hProcess = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.hMusicScript = READ_UINT32(p); p += sizeof(uint32);
+ g_tempStruc.hMusicSegment = READ_UINT32(p); p += sizeof(uint32);
+ // scollfields scaling/speed - 4 ints
+ warning("TODO: Complete scene loading logic for Noir");
return &g_tempStruc;
}
+const SCENE_STRUC *GetSceneStruc(const byte *pStruc) {
+ memset(&g_tempStruc, 0, sizeof(SCENE_STRUC));
+
+ if (TinselVersion == 3) {
+ return parseSceneV3(pStruc);
+ } else if (TinselVersion == 2) {
+ return parseSceneV2(pStruc);
+ } else {
+ return parseSceneV1(pStruc);
+ }
+}
/**
* Started up for scene script and entrance script.
@@ -423,6 +468,8 @@ void StartNewScene(SCNHANDLE scene, int entry) {
PrimeScene(); // Start up the standard stuff for the next scene.
LoadScene(scene, entry);
+
+ g_isViewSet = false;
}
#ifdef DEBUG
@@ -469,4 +516,57 @@ void WrapScene() {
SendSceneTinselProcess(CLOSEDOWN);
}
+
+
+/**
+ * Set parameters for 3D rendering for Noir.
+ */
+void SetView(int sceneId, int scale) {
+ if (sceneId == SysVar(SV_SPRITER_SCENE_ID)) {
+ if (scale == SysVar(SV_SPRITER_SCALE)) {
+ debug("Ignoring SetView()");
+ return;
+ }
+ }
+ debug("SetView(%d, %d)", sceneId, scale);
+
+ SetSysVar(SV_SPRITER_SCALE, scale);
+ SetSysVar(SV_USER3 ,0x28);
+
+ if (g_isViewSet) {
+ //EndActors();
+ } else {
+ g_isViewSet = true;
+ }
+
+ int i = 0;
+ CAMERA_STRUC *pCamera = (CAMERA_STRUC *)_vm->_handle->LockMem(g_tempStruc.hCamera);
+ for (i = 0; i < g_tempStruc.numCameras; ++i, ++pCamera) {
+ if (sceneId == FROM_32(pCamera->sceneId)) {
+ // set camera
+ SetSysVar(SV_SPRITER_SCENE_ID, sceneId);
+ break;
+ }
+ }
+
+ if (i == g_tempStruc.numCameras) {
+ // no suitable camera found
+ return;
+ }
+
+ LIGHT_STRUC *pLight = (LIGHT_STRUC *)_vm->_handle->LockMem(g_tempStruc.hLight);
+ for (i = 0; i < g_tempStruc.numLights; ++i, ++pLight) {
+ if (sceneId == FROM_32(pLight->sceneId)) {
+ // set light
+ break;
+ }
+ }
+
+ if (i == g_tempStruc.numLights) {
+ // use default light
+ }
+
+ //update ground plane
+}
+
} // End of namespace Tinsel
diff --git a/engines/tinsel/scene.h b/engines/tinsel/scene.h
index 827f76f0a4a..617dc2f94cc 100644
--- a/engines/tinsel/scene.h
+++ b/engines/tinsel/scene.h
@@ -88,6 +88,8 @@ void EndScene();
void SendSceneTinselProcess(TINSEL_EVENT event);
+void SetView(int id, int scale);
+
} // End of namespace Tinsel
#endif // TINSEL_SCENE_H
diff --git a/engines/tinsel/tinlib.cpp b/engines/tinsel/tinlib.cpp
index a7732cf4d8c..c6d14206864 100644
--- a/engines/tinsel/tinlib.cpp
+++ b/engines/tinsel/tinlib.cpp
@@ -6418,7 +6418,7 @@ int CallLibraryRoutine(CORO_PARAM, int operand, int32 *pp, const INT_CONTEXT *pi
case SETVIEW:
// Noir only
pp -= 1;
- warning("TODO: Implement SETVIEW(0x%08X, %i)", pp[0], pp[1]);
+ SetView(pp[0], pp[1]);
return -2;
case SHELL:
Commit: 37ab2d73a68e88718be47f3ba464acf85311aadb
https://github.com/scummvm/scummvm/commit/37ab2d73a68e88718be47f3ba464acf85311aadb
Author: Peter Kohaut (peter.kohaut at gmail.com)
Date: 2022-05-07T12:30:52+02:00
Commit Message:
TINSEL: Start of groundplane
Changed paths:
engines/tinsel/move.cpp
engines/tinsel/polygons.cpp
engines/tinsel/polygons.h
diff --git a/engines/tinsel/move.cpp b/engines/tinsel/move.cpp
index 53ff08e69d0..75366223ad7 100644
--- a/engines/tinsel/move.cpp
+++ b/engines/tinsel/move.cpp
@@ -691,10 +691,35 @@ static void SetMoverDest(MOVER *pActor, int x, int y) {
pActor->targetY = y;
pActor->InDifficulty = NO_PROB;
- reel = GetDirection(pActor->objX, pActor->objY, x, y, pActor->direction, pActor->hCpath);
- scale = GetScale(pActor->hCpath, pActor->objY);
- if (scale != pActor->scale || reel != pActor->direction) {
- SetMoverWalkReel(pActor, reel, scale, false);
+
+ if ((TinselVersion == 3) && pActor->type == MOVER_3D) {
+ // int scale = SysVar(SV_SPRITER_SCALE);
+ // groundplane::Get3Dfrom2D(&pActor->vObj,pActor->objX,pActor->objY);
+ // groundplane::Get3Dfrom2D(&pActor->vTarget,pActor->targetX,pActor->targetY);
+ // targetX = (pActor->vTarget).x;
+ // posX = (pActor->vObj).x;
+ // targetZ = (pActor->vTarget).z;
+ // posZ = (pActor->vObj).z;
+ // int dX = (targetX - posX) / scale;
+ // int dZ = (targetZ - posZ) / scale;
+ // if ((dX != 0) || (dZ != 0)) {
+ // if (dX < 1) {
+ // if (dX < 0) {
+ // fpatan(-(float10)dZ / (float10)dX,(float10)1);
+ // }
+ // }
+ // else {
+ // fpatan((float10)dZ / (float10)dX,(float10)1);
+ // }
+ // direction = (int)(longlong)ROUND(0.5 + *(double *)(local_8 + 0x10));
+ // pActor->direction = direction;
+ // }
+ } else {
+ reel = GetDirection(pActor->objX, pActor->objY, x, y, pActor->direction, pActor->hCpath);
+ scale = GetScale(pActor->hCpath, pActor->objY);
+ if (scale != pActor->scale || reel != pActor->direction) {
+ SetMoverWalkReel(pActor, reel, scale, false);
+ }
}
}
diff --git a/engines/tinsel/polygons.cpp b/engines/tinsel/polygons.cpp
index 4fb6a37410d..0d885d3c967 100644
--- a/engines/tinsel/polygons.cpp
+++ b/engines/tinsel/polygons.cpp
@@ -29,6 +29,10 @@
#include "common/serializer.h"
#include "tinsel/tinsel.h"
#include "tinsel/token.h"
+#include "tinsel/spriter.h"
+#include "tinsel/sysvar.h"
+
+#include "tinsel/background.h"
#include "common/textconsole.h"
#include "common/util.h"
@@ -185,6 +189,10 @@ public:
int32 playfield; // Noir field
int32 sceneId; // Noir field
+ int32 vx[4]; // Noir field, only for scale polygon
+ int32 vy[4]; // Noir field, only for scale polygon
+ int32 vz[4]; // Noir field, only for scale polygon
+
protected:
int32 nodecount; ///<The number of nodes in this polygon
int32 pnodelistx, pnodelisty; ///<offset in chunk to this array if present
@@ -193,10 +201,6 @@ protected:
const int32 *nlistx;
const int32 *nlisty;
- int32 vx[4]; // Noir field, only for scale polygon
- int32 vy[4]; // Noir field, only for scale polygon
- int32 vz[4]; // Noir field, only for scale polygon
-
public:
SCNHANDLE hScript; ///< handle of code segment for polygon events
};
@@ -2428,4 +2432,49 @@ void DisableExit(int exitno) {
}
}
+#if 0
+void drawpolys() {
+ int Loffset, Toffset;
+
+ _vm->_bg->PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset);
+ for (int i = 0; i < noofPolys; ++i) {
+ POLYGON* p = Polys[i];
+ if (volatileStuff[i].bDead) continue;
+ if (p->polyType != PATH) continue;
+ int xoff = volatileStuff[i].xoff - Loffset;
+ int yoff = volatileStuff[i].yoff - Toffset;
+ // if (p->polyType == TAG) {
+
+ uint color = 0xFFFF;
+ _vm->screen().drawLine(xoff + p->cx[0], yoff + p->cy[0], xoff + p->cx[1], yoff + p->cy[1], 0xFFFF);
+ _vm->screen().drawLine(xoff + p->cx[2], yoff + p->cy[2], xoff + p->cx[1], yoff + p->cy[1], 0xFFFF);
+ _vm->screen().drawLine(xoff + p->cx[2], yoff + p->cy[2], xoff + p->cx[3], yoff + p->cy[3], 0xFFFF);
+ _vm->screen().drawLine(xoff + p->cx[0], yoff + p->cy[0], xoff + p->cx[3], yoff + p->cy[3], 0xFFFF);
+ }
+}
+#endif
+
+void UpdateGroundPlane() {
+ int i;
+ for (i = 0; i < noofPolys; ++i) {
+ if (Polys[i]->polyType == SCALE && Polys[i]->polyID == SysVar(SV_SPRITER_SCENE_ID)) {
+ break;
+ }
+ }
+ if (i >= noofPolys) return;
+ //assert(i < noofPolys);// No scale polygon
+
+ POLYGON* pp = Polys[i];
+ Poly ptp(_vm->_handle->LockMem(pHandle), pp->pIndex);
+
+ Vertex2c v[4];
+
+ float scale = SysVar(SV_SPRITER_SCALE);
+ TransformXYZ(ptp.vx[0] * scale, -ptp.vy[0] * scale, -ptp.vz[0] * scale, v[0]);
+ TransformXYZ(ptp.vx[1] * scale, -ptp.vy[1] * scale, -ptp.vz[1] * scale, v[1]);
+ TransformXYZ(ptp.vx[2] * scale, -ptp.vy[2] * scale, -ptp.vz[2] * scale, v[2]);
+ TransformXYZ(ptp.vx[3] * scale, -ptp.vy[3] * scale, -ptp.vz[3] * scale, v[3]);
+ //...
+}
+
} // End of namespace Tinsel
diff --git a/engines/tinsel/polygons.h b/engines/tinsel/polygons.h
index ac18217e06f..83a9f9ace70 100644
--- a/engines/tinsel/polygons.h
+++ b/engines/tinsel/polygons.h
@@ -154,6 +154,8 @@ void MovePolygonTo(PTYPE ptype, int id, int x, int y);
/*-------------------------------------------------------------------------*/
+void UpdateGroundPlane();
+
} // End of namespace Tinsel
#endif /* TINSEL_POLYGONS_H */
More information about the Scummvm-git-logs
mailing list