annotate romdb.h @ 1442:59e1dbb795a7

Update README in anticipation of 0.5.1 release
author Michael Pavone <pavone@retrodev.com>
date Fri, 25 Aug 2017 20:12:21 -0700
parents 11ac0b511cff
children 14a2834d010c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
766
1b2f8280ba81 WIP changes to support reading cart memory map from ROM DB
Michael Pavone <pavone@retrodev.com>
parents: 765
diff changeset
14 #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
15
764
bb60259e8edf Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
16 #include "tern.h"
bb60259e8edf Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
17
bb60259e8edf Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
18 typedef struct {
769
4638b88bc72d Initial work on I2C EEPROM implementation
Michael Pavone <pavone@retrodev.com>
parents: 767
diff changeset
19 uint32_t start;
4638b88bc72d Initial work on I2C EEPROM implementation
Michael Pavone <pavone@retrodev.com>
parents: 767
diff changeset
20 uint32_t end;
4638b88bc72d Initial work on I2C EEPROM implementation
Michael Pavone <pavone@retrodev.com>
parents: 767
diff changeset
21 uint16_t sda_write_mask;
4638b88bc72d Initial work on I2C EEPROM implementation
Michael Pavone <pavone@retrodev.com>
parents: 767
diff changeset
22 uint16_t scl_mask;
4638b88bc72d Initial work on I2C EEPROM implementation
Michael Pavone <pavone@retrodev.com>
parents: 767
diff changeset
23 uint8_t sda_read_bit;
4638b88bc72d Initial work on I2C EEPROM implementation
Michael Pavone <pavone@retrodev.com>
parents: 767
diff changeset
24 } eeprom_map;
4638b88bc72d Initial work on I2C EEPROM implementation
Michael Pavone <pavone@retrodev.com>
parents: 767
diff changeset
25
4638b88bc72d Initial work on I2C EEPROM implementation
Michael Pavone <pavone@retrodev.com>
parents: 767
diff changeset
26 typedef struct {
1395
efa7225e0f07 Initial work to support parallel NOR flash and the Magistr 16
Michael Pavone <pavone@retrodev.com>
parents: 1228
diff changeset
27 uint8_t *buffer;
efa7225e0f07 Initial work to support parallel NOR flash and the Magistr 16
Michael Pavone <pavone@retrodev.com>
parents: 1228
diff changeset
28 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
29 uint32_t size;
efa7225e0f07 Initial work to support parallel NOR flash and the Magistr 16
Michael Pavone <pavone@retrodev.com>
parents: 1228
diff changeset
30 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
31 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
32 uint32_t last_write_cycle;
efa7225e0f07 Initial work to support parallel NOR flash and the Magistr 16
Michael Pavone <pavone@retrodev.com>
parents: 1228
diff changeset
33 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
34 uint8_t mode;
efa7225e0f07 Initial work to support parallel NOR flash and the Magistr 16
Michael Pavone <pavone@retrodev.com>
parents: 1228
diff changeset
35 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
36 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
37 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
38 } nor_state;
efa7225e0f07 Initial work to support parallel NOR flash and the Magistr 16
Michael Pavone <pavone@retrodev.com>
parents: 1228
diff changeset
39
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
40
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
41 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
42
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
43 #include "backend.h"
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
44
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
45 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
46 char *name;
1b2f8280ba81 WIP changes to support reading cart memory map from ROM DB
Michael Pavone <pavone@retrodev.com>
parents: 765
diff changeset
47 memmap_chunk *map;
1b2f8280ba81 WIP changes to support reading cart memory map from ROM DB
Michael Pavone <pavone@retrodev.com>
parents: 765
diff changeset
48 uint8_t *save_buffer;
1416
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents: 1414
diff changeset
49 void *rom;
769
4638b88bc72d Initial work on I2C EEPROM implementation
Michael Pavone <pavone@retrodev.com>
parents: 767
diff changeset
50 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
51 char *port1_override;
a5a51465f8b0 Allow IO device config to be overriden by ROM DB
Michael Pavone <pavone@retrodev.com>
parents: 776
diff changeset
52 char *port2_override;
a5a51465f8b0 Allow IO device config to be overriden by ROM DB
Michael Pavone <pavone@retrodev.com>
parents: 776
diff changeset
53 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
54 char *mouse_mode;
769
4638b88bc72d Initial work on I2C EEPROM implementation
Michael Pavone <pavone@retrodev.com>
parents: 767
diff changeset
55 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
56 uint32_t map_chunks;
1416
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents: 1414
diff changeset
57 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
58 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
59 uint32_t save_mask;
1395
efa7225e0f07 Initial work to support parallel NOR flash and the Magistr 16
Michael Pavone <pavone@retrodev.com>
parents: 1228
diff changeset
60 uint32_t save_page_size;
efa7225e0f07 Initial work to support parallel NOR flash and the Magistr 16
Michael Pavone <pavone@retrodev.com>
parents: 1228
diff changeset
61 uint16_t save_product_id;
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
62 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
63 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
64 uint8_t save_bus; //only used for NOR currently
766
1b2f8280ba81 WIP changes to support reading cart memory map from ROM DB
Michael Pavone <pavone@retrodev.com>
parents: 765
diff changeset
65 uint8_t regions;
1411
780fbe0b97be WIP support for handling S3 save RAM when locked on
Michael Pavone <pavone@retrodev.com>
parents: 1395
diff changeset
66 uint8_t is_save_lock_on; //Does the save buffer actually belong to a lock-on cart?
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
67 };
764
bb60259e8edf Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
68
1228
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents: 1149
diff changeset
69 #define GAME_ID_OFF 0x183
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents: 1149
diff changeset
70 #define GAME_ID_LEN 8
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents: 1149
diff changeset
71
764
bb60259e8edf Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
72 tern_node *load_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
73 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
74 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
75 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
76 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
77 //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
78 //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
79 void free_rom_info(rom_info *info);
764
bb60259e8edf Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
80
bb60259e8edf Initial work on ROM database
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
81 #endif //ROMDB_H_