more array size zero fixes

This commit is contained in:
Niko 2023-11-06 13:38:58 -05:00
parent 4414746afe
commit 78d3aa6f47
7 changed files with 33 additions and 25 deletions

View File

@ -18,6 +18,7 @@ void GhostReplay_Init1(void)
struct GhostHeader* gh;
struct GhostTape* tape;
int charID;
char* recordBuffer;
struct GameTracker *gGT = sdata->gGT;
@ -33,9 +34,10 @@ void GhostReplay_Init1(void)
// In the future, this can move to GhostTape_Start, when byte budget allows
gh = MEMPACK_AllocMem(0x3e00/*, "ghost record buffer"*/);
recordBuffer = GHOSTHEADER_GETRECORDBUFFER(gh);
sdata->GhostRecording.ptrGhost = gh;
sdata->GhostRecording.ptrStartOffset = &gh->recordBuffer[0];
sdata->GhostRecording.ptrEndOffset = &gh->recordBuffer[0x3DD4];
sdata->GhostRecording.ptrStartOffset = &recordBuffer[0];
sdata->GhostRecording.ptrEndOffset = &recordBuffer[0x3DD4];
// === Replay Buffer ===
// 0: human ghost
@ -86,12 +88,13 @@ void GhostReplay_Init1(void)
}
sdata->boolGhostsDrawing = 1;
recordBuffer = GHOSTHEADER_GETRECORDBUFFER(gh);
tape->gh = gh;
tape->gh_again = gh;
tape->constDEADC0ED = 0xDEADC0ED;
tape->ptrStart = &gh->recordBuffer[0];
tape->ptrEnd = &gh->recordBuffer[gh->size];
tape->ptrStart = &recordBuffer[0];
tape->ptrEnd = &recordBuffer[gh->size];
tape->ptrCurr = tape->ptrStart;
tape->timeElapsedInRace = 0;
tape->timeInPacket32_backup = 0;

View File

@ -41,11 +41,8 @@ int DECOMP_Bank_AssignSpuAddrs()
for(i = 0; i < sdata->ptrSampleBlock1->numSamples; i++)
{
sdata->audioAllocSize +=
sdata->howl_spuAddrs
[
sdata->ptrSampleBlock1->spuIndex[i]
].spuSize;
short* spuIndexArr = SBHEADER_GETARR(sdata->ptrSampleBlock1);
sdata->audioAllocSize += sdata->howl_spuAddrs[spuIndexArr[i]].spuSize;
}
// convert bit-shifted count to
@ -106,11 +103,8 @@ int DECOMP_Bank_AssignSpuAddrs()
for(i = 0; i < sdata->ptrSampleBlock1->numSamples; i++)
{
sae =
&sdata->howl_spuAddrs
[
sdata->ptrSampleBlock1->spuIndex[i]
];
short* spuIndexArr = SBHEADER_GETARR(sdata->ptrSampleBlock1);
sae = &sdata->howl_spuAddrs[spuIndexArr[i]];
if(sae->spuAddr == 0)
{

View File

@ -62,9 +62,11 @@ void DECOMP_SongPool_Start(
song->vol_StepRate = 1;
song->numSequences = 0;
short* seqOffsetArr = SONGHEADER_GETSEQOFFARR(csh);
// first note header comes after end of CseqSongHeader
// and the full array of seqOffsets within the header
cnhFirst = &csh->seqOffsetArr[csh->numSeqs];
cnhFirst = &seqOffsetArr[csh->numSeqs];
// align up by 4
if(((int)cnhFirst & 2) != 0) cnhFirst += 2;
@ -72,7 +74,7 @@ void DECOMP_SongPool_Start(
for(i = 0; i < csh->numSeqs; i++)
{
cnhCurr = &cnhFirst[csh->seqOffsetArr[i]];
cnhCurr = &cnhFirst[seqOffsetArr[i]];
seqCurr = SongPool_FindFreeChannel();
if(seqCurr == NULL) continue;
@ -123,7 +125,7 @@ void DECOMP_SongPool_Start(
seqCurr->NoteLength = 0;
seqCurr->NoteTimeElapsed = 0;
seqCurr->firstNote = &cnhCurr->notes[0];
seqCurr->firstNote = NOTEHEADER_GETNOTES(cnhCurr);
seqCurr->currNote =
howl_GetNextNote(seqCurr->firstNote, &seqCurr->NoteLength);

View File

@ -5,7 +5,7 @@ void DECOMP_MainInit_VisMem(struct GameTracker* gGT) {
struct VisMem* visMem = gGT->level1->visMem;
if(visMem == NULL) return;
visMem = gGT->visMem1;
gGT->visMem1 = visMem;
for (int i = 0; i < gGT->numPlyrCurrGame; i++)
{
visMem->visLeafSrc[i] = 0;

View File

@ -1369,7 +1369,7 @@ uint FUN_800293b8(void)
(uint)*(ushort *)
// howl_spuAddrs[sampleBlockHeader->spuIndex[iVar3]].size
// howl_spuAddrs[sampleBlockHeader->spuIndexArr[iVar3]].size
(
// sampleBlock->???->size?
(uint)*(ushort *)((int)DAT_8008d784 + iVar3 + 2) * 4 +
@ -1438,7 +1438,7 @@ uint FUN_800293b8(void)
// loop through all samples in the block
do
{
// howl_spuAddrs[sampleBlock->spuIndex[iVar3]]
// howl_spuAddrs[sampleBlock->spuIndexArr[iVar3]]
psVar5 = (short *)((uint)DAT_8008d784[iVar3 + 1] * 4 + iVar2);
// if not specified

View File

@ -98,5 +98,8 @@ struct GhostHeader
char emptyPadding[0x14];
// 0x28
char recordBuffer[0]; // yes, zero bytes
};
//char recordBuffer[0]; // yes, zero bytes
};
#define GHOSTHEADER_GETRECORDBUFFER(x) \
((unsigned int)x + sizeof(struct GhostHeader))

View File

@ -259,8 +259,10 @@ struct CseqSongHeader
// size of numSeqs
// each seq is an array of SongNote
short seqOffsetArr[0];
//short seqOffsetArr[0];
};
#define SONGHEADER_GETSEQOFFARR(x) \
((unsigned int)x + sizeof(struct CseqSongHeader))
// right before first note
struct SongNoteHeader
@ -270,8 +272,10 @@ struct SongNoteHeader
char unk;
char notes[0];
//char notes[0];
};
#define NOTEHEADER_GETNOTES(x) \
((unsigned int)x + sizeof(struct SongNoteHeader))
// AKA: SongNote
struct SongOpcode
@ -418,8 +422,10 @@ struct SampleBlockHeader
{
short numSamples;
short spuIndex[0];
//short spuIndexArr[0];
};
#define SBHEADER_GETARR(x) \
((unsigned int)x + sizeof(struct SampleBlockHeader))
struct SpuAddrEntry
{