Merge pull request #35 from SoapyMan/develop-SoapyMan

Develop soapy man
This commit is contained in:
Ilya 2020-09-29 09:41:24 +06:00 committed by GitHub
commit d24ff50614
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 132 additions and 60 deletions

View File

@ -58,12 +58,12 @@ before_build:
- cmd: premake5 vs2019
- cmd: ren "%JPEG_DIR%\jconfig.vc" "jconfig.h"
artifacts:
- path: src_rebuild\bin\%configuration%\*.zip
name: Binaries
#artifacts:
# - path: src_rebuild\bin\%configuration%\*.zip
# name: Binaries
after_build:
- cmd: cd %project_folder%\bin\%configuration%
- 7z a REDRIVER2.zip ".\*"
#after_build:
# - cmd: cd %project_folder%\bin\%configuration%
# - 7z a REDRIVER2.zip ".\*"
#build: off

View File

@ -13,7 +13,7 @@ short SQRT[] = {
0x18a8, 0x18bd, 0x18d1, 0x18e6, 0x18fa, 0x190f, 0x1923, 0x1938,
0x194c, 0x1960, 0x1974, 0x1988, 0x199c, 0x19b0, 0x19c4, 0x19d8,
0x19ec, 0x1a00, 0x1a13, 0x1a27, 0x1a3a, 0x1a4e, 0x1a61, 0x1a75,
0x1a88, 0x1a9b, 0x1aae, 0x1ac2, 0xa1d5, 0x1ae8, 0x1afb, 0x1b0e,
0x1a88, 0x1a9b, 0x1aae, 0x1ac2, 0x1ad5, 0x1ae8, 0x1afb, 0x1b0e,
0x1b21, 0x1b33, 0x1b46, 0x1b59, 0x1b6c, 0x1b7e, 0x1b91, 0x1ba3,
0x1bb6, 0x1bc8, 0x1bdb, 0x1bed, 0x1c00, 0x1c12, 0x1c24, 0x1c36,
0x1c48, 0x1c5a, 0x1c6c, 0x1c7e, 0x1c90, 0x1ca2, 0x1cb4, 0x1cc6,

View File

@ -272,6 +272,11 @@ extern int docop2(int op);
*(uint*)((char*)r0 + 4) = CFC2(22);\
*(uint*)((char*)r0 + 8) = CFC2(23);
// ctc2 24,25
#define gte_SetGeomOffset( r0, r1 )\
CTC2(r0 << 16, 24); \
CTC2(r1 << 16, 25); \
// TODO: GTEMAC
#define gte_RotTransPers3(r1,r2,r3,r4,r5,r6,r7,r8,r9) \
{ gte_ldv3(r1,r2,r3); \

View File

@ -1687,10 +1687,9 @@ long ratan2(long y, long x)
long SquareRoot0(long a)
{
#if 1
#if 0
return sqrtl(a);
#else
// working but bugged
int idx;
int lzcs;
lzcs = gte_leadingzerocount(a);
@ -1705,6 +1704,6 @@ long SquareRoot0(long a)
else
idx = a << (lzcs - 24);
return (SQRT[idx - 64] << ((31 - lzcs) >> 1)) >> 12;
return SQRT[idx - 64] << (31 - lzcs >> 1) >> 12;
#endif
}

View File

@ -3557,7 +3557,7 @@ int PingOutAllCivCarsAndCopCars(void)
do {
if (cp->controlType == CONTROL_TYPE_CIV_AI && cp->controlType == CONTROL_TYPE_PURSUER_AI)
if (cp->controlType == CONTROL_TYPE_CIV_AI || cp->controlType == CONTROL_TYPE_PURSUER_AI)
PingOutCar(cp);
cp++;
@ -4958,7 +4958,7 @@ int CivControl(_CAR_DATA * cp)
if (cp->ai.c.thrustState != 3)
cp->wheel_angle = CivSteerAngle(cp);
#if 1
#if 0
{
//maxCivCars = 2;
//maxCopCars = 0;

View File

@ -540,7 +540,7 @@ int CarConeCollision(VECTOR *pPos, int car)
cd[0].x.vz = pPos->vz;
cd[0].length[0] = 0x28;
cd[0].length[1] = 0x28;
cd[0].theta = 0;
cd[0].theta = pPos->pad;
if (car_data[car].controlType == CONTROL_TYPE_NONE)
return 0;
@ -979,6 +979,7 @@ void GetConePos(int cone, VECTOR *pos, int side)
pos->vx = pTVar2->x;
pos->vy = pTVar2->y;
pos->vz = pTVar2->z;
pos->pad = pTVar2->rot; // [A] store cone rotation
}
else
{
@ -1005,6 +1006,7 @@ void GetConePos(int cone, VECTOR *pos, int side)
}
pos->vz = pTVar2->z + iVar4;
pos->pad = pTVar2->rot;
}
}

View File

@ -643,21 +643,20 @@ void GetRandomChase(void)
// [D]
int FindPrevMissionFromLadderPos(int pos)
{
if (pos-- > 0)
MISSION_STEP *step = &MissionLadder[pos];
while (pos-- > 0)
{
MISSION_STEP *step = &MissionLadder[pos];
do {
if (step->flags == 2) {
int mission = step->data;
if (step->flags == 2)
{
int mission = step->data;
if (gFurthestMission < mission)
gFurthestMission = mission;
if (gFurthestMission < mission)
gFurthestMission = mission;
return 1;
}
return 1;
}
step--;
} while (pos-- > 0);
step--;
}
return 0;

View File

@ -10,11 +10,53 @@
#include "MISSION.H"
#include "COP_AI.H"
#include "SCORES.H"
#include "LIBGPU.H"
#include "LIBETC.H"
#include "E3STUFF.H"
#include "PRES.H"
#include "PAUSE.H"
#ifndef PSX
#include <stdlib.h>
#include <direct.h>
// [A]
void ShowSavingWaitMessage(char *message, int height)
{
char *filename;
DISPENV disp;
DRAWENV draw;
DrawSync(0);
VSync(0);
SetDispMask(0);
SetupDefDrawEnv(&draw, 0, 0, 320, 256);
SetupDefDispEnv(&disp, 0, 0, 320, 256);
draw.dfe = 1;
PutDrawEnv(&draw);
PutDispEnv(&disp);
LoadFont(NULL);
#ifndef PSX
Emulator_BeginScene();
SetDispMask(1);
#endif
gShowMap = 1;
PrintStringCentred(message, 128 + height);
gShowMap = 0;
VSync(0);
#ifndef PSX
Emulator_EndScene();
Emulator_WaitForTimestep(40);
#endif // PSX
}
void GetGameProfilePath(char* str)
{
char* homepath;
@ -40,12 +82,30 @@ void LoadCurrentProfile()
{
char filePath[2048];
int fileSize;
int error;
GetGameProfilePath(filePath);
strcat(filePath, "/config.dat");
printMsg("Loading game configuration...\n");
{
RECT16 rect;
SetupDrawBuffers();
rect.x = 0;
rect.y = 0;
rect.w = 320;
rect.h = 512;
ClearImage(&rect, 0, 0, 0);
DrawSync(0);
}
SetTextColour(128, 128, 64);
ShowSavingWaitMessage("Loading configuration...", 0);
error = 1;
// load config
FILE* fp = fopen(filePath, "rb");
@ -62,32 +122,61 @@ void LoadCurrentProfile()
if (fileSize <= CalcConfigDataSize())
{
LoadConfigData(_other_buffer);
error = 0;
}
}
if (error)
{
SetTextColour(128, 0, 0);
ShowSavingWaitMessage("Loading error", 0);
}
else
{
ShowSavingWaitMessage("OK", 0);
}
SetMasterVolume(gMasterVolume);
}
// [A] saves config to file
void SaveCurrentProfile()
{
int dataSize = 0;
int dataSize;
char filePath[2048];
int error;
GetGameProfilePath(filePath);
strcat(filePath, "/config.dat");
printMsg("Saving game configuration...\n");
SetTextColour(128, 128, 64);
ShowSavingWaitMessage("Saving configuration...", 0);
dataSize = 0;
if (SaveConfigData(_other_buffer))
dataSize = CalcConfigDataSize();
error = 1;
// load config
FILE* fp = fopen(filePath, "wb");
if (fp)
{
fwrite(_other_buffer, 1, dataSize, fp);
fclose(fp);
error = 0;
}
if (error)
{
SetTextColour(128, 0, 0);
ShowSavingWaitMessage("Saving error", 0);
}
else
{
ShowSavingWaitMessage("OK", 0);
}
}
@ -101,7 +190,8 @@ int LoadCurrentGame()
strcat(filePath, "/progress.dat");
printMsg("Saving game progress...\n");
SetTextColour(128, 128, 64);
ShowSavingWaitMessage("Loading progress...", 0);
// load config
FILE* fp = fopen(filePath, "rb");
@ -128,8 +218,6 @@ int LoadCurrentGame()
// [A] saves current game progress
void SaveCurrentGame()
{
SaveCurrentProfile(); // profile has to be saved too
int dataSize = 0;
char filePath[2048];
@ -137,7 +225,8 @@ void SaveCurrentGame()
strcat(filePath, "/progress.dat");
printMsg("Saving game progress...\n");
SetTextColour(128, 128, 64);
ShowSavingWaitMessage("Saving progress...", 0);
dataSize = 0;
if (SaveGameData(_other_buffer))

View File

@ -2496,6 +2496,8 @@ int redriver2_main(int argc, char** argv)
InitialiseScoreTables();
LoadCurrentProfile();
#ifndef PSX
for (int i = 1; i < argc; i++)
{
@ -2646,8 +2648,6 @@ int redriver2_main(int argc, char** argv)
}
#endif // PSX
LoadCurrentProfile();
// now run the frontend
DoFrontEnd();

View File

@ -2604,7 +2604,7 @@ void TannerShadow(PEDESTRIAN* pDrawingPed, VECTOR *pPedPos, SVECTOR *pLightPos,
// [A] not supported by emulator
// proposed change: double buffering of VRAM (one used as render target, second as texture)
return;
#ifdef PSX
memset(&d, 0, sizeof(VECTOR));
memset(&myVector, 0, sizeof(VECTOR));
@ -2720,8 +2720,7 @@ void TannerShadow(PEDESTRIAN* pDrawingPed, VECTOR *pPedPos, SVECTOR *pLightPos,
SetBasePos(&myVector);
cVar9 = tracking_car;
setCopControlWord(2, 0xc000, 0x200000); // hmmmm?
setCopControlWord(2, 0xc800, 0x800000);
gte_SetGeomOffset(32, 128);
tracking_car = 1;
PlaceCameraAtLocation(&player[0], 0);
@ -2739,8 +2738,8 @@ void TannerShadow(PEDESTRIAN* pDrawingPed, VECTOR *pPedPos, SVECTOR *pLightPos,
BuildWorldMatrix();
InitCamera(&player[0]);
setCopControlWord(2, 0xc000, 0xa00000);
setCopControlWord(2, 0xc800, 0x800000);
gte_SetGeomOffset(160, 128);
SetDefDrawEnv(&drEnv, rectTannerWindow.x, rectTannerWindow.y, rectTannerWindow.w, rectTannerWindow.h);
dr_env = (DR_ENV*)current->primptr;
@ -2748,6 +2747,7 @@ void TannerShadow(PEDESTRIAN* pDrawingPed, VECTOR *pPedPos, SVECTOR *pLightPos,
addPrim(current->ot + 0x107f, dr_env);
current->primptr += sizeof(DR_ENV);
#endif
}

View File

@ -2,28 +2,6 @@
#define REVERSING_H
// reverse engineering stuff
// Ghidra stuff
#define _CopReg0 gteRegs.CP0
#define _CopReg2 gteRegs.CP2D
#define copReg(n, reg) _CopReg##n.p[reg]
#define getCopReg(n, reg) copReg(n, reg).d
#define setCopReg(n, reg, value) (copReg(n, reg).d = value)
#define _CopControlWord2 gteRegs.CP2C
#define copControlWord(n, reg) _CopControlWord##n.p[reg]
#define getCopControlWord(n, reg) copControlWord(n, reg).d
#define setCopControlWord(n, reg, value) (copControlWord(n, reg).d = value)
#define _CopFunc2 docop2
#define copFunction(n, op) _CopFunc##n(op)
//----------------------------------------
// byte swapped short