Previous 15994 Revisions Next

r14134 Monday 23rd January, 2012 at 08:56:57 UTC by Curt Coder
[WANGPC] Keyboard WIP. (nw)
[src/mess/drivers]wangpc.c
[src/mess/includes]wangpc.h
[src/mess/machine]wangpckb.c wangpckb.h

src/mess/machine/wangpckb.c
r14133r14134
352352 
353353wangpc_keyboard_device::wangpc_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
354354    : device_t(mconfig, WANGPC_KEYBOARD, "Wang PC Keyboard", tag, owner, clock),
355     device_serial_interface(mconfig, *this),
355356     m_maincpu(*this, I8051_TAG)
356357{
357358}
r14133r14134
363364 
364365void wangpc_keyboard_device::device_start()
365366{
367   // set serial callbacks
368   i8051_set_serial_tx_callback(m_maincpu, wangpc_keyboard_device::mcs51_tx_callback);
369   i8051_set_serial_rx_callback(m_maincpu, wangpc_keyboard_device::mcs51_rx_callback);
370   set_data_frame(8, 2, SERIAL_PARITY_NONE);
366371}
367372 
368373 
r14133r14134
376381 
377382 
378383//-------------------------------------------------
384//  device_timer - handler timer events
385//-------------------------------------------------
386 
387void wangpc_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
388{
389   // receive
390   int bit = get_in_data_bit();
391   receive_register_update_bit(bit);
392   /*
393   if (start bit)
394   {
395      m_maincpu->set_input_line(MCS51_RX_LINE, ASSERT_LINE);
396   }
397   */
398   if (is_receive_register_full())
399   {
400      receive_register_extract();
401   }
402   
403   // transmit
404   if (!is_transmit_register_empty())
405   {
406      transmit_register_get_data_bit();
407      serial_connection_out();
408   }
409}
410 
411 
412//-------------------------------------------------
413//  input_callback -
414//-------------------------------------------------
415 
416void wangpc_keyboard_device::input_callback(UINT8 state)
417{
418}
419 
420 
421//-------------------------------------------------
422//  mcs51_rx_callback -
423//-------------------------------------------------
424 
425int wangpc_keyboard_device::mcs51_rx_callback(device_t *device)
426{
427   wangpc_keyboard_device *kb = static_cast<wangpc_keyboard_device *>(device->owner());
428   
429   return kb->get_received_char();
430}
431 
432 
433//-------------------------------------------------
434//  mcs51_tx_callback -
435//-------------------------------------------------
436 
437void wangpc_keyboard_device::mcs51_tx_callback(device_t *device, int data)
438{
439   wangpc_keyboard_device *kb = static_cast<wangpc_keyboard_device *>(device->owner());
440   
441   kb->transmit_register_setup(data);
442}
443 
444 
445//-------------------------------------------------
379446//  kb_p1_r -
380447//-------------------------------------------------
381448 
src/mess/machine/wangpckb.h
r14133r14134
4848// ======================> wangpc_keyboard_device
4949 
5050class wangpc_keyboard_device :  public device_t,
51                        public device_serial_interface,
5152                        public wangpc_keyboard_interface
5253{
5354public:
r14133r14134
6465   DECLARE_WRITE8_MEMBER( kb_p2_w );
6566   DECLARE_WRITE8_MEMBER( kb_p3_w );
6667   
68   static int mcs51_rx_callback(device_t *device);
69   static void mcs51_tx_callback(device_t *device, int data);
70   
6771protected:
6872    // device-level overrides
73   virtual void device_config_complete() { m_shortname = "wangpckb"; }
6974    virtual void device_start();
7075   virtual void device_reset();
71   virtual void device_config_complete() { m_shortname = "wangpckb"; }
76   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
77   
78   // device_serial_interface overrides
79   virtual void input_callback(UINT8 state);
7280 
7381private:
7482   required_device<cpu_device> m_maincpu;
src/mess/includes/wangpc.h
r14133r14134
2525#define IM6402_TAG      "im6402"
2626#define SCN2661_TAG      "scn2661"
2727#define UPD765_TAG      "upd765"
28#define KB_TAG         "serkb"
2829#define SCREEN_TAG      "screen"
2930 
3031class wangpc_state : public driver_device
r14133r14134
4344        m_ram(*this, RAM_TAG),
4445        m_floppy0(*this, FLOPPY_0),
4546        m_floppy1(*this, FLOPPY_1),
47        m_kb(*this, WANGPC_KEYBOARD_TAG),
4648        m_timer2_irq(1),
49        m_ecpi_irq(1),
50        m_ppi_irq(1),
51        m_uart_dr(0),
52        m_uart_tre(0),
53        m_fpu_irq(0),
4754        m_ds1(1),
4855        m_ds2(1)
4956   { }
r14133r14134
5865   required_device<ram_device> m_ram;
5966   required_device<device_t> m_floppy0;
6067   required_device<device_t> m_floppy1;
68   required_device<wangpc_keyboard_device> m_kb;
6169 
6270   virtual void machine_start();
71   virtual void machine_reset();
6372   
6473   UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
6574   {
r14133r14134
6776      return 0;
6877   }
6978   
79   void check_level1_interrupts();
80   void check_level2_interrupts();
81   
7082   DECLARE_WRITE8_MEMBER( fdc_ctrl_w );
7183   DECLARE_READ8_MEMBER( deselect_drive1_r );
7284   DECLARE_WRITE8_MEMBER( deselect_drive1_w );
r14133r14134
95107   DECLARE_WRITE8_MEMBER( nmi_mask_w );
96108   DECLARE_READ8_MEMBER( led_on_r );
97109   DECLARE_WRITE8_MEMBER( fpu_mask_w );
110   DECLARE_WRITE8_MEMBER( uart_tre_clr_w );
111   DECLARE_READ8_MEMBER( uart_r );
112   DECLARE_WRITE8_MEMBER( uart_w );
98113   DECLARE_READ8_MEMBER( led_off_r );
99114   DECLARE_WRITE8_MEMBER( parity_nmi_clr_w );
100115   DECLARE_READ8_MEMBER( option_id_r );
r14133r14134
105120   DECLARE_WRITE8_MEMBER( ppi_pc_w );
106121   DECLARE_WRITE_LINE_MEMBER( pit0_w );
107122   DECLARE_WRITE_LINE_MEMBER( pit2_w );
123   DECLARE_WRITE_LINE_MEMBER( uart_dr_w );
124   DECLARE_WRITE_LINE_MEMBER( uart_tre_w );
125   DECLARE_WRITE_LINE_MEMBER( fdc_int_w );
126   DECLARE_WRITE_LINE_MEMBER( bus_irq2_w );
108127   
109128   UINT8 m_dma_page[3];
110129   
111130   int m_timer2_irq;
131   int m_ecpi_irq;
132   int m_ppi_irq;
133   int m_uart_dr;
134   int m_uart_tre;
135   int m_fpu_irq;
112136   
113137   int m_ds1;
114138   int m_ds2;
139   
115140};
116141 
117142 
src/mess/drivers/wangpc.c
r14133r14134
237237READ8_MEMBER( wangpc_state::timer2_irq_clr_r )
238238{
239239   m_timer2_irq = 1;
240   check_level1_interrupts();
240241 
241242   return 0;
242243}
r14133r14134
273274 
274275 
275276//-------------------------------------------------
277//  uart_tre_clr_w -
278//-------------------------------------------------
279 
280WRITE8_MEMBER( wangpc_state::uart_tre_clr_w  )
281{
282   m_uart_tre = 0;
283   check_level2_interrupts();
284}
285 
286 
287//-------------------------------------------------
288//  uart_r -
289//-------------------------------------------------
290 
291READ8_MEMBER( wangpc_state::uart_r )
292{
293   m_uart_dr = 0;
294   check_level2_interrupts();
295   
296   return m_uart->read(space, 0);
297}
298 
299 
300//-------------------------------------------------
301//  uart_w -
302//-------------------------------------------------
303 
304WRITE8_MEMBER( wangpc_state::uart_w  )
305{
306   m_uart_tre = 0;
307   check_level2_interrupts();
308   
309   m_uart->write(space, 0, data);
310}
311 
312 
313//-------------------------------------------------
276314//  led_off_r -
277315//-------------------------------------------------
278316 
r14133r14134
363401   AM_RANGE(0x10e0, 0x10e1) AM_READWRITE8(status_r, timer0_irq_clr_w, 0x00ff)
364402   AM_RANGE(0x10e2, 0x10e3) AM_READWRITE8(timer2_irq_clr_r, nmi_mask_w, 0x00ff)
365403   AM_RANGE(0x10e4, 0x10e5) AM_READWRITE8(led_on_r, fpu_mask_w, 0x00ff)
366   AM_RANGE(0x10e8, 0x10e9) AM_DEVREADWRITE8(IM6402_TAG, im6402_device, read, write, 0x00ff)
404   AM_RANGE(0x10e6, 0x10e7) AM_WRITE8(uart_tre_clr_w, 0x00ff)
405   AM_RANGE(0x10e8, 0x10e9) AM_READWRITE8(uart_r, uart_w, 0x00ff)
367406   AM_RANGE(0x10ee, 0x10ef) AM_READWRITE8(led_off_r, parity_nmi_clr_w, 0x00ff)
368407   AM_RANGE(0x10fe, 0x10ff) AM_READ8(option_id_r, 0x00ff)
369408ADDRESS_MAP_END
r14133r14134
407446//  pic8259_interface pic_intf
408447//-------------------------------------------------
409448 
449void wangpc_state::check_level1_interrupts()
450{
451   int state = !m_timer2_irq | !m_ecpi_irq | !m_ppi_irq;
452   
453   pic8259_ir1_w(m_pic, state);
454}
455 
456void wangpc_state::check_level2_interrupts()
457{
458   int state = /* !i8237_eop_r(m_dmac) | */ m_uart_dr | m_uart_tre | upd765_int_r(m_fdc) | m_fpu_irq;
459   
460   pic8259_ir2_w(m_pic, state);
461}
462 
410463static IRQ_CALLBACK( wangpc_irq_callback )
411464{
412465   wangpc_state *state = device->machine().driver_data<wangpc_state>();
r14133r14134
416469 
417470static const struct pic8259_interface pic_intf =
418471{
419   DEVCB_NULL,
420   DEVCB_NULL,
472   DEVCB_CPU_INPUT_LINE(I8086_TAG, INPUT_LINE_IRQ0),
473   DEVCB_LINE_VCC,
421474   DEVCB_NULL
422475};
423476 
r14133r14134
468521   // timer 2 interrupt
469522   data |= m_timer2_irq;
470523   
524   // serial interrupt
525   data |= m_ecpi_irq << 1;
526   
527   // parallel port interrupt
528   data |= m_ppi_irq << 2;
529   
530   // DMA interrupt
531   // data |= i8237_eop_r(m_dmac) << 3;
532       
533   // keyboard interrupt
534   data |= m_uart_tre << 4;
535   data |= m_uart_dr << 5;
536   
471537   // FDC interrupt
472538   data |= upd765_int_r(m_fdc) << 6;
473539   
540   // 8087 interrupt
541   data |= m_fpu_irq << 7;
542   
474543   return data;
475544}
476545 
r14133r14134
532601   if (state)
533602   {
534603      m_timer2_irq = 0;
604      check_level1_interrupts();
535605   }
536606}
537607 
r14133r14134
539609{
540610   {
541611      {
542         0,
612         500000,
543613         DEVCB_LINE_VCC,
544614         DEVCB_DEVICE_LINE(I8259A_TAG, pic8259_ir0_w)
545615      }, {
546         0,
616         2000000,
547617         DEVCB_LINE_VCC,
548618         DEVCB_NULL
549619      }, {
550         0,
620         500000,
551621         DEVCB_LINE_VCC,
552622         DEVCB_DRIVER_LINE_MEMBER(wangpc_state, pit2_w)
553623      }
r14133r14134
559629//  IM6402_INTERFACE( uart_intf )
560630//-------------------------------------------------
561631 
632WRITE_LINE_MEMBER( wangpc_state::uart_dr_w )
633{
634   if (state)
635   {
636      m_uart_dr = 1;       
637      check_level2_interrupts();
638   }
639}
640 
641WRITE_LINE_MEMBER( wangpc_state::uart_tre_w )
642{
643   if (state)
644   {
645      m_uart_tre = 1;
646      check_level2_interrupts();
647   }
648}
649 
562650static IM6402_INTERFACE( uart_intf )
563651{
564   0,
565   0,
652   62500,
653   62500,
566654   DEVCB_NULL,
567655   DEVCB_NULL,
656   DEVCB_DRIVER_LINE_MEMBER(wangpc_state, uart_dr_w),
568657   DEVCB_NULL,
569   DEVCB_NULL,
570   DEVCB_NULL
658   DEVCB_DRIVER_LINE_MEMBER(wangpc_state, uart_tre_w)
571659};
572660 
573661 
r14133r14134
582670   DEVCB_NULL,
583671   DEVCB_NULL,
584672   DEVCB_NULL,
585   FLOPPY_STANDARD_5_25_DSSD,
673   FLOPPY_STANDARD_5_25_DSDD,
586674   LEGACY_FLOPPY_OPTIONS_NAME(default),
587675   "floppy_5_25",
588676   NULL
589677};
590678 
679WRITE_LINE_MEMBER( wangpc_state::fdc_int_w )
680{
681   check_level2_interrupts();
682}
683 
591684static UPD765_GET_IMAGE( wangpc_fdc_get_image )
592685{
593686   wangpc_state *state = device->machine().driver_data<wangpc_state>();
r14133r14134
600693 
601694static const upd765_interface fdc_intf =
602695{
696   DEVCB_DRIVER_LINE_MEMBER(wangpc_state, fdc_int_w),
603697   DEVCB_NULL,
604   DEVCB_NULL,
605698   wangpc_fdc_get_image,
606699   UPD765_RDY_PIN_NOT_CONNECTED,
607700   { FLOPPY_0, FLOPPY_1, NULL, NULL }
r14133r14134
622715//  WANGPC_BUS_INTERFACE( kb_intf )
623716//-------------------------------------------------
624717 
718WRITE_LINE_MEMBER( wangpc_state::bus_irq2_w )
719{
720   check_level2_interrupts();
721}
722 
625723static WANGPC_BUS_INTERFACE( bus_intf )
626724{
627   DEVCB_DEVICE_LINE(I8259A_TAG, pic8259_ir2_w),
725   DEVCB_DRIVER_LINE_MEMBER(wangpc_state, bus_irq2_w),
628726   DEVCB_DEVICE_LINE(I8259A_TAG, pic8259_ir3_w),
629727   DEVCB_DEVICE_LINE(I8259A_TAG, pic8259_ir4_w),
630728   DEVCB_DEVICE_LINE(I8259A_TAG, pic8259_ir5_w),
r14133r14134
633731   DEVCB_DEVICE_LINE(AM9517A_TAG, i8237_dreq1_w),
634732   DEVCB_DEVICE_LINE(AM9517A_TAG, i8237_dreq2_w),
635733   DEVCB_DEVICE_LINE(AM9517A_TAG, i8237_dreq3_w),
636   DEVCB_NULL
734   DEVCB_CPU_INPUT_LINE(I8086_TAG, INPUT_LINE_NMI)
637735};
638736 
639737static SLOT_INTERFACE_START( wangpc_cards )
r14133r14134
653751{
654752   // register CPU IRQ callback
655753   device_set_irq_callback(m_maincpu, wangpc_irq_callback);
754   
755   // connect serial keyboard
756   m_uart->connect(m_kb);
656757}
657758 
658759 
760//-------------------------------------------------
761//  MACHINE_RESET( wangpc )
762//-------------------------------------------------
659763 
764void wangpc_state::machine_reset()
765{
766   // initialize UART
767   m_uart->cls1_w(1);
768   m_uart->cls2_w(1);
769   m_uart->pi_w(1);
770   m_uart->sbs_w(1);
771   m_uart->crl_w(1);
772}
773 
774 
775 
660776//**************************************************************************
661777//  MACHINE DRIVERS
662778//**************************************************************************

Previous 15994 Revisions Next


© 1998-2018 The MESS Team