Mercurial > repos > blastem
comparison 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 |
comparison
equal
deleted
inserted
replaced
1110:d1eed3b1121c | 1111:2eb54e24914e |
---|---|
1 #include <string.h> | |
2 #include "system.h" | |
3 #include "genesis.h" | |
4 | |
5 system_type detect_system_type(uint8_t *rom, long filesize) | |
6 { | |
7 if (filesize >= 0x104 && !memcmp("SEGA", rom + 0x100, 4)) { | |
8 //TODO: Differentiate between vanilla Genesis and Sega CD/32X games | |
9 return SYSTEM_GENESIS; | |
10 } | |
11 //TODO: Detect SMS and Jaguar ROMs here | |
12 | |
13 //More certain checks failed, look for a valid 68K reset vector | |
14 if (filesize >= 8) { | |
15 uint32_t reset = rom[4] << 24 | rom[5] << 16 | rom[6] << 8 | rom[7]; | |
16 if (!(reset & 1) && reset < filesize) { | |
17 //we have a valid looking reset vector, assume it's a Genesis ROM | |
18 return SYSTEM_GENESIS; | |
19 } | |
20 } | |
21 return SYSTEM_UNKNOWN; | |
22 } | |
23 | |
24 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) | |
25 { | |
26 switch (stype) | |
27 { | |
28 case SYSTEM_GENESIS: | |
29 return &(alloc_config_genesis(rom, rom_size, lock_on, lock_on_size, opts, force_region, info_out))->header; | |
30 default: | |
31 return NULL; | |
32 } | |
33 } |