trunk/src/emu/bus/ql/trumpcard.c
| r30799 | r30800 | |
| 26 | 26 | //************************************************************************** |
| 27 | 27 | |
| 28 | 28 | const device_type QL_TRUMP_CARD = &device_creator<ql_trump_card_t>; |
| 29 | const device_type QL_TRUMP_CARD_256K = &device_creator<ql_trump_card_256k_t>; |
| 30 | const device_type QL_TRUMP_CARD_512K = &device_creator<ql_trump_card_512k_t>; |
| 31 | const device_type QL_TRUMP_CARD_768K = &device_creator<ql_trump_card_768k_t>; |
| 29 | 32 | |
| 30 | 33 | |
| 31 | 34 | //------------------------------------------------- |
| r30799 | r30800 | |
| 76 | 79 | |
| 77 | 80 | static MACHINE_CONFIG_FRAGMENT( ql_trump_card ) |
| 78 | 81 | MCFG_DEVICE_ADD(WD1772_TAG, WD1772x, 8000000) |
| 79 | | //MCFG_WD_FDC_INTRQ_CALLBACK(WRITELINE(ql_trump_card_t, fdc_intrq_w)) |
| 80 | | //MCFG_WD_FDC_DRQ_CALLBACK(WRITELINE(ql_trump_card_t, fdc_drq_w)) |
| 81 | 82 | MCFG_FLOPPY_DRIVE_ADD(WD1772_TAG":0", ql_trump_card_floppies, "35dd", ql_trump_card_t::floppy_formats) |
| 82 | 83 | MCFG_FLOPPY_DRIVE_ADD(WD1772_TAG":1", ql_trump_card_floppies, NULL, ql_trump_card_t::floppy_formats) |
| 83 | 84 | MACHINE_CONFIG_END |
| r30799 | r30800 | |
| 104 | 105 | //------------------------------------------------- |
| 105 | 106 | |
| 106 | 107 | ql_trump_card_t::ql_trump_card_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 107 | | device_t(mconfig, QL_TRUMP_CARD, "QL Trump Card", tag, owner, clock, "ql_trump_card", __FILE__), |
| 108 | device_t(mconfig, QL_TRUMP_CARD, "QL Trump Card", tag, owner, clock, "trump", __FILE__), |
| 108 | 109 | device_ql_expansion_card_interface(mconfig, *this), |
| 110 | m_fdc(*this, WD1772_TAG), |
| 111 | m_floppy0(*this, WD1772_TAG":0"), |
| 112 | m_floppy1(*this, WD1772_TAG":1"), |
| 109 | 113 | m_rom(*this, "rom"), |
| 110 | | m_ram(*this, "ram") |
| 114 | m_ram(*this, "ram"), |
| 115 | m_ram_size(0) |
| 111 | 116 | { |
| 112 | 117 | } |
| 113 | 118 | |
| 119 | ql_trump_card_t::ql_trump_card_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source, int ram_size) : |
| 120 | device_t(mconfig, QL_TRUMP_CARD, "QL Trump Card", tag, owner, clock, "trump", __FILE__), |
| 121 | device_ql_expansion_card_interface(mconfig, *this), |
| 122 | m_fdc(*this, WD1772_TAG), |
| 123 | m_floppy0(*this, WD1772_TAG":0"), |
| 124 | m_floppy1(*this, WD1772_TAG":1"), |
| 125 | m_rom(*this, "rom"), |
| 126 | m_ram(*this, "ram"), |
| 127 | m_ram_size(ram_size) |
| 128 | { |
| 129 | } |
| 114 | 130 | |
| 131 | ql_trump_card_256k_t::ql_trump_card_256k_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 132 | : ql_trump_card_t(mconfig, QL_TRUMP_CARD_256K, "QL Trump Card 256K", tag, owner, clock, "trump256k", __FILE__, 256*1024) { } |
| 133 | |
| 134 | ql_trump_card_512k_t::ql_trump_card_512k_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 135 | : ql_trump_card_t(mconfig, QL_TRUMP_CARD_512K, "QL Trump Card 512K", tag, owner, clock, "trump512k", __FILE__, 512*1024) { } |
| 136 | |
| 137 | ql_trump_card_768k_t::ql_trump_card_768k_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 138 | : ql_trump_card_t(mconfig, QL_TRUMP_CARD_768K, "QL Trump Card 768K", tag, owner, clock, "trump768k", __FILE__, 768*1024) { } |
| 139 | |
| 140 | |
| 115 | 141 | //------------------------------------------------- |
| 116 | 142 | // device_start - device-specific startup |
| 117 | 143 | //------------------------------------------------- |
| 118 | 144 | |
| 119 | 145 | void ql_trump_card_t::device_start() |
| 120 | 146 | { |
| 147 | m_ram.allocate(m_ram_size); |
| 121 | 148 | } |
| 122 | 149 | |
| 123 | 150 | |
| r30799 | r30800 | |
| 127 | 154 | |
| 128 | 155 | void ql_trump_card_t::device_reset() |
| 129 | 156 | { |
| 157 | m_fdc->set_floppy(NULL); |
| 158 | m_fdc->dden_w(0); |
| 159 | |
| 160 | m_rom_en = false; |
| 161 | m_ram_en = false; |
| 130 | 162 | } |
| 163 | |
| 164 | |
| 165 | //------------------------------------------------- |
| 166 | // read - |
| 167 | //------------------------------------------------- |
| 168 | |
| 169 | UINT8 ql_trump_card_t::read(address_space &space, offs_t offset, UINT8 data) |
| 170 | { |
| 171 | if (!m_rom_en && offset >= 0xc000 && offset < 0x10000) |
| 172 | { |
| 173 | m_rom_en = true; |
| 174 | |
| 175 | data = m_rom->base()[offset & 0x3fff]; |
| 176 | } |
| 177 | |
| 178 | if (offset >= 0x10000 && offset < 0x18000) |
| 179 | { |
| 180 | if (m_ram_size == 768*1024) |
| 181 | { |
| 182 | m_ram_en = true; |
| 183 | } |
| 184 | |
| 185 | data = m_rom->base()[offset & 0x7fff]; |
| 186 | } |
| 187 | |
| 188 | if (offset >= 0x1c000 && offset <= 0x1c003) |
| 189 | { |
| 190 | data = m_fdc->read(space, offset & 0x03); |
| 191 | } |
| 192 | |
| 193 | if (offset >= 0x60000 && offset < 0xc0000) |
| 194 | { |
| 195 | if ((offset - 0x60000) < m_ram_size) |
| 196 | { |
| 197 | data = m_ram[offset - 0x60000]; |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | if (offset >= 0xc0000) |
| 202 | { |
| 203 | if (m_rom_en && offset < 0xc8000) |
| 204 | { |
| 205 | data = m_rom->base()[offset & 0x7fff]; |
| 206 | } |
| 207 | |
| 208 | if (m_ram_en) |
| 209 | { |
| 210 | data = m_ram[offset - 0x60000]; |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | return data; |
| 215 | } |
| 216 | |
| 217 | |
| 218 | //------------------------------------------------- |
| 219 | // write - |
| 220 | //------------------------------------------------- |
| 221 | |
| 222 | void ql_trump_card_t::write(address_space &space, offs_t offset, UINT8 data) |
| 223 | { |
| 224 | if (offset >= 0x1c000 && offset <= 0x1c003) |
| 225 | { |
| 226 | m_fdc->write(space, offset & 0x03, data); |
| 227 | } |
| 228 | |
| 229 | if (offset == 0x1e000) |
| 230 | { |
| 231 | /* |
| 232 | |
| 233 | bit description |
| 234 | |
| 235 | 0 DRIVE1 |
| 236 | 1 DRIVE0 |
| 237 | 2 MOTOR |
| 238 | 3 SIDE |
| 239 | 4 |
| 240 | 5 |
| 241 | 6 |
| 242 | 7 |
| 243 | |
| 244 | */ |
| 245 | |
| 246 | floppy_image_device *floppy = NULL; |
| 247 | |
| 248 | if (BIT(data, 1)) |
| 249 | { |
| 250 | floppy = m_floppy0->get_device(); |
| 251 | } |
| 252 | else if (BIT(data, 0)) |
| 253 | { |
| 254 | floppy = m_floppy1->get_device(); |
| 255 | } |
| 256 | |
| 257 | m_fdc->set_floppy(floppy); |
| 258 | |
| 259 | if (floppy) |
| 260 | { |
| 261 | floppy->ss_w(BIT(data, 3)); |
| 262 | floppy->mon_w(BIT(data, 2)); |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | if (offset >= 0x60000 && offset < 0xc0000) |
| 267 | { |
| 268 | if ((offset - 0x60000) < m_ram_size) |
| 269 | { |
| 270 | m_ram[offset - 0x60000] = data; |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | if (offset >= 0xc0000) |
| 275 | { |
| 276 | if (m_ram_en) |
| 277 | { |
| 278 | m_ram[offset - 0x60000] = data; |
| 279 | } |
| 280 | } |
| 281 | } |
trunk/src/emu/bus/ql/trumpcard.h
| r30799 | r30800 | |
| 32 | 32 | public: |
| 33 | 33 | // construction/destruction |
| 34 | 34 | ql_trump_card_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 35 | ql_trump_card_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source, int ram_size); |
| 35 | 36 | |
| 36 | 37 | // optional information overrides |
| 37 | 38 | virtual const rom_entry *device_rom_region() const; |
| r30799 | r30800 | |
| 45 | 46 | virtual void device_reset(); |
| 46 | 47 | |
| 47 | 48 | // device_ql_expansion_card_interface overrides |
| 49 | virtual UINT8 read(address_space &space, offs_t offset, UINT8 data); |
| 50 | virtual void write(address_space &space, offs_t offset, UINT8 data); |
| 48 | 51 | |
| 49 | 52 | private: |
| 53 | required_device<wd1772_t> m_fdc; |
| 54 | required_device<floppy_connector> m_floppy0; |
| 55 | required_device<floppy_connector> m_floppy1; |
| 50 | 56 | required_memory_region m_rom; |
| 51 | 57 | optional_shared_ptr<UINT8> m_ram; |
| 58 | |
| 59 | int m_ram_size; |
| 60 | bool m_rom_en; |
| 61 | bool m_ram_en; |
| 52 | 62 | }; |
| 53 | 63 | |
| 54 | 64 | |
| 65 | // ======================> ql_trump_card_256k_t |
| 66 | |
| 67 | class ql_trump_card_256k_t : public ql_trump_card_t |
| 68 | { |
| 69 | public: |
| 70 | // construction/destruction |
| 71 | ql_trump_card_256k_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 72 | }; |
| 73 | |
| 74 | |
| 75 | // ======================> ql_trump_card_512k_t |
| 76 | |
| 77 | class ql_trump_card_512k_t : public ql_trump_card_t |
| 78 | { |
| 79 | public: |
| 80 | // construction/destruction |
| 81 | ql_trump_card_512k_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 82 | }; |
| 83 | |
| 84 | |
| 85 | // ======================> ql_trump_card_768k_t |
| 86 | |
| 87 | class ql_trump_card_768k_t : public ql_trump_card_t |
| 88 | { |
| 89 | public: |
| 90 | // construction/destruction |
| 91 | ql_trump_card_768k_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 92 | }; |
| 93 | |
| 94 | |
| 95 | |
| 55 | 96 | // device type definition |
| 56 | 97 | extern const device_type QL_TRUMP_CARD; |
| 98 | extern const device_type QL_TRUMP_CARD_256K; |
| 99 | extern const device_type QL_TRUMP_CARD_512K; |
| 100 | extern const device_type QL_TRUMP_CARD_768K; |
| 57 | 101 | |
| 58 | 102 | |
| 103 | |
| 59 | 104 | #endif |