Skip to content

Commit

Permalink
60fps fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Niko committed Apr 14, 2024
1 parent b9d3f8f commit 5f1e709
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
28 changes: 28 additions & 0 deletions decompile/General/AltMods/Mods1.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,30 @@ struct Particle* NewParticleInit(struct LinkedList* param_1)
return (struct Particle*)LIST_RemoveFront(param_1);
}

void NewParticleDestroy(struct Particle* p)
{
struct Particle *pp;

// unpatch
p->prev = (int)p->prev & ~(1);

pp = p->prev;

while (pp != NULL)
{
// unpatch
pp->prev = (int)pp->prev & ~(1);

pp = pp->next;

// unpatch
pp->prev = (int)pp->prev & ~(1);

// free list of Oscillator Pool
LIST_AddFront(&sdata->gGT->JitPools.oscillator.free, pp);
}
}

// This executes one time, before the
// Crash Team Racing exe boots
void ui60_entryHook()
Expand All @@ -111,6 +135,10 @@ void ui60_entryHook()

// replace call to LIST_RemoveFront inside Particle_Init
*(unsigned int*)0x80040348 = JAL(NewParticleInit);

// hook to remove bit tagging
*(unsigned int*)0x8003eeb0 = JMP(NewParticleDestroy);
*(unsigned int*)0x8003eeb4 = 0;

// Starting line
{
Expand Down
16 changes: 4 additions & 12 deletions decompile/General/MAIN/MainFrame_GameLogic.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,19 +260,11 @@ void DECOMP_MainFrame_GameLogic(struct GameTracker* gGT, struct GamepadSystem* g
// This does not fix Underwater, or particles with function pointers
for(struct Particle* p = gGT->particleList_ordinary; p != 0; p = p->next)
{
// good thing PSX supports address mirroring,
// use the top bit to determine if particle is patched
unsigned int pointer = p->ptrIconGroup;
unsigned int topBit = pointer & 0xC0000000;
// skip if already tagged
if( ((int)p->prev) & 1 ) continue;

// topBit will be 00000000 (if null) or 80000000 (not null),
// set the bit 40000000 to prove it was patched, and the
// pointer will behave as if it was never edited (thanks psx mirroring)
if(topBit == 0x40000000) continue;

pointer = pointer & 0xfffffff;
pointer |= 0x40000000;
p->ptrIconGroup = pointer;
// tag to show that it's patched
p->prev = (unsigned int)p->prev | 1;

p->framesLeftInLife *= 2;

Expand Down

0 comments on commit 5f1e709

Please sign in to comment.