Skip to content

Commit

Permalink
- Guess which region a file belongs to.
Browse files Browse the repository at this point in the history
  • Loading branch information
Extrems committed Oct 21, 2021
1 parent 78f6088 commit 244931f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cube/swiss/source/devices/filemeta.c
Expand Up @@ -190,6 +190,13 @@ void populate_meta(file_handle *f) {
card_stat stat;
if(CARD_GetStatus(dir->chn, dir->fileno, &stat) == CARD_ERROR_READY) {
populate_save_meta(f, stat.banner_fmt, stat.icon_addr, stat.comment_addr);
char region = getGCIRegion((const char*)stat.gamecode);
if(region == 'J')
f->meta->regionTexObj = &ntscjTexObj;
else if(region == 'E')
f->meta->regionTexObj = &ntscuTexObj;
else if(region == 'P')
f->meta->regionTexObj = &palTexObj;
}
}
else if(endsWith(f->name,".gci")) {
Expand All @@ -199,6 +206,13 @@ void populate_meta(file_handle *f) {
if(gci.icon_addr != -1) gci.icon_addr += sizeof(GCI);
if(gci.comment_addr != -1) gci.comment_addr += sizeof(GCI);
populate_save_meta(f, gci.banner_fmt, gci.icon_addr, gci.comment_addr);
char region = getGCIRegion((const char*)gci.gamecode);
if(region == 'J')
f->meta->regionTexObj = &ntscjTexObj;
else if(region == 'E')
f->meta->regionTexObj = &ntscuTexObj;
else if(region == 'P')
f->meta->regionTexObj = &palTexObj;
}
}
else if(endsWith(f->name,".gcm") || endsWith(f->name,".iso")) {
Expand Down
29 changes: 29 additions & 0 deletions cube/swiss/source/devices/memcard/deviceHandler-CARD.c
Expand Up @@ -429,6 +429,35 @@ void setGCIInfo(void *buffer) {
}
}

char getGCIRegion(const char *gameID)
{
if (!strncmp(gameID, "DOLX00", 6) || !strncmp(gameID, "SWISS0", 6))
return 'A';

switch (gameID[3]) {
case 'J':
case 'K':
case 'W':
return 'J';
case 'E':
return 'E';
case 'D':
case 'F':
case 'H':
case 'I':
case 'P':
case 'S':
case 'U':
case 'X':
case 'Y':
return 'P';
case 'A':
return 'A';
default:
return '?';
}
}

s32 deviceHandler_CARD_setupFile(file_handle* file, file_handle* file2, int numToPatch) {
return 1;
}
Expand Down
1 change: 1 addition & 0 deletions cube/swiss/source/devices/memcard/deviceHandler-CARD.h
Expand Up @@ -34,5 +34,6 @@ extern DEVICEHANDLER_INTERFACE __device_card_b;
int initialize_card(int slot);
void setCopyGCIMode(bool _isCopyGCIMode);
void setGCIInfo(void *buffer);
char getGCIRegion(const char *gameID);
#endif

0 comments on commit 244931f

Please sign in to comment.