trunk/src/mess/machine/ti99/gromport.c
r25468 | r25469 | |
113 | 113 | #define VERBOSE 1 |
114 | 114 | #define LOG logerror |
115 | 115 | |
116 | | #define GROM_AREA 0x9800 |
117 | | #define GROM_MASK 0xf800 |
118 | | |
119 | 116 | #define GROM3_TAG "grom3" |
120 | 117 | #define GROM4_TAG "grom4" |
121 | 118 | #define GROM5_TAG "grom5" |
r25468 | r25469 | |
175 | 172 | m_reset_on_insert = (ioport("CARTRESET")->read()==0x01); |
176 | 173 | } |
177 | 174 | |
| 175 | void gromport_device::set_grom_base(UINT16 grombase, UINT16 grommask) |
| 176 | { |
| 177 | m_grombase = grombase; |
| 178 | m_grommask = grommask; |
| 179 | } |
| 180 | |
178 | 181 | /* |
179 | 182 | Shall we reset the console when a cartridge has been inserted? |
180 | 183 | This is triggered by the cartridge by pulling down /RESET via a capacitor. |
r25468 | r25469 | |
191 | 194 | } |
192 | 195 | } |
193 | 196 | |
194 | | |
195 | 197 | void gromport_device::device_config_complete() |
196 | 198 | { |
197 | 199 | const gromport_config *intf = reinterpret_cast<const gromport_config *>(static_config()); |
198 | 200 | m_console_ready.resolve(intf->ready, *this); |
199 | 201 | m_console_reset.resolve(intf->reset, *this); |
200 | 202 | m_connector = static_cast<ti99_cartridge_connector_device*>(first_subdevice()); |
| 203 | set_grom_base(0x9800, 0xf800); |
201 | 204 | } |
202 | 205 | |
203 | 206 | SLOT_INTERFACE_START( gromport ) |
r25468 | r25469 | |
247 | 250 | m_gromport->ready_line(state); |
248 | 251 | } |
249 | 252 | |
| 253 | void ti99_cartridge_connector_device::device_config_complete() |
| 254 | { |
| 255 | m_gromport = static_cast<gromport_device*>(owner()); |
| 256 | } |
| 257 | |
| 258 | UINT16 ti99_cartridge_connector_device::grom_base() |
| 259 | { |
| 260 | return m_gromport->get_grom_base(); |
| 261 | } |
| 262 | |
| 263 | UINT16 ti99_cartridge_connector_device::grom_mask() |
| 264 | { |
| 265 | return m_gromport->get_grom_mask(); |
| 266 | } |
| 267 | |
250 | 268 | single_conn_device::single_conn_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
251 | 269 | : ti99_cartridge_connector_device(mconfig, GROMPORT_SINGLE, "Standard cartridge connector", tag, owner, clock, "single", __FILE__), |
252 | 270 | m_cartridge(NULL) |
r25468 | r25469 | |
277 | 295 | m_cartridge->cruwrite(offset, data); |
278 | 296 | } |
279 | 297 | |
| 298 | void single_conn_device::device_start() |
| 299 | { |
| 300 | m_cartridge = static_cast<ti99_cartridge_device*>(first_subdevice()); |
| 301 | } |
| 302 | |
280 | 303 | void single_conn_device::device_reset() |
281 | 304 | { |
282 | 305 | m_cartridge->set_slot(0); |
r25468 | r25469 | |
291 | 314 | return MACHINE_CONFIG_NAME( single_slot ); |
292 | 315 | } |
293 | 316 | |
294 | | void single_conn_device::device_config_complete() |
295 | | { |
296 | | m_cartridge = static_cast<ti99_cartridge_device*>(first_subdevice()); |
297 | | m_gromport = static_cast<gromport_device*>(owner()); |
298 | | } |
299 | | |
300 | 317 | /********************************************************/ |
301 | 318 | |
302 | 319 | /* |
r25468 | r25469 | |
403 | 420 | int slot; |
404 | 421 | if (changebase) |
405 | 422 | { |
406 | | if ((offset & GROM_MASK) == GROM_AREA) |
| 423 | if ((offset & grom_mask()) == grom_base()) |
407 | 424 | { |
408 | 425 | set_slot((offset>>2) & 0x00ff); |
409 | 426 | } |
r25468 | r25469 | |
432 | 449 | // If we have a GROM access, we need to send the read request to all |
433 | 450 | // attached cartridges so the slot is irrelevant here. Each GROM |
434 | 451 | // contains an internal address counter, and we must make sure they all stay in sync. |
435 | | if ((offset & GROM_MASK) == GROM_AREA) |
| 452 | if ((offset & grom_mask()) == grom_base()) |
436 | 453 | { |
437 | 454 | for (int i=0; i < NUMBER_OF_CARTRIDGE_SLOTS; i++) |
438 | 455 | { |
r25468 | r25469 | |
462 | 479 | |
463 | 480 | // Same issue as above (read) |
464 | 481 | // We don't have GRAM cartridges, anyway, so it's just used for setting the address. |
465 | | if ((offset & GROM_MASK) == GROM_AREA) |
| 482 | if ((offset & grom_mask()) == grom_base()) |
466 | 483 | { |
467 | 484 | for (int i=0; i < NUMBER_OF_CARTRIDGE_SLOTS; i++) |
468 | 485 | { |
r25468 | r25469 | |
517 | 534 | { |
518 | 535 | m_cartridge[i] = NULL; |
519 | 536 | } |
520 | | m_gromport = static_cast<gromport_device*>(owner()); |
521 | 537 | } |
522 | 538 | |
523 | 539 | void multi_conn_device::device_reset(void) |
r25468 | r25469 | |
682 | 698 | |
683 | 699 | READ8Z_MEMBER(gkracker_device::readz) |
684 | 700 | { |
685 | | if ((offset & GROM_MASK) == GROM_AREA) |
| 701 | if ((offset & grom_mask()) == grom_base()) |
686 | 702 | { |
687 | 703 | // Reads from the GRAM space of the GRAM Kracker. |
688 | 704 | |
r25468 | r25469 | |
792 | 808 | m_cartridge->write(space, offset, data, mem_mask); |
793 | 809 | } |
794 | 810 | |
795 | | if ((offset & GROM_MASK) == GROM_AREA) |
| 811 | if ((offset & grom_mask()) == grom_base()) |
796 | 812 | { |
797 | 813 | // Write to the GRAM space of the GRAM Kracker. |
798 | 814 | if ((offset & 0x0002)==0x0002) |
r25468 | r25469 | |
973 | 989 | m_grom_ptr = memregion(GKRACKER_ROM_TAG)->base(); |
974 | 990 | m_cartridge = NULL; |
975 | 991 | for (int i=1; i < 6; i++) m_gk_switch[i] = 0; |
976 | | m_gromport = static_cast<gromport_device*>(owner()); |
977 | 992 | } |
978 | 993 | |
979 | 994 | void gkracker_device::device_reset() |
r25468 | r25469 | |
1197 | 1212 | return m_pcb->m_grom_size>0; |
1198 | 1213 | } |
1199 | 1214 | |
| 1215 | UINT16 ti99_cartridge_device::grom_base() |
| 1216 | { |
| 1217 | return m_connector->grom_base(); |
| 1218 | } |
| 1219 | |
| 1220 | UINT16 ti99_cartridge_device::grom_mask() |
| 1221 | { |
| 1222 | return m_connector->grom_mask(); |
| 1223 | } |
| 1224 | |
1200 | 1225 | bool ti99_cartridge_device::call_load() |
1201 | 1226 | { |
1202 | 1227 | // File name is in m_basename |
r25468 | r25469 | |
1273 | 1298 | } |
1274 | 1299 | |
1275 | 1300 | prepare_cartridge(); |
| 1301 | m_pcb->set_cartridge(this); |
1276 | 1302 | m_slot = get_index_from_tagname(); |
1277 | 1303 | m_connector->insert(m_slot, this); |
1278 | 1304 | return false; |
r25468 | r25469 | |
1406 | 1432 | { |
1407 | 1433 | } |
1408 | 1434 | |
| 1435 | UINT16 ti99_cartridge_pcb::grom_base() |
| 1436 | { |
| 1437 | return m_cart->grom_base(); |
| 1438 | } |
| 1439 | |
| 1440 | UINT16 ti99_cartridge_pcb::grom_mask() |
| 1441 | { |
| 1442 | return m_cart->grom_mask(); |
| 1443 | } |
| 1444 | |
| 1445 | void ti99_cartridge_pcb::set_cartridge(ti99_cartridge_device *cart) |
| 1446 | { |
| 1447 | m_cart = cart; |
| 1448 | } |
| 1449 | |
1409 | 1450 | READ8Z_MEMBER(ti99_cartridge_pcb::gromreadz) |
1410 | 1451 | { |
1411 | 1452 | for (int i=0; i < 5; i++) |
r25468 | r25469 | |
1430 | 1471 | |
1431 | 1472 | READ8Z_MEMBER(ti99_cartridge_pcb::readz) |
1432 | 1473 | { |
1433 | | if ((offset & GROM_MASK)==GROM_AREA) |
| 1474 | if ((offset & grom_mask())==grom_base()) |
1434 | 1475 | gromreadz(space, offset, value, mem_mask); |
1435 | 1476 | else |
1436 | 1477 | { |
r25468 | r25469 | |
1447 | 1488 | WRITE8_MEMBER(ti99_cartridge_pcb::write) |
1448 | 1489 | { |
1449 | 1490 | // LOG("write standard\n"); |
1450 | | if ((offset & GROM_MASK)==GROM_AREA) |
| 1491 | if ((offset & grom_mask())==grom_base()) |
1451 | 1492 | gromwrite(space, offset, data, mem_mask); |
1452 | 1493 | else |
1453 | 1494 | { |
r25468 | r25469 | |
1479 | 1520 | |
1480 | 1521 | READ8Z_MEMBER(ti99_paged_cartridge::readz) |
1481 | 1522 | { |
1482 | | if ((offset & GROM_MASK)==GROM_AREA) |
| 1523 | if ((offset & grom_mask())==grom_base()) |
1483 | 1524 | gromreadz(space, offset, value, mem_mask); |
1484 | 1525 | else |
1485 | 1526 | { |
r25468 | r25469 | |
1497 | 1538 | WRITE8_MEMBER(ti99_paged_cartridge::write) |
1498 | 1539 | { |
1499 | 1540 | // LOG("write standard\n"); |
1500 | | if ((offset & GROM_MASK)==GROM_AREA) |
| 1541 | if ((offset & grom_mask())==grom_base()) |
1501 | 1542 | gromwrite(space, offset, data, mem_mask); |
1502 | 1543 | |
1503 | 1544 | else { |
r25468 | r25469 | |
1515 | 1556 | /* Read function for the minimem cartridge. */ |
1516 | 1557 | READ8Z_MEMBER(ti99_minimem_cartridge::readz) |
1517 | 1558 | { |
1518 | | if ((offset & GROM_MASK)==GROM_AREA) |
| 1559 | if ((offset & grom_mask())==grom_base()) |
1519 | 1560 | gromreadz(space, offset, value, mem_mask); |
1520 | 1561 | |
1521 | 1562 | else |
r25468 | r25469 | |
1538 | 1579 | WRITE8_MEMBER(ti99_minimem_cartridge::write) |
1539 | 1580 | { |
1540 | 1581 | // LOG("write standard\n"); |
1541 | | if ((offset & GROM_MASK)==GROM_AREA) |
| 1582 | if ((offset & grom_mask())==grom_base()) |
1542 | 1583 | gromwrite(space, offset, data, mem_mask); |
1543 | 1584 | |
1544 | 1585 | else |
r25468 | r25469 | |
1573 | 1614 | /* Read function for the super cartridge. */ |
1574 | 1615 | READ8Z_MEMBER(ti99_super_cartridge::readz) |
1575 | 1616 | { |
1576 | | if ((offset & GROM_MASK)==GROM_AREA) |
| 1617 | if ((offset & grom_mask())==grom_base()) |
1577 | 1618 | gromreadz(space, offset, value, mem_mask); |
1578 | 1619 | else |
1579 | 1620 | { |
r25468 | r25469 | |
1587 | 1628 | /* Write function for the super cartridge. */ |
1588 | 1629 | WRITE8_MEMBER(ti99_super_cartridge::write) |
1589 | 1630 | { |
1590 | | if ((offset & GROM_MASK)==GROM_AREA) |
| 1631 | if ((offset & grom_mask())==grom_base()) |
1591 | 1632 | gromwrite(space, offset, data, mem_mask); |
1592 | 1633 | else |
1593 | 1634 | { |
r25468 | r25469 | |
1658 | 1699 | /* Read function for the mbx cartridge. */ |
1659 | 1700 | READ8Z_MEMBER(ti99_mbx_cartridge::readz) |
1660 | 1701 | { |
1661 | | if ((offset & GROM_MASK)==GROM_AREA) |
| 1702 | if ((offset & grom_mask())==grom_base()) |
1662 | 1703 | gromreadz(space, offset, value, mem_mask); |
1663 | 1704 | else |
1664 | 1705 | { |
r25468 | r25469 | |
1681 | 1722 | /* Write function for the mbx cartridge. */ |
1682 | 1723 | WRITE8_MEMBER(ti99_mbx_cartridge::write) |
1683 | 1724 | { |
1684 | | if ((offset & GROM_MASK)==GROM_AREA) |
| 1725 | if ((offset & grom_mask())==grom_base()) |
1685 | 1726 | gromwrite(space, offset, data, mem_mask); |
1686 | 1727 | else |
1687 | 1728 | { |
r25468 | r25469 | |
1871 | 1912 | |
1872 | 1913 | READ8Z_MEMBER(ti99_gromemu_cartridge::readz) |
1873 | 1914 | { |
1874 | | if ((offset & GROM_MASK)==GROM_AREA) |
| 1915 | if ((offset & grom_mask())==grom_base()) |
1875 | 1916 | gromemureadz(space, offset, value, mem_mask); |
1876 | 1917 | else |
1877 | 1918 | { |
r25468 | r25469 | |
1900 | 1941 | WRITE8_MEMBER(ti99_gromemu_cartridge::write) |
1901 | 1942 | { |
1902 | 1943 | // LOG("write standard\n"); |
1903 | | if ((offset & GROM_MASK)==GROM_AREA) |
| 1944 | if ((offset & grom_mask())==grom_base()) |
1904 | 1945 | gromemuwrite(space, offset, data, mem_mask); |
1905 | 1946 | |
1906 | 1947 | else { |
trunk/src/mess/machine/ti99/gromport.h
r25468 | r25469 | |
37 | 37 | DECLARE_WRITE_LINE_MEMBER(ready_line); |
38 | 38 | |
39 | 39 | void cartridge_inserted(); |
| 40 | void set_grom_base(UINT16 grombase, UINT16 grommask); |
| 41 | UINT16 get_grom_base() { return m_grombase; } |
| 42 | UINT16 get_grom_mask() { return m_grommask; } |
40 | 43 | |
41 | 44 | protected: |
42 | 45 | virtual void device_start(); |
r25468 | r25469 | |
49 | 52 | bool m_reset_on_insert; |
50 | 53 | devcb_resolved_write_line m_console_reset; |
51 | 54 | devcb_resolved_write_line m_console_ready; |
| 55 | UINT16 m_grombase; |
| 56 | UINT16 m_grommask; |
52 | 57 | }; |
53 | 58 | |
54 | 59 | SLOT_INTERFACE_EXTERN(gromport); |
r25468 | r25469 | |
72 | 77 | DECLARE_WRITE8_MEMBER(write); |
73 | 78 | void crureadz(offs_t offset, UINT8 *value); |
74 | 79 | void cruwrite(offs_t offset, UINT8 data); |
| 80 | |
75 | 81 | void ready_line(int state); |
76 | 82 | bool is_available() { return m_pcb != NULL; } |
77 | 83 | bool has_grom(); |
78 | 84 | void set_slot(int i); |
| 85 | UINT16 grom_base(); |
| 86 | UINT16 grom_mask(); |
79 | 87 | |
80 | 88 | protected: |
81 | 89 | virtual void device_start() { }; |
r25468 | r25469 | |
126 | 134 | virtual DECLARE_WRITE8_MEMBER(write) =0; |
127 | 135 | virtual void crureadz(offs_t offset, UINT8 *value) =0; |
128 | 136 | virtual void cruwrite(offs_t offset, UINT8 data) =0; |
| 137 | |
129 | 138 | void ready_line(int state); |
130 | 139 | |
131 | 140 | virtual void insert(int index, ti99_cartridge_device* cart) { m_gromport->cartridge_inserted(); }; |
132 | 141 | virtual void remove(int index) { }; |
| 142 | UINT16 grom_base(); |
| 143 | UINT16 grom_mask(); |
133 | 144 | |
134 | 145 | protected: |
135 | 146 | ti99_cartridge_connector_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); |
| 147 | virtual void device_config_complete(); |
| 148 | |
136 | 149 | gromport_device* m_gromport; |
137 | 150 | }; |
138 | 151 | |
r25468 | r25469 | |
150 | 163 | void cruwrite(offs_t offset, UINT8 data); |
151 | 164 | |
152 | 165 | protected: |
153 | | virtual void device_start() { }; |
| 166 | virtual void device_start(); |
154 | 167 | virtual void device_reset(); |
155 | 168 | virtual machine_config_constructor device_mconfig_additions() const; |
156 | | virtual void device_config_complete(); |
157 | 169 | |
158 | 170 | private: |
159 | 171 | ti99_cartridge_device *m_cartridge; |
r25468 | r25469 | |
266 | 278 | DECLARE_READ8Z_MEMBER(gromreadz); |
267 | 279 | DECLARE_WRITE8_MEMBER(gromwrite); |
268 | 280 | inline void set_grom_pointer(int number, device_t *dev); |
| 281 | void set_cartridge(ti99_cartridge_device *cart); |
| 282 | UINT16 grom_base(); |
| 283 | UINT16 grom_mask(); |
269 | 284 | |
| 285 | ti99_cartridge_device* m_cart; |
270 | 286 | ti99_grom_device* m_grom[5]; |
271 | 287 | int m_grom_size; |
272 | 288 | int m_rom_size; |