diff options
Diffstat (limited to 'src/devices/video/mc6847.h')
-rw-r--r-- | src/devices/video/mc6847.h | 151 |
1 files changed, 65 insertions, 86 deletions
diff --git a/src/devices/video/mc6847.h b/src/devices/video/mc6847.h index 51ecde98334..b82c014e5b0 100644 --- a/src/devices/video/mc6847.h +++ b/src/devices/video/mc6847.h @@ -58,19 +58,12 @@ public: protected: mc6847_friend_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, - const uint8_t *fontdata, bool is_mc6847t1, double tpfs, int field_sync_falling_edge_scanline, int divider, bool supports_partial_body_scanlines); - - // timer constants - static constexpr device_timer_id TIMER_FRAME = 0; - static constexpr device_timer_id TIMER_HSYNC_OFF = 1; - static constexpr device_timer_id TIMER_HSYNC_ON = 2; - static constexpr device_timer_id TIMER_FSYNC = 3; + const uint8_t *fontdata, bool is_mc6847t1, double tpfs, int field_sync_falling_edge_scanline, int divider, + bool supports_partial_body_scanlines, bool pal); // fonts - static const uint8_t pal_round_fontdata8x12[]; - static const uint8_t pal_square_fontdata8x12[]; - static const uint8_t ntsc_round_fontdata8x12[]; - static const uint8_t ntsc_square_fontdata8x12[]; + static const uint8_t vdg_t1_fontdata8x12[]; + static const uint8_t vdg_fontdata8x12[]; static const uint8_t semigraphics4_fontdata8x12[]; static const uint8_t semigraphics6_fontdata8x12[]; static const uint8_t s68047_fontdata8x12[]; @@ -219,11 +212,11 @@ protected: for (x = 0; x < 256; x += 2) { uint8_t val = ((pixels[(x - 2) * xscale] == c1) ? 0x20 : 0x00) - | ((pixels[(x - 1) * xscale] == c1) ? 0x10 : 0x00) - | ((pixels[(x + 0) * xscale] == c1) ? 0x08 : 0x00) - | ((pixels[(x + 1) * xscale] == c1) ? 0x04 : 0x00) - | ((pixels[(x + 2) * xscale] == c1) ? 0x02 : 0x00) - | ((pixels[(x + 3) * xscale] == c1) ? 0x01 : 0x00); + | ((pixels[(x - 1) * xscale] == c1) ? 0x10 : 0x00) + | ((pixels[(x + 0) * xscale] == c1) ? 0x08 : 0x00) + | ((pixels[(x + 1) * xscale] == c1) ? 0x04 : 0x00) + | ((pixels[(x + 2) * xscale] == c1) ? 0x02 : 0x00) + | ((pixels[(x + 3) * xscale] == c1) ? 0x01 : 0x00); new_line[x + 0] = m_expanded_colors[val * 2 + 0]; new_line[x + 1] = m_expanded_colors[val * 2 + 1]; @@ -253,14 +246,6 @@ protected: static pixel_t mix_color(double factor, uint8_t c0, uint8_t c1); }; - enum border_color_t - { - BORDER_COLOR_BLACK, - BORDER_COLOR_GREEN, - BORDER_COLOR_WHITE, - BORDER_COLOR_ORANGE - }; - // callbacks devcb_write_line m_write_hsync; devcb_write_line m_write_fsync; @@ -275,26 +260,22 @@ protected: // device-level overrides virtual void device_start() override; - virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; virtual void device_reset() override; virtual void device_post_load() override; // other overridables virtual void new_frame(); - virtual void horizontal_sync_changed(bool line); + virtual TIMER_CALLBACK_MEMBER(horizontal_sync_changed); virtual void field_sync_changed(bool line); virtual void enter_bottom_border(); virtual void record_border_scanline(uint16_t physical_scanline); - virtual void record_body_scanline(uint16_t physical_scanline, uint16_t logical_scanline) = 0; + virtual void record_full_body_scanline(uint16_t physical_scanline, uint16_t logical_scanline) = 0; virtual void record_partial_body_scanline(uint16_t physical_scanline, uint16_t logical_scanline, int32_t start_clock, int32_t end_clock) = 0; // miscellaneous void video_flush(); std::string describe_context() const; - // setup functions - emu_timer *setup_timer(device_timer_id id, double offset, double period); - // converts to B&W static pixel_t black_and_white(rgb_t color) { @@ -316,29 +297,6 @@ protected: } } - // calculates the border color - static ATTR_FORCE_INLINE border_color_t border_value(uint8_t mode, bool is_mc6847t1) - { - border_color_t result; - - if (mode & MODE_AG) - { - // graphics - result = mode & MODE_CSS ? BORDER_COLOR_WHITE : BORDER_COLOR_GREEN; - } - else if (!is_mc6847t1 || ((mode & MODE_GM2) == 0)) - { - // text, black border - result = BORDER_COLOR_BLACK; - } - else - { - // text, green or orange border - result = mode & MODE_CSS ? BORDER_COLOR_ORANGE : BORDER_COLOR_GREEN; - } - return result; - } - // checks to see if the video has changed ATTR_FORCE_INLINE bool has_video_changed() { @@ -467,11 +425,9 @@ private: SCANLINE_ZONE_BOTTOM_BORDER, SCANLINE_ZONE_RETRACE, SCANLINE_ZONE_VBLANK, - SCANLINE_ZONE_FRAME_END }; // timers - emu_timer *m_frame_timer; emu_timer *m_hsync_on_timer; emu_timer *m_hsync_off_timer; emu_timer *m_fsync_timer; @@ -482,7 +438,7 @@ protected: private: // incidentals const int m_divider; - int m_field_sync_falling_edge_scanline; + const int m_field_sync_falling_edge_scanline; bool m_wide; bool m_video_changed; uint16_t m_top_border_scanlines; @@ -490,6 +446,13 @@ private: bool m_recording_scanline; const bool m_supports_partial_body_scanlines; +protected: + const bool m_pal; + const uint16_t m_lines_top_border; + const uint16_t m_lines_until_vblank; + const uint16_t m_lines_until_retrace; + +private: // video state uint16_t m_physical_scanline; uint16_t m_logical_scanline; @@ -499,14 +462,19 @@ private: uint32_t m_partial_scanline_clocks; // functions - void change_horizontal_sync(bool line); - void change_field_sync(bool line); + virtual TIMER_CALLBACK_MEMBER(change_horizontal_sync); + TIMER_CALLBACK_MEMBER(change_field_sync); void update_field_sync_timer(); void next_scanline(); int32_t get_clocks_since_hsync(); // debugging std::string scanline_zone_string(scanline_zone zone) const; + +protected: + bool is_top_pal_padding_line(int scanline) const; + bool is_bottom_pal_padding_line(int scanline) const; + bool is_pal_padding_line(int scanline) const; }; // actual base class for MC6847 family of devices @@ -524,17 +492,20 @@ public: uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); // mode changing operations - DECLARE_WRITE_LINE_MEMBER( ag_w ) { change_mode(MODE_AG, state); } - DECLARE_WRITE_LINE_MEMBER( gm2_w ) { change_mode(MODE_GM2, state); } - DECLARE_WRITE_LINE_MEMBER( gm1_w ) { change_mode(MODE_GM1, state); } - DECLARE_WRITE_LINE_MEMBER( gm0_w ) { change_mode(MODE_GM0, state); } - DECLARE_WRITE_LINE_MEMBER( as_w ) { change_mode(MODE_AS, state); } - DECLARE_WRITE_LINE_MEMBER( css_w ) { change_mode(MODE_CSS, state); } - DECLARE_WRITE_LINE_MEMBER( intext_w ) { change_mode(MODE_INTEXT, state); } - DECLARE_WRITE_LINE_MEMBER( inv_w ) { change_mode(MODE_INV, state); } + void ag_w(int state) { change_mode(MODE_AG, state); } + void gm2_w(int state) { change_mode(MODE_GM2, state); } + void gm1_w(int state) { change_mode(MODE_GM1, state); } + void gm0_w(int state) { change_mode(MODE_GM0, state); } + void as_w(int state) { change_mode(MODE_AS, state); } + void css_w(int state) { change_mode(MODE_CSS, state); } + void intext_w(int state) { change_mode(MODE_INTEXT, state); } + void inv_w(int state) { change_mode(MODE_INV, state); } + + // palette + void set_palette(const uint32_t *palette) { m_palette = (palette) ? palette : default_palette(); } protected: - mc6847_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, const uint8_t *fontdata, double tpfs); + mc6847_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, const uint8_t *fontdata, double tpfs, bool pal); // device-level overrides virtual void device_config_complete() override; @@ -544,16 +515,23 @@ protected: // other overrides virtual void field_sync_changed(bool line) override; - virtual void record_body_scanline(uint16_t physical_scanline, uint16_t scanline) override; + virtual void record_full_body_scanline(uint16_t physical_scanline, uint16_t scanline) override; virtual void record_partial_body_scanline(uint16_t physical_scanline, uint16_t logical_scanline, int32_t start_clock, int32_t end_clock) override; - void set_custom_palette(const pixel_t *custom_palette) + virtual uint32_t emit_samples(uint8_t mode, const uint8_t *data, int length, pixel_t *RESTRICT pixels, const pixel_t *RESTRICT palette, + get_char_rom_delegate const &get_char_rom, int x, int y) { - if (m_palette != m_bw_palette) - { - m_palette = custom_palette ? custom_palette : s_palette; - } + return emit_mc6847_samples<1>(mode, data, length, pixels, palette, get_char_rom, x, y); } + virtual const uint32_t* default_palette() { return s_palette; } + + // runtime functions + virtual void record_body_scanline(uint8_t mode, uint16_t physical_scanline, uint16_t scanline, int32_t start_pos, int32_t end_pos); + virtual uint8_t border_value(uint8_t mode); + + // template function for doing video update collection + template<int sample_count, int yres> + void record_scanline_res(int scanline, int32_t start_pos, int32_t end_pos); private: struct video_scanline @@ -567,8 +545,6 @@ private: static const int PALETTE_LENGTH = 16; static const uint32_t s_palette[PALETTE_LENGTH]; - // callbacks - /* if specified, this gets called whenever reading a byte (offs_t ~0 specifies DA* entering the tristate mode) */ devcb_read8 m_input_cb; @@ -617,14 +593,6 @@ private: // setup functions void setup_fixed_mode(); - // runtime functions - void record_body_scanline(uint16_t physical_scanline, uint16_t scanline, int32_t start_pos, int32_t end_pos); - pixel_t border_value(uint8_t mode, const pixel_t *palette, bool is_mc6847t1); - - // template function for doing video update collection - template<int sample_count, int yres> - void record_scanline_res(int scanline, int32_t start_pos, int32_t end_pos); - // miscellaneous uint8_t input(uint16_t address); int32_t scanline_position_from_clock(int32_t clocks_since_hsync); @@ -663,9 +631,14 @@ class mc6847t1_ntsc_device : public mc6847_base_device { public: mc6847t1_ntsc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + +protected: + mc6847t1_ntsc_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, const uint8_t *fontdata, double tpfs, bool pal); + + virtual uint8_t border_value(uint8_t mode) override; }; -class mc6847t1_pal_device : public mc6847_base_device +class mc6847t1_pal_device : public mc6847t1_ntsc_device { public: mc6847t1_pal_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); @@ -676,10 +649,16 @@ class s68047_device : public mc6847_base_device public: s68047_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - void hack_black_becomes_blue(bool flag); +protected: + virtual uint32_t emit_samples(uint8_t mode, const uint8_t *data, int length, pixel_t *RESTRICT pixels, const pixel_t *RESTRICT palette, + get_char_rom_delegate const &get_char_rom, int x, int y) override; + virtual const uint32_t* default_palette() override { return s_s68047_palette; } + + virtual void record_body_scanline(uint8_t mode, uint16_t physical_scanline, uint16_t scanline, int32_t start_pos, int32_t end_pos) override; + virtual uint8_t border_value(uint8_t mode) override; private: - static const uint32_t s_s68047_hack_palette[16]; + static const uint32_t s_s68047_palette[16]; }; class m5c6847p1_device : public mc6847_base_device |