Previous 15994 Revisions Next

r4177 Wednesday 21st January, 2009 at 16:06:46 UTC by Dirk Best
[TTL74145] Made the interface optional
[src/mess/drivers]acrnsys1.c
[src/mess/machine]74145.c 74145.h

src/mess/machine/74145.c
r4176r4177
4646#include "74145.h"
4747
4848
49/*****************************************************************************
50 Type definitions
51*****************************************************************************/
49/***************************************************************************
50    TYPE DEFINITIONS
51***************************************************************************/
5252
53
5453typedef struct _ttl74145_t ttl74145_t;
5554struct _ttl74145_t
5655{
57   /* Pointer to our interface */
58   const ttl74145_interface *intf;
59
60   /* Decoded number */
56   /* decoded number */
6157   UINT16 number;
6258};
6359
64/*****************************************************************************
65 Implementation
66*****************************************************************************/
6760
61/***************************************************************************
62    IMPLEMENTATION
63***************************************************************************/
64
6865INLINE ttl74145_t *get_safe_token(const device_config *device)
6966{
7067   assert(device != NULL);
r4176r4177
7370   return (ttl74145_t *)device->token;
7471}
7572
76WRITE8_DEVICE_HANDLER( ttl74145_w ) {
77   /* Decode number */
73
74WRITE8_DEVICE_HANDLER( ttl74145_w )
75{
7876   ttl74145_t *ttl74145 = get_safe_token(device);
77
78   /* decode number */
7979   UINT16 new_number = bcd_2_dec(data & 0x0f);
8080
81   /* Call output callbacks if the number changed */
81   /* call output callbacks if the number changed */
8282   if (new_number != ttl74145->number)
8383   {
84      const ttl74145_interface *i = ttl74145->intf;
84      const ttl74145_interface *i = device->static_config;
8585
86      if (i->output_line_0) i->output_line_0(device, new_number == 0);
87      if (i->output_line_1) i->output_line_1(device, new_number == 1);
88      if (i->output_line_2) i->output_line_2(device, new_number == 2);
89      if (i->output_line_3) i->output_line_3(device, new_number == 3);
90      if (i->output_line_4) i->output_line_4(device, new_number == 4);
91      if (i->output_line_5) i->output_line_5(device, new_number == 5);
92      if (i->output_line_6) i->output_line_6(device, new_number == 6);
93      if (i->output_line_7) i->output_line_7(device, new_number == 7);
94      if (i->output_line_8) i->output_line_8(device, new_number == 8);
95      if (i->output_line_9) i->output_line_9(device, new_number == 9);
86      if (i != NULL)
87      {
88         if (i->output_line_0) i->output_line_0(device, new_number == 0);
89         if (i->output_line_1) i->output_line_1(device, new_number == 1);
90         if (i->output_line_2) i->output_line_2(device, new_number == 2);
91         if (i->output_line_3) i->output_line_3(device, new_number == 3);
92         if (i->output_line_4) i->output_line_4(device, new_number == 4);
93         if (i->output_line_5) i->output_line_5(device, new_number == 5);
94         if (i->output_line_6) i->output_line_6(device, new_number == 6);
95         if (i->output_line_7) i->output_line_7(device, new_number == 7);
96         if (i->output_line_8) i->output_line_8(device, new_number == 8);
97         if (i->output_line_9) i->output_line_9(device, new_number == 9);
98      }
9699   }
97100
98   /* Update state */
101   /* update state */
99102   ttl74145->number = new_number;
100103}
101104
102READ16_DEVICE_HANDLER( ttl74145_r ) {
105
106READ16_DEVICE_HANDLER( ttl74145_r )
107{
103108   ttl74145_t *ttl74145 = get_safe_token(device);
104109
105110   return ttl74145->number;
106111}
107112
108/* Device Interface */
109113
114/***************************************************************************
115    DEVICE INTERFACE
116***************************************************************************/
117
110118static DEVICE_START( ttl74145 )
111119{
112120   ttl74145_t *ttl74145 = get_safe_token(device);
113   // validate arguments
114121
122   /* validate arguments */
115123   assert(device != NULL);
116124   assert(device->tag != NULL);
117   assert(device->static_config != NULL);
118125
119   ttl74145->intf = device->static_config;
126   /* initialize with 0 */
120127   ttl74145->number = 0;
121128
122   // register for state saving
129   /* register for state saving */
123130   state_save_register_item(device->machine, "ttl74145", device->tag, 0, ttl74145->number);
131
124132   return DEVICE_START_OK;
125133}
126134
135
127136static DEVICE_RESET( ttl74145 )
128137{
129138   ttl74145_t *ttl74145 = get_safe_token(device);
130139   ttl74145->number = 0;
131140}
132141
142
133143static DEVICE_SET_INFO( ttl74145 )
134144{
135145   switch (state)
r4176r4177
138148   }
139149}
140150
151
141152DEVICE_GET_INFO( ttl74145 )
142153{
143154   switch (state)
144155   {
145156      /* --- the following bits of info are returned as 64-bit signed integers --- */
146      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(ttl74145_t);               break;
147      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                        break;
148      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;         break;
157      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(ttl74145_t);            break;
158      case DEVINFO_INT_INLINE_CONFIG_BYTES:   info->i = 0;                        break;
159      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_PERIPHERAL;         break;
149160
150161      /* --- the following bits of info are returned as pointers to data or functions --- */
151      case DEVINFO_FCT_SET_INFO:                  info->set_info = DEVICE_SET_INFO_NAME(ttl74145); break;
152      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(ttl74145);      break;
153      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
154      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(ttl74145);      break;
162      case DEVINFO_FCT_SET_INFO:            info->set_info = DEVICE_SET_INFO_NAME(ttl74145); break;
163      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(ttl74145);   break;
164      case DEVINFO_FCT_STOP:               /* Nothing */                        break;
165      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(ttl74145);   break;
155166
156167      /* --- the following bits of info are returned as NULL-terminated strings --- */
157      case DEVINFO_STR_NAME:                     strcpy(info->s, "TTL74145");            break;
158      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "TTL74145");            break;
159      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                  break;
160      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);               break;
161      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright MESS Team");      break;
168      case DEVINFO_STR_NAME:               strcpy(info->s, "TTL74145");            break;
169      case DEVINFO_STR_FAMILY:            strcpy(info->s, "TTL74145");            break;
170      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.1");                  break;
171      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);               break;
172      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright MESS Team");      break;
162173   }
163174}
src/mess/machine/74145.h
r4176r4177
44 *
55 ****************************************************************************/
66
7#ifndef TTL74145_H_
8#define TTL74145_H_
7#ifndef __TTL74145_H__
8#define __TTL74145_H__
99
10
1011/***************************************************************************
1112    MACROS
1213***************************************************************************/
1314
1415#define TTL74145      DEVICE_GET_INFO_NAME(ttl74145)
1516
17
1618/***************************************************************************
1719    TYPE DEFINITIONS
1820***************************************************************************/
r4176r4177
2123#define TTL74145_OUTPUT_LINE(name)   void name(const device_config *device, int state )
2224
2325
24/* Interface */
26/* interface */
2527typedef struct _ttl74145_interface ttl74145_interface;
2628struct _ttl74145_interface
2729{
28   /* Outputs */
30   /* outputs */
2931   ttl74145_output_line_func output_line_0;
3032   ttl74145_output_line_func output_line_1;
3133   ttl74145_output_line_func output_line_2;
r4176r4177
4648/* device interface */
4749DEVICE_GET_INFO( ttl74145 );
4850
49/* Standard handlers */
51/* standard handlers */
5052WRITE8_DEVICE_HANDLER( ttl74145_w );
5153READ16_DEVICE_HANDLER( ttl74145_r );
5254
55
5356/***************************************************************************
5457    DEVICE CONFIGURATION MACROS
5558***************************************************************************/
5659
57#define MDRV_TTL74145_ADD(_tag, _intrf) \
58   MDRV_DEVICE_ADD(_tag, TTL74145, 0) \
60#define MDRV_TTL74145_ADD(_tag) \
61   MDRV_DEVICE_ADD(_tag, TTL74145, 0)
62
63#define MDRV_TTL74145_CONFIG(_intrf) \
5964   MDRV_DEVICE_CONFIG(_intrf)
6065
6166
62#endif /*TTL74145_H_*/
67#endif /* __TTL74145_H__ */
src/mess/drivers/acrnsys1.c
r4176r4177
2626static READ8_DEVICE_HANDLER( ins8154_b1_port_a_r )
2727{
2828   UINT8 data;
29   static const char *const keynames[] = { "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3",
29   static const char *const keynames[] = { "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3",
3030                              "keyboard_4", "keyboard_5", "keyboard_6", "keyboard_7" };
3131
3232   data = input_port_read(device->machine, keynames[key_digit]);
r4176r4177
4242static WRITE8_DEVICE_HANDLER( acrnsys1_led_segment_w )
4343{
4444   logerror("led %d segment data: %02x\n", key_digit, data);
45   
45
4646   output_set_digit_value(key_digit + 0, data);
4747}
4848
r4176r4177
112112   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("M") PORT_CODE(KEYCODE_M) PORT_CHAR('M')
113113   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("0") PORT_CODE(KEYCODE_0) PORT_CHAR('0')
114114   PORT_BIT(0xc7, IP_ACTIVE_LOW, IPT_UNUSED)
115   
115
116116   PORT_START("keyboard_1")
117117   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("9") PORT_CODE(KEYCODE_9) PORT_CHAR('9')
118118   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("G") PORT_CODE(KEYCODE_G) PORT_CHAR('G')
r4176r4177
130130   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("S") PORT_CODE(KEYCODE_S) PORT_CHAR('S')
131131   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("3") PORT_CODE(KEYCODE_3) PORT_CHAR('3')
132132   PORT_BIT(0xc7, IP_ACTIVE_LOW, IPT_UNUSED)
133   
133
134134   PORT_START("keyboard_4")
135135   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("C") PORT_CODE(KEYCODE_C) PORT_CHAR('C')
136136   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("L") PORT_CODE(KEYCODE_L) PORT_CHAR('L')
r4176r4177
158158   PORT_START("reset")
159159   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("RST") PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3))
160160   PORT_BIT(0xfe, IP_ACTIVE_LOW, IPT_UNUSED)
161   
161
162162   PORT_START("switch")
163163   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Switch") PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F1))
164164   PORT_BIT(0xfe, IP_ACTIVE_LOW, IPT_UNUSED)
r4176r4177
183183   MDRV_CPU_PROGRAM_MAP(acrnsys1_map, 0)
184184
185185   MDRV_MACHINE_RESET(acrnsys1)
186   
186
187187   MDRV_DEFAULT_LAYOUT(layout_acrnsys1)
188   
188
189189   /* devices */
190190   MDRV_INS8154_ADD("b1", ins8154_b1)
191   MDRV_TTL74145_ADD("ttl74145", ic8_7445)
191   MDRV_TTL74145_ADD("ttl74145")
192   MDRV_TTL74145_CONFIG(ic8_7445)
192193MACHINE_DRIVER_END
193194
194195

Previous 15994 Revisions Next


© 1998-2018 The MESS Team