Skip to content

Commit 528f20f

Browse files
author
Niko
committed
USE_MOREPRIM is now feature-guarded
1 parent 2136ee8 commit 528f20f

4 files changed

Lines changed: 42 additions & 20 deletions

File tree

decompile/General/LOAD/LOAD_44_TenStages.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,7 @@ int DECOMP_LOAD_TenStages(struct GameTracker* gGT, int loadingStage, struct BigH
212212
sdata->levelLOD = 8;
213213
}
214214

215-
// RAM optimization, dont do this OG code
216-
#if 0
215+
#ifndef USE_MOREPRIM
217216
// OG game
218217
DECOMP_MainInit_PrimMem(gGT);
219218
DECOMP_MainInit_OTMem(gGT);
@@ -672,8 +671,8 @@ int DECOMP_LOAD_TenStages(struct GameTracker* gGT, int loadingStage, struct BigH
672671
DECOMP_MEMPACK_SwapPacks(0);
673672
DECOMP_MainInit_JitPoolsNew(gGT);
674673

675-
// end of RAM, steal rest of heap
676-
#if 1
674+
#ifdef USE_MOREPRIM
675+
// Stage 8: Fill remaining heap
677676
DECOMP_MainInit_PrimMem(gGT, 0);
678677
#endif
679678

decompile/General/MAIN/MainInit_02_PrimMem.c

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
#include <common.h>
22

3-
// force parameter is a personal optimization
4-
void DECOMP_MainInit_PrimMem(struct GameTracker* gGT, int force)
5-
{
3+
void DECOMP_MainInit_PrimMem(
4+
struct GameTracker* gGT
5+
6+
#ifdef USE_MOREPRIM
7+
, int force
8+
#endif
9+
)
610

11+
{
712
int GetOriginalSize(struct GameTracker* gGT);
813
int size = GetOriginalSize(gGT);
914

1015
int backup = 0;
1116

12-
// On PS1
13-
// Stage 0 allocates PrimMem to HighMem,
14-
// Stage 8 allocates PrimMem to fill rest of RAM
15-
#ifndef REBUILD_PC
17+
#ifdef USE_MOREPRIM
18+
19+
// On PS1
20+
// Stage 0 allocates PrimMem to HighMem,
21+
// Stage 8 allocates PrimMem to fill rest of RAM
22+
#ifndef REBUILD_PC
1623

1724
// optimization,
1825
// LOAD_TenStages: Stage 0,
@@ -69,12 +76,12 @@ void DECOMP_MainInit_PrimMem(struct GameTracker* gGT, int force)
6976
}
7077
}
7178

72-
// On PC
73-
// Stage 0 allocates all 24-bit RAM to primitives,
74-
// Stage 8 does nothing,
75-
// The rest of LOAD_TenStages can use
76-
// 32-bit addresses above 24-bit max
77-
#else
79+
// On PC
80+
// Stage 0 allocates all 24-bit RAM to primitives,
81+
// Stage 8 does nothing,
82+
// The rest of LOAD_TenStages can use
83+
// 32-bit addresses above 24-bit max
84+
#else
7885

7986
// optimization,
8087
// LOAD_TenStages: Stage 0
@@ -93,20 +100,27 @@ void DECOMP_MainInit_PrimMem(struct GameTracker* gGT, int force)
93100
return;
94101
}
95102

96-
#endif
103+
#endif // PS1 or PC
104+
105+
#endif // USE_MOREPRIM
97106

98107
DECOMP_MainDB_PrimMem(&gGT->db[0].primMem, size);
99108
DECOMP_MainDB_PrimMem(&gGT->db[1].primMem, size);
100109

101-
#ifndef REBUILD_PC
110+
#ifdef USE_MOREPRIM
111+
112+
#ifndef REBUILD_PC
102113
// Stage 0:
103114
// restore firstFreeByte for the rest
104115
// of the LOAD_TenStages loading system
105116
if(backup != 0)
106117
{
107118
sdata->mempack[0].firstFreeByte = (void*)backup;
108119
}
120+
#endif
121+
109122
#endif
123+
110124
}
111125

112126
int GetOriginalSize(struct GameTracker* gGT)

include/common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
//#define USE_BOOSTBAR // Super's reserve bar
1717
//#define USE_PROFILER // Debug profiler from PizzaHut
1818
//#define USE_4PADTEST // 1 controller for all 4 players (not done)
19+
//#define USE_MOREPRIM // Bonus Primitive Memory
1920

2021
// 8mb
2122
//#define USE_RAMEX // 8mb RAM expansion

include/decomp_functions.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,15 @@ void DECOMP_MainGameStart_Initialize(struct GameTracker* gGT, char boolStopAudio
337337
void DECOMP_MainInit_Drivers(struct GameTracker *gGT);
338338
void DECOMP_MainInit_JitPoolsNew(struct GameTracker *gGT);
339339
void DECOMP_MainInit_JitPoolsReset(struct GameTracker* gGT);
340-
void DECOMP_MainInit_PrimMem(struct GameTracker* gGT, int force);
340+
341+
void DECOMP_MainInit_PrimMem(
342+
struct GameTracker* gGT
343+
344+
#ifdef USE_MOREPRIM
345+
, int force
346+
#endif
347+
);
348+
341349
void DECOMP_MainInit_OTMem(struct GameTracker* gGT);
342350
void DECOMP_MainInit_FinalizeInit(struct GameTracker* gGT);
343351
void DECOMP_MainInit_VRAMClear(void);

0 commit comments

Comments
 (0)