trunk/src/emu/bus/a2bus/a2bus.c
| r243289 | r243290 | |
| 160 | 160 | void a2bus_device::device_start() |
| 161 | 161 | { |
| 162 | 162 | m_maincpu = machine().device<cpu_device>(m_cputag); |
| 163 | m_maincpu_space = &machine().device<cpu_device>(m_cputag)->space(AS_PROGRAM); |
| 163 | 164 | |
| 164 | 165 | // resolve callbacks |
| 165 | 166 | m_out_irq_cb.resolve_safe(); |
| r243289 | r243290 | |
| 246 | 247 | m_maincpu->set_input_line(INPUT_LINE_HALT, state); |
| 247 | 248 | } |
| 248 | 249 | |
| 250 | UINT8 a2bus_device::dma_r(address_space &space, UINT16 offset) |
| 251 | { |
| 252 | m_maincpu_space->set_debugger_access(space.debugger_access()); |
| 253 | |
| 254 | return m_maincpu_space->read_byte(offset); |
| 255 | } |
| 256 | |
| 257 | void a2bus_device::dma_w(address_space &space, UINT16 offset, UINT8 data) |
| 258 | { |
| 259 | m_maincpu_space->set_debugger_access(space.debugger_access()); |
| 260 | |
| 261 | m_maincpu_space->write_byte(offset, data); |
| 262 | } |
| 263 | |
| 264 | UINT8 a2bus_device::dma_nospace_r(UINT16 offset) |
| 265 | { |
| 266 | return m_maincpu_space->read_byte(offset); |
| 267 | } |
| 268 | |
| 269 | void a2bus_device::dma_nospace_w(UINT16 offset, UINT8 data) |
| 270 | { |
| 271 | m_maincpu_space->write_byte(offset, data); |
| 272 | } |
| 273 | |
| 249 | 274 | void a2bus_device::recalc_inh(int slot) |
| 250 | 275 | { |
| 251 | 276 | m_out_inh_cb(ASSERT_LINE); |
trunk/src/emu/bus/a2bus/a2bus.h
| r243289 | r243290 | |
| 106 | 106 | void set_nmi_line(int state, int slot); |
| 107 | 107 | void set_maincpu_halt(int state); |
| 108 | 108 | void recalc_inh(int slot); |
| 109 | UINT8 dma_r(address_space &space, UINT16 offset); |
| 110 | void dma_w(address_space &space, UINT16 offset, UINT8 data); |
| 111 | UINT8 dma_nospace_r(UINT16 offset); |
| 112 | void dma_nospace_w(UINT16 offset, UINT8 data); |
| 109 | 113 | |
| 110 | 114 | DECLARE_WRITE_LINE_MEMBER( irq_w ); |
| 111 | 115 | DECLARE_WRITE_LINE_MEMBER( nmi_w ); |
| r243289 | r243290 | |
| 117 | 121 | |
| 118 | 122 | // internal state |
| 119 | 123 | cpu_device *m_maincpu; |
| 124 | address_space *m_maincpu_space; |
| 120 | 125 | |
| 121 | 126 | devcb_write_line m_out_irq_cb; |
| 122 | 127 | devcb_write_line m_out_nmi_cb; |
| r243289 | r243290 | |
| 144 | 149 | device_a2bus_card_interface(const machine_config &mconfig, device_t &device); |
| 145 | 150 | virtual ~device_a2bus_card_interface(); |
| 146 | 151 | |
| 147 | | virtual UINT8 read_c0nx(address_space &space, UINT8 offset) { printf("a2bus: unhandled read at C0n%x\n", offset); return 0; } // C0nX - /DEVSEL |
| 148 | | virtual void write_c0nx(address_space &space, UINT8 offset, UINT8 data) { printf("a2bus: unhandled write %02x to C0n%x\n", data, offset); } |
| 152 | virtual UINT8 read_c0nx(address_space &space, UINT8 offset) { logerror("a2bus: unhandled read at C0n%x\n", offset); return 0; } // C0nX - /DEVSEL |
| 153 | virtual void write_c0nx(address_space &space, UINT8 offset, UINT8 data) { logerror("a2bus: unhandled write %02x to C0n%x\n", data, offset); } |
| 149 | 154 | virtual UINT8 read_cnxx(address_space &space, UINT8 offset) { return 0; } // CnXX - /IOSEL |
| 150 | | virtual void write_cnxx(address_space &space, UINT8 offset, UINT8 data) { printf("a2bus: unhandled write %02x to Cn%02x\n", data, offset); } |
| 155 | virtual void write_cnxx(address_space &space, UINT8 offset, UINT8 data) { logerror("a2bus: unhandled write %02x to Cn%02x\n", data, offset); } |
| 151 | 156 | virtual UINT8 read_c800(address_space &space, UINT16 offset) { return 0; } // C800 - /IOSTB |
| 152 | | virtual void write_c800(address_space &space, UINT16 offset, UINT8 data) { printf("a2bus: unhandled write %02x to %04x\n", data, offset + 0xc800); } |
| 157 | virtual void write_c800(address_space &space, UINT16 offset, UINT8 data) { logerror("a2bus: unhandled write %02x to %04x\n", data, offset + 0xc800); } |
| 153 | 158 | virtual bool take_c800() { return true; } // override and return false if your card doesn't take over the c800 space |
| 154 | 159 | virtual UINT8 read_inh_rom(address_space &space, UINT16 offset) { return 0; } |
| 155 | 160 | virtual void write_inh_rom(address_space &space, UINT16 offset, UINT8 data) { } |
| r243289 | r243290 | |
| 171 | 176 | void recalc_slot_inh() { m_a2bus->recalc_inh(m_slot); } |
| 172 | 177 | void set_maincpu_halt(int state) { m_a2bus->set_maincpu_halt(state); } |
| 173 | 178 | |
| 179 | // pass through the original address space if any for debugger protection |
| 180 | // when debugging e.g. coprocessor cards (Z80 SoftCard etc). |
| 181 | UINT8 slot_dma_read(address_space &space, UINT16 offset) { return m_a2bus->dma_r(space, offset); } |
| 182 | void slot_dma_write(address_space &space, UINT16 offset, UINT8 data) { m_a2bus->dma_w(space, offset, data); } |
| 183 | |
| 184 | // these versions forego that protection for when the DMA isn't coming from a debuggable CPU device |
| 185 | UINT8 slot_dma_read_no_space(UINT16 offset) { return m_a2bus->dma_nospace_r(offset); } |
| 186 | void slot_dma_write_no_space(UINT16 offset, UINT8 data) { m_a2bus->dma_nospace_w(offset, data); } |
| 187 | |
| 174 | 188 | // inline configuration |
| 175 | 189 | static void static_set_a2bus_tag(device_t &device, const char *tag, const char *slottag); |
| 176 | 190 | public: |
trunk/src/emu/bus/a2bus/a2softcard.c
| r243289 | r243290 | |
| 52 | 52 | a2bus_softcard_device::a2bus_softcard_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) : |
| 53 | 53 | device_t(mconfig, type, name, tag, owner, clock, shortname, source), |
| 54 | 54 | device_a2bus_card_interface(mconfig, *this), |
| 55 | | m_z80(*this, Z80_TAG), |
| 56 | | m_6502space(NULL) |
| 55 | m_z80(*this, Z80_TAG) |
| 57 | 56 | { |
| 58 | 57 | } |
| 59 | 58 | |
| 60 | 59 | a2bus_softcard_device::a2bus_softcard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 61 | 60 | device_t(mconfig, A2BUS_SOFTCARD, "Microsoft SoftCard", tag, owner, clock, "a2softcard", __FILE__), |
| 62 | 61 | device_a2bus_card_interface(mconfig, *this), |
| 63 | | m_z80(*this, Z80_TAG), |
| 64 | | m_6502space(NULL) |
| 62 | m_z80(*this, Z80_TAG) |
| 65 | 63 | { |
| 66 | 64 | } |
| 67 | 65 | |
| r243289 | r243290 | |
| 82 | 80 | { |
| 83 | 81 | m_bEnabled = false; |
| 84 | 82 | |
| 85 | | m_6502space = NULL; |
| 86 | 83 | m_FirstZ80Boot = true; |
| 87 | 84 | m_z80->set_input_line(INPUT_LINE_HALT, ASSERT_LINE); |
| 88 | 85 | } |
| r243289 | r243290 | |
| 91 | 88 | { |
| 92 | 89 | if (!m_bEnabled) |
| 93 | 90 | { |
| 94 | | // steal the 6502's address space |
| 95 | | m_6502space = &space; |
| 96 | | |
| 97 | 91 | m_z80->set_input_line(INPUT_LINE_HALT, CLEAR_LINE); |
| 98 | 92 | set_maincpu_halt(ASSERT_LINE); |
| 99 | 93 | |
| r243289 | r243290 | |
| 115 | 109 | |
| 116 | 110 | READ8_MEMBER( a2bus_softcard_device::dma_r ) |
| 117 | 111 | { |
| 118 | | if (m_6502space) |
| 112 | if (m_bEnabled) |
| 119 | 113 | { |
| 120 | 114 | if (offset <= 0xafff) |
| 121 | 115 | { |
| 122 | | return m_6502space->read_byte(offset+0x1000); |
| 116 | return slot_dma_read(space, offset+0x1000); |
| 123 | 117 | } |
| 124 | 118 | else if (offset <= 0xbfff) // LC bank 2 d000-dfff |
| 125 | 119 | { |
| 126 | | return m_6502space->read_byte((offset&0xfff) + 0xd000); |
| 120 | return slot_dma_read(space, (offset&0xfff) + 0xd000); |
| 127 | 121 | } |
| 128 | 122 | else if (offset <= 0xcfff) // LC e000-efff |
| 129 | 123 | { |
| 130 | | return m_6502space->read_byte((offset&0xfff) + 0xe000); |
| 124 | return slot_dma_read(space, (offset&0xfff) + 0xe000); |
| 131 | 125 | } |
| 132 | 126 | else if (offset <= 0xdfff) // LC f000-ffff (or ROM?) |
| 133 | 127 | { |
| 134 | | return m_6502space->read_byte((offset&0xfff) + 0xf000); |
| 128 | return slot_dma_read(space, (offset&0xfff) + 0xf000); |
| 135 | 129 | } |
| 136 | 130 | else if (offset <= 0xefff) // I/O space c000-cfff |
| 137 | 131 | { |
| 138 | | return m_6502space->read_byte((offset&0xfff) + 0xc000); |
| 132 | return slot_dma_read(space, (offset&0xfff) + 0xc000); |
| 139 | 133 | } |
| 140 | 134 | else // zero page |
| 141 | 135 | { |
| 142 | | return m_6502space->read_byte(offset&0xfff); |
| 136 | return slot_dma_read(space, offset&0xfff); |
| 143 | 137 | } |
| 144 | 138 | } |
| 145 | 139 | |
| r243289 | r243290 | |
| 153 | 147 | |
| 154 | 148 | WRITE8_MEMBER( a2bus_softcard_device::dma_w ) |
| 155 | 149 | { |
| 156 | | if (m_6502space) |
| 150 | if (m_bEnabled) |
| 157 | 151 | { |
| 158 | 152 | if (offset <= 0xafff) |
| 159 | 153 | { |
| 160 | | m_6502space->write_byte(offset+0x1000, data); |
| 154 | slot_dma_write(space, offset+0x1000, data); |
| 161 | 155 | } |
| 162 | 156 | else if (offset <= 0xbfff) // LC bank 2 d000-dfff |
| 163 | 157 | { |
| 164 | | m_6502space->write_byte((offset&0xfff) + 0xd000, data); |
| 158 | slot_dma_write(space, (offset&0xfff) + 0xd000, data); |
| 165 | 159 | } |
| 166 | 160 | else if (offset <= 0xcfff) // LC e000-efff |
| 167 | 161 | { |
| 168 | | m_6502space->write_byte((offset&0xfff) + 0xe000, data); |
| 162 | slot_dma_write(space, (offset&0xfff) + 0xe000, data); |
| 169 | 163 | } |
| 170 | 164 | else if (offset <= 0xdfff) // LC f000-ffff (or ROM?) |
| 171 | 165 | { |
| 172 | | m_6502space->write_byte((offset&0xfff) + 0xf000, data); |
| 166 | slot_dma_write(space, (offset&0xfff) + 0xf000, data); |
| 173 | 167 | } |
| 174 | 168 | else if (offset <= 0xefff) // I/O space c000-cfff |
| 175 | 169 | { |
| 176 | | m_6502space->write_byte((offset&0xfff) + 0xc000, data); |
| 170 | slot_dma_write(space, (offset&0xfff) + 0xc000, data); |
| 177 | 171 | } |
| 178 | 172 | else // zero page |
| 179 | 173 | { |
| 180 | | m_6502space->write_byte(offset&0xfff, data); |
| 174 | slot_dma_write(space, offset&0xfff, data); |
| 181 | 175 | } |
| 182 | 176 | } |
| 183 | 177 | } |
trunk/src/emu/bus/a2bus/a2themill.c
| r243289 | r243290 | |
| 71 | 71 | a2bus_themill_device::a2bus_themill_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) : |
| 72 | 72 | device_t(mconfig, type, name, tag, owner, clock, shortname, source), |
| 73 | 73 | device_a2bus_card_interface(mconfig, *this), |
| 74 | | m_6809(*this, M6809_TAG), |
| 75 | | m_6502space(NULL) |
| 74 | m_6809(*this, M6809_TAG) |
| 76 | 75 | { |
| 77 | 76 | } |
| 78 | 77 | |
| 79 | 78 | a2bus_themill_device::a2bus_themill_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 80 | 79 | device_t(mconfig, A2BUS_THEMILL, "Stellation Two The Mill", tag, owner, clock, "a2themill", __FILE__), |
| 81 | 80 | device_a2bus_card_interface(mconfig, *this), |
| 82 | | m_6809(*this, M6809_TAG), |
| 83 | | m_6502space(NULL) |
| 81 | m_6809(*this, M6809_TAG) |
| 84 | 82 | { |
| 85 | 83 | } |
| 86 | 84 | |
| r243289 | r243290 | |
| 102 | 100 | void a2bus_themill_device::device_reset() |
| 103 | 101 | { |
| 104 | 102 | m_bEnabled = false; |
| 105 | | m_6502space = NULL; |
| 106 | 103 | m_flipAddrSpace = false; |
| 107 | 104 | m_6809Mode = false; |
| 108 | 105 | m_status = 0xc0; // OS9 loader relies on this |
| r243289 | r243290 | |
| 135 | 132 | case 2: // 6809 reset |
| 136 | 133 | if (data & 0x80) |
| 137 | 134 | { |
| 138 | | // steal the 6502's address space |
| 139 | | m_6502space = &space; |
| 140 | 135 | m_6809->reset(); |
| 141 | 136 | |
| 142 | 137 | m_6809->set_input_line(INPUT_LINE_HALT, CLEAR_LINE); |
| r243289 | r243290 | |
| 241 | 236 | |
| 242 | 237 | READ8_MEMBER( a2bus_themill_device::dma_r ) |
| 243 | 238 | { |
| 244 | | if (m_6502space) |
| 239 | if (m_6809Mode) |
| 245 | 240 | { |
| 246 | | if (m_6809Mode) |
| 241 | if (offset <= 0xafff) |
| 247 | 242 | { |
| 248 | | if (offset <= 0xafff) |
| 249 | | { |
| 250 | | return m_6502space->read_byte(offset+0x1000); |
| 251 | | } |
| 252 | | else if (offset <= 0xbfff) |
| 253 | | { |
| 254 | | return m_6502space->read_byte((offset&0xfff) + 0xd000); |
| 255 | | } |
| 256 | | else if (offset <= 0xcfff) |
| 257 | | { |
| 258 | | return m_6502space->read_byte((offset&0xfff) + 0xe000); |
| 259 | | } |
| 260 | | else if (offset <= 0xdfff) |
| 261 | | { |
| 262 | | return m_6502space->read_byte((offset&0xfff) + 0xf000); |
| 263 | | } |
| 264 | | else if (offset <= 0xefff) |
| 265 | | { |
| 266 | | return m_6502space->read_byte((offset&0xfff) + 0xc000); |
| 267 | | } |
| 268 | | else // 6809 Fxxx -> 6502 ZP |
| 269 | | { |
| 270 | | return m_6502space->read_byte(offset&0xfff); |
| 271 | | } |
| 243 | return slot_dma_read(space, offset+0x1000); |
| 272 | 244 | } |
| 245 | else if (offset <= 0xbfff) |
| 246 | { |
| 247 | return slot_dma_read(space, (offset&0xfff) + 0xd000); |
| 248 | } |
| 249 | else if (offset <= 0xcfff) |
| 250 | { |
| 251 | return slot_dma_read(space, (offset&0xfff) + 0xe000); |
| 252 | } |
| 253 | else if (offset <= 0xdfff) |
| 254 | { |
| 255 | return slot_dma_read(space, (offset&0xfff) + 0xf000); |
| 256 | } |
| 257 | else if (offset <= 0xefff) |
| 258 | { |
| 259 | return slot_dma_read(space, (offset&0xfff) + 0xc000); |
| 260 | } |
| 261 | else // 6809 Fxxx -> 6502 ZP |
| 262 | { |
| 263 | return slot_dma_read(space, offset&0xfff); |
| 264 | } |
| 265 | } |
| 266 | else |
| 267 | { |
| 268 | if (m_flipAddrSpace) |
| 269 | { |
| 270 | return slot_dma_read(space, offset^0x8000); |
| 271 | } |
| 273 | 272 | else |
| 274 | 273 | { |
| 275 | | if (m_flipAddrSpace) |
| 276 | | { |
| 277 | | return m_6502space->read_byte(offset^0x8000); |
| 278 | | } |
| 279 | | else |
| 280 | | { |
| 281 | | return m_6502space->read_byte(offset); |
| 282 | | } |
| 274 | return slot_dma_read(space, offset); |
| 283 | 275 | } |
| 284 | 276 | } |
| 285 | 277 | |
| r243289 | r243290 | |
| 293 | 285 | |
| 294 | 286 | WRITE8_MEMBER( a2bus_themill_device::dma_w ) |
| 295 | 287 | { |
| 296 | | if (m_6502space) |
| 288 | if (m_6809Mode) |
| 297 | 289 | { |
| 298 | | if (m_6809Mode) |
| 290 | if (offset <= 0xafff) |
| 299 | 291 | { |
| 300 | | if (offset <= 0xafff) |
| 301 | | { |
| 302 | | m_6502space->write_byte(offset+0x1000, data); |
| 303 | | } |
| 304 | | else if (offset <= 0xbfff) |
| 305 | | { |
| 306 | | m_6502space->write_byte((offset&0xfff) + 0xd000, data); |
| 307 | | } |
| 308 | | else if (offset <= 0xcfff) |
| 309 | | { |
| 310 | | m_6502space->write_byte((offset&0xfff) + 0xe000, data); |
| 311 | | } |
| 312 | | else if (offset <= 0xdfff) |
| 313 | | { |
| 314 | | m_6502space->write_byte((offset&0xfff) + 0xf000, data); |
| 315 | | } |
| 316 | | else if (offset <= 0xefff) |
| 317 | | { |
| 318 | | m_6502space->write_byte((offset&0xfff) + 0xc000, data); |
| 319 | | } |
| 320 | | else // 6809 Fxxx -> 6502 ZP |
| 321 | | { |
| 322 | | m_6502space->write_byte(offset&0xfff, data); |
| 323 | | } |
| 292 | slot_dma_write(space, offset+0x1000, data); |
| 324 | 293 | } |
| 294 | else if (offset <= 0xbfff) |
| 295 | { |
| 296 | slot_dma_write(space, (offset&0xfff) + 0xd000, data); |
| 297 | } |
| 298 | else if (offset <= 0xcfff) |
| 299 | { |
| 300 | slot_dma_write(space, (offset&0xfff) + 0xe000, data); |
| 301 | } |
| 302 | else if (offset <= 0xdfff) |
| 303 | { |
| 304 | slot_dma_write(space, (offset&0xfff) + 0xf000, data); |
| 305 | } |
| 306 | else if (offset <= 0xefff) |
| 307 | { |
| 308 | slot_dma_write(space, (offset&0xfff) + 0xc000, data); |
| 309 | } |
| 310 | else // 6809 Fxxx -> 6502 ZP |
| 311 | { |
| 312 | slot_dma_write(space, offset&0xfff, data); |
| 313 | } |
| 314 | } |
| 315 | else |
| 316 | { |
| 317 | if (m_flipAddrSpace) |
| 318 | { |
| 319 | slot_dma_write(space, offset^0x8000, data); |
| 320 | } |
| 325 | 321 | else |
| 326 | 322 | { |
| 327 | | if (m_flipAddrSpace) |
| 328 | | { |
| 329 | | m_6502space->write_byte(offset^0x8000, data); |
| 330 | | } |
| 331 | | else |
| 332 | | { |
| 333 | | m_6502space->write_byte(offset, data); |
| 334 | | } |
| 323 | slot_dma_write(space, offset, data); |
| 335 | 324 | } |
| 336 | 325 | } |
| 337 | 326 | } |