- some PSX slowdowns fixed (& bugfixes to scratchpad)

- misc changes
This commit is contained in:
Ilya Shurumov 2021-05-24 18:46:25 +06:00 committed by InspirationByte
parent 8583be65f7
commit bf8421340b
8 changed files with 35 additions and 36 deletions

View File

@ -584,7 +584,7 @@ int CarBuildingCollision(CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop,
#if 0 //def PSX
CDATA2D* cd = (CDATA2D*)getScratchAddr(0);
CRET2D& collisionResult = *(CRET2D*)getScratchAddr(sizeof(CDATA2D) * 2);
CRET2D& collisionResult = *(CRET2D*)(getScratchAddr(0) + sizeof(CDATA2D) * 2);
memset((u_char*)cd, 0, sizeof(CDATA2D));
memset((u_char*)&collisionResult, 0, sizeof(CRET2D));

View File

@ -344,7 +344,7 @@ void restoreLightingMatrices(void)
// [D] [T]
void ComputeCarLightingLevels(CAR_DATA* cp, char detail)
{
MATRIX& scratchPadMat = *(MATRIX*)getScratchAddr(0x344);
MATRIX& scratchPadMat = *(MATRIX*)(getScratchAddr(0) + 0x344);
int doLight;
int orW;
@ -566,9 +566,9 @@ void DrawCarWheels(CAR_DATA *cp, MATRIX *RearMatrix, VECTOR *pos, int zclip)
#ifdef PSX
MATRIX& FrontMatrix = *(MATRIX*)getScratchAddr(0);
MATRIX& SteerMatrix = *(MATRIX*)getScratchAddr(sizeof(MATRIX));
VECTOR& WheelPos = *(VECTOR*)getScratchAddr(sizeof(MATRIX) * 2);
SVECTOR& sWheelPos = *(SVECTOR*)getScratchAddr(sizeof(MATRIX) * 2 + sizeof(VECTOR));
MATRIX& SteerMatrix = *(MATRIX*)(getScratchAddr(0) + sizeof(MATRIX));
VECTOR& WheelPos = *(VECTOR*)(getScratchAddr(0) + sizeof(MATRIX) * 2);
SVECTOR& sWheelPos = *(SVECTOR*)(getScratchAddr(0) + sizeof(MATRIX) * 2 + sizeof(VECTOR));
#else
MATRIX FrontMatrix;
MATRIX SteerMatrix;
@ -1233,7 +1233,7 @@ void DrawCarObject(CAR_MODEL* car, MATRIX* matrix, VECTOR* pos, int palette, CAR
gte_SetTransVector(&modelLocation);
savedSP = SetSp((u_long)getScratchAddr(0x308));
savedSP = SetSp((u_long)(getScratchAddr(0) + 0x308));
plotNewCarModel(car, palette);

View File

@ -112,7 +112,7 @@ int setupYet = 0;
int gDrawDistance = 441;
_pct& plotContext = *(_pct*)getScratchAddr(1024 - sizeof(_pct)); // orig offset: 0x1f800020
_pct& plotContext = *(_pct*)(getScratchAddr(0) + 1024 - sizeof(_pct)); // orig offset: 0x1f800020
// [D] [T] [A]
void addSubdivSpriteShadow(POLYFT4* src, SVECTOR* verts, int z)
@ -1310,8 +1310,8 @@ void DrawMapPSX(int* comp_val)
#ifdef PSX
CELL_ITERATOR& ci = *(CELL_ITERATOR*)getScratchAddr(0);
MATRIX& mRotStore = *(MATRIX*)getScratchAddr(sizeof(CELL_ITERATOR));
DrawMapData& drawData = *(DrawMapData*)getScratchAddr(sizeof(CELL_ITERATOR) + sizeof(MATRIX));
MATRIX& mRotStore = *(MATRIX*)(getScratchAddr(0) + sizeof(CELL_ITERATOR));
DrawMapData& drawData = *(DrawMapData*)(getScratchAddr(0) + sizeof(CELL_ITERATOR) + sizeof(MATRIX));
#else
CELL_ITERATOR ci;
MATRIX mRotStore;
@ -1325,10 +1325,7 @@ void DrawMapPSX(int* comp_val)
static int alleycount = 0;
if (setupYet == 0)
{
SetupDrawMapPSX();
setupYet = 0;
}
// clean cell cache
ClearCopUsage();
@ -1363,9 +1360,6 @@ void DrawMapPSX(int* comp_val)
drawData.sprites_found = 0;
drawData.current_object_computed_value = *comp_val;
drawData.other_models_found = 0;
goFaster = goFaster ^ fasterToggle;
drawData.anim_objs_found = 0;
drawData.cellzpos = current_cell_z;
@ -1377,6 +1371,8 @@ void DrawMapPSX(int* comp_val)
hloop = 0;
dir = 0;
goFaster ^= fasterToggle;
if (NumPlayers == 2)
distScale = goFaster & 31 | 1;
else
@ -1589,4 +1585,6 @@ void DrawMapPSX(int* comp_val)
if (drawData.anim_objs_found)
DrawAllAnimatingObjects((CELL_OBJECT**)anim_obj_buffer, drawData.anim_objs_found);
setupYet = 0;
}

View File

@ -2285,10 +2285,10 @@ void RenderGame2(int view)
FrAng = ratan2(160, scr_z);
#endif
Set_Inv_CameraMatrix();
SetCameraVector();
//Set_Inv_CameraMatrix();
//SetCameraVector();
SetupDrawMapPSX();
//SetupDrawMapPSX();
if (gLoadedMotionCapture != 0)
DrawAllPedestrians();
@ -2302,7 +2302,8 @@ void RenderGame2(int view)
Set_Inv_CameraMatrix();
SetCameraVector();
SetupDrawMapPSX();
//SetupDrawMapPSX();
DrawDrivingGames();
DrawThrownBombs();
AddGroundDebris();

View File

@ -525,7 +525,7 @@ unsigned char *PVSEncodeTable = NULL;
// [D] [T]
void PVSDecode(char *output, char *celldata, ushort sz, int havanaCorruptCellBodge)
{
u_char nybblearray[256];
u_char* nybblearray;
int pixelIndex;
u_char* decodebuf;
u_char* op;
@ -534,15 +534,13 @@ void PVSDecode(char *output, char *celldata, ushort sz, int havanaCorruptCellBod
int size;
decodebuf = (u_char*)getScratchAddr(0);
nybblearray = (u_char*)getScratchAddr(0) + pvs_square_sq;
ClearMem((char*)decodebuf,pvs_square_sq);
// decode byte-swapped array
i = 0;
while (i < sz)
{
for (i = 0; i < sz; i++)
((ushort*)nybblearray)[i] = M_SHRT_2((unsigned char)celldata[i], (unsigned char)celldata[i] >> 4) & 0xf0f;
i++;
}
pixelIndex = 0;
symIndex = 0;
@ -673,7 +671,7 @@ void GetPVSRegionCell2(int source_region, int region, int cell, char *output)
if (regions_unpacked[source_region] == region && loading_region[source_region] == -1)
{
bp = PVS_Buffers[source_region];
PVSEncodeTable = (unsigned char *)(bp + 0x802);
PVSEncodeTable = (u_char *)(bp + 0x802);
tbp = bp + cell * 2;
length = M_SHRT_2((u_char)tbp[2], (u_char)tbp[3]) - M_SHRT_2((u_char)tbp[0], (u_char)tbp[1]) & 0xffff;

View File

@ -927,7 +927,7 @@ void SetupTannerSkeleton(PEDESTRIAN* pDrawingPed)
}
#ifdef PSX
store = (SVECTOR*)getScratchAddr(0x200);
store = (SVECTOR*)(getScratchAddr(0) + 0x200);
#else
SVECTOR scratchVectors[64];
store = scratchVectors;
@ -1013,7 +1013,7 @@ void DrawSprite(PEDESTRIAN* pDrawingPed, BONE* pBone, VECTOR* vJPos)
int z, z1, z2;
#ifdef PSX
SVECTOR* data = (SVECTOR*)getScratchAddr(0x200);
SVECTOR* data = (SVECTOR*)(getScratchAddr(0) + 0x200);
#else
SVECTOR scratchVectors[64];
SVECTOR* data = scratchVectors;
@ -1050,7 +1050,7 @@ void newShowTanner(PEDESTRIAN* pDrawingPed)
int draw;
#ifdef PSX
VECTOR* spad = (VECTOR*)getScratchAddr(0x100);
VECTOR* spad = (VECTOR*)(getScratchAddr(0) + 0x100);
#else
VECTOR spad[64];
#endif

View File

@ -33,7 +33,7 @@ char CellEmpty(VECTOR *pPosition, int radius)
int type;
#if 0
CELL_ITERATOR& ci = *(CELL_ITERATOR*)getScratchAddr(1024 - sizeof(CELL_ITERATOR));
CELL_ITERATOR& ci = *(CELL_ITERATOR*)(getScratchAddr(0) + 1024 - sizeof(CELL_ITERATOR));
#else
CELL_ITERATOR ci;
#endif
@ -337,7 +337,7 @@ char lineClear(VECTOR *v1, VECTOR *v2)
int zd; // $v1
#ifdef PSX
CELL_ITERATOR& ci = *(CELL_ITERATOR*)getScratchAddr(1024 - sizeof(CELL_ITERATOR));
CELL_ITERATOR& ci = *(CELL_ITERATOR*)(getScratchAddr(0) + 1024 - sizeof(CELL_ITERATOR));
#else
CELL_ITERATOR ci;
#endif
@ -531,7 +531,7 @@ void CollisionCopList(XZPAIR* pos, int* count)
int type;
#if 0
CELL_ITERATOR& ci = *(CELL_ITERATOR*)getScratchAddr(1024 - sizeof(CELL_ITERATOR));
CELL_ITERATOR& ci = *(CELL_ITERATOR*)(getScratchAddr(0) + 1024 - sizeof(CELL_ITERATOR));
#else
CELL_ITERATOR ci;
#endif
@ -810,7 +810,7 @@ int QuickBuildingCollisionCheck(VECTOR *pPos, int dir, int l, int w, int extra)
int dx, dz;
#if 0
CDATA2D* cd = (CDATA2D*)getScratchAddr(1024 - sizeof(CDATA2D)*2);
CDATA2D* cd = (CDATA2D*)(getScratchAddr(0) + 1024 - sizeof(CDATA2D) * 2);
#else
CDATA2D cd[2] = { 0 };
#endif

View File

@ -397,7 +397,7 @@ enum MenuSelectScreens
MenuSelectScreens iScreenSelect = SCREEN_NONE;
int bRedrawFrontend = 0;
int bRedrawFrontend = 1;
int bReturnToMain = 1;
int idle_timer = 0;
@ -1067,6 +1067,8 @@ void LoadBackgroundFile(char* name)
DrawSync(0);
SetupBackgroundPolys();
bRedrawFrontend = 1;
}
// [D] [T]