src/mess/audio/vp550.c
| r5725 | r5726 | |
| 11 | 11 | |
| 12 | 12 | TODO: |
| 13 | 13 | |
| 14 | | - octave (CD22100) |
| 15 | | - amplitude (CD4508) |
| 16 | | - tempo interrupt |
| 14 | - tempo control |
| 17 | 15 | - mono/stereo mode |
| 16 | - VP551 memory map |
| 18 | 17 | |
| 19 | 18 | */ |
| 20 | 19 | |
| r5725 | r5726 | |
| 27 | 26 | PARAMETERS |
| 28 | 27 | ***************************************************************************/ |
| 29 | 28 | |
| 29 | #define LOG 0 |
| 30 | |
| 31 | #define MAX_CHANNELS 4 |
| 32 | |
| 30 | 33 | #define CDP1863_A_TAG "u1" |
| 31 | 34 | #define CDP1863_B_TAG "u2" |
| 35 | #define CDP1863_C_TAG "cdp1863c" |
| 36 | #define CDP1863_D_TAG "cdp1863d" |
| 32 | 37 | |
| 38 | enum |
| 39 | { |
| 40 | CHANNEL_A = 0, |
| 41 | CHANNEL_B, |
| 42 | CHANNEL_C, |
| 43 | CHANNEL_D |
| 44 | }; |
| 45 | |
| 33 | 46 | /*************************************************************************** |
| 34 | 47 | TYPE DEFINITIONS |
| 35 | 48 | ***************************************************************************/ |
| r5725 | r5726 | |
| 37 | 50 | typedef struct _vp550_t vp550_t; |
| 38 | 51 | struct _vp550_t |
| 39 | 52 | { |
| 40 | | int ie; /* interrupt enable */ |
| 53 | int channels; /* number of channels */ |
| 41 | 54 | |
| 42 | 55 | /* devices */ |
| 43 | | const device_config *cdp1863_a; |
| 44 | | const device_config *cdp1863_b; |
| 56 | const device_config *cdp1863[MAX_CHANNELS]; |
| 57 | const device_config *sync_timer; |
| 45 | 58 | }; |
| 46 | 59 | |
| 47 | 60 | /*************************************************************************** |
| r5725 | r5726 | |
| 52 | 65 | { |
| 53 | 66 | assert(device != NULL); |
| 54 | 67 | assert(device->token != NULL); |
| 55 | | assert(device->type == VP550); |
| 68 | assert((device->type == VP550) || (device->type == VP551)); |
| 56 | 69 | return (vp550_t *)device->token; |
| 57 | 70 | } |
| 58 | 71 | |
| r5725 | r5726 | |
| 68 | 81 | { |
| 69 | 82 | vp550_t *vp550 = get_safe_token(device); |
| 70 | 83 | |
| 71 | | cdp1863_oe_w(vp550->cdp1863_a, state); |
| 72 | | cdp1863_oe_w(vp550->cdp1863_b, state); |
| 84 | int channel; |
| 85 | |
| 86 | for (channel = CHANNEL_A; channel < vp550->channels; channel++) |
| 87 | { |
| 88 | cdp1863_oe_w(vp550->cdp1863[channel], state); |
| 89 | } |
| 73 | 90 | } |
| 74 | 91 | |
| 75 | 92 | /*------------------------------------------------- |
| 76 | | vp550_octave_w - |
| 93 | vp550_sc1_w - SC1 line write |
| 77 | 94 | -------------------------------------------------*/ |
| 78 | 95 | |
| 96 | WRITE_LINE_DEVICE_HANDLER( vp550_sc1_w ) |
| 97 | { |
| 98 | if (state) |
| 99 | { |
| 100 | cpu_set_input_line(device->machine->firstcpu, CDP1802_INPUT_LINE_INT, CLEAR_LINE); |
| 101 | |
| 102 | if (LOG) logerror("VP550 Clear Interrupt\n"); |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | /*------------------------------------------------- |
| 107 | vp550_octave_w - octave select write |
| 108 | -------------------------------------------------*/ |
| 109 | |
| 79 | 110 | static WRITE8_DEVICE_HANDLER( vp550_octave_w ) |
| 80 | 111 | { |
| 112 | vp550_t *vp550 = get_safe_token(device); |
| 113 | |
| 114 | int channel = (data >> 2) & 0x03; |
| 115 | int clock = 0; |
| 116 | |
| 117 | if (data & 0x10) |
| 118 | { |
| 119 | switch (data & 0x03) |
| 120 | { |
| 121 | case 0: clock = device->clock / 8; break; |
| 122 | case 1: clock = device->clock / 4; break; |
| 123 | case 2: clock = device->clock / 2; break; |
| 124 | case 3: clock = device->clock; break; |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | if (vp550->cdp1863[channel]) cdp1863_set_clk2(vp550->cdp1863[channel], clock); |
| 129 | |
| 130 | if (LOG) logerror("VP550 Clock %c: %u Hz\n", 'A' + channel, clock); |
| 81 | 131 | } |
| 82 | 132 | |
| 83 | 133 | /*------------------------------------------------- |
| r5725 | r5726 | |
| 86 | 136 | |
| 87 | 137 | static WRITE8_DEVICE_HANDLER( vp550_vlmna_w ) |
| 88 | 138 | { |
| 139 | vp550_t *vp550 = get_safe_token(device); |
| 140 | float gain = 0.625f * (data & 0x0f); |
| 141 | |
| 142 | sound_set_output_gain(vp550->cdp1863[CHANNEL_A], 0, gain); |
| 143 | |
| 144 | if (LOG) logerror("VP550 Volume A: %u\n", data & 0x0f); |
| 89 | 145 | } |
| 90 | 146 | |
| 91 | 147 | /*------------------------------------------------- |
| r5725 | r5726 | |
| 94 | 150 | |
| 95 | 151 | static WRITE8_DEVICE_HANDLER( vp550_vlmnb_w ) |
| 96 | 152 | { |
| 153 | vp550_t *vp550 = get_safe_token(device); |
| 154 | float gain = 0.625f * (data & 0x0f); |
| 155 | |
| 156 | sound_set_output_gain(vp550->cdp1863[CHANNEL_B], 0, gain); |
| 157 | |
| 158 | if (LOG) logerror("VP550 Volume B: %u\n", data & 0x0f); |
| 97 | 159 | } |
| 98 | 160 | |
| 99 | 161 | /*------------------------------------------------- |
| r5725 | r5726 | |
| 102 | 164 | |
| 103 | 165 | static WRITE8_DEVICE_HANDLER( vp550_sync_w ) |
| 104 | 166 | { |
| 167 | vp550_t *vp550 = get_safe_token(device); |
| 168 | |
| 169 | timer_device_enable(vp550->sync_timer, BIT(data, 0)); |
| 170 | |
| 171 | if (LOG) logerror("VP550 Interrupt Enable: %u\n", BIT(data, 0)); |
| 105 | 172 | } |
| 106 | 173 | |
| 107 | 174 | /*------------------------------------------------- |
| r5725 | r5726 | |
| 115 | 182 | |
| 116 | 183 | if (enabled) |
| 117 | 184 | { |
| 118 | | memory_install_write8_device_handler(program, vp550->cdp1863_a, 0x8001, 0x8001, 0, 0, cdp1863_str_w); |
| 119 | | memory_install_write8_device_handler(program, vp550->cdp1863_b, 0x8002, 0x8002, 0, 0, cdp1863_str_w); |
| 185 | memory_install_write8_device_handler(program, vp550->cdp1863[CHANNEL_A], 0x8001, 0x8001, 0, 0, cdp1863_str_w); |
| 186 | memory_install_write8_device_handler(program, vp550->cdp1863[CHANNEL_B], 0x8002, 0x8002, 0, 0, cdp1863_str_w); |
| 120 | 187 | memory_install_write8_device_handler(program, device, 0x8003, 0x8003, 0, 0, vp550_octave_w); |
| 121 | 188 | memory_install_write8_device_handler(program, device, 0x8010, 0x8010, 0, 0, vp550_vlmna_w); |
| 122 | 189 | memory_install_write8_device_handler(program, device, 0x8020, 0x8020, 0, 0, vp550_vlmnb_w); |
| r5725 | r5726 | |
| 134 | 201 | } |
| 135 | 202 | |
| 136 | 203 | /*------------------------------------------------- |
| 204 | TIMER_DEVICE_CALLBACK( sync_tick ) |
| 205 | -------------------------------------------------*/ |
| 206 | |
| 207 | static TIMER_DEVICE_CALLBACK( sync_tick ) |
| 208 | { |
| 209 | cpu_set_input_line(timer->machine->firstcpu, CDP1802_INPUT_LINE_INT, ASSERT_LINE); |
| 210 | |
| 211 | if (LOG) logerror("VP550 Interrupt\n"); |
| 212 | } |
| 213 | |
| 214 | /*------------------------------------------------- |
| 137 | 215 | MACHINE_DRIVER( vp550 ) |
| 138 | 216 | -------------------------------------------------*/ |
| 139 | 217 | |
| 140 | 218 | static MACHINE_DRIVER_START( vp550 ) |
| 219 | MDRV_TIMER_ADD_PERIODIC("sync", sync_tick, HZ(50)) |
| 220 | |
| 141 | 221 | MDRV_CDP1863_ADD(CDP1863_A_TAG, 0, 0) |
| 142 | 222 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 143 | 223 | |
| r5725 | r5726 | |
| 146 | 226 | MACHINE_DRIVER_END |
| 147 | 227 | |
| 148 | 228 | /*------------------------------------------------- |
| 229 | MACHINE_DRIVER( vp551 ) |
| 230 | -------------------------------------------------*/ |
| 231 | |
| 232 | static MACHINE_DRIVER_START( vp551 ) |
| 233 | MDRV_IMPORT_FROM(vp550) |
| 234 | |
| 235 | MDRV_CDP1863_ADD(CDP1863_C_TAG, 0, 0) |
| 236 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 237 | |
| 238 | MDRV_CDP1863_ADD(CDP1863_D_TAG, 0, 0) |
| 239 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 240 | MACHINE_DRIVER_END |
| 241 | |
| 242 | /*------------------------------------------------- |
| 149 | 243 | DEVICE_START( vp550 ) |
| 150 | 244 | -------------------------------------------------*/ |
| 151 | 245 | |
| r5725 | r5726 | |
| 154 | 248 | vp550_t *vp550 = get_safe_token(device); |
| 155 | 249 | |
| 156 | 250 | /* look up devices */ |
| 157 | | vp550->cdp1863_a = devtag_get_device(device->machine, "vp550:u1"); |
| 158 | | vp550->cdp1863_b = devtag_get_device(device->machine, "vp550:u2"); |
| 159 | | assert(vp550->cdp1863_a != NULL); |
| 160 | | assert(vp550->cdp1863_b != NULL); |
| 251 | vp550->cdp1863[CHANNEL_A] = devtag_get_device(device->machine, "vp550:u1"); |
| 252 | vp550->cdp1863[CHANNEL_B] = devtag_get_device(device->machine, "vp550:u2"); |
| 253 | vp550->sync_timer = devtag_get_device(device->machine, "vp550:sync"); |
| 161 | 254 | |
| 162 | | /* register for state saving */ |
| 163 | | state_save_register_global(device->machine, vp550->ie); |
| 255 | /* set initial values */ |
| 256 | vp550->channels = 2; |
| 164 | 257 | } |
| 165 | 258 | |
| 166 | 259 | /*------------------------------------------------- |
| 260 | DEVICE_START( vp551 ) |
| 261 | -------------------------------------------------*/ |
| 262 | |
| 263 | static DEVICE_START( vp551 ) |
| 264 | { |
| 265 | vp550_t *vp550 = get_safe_token(device); |
| 266 | |
| 267 | /* look up devices */ |
| 268 | vp550->cdp1863[CHANNEL_A] = devtag_get_device(device->machine, "vp551:u1"); |
| 269 | vp550->cdp1863[CHANNEL_B] = devtag_get_device(device->machine, "vp551:u2"); |
| 270 | vp550->cdp1863[CHANNEL_C] = devtag_get_device(device->machine, "vp551:cdp1863c"); |
| 271 | vp550->cdp1863[CHANNEL_D] = devtag_get_device(device->machine, "vp551:cdp1863d"); |
| 272 | vp550->sync_timer = devtag_get_device(device->machine, "vp551:sync"); |
| 273 | |
| 274 | /* set initial values */ |
| 275 | vp550->channels = 4; |
| 276 | } |
| 277 | |
| 278 | /*------------------------------------------------- |
| 167 | 279 | DEVICE_RESET( vp550 ) |
| 168 | 280 | -------------------------------------------------*/ |
| 169 | 281 | |
| r5725 | r5726 | |
| 171 | 283 | { |
| 172 | 284 | vp550_t *vp550 = get_safe_token(device); |
| 173 | 285 | |
| 174 | | device_reset(vp550->cdp1863_a); |
| 175 | | device_reset(vp550->cdp1863_b); |
| 286 | /* reset chips */ |
| 287 | device_reset(vp550->cdp1863[CHANNEL_A]); |
| 288 | device_reset(vp550->cdp1863[CHANNEL_B]); |
| 176 | 289 | |
| 290 | /* disable interrupt timer */ |
| 291 | timer_device_enable(vp550->sync_timer, 0); |
| 292 | |
| 293 | /* clear interrupt */ |
| 177 | 294 | cpu_set_input_line(device->machine->firstcpu, CDP1802_INPUT_LINE_INT, CLEAR_LINE); |
| 178 | 295 | } |
| 179 | 296 | |
| 180 | 297 | /*------------------------------------------------- |
| 298 | DEVICE_RESET( vp551 ) |
| 299 | -------------------------------------------------*/ |
| 300 | |
| 301 | static DEVICE_RESET( vp551 ) |
| 302 | { |
| 303 | vp550_t *vp550 = get_safe_token(device); |
| 304 | |
| 305 | DEVICE_RESET_CALL(vp550); |
| 306 | |
| 307 | /* reset chips */ |
| 308 | device_reset(vp550->cdp1863[CHANNEL_C]); |
| 309 | device_reset(vp550->cdp1863[CHANNEL_D]); |
| 310 | } |
| 311 | |
| 312 | /*------------------------------------------------- |
| 181 | 313 | DEVICE_GET_INFO( vp550 ) |
| 182 | 314 | -------------------------------------------------*/ |
| 183 | 315 | |
| r5725 | r5726 | |
| 206 | 338 | case DEVINFO_STR_CREDITS: /* Nothing */ break; |
| 207 | 339 | } |
| 208 | 340 | } |
| 341 | |
| 342 | /*------------------------------------------------- |
| 343 | DEVICE_GET_INFO( vp551 ) |
| 344 | -------------------------------------------------*/ |
| 345 | |
| 346 | DEVICE_GET_INFO( vp551 ) |
| 347 | { |
| 348 | switch (state) |
| 349 | { |
| 350 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 351 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(vp550_t); break; |
| 352 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 353 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 354 | |
| 355 | /* --- the following bits of info are returned as pointers --- */ |
| 356 | case DEVINFO_PTR_MACHINE_CONFIG: info->machine_config = machine_config_vp551;break; |
| 357 | |
| 358 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 359 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(vp551); break; |
| 360 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 361 | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(vp551); break; |
| 362 | |
| 363 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 364 | case DEVINFO_STR_NAME: strcpy(info->s, "RCA VP551"); break; |
| 365 | case DEVINFO_STR_FAMILY: strcpy(info->s, "RCA VIP"); break; |
| 366 | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 367 | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 368 | case DEVINFO_STR_CREDITS: /* Nothing */ break; |
| 369 | } |
| 370 | } |