annotate genesis.h @ 2149:9209858b2f74

Fix a couple of bugs in the TOC file parser
author Michael Pavone <pavone@retrodev.com>
date Sat, 26 Mar 2022 23:05:08 -0700
parents 8ee7ecbf3f21
children 408fb8a7e990
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
467
140af5509ce7 Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents: 451
diff changeset
1 /*
140af5509ce7 Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents: 451
diff changeset
2 Copyright 2013 Michael Pavone
483
3e1573fa22cf Implement turbo/slow motion feature that overclocks or underclocks the entire system at the push of a button
Mike Pavone <pavone@retrodev.com>
parents: 467
diff changeset
3 This file is part of BlastEm.
467
140af5509ce7 Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents: 451
diff changeset
4 BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text.
140af5509ce7 Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents: 451
diff changeset
5 */
1103
22e87b739ad6 WIP split of ROM loading/argument parsing from Genesis emulation code. Compiles and doesn't crash, but nothing works. Still a few too many globals as well.
Michael Pavone <pavone@retrodev.com>
parents: 1016
diff changeset
6 #ifndef GENESIS_H_
22e87b739ad6 WIP split of ROM loading/argument parsing from Genesis emulation code. Compiles and doesn't crash, but nothing works. Still a few too many globals as well.
Michael Pavone <pavone@retrodev.com>
parents: 1016
diff changeset
7 #define GENESIS_H_
66
7a22a0e6c004 Gamepad support
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
8
75
108e587165c0 Implement DMA (untested)
Mike Pavone <pavone@retrodev.com>
parents: 66
diff changeset
9 #include <stdint.h>
1111
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents: 1103
diff changeset
10 #include "system.h"
569
9b7fcf748be0 Rename x86_68k_options and m68k_to_x86.h to m68k_options and m68k_core.h respectively
Michael Pavone <pavone@retrodev.com>
parents: 524
diff changeset
11 #include "m68k_core.h"
1752
d6d4c006a7b3 Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents: 1690
diff changeset
12 #ifdef NEW_CORE
d6d4c006a7b3 Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents: 1690
diff changeset
13 #include "z80.h"
d6d4c006a7b3 Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents: 1690
diff changeset
14 #else
288
a8ee7934a1f8 Add a YM2612 stub implementation with just timers and status registers so that games that depend on it can run.
Mike Pavone <pavone@retrodev.com>
parents: 198
diff changeset
15 #include "z80_to_x86.h"
1752
d6d4c006a7b3 Initial attempt at interrupts in new Z80 core and integrating it into main executable
Michael Pavone <pavone@retrodev.com>
parents: 1690
diff changeset
16 #endif
288
a8ee7934a1f8 Add a YM2612 stub implementation with just timers and status registers so that games that depend on it can run.
Mike Pavone <pavone@retrodev.com>
parents: 198
diff changeset
17 #include "ym2612.h"
a8ee7934a1f8 Add a YM2612 stub implementation with just timers and status registers so that games that depend on it can run.
Mike Pavone <pavone@retrodev.com>
parents: 198
diff changeset
18 #include "vdp.h"
354
15dd6418fe67 Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents: 351
diff changeset
19 #include "psg.h"
421
d0cacb4ade0b Move IO code to a separate file and do a tiny bit of refactoring
Mike Pavone <pavone@retrodev.com>
parents: 418
diff changeset
20 #include "io.h"
769
4638b88bc72d Initial work on I2C EEPROM implementation
Michael Pavone <pavone@retrodev.com>
parents: 767
diff changeset
21 #include "romdb.h"
883
9f149f0e98b7 It is now possible to switch back and forth between the menu ROM and the game
Michael Pavone <pavone@retrodev.com>
parents: 874
diff changeset
22 #include "arena.h"
1414
d94855080529 Move I2C EEPROM and NOR Flash functions out of romdb.c into new files
Michael Pavone <pavone@retrodev.com>
parents: 1413
diff changeset
23 #include "i2c.h"
66
7a22a0e6c004 Gamepad support
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
24
957
1618d3676a35 Save state menu WIP
Michael Pavone <pavone@retrodev.com>
parents: 956
diff changeset
25 typedef struct genesis_context genesis_context;
1618d3676a35 Save state menu WIP
Michael Pavone <pavone@retrodev.com>
parents: 956
diff changeset
26
1618d3676a35 Save state menu WIP
Michael Pavone <pavone@retrodev.com>
parents: 956
diff changeset
27 struct genesis_context {
1111
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents: 1103
diff changeset
28 system_header header;
957
1618d3676a35 Save state menu WIP
Michael Pavone <pavone@retrodev.com>
parents: 956
diff changeset
29 m68k_context *m68k;
1618d3676a35 Save state menu WIP
Michael Pavone <pavone@retrodev.com>
parents: 956
diff changeset
30 z80_context *z80;
1618d3676a35 Save state menu WIP
Michael Pavone <pavone@retrodev.com>
parents: 956
diff changeset
31 vdp_context *vdp;
1618d3676a35 Save state menu WIP
Michael Pavone <pavone@retrodev.com>
parents: 956
diff changeset
32 ym2612_context *ym;
1618d3676a35 Save state menu WIP
Michael Pavone <pavone@retrodev.com>
parents: 956
diff changeset
33 psg_context *psg;
1618d3676a35 Save state menu WIP
Michael Pavone <pavone@retrodev.com>
parents: 956
diff changeset
34 uint16_t *cart;
1016
5fb64487b6e1 Very basic support for S&K lock-on. Needs more work for full functionality.
Michael Pavone <pavone@retrodev.com>
parents: 981
diff changeset
35 uint16_t *lock_on;
957
1618d3676a35 Save state menu WIP
Michael Pavone <pavone@retrodev.com>
parents: 956
diff changeset
36 uint16_t *work_ram;
1618d3676a35 Save state menu WIP
Michael Pavone <pavone@retrodev.com>
parents: 956
diff changeset
37 uint8_t *zram;
1502
2564b6ba2e12 Initial skeleton of Sega CD memory handlers
Michael Pavone <pavone@retrodev.com>
parents: 1444
diff changeset
38 void *expansion;
957
1618d3676a35 Save state menu WIP
Michael Pavone <pavone@retrodev.com>
parents: 956
diff changeset
39 void *extra;
1618d3676a35 Save state menu WIP
Michael Pavone <pavone@retrodev.com>
parents: 956
diff changeset
40 uint8_t *save_storage;
1413
3d7f668dce3d Sonic 3 & Knuckles lock-on is now 100% functional with working saves
Michael Pavone <pavone@retrodev.com>
parents: 1395
diff changeset
41 void *mapper_temp;
957
1618d3676a35 Save state menu WIP
Michael Pavone <pavone@retrodev.com>
parents: 956
diff changeset
42 eeprom_map *eeprom_map;
2034
8b2ef428d1aa Implement TMSS ROM and cart mapping register
Michael Pavone <pavone@retrodev.com>
parents: 1971
diff changeset
43 write_16_fun tmss_write_16;
8b2ef428d1aa Implement TMSS ROM and cart mapping register
Michael Pavone <pavone@retrodev.com>
parents: 1971
diff changeset
44 write_8_fun tmss_write_8;
8b2ef428d1aa Implement TMSS ROM and cart mapping register
Michael Pavone <pavone@retrodev.com>
parents: 1971
diff changeset
45 read_16_fun tmss_read_16;
8b2ef428d1aa Implement TMSS ROM and cart mapping register
Michael Pavone <pavone@retrodev.com>
parents: 1971
diff changeset
46 read_8_fun tmss_read_8;
8b2ef428d1aa Implement TMSS ROM and cart mapping register
Michael Pavone <pavone@retrodev.com>
parents: 1971
diff changeset
47 uint16_t *tmss_pointers[NUM_MEM_AREAS];
8b2ef428d1aa Implement TMSS ROM and cart mapping register
Michael Pavone <pavone@retrodev.com>
parents: 1971
diff changeset
48 uint8_t *tmss_buffer;
1690
319d90025d50 Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents: 1649
diff changeset
49 uint8_t *serialize_tmp;
319d90025d50 Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents: 1649
diff changeset
50 size_t serialize_size;
957
1618d3676a35 Save state menu WIP
Michael Pavone <pavone@retrodev.com>
parents: 956
diff changeset
51 uint32_t num_eeprom;
1618d3676a35 Save state menu WIP
Michael Pavone <pavone@retrodev.com>
parents: 956
diff changeset
52 uint32_t save_size;
1618d3676a35 Save state menu WIP
Michael Pavone <pavone@retrodev.com>
parents: 956
diff changeset
53 uint32_t save_ram_mask;
1618d3676a35 Save state menu WIP
Michael Pavone <pavone@retrodev.com>
parents: 956
diff changeset
54 uint32_t master_clock; //Current master clock value
1618d3676a35 Save state menu WIP
Michael Pavone <pavone@retrodev.com>
parents: 956
diff changeset
55 uint32_t normal_clock; //Normal master clock (used to restore master clock after turbo mode)
1618d3676a35 Save state menu WIP
Michael Pavone <pavone@retrodev.com>
parents: 956
diff changeset
56 uint32_t frame_end;
1618d3676a35 Save state menu WIP
Michael Pavone <pavone@retrodev.com>
parents: 956
diff changeset
57 uint32_t max_cycles;
1364
30123ca5856c Added some code to try and prevent Z80 accesses and refresh cycles from screwing up interrupt latency more than on hardware
Michael Pavone <pavone@retrodev.com>
parents: 1208
diff changeset
58 uint32_t int_latency_prev1;
30123ca5856c Added some code to try and prevent Z80 accesses and refresh cycles from screwing up interrupt latency more than on hardware
Michael Pavone <pavone@retrodev.com>
parents: 1208
diff changeset
59 uint32_t int_latency_prev2;
1556
075df0844baa Randomize soft reset timing and fix silly bug that was accidentally clearing IO state on soft reset
Michael Pavone <pavone@retrodev.com>
parents: 1444
diff changeset
60 uint32_t reset_cycle;
1971
80920c21bb52 Add an event log soft flush and call it twice per frame in between hard flushes to netplay latency when there are insufficient hardware updates to flush packets in the middle of a frame
Michael Pavone <pavone@retrodev.com>
parents: 1946
diff changeset
61 uint32_t last_frame;
80920c21bb52 Add an event log soft flush and call it twice per frame in between hard flushes to netplay latency when there are insufficient hardware updates to flush packets in the middle of a frame
Michael Pavone <pavone@retrodev.com>
parents: 1946
diff changeset
62 uint32_t last_flush_cycle;
80920c21bb52 Add an event log soft flush and call it twice per frame in between hard flushes to netplay latency when there are insufficient hardware updates to flush packets in the middle of a frame
Michael Pavone <pavone@retrodev.com>
parents: 1946
diff changeset
63 uint32_t soft_flush_cycles;
2034
8b2ef428d1aa Implement TMSS ROM and cart mapping register
Michael Pavone <pavone@retrodev.com>
parents: 1971
diff changeset
64 uint32_t tmss_write_offset;
1757
bb4d19c7c047 Fix size of relocated Z80 bank register field
Michael Pavone <pavone@retrodev.com>
parents: 1752
diff changeset
65 uint16_t z80_bank_reg;
1907
b021ca0bc375 Some partial work on TMSS registers, more accurate open bus locations and implement machine freezes for unmapped areas in the IO region
Michael Pavone <pavone@retrodev.com>
parents: 1757
diff changeset
66 uint16_t tmss_lock[2];
957
1618d3676a35 Save state menu WIP
Michael Pavone <pavone@retrodev.com>
parents: 956
diff changeset
67 uint16_t mapper_start_index;
1444
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1428
diff changeset
68 uint8_t mapper_type;
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: 2037
diff changeset
69 uint8_t bank_regs[9];
957
1618d3676a35 Save state menu WIP
Michael Pavone <pavone@retrodev.com>
parents: 956
diff changeset
70 uint8_t save_type;
1111
2eb54e24914e Mostly working changes to allow support for multiple emulated system types in main blastem program
Michael Pavone <pavone@retrodev.com>
parents: 1103
diff changeset
71 sega_io io;
1103
22e87b739ad6 WIP split of ROM loading/argument parsing from Genesis emulation code. Compiles and doesn't crash, but nothing works. Still a few too many globals as well.
Michael Pavone <pavone@retrodev.com>
parents: 1016
diff changeset
72 uint8_t version_reg;
957
1618d3676a35 Save state menu WIP
Michael Pavone <pavone@retrodev.com>
parents: 956
diff changeset
73 uint8_t bus_busy;
1208
95f5253e75c7 Implement soft reset in Genesis mode
Michael Pavone <pavone@retrodev.com>
parents: 1117
diff changeset
74 uint8_t reset_requested;
1907
b021ca0bc375 Some partial work on TMSS registers, more accurate open bus locations and implement machine freezes for unmapped areas in the IO region
Michael Pavone <pavone@retrodev.com>
parents: 1757
diff changeset
75 uint8_t tmss;
2037
b0b0c31338c3 Implement TMSS VDP lock
Michael Pavone <pavone@retrodev.com>
parents: 2034
diff changeset
76 uint8_t vdp_unlocked;
957
1618d3676a35 Save state menu WIP
Michael Pavone <pavone@retrodev.com>
parents: 956
diff changeset
77 eeprom_state eeprom;
1395
efa7225e0f07 Initial work to support parallel NOR flash and the Magistr 16
Michael Pavone <pavone@retrodev.com>
parents: 1364
diff changeset
78 nor_state nor;
957
1618d3676a35 Save state menu WIP
Michael Pavone <pavone@retrodev.com>
parents: 956
diff changeset
79 };
288
a8ee7934a1f8 Add a YM2612 stub implementation with just timers and status registers so that games that depend on it can run.
Mike Pavone <pavone@retrodev.com>
parents: 198
diff changeset
80
524
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents: 508
diff changeset
81 #define RAM_WORDS 32 * 1024
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents: 508
diff changeset
82 #define Z80_RAM_BYTES 8 * 1024
fb39534b6604 Move debugging code outside of main source file
Mike Pavone <pavone@retrodev.com>
parents: 508
diff changeset
83
1595
360d5bab199f Update controller config when changed in UI without restart
Michael Pavone <pavone@retrodev.com>
parents: 1556
diff changeset
84 genesis_context *alloc_config_genesis(void *rom, uint32_t rom_size, void *lock_on, uint32_t lock_on_size, uint32_t system_opts, uint8_t force_region);
1692
5dacaef602a7 Merge from default
Michael Pavone <pavone@retrodev.com>
parents: 1503 1649
diff changeset
85 genesis_context *alloc_config_genesis_cdboot(system_media *media, uint32_t system_opts, uint8_t force_region);
1946
c3c62dbf1ceb WIP netplay support
Michael Pavone <pavone@retrodev.com>
parents: 1907
diff changeset
86 void genesis_serialize(genesis_context *gen, serialize_buffer *buf, uint32_t m68k_pc, uint8_t all);
1428
2540c05520f2 New savestates are working. New config file option for selecting format states will be saved in. Mostly complete, needs a little more work before release
Michael Pavone <pavone@retrodev.com>
parents: 1414
diff changeset
87 void genesis_deserialize(deserialize_buffer *buf, genesis_context *gen);
66
7a22a0e6c004 Gamepad support
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
88
1103
22e87b739ad6 WIP split of ROM loading/argument parsing from Genesis emulation code. Compiles and doesn't crash, but nothing works. Still a few too many globals as well.
Michael Pavone <pavone@retrodev.com>
parents: 1016
diff changeset
89 #endif //GENESIS_H_
66
7a22a0e6c004 Gamepad support
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
90