mirror of https://github.com/inolen/redream.git
cache off IP.BIN meta data in disc_create
This commit is contained in:
parent
26cfcc14fe
commit
3e88f043ca
|
@ -10,7 +10,7 @@
|
|||
/* meta information found in the ip.bin */
|
||||
struct disc_meta {
|
||||
char hardware_id[16];
|
||||
char marker_id[16];
|
||||
char manufacturer_id[16];
|
||||
char device_info[16];
|
||||
char area_symbols[8];
|
||||
char peripherals[8];
|
||||
|
@ -18,8 +18,8 @@ struct disc_meta {
|
|||
char product_version[6];
|
||||
char release_date[16];
|
||||
char bootname[16];
|
||||
char producer[16];
|
||||
char name[128];
|
||||
char producer_name[16];
|
||||
char product_name[128];
|
||||
};
|
||||
|
||||
static void disc_get_meta(struct disc *disc, struct disc_meta *meta) {
|
||||
|
@ -66,8 +66,6 @@ int disc_read_sectors(struct disc *disc, int fad, int num_sectors,
|
|||
|
||||
int read = 0;
|
||||
int endfad = fad + num_sectors;
|
||||
int bootstart = disc->bootfad;
|
||||
int bootend = disc->bootfad + (disc->bootlen / track->data_size);
|
||||
|
||||
for (int i = fad; i < endfad; i++) {
|
||||
CHECK_LE(read + track->data_size, dst_size);
|
||||
|
@ -76,9 +74,12 @@ int disc_read_sectors(struct disc *disc, int fad, int num_sectors,
|
|||
}
|
||||
|
||||
/* apply bootfile patches */
|
||||
int bootstart = disc->bootfad;
|
||||
int bootend = disc->bootfad + (disc->bootlen / track->data_size);
|
||||
|
||||
if (bootstart <= endfad && fad <= bootend) {
|
||||
int offset = (fad - bootstart) * track->data_size;
|
||||
patch_bootfile(disc->id, dst, offset, read);
|
||||
patch_bootfile(disc->uid, dst, offset, read);
|
||||
}
|
||||
|
||||
return read;
|
||||
|
@ -145,23 +146,6 @@ int disc_find_file(struct disc *disc, const char *filename, int *fad,
|
|||
return 1;
|
||||
}
|
||||
|
||||
int disc_get_regions(struct disc *disc) {
|
||||
struct disc_meta meta;
|
||||
disc_get_meta(disc, &meta);
|
||||
|
||||
int regions = 0;
|
||||
if (meta.area_symbols[0] == 'J') {
|
||||
regions |= DISC_REGION_JAPAN;
|
||||
}
|
||||
if (meta.area_symbols[1] == 'U') {
|
||||
regions |= DISC_REGION_USA;
|
||||
}
|
||||
if (meta.area_symbols[2] == 'E') {
|
||||
regions |= DISC_REGION_EUROPE;
|
||||
}
|
||||
return regions;
|
||||
}
|
||||
|
||||
void disc_get_toc(struct disc *disc, int area, struct track **first_track,
|
||||
struct track **last_track, int *leadin_fad,
|
||||
int *leadout_fad) {
|
||||
|
@ -231,33 +215,44 @@ struct disc *disc_create(const char *filename) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* generate a unique id for the disc */
|
||||
/* extract meta information from the IP.BIN */
|
||||
struct disc_meta meta;
|
||||
disc_get_meta(disc, &meta);
|
||||
|
||||
char device_info[17];
|
||||
char product_number[11];
|
||||
char product_version[7];
|
||||
char bootname[17];
|
||||
char name[129];
|
||||
|
||||
strncpy_trim_space(device_info, meta.device_info, sizeof(meta.device_info));
|
||||
strncpy_trim_space(product_number, meta.product_number,
|
||||
strncpy_trim_space(disc->product_name, meta.product_name,
|
||||
sizeof(meta.product_name));
|
||||
strncpy_trim_space(disc->product_number, meta.product_number,
|
||||
sizeof(meta.product_number));
|
||||
strncpy_trim_space(product_version, meta.product_version,
|
||||
strncpy_trim_space(disc->product_version, meta.product_version,
|
||||
sizeof(meta.product_version));
|
||||
strncpy_trim_space(bootname, meta.bootname, sizeof(meta.bootname));
|
||||
strncpy_trim_space(name, meta.name, sizeof(meta.name));
|
||||
strncpy_trim_space(disc->media_config, meta.device_info + 5,
|
||||
sizeof(meta.device_info) - 5);
|
||||
strncpy_trim_space(disc->bootname, meta.bootname, sizeof(meta.bootname));
|
||||
|
||||
snprintf(disc->id, sizeof(disc->id), "%s %s %s %s", name, product_number,
|
||||
product_version, device_info);
|
||||
/* the area symbols array contains characters, which are either a space or a
|
||||
specific character corresponding to a particular region the disc is valid
|
||||
for. if the character for a particular region is a space, the disc is not
|
||||
valid for that region */
|
||||
if (meta.area_symbols[0] == 'J') {
|
||||
disc->regions |= DISC_REGION_JAPAN;
|
||||
}
|
||||
if (meta.area_symbols[1] == 'U') {
|
||||
disc->regions |= DISC_REGION_USA;
|
||||
}
|
||||
if (meta.area_symbols[2] == 'E') {
|
||||
disc->regions |= DISC_REGION_EUROPE;
|
||||
}
|
||||
|
||||
/* cache off bootfile info */
|
||||
int found = disc_find_file(disc, bootname, &disc->bootfad, &disc->bootlen);
|
||||
CHECK(found);
|
||||
/* generate unique id for the disc */
|
||||
snprintf(disc->uid, sizeof(disc->uid), "%s %s %s %s", disc->product_name,
|
||||
disc->product_number, disc->product_version, disc->media_config);
|
||||
|
||||
LOG_INFO("disc_create id=%s bootfile=%s fad=%d len=%d", disc->id, bootname,
|
||||
disc->bootfad, disc->bootlen);
|
||||
/* cache off bootfile info in order to patch it in disc_read_sectors */
|
||||
int rs = disc_find_file(disc, disc->bootname, &disc->bootfad, &disc->bootlen);
|
||||
CHECK(rs);
|
||||
|
||||
LOG_INFO("disc_create id=%s bootfile=%s fad=%d len=%d", disc->uid,
|
||||
disc->bootname, disc->bootfad, disc->bootlen);
|
||||
|
||||
return disc;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#define DISC_MAX_SECTOR_SIZE 2352
|
||||
#define DISC_MAX_SESSIONS 2
|
||||
#define DISC_MAX_TRACKS 64
|
||||
#define DISC_MAX_ID_SIZE 161
|
||||
#define DISC_MAX_UID_SIZE 161
|
||||
|
||||
enum {
|
||||
DISC_REGION_JAPAN = 0x1,
|
||||
|
@ -43,10 +43,18 @@ struct session {
|
|||
};
|
||||
|
||||
struct disc {
|
||||
char id[DISC_MAX_ID_SIZE];
|
||||
/* meta information extracted from IP.BIN */
|
||||
char uid[DISC_MAX_UID_SIZE];
|
||||
char product_name[129];
|
||||
char product_number[17];
|
||||
char product_version[7];
|
||||
char media_config[12];
|
||||
char bootname[17];
|
||||
int regions;
|
||||
int bootfad;
|
||||
int bootlen;
|
||||
|
||||
/* media-specific interface */
|
||||
void (*destroy)(struct disc *);
|
||||
|
||||
int (*get_format)(struct disc *);
|
||||
|
@ -74,8 +82,6 @@ struct track *disc_lookup_track(struct disc *disc, int fad);
|
|||
void disc_get_toc(struct disc *disc, int area, struct track **first_track,
|
||||
struct track **last_track, int *leadin_fad, int *leadout_fad);
|
||||
|
||||
int disc_get_regions(struct disc *disc);
|
||||
|
||||
int disc_find_file(struct disc *disc, const char *filename, int *fad, int *len);
|
||||
int disc_read_sectors(struct disc *disc, int fad, int num_sectors,
|
||||
int sector_fmt, int sector_mask, uint8_t *dst,
|
||||
|
|
|
@ -531,7 +531,7 @@ void gdrom_get_bootfile(struct gdrom *gd, int *fad, int *len) {
|
|||
int gdrom_get_regions(struct gdrom *gd) {
|
||||
CHECK_NOTNULL(gd->disc);
|
||||
|
||||
return disc_get_regions(gd->disc);
|
||||
return gd->disc->regions;
|
||||
}
|
||||
|
||||
void gdrom_get_subcode(struct gdrom *gd, int format, uint8_t *data, int size) {
|
||||
|
@ -691,7 +691,7 @@ int gdrom_widescreen_enabled(struct gdrom *gd) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
return patch_widescreen_enabled(gd->disc->id);
|
||||
return patch_widescreen_enabled(gd->disc->uid);
|
||||
}
|
||||
|
||||
void gdrom_set_disc(struct gdrom *gd, struct disc *disc) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
PATCH("DYNAMITE COP MK-51013 V1.005 7996 GD-ROM1/1",
|
||||
PATCH("DYNAMITE COP MK-51013 V1.005 GD-ROM1/1",
|
||||
"widescreen",
|
||||
PATCH_BOOTFILE | PATCH_WIDESCREEN,
|
||||
HUNK(0x00048eb0,0x39,0x8E,0xE3,0x3F),
|
||||
|
@ -13,7 +13,7 @@ PATCH("DYNAMITE COP MK-51013 V1.005 7996 GD-ROM1/1",
|
|||
HUNK(0x000723c0,0x39,0x8E,0xE3,0x3F),
|
||||
HUNK(0x0007d568,0x39,0x8E,0xE3,0x3F))
|
||||
|
||||
PATCH("SONIC ADVENTURE MK-51000 V1.005 3B97 GD-ROM1/1",
|
||||
PATCH("SONIC ADVENTURE MK-51000 V1.005 GD-ROM1/1",
|
||||
"widescreen",
|
||||
PATCH_BOOTFILE | PATCH_WIDESCREEN,
|
||||
HUNK(0x00026fb8,0xF0,0xF5,0x88,0x8C,0xF4,0xF5,0x88,0x8C,0x94,0x3A,0x01,0x8C),
|
||||
|
|
Loading…
Reference in New Issue