src/mess/audio/special.c
| r0 | r2105 | |
| 1 | /***************************************************************************
|
| 2 | |
| 3 | audio/special.c
|
| 4 | |
| 5 | Functions to emulate sound hardware of Specialist MX
|
| 6 | ( based on code of DAI interface )
|
| 7 | |
| 8 | ****************************************************************************/
|
| 9 | |
| 10 | #include "driver.h"
|
| 11 | #include "sound/custom.h"
|
| 12 | #include "machine/pit8253.h"
|
| 13 | #include "includes/dai.h"
|
| 14 | #include "streams.h"
|
| 15 | #include "deprecat.h"
|
| 16 | |
| 17 | static void *specimx_sh_start(int clock, const struct CustomSound_interface *config);
|
| 18 | static void specimx_sh_update(void *param,stream_sample_t **inputs, stream_sample_t **_buffer,int length);
|
| 19 | |
| 20 | static sound_stream *mixer_channel;
|
| 21 | |
| 22 | const struct CustomSound_interface specimx_sound_interface =
|
| 23 | {
|
| 24 | specimx_sh_start,
|
| 25 | NULL,
|
| 26 | NULL
|
| 27 | };
|
| 28 | |
| 29 | static void *specimx_sh_start(int clock, const struct CustomSound_interface *config)
|
| 30 | {
|
| 31 | mixer_channel = stream_create(0, 2, Machine->sample_rate, 0, specimx_sh_update);
|
| 32 | return (void *) ~0;
|
| 33 | }
|
| 34 | |
| 35 | static void specimx_sh_update(void *param,stream_sample_t **inputs, stream_sample_t **buffer,int length)
|
| 36 | {
|
| 37 | INT16 channel_0_signal;
|
| 38 | INT16 channel_1_signal;
|
| 39 | INT16 channel_2_signal;
|
| 40 | static int channel_0_incr = 0;
|
| 41 | static int channel_1_incr = 0;
|
| 42 | static int channel_2_incr = 0;
|
| 43 | int channel_0_baseclock;
|
| 44 | int channel_1_baseclock;
|
| 45 | int channel_2_baseclock;
|
| 46 | |
| 47 | int rate = Machine->sample_rate / 2;
|
| 48 | |
| 49 | stream_sample_t *sample_left = buffer[0];
|
| 50 | stream_sample_t *sample_right = buffer[1];
|
| 51 | |
| 52 | channel_0_baseclock = pit8253_get_frequency(0, 0);
|
| 53 | channel_1_baseclock = pit8253_get_frequency(0, 1);
|
| 54 | channel_2_baseclock = pit8253_get_frequency(0, 2);
|
| 55 | |
| 56 | channel_0_signal = pit8253_get_output (0,0) ? 3000 : -3000;
|
| 57 | channel_1_signal = pit8253_get_output (0,1) ? 3000 : -3000;
|
| 58 | channel_2_signal = pit8253_get_output (0,2) ? 3000 : -3000;
|
| 59 | |
| 60 | |
| 61 | while (length--)
|
| 62 | {
|
| 63 | *sample_left = 0;
|
| 64 | *sample_right = 0;
|
| 65 | |
| 66 | /* music channel 0 */
|
| 67 | |
| 68 | *sample_left += channel_0_signal;
|
| 69 | channel_0_incr -= channel_0_baseclock;
|
| 70 | while( channel_0_incr < 0 )
|
| 71 | {
|
| 72 | channel_0_incr += rate;
|
| 73 | channel_0_signal = -channel_0_signal;
|
| 74 | }
|
| 75 | |
| 76 | |
| 77 | /* music channel 1 */
|
| 78 | |
| 79 | *sample_left += channel_1_signal;
|
| 80 | channel_1_incr -= channel_1_baseclock;
|
| 81 | while( channel_1_incr < 0 )
|
| 82 | {
|
| 83 | channel_1_incr += rate;
|
| 84 | channel_1_signal = -channel_1_signal;
|
| 85 | }
|
| 86 | |
| 87 | /* music channel 2 */
|
| 88 | |
| 89 | *sample_left += channel_2_signal;
|
| 90 | channel_2_incr -= channel_2_baseclock;
|
| 91 | while( channel_2_incr < 0 )
|
| 92 | {
|
| 93 | channel_2_incr += rate;
|
| 94 | channel_2_signal = -channel_2_signal;
|
| 95 | }
|
| 96 | |
| 97 | sample_left++;
|
| 98 | sample_right++;
|
| 99 | }
|
| 100 | }
|
| 101 | |
| 102 | void specimx_sh_change_clock(double clock)
|
| 103 | {
|
| 104 | stream_update(mixer_channel);
|
| 105 | }
|
src/mess/includes/special.h
| r2104 | r2105 | |
| 31 | 31 | extern READ8_HANDLER ( specimx_disk_ctrl_r ); |
| 32 | 32 | extern WRITE8_HANDLER( specimx_disk_ctrl_w ); |
| 33 | 33 | |
| 34 | extern WRITE8_HANDLER( specimx_sound_w ); |
| 35 | |
| 34 | 36 | /*----------- defined in video/special.c -----------*/ |
| 35 | 37 | |
| 36 | 38 | extern UINT8 *specialist_video_ram; |
| r2104 | r2105 | |
| 45 | 47 | extern PALETTE_INIT( specimx ); |
| 46 | 48 | extern rgb_t specimx_palette; |
| 47 | 49 | |
| 50 | /*----------- defined in audio/special.c -----------*/ |
| 51 | |
| 52 | extern const struct CustomSound_interface specimx_sound_interface; |
| 53 | extern void specimx_sh_change_clock(double); |
| 54 | |
| 48 | 55 | #endif /* SPECIAL_H_ */ |
src/mess/machine/special.c
| r2104 | r2105 | |
| 251 | 251 | specimx_color = 0x70; |
| 252 | 252 | wd17xx_reset(); |
| 253 | 253 | wd17xx_set_side(0); |
| 254 | pit8253_reset(0); |
| 255 | pit8253_0_gate_w(machine, 0, 0); |
| 256 | pit8253_0_gate_w(machine, 1, 0); |
| 257 | pit8253_0_gate_w(machine, 2, 0); |
| 254 | 258 | } |
| 255 | 259 | |
| 256 | 260 | READ8_HANDLER ( specimx_disk_data_r ) |
| r2104 | r2105 | |
| 334 | 338 | basicdsk_set_calcoffset(image, specimx_calcoffset); |
| 335 | 339 | return INIT_PASS; |
| 336 | 340 | } |
| 341 | |
| 342 | WRITE8_HANDLER( specimx_sound_w) |
| 343 | { |
| 344 | |
| 345 | pit8253_0_w(machine,offset,data); |
| 346 | } |
src/mess/drivers/special.c
| r2104 | r2105 | |
| 38 | 38 | AM_RANGE( 0xffe0, 0xffe3 ) AM_READWRITE(specialist_keyboard_r,specialist_keyboard_w) // 8255 for keyboard |
| 39 | 39 | AM_RANGE( 0xffe4, 0xffe7 ) AM_RAM //external 8255 |
| 40 | 40 | AM_RANGE( 0xffe8, 0xffeb ) AM_READWRITE(specimx_disk_data_r,specimx_disk_data_w) |
| 41 | | AM_RANGE( 0xffec, 0xffef ) AM_READWRITE(pit8253_0_r, pit8253_0_w) |
| 41 | AM_RANGE( 0xffec, 0xffef ) AM_READWRITE(pit8253_0_r, specimx_sound_w) |
| 42 | 42 | AM_RANGE( 0xfff0, 0xfff3 ) AM_READWRITE(specimx_disk_ctrl_r, specimx_disk_ctrl_w) |
| 43 | 43 | AM_RANGE( 0xfff8, 0xfff8 ) AM_READWRITE(specimx_video_color_r,specimx_video_color_w) |
| 44 | 44 | AM_RANGE( 0xfffc, 0xfffe ) AM_WRITE(specimx_select_bank) |
| r2104 | r2105 | |
| 335 | 335 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 336 | 336 | MDRV_SOUND_ADD(WAVE, 0) |
| 337 | 337 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 338 | MDRV_SOUND_ADD(CUSTOM, 0) |
| 339 | MDRV_SOUND_CONFIG(specimx_sound_interface) |
| 340 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 338 | 341 | MACHINE_DRIVER_END |
| 339 | 342 | |
| 340 | 343 | /* ROM definition */ |