From 8cebe92a4dfe7f04a9c0ec963a3f43746ddd1d35 Mon Sep 17 00:00:00 2001 From: "0xD15EA5E@gmail.com" <0xD15EA5E@gmail.com@be6c1b03-d731-4111-a574-e37d80d43941> Date: Mon, 24 Sep 2012 14:03:20 +0000 Subject: [PATCH] -updated to version 2.3- *Fixed creating NMM save file folders in FST mode *Fixed CardFindEntryByName which incorrectly compared file names *Added a hack for Phantasy Star Online 1&2 version 1.0 *GCLoader improvements that include warning the user if an incorrect CONFIG_VERSION is used *Hardcoded the only worthy DVDGetDriveStatus patching, so once again the NODISC cfg doesn't do anything *Removed unused code *Removed unused files git-svn-id: svn://localhost/Users/andi/Downloads/code/trunk@29 be6c1b03-d731-4111-a574-e37d80d43941 --- Card.c | 54 +++++++++++++++++++++++++------------------- Config.c | 10 ++++----- Config.h | 1 - HW.h | 1 - Patches.c | 5 ++++- Patches.h | 1 - dip.c | 11 +++++---- global.h | 2 +- ipc.h | 67 ------------------------------------------------------- main.c | 1 - memory.h | 1 - 11 files changed, 48 insertions(+), 106 deletions(-) delete mode 100644 ipc.h diff --git a/Card.c b/Card.c index 0631113..89f9721 100644 --- a/Card.c +++ b/Card.c @@ -1,12 +1,16 @@ #include "Card.h" FIL CardStat; +extern u32 FSTMode; +extern FIL GameFile; void CardInit( void ) { FILINFO f; u32 i,wrote; CARDStat CStat; + char GameID[0x20]; + memset32( (void*)CARD_BASE, 0xdeadbeef, 0x20 ); memset32( (void*)CARD_SHADOW, 0, 0x20 ); @@ -18,10 +22,20 @@ void CardInit( void ) f_chdir("/saves"); } - if( f_chdir((const TCHAR*)0) != FR_OK ) + if( FSTMode ) { - f_mkdir((const TCHAR*)0); - f_chdir((const TCHAR*)0); + FSTRead( (char*)GameID, 0x20, 0 ); + + } else { + + f_lseek( &GameFile, 0 ); + f_read( &GameFile, (char*)GameID, 0x20, &wrote ); + } + + if( f_chdir(GameID) != FR_OK ) + { + f_mkdir(GameID); + f_chdir(GameID); } switch( f_stat( "stats.bin", &f ) ) @@ -57,6 +71,7 @@ void CardInit( void ) write32( 0x2FA0, 0 ); } + s32 CardFindFreeEntry( void ) { CARDStat CStat; @@ -88,8 +103,8 @@ s32 CardFindEntryByName( char *Filename ) { f_lseek( &CardStat, sizeof(CARDStat) * i ); f_read( &CardStat, &CStat, sizeof(CARDStat), &read ); - - if( memcmp( Filename, CStat.fileName, strlen(Filename) ) == 0 ) + + if( strcmp( Filename, CStat.fileName ) == 0 ) { //dbgprintf("CardFindEntryByName(%d,%s,%s)\n", i, Filename, CStat.fileName ); return i; @@ -144,7 +159,7 @@ s32 CardFastOpenFile( u32 FileNo, CARDFileInfo *CFInfo ) { CARDStat CStat; FIL savefile; - s32 fres; + s32 Slot,fres; u32 read; if( FileNo >= CARD_MAX_FILES ) @@ -505,10 +520,9 @@ void CardUpdateStats( CARDStat *CStat ) CStat->offsetData = Offset; } -u32 Device = 0; void CARDUpdateRegisters( void ) { - u32 read; + u32 read,i; if( read32(CARD_CONTROL) != 0xdeadbeef ) { @@ -524,20 +538,17 @@ void CARDUpdateRegisters( void ) write32( CARD_CONTROL, 0xdeadbeef ); -#ifdef ACTIVITYLED - set32( HW_GPIO_OUT, 1<<5 ); -#endif + if( ConfigGetConfig(DML_CFG_ACTIVITY_LED) ) + set32( HW_GPIO_OUT, 1<<5 ); while( read32(CARD_CMD) == 0xdeadbeef ); write32( CARD_SCMD, read32(CARD_CMD) ); write32( CARD_CMD, 0xdeadbeef ); - - if( read32(CARD_CMD_1) != 0xdeadbeef ) - { - write32( CARD_SCMD_1, read32(CARD_CMD_1) ); - write32( CARD_CMD_1, 0xdeadbeef ); - } + while( read32(CARD_CMD_1) == 0xdeadbeef ); + write32( CARD_SCMD_1, read32(CARD_CMD_1) ); + write32( CARD_CMD_1, 0xdeadbeef ); + if( read32(CARD_CMD_2) != 0xdeadbeef ) { write32( CARD_SCMD_2, read32(CARD_CMD_2) ); @@ -565,12 +576,9 @@ void CARDUpdateRegisters( void ) default: { //EXIControl(1); - dbgprintf("CARD:Unknown CMD:%08X %08X %08X %08X %08X %08X\n", read32(CARD_SCMD), read32(CARD_SCMD_1), read32(CARD_SCMD_2), read32(CARD_SCMD_3), read32(CARD_SCMD_4), read32(CARD_SCONTROL) ); - Shutdown(); } break; - /* CARDOpen( char *FileName ) */ case 0xC0: { @@ -942,8 +950,8 @@ void CARDUpdateRegisters( void ) #endif } break; } -#ifdef ACTIVITYLED - clear32( HW_GPIO_OUT, 1<<5 ); -#endif + + if( ConfigGetConfig(DML_CFG_ACTIVITY_LED) ) + clear32( HW_GPIO_OUT, 1<<5 ); } } diff --git a/Config.c b/Config.c index 9f7032c..98c5582 100644 --- a/Config.c +++ b/Config.c @@ -9,15 +9,15 @@ void ConfigInit( DML_CFG *Cfg ) memset32( DMLCfg, 0, sizeof(DML_CFG) ); //If a loader supplied any options we use them otherwise use the code defines - if( Cfg->Magicbytes == 0xD1050CF6 && Cfg->Version == CONFIG_VERSION ) + if( Cfg->Magicbytes == 0xD1050CF6 ) { memcpy( DMLCfg, Cfg, sizeof( DML_CFG ) ); } else { - dbgprintf("No config found in RAM\n"); + dbgprintf("No valid config found in RAM\n"); dbgprintf("Version:%08X\n", DMLCfg->Version ); - dbgprintf("Config:%08X\n", DMLCfg->Config ); + dbgprintf("Config :%08X\n", DMLCfg->Config ); DMLCfg->Config = 0; #ifdef CHEATHOOK @@ -41,9 +41,9 @@ void ConfigInit( DML_CFG *Cfg ) #ifdef PADHOOK DMLCfg->Config |= DML_CFG_PADHOOK; #endif - DMLCfg->VideoMode = DML_VID_DML_AUTO; - DMLCfg->Version = CONFIG_VERSION; DMLCfg->Magicbytes = 0xD1050CF6; + DMLCfg->Version = CONFIG_VERSION; + DMLCfg->VideoMode = DML_VID_DML_AUTO; } //Check if a memcard is inserted in Slot A diff --git a/Config.h b/Config.h index 4d5fd97..01d9459 100644 --- a/Config.h +++ b/Config.h @@ -3,7 +3,6 @@ #include "string.h" #include "global.h" -#include "ipc.h" #include "alloc.h" #include "vsprintf.h" #include "HW.h" diff --git a/HW.h b/HW.h index 8b6a47f..e329488 100644 --- a/HW.h +++ b/HW.h @@ -4,7 +4,6 @@ #include "string.h" #include "global.h" #include "memory.h" -#include "ipc.h" #include "alloc.h" #include "dip.h" diff --git a/Patches.c b/Patches.c index 0dda486..7344061 100644 --- a/Patches.c +++ b/Patches.c @@ -887,8 +887,11 @@ void DoPatches( char *ptr, u32 size, u32 SectionOffset ) if( FPatterns[j].Patch == (u8*)DVDGetDriveStatus ) { - if( !ConfigGetConfig( DML_CFG_NODISC ) ) + if( (read32(0) >> 8) != 0x474754 && // Chibi-Robo! + (read32(0) >> 8) != 0x475041 ) // Pokémon Channel break; + + dbgprintf("Patch:DVDGetDriveStatus\n"); } if( (FPatterns[j].Length >> 16) == 0xdead ) diff --git a/Patches.h b/Patches.h index fe64b2a..d6cafa5 100644 --- a/Patches.h +++ b/Patches.h @@ -3,7 +3,6 @@ #include "string.h" #include "global.h" -#include "ipc.h" #include "alloc.h" #include "ff.h" #include "vsprintf.h" diff --git a/dip.c b/dip.c index a547222..61de201 100644 --- a/dip.c +++ b/dip.c @@ -37,6 +37,7 @@ char *getfilenamebyoffset(u32 offset) return (char*)NULL; } + void DIInit( void ) { memset32( (void*)DI_BASE, 0xdeadbeef, 0x30 ); @@ -53,7 +54,7 @@ u32 DIUpdateRegisters( void ) static u32 PatchState = 0; static u32 DOLReadSize = 0; static u32 PSOHack = 0; - + if( read32(DI_CONTROL) != 0xdeadbeef ) { write32( DI_SCONTROL, read32(DI_CONTROL) & 3 ); @@ -102,7 +103,7 @@ u32 DIUpdateRegisters( void ) write32( DI_SIMM, read32(DI_IMM) ); write32( DI_IMM, 0xdeadbeef ); } - + switch( read32(DI_SCMD_0) >> 24 ) { case 0xA7: @@ -156,7 +157,8 @@ u32 DIUpdateRegisters( void ) switch( Offset ) { case 0x56B8E7E0: // AppSwitcher [EUR] - case 0x56C49600: // [USA] + case 0x56C49600: // [USA] v1.1 + case 0x56C4C980: // [USA] v1.0 { DMLCfg->Config &= ~(DML_CFG_CHEATS|DML_CFG_PADHOOK|DML_CFG_DEBUGGER|DML_CFG_DEBUGWAIT); @@ -164,7 +166,8 @@ u32 DIUpdateRegisters( void ) } break; case 0x5668FE20: // psov3.dol [EUR] - case 0x56750660: // [USA] + case 0x56750660: // [USA] v1.1 + case 0x56753EC0: // [USA] v1.0 { PSOHack = 1; } break; diff --git a/global.h b/global.h index 2c540b5..5b025e7 100644 --- a/global.h +++ b/global.h @@ -15,7 +15,7 @@ #define PADHOOK 1 #define CONFIG_VERSION 0x00000002 -#define DM_VERSION 0x00020002 +#define DM_VERSION 0x00020003 #define DI_SUCCESS 1 #define DI_ERROR 2 diff --git a/ipc.h b/ipc.h deleted file mode 100644 index e703c41..0000000 --- a/ipc.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef __IPC_H__ -#define __IPC_H__ 1 - -struct ioctl_vector { - void *data; - unsigned int len; -} __attribute__((packed)); - -struct ipcmessage -{ - unsigned int command; // 0 - unsigned int result; // 4 - union - { - unsigned int fd; // 8 - }; - union - { - struct - { - char *device; // 12 - unsigned int mode; // 16 - unsigned int resultfd; // 20 - } open; - - struct - { - void *data; - unsigned int length; - } read, write; - - struct - { - int offset; - int origin; - } seek; - - struct - { - unsigned int command; - - unsigned int *buffer_in; - unsigned int length_in; - unsigned int *buffer_io; - unsigned int length_io; - } ioctl; - - struct - { - unsigned int command; // C - - unsigned int argc_in; // 10 - unsigned int argc_io; // 14 - struct ioctl_vector *argv; // 18 - } ioctlv; - }; -} __attribute__((packed)) ipcmessage; - -#define IOS_OPEN 0x01 -#define IOS_CLOSE 0x02 -#define IOS_READ 0x03 -#define IOS_WRITE 0x04 -#define IOS_SEEK 0x05 -#define IOS_IOCTL 0x06 -#define IOS_IOCTLV 0x07 - -#endif diff --git a/main.c b/main.c index 60797fc..b472dd1 100644 --- a/main.c +++ b/main.c @@ -7,7 +7,6 @@ Copyright (C) 2010-2012 crediar */ #include "string.h" #include "global.h" -#include "ipc.h" #include "alloc.h" #include "ff.h" #include "diskio.h" diff --git a/memory.h b/memory.h index c645c22..326b712 100644 --- a/memory.h +++ b/memory.h @@ -3,7 +3,6 @@ #include "string.h" #include "global.h" -#include "ipc.h" #include "utils.h" #include "hollywood.h" #include "vsprintf.h"