Previous 199869 Revisions Next

r31962 Sunday 7th September, 2014 at 06:27:29 UTC by Fabio Priuli
(MESS) megadriv.c: Added support for Game Genie as a passthru cart. [Fabio Priuli]
[hash]megadriv.xml
[src/emu/bus]bus.mak
[src/emu/bus/megadrive]ggenie.c* ggenie.h* md_carts.c md_carts.h

trunk/hash/megadriv.xml
r31961r31962
3104631046      </part>
3104731047   </software>
3104831048
31049   <software name="ggenie" supported="no">
31049   <software name="ggenie">
3105031050      <description>Game Genie (Euro, USA, Rev. A)</description>
3105131051      <year>199?</year>
3105231052      <publisher>&lt;unknown&gt;</publisher>
3105331053      <part name="cart" interface="megadriv_cart">
31054         <feature name="slot" value="rom_ggenie"/>
3105431055         <dataarea name="rom" width="16" endianness="big" size="32768">
3105531056            <rom name="sgr001-a+sgr002-a.bin" size="32768" crc="14dbce4a" sha1="937e1878ebd104f489e6bdbc410a184f79f1144a" offset="0x000000"/>
3105631057         </dataarea>
3105731058      </part>
3105831059   </software>
3105931060
31060   <software name="ggenie1" cloneof="ggenie" supported="no">
31061   <software name="ggenie1" cloneof="ggenie">
3106131062      <description>Game Genie (Euro, USA)</description>
3106231063      <year>199?</year>
3106331064      <publisher>&lt;unknown&gt;</publisher>
3106431065      <part name="cart" interface="megadriv_cart">
31066         <feature name="slot" value="rom_ggenie"/>
3106531067         <dataarea name="rom" width="16" endianness="big" size="32768">
3106631068            <rom name="sgr001+sgr002.bin" size="32768" crc="5f293e4c" sha1="ea4b0418d90bc47996f6788ad455391d07cad6cc" offset="0x000000"/>
3106731069         </dataarea>
trunk/src/emu/bus/bus.mak
r31961r31962
947947BUSOBJS += $(BUSOBJ)/megadrive/md_slot.o
948948BUSOBJS += $(BUSOBJ)/megadrive/md_carts.o
949949BUSOBJS += $(BUSOBJ)/megadrive/eeprom.o
950BUSOBJS += $(BUSOBJ)/megadrive/ggenie.o
950951BUSOBJS += $(BUSOBJ)/megadrive/jcart.o
951952BUSOBJS += $(BUSOBJ)/megadrive/rom.o
952953BUSOBJS += $(BUSOBJ)/megadrive/sk.o
trunk/src/emu/bus/megadrive/md_carts.c
r31961r31962
3535   SLOT_INTERFACE_INTERNAL("rom_stm95",  MD_EEPROM_STM95)
3636// CodeMasters 2-in-1 (reset based)
3737   SLOT_INTERFACE_INTERNAL("rom_cm2in1",  MD_ROM_CM2IN1)
38// Game Genie
39   SLOT_INTERFACE_INTERNAL("rom_ggenie",  MD_ROM_GAMEGENIE)
3840// unique bankswitch
3941   SLOT_INTERFACE_INTERNAL("rom_ssf2",  MD_ROM_SSF2)
4042   SLOT_INTERFACE_INTERNAL("rom_radica",  MD_ROM_RADICA)
trunk/src/emu/bus/megadrive/ggenie.c
r0r31962
1/***********************************************************************************************************
2
3
4 Game Genie pass-thorugh cart emulation
5
6
7 based on Charles MacDonald's docs: http://cgfm2.emuviews.com/txt/genie.txt
8 
9
10 There is an interesting difference between Rev.0 and Rev.A
11 After the codes has been entered, the former just performs
12 a last write to the MODE register (m_gg_regs[0]) which both
13 sets the enable bits for the 6 available cheats (in the low
14 8 bits) and locks the GG so that later reads goes to the
15 piggyback cart. The latter revision, instead, performs the
16 same operations in two subsequent 8bit writes, accessing
17 separately the low and high bits of the register.
18 
19 ***********************************************************************************************************/
20
21#include "emu.h"
22#include "ggenie.h"
23#include "rom.h"
24
25
26//-------------------------------------------------
27//  md_rom_device - constructor
28//-------------------------------------------------
29
30const device_type MD_ROM_GAMEGENIE = &device_creator<md_rom_ggenie_device>;
31
32
33md_rom_ggenie_device::md_rom_ggenie_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
34               : device_t(mconfig, MD_ROM_GAMEGENIE, "MD Game Genie", tag, owner, clock, "md_ggenie", __FILE__),
35                  device_md_cart_interface( mconfig, *this ),
36                  m_exp(*this, "subslot")
37{
38}
39
40
41void md_rom_ggenie_device::device_start()
42{
43   save_item(NAME(m_gg_bypass));
44   save_item(NAME(m_reg_enable));
45   save_item(NAME(m_gg_regs));
46   save_item(NAME(m_gg_addr));
47   save_item(NAME(m_gg_data));
48}
49
50void md_rom_ggenie_device::device_reset()
51{
52   m_gg_bypass = 0;
53   m_reg_enable = 0;
54   memset(m_gg_regs, 0, sizeof(m_gg_regs));
55   memset(m_gg_addr, 0, sizeof(m_gg_addr));
56   memset(m_gg_data, 0, sizeof(m_gg_data));
57}
58
59/*-------------------------------------------------
60 mapper specific handlers
61 -------------------------------------------------*/
62
63READ16_MEMBER(md_rom_ggenie_device::read)
64{
65   if (!m_gg_bypass || !m_exp->m_cart)
66   {
67      if (m_reg_enable)
68         return m_gg_regs[offset & 0x1f];
69      else
70         return m_rom[MD_ADDR(offset)];
71   }
72
73   if (m_exp->m_cart)
74   {
75      if (offset == m_gg_addr[0]/2 && BIT(m_gg_regs[0], 0))
76         return m_gg_data[0];
77      else if (offset == m_gg_addr[1]/2 && BIT(m_gg_regs[0], 1))
78         return m_gg_data[1];
79      else if (offset == m_gg_addr[2]/2 && BIT(m_gg_regs[0], 2))
80         return m_gg_data[2];
81      else if (offset == m_gg_addr[3]/2 && BIT(m_gg_regs[0], 3))
82         return m_gg_data[3];
83      else if (offset == m_gg_addr[4]/2 && BIT(m_gg_regs[0], 4))
84         return m_gg_data[4];
85      else if (offset == m_gg_addr[5]/2 && BIT(m_gg_regs[0], 5))
86         return m_gg_data[5];
87      else
88         return m_exp->m_cart->read(space, offset);
89   }   
90   else
91      return 0xffff;
92}
93
94WRITE16_MEMBER(md_rom_ggenie_device::write)
95{
96   if (offset >= 0x40/2)
97      return;
98
99   if (ACCESSING_BITS_0_7)
100      m_gg_regs[offset] = (m_gg_regs[offset] & 0xff00) | (data & 0x00ff);
101
102   if (ACCESSING_BITS_8_15)
103      m_gg_regs[offset] = (m_gg_regs[offset] & 0x00ff) | (data & 0xff00);
104
105   //printf("write to 0x%X, data 0x%X\n", offset, data);
106
107   // MODE
108   if (offset == 0)
109   {
110      // bit10 set = read goes to piggyback cart
111      if (data & 0x400)
112         m_gg_bypass = 1;
113      // bit10 unset = read goes to Game Genie ASIC/ROM
114      else
115      {
116         m_gg_bypass = 0;
117         
118         // bit9 set = read goes to ASIC registers
119         if (data & 0x200)
120            m_reg_enable = 1;
121         // bit9 unset = read goes to GG ROM
122         else
123            m_reg_enable = 0;
124      }
125     
126      // LOCK bit
127      if (data & 0x100)
128      {
129         // addresses
130         m_gg_addr[0] = ((m_gg_regs[2]   & 0x3f) << 16) | m_gg_regs[3];
131         m_gg_addr[1] = ((m_gg_regs[5]   & 0x3f) << 16) | m_gg_regs[6];
132         m_gg_addr[2] = ((m_gg_regs[8]   & 0x3f) << 16) | m_gg_regs[9];
133         m_gg_addr[3] = ((m_gg_regs[11]  & 0x3f) << 16) | m_gg_regs[12];
134         m_gg_addr[4] = ((m_gg_regs[14]  & 0x3f) << 16) | m_gg_regs[15];
135         m_gg_addr[5] = ((m_gg_regs[17]  & 0x3f) << 16) | m_gg_regs[18];
136         
137         // data
138         m_gg_data[0] = m_gg_regs[4];
139         m_gg_data[1] = m_gg_regs[7];
140         m_gg_data[2] = m_gg_regs[10];
141         m_gg_data[3] = m_gg_regs[13];
142         m_gg_data[4] = m_gg_regs[16];
143         m_gg_data[5] = m_gg_regs[19];
144
145         //printf("mode %X\n", data);
146         //for (int i = 0; i < 6; i++)
147         //   printf("addr %d = 0x%X - data 0x%X\n", i, m_gg_addr[i], m_gg_data[i]);
148      }
149   }   
150   else if (offset == 1)
151   {
152      // RESET
153      m_gg_regs[1] |= 1;
154   }
155}
156
157//-------------------------------------------------
158//  MACHINE_CONFIG_FRAGMENT( ggenie_slot )
159//-------------------------------------------------
160
161static SLOT_INTERFACE_START(ggenie_sub_cart)
162   SLOT_INTERFACE_INTERNAL("rom",  MD_STD_ROM)
163   SLOT_INTERFACE_INTERNAL("rom_svp",  MD_STD_ROM)
164   SLOT_INTERFACE_INTERNAL("rom_sram",  MD_ROM_SRAM)
165   SLOT_INTERFACE_INTERNAL("rom_sramsafe",  MD_ROM_SRAM)
166   SLOT_INTERFACE_INTERNAL("rom_fram",  MD_ROM_FRAM)
167SLOT_INTERFACE_END
168
169static MACHINE_CONFIG_FRAGMENT( ggenie_slot )
170   MCFG_MD_CARTRIDGE_ADD("subslot", ggenie_sub_cart, NULL)
171   MCFG_MD_CARTRIDGE_NOT_MANDATORY
172MACHINE_CONFIG_END
173
174
175//-------------------------------------------------
176//  machine_config_additions - device-specific
177//  machine configurations
178//-------------------------------------------------
179
180machine_config_constructor md_rom_ggenie_device::device_mconfig_additions() const
181{
182   return MACHINE_CONFIG_NAME( ggenie_slot );
183}
Property changes on: trunk/src/emu/bus/megadrive/ggenie.c
Added: svn:eol-style
   + native
Added: svn:mime-type
   + text/plain
trunk/src/emu/bus/megadrive/md_carts.h
r31961r31962
1414#include "rom.h"
1515#include "svp.h"
1616#include "sk.h"
17#include "ggenie.h"
1718#include "eeprom.h"
1819#include "jcart.h"
1920#include "stm95.h"
trunk/src/emu/bus/megadrive/ggenie.h
r0r31962
1#ifndef __MD_GGENIE_H
2#define __MD_GGENIE_H
3
4#include "md_slot.h"
5
6
7// ======================> md_rom_ggenie_device
8
9class md_rom_ggenie_device : public device_t,
10                  public device_md_cart_interface
11{
12public:
13   // construction/destruction
14   md_rom_ggenie_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
15
16   // device-level overrides
17   virtual void device_start();
18   virtual void device_reset();
19   virtual machine_config_constructor device_mconfig_additions() const;
20
21   // reading and writing
22   virtual DECLARE_READ16_MEMBER(read);
23   virtual DECLARE_WRITE16_MEMBER(write);
24
25private:
26   required_device<md_cart_slot_device> m_exp;
27   UINT16 m_gg_regs[0x20];
28   int m_gg_bypass;
29   int m_reg_enable;
30   UINT16 m_gg_addr[6];
31   UINT16 m_gg_data[6];
32};
33
34
35// device type definition
36extern const device_type MD_ROM_GAMEGENIE;
37
38#endif
Property changes on: trunk/src/emu/bus/megadrive/ggenie.h
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

Previous 199869 Revisions Next


© 1997-2024 The MAME Team