mirror of
https://github.com/perfect-dark-pc-port/perfect_dark.git
synced 2026-10-23 15:52:41 +02:00
portx64: lots of adjustments in memory allocations/data sizes/offsets etc
This commit is contained in:
1 parent
b0e6e8f24f
commit
00c990eded
12 files changed
+82
-33
No files matched your search
+2
-2
@@ -763,7 +763,7 @@ Gfx *bgRenderGdlInXray(Gfx *gdl, s8 *readgdl, Vtx *vertices, s16 arg3[3])
|
||||
gdl = bgProcessXrayTri(gdl, &xraydata, dmemvertices[x], dmemvertices[y], dmemvertices[z], dmemcolours[x], dmemcolours[y], dmemcolours[z], inrange[x], inrange[y], inrange[z]);
|
||||
}
|
||||
|
||||
readgdl += 8;
|
||||
readgdl += sizeof(Gfx);
|
||||
}
|
||||
|
||||
gdl = bgRenderXrayData(gdl, &xraydata);
|
||||
@@ -1606,7 +1606,7 @@ void bgReset(s32 stagenum)
|
||||
var800a4920 = *(u32 *)g_BgPrimaryData;
|
||||
|
||||
if (var800a4920 == 0) {
|
||||
g_BgPrimaryData2 = (u32 *)g_BgPrimaryData;
|
||||
g_BgPrimaryData2 = (uintptr_t*)g_BgPrimaryData;
|
||||
g_BgRooms = (struct bgroom *)(g_BgPrimaryData2[1] + g_BgPrimaryData - 0x0f000000);
|
||||
goto foo; foo:;
|
||||
g_Vars.roomcount = 0;
|
||||
|
||||
@@ -165,8 +165,13 @@ u32 fill2[1];
|
||||
|
||||
Lights1 var80070090 = gdSPDefLights1(0x96, 0x96, 0x96, 0xff, 0xff, 0xff, 0xb2, 0x4d, 0x2e);
|
||||
|
||||
#ifdef PLATFORM_64BIT
|
||||
u32 g_BgunGunMemBaseSizeDefault = 150 * 1024 * 2; // #TODO adjust these values properly
|
||||
u32 g_BgunGunMemBaseSize4Mb2P = 120 * 1024 * 2;
|
||||
#else
|
||||
u32 g_BgunGunMemBaseSizeDefault = 150 * 1024;
|
||||
u32 g_BgunGunMemBaseSize4Mb2P = 120 * 1024;
|
||||
#endif
|
||||
|
||||
u16 g_CartFileNums[] = {
|
||||
FILE_GCARTRIDGE,
|
||||
@@ -3844,6 +3849,9 @@ void bgunTickGunLoad(void)
|
||||
|
||||
// Reserve some space for textures
|
||||
allocsize = fileGetLoadedSize(player->gunctrl.loadfilenum) + 0xe00;
|
||||
#ifdef PLATFORM_64BIT
|
||||
allocsize += 0xe00;
|
||||
#endif
|
||||
|
||||
osSyncPrintf("BriGun: Used size %d (Ob Size %d)\n");
|
||||
osSyncPrintf("BriGun: block len %d usedsize %d\n");
|
||||
|
||||
@@ -592,7 +592,11 @@ void func0f001c0c(void)
|
||||
table2size = align16(g_NumPortals * 4);
|
||||
table3size = align16(g_Vars.roomcount * 4);
|
||||
table4size = align16((u32)var8009cae0 * (u32)var8009cae0);
|
||||
#ifdef PLATFORM_64BIT
|
||||
sp68 = align16(g_Vars.roomcount * 8 * 2);
|
||||
#else
|
||||
sp68 = align16(g_Vars.roomcount * 8);
|
||||
#endif
|
||||
|
||||
mempGetStageFree();
|
||||
|
||||
@@ -1695,11 +1699,19 @@ void func0f004c6c(void)
|
||||
u8 *ptr;
|
||||
u8 *backupptr;
|
||||
|
||||
#ifdef PLATFORM_64BIT
|
||||
sp44 = align16(0x2000 * 2);
|
||||
sp40 = align16(g_NumPortals * 4 * 2);
|
||||
sp3c = align16(g_NumPortals * 0xc * 2);
|
||||
sp38 = align16(g_NumPortals * 4 * 2);
|
||||
sp34 = align16(g_NumPortals * 2 * 2);
|
||||
#else
|
||||
sp44 = align16(0x2000);
|
||||
sp40 = align16(g_NumPortals * 4);
|
||||
sp3c = align16(g_NumPortals * 0xc);
|
||||
sp38 = align16(g_NumPortals * 4);
|
||||
sp34 = align16(g_NumPortals * 2);
|
||||
#endif
|
||||
|
||||
for (i = 0, s4 = sp38; i < g_NumPortals; i++) {
|
||||
if (i != 0) {
|
||||
|
||||
@@ -148,7 +148,11 @@ void *gfxAllocateMatrix(void)
|
||||
LookAt *gfxAllocateLookAt(s32 count)
|
||||
{
|
||||
void *ptr = g_GfxMemPos;
|
||||
#ifdef PLATFORM_64BIT
|
||||
g_GfxMemPos += count * (sizeof(LookAt) * 2);
|
||||
#else
|
||||
g_GfxMemPos += count * (sizeof(LookAt) / 2);
|
||||
#endif
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
+9
-7
@@ -109,6 +109,10 @@ struct model *modelmgrInstantiateModel(struct modeldef *modeldef, bool withanim)
|
||||
struct model *model = NULL;
|
||||
u32 *rwdatas = NULL;
|
||||
s16 datalen = -1;
|
||||
s16 extra = 0;
|
||||
#ifdef PLATFORM_64BIT
|
||||
extra = 128;
|
||||
#endif
|
||||
s32 i;
|
||||
|
||||
if (!g_ModelIsLvResetting) {
|
||||
@@ -148,7 +152,7 @@ struct model *modelmgrInstantiateModel(struct modeldef *modeldef, bool withanim)
|
||||
} else {
|
||||
// At this point, it's during gameplay. A model instance slot has
|
||||
// been found or allocated, but rwdata needs to be allocated.
|
||||
if (modeldef->rwdatalen < 256) {
|
||||
if (modeldef->rwdatalen < 256+extra) {
|
||||
bool done = false;
|
||||
u32 stack;
|
||||
|
||||
@@ -181,7 +185,7 @@ struct model *modelmgrInstantiateModel(struct modeldef *modeldef, bool withanim)
|
||||
|
||||
// 256 words (0x400 bytes) or less -> try type 3
|
||||
// First looking for unused slots with an existing rwdata allocation
|
||||
if (!done && modeldef->rwdatalen <= 256) {
|
||||
if (!done && modeldef->rwdatalen <= 256+extra) {
|
||||
for (i = 0; i < NUMTYPE3(); i++) {
|
||||
if (g_ModelRwdataBindings[2][i].model == NULL && g_ModelRwdataBindings[2][i].rwdata != NULL) {
|
||||
osSyncPrintf("MotInst: Using cache entry type 3 %d (0x%08x) - Bytes=%d\n");
|
||||
@@ -195,10 +199,10 @@ struct model *modelmgrInstantiateModel(struct modeldef *modeldef, bool withanim)
|
||||
}
|
||||
|
||||
// Type 3 again, but looking for null rwdata allocations
|
||||
if (!done && modeldef->rwdatalen <= 256) {
|
||||
if (!done && modeldef->rwdatalen <= 256+extra) {
|
||||
for (i = 0; i < NUMTYPE3(); i++) {
|
||||
if (g_ModelRwdataBindings[2][i].model == NULL && g_ModelRwdataBindings[2][i].rwdata == NULL) {
|
||||
g_ModelRwdataBindings[2][i].rwdata = mempAlloc(256 * 4, MEMPOOL_STAGE);
|
||||
g_ModelRwdataBindings[2][i].rwdata = mempAlloc((256+128) * 4, MEMPOOL_STAGE);
|
||||
rwdatas = g_ModelRwdataBindings[2][i].rwdata;
|
||||
g_ModelRwdataBindings[2][i].model = model;
|
||||
break;
|
||||
@@ -215,9 +219,7 @@ struct model *modelmgrInstantiateModel(struct modeldef *modeldef, bool withanim)
|
||||
datalen = IS4MB() ? 52 : 256;
|
||||
}
|
||||
|
||||
#ifdef PLATFORM_64BIT
|
||||
datalen += 128;
|
||||
#endif
|
||||
datalen += extra;
|
||||
|
||||
if (datalen < modeldef->rwdatalen) {
|
||||
datalen = modeldef->rwdatalen;
|
||||
|
||||
@@ -101,17 +101,17 @@ void modelmgrAllocateSlots(s32 numobjs, s32 numchrs)
|
||||
|
||||
if (NUMTYPE1()) {
|
||||
g_ModelRwdataBindings[0] = (struct modelrwdatabinding *) ptr;
|
||||
ptr += NUMTYPE1() * 8;
|
||||
ptr += NUMTYPE1() * sizeof(struct modelrwdatabinding);
|
||||
}
|
||||
|
||||
if (NUMTYPE2()) {
|
||||
g_ModelRwdataBindings[1] = (struct modelrwdatabinding *) ptr;
|
||||
ptr += NUMTYPE2() * 8;
|
||||
ptr += NUMTYPE2() * sizeof(struct modelrwdatabinding);
|
||||
}
|
||||
|
||||
if (NUMTYPE3()) {
|
||||
g_ModelRwdataBindings[2] = (struct modelrwdatabinding *) ptr;
|
||||
ptr += NUMTYPE3() * 8;
|
||||
ptr += NUMTYPE3() * sizeof(struct modelrwdatabinding);
|
||||
}
|
||||
|
||||
g_ModelSlots = (struct model *) ptr;
|
||||
|
||||
@@ -314,7 +314,11 @@ s32 nbombCalculateAlpha(struct nbomb *nbomb)
|
||||
Gfx *nbombCreateGdl(void)
|
||||
{
|
||||
Vtx *vertices;
|
||||
#ifdef PLATFORM_64BIT
|
||||
u32 gdlsizes[] = { 0x0a30*2, 0x0330*2 }; // 1 player, 2+ players
|
||||
#else
|
||||
u32 gdlsizes[] = { 0x0a30, 0x0330 }; // 1 player, 2+ players
|
||||
#endif
|
||||
Gfx *gdlstart;
|
||||
Gfx *gdl;
|
||||
s32 index = 0;
|
||||
|
||||
@@ -1414,6 +1414,9 @@ void playerTickChrBody(void)
|
||||
rwdatas = (u32 *)(allocation + offset1);
|
||||
osSyncPrintf("Gunmem: savedata 0x%08x\n", (uintptr_t)rwdatas);
|
||||
offset1 += 0x400;
|
||||
#ifdef PLATFORM_64BIT
|
||||
offset1 += 0x200;
|
||||
#endif
|
||||
offset1 = ALIGN64(offset1);
|
||||
|
||||
weaponobj = (struct weaponobj *)(allocation + offset1);
|
||||
@@ -1432,6 +1435,9 @@ void playerTickChrBody(void)
|
||||
}
|
||||
|
||||
offset2 += 0x4000;
|
||||
#ifdef PLATFORM_64BIT
|
||||
offset2 += 0x2000;
|
||||
#endif
|
||||
bgunCalculateGunMemCapacity();
|
||||
spe8 = g_Vars.currentplayer->gunmem2 + offset2;
|
||||
texInitPool(&texpool, spe8, bgunCalculateGunMemCapacity() - offset2);
|
||||
|
||||
@@ -40,7 +40,11 @@ void setupPreparePads(void)
|
||||
s32 offset;
|
||||
|
||||
g_PadsFile = (struct padsfileheader *)g_StageSetup.padfiledata;
|
||||
#ifdef PLATFORM_64BIT
|
||||
g_PadOffsets = (u16 *)(g_StageSetup.padfiledata + 0x20);
|
||||
#else
|
||||
g_PadOffsets = (u16 *)(g_StageSetup.padfiledata + 0x14);
|
||||
#endif
|
||||
padnum = 0;
|
||||
numpads = g_PadsFile->numpads;
|
||||
|
||||
|
||||
@@ -2155,11 +2155,16 @@ u8 *texGetPoolLeftPos(struct texpool *pool)
|
||||
void texLoadFromDisplayList(Gfx *gdl, struct texpool *pool, s32 arg2)
|
||||
{
|
||||
u8 *bytes = (u8 *)gdl;
|
||||
u8 ofs = 4;
|
||||
#ifdef PLATFORM_64BIT
|
||||
ofs = 8;
|
||||
#endif
|
||||
|
||||
|
||||
while (bytes[GFX_W0_BYTE(0)] != (u8)G_ENDDL) {
|
||||
// Look for GBI sequence: fd...... abcd....
|
||||
if (bytes[GFX_W0_BYTE(0)] == G_SETTIMG && bytes[GFX_W1_BYTE(0)] == 0xab && bytes[GFX_W1_BYTE(1)] == 0xcd) {
|
||||
texLoad((texnum_t *)((uintptr_t)bytes + 4), pool, arg2);
|
||||
texLoad((texnum_t *)((uintptr_t)bytes + ofs), pool, arg2);
|
||||
}
|
||||
|
||||
bytes += sizeof(Gfx);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "data.h"
|
||||
#include "types.h"
|
||||
|
||||
#define TITLE_ALLOCSIZE 1024 * 332
|
||||
#define TITLE_ALLOCSIZE 1024 * 378
|
||||
|
||||
extern u32 var800624d4;
|
||||
extern u32 var800624d8;
|
||||
|
||||
+23
-19
@@ -64,7 +64,7 @@ struct curmp3 {
|
||||
};
|
||||
|
||||
s32 g_NumSounds;
|
||||
u32 *g_ALSoundRomOffsets;
|
||||
uintptr_t *g_ALSoundRomOffsets;
|
||||
s32 g_SndMaxFxBusses;
|
||||
u32 var80094eac;
|
||||
struct curmp3 g_SndCurMp3;
|
||||
@@ -984,12 +984,12 @@ void sndLoadSfxCtl(void)
|
||||
// Calculate the size of the ALInstrument and load it. The pointer is then
|
||||
// shifted forward to point to the instrument's ALSound array. This leaks
|
||||
// some memory but this is initialisation code so it's not much of an issue.
|
||||
size = g_NumSounds * 4 + 20;
|
||||
size = g_NumSounds * sizeof(uintptr_t) + 20;
|
||||
size = ALIGN16(size);
|
||||
g_ALSoundRomOffsets = alHeapAlloc(&g_SndHeap, 1, size);
|
||||
dmaExec(g_ALSoundRomOffsets, romaddr, size);
|
||||
|
||||
*(u32 *)&g_ALSoundRomOffsets += 0x10;
|
||||
*(uintptr_t *)&g_ALSoundRomOffsets += 0x10;
|
||||
|
||||
// Convert ctl-local offsets to ROM offsets
|
||||
for (i = 0; i < g_NumSounds; i++) {
|
||||
@@ -1030,8 +1030,8 @@ void sndIncrementAges(void)
|
||||
ALEnvelope *sndLoadEnvelope(u32 offset, u16 cacheindex)
|
||||
{
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
u8 spaf[0x50];
|
||||
u8 sp5f[0x50];
|
||||
u8 spaf[0x90];
|
||||
u8 sp5f[0x90];
|
||||
ALEnvelope *s2 = (ALEnvelope *)ALIGN16((uintptr_t)spaf);
|
||||
ALEnvelope *s1 = (ALEnvelope *)ALIGN16((uintptr_t)sp5f);
|
||||
s32 i;
|
||||
@@ -1041,14 +1041,14 @@ ALEnvelope *sndLoadEnvelope(u32 offset, u16 cacheindex)
|
||||
offset += (romptr_t) REF_SEG _sfxctlSegmentRomStart;
|
||||
|
||||
do {
|
||||
dmaExecHighPriority(s2, offset, 0x40);
|
||||
dmaExecHighPriority(s2, offset, 16 * sizeof(uintptr_t));
|
||||
sum1 = 0;
|
||||
|
||||
for (i = 0; i < 16U; i++) {
|
||||
sum1 += ((u32 *)s2)[i];
|
||||
}
|
||||
|
||||
dmaExecHighPriority(s1, offset, 0x40);
|
||||
dmaExecHighPriority(s1, offset, 16 * sizeof(uintptr_t));
|
||||
sum2 = 0;
|
||||
|
||||
for (i = 0; i < 16U; i++) {
|
||||
@@ -1077,8 +1077,8 @@ ALEnvelope *sndLoadEnvelope(u32 offset, u16 cacheindex)
|
||||
ALKeyMap *sndLoadKeymap(u32 offset, u16 cacheindex)
|
||||
{
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
u8 spaf[0x50];
|
||||
u8 sp5f[0x50];
|
||||
u8 spaf[0x90];
|
||||
u8 sp5f[0x90];
|
||||
ALKeyMap *s2 = (ALKeyMap *)ALIGN16((uintptr_t)spaf);
|
||||
ALKeyMap *s1 = (ALKeyMap *)ALIGN16((uintptr_t)sp5f);
|
||||
s32 i;
|
||||
@@ -1088,14 +1088,14 @@ ALKeyMap *sndLoadKeymap(u32 offset, u16 cacheindex)
|
||||
offset += (romptr_t) REF_SEG _sfxctlSegmentRomStart;
|
||||
|
||||
do {
|
||||
dmaExecHighPriority(s2, offset, 0x40);
|
||||
dmaExecHighPriority(s2, offset, 16 * sizeof(uintptr_t));
|
||||
sum1 = 0;
|
||||
|
||||
for (i = 0; i < 16U; i++) {
|
||||
sum1 += ((u32 *)s2)[i];
|
||||
}
|
||||
|
||||
dmaExecHighPriority(s1, offset, 0x40);
|
||||
dmaExecHighPriority(s1, offset, 16 * sizeof(uintptr_t));
|
||||
sum2 = 0;
|
||||
|
||||
for (i = 0; i < 16U; i++) {
|
||||
@@ -1171,8 +1171,8 @@ ALADPCMBook *sndLoadAdpcmBook(u32 offset, u16 cacheindex)
|
||||
ALADPCMloop *sndLoadAdpcmLoop(u32 offset, u16 cacheindex)
|
||||
{
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
u8 spaf[0x50];
|
||||
u8 sp5f[0x50];
|
||||
u8 spaf[0x90];
|
||||
u8 sp5f[0x90];
|
||||
ALADPCMloop *s2 = (ALADPCMloop *)ALIGN16((uintptr_t)spaf);
|
||||
ALADPCMloop *s1 = (ALADPCMloop *)ALIGN16((uintptr_t)sp5f);
|
||||
s32 i;
|
||||
@@ -1186,14 +1186,14 @@ ALADPCMloop *sndLoadAdpcmLoop(u32 offset, u16 cacheindex)
|
||||
offset += (romptr_t) REF_SEG _sfxctlSegmentRomStart;
|
||||
|
||||
do {
|
||||
dmaExecHighPriority(s2, offset, 0x40);
|
||||
dmaExecHighPriority(s2, offset, 16 * sizeof(uintptr_t));
|
||||
sum1 = 0;
|
||||
|
||||
for (i = 0; i < 16U; i++) {
|
||||
sum1 += ((u32 *)s2)[i];
|
||||
}
|
||||
|
||||
dmaExecHighPriority(s1, offset, 0x40);
|
||||
dmaExecHighPriority(s1, offset, 16 * sizeof(uintptr_t));
|
||||
sum2 = 0;
|
||||
|
||||
for (i = 0; i < 16U; i++) {
|
||||
@@ -1226,8 +1226,8 @@ ALADPCMloop *sndLoadAdpcmLoop(u32 offset, u16 cacheindex)
|
||||
ALWaveTable *sndLoadWavetable(u32 offset, u16 cacheindex)
|
||||
{
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
u8 spaf[0x50];
|
||||
u8 sp5f[0x50];
|
||||
u8 spaf[0x90];
|
||||
u8 sp5f[0x90];
|
||||
ALWaveTable *s2 = (ALWaveTable *)ALIGN16((uintptr_t)spaf);
|
||||
ALWaveTable *s1 = (ALWaveTable *)ALIGN16((uintptr_t)sp5f);
|
||||
s32 i;
|
||||
@@ -1238,14 +1238,14 @@ ALWaveTable *sndLoadWavetable(u32 offset, u16 cacheindex)
|
||||
offset += (romptr_t) REF_SEG _sfxctlSegmentRomStart;
|
||||
|
||||
do {
|
||||
dmaExecHighPriority(s2, offset, 0x40);
|
||||
dmaExecHighPriority(s2, offset, 16 * sizeof(uintptr_t));
|
||||
sum1 = 0;
|
||||
|
||||
for (i = 0; i < 16U; i++) {
|
||||
sum1 += ((u32 *)s2)[i];
|
||||
}
|
||||
|
||||
dmaExecHighPriority(s1, offset, 0x40);
|
||||
dmaExecHighPriority(s1, offset, 16 * sizeof(uintptr_t));
|
||||
sum2 = 0;
|
||||
|
||||
for (i = 0; i < 16U; i++) {
|
||||
@@ -1457,6 +1457,10 @@ void sndInit(void)
|
||||
u32 heaplen = 1024 * 438;
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_64BIT
|
||||
heaplen = 1024 * 661;
|
||||
#endif
|
||||
|
||||
g_Vars.langfilteron = false;
|
||||
|
||||
if (IS4MB()) {
|
||||
|
||||
Reference in new issue
Block a user