ICB: Replace PXmin and PXmax with MIN and MAX

This commit is contained in:
Cameron Cawley 2021-02-26 15:12:39 +00:00 committed by Paweł Kołodziejski
parent 8eb1cecf53
commit 286f377d1f
5 changed files with 32 additions and 142 deletions

View File

@ -1,70 +0,0 @@
/* ResidualVM - A 3D game interpreter
*
* ResidualVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the AUTHORS
* file distributed with this source distribution.
*
* Additional copyright for this file:
* Copyright (C) 1999-2000 Revolution Software Ltd.
* This code is based on source code created by Revolution Software,
* used with permission.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef ICB_PX_MATHS_H
#define ICB_PX_MATHS_H
namespace ICB {
static inline int fastABSc(int a) {
int r0 = a >> 31;
int r1 = a + r0;
int r2 = r1 ^ r0;
return r2;
}
static inline int fastMINc(int a, int b) {
int r0 = a - b;
int r1 = r0 >> 31;
int r2 = a & r1;
int r3 = ~r1;
int r4 = b & r3;
int r5 = r2 | r4;
return r5;
}
static inline int fastMAXc(int a, int b) {
int r0 = a - b;
int r1 = r0 >> 31;
int r2 = b & r1;
int r3 = ~r1;
int r4 = a & r3;
int r5 = r2 | r4;
return r5;
}
#include "engines/icb/common/px_maths_pc.h"
#define PXmin(a, b) PCfastMIN(a, b)
#define PXmax(a, b) PCfastMAX(a, b)
#define PXabs(a) PCfastABS(a)
} // End of namespace ICB
#endif // #ifndef PX_MATHS_H

View File

@ -1,41 +0,0 @@
/* ResidualVM - A 3D game interpreter
*
* ResidualVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the AUTHORS
* file distributed with this source distribution.
*
* Additional copyright for this file:
* Copyright (C) 1999-2000 Revolution Software Ltd.
* This code is based on source code created by Revolution Software,
* used with permission.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef ICB_PX_MATHS_PC_H
#define ICB_PX_MATHS_PC_H
namespace ICB {
#define PCfastMIN(a, b) (a < b) ? a : b;
#define PCfastMAX(a, b) (a > b) ? a : b;
#define PCfastABS(a) (abs(a))
} // End of namespace ICB
#endif // #ifndef PX_MATHS_PC_H

View File

@ -31,9 +31,10 @@
#include "engines/icb/gfx/psx_pcgpu.h"
#include "engines/icb/gfx/psx_pcdefines.h"
#include "engines/icb/common/px_assert.h"
#include "engines/icb/common/px_maths.h"
#include "engines/icb/gfx/psx_ot.h"
#include "common/util.h"
namespace ICB {
typedef struct DoubleBuffer {
@ -210,11 +211,11 @@ static inline void myAddDRLOADNoFlush(RECT16 *r, uint32 *pot, int length) {
static inline int32 myMakeOTPosition(int32 z0) {
int32 z1 = (z0 >> otz_shift) - otz_offset;
minUsedZpos = PXmin(z0, minUsedZpos);
maxUsedZpos = PXmax(z0, maxUsedZpos);
minUsedZpos = MIN(z0, minUsedZpos);
maxUsedZpos = MAX(z0, maxUsedZpos);
z1 = PXmax(minZOTpos, z1);
z1 = PXmin(maxZOTpos, z1);
z1 = MAX(minZOTpos, z1);
z1 = MIN(maxZOTpos, z1);
return z1;
}

View File

@ -32,7 +32,6 @@
#include "engines/icb/common/px_common.h"
#include "engines/icb/common/px_scriptengine.h"
#include "engines/icb/common/px_game_object.h"
#include "engines/icb/common/px_maths.h"
#include "engines/icb/common/ptr_util.h"
#include "engines/icb/mission.h"
#include "engines/icb/session.h"

View File

@ -26,10 +26,11 @@
*/
#include "engines/icb/common/px_common.h"
#include "engines/icb/common/px_maths.h"
#include "engines/icb/softskin_pc.h"
#include "engines/icb/common/px_capri_maths.h"
#include "common/util.h"
namespace ICB {
int softskinPC(rap_API *rap, int poseBone, MATRIXPC *lw, SVECTORPC *local, int16 *xminLocal, int16 *xmaxLocal, int16 *yminLocal, int16 *ymaxLocal, int16 *zminLocal,
@ -94,13 +95,13 @@ int softskinPC(rap_API *rap, int poseBone, MATRIXPC *lw, SVECTORPC *local, int16
lvy = plocal->vy;
lvz = plocal->vz;
xmin = PXmin(lvx, xmin);
ymin = PXmin(lvy, ymin);
zmin = PXmin(lvz, zmin);
xmin = MIN(lvx, xmin);
ymin = MIN(lvy, ymin);
zmin = MIN(lvz, zmin);
xmax = PXmax(lvx, xmax);
ymax = PXmax(lvy, ymax);
zmax = PXmax(lvz, zmax);
xmax = MAX(lvx, xmax);
ymax = MAX(lvy, ymax);
zmax = MAX(lvz, zmax);
noneLink++;
}
@ -122,13 +123,13 @@ int softskinPC(rap_API *rap, int poseBone, MATRIXPC *lw, SVECTORPC *local, int16
lvy = plocal->vy;
lvz = plocal->vz;
xmin = PXmin(lvx, xmin);
ymin = PXmin(lvy, ymin);
zmin = PXmin(lvz, zmin);
xmin = MIN(lvx, xmin);
ymin = MIN(lvy, ymin);
zmin = MIN(lvz, zmin);
xmax = PXmax(lvx, xmax);
ymax = PXmax(lvy, ymax);
zmax = PXmax(lvz, zmax);
xmax = MAX(lvx, xmax);
ymax = MAX(lvy, ymax);
zmax = MAX(lvz, zmax);
noneLink++;
}
@ -158,13 +159,13 @@ int softskinPC(rap_API *rap, int poseBone, MATRIXPC *lw, SVECTORPC *local, int16
lvy = plocal->vy;
lvz = plocal->vz;
xmin = PXmin(lvx, xmin);
ymin = PXmin(lvy, ymin);
zmin = PXmin(lvz, zmin);
xmin = MIN(lvx, xmin);
ymin = MIN(lvy, ymin);
zmin = MIN(lvz, zmin);
xmax = PXmax(lvx, xmax);
ymax = PXmax(lvy, ymax);
zmax = PXmax(lvz, zmax);
xmax = MAX(lvx, xmax);
ymax = MAX(lvy, ymax);
zmax = MAX(lvz, zmax);
singleLink++;
}
@ -215,13 +216,13 @@ int softskinPC(rap_API *rap, int poseBone, MATRIXPC *lw, SVECTORPC *local, int16
lvy = plocal->vy;
lvz = plocal->vz;
xmin = PXmin(lvx, xmin);
ymin = PXmin(lvy, ymin);
zmin = PXmin(lvz, zmin);
xmin = MIN(lvx, xmin);
ymin = MIN(lvy, ymin);
zmin = MIN(lvz, zmin);
xmax = PXmax(lvx, xmax);
ymax = PXmax(lvy, ymax);
zmax = PXmax(lvz, zmax);
xmax = MAX(lvx, xmax);
ymax = MAX(lvy, ymax);
zmax = MAX(lvz, zmax);
}
}