trunk/src/mess/machine/nes_slot.c
| r20939 | r20940 | |
| 9 | 9 | //************************************************************************** |
| 10 | 10 | |
| 11 | 11 | const device_type NES_CART_SLOT = &device_creator<nes_cart_slot_device>; |
| 12 | | const device_type FC_CART_SLOT = &device_creator<fc_cart_slot_device>; |
| 13 | 12 | |
| 14 | 13 | |
| 15 | 14 | //************************************************************************** |
| r20939 | r20940 | |
| 121 | 120 | //************************************************************************** |
| 122 | 121 | |
| 123 | 122 | //------------------------------------------------- |
| 124 | | // base_nes_cart_slot_device - constructor |
| 123 | // nes_cart_slot_device - constructor |
| 125 | 124 | //------------------------------------------------- |
| 126 | | base_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), |
| 125 | nes_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), |
| 128 | 127 | device_image_interface(mconfig, *this), |
| 129 | 128 | device_slot_interface(mconfig, *this), |
| 130 | 129 | m_chr_open_bus(0), |
| r20939 | r20940 | |
| 133 | 132 | m_vrc_ls_prg_a(0), |
| 134 | 133 | m_vrc_ls_prg_b(0), |
| 135 | 134 | m_vrc_ls_chr(0), |
| 136 | | m_crc_hack(0) |
| 135 | m_crc_hack(0), |
| 136 | m_must_be_loaded(1) |
| 137 | 137 | { |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | | nes_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 | | |
| 145 | | fc_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 | | |
| 150 | 140 | //------------------------------------------------- |
| 151 | | // base_nes_cart_slot_device - destructor |
| 141 | // nes_cart_slot_device - destructor |
| 152 | 142 | //------------------------------------------------- |
| 153 | 143 | |
| 154 | | base_nes_cart_slot_device::~base_nes_cart_slot_device() |
| 144 | nes_cart_slot_device::~nes_cart_slot_device() |
| 155 | 145 | { |
| 156 | 146 | } |
| 157 | 147 | |
| r20939 | r20940 | |
| 159 | 149 | // device_start - device-specific startup |
| 160 | 150 | //------------------------------------------------- |
| 161 | 151 | |
| 162 | | void base_nes_cart_slot_device::device_start() |
| 152 | void nes_cart_slot_device::device_start() |
| 163 | 153 | { |
| 164 | 154 | m_cart = dynamic_cast<device_nes_cart_interface *>(get_card_device()); |
| 165 | 155 | } |
| r20939 | r20940 | |
| 170 | 160 | // complete |
| 171 | 161 | //------------------------------------------------- |
| 172 | 162 | |
| 173 | | void base_nes_cart_slot_device::device_config_complete() |
| 163 | void nes_cart_slot_device::device_config_complete() |
| 174 | 164 | { |
| 175 | 165 | // inherit a copy of the static data |
| 176 | 166 | // const nes_cart_interface *intf = reinterpret_cast<const nes_cart_interface *>(static_config()); |
| r20939 | r20940 | |
| 243 | 233 | #define SPLIT_PRG 0 |
| 244 | 234 | #define SPLIT_CHR 0 |
| 245 | 235 | |
| 246 | | bool base_nes_cart_slot_device::call_load() |
| 236 | bool nes_cart_slot_device::call_load() |
| 247 | 237 | { |
| 248 | 238 | if (m_cart) |
| 249 | 239 | { |
| r20939 | r20940 | |
| 1120 | 1110 | call_unloadload |
| 1121 | 1111 | -------------------------------------------------*/ |
| 1122 | 1112 | |
| 1123 | | void base_nes_cart_slot_device::call_unload() |
| 1113 | void nes_cart_slot_device::call_unload() |
| 1124 | 1114 | { |
| 1125 | 1115 | if (m_cart->get_battery_size()) |
| 1126 | 1116 | battery_save(m_cart->get_battery_base(), m_cart->get_battery_size()); |
| r20939 | r20940 | |
| 1133 | 1123 | call softlist load |
| 1134 | 1124 | -------------------------------------------------*/ |
| 1135 | 1125 | |
| 1136 | | bool base_nes_cart_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry) |
| 1126 | bool nes_cart_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry) |
| 1137 | 1127 | { |
| 1138 | 1128 | load_software_part_region(this, swlist, swname, start_entry ); |
| 1139 | 1129 | return TRUE; |
| r20939 | r20940 | |
| 1143 | 1133 | get default card software |
| 1144 | 1134 | -------------------------------------------------*/ |
| 1145 | 1135 | |
| 1146 | | const char * base_nes_cart_slot_device::get_default_card_software(const machine_config &config, emu_options &options) |
| 1136 | const char * nes_cart_slot_device::get_default_card_software(const machine_config &config, emu_options &options) |
| 1147 | 1137 | { |
| 1148 | 1138 | return software_get_default_slot(config, options, this, "rom"); |
| 1149 | 1139 | } |
| r20939 | r20940 | |
| 1153 | 1143 | read |
| 1154 | 1144 | -------------------------------------------------*/ |
| 1155 | 1145 | |
| 1156 | | READ8_MEMBER(base_nes_cart_slot_device::read_l) |
| 1146 | READ8_MEMBER(nes_cart_slot_device::read_l) |
| 1157 | 1147 | { |
| 1158 | 1148 | if (m_cart) |
| 1159 | 1149 | return m_cart->read_l(space, offset); |
| r20939 | r20940 | |
| 1161 | 1151 | return 0xff; |
| 1162 | 1152 | } |
| 1163 | 1153 | |
| 1164 | | READ8_MEMBER(base_nes_cart_slot_device::read_m) |
| 1154 | READ8_MEMBER(nes_cart_slot_device::read_m) |
| 1165 | 1155 | { |
| 1166 | 1156 | if (m_cart) |
| 1167 | 1157 | return m_cart->read_m(space, offset); |
| r20939 | r20940 | |
| 1169 | 1159 | return 0xff; |
| 1170 | 1160 | } |
| 1171 | 1161 | |
| 1172 | | READ8_MEMBER(base_nes_cart_slot_device::read_h) |
| 1162 | READ8_MEMBER(nes_cart_slot_device::read_h) |
| 1173 | 1163 | { |
| 1174 | 1164 | if (m_cart) |
| 1175 | 1165 | return m_cart->read_h(space, offset); |
| r20939 | r20940 | |
| 1182 | 1172 | write |
| 1183 | 1173 | -------------------------------------------------*/ |
| 1184 | 1174 | |
| 1185 | | WRITE8_MEMBER(base_nes_cart_slot_device::write_l) |
| 1175 | WRITE8_MEMBER(nes_cart_slot_device::write_l) |
| 1186 | 1176 | { |
| 1187 | 1177 | if (m_cart) |
| 1188 | 1178 | m_cart->write_l(space, offset, data); |
| 1189 | 1179 | } |
| 1190 | 1180 | |
| 1191 | | WRITE8_MEMBER(base_nes_cart_slot_device::write_m) |
| 1181 | WRITE8_MEMBER(nes_cart_slot_device::write_m) |
| 1192 | 1182 | { |
| 1193 | 1183 | if (m_cart) |
| 1194 | 1184 | m_cart->write_m(space, offset, data); |
| 1195 | 1185 | } |
| 1196 | 1186 | |
| 1197 | | WRITE8_MEMBER(base_nes_cart_slot_device::write_h) |
| 1187 | WRITE8_MEMBER(nes_cart_slot_device::write_h) |
| 1198 | 1188 | { |
| 1199 | 1189 | if (m_cart) |
| 1200 | 1190 | m_cart->write_h(space, offset, data); |
trunk/src/mess/machine/nes_slot.h
| r20939 | r20940 | |
| 89 | 89 | |
| 90 | 90 | // ======================> nes_cart_slot_device |
| 91 | 91 | |
| 92 | | class base_nes_cart_slot_device : public device_t, |
| 92 | class nes_cart_slot_device : public device_t, |
| 93 | 93 | public nes_cart_interface, |
| 94 | 94 | public device_image_interface, |
| 95 | 95 | public device_slot_interface |
| 96 | 96 | { |
| 97 | 97 | public: |
| 98 | 98 | // 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(); |
| 101 | 101 | |
| 102 | 102 | // device-level overrides |
| 103 | 103 | virtual void device_start(); |
| r20939 | r20940 | |
| 112 | 112 | virtual bool is_readable() const { return 1; } |
| 113 | 113 | virtual bool is_writeable() const { return 0; } |
| 114 | 114 | 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; } |
| 116 | 117 | virtual bool is_reset_on_load() const { return 0; } |
| 117 | 118 | virtual const char *image_interface() const { return "nes_cart"; } |
| 118 | 119 | virtual const char *file_extensions() const { return "nes,unf,unif"; } |
| r20939 | r20940 | |
| 153 | 154 | |
| 154 | 155 | device_nes_cart_interface* m_cart; |
| 155 | 156 | int m_pcb_id; |
| 157 | bool m_must_be_loaded; |
| 156 | 158 | }; |
| 157 | 159 | |
| 158 | | // ======================> nes_cart_slot_device |
| 159 | | |
| 160 | | class nes_cart_slot_device : public base_nes_cart_slot_device |
| 161 | | { |
| 162 | | public: |
| 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 | | |
| 171 | | class fc_cart_slot_device : public base_nes_cart_slot_device |
| 172 | | { |
| 173 | | public: |
| 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 | | |
| 180 | 160 | // device type definition |
| 181 | 161 | extern const device_type NES_CART_SLOT; |
| 182 | | extern const device_type FC_CART_SLOT; // same but not mandatory |
| 183 | 162 | |
| 184 | 163 | |
| 185 | 164 | /*************************************************************************** |
| r20939 | r20940 | |
| 191 | 170 | MCFG_DEVICE_CONFIG(_config) \ |
| 192 | 171 | MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, _def_inp, false) |
| 193 | 172 | |
| 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); |
| 198 | 175 | |
| 199 | 176 | |
| 200 | 177 | // CART DEVICE [TO BE MOVED TO SEPARATE SOURCE LATER] |