Fix compiling for linux arm64 (#650)

* Enable MK64 build option for torch

* Fix HMAS type error (present on arm64)

* Align memory pool and fix empty macro

* Experimental: Add 4096 memory alignment

* Add alignment for ALIGNED8 macro

* Use memset over deprecated bzero

* Ensure OPENGLES flag can be used in CMakeLists.txt

* Diagnostic: align ship2_window_i8 to rule out odd-alignment crash

---------

Co-authored-by: MegaMech <MegaMech@users.noreply.github.com>
This commit is contained in:
Jeod
2026-04-22 19:38:48 -04:00
committed by GitHub
parent 3a5af8ff76
commit 10f10f17e6
15 changed files with 55 additions and 33 deletions
+1 -1
View File
@@ -3468,7 +3468,7 @@ void func_8000F124(void) {
// Delete track waypoints
void clear_path_point(TrackPathPoint* arg0, size_t size) {
bzero((void*) arg0, size * sizeof(TrackPathPoint));
memset((void*) arg0, 0, size * sizeof(TrackPathPoint));
}
// Appears to allocate memory for each track.
+2 -2
View File
@@ -60,7 +60,7 @@ void reset_object_variable(void) {
s32 j;
func_8006EB10();
clear_object_list();
bzero(playerHUD, HUD_PLAYERS_SIZE * sizeof(hud_player));
memset(playerHUD, 0, HUD_PLAYERS_SIZE * sizeof(hud_player));
for (i = 0; i < HUD_PLAYERS_SIZE; i++) {
playerHUD[i].lapCount = 0;
@@ -114,7 +114,7 @@ void func_8006EB10(void) {
}
void clear_object_list() {
bzero(gObjectList, OBJECT_LIST_SIZE * sizeof(Object));
memset(gObjectList, 0, OBJECT_LIST_SIZE * sizeof(Object));
objectListSize = -1;
}
+2 -2
View File
@@ -105,7 +105,7 @@ CeremonyActor* find_available_entry(void) {
// Find an inactive actor.
if ((actor->isActive & 1) == 0) {
bzero(actor, sizeof(CeremonyActor));
memset(actor, 0, sizeof(CeremonyActor));
actor->isActive = 1;
actor->unk24 = 1.0f;
return actor;
@@ -311,7 +311,7 @@ void unused_80280FA8(UNUSED CeremonyActor* actor) {
void balloons_and_fireworks_init(void) {
D_802874D8.actorTimer = 0;
sPodiumActorList = (CeremonyActor*) get_next_available_memory_addr(sizeof(CeremonyActor) * 200);
bzero(sPodiumActorList, (sizeof(CeremonyActor) * 200));
memset(sPodiumActorList, 0, (sizeof(CeremonyActor) * 200));
new_actor(&initDummy);
}
+2 -2
View File
@@ -522,7 +522,7 @@ void display_and_vsync(void) {
void init_segment_ending_sequences(void) {
#ifdef TARGET_N64
bzero((void*) SEG_ENDING, SEG_ENDING_SIZE);
memset((void*) SEG_ENDING, 0, SEG_ENDING_SIZE);
osWritebackDCacheAll();
dma_copy((u8*) SEG_ENDING, (u8*) SEG_ENDING_ROM_START, SEG_ENDING_ROM_SIZE);
osInvalICache((void*) SEG_ENDING, SEG_ENDING_SIZE);
@@ -532,7 +532,7 @@ void init_segment_ending_sequences(void) {
void init_segment_racing(void) {
#ifdef TARGET_N64
bzero((void*) SEG_RACING, SEG_RACING_SIZE);
memset((void*) SEG_RACING, 0, SEG_RACING_SIZE);
osWritebackDCacheAll();
dma_copy((u8*) SEG_RACING, (u8*) SEG_RACING_ROM_START, SEG_RACING_ROM_SIZE);
osInvalICache((void*) SEG_RACING, SEG_RACING_SIZE);
+1 -1
View File
@@ -15,7 +15,7 @@ extern OSViMode osViModeMpalLan1;
extern OSViMode osViModeNtscLan1;
void __osViInit(void) {
bzero(sViContexts, sizeof(sViContexts));
memset(sViContexts, 0, sizeof(sViContexts));
__osViCurr = &sViContexts[0];
__osViNext = &sViContexts[1];
__osViNext->retraceCount = 1;
-1
View File
@@ -28,7 +28,6 @@ extern "C" {
extern void bcopy(const void*, void*, size_t);
extern int bcmp(const void*, const void*, int);
extern void bzero(void*, size_t);
extern void blkclr(void*, int);
#ifdef __cplusplus
+1 -1
View File
@@ -29,7 +29,7 @@ OSPiHandle* osCartRomInit(void) {
CartRomHandle.domain = PI_DOMAIN1;
// CartRomHandle.speed = 0;
bzero(&CartRomHandle.transferInfo, sizeof(__OSTranxInfo));
memset(&CartRomHandle.transferInfo, 0, sizeof(__OSTranxInfo));
saveMask = __osDisableInt();
CartRomHandle.next = __osPiTable;
+1 -1
View File
@@ -57,7 +57,7 @@ void osInitialize(void) {
}
osClockRate = osClockRate * 3 / 4;
if (osResetType == RESET_TYPE_COLD_RESET) {
bzero(osAppNmiBuffer, sizeof(osAppNmiBuffer));
memset(osAppNmiBuffer, 0, sizeof(osAppNmiBuffer));
}
eu_sp30 = HW_REG(PI_STATUS_REG, u32);
+1 -1
View File
@@ -26,7 +26,7 @@ OSPiHandle* osLeoDiskInit(void) {
HW_REG(PI_BSD_DOM2_PWD_REG, u32) = LeoDiskHandle.pulse;
HW_REG(PI_BSD_DOM2_PGS_REG, u32) = LeoDiskHandle.pageSize;
HW_REG(PI_BSD_DOM2_RLS_REG, u32) = LeoDiskHandle.relDuration;
bzero(&LeoDiskHandle.transferInfo, sizeof(__OSTranxInfo));
memset(&LeoDiskHandle.transferInfo, 0, sizeof(__OSTranxInfo));
sp1c = __osDisableInt();
LeoDiskHandle.next = __osPiTable;
__osPiTable = &LeoDiskHandle;
+1 -1
View File
@@ -58,7 +58,7 @@ struct HMAS_Effect {
struct HMAS_ChannelInfo {
ma_sound* sound;
uint64_t cursor;
ma_uint64 cursor;
float pitch;
float volume;
+10 -11
View File
@@ -25,7 +25,7 @@
s32 sGfxSeekPosition;
s32 sPackedSeekPosition;
static u8 sMemoryPool[0xFFFFFFF]; // Stock memory pool size: 0xAB630
static u8 sMemoryPool[0x10000000] ALIGNED4096;
uintptr_t sPoolEnd = sMemoryPool + sizeof(sMemoryPool);
uintptr_t sPoolFreeSpace;
@@ -88,17 +88,16 @@ static uintptr_t get_texture2(size_t offset, const course_texture* textures) {
* Default memory size, 701.984 Kilobytes.
*/
void initialize_memory_pool() {
// Clear pool
memset(sMemoryPool, 0, sizeof(sMemoryPool));
uintptr_t poolStart = sMemoryPool;
// uintptr_t sPoolEnd = sMemoryPool + sizeof(sMemoryPool);
// Force the pointer to be exactly at the start of the aligned array
uintptr_t poolStart = (uintptr_t)sMemoryPool;
// Ensure sPoolEnd is exactly at the end of the 256MB block
sPoolEnd = poolStart + sizeof(sMemoryPool);
bzero(sMemoryPool, sizeof(sMemoryPool));
poolStart = ALIGN16(poolStart);
// Truncate to a 16-byte boundary.
sPoolEnd &= ~0xF;
gFreeMemorySize = (sPoolEnd - poolStart) - 0x10;
gFreeMemorySize = sPoolEnd - poolStart;
gNextFreeMemoryAddress = poolStart;
PRINT_MEMPOOL;
@@ -309,7 +308,7 @@ u8* load_lakitu_tlut_x64(const char** textureList, size_t length) {
}
u8* textures = (u8*) gNextFreeMemoryAddress;
gNextFreeMemoryAddress += size;
gNextFreeMemoryAddress = ALIGN16(gNextFreeMemoryAddress + size);
size_t offset = 0;
for (size_t i = 0; i < length; i++) {
u8* tex = (u8*) LOAD_ASSET_RAW(textureList[i]);