-whoops removed some pretty important line :P

-using low mem setup of GX, because it got more expainations
what is what and works fine so why now ;)
-allocating memory to find partition dynamically now to prevent
the function from overwriting something maybe in wiiflow
-moved cheat file loading to mem2, because we cant just allocate
the memory *somewhere* as it was before
-categories should be found faster now (thanks yardape8000 for tip)
-we dont need to debug print if we set gecko debugging on or not :P
This commit is contained in:
fix94.1 2012-05-16 16:21:03 +00:00
parent 1b0f97393f
commit bdab5cf650
5 changed files with 80 additions and 68 deletions

View File

@ -20,7 +20,7 @@
#include "frag.h"
#include "usbstorage.h"
#include "wip.h"
#include "memory.h"
#include "gecko.h"
#define ALIGNED(x) __attribute__((aligned(x)))
@ -41,7 +41,7 @@ GXRModeObj *disc_vmode = NULL;
GXRModeObj *vmode = NULL;
u32 vmode_reg = 0;
static u8 Tmd_Buffer[0x49e4 + 0x1C] ALIGNED(32);
static u8 Tmd_Buffer[0x49e4] ALIGNED(32);
extern void __exception_closeall();
entry_point p_entry;
@ -49,35 +49,21 @@ entry_point p_entry;
void __Disc_SetLowMem()
{
/* Setup low memory */
*(vu32 *)0x80000030 = 0x00000000; // Arena Low
*(vu32 *)0x80000060 = 0x38A00040;
*(vu32 *)0x800000E4 = 0x80431A80;
*(vu32 *)0x800000EC = 0x81800000; // Dev Debugger Monitor Address
*(vu32 *)0x800000F0 = 0x01800000; // Simulated Memory Size
*(vu32 *)0x800000F4 = 0x817E5480;
*(vu32 *)0x800000F8 = 0x0E7BE2C0; // bus speed
*(vu32 *)0x800000FC = 0x2B73A840; // cpu speed
*(vu32 *)0xCD00643C = 0x00000000; // 32Mhz on Bus
*Sys_Magic = 0x0D15EA5E; // Standard Boot Code
*Sys_Version = 0x00000001; // Version
*Arena_L = 0x00000000; // Arena Low
*BI2 = 0x817E5480; // BI2
*Bus_Speed = 0x0E7BE2C0; // Console Bus Speed
*CPU_Speed = 0x2B73A840; // Console CPU Speed
*Assembler = 0x38A00040; // Assembler
*(u32*)0x800000E4 = 0x80431A80;
*Dev_Debugger = 0x81800000; // Dev Debugger Monitor Address
*Simulated_Mem = 0x01800000; // Simulated Memory Size
*(vu32*)0xCD00643C = 0x00000000; // 32Mhz on Bus
/* Copy disc ID (online check) */
memcpy((void *)0x80003180, (void *)0x80000000, 4);
/* Copy disc ID */
memcpy((void *) Online_Check, (void *) Disc_ID, 4);
// Patch in info missing from apploader reads
*Sys_Magic = 0x0d15ea5e;
*Version = 1;
*Arena_L = 0x00000000;
*BI2 = 0x817E5480;
*Bus_Speed = 0x0E7BE2C0;
*CPU_Speed = 0x2B73A840;
// From NeoGamme R4 (WiiPower)
*(vu32 *)0x800030F0 = 0x0000001C;
*(vu32 *)0x8000318C = 0x00000000;
*(vu32 *)0x80003190 = 0x00000000;
// Fix for Sam & Max (WiiPower)
*(vu32 *)0x80003184 = 0x80000000;
/* Flush cache */
DCFlushRange((void *)0x80000000, 0x3F00);
}
@ -143,7 +129,7 @@ GXRModeObj * __Disc_SelectVMode(u8 videoselected, u64 chantitle)
if (CONF_GetVideo() != CONF_VIDEO_NTSC)
{
vmode_reg = VI_NTSC;
vmode = progressive ? &TVNtsc480Prog : &TVEurgb60Hz480IntDf;
vmode = progressive ? &TVEurgb60Hz480Prog : &TVEurgb60Hz480IntDf;
}
break;
}
@ -153,8 +139,8 @@ GXRModeObj * __Disc_SelectVMode(u8 videoselected, u64 chantitle)
vmode_reg = vmode->viTVMode >> 2;
break;
case 2: // PAL60
vmode = progressive ? &TVNtsc480Prog : &TVEurgb60Hz480IntDf;
vmode_reg = progressive ? TVEurgb60Hz480Prog.viTVMode >> 2 : vmode->viTVMode >> 2;
vmode = progressive ? &TVEurgb60Hz480Prog : &TVEurgb60Hz480IntDf;
vmode_reg = progressive ? vmode->viTVMode >> 2 : vmode->viTVMode >> 2;
break;
case 3: // NTSC
vmode = progressive ? &TVNtsc480Prog : &TVNtsc480IntDf;
@ -205,31 +191,52 @@ s32 Disc_FindPartition(u64 *outbuf)
u64 offset = 0;
u32 cnt;
u32 *TMP_Buffer = (u32*)MEM2_alloc(0x20);
if(!TMP_Buffer)
return -1;
/* Read partition info */
s32 ret = WDVD_UnencryptedRead(buffer, 0x20, PTABLE_OFFSET);
if (ret < 0) return ret;
/* Get data */
u32 nb_partitions = buffer[0];
u64 table_offset = buffer[1] << 2;
if (nb_partitions > 8) return -1;
/* Read partition table */
ret = WDVD_UnencryptedRead(buffer, 0x20, table_offset);
if (ret < 0) return ret;
/* Find game partition */
for (cnt = 0; cnt < nb_partitions; cnt++)
s32 ret = WDVD_UnencryptedRead(TMP_Buffer, 0x20, PTABLE_OFFSET);
if(ret < 0)
{
u32 type = buffer[cnt * 2 + 1];
/* Game partition */
if(!type) offset = buffer[cnt * 2] << 2;
MEM2_free(TMP_Buffer);
return ret;
}
/* Get data */
u32 nb_partitions = TMP_Buffer[0];
u64 table_offset = TMP_Buffer[1] << 2;
if(nb_partitions > 8)
{
MEM2_free(TMP_Buffer);
return -1;
}
memset(TMP_Buffer, 0, sizeof(TMP_Buffer));
/* Read partition table */
ret = WDVD_UnencryptedRead(TMP_Buffer, 0x20, table_offset);
if (ret < 0)
{
MEM2_free(TMP_Buffer);
return ret;
}
/* Find game partition */
for(cnt = 0; cnt < nb_partitions; cnt++)
{
u32 type = TMP_Buffer[cnt * 2 + 1];
/* Game partition */
if(!type)
offset = TMP_Buffer[cnt * 2] << 2;
}
MEM2_free(TMP_Buffer);
/* No game partition found */
if (!offset) return -1;
if (!offset)
return -1;
/* Set output buffer */
*outbuf = offset;
@ -363,6 +370,7 @@ s32 Disc_BootPartition()
__Disc_SetVMode();
/* Shutdown IOS subsystems */
__dsp_shutdown();
u32 level = IRQ_Disable();
__IOS_ShutdownSubsystems();
__exception_closeall();

View File

@ -1,13 +1,6 @@
#ifndef _DISC_H_
#define _DISC_H_
#define Sys_Magic ((vu32*)0x80000020)
#define Version ((vu32*)0x80000024)
#define Arena_L ((vu32*)0x80000030)
#define BI2 ((vu32*)0x800000F4)
#define Bus_Speed ((vu32*)0x800000F8)
#define CPU_Speed ((vu32*)0x800000Fc)
/* Disc header structure */
struct discHdr
{

View File

@ -336,7 +336,7 @@ void load_handler()
{
if (debuggerselect == 0x01)
{
gprintf("Debbugger selected is gecko\n");
//gprintf("Debbugger selected is gecko\n");
memset((void*)0x80001800,0,codehandler_size);
memcpy((void*)0x80001800,codehandler,codehandler_size);
//if (pausedstartoption == 0x01)
@ -349,7 +349,7 @@ void load_handler()
}
else
{
gprintf("Debbugger selected is not gecko\n");
//gprintf("Debbugger selected is not gecko\n");
memset((void*)0x80001800,0,codehandleronly_size);
memcpy((void*)0x80001800,codehandleronly,codehandleronly_size);
memcpy((void*)0x80001906, &codelist, 2);

View File

@ -1596,16 +1596,24 @@ void CMenu::_initCF(void)
&& (!m_locked || !m_gcfg1.getBool("ADULTONLY", id, false))
&& !ageLocked)
{
if (catviews[0] == '0')
if(catviews[0] == '0')
{
const char *idcats = m_cat.getString("CATEGORIES", id, "").c_str();
if (strlen(idcats) == 0)
if(strlen(idcats) == 0)
continue;
else
{
bool idinacat=0;
for (u32 j = 1; j<m_max_categories; ++j) if (catviews[j] == '1' && idcats[j] == '1') idinacat=1;
if (!idinacat) continue;
bool idinacat = false;
for(u32 j = 1; j<m_max_categories; ++j)
{
if(catviews[j] == '1' && idcats[j] == '1')
{
idinacat = true;
break;
}
}
if(!idinacat)
continue;
}
}
int playcount = m_gcfg1.getInt("PLAYCOUNT", id, 0);
@ -2204,7 +2212,7 @@ bool CMenu::_loadFile(SmartBuf &buffer, u32 &size, const char *path, const char
fseek(fp, 0, SEEK_END);
u32 fileSize = ftell(fp);
fseek(fp, 0, SEEK_SET);
SmartBuf fileBuf = smartAnyAlloc(fileSize);
SmartBuf fileBuf = smartMem2Alloc(fileSize);
if (!fileBuf)
{
fclose(fp);

View File

@ -1298,7 +1298,10 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
/* Find game partition offset */
u64 offset;
Disc_FindPartition(&offset);
s32 ret = Disc_FindPartition(&offset);
if(ret < 0)
return;
RunApploader(offset, videoMode, vipatch, countryPatch, patchVidMode, aspectRatio);
DeviceHandler::DestroyInstance();
USBStorage_Deinit();