diff options
author | Michael Pavone <pavone@retrodev.com> | 2016-12-19 13:28:18 -0800 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2016-12-19 13:28:18 -0800 |
commit | 7b8127d36a9c6a824da4f1709bdee12c40c631a5 (patch) | |
tree | 33d0e6914620deaee1296f1672091c5b79793778 /system.c | |
parent | 11861fca5815015b2afb712f328195c5f7bc231e (diff) |
Mostly working changes to allow support for multiple emulated system types in main blastem program
Diffstat (limited to 'system.c')
-rw-r--r-- | system.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/system.c b/system.c new file mode 100644 index 0000000..5d5e9f8 --- /dev/null +++ b/system.c @@ -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; + } +} |