trunk/src/mame/drivers/namcos23.c
| r18805 | r18806 | |
| 1313 | 1313 | int scanline; |
| 1314 | 1314 | }; |
| 1315 | 1315 | |
| 1316 | struct c404_t |
| 1317 | { |
| 1318 | rgb_t bgcolor; |
| 1319 | UINT16 palbase; |
| 1320 | UINT8 layer; |
| 1321 | }; |
| 1322 | |
| 1316 | 1323 | struct render_t |
| 1317 | 1324 | { |
| 1318 | 1325 | poly_manager *polymgr; |
| r18805 | r18806 | |
| 1335 | 1342 | m_rtc(*this, "rtc"), |
| 1336 | 1343 | m_mainram(*this, "mainram"), |
| 1337 | 1344 | m_shared_ram(*this, "shared_ram"), |
| 1345 | m_gammaram(*this, "gammaram"), |
| 1338 | 1346 | m_charram(*this, "charram"), |
| 1339 | 1347 | m_textram(*this, "textram"), |
| 1340 | 1348 | m_czattr(*this, "czattr"), |
| r18805 | r18806 | |
| 1348 | 1356 | required_device<rtc4543_device> m_rtc; |
| 1349 | 1357 | required_shared_ptr<UINT32> m_mainram; |
| 1350 | 1358 | required_shared_ptr<UINT32> m_shared_ram; |
| 1359 | required_shared_ptr<UINT32> m_gammaram; |
| 1351 | 1360 | required_shared_ptr<UINT32> m_charram; |
| 1352 | 1361 | required_shared_ptr<UINT32> m_textram; |
| 1353 | 1362 | optional_shared_ptr<UINT32> m_czattr; |
| 1354 | 1363 | optional_device<cpu_device> m_gmen_sh2; |
| 1355 | 1364 | optional_shared_ptr<UINT32> m_gmen_sh2_shared; |
| 1356 | 1365 | |
| 1366 | c404_t m_c404; |
| 1357 | 1367 | c361_t m_c361; |
| 1358 | 1368 | c417_t m_c417; |
| 1359 | 1369 | c412_t m_c412; |
| r18805 | r18806 | |
| 1409 | 1419 | UINT8 m_s23_tssio_port_4; |
| 1410 | 1420 | |
| 1411 | 1421 | void update_main_interrupts(UINT32 cause); |
| 1422 | void update_mixer(); |
| 1412 | 1423 | |
| 1413 | 1424 | DECLARE_WRITE32_MEMBER(namcos23_textram_w); |
| 1414 | 1425 | DECLARE_WRITE32_MEMBER(s23_txtchar_w); |
| r18805 | r18806 | |
| 1470 | 1481 | }; |
| 1471 | 1482 | |
| 1472 | 1483 | |
| 1484 | static UINT8 nthbyte(const UINT32 *pSource, int offs) |
| 1485 | { |
| 1486 | pSource += offs/4; |
| 1487 | return (pSource[0]<<((offs&3)*8))>>24; |
| 1488 | } |
| 1489 | |
| 1490 | static UINT16 nthword(const UINT32 *pSource, int offs) |
| 1491 | { |
| 1492 | pSource += offs/2; |
| 1493 | return (pSource[0]<<((offs&1)*16))>>16; |
| 1494 | } |
| 1495 | |
| 1496 | |
| 1473 | 1497 | void namcos23_state::update_main_interrupts(UINT32 cause) |
| 1474 | 1498 | { |
| 1475 | 1499 | UINT32 changed = cause ^ m_main_irqcause; |
| r18805 | r18806 | |
| 1498 | 1522 | // level 6: C450 |
| 1499 | 1523 | } |
| 1500 | 1524 | |
| 1501 | | static UINT16 nthword( const UINT32 *pSource, int offs ) |
| 1502 | | { |
| 1503 | | pSource += offs/2; |
| 1504 | | return (pSource[0]<<((offs&1)*16))>>16; |
| 1505 | | } |
| 1506 | 1525 | |
| 1507 | 1526 | TILE_GET_INFO_MEMBER(namcos23_state::TextTilemapGetInfo) |
| 1508 | 1527 | { |
| r18805 | r18806 | |
| 1512 | 1531 | * ----.xx--.----.---- flip |
| 1513 | 1532 | * ----.--xx.xxxx.xxxx code |
| 1514 | 1533 | */ |
| 1515 | | SET_TILE_INFO_MEMBER( 0, data&0x03ff, data>>12, TILE_FLIPYX((data&0x0c00)>>10) ); |
| 1516 | | } /* TextTilemapGetInfo */ |
| 1534 | SET_TILE_INFO_MEMBER(0, data&0x03ff, data>>12, TILE_FLIPYX((data&0x0c00)>>10)); |
| 1535 | } |
| 1517 | 1536 | |
| 1518 | 1537 | WRITE32_MEMBER(namcos23_state::namcos23_textram_w) |
| 1519 | 1538 | { |
| r18805 | r18806 | |
| 1528 | 1547 | machine().gfx[0]->mark_dirty(offset/32); |
| 1529 | 1548 | } |
| 1530 | 1549 | |
| 1531 | | static UINT8 nthbyte( const UINT32 *pSource, int offs ) |
| 1550 | WRITE32_MEMBER(namcos23_state::namcos23_paletteram_w) |
| 1532 | 1551 | { |
| 1533 | | pSource += offs/4; |
| 1534 | | return (pSource[0]<<((offs&3)*8))>>24; |
| 1535 | | } |
| 1552 | COMBINE_DATA(&m_generic_paletteram_32[offset]); |
| 1536 | 1553 | |
| 1537 | | INLINE void UpdatePalette( running_machine &machine, int entry ) |
| 1538 | | { |
| 1539 | | namcos23_state *state = machine.driver_data<namcos23_state>(); |
| 1540 | | int j; |
| 1541 | | |
| 1542 | | for( j=0; j<2; j++ ) |
| 1554 | // each LONGWORD is 2 colors, each OFFSET is 2 colors |
| 1555 | for (int i = 0; i < 2; i++) |
| 1543 | 1556 | { |
| 1544 | | int which = (entry*2)+(j*2); |
| 1545 | | int r = nthbyte(state->m_generic_paletteram_32, which+0x00001); |
| 1546 | | int g = nthbyte(state->m_generic_paletteram_32, which+0x10001); |
| 1547 | | int b = nthbyte(state->m_generic_paletteram_32, which+0x20001); |
| 1548 | | palette_set_color( machine, which/2, MAKE_RGB(r,g,b) ); |
| 1557 | int which = (offset << 2 | i << 1) & 0xfffe; |
| 1558 | int r = nthbyte(m_generic_paletteram_32, which|0x00001); |
| 1559 | int g = nthbyte(m_generic_paletteram_32, which|0x10001); |
| 1560 | int b = nthbyte(m_generic_paletteram_32, which|0x20001); |
| 1561 | palette_set_color(machine(), which/2, MAKE_RGB(r,g,b)); |
| 1549 | 1562 | } |
| 1550 | 1563 | } |
| 1551 | 1564 | |
| 1552 | | /* each LONGWORD is 2 colors. each OFFSET is 2 colors */ |
| 1553 | | |
| 1554 | | WRITE32_MEMBER(namcos23_state::namcos23_paletteram_w) |
| 1555 | | { |
| 1556 | | COMBINE_DATA( &m_generic_paletteram_32[offset] ); |
| 1557 | | |
| 1558 | | UpdatePalette(machine(), (offset % (0x10000/4))*2); |
| 1559 | | } |
| 1560 | | |
| 1561 | 1565 | READ16_MEMBER(namcos23_state::s23_c417_r) |
| 1562 | 1566 | { |
| 1563 | | c417_t &c417 = m_c417; |
| 1564 | | |
| 1565 | 1567 | switch (offset) |
| 1566 | 1568 | { |
| 1567 | 1569 | /* According to timecrs2c, +0 is the status word with bits being: |
| r18805 | r18806 | |
| 1581 | 1583 | case 0: |
| 1582 | 1584 | return 0x8e | (machine().primary_screen->vblank() ? 0x0000 : 0x8000); |
| 1583 | 1585 | case 1: |
| 1584 | | return c417.adr; |
| 1586 | return m_c417.adr; |
| 1585 | 1587 | case 4: |
| 1586 | 1588 | //logerror("c417_r %04x = %04x (%08x, %08x)\n", c417.adr, c417.ram[c417.adr], space.device().safe_pc(), (unsigned int)space.device().state().state_int(MIPS3_R31)); |
| 1587 | | return c417.ram[c417.adr]; |
| 1589 | return m_c417.ram[m_c417.adr]; |
| 1588 | 1590 | case 5: |
| 1589 | | if(c417.pointrom_adr >= m_ptrom_limit) |
| 1591 | if (m_c417.pointrom_adr >= m_ptrom_limit) |
| 1590 | 1592 | return 0xffff; |
| 1591 | | return m_ptrom[c417.pointrom_adr] >> 16; |
| 1593 | return m_ptrom[m_c417.pointrom_adr] >> 16; |
| 1592 | 1594 | case 6: |
| 1593 | | if(c417.pointrom_adr >= m_ptrom_limit) |
| 1595 | if (m_c417.pointrom_adr >= m_ptrom_limit) |
| 1594 | 1596 | return 0xffff; |
| 1595 | | return m_ptrom[c417.pointrom_adr]; |
| 1597 | return m_ptrom[m_c417.pointrom_adr]; |
| 1596 | 1598 | } |
| 1597 | 1599 | |
| 1598 | 1600 | logerror("c417_r %x @ %04x (%08x, %08x)\n", offset, mem_mask, space.device().safe_pc(), (unsigned int)space.device().state().state_int(MIPS3_R31)); |
| r18805 | r18806 | |
| 1601 | 1603 | |
| 1602 | 1604 | WRITE16_MEMBER(namcos23_state::s23_c417_w) |
| 1603 | 1605 | { |
| 1604 | | c417_t &c417 = m_c417; |
| 1605 | | |
| 1606 | | switch(offset) |
| 1606 | switch (offset) |
| 1607 | 1607 | { |
| 1608 | 1608 | case 0: |
| 1609 | 1609 | logerror("p3d PIO %04x\n", data); |
| 1610 | 1610 | break; |
| 1611 | 1611 | case 1: |
| 1612 | | COMBINE_DATA(&c417.adr); |
| 1612 | COMBINE_DATA(&m_c417.adr); |
| 1613 | 1613 | break; |
| 1614 | 1614 | case 2: |
| 1615 | | c417.pointrom_adr = (c417.pointrom_adr << 16) | data; |
| 1615 | m_c417.pointrom_adr = (m_c417.pointrom_adr << 16) | data; |
| 1616 | 1616 | break; |
| 1617 | 1617 | case 3: |
| 1618 | | c417.pointrom_adr = 0; |
| 1618 | m_c417.pointrom_adr = 0; |
| 1619 | 1619 | break; |
| 1620 | 1620 | case 4: |
| 1621 | 1621 | //logerror("c417_w %04x = %04x (%08x, %08x)\n", c417.adr, data, space.device().safe_pc(), (unsigned int)space.device().state().state_int(MIPS3_R31)); |
| 1622 | | COMBINE_DATA(c417.ram + c417.adr); |
| 1622 | COMBINE_DATA(m_c417.ram + m_c417.adr); |
| 1623 | 1623 | break; |
| 1624 | 1624 | case 7: |
| 1625 | 1625 | logerror("c417_w: ack IRQ 2 (%x)\n", data); |
| r18805 | r18806 | |
| 1633 | 1633 | |
| 1634 | 1634 | READ16_MEMBER(namcos23_state::s23_c412_ram_r) |
| 1635 | 1635 | { |
| 1636 | | c412_t &c412 = m_c412; |
| 1637 | | |
| 1638 | 1636 | // logerror("c412_ram_r %06x (%08x, %08x)\n", offset, space.device().safe_pc(), (unsigned int)space.device().state().state_int(MIPS3_R31)); |
| 1639 | 1637 | if(offset < 0x100000) |
| 1640 | | return c412.sdram_a[offset & 0xfffff]; |
| 1638 | return m_c412.sdram_a[offset & 0xfffff]; |
| 1641 | 1639 | else if(offset < 0x200000) |
| 1642 | | return c412.sdram_b[offset & 0xfffff]; |
| 1640 | return m_c412.sdram_b[offset & 0xfffff]; |
| 1643 | 1641 | else if(offset < 0x220000) |
| 1644 | | return c412.sram [offset & 0x1ffff]; |
| 1642 | return m_c412.sram [offset & 0x1ffff]; |
| 1645 | 1643 | else if(offset < 0x220200) |
| 1646 | | return c412.pczram [offset & 0x001ff]; |
| 1644 | return m_c412.pczram [offset & 0x001ff]; |
| 1647 | 1645 | |
| 1648 | 1646 | return 0xffff; |
| 1649 | 1647 | } |
| 1650 | 1648 | |
| 1651 | 1649 | WRITE16_MEMBER(namcos23_state::s23_c412_ram_w) |
| 1652 | 1650 | { |
| 1653 | | c412_t &c412 = m_c412; |
| 1654 | | |
| 1655 | 1651 | // logerror("c412_ram_w %06x = %04x (%08x, %08x)\n", offset, data, space.device().safe_pc(), (unsigned int)space.device().state().state_int(MIPS3_R31)); |
| 1656 | 1652 | if(offset < 0x100000) |
| 1657 | | COMBINE_DATA(c412.sdram_a + (offset & 0xfffff)); |
| 1653 | COMBINE_DATA(m_c412.sdram_a + (offset & 0xfffff)); |
| 1658 | 1654 | else if(offset < 0x200000) |
| 1659 | | COMBINE_DATA(c412.sdram_b + (offset & 0xfffff)); |
| 1655 | COMBINE_DATA(m_c412.sdram_b + (offset & 0xfffff)); |
| 1660 | 1656 | else if(offset < 0x220000) |
| 1661 | | COMBINE_DATA(c412.sram + (offset & 0x1ffff)); |
| 1657 | COMBINE_DATA(m_c412.sram + (offset & 0x1ffff)); |
| 1662 | 1658 | else if(offset < 0x220200) |
| 1663 | | COMBINE_DATA(c412.pczram + (offset & 0x001ff)); |
| 1659 | COMBINE_DATA(m_c412.pczram + (offset & 0x001ff)); |
| 1664 | 1660 | } |
| 1665 | 1661 | |
| 1666 | 1662 | READ16_MEMBER(namcos23_state::s23_c412_r) |
| 1667 | 1663 | { |
| 1668 | | c412_t &c412 = m_c412; |
| 1669 | | |
| 1670 | | switch(offset) |
| 1664 | switch (offset) |
| 1671 | 1665 | { |
| 1672 | 1666 | case 0x3: |
| 1673 | 1667 | return 0x0002; // 0001 = busy, 0002 = game uploads things |
| 1674 | 1668 | case 0x8: |
| 1675 | | return c412.adr; |
| 1669 | return m_c412.adr; |
| 1676 | 1670 | case 0x9: |
| 1677 | | return c412.adr >> 16; |
| 1671 | return m_c412.adr >> 16; |
| 1678 | 1672 | case 0xa: |
| 1679 | | return s23_c412_ram_r(space, c412.adr, mem_mask); |
| 1673 | return s23_c412_ram_r(space, m_c412.adr, mem_mask); |
| 1680 | 1674 | } |
| 1681 | 1675 | |
| 1682 | 1676 | logerror("c412_r %x @ %04x (%08x, %08x)\n", offset, mem_mask, space.device().safe_pc(), (unsigned int)space.device().state().state_int(MIPS3_R31)); |
| r18805 | r18806 | |
| 1685 | 1679 | |
| 1686 | 1680 | WRITE16_MEMBER(namcos23_state::s23_c412_w) |
| 1687 | 1681 | { |
| 1688 | | c412_t &c412 = m_c412; |
| 1689 | | |
| 1690 | 1682 | switch (offset) |
| 1691 | 1683 | { |
| 1692 | 1684 | case 8: |
| 1693 | | c412.adr = (data & mem_mask) | (c412.adr & (0xffffffff ^ mem_mask)); |
| 1685 | m_c412.adr = (data & mem_mask) | (m_c412.adr & (0xffffffff ^ mem_mask)); |
| 1694 | 1686 | break; |
| 1695 | 1687 | case 9: |
| 1696 | | c412.adr = ((data & mem_mask) << 16) | (c412.adr & (0xffffffff ^ (mem_mask << 16))); |
| 1688 | m_c412.adr = ((data & mem_mask) << 16) | (m_c412.adr & (0xffffffff ^ (mem_mask << 16))); |
| 1697 | 1689 | break; |
| 1698 | 1690 | case 10: |
| 1699 | | s23_c412_ram_w(space, c412.adr, data, mem_mask); |
| 1700 | | c412.adr += 2; |
| 1691 | s23_c412_ram_w(space, m_c412.adr, data, mem_mask); |
| 1692 | m_c412.adr += 2; |
| 1701 | 1693 | break; |
| 1702 | 1694 | default: |
| 1703 | 1695 | logerror("c412_w %x, %04x @ %04x (%08x, %08x)\n", offset, data, mem_mask, space.device().safe_pc(), (unsigned int)space.device().state().state_int(MIPS3_R31)); |
| r18805 | r18806 | |
| 1707 | 1699 | |
| 1708 | 1700 | READ16_MEMBER(namcos23_state::s23_c421_ram_r) |
| 1709 | 1701 | { |
| 1710 | | c421_t &c421 = m_c421; |
| 1711 | | |
| 1712 | 1702 | // logerror("c421_ram_r %06x (%08x, %08x)\n", offset, space.device().safe_pc(), (unsigned int)space.device().state().state_int(MIPS3_R31)); |
| 1713 | 1703 | if(offset < 0x40000) |
| 1714 | | return c421.dram_a[offset & 0x3ffff]; |
| 1704 | return m_c421.dram_a[offset & 0x3ffff]; |
| 1715 | 1705 | else if(offset < 0x80000) |
| 1716 | | return c421.dram_b[offset & 0x3ffff]; |
| 1706 | return m_c421.dram_b[offset & 0x3ffff]; |
| 1717 | 1707 | else if(offset < 0x88000) |
| 1718 | | return c421.sram [offset & 0x07fff]; |
| 1708 | return m_c421.sram [offset & 0x07fff]; |
| 1719 | 1709 | |
| 1720 | 1710 | return 0xffff; |
| 1721 | 1711 | } |
| 1722 | 1712 | |
| 1723 | 1713 | WRITE16_MEMBER(namcos23_state::s23_c421_ram_w) |
| 1724 | 1714 | { |
| 1725 | | c421_t &c421 = m_c421; |
| 1726 | | |
| 1727 | 1715 | // logerror("c421_ram_w %06x = %04x (%08x, %08x)\n", offset, data, space.device().safe_pc(), (unsigned int)space.device().state().state_int(MIPS3_R31)); |
| 1728 | 1716 | if(offset < 0x40000) |
| 1729 | | COMBINE_DATA(c421.dram_a + (offset & 0x3ffff)); |
| 1717 | COMBINE_DATA(m_c421.dram_a + (offset & 0x3ffff)); |
| 1730 | 1718 | else if(offset < 0x80000) |
| 1731 | | COMBINE_DATA(c421.dram_b + (offset & 0x3ffff)); |
| 1719 | COMBINE_DATA(m_c421.dram_b + (offset & 0x3ffff)); |
| 1732 | 1720 | else if(offset < 0x88000) |
| 1733 | | COMBINE_DATA(c421.sram + (offset & 0x07fff)); |
| 1721 | COMBINE_DATA(m_c421.sram + (offset & 0x07fff)); |
| 1734 | 1722 | } |
| 1735 | 1723 | |
| 1736 | 1724 | READ16_MEMBER(namcos23_state::s23_c421_r) |
| 1737 | 1725 | { |
| 1738 | | c421_t &c421 = m_c421; |
| 1739 | | |
| 1740 | 1726 | switch (offset) |
| 1741 | 1727 | { |
| 1742 | 1728 | case 0: |
| 1743 | | return s23_c421_ram_r(space, c421.adr & 0xfffff, mem_mask); |
| 1729 | return s23_c421_ram_r(space, m_c421.adr & 0xfffff, mem_mask); |
| 1744 | 1730 | |
| 1745 | 1731 | case 2: |
| 1746 | | return c421.adr >> 16; |
| 1732 | return m_c421.adr >> 16; |
| 1747 | 1733 | case 3: |
| 1748 | | return c421.adr; |
| 1734 | return m_c421.adr; |
| 1749 | 1735 | } |
| 1750 | 1736 | |
| 1751 | 1737 | logerror("c421_r %x @ %04x (%08x, %08x)\n", offset, mem_mask, space.device().safe_pc(), (unsigned int)space.device().state().state_int(MIPS3_R31)); |
| r18805 | r18806 | |
| 1754 | 1740 | |
| 1755 | 1741 | WRITE16_MEMBER(namcos23_state::s23_c421_w) |
| 1756 | 1742 | { |
| 1757 | | c421_t &c421 = m_c421; |
| 1758 | | |
| 1759 | 1743 | switch (offset) |
| 1760 | 1744 | { |
| 1761 | 1745 | case 0: |
| 1762 | | s23_c421_ram_w(space, c421.adr & 0xfffff, data, mem_mask); |
| 1763 | | c421.adr += 2; |
| 1746 | s23_c421_ram_w(space, m_c421.adr & 0xfffff, data, mem_mask); |
| 1747 | m_c421.adr += 2; |
| 1764 | 1748 | break; |
| 1765 | 1749 | case 2: |
| 1766 | | c421.adr = ((data & mem_mask) << 16) | (c421.adr & (0xffffffff ^ (mem_mask << 16))); |
| 1750 | m_c421.adr = ((data & mem_mask) << 16) | (m_c421.adr & (0xffffffff ^ (mem_mask << 16))); |
| 1767 | 1751 | break; |
| 1768 | 1752 | case 3: |
| 1769 | | c421.adr = (data & mem_mask) | (c421.adr & (0xffffffff ^ mem_mask)); |
| 1753 | m_c421.adr = (data & mem_mask) | (m_c421.adr & (0xffffffff ^ mem_mask)); |
| 1770 | 1754 | break; |
| 1771 | 1755 | default: |
| 1772 | 1756 | logerror("c421_w %x, %04x @ %04x (%08x, %08x)\n", offset, data, mem_mask, space.device().safe_pc(), (unsigned int)space.device().state().state_int(MIPS3_R31)); |
| r18805 | r18806 | |
| 1806 | 1790 | |
| 1807 | 1791 | default: |
| 1808 | 1792 | logerror("ctl_w %x, %04x @ %04x (%08x, %08x)\n", offset, data, mem_mask, space.device().safe_pc(), (unsigned int)space.device().state().state_int(MIPS3_R31)); |
| 1793 | break; |
| 1809 | 1794 | } |
| 1810 | 1795 | } |
| 1811 | 1796 | |
| r18805 | r18806 | |
| 1830 | 1815 | |
| 1831 | 1816 | TIMER_CALLBACK_MEMBER(namcos23_state::c361_timer_cb) |
| 1832 | 1817 | { |
| 1833 | | c361_t &c361 = m_c361; |
| 1834 | | |
| 1835 | | if (c361.scanline != 0x1ff) |
| 1818 | if (m_c361.scanline != 0x1ff) |
| 1836 | 1819 | { |
| 1837 | 1820 | // need to do a partial update here, but doesn't work properly yet |
| 1838 | 1821 | //machine().primary_screen->update_partial(machine().primary_screen->vpos()); |
| r18805 | r18806 | |
| 1847 | 1830 | |
| 1848 | 1831 | WRITE16_MEMBER(namcos23_state::s23_c361_w) |
| 1849 | 1832 | { |
| 1850 | | c361_t &c361 = m_c361; |
| 1851 | | |
| 1852 | 1833 | switch (offset) |
| 1853 | 1834 | { |
| 1854 | 1835 | case 0: |
| r18805 | r18806 | |
| 1860 | 1841 | break; |
| 1861 | 1842 | |
| 1862 | 1843 | case 4: // interrupt control |
| 1863 | | c361.scanline = data & 0x1ff; |
| 1864 | | c361.timer->adjust(machine().primary_screen->time_until_pos(c361.scanline)); |
| 1844 | m_c361.scanline = data & 0x1ff; |
| 1845 | m_c361.timer->adjust(machine().primary_screen->time_until_pos(m_c361.scanline)); |
| 1865 | 1846 | break; |
| 1866 | 1847 | |
| 1867 | 1848 | default: |
| r18805 | r18806 | |
| 1890 | 1871 | |
| 1891 | 1872 | READ16_MEMBER(namcos23_state::s23_c422_r) |
| 1892 | 1873 | { |
| 1893 | | c422_t &c422 = m_c422; |
| 1894 | | |
| 1895 | | return c422.regs[offset]; |
| 1874 | return m_c422.regs[offset]; |
| 1896 | 1875 | } |
| 1897 | 1876 | |
| 1898 | 1877 | WRITE16_MEMBER(namcos23_state::s23_c422_w) |
| 1899 | 1878 | { |
| 1900 | | c422_t &c422 = m_c422; |
| 1901 | | |
| 1902 | 1879 | switch (offset) |
| 1903 | 1880 | { |
| 1904 | 1881 | case 1: |
| r18805 | r18806 | |
| 1919 | 1896 | break; |
| 1920 | 1897 | } |
| 1921 | 1898 | |
| 1922 | | COMBINE_DATA(&c422.regs[offset]); |
| 1899 | COMBINE_DATA(&m_c422.regs[offset]); |
| 1923 | 1900 | } |
| 1924 | 1901 | |
| 1925 | 1902 | |
| r18805 | r18806 | |
| 1961 | 1938 | } |
| 1962 | 1939 | } |
| 1963 | 1940 | |
| 1964 | | // Panic Park sits in a tight loop waiting for this AND 0002 to be non-zero (at PC=BFC02F00) |
| 1941 | // panicprk sits in a tight loop waiting for this AND 0002 to be non-zero (at PC=BFC02F00) |
| 1942 | // timecrs2 locks up in a similar way as panicprk, at the beginning of the 2nd level, by reading/writing to this register a couple of times |
| 1965 | 1943 | READ32_MEMBER(namcos23_state::s23_unk_status_r) |
| 1966 | 1944 | { |
| 1967 | 1945 | return 0x00020002; |
| r18805 | r18806 | |
| 2519 | 2497 | m_render.polymgr = poly_alloc(machine(), 10000, sizeof(namcos23_render_data), 0); |
| 2520 | 2498 | } |
| 2521 | 2499 | |
| 2500 | |
| 2501 | void namcos23_state::update_mixer() |
| 2502 | { |
| 2503 | // should be similar to Super System 22 C404 |
| 2504 | // 08 - background color red |
| 2505 | // 09 - background color green |
| 2506 | // 0a - background color blue |
| 2507 | // 1b - text layer palette base |
| 2508 | // 1f - layer enable (d0: polygons, d1: sprites, d2: text) |
| 2509 | m_c404.bgcolor = MAKE_RGB(nthword(m_gammaram,0x08), nthword(m_gammaram,0x09), nthword(m_gammaram,0x0a)); |
| 2510 | m_c404.palbase = nthword(m_gammaram, 0x1b) << 8 & 0x7f00; |
| 2511 | m_c404.layer = nthword(m_gammaram, 0x1f) & 0xff; |
| 2512 | } |
| 2513 | |
| 2522 | 2514 | UINT32 namcos23_state::screen_update_ss23(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) |
| 2523 | 2515 | { |
| 2524 | | bitmap.fill(get_black_pen(machine()), cliprect); |
| 2516 | update_mixer(); |
| 2517 | bitmap.fill(m_c404.bgcolor, cliprect); |
| 2525 | 2518 | |
| 2526 | | render_run( machine(), bitmap ); |
| 2519 | render_run(machine(), bitmap); |
| 2527 | 2520 | |
| 2528 | | gfx_element *gfx = machine().gfx[0]; |
| 2529 | | gfx->mark_all_dirty(); |
| 2530 | | |
| 2531 | | m_bgtilemap->draw(bitmap, cliprect, 0/*flags*/, 0/*priority*/ ); /* opaque */ |
| 2521 | m_bgtilemap->set_palette_offset(m_c404.palbase); |
| 2522 | if (m_c404.layer & 4) |
| 2523 | m_bgtilemap->draw(bitmap, cliprect, 0, 0); |
| 2532 | 2524 | return 0; |
| 2533 | 2525 | } |
| 2534 | 2526 | |
| 2535 | 2527 | INTERRUPT_GEN_MEMBER(namcos23_state::s23_interrupt) |
| 2536 | 2528 | { |
| 2537 | | render_t &render = m_render; |
| 2538 | | |
| 2539 | | if(!m_ctl_vbl_active) |
| 2529 | if (!m_ctl_vbl_active) |
| 2540 | 2530 | { |
| 2541 | 2531 | m_ctl_vbl_active = true; |
| 2542 | 2532 | update_main_interrupts(m_main_irqcause | MAIN_VBLANK_IRQ); |
| 2543 | 2533 | } |
| 2544 | 2534 | |
| 2545 | | render.cur = !render.cur; |
| 2546 | | render.count[render.cur] = 0; |
| 2535 | m_render.cur = !m_render.cur; |
| 2536 | m_render.count[m_render.cur] = 0; |
| 2547 | 2537 | } |
| 2548 | 2538 | |
| 2549 | 2539 | void namcos23_state::machine_start() |
| 2550 | 2540 | { |
| 2551 | | c361_t &c361 = m_c361; |
| 2552 | | c361.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(namcos23_state::c361_timer_cb),this)); |
| 2553 | | c361.timer->adjust(attotime::never); |
| 2541 | m_c361.timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(namcos23_state::c361_timer_cb),this)); |
| 2542 | m_c361.timer->adjust(attotime::never); |
| 2554 | 2543 | |
| 2555 | 2544 | mips3drc_add_fastram(m_maincpu, 0, m_mainram.bytes()-1, FALSE, reinterpret_cast<UINT32 *>(machine().root_device().memshare("mainram")->ptr())); |
| 2556 | 2545 | } |
| r18805 | r18806 | |
| 2564 | 2553 | AM_RANGE(0x04c3ff00, 0x04c3ff0f) AM_WRITE16(s23_mcuen_w, 0xffffffff) |
| 2565 | 2554 | AM_RANGE(0x06080000, 0x0608000f) AM_RAM AM_SHARE("czattr") |
| 2566 | 2555 | AM_RANGE(0x06080200, 0x060803ff) AM_RAM // PCZ Convert RAM (C406) (should be banked) |
| 2567 | | AM_RANGE(0x06108000, 0x061087ff) AM_RAM // Gamma RAM (C404) |
| 2556 | AM_RANGE(0x06108000, 0x061087ff) AM_RAM AM_SHARE("gammaram") // Gamma RAM (C404) |
| 2568 | 2557 | AM_RANGE(0x06110000, 0x0613ffff) AM_RAM_WRITE(namcos23_paletteram_w) AM_SHARE("paletteram") // Palette RAM (C404) |
| 2569 | 2558 | AM_RANGE(0x06400000, 0x0641dfff) AM_RAM_WRITE(s23_txtchar_w) AM_SHARE("charram") // Text CGRAM (C361) |
| 2570 | 2559 | AM_RANGE(0x0641e000, 0x0641ffff) AM_RAM_WRITE(namcos23_textram_w) AM_SHARE("textram") // Text VRAM (C361) |
| r18805 | r18806 | |
| 2573 | 2562 | AM_RANGE(0x0c000000, 0x0c00ffff) AM_RAM AM_SHARE("nvram") // Backup RAM |
| 2574 | 2563 | AM_RANGE(0x0d000000, 0x0d00000f) AM_READWRITE16(s23_ctl_r, s23_ctl_w, 0xffffffff) // write for LEDs at d000000, watchdog at d000004 |
| 2575 | 2564 | AM_RANGE(0x0e000000, 0x0e007fff) AM_RAM // C405 RAM - what is this? |
| 2576 | | AM_RANGE(0x0f000000, 0x0f000003) AM_READ(s23_unk_status_r) |
| 2565 | AM_RANGE(0x0f000000, 0x0f000003) AM_READ(s23_unk_status_r) // error status, or protection? (also gets written to) |
| 2577 | 2566 | AM_RANGE(0x0f200000, 0x0f203fff) AM_RAM // C422 RAM |
| 2578 | 2567 | AM_RANGE(0x0f300000, 0x0f30000f) AM_READWRITE16(s23_c422_r, s23_c422_w, 0xffffffff) // C422 registers |
| 2579 | 2568 | AM_RANGE(0x0fc00000, 0x0fffffff) AM_WRITENOP AM_ROM AM_REGION("user1", 0) |
| r18805 | r18806 | |
| 2592 | 2581 | AM_RANGE(0x06800000, 0x0681dfff) AM_RAM_WRITE(s23_txtchar_w) AM_SHARE("charram") // Text CGRAM (C361) |
| 2593 | 2582 | AM_RANGE(0x0681e000, 0x0681ffff) AM_RAM_WRITE(namcos23_textram_w) AM_SHARE("textram") // Text VRAM (C361) |
| 2594 | 2583 | AM_RANGE(0x06820000, 0x0682000f) AM_READWRITE16(s23_c361_r, s23_c361_w, 0xffffffff) // C361 |
| 2595 | | AM_RANGE(0x06a08000, 0x06a087ff) AM_RAM // Blending control & GAMMA (C404) |
| 2584 | AM_RANGE(0x06a08000, 0x06a087ff) AM_RAM AM_SHARE("gammaram") // Gamma RAM (C404) |
| 2596 | 2585 | AM_RANGE(0x06a10000, 0x06a3ffff) AM_RAM_WRITE(namcos23_paletteram_w) AM_SHARE("paletteram") // Palette RAM (C404) |
| 2597 | 2586 | AM_RANGE(0x08000000, 0x08ffffff) AM_ROM AM_REGION("data", 0x0000000) AM_MIRROR(0x1000000) // data ROMs |
| 2598 | 2587 | AM_RANGE(0x0a000000, 0x0affffff) AM_ROM AM_REGION("data", 0x1000000) AM_MIRROR(0x1000000) |
| 2599 | 2588 | AM_RANGE(0x0c000000, 0x0c00001f) AM_READWRITE16(s23_c412_r, s23_c412_w, 0xffffffff) |
| 2600 | 2589 | AM_RANGE(0x0c400000, 0x0c400007) AM_READWRITE16(s23_c421_r, s23_c421_w, 0xffffffff) |
| 2601 | 2590 | AM_RANGE(0x0d000000, 0x0d00000f) AM_READWRITE16(s23_ctl_r, s23_ctl_w, 0xffffffff) |
| 2602 | | AM_RANGE(0x0e800000, 0x0e800003) AM_READ(s23_unk_status_r) |
| 2591 | AM_RANGE(0x0e800000, 0x0e800003) AM_READ(s23_unk_status_r) // error status, or protection? (also gets written to) |
| 2603 | 2592 | AM_RANGE(0x0fc00000, 0x0fffffff) AM_WRITENOP AM_ROM AM_REGION("user1", 0) |
| 2604 | 2593 | ADDRESS_MAP_END |
| 2605 | 2594 | |
| r18805 | r18806 | |
| 2629 | 2618 | |
| 2630 | 2619 | |
| 2631 | 2620 | static ADDRESS_MAP_START( gmen_sh2_map, AS_PROGRAM, 32, namcos23_state ) |
| 2632 | | AM_RANGE( 0x00000000, 0x00007fff ) AM_RAM AM_SHARE("gmen_sh2_shared") |
| 2633 | | AM_RANGE( 0x04000000, 0x043fffff ) AM_RAM // SH-2 main work RAM |
| 2621 | AM_RANGE(0x00000000, 0x00007fff) AM_RAM AM_SHARE("gmen_sh2_shared") |
| 2622 | AM_RANGE(0x04000000, 0x043fffff) AM_RAM // SH-2 main work RAM |
| 2634 | 2623 | ADDRESS_MAP_END |
| 2635 | 2624 | |
| 2636 | 2625 | MACHINE_RESET_MEMBER(namcos23_state,gmen) |
| r18805 | r18806 | |
| 3207 | 3196 | |
| 3208 | 3197 | DRIVER_INIT_MEMBER(namcos23_state,ss23) |
| 3209 | 3198 | { |
| 3210 | | render_t &render = m_render; |
| 3211 | 3199 | m_ptrom = (const UINT32 *)memregion("pointrom")->base(); |
| 3212 | 3200 | m_tmlrom = (const UINT16 *)memregion("textilemapl")->base(); |
| 3213 | 3201 | m_tmhrom = memregion("textilemaph")->base(); |
| r18805 | r18806 | |
| 3228 | 3216 | m_s23_tssio_port_4 = 0; |
| 3229 | 3217 | m_s23_porta = 0, m_s23_rtcstate = 0; |
| 3230 | 3218 | m_audiocpu_running = false; |
| 3231 | | render.count[0] = render.count[1] = 0; |
| 3232 | | render.cur = 0; |
| 3219 | m_render.count[0] = m_render.count[1] = 0; |
| 3220 | m_render.cur = 0; |
| 3233 | 3221 | |
| 3234 | 3222 | if ((!strcmp(machine().system().name, "motoxgo")) || |
| 3235 | 3223 | (!strcmp(machine().system().name, "panicprk")) || |
| r18805 | r18806 | |
| 3277 | 3265 | }; /* cg_layout */ |
| 3278 | 3266 | |
| 3279 | 3267 | static GFXDECODE_START( namcos23 ) |
| 3280 | | GFXDECODE_ENTRY( NULL, 0, namcos23_cg_layout, 0x7f00, 0x80 ) |
| 3268 | GFXDECODE_ENTRY( NULL, 0, namcos23_cg_layout, 0, 0x800 ) |
| 3281 | 3269 | GFXDECODE_END |
| 3282 | 3270 | |
| 3283 | 3271 | static const mips3_config r4650_config = |