Previous 199869 Revisions Next

r18553 Tuesday 16th October, 2012 at 07:51:10 UTC by Miodrag Milanović
updated i8243 to use devcb2 and remove trampolines (no whatsnew)
[src/emu/machine]i8243.c i8243.h
[src/mame/audio]segag80r.c
[src/mame/drivers]othello.c segas16a.c
[src/mame/includes]segas16a.h
[src/mess/drivers]fidelz80.c
[src/mess/includes]fidelz80.h

trunk/src/mame/includes/segas16a.h
r18552r18553
9191   DECLARE_WRITE8_MEMBER( n7751_command_w );
9292   DECLARE_WRITE8_MEMBER( n7751_control_w );
9393   DECLARE_WRITE8_MEMBER( n7751_rom_offset_w );
94   static DECLARE_WRITE8_DEVICE_HANDLER( static_n7751_rom_offset_w );
9594
9695   // N7751 sound generator CPU read/write handlers
9796   DECLARE_READ8_MEMBER( n7751_rom_r );
trunk/src/mame/drivers/othello.c
r18552r18553
9090   DECLARE_READ8_MEMBER(n7751_command_r);
9191   DECLARE_READ8_MEMBER(n7751_t1_r);
9292   DECLARE_WRITE8_MEMBER(n7751_p2_w);
93   DECLARE_WRITE8_MEMBER(n7751_rom_control_w);
9394   virtual void machine_start();
9495   virtual void machine_reset();
9596   virtual void palette_init();
r18552r18553
250251   AM_RANGE(0x08, 0x08) AM_WRITE(ay_select_w)
251252ADDRESS_MAP_END
252253
253static WRITE8_DEVICE_HANDLER( n7751_rom_control_w )
254WRITE8_MEMBER(othello_state::n7751_rom_control_w)
254255{
255   othello_state *state = space.machine().driver_data<othello_state>();
256
257256   /* P4 - address lines 0-3 */
258257   /* P5 - address lines 4-7 */
259258   /* P6 - address lines 8-11 */
r18552r18553
261260   switch (offset)
262261   {
263262      case 0:
264         state->m_sound_addr = (state->m_sound_addr & ~0x00f) | ((data & 0x0f) << 0);
263         m_sound_addr = (m_sound_addr & ~0x00f) | ((data & 0x0f) << 0);
265264         break;
266265
267266      case 1:
268         state->m_sound_addr = (state->m_sound_addr & ~0x0f0) | ((data & 0x0f) << 4);
267         m_sound_addr = (m_sound_addr & ~0x0f0) | ((data & 0x0f) << 4);
269268         break;
270269
271270      case 2:
272         state->m_sound_addr = (state->m_sound_addr & ~0xf00) | ((data & 0x0f) << 8);
271         m_sound_addr = (m_sound_addr & ~0xf00) | ((data & 0x0f) << 8);
273272         break;
274273
275274      case 3:
276         state->m_sound_addr &= 0xfff;
275         m_sound_addr &= 0xfff;
277276         {
278277
279            if (!BIT(data, 0)) state->m_sound_addr |= 0x0000;
280            if (!BIT(data, 1)) state->m_sound_addr |= 0x1000;
281            if (!BIT(data, 2)) state->m_sound_addr |= 0x2000;
282            if (!BIT(data, 3)) state->m_sound_addr |= 0x3000;
278            if (!BIT(data, 0)) m_sound_addr |= 0x0000;
279            if (!BIT(data, 1)) m_sound_addr |= 0x1000;
280            if (!BIT(data, 2)) m_sound_addr |= 0x2000;
281            if (!BIT(data, 3)) m_sound_addr |= 0x3000;
283282         }
284283         break;
285284   }
r18552r18553
297296
298297WRITE8_MEMBER(othello_state::n7751_p2_w)
299298{
300   device_t *device = machine().device("n7751_8243");
299   i8243_device *device = machine().device<i8243_device>("n7751_8243");
301300
302301   /* write to P2; low 4 bits go to 8243 */
303   i8243_p2_w(device, space, offset, data & 0x0f);
302   device->i8243_p2_w(space, offset, data & 0x0f);
304303
305304   /* output of bit $80 indicates we are ready (1) or busy (0) */
306305   /* no other outputs are used */
r18552r18553
319318   AM_RANGE(MCS48_PORT_BUS,  MCS48_PORT_BUS) AM_READ(n7751_rom_r)
320319   AM_RANGE(MCS48_PORT_P1,   MCS48_PORT_P1) AM_DEVWRITE("dac", dac_device, write_unsigned8)
321320   AM_RANGE(MCS48_PORT_P2,   MCS48_PORT_P2) AM_WRITE(n7751_p2_w)
322   AM_RANGE(MCS48_PORT_PROG, MCS48_PORT_PROG) AM_DEVWRITE_LEGACY("n7751_8243", i8243_prog_w)
321   AM_RANGE(MCS48_PORT_PROG, MCS48_PORT_PROG) AM_DEVWRITE("n7751_8243", i8243_device, i8243_prog_w)
323322ADDRESS_MAP_END
324323
325324static INPUT_PORTS_START( othello )
r18552r18553
426425   MCFG_CPU_ADD("n7751", N7751, XTAL_6MHz)
427426   MCFG_CPU_IO_MAP(n7751_portmap)
428427
429   MCFG_I8243_ADD("n7751_8243", NULL, n7751_rom_control_w)
428   MCFG_I8243_ADD("n7751_8243", NOOP, WRITE8(othello_state,n7751_rom_control_w))
430429
431430
432431   /* video hardware */
trunk/src/mame/drivers/segas16a.c
r18552r18553
424424   m_n7751_rom_address = (m_n7751_rom_address & ~mask) | newdata;
425425}
426426
427WRITE8_DEVICE_HANDLER( segas16a_state::static_n7751_rom_offset_w )
428{
429   segas16a_state *state = space.machine().driver_data<segas16a_state>();
430   state->n7751_rom_offset_w(state->m_maincpu->space(AS_PROGRAM), offset, data);
431}
432
433
434
435427//**************************************************************************
436428//  N7751 SOUND GENERATOR CPU READ/WRITE HANDLERS
437429//**************************************************************************
r18552r18553
455447{
456448   // read from P2 - 8255's PC0-2 connects to 7751's S0-2 (P24-P26 on an 8048)
457449   // bit 0x80 is an alternate way to control the sample on/off; doesn't appear to be used
458   return 0x80 | ((m_n7751_command & 0x07) << 4) | (i8243_p2_r(m_n7751_i8243, space, offset) & 0x0f);
450   return 0x80 | ((m_n7751_command & 0x07) << 4) | (m_n7751_i8243->i8243_p2_r(space, offset) & 0x0f);
459451}
460452
461453
r18552r18553
466458WRITE8_MEMBER( segas16a_state::n7751_p2_w )
467459{
468460   // write to P2; low 4 bits go to 8243
469   i8243_p2_w(m_n7751_i8243, space, offset, data & 0x0f);
461   m_n7751_i8243->i8243_p2_w(space, offset, data & 0x0f);
470462
471463   // output of bit $80 indicates we are ready (1) or busy (0)
472464   // no other outputs are used
r18552r18553
10461038   AM_RANGE(MCS48_PORT_T1,   MCS48_PORT_T1)   AM_READ(n7751_t1_r)
10471039   AM_RANGE(MCS48_PORT_P1,   MCS48_PORT_P1)   AM_DEVWRITE("dac", dac_device, write_unsigned8)
10481040   AM_RANGE(MCS48_PORT_P2,   MCS48_PORT_P2)   AM_READWRITE(n7751_p2_r, n7751_p2_w)
1049   AM_RANGE(MCS48_PORT_PROG, MCS48_PORT_PROG) AM_DEVWRITE_LEGACY("n7751_8243", i8243_prog_w)
1041   AM_RANGE(MCS48_PORT_PROG, MCS48_PORT_PROG) AM_DEVWRITE("n7751_8243", i8243_device, i8243_prog_w)
10501042ADDRESS_MAP_END
10511043
10521044
r18552r18553
19441936   MCFG_CPU_ADD("n7751", N7751, 6000000)
19451937   MCFG_CPU_IO_MAP(n7751_portmap)
19461938
1947   MCFG_I8243_ADD("n7751_8243", NULL, segas16a_state::static_n7751_rom_offset_w)
1939   MCFG_I8243_ADD("n7751_8243", NOOP, WRITE8(segas16a_state,n7751_rom_offset_w))
19481940
19491941   MCFG_NVRAM_ADD_0FILL("nvram")
19501942
trunk/src/mame/audio/segag80r.c
r18552r18553
780780
781781static SOUND_START( monsterb );
782782
783static DECLARE_WRITE8_DEVICE_HANDLER( n7751_rom_control_w );
784
785783/*
786784    Monster Bash
787785
r18552r18553
829827   AM_RANGE(MCS48_PORT_BUS,  MCS48_PORT_BUS) AM_READ(n7751_rom_r)
830828   AM_RANGE(MCS48_PORT_P1,   MCS48_PORT_P1) AM_DEVWRITE("dac", dac_device, write_unsigned8)
831829   AM_RANGE(MCS48_PORT_P2,   MCS48_PORT_P2) AM_WRITE(n7751_p2_w)
832   AM_RANGE(MCS48_PORT_PROG, MCS48_PORT_PROG) AM_DEVWRITE_LEGACY("audio_8243", i8243_prog_w)
830   AM_RANGE(MCS48_PORT_PROG, MCS48_PORT_PROG) AM_DEVWRITE("audio_8243", i8243_device, i8243_prog_w)
833831ADDRESS_MAP_END
834832
835833
r18552r18553
859857   MCFG_CPU_ADD("audiocpu", N7751, 6000000)
860858   MCFG_CPU_IO_MAP(monsterb_7751_portmap)
861859
862   MCFG_I8243_ADD("audio_8243", NULL, n7751_rom_control_w)
860   MCFG_I8243_ADD("audio_8243", NOOP, WRITE8(segag80r_state,n7751_rom_control_w))
863861
864862   /* sound hardware */
865863   MCFG_SOUND_START(monsterb)
r18552r18553
964962}
965963
966964
967static WRITE8_DEVICE_HANDLER( n7751_rom_control_w )
965WRITE8_MEMBER(segag80r_state::n7751_rom_control_w)
968966{
969   segag80r_state *state = space.machine().driver_data<segag80r_state>();
970967   /* P4 - address lines 0-3 */
971968   /* P5 - address lines 4-7 */
972969   /* P6 - address lines 8-11 */
r18552r18553
974971   switch (offset)
975972   {
976973      case 0:
977         state->m_sound_addr = (state->m_sound_addr & ~0x00f) | ((data & 0x0f) << 0);
974         m_sound_addr = (m_sound_addr & ~0x00f) | ((data & 0x0f) << 0);
978975         break;
979976
980977      case 1:
981         state->m_sound_addr = (state->m_sound_addr & ~0x0f0) | ((data & 0x0f) << 4);
978         m_sound_addr = (m_sound_addr & ~0x0f0) | ((data & 0x0f) << 4);
982979         break;
983980
984981      case 2:
985         state->m_sound_addr = (state->m_sound_addr & ~0xf00) | ((data & 0x0f) << 8);
982         m_sound_addr = (m_sound_addr & ~0xf00) | ((data & 0x0f) << 8);
986983         break;
987984
988985      case 3:
989         state->m_sound_addr &= 0xfff;
986         m_sound_addr &= 0xfff;
990987         {
991            int numroms = state->memregion("n7751")->bytes() / 0x1000;
992            if (!(data & 0x01) && numroms >= 1) state->m_sound_addr |= 0x0000;
993            if (!(data & 0x02) && numroms >= 2) state->m_sound_addr |= 0x1000;
994            if (!(data & 0x04) && numroms >= 3) state->m_sound_addr |= 0x2000;
995            if (!(data & 0x08) && numroms >= 4) state->m_sound_addr |= 0x3000;
988            int numroms = memregion("n7751")->bytes() / 0x1000;
989            if (!(data & 0x01) && numroms >= 1) m_sound_addr |= 0x0000;
990            if (!(data & 0x02) && numroms >= 2) m_sound_addr |= 0x1000;
991            if (!(data & 0x04) && numroms >= 3) m_sound_addr |= 0x2000;
992            if (!(data & 0x08) && numroms >= 4) m_sound_addr |= 0x3000;
996993         }
997994         break;
998995   }
r18552r18553
10161013
10171014WRITE8_MEMBER(segag80r_state::n7751_p2_w)
10181015{
1019   device_t *device = machine().device("audio_8243");
1016   i8243_device *device = machine().device<i8243_device>("audio_8243");
10201017   /* write to P2; low 4 bits go to 8243 */
1021   i8243_p2_w(device, space, offset, data & 0x0f);
1018   device->i8243_p2_w(space, offset, data & 0x0f);
10221019
10231020   /* output of bit $80 indicates we are ready (1) or busy (0) */
10241021   /* no other outputs are used */
trunk/src/emu/machine/i8243.c
r18552r18553
2424//-------------------------------------------------
2525
2626i8243_device::i8243_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
27    : device_t(mconfig, I8243, "I8243", tag, owner, clock)
27    : device_t(mconfig, I8243, "I8243", tag, owner, clock),
28     m_readhandler(*this),
29     m_writehandler(*this)
2830{
29
3031}
3132
32
3333//-------------------------------------------------
34//  static_set_read_handler - configuration helper
35//  to set the read handler
36//-------------------------------------------------
37
38void i8243_device::static_set_read_handler(device_t &device, read8_device_func callback)
39{
40   i8243_device &i8243 = downcast<i8243_device &>(device);
41   if(callback != NULL)
42   {
43      i8243.m_readhandler_cb.type = DEVCB_TYPE_DEVICE;
44      i8243.m_readhandler_cb.index = 0;
45      i8243.m_readhandler_cb.tag = "";
46      i8243.m_readhandler_cb.readdevice = callback;
47   }
48   else
49   {
50      i8243.m_readhandler_cb.type = DEVCB_TYPE_NULL;
51   }
52}
53
54
55//-------------------------------------------------
56//  static_set_write_handler - configuration helper
57//  to set the write handler
58//-------------------------------------------------
59
60void i8243_device::static_set_write_handler(device_t &device, write8_device_func callback)
61{
62   i8243_device &i8243 = downcast<i8243_device &>(device);
63   if(callback != NULL)
64   {
65      i8243.m_writehandler_cb.type = DEVCB_TYPE_DEVICE;
66      i8243.m_writehandler_cb.index = 0;
67      i8243.m_writehandler_cb.tag = "";
68      i8243.m_writehandler_cb.writedevice = callback;
69   }
70   else
71   {
72      i8243.m_writehandler_cb.type = DEVCB_TYPE_NULL;
73   }
74}
75
76
77//-------------------------------------------------
7834//  device_start - device-specific startup
7935//-------------------------------------------------
8036
8137void i8243_device::device_start()
8238{
83   m_readhandler.resolve(m_readhandler_cb, *this);
84   m_writehandler.resolve(m_writehandler_cb, *this);
39   m_readhandler.resolve_safe(0);
40   m_writehandler.resolve_safe();
8541}
8642
8743
r18552r18553
10157    i8243_p2_r - handle a read from port 2
10258-------------------------------------------------*/
10359
104READ8_DEVICE_HANDLER_TRAMPOLINE(i8243, i8243_p2_r)
60READ8_MEMBER(i8243_device::i8243_p2_r)
10561{
10662   return m_p2out;
10763}
r18552r18553
11167    i8243_p2_r - handle a write to port 2
11268-------------------------------------------------*/
11369
114WRITE8_DEVICE_HANDLER_TRAMPOLINE(i8243, i8243_p2_w)
70WRITE8_MEMBER(i8243_device::i8243_p2_w)
11571{
11672   m_p2 = data & 0x0f;
11773}
r18552r18553
12278    line state
12379-------------------------------------------------*/
12480
125WRITE8_DEVICE_HANDLER_TRAMPOLINE(i8243, i8243_prog_w)
81WRITE8_MEMBER(i8243_device::i8243_prog_w)
12682{
12783   /* only care about low bit */
12884   data &= 1;
r18552r18553
150106      {
151107         case MCS48_EXPANDER_OP_WRITE:
152108            m_p[m_opcode & 3] = m_p2 & 0x0f;
153            m_writehandler(m_opcode & 3, m_p[m_opcode & 3]);
109            m_writehandler((UINT8)(m_opcode & 3), (UINT8)(m_p[m_opcode & 3]));
154110            break;
155111
156112         case MCS48_EXPANDER_OP_OR:
157113            m_p[m_opcode & 3] |= m_p2 & 0x0f;
158            m_writehandler(m_opcode & 3, m_p[m_opcode & 3]);
114            m_writehandler((UINT8)(m_opcode & 3), (UINT8)(m_p[m_opcode & 3]));
159115            break;
160116
161117         case MCS48_EXPANDER_OP_AND:
162118            m_p[m_opcode & 3] &= m_p2 & 0x0f;
163            m_writehandler(m_opcode & 3, m_p[m_opcode & 3]);
119            m_writehandler((UINT8)(m_opcode & 3), (UINT8)(m_p[m_opcode & 3]));
164120            break;
165121      }
166122   }
trunk/src/emu/machine/i8243.h
r18552r18553
2727   MCFG_I8243_READHANDLER(_read) \
2828   MCFG_I8243_WRITEHANDLER(_write) \
2929
30#define MCFG_I8243_READHANDLER(_read) \
31   i8243_device::static_set_read_handler(*device, _read); \
30#define MCFG_I8243_READHANDLER(_devcb) \
31   devcb = &i8243_device::set_read_handler(*device, DEVCB2_##_devcb); \
3232
33#define MCFG_I8243_WRITEHANDLER(_write) \
34   i8243_device::static_set_write_handler(*device, _write); \
33#define MCFG_I8243_WRITEHANDLER(_devcb) \
34   devcb = &i8243_device::set_write_handler(*device, DEVCB2_##_devcb); \
3535
3636/***************************************************************************
3737    TYPE DEFINITIONS
r18552r18553
4646    // construction/destruction
4747    i8243_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
4848
49   // inline configuration helpers
50   static void static_set_read_handler(device_t &device, read8_device_func callback);
51   static void static_set_write_handler(device_t &device, write8_device_func callback);
49   // static configuration helpers
50   template<class _Object> static devcb2_base &set_read_handler(device_t &device, _Object object) { return downcast<i8243_device &>(device).m_readhandler.set_callback(object); }
51   template<class _Object> static devcb2_base &set_write_handler(device_t &device, _Object object) { return downcast<i8243_device &>(device).m_writehandler.set_callback(object); }
52 
53   DECLARE_READ8_MEMBER(i8243_p2_r);
54   DECLARE_WRITE8_MEMBER(i8243_p2_w);
5255
56   DECLARE_WRITE8_MEMBER(i8243_prog_w);
5357
54   UINT8 i8243_p2_r(UINT32 offset);
55   void i8243_p2_w(UINT32 offset, UINT8 data);
56
57   void i8243_prog_w(UINT32 offset, UINT8 data);
58
5958protected:
6059    // device-level overrides
6160    virtual void device_start();
r18552r18553
7170   UINT8      m_opcode;         /* latched opcode */
7271   UINT8      m_prog;            /* previous PROG state */
7372
74   devcb_read8      m_readhandler_cb;
75   devcb_write8   m_writehandler_cb;
76
77   devcb_resolved_read8   m_readhandler;
78   devcb_resolved_write8   m_writehandler;
73   devcb2_read8   m_readhandler;
74   devcb2_write8   m_writehandler;
7975};
8076
8177
8278// device type definition
8379extern const device_type I8243;
8480
85
86
87/***************************************************************************
88    PROTOTYPES
89***************************************************************************/
90
91DECLARE_READ8_DEVICE_HANDLER( i8243_p2_r );
92DECLARE_WRITE8_DEVICE_HANDLER( i8243_p2_w );
93
94DECLARE_WRITE8_DEVICE_HANDLER( i8243_prog_w );
95
96
9781#endif  /* __I8243_H__ */
trunk/src/mess/includes/fidelz80.h
r18552r18553
6666   DECLARE_INPUT_CHANGED_MEMBER(fidelz80_trigger_reset);
6767   DECLARE_INPUT_CHANGED_MEMBER(abc_trigger_reset);
6868   TIMER_DEVICE_CALLBACK_MEMBER(nmi_timer);
69   
70   DECLARE_WRITE8_MEMBER(digit_w);
6971};
7072
7173
trunk/src/mess/drivers/fidelz80.c
r18552r18553
918918   if (m_kp_matrix & 0x80)
919919      data &= ioport("LINE8")->read();
920920
921   return (m_i8243->i8243_p2_r(offset)&0x0f) | (data&0xf0);
921   return (m_i8243->i8243_p2_r(space, offset)&0x0f) | (data&0xf0);
922922}
923923
924924WRITE8_MEMBER(fidelz80_state::exp_i8243_p2_w)
925925{
926   m_i8243->i8243_p2_w(offset, data&0x0f);
926   m_i8243->i8243_p2_w(space, offset, data&0x0f);
927927}
928928
929929// probably related to the card scanner
r18552r18553
941941    I8243 expander
942942******************************************************************************/
943943
944static WRITE8_DEVICE_HANDLER( digit_w )
944WRITE8_MEMBER(fidelz80_state::digit_w)
945945{
946   fidelz80_state *state = space.machine().driver_data<fidelz80_state>();
947
948   if (state->m_digit_line_status[offset])
946   if (m_digit_line_status[offset])
949947      return;
950948
951   state->m_digit_line_status[offset&3] = 1;
949   m_digit_line_status[offset&3] = 1;
952950
953951   switch (offset)
954952   {
955953   case 0:
956      state->m_digit_data = (state->m_digit_data&(~0x000f)) | ((data<<0)&0x000f);
954      m_digit_data = (m_digit_data&(~0x000f)) | ((data<<0)&0x000f);
957955      break;
958956   case 1:
959      state->m_digit_data = (state->m_digit_data&(~0x00f0)) | ((data<<4)&0x00f0);
957      m_digit_data = (m_digit_data&(~0x00f0)) | ((data<<4)&0x00f0);
960958      break;
961959   case 2:
962      state->m_digit_data = (state->m_digit_data&(~0x0f00)) | ((data<<8)&0x0f00);
960      m_digit_data = (m_digit_data&(~0x0f00)) | ((data<<8)&0x0f00);
963961      break;
964962   case 3:
965      state->m_digit_data = (state->m_digit_data&(~0xf000)) | ((data<<12)&0xf000);
963      m_digit_data = (m_digit_data&(~0xf000)) | ((data<<12)&0xf000);
966964      break;
967965   }
968966}
r18552r18553
10721070   ADDRESS_MAP_UNMAP_LOW
10731071   AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_WRITE(kp_matrix_w)
10741072   AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_READWRITE(exp_i8243_p2_r, exp_i8243_p2_w)
1075   AM_RANGE(MCS48_PORT_PROG, MCS48_PORT_PROG) AM_DEVWRITE_LEGACY("i8243", i8243_prog_w)
1073   AM_RANGE(MCS48_PORT_PROG, MCS48_PORT_PROG) AM_DEVWRITE("i8243", i8243_device, i8243_prog_w)
10761074
10771075   // related to the card scanner, probably clock and data optical
10781076   AM_RANGE(MCS48_PORT_T0, MCS48_PORT_T0) AM_READ(unknown_r)
r18552r18553
13581356   MCFG_CPU_ADD("mcu", I8041, XTAL_5MHz) // 5MHz
13591357   MCFG_CPU_IO_MAP(abc_mcu_io)
13601358
1361   MCFG_I8243_ADD("i8243", NULL, digit_w)
1359   MCFG_I8243_ADD("i8243", NOOP, WRITE8(fidelz80_state,digit_w))
13621360
13631361   /* sound hardware */
13641362   MCFG_SPEAKER_STANDARD_MONO( "mono" )

Previous 199869 Revisions Next


© 1997-2024 The MAME Team