src/mess/machine/74145.c
| r4176 | r4177 | |
| 46 | 46 | #include "74145.h" |
| 47 | 47 | |
| 48 | 48 | |
| 49 | | /***************************************************************************** |
| 50 | | Type definitions |
| 51 | | *****************************************************************************/ |
| 49 | /*************************************************************************** |
| 50 | TYPE DEFINITIONS |
| 51 | ***************************************************************************/ |
| 52 | 52 | |
| 53 | | |
| 54 | 53 | typedef struct _ttl74145_t ttl74145_t; |
| 55 | 54 | struct _ttl74145_t |
| 56 | 55 | { |
| 57 | | /* Pointer to our interface */ |
| 58 | | const ttl74145_interface *intf; |
| 59 | | |
| 60 | | /* Decoded number */ |
| 56 | /* decoded number */ |
| 61 | 57 | UINT16 number; |
| 62 | 58 | }; |
| 63 | 59 | |
| 64 | | /***************************************************************************** |
| 65 | | Implementation |
| 66 | | *****************************************************************************/ |
| 67 | 60 | |
| 61 | /*************************************************************************** |
| 62 | IMPLEMENTATION |
| 63 | ***************************************************************************/ |
| 64 | |
| 68 | 65 | INLINE ttl74145_t *get_safe_token(const device_config *device) |
| 69 | 66 | { |
| 70 | 67 | assert(device != NULL); |
| r4176 | r4177 | |
| 73 | 70 | return (ttl74145_t *)device->token; |
| 74 | 71 | } |
| 75 | 72 | |
| 76 | | WRITE8_DEVICE_HANDLER( ttl74145_w ) { |
| 77 | | /* Decode number */ |
| 73 | |
| 74 | WRITE8_DEVICE_HANDLER( ttl74145_w ) |
| 75 | { |
| 78 | 76 | ttl74145_t *ttl74145 = get_safe_token(device); |
| 77 | |
| 78 | /* decode number */ |
| 79 | 79 | UINT16 new_number = bcd_2_dec(data & 0x0f); |
| 80 | 80 | |
| 81 | | /* Call output callbacks if the number changed */ |
| 81 | /* call output callbacks if the number changed */ |
| 82 | 82 | if (new_number != ttl74145->number) |
| 83 | 83 | { |
| 84 | | const ttl74145_interface *i = ttl74145->intf; |
| 84 | const ttl74145_interface *i = device->static_config; |
| 85 | 85 | |
| 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 | } |
| 96 | 99 | } |
| 97 | 100 | |
| 98 | | /* Update state */ |
| 101 | /* update state */ |
| 99 | 102 | ttl74145->number = new_number; |
| 100 | 103 | } |
| 101 | 104 | |
| 102 | | READ16_DEVICE_HANDLER( ttl74145_r ) { |
| 105 | |
| 106 | READ16_DEVICE_HANDLER( ttl74145_r ) |
| 107 | { |
| 103 | 108 | ttl74145_t *ttl74145 = get_safe_token(device); |
| 104 | 109 | |
| 105 | 110 | return ttl74145->number; |
| 106 | 111 | } |
| 107 | 112 | |
| 108 | | /* Device Interface */ |
| 109 | 113 | |
| 114 | /*************************************************************************** |
| 115 | DEVICE INTERFACE |
| 116 | ***************************************************************************/ |
| 117 | |
| 110 | 118 | static DEVICE_START( ttl74145 ) |
| 111 | 119 | { |
| 112 | 120 | ttl74145_t *ttl74145 = get_safe_token(device); |
| 113 | | // validate arguments |
| 114 | 121 | |
| 122 | /* validate arguments */ |
| 115 | 123 | assert(device != NULL); |
| 116 | 124 | assert(device->tag != NULL); |
| 117 | | assert(device->static_config != NULL); |
| 118 | 125 | |
| 119 | | ttl74145->intf = device->static_config; |
| 126 | /* initialize with 0 */ |
| 120 | 127 | ttl74145->number = 0; |
| 121 | 128 | |
| 122 | | // register for state saving |
| 129 | /* register for state saving */ |
| 123 | 130 | state_save_register_item(device->machine, "ttl74145", device->tag, 0, ttl74145->number); |
| 131 | |
| 124 | 132 | return DEVICE_START_OK; |
| 125 | 133 | } |
| 126 | 134 | |
| 135 | |
| 127 | 136 | static DEVICE_RESET( ttl74145 ) |
| 128 | 137 | { |
| 129 | 138 | ttl74145_t *ttl74145 = get_safe_token(device); |
| 130 | 139 | ttl74145->number = 0; |
| 131 | 140 | } |
| 132 | 141 | |
| 142 | |
| 133 | 143 | static DEVICE_SET_INFO( ttl74145 ) |
| 134 | 144 | { |
| 135 | 145 | switch (state) |
| r4176 | r4177 | |
| 138 | 148 | } |
| 139 | 149 | } |
| 140 | 150 | |
| 151 | |
| 141 | 152 | DEVICE_GET_INFO( ttl74145 ) |
| 142 | 153 | { |
| 143 | 154 | switch (state) |
| 144 | 155 | { |
| 145 | 156 | /* --- 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; |
| 149 | 160 | |
| 150 | 161 | /* --- 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; |
| 155 | 166 | |
| 156 | 167 | /* --- 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; |
| 162 | 173 | } |
| 163 | 174 | } |
src/mess/machine/74145.h
| r4176 | r4177 | |
| 4 | 4 | * |
| 5 | 5 | ****************************************************************************/ |
| 6 | 6 | |
| 7 | | #ifndef TTL74145_H_ |
| 8 | | #define TTL74145_H_ |
| 7 | #ifndef __TTL74145_H__ |
| 8 | #define __TTL74145_H__ |
| 9 | 9 | |
| 10 | |
| 10 | 11 | /*************************************************************************** |
| 11 | 12 | MACROS |
| 12 | 13 | ***************************************************************************/ |
| 13 | 14 | |
| 14 | 15 | #define TTL74145 DEVICE_GET_INFO_NAME(ttl74145) |
| 15 | 16 | |
| 17 | |
| 16 | 18 | /*************************************************************************** |
| 17 | 19 | TYPE DEFINITIONS |
| 18 | 20 | ***************************************************************************/ |
| r4176 | r4177 | |
| 21 | 23 | #define TTL74145_OUTPUT_LINE(name) void name(const device_config *device, int state ) |
| 22 | 24 | |
| 23 | 25 | |
| 24 | | /* Interface */ |
| 26 | /* interface */ |
| 25 | 27 | typedef struct _ttl74145_interface ttl74145_interface; |
| 26 | 28 | struct _ttl74145_interface |
| 27 | 29 | { |
| 28 | | /* Outputs */ |
| 30 | /* outputs */ |
| 29 | 31 | ttl74145_output_line_func output_line_0; |
| 30 | 32 | ttl74145_output_line_func output_line_1; |
| 31 | 33 | ttl74145_output_line_func output_line_2; |
| r4176 | r4177 | |
| 46 | 48 | /* device interface */ |
| 47 | 49 | DEVICE_GET_INFO( ttl74145 ); |
| 48 | 50 | |
| 49 | | /* Standard handlers */ |
| 51 | /* standard handlers */ |
| 50 | 52 | WRITE8_DEVICE_HANDLER( ttl74145_w ); |
| 51 | 53 | READ16_DEVICE_HANDLER( ttl74145_r ); |
| 52 | 54 | |
| 55 | |
| 53 | 56 | /*************************************************************************** |
| 54 | 57 | DEVICE CONFIGURATION MACROS |
| 55 | 58 | ***************************************************************************/ |
| 56 | 59 | |
| 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) \ |
| 59 | 64 | MDRV_DEVICE_CONFIG(_intrf) |
| 60 | 65 | |
| 61 | 66 | |
| 62 | | #endif /*TTL74145_H_*/ |
| 67 | #endif /* __TTL74145_H__ */ |
src/mess/drivers/acrnsys1.c
| r4176 | r4177 | |
| 26 | 26 | static READ8_DEVICE_HANDLER( ins8154_b1_port_a_r ) |
| 27 | 27 | { |
| 28 | 28 | 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", |
| 30 | 30 | "keyboard_4", "keyboard_5", "keyboard_6", "keyboard_7" }; |
| 31 | 31 | |
| 32 | 32 | data = input_port_read(device->machine, keynames[key_digit]); |
| r4176 | r4177 | |
| 42 | 42 | static WRITE8_DEVICE_HANDLER( acrnsys1_led_segment_w ) |
| 43 | 43 | { |
| 44 | 44 | logerror("led %d segment data: %02x\n", key_digit, data); |
| 45 | | |
| 45 | |
| 46 | 46 | output_set_digit_value(key_digit + 0, data); |
| 47 | 47 | } |
| 48 | 48 | |
| r4176 | r4177 | |
| 112 | 112 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("M") PORT_CODE(KEYCODE_M) PORT_CHAR('M') |
| 113 | 113 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("0") PORT_CODE(KEYCODE_0) PORT_CHAR('0') |
| 114 | 114 | PORT_BIT(0xc7, IP_ACTIVE_LOW, IPT_UNUSED) |
| 115 | | |
| 115 | |
| 116 | 116 | PORT_START("keyboard_1") |
| 117 | 117 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("9") PORT_CODE(KEYCODE_9) PORT_CHAR('9') |
| 118 | 118 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("G") PORT_CODE(KEYCODE_G) PORT_CHAR('G') |
| r4176 | r4177 | |
| 130 | 130 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("S") PORT_CODE(KEYCODE_S) PORT_CHAR('S') |
| 131 | 131 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("3") PORT_CODE(KEYCODE_3) PORT_CHAR('3') |
| 132 | 132 | PORT_BIT(0xc7, IP_ACTIVE_LOW, IPT_UNUSED) |
| 133 | | |
| 133 | |
| 134 | 134 | PORT_START("keyboard_4") |
| 135 | 135 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("C") PORT_CODE(KEYCODE_C) PORT_CHAR('C') |
| 136 | 136 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("L") PORT_CODE(KEYCODE_L) PORT_CHAR('L') |
| r4176 | r4177 | |
| 158 | 158 | PORT_START("reset") |
| 159 | 159 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("RST") PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3)) |
| 160 | 160 | PORT_BIT(0xfe, IP_ACTIVE_LOW, IPT_UNUSED) |
| 161 | | |
| 161 | |
| 162 | 162 | PORT_START("switch") |
| 163 | 163 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Switch") PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F1)) |
| 164 | 164 | PORT_BIT(0xfe, IP_ACTIVE_LOW, IPT_UNUSED) |
| r4176 | r4177 | |
| 183 | 183 | MDRV_CPU_PROGRAM_MAP(acrnsys1_map, 0) |
| 184 | 184 | |
| 185 | 185 | MDRV_MACHINE_RESET(acrnsys1) |
| 186 | | |
| 186 | |
| 187 | 187 | MDRV_DEFAULT_LAYOUT(layout_acrnsys1) |
| 188 | | |
| 188 | |
| 189 | 189 | /* devices */ |
| 190 | 190 | MDRV_INS8154_ADD("b1", ins8154_b1) |
| 191 | | MDRV_TTL74145_ADD("ttl74145", ic8_7445) |
| 191 | MDRV_TTL74145_ADD("ttl74145") |
| 192 | MDRV_TTL74145_CONFIG(ic8_7445) |
| 192 | 193 | MACHINE_DRIVER_END |
| 193 | 194 | |
| 194 | 195 | |