diff --git a/source/memory.h b/source/memory.h new file mode 100644 index 00000000..68363d5e --- /dev/null +++ b/source/memory.h @@ -0,0 +1,37 @@ +#ifndef __MEMORY_H_ +#define __MEMORY_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define Disc_ID ((u32*) 0x80000000) +#define Disc_Region ((u32*) 0x80000003) +#define Disc_Magic ((u32*) 0x80000018) +#define Sys_Magic ((u32*) 0x80000020) +#define Version ((u32*) 0x80000024) +#define Mem_Size ((u32*) 0x80000028) +#define Board_Model ((u32*) 0x8000002C) +#define Arena_L ((u32*) 0x80000030) +#define Arena_H ((u32*) 0x80000034) +#define FST ((u32*) 0x80000038) +#define Max_FST ((u32*) 0x8000003C) +#define Assembler ((u32*) 0x80000060) +#define Video_Mode ((u32*) 0x800000CC) +#define Dev_Debugger ((u32*) 0x800000EC) +#define Simulated_Mem ((u32*) 0x800000F0) +#define BI2 ((u32*) 0x800000F4) +#define Bus_Speed ((u32*) 0x800000F8) +#define CPU_Speed ((u32*) 0x800000FC) +#define Online_Check ((u32*) 0x80003180) +#define GameID_Address ((u32*) 0x80003184) + + +#define allocate_memory(size) memalign(32, (size+31)&(~31)) + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/source/prompts/DiscBrowser.cpp b/source/prompts/DiscBrowser.cpp index afd33d87..d1d3daaa 100644 --- a/source/prompts/DiscBrowser.cpp +++ b/source/prompts/DiscBrowser.cpp @@ -16,6 +16,7 @@ #include "main.h" #include "sys.h" #include "settings/cfg.h" +#include "memory.h" /*** Extern functions ***/ extern void ResumeGui(); @@ -62,7 +63,7 @@ int DiscBrowse(struct discHdr * header) { return ret; } - int *buffer = (int*)memalign(32, 0x20); + int *buffer = (int*)allocate_memory(0x20); if (buffer == NULL) { WindowPrompt(tr("ERROR:"), tr("Not enough free memory."), tr("OK")); @@ -75,7 +76,7 @@ int DiscBrowse(struct discHdr * header) { return ret; } - void *fstbuffer = memalign(32, buffer[2]*4); + void *fstbuffer = allocate_memory(buffer[2]*4); FST_ENTRY *fst = (FST_ENTRY *)fstbuffer; if (fst == NULL) { diff --git a/source/usbloader/disc.c b/source/usbloader/disc.c index f3490897..6ca83497 100644 --- a/source/usbloader/disc.c +++ b/source/usbloader/disc.c @@ -10,7 +10,8 @@ #include "disc.h" #include "video.h" #include "wdvd.h" -#include "alternatedol.h" +#include "alternatedol.h" +#include "memory.h" /* Constants */ #define PTABLE_OFFSET 0x40000 @@ -18,42 +19,42 @@ /* Disc pointers */ static u32 *buffer = (u32 *)0x93000000; -static u8 *diskid = (u8 *)0x80000000; +static u8 *diskid = (u8 *)Disc_ID; void __Disc_SetLowMem(void) { - *(vu32 *)0x80000020 = 0x0D15EA5E; // Standard Boot Code - *(vu32 *)0x80000024 = 0x00000001; // Version - - *(vu32 *)0x80000030 = 0x00000000; // Arena Low - *(vu32 *)0x800000F4 = 0x817E5480; // BI2 - *(vu32 *)0x800000F8 = 0x0E7BE2C0; // Console Bus Speed - *(vu32 *)0x800000FC = 0x2B73A840; // Console CPU Speed + + *Sys_Magic = 0x0D15EA5E; // Standard Boot Code + *Version = 0x00000001; // Version + *Arena_L = 0x00000000; // Arena Low + *BI2 = 0x817E5480; // BI2 + *Bus_Speed = 0x0E7BE2C0; // Console Bus Speed + *CPU_Speed = 0x2B73A840; // Console CPU Speed /* Setup low memory */ - *(vu32 *)0x80000060 = 0x38A00040; - *(vu32 *)0x800000E4 = 0x80431A80; - *(vu32 *)0x800000EC = 0x81800000; // Dev Debugger Monitor Address - *(vu32 *)0x800000F0 = 0x01800000; // Simulated Memory Size + *Assembler = 0x38A00040; // Assembler + *(u32 *)0x800000E4 = 0x80431A80; + *Dev_Debugger = 0x81800000; // Dev Debugger Monitor Address + *Simulated_Mem = 0x01800000; // Simulated Memory Size //If the game is sam & max: season 1 put this shit in char gameid[8]; memset(gameid, 0, 8); - memcpy(gameid, (char*)0x80000000, 6); + memcpy(gameid, (char*)Disc_ID, 6); if ((strcmp(gameid,"R3XE6U")==0)|| (strcmp(gameid,"R3XP6V")==0))/*&& (IOS_GetVersion()==249)&& ((IOS_GetRevision()==10)||(IOS_GetRevision()==13)) I left out the ios check to see if works with other ios versions.*/ { - *(vu32*)0x80003184 = 0x80000000; // Game ID Address + *GameID_Address = Disc_ID; // Game ID Address } /* Copy disc ID */ - memcpy((void *)0x80003180, (void *)0x80000000, 4); + memcpy((void *)Online_Check, (void *)Disc_ID, 4); /* Flush cache */ - DCFlushRange((void *)0x80000000, 0x3F00); + DCFlushRange((void *)Disc_ID, 0x3F00); } void __Disc_SetVMode(u8 videoselected) { @@ -130,7 +131,7 @@ void __Disc_SetVMode(u8 videoselected) { } /* Set video mode register */ - *(vu32 *)0x800000CC = vmode_reg; + *Video_Mode = vmode_reg; /* Set video mode */ if (vmode) { @@ -282,7 +283,7 @@ s32 Disc_BootPartition(u64 offset, u8 videoselected, u8 cheat, u8 vipatch, u8 pa char gameid[8]; /* OCARINA STUFF - FISHEARS*/ memset(gameid, 0, 8); - memcpy(gameid, (char*)0x80000000, 6); + memcpy(gameid, (char*)Disc_ID, 6); do_sd_code(gameid); /* OCARINA STUFF - FISHEARS*/ }