Previous 199869 Revisions Next

r32681 Sunday 12th October, 2014 at 07:40:44 UTC by Fabio Priuli
(MESS) hd61700: converted to use devcb callbacks instead of
static config, and removed a few trampolines in pb1000.c as a
consequence. nw.
[src/emu/cpu/hd61700]hd61700.c hd61700.h
[src/mess/drivers]pb1000.c

trunk/src/emu/cpu/hd61700/hd61700.h
r32680r32681
1515//  INTERFACE CONFIGURATION MACROS
1616//**************************************************************************
1717
18#define MCFG_HD61700_CONFIG(_config) \
19   hd61700_cpu_device::static_set_config(*device, _config);
20//**************************************************************************
21//  DEFINITIONS
22//**************************************************************************
18#define MCFG_HD61700_LCD_CTRL_CB(_devcb) \
19   devcb = &hd61700_cpu_device::set_lcd_ctrl_callback(*device, DEVCB_##_devcb);
2320
24// class definition
25class hd61700_cpu_device;
21#define MCFG_HD61700_LCD_WRITE_CB(_devcb) \
22   devcb = &hd61700_cpu_device::set_lcd_write_callback(*device, DEVCB_##_devcb);
2623
27// cpu port callbacks types
28typedef void   (*hd61700_lcd_control_func)(hd61700_cpu_device &device, UINT8 data);
29typedef UINT8  (*hd61700_lcd_data_r_func)(hd61700_cpu_device &device);
30typedef void   (*hd61700_lcd_data_w_func)(hd61700_cpu_device &device, UINT8 data);
31typedef UINT16 (*hd61700_kb_r_func)(hd61700_cpu_device &device);
32typedef void   (*hd61700_kb_w_func)(hd61700_cpu_device &device, UINT8 matrix);
33typedef UINT8  (*hd61700_port_r_func)(hd61700_cpu_device &device);
34typedef void   (*hd61700_port_w_func)(hd61700_cpu_device &device, UINT8 data);
24#define MCFG_HD61700_LCD_READ_CB(_devcb) \
25   devcb = &hd61700_cpu_device::set_lcd_read_callback(*device, DEVCB_##_devcb);
3526
36// device config
37struct hd61700_config
38{
39   hd61700_lcd_control_func    m_lcd_control;      //lcd control
40   hd61700_lcd_data_r_func     m_lcd_data_r;       //lcd data read
41   hd61700_lcd_data_w_func     m_lcd_data_w;       //lcd data write
42   hd61700_kb_r_func           m_kb_r;             //keyboard matrix read
43   hd61700_kb_w_func           m_kb_w;             //keyboard matrix write
44   hd61700_port_r_func         m_port_r;           //8 bit port read
45   hd61700_port_w_func         m_port_w;           //8 bit port write
46};
27#define MCFG_HD61700_KB_WRITE_CB(_devcb) \
28   devcb = &hd61700_cpu_device::set_kb_write_callback(*device, DEVCB_##_devcb);
4729
30#define MCFG_HD61700_KB_READ_CB(_devcb) \
31   devcb = &hd61700_cpu_device::set_kb_read_callback(*device, DEVCB_##_devcb);
4832
33#define MCFG_HD61700_PORT_WRITE_CB(_devcb) \
34   devcb = &hd61700_cpu_device::set_port_write_callback(*device, DEVCB_##_devcb);
35
36#define MCFG_HD61700_PORT_READ_CB(_devcb) \
37   devcb = &hd61700_cpu_device::set_port_read_callback(*device, DEVCB_##_devcb);
38
39
40//**************************************************************************
41//  DEFINITIONS
42//**************************************************************************
43
4944// registers
5045enum
5146{
r32680r32681
6863
6964// ======================> hd61700_cpu_device
7065
71class hd61700_cpu_device : public cpu_device,
72                     public hd61700_config
66class hd61700_cpu_device : public cpu_device
7367{
7468public:
7569   // construction/destruction
7670   hd61700_cpu_device(const machine_config &mconfig, const char *_tag, device_t *_owner, UINT32 _clock);
7771
78   static void static_set_config(device_t &device, const hd61700_config &config);
79
72   template<class _Object> static devcb_base &set_lcd_ctrl_callback(device_t &device, _Object object) { return downcast<hd61700_cpu_device &>(device).m_lcd_ctrl_cb.set_callback(object); }
73   template<class _Object> static devcb_base &set_lcd_write_callback(device_t &device, _Object object) { return downcast<hd61700_cpu_device &>(device).m_lcd_write_cb.set_callback(object); }
74   template<class _Object> static devcb_base &set_lcd_read_callback(device_t &device, _Object object) { return downcast<hd61700_cpu_device &>(device).m_lcd_read_cb.set_callback(object); }
75   template<class _Object> static devcb_base &set_kb_write_callback(device_t &device, _Object object) { return downcast<hd61700_cpu_device &>(device).m_kb_write_cb.set_callback(object); }
76   template<class _Object> static devcb_base &set_kb_read_callback(device_t &device, _Object object) { return downcast<hd61700_cpu_device &>(device).m_kb_read_cb.set_callback(object); }
77   template<class _Object> static devcb_base &set_port_write_callback(device_t &device, _Object object) { return downcast<hd61700_cpu_device &>(device).m_port_write_cb.set_callback(object); }
78   template<class _Object> static devcb_base &set_port_read_callback(device_t &device, _Object object) { return downcast<hd61700_cpu_device &>(device).m_port_read_cb.set_callback(object); }
79   
8080protected:
8181   // device-level overrides
8282   virtual void device_start();
r32680r32681
148148
149149   address_space *m_program;
150150
151   devcb_write8    m_lcd_ctrl_cb;      //lcd control
152   devcb_read8     m_lcd_read_cb;      //lcd data read
153   devcb_write8    m_lcd_write_cb;     //lcd data write
154   devcb_read16    m_kb_read_cb;       //keyboard matrix read
155   devcb_write8    m_kb_write_cb;      //keyboard matrix write
156   devcb_read8     m_port_read_cb;     //8 bit port read
157   devcb_write8    m_port_write_cb;    //8 bit port write
158   
151159   // flag definitions
152160   static const int FLAG_Z     = 0x80;
153161   static const int FLAG_C     = 0x40;
trunk/src/emu/cpu/hd61700/hd61700.c
r32680r32681
107107      m_ppc(0x0000),
108108      m_curpc(0x0000),
109109      m_pc(0),
110      m_flags(0)
110      m_flags(0),
111      m_lcd_ctrl_cb(*this),
112      m_lcd_read_cb(*this),
113      m_lcd_write_cb(*this),
114      m_kb_read_cb(*this),
115      m_kb_write_cb(*this),
116      m_port_read_cb(*this),
117      m_port_write_cb(*this)
111118{
112119   // ...
113120}
114121
115122
116123//-------------------------------------------------
117//  static_set_config - set the configuration
118//  structure
119//-------------------------------------------------
120
121void hd61700_cpu_device::static_set_config(device_t &device, const hd61700_config &config)
122{
123   hd61700_cpu_device &conf = downcast<hd61700_cpu_device &>(device);
124   static_cast<hd61700_config &>(conf) = config;
125}
126
127//-------------------------------------------------
128124//  device_start - start up the device
129125//-------------------------------------------------
130126
r32680r32681
135131   m_sec_timer = timer_alloc(SEC_TIMER);
136132   m_sec_timer->adjust(attotime::from_seconds(1), 0, attotime::from_seconds(1));
137133
134   m_lcd_ctrl_cb.resolve_safe();
135   m_lcd_read_cb.resolve_safe(0xff);
136   m_lcd_write_cb.resolve_safe();
137   m_kb_read_cb.resolve_safe(0xff);
138   m_kb_write_cb.resolve_safe();
139   m_port_read_cb.resolve_safe(0xff);
140   m_port_write_cb.resolve_safe();
141   
138142   // save state
139143   save_item(NAME(m_ppc));
140144   save_item(NAME(m_curpc));
r32680r32681
464468            case 0x12:  //stl
465469               {
466470                  UINT8 arg = read_op();
471                  m_lcd_write_cb((offs_t)0, READ_REG(arg));
467472
468                  if (m_lcd_data_w)
469                     (*m_lcd_data_w)(*this, READ_REG(arg));
470
471473                  check_optional_jr(arg);
472474                  m_icount -= 11;
473475               }
r32680r32681
476478            case 0x13:  //ldl
477479               {
478480                  UINT8 arg = read_op();
479                  UINT8 res = 0xff;
481                  UINT8 res = m_lcd_read_cb(0);
480482
481                  if (m_lcd_data_r)
482                     res = (*m_lcd_data_r)(*this);
483
484483                  WRITE_REG(arg, res);
485484
486485                  check_optional_jr(arg);
r32680r32681
498497                  }
499498                  else
500499                  {
501                     if (m_lcd_control)
502                        (*m_lcd_control)(*this, READ_REG(arg));
500                     m_lcd_ctrl_cb((offs_t)0, READ_REG(arg));
503501                  }
504502
505503                  check_optional_jr(arg);
r32680r32681
529527                     case 0:     //PE
530528                     case 1:     //PD
531529                        WRITE_REG8(idx, src);
532                        if (m_port_w)
533                           (*m_port_w)(*this, REG_PD & REG_PE);
530                        m_port_write_cb((offs_t)0, REG_PD & REG_PE);
534531                        break;
535532                     case 2:     //IB
536533                        REG_IB = (REG_IB & 0x1f) | (src & 0xe0);
r32680r32681
539536                        WRITE_REG8(idx, src);
540537                        break;
541538                     case 4:     //IA
542                        if (m_kb_w)
543                           (*m_kb_w)(*this, src);
539                        m_kb_write_cb((offs_t)0, src);
544540                        WRITE_REG8(idx, src);
545541                        break;
546542                     case 5:     //IE
r32680r32681
673669                  }
674670                  else
675671                  {
676                     if (m_port_r)
677                        src = (*m_port_r)(*this);
678
672                     src = m_port_read_cb(0);
679673                     src&=(~REG_PE);
680674                  }
681675
r32680r32681
10171011            case 0x52:  //stl
10181012               {
10191013                  UINT8 arg = read_op();
1014                  m_lcd_write_cb((offs_t)0, arg);
10201015
1021                  if (m_lcd_data_w)
1022                     (*m_lcd_data_w)(*this, arg);
1023
10241016                  m_icount -= 12;
10251017               }
10261018               break;
r32680r32681
10361028                  }
10371029                  else
10381030                  {
1039                     if (m_lcd_control)
1040                        (*m_lcd_control)(*this, src);
1031                     m_lcd_ctrl_cb((offs_t)0, src);
10411032                  }
10421033
10431034                  m_icount -= 3;
r32680r32681
10651056                     case 0:     //PE
10661057                     case 1:     //PD
10671058                        WRITE_REG8(idx, src);
1068                        if (m_port_w)
1069                           (*m_port_w)(*this, REG_PD & REG_PE);
1059                        m_port_write_cb((offs_t)0, REG_PD & REG_PE);
10701060                        break;
10711061                     case 2:     //IB
10721062                        REG_IB = (REG_IB & 0x1f) | (src & 0xe0);
r32680r32681
10751065                        WRITE_REG8(idx, src);
10761066                        break;
10771067                     case 4:     //IA
1078                        if (m_kb_w)
1079                           (*m_kb_w)(*this, src);
1068                        m_kb_write_cb((offs_t)0, src);
10801069                        WRITE_REG8(idx, src);
10811070                        break;
10821071                     case 5:     //IE
r32680r32681
14491438               {
14501439                  UINT8 arg = read_op();
14511440
1452                  if (m_lcd_data_w)
1453                  {
1454                     (*m_lcd_data_w)(*this, READ_REG(arg));
1455                     (*m_lcd_data_w)(*this, READ_REG(arg+1));
1456                  }
1441                  m_lcd_write_cb((offs_t)0, READ_REG(arg));
1442                  m_lcd_write_cb((offs_t)0, READ_REG(arg+1));
14571443
14581444                  check_optional_jr(arg);
14591445                  m_icount -= 19;
r32680r32681
14651451                  UINT8 arg = read_op();
14661452                  UINT8 reg0, reg1;
14671453
1468                  if (m_lcd_data_r)
1469                  {
1470                     reg0 = (*m_lcd_data_r)(*this);
1471                     reg1 = (*m_lcd_data_r)(*this);
1472                  }
1473                  else
1474                     reg0 = reg1 = 0xff;
1454                  reg0 = m_lcd_read_cb(0);
1455                  reg1 = m_lcd_read_cb(0);
14751456
14761457                  WRITE_REG(arg+0, reg0);
14771458                  WRITE_REG(arg+1, reg1);
r32680r32681
16331614                  }
16341615                  else
16351616                  {
1636                     if (m_port_r)
1637                     {
1638                        reg0 = (*m_port_r)(*this);
1639                        reg1 = (*m_port_r)(*this);
1640                     }
1641                     else
1642                        reg0 = reg1 = 0xff;
1617                     reg0 = m_port_read_cb(0);
1618                     reg1 = m_port_read_cb(0);
16431619
16441620                     reg0&=(~REG_PE);
16451621                     reg1&=(~REG_PE);
r32680r32681
16631639
16641640                  if (idx >= 5)
16651641                  {
1666                     UINT16 port = 0xff;
1667
1668                     if (m_kb_r)
1669                        port = (*m_kb_r)(*this);
1670
1642                     UINT16 port = m_kb_read_cb(0);
16711643                     src = (REG_KY & 0x0f00) | (port & 0xf0ff);
16721644                  }
16731645                  else
r32680r32681
21252097
21262098                  for (int n=GET_IM3(arg1); n>0; n--)
21272099                  {
2128                     if (m_lcd_data_w)
2129                        (*m_lcd_data_w)(*this, READ_REG(arg));
2100                     m_lcd_write_cb((offs_t)0, READ_REG(arg));
21302101
21312102                     arg++;
21322103                     m_icount -= 8;
r32680r32681
21442115
21452116                  for (int n=GET_IM3(arg1); n>0; n--)
21462117                  {
2147                     if (m_lcd_data_r)
2148                        src = (*m_lcd_data_r)(*this);
2149                     else
2150                        src = 0xff;
2118                     src = m_lcd_read_cb(0);
21512119
21522120                     WRITE_REG(arg, src++);
21532121
r32680r32681
26412609                  m_state |= CPU_SLP;
26422610
26432611                  m_irq_status = 0;
2644                  if (m_lcd_control)
2645                     (*m_lcd_control)(*this, 0);
2646
2647                  if (m_kb_w)
2648                     (*m_kb_w)(*this, 0);
2612                  m_lcd_ctrl_cb((offs_t)0, 0);
2613                  m_kb_write_cb((offs_t)0, 0);
26492614                  m_icount -= 3;
26502615               }
26512616               break;
trunk/src/mess/drivers/pb1000.c
r32680r32681
5959   virtual void machine_start();
6060   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6161   DECLARE_WRITE16_MEMBER( gatearray_w );
62   UINT16 pb2000c_kb_r();
63   UINT16 pb1000_kb_r();
64   void kb_matrix_w(UINT8 matrix);
62   DECLARE_WRITE8_MEMBER( lcd_control );
63   DECLARE_READ8_MEMBER( lcd_data_r );
64   DECLARE_WRITE8_MEMBER( lcd_data_w );
65   DECLARE_READ16_MEMBER( pb1000_kb_r );
66   DECLARE_READ16_MEMBER( pb2000c_kb_r );
67   DECLARE_WRITE8_MEMBER( kb_matrix_w );
68   DECLARE_READ8_MEMBER( pb1000_port_r );
69   DECLARE_READ8_MEMBER( pb2000c_port_r );
70   DECLARE_WRITE8_MEMBER( port_w );
6571   UINT16 read_touchscreen(UINT8 line);
6672   DECLARE_PALETTE_INIT(pb1000);
6773   TIMER_CALLBACK_MEMBER(keyboard_timer);
r32680r32681
325331      membank("bank1")->set_base(m_rom_reg->base());
326332}
327333
328static void lcd_control(hd61700_cpu_device &device, UINT8 data)
334WRITE8_MEMBER( pb1000_state::lcd_control )
329335{
330   pb1000_state *state = device.machine().driver_data<pb1000_state>();
331
332   state->m_hd44352->control_write(data);
336   m_hd44352->control_write(data);
333337}
334338
335339
336static UINT8 lcd_data_r(hd61700_cpu_device &device)
340READ8_MEMBER( pb1000_state::lcd_data_r )
337341{
338   pb1000_state *state = device.machine().driver_data<pb1000_state>();
339
340   return state->m_hd44352->data_read();
342   return m_hd44352->data_read();
341343}
342344
343345
344static void lcd_data_w(hd61700_cpu_device &device, UINT8 data)
346WRITE8_MEMBER( pb1000_state::lcd_data_w )
345347{
346   pb1000_state *state = device.machine().driver_data<pb1000_state>();
347
348   state->m_hd44352->data_write(data);
348   m_hd44352->data_write(data);
349349}
350350
351351
r32680r32681
364364}
365365
366366
367UINT16 pb1000_state::pb1000_kb_r()
367READ16_MEMBER( pb1000_state::pb1000_kb_r )
368368{
369369   static const char *const bitnames[] = {"NULL", "KO1", "KO2", "KO3", "KO4", "KO5", "KO6", "KO7", "KO8", "KO9", "KO10", "KO11", "KO12", "NULL", "NULL", "NULL"};
370370   UINT16 data = 0;
r32680r32681
388388   return data;
389389}
390390
391UINT16 pb1000_state::pb2000c_kb_r()
391READ16_MEMBER( pb1000_state::pb2000c_kb_r )
392392{
393393   static const char *const bitnames[] = {"NULL", "KO1", "KO2", "KO3", "KO4", "KO5", "KO6", "KO7", "KO8", "KO9", "KO10", "KO11", "KO12", "NULL", "NULL", "NULL"};
394394   UINT16 data = 0;
r32680r32681
410410   return data;
411411}
412412
413void pb1000_state::kb_matrix_w(UINT8 matrix)
413WRITE8_MEMBER( pb1000_state::kb_matrix_w )
414414{
415   if (matrix & 0x80)
415   if (data & 0x80)
416416   {
417      if ((m_kb_matrix & 0x80) != (matrix & 0x80))
417      if ((m_kb_matrix & 0x80) != (data & 0x80))
418418         m_kb_timer->adjust(attotime::never, 0, attotime::never);
419419   }
420420   else
421421   {
422      if ((m_kb_matrix & 0x40) != (matrix & 0x40))
422      if ((m_kb_matrix & 0x40) != (data & 0x40))
423423      {
424         if (matrix & 0x40)
424         if (data & 0x40)
425425            m_kb_timer->adjust(attotime::from_hz(32), 0, attotime::from_hz(32));
426426         else
427427            m_kb_timer->adjust(attotime::from_hz(256), 0, attotime::from_hz(256));
428428      }
429429   }
430430
431   m_kb_matrix = matrix;
431   m_kb_matrix = data;
432432}
433433
434//-------------------------------------------------
435//  HD61700 interface
436//-------------------------------------------------
437
438static void kb_matrix_w_call(hd61700_cpu_device &device, UINT8 matrix)
434READ8_MEMBER( pb1000_state::pb1000_port_r )
439435{
440   pb1000_state *state = device.machine().driver_data<pb1000_state>();
441
442   state->kb_matrix_w(matrix);
443}
444
445static UINT8 pb1000_port_r(hd61700_cpu_device &device)
446{
447436   //TODO
448437   return 0x00;
449438}
450439
451static UINT8 pb2000c_port_r(hd61700_cpu_device &device)
440READ8_MEMBER( pb1000_state::pb2000c_port_r )
452441{
453442   //TODO
454443   return 0xfc;
455444}
456445
457static void port_w(hd61700_cpu_device &device, UINT8 data)
446WRITE8_MEMBER( pb1000_state::port_w )
458447{
459   pb1000_state *state = device.machine().driver_data<pb1000_state>();
460   state->m_beeper->set_state((BIT(data,7) ^ BIT(data,6)));
448   m_beeper->set_state((BIT(data,7) ^ BIT(data,6)));
461449   //printf("%x\n", data);
462450}
463451
464static UINT16 pb1000_kb_r_call(hd61700_cpu_device &device)
465{
466   pb1000_state *state = device.machine().driver_data<pb1000_state>();
467452
468   return state->pb1000_kb_r();
469}
470
471static UINT16 pb2000c_kb_r_call(hd61700_cpu_device &device)
472{
473   pb1000_state *state = device.machine().driver_data<pb1000_state>();
474
475   return state->pb2000c_kb_r();
476}
477
478static const hd61700_config pb1000_config =
479{
480   lcd_control,            //lcd control
481   lcd_data_r,             //lcd data read
482   lcd_data_w,             //lcd data write
483   pb1000_kb_r_call,       //keyboard matrix read
484   kb_matrix_w_call,       //keyboard matrix write
485   pb1000_port_r,          //8 bit port read
486   port_w                  //8 bit port  write
487};
488
489static const hd61700_config pb2000c_config =
490{
491   lcd_control,            //lcd control
492   lcd_data_r,             //lcd data read
493   lcd_data_w,             //lcd data write
494   pb2000c_kb_r_call,      //keyboard matrix read
495   kb_matrix_w_call,       //keyboard matrix write
496   pb2000c_port_r,         //8 bit port read
497   port_w                  //8 bit port  write
498};
499
500453TIMER_CALLBACK_MEMBER(pb1000_state::keyboard_timer)
501454{
502455   m_maincpu->set_input_line(HD61700_KEY_INT, ASSERT_LINE);
r32680r32681
522475   /* basic machine hardware */
523476   MCFG_CPU_ADD("maincpu", HD61700, 910000)
524477   MCFG_CPU_PROGRAM_MAP(pb1000_mem)
525   MCFG_HD61700_CONFIG(pb1000_config)
478   MCFG_HD61700_LCD_CTRL_CB(WRITE8(pb1000_state, lcd_control))
479   MCFG_HD61700_LCD_READ_CB(READ8(pb1000_state, lcd_data_r))
480   MCFG_HD61700_LCD_WRITE_CB(WRITE8(pb1000_state, lcd_data_w))
481   MCFG_HD61700_KB_READ_CB(READ16(pb1000_state, pb1000_kb_r))
482   MCFG_HD61700_KB_WRITE_CB(WRITE8(pb1000_state, kb_matrix_w))
483   MCFG_HD61700_PORT_READ_CB(READ8(pb1000_state, pb1000_port_r))
484   MCFG_HD61700_PORT_WRITE_CB(WRITE8(pb1000_state, port_w))
526485
527486   /* video hardware */
528487   MCFG_SCREEN_ADD("screen", LCD)
r32680r32681
554513   /* basic machine hardware */
555514   MCFG_CPU_MODIFY("maincpu")
556515   MCFG_CPU_PROGRAM_MAP(pb2000c_mem)
557   MCFG_HD61700_CONFIG(pb2000c_config)
516   MCFG_HD61700_KB_READ_CB(READ16(pb1000_state, pb2000c_kb_r))
517   MCFG_HD61700_PORT_READ_CB(READ8(pb1000_state, pb2000c_port_r))
558518
559519   MCFG_GENERIC_CARTSLOT_ADD("cardslot1", generic_plain_slot, "pb2000c_card")
560520   MCFG_GENERIC_CARTSLOT_ADD("cardslot2", generic_plain_slot, "pb2000c_card")

Previous 199869 Revisions Next


© 1997-2024 The MAME Team