diff system.c @ 1111:2eb54e24914e

Mostly working changes to allow support for multiple emulated system types in main blastem program
author Michael Pavone <pavone@retrodev.com>
date Mon, 19 Dec 2016 13:28:18 -0800
parents
children 928a65750345
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/system.c	Mon Dec 19 13:28:18 2016 -0800
@@ -0,0 +1,33 @@
+#include <string.h>
+#include "system.h"
+#include "genesis.h"
+
+system_type detect_system_type(uint8_t *rom, long filesize)
+{
+	if (filesize >= 0x104 && !memcmp("SEGA", rom + 0x100, 4)) {
+		//TODO: Differentiate between vanilla Genesis and Sega CD/32X games
+		return SYSTEM_GENESIS;
+	}
+	//TODO: Detect SMS and Jaguar ROMs here
+	
+	//More certain checks failed, look for a valid 68K reset vector
+	if (filesize >= 8) {
+		uint32_t reset = rom[4] << 24 | rom[5] << 16 | rom[6] << 8 | rom[7];
+		if (!(reset & 1) && reset < filesize) {
+			//we have a valid looking reset vector, assume it's a Genesis ROM
+			return SYSTEM_GENESIS;
+		}
+	}
+	return SYSTEM_UNKNOWN;
+}
+
+system_header *alloc_config_system(system_type stype, void *rom, uint32_t rom_size, void *lock_on, uint32_t lock_on_size, uint32_t opts, uint8_t force_region, rom_info *info_out)
+{
+	switch (stype)
+	{
+	case SYSTEM_GENESIS:
+		return &(alloc_config_genesis(rom, rom_size, lock_on, lock_on_size, opts, force_region, info_out))->header;
+	default:
+		return NULL;
+	}
+}