/****************************************************************************1* Genesis Plus2* Mega Drive cartridge hardware support3*4* Copyright (C) 2007-2013 Eke-Eke (Genesis Plus GX)5*6* Most cartridge protections were initially documented by Haze7* (http://haze.mameworld.info/)8*9* Realtec mapper was documented by TascoDeluxe10*11* Redistribution and use of this code or any derivative works are permitted12* provided that the following conditions are met:13*14* - Redistributions may not be sold, nor may they be used in a commercial15* product or activity.16*17* - Redistributions that are modified from the original source must include the18* complete source code, including the source code for all components used by a19* binary built from the modified sources. However, as a special exception, the20* source code distributed need not include anything that is normally distributed21* (in either source or binary form) with the major components (compiler, kernel,22* and so on) of the operating system on which the executable runs, unless that23* component itself accompanies the executable.24*25* - Redistributions must reproduce the above copyright notice, this list of26* conditions and the following disclaimer in the documentation and/or other27* materials provided with the distribution.28*29* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"30* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE31* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE32* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE33* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR34* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF35* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS36* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN37* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)38* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE39* POSSIBILITY OF SUCH DAMAGE.40*41****************************************************************************************/4243#ifndef _MD_CART_H_44#define _MD_CART_H_4546#define cart ext.md_cart4748/* Lock-On cartridge type */49#define TYPE_GG 0x01 /* Game Genie */50#define TYPE_AR 0x02 /* (Pro) Action Replay */51#define TYPE_SK 0x03 /* Sonic & Knuckles */5253/* Special hardware (0x01 & 0x02 reserved for Master System 3-D glasses & Terebi Oekaki) */54#define HW_J_CART 0x0455#define HW_LOCK_ON 0x085657/* Cartridge extra hardware */58typedef struct59{60uint8 regs[4]; /* internal registers (R/W) */61uint32 mask[4]; /* registers address mask */62uint32 addr[4]; /* registers address */63uint16 realtec; /* realtec mapper */64uint16 bankshift; /* cartridge with bankshift mecanism reseted on software reset */65unsigned int (*time_r)(unsigned int address); /* !TIME signal ($a130xx) read handler */66void (*time_w)(unsigned int address, unsigned int data); /* !TIME signal ($a130xx) write handler */67unsigned int (*regs_r)(unsigned int address); /* cart hardware registers read handler */68void (*regs_w)(unsigned int address, unsigned int data); /* cart hardware registers write handler */69} cart_hw_t;7071/* Cartridge type */72typedef struct73{74uint8 rom[MAXROMSIZE]; /* ROM area */75uint8 *base; /* ROM base (saved for OS/Cartridge ROM swap) */76uint32 romsize; /* ROM size */77uint32 mask; /* ROM mask */78uint8 special; /* Lock-On, J-Cart or SMS 3-D glasses hardware */79cart_hw_t hw; /* Extra mapping hardware */80} md_cart_t;818283/* Function prototypes */84extern void md_cart_init(void);85extern void md_cart_reset(int hard_reset);86extern int md_cart_context_save(uint8 *state);87extern int md_cart_context_load(uint8 *state);8889#endif909192