Previous 199869 Revisions Next

r20940 Monday 11th February, 2013 at 15:06:05 UTC by Miodrag Milanović
nes: fixed non-mandatory cart handling for famicom (nw)
[src/mess/drivers]nes.c
[src/mess/machine]nes_slot.c nes_slot.h

trunk/src/mess/machine/nes_slot.c
r20939r20940
99//**************************************************************************
1010
1111const device_type NES_CART_SLOT = &device_creator<nes_cart_slot_device>;
12const device_type FC_CART_SLOT = &device_creator<fc_cart_slot_device>;
1312
1413
1514//**************************************************************************
r20939r20940
121120//**************************************************************************
122121
123122//-------------------------------------------------
124//  base_nes_cart_slot_device - constructor
123//  nes_cart_slot_device - constructor
125124//-------------------------------------------------
126base_nes_cart_slot_device::base_nes_cart_slot_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) :
127                  device_t(mconfig, type, name, tag, owner, clock),
125nes_cart_slot_device::nes_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
126                  device_t(mconfig, NES_CART_SLOT, "NES Cartridge Slot", tag, owner, clock),
128127                  device_image_interface(mconfig, *this),
129128                  device_slot_interface(mconfig, *this),
130129                  m_chr_open_bus(0),
r20939r20940
133132                  m_vrc_ls_prg_a(0),
134133                  m_vrc_ls_prg_b(0),
135134                  m_vrc_ls_chr(0),
136                  m_crc_hack(0)
135                  m_crc_hack(0),
136                  m_must_be_loaded(1)
137137{
138138}
139139
140nes_cart_slot_device::nes_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
141                  base_nes_cart_slot_device(mconfig, NES_CART_SLOT, "NES Cartridge Slot", tag, owner, clock)
142{
143}
144
145fc_cart_slot_device::fc_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
146                  base_nes_cart_slot_device(mconfig, FC_CART_SLOT, "FC Cartridge Slot", tag, owner, clock)
147{
148}
149
150140//-------------------------------------------------
151//  base_nes_cart_slot_device - destructor
141//  nes_cart_slot_device - destructor
152142//-------------------------------------------------
153143
154base_nes_cart_slot_device::~base_nes_cart_slot_device()
144nes_cart_slot_device::~nes_cart_slot_device()
155145{
156146}
157147
r20939r20940
159149//  device_start - device-specific startup
160150//-------------------------------------------------
161151
162void base_nes_cart_slot_device::device_start()
152void nes_cart_slot_device::device_start()
163153{
164154   m_cart = dynamic_cast<device_nes_cart_interface *>(get_card_device());
165155}
r20939r20940
170160//  complete
171161//-------------------------------------------------
172162
173void base_nes_cart_slot_device::device_config_complete()
163void nes_cart_slot_device::device_config_complete()
174164{
175165   // inherit a copy of the static data
176166//   const nes_cart_interface *intf = reinterpret_cast<const nes_cart_interface *>(static_config());
r20939r20940
243233#define SPLIT_PRG   0
244234#define SPLIT_CHR   0
245235
246bool base_nes_cart_slot_device::call_load()
236bool nes_cart_slot_device::call_load()
247237{
248238   if (m_cart)
249239   {
r20939r20940
11201110 call_unloadload
11211111 -------------------------------------------------*/
11221112
1123void base_nes_cart_slot_device::call_unload()
1113void nes_cart_slot_device::call_unload()
11241114{
11251115   if (m_cart->get_battery_size())
11261116      battery_save(m_cart->get_battery_base(), m_cart->get_battery_size());
r20939r20940
11331123 call softlist load
11341124 -------------------------------------------------*/
11351125
1136bool base_nes_cart_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
1126bool nes_cart_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
11371127{
11381128   load_software_part_region(this, swlist, swname, start_entry );
11391129   return TRUE;
r20939r20940
11431133 get default card software
11441134 -------------------------------------------------*/
11451135
1146const char * base_nes_cart_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
1136const char * nes_cart_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
11471137{
11481138   return software_get_default_slot(config, options, this, "rom");
11491139}
r20939r20940
11531143 read
11541144 -------------------------------------------------*/
11551145
1156READ8_MEMBER(base_nes_cart_slot_device::read_l)
1146READ8_MEMBER(nes_cart_slot_device::read_l)
11571147{
11581148   if (m_cart)
11591149      return m_cart->read_l(space, offset);
r20939r20940
11611151      return 0xff;
11621152}
11631153
1164READ8_MEMBER(base_nes_cart_slot_device::read_m)
1154READ8_MEMBER(nes_cart_slot_device::read_m)
11651155{
11661156   if (m_cart)
11671157      return m_cart->read_m(space, offset);
r20939r20940
11691159      return 0xff;
11701160}
11711161
1172READ8_MEMBER(base_nes_cart_slot_device::read_h)
1162READ8_MEMBER(nes_cart_slot_device::read_h)
11731163{
11741164   if (m_cart)
11751165      return m_cart->read_h(space, offset);
r20939r20940
11821172 write
11831173 -------------------------------------------------*/
11841174
1185WRITE8_MEMBER(base_nes_cart_slot_device::write_l)
1175WRITE8_MEMBER(nes_cart_slot_device::write_l)
11861176{
11871177   if (m_cart)
11881178      m_cart->write_l(space, offset, data);
11891179}
11901180
1191WRITE8_MEMBER(base_nes_cart_slot_device::write_m)
1181WRITE8_MEMBER(nes_cart_slot_device::write_m)
11921182{
11931183   if (m_cart)
11941184      m_cart->write_m(space, offset, data);
11951185}
11961186
1197WRITE8_MEMBER(base_nes_cart_slot_device::write_h)
1187WRITE8_MEMBER(nes_cart_slot_device::write_h)
11981188{
11991189   if (m_cart)
12001190      m_cart->write_h(space, offset, data);
trunk/src/mess/machine/nes_slot.h
r20939r20940
8989
9090// ======================> nes_cart_slot_device
9191
92class base_nes_cart_slot_device : public device_t,
92class nes_cart_slot_device : public device_t,
9393                        public nes_cart_interface,
9494                        public device_image_interface,
9595                        public device_slot_interface
9696{
9797public:
9898   // construction/destruction
99   base_nes_cart_slot_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
100   virtual ~base_nes_cart_slot_device();
99   nes_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
100   virtual ~nes_cart_slot_device();
101101   
102102   // device-level overrides
103103   virtual void device_start();
r20939r20940
112112   virtual bool is_readable()  const { return 1; }
113113   virtual bool is_writeable() const { return 0; }
114114   virtual bool is_creatable() const { return 0; }
115   virtual bool must_be_loaded() const { return 1; }
115   virtual bool must_be_loaded() const { return m_must_be_loaded; }
116   void set_must_be_loaded(bool _must_be_loaded) { m_must_be_loaded = _must_be_loaded; }
116117   virtual bool is_reset_on_load() const { return 0; }
117118   virtual const char *image_interface() const { return "nes_cart"; }
118119   virtual const char *file_extensions() const { return "nes,unf,unif"; }
r20939r20940
153154   
154155   device_nes_cart_interface*      m_cart;
155156   int m_pcb_id;
157   bool                            m_must_be_loaded;
156158};
157159
158// ======================> nes_cart_slot_device
159
160class nes_cart_slot_device :  public base_nes_cart_slot_device
161{
162public:
163   // construction/destruction
164   nes_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
165   virtual bool must_be_loaded() const { return 1; }
166};
167
168
169// ======================> fc_cart_slot_device
170
171class fc_cart_slot_device :  public base_nes_cart_slot_device
172{
173public:
174   // construction/destruction
175   fc_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
176   virtual bool must_be_loaded() const { return 0; }
177};
178
179
180160// device type definition
181161extern const device_type NES_CART_SLOT;
182extern const device_type FC_CART_SLOT;   // same but not mandatory
183162
184163
185164/***************************************************************************
r20939r20940
191170   MCFG_DEVICE_CONFIG(_config) \
192171   MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, _def_inp, false)
193172
194#define MCFG_FC_CARTRIDGE_ADD(_tag,_config,_slot_intf,_def_slot,_def_inp) \
195   MCFG_DEVICE_ADD(_tag, FC_CART_SLOT, 0) \
196   MCFG_DEVICE_CONFIG(_config) \
197   MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, _def_inp, false)
173#define MCFG_NES_CARTRIDGE_NOT_MANDATORY                                     \
174   static_cast<nes_cart_slot_device *>(device)->set_must_be_loaded(FALSE);
198175
199176
200177// CART DEVICE [TO BE MOVED TO SEPARATE SOURCE LATER]
trunk/src/mess/drivers/nes.c
r20939r20940
527527
528528static MACHINE_CONFIG_DERIVED( famicom, nes )
529529   MCFG_DEVICE_REMOVE( "nes_slot" )
530//   MCFG_FC_CARTRIDGE_ADD("nes_slot", nes_crt_interface, nes_cart, NULL, NULL)   // here we need a non-mandatory cart...
530   MCFG_NES_CARTRIDGE_ADD("nes_slot", nes_crt_interface, nes_cart, NULL, NULL)   // here we need a non-mandatory cart...
531   MCFG_NES_CARTRIDGE_NOT_MANDATORY
531532
532533   MCFG_LEGACY_FLOPPY_DRIVE_ADD(FLOPPY_0, nes_floppy_interface)
533534   MCFG_SOFTWARE_LIST_ADD("flop_list","famicom_flop")

Previous 199869 Revisions Next


© 1997-2024 The MAME Team