-updated to version 2.6-

*Reduced HDD read time out to 25 seconds
*Added two disc feature (Extracted format is unsupported)
 Use the latest DMToolBox (0.3 or higher) to install your two disc games

This will be the last version for some time, since I'm moving my focus to other things.

Always remember; Impossible is nothing!



git-svn-id: svn://localhost/Users/andi/Downloads/code/DML@34 be6c1b03-d731-4111-a574-e37d80d43941
This commit is contained in:
crediar@rypp.net 2012-11-30 21:46:19 +00:00
parent c879f0d115
commit 88c12646f4
7 changed files with 170 additions and 11 deletions

View File

@ -59,6 +59,14 @@ inline u32 ConfigGetConfig( u32 Config )
{ {
return !!(DMLCfg->Config & Config); return !!(DMLCfg->Config & Config);
} }
inline void ConfigSetConfig( u32 Config )
{
DMLCfg->Config |= Config;
}
inline void ConfigClearConfig( u32 Config )
{
DMLCfg->Config &= ~Config;
}
u32 ConfigGetVideMode( void ) u32 ConfigGetVideMode( void )
{ {
return DMLCfg->VideoMode; return DMLCfg->VideoMode;

View File

@ -90,6 +90,8 @@ enum VideoModes
void ConfigInit( DML_CFG *Cfg ); void ConfigInit( DML_CFG *Cfg );
u32 ConfigGetConfig( u32 Config ); u32 ConfigGetConfig( u32 Config );
void ConfigSetConfig( u32 Config );
void ConfigClearConfig( u32 Config );
u32 ConfigGetVideMode( void ); u32 ConfigGetVideMode( void );
char *ConfigGetGamePath( void ); char *ConfigGetGamePath( void );

32
DVD.c
View File

@ -20,13 +20,14 @@ u32 FCState[FILECACHE_MAX];
s32 DVDSelectGame( void ) s32 DVDSelectGame( void )
{ {
char *str = (char*)malloca( 256, 32 ); char *str = (char*)malloca( 256, 32 );
u32 i=0;
if( ConfigGetConfig(DML_CFG_GAME_PATH) ) if( ConfigGetConfig(DML_CFG_GAME_PATH) )
{ {
sprintf( str, "%s", ConfigGetGamePath() ); sprintf( str, "%s", ConfigGetGamePath() );
} else { } else {
dbgprintf("No game path was supplied!\n"); dbgprintf("DIP:No game path was supplied!\n");
free(str); free(str);
return -1; return -1;
} }
@ -39,13 +40,40 @@ s32 DVDSelectGame( void )
//Try to switch to FST mode //Try to switch to FST mode
if( !FSTInit() ) if( !FSTInit() )
{ {
dbgprintf("Failed to open:\"%s\" fres:%d\n", str, fres ); dbgprintf("DIP:Failed to open:\"%s\" fres:%d\n", str, fres );
free(str); free(str);
return -2; return -2;
} }
} else { } else {
f_close( &GameFile );
dbgprintf("DIP:Current Gamepath:\"%s\"\n", str );
//search the string backwards for '/'
for( i=strlen(str); i > 0; --i )
if( str[i] == '/' )
break;
i++;
if( ConfigGetConfig(DML_CFG_BOOT_DISC2) )
{
sprintf( str+i, "disc2.iso" );
} else {
sprintf( str+i, "game.iso" );
}
dbgprintf("DIP:New Gamepath:\"%s\"\n", str );
fres = f_open( &GameFile, str, FA_READ );
if( fres != FR_OK )
{
dbgprintf("DIP:Failed to open:\"%s\" fres:%d\n", str, fres );
free(str);
return -3;
}
f_lseek( &GameFile, 0 ); f_lseek( &GameFile, 0 );
f_read( &GameFile, (void*)0, 0x20, &read ); f_read( &GameFile, (void*)0, 0x20, &read );

View File

@ -597,6 +597,10 @@ void DoCardPatches( char *ptr, u32 size, u32 SectionOffset )
return; return;
}
void InitPatches( void )
{
} }
void DoPatches( char *ptr, u32 size, u32 SectionOffset ) void DoPatches( char *ptr, u32 size, u32 SectionOffset )
{ {
@ -648,15 +652,15 @@ void DoPatches( char *ptr, u32 size, u32 SectionOffset )
for( i=0; i < size; i+=4 ) for( i=0; i < size; i+=4 )
{ {
if( (PatchCount & 2) == 0 ) if( (PatchCount & 2) == 0 )
if( (read32( (u32)ptr + i )&0xFC00FFFF) == 0x5400077A && if( (read32( (u32)ptr + i ) & 0xFC00FFFF) == 0x5400077A &&
(read32( (u32)ptr + i + 4 )&0xFC00FFFF) == 0x28000000 && (read32( (u32)ptr + i + 4 ) & 0xFC00FFFF) == 0x28000000 &&
read32( (u32)ptr + i + 8 ) == 0x41820008 && read32( (u32)ptr + i + 8 ) == 0x41820008 &&
(read32( (u32)ptr + i +12 )&0xFC00FFFF) == 0x64002000 (read32( (u32)ptr + i +12 ) & 0xFC00FFFF) == 0x64002000
) )
{ {
dbgprintf("Patch:Found [__OSDispatchInterrupt]: 0x%08X 0x%08X\n", (u32)ptr + i + 0 + SectionOffset, (u32)ptr + i + 0x1A8 + SectionOffset ); dbgprintf("Patch:Found [__OSDispatchInterrupt]: 0x%08X 0x%08X\n", (u32)ptr + i + 0 + SectionOffset, (u32)ptr + i + 0x1A8 + SectionOffset );
write32( (u32)ptr + i + 0, (read32( (u32)ptr + i + 0 ) & 0xFFFF0000) | 0x0463 ); write32( (u32)ptr + i + 0, (read32( (u32)ptr + i + 0 ) & 0xFFFF0000) | 0x0463 );
write32( (u32)ptr + i + 0x1A8, (read32( (u32)ptr + i + 0x1A8 ) & 0xFFFF0000) | 0x0463 ); write32( (u32)ptr + i + 0x1A8, (read32( (u32)ptr + i + 0x1A8 ) & 0xFFFF0000) | 0x0463 );
PatchCount |= 2; PatchCount |= 2;
@ -909,12 +913,73 @@ void DoPatches( char *ptr, u32 size, u32 SectionOffset )
} }
} }
if( (PatchCount & 256) == 0 ) //DVDLowStopMotor
{
if( read32( (u32)ptr + i ) == 0x3C00E300 )
{
u32 Offset = (u32)ptr + i;
dbgprintf("Patch:[DVDLowStopMotor] 0x%08X\n", Offset + SectionOffset );
value = *(vu32*)(Offset-12);
value&= 0xFFFF0000;
value|= 0x0000C000;
*(vu32*)(Offset-12) = value;
value = *(vu32*)(Offset-8);
value&= 0xFFFF0000;
value|= 0x00002F00;
*(vu32*)(Offset-8) = value;
value = *(vu32*)(Offset+4);
value&= 0xFFFF0000;
value|= 0x00002F08;
*(vu32*)(Offset+4) = value;
PatchCount |= 256;
}
}
if( (PatchCount & 512) == 0 ) //DVDLowReadDiskID
{
if( (read32( (u32)ptr + i ) & 0xFFFF ) == 0xA800 && (read32( (u32)ptr + i + 4 ) & 0xFFFF ) == 0x40 )
{
u32 Offset = (u32)ptr + i;
dbgprintf("Patch:[DVDLowReadDiskID] 0x%08X\n", Offset + SectionOffset );
value = *(vu32*)(Offset);
value&= 0xFFFF0000;
value|= 0x0000A700;
*(vu32*)(Offset) = value;
value = *(vu32*)(Offset+0x20);
value&= 0xFFFF0000;
value|= 0x0000C000;
*(vu32*)(Offset+0x20) = value;
value = *(vu32*)(Offset+0x24);
value&= 0xFFFF0000;
value|= 0x00002F00;
*(vu32*)(Offset+0x24) = value;
value = *(vu32*)(Offset+0x2C);
value&= 0xFFFF0000;
value|= 0x00002F08;
*(vu32*)(Offset+0x2C) = value;
write32( 0x01576D4, 0x38600000 );
PatchCount |= 512;
}
}
if( ConfigGetConfig(DML_CFG_CHEATS) || ConfigGetConfig( DML_CFG_DEBUGGER ) ) if( ConfigGetConfig(DML_CFG_CHEATS) || ConfigGetConfig( DML_CFG_DEBUGGER ) )
{ {
if( PatchCount == 255 ) if( PatchCount == 1023 )
break; break;
} else { } else {
if( PatchCount == 239 ) if( PatchCount == 1007 )
break; break;
} }
} }

34
dip.c
View File

@ -15,6 +15,7 @@ u32 DOLSize = 0;
u32 DOLOffset = 0; u32 DOLOffset = 0;
s32 ELFNumberOfSections = 0; s32 ELFNumberOfSections = 0;
u32 FSTMode = 0; u32 FSTMode = 0;
u32 DiscChangeIRQ = 0;
extern DML_CFG *DMLCfg; extern DML_CFG *DMLCfg;
@ -104,6 +105,39 @@ u32 DIUpdateRegisters( void )
switch( read32(DI_SCMD_0) >> 24 ) switch( read32(DI_SCMD_0) >> 24 )
{ {
case 0xE3:
{
dbgprintf("DIP:DVDLowStopMotor()\n");
u32 CDiscNumber = (read32(4) << 16 ) >> 24;
dbgprintf("DIP:Current disc number:%u\n", CDiscNumber + 1 );
if( CDiscNumber )
{
ConfigClearConfig(DML_CFG_BOOT_DISC2);
} else {
ConfigSetConfig(DML_CFG_BOOT_DISC2);
}
f_close( &GameFile );
dbgprintf("DVDSelectGame():%d\n", DVDSelectGame() );
DiscChangeIRQ = 1;
while( read32(DI_SCONTROL) & 1 )
clear32( DI_SCONTROL, 1 );
set32( DI_SSTATUS, 0x3A );
write32( 0x0d80000C, (1<<0) | (1<<4) );
write32( HW_PPCIRQFLAG, read32(HW_PPCIRQFLAG) );
write32( HW_ARMIRQFLAG, read32(HW_ARMIRQFLAG) );
set32( 0x0d80000C, (1<<2) );
write32( HW_TIMER, 0 );
} break;
case 0xA7: case 0xA7:
case 0xA9: case 0xA9:
//dbgprintf("DIP:Async!\n"); //dbgprintf("DIP:Async!\n");

View File

@ -15,7 +15,7 @@
#define PADHOOK 1 #define PADHOOK 1
#define CONFIG_VERSION 0x00000002 #define CONFIG_VERSION 0x00000002
#define DML_VERSION 0x00020005 #define DML_VERSION 0x00020006
#define DI_SUCCESS 1 #define DI_SUCCESS 1
#define DI_ERROR 2 #define DI_ERROR 2

24
main.c
View File

@ -22,6 +22,8 @@ Copyright (C) 2010-2012 crediar
#include "dip.h" #include "dip.h"
#include "Patches.h" #include "Patches.h"
extern u32 DiscChangeIRQ;
char __aeabi_unwind_cpp_pr0[0]; char __aeabi_unwind_cpp_pr0[0];
void Syscall( u32 a, u32 b, u32 c, u32 d ) void Syscall( u32 a, u32 b, u32 c, u32 d )
@ -113,7 +115,6 @@ void SysShutdown( void )
} }
u32 fail; u32 fail;
FIL Log;
int main( int argc, char *argv[] ) int main( int argc, char *argv[] )
{ {
@ -239,6 +240,27 @@ int main( int argc, char *argv[] )
PADLock = 0; PADLock = 0;
} }
if( DiscChangeIRQ )
if( read32(HW_TIMER) * 128 / 243000000 > 2 )
{
// dbgprintf("DIP:IRQ mon!\n");
//DVDGetDriveStatus
//write32( 0x01576D4, 0x38600000 );
while( read32(DI_SCONTROL) & 1 )
clear32( DI_SCONTROL, 1 );
set32( DI_SSTATUS, 0x3A );
write32( 0x0d80000C, (1<<0) | (1<<4) );
write32( HW_PPCIRQFLAG, read32(HW_PPCIRQFLAG) );
write32( HW_ARMIRQFLAG, read32(HW_ARMIRQFLAG) );
set32( 0x0d80000C, (1<<2) );
DiscChangeIRQ = 0;
}
if( (((read32(0x12FC) >> 16) & 0x1030) == 0x1030 ) ) if( (((read32(0x12FC) >> 16) & 0x1030) == 0x1030 ) )
{ {
SysReset(); SysReset();