Mercurial > repos > blastem
annotate romdb.h @ 2195:40290a923886
Implement Game Gear start button and region register
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 21 Aug 2022 22:56:32 -0700 |
parents | 8ee7ecbf3f21 |
children | fd68fe5f723e |
rev | line source |
---|---|
764
bb60259e8edf
Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #ifndef ROMDB_H_ |
bb60259e8edf
Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 #define ROMDB_H_ |
bb60259e8edf
Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 |
bb60259e8edf
Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 #define REGION_J 1 |
bb60259e8edf
Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 #define REGION_U 2 |
bb60259e8edf
Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 #define REGION_E 4 |
bb60259e8edf
Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 |
766
1b2f8280ba81
WIP changes to support reading cart memory map from ROM DB
Michael Pavone <pavone@retrodev.com>
parents:
765
diff
changeset
|
8 #define RAM_FLAG_ODD 0x18 |
1b2f8280ba81
WIP changes to support reading cart memory map from ROM DB
Michael Pavone <pavone@retrodev.com>
parents:
765
diff
changeset
|
9 #define RAM_FLAG_EVEN 0x10 |
1b2f8280ba81
WIP changes to support reading cart memory map from ROM DB
Michael Pavone <pavone@retrodev.com>
parents:
765
diff
changeset
|
10 #define RAM_FLAG_BOTH 0x00 |
1b2f8280ba81
WIP changes to support reading cart memory map from ROM DB
Michael Pavone <pavone@retrodev.com>
parents:
765
diff
changeset
|
11 #define RAM_FLAG_MASK RAM_FLAG_ODD |
1b2f8280ba81
WIP changes to support reading cart memory map from ROM DB
Michael Pavone <pavone@retrodev.com>
parents:
765
diff
changeset
|
12 #define SAVE_I2C 0x01 |
1395
efa7225e0f07
Initial work to support parallel NOR flash and the Magistr 16
Michael Pavone <pavone@retrodev.com>
parents:
1228
diff
changeset
|
13 #define SAVE_NOR 0x02 |
2027
0f54a898db03
Implement Heartbeat Personal Trainer peripheral and add ROM DB entry for Outback Joey
Michael Pavone <pavone@retrodev.com>
parents:
1863
diff
changeset
|
14 #define SAVE_HBPT 0x03 |
766
1b2f8280ba81
WIP changes to support reading cart memory map from ROM DB
Michael Pavone <pavone@retrodev.com>
parents:
765
diff
changeset
|
15 #define SAVE_NONE 0xFF |
1b2f8280ba81
WIP changes to support reading cart memory map from ROM DB
Michael Pavone <pavone@retrodev.com>
parents:
765
diff
changeset
|
16 |
764
bb60259e8edf
Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 #include "tern.h" |
1444
14a2834d010c
Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents:
1416
diff
changeset
|
18 #include "serialize.h" |
764
bb60259e8edf
Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 |
bb60259e8edf
Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 typedef struct { |
769
4638b88bc72d
Initial work on I2C EEPROM implementation
Michael Pavone <pavone@retrodev.com>
parents:
767
diff
changeset
|
21 uint32_t start; |
4638b88bc72d
Initial work on I2C EEPROM implementation
Michael Pavone <pavone@retrodev.com>
parents:
767
diff
changeset
|
22 uint32_t end; |
4638b88bc72d
Initial work on I2C EEPROM implementation
Michael Pavone <pavone@retrodev.com>
parents:
767
diff
changeset
|
23 uint16_t sda_write_mask; |
4638b88bc72d
Initial work on I2C EEPROM implementation
Michael Pavone <pavone@retrodev.com>
parents:
767
diff
changeset
|
24 uint16_t scl_mask; |
4638b88bc72d
Initial work on I2C EEPROM implementation
Michael Pavone <pavone@retrodev.com>
parents:
767
diff
changeset
|
25 uint8_t sda_read_bit; |
4638b88bc72d
Initial work on I2C EEPROM implementation
Michael Pavone <pavone@retrodev.com>
parents:
767
diff
changeset
|
26 } eeprom_map; |
4638b88bc72d
Initial work on I2C EEPROM implementation
Michael Pavone <pavone@retrodev.com>
parents:
767
diff
changeset
|
27 |
4638b88bc72d
Initial work on I2C EEPROM implementation
Michael Pavone <pavone@retrodev.com>
parents:
767
diff
changeset
|
28 typedef struct { |
1395
efa7225e0f07
Initial work to support parallel NOR flash and the Magistr 16
Michael Pavone <pavone@retrodev.com>
parents:
1228
diff
changeset
|
29 uint8_t *buffer; |
efa7225e0f07
Initial work to support parallel NOR flash and the Magistr 16
Michael Pavone <pavone@retrodev.com>
parents:
1228
diff
changeset
|
30 uint8_t *page_buffer; |
efa7225e0f07
Initial work to support parallel NOR flash and the Magistr 16
Michael Pavone <pavone@retrodev.com>
parents:
1228
diff
changeset
|
31 uint32_t size; |
efa7225e0f07
Initial work to support parallel NOR flash and the Magistr 16
Michael Pavone <pavone@retrodev.com>
parents:
1228
diff
changeset
|
32 uint32_t page_size; |
efa7225e0f07
Initial work to support parallel NOR flash and the Magistr 16
Michael Pavone <pavone@retrodev.com>
parents:
1228
diff
changeset
|
33 uint32_t current_page; |
efa7225e0f07
Initial work to support parallel NOR flash and the Magistr 16
Michael Pavone <pavone@retrodev.com>
parents:
1228
diff
changeset
|
34 uint32_t last_write_cycle; |
1519
1f745318f10a
Made the NOR flash emulation a bit more flexible, but not yet flexible enough to properly support the flash chip in the MegaWiFi cart
Michael Pavone <pavone@retrodev.com>
parents:
1444
diff
changeset
|
35 uint32_t cmd_address1; |
1f745318f10a
Made the NOR flash emulation a bit more flexible, but not yet flexible enough to properly support the flash chip in the MegaWiFi cart
Michael Pavone <pavone@retrodev.com>
parents:
1444
diff
changeset
|
36 uint32_t cmd_address2; |
1395
efa7225e0f07
Initial work to support parallel NOR flash and the Magistr 16
Michael Pavone <pavone@retrodev.com>
parents:
1228
diff
changeset
|
37 uint16_t product_id; |
efa7225e0f07
Initial work to support parallel NOR flash and the Magistr 16
Michael Pavone <pavone@retrodev.com>
parents:
1228
diff
changeset
|
38 uint8_t mode; |
efa7225e0f07
Initial work to support parallel NOR flash and the Magistr 16
Michael Pavone <pavone@retrodev.com>
parents:
1228
diff
changeset
|
39 uint8_t cmd_state; |
efa7225e0f07
Initial work to support parallel NOR flash and the Magistr 16
Michael Pavone <pavone@retrodev.com>
parents:
1228
diff
changeset
|
40 uint8_t alt_cmd; |
efa7225e0f07
Initial work to support parallel NOR flash and the Magistr 16
Michael Pavone <pavone@retrodev.com>
parents:
1228
diff
changeset
|
41 uint8_t bus_flags; |
efa7225e0f07
Initial work to support parallel NOR flash and the Magistr 16
Michael Pavone <pavone@retrodev.com>
parents:
1228
diff
changeset
|
42 } nor_state; |
efa7225e0f07
Initial work to support parallel NOR flash and the Magistr 16
Michael Pavone <pavone@retrodev.com>
parents:
1228
diff
changeset
|
43 |
1444
14a2834d010c
Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents:
1416
diff
changeset
|
44 enum { |
14a2834d010c
Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents:
1416
diff
changeset
|
45 MAPPER_NONE, |
14a2834d010c
Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents:
1416
diff
changeset
|
46 MAPPER_SEGA, |
1863
d60f2d7c02a5
Differentiate between the full Sega mapper and the SRAM only one. Fixes crash on save state load for Phantasy Star IV and other games that use the same mapper
Michael Pavone <pavone@retrodev.com>
parents:
1610
diff
changeset
|
47 MAPPER_SEGA_SRAM, |
1444
14a2834d010c
Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents:
1416
diff
changeset
|
48 MAPPER_REALTEC, |
14a2834d010c
Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents:
1416
diff
changeset
|
49 MAPPER_XBAND, |
1610 | 50 MAPPER_MULTI_GAME, |
2052
3748a2a8a4b7
Support Sega mapper without 'SEGA SSF' in header or ROM DB entry and implement a subset of the extended Sega mapper implemented in the Mega Everdrive when 'SEGA SSF' is present
Michael Pavone <pavone@retrodev.com>
parents:
2027
diff
changeset
|
51 MAPPER_JCART, |
3748a2a8a4b7
Support Sega mapper without 'SEGA SSF' in header or ROM DB entry and implement a subset of the extended Sega mapper implemented in the Mega Everdrive when 'SEGA SSF' is present
Michael Pavone <pavone@retrodev.com>
parents:
2027
diff
changeset
|
52 MAPPER_SEGA_MED_V2 |
1444
14a2834d010c
Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents:
1416
diff
changeset
|
53 }; |
14a2834d010c
Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents:
1416
diff
changeset
|
54 |
1149
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1016
diff
changeset
|
55 |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1016
diff
changeset
|
56 typedef struct rom_info rom_info; |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1016
diff
changeset
|
57 |
1595
360d5bab199f
Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents:
1519
diff
changeset
|
58 #include "memmap.h" |
1149
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1016
diff
changeset
|
59 |
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1016
diff
changeset
|
60 struct rom_info { |
766
1b2f8280ba81
WIP changes to support reading cart memory map from ROM DB
Michael Pavone <pavone@retrodev.com>
parents:
765
diff
changeset
|
61 char *name; |
1b2f8280ba81
WIP changes to support reading cart memory map from ROM DB
Michael Pavone <pavone@retrodev.com>
parents:
765
diff
changeset
|
62 memmap_chunk *map; |
1b2f8280ba81
WIP changes to support reading cart memory map from ROM DB
Michael Pavone <pavone@retrodev.com>
parents:
765
diff
changeset
|
63 uint8_t *save_buffer; |
1416
11ac0b511cff
Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
1414
diff
changeset
|
64 void *rom; |
769
4638b88bc72d
Initial work on I2C EEPROM implementation
Michael Pavone <pavone@retrodev.com>
parents:
767
diff
changeset
|
65 eeprom_map *eeprom_map; |
913
a5a51465f8b0
Allow IO device config to be overriden by ROM DB
Michael Pavone <pavone@retrodev.com>
parents:
776
diff
changeset
|
66 char *port1_override; |
a5a51465f8b0
Allow IO device config to be overriden by ROM DB
Michael Pavone <pavone@retrodev.com>
parents:
776
diff
changeset
|
67 char *port2_override; |
a5a51465f8b0
Allow IO device config to be overriden by ROM DB
Michael Pavone <pavone@retrodev.com>
parents:
776
diff
changeset
|
68 char *ext_override; |
915
9e882eca717e
Initial support for relative mouse mode and skeleton of support for capture mode. Avoid mouse position overflow in absolute mode. Allow absolute mode to be set by ROM DB.
Michael Pavone <pavone@retrodev.com>
parents:
913
diff
changeset
|
69 char *mouse_mode; |
1519
1f745318f10a
Made the NOR flash emulation a bit more flexible, but not yet flexible enough to properly support the flash chip in the MegaWiFi cart
Michael Pavone <pavone@retrodev.com>
parents:
1444
diff
changeset
|
70 nor_state *nor; |
769
4638b88bc72d
Initial work on I2C EEPROM implementation
Michael Pavone <pavone@retrodev.com>
parents:
767
diff
changeset
|
71 uint32_t num_eeprom; |
766
1b2f8280ba81
WIP changes to support reading cart memory map from ROM DB
Michael Pavone <pavone@retrodev.com>
parents:
765
diff
changeset
|
72 uint32_t map_chunks; |
1416
11ac0b511cff
Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
1414
diff
changeset
|
73 uint32_t rom_size; |
766
1b2f8280ba81
WIP changes to support reading cart memory map from ROM DB
Michael Pavone <pavone@retrodev.com>
parents:
765
diff
changeset
|
74 uint32_t save_size; |
767
ea525f600b1d
SRAM detection from ROM header is no working correctly again
Michael Pavone <pavone@retrodev.com>
parents:
766
diff
changeset
|
75 uint32_t save_mask; |
776
cbf97d335444
Full support for Sega mapper when it comes to data. Code in remapped sections may not work reliably. SSF2 now works.
Michael Pavone <pavone@retrodev.com>
parents:
770
diff
changeset
|
76 uint16_t mapper_start_index; |
766
1b2f8280ba81
WIP changes to support reading cart memory map from ROM DB
Michael Pavone <pavone@retrodev.com>
parents:
765
diff
changeset
|
77 uint8_t save_type; |
1395
efa7225e0f07
Initial work to support parallel NOR flash and the Magistr 16
Michael Pavone <pavone@retrodev.com>
parents:
1228
diff
changeset
|
78 uint8_t save_bus; //only used for NOR currently |
1444
14a2834d010c
Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents:
1416
diff
changeset
|
79 uint8_t mapper_type; |
766
1b2f8280ba81
WIP changes to support reading cart memory map from ROM DB
Michael Pavone <pavone@retrodev.com>
parents:
765
diff
changeset
|
80 uint8_t regions; |
1411
780fbe0b97be
WIP support for handling S3 save RAM when locked on
Michael Pavone <pavone@retrodev.com>
parents:
1395
diff
changeset
|
81 uint8_t is_save_lock_on; //Does the save buffer actually belong to a lock-on cart? |
2054
8ee7ecbf3f21
Implement enough of Sega CD gate array and Sub CPU to pass Sik's Mode 1 test ROM
Michael Pavone <pavone@retrodev.com>
parents:
2053
diff
changeset
|
82 uint8_t wants_cd; |
1149
6b0da6021544
Don't lock up CPU if performing a read with writes configured when in PBC mode. Allow access to VDP debug commands from Z80 debugger in PBC mode. Handle Mode 4 in VDP debug print functions
Michael Pavone <pavone@retrodev.com>
parents:
1016
diff
changeset
|
83 }; |
764
bb60259e8edf
Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
84 |
1228
2e6dcb5c11a2
WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
1149
diff
changeset
|
85 #define GAME_ID_OFF 0x183 |
2e6dcb5c11a2
WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
1149
diff
changeset
|
86 #define GAME_ID_LEN 8 |
2e6dcb5c11a2
WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
1149
diff
changeset
|
87 |
1503
a763523dadf4
Added code for initializing a combined Genesis + Sega CD system when a Sega CD ISO is loaded
Michael Pavone <pavone@retrodev.com>
parents:
1444
diff
changeset
|
88 tern_node *get_rom_db(); |
1016
5fb64487b6e1
Very basic support for S&K lock-on. Needs more work for full functionality.
Michael Pavone <pavone@retrodev.com>
parents:
956
diff
changeset
|
89 rom_info configure_rom(tern_node *rom_db, void *vrom, uint32_t rom_size, void *lock_on, uint32_t lock_on_size, memmap_chunk const *base_map, uint32_t base_chunks); |
766
1b2f8280ba81
WIP changes to support reading cart memory map from ROM DB
Michael Pavone <pavone@retrodev.com>
parents:
765
diff
changeset
|
90 rom_info configure_rom_heuristics(uint8_t *rom, uint32_t rom_size, memmap_chunk const *base_map, uint32_t base_chunks); |
765
dc54387ee1cd
Allow regions to be set in ROM DB. Prefer default region if it is one of the valid regions for the ROM.
Michael Pavone <pavone@retrodev.com>
parents:
764
diff
changeset
|
91 uint8_t translate_region_char(uint8_t c); |
1395
efa7225e0f07
Initial work to support parallel NOR flash and the Magistr 16
Michael Pavone <pavone@retrodev.com>
parents:
1228
diff
changeset
|
92 char const *save_type_name(uint8_t save_type); |
1411
780fbe0b97be
WIP support for handling S3 save RAM when locked on
Michael Pavone <pavone@retrodev.com>
parents:
1395
diff
changeset
|
93 //Note: free_rom_info only frees things pointed to by a rom_info struct, not the struct itself |
780fbe0b97be
WIP support for handling S3 save RAM when locked on
Michael Pavone <pavone@retrodev.com>
parents:
1395
diff
changeset
|
94 //this is because rom_info structs are typically stack allocated |
780fbe0b97be
WIP support for handling S3 save RAM when locked on
Michael Pavone <pavone@retrodev.com>
parents:
1395
diff
changeset
|
95 void free_rom_info(rom_info *info); |
1595
360d5bab199f
Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents:
1519
diff
changeset
|
96 typedef struct system_header system_header; |
1444
14a2834d010c
Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents:
1416
diff
changeset
|
97 void cart_serialize(system_header *sys, serialize_buffer *buf); |
14a2834d010c
Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents:
1416
diff
changeset
|
98 void cart_deserialize(deserialize_buffer *buf, void *vcontext); |
764
bb60259e8edf
Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
99 |
bb60259e8edf
Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
100 #endif //ROMDB_H_ |