Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/genplus-gx32/core/cart_hw/md_cart.h
2 views
1
/****************************************************************************
2
* Genesis Plus
3
* Mega Drive cartridge hardware support
4
*
5
* Copyright (C) 2007-2013 Eke-Eke (Genesis Plus GX)
6
*
7
* Most cartridge protections were initially documented by Haze
8
* (http://haze.mameworld.info/)
9
*
10
* Realtec mapper was documented by TascoDeluxe
11
*
12
* Redistribution and use of this code or any derivative works are permitted
13
* provided that the following conditions are met:
14
*
15
* - Redistributions may not be sold, nor may they be used in a commercial
16
* product or activity.
17
*
18
* - Redistributions that are modified from the original source must include the
19
* complete source code, including the source code for all components used by a
20
* binary built from the modified sources. However, as a special exception, the
21
* source code distributed need not include anything that is normally distributed
22
* (in either source or binary form) with the major components (compiler, kernel,
23
* and so on) of the operating system on which the executable runs, unless that
24
* component itself accompanies the executable.
25
*
26
* - Redistributions must reproduce the above copyright notice, this list of
27
* conditions and the following disclaimer in the documentation and/or other
28
* materials provided with the distribution.
29
*
30
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
31
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
34
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
35
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
36
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
37
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
38
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
39
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40
* POSSIBILITY OF SUCH DAMAGE.
41
*
42
****************************************************************************************/
43
44
#ifndef _MD_CART_H_
45
#define _MD_CART_H_
46
47
#define cart ext.md_cart
48
49
/* Lock-On cartridge type */
50
#define TYPE_GG 0x01 /* Game Genie */
51
#define TYPE_AR 0x02 /* (Pro) Action Replay */
52
#define TYPE_SK 0x03 /* Sonic & Knuckles */
53
54
/* Special hardware (0x01 & 0x02 reserved for Master System 3-D glasses & Terebi Oekaki) */
55
#define HW_J_CART 0x04
56
#define HW_LOCK_ON 0x08
57
58
/* Cartridge extra hardware */
59
typedef struct
60
{
61
uint8 regs[4]; /* internal registers (R/W) */
62
uint32 mask[4]; /* registers address mask */
63
uint32 addr[4]; /* registers address */
64
uint16 realtec; /* realtec mapper */
65
uint16 bankshift; /* cartridge with bankshift mecanism reseted on software reset */
66
unsigned int (*time_r)(unsigned int address); /* !TIME signal ($a130xx) read handler */
67
void (*time_w)(unsigned int address, unsigned int data); /* !TIME signal ($a130xx) write handler */
68
unsigned int (*regs_r)(unsigned int address); /* cart hardware registers read handler */
69
void (*regs_w)(unsigned int address, unsigned int data); /* cart hardware registers write handler */
70
} cart_hw_t;
71
72
/* Cartridge type */
73
typedef struct
74
{
75
uint8 rom[MAXROMSIZE]; /* ROM area */
76
uint8 *base; /* ROM base (saved for OS/Cartridge ROM swap) */
77
uint32 romsize; /* ROM size */
78
uint32 mask; /* ROM mask */
79
uint8 special; /* Lock-On, J-Cart or SMS 3-D glasses hardware */
80
cart_hw_t hw; /* Extra mapping hardware */
81
} md_cart_t;
82
83
84
/* Function prototypes */
85
extern void md_cart_init(void);
86
extern void md_cart_reset(int hard_reset);
87
extern int md_cart_context_save(uint8 *state);
88
extern int md_cart_context_load(uint8 *state);
89
90
#endif
91
92