[Scummvm-git-logs] scummvm master -> c37ab7845ce7951cb8ae131e92be41983171bb86
aquadran
noreply at scummvm.org
Sat Jul 30 22:25:54 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
c37ab7845c ICB: Avoid casting RapAPIObject to memory, cleanup naming, endian fixes
Commit: c37ab7845ce7951cb8ae131e92be41983171bb86
https://github.com/scummvm/scummvm/commit/c37ab7845ce7951cb8ae131e92be41983171bb86
Author: PaweÅ KoÅodziejski (aquadran at gmail.com)
Date: 2022-07-31T00:25:48+02:00
Commit Message:
ICB: Avoid casting RapAPIObject to memory, cleanup naming, endian fixes
Changed paths:
engines/icb/actor_pc.cpp
engines/icb/actor_pc.h
engines/icb/actor_view_pc.cpp
engines/icb/bone.cpp
engines/icb/bone.h
engines/icb/common/px_bitmap_pc.h
engines/icb/gfx/gfxstub_dutch.cpp
engines/icb/gfx/rab_api.cpp
engines/icb/gfx/rab_api.h
engines/icb/gfx/rap_api.h
engines/icb/logic.cpp
engines/icb/remora_pc.cpp
engines/icb/shadow_pc.cpp
engines/icb/shadow_pc.h
engines/icb/softskin_pc.cpp
engines/icb/softskin_pc.h
engines/icb/stagedraw_pc_poly.cpp
diff --git a/engines/icb/actor_pc.cpp b/engines/icb/actor_pc.cpp
index cd433af92ee..49a1d61741b 100644
--- a/engines/icb/actor_pc.cpp
+++ b/engines/icb/actor_pc.cpp
@@ -62,14 +62,14 @@ int32 shadtpc;
// Local prototypes
void drawBboxPC(SVECTOR *scrn, CVECTOR colour);
void drawOutlinePC(SVECTOR *min, SVECTOR *max, CVECTOR colour);
-void DrawModel4PC(rap_API *mrap, int32 poseBone, MATRIXPC *lw, MATRIXPC *local2screen, int32 uvframe, uint32 debug, SVECTOR *bbox, SVECTOR *minbbox, SVECTOR *maxbbox);
+void DrawModel4PC(RapAPI *mrap, int32 poseBone, MATRIXPC *lw, MATRIXPC *local2screen, int32 uvframe, uint32 debug, SVECTOR *bbox, SVECTOR *minbbox, SVECTOR *maxbbox);
// My home grown replacement for the DrawActor routine
// which uses home grown replacement to do the drawing
// and also does the skinning using the co-ordinate animation data
// using soft-skinning specific data
-void DrawActor4PC(psxActor *actor, psxCamera *camera, Bone_Frame *frame, rap_API *mesh, rap_API *pose, rap_API *smesh, PSXrgb *ambient, PSXLampList *lamplist,
+void DrawActor4PC(psxActor *actor, psxCamera *camera, Bone_Frame *frame, RapAPI *mesh, RapAPI *pose, RapAPI *smesh, PSXrgb *ambient, PSXLampList *lamplist,
PSXShadeList *shadelist, int32 nShadows, SVECTORPC *p_n, int32 *p_d, uint32 debug, int32 uvframe, BoneDeformation **boneDeforms, int32 *brightness,
MATRIXPC *local2screen // filled in
) {
@@ -83,7 +83,7 @@ void DrawActor4PC(psxActor *actor, psxCamera *camera, Bone_Frame *frame, rap_API
MATRIXPC bone2actor[MAX_LW_MATRICES];
MatrixHierarchyPC skeleton[MAX_LW_MATRICES];
MATRIXPC *lwPtr;
- BoneLink *bones = rap_API_Object::GetBonePtr(mesh);
+ BoneLink *bones = RapAPIObject::GetBonePtr(mesh);
SVECTOR poseBox[8];
SVECTOR poseMinBox, poseMaxBox;
@@ -517,7 +517,7 @@ void drawOutlinePC(SVECTOR *min, SVECTOR *max, CVECTOR colour) {
}
// New version using soft-skinning specific data-files
-void DrawModel4PC(rap_API *mrap, int32 poseBone, MATRIXPC *lw, MATRIXPC *local2screen, int32 uvframe, uint32 debug, SVECTOR *bbox, SVECTOR *minbbox, SVECTOR *maxbbox) {
+void DrawModel4PC(RapAPI *mrap, int32 poseBone, MATRIXPC *lw, MATRIXPC *local2screen, int32 uvframe, uint32 debug, SVECTOR *bbox, SVECTOR *minbbox, SVECTOR *maxbbox) {
SVECTORPC local[MAX_VECTORS];
SVECTORPC screen[MAX_VECTORS];
@@ -619,11 +619,11 @@ void DrawModel4PC(rap_API *mrap, int32 poseBone, MATRIXPC *lw, MATRIXPC *local2s
// Now go and find the actual polygon data for this primitive
uint32 *polyStart;
uint32 nPolys;
- uint32 *pNormal = rap_API_Object::GetNormalPtr(mrap);
+ uint32 *pNormal = RapAPIObject::GetNormalPtr(mrap);
nPolys = mrap->nFUS3;
if (nPolys != 0) {
- polyStart = rap_API_Object::GetFUS3Ptr(mrap);
+ polyStart = RapAPIObject::GetFUS3Ptr(mrap);
// Do the drawing using internal C based debugging drawing code
if (debug) {
drawFUS3PC(polyStart, nPolys, local);
@@ -633,7 +633,7 @@ void DrawModel4PC(rap_API *mrap, int32 poseBone, MATRIXPC *lw, MATRIXPC *local2s
}
nPolys = mrap->nGUS3;
if (nPolys != 0) {
- polyStart = rap_API_Object::GetGUS3Ptr(mrap);
+ polyStart = RapAPIObject::GetGUS3Ptr(mrap);
// Do the drawing using internal C based debugging drawing code
if (debug) {
drawGUS3PC(polyStart, nPolys, local);
@@ -643,7 +643,7 @@ void DrawModel4PC(rap_API *mrap, int32 poseBone, MATRIXPC *lw, MATRIXPC *local2s
}
nPolys = mrap->nFTS3;
if (nPolys != 0) {
- polyStart = rap_API_Object::GetFTS3Ptr(mrap);
+ polyStart = RapAPIObject::GetFTS3Ptr(mrap);
// Do the drawing using internal C based debugging drawing code
if (debug) {
drawFTS3PC(polyStart, nPolys, local);
@@ -653,7 +653,7 @@ void DrawModel4PC(rap_API *mrap, int32 poseBone, MATRIXPC *lw, MATRIXPC *local2s
}
nPolys = mrap->nGTS3;
if (nPolys != 0) {
- polyStart = rap_API_Object::GetGTS3Ptr(mrap);
+ polyStart = RapAPIObject::GetGTS3Ptr(mrap);
// Do the drawing using internal C based debugging drawing code
if (debug) {
drawGTS3PC(polyStart, nPolys, local);
@@ -663,7 +663,7 @@ void DrawModel4PC(rap_API *mrap, int32 poseBone, MATRIXPC *lw, MATRIXPC *local2s
}
nPolys = mrap->nFUL3;
if (nPolys != 0) {
- polyStart = rap_API_Object::GetFUL3Ptr(mrap);
+ polyStart = RapAPIObject::GetFUL3Ptr(mrap);
// Do the drawing using internal C based debugging drawing code
if (debug) {
drawFUL3PC(polyStart, nPolys, local, (SVECTOR *)pNormal);
@@ -673,7 +673,7 @@ void DrawModel4PC(rap_API *mrap, int32 poseBone, MATRIXPC *lw, MATRIXPC *local2s
}
nPolys = mrap->nGUL3;
if (nPolys != 0) {
- polyStart = rap_API_Object::GetGUL3Ptr(mrap);
+ polyStart = RapAPIObject::GetGUL3Ptr(mrap);
// Do the drawing using internal C based debugging drawing code
if (debug) {
drawGUL3PC(polyStart, nPolys, local, (SVECTOR *)pNormal);
@@ -683,7 +683,7 @@ void DrawModel4PC(rap_API *mrap, int32 poseBone, MATRIXPC *lw, MATRIXPC *local2s
}
nPolys = mrap->nFTL3;
if (nPolys != 0) {
- polyStart = rap_API_Object::GetFTL3Ptr(mrap);
+ polyStart = RapAPIObject::GetFTL3Ptr(mrap);
// Do the drawing using internal C based debugging drawing code
if (debug) {
drawFTL3PC(polyStart, nPolys, local, (SVECTOR *)pNormal);
@@ -693,7 +693,7 @@ void DrawModel4PC(rap_API *mrap, int32 poseBone, MATRIXPC *lw, MATRIXPC *local2s
}
nPolys = mrap->nGTL3;
if (nPolys != 0) {
- polyStart = rap_API_Object::GetGTL3Ptr(mrap);
+ polyStart = RapAPIObject::GetGTL3Ptr(mrap);
// Do the drawing using internal C based debugging drawing code
if (debug) {
drawGTL3PC(polyStart, nPolys, local, (SVECTOR *)pNormal);
@@ -718,8 +718,8 @@ void DrawModel4PC(rap_API *mrap, int32 poseBone, MATRIXPC *lw, MATRIXPC *local2s
deadObject = 0;
}
- uint32 *typePtr = rap_API_Object::GetAnimPolyPtr(mrap);
- polyStart = rap_API_Object::GetAnimPolyFrame(mrap, frm);
+ uint32 *typePtr = RapAPIObject::GetAnimPolyPtr(mrap);
+ polyStart = RapAPIObject::GetAnimPolyFrame(mrap, frm);
for (uint32 t = 0; t < nTypes; t++) {
switch (*typePtr++) { // ++ skips the type field
case HMD_FUS3: {
diff --git a/engines/icb/actor_pc.h b/engines/icb/actor_pc.h
index 7c67d520f48..b6448184bdd 100644
--- a/engines/icb/actor_pc.h
+++ b/engines/icb/actor_pc.h
@@ -44,7 +44,7 @@ namespace ICB {
void ConvertToScreenCoords(SVECTORPC *local, SVECTORPC *screen, int32 nVertices);
void ConvertToScreenCoords(SVECTOR *local, SVECTOR *screen, int32 nVertices);
-void DrawActor4PC(psxActor *actor, psxCamera *camera, Bone_Frame *frame, rap_API *mesh, rap_API *pose, rap_API *smesh, PSXrgb *ambient, PSXLampList *lamplist,
+void DrawActor4PC(psxActor *actor, psxCamera *camera, Bone_Frame *frame, RapAPI *mesh, RapAPI *pose, RapAPI *smesh, PSXrgb *ambient, PSXLampList *lamplist,
PSXShadeList *shadelist, int32 nShadows, SVECTORPC *p_n, int32 *p_d, uint32 debug, int32 uvframe, BoneDeformation **boneDeforms, int32 *brightness,
MATRIXPC *local2screen);
diff --git a/engines/icb/actor_view_pc.cpp b/engines/icb/actor_view_pc.cpp
index e28cea8a42a..2e581ad5d36 100644
--- a/engines/icb/actor_view_pc.cpp
+++ b/engines/icb/actor_view_pc.cpp
@@ -408,13 +408,13 @@ void DrawFrame(const int32 frame) {
sprintf(smesh_name, "mesh_shadow.rap");
uint32 mesh_hash = HashString(mesh_name);
- rap_API *mesh = (rap_API *)rs_anims->Res_open(mesh_name, mesh_hash, cluster_name, cluster_name_hash);
+ RapAPI *mesh = (RapAPI *)rs_anims->Res_open(mesh_name, mesh_hash, cluster_name, cluster_name_hash);
uint32 smesh_hash = HashString(smesh_name);
- rap_API *smesh = (rap_API *)rs_anims->Res_open(smesh_name, smesh_hash, cluster_name, cluster_name_hash);
+ RapAPI *smesh = (RapAPI *)rs_anims->Res_open(smesh_name, smesh_hash, cluster_name, cluster_name_hash);
uint32 pose_hash = HashString(pose_name);
- rap_API *pose = (rap_API *)rs_anims->Res_open(pose_name, pose_hash, cluster_name, cluster_name_hash);
+ RapAPI *pose = (RapAPI *)rs_anims->Res_open(pose_name, pose_hash, cluster_name, cluster_name_hash);
uint32 bone_hash = HashString(bone_name);
- rab_API *rab = (rab_API *)rs_anims->Res_open(bone_name, bone_hash, cluster_name, cluster_name_hash);
+ RabAPI *rab = (RabAPI *)rs_anims->Res_open(bone_name, bone_hash, cluster_name, cluster_name_hash);
ConvertRAP(pose);
ConvertRAP(smesh);
@@ -444,7 +444,7 @@ void DrawFrame(const int32 frame) {
}
// Pass in the linkage file and the bones file
- Bone_Frame *bone_frame = rab->GetFrame(frame);
+ Bone_Frame *bone_frame = RabAPIObject::GetFrame(rab, frame);
int32 brightness;
int32 debug = 1;
diff --git a/engines/icb/bone.cpp b/engines/icb/bone.cpp
index 8b47d5fec6a..adc6ffd844b 100644
--- a/engines/icb/bone.cpp
+++ b/engines/icb/bone.cpp
@@ -103,7 +103,7 @@ void _game_session::UpdateCartridgeCase() {
// for jaw and neck. This sets random
// movement on neck (x,y,z) and random
// movement for jaw (just in x)
-void UpdateTalking(_logic *log, rap_API *rap) {
+void UpdateTalking(_logic *log, RapAPI *rap) {
// check for -1 in rap
if (rap->jawBone == (int8)-1)
Tdebug("bones.txt", "mega %s speaking but has no jaw bone!", log->mega->chr_name);
diff --git a/engines/icb/bone.h b/engines/icb/bone.h
index f81aac37d87..027716d7ac1 100644
--- a/engines/icb/bone.h
+++ b/engines/icb/bone.h
@@ -33,7 +33,7 @@
namespace ICB {
-void UpdateTalking(_logic *log, rap_API *rap);
+void UpdateTalking(_logic *log, RapAPI *rap);
void SetPlayerShotBone(int32 obj_id);
diff --git a/engines/icb/common/px_bitmap_pc.h b/engines/icb/common/px_bitmap_pc.h
index f41272ea540..bd4ccfa47b5 100644
--- a/engines/icb/common/px_bitmap_pc.h
+++ b/engines/icb/common/px_bitmap_pc.h
@@ -58,41 +58,6 @@ typedef struct _pxPCBitmap {
} _pxPCBitmap;
-/*
-// This holds information about a bitmap (which may contain a number of frames).
-class _pxPCBitmap {
-public:
- // Constructor and destructor (don't need to do anything because these items are always created
- // by doing a Res_open and casting a block of memory to this type).
- _pxPCBitmap() { ; }
- ~_pxPCBitmap() { ; }
-
- char id[4]; // "PCB" Pc bitmap
- uint32 schema; // The current schema number
-
- // Gets and sets.
- uint32 Fetch_number_of_items() const { return num_sprites; }
- inline _pxPCSprite *Fetch_item_by_number(uint32 nNumber);
-
- uint8 *Fetch_palette_pointer() { return &palette[0]; }
-
-private:
- uint8 palette[4 * 256]; // RGB but padded with 0 to 32-bits.
- uint32 num_sprites; // Number of sprites in this file.
- uint32 sprite_offsets[1]; // Offsets to sprite data for each sprite.
-
- _pxPCBitmap(const _pxPCBitmap &) { ; }
- void operator=(const _pxPCBitmap &) { ; }
-};
-
-inline _pxPCSprite *_pxPCBitmap::Fetch_item_by_number(uint32 nNumber) {
- // Make sure requested sprite is in the resource.
- assert(nNumber < num_sprites);
-
- // Return the pointer.
- return ((_pxPCSprite *)(((uint8 *)this) + sprite_offsets[nNumber]));
-}*/
-
} // End of namespace ICB
#endif // #ifndef _PX_BITMAP_PC_H_INCLUDED
diff --git a/engines/icb/gfx/gfxstub_dutch.cpp b/engines/icb/gfx/gfxstub_dutch.cpp
index 858c0c2b621..79e58bac246 100644
--- a/engines/icb/gfx/gfxstub_dutch.cpp
+++ b/engines/icb/gfx/gfxstub_dutch.cpp
@@ -28,6 +28,8 @@
#include "engines/icb/gfx/gfxstub_dutch.h"
#include "engines/icb/gfx/gfxstub_rev_dutch.h"
+#include "common/endian.h"
+
namespace ICB {
typedef struct {
@@ -120,7 +122,7 @@ TextureHandle *RegisterTexture(const RevTexture *revInput) {
for (i = 0; i < 9; i++)
th->pRGBA[i] = nullptr;
- if (revInput->palette[0] == 0xDEADBEAF) {
+ if (FROM_LE_32(revInput->palette[0]) == 0xDEADBEAF) {
th->bpp = 4;
th->palette = nullptr;
th->pRGBA[0] = revInput->level[0];
@@ -156,7 +158,7 @@ TextureHandle *RegisterTexture(const RevTexture *revInput) {
th->bpp = 1;
th->palette = new uint32[256];
for (i = 0; i < 256; i++)
- th->palette[i] = revInput->palette[i];
+ th->palette[i] = FROM_LE_32(revInput->palette[i]);
int32 size = th->w * th->h * th->bpp;
for (i = 0; i < 9; i++) {
diff --git a/engines/icb/gfx/rab_api.cpp b/engines/icb/gfx/rab_api.cpp
index 856b7edf5b8..ddad9f2f94f 100644
--- a/engines/icb/gfx/rab_api.cpp
+++ b/engines/icb/gfx/rab_api.cpp
@@ -33,14 +33,14 @@ namespace ICB {
// Decompress the FrameData into the CurrentFrame data storage
// e.g. undo the delta compression or replace the zero ignored
// values with zero
-Bone_Frame *rab_API::GetFrame(const int32 f) {
- Bone_Frame *curFrm = GetCurrentFrame();
+Bone_Frame *RabAPIObject::GetFrame(RabAPI *rab, const int32 f) {
+ Bone_Frame *curFrm = GetCurrentFrame(rab);
Bone_Frame *prevFrm = nullptr;
- if (f != currentFrame) {
+ if (f != rab->currentFrame) {
// Decode and decompress the data from the animation frame into
// the current frame
- FrameData *frm = GetFrameData(f);
+ FrameData *frm = GetFrameData(rab, f);
uint32 b, i;
uint32 nt = frm->nThings;
@@ -48,7 +48,7 @@ Bone_Frame *rab_API::GetFrame(const int32 f) {
// For deltas we need the previous frame
if ((frm->typeSize & DataTypeDeltas) != 0) {
- prevFrm = GetFrame(f - 1);
+ prevFrm = GetFrame(rab, f - 1);
int32 dcvx;
int32 dcvy;
int32 dcvz;
@@ -96,10 +96,18 @@ Bone_Frame *rab_API::GetFrame(const int32 f) {
} else {
b = i;
}
- memcpy(&temp, (data), dataSize);
+ byte *tempSrc = (byte *)data;
+ byte *tempDst = (byte *)&temp;
+ for (int t = 0; t < dataSize; t++) {
+#ifdef SCUMM_LITTLE_ENDIAN
+ tempDst[t] = tempSrc[t];
+#else
+ tempDst[t] = tempSrc[dataSize - t - 1];
+#endif
+ }
// The previous compressed angles
- prevCrot = prevFrm->bones[b].crot;
+ prevCrot = FROM_LE_32(prevFrm->bones[b].crot);
prevVx = (prevCrot >> COMP_VX_SHIFT) & COMP_VX_MASK;
prevVy = (prevCrot >> COMP_VY_SHIFT) & COMP_VY_MASK;
prevVz = (prevCrot >> COMP_VZ_SHIFT) & COMP_VZ_MASK;
@@ -144,7 +152,7 @@ Bone_Frame *rab_API::GetFrame(const int32 f) {
temp |= (curVz << COMP_VZ_SHIFT);
// Store the deltas in the currentFrame structure
- curFrm->bones[b].crot = temp;
+ curFrm->bones[b].crot = TO_LE_32(temp);
data += dataSize;
}
}
@@ -154,20 +162,36 @@ Bone_Frame *rab_API::GetFrame(const int32 f) {
case ALL_ANGLES_32_TYPESIZE: {
for (b = 0; b < nt; b++) {
// The data is not aligned so need to do memcpy
- memcpy(&(curFrm->bones[b].crot), (data), sizeof(CompTriplet));
+ byte *tempSrc = (byte *)data;
+ byte *tempDst = (byte *)&(curFrm->bones[b].crot);
+ for (uint t = 0; t < sizeof(CompTriplet); t++) {
+#ifdef SCUMM_LITTLE_ENDIAN
+ tempDst[t] = tempSrc[t];
+#else
+ tempDst[t] = tempSrc[dataSize - t - 1];
+#endif
+ }
data += ALL_ANGLES_32_BYTE_SIZE;
}
break;
}
case NONZERO_ANGLES_32_TYPESIZE: {
// Zero out the angles first
- for (b = 0; b < nBones; b++) {
- curFrm->bones[b].crot = ZERO_ANGLE;
+ for (b = 0; b < rab->nBones; b++) {
+ curFrm->bones[b].crot = TO_LE_32(ZERO_ANGLE);
}
// Then update the angles which are non-zero
for (i = 0; i < nt; i++) {
b = (int32)(*data);
- memcpy(&(curFrm->bones[b].crot), (data + 1), sizeof(CompTriplet));
+ byte *tempSrc = (byte *)data + 1;
+ byte *tempDst = (byte *)&(curFrm->bones[b].crot);
+ for (uint t = 0; t < sizeof(CompTriplet); t++) {
+#ifdef SCUMM_LITTLE_ENDIAN
+ tempDst[t] = tempSrc[t];
+#else
+ tempDst[t] = tempSrc[dataSize - t - 1];
+#endif
+ }
data += NONZERO_ANGLES_32_BYTE_SIZE;
}
break;
@@ -175,8 +199,11 @@ Bone_Frame *rab_API::GetFrame(const int32 f) {
default: { return nullptr; }
}
}
- curFrm->poseBone = frm->poseBone;
- currentFrame = (uint8)f;
+ curFrm->poseBone.tx = FROM_LE_16(frm->poseBone.tx);
+ curFrm->poseBone.ty = FROM_LE_16(frm->poseBone.ty);
+ curFrm->poseBone.tz = FROM_LE_16(frm->poseBone.tz);
+ curFrm->poseBone.parent = FROM_LE_16(frm->poseBone.parent);
+ rab->currentFrame = (uint8)f;
}
return curFrm;
diff --git a/engines/icb/gfx/rab_api.h b/engines/icb/gfx/rab_api.h
index c0a31ff59c5..9475387ed58 100644
--- a/engines/icb/gfx/rab_api.h
+++ b/engines/icb/gfx/rab_api.h
@@ -143,7 +143,7 @@ typedef struct Bone_Frame {
LinkedMatrix bones[1]; // actually LinkedMatrix rot[nBones]
} Bone_Frame;
-typedef struct rab_API {
+typedef struct {
char id[4];
uint32 schema;
uint16 nFrames;
@@ -155,14 +155,16 @@ typedef struct rab_API {
// byte offsets from start of the file
uint32 frameOffsets[1]; // nFrames of them
+} RabAPI;
- Bone_Frame *GetFrame(const int32 f);
+typedef struct _RabAPIObject {
+ static Bone_Frame *GetFrame(RabAPI *rab, const int32 f);
- Bone_Frame *GetCurrentFrame(void) { return (Bone_Frame *)((uint8 *)(id + currentFrameOffset)); }
+ static Bone_Frame *GetCurrentFrame(RabAPI *rab) { return (Bone_Frame *)((uint8 *)(rab->id + FROM_LE_32(rab->currentFrameOffset))); }
- FrameData *GetFrameData(const int32 f) { return (FrameData *)((uint8 *)(id + frameOffsets[f])); }
+ static FrameData *GetFrameData(RabAPI *rab, const int32 f) { return (FrameData *)((uint8 *)(rab->id + FROM_LE_32(rab->frameOffsets[f]))); }
-} rab_API;
+} RabAPIObject;
// Compress an SVECTOR ( uint16 vx,vy,vz, pad; ) -> uint32
// by dividing the angles (12-bits 0-4095) by four to make them 10-bits
diff --git a/engines/icb/gfx/rap_api.h b/engines/icb/gfx/rap_api.h
index afc1025d19b..a9c3e779f15 100644
--- a/engines/icb/gfx/rap_api.h
+++ b/engines/icb/gfx/rap_api.h
@@ -94,7 +94,7 @@ typedef struct WeightedVertexLink {
// Notice, how poor ANSI C/C++ is at its representation
//
-typedef struct rap_API {
+typedef struct {
char id[4];
uint32 schema;
uint32 platform;
@@ -134,41 +134,41 @@ typedef struct rap_API {
uint32 normalOffset; // in bytes
uint32 boneOffset; // in bytes
Vertex noneLinkData[1]; // Vertex noLinkData[nNone];
-} rap_API;
+} RapAPI;
-class rap_API_Object {
+class RapAPIObject {
public:
- static Vertex *GetNoneLinkPtr(rap_API *rap) { return rap->noneLinkData; }
-
- static VertexLink *GetSingleLinkPtr(rap_API *rap) { return (VertexLink *)(rap->id + rap->singleLinkOffset); }
-
- static WeightedVertexLink *GetMultiLinkPtr(rap_API *rap) { return (WeightedVertexLink *)(rap->id + rap->multiLinkOffset); }
-
- static uint32 *GetFUS3Ptr(rap_API *rap) { return (uint32 *)(rap->id + rap->FUS3offset); }
- static uint32 *GetGUS3Ptr(rap_API *rap) { return (uint32 *)(rap->id + rap->GUS3offset); }
- static uint32 *GetFTS3Ptr(rap_API *rap) { return (uint32 *)(rap->id + rap->FTS3offset); }
- static uint32 *GetGTS3Ptr(rap_API *rap) { return (uint32 *)(rap->id + rap->GTS3offset); }
- static uint32 *GetFUL3Ptr(rap_API *rap) { return (uint32 *)(rap->id + rap->FUL3offset); }
- static uint32 *GetGUL3Ptr(rap_API *rap) { return (uint32 *)(rap->id + rap->GUL3offset); }
- static uint32 *GetFTL3Ptr(rap_API *rap) { return (uint32 *)(rap->id + rap->FTL3offset); }
- static uint32 *GetGTL3Ptr(rap_API *rap) { return (uint32 *)(rap->id + rap->GTL3offset); }
- static uint32 *GetTRI3Ptr(rap_API *rap) { return (uint32 *)(rap->id + rap->TRI3offset); }
- static uint32 *GetNormalPtr(rap_API *rap) { return (uint32 *)(rap->id + rap->normalOffset); }
- static BoneLink *GetBonePtr(rap_API *rap) { return (BoneLink *)(rap->id + rap->boneOffset); }
- static uint32 *GetBoneHashPtr(rap_API *rap) {
+ static Vertex *GetNoneLinkPtr(RapAPI *rap) { return rap->noneLinkData; }
+
+ static VertexLink *GetSingleLinkPtr(RapAPI *rap) { return (VertexLink *)(rap->id + rap->singleLinkOffset); }
+
+ static WeightedVertexLink *GetMultiLinkPtr(RapAPI *rap) { return (WeightedVertexLink *)(rap->id + rap->multiLinkOffset); }
+
+ static uint32 *GetFUS3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->FUS3offset); }
+ static uint32 *GetGUS3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->GUS3offset); }
+ static uint32 *GetFTS3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->FTS3offset); }
+ static uint32 *GetGTS3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->GTS3offset); }
+ static uint32 *GetFUL3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->FUL3offset); }
+ static uint32 *GetGUL3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->GUL3offset); }
+ static uint32 *GetFTL3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->FTL3offset); }
+ static uint32 *GetGTL3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->GTL3offset); }
+ static uint32 *GetTRI3Ptr(RapAPI *rap) { return (uint32 *)(rap->id + rap->TRI3offset); }
+ static uint32 *GetNormalPtr(RapAPI *rap) { return (uint32 *)(rap->id + rap->normalOffset); }
+ static BoneLink *GetBonePtr(RapAPI *rap) { return (BoneLink *)(rap->id + rap->boneOffset); }
+ static uint32 *GetBoneHashPtr(RapAPI *rap) {
BoneLink *bPtr = GetBonePtr(rap);
return (uint32 *)(bPtr + rap->nBones);
}
- static uint32 *GetAnimPolyPtr(rap_API *rap) {
+ static uint32 *GetAnimPolyPtr(RapAPI *rap) {
return (uint32 *)(rap->id + rap->animPolyOffset);
}
- static uint32 *GetAnimPolyFrame(rap_API *rap, int32 frame) {
+ static uint32 *GetAnimPolyFrame(RapAPI *rap, int32 frame) {
return (uint32 *)(rap->id + rap->animPolyOffset + rap->nAnimTypes * 2 * sizeof(uint32) + frame * rap->animPolySize);
}
};
-inline void ConvertRAP(rap_API *rap) {
+inline void ConvertRAP(RapAPI *rap) {
// Do we need to do any conversion ?
if (FROM_LE_32(rap->schema) == RAP_API_SCHEMA)
return;
diff --git a/engines/icb/logic.cpp b/engines/icb/logic.cpp
index 80ff6118d7d..85fdd2fd53a 100644
--- a/engines/icb/logic.cpp
+++ b/engines/icb/logic.cpp
@@ -952,7 +952,7 @@ void _game_session::UpdateMegaFX() {
(speech_info[CONV_ID].state == __SAYING) // are definately saying, not just getting ready to...
) {
// get rap
- rap_API *pose = (rap_API *)rs_anims->Res_open(I->get_pose_name(), I->pose_hash, I->base_path, I->base_path_hash);
+ RapAPI *pose = (RapAPI *)rs_anims->Res_open(I->get_pose_name(), I->pose_hash, I->base_path, I->base_path_hash);
// use it
UpdateTalking(L, pose); // update jaw and neck bone
diff --git a/engines/icb/remora_pc.cpp b/engines/icb/remora_pc.cpp
index 91663de7dcf..8b8e8ea803f 100644
--- a/engines/icb/remora_pc.cpp
+++ b/engines/icb/remora_pc.cpp
@@ -1580,21 +1580,21 @@ void _remora::SetUpSurfaceForBitmap(const char *pcBitmapName, DXrect &sSourceRec
pcFullBitmapName = MakeRemoraGraphicsPath(pcBitmapName);
pBitmap = (_pxBitmap *)rs_remora->Res_open(pcFullBitmapName, nFullBitmapNameHash, m_pcRemoraCluster, m_nRemoraClusterHash);
- if (pBitmap->schema != PC_BITMAP_SCHEMA)
+ if (FROM_LE_32(pBitmap->schema) != PC_BITMAP_SCHEMA)
Fatal_error("Incorrect versions loading [%s] (engine has %d, data has %d", pcFullBitmapName, PC_BITMAP_SCHEMA, pBitmap->schema);
pSprite = (_pxSprite *)((byte *)pBitmap + FROM_LE_32(pBitmap->sprite_offsets[0]));
// Prepare the source/target rectangles for blitting later.
- sSourceRect = MakeRECTFromSpriteSizes(0, 0, pSprite->width, pSprite->height);
- sTargetRect = MakeRECTFromSpriteSizes(pSprite->x, pSprite->y, pSprite->width, pSprite->height);
+ sSourceRect = MakeRECTFromSpriteSizes(0, 0, FROM_LE_32(pSprite->width), FROM_LE_32(pSprite->height));
+ sTargetRect = MakeRECTFromSpriteSizes(FROM_LE_32(pSprite->x), FROM_LE_32(pSprite->y), FROM_LE_32(pSprite->width), FROM_LE_32(pSprite->height));
- nSurfaceID = surface_manager->Create_new_surface(pcBitmapName, pSprite->width, pSprite->height, SYSTEM);
+ nSurfaceID = surface_manager->Create_new_surface(pcBitmapName, FROM_LE_32(pSprite->width), FROM_LE_32(pSprite->height), SYSTEM);
surface_manager->Set_transparent_colour_key(nSurfaceID, g_oIconMenu->GetTransparencyKey());
pSurfaceBitmap = surface_manager->Lock_surface(nSurfaceID);
nPitch = surface_manager->Get_pitch(nSurfaceID);
- SpriteXYFrameDraw(pSurfaceBitmap, nPitch, pSprite->width, pSprite->height, pBitmap, 0, 0, 0, FALSE8, nullptr, 255);
+ SpriteXYFrameDraw(pSurfaceBitmap, nPitch, FROM_LE_32(pSprite->width), FROM_LE_32(pSprite->height), pBitmap, 0, 0, 0, FALSE8, nullptr, 255);
surface_manager->Unlock_surface(nSurfaceID);
}
diff --git a/engines/icb/shadow_pc.cpp b/engines/icb/shadow_pc.cpp
index 0d0344def43..580eb4c9b61 100644
--- a/engines/icb/shadow_pc.cpp
+++ b/engines/icb/shadow_pc.cpp
@@ -46,11 +46,11 @@ int32 st1pc;
int32 st2pc;
int32 st3pc;
-void MakeShadowPC(rap_API *srap, SVECTORPC *local, int32 nVertices, SVECTORPC *p_n, int32 p_d, SVECTORPC *ldir, CVECTOR *lcolour, MATRIXPC *world2screen, MATRIXPC *local2world,
+void MakeShadowPC(RapAPI *srap, SVECTORPC *local, int32 nVertices, SVECTORPC *p_n, int32 p_d, SVECTORPC *ldir, CVECTOR *lcolour, MATRIXPC *world2screen, MATRIXPC *local2world,
int32 debug, SVECTOR *bbox, SVECTOR *minbbox, SVECTOR *maxbbox, int16 xminLocal, int16 xmaxLocal, int16 yminLocal, int16 ymaxLocal, int16 zminLocal,
int16 zmaxLocal);
-void DrawShadow1PC(rap_API *srap, int32 poseBone, MATRIXPC *lw, MATRIXPC *world2screen, MATRIXPC *local2world, int32 nShadows, SVECTORPC *ldirs, CVECTOR *lcolours, SVECTORPC *p_n,
+void DrawShadow1PC(RapAPI *srap, int32 poseBone, MATRIXPC *lw, MATRIXPC *world2screen, MATRIXPC *local2world, int32 nShadows, SVECTORPC *ldirs, CVECTOR *lcolours, SVECTORPC *p_n,
int32 *p_d, int32 debug, SVECTOR **shadowBox, SVECTOR *shadowBoxMin, SVECTOR *shadowBoxMax) {
if (nShadows == 0)
return;
@@ -88,7 +88,7 @@ void DrawShadow1PC(rap_API *srap, int32 poseBone, MATRIXPC *lw, MATRIXPC *world2
}
}
-void MakeShadowPC(rap_API *srap, SVECTORPC *local, int32 nVertices, SVECTORPC *p_n, int32 p_d, SVECTORPC *ldir, CVECTOR *lcolour, MATRIXPC *world2screen, MATRIXPC *local2world,
+void MakeShadowPC(RapAPI *srap, SVECTORPC *local, int32 nVertices, SVECTORPC *p_n, int32 p_d, SVECTORPC *ldir, CVECTOR *lcolour, MATRIXPC *world2screen, MATRIXPC *local2world,
int32 debug, SVECTOR *bbox, SVECTOR *minbbox, SVECTOR *maxbbox, int16 xminLocal, int16 xmaxLocal, int16 yminLocal, int16 ymaxLocal, int16 zminLocal,
int16 zmaxLocal) {
@@ -351,7 +351,7 @@ void MakeShadowPC(rap_API *srap, SVECTORPC *local, int32 nVertices, SVECTORPC *p
nPolys = srap->nTRI3;
if (nPolys != 0) {
- polyStart = rap_API_Object::GetTRI3Ptr(srap);
+ polyStart = RapAPIObject::GetTRI3Ptr(srap);
// Do the drawing using internal C based debugging drawing code
if (debug) {
drawTRI3PC(polyStart, nPolys, pvert);
diff --git a/engines/icb/shadow_pc.h b/engines/icb/shadow_pc.h
index cee6a26b189..ebc12700210 100644
--- a/engines/icb/shadow_pc.h
+++ b/engines/icb/shadow_pc.h
@@ -38,7 +38,7 @@
namespace ICB {
-void DrawShadow1PC(rap_API *srap, int32 poseBone, MATRIXPC *lw, MATRIXPC *world2screen, MATRIXPC *local2world, int32 nShadows, SVECTORPC *ldirs, CVECTOR *lcolours, SVECTORPC *p_n,
+void DrawShadow1PC(RapAPI *srap, int32 poseBone, MATRIXPC *lw, MATRIXPC *world2screen, MATRIXPC *local2world, int32 nShadows, SVECTORPC *ldirs, CVECTOR *lcolours, SVECTORPC *p_n,
int32 *p_d, int32 debug, SVECTOR **shadowBox, SVECTOR *shadowBoxMin, SVECTOR *shadowBoxMax);
} // End of namespace ICB
diff --git a/engines/icb/softskin_pc.cpp b/engines/icb/softskin_pc.cpp
index e3ce1e61ae9..dc28656b69b 100644
--- a/engines/icb/softskin_pc.cpp
+++ b/engines/icb/softskin_pc.cpp
@@ -32,7 +32,7 @@
namespace ICB {
-int32 softskinPC(rap_API *rap, int32 poseBone, MATRIXPC *lw, SVECTORPC *local, int16 *xminLocal, int16 *xmaxLocal, int16 *yminLocal, int16 *ymaxLocal, int16 *zminLocal,
+int32 softskinPC(RapAPI *rap, int32 poseBone, MATRIXPC *lw, SVECTORPC *local, int16 *xminLocal, int16 *xmaxLocal, int16 *yminLocal, int16 *ymaxLocal, int16 *zminLocal,
int16 *zmaxLocal, int32 screenShift) {
// step 1 : make all the local-world and local-screen matrices
// This is done prior to this function
@@ -43,14 +43,14 @@ int32 softskinPC(rap_API *rap, int32 poseBone, MATRIXPC *lw, SVECTORPC *local, i
//
// step 2
- rap_API *pLink = rap;
+ RapAPI *pLink = rap;
uint32 nNone = pLink->nNone;
uint32 nSingle = pLink->nSingle;
uint32 nMulti = pLink->nMultiple;
uint32 i, vIndex;
- Vertex *noneLink = rap_API_Object::GetNoneLinkPtr(rap);
- VertexLink *singleLink = rap_API_Object::GetSingleLinkPtr(rap);
- WeightedVertexLink *multiLink = rap_API_Object::GetMultiLinkPtr(rap);
+ Vertex *noneLink = RapAPIObject::GetNoneLinkPtr(rap);
+ VertexLink *singleLink = RapAPIObject::GetSingleLinkPtr(rap);
+ WeightedVertexLink *multiLink = RapAPIObject::GetMultiLinkPtr(rap);
uint32 prim;
uint32 nVertices = 0;
diff --git a/engines/icb/softskin_pc.h b/engines/icb/softskin_pc.h
index a95af4f8065..c5451696d52 100644
--- a/engines/icb/softskin_pc.h
+++ b/engines/icb/softskin_pc.h
@@ -32,7 +32,7 @@
namespace ICB {
-int32 softskinPC(rap_API *rap, int32 poseBone, MATRIXPC *lw, SVECTORPC *local, int16 *xminLocal, int16 *xmaxLocal, int16 *yminLocal, int16 *ymaxLocal, int16 *zminLocal,
+int32 softskinPC(RapAPI *rap, int32 poseBone, MATRIXPC *lw, SVECTORPC *local, int16 *xminLocal, int16 *xmaxLocal, int16 *yminLocal, int16 *ymaxLocal, int16 *zminLocal,
int16 *zmaxLocal, int32 screenShift);
} // End of namespace ICB
diff --git a/engines/icb/stagedraw_pc_poly.cpp b/engines/icb/stagedraw_pc_poly.cpp
index b3bb9e2db3d..ab72032894f 100644
--- a/engines/icb/stagedraw_pc_poly.cpp
+++ b/engines/icb/stagedraw_pc_poly.cpp
@@ -171,11 +171,11 @@ void OpenTexture(const char *tex_name, uint32 tex_hash, const char *pal_name, ui
revtex_API *rTexAPI = (revtex_API *)rs_anims->Res_open(tex_name, tex_hash, base, base_hash);
// Check the texture file is correct ID & schema
- if ((*(uint32 *)rTexAPI->id) != (*(uint32 *)const_cast<char *>(REVTEX_API_ID)))
+ if (READ_LE_UINT32((uint32 *)rTexAPI->id) != (*(uint32 *)const_cast<char *>(REVTEX_API_ID)))
Fatal_error("Invalid revtex_API id file %s API %s in file %s", rTexAPI->id, REVTEX_API_ID, tex_name);
- if (rTexAPI->schema != REVTEX_API_SCHEMA)
- Fatal_error("Invalid revtex_API file schema file %d API %d in file %s", rTexAPI->schema, REVTEX_API_SCHEMA, tex_name);
+ if (FROM_LE_32(rTexAPI->schema) != REVTEX_API_SCHEMA)
+ Fatal_error("Invalid revtex_API file schema file %d API %d in file %s", FROM_LE_32(rTexAPI->schema), REVTEX_API_SCHEMA, tex_name);
// Load the palette (it might be the same file !)
revtex_API *rPalAPI = (revtex_API *)rs_anims->Res_open(pal_name, pal_hash, base, base_hash);
@@ -183,11 +183,11 @@ void OpenTexture(const char *tex_name, uint32 tex_hash, const char *pal_name, ui
// Is the palette different ?
if (rPalAPI != rTexAPI) {
// It's different !
- if ((*(uint32 *)rPalAPI->id) != (*(uint32 *)const_cast<char *>(REVTEX_API_ID)))
+ if ((READ_LE_UINT32((uint32 *)rPalAPI->id)) != (*(uint32 *)const_cast<char *>(REVTEX_API_ID)))
Fatal_error("Invalid revtex_API id file %s API %s in file %s", rTexAPI->id, REVTEX_API_ID, pal_name);
- if (rPalAPI->schema != REVTEX_API_SCHEMA)
- Fatal_error("Invalid revtex_API file schema file %d API %d in file %s", rTexAPI->schema, REVTEX_API_SCHEMA, pal_name);
+ if (FROM_LE_32(rPalAPI->schema) != REVTEX_API_SCHEMA)
+ Fatal_error("Invalid revtex_API file schema file %d API %d in file %s", FROM_LE_32(rTexAPI->schema), REVTEX_API_SCHEMA, pal_name);
// Copy the palette into the texture
memcpy(rTexAPI->palette, rPalAPI->palette, 256 * sizeof(uint32));
@@ -196,10 +196,10 @@ void OpenTexture(const char *tex_name, uint32 tex_hash, const char *pal_name, ui
// Set up RevTexture structure
RevTexture revTex;
revTex.palette = rTexAPI->palette;
- revTex.width = rTexAPI->width;
- revTex.height = rTexAPI->height;
+ revTex.width = FROM_LE_32(rTexAPI->width);
+ revTex.height = FROM_LE_32(rTexAPI->height);
for (int32 i = 0; i < 9; i++) {
- revTex.level[i] = (uint8 *)rTexAPI + rTexAPI->levelOffset[i];
+ revTex.level[i] = (uint8 *)rTexAPI + FROM_LE_32(rTexAPI->levelOffset[i]);
}
// Register the texture
@@ -248,10 +248,10 @@ void PreRegisterTexture(const char *tex_name, uint32 tex_hash, const char *pal_n
void drawObjects(SDactor &act, PSXLampList &lamplist, PSXrgb *pAmbient, PSXShadeList &shadelist, MATRIXPC *local2screen, int32 *brightnessReturn) {
psxActor &actor = act.psx_actor;
- rap_API *mesh;
- rap_API *smesh;
- rap_API *pose;
- rab_API *bones;
+ RapAPI *mesh;
+ RapAPI *smesh;
+ RapAPI *pose;
+ RabAPI *bones;
_vox_image *&vox = act.log->voxel_info;
_mega *&mega = act.log->mega;
@@ -276,92 +276,92 @@ void drawObjects(SDactor &act, PSXLampList &lamplist, PSXrgb *pAmbient, PSXShade
}
// Load the POSE
- pose = (rap_API *)rs_anims->Res_open(poseName, poseHash, vox->base_path, vox->base_path_hash);
+ pose = (RapAPI *)rs_anims->Res_open(poseName, poseHash, vox->base_path, vox->base_path_hash);
ConvertRAP(pose);
// check the pose data
- if (*(int32 *)pose->id != *(int32 *)const_cast<char *>(RAP_API_ID))
+ if (READ_LE_INT32((int32 *)pose->id) != *(int32 *)const_cast<char *>(RAP_API_ID))
Fatal_error("Pose Invalid rap ID rap_api.h %s file:%s file:%s", pose->id, RAP_API_ID, poseName);
if (pose->schema != RAP_API_SCHEMA)
Fatal_error("Wrong rap schema value file %d api %d file:%s", pose->schema, RAP_API_SCHEMA, poseName);
// Load the MESH
- mesh = (rap_API *)rs_anims->Res_open(vox->mesh_name, vox->mesh_hash, vox->base_path, vox->base_path_hash);
+ mesh = (RapAPI *)rs_anims->Res_open(vox->mesh_name, vox->mesh_hash, vox->base_path, vox->base_path_hash);
ConvertRAP(mesh);
// check the mesh data
- if (*(int32 *)mesh->id != *(int32 *)const_cast<char *>(RAP_API_ID))
+ if (READ_LE_INT32((int32 *)mesh->id) != *(int32 *)const_cast<char *>(RAP_API_ID))
Fatal_error("Mesh Invalid rap ID rap_api.h %s file:%s file:%s", mesh->id, RAP_API_ID, vox->mesh_name);
if (mesh->schema != RAP_API_SCHEMA)
Fatal_error("Mesh rap schema value file %d api %d file:%s", mesh->schema, RAP_API_SCHEMA, vox->mesh_name);
// Load the SHADOW MESH
- smesh = (rap_API *)rs_anims->Res_open(vox->shadow_mesh_name, vox->shadow_mesh_hash, vox->base_path, vox->base_path_hash);
+ smesh = (RapAPI *)rs_anims->Res_open(vox->shadow_mesh_name, vox->shadow_mesh_hash, vox->base_path, vox->base_path_hash);
ConvertRAP(smesh);
// check the shadow mesh data
- if (*(int32 *)smesh->id != *(int32 *)const_cast<char *>(RAP_API_ID))
+ if (READ_LE_INT32((int32 *)smesh->id) != *(int32 *)const_cast<char *>(RAP_API_ID))
Fatal_error("Mesh Invalid rap ID rap_api.h %s file:%s file:%s", smesh->id, RAP_API_ID, vox->shadow_mesh_name);
if (smesh->schema != RAP_API_SCHEMA)
Fatal_error("Mesh rap schema value file %d api %d file:%s", smesh->schema, RAP_API_SCHEMA, vox->shadow_mesh_name);
// Load the BONES
- bones = (rab_API *)rs_anims->Res_open(vox->anim_name[act.log->cur_anim_type], vox->anim_name_hash[act.log->cur_anim_type], vox->base_path, vox->base_path_hash);
+ bones = (RabAPI *)rs_anims->Res_open(vox->anim_name[act.log->cur_anim_type], vox->anim_name_hash[act.log->cur_anim_type], vox->base_path, vox->base_path_hash);
// check the bones...
- if (*(int32 *)bones->id != *(int32 *)const_cast<char *>(RAB_API_ID))
+ if (READ_LE_INT32((int32 *)bones->id) != *(int32 *)const_cast<char *>(RAB_API_ID))
Fatal_error("Bones Invalid rab ID rab_api.h %s file:%s file:%s", bones->id, RAB_API_ID, vox->anim_name[act.log->cur_anim_type]);
if (bones->schema != RAB_API_SCHEMA)
Fatal_error("Bones rab schema value file %d api %d file:%s", bones->schema, RAB_API_SCHEMA, vox->anim_name[act.log->cur_anim_type]);
// Check the data is all in still and resman has settled.
- if (*(int32 *)mesh->id != *(int32 *)const_cast<char *>(RAP_API_ID)) {
- mesh = (rap_API *)rs_anims->Res_open(vox->mesh_name, vox->mesh_hash, vox->base_path, vox->base_path_hash);
+ if (READ_LE_INT32((int32 *)mesh->id) != *(int32 *)const_cast<char *>(RAP_API_ID)) {
+ mesh = (RapAPI *)rs_anims->Res_open(vox->mesh_name, vox->mesh_hash, vox->base_path, vox->base_path_hash);
ConvertRAP(mesh);
}
- if (*(int32 *)smesh->id != *(int32 *)const_cast<char *>(RAP_API_ID)) {
- smesh = (rap_API *)rs_anims->Res_open(vox->shadow_mesh_name, vox->shadow_mesh_hash, vox->base_path, vox->base_path_hash);
+ if (READ_LE_INT32((int32 *)smesh->id) != *(int32 *)const_cast<char *>(RAP_API_ID)) {
+ smesh = (RapAPI *)rs_anims->Res_open(vox->shadow_mesh_name, vox->shadow_mesh_hash, vox->base_path, vox->base_path_hash);
ConvertRAP(smesh);
}
- if (*(int32 *)bones->id != *(int32 *)const_cast<char *>(RAB_API_ID)) {
- bones = (rab_API *)rs_anims->Res_open(vox->anim_name[act.log->cur_anim_type], vox->anim_name_hash[act.log->cur_anim_type], vox->base_path, vox->base_path_hash);
+ if (READ_LE_INT32((int32 *)bones->id) != *(int32 *)const_cast<char *>(RAB_API_ID)) {
+ bones = (RabAPI *)rs_anims->Res_open(vox->anim_name[act.log->cur_anim_type], vox->anim_name_hash[act.log->cur_anim_type], vox->base_path, vox->base_path_hash);
}
- if (*(int32 *)pose->id != *(int32 *)const_cast<char *>(RAP_API_ID)) {
- pose = (rap_API *)rs_anims->Res_open(poseName, poseHash, vox->base_path, vox->base_path_hash);
+ if (READ_LE_INT32((int32 *)pose->id) != *(int32 *)const_cast<char *>(RAP_API_ID)) {
+ pose = (RapAPI *)rs_anims->Res_open(poseName, poseHash, vox->base_path, vox->base_path_hash);
ConvertRAP(pose);
}
- if (*(int32 *)mesh->id != *(int32 *)const_cast<char *>(RAP_API_ID)) {
- mesh = (rap_API *)rs_anims->Res_open(vox->mesh_name, vox->mesh_hash, vox->base_path, vox->base_path_hash);
+ if (READ_LE_INT32((int32 *)mesh->id) != *(int32 *)const_cast<char *>(RAP_API_ID)) {
+ mesh = (RapAPI *)rs_anims->Res_open(vox->mesh_name, vox->mesh_hash, vox->base_path, vox->base_path_hash);
ConvertRAP(mesh);
}
- if (*(int32 *)smesh->id != *(int32 *)const_cast<char *>(RAP_API_ID)) {
- smesh = (rap_API *)rs_anims->Res_open(vox->shadow_mesh_name, vox->shadow_mesh_hash, vox->base_path, vox->base_path_hash);
+ if (READ_LE_INT32((int32 *)smesh->id) != *(int32 *)const_cast<char *>(RAP_API_ID)) {
+ smesh = (RapAPI *)rs_anims->Res_open(vox->shadow_mesh_name, vox->shadow_mesh_hash, vox->base_path, vox->base_path_hash);
ConvertRAP(smesh);
}
- if (*(int32 *)bones->id != *(int32 *)const_cast<char *>(RAB_API_ID)) {
- bones = (rab_API *)rs_anims->Res_open(vox->anim_name[act.log->cur_anim_type], vox->anim_name_hash[act.log->cur_anim_type], vox->base_path, vox->base_path_hash);
+ if (READ_LE_INT32((int32 *)bones->id) != *(int32 *)const_cast<char *>(RAB_API_ID)) {
+ bones = (RabAPI *)rs_anims->Res_open(vox->anim_name[act.log->cur_anim_type], vox->anim_name_hash[act.log->cur_anim_type], vox->base_path, vox->base_path_hash);
}
- if (*(int32 *)pose->id != *(int32 *)const_cast<char *>(RAP_API_ID)) {
- pose = (rap_API *)rs_anims->Res_open(poseName, poseHash, vox->base_path, vox->base_path_hash);
+ if (READ_LE_INT32((int32 *)pose->id) != *(int32 *)const_cast<char *>(RAP_API_ID)) {
+ pose = (RapAPI *)rs_anims->Res_open(poseName, poseHash, vox->base_path, vox->base_path_hash);
ConvertRAP(pose);
}
// FINAL CHECKS
- if (*(int32 *)mesh->id != *(int32 *)const_cast<char *>(RAP_API_ID))
+ if (READ_LE_INT32((int32 *)mesh->id) != *(int32 *)const_cast<char *>(RAP_API_ID))
Fatal_error("Failed to get MESH %s settled within Resman", vox->mesh_name);
- if (*(int32 *)smesh->id != *(int32 *)const_cast<char *>(RAP_API_ID))
+ if (READ_LE_INT32((int32 *)smesh->id) != *(int32 *)const_cast<char *>(RAP_API_ID))
Fatal_error("Failed to get SHADOW MESH %s settled within Resman", vox->shadow_mesh_name);
- if (*(int32 *)bones->id != *(int32 *)const_cast<char *>(RAB_API_ID))
+ if (READ_LE_INT32((int32 *)bones->id) != *(int32 *)const_cast<char *>(RAB_API_ID))
Fatal_error("Failed to get BONES %s settled within Resman", vox->anim_name[act.log->cur_anim_type]);
- if (*(int32 *)pose->id != *(int32 *)const_cast<char *>(RAP_API_ID))
+ if (READ_LE_INT32((int32 *)pose->id) != *(int32 *)const_cast<char *>(RAP_API_ID))
Fatal_error("Failed to get POSE %s settled within Resman", poseName);
// FINISHED LOADING
// Turn this code back after the demo
- if (act.frame >= bones->nFrames) {
+ if (FROM_LE_32(act.frame) >= FROM_LE_16(bones->nFrames)) {
Fatal_error("stagedraw_pc_poly Illegal frame %d bones %d anim %s", act.frame, bones->nFrames, vox->anim_name[act.log->cur_anim_type]);
}
@@ -371,7 +371,7 @@ void drawObjects(SDactor &act, PSXLampList &lamplist, PSXrgb *pAmbient, PSXShade
Bone_Frame *frame;
- frame = bones->GetFrame(f);
+ frame = RabAPIObject::GetFrame(bones, f);
selFace = 65535;
More information about the Scummvm-git-logs
mailing list