mirror of
https://github.com/OpenDriver2/REDRIVER2.git
synced 2024-11-22 18:32:42 +01:00
- redone cutscene memory - no more overlay unloading!
This commit is contained in:
parent
a8a65ab17b
commit
7079f8a1ee
@ -67,8 +67,6 @@ int IsCutsceneResident(int cutscene);
|
|||||||
|
|
||||||
|
|
||||||
#ifndef PSX
|
#ifndef PSX
|
||||||
char* gCustomCutsceneBuffer;
|
|
||||||
|
|
||||||
char gUserReplayFolderList[MAX_USER_REPLAYS][48];
|
char gUserReplayFolderList[MAX_USER_REPLAYS][48];
|
||||||
int gNumUserChases = 0;
|
int gNumUserChases = 0;
|
||||||
int gUserChaseLoaded = -1;
|
int gUserChaseLoaded = -1;
|
||||||
@ -547,6 +545,7 @@ int LoadInGameCutscene(int subindex)
|
|||||||
if (CutsceneInReplayBuffer)
|
if (CutsceneInReplayBuffer)
|
||||||
return LoadCutsceneToBuffer(subindex);
|
return LoadCutsceneToBuffer(subindex);
|
||||||
|
|
||||||
|
// first cutscene (intro) always goes to replay buffer
|
||||||
if (LoadCutsceneToBuffer(subindex))
|
if (LoadCutsceneToBuffer(subindex))
|
||||||
{
|
{
|
||||||
if (LoadCutsceneToReplayBuffer(0))
|
if (LoadCutsceneToReplayBuffer(0))
|
||||||
@ -876,31 +875,6 @@ int LoadCutsceneToReplayBuffer(int residentCutscene)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef PSX
|
|
||||||
int LoadChaseReplayFromFile(char *filename, int subindex, int userId = -1)
|
|
||||||
{
|
|
||||||
gUserChaseLoaded = userId;
|
|
||||||
|
|
||||||
int size = LoadfileSeg(filename, gCustomCutsceneBuffer, 0, 0xffff);
|
|
||||||
|
|
||||||
if (size != 0)
|
|
||||||
{
|
|
||||||
// load into custom buffer
|
|
||||||
printInfo("Custom chase '%s' loaded\n", filename);
|
|
||||||
|
|
||||||
CutsceneBuffer.residentCutscenes[CutsceneBuffer.numResident] = subindex;
|
|
||||||
CutsceneBuffer.residentPointers[CutsceneBuffer.numResident] = gCustomCutsceneBuffer;
|
|
||||||
CutsceneBuffer.numResident++;
|
|
||||||
|
|
||||||
gCustomCutsceneBuffer += size;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// [D] [T]
|
// [D] [T]
|
||||||
int LoadCutsceneToBuffer(int subindex)
|
int LoadCutsceneToBuffer(int subindex)
|
||||||
{
|
{
|
||||||
@ -932,10 +906,10 @@ int LoadCutsceneToBuffer(int subindex)
|
|||||||
if (userId != -1)
|
if (userId != -1)
|
||||||
sprintf(filename, "REPLAYS\\UserChases\\%s\\CUT%d_N.R", (char*)gUserReplayFolderList[userId], gCurrentMissionNumber);
|
sprintf(filename, "REPLAYS\\UserChases\\%s\\CUT%d_N.R", (char*)gUserReplayFolderList[userId], gCurrentMissionNumber);
|
||||||
|
|
||||||
//gUserChaseLoaded = userId;
|
if(FileExists(filename))
|
||||||
|
gUserChaseLoaded = userId;
|
||||||
|
else
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!FileExists(filename)) // fallback
|
|
||||||
sprintf(filename, "REPLAYS\\ReChases\\CUT%d_N.R", gCurrentMissionNumber);
|
sprintf(filename, "REPLAYS\\ReChases\\CUT%d_N.R", gCurrentMissionNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -958,6 +932,45 @@ int LoadCutsceneToBuffer(int subindex)
|
|||||||
offset = header.data[subindex].offset * 4;
|
offset = header.data[subindex].offset * 4;
|
||||||
size = header.data[subindex].size;
|
size = header.data[subindex].size;
|
||||||
|
|
||||||
|
// [A] if starting game - allocate new buffer
|
||||||
|
if (CutsceneBuffer.currentPointer == NULL)
|
||||||
|
{
|
||||||
|
if(CutsceneInReplayBuffer)
|
||||||
|
{
|
||||||
|
// reserve new buffer with malloc
|
||||||
|
if (CutsceneBuffer.reservedSize == 0)
|
||||||
|
{
|
||||||
|
int i, maxSize;
|
||||||
|
|
||||||
|
maxSize = 0;
|
||||||
|
for (i = 2; i < 15; i++)
|
||||||
|
{
|
||||||
|
if (header.data[i].size > maxSize)
|
||||||
|
maxSize = header.data[i].size;
|
||||||
|
}
|
||||||
|
|
||||||
|
maxSize += MAX(header.data[0].size, header.data[1].size);
|
||||||
|
|
||||||
|
CutsceneBuffer.reservedSize = maxSize;
|
||||||
|
CutsceneBuffer.buffer = D_MALLOC(maxSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
CutsceneBuffer.currentPointer = CutsceneBuffer.buffer;
|
||||||
|
CutsceneBuffer.bytesFree = CutsceneBuffer.reservedSize;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// obtain temp buffer
|
||||||
|
CutsceneBuffer.currentPointer = D_TEMPALLOC(size);
|
||||||
|
CutsceneBuffer.bytesFree = size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
WE DON'T NEED IT ANYMORE! EVEN ON PSX!
|
||||||
|
|
||||||
|
// we keep fallback here
|
||||||
if (size > CutsceneBuffer.bytesFree)
|
if (size > CutsceneBuffer.bytesFree)
|
||||||
{
|
{
|
||||||
printWarning("WARNING - Using leadAI/pathAI buffer for cutscene!\n");
|
printWarning("WARNING - Using leadAI/pathAI buffer for cutscene!\n");
|
||||||
@ -968,13 +981,14 @@ int LoadCutsceneToBuffer(int subindex)
|
|||||||
|
|
||||||
CutsceneBuffer.currentPointer = (char*)_other_buffer2;
|
CutsceneBuffer.currentPointer = (char*)_other_buffer2;
|
||||||
CutsceneBuffer.bytesFree = 0xC000;
|
CutsceneBuffer.bytesFree = 0xC000;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
LoadfileSeg(filename, CutsceneBuffer.currentPointer, offset, size);
|
LoadfileSeg(filename, CutsceneBuffer.currentPointer, offset, size);
|
||||||
|
|
||||||
CutsceneBuffer.residentCutscenes[CutsceneBuffer.numResident] = subindex;
|
CutsceneBuffer.residentCutscenes[CutsceneBuffer.numResident] = subindex;
|
||||||
CutsceneBuffer.residentPointers[CutsceneBuffer.numResident] = CutsceneBuffer.currentPointer;
|
CutsceneBuffer.residentPointers[CutsceneBuffer.numResident] = CutsceneBuffer.currentPointer;
|
||||||
CutsceneBuffer.numResident++;
|
CutsceneBuffer.numResident++;
|
||||||
|
|
||||||
CutsceneBuffer.currentPointer += size;
|
CutsceneBuffer.currentPointer += size;
|
||||||
CutsceneBuffer.bytesFree -= size;
|
CutsceneBuffer.bytesFree -= size;
|
||||||
|
|
||||||
@ -1037,7 +1051,7 @@ int LoadCutsceneInformation(int cutscene)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1054,14 +1068,16 @@ void FreeCutsceneBuffer(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CutsceneBuffer.numResident = 0;
|
CutsceneBuffer.numResident = 0;
|
||||||
CutsceneBuffer.currentPointer = CutsceneBuffer.buffer;
|
|
||||||
|
|
||||||
CutsceneBuffer.bytesFree = sizeof(CutsceneBuffer.buffer);
|
|
||||||
ClearMem(CutsceneBuffer.buffer, sizeof(CutsceneBuffer.buffer));
|
|
||||||
|
|
||||||
#ifndef PSX
|
if (NewLevel) // [A] since we use malloctab we need to let it go...
|
||||||
gCustomCutsceneBuffer = (char*)_other_buffer2;
|
{
|
||||||
#endif
|
CutsceneBuffer.buffer = NULL;
|
||||||
|
CutsceneBuffer.reservedSize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
CutsceneBuffer.currentPointer = NULL;
|
||||||
|
CutsceneBuffer.bytesFree = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// [D] [T]
|
// [D] [T]
|
||||||
|
@ -52,25 +52,28 @@ void InitDrivingGames(void)
|
|||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
|
if (NewLevel)
|
||||||
|
gTrailblazerData = NULL;
|
||||||
|
|
||||||
gPlayerScore.time = 0;
|
gPlayerScore.time = 0;
|
||||||
gTrailblazerData = NULL;
|
|
||||||
gPlayerScore.items = 0;
|
gPlayerScore.items = 0;
|
||||||
gPlayerScore.P2time = 0;
|
gPlayerScore.P2time = 0;
|
||||||
gPlayerScore.P2items = 0;
|
gPlayerScore.P2items = 0;
|
||||||
|
|
||||||
if (GameType == GAME_GATERACE || GameType == GAME_TRAILBLAZER)
|
if (GameType == GAME_GATERACE || GameType == GAME_TRAILBLAZER)
|
||||||
{
|
{
|
||||||
D_CHECK_ERROR(CutsceneBuffer.bytesFree < 1200, "Cutscene buffer is less than 1200 bytes");
|
|
||||||
|
|
||||||
gTrailblazerConeCount = 0;
|
gTrailblazerConeCount = 0;
|
||||||
gTrailblazerConeIndex = 0;
|
gTrailblazerConeIndex = 0;
|
||||||
gTrailblazerData = (TRAILBLAZER_DATA *)CutsceneBuffer.currentPointer;
|
|
||||||
|
|
||||||
CutsceneBuffer.bytesFree -= 1200;
|
if(NewLevel)
|
||||||
sprintf(filename, "TRAILS\\TRAIL.%d", gCurrentMissionNumber);
|
{
|
||||||
|
gTrailblazerData = (TRAILBLAZER_DATA*)D_MALLOC(1200); // [A] use malloc
|
||||||
|
|
||||||
if (FileExists(filename) != 0)
|
sprintf(filename, "TRAILS\\TRAIL.%d", gCurrentMissionNumber);
|
||||||
Loadfile(filename, (char *)gTrailblazerData);
|
|
||||||
|
if (FileExists(filename) != 0)
|
||||||
|
Loadfile(filename, (char*)gTrailblazerData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 2; i++)
|
for (i = 0; i < 2; i++)
|
||||||
|
@ -1399,9 +1399,13 @@ struct CUTSCENE_BUFFER
|
|||||||
int numResident;
|
int numResident;
|
||||||
u_char residentCutscenes[4];
|
u_char residentCutscenes[4];
|
||||||
char(*residentPointers[4]);
|
char(*residentPointers[4]);
|
||||||
|
|
||||||
|
char* buffer;
|
||||||
char* currentPointer;
|
char* currentPointer;
|
||||||
|
|
||||||
int bytesFree;
|
int bytesFree;
|
||||||
char buffer[32*1024]; // was 8192, but we have some free mem now even for PSX
|
int reservedSize;
|
||||||
|
// char buffer[32*1024]; // was 8192, but we have some free mem now even for PSX. Using malloc.
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CUTSCENE_INFO
|
struct CUTSCENE_INFO
|
||||||
|
Loading…
Reference in New Issue
Block a user