src/mess/drivers/pc8801.c
| r10198 | r10199 | |
| 15 | 15 | - Add limits for extend work RAM; |
| 16 | 16 | - What happens to the palette contents when the analog/digital palette mode changes? |
| 17 | 17 | - dipswitches needs to be controlled; |
| 18 | | - Several games (most notably Ys series of games) have issues with the YM2203 music tempo (too fast) ... why? |
| 19 | 18 | |
| 20 | 19 | per-game specific TODO: |
| 21 | 20 | - 100 Yen disk(s): reads kanji ports; |
| r10198 | r10199 | |
| 162 | 161 | static UINT8 txt_width, txt_color; |
| 163 | 162 | static int vblank_pos; |
| 164 | 163 | #ifdef USE_PROPER_I8214 |
| 165 | | static UINT8 m_int_mask,m_int_state; |
| 164 | static UINT8 timer_irq_mask,vblank_irq_mask,sound_irq_mask,m_int_state; |
| 166 | 165 | #else |
| 167 | 166 | static UINT8 i8214_irq_level; |
| 168 | 167 | static UINT8 vrtc_irq_mask,vrtc_irq_latch; |
| r10198 | r10199 | |
| 910 | 909 | |
| 911 | 910 | static WRITE8_HANDLER( i8214_irq_level_w ) |
| 912 | 911 | { |
| 913 | | i8214_b_w(space->machine->device("i8214"), 0, (data & 0x0f)); |
| 912 | if(data & 8) |
| 913 | i8214_b_w(space->machine->device("i8214"), 0, (7)); |
| 914 | else |
| 915 | i8214_b_w(space->machine->device("i8214"), 0, (data & 0x07)); |
| 914 | 916 | } |
| 915 | 917 | |
| 916 | 918 | static WRITE8_HANDLER( i8214_irq_mask_w ) |
| 917 | 919 | { |
| 918 | | m_int_mask = BITSWAP8((data & 0x07) | (m_int_mask & 0xf8),7,6,5,4,3,0,1,2); |
| 920 | timer_irq_mask = data & 1; |
| 921 | vblank_irq_mask = data & 2; |
| 919 | 922 | } |
| 920 | 923 | |
| 921 | 924 | |
| r10198 | r10199 | |
| 971 | 974 | misc_ctrl = data; |
| 972 | 975 | |
| 973 | 976 | #ifdef USE_PROPER_I8214 |
| 974 | | m_int_mask = (m_int_mask & 0xef) | ((data & 0x80) ? 0x00 : 0x10); |
| 977 | sound_irq_mask = ((data & 0x80) == 0); |
| 975 | 978 | #else |
| 976 | 979 | sound_irq_mask = ((data & 0x80) == 0); |
| 977 | 980 | |
| r10198 | r10199 | |
| 1690 | 1693 | }; |
| 1691 | 1694 | |
| 1692 | 1695 | #ifdef USE_PROPER_I8214 |
| 1693 | | void pc8801_raise_irq(running_machine *machine,UINT8 mask) |
| 1696 | void pc8801_raise_irq(running_machine *machine,UINT8 irq,UINT8 mask) |
| 1694 | 1697 | { |
| 1695 | 1698 | m_int_state |= mask; |
| 1696 | 1699 | |
| 1697 | | i8214_r_w(machine->device("i8214"), 0, ~(m_int_state & m_int_mask)); |
| 1700 | i8214_r_w(machine->device("i8214"), 0, ~irq); |
| 1701 | |
| 1702 | if(mask) |
| 1703 | cputag_set_input_line(machine,"maincpu",0,ASSERT_LINE); |
| 1698 | 1704 | } |
| 1699 | 1705 | |
| 1700 | 1706 | static WRITE_LINE_DEVICE_HANDLER( pic_int_w ) |
| 1701 | 1707 | { |
| 1702 | | if (state == ASSERT_LINE) |
| 1703 | | { |
| 1704 | | cpu_set_input_line(device, INPUT_LINE_IRQ0, ASSERT_LINE); |
| 1705 | | } |
| 1708 | // if (state == ASSERT_LINE) |
| 1709 | // { |
| 1710 | // } |
| 1706 | 1711 | } |
| 1707 | 1712 | |
| 1713 | static WRITE_LINE_DEVICE_HANDLER( pic_enlg_w ) |
| 1714 | { |
| 1715 | //if (state == CLEAR_LINE) |
| 1716 | //{ |
| 1717 | //} |
| 1718 | } |
| 1719 | |
| 1708 | 1720 | static I8214_INTERFACE( pic_intf ) |
| 1709 | 1721 | { |
| 1710 | 1722 | DEVCB_DEVICE_LINE("maincpu", pic_int_w), |
| 1711 | | DEVCB_NULL |
| 1723 | DEVCB_DEVICE_LINE("maincpu", pic_enlg_w) |
| 1712 | 1724 | }; |
| 1713 | 1725 | |
| 1714 | 1726 | static IRQ_CALLBACK( pc8801_irq_callback ) |
| 1715 | 1727 | { |
| 1716 | | UINT8 vector = (i8214_a_r(device->machine->device("i8214"), 0)); // |
| 1728 | UINT8 vector = (7 - i8214_a_r(device->machine->device("i8214"), 0)); |
| 1717 | 1729 | |
| 1718 | | printf("Interrupt Acknowledge Vector: %02x\n", vector); |
| 1719 | | m_int_state &= ~vector; |
| 1730 | m_int_state &= ~(1<<vector); |
| 1731 | cputag_set_input_line(device->machine,"maincpu",0,CLEAR_LINE); |
| 1720 | 1732 | |
| 1721 | | cputag_set_input_line(device->machine,"maincpu", INPUT_LINE_IRQ0, CLEAR_LINE); |
| 1722 | | i8214_r_w(device->machine->device("i8214"), 0, ~(m_int_state & m_int_mask)); |
| 1723 | | |
| 1724 | | return 1*2; |
| 1733 | return vector << 1; |
| 1725 | 1734 | } |
| 1726 | 1735 | |
| 1727 | 1736 | static void pc8801_sound_irq( device_t *device, int irq ) |
| 1728 | 1737 | { |
| 1729 | | |
| 1738 | pc8801_raise_irq(device->machine,1<<(4),sound_irq_mask); |
| 1730 | 1739 | } |
| 1731 | 1740 | |
| 1732 | 1741 | static TIMER_CALLBACK( pc8801_rtc_irq ) |
| 1733 | 1742 | { |
| 1734 | | //pc8801_raise_irq(machine,2); |
| 1735 | | //if(m_int_mask & 4) |
| 1736 | | // cputag_set_input_line(machine, "maincpu", INPUT_LINE_IRQ0, ASSERT_LINE); |
| 1743 | pc8801_raise_irq(machine,1<<(2),timer_irq_mask); |
| 1737 | 1744 | } |
| 1738 | 1745 | |
| 1739 | 1746 | static INTERRUPT_GEN( pc8801_vrtc_irq ) |
| 1740 | 1747 | { |
| 1741 | | pc8801_raise_irq(device->machine,1); |
| 1742 | | //if(m_int_mask & 2) |
| 1743 | | // cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_IRQ0, ASSERT_LINE); |
| 1748 | pc8801_raise_irq(device->machine,1<<(1),vblank_irq_mask); |
| 1744 | 1749 | } |
| 1745 | 1750 | |
| 1746 | 1751 | #else |
| r10198 | r10199 | |
| 1763 | 1768 | } |
| 1764 | 1769 | |
| 1765 | 1770 | printf("IRQ triggered but no vector on the bus! %02x %02x %02x %02x\n",i8214_irq_level,sound_irq_latch,vrtc_irq_latch,timer_irq_latch); |
| 1766 | | if(sound_irq_latch) |
| 1767 | | return 4*2; |
| 1768 | 1771 | |
| 1769 | 1772 | return 2*2; //TODO: mustn't happen, it does if you press shift on N88-BASIC |
| 1770 | 1773 | } |
| r10198 | r10199 | |
| 1773 | 1776 | { |
| 1774 | 1777 | if(sound_irq_mask) |
| 1775 | 1778 | { |
| 1776 | | sound_irq_latch = 1; |
| 1777 | | cputag_set_input_line(device->machine,"maincpu",0,HOLD_LINE); |
| 1779 | sound_irq_latch = irq; |
| 1780 | cputag_set_input_line(device->machine,"maincpu",0,irq); |
| 1778 | 1781 | } |
| 1779 | 1782 | } |
| 1780 | 1783 | |