diff --git a/CMakeLists.txt b/CMakeLists.txt index 920b2b18..8b2ebf11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -201,7 +201,6 @@ set(RELIB_SOURCES src/guest/gdrom/disc.c src/guest/gdrom/gdi.c src/guest/gdrom/gdrom.c - src/guest/gdrom/patch.c src/guest/holly/holly.c src/guest/maple/controller.c src/guest/maple/maple.c diff --git a/src/emulator.c b/src/emulator.c index ba72a179..fd9e4c1d 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -432,11 +432,6 @@ static void emu_set_aspect_ratio(struct emu *emu, const char *new_ratio) { /* update persistent option as well as this session's aspect ratio */ strncpy(OPTION_aspect, aspect_ratios[i], sizeof(OPTION_aspect)); emu->aspect_ratio = i; - - /* if a widescreen hack is enabled, force to stretch for the session */ - if (gdrom_widescreen_enabled(emu->dc->gdrom)) { - emu->aspect_ratio = ASPECT_RATIO_16BY9; - } } static void emu_debug_menu(struct emu *emu) { @@ -488,7 +483,6 @@ static void emu_debug_menu(struct emu *emu) { } bios_debug_menu(emu->dc->bios); - gdrom_debug_menu(emu->dc->gdrom); holly_debug_menu(emu->dc->holly); aica_debug_menu(emu->dc->aica); sh4_debug_menu(emu->dc->sh4); @@ -786,5 +780,8 @@ struct emu *emu_create(struct host *host) { CHECK_NOTNULL(emu->run_thread); } + /* set initial aspect ratio */ + emu_set_aspect_ratio(emu, OPTION_aspect); + return emu; } diff --git a/src/guest/gdrom/disc.c b/src/guest/gdrom/disc.c index 8e5cc380..be6d6131 100644 --- a/src/guest/gdrom/disc.c +++ b/src/guest/gdrom/disc.c @@ -5,7 +5,6 @@ #include "guest/gdrom/chd.h" #include "guest/gdrom/gdi.h" #include "guest/gdrom/iso.h" -#include "guest/gdrom/patch.h" /* meta information found in the ip.bin */ struct disc_meta { @@ -73,15 +72,6 @@ int disc_read_sectors(struct disc *disc, int fad, int num_sectors, read += track->data_size; } - /* 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->uid, dst, offset, read); - } - return read; } @@ -247,12 +237,7 @@ struct disc *disc_create(const char *filename) { snprintf(disc->uid, sizeof(disc->uid), "%s %s %s %s", disc->product_name, disc->product_number, disc->product_version, disc->media_config); - /* 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); + LOG_INFO("disc_create id=%s", disc->uid); return disc; } diff --git a/src/guest/gdrom/disc.h b/src/guest/gdrom/disc.h index 361fb791..7d2b9617 100644 --- a/src/guest/gdrom/disc.h +++ b/src/guest/gdrom/disc.h @@ -52,8 +52,6 @@ struct disc { char media_config[12]; char bootname[17]; int regions; - int bootfad; - int bootlen; /* media-specific interface */ void (*destroy)(struct disc *); diff --git a/src/guest/gdrom/gdrom.c b/src/guest/gdrom/gdrom.c index b63479d8..10291200 100644 --- a/src/guest/gdrom/gdrom.c +++ b/src/guest/gdrom/gdrom.c @@ -4,7 +4,6 @@ #include "guest/dreamcast.h" #include "guest/gdrom/gdrom_replies.inc" #include "guest/gdrom/gdrom_types.h" -#include "guest/gdrom/patch.h" #include "guest/holly/holly.h" #include "imgui.h" @@ -524,8 +523,8 @@ int gdrom_find_file(struct gdrom *gd, const char *filename, int *fad, void gdrom_get_bootfile(struct gdrom *gd, int *fad, int *len) { CHECK_NOTNULL(gd->disc); - *fad = gd->disc->bootfad; - *len = gd->disc->bootlen; + int res = disc_find_file(gd->disc, gd->disc->bootname, fad, len); + CHECK(res); } int gdrom_get_regions(struct gdrom *gd) { @@ -686,14 +685,6 @@ void gdrom_dma_begin(struct gdrom *gd) { LOG_GDROM("gd_dma_begin"); } -int gdrom_widescreen_enabled(struct gdrom *gd) { - if (!gd->disc) { - return 0; - } - - return patch_widescreen_enabled(gd->disc->uid); -} - void gdrom_set_disc(struct gdrom *gd, struct disc *disc) { if (gd->disc != disc) { if (gd->disc) { @@ -725,20 +716,6 @@ int gdrom_has_disc(struct gdrom *gd) { return gd->disc != NULL; } -#ifdef HAVE_IMGUI -void gdrom_debug_menu(struct gdrom *gd) { - if (igBeginMainMenuBar()) { - if (igBeginMenu("GDROM", 1)) { - patch_debug_menu(); - - igEndMenu(); - } - - igEndMainMenuBar(); - } -} -#endif - void gdrom_destroy(struct gdrom *gd) { if (gd->disc) { disc_destroy(gd->disc); diff --git a/src/guest/gdrom/gdrom.h b/src/guest/gdrom/gdrom.h index b82fd94a..a46e4b3c 100644 --- a/src/guest/gdrom/gdrom.h +++ b/src/guest/gdrom/gdrom.h @@ -14,7 +14,6 @@ void gdrom_debug_menu(struct gdrom *gd); int gdrom_has_disc(struct gdrom *gd); void gdrom_set_disc(struct gdrom *gd, struct disc *disc); -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); diff --git a/src/guest/gdrom/patch.c b/src/guest/gdrom/patch.c deleted file mode 100644 index 3009e307..00000000 --- a/src/guest/gdrom/patch.c +++ /dev/null @@ -1,113 +0,0 @@ -#include "guest/gdrom/patch.h" -#include "core/assert.h" -#include "core/string.h" -#include "guest/memory.h" -#include "imgui.h" - -DEFINE_PERSISTENT_OPTION_INT(patch_widescreen, 0, "Apply widescreen patches"); - -#if 0 -#define LOG_PATCH LOG_INFO -#else -#define LOG_PATCH(...) -#endif - -#define DATA(...) \ - (uint8_t[]) { \ - __VA_ARGS__ \ - } - -#define HUNKS(...) \ - (struct patch_hunk[]) { \ - __VA_ARGS__ \ - } - -#define NUM_HUNKS(...) (sizeof(HUNKS(__VA_ARGS__)) / sizeof(struct patch_hunk)) - -#define HUNK(offset, ...) \ - { offset, DATA(__VA_ARGS__), sizeof(DATA(__VA_ARGS__)) } - -#define PATCH(game, desc, flags, ...) \ - {game, desc, flags, HUNKS(__VA_ARGS__), NUM_HUNKS(__VA_ARGS__)}, - -static struct patch patches[] = { -#include "guest/gdrom/patch.inc" -}; -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]; - - if (strcmp(patch->game, game)) { - continue; - } - - if (!(patch->flags & PATCH_BOOTFILE)) { - continue; - } - - if (!patch_should_apply(patch)) { - continue; - } - - LOG_PATCH("patches_apply %s at 0x%x", patch->desc, offset); - - for (int j = 0; j < patch->num_hunks; j++) { - struct patch_hunk *hunk = &patch->hunks[j]; - - for (int k = 0; k < hunk->len; k++) { - int index = hunk->offset + k; - - if (index < offset || index >= offset + size) { - continue; - } - - buffer[index - offset] = hunk->data[k]; - } - } - } -} - -#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 diff --git a/src/guest/gdrom/patch.h b/src/guest/gdrom/patch.h deleted file mode 100644 index 475ff077..00000000 --- a/src/guest/gdrom/patch.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef PATCH_H -#define PATCH_H - -#include - -struct address_space; - -enum { - PATCH_BOOTFILE = 0x1, - PATCH_WIDESCREEN = 0x2, -}; - -struct patch_hunk { - int offset; - uint8_t *data; - int len; -}; - -struct patch { - char *game; - char *desc; - int flags; - struct patch_hunk *hunks; - int num_hunks; -}; - -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 diff --git a/src/guest/gdrom/patch.inc b/src/guest/gdrom/patch.inc deleted file mode 100644 index dc5ada61..00000000 --- a/src/guest/gdrom/patch.inc +++ /dev/null @@ -1,22 +0,0 @@ -PATCH("DYNAMITE COP MK-51013 V1.005 GD-ROM1/1", - "widescreen", - PATCH_BOOTFILE | PATCH_WIDESCREEN, - HUNK(0x00048eb0,0x39,0x8E,0xE3,0x3F), - HUNK(0x00048fb8,0x39,0x8E,0xE3,0x3F), - HUNK(0x00049100,0x39,0x8E,0xE3,0x3F), - HUNK(0x0004b590,0x39,0x8E,0xE3,0x3F), - HUNK(0x0006b93c,0x39,0x8E,0xE3,0x3F), - HUNK(0x0006bce0,0x39,0x8E,0xE3,0x3F), - HUNK(0x0006c0d0,0x39,0x8E,0xE3,0x3F), - HUNK(0x0006c21c,0x39,0x8E,0xE3,0x3F), - HUNK(0x0006eec4,0x39,0x8E,0xE3,0x3F), - HUNK(0x000723c0,0x39,0x8E,0xE3,0x3F), - HUNK(0x0007d568,0x39,0x8E,0xE3,0x3F)) - -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), - HUNK(0x00026fc4,0x80,0xEF,0x0A,0x8C,0x10,0xF6,0x88,0x8C,0x18,0xF6,0x88,0x8C), - HUNK(0x00600d70,0x80,0xEF,0x0A,0x8C,0xA8,0x35,0x67,0x8C,0xE6,0x2F,0x43,0x6E), - HUNK(0x00612200,0x80,0xEF,0x0A,0x8C,0x18,0x03,0x89,0x8C,0x59,0xF0,0x59,0xF1))