From b5e17ec13a758bf4aaa660dae72b02614f2528b1 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Thu, 22 Dec 2016 19:51:25 -0800 Subject: Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful. --- system.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'system.c') diff --git a/system.c b/system.c index 5d5e9f8..cef8575 100644 --- a/system.c +++ b/system.c @@ -1,14 +1,27 @@ #include #include "system.h" #include "genesis.h" +#include "sms.h" + +uint8_t safe_cmp(char *str, long offset, uint8_t *buffer, long filesize) +{ + long len = strlen(str); + return filesize >= offset+len && !memcmp(str, buffer + offset, len); +} system_type detect_system_type(uint8_t *rom, long filesize) { - if (filesize >= 0x104 && !memcmp("SEGA", rom + 0x100, 4)) { + if (safe_cmp("SEGA", 0x100, rom, filesize)) { //TODO: Differentiate between vanilla Genesis and Sega CD/32X games return SYSTEM_GENESIS; } - //TODO: Detect SMS and Jaguar ROMs here + if (safe_cmp("TMR SEGA", 0x1FF0, rom, filesize) + || safe_cmp("TMR SEGA", 0x3FF0, rom, filesize) + || safe_cmp("TMR SEGA", 0x7FF0, rom, filesize) + ) { + return SYSTEM_SMS; + } + //TODO: Detect Jaguar ROMs here //More certain checks failed, look for a valid 68K reset vector if (filesize >= 8) { @@ -27,6 +40,10 @@ system_header *alloc_config_system(system_type stype, void *rom, uint32_t rom_si { case SYSTEM_GENESIS: return &(alloc_config_genesis(rom, rom_size, lock_on, lock_on_size, opts, force_region, info_out))->header; +#ifndef NO_Z80 + case SYSTEM_SMS: + return &(alloc_configure_sms(rom, rom_size, lock_on, lock_on_size, opts, force_region, info_out))->header; +#endif default: return NULL; } -- cgit v1.2.3