diff options
Diffstat (limited to 'src/devices/imagedev/cassette.h')
-rw-r--r-- | src/devices/imagedev/cassette.h | 99 |
1 files changed, 57 insertions, 42 deletions
diff --git a/src/devices/imagedev/cassette.h b/src/devices/imagedev/cassette.h index aac43869d2a..88b63caf38b 100644 --- a/src/devices/imagedev/cassette.h +++ b/src/devices/imagedev/cassette.h @@ -8,33 +8,36 @@ *********************************************************************/ -#ifndef MAME_DEVICES_IMAGEDEV_CASSETTE_H -#define MAME_DEVICES_IMAGEDEV_CASSETTE_H +#ifndef MAME_IMAGEDEV_CASSETTE_H +#define MAME_IMAGEDEV_CASSETTE_H + +#pragma once #include "formats/cassimg.h" -#include "softlist_dev.h" -enum cassette_state +enum cassette_state : uint8_t { - /* this part of the state is controlled by the UI */ + // this part of the state is controlled by the UI CASSETTE_STOPPED = 0, CASSETTE_PLAY = 1, CASSETTE_RECORD = 2, - /* this part of the state is controlled by drivers */ + // this part of the state is controlled by drivers CASSETTE_MOTOR_ENABLED = 0, CASSETTE_MOTOR_DISABLED = 4, CASSETTE_SPEAKER_ENABLED = 0, CASSETTE_SPEAKER_MUTED = 8, - /* masks */ + // masks CASSETTE_MASK_UISTATE = 3, CASSETTE_MASK_MOTOR = 4, CASSETTE_MASK_SPEAKER = 8, CASSETTE_MASK_DRVSTATE = 12 }; +DECLARE_ENUM_BITWISE_OPERATORS(cassette_state) + /*************************************************************************** TYPE DEFINITIONS @@ -51,38 +54,46 @@ public: cassette_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); virtual ~cassette_image_device(); - void set_formats(const struct CassetteFormat* const *formats) { m_formats = formats; } - void set_create_opts(const struct CassetteOptions *create_opts) { m_create_opts = create_opts; } + void set_formats(const cassette_image::Format* const *formats) { m_formats = formats; } + void set_create_opts(const cassette_image::Options *create_opts) { m_create_opts = create_opts; } void set_default_state(cassette_state default_state) { m_default_state = default_state; } - void set_default_state(int default_state) { m_default_state = (cassette_state)default_state; } void set_interface(const char *interface) { m_interface = interface; } - // image-level overrides - virtual image_init_result call_load() override; - virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override; + // device_image_interface implementation + virtual std::pair<std::error_condition, std::string> call_load() override; + virtual std::pair<std::error_condition, std::string> call_create(int format_type, util::option_resolution *format_options) override; virtual void call_unload() override; virtual std::string call_display() override; - virtual const software_list_loader &get_software_list_loader() const override { return image_software_list_loader::instance(); } - virtual iodevice_t image_type() const override { return IO_CASSETTE; } + virtual bool is_readable() const noexcept override { return true; } + virtual bool is_writeable() const noexcept override { return true; } + virtual bool is_creatable() const noexcept override { return true; } + virtual bool is_reset_on_load() const noexcept override { return false; } + virtual bool support_command_line_image_creation() const noexcept override { return true; } + virtual const char *image_interface() const noexcept override { return m_interface; } + virtual const char *file_extensions() const noexcept override { return m_extension_list; } + virtual const char *image_type_name() const noexcept override { return "cassette"; } + virtual const char *image_brief_type_name() const noexcept override { return "cass"; } - virtual bool is_readable() const override { return 1; } - virtual bool is_writeable() const override { return 1; } - virtual bool is_creatable() const override { return 1; } - virtual bool must_be_loaded() const override { return 0; } - virtual bool is_reset_on_load() const override { return 0; } - virtual const char *image_interface() const override { return m_interface; } - virtual const char *file_extensions() const override { return m_extension_list; } + double input(); + void output(double value); // specific implementation cassette_state get_state() { return m_state; } - void set_state(cassette_state state) { change_state(state, (cassette_state)(~0)); } + void set_state(cassette_state state) { change_state(state, cassette_state(~0)); } void change_state(cassette_state state, cassette_state mask); - double input(); - void output(double value); + // state getters/setters + bool is_stopped() { return (m_state & CASSETTE_MASK_UISTATE) == CASSETTE_STOPPED; } + bool is_playing() { return (m_state & CASSETTE_MASK_UISTATE) == CASSETTE_PLAY; } + bool is_recording() { return (m_state & CASSETTE_MASK_UISTATE) == CASSETTE_RECORD; } - cassette_image *get_image() { return m_cassette; } + void set_motor(bool state) { change_state(state ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR); } // aka remote control + bool motor_on() { return (m_state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_ENABLED; } + void set_speaker(bool state) { change_state(state ? CASSETTE_SPEAKER_ENABLED : CASSETTE_SPEAKER_MUTED, CASSETTE_MASK_SPEAKER); } + bool speaker_on() { return (m_state & CASSETTE_MASK_SPEAKER) == CASSETTE_SPEAKER_ENABLED; } + + cassette_image *get_image() { return m_cassette.get(); } double get_position(); double get_length(); void set_speed(double speed); @@ -92,41 +103,45 @@ public: void seek(double time, int origin); // sound stream update overrides - void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override; + virtual void sound_stream_update(sound_stream &stream) override; device_sound_interface& set_stereo() { m_stereo = true; return *this; } protected: - bool is_motor_on(); - void update(); - - // device-level overrides + // device_t implementation virtual void device_config_complete() override; - virtual void device_start() override; - virtual const bool use_software_list_file_extension_for_filetype() const override { return true; } + virtual void device_start() override ATTR_COLD; + virtual bool use_software_list_file_extension_for_filetype() const noexcept override { return true; } + + // device_image_interface implementation + virtual const software_list_loader &get_software_list_loader() const override; + + void update(); private: - cassette_image *m_cassette; + cassette_image::ptr m_cassette; cassette_state m_state; double m_position; double m_position_time; - int32_t m_value; + int32_t m_value; int m_channel; double m_speed; // speed multiplier for tape speeds other than standard 1.875ips (used in adam driver) int m_direction; // direction select char m_extension_list[256]; - const struct CassetteFormat* const *m_formats; - const struct CassetteOptions *m_create_opts; - cassette_state m_default_state; - const char * m_interface; + const cassette_image::Format* const *m_formats; + const cassette_image::Options *m_create_opts; + cassette_state m_default_state; + const char * m_interface; - image_init_result internal_load(bool is_create); + std::error_condition internal_load(bool is_create); + bool has_any_extension(std::string_view candidate_extensions) const; bool m_stereo; + std::vector<s16> m_samples; }; // device type definition DECLARE_DEVICE_TYPE(CASSETTE, cassette_image_device) // device iterator -typedef device_type_iterator<cassette_image_device> cassette_device_iterator; +typedef device_type_enumerator<cassette_image_device> cassette_device_enumerator; -#endif // MAME_DEVICES_IMAGEDEV_CASSETTE_H +#endif // MAME_IMAGEDEV_CASSETTE_H |