trunk/src/emu/sound/wave.c
| r26430 | r26431 | |
| 16 | 16 | #include "emu.h" |
| 17 | 17 | #include "imagedev/cassette.h" |
| 18 | 18 | #include "wave.h" |
| 19 | | #include "devlegcy.h" |
| 20 | 19 | |
| 21 | 20 | #define ALWAYS_PLAY_SOUND 0 |
| 22 | 21 | |
| 23 | | static STREAM_UPDATE( wave_sound_update ) |
| 22 | |
| 23 | |
| 24 | void wave_device::static_set_cassette_tag(device_t &device, const char *cassette_tag) |
| 24 | 25 | { |
| 25 | | cassette_image_device *cass = (cassette_image_device *)param; |
| 26 | wave_device &wave = downcast<wave_device &>(device); |
| 27 | wave.m_cassette_tag = cassette_tag; |
| 28 | } |
| 29 | |
| 30 | const device_type WAVE = &device_creator<wave_device>; |
| 31 | |
| 32 | wave_device::wave_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 33 | : device_t(mconfig, WAVE, "Wave", tag, owner, clock, "wawe", __FILE__), |
| 34 | device_sound_interface(mconfig, *this) |
| 35 | { |
| 36 | m_cassette_tag = 0; |
| 37 | } |
| 38 | |
| 39 | //------------------------------------------------- |
| 40 | // device_config_complete - perform any |
| 41 | // operations now that the configuration is |
| 42 | // complete |
| 43 | //------------------------------------------------- |
| 44 | |
| 45 | void wave_device::device_config_complete() |
| 46 | { |
| 47 | } |
| 48 | |
| 49 | //------------------------------------------------- |
| 50 | // device_start - device-specific startup |
| 51 | //------------------------------------------------- |
| 52 | |
| 53 | void wave_device::device_start() |
| 54 | { |
| 55 | speaker_device_iterator spkiter(machine().root_device()); |
| 56 | int speakers = spkiter.count(); |
| 57 | if (speakers > 1) |
| 58 | machine().sound().stream_alloc(*this, 0, 2, machine().sample_rate(), this); |
| 59 | else |
| 60 | machine().sound().stream_alloc(*this, 0, 1, machine().sample_rate(), this); |
| 61 | } |
| 62 | |
| 63 | //------------------------------------------------- |
| 64 | // sound_stream_update - handle a stream update |
| 65 | //------------------------------------------------- |
| 66 | |
| 67 | void wave_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) |
| 68 | { |
| 69 | cassette_image_device *cass = machine().device<cassette_image_device>(m_cassette_tag); |
| 26 | 70 | cassette_image *cassette; |
| 27 | 71 | cassette_state state; |
| 28 | 72 | double time_index; |
| r26430 | r26431 | |
| 64 | 108 | memset(right_buffer, 0, sizeof(*right_buffer) * samples); |
| 65 | 109 | } |
| 66 | 110 | } |
| 67 | | |
| 68 | | |
| 69 | | |
| 70 | | static DEVICE_START( wave ) |
| 71 | | { |
| 72 | | cassette_image_device *image = NULL; |
| 73 | | |
| 74 | | assert( device != NULL ); |
| 75 | | assert( device->static_config() != NULL ); |
| 76 | | speaker_device_iterator spkiter(device->machine().root_device()); |
| 77 | | int speakers = spkiter.count(); |
| 78 | | image = dynamic_cast<cassette_image_device *>(device->machine().device( (const char *)device->static_config())); |
| 79 | | if (speakers > 1) |
| 80 | | device->machine().sound().stream_alloc(*device, 0, 2, device->machine().sample_rate(), (void *)image, wave_sound_update); |
| 81 | | else |
| 82 | | device->machine().sound().stream_alloc(*device, 0, 1, device->machine().sample_rate(), (void *)image, wave_sound_update); |
| 83 | | } |
| 84 | | |
| 85 | | |
| 86 | | const device_type WAVE = &device_creator<wave_device>; |
| 87 | | |
| 88 | | wave_device::wave_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 89 | | : device_t(mconfig, WAVE, "Wave", tag, owner, clock, "wawe", __FILE__), |
| 90 | | device_sound_interface(mconfig, *this) |
| 91 | | { |
| 92 | | } |
| 93 | | |
| 94 | | //------------------------------------------------- |
| 95 | | // device_config_complete - perform any |
| 96 | | // operations now that the configuration is |
| 97 | | // complete |
| 98 | | //------------------------------------------------- |
| 99 | | |
| 100 | | void wave_device::device_config_complete() |
| 101 | | { |
| 102 | | } |
| 103 | | |
| 104 | | //------------------------------------------------- |
| 105 | | // device_start - device-specific startup |
| 106 | | //------------------------------------------------- |
| 107 | | |
| 108 | | void wave_device::device_start() |
| 109 | | { |
| 110 | | DEVICE_START_NAME( wave )(this); |
| 111 | | } |
| 112 | | |
| 113 | | //------------------------------------------------- |
| 114 | | // sound_stream_update - handle a stream update |
| 115 | | //------------------------------------------------- |
| 116 | | |
| 117 | | void wave_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) |
| 118 | | { |
| 119 | | // should never get here |
| 120 | | fatalerror("sound_stream_update called; not applicable to legacy sound devices\n"); |
| 121 | | } |
trunk/src/emu/sound/wave.h
| r26430 | r26431 | |
| 13 | 13 | { |
| 14 | 14 | public: |
| 15 | 15 | wave_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 16 | | |
| 16 | |
| 17 | static void static_set_cassette_tag(device_t &device, const char *cassette_tag); |
| 18 | |
| 17 | 19 | protected: |
| 18 | 20 | // device-level overrides |
| 19 | 21 | virtual void device_config_complete(); |
| r26430 | r26431 | |
| 21 | 23 | |
| 22 | 24 | // sound stream update overrides |
| 23 | 25 | virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); |
| 26 | |
| 24 | 27 | private: |
| 28 | const char *m_cassette_tag; |
| 25 | 29 | }; |
| 26 | 30 | |
| 27 | 31 | extern const device_type WAVE; |
| r26430 | r26431 | |
| 33 | 37 | |
| 34 | 38 | #define MCFG_SOUND_WAVE_ADD(_tag, _cass_tag) \ |
| 35 | 39 | MCFG_SOUND_ADD( _tag, WAVE, 0 ) \ |
| 36 | | MCFG_DEVICE_CONFIG( _cass_tag ) |
| 40 | wave_device::static_set_cassette_tag(*device, _cass_tag); |
| 37 | 41 | |
| 38 | 42 | #endif /* __WAVE_H__ */ |