diff --git a/src/game/bg.c b/src/game/bg.c index 6ca79a5de..ac6b51c7c 100644 --- a/src/game/bg.c +++ b/src/game/bg.c @@ -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; diff --git a/src/game/bondgun.c b/src/game/bondgun.c index 1bfe79cc3..f78dc6d44 100644 --- a/src/game/bondgun.c +++ b/src/game/bondgun.c @@ -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"); diff --git a/src/game/dlights.c b/src/game/dlights.c index 018f3e4e4..2dd9af0fe 100644 --- a/src/game/dlights.c +++ b/src/game/dlights.c @@ -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) { diff --git a/src/game/gfxmemory.c b/src/game/gfxmemory.c index a7d6bb9d6..f105bce2c 100644 --- a/src/game/gfxmemory.c +++ b/src/game/gfxmemory.c @@ -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; } diff --git a/src/game/modelmgr.c b/src/game/modelmgr.c index d6bec4876..70fefead6 100644 --- a/src/game/modelmgr.c +++ b/src/game/modelmgr.c @@ -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; diff --git a/src/game/modelmgrreset.c b/src/game/modelmgrreset.c index 1d6600514..2f268e06e 100644 --- a/src/game/modelmgrreset.c +++ b/src/game/modelmgrreset.c @@ -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; diff --git a/src/game/nbomb.c b/src/game/nbomb.c index b5f4fa72b..e3e3dcb9d 100644 --- a/src/game/nbomb.c +++ b/src/game/nbomb.c @@ -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; diff --git a/src/game/player.c b/src/game/player.c index 198254e16..2b3b418c3 100644 --- a/src/game/player.c +++ b/src/game/player.c @@ -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); diff --git a/src/game/setuppads.c b/src/game/setuppads.c index 9e629fdad..241d31479 100644 --- a/src/game/setuppads.c +++ b/src/game/setuppads.c @@ -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; diff --git a/src/game/texdecompress.c b/src/game/texdecompress.c index 7a71781f7..494bda391 100644 --- a/src/game/texdecompress.c +++ b/src/game/texdecompress.c @@ -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); diff --git a/src/include/game/title.h b/src/include/game/title.h index 02ecfb690..3e6771dc5 100644 --- a/src/include/game/title.h +++ b/src/include/game/title.h @@ -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; diff --git a/src/lib/snd.c b/src/lib/snd.c index 997f868b5..0abedf5a8 100644 --- a/src/lib/snd.c +++ b/src/lib/snd.c @@ -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()) {