SNEEK+DI titles.txt

Discussion in 'Wii - Hacking' started by nano351, Jan 16, 2011.

  1. nano351
    OP

    nano351 GBAtemp Regular

    Member
    259
    2
    Jun 6, 2009
    United States
    I made a modificaiton to SNEEK's DI module which I think is pretty useful.

    When you open up SNEEK and look at the DI game menu you get a list of games but some of them have crappy names because they are the one's being read off of the disc's data. So I wrote this modification of the DVDUpdateCache() function to have it read titles of games from a titles.txt file obtained from WiiTDB. It also modifies the code that counts how many games you have installed so that it doesn't mistake titles.txt as a game folder and then cause an invalid game to be in the games list.

    In dip.c replace the DVDUpdateCache() function with this new one:
    CODEs32 DVDUpdateCache( void )
    {ÂÂÂÂÂÂÂÂ
    ÂÂÂÂ//check if new games were installed
    ÂÂÂÂu32 GameCount=0;
    ÂÂÂÂif( DVDOpenDir( "/games" ) != DVD_SUCCESS )
    ÂÂÂÂ{
    ÂÂÂÂÂÂÂÂdbgprintf("DIP:Could not open game dir!\n");
    ÂÂÂÂÂÂÂÂreturn DI_FATAL;
    ÂÂÂÂ}

    ÂÂÂÂchar *TempPath = (char*)malloca(128, 32);

    ÂÂÂÂwhile( DVDReadDir() == DVD_SUCCESS )
    ÂÂÂÂ{
    ÂÂÂÂÂÂÂÂsprintf( TempPath, "/games/%s/sys/boot.bin", DVDDirGetEntryName() );

    ÂÂÂÂÂÂÂÂs32 bi = DVDOpen( TempPath, FA_READ );
    ÂÂÂÂÂÂÂÂif( bi >= 0 ){
    ÂÂÂÂÂÂÂÂÂÂÂÂGameCount++;
    ÂÂÂÂÂÂÂÂÂÂÂÂDVDClose( bi );
    ÂÂÂÂÂÂÂÂ}
    ÂÂÂÂ}

    ÂÂÂÂfree(TempPath);

    ÂÂÂÂs32 fd = DVDOpen( "/sneek/diconfig.bin", FA_WRITE|FA_READ );
    ÂÂÂÂif( fd < 0 )
    ÂÂÂÂ{
    ÂÂÂÂÂÂÂÂif( fd == DVD_NO_FILE )
    ÂÂÂÂÂÂÂÂ{
    ÂÂÂÂÂÂÂÂÂÂÂÂDVDCreateDir( "/sneek" );
    ÂÂÂÂÂÂÂÂÂÂÂÂfd = DVDOpen( "/sneek/diconfig.bin", FA_CREATE_ALWAYS|FA_WRITE|FA_READ );
    ÂÂÂÂÂÂÂÂÂÂÂÂif( fd < 0 )
    ÂÂÂÂÂÂÂÂÂÂÂÂ{
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂdbgprintf("DIP:Failed to create sneek folder/diconfig.bin file!\n");
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂreturn DI_FATAL;
    ÂÂÂÂÂÂÂÂÂÂÂÂ}ÂÂÂÂÂÂÂÂÂÂÂÂ
    ÂÂÂÂÂÂÂÂ}
    ÂÂÂÂ}

    ÂÂÂÂif( DVDGetSize(fd) >= 0x10 )
    ÂÂÂÂ{
    ÂÂÂÂÂÂÂÂDVDRead( fd, DICfg, sizeof(u32) * 4 );

    ÂÂÂÂÂÂÂÂif( DVDGetSize(fd) != GameCount * 0x60 + 0x10 )
    ÂÂÂÂÂÂÂÂ{
    ÂÂÂÂÂÂÂÂÂÂÂÂDVDClose( fd );
    ÂÂÂÂÂÂÂÂÂÂÂÂfd = DVDOpen( "/sneek/diconfig.bin", FA_CREATE_ALWAYS|FA_WRITE|FA_READ );
    ÂÂÂÂÂÂÂÂÂÂÂÂif( fd < 0 )
    ÂÂÂÂÂÂÂÂÂÂÂÂ{
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂdbgprintf("DIP:Failed to create sneek folder/diconfig.bin file!\n");
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂreturn DI_FATAL;
    ÂÂÂÂÂÂÂÂÂÂÂÂ}
    ÂÂÂÂÂÂÂÂÂÂÂÂDVDWrite( fd, DICfg, sizeof(u32) * 4 );
    ÂÂÂÂÂÂÂÂ}

    ÂÂÂÂ} else {

    ÂÂÂÂÂÂÂÂdbgprintf("DIP:Creating new DI-Config\n");

    ÂÂÂÂÂÂÂÂDICfg->Region = EUR;
    ÂÂÂÂÂÂÂÂDICfg->SlotID = 0;
    ÂÂÂÂÂÂÂÂDICfg->Config = CONFIG_PATCH_MPVIDEO;
    ÂÂÂÂÂÂÂÂDICfg->Gamecount = 0;

    ÂÂÂÂÂÂÂÂDVDWrite( fd, DICfg, sizeof(u32) * 4 );
    ÂÂÂÂ}

    ÂÂÂÂdbgprintf("DIP:Installed Games:%d\tGames in cache:%d\n", GameCount, DICfg->Gamecount );

    ÂÂÂÂif( GameCount != DICfg->Gamecount )
    ÂÂÂÂ{
    ÂÂÂÂÂÂÂÂs32 titlesFile = DVDOpen("/games/titles.txt", FA_READ);
    ÂÂÂÂÂÂÂÂchar* titlesContent = NULL;
    ÂÂÂÂÂÂÂÂu32 titlesSize = 0;
    ÂÂÂÂÂÂÂÂif (titlesFile >= 0){
    ÂÂÂÂÂÂÂÂÂÂÂÂtitlesSize = DVDGetSize(titlesFile);
    ÂÂÂÂÂÂÂÂÂÂÂÂtitlesContent = (char*) malloc(titlesSize + 1);
    ÂÂÂÂÂÂÂÂÂÂÂÂtitlesContent[titlesSize] = 0;
    ÂÂÂÂÂÂÂÂÂÂÂÂDVDRead(titlesFile,titlesContent,titlesSize);
    ÂÂÂÂÂÂÂÂÂÂÂÂDVDClose(titlesFile);
    ÂÂÂÂÂÂÂÂ}
    ÂÂÂÂÂÂÂÂ
    ÂÂÂÂÂÂÂÂdbgprintf("DIP:Updating game info cache...");

    ÂÂÂÂÂÂÂÂDVDSeek( fd, 0, 0x10 );

    ÂÂÂÂÂÂÂÂchar *LPath = (char*)malloca( 128, 32 );
    ÂÂÂÂÂÂÂÂchar *GInfo = (char*)malloca( 0x60, 32 );
    ÂÂÂÂÂÂÂÂchar* GInfoName = &GInfo[32];

    ÂÂÂÂÂÂÂÂif( DVDOpenDir( "/games" ) == DVD_SUCCESS )
    ÂÂÂÂÂÂÂÂ{
    ÂÂÂÂÂÂÂÂÂÂÂÂwhile( DVDReadDir() == DVD_SUCCESS )
    ÂÂÂÂÂÂÂÂÂÂÂÂ{
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂif( DVDDirIsFile() )ÂÂÂÂÂÂÂÂ// skip files
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂcontinue;

    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂsprintf( LPath, "/games/%s/sys/boot.bin", DVDDirGetEntryName() );

    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂs32 bi = DVDOpen( LPath, FA_READ );
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂif( bi >= 0 )
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ{
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂDVDRead( bi, GInfo, 0x60 );
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂif (titlesContent != NULL){
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂchar* curSearch = titlesContent;
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂu32 found = 0;
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂwhile (curSearch != NULL && found == 0){
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂif (strncmp(DVDDirGetEntryName(),curSearch,6) == 0){
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂfound = 1;
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂcurSearch += 9;
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂchar* endLine = strchr(curSearch,'\r');
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂif (endLine == NULL){
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂendLine = &titlesContent[titlesSize];
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ}
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂu32 length = (u32) (endLine - curSearch);
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂif (length > 64)
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂlength = 64;
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂmemcpy(GInfoName,curSearch,length);
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂGInfoName[length] = 0;
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ}
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂelse{
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂcurSearch = strchr(curSearch,'\n');
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂif (curSearch != NULL)
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂcurSearch += 1;
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ}
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ}
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ}

    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂDVDWrite( fd, GInfo, 0x60 );
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂDVDClose( bi );
    ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ}
    ÂÂÂÂÂÂÂÂÂÂÂÂ}
    ÂÂÂÂÂÂÂÂ}
    ÂÂÂÂÂÂÂÂif (titlesContent != NULL)
    ÂÂÂÂÂÂÂÂÂÂÂÂfree(titlesContent);

    ÂÂÂÂÂÂÂÂfree( LPath );
    ÂÂÂÂÂÂÂÂfree( GInfo );

    ÂÂÂÂÂÂÂÂDICfg->Gamecount = GameCount;

    ÂÂÂÂÂÂÂÂif( DICfg->SlotID >= DICfg->Gamecount )
    ÂÂÂÂÂÂÂÂÂÂÂÂDICfg->SlotID = 0;

    ÂÂÂÂÂÂÂÂif( DICfg->Region > LTN )
    ÂÂÂÂÂÂÂÂÂÂÂÂDICfg->Region = EUR;
    ÂÂÂÂÂÂÂÂ
    ÂÂÂÂÂÂÂÂDVDSeek( fd, 0, 0 );
    ÂÂÂÂÂÂÂÂDVDWrite( fd, DICfg, 0x10 );

    ÂÂÂÂÂÂÂÂdbgprintf("done\n");
    ÂÂÂÂ}

    ÂÂÂÂDVDClose( fd );

    ÂÂÂÂreturn DI_SUCCESS;
    }

    then recompile the DI module and put it with your sneek stuff. To get your titles.txt setup go download a titles.txt file from here. save it as titles.txt in your games folder on your usb device. Make sure it's encoded as either ANSI or UTF-8. ANSI would be preferable as sneek probably can't disply unicode characters anyhow.

    Additional note: the titles.txt is only read during the caching of the games you have. So in order to get DI to use the titles you have in the titles.txt you'll need to either change the number of games you have on your USB or delete your diconfig.bin file so that DI will recache the titles of the games.
     
  2. PizzaPino

    PizzaPino GBAtemp Fan

    Member
    308
    17
    Oct 4, 2008
    Spain
    i haven't tested it yet, but very useful for me. thanks!
     
  3. Slimmmmmm

    Slimmmmmm GBAtemp MoNkEeE

    Member
    1,687
    27
    Nov 1, 2007
    the land of lol
    Very good, not for me but worth a bump [​IMG]