Previous 15994 Revisions Next

r5790 Friday 18th September, 2009 at 14:36:55 UTC by Barry Rodewald
[X1] Basic device-ification of keyboard, added Z80 daisy chain.
[src/mess/drivers]x1.c

src/mess/drivers/x1.c
r5789r5790
142142
143143#include "driver.h"
144144#include "cpu/z80/z80.h"
145#include "cpu/z80/z80daisy.h"
145146#include "machine/z80ctc.h"
146147#include "machine/z80sio.h"
147148#include "machine/8255ppi.h"
r5789r5790
166167static UINT8 pcg_reset;
167168static UINT16 crtc_start_addr;
168169static UINT8 sub_obf;
170static UINT8 key_irq_flag;
171static UINT8 ctc_irq_flag;
169172static struct
170173{
171174   UINT8 gfx_bank;
r5789r5790
187190
188191static UINT8 pcg_write_addr;
189192
193static DEVICE_START(x1_daisy){}
190194
191195/*************************************
192196 *
r5789r5790
682686   logerror("SUB: Command byte 0x%02x\n",data);
683687}
684688
689static int x1_keyboard_irq_state(const device_config* device)
690{
691   if(key_irq_flag != 0)
692      return Z80_DAISY_INT;
693     
694   return 0;
695}
696
697static int x1_keyboard_irq_ack(const device_config* device)
698{
699   key_irq_flag = 0;
700   cputag_set_input_line(device->machine,"maincpu",INPUT_LINE_IRQ0,CLEAR_LINE);
701   return key_irq_vector;
702}
703
704static DEVICE_GET_INFO( x1_keyboard_getinfo )
705{
706   switch (state)
707   {
708      /* --- the following bits of info are returned as 64-bit signed integers --- */
709      case DEVINFO_INT_TOKEN_BYTES:               info->i = 4;                                 break;
710      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                                 break;
711      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;                  break;
712
713      /* --- the following bits of info are returned as pointers to data or functions --- */
714      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(x1_daisy);      break;
715      case DEVINFO_FCT_IRQ_STATE:                  info->f = (genf *)x1_keyboard_irq_state;   break;
716      case DEVINFO_FCT_IRQ_ACK:                  info->f = (genf *)x1_keyboard_irq_ack;      break;
717
718      /* --- the following bits of info are returned as NULL-terminated strings --- */
719      case DEVINFO_STR_NAME:                     strcpy(info->s, "X1 keyboard");      break;
720      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "X1 daisy chain");            break;
721      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                           break;
722      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                        break;
723      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");            break;
724   }
725}
726
685727/*************************************
686728 *
687729 *  ROM Image / Banking Handling
r5789r5790
17401782
17411783static void ctc0_interrupt(const device_config *device, int state)
17421784{
1743   //x1_irq_vector = 0x5e;
1744   //cputag_set_input_line(device->machine, "maincpu", 0, state);
1785   cputag_set_input_line(device->machine,"maincpu",INPUT_LINE_IRQ0,state);
17451786}
17461787
17471788
r5789r5790
17491790{
17501791   0,               // timer disables
17511792   ctc0_interrupt,      // interrupt handler
1752   z80ctc_trg0_w,      // ZC/TO0 callback
1793   z80ctc_trg3_w,      // ZC/TO0 callback
17531794   z80ctc_trg1_w,      // ZC/TO1 callback
17541795   z80ctc_trg2_w,      // ZC/TO2 callback
17551796};
r5789r5790
17641805   0               /* receive handler */
17651806};
17661807
1808static const z80_daisy_chain x1_daisy[] =
1809{
1810   { "x1kb" },
1811   { "ctc" },
1812//   { "dma" },
1813//   { "sio" },
1814   { NULL }
1815};
17671816
17681817/*************************************
17691818 *
r5789r5790
18081857   //...
18091858}
18101859
1811static IRQ_CALLBACK(x1_irq_callback)
1860/*static IRQ_CALLBACK(x1_irq_callback)
18121861{
1813   cpu_set_input_line(device, 0, CLEAR_LINE);
1862   if(ctc_irq_flag != 0)
1863   {
1864      ctc_irq_flag = 0;
1865      if(key_irq_flag == 0)  // if no other devices are pulling the IRQ line high
1866         cpu_set_input_line(device, 0, CLEAR_LINE);
1867      return x1_irq_vector;
1868   }
1869   if(key_irq_flag != 0)
1870   {
1871      key_irq_flag = 0;
1872      if(ctc_irq_flag == 0)  // if no other devices are pulling the IRQ line high
1873         cpu_set_input_line(device, 0, CLEAR_LINE);
1874      return key_irq_vector;
1875   }
18141876   return x1_irq_vector;
18151877}
1816
1878*/
18171879static TIMER_CALLBACK(keyboard_callback)
18181880{
18191881   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
r5789r5790
18301892         // generate keyboard IRQ
18311893         sub_io_w(space,0,0xe6);
18321894         x1_irq_vector = key_irq_vector;
1895         key_irq_flag = 1;
18331896         cputag_set_input_line(machine,"maincpu",0,ASSERT_LINE);
18341897         old_key1 = key1;
18351898         old_key2 = key2;
r5789r5790
18651928   io_bank_mode = 0;
18661929   pcg_index[0] = pcg_index[1] = pcg_index[2] = 0;
18671930
1868   cpu_set_irq_callback(cputag_get_cpu(machine, "maincpu"), x1_irq_callback);
1931   //cpu_set_irq_callback(cputag_get_cpu(machine, "maincpu"), x1_irq_callback);
18691932   timer_pulse(machine, ATTOTIME_IN_HZ(240), NULL, 0, keyboard_callback);
18701933
18711934   cmt_current_cmd = 0;
18721935   cmt_test = 0;
18731936   cassette_change_state(devtag_get_device(machine, "cass" ),CASSETTE_MOTOR_DISABLED,CASSETTE_MASK_MOTOR);
1937   
1938   key_irq_flag = ctc_irq_flag = 0;
18741939}
18751940
18761941static PALETTE_INIT(x1)
r5789r5790
19271992   MDRV_CPU_PROGRAM_MAP(x1_mem)
19281993   MDRV_CPU_IO_MAP(x1_io)
19291994   MDRV_CPU_VBLANK_INT("screen", x1_vbl)
1995   MDRV_CPU_CONFIG(x1_daisy)
19301996
19311997   MDRV_Z80CTC_ADD( "ctc", XTAL_4MHz , ctc_intf )
19321998   MDRV_Z80SIO_ADD( "sio", XTAL_4MHz , sio_intf )
19331999   MDRV_Z80DMA_ADD( "dma", XTAL_4MHz , x1_dma )
19342000
2001   MDRV_DEVICE_ADD("x1kb", DEVICE_GET_INFO_NAME(x1_keyboard_getinfo), 0)
2002
19352003   MDRV_PPI8255_ADD( "ppi8255_0", ppi8255_intf )
19362004
19372005   MDRV_MACHINE_RESET(x1)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team