ICB: Reworked some global constructors

This commit is contained in:
Paweł Kołodziejski 2021-03-13 17:34:02 +01:00
parent b75a34e179
commit e69d636329
19 changed files with 228 additions and 167 deletions

View File

@ -64,15 +64,11 @@ extern int32 texturesUsedThisCycle;
uint32 auto_anim = 2;
// Camera and animation structures
psxCamera camera;
PXanim *pxanim;
SVECTOR rot; // Actor rotation
SVECTOR _crot; // Camera rotation
int32 uvframe = 0;
// Actor structure
psxActor av_actor;
// Global filename stuff
char cluster_name[32];
uint32 cluster_name_hash;
@ -92,7 +88,6 @@ int32 g_repeats;
bool8 g_av_userControlled = FALSE8;
// Lighting structure and coordinates, colour components
PSXLamp av_Light;
int16 av_LightX;
int16 av_LightY;
int16 av_LightZ;
@ -368,7 +363,7 @@ void DrawFrame(const int32 frame) {
PSXShadeList the_shades;
the_lights.n = 1;
the_lights.states[0] = 0;
the_lights.lamps[0] = (PSXLamp *)(&av_Light);
the_lights.lamps[0] = g_av_Light;
the_shades.n = 0;
// Open the animation file
@ -385,11 +380,11 @@ void DrawFrame(const int32 frame) {
PXFrameEnOfAnim(framenum, pxanim)->markers[ORG_POS];
// Make the actors orientation matrix
av_actor.rot = rot;
av_actor.rot.vy = (int16)(av_actor.rot.vy);
g_av_actor->rot = rot;
g_av_actor->rot.vy = (int16)(g_av_actor->rot.vy);
// Make the root local-world matrix
RotMatrix_gte(&av_actor.rot, &av_actor.lw);
RotMatrix_gte(&g_av_actor->rot, &g_av_actor->lw);
// Need to use marker to get correct actor height (making crouch look correct)
PXframe *frm = PXFrameEnOfAnim(framenum, pxanim);
@ -398,15 +393,15 @@ void DrawFrame(const int32 frame) {
marker.GetXYZ(&mposx, &mposy, &mposz);
int32 dy = (int32)mposy;
av_actor.lw.t[0] = 0;
av_actor.lw.t[1] = dy - 112;
av_actor.lw.t[2] = 0;
g_av_actor->lw.t[0] = 0;
g_av_actor->lw.t[1] = dy - 112;
g_av_actor->lw.t[2] = 0;
// Set the true rotation & position values from the ORG marker
av_actor.truePos.x = 0;
av_actor.truePos.y = dy - 112;
av_actor.truePos.z = 0;
av_actor.trueRot = av_actor.rot;
g_av_actor->truePos.x = 0;
g_av_actor->truePos.y = dy - 112;
g_av_actor->truePos.z = 0;
g_av_actor->trueRot = g_av_actor->rot;
sprintf(pose_name, "%s\\pose.rap", weapon_name);
sprintf(bone_name, "%s\\%s.rab", weapon_name, anim_name);
@ -474,35 +469,35 @@ void DrawFrame(const int32 frame) {
MATRIXPC local2screen; // not really bothered about this...
// Drawing finally
DrawActor4PC(&av_actor, &camera, bone_frame, mesh, pose, smesh, &ambient, &the_lights, &the_shades, nShadows, p_n, p_d, debug, uvframe, myBones, &brightness,
DrawActor4PC(g_av_actor, g_camera, bone_frame, mesh, pose, smesh, &ambient, &the_lights, &the_shades, nShadows, p_n, p_d, debug, uvframe, myBones, &brightness,
&local2screen);
uvframe++;
}
void MakeCameraView() {
RotMatrix_gte(&_crot, &camera.view);
RotMatrix_gte(&_crot, &g_camera->view);
// Include the x,y,z scalings
camera.view.m[0][0] = (int16)(camera.view.m[0][0] * 1);
camera.view.m[0][1] = (int16)(camera.view.m[0][1] * 1);
camera.view.m[0][2] = (int16)(camera.view.m[0][2] * 1);
camera.view.m[1][0] = (int16)(camera.view.m[1][0] * 1);
camera.view.m[1][1] = (int16)(camera.view.m[1][1] * 1);
camera.view.m[1][2] = (int16)(camera.view.m[1][2] * 1);
camera.view.m[2][0] = (int16)(camera.view.m[2][0] * 4);
camera.view.m[2][1] = (int16)(camera.view.m[2][1] * 4);
camera.view.m[2][2] = (int16)(camera.view.m[2][2] * 4);
g_camera->view.m[0][0] = (int16)(g_camera->view.m[0][0] * 1);
g_camera->view.m[0][1] = (int16)(g_camera->view.m[0][1] * 1);
g_camera->view.m[0][2] = (int16)(g_camera->view.m[0][2] * 1);
g_camera->view.m[1][0] = (int16)(g_camera->view.m[1][0] * 1);
g_camera->view.m[1][1] = (int16)(g_camera->view.m[1][1] * 1);
g_camera->view.m[1][2] = (int16)(g_camera->view.m[1][2] * 1);
g_camera->view.m[2][0] = (int16)(g_camera->view.m[2][0] * 4);
g_camera->view.m[2][1] = (int16)(g_camera->view.m[2][1] * 4);
g_camera->view.m[2][2] = (int16)(g_camera->view.m[2][2] * 4);
}
void ResetCamera() {
_crot.vx = (4096 * 180) / 360;
_crot.vy = (4096 * -30) / 360;
_crot.vz = 0;
camera.view.t[0] = 170 + av_x;
camera.view.t[1] = 0 + av_y;
camera.view.t[2] = 1800 + av_z;
camera.focLen = 619 * 4;
g_camera->view.t[0] = 170 + av_x;
g_camera->view.t[1] = 0 + av_y;
g_camera->view.t[2] = 1800 + av_z;
g_camera->focLen = 619 * 4;
MakeCameraView();
}
@ -514,25 +509,25 @@ void ResetActor() {
}
void InitLight() {
av_Light.nStates = 1; // One state
av_Light.w = 0; // Zero width
av_Light.b = 0; // Zero bounce
av_Light.anu = 0; // Don't use it
av_Light.type = OMNI_LIGHT; // OMNI
av_Light.ba = 0; // Means nothing for an OMNI
av_Light.bs = 0; // Means nothing for an OMNI
g_av_Light->nStates = 1; // One state
g_av_Light->w = 0; // Zero width
g_av_Light->b = 0; // Zero bounce
g_av_Light->anu = 0; // Don't use it
g_av_Light->type = OMNI_LIGHT; // OMNI
g_av_Light->ba = 0; // Means nothing for an OMNI
g_av_Light->bs = 0; // Means nothing for an OMNI
// Don't think these things are used...
av_Light.states[0].ans2 = 0;
av_Light.states[0].ane2 = (100 * 1) * (100 * 1);
g_av_Light->states[0].ans2 = 0;
g_av_Light->states[0].ane2 = (100 * 1) * (100 * 1);
// No shade...
av_Light.states[0].m = 128;
g_av_Light->states[0].m = 128;
// Direction doesn't matter; it's an OMNI light
av_Light.states[0].vx = 4096; // Ignored for an OMNI light
av_Light.states[0].vy = 0; // Ignored for an OMNI light
av_Light.states[0].vz = 0; // Ignored for an OMNI light
g_av_Light->states[0].vx = 4096; // Ignored for an OMNI light
g_av_Light->states[0].vy = 0; // Ignored for an OMNI light
g_av_Light->states[0].vz = 0; // Ignored for an OMNI light
// Initial angle
av_LightA = 0;
@ -642,33 +637,33 @@ void SetLight(int32 falloff) {
Fatal_error("ActorView light rgb %d,%d,%d out of range (0-255)", av_LightR, av_LightG, av_LightB);
// Set colours (scale 0-255 to 0-4095)
av_Light.states[0].c.r = (int16)((av_LightR * 4096) / 256);
av_Light.states[0].c.g = (int16)((av_LightG * 4096) / 256);
av_Light.states[0].c.b = (int16)((av_LightB * 4096) / 256);
g_av_Light->states[0].c.r = (int16)((av_LightR * 4096) / 256);
g_av_Light->states[0].c.g = (int16)((av_LightG * 4096) / 256);
g_av_Light->states[0].c.b = (int16)((av_LightB * 4096) / 256);
// Set the v field of colour to be the maximum of r,g,b
av_Light.states[0].c.v = av_Light.states[0].c.r; // Start at red
if (av_Light.states[0].c.g > av_Light.states[0].c.v) // If green bigger
av_Light.states[0].c.v = av_Light.states[0].c.g; // Set to green
if (av_Light.states[0].c.b > av_Light.states[0].c.v) // If blue bigger
av_Light.states[0].c.v = av_Light.states[0].c.b; // Set to blue
g_av_Light->states[0].c.v = g_av_Light->states[0].c.r; // Start at red
if (g_av_Light->states[0].c.g > g_av_Light->states[0].c.v) // If green bigger
g_av_Light->states[0].c.v = g_av_Light->states[0].c.g; // Set to green
if (g_av_Light->states[0].c.b > g_av_Light->states[0].c.v) // If blue bigger
g_av_Light->states[0].c.v = g_av_Light->states[0].c.b; // Set to blue
av_Light.states[0].pos.vx = (int32)av_LightX;
av_Light.states[0].pos.vy = (int32)av_LightY;
av_Light.states[0].pos.vz = (int32)av_LightZ;
g_av_Light->states[0].pos.vx = (int32)av_LightX;
g_av_Light->states[0].pos.vy = (int32)av_LightY;
g_av_Light->states[0].pos.vz = (int32)av_LightZ;
// And add the players position
av_Light.states[0].pos.vx += (int32)av_actor.truePos.x;
av_Light.states[0].pos.vy += (int32)av_actor.truePos.y;
av_Light.states[0].pos.vz += (int32)av_actor.truePos.z;
g_av_Light->states[0].pos.vx += (int32)g_av_actor->truePos.x;
g_av_Light->states[0].pos.vy += (int32)g_av_actor->truePos.y;
g_av_Light->states[0].pos.vz += (int32)g_av_actor->truePos.z;
// Falloff
if (falloff == 0) {
av_Light.afu = 0; // Don't use it
g_av_Light->afu = 0; // Don't use it
} else {
av_Light.states[0].afs2 = (falloff * falloff) / 100; // (d/10)^2 = (d*d)/100
av_Light.states[0].afe2 = falloff * falloff; // d^2 = (d*d)
av_Light.afu = 1; // Use it
g_av_Light->states[0].afs2 = (falloff * falloff) / 100; // (d/10)^2 = (d*d)/100
g_av_Light->states[0].afe2 = falloff * falloff; // d^2 = (d*d)
g_av_Light->afu = 1; // Use it
}
}

View File

@ -33,10 +33,10 @@
namespace ICB {
MATRIX gterot;
MATRIX gtetrans;
MATRIX gtecolour;
MATRIX gtelight;
MATRIX *gterot;
MATRIX *gtetrans;
MATRIX *gtecolour;
MATRIX *gtelight;
short gteback[3];
int32 gtegeomscrn;
uint8 dcache[1024];

View File

@ -97,10 +97,10 @@ inline int32 myNINT(float f) {
#define gte_NormalClip mygte_NormalClip
#define gte_AverageZ3 mygte_AverageZ3
extern MATRIX gterot;
extern MATRIX gtetrans;
extern MATRIX gtecolour;
extern MATRIX gtelight;
extern MATRIX *gterot;
extern MATRIX *gtetrans;
extern MATRIX *gtecolour;
extern MATRIX *gtelight;
extern int16 gteback[3];
extern int32 gtegeomscrn;
extern uint8 dcache[1024];
@ -189,21 +189,21 @@ inline void mygte_MulMatrix0(MATRIX *m1, MATRIX *m2, MATRIX *out) {
}
}
inline void mygte_SetRotMatrix(MATRIX *m) { gterot = *m; }
inline void mygte_SetRotMatrix(MATRIX *m) { *gterot = *m; }
inline void mygte_SetTransMatrix(MATRIX *m) { gtetrans = *m; }
inline void mygte_SetTransMatrix(MATRIX *m) { *gtetrans = *m; }
inline void mygte_ApplyRotMatrix(SVECTOR *invec, VECTOR *outvec) {
outvec->vx = (((int)gterot.m[0][0] * (int)invec->vx + (int)gterot.m[0][1] * (int)invec->vy + (int)gterot.m[0][2] * (int)invec->vz) / 4096);
outvec->vy = (((int)gterot.m[1][0] * (int)invec->vx + (int)gterot.m[1][1] * (int)invec->vy + (int)gterot.m[1][2] * (int)invec->vz) / 4096);
outvec->vz = (((int)gterot.m[2][0] * (int)invec->vx + (int)gterot.m[2][1] * (int)invec->vy + (int)gterot.m[2][2] * (int)invec->vz) / 4096);
outvec->vx = (((int)gterot->m[0][0] * (int)invec->vx + (int)gterot->m[0][1] * (int)invec->vy + (int)gterot->m[0][2] * (int)invec->vz) / 4096);
outvec->vy = (((int)gterot->m[1][0] * (int)invec->vx + (int)gterot->m[1][1] * (int)invec->vy + (int)gterot->m[1][2] * (int)invec->vz) / 4096);
outvec->vz = (((int)gterot->m[2][0] * (int)invec->vx + (int)gterot->m[2][1] * (int)invec->vy + (int)gterot->m[2][2] * (int)invec->vz) / 4096);
}
inline void mygte_RotTrans(SVECTOR *in0, VECTOR *out0, int32 *flag) {
mygte_ApplyRotMatrix(in0, out0);
out0->vx += gtetrans.t[0];
out0->vy += gtetrans.t[1];
out0->vz += gtetrans.t[2];
out0->vx += gtetrans->t[0];
out0->vy += gtetrans->t[1];
out0->vz += gtetrans->t[2];
// What GTE flags should we set ?
*flag = 0;
@ -314,16 +314,16 @@ inline void mygte_SetBackColor(int32 r, int32 g, int32 b) {
gteback[2] = (int16)b;
}
inline void mygte_SetColorMatrix(MATRIX *m) { gtecolour = *m; }
inline void mygte_SetColorMatrix(MATRIX *m) { *gtecolour = *m; }
inline void mygte_SetLightMatrix(MATRIX *m) { gtelight = *m; }
inline void mygte_SetLightMatrix(MATRIX *m) { *gtelight = *m; }
inline void mygte_SetGeomScreen(int32 h) { gtegeomscrn = h; }
inline void mygte_NormalColorCol(SVECTOR *v0, CVECTOR *in0, CVECTOR *out0) {
SVECTOR lightEffect;
// Normal line vector(local) -> light source effect
ApplyMatrixSV(&gtelight, v0, &lightEffect);
ApplyMatrixSV(gtelight, v0, &lightEffect);
if (lightEffect.vx < 0)
lightEffect.vx = 0;
if (lightEffect.vy < 0)
@ -333,7 +333,7 @@ inline void mygte_NormalColorCol(SVECTOR *v0, CVECTOR *in0, CVECTOR *out0) {
// Light source effect -> Colour effect(local colour matrix+back colour)
SVECTOR colourEffect;
ApplyMatrixSV(&gtecolour, &lightEffect, &colourEffect);
ApplyMatrixSV(gtecolour, &lightEffect, &colourEffect);
if (colourEffect.vx < 0)
colourEffect.vx = 0;
if (colourEffect.vy < 0)

View File

@ -33,10 +33,10 @@
namespace ICB {
MATRIXPC gterot_pc;
MATRIXPC gtetrans_pc;
MATRIXPC gtecolour_pc;
MATRIXPC gtelight_pc;
MATRIXPC *gterot_pc;
MATRIXPC *gtetrans_pc;
MATRIXPC *gtecolour_pc;
MATRIXPC *gtelight_pc;
int32 gteback_pc[3];
int32 gtegeomscrn_pc;
int32 gtescreenscaleshift_pc = 0;

View File

@ -105,10 +105,10 @@ inline int32 myNINT_PC(float f) {
//------------------------------------------------------------------------
extern MATRIXPC gterot_pc;
extern MATRIXPC gtetrans_pc;
extern MATRIXPC gtecolour_pc;
extern MATRIXPC gtelight_pc;
extern MATRIXPC *gterot_pc;
extern MATRIXPC *gtetrans_pc;
extern MATRIXPC *gtecolour_pc;
extern MATRIXPC *gtelight_pc;
extern int32 gteback_pc[3];
extern int32 gtegeomscrn_pc;
extern int32 gtescreenscaleshift_pc;
@ -219,27 +219,27 @@ inline void mygte_MulMatrix0_pc(MATRIXPC *m1, MATRIXPC *m2, MATRIXPC *out) {
//------------------------------------------------------------------------
inline void mygte_SetRotMatrix_pc(MATRIXPC *m) { gterot_pc = *m; }
inline void mygte_SetRotMatrix_pc(MATRIXPC *m) { *gterot_pc = *m; }
//------------------------------------------------------------------------
inline void mygte_SetTransMatrix_pc(MATRIXPC *m) { gtetrans_pc = *m; }
inline void mygte_SetTransMatrix_pc(MATRIXPC *m) { *gtetrans_pc = *m; }
//------------------------------------------------------------------------
inline void mygte_ApplyRotMatrix_pc(SVECTORPC *invec, VECTOR *outvec) {
outvec->vx = ((gterot_pc.m[0][0] * invec->vx + gterot_pc.m[0][1] * invec->vy + gterot_pc.m[0][2] * invec->vz) / ONE_PC);
outvec->vy = ((gterot_pc.m[1][0] * invec->vx + gterot_pc.m[1][1] * invec->vy + gterot_pc.m[1][2] * invec->vz) / ONE_PC);
outvec->vz = ((gterot_pc.m[2][0] * invec->vx + gterot_pc.m[2][1] * invec->vy + gterot_pc.m[2][2] * invec->vz) / ONE_PC);
outvec->vx = ((gterot_pc->m[0][0] * invec->vx + gterot_pc->m[0][1] * invec->vy + gterot_pc->m[0][2] * invec->vz) / ONE_PC);
outvec->vy = ((gterot_pc->m[1][0] * invec->vx + gterot_pc->m[1][1] * invec->vy + gterot_pc->m[1][2] * invec->vz) / ONE_PC);
outvec->vz = ((gterot_pc->m[2][0] * invec->vx + gterot_pc->m[2][1] * invec->vy + gterot_pc->m[2][2] * invec->vz) / ONE_PC);
}
//------------------------------------------------------------------------
inline void mygte_RotTrans_pc(SVECTORPC *in0, VECTOR *out0, int32 *flag) {
mygte_ApplyRotMatrix_pc(in0, out0);
out0->vx += gtetrans_pc.t[0];
out0->vy += gtetrans_pc.t[1];
out0->vz += gtetrans_pc.t[2];
out0->vx += gtetrans_pc->t[0];
out0->vy += gtetrans_pc->t[1];
out0->vz += gtetrans_pc->t[2];
// What GTE flags should we set ?
*flag = 0;
@ -255,9 +255,9 @@ inline void mygte_RotTrans_pc(SVECTOR *in0, VECTOR *out0, int32 *flag) {
mygte_ApplyRotMatrix_pc(&sv_pc, out0);
out0->vx += gtetrans_pc.t[0];
out0->vy += gtetrans_pc.t[1];
out0->vz += gtetrans_pc.t[2];
out0->vx += gtetrans_pc->t[0];
out0->vy += gtetrans_pc->t[1];
out0->vz += gtetrans_pc->t[2];
// What GTE flags should we set ?
*flag = 0;
@ -267,12 +267,12 @@ inline void mygte_RotTrans_pc(SVECTOR *in0, VECTOR *out0, int32 *flag) {
inline void mygte_RotTransPers_pc(SVECTORPC *in0, SVECTORPC *sxy0, int32 * /* p */, int32 *flag, int32 *z) {
VECTOR cam;
cam.vx = ((gterot_pc.m[0][0] * in0->vx + gterot_pc.m[0][1] * in0->vy + gterot_pc.m[0][2] * in0->vz) / ONE_PC);
cam.vy = ((gterot_pc.m[1][0] * in0->vx + gterot_pc.m[1][1] * in0->vy + gterot_pc.m[1][2] * in0->vz) / ONE_PC);
cam.vz = ((gterot_pc.m[2][0] * in0->vx + gterot_pc.m[2][1] * in0->vy + gterot_pc.m[2][2] * in0->vz) / ONE_PC);
cam.vx += (gtetrans_pc.t[0] << gtescreenscaleshift_pc);
cam.vy += (gtetrans_pc.t[1] << gtescreenscaleshift_pc);
cam.vz += (gtetrans_pc.t[2] << gtescreenscaleshift_pc);
cam.vx = ((gterot_pc->m[0][0] * in0->vx + gterot_pc->m[0][1] * in0->vy + gterot_pc->m[0][2] * in0->vz) / ONE_PC);
cam.vy = ((gterot_pc->m[1][0] * in0->vx + gterot_pc->m[1][1] * in0->vy + gterot_pc->m[1][2] * in0->vz) / ONE_PC);
cam.vz = ((gterot_pc->m[2][0] * in0->vx + gterot_pc->m[2][1] * in0->vy + gterot_pc->m[2][2] * in0->vz) / ONE_PC);
cam.vx += (gtetrans_pc->t[0] << gtescreenscaleshift_pc);
cam.vy += (gtetrans_pc->t[1] << gtescreenscaleshift_pc);
cam.vz += (gtetrans_pc->t[2] << gtescreenscaleshift_pc);
*flag = 0;
@ -302,12 +302,12 @@ inline void mygte_RotTransPers_pc(SVECTORPC *in0, SVECTORPC *sxy0, int32 * /* p
inline void mygte_RotTransPers_pc(SVECTOR *in0, SVECTORPC *sxy0, int32 * /* p */, int32 *flag, int32 *z) {
VECTOR cam;
cam.vx = ((gterot_pc.m[0][0] * (int)in0->vx + gterot_pc.m[0][1] * (int)in0->vy + gterot_pc.m[0][2] * (int)in0->vz) / ONE_PC);
cam.vy = ((gterot_pc.m[1][0] * (int)in0->vx + gterot_pc.m[1][1] * (int)in0->vy + gterot_pc.m[1][2] * (int)in0->vz) / ONE_PC);
cam.vz = ((gterot_pc.m[2][0] * (int)in0->vx + gterot_pc.m[2][1] * (int)in0->vy + gterot_pc.m[2][2] * (int)in0->vz) / ONE_PC);
cam.vx += (gtetrans_pc.t[0] << gtescreenscaleshift_pc);
cam.vy += (gtetrans_pc.t[1] << gtescreenscaleshift_pc);
cam.vz += (gtetrans_pc.t[2] << gtescreenscaleshift_pc);
cam.vx = ((gterot_pc->m[0][0] * (int)in0->vx + gterot_pc->m[0][1] * (int)in0->vy + gterot_pc->m[0][2] * (int)in0->vz) / ONE_PC);
cam.vy = ((gterot_pc->m[1][0] * (int)in0->vx + gterot_pc->m[1][1] * (int)in0->vy + gterot_pc->m[1][2] * (int)in0->vz) / ONE_PC);
cam.vz = ((gterot_pc->m[2][0] * (int)in0->vx + gterot_pc->m[2][1] * (int)in0->vy + gterot_pc->m[2][2] * (int)in0->vz) / ONE_PC);
cam.vx += (gtetrans_pc->t[0] << gtescreenscaleshift_pc);
cam.vy += (gtetrans_pc->t[1] << gtescreenscaleshift_pc);
cam.vz += (gtetrans_pc->t[2] << gtescreenscaleshift_pc);
*flag = 0;
@ -416,11 +416,11 @@ inline void mygte_SetBackColor_pc(int32 r, int32 g, int32 b) {
//------------------------------------------------------------------------
inline void mygte_SetColorMatrix_pc(MATRIXPC *m) { gtecolour_pc = *m; }
inline void mygte_SetColorMatrix_pc(MATRIXPC *m) { *gtecolour_pc = *m; }
//------------------------------------------------------------------------
inline void mygte_SetLightMatrix_pc(MATRIXPC *m) { gtelight_pc = *m; }
inline void mygte_SetLightMatrix_pc(MATRIXPC *m) { *gtelight_pc = *m; }
//------------------------------------------------------------------------
@ -431,7 +431,7 @@ inline void mygte_SetGeomScreen_pc(int32 h) { gtegeomscrn_pc = h; }
inline void mygte_NormalColorCol_pc(SVECTOR *v0, CVECTOR *in0, CVECTOR *out0) {
SVECTORPC lightEffect;
// Normal line vector(local) -> light source effect
ApplyMatrixSV_pc(&gtelight_pc, v0, &lightEffect);
ApplyMatrixSV_pc(gtelight_pc, v0, &lightEffect);
if (lightEffect.vx < 0)
lightEffect.vx = 0;
if (lightEffect.vy < 0)
@ -441,7 +441,7 @@ inline void mygte_NormalColorCol_pc(SVECTOR *v0, CVECTOR *in0, CVECTOR *out0) {
// Light source effect -> Colour effect(local colour matrix+back colour)
SVECTORPC colourEffect;
ApplyMatrixSV_pc(&gtecolour_pc, &lightEffect, &colourEffect);
ApplyMatrixSV_pc(gtecolour_pc, &lightEffect, &colourEffect);
if (colourEffect.vx < 0)
colourEffect.vx = 0;
if (colourEffect.vy < 0)

View File

@ -79,7 +79,7 @@ uint8 selPAlpha = 0;
inline void LightPolygon(SVECTOR *n0, CVECTOR *rgbIn, CVECTOR *rgb0) {
SVECTORPC lightEffect;
// Normal line vector(local) -> light source effect
ApplyMatrixSV_pc(&gtelight_pc, n0, &lightEffect);
ApplyMatrixSV_pc(gtelight_pc, n0, &lightEffect);
if (useLampWidth) {
lightEffect.vx = (int16)(lightEffect.vx + lampWidth[0]);
@ -113,7 +113,7 @@ inline void LightPolygon(SVECTOR *n0, CVECTOR *rgbIn, CVECTOR *rgb0) {
// Light source effect -> Colour effect(local colour matrix+back colour)
SVECTORPC colourEffect;
ApplyMatrixSV_pc(&gtecolour_pc, &lightEffect, &colourEffect);
ApplyMatrixSV_pc(gtecolour_pc, &lightEffect, &colourEffect);
if (colourEffect.vx < 0)
colourEffect.vx = 0;
if (colourEffect.vy < 0)

View File

@ -155,7 +155,7 @@ void Init_play_movie(const char *param0, bool8 param1) {
// Bink is now active and playing
// Successfully opened a bink sequence so set the engine to play and display it
stub.Push_stub_mode(__sequence);
g_stub->Push_stub_mode(__sequence);
} else {
Fatal_error(pxVString("Couldn't register the movie: %s", (const char *)fullname));
}

View File

@ -337,7 +337,7 @@ mcodeFunctionReturnCodes _game_session::fn_create_mega(int32 &, int32 *) {
Zdebug("FN_create_mega");
// assign _mega object
logic_structs[cur_id]->mega = &megas[num_megas];
logic_structs[cur_id]->mega = g_megas[num_megas];
logic_structs[cur_id]->mega->___init();
@ -434,7 +434,7 @@ mcodeFunctionReturnCodes _game_session::fn_set_voxel_image_path(int32 &, int32 *
// create _vox_image object
if (!logic_structs[cur_id]->voxel_info) {
// assign a struct
logic_structs[cur_id]->voxel_info = &vox_images[num_vox_images];
logic_structs[cur_id]->voxel_info = g_vox_images[num_vox_images];
num_vox_images++;
}

View File

@ -164,7 +164,7 @@ void _game_script::Process_game_script() {
case 'X': // yes, its the amazing X mode - t h e m a i n m e n u -
Fetch_next_line();
stub.Push_stub_mode(__toe_on_door);
g_stub->Push_stub_mode(__toe_on_door);
break;
case 'W':
@ -182,7 +182,7 @@ void _game_script::Process_game_script() {
if (Setup_new_mission(p1, p2)) { // mission_name, session_name
// only do actor relative on pc
MS->player.Set_control_mode(ACTOR_RELATIVE);
stub.Push_stub_mode(__mission_and_console);
g_stub->Push_stub_mode(__mission_and_console);
} else {
Fatal_error("no such mission-session [%s][%s]", p1, p2);
}
@ -208,7 +208,7 @@ void _game_script::Process_game_script() {
case 'P':
Fetch_next_line();
MS->player.Set_control_mode(ACTOR_RELATIVE);
stub.Push_stub_mode(__mission_and_console);
g_stub->Push_stub_mode(__mission_and_console);
break;
case 'T':
@ -222,7 +222,7 @@ void _game_script::Process_game_script() {
warning("text scrolly %s over movie/screen %s starting frame %d", p1, p2, atoi(p3));
InitisliaseScrollingText(p1, p2, atoi(p3));
stub.Push_stub_mode(__scrolling_text);
g_stub->Push_stub_mode(__scrolling_text);
break;
case 'G':

View File

@ -83,12 +83,12 @@ _game_session *g_icb_session;
// session objects
_barrier_handler g_icb_session_barriers;
_floor_world *g_icb_session_floors;
_logic logics[MAX_session_objects];
_mega megas[MAX_voxel_list];
_vox_image vox_images[MAX_voxel_list];
_logic *g_logics[MAX_session_objects];
_mega *g_megas[MAX_voxel_list];
_vox_image *g_vox_images[MAX_voxel_list];
// master modes
_stub stub;
_stub *g_stub;
// game script manager
_game_script gs;

View File

@ -68,7 +68,7 @@ class _mission;
// holds info about current mission
extern _mission *g_mission;
extern _stub stub;
extern _stub *g_stub;
// game script manager
extern _game_script gs;
@ -79,9 +79,9 @@ extern _game_session *g_icb_session;
// session objects
extern _barrier_handler g_icb_session_barriers;
extern _floor_world *g_icb_session_floors;
extern _logic logics[MAX_session_objects];
extern _mega megas[MAX_voxel_list];
extern _vox_image vox_images[MAX_voxel_list];
extern _logic *g_logics[MAX_session_objects];
extern _mega *g_megas[MAX_voxel_list];
extern _vox_image *g_vox_images[MAX_voxel_list];
// For choosing different sessions & missions
#define NUMBER_OF_MISSIONS (11)

View File

@ -37,6 +37,15 @@ TextureManager *tman;
// The 3 directional lights and the ambient light
psxLight Lights[4];
// Camera and animation structures
psxCamera *g_camera;
// Actor structure
psxActor *g_av_actor;
// Lighting structure and coordinates, colour components
PSXLamp *g_av_Light;
#if CD_BUILD == 0
// Colour of the z-fragments outlines
int32 zfragRed = 255;

View File

@ -32,6 +32,9 @@
#include "engines/icb/surface_manager.h"
#include "engines/icb/gfx/psx_light.h"
#include "engines/icb/gfx/psx_tman.h"
#include "engines/icb/gfx/psx_camera.h"
#include "engines/icb/gfx/psx_pxactor.h"
#include "engines/icb/gfx/rlp_api.h"
namespace ICB {
@ -41,6 +44,15 @@ extern TextureManager *tman;
// The 3 directional lights and the ambient light
extern psxLight Lights[4];
// Camera and animation structures
extern psxCamera *g_camera;
// Actor structure
extern psxActor *g_av_actor;
// Lighting structure and coordinates, colour components
extern PSXLamp *g_av_Light;
// Colour of the actors bounding box
extern int32 bboxRed;
extern int32 bboxGreen;

View File

@ -33,6 +33,7 @@
#include "engines/icb/mission.h"
#include "engines/icb/object_structs.h"
#include "engines/icb/global_objects.h"
#include "engines/icb/global_objects_psx.h"
#include "engines/icb/debug.h"
#include "engines/icb/res_man.h"
#include "engines/icb/movie_pc.h"
@ -41,6 +42,11 @@
#include "engines/icb/options_manager_pc.h"
#include "engines/icb/floors.h"
#include "engines/icb/remora.h"
#include "engines/icb/gfx/psx_camera.h"
#include "engines/icb/gfx/psx_pxactor.h"
#include "engines/icb/gfx/rlp_api.h"
#include "engines/icb/common/px_capri_maths_pc.h"
#include "engines/icb/common/px_capri_maths.h"
namespace ICB {
@ -137,6 +143,25 @@ void CreateGlobalObjects() {
g_icb_session_floors = new _floor_world;
g_text_bloc1 = new text_sprite;
g_text_bloc2 = new text_sprite;
g_av_actor = new psxActor;
g_camera = new psxCamera;
g_av_Light = new PSXLamp;
for (int i = 0; i < MAX_voxel_list; i++) {
g_megas[i] = new _mega;
g_vox_images[i] = new _vox_image;
}
for (int i = 0; i < MAX_session_objects; i++)
g_logics[i] = new _logic;
g_stub = new _stub;
gterot_pc = new MATRIXPC;
gtetrans_pc = new MATRIXPC;
gtecolour_pc = new MATRIXPC;
gtelight_pc = new MATRIXPC;
gterot = new MATRIX;
gtetrans = new MATRIX;
gtecolour = new MATRIX;
gtelight = new MATRIX;
// The order of creation matters:
g_oEventManager = new _event_manager;
g_oLineOfSight = new _line_of_sight;
@ -157,6 +182,25 @@ void DestroyGlobalObjects() {
delete g_icb_session_floors;
delete g_text_bloc1;
delete g_text_bloc2;
delete g_camera;
delete g_av_actor;
delete g_av_Light;
for (int i = 0; i < MAX_voxel_list; i++) {
delete g_megas[i];
delete g_vox_images[i];
}
for (int i = 0; i < MAX_session_objects; i++)
delete g_logics[i];
delete g_stub;
delete gterot_pc;
delete gtetrans_pc;
delete gtecolour_pc;
delete gtelight_pc;
delete gterot;
delete gtetrans;
delete gtecolour;
delete gtelight;
delete g_oEventManager;
delete g_oLineOfSight;
delete g_oIconMenu;

View File

@ -42,7 +42,7 @@ void Main_menu() {
} else {
// OptionsManager is in control
g_theOptionsManager->CycleLogic();
stub.Update_screen();
g_stub->Update_screen();
}
}
@ -52,13 +52,13 @@ void Pause_menu() {
g_theOptionsManager->ForceInGameScreenRefresh();
g_theOptionsManager->CycleLogic();
stub.Update_screen();
g_stub->Update_screen();
}
void Credits() {
uint32 t = GetMicroTimer();
g_theOptionsManager->DoCredits();
stub.Update_screen();
g_stub->Update_screen();
t = GetMicroTimer() - t;
// As the DoCredits() function takes a variable time this timing code
@ -135,7 +135,7 @@ void InitisliaseScrollingText(const char *textFileName, const char *movieFileNam
void ScrollingText() {
uint32 t = GetMicroTimer();
g_theOptionsManager->DoScrollingText();
stub.Update_screen();
g_stub->Update_screen();
t = GetMicroTimer() - t;
#ifdef PC_DEMO
@ -161,7 +161,7 @@ void Gameover_menu() {
g_theOptionsManager->ForceInGameScreenRefresh();
g_theOptionsManager->CycleLogic();
stub.Update_screen();
g_stub->Update_screen();
}
}

View File

@ -598,7 +598,7 @@ void OptionsManager::KillAllSurfii() {
void OptionsManager::StartInGameOptions() {
// Pauses the game and presents the in game options
stub.Push_stub_mode(__pause_menu);
g_stub->Push_stub_mode(__pause_menu);
if (g_theSpeechManager)
g_theSpeechManager->PauseSpeech();
@ -756,7 +756,7 @@ void OptionsManager::CycleInGameOptionsLogic() {
if ((m_thatsEnoughTa) && (m_autoAnimating < 0)) {
// Refresh entire screen
surface_manager->Clear_surface(working_buffer_id);
stub.Update_screen();
g_stub->Update_screen();
// Free up any resources we have used
KillAllSurfii();
@ -766,7 +766,7 @@ void OptionsManager::CycleInGameOptionsLogic() {
// An extra pop needed to return control to gamescript
if (g_resetToTitleScreen) {
g_resetToTitleScreen = FALSE8;
stub.Pop_stub_mode();
g_stub->Pop_stub_mode();
} else {
// Resume the engines sounds
UnpauseSounds();
@ -774,7 +774,7 @@ void OptionsManager::CycleInGameOptionsLogic() {
}
// Then quit
stub.Pop_stub_mode();
g_stub->Pop_stub_mode();
m_haveControl = FALSE8;
return;
@ -807,11 +807,11 @@ void OptionsManager::CycleGameOverLogic() {
// An extra pop needed to return control to gamescript
if (g_resetToTitleScreen) {
g_resetToTitleScreen = FALSE8;
stub.Pop_stub_mode();
g_stub->Pop_stub_mode();
}
// Then quit
stub.Pop_stub_mode();
g_stub->Pop_stub_mode();
m_haveControl = FALSE8;
// Specifically for the Restart Mission command but can't hurt anyway
@ -1750,10 +1750,10 @@ void OptionsManager::CycleMainOptionsLogic() {
if (!g_mainMenuLoadPlease) {
// If we want a new game then just pop to gamescript
stub.Pop_stub_mode();
g_stub->Pop_stub_mode();
} else {
// When loading a game this sets the right gamescript position
stub.Set_current_stub_mode(__mission_and_console);
g_stub->Set_current_stub_mode(__mission_and_console);
}
UnpauseSounds();
@ -2407,15 +2407,15 @@ void OptionsManager::AlterSelected(bool8 _right_) {
case FRAMELIMITER:
if (_right_) {
if (stub.cycle_speed < 200)
stub.cycle_speed += 10;
else if (stub.cycle_speed < 951)
stub.cycle_speed += 50;
if (g_stub->cycle_speed < 200)
g_stub->cycle_speed += 10;
else if (g_stub->cycle_speed < 951)
g_stub->cycle_speed += 50;
} else {
if (stub.cycle_speed > 200)
stub.cycle_speed -= 50;
else if (stub.cycle_speed > 10)
stub.cycle_speed -= 10;
if (g_stub->cycle_speed > 200)
g_stub->cycle_speed -= 50;
else if (g_stub->cycle_speed > 10)
g_stub->cycle_speed -= 10;
}
PlayChosenFX();
Poll_Sound_Engine();
@ -2743,7 +2743,7 @@ void OptionsManager::DoChoice() {
m_M_PROFILES_selected = CORD;
break;
case CREDITS:
stub.Push_stub_mode(__credits);
g_stub->Push_stub_mode(__credits);
break;
case ALLDONE:
m_warpDirection = FALSE8;
@ -4773,7 +4773,7 @@ void OptionsManager::DrawVideoSettings() {
temp = CalculateStringWidth(msg);
DisplayText(ad, pitch, msg, halfScreen - temp - 10, hite, (m_VIDEO_selected == FRAMELIMITER) ? SELECTEDFONT : NORMALFONT, FALSE8);
char msg2[6];
sprintf(msg2, "%d%%", stub.cycle_speed);
sprintf(msg2, "%d%%", g_stub->cycle_speed);
DisplayText(ad, pitch, msg2, halfScreen, hite, NORMALFONT, FALSE8);
}
@ -5983,7 +5983,7 @@ void OptionsManager::DoCredits() {
// Reinstate the title screen movie
LoadTitleScreenMovie();
m_creditControl = FALSE8;
stub.Pop_stub_mode();
g_stub->Pop_stub_mode();
}
}
}
@ -6007,7 +6007,7 @@ void OptionsManager::InitialiseScrollingText(const char *textFileName, const cha
void OptionsManager::DoScrollingText() {
if (m_crediter.DoScreen() == 0) {
m_creditControl = FALSE8;
stub.Pop_stub_mode();
g_stub->Pop_stub_mode();
}
}

View File

@ -246,9 +246,9 @@ void InitEngine(const char *lpCmdLine) {
// unless there is a console.icb file we dont allow debugging
// set base mode of stub to gameScript processor
stub.Set_current_stub_mode(__game_script);
g_stub->Set_current_stub_mode(__game_script);
} else
stub.Set_current_stub_mode(__mission_and_console);
g_stub->Set_current_stub_mode(__mission_and_console);
// Initialise the runtime cluster manager
g_theClusterManager->Initialise();
@ -337,7 +337,7 @@ bool mainLoopIteration() {
}
}
// Used to be triggered by else if(gotTheFocus).
stub.Process_stub();
g_stub->Process_stub();
g_system->delayMillis(1);
return true;
@ -362,7 +362,7 @@ void Mission_and_console() {
int32 ret = ob->GetVariable("state");
if (ob->GetIntegerVariable(ret)) {
// Return to avoid deleting the mission
stub.Push_stub_mode(__gameover_menu);
g_stub->Push_stub_mode(__gameover_menu);
return;
}
@ -372,7 +372,7 @@ void Mission_and_console() {
Fatal_error("Thank you for playing In Cold Blood");
else
stub.Pop_stub_mode(); // back to game script server
g_stub->Pop_stub_mode(); // back to game script server
} else
g_mission->Create_display();
}

View File

@ -672,7 +672,7 @@ void _game_session::Pre_initialise_objects() {
object = (c_game_object *)objects->Fetch_item_by_number(j);
logic_structs[j] = &logics[j];
logic_structs[j] = g_logics[j];
logic_structs[j]->___init((const char *)object->GetName());
}

View File

@ -30,6 +30,7 @@
#include "engines/icb/res_man_pc.h"
#include "engines/icb/sound/sound_common.h"
#include "engines/icb/icb.h"
#include "engines/icb/global_objects.h"
#include "common/textconsole.h"
@ -80,7 +81,7 @@ bool8 FxManager::Poll() {
g_icb->_mixer->setChannelVolume(m_effects[id]._handle, m_effects[id].volume * volumeConversion);
g_icb->_mixer->setChannelBalance(m_effects[id]._handle, m_effects[id].pan);
frequency = (m_effects[id].pitch * stub.cycle_speed) / 100;
frequency = (m_effects[id].pitch * g_stub->cycle_speed) / 100;
// FIXME correct pitch control
//m_effects[id].buffer->SetFrequency( frequency ) ;
//alSourcef(m_effects[id].alStream.source, AL_PITCH, 1.0f);
@ -103,7 +104,7 @@ bool8 FxManager::Poll() {
case Effect::QUEUED: {
// Apply current settings
frequency = (m_effects[id].pitch * stub.cycle_speed) / 100;
frequency = (m_effects[id].pitch * g_stub->cycle_speed) / 100;
// FIXME corrent pitch control
//m_effects[id].buffer->SetFrequency( frequency ) ;
//alSourcef(m_effects[id].alStream.source, AL_PITCH, 1.0f);