diff options
Diffstat (limited to 'src/devices/machine/laserdsc.h')
-rw-r--r-- | src/devices/machine/laserdsc.h | 132 |
1 files changed, 72 insertions, 60 deletions
diff --git a/src/devices/machine/laserdsc.h b/src/devices/machine/laserdsc.h index 78f4ad2702a..f84cd47a06a 100644 --- a/src/devices/machine/laserdsc.h +++ b/src/devices/machine/laserdsc.h @@ -2,8 +2,6 @@ // copyright-holders:Aaron Giles /************************************************************************* - laserdsc.h - Core laserdisc player implementation. *************************************************************************/ @@ -15,8 +13,14 @@ #include "emupal.h" #include "screen.h" -#include "vbiparse.h" + #include "avhuff.h" +#include "vbiparse.h" + +#include <algorithm> +#include <system_error> +#include <utility> +#include <vector> //************************************************************************** @@ -93,7 +97,7 @@ protected: public: // delegates - typedef device_delegate<chd_file *(void)> get_disc_delegate; + typedef device_delegate<chd_file * ()> get_disc_delegate; typedef device_delegate<void (int samplerate, int samples, const int16_t *ch0, const int16_t *ch1)> audio_delegate; laserdisc_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); @@ -122,25 +126,15 @@ public: void set_overlay_config(const laserdisc_overlay_config &config) { static_cast<laserdisc_overlay_config &>(*this) = config; } // configuration helpers - template <typename... T> void set_get_disc(T &&... args) { m_getdisc_callback = get_disc_delegate(std::forward<T>(args)...); } - template <typename... T> void set_audio(T &&... args) { m_audio_callback = audio_delegate(std::forward<T>(args)...); } - // FIXME: these should be aware of current device for resolving the tag - template <class FunctionClass> - void set_overlay(uint32_t width, uint32_t height, u32 (FunctionClass::*callback)(screen_device &, bitmap_rgb32 &, const rectangle &), const char *name) - { - set_overlay(width, height, screen_update_rgb32_delegate(callback, name, nullptr, static_cast<FunctionClass *>(nullptr))); - } - template <class FunctionClass> - void set_overlay(uint32_t width, uint32_t height, const char *devname, u32 (FunctionClass::*callback)(screen_device &, bitmap_rgb32 &, const rectangle &), const char *name) - { - set_overlay(width, height, screen_update_rgb32_delegate(callback, name, devname, static_cast<FunctionClass *>(nullptr))); - } - void set_overlay(uint32_t width, uint32_t height, screen_update_rgb32_delegate &&update) + template <typename... T> void set_get_disc(T &&... args) { m_getdisc_callback.set(std::forward<T>(args)...); } + template <typename... T> void set_audio(T &&... args) { m_audio_callback.set(std::forward<T>(args)...); } + template <typename... T> + void set_overlay(uint32_t width, uint32_t height, T &&... args) { m_overwidth = width; m_overheight = height; m_overclip.set(0, width - 1, 0, height - 1); - m_overupdate_rgb32 = std::move(update); + m_overupdate_rgb32.set(std::forward<T>(args)...); } void set_overlay_clip(int32_t minx, int32_t maxx, int32_t miny, int32_t maxy) { m_overclip.set(minx, maxx, miny, maxy); } void set_overlay_position(float posx, float posy) @@ -155,15 +149,8 @@ public: } protected: - // timer IDs - enum - { - TID_VBI_FETCH, - TID_FIRST_PLAYER_TIMER - }; - // common laserdisc states - enum player_state + enum player_state : uint32_t { LDSTATE_NONE, // unspecified state LDSTATE_EJECTING, // in the process of ejecting @@ -195,7 +182,7 @@ protected: }; // slider position - enum slider_position + enum slider_position : uint32_t { SLIDER_MINIMUM, // at the minimum value SLIDER_VIRTUAL_LEADIN, // within the virtual lead-in area @@ -209,8 +196,8 @@ protected: struct player_state_info { player_state m_state; // current state - int32_t m_substate; // internal sub-state; starts at 0 on any state change - int32_t m_param; // parameter for current state + int32_t m_substate; // internal sub-state; starts at 0 on any state change + int32_t m_param; // parameter for current state attotime m_endtime; // minimum ending time for current state }; @@ -220,24 +207,26 @@ protected: virtual void player_overlay(bitmap_yuy16 &bitmap) = 0; // device-level overrides - virtual void device_start() override; - virtual void device_stop() override; - virtual void device_reset() override; - virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; + virtual void device_start() override ATTR_COLD; + virtual void device_stop() override ATTR_COLD; + virtual void device_reset() override ATTR_COLD; virtual void device_validity_check(validity_checker &valid) const override; // device_sound_interface overrides - virtual 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; + + virtual TIMER_CALLBACK_MEMBER(fetch_vbi_data); // subclass helpers void set_audio_squelch(bool squelchleft, bool squelchright) { m_stream->update(); m_audiosquelch = (squelchleft ? 1 : 0) | (squelchright ? 2 : 0); } void set_video_squelch(bool squelch) { m_videosquelch = squelch; } - void set_slider_speed(int32_t tracks_per_vsync); + void set_slider_speed(const double tracks_per_vsync); void advance_slider(int32_t numtracks); slider_position get_slider_position(); int32_t generic_update(const vbi_metadata &vbi, int fieldnum, const attotime &curtime, player_state_info &curstate); // general helpers + bool is_cav_disc() const { return m_is_cav_disc; } bool is_start_of_frame(const vbi_metadata &vbi); int frame_from_metadata(const vbi_metadata &metadata); int chapter_from_metadata(const vbi_metadata &metadata); @@ -245,14 +234,16 @@ protected: player_state_info m_player_state; // active state player_state_info m_saved_state; // saved state during temporary operations + emu_timer *m_vbi_fetch_timer; // fetcher for our VBI data + private: // internal type definitions struct frame_data { bitmap_yuy16 m_bitmap; // cached bitmap bitmap_yuy16 m_visbitmap; // wrapper around bitmap with only visible lines - uint8_t m_numfields; // number of fields in this frame - int32_t m_lastfield; // last absolute field number + uint8_t m_numfields; // number of fields in this frame + int32_t m_lastfield; // last absolute field number }; // internal helpers @@ -267,55 +258,57 @@ private: void read_track_data(); static void *read_async_static(void *param, int threadid); void process_track_data(); - void config_load(config_type cfg_type, util::xml::data_node const *parentnode); + void config_load(config_type cfg_type, config_level cfg_level, util::xml::data_node const *parentnode); void config_save(config_type cfg_type, util::xml::data_node *parentnode); // configuration get_disc_delegate m_getdisc_callback; audio_delegate m_audio_callback; // audio streaming callback laserdisc_overlay_config m_orig_config; // original overlay configuration - uint32_t m_overwidth; // overlay screen width - uint32_t m_overheight; // overlay screen height + uint32_t m_overwidth; // overlay screen width + uint32_t m_overheight; // overlay screen height rectangle m_overclip; // overlay visarea screen_update_rgb32_delegate m_overupdate_rgb32; // overlay update delegate // disc parameters chd_file * m_disc; // handle to the disc itself - std::vector<uint8_t> m_vbidata; // pointer to precomputed VBI data + std::vector<uint8_t> m_vbidata; // pointer to precomputed VBI data + bool m_is_cav_disc; // precomputed check if the mounted disc is CAV int m_width; // width of video int m_height; // height of video - uint32_t m_fps_times_1million; // frame rate of video + uint32_t m_fps_times_1million; // frame rate of video int m_samplerate; // audio samplerate - int m_readresult; // result of the most recent read - uint32_t m_chdtracks; // number of tracks in the CHD - avhuff_decompress_config m_avhuff_config; // decompression configuration + std::error_condition m_readresult; // result of the most recent read + uint32_t m_chdtracks; // number of tracks in the CHD + bitmap_yuy16 m_avhuff_video; // decompresed frame buffer + avhuff_decoder::config m_avhuff_config; // decompression configuration // async operations osd_work_queue * m_work_queue; // work queue - uint32_t m_queued_hunknum; // queued hunk + uint32_t m_queued_hunknum; // queued hunk // core states - uint8_t m_audiosquelch; // audio squelch state: bit 0 = audio 1, bit 1 = audio 2 - uint8_t m_videosquelch; // video squelch state: bit 0 = on/off - uint8_t m_fieldnum; // field number (0 or 1) - int32_t m_curtrack; // current track at this end of this vsync - uint32_t m_maxtrack; // maximum track number + uint8_t m_audiosquelch; // audio squelch state: bit 0 = audio 1, bit 1 = audio 2 + uint8_t m_videosquelch; // video squelch state: bit 0 = on/off + uint8_t m_fieldnum; // field number (0 or 1) + int32_t m_curtrack; // current track at this end of this vsync + uint32_t m_maxtrack; // maximum track number attoseconds_t m_attospertrack; // attoseconds per track, or 0 if not moving attotime m_sliderupdate; // time of last slider update // video data frame_data m_frame[3]; // circular list of frames - uint8_t m_videoindex; // index of the current video buffer + uint8_t m_videoindex; // index of the current video buffer bitmap_yuy16 m_emptyframe; // blank frame // audio data sound_stream * m_stream; - std::vector<int16_t> m_audiobuffer[2]; // buffer for audio samples - uint32_t m_audiobufsize; // size of buffer - uint32_t m_audiobufin; // input index - uint32_t m_audiobufout; // output index - uint32_t m_audiocursamples; // current samples this track - uint32_t m_audiomaxsamples; // maximum samples per track + std::vector<int16_t> m_audiobuffer[2]; // buffer for audio samples + uint32_t m_audiobufsize; // size of buffer + uint32_t m_audiobufin; // input index + uint32_t m_audiobufout; // output index + uint32_t m_audiocursamples; // current samples this track + uint32_t m_audiomaxsamples; // maximum samples per track // metadata vbi_metadata m_metadata[2]; // metadata parsed from the stream, for each field @@ -333,7 +326,7 @@ private: }; // iterator - interface iterator works for subclasses too -typedef device_interface_iterator<laserdisc_device> laserdisc_device_iterator; +typedef device_interface_enumerator<laserdisc_device> laserdisc_device_enumerator; @@ -341,6 +334,25 @@ typedef device_interface_iterator<laserdisc_device> laserdisc_device_iterator; // INLINE FUNCTIONS //************************************************************************** +// ======================> parallel_laserdisc_device + +class parallel_laserdisc_device : public laserdisc_device +{ +public: + + virtual void data_w(u8 data) = 0; + virtual u8 data_r() = 0; + virtual void enter_w(int state) {} + virtual int data_available_r() { return CLEAR_LINE; } + virtual int status_strobe_r() { return CLEAR_LINE; } + virtual int ready_r() { return ASSERT_LINE; } + +protected: + parallel_laserdisc_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock = 0); + + virtual void player_overlay(bitmap_yuy16 &bitmap) override { } +}; + //------------------------------------------------- // is_start_of_frame - return true if this is // the start of a frame |