src/mess/audio/lmc1992.c
| r2432 | r2433 | |
| 1 | 1 | #include "lmc1992.h" |
| 2 | 2 | |
| 3 | | static struct LMC1992 |
| 3 | #define LOG (0) |
| 4 | |
| 5 | typedef struct _lmc1992_t lmc1992_t; |
| 6 | struct _lmc1992_t |
| 4 | 7 | { |
| 5 | | const lmc1992_interface *intf; |
| 8 | const lmc1992_interface *intf; /* interface */ |
| 6 | 9 | |
| 7 | | int enable; |
| 8 | | int data; |
| 9 | | int clock; |
| 10 | | UINT16 si; |
| 10 | int enable; /* enable latch */ |
| 11 | int data; /* data latch */ |
| 12 | int clock; /* clock latch */ |
| 13 | UINT16 si; /* serial in shift register */ |
| 11 | 14 | |
| 12 | | int input; |
| 13 | | int bass, treble; |
| 14 | | int volume; |
| 15 | | int fader_rf, fader_lf, fader_rr, fader_lr; |
| 16 | | } lmc; |
| 15 | int input; /* input select */ |
| 16 | int bass; /* bass */ |
| 17 | int treble; /* treble */ |
| 18 | int volume; /* volume */ |
| 19 | int fader_rf; /* right front fader */ |
| 20 | int fader_lf; /* left front fader */ |
| 21 | int fader_rr; /* right rear fader */ |
| 22 | int fader_lr; /* left rear fader */ |
| 23 | }; |
| 17 | 24 | |
| 18 | | static void lmc1992_command_w(int addr, int data) |
| 25 | INLINE lmc1992_t *get_safe_token(const device_config *device) |
| 19 | 26 | { |
| 27 | assert(device != NULL); |
| 28 | assert(device->token != NULL); |
| 29 | |
| 30 | return (lmc1992_t *)device->token; |
| 31 | } |
| 32 | |
| 33 | static void lmc1992_command_w(const device_config *device, int addr, int data) |
| 34 | { |
| 35 | lmc1992_t *lmc1992 = get_safe_token(device); |
| 36 | |
| 20 | 37 | switch (addr) |
| 21 | 38 | { |
| 22 | 39 | case LMC1992_FUNCTION_INPUT_SELECT: |
| 23 | 40 | if (data == LCM1992_INPUT_SELECT_OPEN) |
| 24 | 41 | { |
| 25 | | logerror("LMC1992 Input Select : OPEN\n"); |
| 42 | if (LOG) logerror("LMC1992 Input Select : OPEN\n"); |
| 26 | 43 | } |
| 27 | 44 | else |
| 28 | 45 | { |
| 29 | | logerror("LMC1992 Input Select : INPUT%u\n", data); |
| 46 | if (LOG) logerror("LMC1992 Input Select : INPUT%u\n", data); |
| 30 | 47 | } |
| 31 | | lmc.input = data; |
| 48 | lmc1992->input = data; |
| 32 | 49 | break; |
| 50 | |
| 33 | 51 | case LMC1992_FUNCTION_BASS: |
| 34 | | logerror("LMC1992 Bass : %i dB\n", -40 + (data * 2)); |
| 35 | | lmc.bass = data; |
| 52 | if (LOG) logerror("LMC1992 Bass : %i dB\n", -40 + (data * 2)); |
| 53 | lmc1992->bass = data; |
| 36 | 54 | break; |
| 55 | |
| 37 | 56 | case LMC1992_FUNCTION_TREBLE: |
| 38 | | logerror("LMC1992 Treble : %i dB\n", -40 + (data * 2)); |
| 39 | | lmc.treble = data; |
| 57 | if (LOG) logerror("LMC1992 Treble : %i dB\n", -40 + (data * 2)); |
| 58 | lmc1992->treble = data; |
| 40 | 59 | break; |
| 60 | |
| 41 | 61 | case LMC1992_FUNCTION_VOLUME: |
| 42 | | logerror("LMC1992 Volume : %i dB\n", -80 + (data * 2)); |
| 43 | | lmc.volume = data; |
| 62 | if (LOG) logerror("LMC1992 Volume : %i dB\n", -80 + (data * 2)); |
| 63 | lmc1992->volume = data; |
| 44 | 64 | break; |
| 65 | |
| 45 | 66 | case LMC1992_FUNCTION_RIGHT_FRONT_FADER: |
| 46 | | logerror("LMC1992 Right Front Fader : %i dB\n", -40 + (data * 2)); |
| 47 | | lmc.fader_rf = data; |
| 67 | if (LOG) logerror("LMC1992 Right Front Fader : %i dB\n", -40 + (data * 2)); |
| 68 | lmc1992->fader_rf = data; |
| 48 | 69 | break; |
| 70 | |
| 49 | 71 | case LMC1992_FUNCTION_LEFT_FRONT_FADER: |
| 50 | | logerror("LMC1992 Left Front Fader : %i dB\n", -40 + (data * 2)); |
| 51 | | lmc.fader_lf = data; |
| 72 | if (LOG) logerror("LMC1992 Left Front Fader : %i dB\n", -40 + (data * 2)); |
| 73 | lmc1992->fader_lf = data; |
| 52 | 74 | break; |
| 75 | |
| 53 | 76 | case LMC1992_FUNCTION_RIGHT_REAR_FADER: |
| 54 | | logerror("LMC1992 Right Rear Fader : %i dB\n", -40 + (data * 2)); |
| 55 | | lmc.fader_rr = data; |
| 77 | if (LOG) logerror("LMC1992 Right Rear Fader : %i dB\n", -40 + (data * 2)); |
| 78 | lmc1992->fader_rr = data; |
| 56 | 79 | break; |
| 80 | |
| 57 | 81 | case LMC1992_FUNCTION_LEFT_REAR_FADER: |
| 58 | | logerror("LMC1992 Left Rear Fader : %i dB\n", -40 + (data * 2)); |
| 59 | | lmc.fader_lr = data; |
| 82 | if (LOG) logerror("LMC1992 Left Rear Fader : %i dB\n", -40 + (data * 2)); |
| 83 | lmc1992->fader_lr = data; |
| 60 | 84 | break; |
| 61 | 85 | } |
| 62 | 86 | } |
| 63 | 87 | |
| 64 | | void lmc1992_clock_w(int level) |
| 88 | void lmc1992_clock_w(const device_config *device, int level) |
| 65 | 89 | { |
| 90 | lmc1992_t *lmc1992 = get_safe_token(device); |
| 91 | |
| 66 | 92 | // clock data in on rising edge |
| 67 | 93 | |
| 68 | | if ((lmc.enable == 0) && ((lmc.clock == 0) && (level == 1))) |
| 94 | if ((lmc1992->enable == 0) && ((lmc1992->clock == 0) && (level == 1))) |
| 69 | 95 | { |
| 70 | | lmc.si >>= 1; |
| 71 | | lmc.si = lmc.si & 0x7fff; |
| 96 | lmc1992->si >>= 1; |
| 97 | lmc1992->si = lmc1992->si & 0x7fff; |
| 72 | 98 | |
| 73 | | if (lmc.data) |
| 99 | if (lmc1992->data) |
| 74 | 100 | { |
| 75 | | lmc.si &= 0x8000; |
| 101 | lmc1992->si &= 0x8000; |
| 76 | 102 | } |
| 77 | 103 | } |
| 78 | 104 | |
| 79 | | lmc.clock = level; |
| 105 | lmc1992->clock = level; |
| 80 | 106 | } |
| 81 | 107 | |
| 82 | | void lmc1992_data_w(int level) |
| 108 | void lmc1992_data_w(const device_config *device, int level) |
| 83 | 109 | { |
| 84 | | lmc.data = level; |
| 110 | lmc1992_t *lmc1992 = get_safe_token(device); |
| 111 | |
| 112 | lmc1992->data = level; |
| 85 | 113 | } |
| 86 | 114 | |
| 87 | | void lmc1992_enable_w(int level) |
| 115 | void lmc1992_enable_w(const device_config *device, int level) |
| 88 | 116 | { |
| 89 | | if ((lmc.enable == 0) && (level == 1)) |
| 117 | lmc1992_t *lmc1992 = get_safe_token(device); |
| 118 | |
| 119 | if ((lmc1992->enable == 0) && (level == 1)) |
| 90 | 120 | { |
| 91 | | UINT8 device = (lmc.si & 0xc000) >> 14; |
| 92 | | UINT8 addr = (lmc.si & 0x3800) >> 11; |
| 93 | | UINT8 data = (lmc.si & 0x07e0) >> 5; |
| 121 | UINT8 device_addr = (lmc1992->si & 0xc000) >> 14; |
| 122 | UINT8 addr = (lmc1992->si & 0x3800) >> 11; |
| 123 | UINT8 data = (lmc1992->si & 0x07e0) >> 5; |
| 94 | 124 | |
| 95 | | if (device == LMC1992_MICROWIRE_DEVICE_ADDRESS) |
| 125 | if (device_addr == LMC1992_MICROWIRE_DEVICE_ADDRESS) |
| 96 | 126 | { |
| 97 | | lmc1992_command_w(addr, data); |
| 127 | lmc1992_command_w(device, addr, data); |
| 98 | 128 | } |
| 99 | 129 | } |
| 100 | 130 | |
| 101 | | lmc.enable = level; |
| 131 | lmc1992->enable = level; |
| 102 | 132 | } |
| 103 | 133 | |
| 104 | | void lmc1992_config(const lmc1992_interface *intf) |
| 134 | /* Device Interface */ |
| 135 | |
| 136 | static DEVICE_START( lmc1992 ) |
| 105 | 137 | { |
| 106 | | memset(&lmc, 0, sizeof(lmc)); |
| 138 | lmc1992_t *lmc1992 = get_safe_token(device); |
| 139 | char unique_tag[30]; |
| 107 | 140 | |
| 108 | | lmc.intf = intf; |
| 141 | /* validate arguments */ |
| 142 | assert(device != NULL); |
| 143 | assert(device->tag != NULL); |
| 144 | assert(strlen(device->tag) < 20); |
| 109 | 145 | |
| 110 | | state_save_register_global(lmc.enable); |
| 111 | | state_save_register_global(lmc.data); |
| 112 | | state_save_register_global(lmc.clock); |
| 113 | | state_save_register_global(lmc.si); |
| 114 | | state_save_register_global(lmc.input); |
| 115 | | state_save_register_global(lmc.bass); |
| 116 | | state_save_register_global(lmc.treble); |
| 117 | | state_save_register_global(lmc.volume); |
| 118 | | state_save_register_global(lmc.fader_rf); |
| 119 | | state_save_register_global(lmc.fader_lf); |
| 120 | | state_save_register_global(lmc.fader_rr); |
| 121 | | state_save_register_global(lmc.fader_lr); |
| 146 | lmc1992->intf = device->static_config; |
| 147 | |
| 148 | // assert(lmc1992->intf != NULL); |
| 149 | |
| 150 | /* register for state saving */ |
| 151 | state_save_combine_module_and_tag(unique_tag, "LMC1992", device->tag); |
| 152 | |
| 153 | state_save_register_item(unique_tag, 0, lmc1992->enable); |
| 154 | state_save_register_item(unique_tag, 0, lmc1992->data); |
| 155 | state_save_register_item(unique_tag, 0, lmc1992->clock); |
| 156 | state_save_register_item(unique_tag, 0, lmc1992->si); |
| 157 | state_save_register_item(unique_tag, 0, lmc1992->input); |
| 158 | state_save_register_item(unique_tag, 0, lmc1992->bass); |
| 159 | state_save_register_item(unique_tag, 0, lmc1992->treble); |
| 160 | state_save_register_item(unique_tag, 0, lmc1992->volume); |
| 161 | state_save_register_item(unique_tag, 0, lmc1992->fader_rf); |
| 162 | state_save_register_item(unique_tag, 0, lmc1992->fader_lf); |
| 163 | state_save_register_item(unique_tag, 0, lmc1992->fader_rr); |
| 164 | state_save_register_item(unique_tag, 0, lmc1992->fader_lr); |
| 122 | 165 | } |
| 166 | |
| 167 | static DEVICE_SET_INFO( lmc1992 ) |
| 168 | { |
| 169 | switch (state) |
| 170 | { |
| 171 | /* no parameters to set */ |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | DEVICE_GET_INFO( lmc1992 ) |
| 176 | { |
| 177 | switch (state) |
| 178 | { |
| 179 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 180 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(lmc1992_t); break; |
| 181 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 182 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 183 | |
| 184 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 185 | case DEVINFO_FCT_SET_INFO: info->set_info = DEVICE_SET_INFO_NAME(lmc1992); break; |
| 186 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(lmc1992); break; |
| 187 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 188 | case DEVINFO_FCT_RESET: /* Nothing */ break; |
| 189 | |
| 190 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 191 | case DEVINFO_STR_NAME: info->s = "LMC1992"; break; |
| 192 | case DEVINFO_STR_FAMILY: info->s = "LMC1992"; break; |
| 193 | case DEVINFO_STR_VERSION: info->s = "1.0"; break; |
| 194 | case DEVINFO_STR_SOURCE_FILE: info->s = __FILE__; break; |
| 195 | case DEVINFO_STR_CREDITS: info->s = "Copyright MESS Team"; break; |
| 196 | } |
| 197 | } |
src/mess/drivers/atarist.c
| r2432 | r2433 | |
| 657 | 657 | |
| 658 | 658 | static emu_timer *microwire_timer; |
| 659 | 659 | |
| 660 | | static void atariste_microwire_shift(void) |
| 660 | static void atariste_microwire_shift(running_machine *machine) |
| 661 | 661 | { |
| 662 | const device_config *lmc1992 = device_list_find_by_tag(machine->config->devicelist, LMC1992, LMC1992_TAG); |
| 663 | |
| 662 | 664 | if (BIT(mwire.mask, 15)) |
| 663 | 665 | { |
| 664 | | lmc1992_data_w(BIT(mwire.data, 15)); |
| 665 | | lmc1992_clock_w(1); |
| 666 | | lmc1992_clock_w(0); |
| 666 | lmc1992_data_w(lmc1992, BIT(mwire.data, 15)); |
| 667 | lmc1992_clock_w(lmc1992, 1); |
| 668 | lmc1992_clock_w(lmc1992, 0); |
| 667 | 669 | } |
| 668 | 670 | |
| 669 | 671 | // rotate mask and data left |
| r2432 | r2433 | |
| 675 | 677 | |
| 676 | 678 | static TIMER_CALLBACK( atariste_microwire_tick ) |
| 677 | 679 | { |
| 680 | const device_config *lmc1992 = device_list_find_by_tag(machine->config->devicelist, LMC1992, LMC1992_TAG); |
| 681 | |
| 678 | 682 | switch (mwire.shift) |
| 679 | 683 | { |
| 680 | 684 | case 0: |
| 681 | | lmc1992_enable_w(0); |
| 682 | | atariste_microwire_shift(); |
| 685 | lmc1992_enable_w(lmc1992, 0); |
| 686 | atariste_microwire_shift(machine); |
| 683 | 687 | break; |
| 684 | 688 | |
| 685 | 689 | default: |
| 686 | | atariste_microwire_shift(); |
| 690 | atariste_microwire_shift(machine); |
| 687 | 691 | break; |
| 688 | 692 | |
| 689 | 693 | case 15: |
| 690 | | atariste_microwire_shift(); |
| 691 | | lmc1992_enable_w(1); |
| 694 | atariste_microwire_shift(machine); |
| 695 | lmc1992_enable_w(lmc1992, 1); |
| 692 | 696 | mwire.shift = 0; |
| 693 | 697 | timer_enable(microwire_timer, 0); |
| 694 | 698 | break; |
| r2432 | r2433 | |
| 1790 | 1794 | MDRV_SOUND_ROUTE(0, "right", 0.50) |
| 1791 | 1795 | MDRV_SOUND_ROUTE(1, "left", 0.50) |
| 1792 | 1796 | */ |
| 1797 | MDRV_DEVICE_ADD(LMC1992_TAG, LMC1992) |
| 1798 | // MDRV_DEVICE_CONFIG(atariste_lmc1992_intf) |
| 1793 | 1799 | |
| 1794 | 1800 | /* printer */ |
| 1795 | 1801 | MDRV_DEVICE_ADD("printer", PRINTER) |