mirror of https://github.com/inolen/redream.git
default to 4:3 aspect ratio if no widescreen patch is available
This commit is contained in:
parent
1abd57f054
commit
173aa37b33
|
@ -39,6 +39,11 @@ DEFINE_AGGREGATE_COUNTER(frames);
|
|||
|
||||
DEFINE_PERSISTENT_OPTION_STRING(aspect_ratio, "stretch", "Video aspect ratio");
|
||||
|
||||
enum {
|
||||
ASPECT_STRETCH,
|
||||
ASPECT_4BY3,
|
||||
};
|
||||
|
||||
static const char *aspect_ratios[] = {
|
||||
"stretch", "4:3",
|
||||
};
|
||||
|
@ -639,12 +644,12 @@ void emu_render_frame(struct emu *emu) {
|
|||
int frame_height, frame_width;
|
||||
int frame_x, frame_y;
|
||||
|
||||
if (!strcmp(OPTION_aspect_ratio, "stretch")) {
|
||||
if (!strcmp(OPTION_aspect_ratio, aspect_ratios[ASPECT_STRETCH])) {
|
||||
frame_height = emu->video_height;
|
||||
frame_width = emu->video_width;
|
||||
frame_x = 0;
|
||||
frame_y = 0;
|
||||
} else if (!strcmp(OPTION_aspect_ratio, "4:3")) {
|
||||
} else if (!strcmp(OPTION_aspect_ratio, aspect_ratios[ASPECT_4BY3])) {
|
||||
frame_height = emu->video_height;
|
||||
frame_width = frame_height * (4.0f / 3.0f);
|
||||
frame_x = (emu->video_width - frame_width) / 2.0f;
|
||||
|
@ -735,6 +740,15 @@ int emu_load_game(struct emu *emu, const char *path) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* stretch to fill if the game has a widescreen hack enabled */
|
||||
if (gdrom_widescreen_enabled(emu->dc->gdrom)) {
|
||||
strncpy(OPTION_aspect_ratio, aspect_ratios[ASPECT_STRETCH],
|
||||
sizeof(OPTION_aspect_ratio));
|
||||
} else {
|
||||
strncpy(OPTION_aspect_ratio, aspect_ratios[ASPECT_4BY3],
|
||||
sizeof(OPTION_aspect_ratio));
|
||||
}
|
||||
|
||||
dc_resume(emu->dc);
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -338,7 +338,7 @@ void bios_debug_menu(struct bios *bios) {
|
|||
}
|
||||
|
||||
if (changed) {
|
||||
LOG_WARNING("bios settings changed, restart for changes to take effect");
|
||||
LOG_WARNING("bios settings changed, restart to apply");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -469,6 +469,28 @@ static void gdrom_event(struct gdrom *gd, enum gd_event ev, int arg) {
|
|||
cb(gd, arg);
|
||||
}
|
||||
|
||||
static int gdrom_init(struct device *dev) {
|
||||
struct gdrom *gd = (struct gdrom *)dev;
|
||||
|
||||
/* set default hardware information */
|
||||
memset(&gd->hw_info, 0, sizeof(gd->hw_info));
|
||||
gd->hw_info.speed = 0x0;
|
||||
gd->hw_info.standby_hi = 0x00;
|
||||
gd->hw_info.standby_lo = 0xb4;
|
||||
gd->hw_info.read_flags = 0x19;
|
||||
gd->hw_info.read_retry = 0x08;
|
||||
strncpy_pad_spaces(gd->hw_info.drive_info, "SE",
|
||||
sizeof(gd->hw_info.drive_info));
|
||||
strncpy_pad_spaces(gd->hw_info.system_version, "Rev 6.43",
|
||||
sizeof(gd->hw_info.system_version));
|
||||
strncpy_pad_spaces(gd->hw_info.system_date, "990408",
|
||||
sizeof(gd->hw_info.system_date));
|
||||
|
||||
gdrom_set_disc(gd, NULL);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int gdrom_read_bytes(struct gdrom *gd, int fad, int len, uint8_t *dst,
|
||||
int dst_size) {
|
||||
if (!gd->disc) {
|
||||
|
@ -492,6 +514,20 @@ int gdrom_read_sectors(struct gdrom *gd, int fad, int num_sectors, int fmt,
|
|||
dst_size);
|
||||
}
|
||||
|
||||
int gdrom_find_file(struct gdrom *gd, const char *filename, int *fad,
|
||||
int *len) {
|
||||
CHECK_NOTNULL(gd->disc);
|
||||
|
||||
return disc_find_file(gd->disc, filename, fad, len);
|
||||
}
|
||||
|
||||
void gdrom_get_bootfile(struct gdrom *gd, int *fad, int *len) {
|
||||
CHECK_NOTNULL(gd->disc);
|
||||
|
||||
*fad = gd->disc->bootfad;
|
||||
*len = gd->disc->bootlen;
|
||||
}
|
||||
|
||||
void gdrom_get_subcode(struct gdrom *gd, int format, uint8_t *data, int size) {
|
||||
CHECK_NOTNULL(gd->disc);
|
||||
CHECK_GE(size, GD_SPI_SCD_SIZE);
|
||||
|
@ -602,28 +638,6 @@ void gdrom_get_status(struct gdrom *gd, struct gd_spi_status *stat) {
|
|||
stat->fad = 0x0;
|
||||
}
|
||||
|
||||
static int gdrom_init(struct device *dev) {
|
||||
struct gdrom *gd = (struct gdrom *)dev;
|
||||
|
||||
/* set default hardware information */
|
||||
memset(&gd->hw_info, 0, sizeof(gd->hw_info));
|
||||
gd->hw_info.speed = 0x0;
|
||||
gd->hw_info.standby_hi = 0x00;
|
||||
gd->hw_info.standby_lo = 0xb4;
|
||||
gd->hw_info.read_flags = 0x19;
|
||||
gd->hw_info.read_retry = 0x08;
|
||||
strncpy_pad_spaces(gd->hw_info.drive_info, "SE",
|
||||
sizeof(gd->hw_info.drive_info));
|
||||
strncpy_pad_spaces(gd->hw_info.system_version, "Rev 6.43",
|
||||
sizeof(gd->hw_info.system_version));
|
||||
strncpy_pad_spaces(gd->hw_info.system_date, "990408",
|
||||
sizeof(gd->hw_info.system_date));
|
||||
|
||||
gdrom_set_disc(gd, NULL);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void gdrom_set_drive_mode(struct gdrom *gd, struct gd_hw_info *info) {
|
||||
gd->hw_info = *info;
|
||||
}
|
||||
|
@ -666,18 +680,10 @@ void gdrom_dma_begin(struct gdrom *gd) {
|
|||
LOG_GDROM("gd_dma_begin");
|
||||
}
|
||||
|
||||
int gdrom_find_file(struct gdrom *gd, const char *filename, int *fad,
|
||||
int *len) {
|
||||
int gdrom_widescreen_enabled(struct gdrom *gd) {
|
||||
CHECK_NOTNULL(gd->disc);
|
||||
|
||||
return disc_find_file(gd->disc, filename, fad, len);
|
||||
}
|
||||
|
||||
void gdrom_get_bootfile(struct gdrom *gd, int *fad, int *len) {
|
||||
CHECK_NOTNULL(gd->disc);
|
||||
|
||||
*fad = gd->disc->bootfad;
|
||||
*len = gd->disc->bootlen;
|
||||
return patch_widescreen_enabled(gd->disc->id);
|
||||
}
|
||||
|
||||
void gdrom_set_disc(struct gdrom *gd, struct disc *disc) {
|
||||
|
|
|
@ -13,8 +13,7 @@ void gdrom_destroy(struct gdrom *gd);
|
|||
void gdrom_debug_menu(struct gdrom *gd);
|
||||
|
||||
void gdrom_set_disc(struct gdrom *gd, struct disc *disc);
|
||||
void gdrom_get_bootfile(struct gdrom *gd, int *fad, int *len);
|
||||
int gdrom_find_file(struct gdrom *gd, const char *filename, int *fad, int *len);
|
||||
int gdrom_widescreen_enabled(struct gdrom *gd);
|
||||
|
||||
void gdrom_dma_begin(struct gdrom *gd);
|
||||
int gdrom_dma_read(struct gdrom *gd, uint8_t *data, int n);
|
||||
|
@ -28,6 +27,9 @@ void gdrom_get_toc(struct gdrom *gd, int area, struct gd_spi_toc *toc);
|
|||
void gdrom_get_session(struct gdrom *gd, int session,
|
||||
struct gd_spi_session *ses);
|
||||
void gdrom_get_subcode(struct gdrom *gd, int format, uint8_t *data, int size);
|
||||
|
||||
void gdrom_get_bootfile(struct gdrom *gd, int *fad, int *len);
|
||||
int gdrom_find_file(struct gdrom *gd, const char *filename, int *fad, int *len);
|
||||
int gdrom_read_sectors(struct gdrom *gd, int fad, int num_sectors, int fmt,
|
||||
int mask, uint8_t *dst, int dst_size);
|
||||
int gdrom_read_bytes(struct gdrom *gd, int fad, int len, uint8_t *dst,
|
||||
|
|
|
@ -35,11 +35,34 @@ static struct patch patches[] = {
|
|||
};
|
||||
static int num_patches = sizeof(patches) / sizeof(patches[0]);
|
||||
|
||||
static int patch_should_apply(struct patch *patch) {
|
||||
if (patch->flags & PATCH_WIDESCREEN) {
|
||||
return OPTION_patch_widescreen;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int patch_widescreen_enabled(const char *game) {
|
||||
for (int i = 0; i < num_patches; i++) {
|
||||
struct patch *patch = &patches[i];
|
||||
|
||||
if (strcmp(patch->game, game)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (patch->flags & PATCH_WIDESCREEN) {
|
||||
return patch_should_apply(patch);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void patch_bootfile(const char *game, uint8_t *buffer, int offset, int size) {
|
||||
for (int i = 0; i < num_patches; i++) {
|
||||
struct patch *patch = &patches[i];
|
||||
|
||||
/* only apply patches for the current game */
|
||||
if (strcmp(patch->game, game)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -48,7 +71,7 @@ void patch_bootfile(const char *game, uint8_t *buffer, int offset, int size) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if ((patch->flags & PATCH_WIDESCREEN) && !OPTION_patch_widescreen) {
|
||||
if (!patch_should_apply(patch)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -72,12 +95,19 @@ void patch_bootfile(const char *game, uint8_t *buffer, int offset, int size) {
|
|||
|
||||
#ifdef HAVE_IMGUI
|
||||
void patch_debug_menu() {
|
||||
int changed = 0;
|
||||
|
||||
if (igBeginMenu("patches", 1)) {
|
||||
if (igMenuItem("widescreen", NULL, OPTION_patch_widescreen, 1)) {
|
||||
changed = 1;
|
||||
OPTION_patch_widescreen = !OPTION_patch_widescreen;
|
||||
}
|
||||
|
||||
igEndMenu();
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
LOG_WARNING("patch settings changed, restart to apply");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -25,6 +25,9 @@ struct patch {
|
|||
};
|
||||
|
||||
void patch_debug_menu();
|
||||
|
||||
int patch_widescreen_enabled(const char *game);
|
||||
|
||||
void patch_bootfile(const char *game, uint8_t *data, int offset, int size);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
PATCH("DYNAMITE COP MK-51013 V1.005 7996 GD-ROM1/1",
|
||||
"widescreen hack",
|
||||
"widescreen",
|
||||
PATCH_BOOTFILE | PATCH_WIDESCREEN,
|
||||
HUNK(0x00048eb0,0x39,0x8E,0xE3,0x3F),
|
||||
HUNK(0x00048fb8,0x39,0x8E,0xE3,0x3F),
|
||||
|
@ -14,7 +14,7 @@ PATCH("DYNAMITE COP MK-51013 V1.005 7996 GD-ROM1/1",
|
|||
HUNK(0x0007d568,0x39,0x8E,0xE3,0x3F))
|
||||
|
||||
PATCH("SONIC ADVENTURE MK-51000 V1.005 3B97 GD-ROM1/1",
|
||||
"widescreen hack",
|
||||
"widescreen",
|
||||
PATCH_BOOTFILE | PATCH_WIDESCREEN,
|
||||
HUNK(0x00026fb8,0xF0,0xF5,0x88,0x8C,0xF4,0xF5,0x88,0x8C,0x94,0x3A,0x01,0x8C),
|
||||
HUNK(0x00026fc4,0x80,0xEF,0x0A,0x8C,0x10,0xF6,0x88,0x8C,0x18,0xF6,0x88,0x8C),
|
||||
|
|
Loading…
Reference in New Issue