diff options
Diffstat (limited to 'src/devices/video/fixfreq.h')
-rw-r--r-- | src/devices/video/fixfreq.h | 160 |
1 files changed, 100 insertions, 60 deletions
diff --git a/src/devices/video/fixfreq.h b/src/devices/video/fixfreq.h index fdbf728f04a..6d1da4f22f7 100644 --- a/src/devices/video/fixfreq.h +++ b/src/devices/video/fixfreq.h @@ -22,6 +22,11 @@ struct fixedfreq_monitor_desc fixedfreq_monitor_desc() // default to NTSC "704x480@30i" : m_monitor_clock(13500000), + m_fieldcount(2), + m_sync_threshold(0.3), + m_gain(1.0 / 3.7), + m_hscale(1), + m_vsync_threshold(0.600), // trigger at 91% of vsync length 1-exp(-0.6) m_hvisible(704), m_hfrontporch(728), m_hsync(791), @@ -29,19 +34,64 @@ struct fixedfreq_monitor_desc m_vvisible(480), m_vfrontporch(486), m_vsync(492), - m_vbackporch(525), - m_fieldcount(2), - m_sync_threshold(0.3), - m_gain(1.0 / 3.7), - m_hscale(1) + m_vbackporch(525) {} - int minh() const { return (m_hbackporch - m_hfrontporch) * m_hscale; } - int maxh() const { return (m_hbackporch - m_hfrontporch + m_hvisible) * m_hscale - 1; } - int minv() const { return m_vbackporch - m_vfrontporch; } - int maxv() const { return m_vbackporch - m_vfrontporch + m_vvisible - 1; } + uint32_t monitor_clock() const noexcept { return m_monitor_clock; } + double clock_period() const noexcept { return 1.0 / (double) m_monitor_clock; }; + + int minh() const noexcept { return (m_hbackporch - m_hsync) * m_hscale; } + int maxh() const noexcept { return (m_hbackporch - m_hsync + m_hvisible) * m_hscale - 1; } + int minv() const noexcept { return m_vbackporch - m_vsync; } + int maxv() const noexcept { return m_vbackporch - m_vsync + m_vvisible - 1; } + + int htotal_scaled() const noexcept { return m_hbackporch * m_hscale; } + + int vbackporch_width() const noexcept { return m_vbackporch - m_vsync; } + int vsync_width() const noexcept { return m_vsync - m_vfrontporch; } + int vfrontporch_width() const noexcept { return m_vfrontporch - m_vvisible; } + int vvisible_width() const noexcept { return m_vvisible; } + int vtotal() const noexcept { return m_vbackporch; } + + int hbackporch_width() const noexcept { return m_hbackporch - m_hsync; } + int hsync_width() const noexcept { return m_hsync - m_hfrontporch; } + int hfrontporch_width() const noexcept { return m_hfrontporch - m_hvisible; } + int hvisible_width() const noexcept { return m_hvisible; } + int htotal() const noexcept { return m_hbackporch; } + + void set_h_rel(int vw, int fpw, int sw, int bpw) + { + m_hvisible = vw; + m_hfrontporch = m_hvisible + fpw; + m_hsync = m_hfrontporch + sw; + m_hbackporch = m_hsync + bpw; + } + + void set_v_rel(int vw, int fpw, int sw, int bpw) + { + m_vvisible = vw; + m_vfrontporch = m_vvisible + fpw; + m_vsync = m_vfrontporch + sw; + m_vbackporch = m_vsync + bpw; + } + + double vsync_filter_timeconst() const noexcept + { + return (double) (m_monitor_clock) / ((double) m_hbackporch * vsync_width()); + } + + double hsync_filter_timeconst() const noexcept + { + return (double) m_monitor_clock / (double) hsync_width(); + } uint32_t m_monitor_clock; + int m_fieldcount; + double m_sync_threshold; + double m_gain; + int m_hscale; + double m_vsync_threshold; +private: int m_hvisible; int m_hfrontporch; int m_hsync; @@ -50,16 +100,12 @@ struct fixedfreq_monitor_desc int m_vfrontporch; int m_vsync; int m_vbackporch; - int m_fieldcount; - double m_sync_threshold; - double m_gain; - int m_hscale; }; struct fixedfreq_monitor_intf { virtual ~fixedfreq_monitor_intf() = default; - virtual void vsync_start_cb(double refresh_time) = 0; + virtual void vsync_end_cb(double refresh_time) = 0; }; struct fixedfreq_monitor_line @@ -77,7 +123,7 @@ struct fixedfreq_monitor_state fixedfreq_monitor_state(fixedfreq_monitor_desc &desc, fixedfreq_monitor_intf &intf) : m_desc(desc), m_intf(intf), - m_sync_signal(0), + m_last_sync(0), m_col(0), m_last_x(0), m_last_y(0), @@ -85,14 +131,10 @@ struct fixedfreq_monitor_state m_line_time(time_type(0)), m_last_hsync_time(time_type(0)), m_last_vsync_time(time_type(0)), - m_clock_period(time_type(0)), m_vsync_filter(0), - m_vsync_threshold(0), - m_vsync_filter_timeconst(0), m_sig_vsync(0), m_sig_composite(0), - m_sig_field(0), - m_min_frame_period(time_type(0)) + m_sig_field(0) {} /*** @@ -103,7 +145,7 @@ struct fixedfreq_monitor_state // FIXME: once moved to netlist this may no longer be necessary. // Only copies constructor init - m_sync_signal = 0.0; + m_last_sync = 0.0; m_col = rgb_t(0,0,0); m_last_x = 0; m_last_y = 0; @@ -111,12 +153,9 @@ struct fixedfreq_monitor_state m_line_time = time_type(0); m_last_hsync_time = time_type(0); m_last_vsync_time = time_type(0); - m_clock_period = time_type(0); /* sync separator */ m_vsync_filter = 0.0; - m_vsync_threshold = 0.0; - m_vsync_filter_timeconst = 0.0; m_sig_vsync = 0; m_sig_composite = 0; @@ -127,22 +166,18 @@ struct fixedfreq_monitor_state /* sync separator */ - m_vsync_threshold = (exp(- 3.0/(3.0+3.0))) - exp(-1.0); - m_vsync_filter_timeconst = (double) (m_desc.m_monitor_clock) / (double) m_desc.m_hbackporch * 1.0; // / (3.0 + 3.0); - //LOG("trigger %f with len %f\n", m_vsync_threshold, 1e6 / m_vsync_filter_timeconst); - - m_clock_period = 1.0 / m_desc.m_monitor_clock; + //m_vsync_threshold = (exp(- 3.0/(3.0+3.0))) - exp(-1.0); + //printf("trigger %f with len %f\n", m_vsync_threshold, 1e6 / m_vsync_filter_timeconst); // Minimum frame period to be passed to video system ? - m_min_frame_period = 0.25 * m_clock_period * m_desc.m_vbackporch * m_desc.m_hbackporch; m_fragments.clear(); - m_intf.vsync_start_cb(m_min_frame_period); + m_intf.vsync_end_cb(m_desc.clock_period() * m_desc.vtotal() * m_desc.htotal()); } void reset() { - m_sync_signal = 0; + m_last_sync = 0; m_col = 0; m_last_x = 0; m_last_y = 0; @@ -171,7 +206,7 @@ struct fixedfreq_monitor_state const fixedfreq_monitor_desc &m_desc; fixedfreq_monitor_intf &m_intf; - double m_sync_signal; + double m_last_sync; uint32_t m_col; float m_last_x; int m_last_y; @@ -179,17 +214,13 @@ struct fixedfreq_monitor_state time_type m_line_time; time_type m_last_hsync_time; time_type m_last_vsync_time; - time_type m_clock_period; /* sync separator */ double m_vsync_filter; - double m_vsync_threshold; - double m_vsync_filter_timeconst; int m_sig_vsync; int m_sig_composite; int m_sig_field; - time_type m_min_frame_period; std::vector<fixedfreq_monitor_line> m_fragments; }; @@ -206,42 +237,48 @@ public: fixedfreq_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); // inline configuration helpers - void set_monitor_clock(uint32_t clock) { m_monitor.m_monitor_clock = clock; } - void set_fieldcount(int count) { m_monitor.m_fieldcount = count; } - void set_threshold(double threshold) { m_monitor.m_sync_threshold = threshold; } - void set_gain(double gain) { m_monitor.m_gain = gain; } - void set_horz_params(int visible, int frontporch, int sync, int backporch) + fixedfreq_device &set_monitor_clock(uint32_t clock) { m_monitor.m_monitor_clock = clock; return *this;} + fixedfreq_device &set_fieldcount(int count) { m_monitor.m_fieldcount = count; return *this; } + fixedfreq_device &set_threshold(double threshold) { m_monitor.m_sync_threshold = threshold; return *this; } + fixedfreq_device &set_gain(double gain) { m_monitor.m_gain = gain; return *this; } + fixedfreq_device &set_horz_params(int visible, int frontporch, int sync, int backporch) { - m_monitor.m_hvisible = visible; - m_monitor.m_hfrontporch = frontporch; - m_monitor.m_hsync = sync; - m_monitor.m_hbackporch = backporch; + m_monitor.set_h_rel( + visible, + frontporch - visible, + sync - frontporch, + backporch - sync); + return *this; } - void set_vert_params(int visible, int frontporch, int sync, int backporch) + fixedfreq_device &set_vert_params(int visible, int frontporch, int sync, int backporch) { - m_monitor.m_vvisible = visible; - m_monitor.m_vfrontporch = frontporch; - m_monitor.m_vsync = sync; - m_monitor.m_vbackporch = backporch; + m_monitor.set_v_rel( + visible, + frontporch - visible, + sync - frontporch, + backporch - sync); + return *this; } - void set_horz_scale(int hscale) { m_monitor.m_hscale = hscale; } + fixedfreq_device &set_horz_scale(int hscale) { m_monitor.m_hscale = hscale; return *this;} // pre-defined configurations - void set_mode_ntsc720() //ModeLine "720x480@30i" 13.5 720 736 799 858 480 486 492 525 interlace -hsync -vsync + fixedfreq_device &set_mode_ntsc720() //ModeLine "720x480@30i" 13.5 720 736 799 858 480 486 492 525 interlace -hsync -vsync { set_monitor_clock(13500000); set_horz_params(720, 736, 799, 858); set_vert_params(480, 486, 492, 525); set_fieldcount(2); set_threshold(0.3); + return *this; } - void set_mode_ntsc704() //ModeLine "704x480@30i" 13.5 704 728 791 858 480 486 492 525 + fixedfreq_device &set_mode_ntsc704() //ModeLine "704x480@30i" 13.5 704 728 791 858 480 486 492 525 { set_monitor_clock(13500000); set_horz_params(704, 728, 791, 858); set_vert_params(480, 486, 492, 525); set_fieldcount(2); set_threshold(0.3); + return *this; } virtual uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); @@ -252,6 +289,9 @@ public: NETDEV_ANALOG_CALLBACK_MEMBER(update_blue); NETDEV_ANALOG_CALLBACK_MEMBER(update_sync); + INPUT_CHANGED_MEMBER(port_changed); + + unsigned monitor_val(unsigned param) const; protected: @@ -264,14 +304,14 @@ protected: virtual void device_post_load() override; //virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); - void vsync_start_cb(double refresh_time) override; - -private: + virtual ioport_constructor device_input_ports() const override; - int m_htotal; - int m_vtotal; + void vsync_end_cb(double refresh_time) override; - time_type m_refresh_period; +private: + required_ioport m_enable; + required_ioport m_vector; + float m_scanline_height; /* adjustable by drivers */ fixedfreq_monitor_desc m_monitor; |