Previous 15994 Revisions Next

r10172 Monday 24th January, 2011 at 01:30:25 UTC by Angelo Salese
[PC-8801]: Added proper i8214 routing, disabled by default thru a compile switch
[src/mess/drivers]pc8801.c

src/mess/drivers/pc8801.c
r10171r10172
147147#include "sound/beep.h"
148148//#include "includes/pc8801.h"
149149
150//#define USE_PROPER_I8214
151
150152static UINT8 i8255_0_pc,i8255_1_pc;
151153static UINT8 fdc_irq_opcode;
152154static UINT8 ext_rom_bank,gfx_ctrl,vram_sel,misc_ctrl,device_ctrl_data;
r10171r10172
159161static UINT8 extram_mode,extram_bank;
160162static UINT8 txt_width, txt_color;
161163static int vblank_pos;
164#ifdef USE_PROPER_I8214
165static UINT8 m_int_mask,m_int_state;
166#else
162167static UINT8 i8214_irq_level;
163168static UINT8 vrtc_irq_mask,vrtc_irq_latch;
164169static UINT8 timer_irq_mask,timer_irq_latch;
165170static UINT8 sound_irq_mask,sound_irq_latch;
171#endif
166172
167
168173/*
169174CRTC command params:
1701750. CRTC reset
r10171r10172
876881   vram_sel = offset & 3;
877882}
878883
884#ifdef USE_PROPER_I8214
885
886static WRITE8_HANDLER( i8214_irq_level_w )
887{
888   i8214_b_w(space->machine->device("i8214"), 0, (data & 0x0f));
889}
890
891static WRITE8_HANDLER( i8214_irq_mask_w )
892{
893   m_int_mask = BITSWAP8((data & 0x07) | (m_int_mask & 0xf8),7,6,5,4,3,0,1,2);
894}
895
896
897#else
879898static WRITE8_HANDLER( pc8801_irq_level_w )
880899{
881900   if(data & 8)
r10171r10172
899918   //if(data & 4)
900919   //   printf("IRQ mask %02x\n",data);
901920}
921#endif
902922
903923static READ8_HANDLER( pc8801_window_bank_r )
904924{
r10171r10172
925945{
926946   misc_ctrl = data;
927947
948   #ifdef USE_PROPER_I8214
949   m_int_mask = (m_int_mask & 0xef) | ((data & 0x80) ? 0x00 : 0x10);
950   #else
928951   sound_irq_mask = ((data & 0x80) == 0);
929952
930953   if(sound_irq_mask == 0)
931954      sound_irq_latch = 0;
955   #endif
932956}
933957
934958static WRITE8_HANDLER( pc8801_palram_w )
r10171r10172
12031227//  AM_RANGE(0xdc, 0xdf) AM_NOP                                     /* MODEM */
12041228   AM_RANGE(0xe2, 0xe2) AM_READWRITE(pc8801_extram_mode_r,pc8801_extram_mode_w)          /* expand RAM mode */
12051229   AM_RANGE(0xe3, 0xe3) AM_READWRITE(pc8801_extram_bank_r,pc8801_extram_bank_w)          /* expand RAM bank */
1230#ifdef USE_PROPER_I8214
1231   AM_RANGE(0xe4, 0xe4) AM_WRITE(i8214_irq_level_w)
1232   AM_RANGE(0xe6, 0xe6) AM_WRITE(i8214_irq_mask_w)
1233#else
12061234   AM_RANGE(0xe4, 0xe4) AM_WRITE(pc8801_irq_level_w)
12071235   AM_RANGE(0xe6, 0xe6) AM_WRITE(pc8801_irq_mask_w)
1208//  AM_RANGE(0xe7, 0xe7) AM_NOP                                     /* (unknown) */
1236#endif
1237//  AM_RANGE(0xe7, 0xe7) AM_NOP                                     /* Arcus writes here, almost likely to be a mirror of above */
12091238   AM_RANGE(0xe8, 0xeb) AM_READWRITE(pc8801_kanji_r, pc8801_kanji_w)
12101239   AM_RANGE(0xec, 0xef) AM_READWRITE(pc8801_kanji_lv2_r, pc8801_kanji_lv2_w)
12111240//  AM_RANGE(0xf0, 0xf1) AM_NOP                                     /* Kana to Kanji dictionary ROM select (not yet) */
r10171r10172
16111640   DEVCB_NULL
16121641};
16131642
1614/* YM2203 Interface */
1615static void pc8801_sound_irq( device_t *device, int irq )
1616{
1617   if(sound_irq_mask)
1618   {
1619      sound_irq_latch = 1;
1620      cputag_set_input_line(device->machine,"maincpu",0,HOLD_LINE);
1621   }
1622}
1623
1624/* TODO: mouse routing (that's why I don't use DEVCB_INPUT_PORT here) */
1625static READ8_DEVICE_HANDLER( opn_porta_r ) { return input_port_read(device->machine, "OPN_PA"); }
1626static READ8_DEVICE_HANDLER( opn_portb_r ) { return input_port_read(device->machine, "OPN_PB"); }
1627
1628static const ym2203_interface pc88_ym2203_intf =
1629{
1630   {
1631      AY8910_LEGACY_OUTPUT,
1632      AY8910_DEFAULT_LOADS,
1633      DEVCB_HANDLER(opn_porta_r),
1634      DEVCB_HANDLER(opn_portb_r),
1635      DEVCB_NULL,
1636      DEVCB_NULL
1637   },
1638   pc8801_sound_irq
1639};
1640
16411643/* Floppy Configuration */
16421644
16431645static const floppy_config pc88_floppy_config =
r10171r10172
16621664   NULL
16631665};
16641666
1667#ifdef USE_PROPER_I8214
1668void pc8801_raise_irq(running_machine *machine,UINT8 mask)
1669{
1670   m_int_state |= mask;
1671
1672   i8214_r_w(machine->device("i8214"), 0, ~(m_int_state & m_int_mask));
1673}
1674
1675static WRITE_LINE_DEVICE_HANDLER( pic_int_w )
1676{
1677   if (state == ASSERT_LINE)
1678   {
1679      cpu_set_input_line(device, INPUT_LINE_IRQ0, ASSERT_LINE);
1680   }
1681}
1682
1683static I8214_INTERFACE( pic_intf )
1684{
1685   DEVCB_DEVICE_LINE("maincpu", pic_int_w),
1686   DEVCB_NULL
1687};
1688
16651689static IRQ_CALLBACK( pc8801_irq_callback )
16661690{
1691   UINT8 vector = (i8214_a_r(device->machine->device("i8214"), 0)); //
1692
1693   printf("Interrupt Acknowledge Vector: %02x\n", vector);
1694   m_int_state &= ~vector;
1695
1696   cputag_set_input_line(device->machine,"maincpu", INPUT_LINE_IRQ0, CLEAR_LINE);
1697   i8214_r_w(device->machine->device("i8214"), 0, ~(m_int_state & m_int_mask));
1698
1699   return 1*2;
1700}
1701
1702static void pc8801_sound_irq( device_t *device, int irq )
1703{
1704
1705}
1706
1707static TIMER_CALLBACK( pc8801_rtc_irq )
1708{
1709   //pc8801_raise_irq(machine,2);
1710   //if(m_int_mask & 4)
1711   //   cputag_set_input_line(machine, "maincpu", INPUT_LINE_IRQ0, ASSERT_LINE);
1712}
1713
1714static INTERRUPT_GEN( pc8801_vrtc_irq )
1715{
1716   pc8801_raise_irq(device->machine,1);
1717   //if(m_int_mask & 2)
1718   //   cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_IRQ0, ASSERT_LINE);
1719}
1720
1721#else
1722static IRQ_CALLBACK( pc8801_irq_callback )
1723{
16671724   if(i8214_irq_level >= 5 && sound_irq_latch)
16681725   {
16691726      sound_irq_latch = 0;
r10171r10172
16811738   }
16821739
16831740   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);
1741   if(sound_irq_latch)
1742      return 4*2;
1743
16841744   return 2*2; //TODO: mustn't happen, it does if you press shift on N88-BASIC
16851745}
16861746
1747static void pc8801_sound_irq( device_t *device, int irq )
1748{
1749   if(sound_irq_mask)
1750   {
1751      sound_irq_latch = 1;
1752      cputag_set_input_line(device->machine,"maincpu",0,HOLD_LINE);
1753   }
1754}
1755
16871756static TIMER_CALLBACK( pc8801_rtc_irq )
16881757{
16891758   if(timer_irq_mask)
r10171r10172
16931762   }
16941763}
16951764
1765static INTERRUPT_GEN( pc8801_vrtc_irq )
1766{
1767   if(vrtc_irq_mask)
1768   {
1769      vrtc_irq_latch = 1;
1770      cpu_set_input_line(device,0,HOLD_LINE);
1771   }
1772}
1773#endif
1774
16961775static MACHINE_START( pc8801 )
16971776{
16981777   cpu_set_irq_callback(machine->device("maincpu"), pc8801_irq_callback);
r10171r10172
17351814   beep_set_frequency(machine->device("beeper"),2400);
17361815   beep_set_state(machine->device("beeper"),0);
17371816
1817   #ifdef USE_PROPER_I8214
17381818   {
1819      /* initialize I8214 */
1820      i8214_etlg_w(machine->device("i8214"), 1);
1821      i8214_inte_w(machine->device("i8214"), 1);
1822   }
1823   #else
1824   {
17391825      vrtc_irq_mask = 0;
17401826      vrtc_irq_latch = 0;
17411827      timer_irq_mask = 0;
r10171r10172
17441830      sound_irq_latch = 0;
17451831      i8214_irq_level = 0;
17461832   }
1833   #endif
17471834
17481835   {
17491836      dma_address[2] = 0xf300;
r10171r10172
17791866   {FLOPPY_0, FLOPPY_1, NULL, NULL}
17801867};
17811868
1782static INTERRUPT_GEN( pc8801_vrtc_irq )
1869/* YM2203 Interface */
1870
1871/* TODO: mouse routing (that's why I don't use DEVCB_INPUT_PORT here) */
1872static READ8_DEVICE_HANDLER( opn_porta_r ) { return input_port_read(device->machine, "OPN_PA"); }
1873static READ8_DEVICE_HANDLER( opn_portb_r ) { return input_port_read(device->machine, "OPN_PB"); }
1874
1875static const ym2203_interface pc88_ym2203_intf =
17831876{
1784   if(vrtc_irq_mask)
17851877   {
1786      vrtc_irq_latch = 1;
1787      cpu_set_input_line(device,0,HOLD_LINE);
1788   }
1789}
1878      AY8910_LEGACY_OUTPUT,
1879      AY8910_DEFAULT_LOADS,
1880      DEVCB_HANDLER(opn_porta_r),
1881      DEVCB_HANDLER(opn_portb_r),
1882      DEVCB_NULL,
1883      DEVCB_NULL
1884   },
1885   pc8801_sound_irq
1886};
17901887
1888#define MASTER_CLOCK XTAL_4MHz
1889
17911890static MACHINE_CONFIG_START( pc8801, driver_device )
17921891   /* main CPU */
1793   MCFG_CPU_ADD("maincpu", Z80, 4000000)        /* 4 MHz */
1892   MCFG_CPU_ADD("maincpu", Z80, MASTER_CLOCK)        /* 4 MHz */
17941893   MCFG_CPU_PROGRAM_MAP(pc8801_mem)
17951894   MCFG_CPU_IO_MAP(pc8801_io)
17961895   MCFG_CPU_VBLANK_INT("screen", pc8801_vrtc_irq)
17971896
17981897   /* sub CPU(5 inch floppy drive) */
1799   MCFG_CPU_ADD("fdccpu", Z80, 4000000)      /* 4 MHz */
1898   MCFG_CPU_ADD("fdccpu", Z80, MASTER_CLOCK)      /* 4 MHz */
18001899   MCFG_CPU_PROGRAM_MAP(pc8801fdc_mem)
18011900   MCFG_CPU_IO_MAP(pc8801fdc_io)
18021901
r10171r10172
18091908   MCFG_I8255A_ADD( "d8255_slave", slave_fdd_intf )
18101909
18111910   MCFG_UPD765A_ADD("upd765", pc8801_upd765_interface)
1911   #ifdef USE_PROPER_I8214
1912   MCFG_I8214_ADD("i8214", MASTER_CLOCK, pic_intf)
1913   #endif
18121914   //MCFG_UPD1990A_ADD("upd1990a", XTAL_32_768kHz, pc88_upd1990a_intf)
18131915   //MCFG_CENTRONICS_ADD("centronics", standard_centronics)
18141916   //MCFG_CASSETTE_ADD("cassette", pc88_cassette_config)
r10171r10172
18311933
18321934   /* sound hardware */
18331935   MCFG_SPEAKER_STANDARD_MONO("mono")
1834   MCFG_SOUND_ADD("opn", YM2203, 4000000) //unknown clock
1936   MCFG_SOUND_ADD("opn", YM2203, MASTER_CLOCK)
18351937   MCFG_SOUND_CONFIG(pc88_ym2203_intf)
18361938   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
18371939

Previous 15994 Revisions Next


© 1998-2018 The MESS Team