TWINE: converted c artifacts to c++

This commit is contained in:
Martin Gerhardy 2020-10-21 11:23:09 +02:00 committed by Eugene Sandulenko
parent 859957cbee
commit 7e04efc533
15 changed files with 76 additions and 75 deletions

View File

@ -52,31 +52,31 @@ enum HeroBehaviourType {
};
/** Actors move structure */
typedef struct ActorMoveStruct {
struct ActorMoveStruct {
int16 from = 0;
int16 to = 0;
int16 numOfStep = 0;
int32 timeOfChange = 0;
} ActorMoveStruct;
};
/** Actors zone volumique points structure */
typedef struct ZVPoint {
struct ZVPoint {
int16 bottomLeft = 0;
int16 topRight = 0;
} ZVPoint;
};
/** Actors zone volumique box structure */
typedef struct ZVBox {
struct ZVBox {
ZVPoint x;
ZVPoint y;
ZVPoint z;
} ZVBox;
};
/** Actors animation timer structure */
typedef struct AnimTimerDataStruct {
struct AnimTimerDataStruct {
uint8 *ptr = nullptr;
int32 time = 0;
} AnimTimerDataStruct;
};
enum AnimationTypes {
kAnimNone = -1,
@ -108,7 +108,7 @@ enum AnimationTypes {
};
/** Actors static flags structure */
typedef struct StaticFlagsStruct {
struct StaticFlagsStruct {
uint16 bComputeCollisionWithObj : 1; // 0x0001
uint16 bComputeCollisionWithBricks : 1; // 0x0002
uint16 bIsZonable : 1; // 0x0004
@ -125,10 +125,10 @@ typedef struct StaticFlagsStruct {
uint16 bIsBackgrounded : 1; // 0x2000
uint16 bIsCarrierActor : 1; // 0x4000
uint16 bUseMiniZv : 1; // 0x8000
} StaticFlagsStruct;
};
/** Actors dynamic flags structure */
typedef struct DynamicFlagsStruct {
struct DynamicFlagsStruct {
uint16 bWaitHitFrame : 1; // 0x0001 wait for hit frame
uint16 bIsHitting : 1; // 0x0002 hit frame anim
uint16 bAnimEnded : 1; // 0x0004 anim ended in the current loop (will be looped in the next engine loop)
@ -145,10 +145,10 @@ typedef struct DynamicFlagsStruct {
uint16 bUnk2000 : 1; // 0x2000 unused
uint16 bUnk4000 : 1; // 0x4000 unused
uint16 bUnk8000 : 1; // 0x8000 unused
} DynamicFlagsStruct;
};
/** Actors structure */
typedef struct ActorStruct {
struct ActorStruct {
StaticFlagsStruct staticFlags;
DynamicFlagsStruct dynamicFlags;
@ -213,7 +213,7 @@ typedef struct ActorStruct {
ZVBox boudingBox;
ActorMoveStruct move;
AnimTimerDataStruct animTimerData;
} ActorStruct;
};
class TwinEEngine;

View File

@ -505,10 +505,9 @@ int32 Animations::verifyAnimAtKeyframe(int32 animIdx, uint8 *animPtr, uint8 *bod
return 0;
}
struct _DataReader {
struct DataReader {
uint8 *ptr;
};
typedef struct _DataReader DataReader;
int8 readByte(DataReader *data) {
return *(data->ptr++);

View File

@ -450,7 +450,7 @@ void Debug::debugProcessWindow() {
if (mouseData.left) {
int type = 0;
if ((type = debugProcessButton(mouseData.X, mouseData.Y)) != NO_ACTION) { // process menu item
if ((type = debugProcessButton(mouseData.x, mouseData.y)) != NO_ACTION) { // process menu item
if (debugTypeUseMenu(type)) {
_engine->_screens->copyScreen(_engine->workVideoBuffer, _engine->frontVideoBuffer);
_engine->copyBlockPhys(205, 55, 634, 474);

View File

@ -49,7 +49,7 @@ enum WindowType {
ZONES_MENU
};
typedef struct DebugButtonStruct {
struct DebugButtonStruct {
int32 left = 0;
int32 top = 0;
int32 right = 0;
@ -62,9 +62,9 @@ typedef struct DebugButtonStruct {
int32 activeColor = 0;
int32 submenu = 0;
int32 type = 0;
} DebugButtonStruct;
};
typedef struct DebugWindowStruct {
struct DebugWindowStruct {
int32 left = 0;
int32 top = 0;
int32 right = 0;
@ -75,7 +75,7 @@ typedef struct DebugWindowStruct {
const char *text[20] {0};
int32 numButtons = 0;
DebugButtonStruct debugButtons[50];
} DebugWindowStruct;
};
class TwinEEngine;

View File

@ -30,7 +30,7 @@ namespace TwinE {
#define EXTRA_MAX_ENTRIES 50
typedef struct ExtraListStruct {
struct ExtraListStruct {
int16 info0 = 0; // field_0
int16 x = 0;
int16 y = 0;
@ -51,7 +51,7 @@ typedef struct ExtraListStruct {
int16 actorIdx = 0; // field_ 1C
int16 strengthOfHit = 0; // field_1E
int16 info1 = 0; // field_20
} ExtraListStruct;
};
enum ExtraSpecialType {
kHitStars = 0,

View File

@ -36,7 +36,7 @@ namespace TwinE {
#define FLASCREEN_HEIGHT 200
/** FLA movie header structure */
typedef struct FLAHeaderStruct {
struct FLAHeaderStruct {
/** FLA version */
int8 version[6] {0};
/** Number of frames */
@ -49,20 +49,20 @@ typedef struct FLAHeaderStruct {
int16 xsize = 0;
/** Frame height */
int16 ysize = 0;
} FLAHeaderStruct;
};
/** FLA movie frame structure */
typedef struct FLAFrameDataStruct {
struct FLAFrameDataStruct {
/** Current frame size */
int8 videoSize = 0;
/** Dummy variable */
int8 dummy = 0;
/** Unknown frameVar0 */
int32 frameVar0 = 0;
} FLAFrameDataStruct;
};
/** FLA movie sample structure */
typedef struct FLASampleStruct {
struct FLASampleStruct {
/** Number os samples */
int16 sampleNum = 0;
/** Sample frequency */
@ -75,7 +75,7 @@ typedef struct FLASampleStruct {
uint8 x = 0;
/** Unknown y */
uint8 y = 0;
} FLASampleStruct;
};
/** FLA Frame Opcode types */
enum FlaFrameOpcode {

View File

@ -55,7 +55,7 @@ struct BlockEntry {
uint8 brickBlockIdx = 0;
};
/** Brick entry data */
typedef struct BrickEntry {
struct BrickEntry {
/** Brick X position in screen */
int16 x = 0; //z
/** Brick Y position in screen */
@ -72,7 +72,7 @@ typedef struct BrickEntry {
uint8 shape = 0;
/** Brick sound type */
uint8 sound = 0;
} BrickEntry;
};
/** Total number of bricks allowed in the game */
#define NUM_BRICKS 9000

View File

@ -352,6 +352,8 @@ void Movements::processActorMovements(int32 actorIdx) {
_engine->_animations->initAnim(kHide, 0, 255, actorIdx);
}
break;
case kProtoPack:
break;
}
}

View File

@ -43,7 +43,7 @@ enum OverlayPosType {
};
/** Overlay list structure */
typedef struct OverlayListStruct {
struct OverlayListStruct {
int16 type = 0;
int16 info0 = 0; // sprite/3d model entry | number | number range
int16 x = 0;
@ -51,13 +51,13 @@ typedef struct OverlayListStruct {
int16 info1 = 0; // followed actor | total coins
int16 posType = 0;
int16 lifeTime = 0;
} OverlayListStruct;
};
class TwinEEngine;
class Redraw {
private:
TwinEEngine *_engine;
typedef struct DrawListStruct {
struct DrawListStruct {
int16 posValue = 0;
uint16 index = 0; // field_2
uint16 x = 0;
@ -67,17 +67,17 @@ private:
uint16 field_C = 0;
uint16 field_E = 0;
uint16 field_10 = 0;
} DrawListStruct;
};
/** Draw list array to grab the necessary */
DrawListStruct drawList[150];
typedef struct RedrawStruct {
struct RedrawStruct {
uint16 left = 0;
uint16 top = 0;
uint16 right = 0;
uint16 bottom = 0;
} RedrawStruct;
};
RedrawStruct currentRedrawList[300];
RedrawStruct nextRedrawList[300];

View File

@ -31,19 +31,19 @@ class Renderer {
private:
TwinEEngine *_engine;
typedef struct renderTabEntry {
struct renderTabEntry {
int16 depth = 0;
int16 renderType = 0;
uint8 *dataPtr = nullptr;
} renderTabEntry;
};
typedef struct pointTab {
struct pointTab {
int16 X = 0;
int16 Y = 0;
int16 Z = 0;
} pointTab;
};
typedef struct elementEntry {
struct elementEntry {
int16 firstPoint = 0; // data1
int16 numOfPoints = 0; // data2
int16 basePoint = 0; // data3
@ -58,40 +58,40 @@ private:
int32 y = 0;
int32 field_20 = 0;
int16 field_24 = 0;
} elementEntry;
};
typedef struct lineCoordinates {
struct lineCoordinates {
int32 data = 0;
int16 x1 = 0;
int16 y1 = 0;
int16 x2 = 0;
int16 y2 = 0;
} lineCoordinates;
};
typedef struct lineData {
struct lineData {
int32 data = 0;
int16 p1 = 0;
int16 p2 = 0;
} lineData;
};
typedef struct polyHeader {
struct polyHeader {
uint8 renderType = 0; //FillVertic_AType
uint8 numOfVertex = 0;
int16 colorIndex = 0;
} polyHeader;
};
typedef struct polyVertexHeader {
struct polyVertexHeader {
int16 shadeEntry = 0;
int16 dataOffset = 0;
} polyVertexHeader;
};
typedef struct computedVertex {
struct computedVertex {
int16 shadeValue = 0;
int16 x = 0;
int16 y = 0;
} computedVertex;
};
typedef struct bodyHeaderStruct {
struct bodyHeaderStruct {
int16 bodyFlag = 0;
int16 unk0 = 0;
int16 unk1 = 0;
@ -102,21 +102,21 @@ private:
int16 offsetToData = 0;
int8 *ptrToKeyFrame = nullptr;
int32 keyFrameTime = 0;
} bodyHeaderStruct;
};
typedef struct vertexData {
struct vertexData {
uint8 param = 0;
int16 x = 0;
int16 y = 0;
} vertexData;
};
typedef union packed16 {
union packed16 {
struct {
uint8 al = 0;
uint8 ah = 0;
} bit;
uint16 temp = 0;
} packed16;
};
int32 renderAnimatedModel(uint8 *bodyPtr);
void circleFill(int32 x, int32 y, int32 radius, int8 color);

View File

@ -46,13 +46,13 @@ enum ScenePositionType {
// ZONES
typedef struct ScenePoint {
struct ScenePoint {
int16 x = 0;
int16 y = 0;
int16 z = 0;
} ScenePoint;
};
typedef struct ZoneStruct {
struct ZoneStruct {
ScenePoint bottomLeft;
ScenePoint topRight;
int16 type = 0;
@ -87,7 +87,7 @@ typedef struct ZoneStruct {
} generic;
} infoData;
int16 snap = 0;
} ZoneStruct;
};
enum ZoneType {
kCube = 0, // Change to another scene

View File

@ -54,10 +54,10 @@ static char textStr[256]; // string
1 - Break script */
typedef int32 ScriptLifeFunc(TwinEEngine *engine, int32 actorIdx, ActorStruct *actor);
typedef struct ScriptLifeFunction {
struct ScriptLifeFunction {
const char *name;
ScriptLifeFunc *function;
} ScriptLifeFunction;
};
#define MAPFUNC(name, func) \
{ name, func }

View File

@ -42,10 +42,10 @@ static int32 numRepeatSample = 1;
typedef int32 ScriptMoveFunc(TwinEEngine *engine, int32 actorIdx, ActorStruct *actor);
typedef struct ScriptMoveFunction {
struct ScriptMoveFunction {
const char *name;
ScriptMoveFunc *function;
} ScriptMoveFunction;
};
#define MAPFUNC(name, func) \
{ name, func }

View File

@ -1145,8 +1145,8 @@ void TwinEEngine::drawText(int32 x, int32 y, const char *string, int32 center) {
void TwinEEngine::getMousePositions(MouseStatusStruct *mouseData) {
Common::Point point = g_system->getEventManager()->getMousePos();
mouseData->X = point.x;
mouseData->Y = point.y;
mouseData->x = point.x;
mouseData->y = point.y;
mouseData->left = leftMouse;
mouseData->right = rightMouse;
leftMouse = 0;

View File

@ -72,7 +72,7 @@ static const struct TwinELanguage {
Used in the engine to load/use certain parts of code according with
this settings. Check \a lba.cfg file for valid values for each settings.\n
All the settings with (*) means they are new and only exist in this engine. */
typedef struct ConfigFile {
struct ConfigFile {
/** Index into the LanguageTypes array. */
int32 LanguageId = 0;
/** Index into the LanguageTypes array. */
@ -109,14 +109,14 @@ typedef struct ConfigFile {
int32 SceZoom = 0;
/** Flag to toggle Wall Collision */
int32 WallCollision = 0;
} ConfigFile;
};
typedef struct MouseStatusStruct {
struct MouseStatusStruct {
int32 left = 0;
int32 right = 0;
int32 X = 0;
int32 Y = 0;
} MouseStatusStruct;
int32 x = 0;
int32 y = 0;
};
class Actor;
class Animations;