diff --git a/core/cart_hw/sms_cart.c b/core/cart_hw/sms_cart.c index cc4fd22..296d568 100644 --- a/core/cart_hw/sms_cart.c +++ b/core/cart_hw/sms_cart.c @@ -2,7 +2,7 @@ * Genesis Plus * SG-1000, Master System & Game Gear cartridge hardware support * - * Copyright (C) 2007-2017 Eke-Eke (Genesis Plus GX) + * Copyright (C) 2007-2018 Eke-Eke (Genesis Plus GX) * * Redistribution and use of this code or any derivative works are permitted * provided that the following conditions are met: @@ -718,10 +718,21 @@ int sms_cart_region_detect(void) while(i--); /* Mark-III hardware */ - if (system_hw == SYSTEM_MARKIII) + if (config.system == SYSTEM_MARKIII) { - /* Japan */ - return REGION_JAPAN_NTSC; + /* Japan only */ + region_code = REGION_JAPAN_NTSC; + } + + /* Master System / Game Gear ROM file */ + if (system_hw >= SYSTEM_SMS) + { + /* missing header or valid header with Japan region code */ + if (!rominfo.country[0] || !memcmp(rominfo.country,"SMS Japan",9) || !memcmp(rominfo.country,"GG Japan",8)) + { + /* assume Japan region (fixes BIOS support) */ + return REGION_JAPAN_NTSC; + } } /* default region */ diff --git a/core/cart_hw/sms_cart.h b/core/cart_hw/sms_cart.h index 88aa5d7..6657926 100644 --- a/core/cart_hw/sms_cart.h +++ b/core/cart_hw/sms_cart.h @@ -2,7 +2,7 @@ * Genesis Plus * SG-1000, Master System & Game Gear cartridge hardware support * - * Copyright (C) 2007-2017 Eke-Eke (Genesis Plus GX) + * Copyright (C) 2007-2018 Eke-Eke (Genesis Plus GX) * * Redistribution and use of this code or any derivative works are permitted * provided that the following conditions are met: diff --git a/core/loadrom.c b/core/loadrom.c index c9e3b0d..a02d7e0 100644 --- a/core/loadrom.c +++ b/core/loadrom.c @@ -3,7 +3,7 @@ * ROM Loading Support * * Copyright (C) 1998-2003 Charles Mac Donald (original code) - * Copyright (C) 2007-2017 Eke-Eke (Genesis Plus GX) + * Copyright (C) 2007-2018 Eke-Eke (Genesis Plus GX) * * Redistribution and use of this code or any derivative works are permitted * provided that the following conditions are met: @@ -311,7 +311,7 @@ void getrominfo(char *romheader) } /* if found, get infos from header */ - if (offset) + if ((offset > 0) && (offset < cart.romsize)) { /* checksum */ rominfo.checksum = romheader[offset + 0x0a] | (romheader[offset + 0x0b] << 8); diff --git a/core/loadrom.h b/core/loadrom.h index 5809a76..e921c22 100644 --- a/core/loadrom.h +++ b/core/loadrom.h @@ -3,7 +3,7 @@ * ROM Loading Support * * Copyright (C) 1998-2003 Charles Mac Donald (original code) - * Copyright (C) 2007-2017 Eke-Eke (Genesis Plus GX) + * Copyright (C) 2007-2018 Eke-Eke (Genesis Plus GX) * * Redistribution and use of this code or any derivative works are permitted * provided that the following conditions are met: