trunk/src/mess/drivers/snes.c
| r21683 | r21684 | |
| 1513 | 1513 | { |
| 1514 | 1514 | if (address < 0x2000) |
| 1515 | 1515 | return space.read_byte(0x7e0000 + address); |
| 1516 | | if (address >= 0x2000 && address < 0x6000) |
| 1516 | else if (address < 0x6000) |
| 1517 | 1517 | return snes_r_io(space, address); |
| 1518 | | if (address >= 0x6000 && address < 0x8000) |
| 1518 | else if (address < 0x8000) |
| 1519 | 1519 | return snes_open_bus_r(space, 0); |
| 1520 | | if (address >= 0x8000) |
| 1520 | else |
| 1521 | 1521 | return m_slotcart->m_cart->read_h(space, offset); |
| 1522 | 1522 | } |
| 1523 | 1523 | else if (offset < 0x700000) |
| r21683 | r21684 | |
| 1527 | 1527 | else |
| 1528 | 1528 | return m_slotcart->m_cart->read_h(space, offset); |
| 1529 | 1529 | } |
| 1530 | else |
| 1531 | { |
| 1532 | if (m_type == SNES_SUFAMITURBO && address >= 0x8000 && offset < 0x740000) |
| 1533 | return m_slotcart->m_cart->read_h(space, offset); |
| 1530 | 1534 | |
| 1531 | | // ROM & NVRAM access |
| 1532 | | return m_slotcart->m_cart->read_h(space, offset); |
| 1535 | // here usually there is SRAM mirrored in the whole range, but if ROM is very large then arrives here too (see tokimeki and wizardg4) |
| 1536 | if (m_slotcart->m_cart->get_rom_size() > 0x200000 && address >= 0x8000) |
| 1537 | return m_slotcart->m_cart->read_h(space, offset); |
| 1538 | else |
| 1539 | { |
| 1540 | if (m_slotcart->m_cart->get_nvram_size() > 0x8000) |
| 1541 | { |
| 1542 | // In this case, SRAM is mapped in 0x8000 chunks at diff offsets: 0x700000-0x707fff, 0x710000-0x717fff, etc. |
| 1543 | offset = ((offset - 0x700000) / 0x10000) * 0x8000 + (offset & 0x7fff); |
| 1544 | return m_slotcart->m_cart->read_ram(space, offset); |
| 1545 | } |
| 1546 | else if (m_slotcart->m_cart->get_nvram_size() > 0) |
| 1547 | return m_slotcart->m_cart->read_ram(space, offset); |
| 1548 | else |
| 1549 | return snes_open_bus_r(space, 0); |
| 1550 | } |
| 1551 | } |
| 1533 | 1552 | } |
| 1534 | 1553 | |
| 1535 | 1554 | WRITE8_MEMBER( snsnew_state::snes20_hi_w ) |
| 1536 | 1555 | { |
| 1537 | 1556 | UINT16 address = offset & 0xffff; |
| 1557 | |
| 1558 | if (m_type == SNES_SUFAMITURBO && address >= 0x8000 && ((offset >= 0x600000 && offset < 0x640000) || (offset >= 0x700000 && offset < 0x740000))) |
| 1559 | { m_slotcart->m_cart->write_h(space, offset, data); return; } |
| 1560 | |
| 1538 | 1561 | if (offset < 0x400000) |
| 1539 | 1562 | { |
| 1540 | 1563 | if (address < 0x2000) |
| 1541 | 1564 | space.write_byte(0x7e0000 + address, data); |
| 1542 | | if (address >= 0x2000 && address < 0x6000) |
| 1565 | else if (address < 0x6000) |
| 1543 | 1566 | snes_w_io(space, address, data); |
| 1544 | 1567 | } |
| 1545 | | else if (offset >= 0x700000) // NVRAM access |
| 1568 | else if (offset >= 0x700000 && (m_slotcart->m_cart->get_rom_size() <= 0x200000 || address < 0x8000)) // NVRAM access |
| 1546 | 1569 | { |
| 1547 | | m_slotcart->m_cart->write_h(space, offset, data); |
| 1570 | if (m_slotcart->m_cart->get_nvram_size() > 0x8000) |
| 1571 | { |
| 1572 | // In this case, SRAM is mapped in 0x8000 chunks at diff offsets: 0x700000-0x707fff, 0x710000-0x717fff, etc. |
| 1573 | offset = ((offset - 0x700000) / 0x10000) * 0x8000 + (offset & 0x7fff); |
| 1574 | m_slotcart->m_cart->write_ram(space, offset, data); |
| 1575 | } |
| 1576 | else if (m_slotcart->m_cart->get_nvram_size() > 0) |
| 1577 | m_slotcart->m_cart->write_ram(space, offset, data); |
| 1548 | 1578 | } |
| 1549 | 1579 | } |
| 1550 | 1580 | |
| r21683 | r21684 | |
| 1556 | 1586 | { |
| 1557 | 1587 | if (address < 0x2000) |
| 1558 | 1588 | return space.read_byte(0x7e0000 + address); |
| 1559 | | if (address >= 0x2000 && address < 0x6000) |
| 1589 | else if (address < 0x6000) |
| 1560 | 1590 | return snes_r_io(space, address); |
| 1561 | | if (address >= 0x6000 && address < 0x8000) |
| 1591 | else if (address < 0x8000) |
| 1562 | 1592 | return snes_open_bus_r(space, 0); |
| 1563 | | if (address >= 0x8000) |
| 1593 | else |
| 1564 | 1594 | return m_slotcart->m_cart->read_l(space, offset); |
| 1565 | 1595 | } |
| 1566 | 1596 | else if (offset < 0x700000) |
| r21683 | r21684 | |
| 1570 | 1600 | else |
| 1571 | 1601 | return m_slotcart->m_cart->read_l(space, offset); |
| 1572 | 1602 | } |
| 1573 | | |
| 1574 | | // ROM & NVRAM access |
| 1575 | | return m_slotcart->m_cart->read_l(space, offset); |
| 1603 | else |
| 1604 | { |
| 1605 | if (m_type == SNES_SUFAMITURBO && address >= 0x8000 && offset < 0x740000) |
| 1606 | return m_slotcart->m_cart->read_l(space, offset); |
| 1607 | |
| 1608 | // here usually there is SRAM mirrored in the whole range, but if ROM is very large then arrives here too (see tokimeki and wizardg4) |
| 1609 | if (m_slotcart->m_cart->get_rom_size() > 0x200000 && address >= 0x8000) |
| 1610 | return m_slotcart->m_cart->read_l(space, offset); |
| 1611 | else |
| 1612 | { |
| 1613 | if (m_slotcart->m_cart->get_nvram_size() > 0x8000) |
| 1614 | { |
| 1615 | // In this case, SRAM is mapped in 0x8000 chunks at diff offsets: 0x700000-0x707fff, 0x710000-0x717fff, etc. |
| 1616 | offset = ((offset - 0x700000) / 0x10000) * 0x8000 + (offset & 0x7fff); |
| 1617 | return m_slotcart->m_cart->read_ram(space, offset); |
| 1618 | } |
| 1619 | else if (m_slotcart->m_cart->get_nvram_size() > 0) |
| 1620 | return m_slotcart->m_cart->read_ram(space, offset); |
| 1621 | else |
| 1622 | return snes_open_bus_r(space, 0); |
| 1623 | } |
| 1624 | } |
| 1576 | 1625 | } |
| 1577 | 1626 | |
| 1578 | 1627 | WRITE8_MEMBER( snsnew_state::snes20_lo_w ) |
| 1579 | 1628 | { |
| 1629 | if (m_type == SNES_SUFAMITURBO && (offset & 0xffff) >= 0x8000 && ((offset >= 0x600000 && offset < 0x640000) || (offset >= 0x700000 && offset < 0x740000))) |
| 1630 | { m_slotcart->m_cart->write_l(space, offset, data); return; } |
| 1631 | |
| 1580 | 1632 | snes20_hi_w(space, offset, data, 0xff); |
| 1581 | 1633 | } |
| 1582 | 1634 | |
| r21683 | r21684 | |
| 1587 | 1639 | { |
| 1588 | 1640 | UINT16 address = offset & 0xffff; |
| 1589 | 1641 | |
| 1590 | | if (offset < 0x400000) |
| 1642 | if (offset < 0x400000 && address < 0x8000) |
| 1591 | 1643 | { |
| 1592 | 1644 | if (address < 0x2000) |
| 1593 | 1645 | return space.read_byte(0x7e0000 + address); |
| 1594 | | if (address >= 0x2000 && address < 0x6000) |
| 1646 | else if (address < 0x6000) |
| 1595 | 1647 | return snes_r_io(space, address); |
| 1596 | | if (address >= 0x6000 && address < 0x8000) |
| 1648 | else if (address < 0x8000) |
| 1597 | 1649 | { |
| 1598 | | if (m_slotcart->m_cart->get_nvram_size()) |
| 1650 | if (m_type == SNES_BSXHI && m_slotcart->m_cart->get_nvram_size() && offset >= 0x200000) |
| 1599 | 1651 | { |
| 1600 | | // read NVRAM, instead |
| 1601 | | if (offset >= 0x300000) |
| 1602 | | return m_slotcart->m_cart->read_l(space, offset); |
| 1652 | int mask = (m_slotcart->m_cart->get_nvram_size() - 1) & 0x7fff; |
| 1653 | return m_slotcart->m_cart->read_ram(space, (offset - 0x6000) & mask); |
| 1603 | 1654 | } |
| 1604 | | return snes_open_bus_r(space, 0); |
| 1655 | |
| 1656 | if (m_slotcart->m_cart->get_nvram_size() && offset >= 0x300000) |
| 1657 | { |
| 1658 | /* Donkey Kong Country checks this and detects a copier if 0x800 is not masked out due to sram size */ |
| 1659 | /* OTOH Secret of Mana does not work properly if sram is not mirrored on later banks */ |
| 1660 | int mask = (m_slotcart->m_cart->get_nvram_size() - 1) & 0x7fff; /* Limit SRAM size to what's actually present */ |
| 1661 | return m_slotcart->m_cart->read_ram(space, (offset - 0x6000) & mask); |
| 1662 | } |
| 1663 | else |
| 1664 | return snes_open_bus_r(space, 0); |
| 1605 | 1665 | } |
| 1606 | | if (address >= 0x8000) |
| 1607 | | return m_slotcart->m_cart->read_l(space, offset); |
| 1608 | 1666 | } |
| 1609 | 1667 | |
| 1610 | | // ROM & NVRAM access |
| 1668 | // ROM access |
| 1611 | 1669 | return m_slotcart->m_cart->read_l(space, offset); |
| 1612 | 1670 | } |
| 1613 | 1671 | |
| 1614 | 1672 | WRITE8_MEMBER( snsnew_state::snes21_lo_w ) |
| 1615 | 1673 | { |
| 1616 | 1674 | UINT16 address = offset & 0xffff; |
| 1617 | | if (offset < 0x400000) |
| 1675 | if (offset < 0x400000 && address < 0x8000) |
| 1618 | 1676 | { |
| 1619 | 1677 | if (address < 0x2000) |
| 1620 | 1678 | space.write_byte(0x7e0000 + address, data); |
| 1621 | | if (address >= 0x2000 && address < 0x6000) |
| 1679 | else if (address < 0x6000) |
| 1622 | 1680 | snes_w_io(space, address, data); |
| 1623 | | if (address >= 0x6000 && address < 0x8000) |
| 1681 | else if (address < 0x8000) |
| 1624 | 1682 | { |
| 1625 | | if (m_slotcart->m_cart->get_nvram_size()) |
| 1683 | if (m_type == SNES_BSXHI && m_slotcart->m_cart->get_nvram_size() && offset >= 0x200000) |
| 1626 | 1684 | { |
| 1627 | | // write to NVRAM, in this case |
| 1628 | | if (offset >= 0x300000) |
| 1629 | | m_slotcart->m_cart->write_l(space, offset, data); |
| 1685 | int mask = (m_slotcart->m_cart->get_nvram_size() - 1) & 0x7fff; |
| 1686 | m_slotcart->m_cart->write_ram(space, (offset - 0x6000) & mask, data); |
| 1687 | return; |
| 1630 | 1688 | } |
| 1689 | if (m_slotcart->m_cart->get_nvram_size() && offset >= 0x300000) |
| 1690 | { |
| 1691 | /* Donkey Kong Country checks this and detects a copier if 0x800 is not masked out due to sram size */ |
| 1692 | /* OTOH Secret of Mana does not work properly if sram is not mirrored on later banks */ |
| 1693 | int mask = (m_slotcart->m_cart->get_nvram_size() - 1) & 0x7fff; /* Limit SRAM size to what's actually present */ |
| 1694 | m_slotcart->m_cart->write_ram(space, (offset - 0x6000) & mask, data); |
| 1695 | } |
| 1631 | 1696 | } |
| 1632 | 1697 | } |
| 1633 | | else if (offset >= 0x700000) // NVRAM access |
| 1634 | | m_slotcart->m_cart->write_l(space, offset, data); |
| 1635 | 1698 | } |
| 1636 | 1699 | |
| 1637 | 1700 | READ8_MEMBER( snsnew_state::snes21_hi_r ) |
| 1638 | 1701 | { |
| 1639 | 1702 | UINT16 address = offset & 0xffff; |
| 1640 | 1703 | |
| 1641 | | if (offset < 0x400000) |
| 1704 | if (offset < 0x400000 && address < 0x8000) |
| 1642 | 1705 | { |
| 1643 | 1706 | if (address < 0x2000) |
| 1644 | 1707 | return space.read_byte(0x7e0000 + address); |
| 1645 | | if (address >= 0x2000 && address < 0x6000) |
| 1708 | else if (address < 0x6000) |
| 1646 | 1709 | return snes_r_io(space, address); |
| 1647 | | if (address >= 0x6000 && address < 0x8000) |
| 1710 | else if (address < 0x8000) |
| 1648 | 1711 | { |
| 1649 | | if (m_slotcart->m_cart->get_nvram_size()) |
| 1712 | if (m_type == SNES_BSXHI && m_slotcart->m_cart->get_nvram_size() && offset >= 0x200000) |
| 1650 | 1713 | { |
| 1651 | | // read NVRAM, instead |
| 1652 | | if (offset >= 0x300000) |
| 1653 | | return m_slotcart->m_cart->read_h(space, offset); |
| 1714 | int mask = (m_slotcart->m_cart->get_nvram_size() - 1) & 0x7fff; |
| 1715 | return m_slotcart->m_cart->read_ram(space, (offset - 0x6000) & mask); |
| 1654 | 1716 | } |
| 1655 | | return snes_open_bus_r(space, 0); |
| 1717 | |
| 1718 | if (m_slotcart->m_cart->get_nvram_size() && offset >= 0x300000) |
| 1719 | { |
| 1720 | /* Donkey Kong Country checks this and detects a copier if 0x800 is not masked out due to sram size */ |
| 1721 | /* OTOH Secret of Mana does not work properly if sram is not mirrored on later banks */ |
| 1722 | int mask = (m_slotcart->m_cart->get_nvram_size() - 1) & 0x7fff; /* Limit SRAM size to what's actually present */ |
| 1723 | return m_slotcart->m_cart->read_ram(space, (offset - 0x6000) & mask); |
| 1724 | } |
| 1725 | else |
| 1726 | return snes_open_bus_r(space, 0); |
| 1656 | 1727 | } |
| 1657 | | if (address >= 0x8000) |
| 1658 | | return m_slotcart->m_cart->read_h(space, offset); |
| 1659 | 1728 | } |
| 1660 | 1729 | |
| 1661 | | // ROM & NVRAM access |
| 1730 | // ROM access |
| 1662 | 1731 | return m_slotcart->m_cart->read_h(space, offset); |
| 1663 | 1732 | } |
| 1664 | 1733 | |
| 1665 | 1734 | WRITE8_MEMBER( snsnew_state::snes21_hi_w ) |
| 1666 | 1735 | { |
| 1667 | 1736 | UINT16 address = offset & 0xffff; |
| 1668 | | if (offset < 0x400000) |
| 1737 | if (offset < 0x400000 && address < 0x8000) |
| 1669 | 1738 | { |
| 1670 | 1739 | if (address < 0x2000) |
| 1671 | 1740 | space.write_byte(0x7e0000 + address, data); |
| 1672 | | if (address >= 0x2000 && address < 0x6000) |
| 1741 | else if (address < 0x6000) |
| 1673 | 1742 | snes_w_io(space, address, data); |
| 1674 | | if (address >= 0x6000 && address < 0x8000) |
| 1743 | else if (address < 0x8000) |
| 1675 | 1744 | { |
| 1676 | | if (m_slotcart->m_cart->get_nvram_size()) |
| 1745 | if (m_type == SNES_BSXHI && m_slotcart->m_cart->get_nvram_size() && offset >= 0x200000) |
| 1677 | 1746 | { |
| 1678 | | // write to NVRAM, in this case |
| 1679 | | if (offset >= 0x300000) |
| 1680 | | m_slotcart->m_cart->write_h(space, offset, data); |
| 1747 | int mask = (m_slotcart->m_cart->get_nvram_size() - 1) & 0x7fff; |
| 1748 | m_slotcart->m_cart->write_ram(space, (offset - 0x6000) & mask, data); |
| 1749 | return; |
| 1681 | 1750 | } |
| 1751 | if (m_slotcart->m_cart->get_nvram_size() && offset >= 0x300000) |
| 1752 | { |
| 1753 | /* Donkey Kong Country checks this and detects a copier if 0x800 is not masked out due to sram size */ |
| 1754 | /* OTOH Secret of Mana does not work properly if sram is not mirrored on later banks */ |
| 1755 | int mask = (m_slotcart->m_cart->get_nvram_size() - 1) & 0x7fff; /* Limit SRAM size to what's actually present */ |
| 1756 | m_slotcart->m_cart->write_ram(space, (offset - 0x6000) & mask, data); |
| 1757 | } |
| 1682 | 1758 | } |
| 1683 | 1759 | } |
| 1684 | | else if (offset >= 0x700000) // NVRAM access |
| 1685 | | m_slotcart->m_cart->write_h(space, offset, data); |
| 1686 | 1760 | } |
| 1687 | 1761 | |
| 1688 | 1762 | // SuperFX / GSU |
| r21683 | r21684 | |
| 1695 | 1769 | { |
| 1696 | 1770 | if (address < 0x2000) |
| 1697 | 1771 | return space.read_byte(0x7e0000 + address); |
| 1698 | | if (address >= 0x2000 && address < 0x6000) |
| 1772 | else if (address < 0x6000) |
| 1699 | 1773 | { |
| 1700 | 1774 | if (address >= 0x3000 && address < 0x3300) |
| 1701 | 1775 | return m_slotcart->m_cart->chip_read(space, offset); |
| 1702 | 1776 | else |
| 1703 | 1777 | return snes_r_io(space, address); |
| 1704 | 1778 | } |
| 1705 | | if (address >= 0x6000 && address < 0x8000) |
| 1706 | | { |
| 1707 | | return m_slotcart->m_cart->read_h(space, offset); //RAM |
| 1708 | | } |
| 1709 | | if (address >= 0x8000) |
| 1710 | | return m_slotcart->m_cart->read_h(space, offset); //ROM |
| 1779 | else if (address < 0x8000) |
| 1780 | return m_slotcart->m_cart->read_ram(space, offset & 0x1fff); |
| 1781 | else |
| 1782 | return m_slotcart->m_cart->read_h(space, offset); |
| 1711 | 1783 | } |
| 1712 | 1784 | else if (offset < 0x600000) |
| 1713 | | return m_slotcart->m_cart->read_h(space, offset); //ROM |
| 1714 | | |
| 1715 | | return m_slotcart->m_cart->read_h(space, offset); //RAM |
| 1785 | return m_slotcart->m_cart->read_h(space, offset); |
| 1786 | else |
| 1787 | return m_slotcart->m_cart->read_ram(space, offset); |
| 1716 | 1788 | } |
| 1717 | 1789 | |
| 1718 | 1790 | READ8_MEMBER( snsnew_state::snesfx_lo_r ) |
| r21683 | r21684 | |
| 1723 | 1795 | { |
| 1724 | 1796 | if (address < 0x2000) |
| 1725 | 1797 | return space.read_byte(0x7e0000 + address); |
| 1726 | | if (address >= 0x2000 && address < 0x6000) |
| 1798 | else if (address < 0x6000) |
| 1727 | 1799 | { |
| 1728 | 1800 | if (address >= 0x3000 && address < 0x3300) |
| 1729 | 1801 | return m_slotcart->m_cart->chip_read(space, offset); |
| 1730 | 1802 | else |
| 1731 | 1803 | return snes_r_io(space, address); |
| 1732 | 1804 | } |
| 1733 | | if (address >= 0x6000 && address < 0x8000) |
| 1734 | | { |
| 1735 | | return m_slotcart->m_cart->read_l(space, offset); //RAM |
| 1736 | | } |
| 1737 | | if (address >= 0x8000) |
| 1738 | | return m_slotcart->m_cart->read_l(space, offset); //ROM |
| 1805 | else if (address < 0x8000) |
| 1806 | return m_slotcart->m_cart->read_ram(space, offset & 0x1fff); |
| 1807 | else |
| 1808 | return m_slotcart->m_cart->read_l(space, offset); |
| 1739 | 1809 | } |
| 1740 | 1810 | else if (offset < 0x600000) |
| 1741 | | return m_slotcart->m_cart->read_l(space, offset); //ROM |
| 1742 | | |
| 1743 | | return m_slotcart->m_cart->read_l(space, offset); //RAM |
| 1811 | return m_slotcart->m_cart->read_l(space, offset); |
| 1812 | else |
| 1813 | return m_slotcart->m_cart->read_ram(space, offset); |
| 1744 | 1814 | } |
| 1745 | 1815 | |
| 1746 | 1816 | WRITE8_MEMBER( snsnew_state::snesfx_hi_w ) |
| r21683 | r21684 | |
| 1750 | 1820 | { |
| 1751 | 1821 | if (address < 0x2000) |
| 1752 | 1822 | space.write_byte(0x7e0000 + address, data); |
| 1753 | | if (address >= 0x2000 && address < 0x6000) |
| 1823 | else if (address < 0x6000) |
| 1754 | 1824 | { |
| 1755 | 1825 | if (address >= 0x3000 && address < 0x3300) |
| 1756 | 1826 | m_slotcart->m_cart->chip_write(space, offset, data); |
| 1757 | 1827 | else |
| 1758 | 1828 | snes_w_io(space, address, data); |
| 1759 | 1829 | } |
| 1760 | | if (address >= 0x6000 && address < 0x8000) |
| 1761 | | m_slotcart->m_cart->write_h(space, offset, data); |
| 1830 | else if (address < 0x8000) |
| 1831 | m_slotcart->m_cart->write_ram(space, offset & 0x1fff, data); |
| 1762 | 1832 | } |
| 1763 | | else |
| 1764 | | m_slotcart->m_cart->write_h(space, offset, data); |
| 1833 | else if (offset >= 0x600000) |
| 1834 | m_slotcart->m_cart->write_ram(space, offset, data); |
| 1765 | 1835 | } |
| 1766 | 1836 | |
| 1767 | 1837 | WRITE8_MEMBER( snsnew_state::snesfx_lo_w ) |
| 1768 | 1838 | { |
| 1769 | | UINT16 address = offset & 0xffff; |
| 1770 | | if (offset < 0x400000) |
| 1771 | | { |
| 1772 | | if (address < 0x2000) |
| 1773 | | space.write_byte(0x7e0000 + address, data); |
| 1774 | | if (address >= 0x2000 && address < 0x6000) |
| 1775 | | { |
| 1776 | | if (address >= 0x3000 && address < 0x3300) |
| 1777 | | m_slotcart->m_cart->chip_write(space, offset, data); |
| 1778 | | else |
| 1779 | | snes_w_io(space, address, data); |
| 1780 | | } |
| 1781 | | if (address >= 0x6000 && address < 0x8000) |
| 1782 | | m_slotcart->m_cart->write_l(space, offset, data); |
| 1783 | | } |
| 1784 | | else |
| 1785 | | m_slotcart->m_cart->write_l(space, offset, data); |
| 1839 | snesfx_hi_w(space, offset, data, 0xff); |
| 1786 | 1840 | } |
| 1787 | 1841 | |
| 1788 | 1842 | // SPC-7110 |
| r21683 | r21684 | |
| 1795 | 1849 | { |
| 1796 | 1850 | if (address < 0x2000) |
| 1797 | 1851 | return space.read_byte(0x7e0000 + address); |
| 1798 | | if (address >= 0x2000 && address < 0x6000) |
| 1852 | else if (address < 0x6000) |
| 1799 | 1853 | { |
| 1800 | 1854 | UINT16 limit = (m_slotcart->get_type() == SNES_SPC7110_RTC) ? 0x4843 : 0x4840; |
| 1801 | 1855 | if (address >= 0x4800 && address < limit) |
| r21683 | r21684 | |
| 1803 | 1857 | |
| 1804 | 1858 | return snes_r_io(space, address); |
| 1805 | 1859 | } |
| 1806 | | if (address >= 0x6000 && address < 0x8000) |
| 1860 | else if (address < 0x8000) |
| 1807 | 1861 | { |
| 1808 | 1862 | if (offset < 0x10000) |
| 1809 | | return m_slotcart->m_cart->read_h(space, offset); |
| 1863 | return m_slotcart->m_cart->read_ram(space, offset); |
| 1810 | 1864 | if (offset >= 0x300000 && offset < 0x310000) |
| 1811 | | return m_slotcart->m_cart->read_h(space, offset); |
| 1865 | return m_slotcart->m_cart->read_ram(space, offset); |
| 1812 | 1866 | } |
| 1813 | | if (address >= 0x8000) |
| 1867 | else |
| 1814 | 1868 | return m_slotcart->m_cart->read_h(space, offset); |
| 1815 | 1869 | } |
| 1816 | 1870 | return m_slotcart->m_cart->read_h(space, offset); |
| r21683 | r21684 | |
| 1824 | 1878 | { |
| 1825 | 1879 | if (address < 0x2000) |
| 1826 | 1880 | return space.read_byte(0x7e0000 + address); |
| 1827 | | if (address >= 0x2000 && address < 0x6000) |
| 1881 | else if (address < 0x6000) |
| 1828 | 1882 | { |
| 1829 | 1883 | UINT16 limit = (m_slotcart->get_type() == SNES_SPC7110_RTC) ? 0x4843 : 0x4840; |
| 1830 | 1884 | if (address >= 0x4800 && address < limit) |
| r21683 | r21684 | |
| 1832 | 1886 | |
| 1833 | 1887 | return snes_r_io(space, address); |
| 1834 | 1888 | } |
| 1835 | | if (address >= 0x6000 && address < 0x8000) |
| 1889 | else if (address < 0x8000) |
| 1836 | 1890 | { |
| 1837 | 1891 | if (offset < 0x10000) |
| 1838 | | return m_slotcart->m_cart->read_l(space, offset); |
| 1892 | return m_slotcart->m_cart->read_ram(space, offset); |
| 1839 | 1893 | if (offset >= 0x300000 && offset < 0x310000) |
| 1840 | | return m_slotcart->m_cart->read_l(space, offset); |
| 1894 | return m_slotcart->m_cart->read_ram(space, offset); |
| 1841 | 1895 | } |
| 1842 | | if (address >= 0x8000) |
| 1896 | else |
| 1843 | 1897 | return m_slotcart->m_cart->read_l(space, offset); |
| 1844 | 1898 | } |
| 1845 | 1899 | if (offset >= 0x500000 && offset < 0x510000) |
| r21683 | r21684 | |
| 1850 | 1904 | |
| 1851 | 1905 | WRITE8_MEMBER( snsnew_state::snespc7110_hi_w ) |
| 1852 | 1906 | { |
| 1853 | | UINT16 address = offset & 0xffff; |
| 1854 | | if (offset < 0x400000) |
| 1855 | | { |
| 1856 | | if (address < 0x2000) |
| 1857 | | space.write_byte(0x7e0000 + address, data); |
| 1858 | | if (address >= 0x2000 && address < 0x6000) |
| 1859 | | { |
| 1860 | | UINT16 limit = (m_slotcart->get_type() == SNES_SPC7110_RTC) ? 0x4843 : 0x4840; |
| 1861 | | if (address >= 0x4800 && address < limit) |
| 1862 | | { |
| 1863 | | m_slotcart->m_cart->chip_write(space, address, data); |
| 1864 | | return; |
| 1865 | | } |
| 1866 | | snes_w_io(space, address, data); |
| 1867 | | } |
| 1868 | | if (address >= 0x6000 && address < 0x8000) |
| 1869 | | { |
| 1870 | | if (offset < 0x10000) |
| 1871 | | m_slotcart->m_cart->write_l(space, offset, data); |
| 1872 | | if (offset >= 0x300000 && offset < 0x310000) |
| 1873 | | m_slotcart->m_cart->write_l(space, offset, data); |
| 1874 | | } |
| 1875 | | } |
| 1907 | snespc7110_lo_w(space, offset, data, 0xff); |
| 1876 | 1908 | } |
| 1877 | 1909 | |
| 1878 | 1910 | WRITE8_MEMBER( snsnew_state::snespc7110_lo_w ) |
| r21683 | r21684 | |
| 1882 | 1914 | { |
| 1883 | 1915 | if (address < 0x2000) |
| 1884 | 1916 | space.write_byte(0x7e0000 + address, data); |
| 1885 | | if (address >= 0x2000 && address < 0x6000) |
| 1917 | else if (address < 0x6000) |
| 1886 | 1918 | { |
| 1887 | 1919 | UINT16 limit = (m_slotcart->get_type() == SNES_SPC7110_RTC) ? 0x4843 : 0x4840; |
| 1888 | 1920 | if (address >= 0x4800 && address < limit) |
| r21683 | r21684 | |
| 1892 | 1924 | } |
| 1893 | 1925 | snes_w_io(space, address, data); |
| 1894 | 1926 | } |
| 1895 | | if (address >= 0x6000 && address < 0x8000) |
| 1927 | else if (address < 0x8000) |
| 1896 | 1928 | { |
| 1897 | 1929 | if (offset < 0x10000) |
| 1898 | | m_slotcart->m_cart->write_l(space, offset, data); |
| 1930 | m_slotcart->m_cart->write_ram(space, offset, data); |
| 1899 | 1931 | if (offset >= 0x300000 && offset < 0x310000) |
| 1900 | | m_slotcart->m_cart->write_l(space, offset, data); |
| 1932 | m_slotcart->m_cart->write_ram(space, offset, data); |
| 1901 | 1933 | } |
| 1902 | 1934 | } |
| 1903 | 1935 | } |
| r21683 | r21684 | |
| 1913 | 1945 | { |
| 1914 | 1946 | if (address < 0x2000) |
| 1915 | 1947 | return space.read_byte(0x7e0000 + address); |
| 1916 | | if (address >= 0x2000 && address < 0x6000) |
| 1948 | else if (address < 0x6000) |
| 1917 | 1949 | { |
| 1918 | 1950 | if (address >= 0x4800 && address < 0x4808) |
| 1919 | 1951 | return m_slotcart->m_cart->chip_read(space, address); |
| 1920 | 1952 | |
| 1921 | 1953 | return snes_r_io(space, address); |
| 1922 | 1954 | } |
| 1923 | | if (address >= 0x6000 && address < 0x8000) |
| 1955 | else if (address < 0x8000) |
| 1924 | 1956 | return snes_open_bus_r(space, 0); |
| 1925 | | if (address >= 0x8000) |
| 1957 | else |
| 1926 | 1958 | return m_slotcart->m_cart->read_l(space, offset); |
| 1927 | 1959 | } |
| 1960 | else if (offset >= 0x700000 && address < 0x8000 && m_slotcart->m_cart->get_nvram_size()) // NVRAM access |
| 1961 | return m_slotcart->m_cart->read_ram(space, offset); |
| 1962 | else // ROM access |
| 1963 | return m_slotcart->m_cart->read_l(space, offset); |
| 1964 | } |
| 1928 | 1965 | |
| 1929 | | // ROM & NVRAM access |
| 1930 | | return m_slotcart->m_cart->read_l(space, offset); |
| 1966 | READ8_MEMBER( snsnew_state::snesdd1_hi_r ) |
| 1967 | { |
| 1968 | if (offset >= 0x400000) |
| 1969 | return m_slotcart->m_cart->read_h(space, offset); |
| 1970 | else |
| 1971 | return snesdd1_lo_r(space, offset, 0xff); |
| 1931 | 1972 | } |
| 1932 | 1973 | |
| 1933 | 1974 | WRITE8_MEMBER( snsnew_state::snesdd1_lo_w ) |
| 1934 | 1975 | { |
| 1976 | snesdd1_hi_w(space, offset, data, 0xff); |
| 1977 | } |
| 1978 | |
| 1979 | WRITE8_MEMBER( snsnew_state::snesdd1_hi_w ) |
| 1980 | { |
| 1935 | 1981 | UINT16 address = offset & 0xffff; |
| 1936 | 1982 | if (offset < 0x400000) |
| 1937 | 1983 | { |
| 1938 | 1984 | if (address < 0x2000) |
| 1939 | 1985 | space.write_byte(0x7e0000 + address, data); |
| 1940 | | if (address >= 0x2000 && address < 0x6000) |
| 1986 | else if (address < 0x6000) |
| 1941 | 1987 | { |
| 1942 | 1988 | if (address >= 0x4300 && address < 0x4380) |
| 1943 | 1989 | { |
| r21683 | r21684 | |
| 1953 | 1999 | } |
| 1954 | 2000 | } |
| 1955 | 2001 | if (offset >= 0x700000 && address < 0x8000 && m_slotcart->m_cart->get_nvram_size()) |
| 1956 | | return m_slotcart->m_cart->write_l(space, offset, data); |
| 2002 | return m_slotcart->m_cart->write_ram(space, offset, data); |
| 1957 | 2003 | } |
| 1958 | 2004 | |
| 1959 | | READ8_MEMBER( snsnew_state::snesdd1_hi_r ) |
| 1960 | | { |
| 1961 | | if (offset >= 0x400000) |
| 1962 | | return m_slotcart->m_cart->read_h(space, offset); |
| 1963 | | else |
| 1964 | | return snesdd1_lo_r(space, offset, 0xff); |
| 1965 | | } |
| 1966 | 2005 | |
| 1967 | | WRITE8_MEMBER( snsnew_state::snesdd1_hi_w ) |
| 1968 | | { |
| 1969 | | snesdd1_lo_w(space, offset, data, 0xff); |
| 1970 | | } |
| 2006 | // BS-X (Base unit) |
| 1971 | 2007 | |
| 1972 | | |
| 1973 | | // BS-X |
| 1974 | | |
| 1975 | 2008 | READ8_MEMBER( snsnew_state::snesbsx_hi_r ) |
| 1976 | 2009 | { |
| 1977 | 2010 | UINT16 address = offset & 0xffff; |
| r21683 | r21684 | |
| 1980 | 2013 | { |
| 1981 | 2014 | if (address < 0x2000) |
| 1982 | 2015 | return space.read_byte(0x7e0000 + address); |
| 1983 | | if (address >= 0x2000 && address < 0x6000) |
| 2016 | else if (address < 0x6000) |
| 1984 | 2017 | { |
| 1985 | 2018 | if (address >= 0x2188 && address < 0x21a0) |
| 1986 | 2019 | return m_slotcart->m_cart->chip_read(space, offset); |
| r21683 | r21684 | |
| 1988 | 2021 | return m_slotcart->m_cart->chip_read(space, offset); |
| 1989 | 2022 | return snes_r_io(space, address); |
| 1990 | 2023 | } |
| 1991 | | if (address >= 0x6000 && address < 0x8000) |
| 2024 | else if (address < 0x8000) |
| 1992 | 2025 | { |
| 1993 | 2026 | if (offset >= 0x200000) |
| 1994 | | return m_slotcart->m_cart->read_l(space, offset); |
| 2027 | return m_slotcart->m_cart->read_h(space, offset); |
| 1995 | 2028 | else |
| 1996 | 2029 | return snes_open_bus_r(space, 0); |
| 1997 | 2030 | } |
| 1998 | | if (address >= 0x8000) |
| 1999 | | return m_slotcart->m_cart->read_l(space, offset); |
| 2031 | else |
| 2032 | return m_slotcart->m_cart->read_h(space, offset); |
| 2000 | 2033 | } |
| 2001 | | return m_slotcart->m_cart->read_l(space, offset); |
| 2034 | return m_slotcart->m_cart->read_h(space, offset); |
| 2002 | 2035 | } |
| 2003 | 2036 | |
| 2004 | 2037 | WRITE8_MEMBER( snsnew_state::snesbsx_hi_w ) |
| r21683 | r21684 | |
| 2008 | 2041 | { |
| 2009 | 2042 | if (address < 0x2000) |
| 2010 | 2043 | space.write_byte(0x7e0000 + address, data); |
| 2011 | | if (address >= 0x2000 && address < 0x6000) |
| 2044 | else if (address < 0x6000) |
| 2012 | 2045 | { |
| 2013 | 2046 | if (address >= 0x2188 && address < 0x21a0) |
| 2014 | 2047 | { |
| r21683 | r21684 | |
| 2022 | 2055 | } |
| 2023 | 2056 | snes_w_io(space, address, data); |
| 2024 | 2057 | } |
| 2025 | | if (address >= 0x6000 && address < 0x8000) |
| 2058 | else if (address < 0x8000) |
| 2026 | 2059 | { |
| 2027 | 2060 | if (offset >= 0x200000) |
| 2028 | 2061 | return m_slotcart->m_cart->write_l(space, offset, data); |
| 2029 | 2062 | } |
| 2030 | | if (address >= 0x8000) |
| 2063 | else |
| 2031 | 2064 | return m_slotcart->m_cart->write_l(space, offset, data); |
| 2032 | 2065 | } |
| 2033 | 2066 | return m_slotcart->m_cart->write_l(space, offset, data); |
| r21683 | r21684 | |
| 2035 | 2068 | |
| 2036 | 2069 | READ8_MEMBER( snsnew_state::snesbsx_lo_r ) |
| 2037 | 2070 | { |
| 2038 | | return snesbsx_hi_r(space, offset, 0xff); |
| 2071 | UINT16 address = offset & 0xffff; |
| 2072 | |
| 2073 | if (offset < 0x400000) |
| 2074 | { |
| 2075 | if (address < 0x2000) |
| 2076 | return space.read_byte(0x7e0000 + address); |
| 2077 | else if (address < 0x6000) |
| 2078 | { |
| 2079 | if (address >= 0x2188 && address < 0x21a0) |
| 2080 | return m_slotcart->m_cart->chip_read(space, offset); |
| 2081 | if (address >= 0x5000) |
| 2082 | return m_slotcart->m_cart->chip_read(space, offset); |
| 2083 | return snes_r_io(space, address); |
| 2084 | } |
| 2085 | else if (address < 0x8000) |
| 2086 | { |
| 2087 | if (offset >= 0x200000) |
| 2088 | return m_slotcart->m_cart->read_l(space, offset); |
| 2089 | else |
| 2090 | return snes_open_bus_r(space, 0); |
| 2091 | } |
| 2092 | else |
| 2093 | return m_slotcart->m_cart->read_l(space, offset); |
| 2094 | } |
| 2095 | return m_slotcart->m_cart->read_l(space, offset); |
| 2039 | 2096 | } |
| 2040 | 2097 | |
| 2041 | 2098 | WRITE8_MEMBER( snsnew_state::snesbsx_lo_w ) |