forked from emukidid/cleanrip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Datel Disc dumping. Must have information in datel.dat for the disc.
- Loading branch information
Showing
7 changed files
with
412 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?xml version="1.0"?> | ||
<!DOCTYPE datafile PUBLIC "-//Logiqx//DTD ROM Management Datafile//EN" "http://www.logiqx.com/Dats/datafile.dtd"> | ||
<datafile> | ||
<header> | ||
<name>Nintendo - GameCube</name> | ||
<description>Nintendo - GameCube 20130714 15-46-40</description> | ||
<version>20130714 15-46-40</version> | ||
<date>20130714 15-46-40</date> | ||
<author>redump.org</author> | ||
<homepage>redump.org</homepage> | ||
<url>http://redump.org/</url> | ||
</header> | ||
<game name="Datel Advanced Game Port (USA)"> | ||
<category>Applications</category> | ||
<description>Datel Advanced Game Port (USA)</description> | ||
<rom name="Datel Advanced Game Port (USA).iso" size="1459978240" crc="5B478075" md5="0F9710ACA393CF6EFDB1094B96386F3F" sha1="BC6DFEA0577A7C5455473C63362330816CAB4792"/> | ||
<skipcrc crc100000="B5B5592A" skipfill="00"/> | ||
<skip start="00100000" stop="098FFFFF"/> | ||
<skip start="09A00000" stop="0A8FFFFF"/> | ||
<skip start="0AA00000" stop="0B0FFFFF"/> | ||
<skip start="0B200000" stop="0B8FFFFF"/> | ||
<skip start="0BA00000" stop="0C0FFFFF"/> | ||
<skip start="0C200000" stop="0D8FFFFF"/> | ||
<skip start="0DA00000" stop="0E0FFFFF"/> | ||
<skip start="0E200000" stop="0E8FFFFF"/> | ||
<skip start="0EA00000" stop="0F0FFFFF"/> | ||
<skip start="0F200000" stop="0F8FFFFF"/> | ||
<skip start="0FA00000" stop="12AFFFFF"/> | ||
<skip start="12F00000" stop="4FFFFFFF"/> | ||
<skip start="50100000" stop="FFFFFFFF"/> | ||
</game> | ||
<game name="Datel Action Replay (v1.14A)"> | ||
<category>Applications</category> | ||
<description>Datel Action Replay (v1.14A)</description> | ||
<rom name="Datel Action Replay (v1.14A).iso" size="1459978240" crc="1343B270" md5="20CFC5F87ACA12C1E983B23D6145EDAF" sha1="BEA42EE605A7878EEE608AED314432CEBAD20CC6"/> | ||
<skipcrc crc100000="9BEEFEEF" skipfill="00"/> | ||
<skip start="00100000" stop="4FFFFFFF"/> | ||
<skip start="50400000" stop="FFFFFFFF"/> | ||
</game> | ||
<game name="NHL Hitz 2002 (USA)"> | ||
<category>Games</category> | ||
<description>NHL Hitz 2002 (USA)</description> | ||
<rom name="NHL Hitz 2002 (USA).iso" size="1459978240" crc="53f2137a" md5="488d2a15d25da53fa4451a5e8471dfbc" sha1="64d8b607aa2b5fa5fbbb5bfb0be149080781370f"/> | ||
<skipcrc crc100000="5D1B4684" skipfill="00"/> | ||
</game> | ||
<game name="NHL Hitz 2002 (Europe)"> | ||
<category>Games</category> | ||
<description>NHL Hitz 2002 (Europe)</description> | ||
<rom name="NHL Hitz 2002 (Europe).iso" size="1459978240" crc="f8f19d9c" md5="9b04a5dadd1de2ef1e428994506370a0" sha1="c3966219b00b3dbd33ef3070427e03cd4f7f721d"/> | ||
<skipcrc crc100000="" skipfill="00"/> | ||
</game> | ||
</datafile> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* CleanRip - verify.h | ||
* Copyright (C) 2010 emu_kidid | ||
* | ||
* CleanRip homepage: http://code.google.com/p/cleanrip/ | ||
* email address: emukidid@gmail.com | ||
* | ||
* | ||
* This program is free software; you can redistribute it and/ | ||
* or modify it under the terms of the GNU General Public Li- | ||
* cence as published by the Free Software Foundation; either | ||
* version 2 of the Licence, or any later version. | ||
* | ||
* This program is distributed in the hope that it will be use- | ||
* ful, but WITHOUT ANY WARRANTY; without even the implied war- | ||
* ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public Licence for more details. | ||
* | ||
**/ | ||
|
||
#ifndef DATEL_H | ||
#define DATEL_H | ||
|
||
void datel_init(char *mountPath); | ||
int datel_findCrcSum(int crc); | ||
int datel_is_available(int disc_type); | ||
int datel_download(char *mountPath); | ||
char *datel_get_name(); | ||
void datel_adjustStartStop(uint64_t* start, int* length, int* fill); | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,271 @@ | ||
/** | ||
* CleanRip - verify.c | ||
* Copyright (C) 2010 emu_kidid | ||
* | ||
* Uses redump.org .dat files to verify MD5 sums using XML | ||
* | ||
* CleanRip homepage: http://code.google.com/p/cleanrip/ | ||
* email address: emukidid@gmail.com | ||
* | ||
* | ||
* This program is free software; you can redistribute it and/ | ||
* or modify it under the terms of the GNU General Public Li- | ||
* cence as published by the Free Software Foundation; either | ||
* version 2 of the Licence, or any later version. | ||
* | ||
* This program is distributed in the hope that it will be use- | ||
* ful, but WITHOUT ANY WARRANTY; without even the implied war- | ||
* ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public Licence for more details. | ||
* | ||
**/ | ||
|
||
#include <gccore.h> | ||
#include <malloc.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <ogcsys.h> | ||
#include <string.h> | ||
#include <sys/dir.h> | ||
#include <network.h> | ||
#include <mxml.h> | ||
#include "FrameBufferMagic.h" | ||
#include "IPLFontWrite.h" | ||
#include "http.h" | ||
#include "main.h" | ||
#include "verify.h" | ||
|
||
// Pointers to the file | ||
static char *datelDAT = NULL; | ||
static int datel_initialized = 0; | ||
static int datelDontAskAgain = 0; | ||
static int SkipFill = 0; | ||
static int NumSkips = 0; | ||
#define MAX_SKIPS (1000) | ||
static uint64_t SkipStart[MAX_SKIPS]; | ||
static uint64_t SkipStop[MAX_SKIPS]; | ||
|
||
// XML stuff | ||
static mxml_node_t *datelXML = NULL; | ||
static char gameName[256]; | ||
|
||
void datel_init(char *mountPath) { | ||
if (datel_initialized) { | ||
return; | ||
} | ||
|
||
if(datelDAT) { | ||
if(datelXML) { | ||
mxmlDelete(datelXML); | ||
free(datelXML); | ||
} | ||
free(datelDAT); | ||
} | ||
|
||
mxmlSetErrorCallback(print_gecko); | ||
FILE *fp = NULL; | ||
// Check for the datel DAT and read it | ||
sprintf(txtbuffer, "%sdatel.dat", mountPath); | ||
fp = fopen(txtbuffer, "rb"); | ||
if (fp) { | ||
fseek(fp, 0, SEEK_END); | ||
int size = ftell(fp); | ||
fseek(fp, 0, SEEK_SET); | ||
if (size > 0) { | ||
datelDAT = (char*) memalign(32, size); | ||
if (datelDAT) { | ||
fread(datelDAT, 1, size, fp); | ||
} | ||
} | ||
fclose(fp); | ||
fp = NULL; | ||
} | ||
|
||
if (datelDAT) { | ||
datelXML = mxmlLoadString(NULL, datelDAT, MXML_TEXT_CALLBACK); | ||
} | ||
|
||
print_gecko("DAT Files [Datel: %s]\r\n", datelDAT ? "YES":"NO"); | ||
datel_initialized = (datelDAT&&datelXML); | ||
} | ||
|
||
// If there was some new files obtained, return 1, else 0 | ||
void datel_download(char *mountPath) { | ||
if(datelDontAskAgain) { | ||
return; | ||
} | ||
|
||
int res = 0; | ||
// Ask the user if they want to update from the web | ||
if(datel_initialized) { | ||
char *line1 = "GitHUB.org DAT file found"; | ||
char *line2 = "Check for updated DAT file?"; | ||
res = DrawYesNoDialog(line1, line2); | ||
} | ||
else { | ||
char *line1 = "GitHUB.org DAT files not found"; | ||
char *line2 = "Download them now?"; | ||
res = DrawYesNoDialog(line1, line2); | ||
} | ||
|
||
// If yes, lets download an update | ||
if(res) { | ||
// Initialize the network | ||
if(!net_initialized) { | ||
char ip[16]; | ||
DrawMessageBox(D_INFO, "Checking for DAT updates\n \nInitializing Network..."); | ||
res = if_config(ip, NULL, NULL, true); | ||
if(res >= 0) { | ||
sprintf(txtbuffer, "Checking for DAT updates\nNetwork Initialized!\nIP: %s", ip); | ||
DrawMessageBox(D_INFO, txtbuffer); | ||
net_initialized = 1; | ||
print_gecko("Network Initialized!\r\n"); | ||
} | ||
else { | ||
DrawMessageBox(D_FAIL, "Checking for DAT updates\nNetwork failed to Initialize!"); | ||
sleep(5); | ||
net_initialized = 0; | ||
print_gecko("Network Failed to Initialize!\r\n"); | ||
return; | ||
} | ||
} | ||
|
||
// Download the GC DAT | ||
char datFilePath[64]; | ||
sprintf(datFilePath, "%sdatel.dat",mountPath); | ||
u8 *xmlFile = (u8*)memalign(32, 1*1024*1024); | ||
if((res = http_request("www.gc-forever.com","/datfile/datel.dat", xmlFile, (1*1024*1024), 0, 0)) > 0) { | ||
remove(datFilePath); | ||
FILE *fp = fopen(datFilePath, "wb"); | ||
if(fp) { | ||
DrawMessageBox(D_INFO, "Checking for updates\nSaving GC DAT..."); | ||
fwrite(xmlFile, 1, res, fp); | ||
fclose(fp); | ||
datel_initialized = 0; | ||
print_gecko("Saved GameCube DAT! %i Bytes\r\n", res); | ||
} | ||
else { | ||
DrawMessageBox(D_FAIL, "Checking for updates\nFailed to save Datel DAT..."); | ||
sleep(5); | ||
} | ||
} | ||
else { | ||
sprintf(txtbuffer, "Error: %i", res); | ||
print_gecko("Error Saving Datel DAT %i\r\n", res); | ||
DrawMessageBox(D_FAIL, "Checking for updates\nCouldn't find file on gc-forever.com"); | ||
sleep(5); | ||
} | ||
free(xmlFile); | ||
datelDontAskAgain = 1; | ||
} | ||
else { | ||
datelDontAskAgain = 1; | ||
} | ||
} | ||
|
||
int datel_findCrcSum(int crcorig) { | ||
|
||
NumSkips = 0; | ||
print_gecko("Looking for CRC [%x]\r\n", crcorig); | ||
char *xmlPointer = datelDAT; | ||
if(xmlPointer) { | ||
mxml_node_t *pointer = datelXML; | ||
|
||
pointer = mxmlLoadString(NULL, xmlPointer, MXML_TEXT_CALLBACK); | ||
|
||
print_gecko("Looking in the Datel XML\r\n"); | ||
if (pointer) { | ||
// open the <datafile> | ||
mxml_node_t *item = mxmlFindElement(pointer, pointer, "datafile", NULL, | ||
NULL, MXML_DESCEND); | ||
print_gecko("DataFile Pointer OK\r\n"); | ||
if (item) { | ||
mxml_index_t *iterator = mxmlIndexNew(item, "game", NULL); | ||
mxml_node_t *gameElem = NULL; | ||
|
||
//print_gecko("Item Pointer OK\r\n"); | ||
// iterate over all the <game> entries | ||
while ((gameElem = mxmlIndexEnum(iterator)) != NULL) { | ||
// get the crc and compare it | ||
mxml_node_t *crcElem = mxmlFindElement(gameElem, gameElem, | ||
NULL, "crc100000", NULL, MXML_DESCEND); | ||
// get the name too | ||
mxml_node_t *nameElem = mxmlFindElement(gameElem, gameElem, | ||
NULL, "name", NULL, MXML_DESCEND); | ||
mxml_node_t *fillElem = mxmlFindElement(gameElem, gameElem, | ||
NULL, "skipfill", NULL, MXML_DESCEND); | ||
|
||
char crc[64]; | ||
memset(&crc[0], 0, 64); | ||
strncpy(&crc[0], mxmlElementGetAttr(crcElem, "crc100000"), 32); | ||
|
||
int crcval = strtoul(crc, NULL, 16); | ||
|
||
memset(&crc[0], 0, 64); | ||
strncpy(&crc[0], mxmlElementGetAttr(fillElem, "skipfill"), 32); | ||
|
||
SkipFill = strtoul(crc, NULL, 16); | ||
//print_gecko("Comparing game [%x] and crc [%x]\r\n",mxmlElementGetAttr(nameElem, "name"),mxmlElementGetAttr(crcElem, "crc100000")); | ||
if (crcval == crcorig) { | ||
snprintf(&gameName[0], 128, "%s", mxmlElementGetAttr( | ||
nameElem, "name")); | ||
DrawYesNoDialog("Found datel crc", gameName); | ||
print_gecko("Found a match!\r\n"); | ||
mxml_index_t *skipiterator = mxmlIndexNew(gameElem, "skip", NULL); | ||
mxml_node_t *skipElem = NULL; | ||
|
||
//print_gecko("Item Pointer OK\r\n"); | ||
// iterate over all the <game> entries | ||
while ((skipElem = mxmlIndexEnum(skipiterator)) != NULL) { | ||
if (NumSkips >= MAX_SKIPS) | ||
DrawYesNoDialog("datel crc", "TODO: Too many skips. Fix source code."); | ||
char skipstr[64]; | ||
memset(&skipstr[0], 0, 64); | ||
strncpy(&skipstr[0], mxmlElementGetAttr(skipElem, "start"), 32); | ||
|
||
SkipStart[NumSkips] = strtoull(skipstr, NULL, 16); | ||
|
||
memset(&skipstr[0], 0, 64); | ||
strncpy(&skipstr[0], mxmlElementGetAttr(skipElem, "stop"), 32); | ||
|
||
SkipStop[NumSkips] = strtoull(skipstr, NULL, 16); | ||
NumSkips++; | ||
} | ||
return 1; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
void datel_adjustStartStop(uint64_t* start, int* length, int* fill) { | ||
int n=0; | ||
*fill = SkipFill; | ||
for (n=0; (n<NumSkips) && (*length > 0); n++) { | ||
if ((SkipStart[n] <= *start) && (SkipStop[n] >= *start)) { | ||
if (SkipStop[n] + 1 > *start + *length) | ||
*length = 0; | ||
else { | ||
*length -= SkipStop[n] + 1 - *start; | ||
*start = SkipStop[n] + 1; | ||
} | ||
} | ||
if ((SkipStart[n] < (*start + *length)) && (SkipStop[n] >= (*start + *length - 1)) && (*length > 0)) | ||
*length = SkipStart[n] - *start; | ||
} | ||
} | ||
|
||
char *datel_get_name() { | ||
if(strlen(&gameName[0]) > 32) { | ||
gameName[30] = '.'; | ||
gameName[31] = '.'; | ||
gameName[32] = 0; | ||
} | ||
return &gameName[0]; | ||
} | ||
|
||
int datel_is_available() { | ||
return datelDAT != NULL; | ||
} |
Oops, something went wrong.