diff options
author | andreasnaive <andreasnaive@gmail.com> | 2019-03-25 23:13:40 +0100 |
---|---|---|
committer | andreasnaive <andreasnaive@gmail.com> | 2019-03-25 23:13:40 +0100 |
commit | b380514764cf857469bae61c11143a19f79a74c5 (patch) | |
tree | 63c8012e262618f08a332da31dd714281aa2c5ed /src/devices/video | |
parent | c24473ddff715ecec2e258a6eb38960cf8c8e98e (diff) |
Revert "conflict resolution (nw)"
This reverts commit c24473ddff715ecec2e258a6eb38960cf8c8e98e, reversing
changes made to 009cba4fb8102102168ef32870892438327f3705.
Diffstat (limited to 'src/devices/video')
102 files changed, 1742 insertions, 2631 deletions
diff --git a/src/devices/video/315_5124.cpp b/src/devices/video/315_5124.cpp index 90b94577376..ef3b07d1f4f 100644 --- a/src/devices/video/315_5124.cpp +++ b/src/devices/video/315_5124.cpp @@ -88,12 +88,12 @@ PAL frame timing #define BOTTOM_BORDER 4 #define BOTTOM_BLANKING 5 -static constexpr u8 ntsc_192[6] = { 3, 13, 27, 192, 24, 3 }; -static constexpr u8 ntsc_224[6] = { 3, 13, 11, 224, 8, 3 }; -static constexpr u8 ntsc_240[6] = { 3, 13, 3, 240, 0, 3 }; -static constexpr u8 pal_192[6] = { 3, 13, 54, 192, 48, 3 }; -static constexpr u8 pal_224[6] = { 3, 13, 38, 224, 32, 3 }; -static constexpr u8 pal_240[6] = { 3, 13, 30, 240, 24, 3 }; +static constexpr uint8_t ntsc_192[6] = { 3, 13, 27, 192, 24, 3 }; +static constexpr uint8_t ntsc_224[6] = { 3, 13, 11, 224, 8, 3 }; +static constexpr uint8_t ntsc_240[6] = { 3, 13, 3, 240, 0, 3 }; +static constexpr uint8_t pal_192[6] = { 3, 13, 54, 192, 48, 3 }; +static constexpr uint8_t pal_224[6] = { 3, 13, 38, 224, 32, 3 }; +static constexpr uint8_t pal_240[6] = { 3, 13, 30, 240, 24, 3 }; #define VINT_HPOS 0 #define VINT_FLAG_HPOS 1 @@ -104,8 +104,8 @@ static constexpr u8 pal_240[6] = { 3, 13, 30, 240, 24, 3 }; #define SPROVR_HPOS 6 #define SPRCOL_BASEHPOS 7 -static constexpr u8 line_315_5124[8] = { 24, 24, 26, 28 /* not verified */, 21, 23, 24, 59 }; -static constexpr u8 line_315_5377[8] = { 26, 26, 27, 28 /* not verified */, 24, 28, 26, 62 }; +static constexpr uint8_t line_315_5124[8] = { 24, 24, 26, 28 /* not verified */, 21, 23, 24, 59 }; +static constexpr uint8_t line_315_5377[8] = { 26, 26, 27, 28 /* not verified */, 24, 28, 26, 62 }; #define DISPLAY_DISABLED_HPOS 24 /* not verified, works if above 18 (for 'pstrike2') and below 25 (for 'fantdizzy') */ #define DISPLAY_CB_HPOS 2 /* fixes 'roadrash' (SMS game) title scrolling, due to line counter reload timing */ @@ -164,22 +164,20 @@ void sega315_5377_device::sega315_5377_palette(palette_device &palette) const // default address map void sega315_5124_device::sega315_5124(address_map &map) { - if (!has_configured_map(0)) - map(0x0000, VRAM_SIZE-1).ram(); + map(0x0000, VRAM_SIZE-1).ram(); } -sega315_5124_device::sega315_5124_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) +sega315_5124_device::sega315_5124_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : sega315_5124_device(mconfig, SEGA315_5124, tag, owner, clock, SEGA315_5124_CRAM_SIZE, 0x00, 0x0f, 4, 8, line_315_5124) { } -sega315_5124_device::sega315_5124_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 cram_size, u8 palette_offset, u8 reg_num_mask, int max_sprite_zoom_hcount, int max_sprite_zoom_vcount, const u8 *line_timing) +sega315_5124_device::sega315_5124_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint8_t cram_size, uint8_t palette_offset, uint8_t reg_num_mask, int max_sprite_zoom_hcount, int max_sprite_zoom_vcount, const uint8_t *line_timing) : device_t(mconfig, type, tag, owner, clock) , device_memory_interface(mconfig, *this) , device_video_interface(mconfig, *this) - , device_mixer_interface(mconfig, *this, 2) , m_cram_size(cram_size) , m_line_timing(line_timing) , m_palette_offset(palette_offset) @@ -190,33 +188,32 @@ sega315_5124_device::sega315_5124_device(const machine_config &mconfig, device_t , m_int_cb(*this) , m_csync_cb(*this) , m_pause_cb(*this) - , m_space_config("videoram", ENDIANNESS_LITTLE, 8, 14, 0, address_map_constructor(FUNC(sega315_5124_device::sega315_5124), this)) + , m_space_config("videoram", ENDIANNESS_LITTLE, 8, 14, 0, address_map_constructor(), address_map_constructor(FUNC(sega315_5124_device::sega315_5124), this)) , m_palette(*this, "palette") - , m_snsnd(*this, "snsnd") { } -sega315_5246_device::sega315_5246_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) +sega315_5246_device::sega315_5246_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : sega315_5124_device(mconfig, SEGA315_5246, tag, owner, clock, SEGA315_5124_CRAM_SIZE, 0x00, 0x0f, 8, 8, line_315_5124) { } -sega315_5246_device::sega315_5246_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 cram_size, u8 palette_offset, u8 reg_num_mask, int max_sprite_zoom_hcount, int max_sprite_zoom_vcount, const u8 *line_timing) +sega315_5246_device::sega315_5246_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint8_t cram_size, uint8_t palette_offset, uint8_t reg_num_mask, int max_sprite_zoom_hcount, int max_sprite_zoom_vcount, const uint8_t *line_timing) : sega315_5124_device(mconfig, type, tag, owner, clock, cram_size, palette_offset, reg_num_mask, max_sprite_zoom_hcount, max_sprite_zoom_vcount, line_timing) { } // Embedded mode 4 support of the 315-5313 VDP (see 315_5313.cpp), used by Sega Genesis/Mega Drive -sega315_5313_mode4_device::sega315_5313_mode4_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 cram_size, u8 palette_offset, u8 reg_num_mask, int max_sprite_zoom_hcount, int max_sprite_zoom_vcount, const u8 *line_timing) +sega315_5313_mode4_device::sega315_5313_mode4_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint8_t cram_size, uint8_t palette_offset, uint8_t reg_num_mask, int max_sprite_zoom_hcount, int max_sprite_zoom_vcount, const uint8_t *line_timing) : sega315_5246_device(mconfig, type, tag, owner, clock, cram_size, palette_offset, reg_num_mask, max_sprite_zoom_hcount, max_sprite_zoom_vcount, line_timing) { } -sega315_5377_device::sega315_5377_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) +sega315_5377_device::sega315_5377_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : sega315_5246_device(mconfig, SEGA315_5377, tag, owner, clock, SEGA315_5377_CRAM_SIZE, 0x10, 0x0f, 8, 8, line_315_5377) { } @@ -331,7 +328,7 @@ void sega315_5124_device::set_frame_timing() } -u8 sega315_5124_device::vcount_read() +READ8_MEMBER( sega315_5124_device::vcount_read ) { const int active_scr_start = m_frame_timing[VERTICAL_SYNC] + m_frame_timing[TOP_BLANKING] + m_frame_timing[TOP_BORDER]; int vpos = screen().vpos(); @@ -347,7 +344,7 @@ u8 sega315_5124_device::vcount_read() } -u8 sega315_5124_device::hcount_read() +READ8_MEMBER( sega315_5124_device::hcount_read ) { return m_hcounter; } @@ -595,10 +592,10 @@ void sega315_5124_device::process_line_timer() } -u8 sega315_5124_device::data_read() +READ8_MEMBER( sega315_5124_device::data_read ) { /* Return data buffer contents */ - const u8 temp = m_buffer; + const uint8_t temp = m_buffer; /* Clear pending write flag */ m_pending_control_write = false; @@ -656,9 +653,9 @@ void sega315_5124_device::check_pending_flags() } -u8 sega315_5124_device::control_read() +READ8_MEMBER( sega315_5124_device::control_read ) { - u8 temp; + uint8_t temp; check_pending_flags(); temp = m_status; @@ -670,7 +667,7 @@ u8 sega315_5124_device::control_read() /* Clear status flags */ m_hint_occurred = false; - m_status = u8(~(STATUS_VINT | STATUS_SPROVR | STATUS_SPRCOL)); + m_status = uint8_t(~(STATUS_VINT | STATUS_SPROVR | STATUS_SPRCOL)); if (m_irq_state == 1) { @@ -685,7 +682,7 @@ u8 sega315_5124_device::control_read() } -void sega315_5124_device::write_memory(u8 data) +void sega315_5124_device::write_memory(uint8_t data) { switch (m_addrmode) { @@ -705,7 +702,7 @@ void sega315_5124_device::write_memory(u8 data) } -void sega315_5313_mode4_device::write_memory(u8 data) +void sega315_5313_mode4_device::write_memory(uint8_t data) { switch (m_addrmode) { @@ -723,7 +720,7 @@ void sega315_5313_mode4_device::write_memory(u8 data) } -void sega315_5124_device::data_write(u8 data) +WRITE8_MEMBER( sega315_5124_device::data_write ) { /* Clear pending write flag */ m_pending_control_write = false; @@ -733,7 +730,7 @@ void sega315_5124_device::data_write(u8 data) } -void sega315_5124_device::load_vram_addr(u8 data) +void sega315_5124_device::load_vram_addr(uint8_t data) { // Seems like the latched data is passed straight through // to the address register when in the middle of doing a command. @@ -745,7 +742,7 @@ void sega315_5124_device::load_vram_addr(u8 data) } -void sega315_5313_mode4_device::load_vram_addr(u8 data) +void sega315_5313_mode4_device::load_vram_addr(uint8_t data) { if (m_pending_control_write) m_control_write_data_latch = data; @@ -754,7 +751,7 @@ void sega315_5313_mode4_device::load_vram_addr(u8 data) } -void sega315_5124_device::control_write(u8 data) +WRITE8_MEMBER( sega315_5124_device::control_write ) { if (!m_pending_control_write) { @@ -862,13 +859,13 @@ void sega315_5124_device::control_write(u8 data) } -u16 sega315_5124_device::name_table_row_mode4(int row) +uint16_t sega315_5124_device::name_table_row_mode4(int row) { return ((row >> 3) << 6) & (((m_reg[0x02] & 0x01) << 10) | ((m_reg[0x04] & 0x03) << 11) | 0x23ff); } -u16 sega315_5246_device::name_table_row_mode4(int row) +uint16_t sega315_5246_device::name_table_row_mode4(int row) { return (row >> 3) << 6; } @@ -900,7 +897,7 @@ void sega315_5124_device::draw_leftmost_pixels_mode4(int *line_buffer, int *prio // Load data of bit plane 1 for the selected tile. const int tmp_bit_plane_1 = space().read_byte((tile_selected << 5) + ((parse_line & 0x07) << 2) + 0x01); - const u8 pen_bit_1 = BIT(tmp_bit_plane_1, 7 - pixel_x); + const uint8_t pen_bit_1 = BIT(tmp_bit_plane_1, 7 - pixel_x); for (int pixel_plot_x = 0; pixel_plot_x < fine_x_scroll; pixel_plot_x++) { @@ -934,7 +931,7 @@ void sega315_5124_device::draw_scanline_mode4(int *line_buffer, int *priority_se const int fine_x_scroll = (x_scroll & 0x07); int scroll_mod; - u16 name_table_address; + uint16_t name_table_address; if (m_y_pixels != 192) { name_table_address = ((m_reg[0x02] & 0x0c) << 10) | 0x0700; @@ -956,7 +953,7 @@ void sega315_5124_device::draw_scanline_mode4(int *line_buffer, int *priority_se /* vertical scrolling when bit 7 of reg[0x00] is set */ const int y_scroll = (BIT(m_reg[0x00], 7) && (tile_column > 23)) ? 0 : m_reg9copy; - const u16 tile_data = space().read_word(name_table_address + name_table_row_mode4((line + y_scroll) % scroll_mod) + table_column); + const uint16_t tile_data = space().read_word(name_table_address + name_table_row_mode4((line + y_scroll) % scroll_mod) + table_column); const int tile_selected = (tile_data & 0x01ff); const int priority_select = tile_data & PRIORITY_BIT; @@ -981,12 +978,12 @@ void sega315_5124_device::draw_scanline_mode4(int *line_buffer, int *priority_se for (int pixel_x = 0; pixel_x < 8; pixel_x++) { - const u8 pen_bit_0 = BIT(bit_plane_0, 7 - pixel_x); - const u8 pen_bit_1 = BIT(bit_plane_1, 7 - pixel_x); - const u8 pen_bit_2 = BIT(bit_plane_2, 7 - pixel_x); - const u8 pen_bit_3 = BIT(bit_plane_3, 7 - pixel_x); + const uint8_t pen_bit_0 = BIT(bit_plane_0, 7 - pixel_x); + const uint8_t pen_bit_1 = BIT(bit_plane_1, 7 - pixel_x); + const uint8_t pen_bit_2 = BIT(bit_plane_2, 7 - pixel_x); + const uint8_t pen_bit_3 = BIT(bit_plane_3, 7 - pixel_x); - u8 pen_selected = (pen_bit_3 << 3 | pen_bit_2 << 2 | pen_bit_1 << 1 | pen_bit_0); + uint8_t pen_selected = (pen_bit_3 << 3 | pen_bit_2 << 2 | pen_bit_1 << 1 | pen_bit_0); if (palette_selected) pen_selected |= 0x10; @@ -1003,25 +1000,25 @@ void sega315_5124_device::draw_scanline_mode4(int *line_buffer, int *priority_se } -u16 sega315_5124_device::sprite_attributes_addr_mode4(u16 base) +uint16_t sega315_5124_device::sprite_attributes_addr_mode4(uint16_t base) { return base & ((BIT(m_reg[0x05], 0) << 7) | 0x3f7f); } -u16 sega315_5246_device::sprite_attributes_addr_mode4(u16 base) +uint16_t sega315_5246_device::sprite_attributes_addr_mode4(uint16_t base) { return base; } -u8 sega315_5124_device::sprite_tile_mask_mode4(u8 tile_number) +uint8_t sega315_5124_device::sprite_tile_mask_mode4(uint8_t tile_number) { return tile_number & (((m_reg[0x06] & 0x03) << 6) | 0x3f); } -u8 sega315_5246_device::sprite_tile_mask_mode4(u8 tile_number) +uint8_t sega315_5246_device::sprite_tile_mask_mode4(uint8_t tile_number) { return tile_number; } @@ -1032,7 +1029,7 @@ void sega315_5124_device::sprite_count_overflow(int line, int sprite_index) /* Overflow is flagged only on active display and when VINT isn't active */ if (!(m_status & STATUS_VINT) && line >= 0 && line < m_frame_timing[ACTIVE_DISPLAY_V]) { - u8 sprite_number_bits; + uint8_t sprite_number_bits; m_pending_status |= STATUS_SPROVR; if (sprite_index < 14) sprite_number_bits = (sprite_index + 1) / 2; @@ -1099,7 +1096,7 @@ void sega315_5124_device::select_sprites(int line) { const int sprite_x = space().read_byte(m_sprite_base + sprite_index + 1); int sprite_tile_selected = space().read_byte(m_sprite_base + sprite_index + 2); - const u8 flags = space().read_byte(m_sprite_base + sprite_index + 3); + const uint8_t flags = space().read_byte(m_sprite_base + sprite_index + 3); int sprite_line = parse_line - sprite_y; @@ -1268,28 +1265,28 @@ void sega315_5124_device::draw_sprites_mode4(int *line_buffer, int *priority_sel bool sprite_col_occurred = false; int sprite_col_x = 255; - u8 collision_buffer[256] = { 0 }; + uint8_t collision_buffer[256] = { 0 }; // Draw sprite layer for (int sprite_buffer_index = m_sprite_count - 1; sprite_buffer_index >= 0; sprite_buffer_index--) { const int sprite_x = m_sprite_x[sprite_buffer_index]; const int sprite_tile_selected = m_sprite_tile_selected[sprite_buffer_index]; - const u16 sprite_pattern_line = m_sprite_pattern_line[sprite_buffer_index]; + const uint16_t sprite_pattern_line = m_sprite_pattern_line[sprite_buffer_index]; const int zoom_scale = sprite_buffer_index < m_max_sprite_zoom_hcount ? m_sprite_zoom_scale : 1; - const u8 bit_plane_0 = space().read_byte((sprite_tile_selected << 5) + sprite_pattern_line + 0x00); - const u8 bit_plane_1 = space().read_byte((sprite_tile_selected << 5) + sprite_pattern_line + 0x01); - const u8 bit_plane_2 = space().read_byte((sprite_tile_selected << 5) + sprite_pattern_line + 0x02); - const u8 bit_plane_3 = space().read_byte((sprite_tile_selected << 5) + sprite_pattern_line + 0x03); + const uint8_t bit_plane_0 = space().read_byte((sprite_tile_selected << 5) + sprite_pattern_line + 0x00); + const uint8_t bit_plane_1 = space().read_byte((sprite_tile_selected << 5) + sprite_pattern_line + 0x01); + const uint8_t bit_plane_2 = space().read_byte((sprite_tile_selected << 5) + sprite_pattern_line + 0x02); + const uint8_t bit_plane_3 = space().read_byte((sprite_tile_selected << 5) + sprite_pattern_line + 0x03); for (int pixel_x = 0; pixel_x < 8; pixel_x++) { - const u8 pen_bit_0 = BIT(bit_plane_0, 7 - pixel_x); - const u8 pen_bit_1 = BIT(bit_plane_1, 7 - pixel_x); - const u8 pen_bit_2 = BIT(bit_plane_2, 7 - pixel_x); - const u8 pen_bit_3 = BIT(bit_plane_3, 7 - pixel_x); - const u8 pen_selected = (pen_bit_3 << 3 | pen_bit_2 << 2 | pen_bit_1 << 1 | pen_bit_0) | 0x10; + const uint8_t pen_bit_0 = BIT(bit_plane_0, 7 - pixel_x); + const uint8_t pen_bit_1 = BIT(bit_plane_1, 7 - pixel_x); + const uint8_t pen_bit_2 = BIT(bit_plane_2, 7 - pixel_x); + const uint8_t pen_bit_3 = BIT(bit_plane_3, 7 - pixel_x); + const uint8_t pen_selected = (pen_bit_3 << 3 | pen_bit_2 << 2 | pen_bit_1 << 1 | pen_bit_0) | 0x10; if (pen_selected == 0x10) // Transparent palette so skip draw continue; @@ -1355,15 +1352,15 @@ void sega315_5124_device::draw_sprites_tms9918_mode(int *line_buffer, int line) bool sprite_col_occurred = false; int sprite_col_x = 255; - u8 collision_buffer[256] = { 0 }; + uint8_t collision_buffer[256] = { 0 }; /* Draw sprite layer */ for (int sprite_buffer_index = m_sprite_count - 1; sprite_buffer_index >= 0; sprite_buffer_index--) { int sprite_x = m_sprite_x[sprite_buffer_index]; int sprite_tile_selected = m_sprite_tile_selected[sprite_buffer_index]; - const u16 sprite_pattern_line = m_sprite_pattern_line[sprite_buffer_index]; - const u8 flags = m_sprite_flags[sprite_buffer_index]; + const uint16_t sprite_pattern_line = m_sprite_pattern_line[sprite_buffer_index]; + const uint8_t flags = m_sprite_flags[sprite_buffer_index]; const int pen_selected = m_palette_offset + (flags & 0x0f); const int zoom_scale = sprite_buffer_index < m_max_sprite_zoom_hcount ? m_sprite_zoom_scale : 1; @@ -1378,7 +1375,7 @@ void sega315_5124_device::draw_sprites_tms9918_mode(int *line_buffer, int line) sprite_x += (zoom_scale > 1 ? 16 : 8); } - u8 pattern = space().read_byte(sprite_pattern_line + sprite_tile_selected * 8); + uint8_t pattern = space().read_byte(sprite_pattern_line + sprite_tile_selected * 8); for (int pixel_x = 0; pixel_x < 8; pixel_x++) { @@ -1424,23 +1421,23 @@ void sega315_5124_device::draw_sprites_tms9918_mode(int *line_buffer, int line) // Display mode 2 (Graphics II Mode) void sega315_5124_device::draw_scanline_mode2(int *line_buffer, int line) { - const u16 name_table_base = ((m_reg[0x02] & 0x0f) << 10) + ((line >> 3) * 32); - const u16 color_base = ((m_reg[0x03] & 0x80) << 6); + const uint16_t name_table_base = ((m_reg[0x02] & 0x0f) << 10) + ((line >> 3) * 32); + const uint16_t color_base = ((m_reg[0x03] & 0x80) << 6); const int color_mask = ((m_reg[0x03] & 0x7f) << 3) | 0x07; - const u16 pattern_base = ((m_reg[0x04] & 0x04) << 11); + const uint16_t pattern_base = ((m_reg[0x04] & 0x04) << 11); const int pattern_mask = ((m_reg[0x04] & 0x03) << 8) | 0xff; const int pattern_offset = (line & 0xc0) << 2; /* Draw background layer */ for (int tile_column = 0; tile_column < 32; tile_column++) { - const u8 name = space().read_byte(name_table_base + tile_column); - const u8 pattern = space().read_byte(pattern_base + (((pattern_offset + name) & pattern_mask) * 8) + (line & 0x07) ); - const u8 colors = space().read_byte(color_base + (((pattern_offset + name) & color_mask) * 8) + (line & 0x07) ); + const uint8_t name = space().read_byte(name_table_base + tile_column); + const uint8_t pattern = space().read_byte(pattern_base + (((pattern_offset + name) & pattern_mask) * 8) + (line & 0x07) ); + const uint8_t colors = space().read_byte(color_base + (((pattern_offset + name) & color_mask) * 8) + (line & 0x07) ); for (int pixel_x = 0; pixel_x < 8; pixel_x++) { - u8 pen_selected; + uint8_t pen_selected; const int pixel_plot_x = (tile_column << 3) + pixel_x; if (BIT(pattern, 7 - pixel_x)) @@ -1465,16 +1462,16 @@ void sega315_5124_device::draw_scanline_mode2(int *line_buffer, int line) // Display mode 0 (Graphics I Mode) void sega315_5124_device::draw_scanline_mode0(int *line_buffer, int line) { - const u16 name_base = ((m_reg[0x02] & 0x0f) << 10) + ((line >> 3) * 32); - const u16 color_base = ((m_reg[0x03] << 6) & (VRAM_SIZE - 1)); - const u16 pattern_base = ((m_reg[0x04] << 11) & (VRAM_SIZE - 1)); + const uint16_t name_base = ((m_reg[0x02] & 0x0f) << 10) + ((line >> 3) * 32); + const uint16_t color_base = ((m_reg[0x03] << 6) & (VRAM_SIZE - 1)); + const uint16_t pattern_base = ((m_reg[0x04] << 11) & (VRAM_SIZE - 1)); /* Draw background layer */ for (int tile_column = 0; tile_column < 32; tile_column++) { - const u8 name = space().read_byte(name_base + tile_column); - const u8 pattern = space().read_byte(pattern_base + (name << 3) + (line & 0x07)); - const u8 colors = space().read_byte(color_base + (name >> 3)); + const uint8_t name = space().read_byte(name_base + tile_column); + const uint8_t pattern = space().read_byte(pattern_base + (name << 3) + (line & 0x07)); + const uint8_t colors = space().read_byte(color_base + (name >> 3)); for (int pixel_x = 0; pixel_x < 8; pixel_x++) { @@ -1499,8 +1496,8 @@ void sega315_5124_device::draw_scanline_mode0(int *line_buffer, int line) // Display mode 1 (Text Mode) void sega315_5124_device::draw_scanline_mode1(int *line_buffer, int line) { - const u16 name_base = ((m_reg[0x02] & 0x0f) << 10) + ((line >> 3) * 32); - const u16 pattern_base = ((m_reg[0x04] << 11) & (VRAM_SIZE - 1)); + const uint16_t name_base = ((m_reg[0x02] & 0x0f) << 10) + ((line >> 3) * 32); + const uint16_t pattern_base = ((m_reg[0x04] << 11) & (VRAM_SIZE - 1)); for (int pixel_plot_x = 0; pixel_plot_x < 8; pixel_plot_x++) { @@ -1510,8 +1507,8 @@ void sega315_5124_device::draw_scanline_mode1(int *line_buffer, int line) /* Draw background layer */ for (int tile_column = 0; tile_column < 40; tile_column++) { - const u8 name = space().read_byte(name_base + tile_column); - const u8 pattern = space().read_byte(pattern_base + (name << 3) + (line & 0x07)); + const uint8_t name = space().read_byte(name_base + tile_column); + const uint8_t pattern = space().read_byte(pattern_base + (name << 3) + (line & 0x07)); for (int pixel_x = 0; pixel_x < 6; pixel_x++) { @@ -1539,14 +1536,14 @@ void sega315_5124_device::draw_scanline_mode1(int *line_buffer, int line) // Display mode 3 (Multicolor Mode) void sega315_5124_device::draw_scanline_mode3(int *line_buffer, int line) { - const u16 name_base = ((m_reg[0x02] & 0x0f) << 10) + ((line >> 3) * 32); - const u16 pattern_base = ((m_reg[0x04] << 11) & (VRAM_SIZE - 1)); + const uint16_t name_base = ((m_reg[0x02] & 0x0f) << 10) + ((line >> 3) * 32); + const uint16_t pattern_base = ((m_reg[0x04] << 11) & (VRAM_SIZE - 1)); /* Draw background layer */ for (int tile_column = 0; tile_column < 32; tile_column++) { - const u8 name = space().read_byte(name_base + tile_column); - const u8 pattern = space().read_byte(pattern_base + (name << 3) + (((line >> 3) & 3) << 1) + ((line & 4) >> 2)); + const uint8_t name = space().read_byte(name_base + tile_column); + const uint8_t pattern = space().read_byte(pattern_base + (name << 3) + (((line >> 3) & 3) << 1) + ((line & 4) >> 2)); for (int pixel_x = 0; pixel_x < 8; pixel_x++) { @@ -1638,8 +1635,8 @@ void sega315_5124_device::draw_scanline(int pixel_offset_x, int pixel_plot_y, in void sega315_5124_device::blit_scanline(int *line_buffer, int *priority_selected, int pixel_offset_x, int pixel_plot_y, int line) { - u32 *p_bitmap = &m_tmpbitmap.pix32(pixel_plot_y + line, pixel_offset_x); - u8 *p_y1 = &m_y1_bitmap.pix8(pixel_plot_y + line, pixel_offset_x); + uint32_t *p_bitmap = &m_tmpbitmap.pix32(pixel_plot_y + line, pixel_offset_x); + uint8_t *p_y1 = &m_y1_bitmap.pix8(pixel_plot_y + line, pixel_offset_x); int x = 0; if (m_vdp_mode == 4 && BIT(m_reg[0x00], 5)) @@ -1670,8 +1667,8 @@ void sega315_5377_device::blit_scanline(int *line_buffer, int *priority_selected } else { - u32 *p_bitmap = &m_tmpbitmap.pix32(pixel_plot_y + line, pixel_offset_x); - u8 *p_y1 = &m_y1_bitmap.pix8(pixel_plot_y + line, pixel_offset_x); + uint32_t *p_bitmap = &m_tmpbitmap.pix32(pixel_plot_y + line, pixel_offset_x); + uint8_t *p_y1 = &m_y1_bitmap.pix8(pixel_plot_y + line, pixel_offset_x); int x = 0; /* border on left side of the GG active screen */ @@ -1759,9 +1756,9 @@ void sega315_5377_device::update_palette() } -void sega315_5124_device::cram_write(u8 data) +void sega315_5124_device::cram_write(uint8_t data) { - u16 address = m_addr & m_cram_mask; + uint16_t address = m_addr & m_cram_mask; if (data != m_CRAM[address]) { m_CRAM[address] = data; @@ -1770,7 +1767,7 @@ void sega315_5124_device::cram_write(u8 data) } -void sega315_5377_device::cram_write(u8 data) +void sega315_5377_device::cram_write(uint8_t data) { if (m_sega315_5124_compatibility_mode) { @@ -1780,7 +1777,7 @@ void sega315_5377_device::cram_write(u8 data) { if (m_addr & 1) { - u16 address = (m_addr & m_cram_mask) & ~1; + uint16_t address = (m_addr & m_cram_mask) & ~1; if (m_buffer != m_CRAM[address] || data != m_CRAM[address + 1]) { m_CRAM[address] = m_buffer; @@ -1792,7 +1789,7 @@ void sega315_5377_device::cram_write(u8 data) } -u32 sega315_5124_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) +uint32_t sega315_5124_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { copybitmap(bitmap, m_tmpbitmap, 0, 0, 0, 0, cliprect); return 0; @@ -1822,7 +1819,7 @@ void sega315_5313_mode4_device::stop_timers() DEVICE INTERFACE *****************************************************************************/ -void sega315_5124_device::device_post_load() +void sega315_5124_device::vdp_postload() { set_frame_timing(); } @@ -1889,6 +1886,8 @@ void sega315_5124_device::device_start() save_item(NAME(m_max_sprite_zoom_hcount)); save_item(NAME(m_max_sprite_zoom_vcount)); save_item(NAME(m_CRAM)); + + machine().save().register_postload(save_prepost_delegate(FUNC(sega315_5124_device::vdp_postload), this)); } @@ -1900,7 +1899,7 @@ void sega315_5124_device::device_reset() m_reg[0x02] = 0x0e; m_reg[0x0a] = 0xff; - m_status = m_pending_status = u8(~(STATUS_VINT | STATUS_SPROVR | STATUS_SPRCOL)); + m_status = m_pending_status = uint8_t(~(STATUS_VINT | STATUS_SPROVR | STATUS_SPRCOL)); m_pending_sprcol_x = 0; m_pending_control_write = false; m_pending_hint = false; @@ -1935,8 +1934,6 @@ void sega315_5124_device::device_reset() void sega315_5124_device::device_add_mconfig(machine_config &config) { PALETTE(config, m_palette, FUNC(sega315_5124_device::sega315_5124_palette), SEGA315_5124_PALETTE_SIZE); - - SEGAPSG(config, m_snsnd, DERIVED_CLOCK(1, 3)).add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 0); } void sega315_5377_device::device_reset() @@ -1952,11 +1949,6 @@ void sega315_5377_device::device_reset() void sega315_5377_device::device_add_mconfig(machine_config &config) { sega315_5246_device::device_add_mconfig(config); - m_palette->set_entries(SEGA315_5377_PALETTE_SIZE); m_palette->set_init(FUNC(sega315_5377_device::sega315_5377_palette)); - - GAMEGEAR(config.replace(), m_snsnd, DERIVED_CLOCK(1, 3)); - m_snsnd->add_route(0, *this, 1.0, AUTO_ALLOC_INPUT, 0); - m_snsnd->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1); } diff --git a/src/devices/video/315_5124.h b/src/devices/video/315_5124.h index b88cf5c38d7..3ff7b5165a1 100644 --- a/src/devices/video/315_5124.h +++ b/src/devices/video/315_5124.h @@ -13,7 +13,6 @@ #pragma once -#include "sound/sn76496.h" #include "emupal.h" #include "screen.h" @@ -29,8 +28,7 @@ DECLARE_DEVICE_TYPE(SEGA315_5377, sega315_5377_device) /* aka Gamegear (2 A class sega315_5124_device : public device_t, public device_memory_interface, - public device_video_interface, - public device_mixer_interface + public device_video_interface { public: static constexpr unsigned WIDTH = 342; /* 342 pixels */ @@ -53,22 +51,23 @@ public: // construction/destruction - sega315_5124_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + sega315_5124_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); void set_is_pal(bool is_pal) { m_is_pal = is_pal; } + template <class Object> devcb_base &set_int_callback(Object &&cb) { return m_int_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_csync_callback(Object &&cb) { return m_csync_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_pause_callback(Object &&cb) { return m_pause_cb.set_callback(std::forward<Object>(cb)); } auto irq() { return m_int_cb.bind(); } auto csync() { return m_csync_cb.bind(); } auto pause() { return m_pause_cb.bind(); } - void psg_w(u8 data) { m_snsnd->write(data); } - void psg_stereo_w(u8 data) { m_snsnd->stereo_w(data); } - u8 data_read(); - void data_write(u8 data); - u8 control_read(); - void control_write(u8 data); - u8 vcount_read(); - u8 hcount_read(); + DECLARE_READ8_MEMBER( data_read ); + DECLARE_WRITE8_MEMBER( data_write ); + DECLARE_READ8_MEMBER( control_read ); + DECLARE_WRITE8_MEMBER( control_write ); + DECLARE_READ8_MEMBER( vcount_read ); + DECLARE_READ8_MEMBER( hcount_read ); void hcount_latch() { hcount_latch_at_hpos(screen().hpos()); }; void hcount_latch_at_hpos(int hpos); @@ -77,7 +76,7 @@ public: bitmap_ind8 &get_y1_bitmap() { return m_y1_bitmap; }; /* update the screen */ - u32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); + uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); virtual void set_sega315_5124_compatibility_mode(bool sega315_5124_compatibility_mode) { } @@ -85,10 +84,9 @@ protected: static constexpr unsigned SEGA315_5377_CRAM_SIZE = 0x40; /* 32 colors x 2 bytes per color = 64 bytes */ static constexpr unsigned SEGA315_5124_CRAM_SIZE = 0x20; /* 32 colors x 1 bytes per color = 32 bytes */ - sega315_5124_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 cram_size, u8 palette_offset, u8 reg_num_mask, int max_sprite_zoom_hcount, int max_sprite_zoom_vcount, const u8 *line_timing); + sega315_5124_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint8_t cram_size, uint8_t palette_offset, uint8_t reg_num_mask, int max_sprite_zoom_hcount, int max_sprite_zoom_vcount, const uint8_t *line_timing); // device-level overrides - virtual void device_post_load() override; virtual void device_start() override; virtual void device_reset() override; virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; @@ -103,9 +101,9 @@ protected: void set_display_settings(); void set_frame_timing(); virtual void update_palette(); - virtual void write_memory(u8 data); - virtual void cram_write(u8 data); - virtual void load_vram_addr(u8 data); + virtual void write_memory(uint8_t data); + virtual void cram_write(uint8_t data); + virtual void load_vram_addr(uint8_t data); virtual void select_display_mode(); virtual void select_extended_res_mode4(bool M1, bool M2, bool M3); virtual void select_sprites(int line); @@ -114,9 +112,9 @@ protected: virtual void draw_scanline(int pixel_offset_x, int pixel_plot_y, int line); virtual void blit_scanline(int *line_buffer, int *priority_selected, int pixel_offset_x, int pixel_plot_y, int line); virtual void draw_leftmost_pixels_mode4(int *line_buffer, int *priority_selected, int fine_x_scroll, int palette_selected, int tile_line); - virtual u16 name_table_row_mode4(int row); - virtual u16 sprite_attributes_addr_mode4(u16 base); - virtual u8 sprite_tile_mask_mode4(u8 tile_number); + virtual uint16_t name_table_row_mode4(int row); + virtual uint16_t sprite_attributes_addr_mode4(uint16_t base); + virtual uint8_t sprite_tile_mask_mode4(uint8_t tile_number); void process_line_timer(); void draw_scanline_mode4(int *line_buffer, int *priority_selected, int line); void draw_sprites_mode4(int *line_buffer, int *priority_selected, int line); @@ -127,42 +125,44 @@ protected: void draw_scanline_mode0(int *line_buffer, int line); void check_pending_flags(); - u8 m_reg[16]; /* All the registers */ - u8 m_status; /* Status register */ - u8 m_pending_status; /* Pending status flags */ - u8 m_reg8copy; /* Internal copy of register 8 (X-Scroll) */ - u8 m_reg9copy; /* Internal copy of register 9 (Y-Scroll) */ - u8 m_addrmode; /* Type of VDP action */ - u16 m_addr; /* Contents of internal VDP address register */ - const u8 m_cram_size; /* CRAM size */ - u8 m_cram_mask; /* Mask to switch between SMS and GG CRAM sizes */ + void vdp_postload(); + + uint8_t m_reg[16]; /* All the registers */ + uint8_t m_status; /* Status register */ + uint8_t m_pending_status; /* Pending status flags */ + uint8_t m_reg8copy; /* Internal copy of register 8 (X-Scroll) */ + uint8_t m_reg9copy; /* Internal copy of register 9 (Y-Scroll) */ + uint8_t m_addrmode; /* Type of VDP action */ + uint16_t m_addr; /* Contents of internal VDP address register */ + const uint8_t m_cram_size; /* CRAM size */ + uint8_t m_cram_mask; /* Mask to switch between SMS and GG CRAM sizes */ bool m_cram_dirty; /* Have there been any changes to the CRAM area */ bool m_hint_occurred; bool m_pending_hint; bool m_pending_control_write; int m_pending_sprcol_x; - u8 m_buffer; - u8 m_control_write_data_latch; + uint8_t m_buffer; + uint8_t m_control_write_data_latch; bool m_sega315_5124_compatibility_mode; /* when true, GG VDP behaves as SMS VDP */ int m_irq_state; /* The status of the IRQ line of the VDP */ int m_vdp_mode; /* Current mode of the VDP: 0,1,2,3,4 */ int m_y_pixels; /* 192, 224, 240 */ int m_draw_time; - u8 m_line_counter; - u8 m_hcounter; - u8 m_CRAM[SEGA315_5377_CRAM_SIZE]; /* CRAM */ - const u8 *m_frame_timing; - const u8 *m_line_timing; + uint8_t m_line_counter; + uint8_t m_hcounter; + uint8_t m_CRAM[SEGA315_5377_CRAM_SIZE]; /* CRAM */ + const uint8_t *m_frame_timing; + const uint8_t *m_line_timing; bitmap_rgb32 m_tmpbitmap; bitmap_ind8 m_y1_bitmap; - const u8 m_palette_offset; - const u8 m_reg_num_mask; + const uint8_t m_palette_offset; + const uint8_t m_reg_num_mask; bool m_display_disabled; - u16 m_sprite_base; - u16 m_sprite_pattern_line[8]; + uint16_t m_sprite_base; + uint16_t m_sprite_pattern_line[8]; int m_sprite_tile_selected[8]; int m_sprite_x[8]; - u8 m_sprite_flags[8]; + uint8_t m_sprite_flags[8]; int m_sprite_count; int m_sprite_height; int m_sprite_zoom_scale; @@ -195,21 +195,20 @@ protected: static constexpr device_timer_id TIMER_FLAGS = 7; required_device<palette_device> m_palette; - required_device<sn76496_base_device> m_snsnd; }; class sega315_5246_device : public sega315_5124_device { public: - sega315_5246_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + sega315_5246_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); protected: - sega315_5246_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 cram_size, u8 palette_offset, u8 reg_num_mask, int max_sprite_zoom_hcount, int max_sprite_zoom_vcount, const u8 *line_timing); + sega315_5246_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint8_t cram_size, uint8_t palette_offset, uint8_t reg_num_mask, int max_sprite_zoom_hcount, int max_sprite_zoom_vcount, const uint8_t *line_timing); - virtual u16 name_table_row_mode4(int row) override; - virtual u16 sprite_attributes_addr_mode4(u16 base) override; - virtual u8 sprite_tile_mask_mode4(u8 tile_number) override; + virtual uint16_t name_table_row_mode4(int row) override; + virtual uint16_t sprite_attributes_addr_mode4(uint16_t base) override; + virtual uint8_t sprite_tile_mask_mode4(uint8_t tile_number) override; virtual void select_extended_res_mode4(bool M1, bool M2, bool M3) override; }; @@ -217,18 +216,18 @@ protected: class sega315_5377_device : public sega315_5246_device { public: - sega315_5377_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + sega315_5377_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); virtual void set_sega315_5124_compatibility_mode(bool sega315_5124_compatibility_mode) override; protected: - sega315_5377_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 cram_size, u8 palette_offset, u8 reg_num_mask, int max_sprite_zoom_hcount, int max_sprite_zoom_vcount, const u8 *line_timing); + sega315_5377_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint8_t cram_size, uint8_t palette_offset, uint8_t reg_num_mask, int max_sprite_zoom_hcount, int max_sprite_zoom_vcount, const uint8_t *line_timing); virtual void device_reset() override; virtual void device_add_mconfig(machine_config &config) override; virtual void update_palette() override; - virtual void cram_write(u8 data) override; + virtual void cram_write(uint8_t data) override; virtual void blit_scanline(int *line_buffer, int *priority_selected, int pixel_offset_x, int pixel_plot_y, int line) override; private: @@ -243,10 +242,10 @@ public: void stop_timers(); protected: - sega315_5313_mode4_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 cram_size, u8 palette_offset, u8 reg_num_mask, int max_sprite_zoom_hcount, int max_sprite_zoom_vcount, const u8 *line_timing); + sega315_5313_mode4_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint8_t cram_size, uint8_t palette_offset, uint8_t reg_num_mask, int max_sprite_zoom_hcount, int max_sprite_zoom_vcount, const uint8_t *line_timing); - virtual void write_memory(u8 data) override; - virtual void load_vram_addr(u8 data) override; + virtual void write_memory(uint8_t data) override; + virtual void load_vram_addr(uint8_t data) override; virtual void select_sprites(int line) override; virtual void sprite_collision(int line, int sprite_col_x) override; virtual void sprite_count_overflow(int line, int sprite_index) override; @@ -255,4 +254,54 @@ protected: virtual void draw_leftmost_pixels_mode4(int *line_buffer, int *priority_selected, int fine_x_scroll, int palette_selected, int tile_line) override; }; + +/*************************************************************************** + DEVICE CONFIGURATION MACROS +***************************************************************************/ + +#define MCFG_SEGA315_5124_SET_SCREEN MCFG_VIDEO_SET_SCREEN + +#define MCFG_SEGA315_5124_IS_PAL(_bool) \ + downcast<sega315_5124_device &>(*device).set_is_pal(_bool); + +#define MCFG_SEGA315_5124_INT_CB(_devcb) \ + downcast<sega315_5124_device &>(*device).set_int_callback(DEVCB_##_devcb); + +#define MCFG_SEGA315_5124_CSYNC_CB(_devcb) \ + downcast<sega315_5124_device &>(*device).set_csync_callback(DEVCB_##_devcb); + +#define MCFG_SEGA315_5124_PAUSE_CB(_devcb) \ + downcast<sega315_5124_device &>(*device).set_pause_callback(DEVCB_##_devcb); + + +#define MCFG_SEGA315_5246_SET_SCREEN MCFG_VIDEO_SET_SCREEN + +#define MCFG_SEGA315_5246_IS_PAL(_bool) \ + downcast<sega315_5246_device &>(*device).set_is_pal(_bool); + +#define MCFG_SEGA315_5246_INT_CB(_devcb) \ + downcast<sega315_5246_device &>(*device).set_int_callback(DEVCB_##_devcb); + +#define MCFG_SEGA315_5246_CSYNC_CB(_devcb) \ + downcast<sega315_5246_device &>(*device).set_csync_callback(DEVCB_##_devcb); + +#define MCFG_SEGA315_5246_PAUSE_CB(_devcb) \ + downcast<sega315_5246_device &>(*device).set_pause_callback(DEVCB_##_devcb); + + +#define MCFG_SEGA315_5377_SET_SCREEN MCFG_VIDEO_SET_SCREEN + +#define MCFG_SEGA315_5377_IS_PAL(_bool) \ + downcast<sega315_5377_device &>(*device).set_is_pal(_bool); + +#define MCFG_SEGA315_5377_INT_CB(_devcb) \ + downcast<sega315_5377_device &>(*device).set_int_callback(DEVCB_##_devcb); + +#define MCFG_SEGA315_5377_CSYNC_CB(_devcb) \ + downcast<sega315_5377_device &>(*device).set_csync_callback(DEVCB_##_devcb); + +#define MCFG_SEGA315_5377_PAUSE_CB(_devcb) \ + downcast<sega315_5377_device &>(*device).set_pause_callback(DEVCB_##_devcb); + + #endif // MAME_VIDEO_315_5124_H diff --git a/src/devices/video/315_5313.cpp b/src/devices/video/315_5313.cpp index b56f1349f59..921c7011a29 100644 --- a/src/devices/video/315_5313.cpp +++ b/src/devices/video/315_5313.cpp @@ -161,6 +161,7 @@ DEFINE_DEVICE_TYPE(SEGA315_5313, sega315_5313_device, "sega315_5313", "Sega 315- sega315_5313_device::sega315_5313_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) // mode 4 support, for SMS compatibility, is implemented in 315_5124.cpp : sega315_5313_mode4_device(mconfig, SEGA315_5313, tag, owner, clock, SEGA315_5124_CRAM_SIZE, 0x00, 0x1f, 0, 0, line_315_5313_mode4) + , device_mixer_interface(mconfig, *this, 2) , m_render_bitmap(nullptr) , m_render_line(nullptr) , m_render_line_raw(nullptr) @@ -209,6 +210,7 @@ sega315_5313_device::sega315_5313_device(const machine_config &mconfig, const ch , m_palette_lookup_highlight(nullptr) , m_space68k(nullptr) , m_cpu68k(*this, finder_base::DUMMY_TAG) + , m_snsnd(*this, "snsnd") { m_use_alt_timing = 0; m_palwrite_base = -1; @@ -225,7 +227,7 @@ void sega315_5313_device::device_add_mconfig(machine_config &config) m_palette->set_entries(0x200); // more entries for 32X - not really the cleanest way to do this - SEGAPSG(config.replace(), m_snsnd, DERIVED_CLOCK(1, 15)).add_route(ALL_OUTPUTS, *this, 0.5, AUTO_ALLOC_INPUT, 0); + SEGAPSG(config, m_snsnd, DERIVED_CLOCK(1, 15)).add_route(ALL_OUTPUTS, *this, 0.5, AUTO_ALLOC_INPUT, 0); } TIMER_CALLBACK_MEMBER(sega315_5313_device::irq6_on_timer_callback) @@ -966,9 +968,9 @@ WRITE16_MEMBER( sega315_5313_device::vdp_w ) case 0x16: { // accessed by either segapsg_device or sn76496_device - if (ACCESSING_BITS_0_7) - psg_w(data & 0xff); - //if (ACCESSING_BITS_8_15) psg_w((data>>8) & 0xff); + if (m_snsnd && ACCESSING_BITS_0_7) + m_snsnd->write(data & 0xff); + //if (m_snsnd && ACCESSING_BITS_8_15) sn->write((data>>8) & 0xff); break; } diff --git a/src/devices/video/315_5313.h b/src/devices/video/315_5313.h index 28d1d995d97..f2aae550f8b 100644 --- a/src/devices/video/315_5313.h +++ b/src/devices/video/315_5313.h @@ -9,9 +9,49 @@ #include "video/315_5124.h" #include "cpu/m68000/m68000.h" #include "machine/timer.h" +#include "sound/sn76496.h" -class sega315_5313_device : public sega315_5313_mode4_device +#define MCFG_SEGA315_5313_IS_PAL(_bool) \ + downcast<sega315_5313_device &>(*device).set_is_pal(_bool); + +#define MCFG_SEGA315_5313_INT_CB(_devcb) \ + downcast<sega315_5313_device &>(*device).set_int_callback(DEVCB_##_devcb); + +#define MCFG_SEGA315_5313_PAUSE_CB(_devcb) \ + downcast<sega315_5313_device &>(*device).set_pause_callback(DEVCB_##_devcb); + +#define MCFG_SEGA315_5313_SND_IRQ_CALLBACK(_write) \ + downcast<sega315_5313_device &>(*device).set_sndirqline_callback(DEVCB_##_write); + +#define MCFG_SEGA315_5313_LV6_IRQ_CALLBACK(_write) \ + downcast<sega315_5313_device &>(*device).set_lv6irqline_callback(DEVCB_##_write); + +#define MCFG_SEGA315_5313_LV4_IRQ_CALLBACK(_write) \ + downcast<sega315_5313_device &>(*device).set_lv4irqline_callback(DEVCB_##_write); + +#define MCFG_SEGA315_5313_ALT_TIMING(_data) \ + downcast<sega315_5313_device &>(*device).set_alt_timing(_data); + +#define MCFG_SEGA315_5313_PAL_WRITE_BASE(_data) \ + downcast<sega315_5313_device &>(*device).set_pal_write_base(_data); + +#define MCFG_SEGA315_5313_PALETTE(_palette_tag) \ + downcast<sega315_5313_device &>(*device).set_palette(_palette_tag); + + +// Temporary solution while 32x VDP mixing and scanline interrupting is moved outside MD VDP +#define MCFG_SEGA315_5313_32X_SCANLINE_CB(_class, _method) \ + downcast<sega315_5313_device &>(*device).set_md_32x_scanline(sega315_5313_device::md_32x_scanline_delegate(&_class::_method, #_class "::" #_method, this)); + +#define MCFG_SEGA315_5313_32X_INTERRUPT_CB(_class, _method) \ + downcast<sega315_5313_device &>(*device).set_md_32x_interrupt(sega315_5313_device::md_32x_interrupt_delegate(&_class::_method, #_class "::" #_method, this)); + +#define MCFG_SEGA315_5313_32X_SCANLINE_HELPER_CB(_class, _method) \ + downcast<sega315_5313_device &>(*device).set_md_32x_scanline_helper(sega315_5313_device::md_32x_scanline_helper_delegate(&_class::_method, #_class "::" #_method, this)); + + +class sega315_5313_device : public sega315_5313_mode4_device, public device_mixer_interface { public: template <typename T> @@ -27,6 +67,9 @@ public: typedef device_delegate<void (int scanline, int irq6)> md_32x_interrupt_delegate; typedef device_delegate<void (int scanline)> md_32x_scanline_helper_delegate; + template <class Object> devcb_base &set_sndirqline_callback(Object &&cb) { return m_sndirqline_callback.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_lv6irqline_callback(Object &&cb) { return m_lv6irqline_callback.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_lv4irqline_callback(Object &&cb) { return m_lv4irqline_callback.set_callback(std::forward<Object>(cb)); } auto snd_irq() { return m_sndirqline_callback.bind(); } auto lv6_irq() { return m_lv6irqline_callback.bind(); } auto lv4_irq() { return m_lv4irqline_callback.bind(); } @@ -35,10 +78,9 @@ public: void set_pal_write_base(int palwrite_base) { m_palwrite_base = palwrite_base; } template <typename T> void set_palette(T &&tag) { m_palette.set_tag(std::forward<T>(tag)); } - // Temporary solution while 32x VDP mixing and scanline interrupting is moved outside MD VDP - template <typename... T> void set_md_32x_scanline(T &&... args) { m_32x_scanline_func = md_32x_scanline_delegate(std::forward<T>(args)...); } - template <typename... T> void set_md_32x_interrupt(T &&... args) { m_32x_interrupt_func = md_32x_interrupt_delegate(std::forward<T>(args)...); } - template <typename... T> void set_md_32x_scanline_helper(T &&... args) { m_32x_scanline_helper_func = md_32x_scanline_helper_delegate(std::forward<T>(args)...); } + template <typename Object> void set_md_32x_scanline(Object &&cb) { m_32x_scanline_func = std::forward<Object>(cb); } + template <typename Object> void set_md_32x_interrupt(Object &&cb) { m_32x_interrupt_func = std::forward<Object>(cb); } + template <typename Object> void set_md_32x_scanline_helper(Object &&cb) { m_32x_scanline_helper_func = std::forward<Object>(cb); } int m_use_alt_timing; // use MAME scanline timer instead, render only one scanline to a single line buffer, to be rendered by a partial update call.. experimental @@ -186,6 +228,7 @@ private: address_space *m_space68k; required_device<m68000_base_device> m_cpu68k; + required_device<sn76496_base_device> m_snsnd; }; diff --git a/src/devices/video/cdp1862.cpp b/src/devices/video/cdp1862.cpp index ba4375c54de..78985db211c 100644 --- a/src/devices/video/cdp1862.cpp +++ b/src/devices/video/cdp1862.cpp @@ -126,7 +126,7 @@ void cdp1862_device::device_reset() // dma_w - //------------------------------------------------- -void cdp1862_device::dma_w(uint8_t data) +WRITE8_MEMBER( cdp1862_device::dma_w ) { int rd = 1, bd = 1, gd = 1; int sx = screen().hpos() + 4; diff --git a/src/devices/video/cdp1862.h b/src/devices/video/cdp1862.h index 8ab9716642b..0ee90fa3bd6 100644 --- a/src/devices/video/cdp1862.h +++ b/src/devices/video/cdp1862.h @@ -49,7 +49,7 @@ public: void set_luminance(double r, double b, double g, double bkg) { m_lum_r = r; m_lum_b = b; m_lum_g = g; m_lum_bkg = bkg; } void set_chrominance(double r, double b, double g, double bkg) { m_chr_r = r; m_chr_b = b; m_chr_g = g; m_chr_bkg = bkg; } - void dma_w(uint8_t data); + DECLARE_WRITE8_MEMBER( dma_w ); DECLARE_WRITE_LINE_MEMBER( bkg_w ); DECLARE_WRITE_LINE_MEMBER( con_w ); diff --git a/src/devices/video/cesblit.h b/src/devices/video/cesblit.h index d535921ef6b..f22f16df260 100644 --- a/src/devices/video/cesblit.h +++ b/src/devices/video/cesblit.h @@ -11,6 +11,21 @@ #pragma once +/*************************************************************************** + INTERFACE CONFIGURATION MACROS +***************************************************************************/ + +#define MCFG_CESBLIT_ADD(_tag, _screen, _clock) \ + MCFG_DEVICE_ADD(_tag, CESBLIT, _clock) \ + MCFG_VIDEO_SET_SCREEN(_screen) + +#define MCFG_CESBLIT_MAP MCFG_DEVICE_PROGRAM_MAP + +#define MCFG_CESBLIT_COMPUTE_ADDR(_compute_addr) \ + downcast<cesblit_device &>(*device).set_compute_addr(_compute_addr); + +#define MCFG_CESBLIT_IRQ_CB(_devcb) \ + downcast<cesblit_device &>(*device).set_irq_callback(DEVCB_##_devcb); /*************************************************************************** TYPE DEFINITIONS @@ -26,18 +41,11 @@ public: typedef int (*compute_addr_t) (uint16_t reg_low, uint16_t reg_mid, uint16_t reg_high); // construction/destruction - template <typename T> - cesblit_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&screen_tag) - : cesblit_device(mconfig, tag, owner, clock) - { - set_screen(std::forward<T>(screen_tag)); - } - cesblit_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); // configuration void set_compute_addr(compute_addr_t compute_addr) { m_compute_addr = compute_addr; } - auto irq_callback() { return m_blit_irq_cb.bind(); } + template <class Object> devcb_base &set_irq_callback(Object &&cb) { return m_blit_irq_cb.set_callback(std::forward<Object>(cb)); } DECLARE_WRITE16_MEMBER(color_w); DECLARE_WRITE16_MEMBER(addr_hi_w); diff --git a/src/devices/video/crt9007.cpp b/src/devices/video/crt9007.cpp index ff3893a4ca6..40279d1316a 100644 --- a/src/devices/video/crt9007.cpp +++ b/src/devices/video/crt9007.cpp @@ -222,8 +222,7 @@ const int STATUS_LIGHT_PEN_UPDATE = 0x20; // default address map void crt9007_device::crt9007(address_map &map) { - if (!has_configured_map(0)) - map(0x0000, 0x3fff).ram(); + map(0x0000, 0x3fff).ram(); } @@ -457,7 +456,7 @@ crt9007_device::crt9007_device(const machine_config &mconfig, const char *tag, d device_t(mconfig, CRT9007, tag, owner, clock), device_memory_interface(mconfig, *this), device_video_interface(mconfig, *this), - m_space_config("videoram", ENDIANNESS_LITTLE, 8, 14, 0, address_map_constructor(FUNC(crt9007_device::crt9007), this)), + m_space_config("videoram", ENDIANNESS_LITTLE, 8, 14, 0, address_map_constructor(), address_map_constructor(FUNC(crt9007_device::crt9007), this)), m_write_int(*this), m_write_dmar(*this), m_write_hs(*this), diff --git a/src/devices/video/crt9021.h b/src/devices/video/crt9021.h index 65de1032a64..2a7e513fdf2 100644 --- a/src/devices/video/crt9021.h +++ b/src/devices/video/crt9021.h @@ -38,6 +38,10 @@ #define CRT9021_DRAW_CHARACTER_MEMBER(_name) void _name(bitmap_rgb32 &bitmap, int y, int x, uint8_t video, int intout) +#define MCFG_CRT9021_DRAW_CHARACTER_CALLBACK_OWNER(_class, _method) \ + downcast<crt9021_device &>(*device).set_display_callback(crt9021_device::draw_character_delegate(&_class::_method, #_class "::" #_method, this)); + + //************************************************************************** // TYPE DEFINITIONS //************************************************************************** @@ -53,7 +57,7 @@ public: // construction/destruction crt9021_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - template <typename... T> void set_display_callback(T &&... args) { m_display_cb = draw_character_delegate(std::forward<T>(args)...); } + template <typename Object> void set_display_callback(Object &&cb) { m_display_cb = std::forward<Object>(cb); } void write(uint8_t data) { m_data = data; } DECLARE_WRITE8_MEMBER( write ) { write(data); } diff --git a/src/devices/video/crt9028.cpp b/src/devices/video/crt9028.cpp deleted file mode 100644 index 31c0c748420..00000000000 --- a/src/devices/video/crt9028.cpp +++ /dev/null @@ -1,371 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:AJR -/********************************************************************** - - Standard Microsystems CRT9028/9128 Video Terminal Logic Controller - - The CRT 9028 and CRT 9128 are single-chip terminal-oriented video - processors. The two differ from each other in their bus protocol - for accessing the address, data and status registers: the 9028 has - separate RD and WR strobes for an 8051 or similar microcontroller, - while the 9128 replaces these with DS and R/W inputs that are more - Z8-oriented. A separate address/data bus connects to a 2Kx8 static - RAM or similar as display memory. - - The internal 128-character set is mask-programmed, as are all - screen timings, with alternate vertical timings to allow operation - at either 60 Hz or 50 Hz. Mask parameters also determine the - polarity of the sync signals, the positioning of the underline - attribute and cursor and the dot patterns used for 6-segment wide - (block) graphics and 4-segment thin (line) graphics. - - TODO: implement timing and display functions - -**********************************************************************/ - -#include "emu.h" -#include "video/crt9028.h" -#include "screen.h" - -//************************************************************************** -// GLOBAL VARIABLES -//************************************************************************** - -// device type definition -DEFINE_DEVICE_TYPE(CRT9028_000, crt9028_000_device, "crt9028_000", "CRT9028-000 VTLC") - -//************************************************************************** -// DEVICE IMPLEMENTATION -//************************************************************************** - -//------------------------------------------------- -// crt9028_device - constructor -//------------------------------------------------- - -crt9028_device::crt9028_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, - int dots_per_char, int chars_per_row, int horiz_blanking, int hsync_delay, int hsync_width, bool hsync_active, - int char_rows, int scans_per_char, bool vsync_active, - int vert_blanking, int vsync_delay, bool vsync_width, - int alt_vert_blanking, int alt_vsync_delay, bool alt_vsync_width, - int csync_delay, int csync_width, int underline, - u16 wide_gfx_seg1_4, u16 wide_gfx_seg2_5, u16 wide_gfx_seg3_6, u8 wide_gfx_pattern, - u16 thin_gfx_seg1, u16 thin_gfx_seg2, u16 thin_gfx_seg3, u16 thin_gfx_seg4, - u8 thin_gfx_dots1, u8 thin_gfx_dots2, u8 thin_gfx_dots3, u8 thin_gfx_dots4) - : device_t(mconfig, type, tag, owner, clock) - , device_memory_interface(mconfig, *this) - , device_video_interface(mconfig, *this) - , m_space_config("charram", ENDIANNESS_LITTLE, 8, 11, 0) - , m_charset(*this, "charset") - , m_hsync_callback(*this) - , m_vsync_callback(*this) - , m_dots_per_char(dots_per_char) - , m_chars_per_row(chars_per_row) - , m_horiz_blanking(horiz_blanking) - , m_hsync_delay(hsync_delay) - , m_hsync_width(hsync_width) - , m_hsync_active(hsync_active) - , m_char_rows(char_rows) - , m_scans_per_char(scans_per_char) - , m_vsync_active(vsync_active) - , m_vert_blanking{vert_blanking, alt_vert_blanking} - , m_vsync_delay{vsync_delay, alt_vsync_delay} - , m_vsync_width{vsync_width, alt_vsync_width} - , m_csync_delay(csync_delay) - , m_csync_width(csync_width) - , m_underline(underline) - , m_wide_gfx_seg{wide_gfx_seg1_4, wide_gfx_seg2_5, wide_gfx_seg3_6} - , m_wide_gfx_pattern(wide_gfx_pattern) - , m_thin_gfx_seg{thin_gfx_seg1, thin_gfx_seg2, thin_gfx_seg3, thin_gfx_seg4} - , m_thin_gfx_dots{thin_gfx_dots1, thin_gfx_dots2, thin_gfx_dots3, thin_gfx_dots4} - , m_address_register(0) -{ - // Mostly unused now - (void)m_hsync_delay; - (void)m_hsync_width; - (void)m_hsync_active; - (void)m_vsync_active; - (void)m_vsync_delay; - (void)m_vsync_width; - (void)m_csync_delay; - (void)m_csync_width; - (void)m_underline; - (void)m_wide_gfx_seg; - (void)m_wide_gfx_pattern; - (void)m_thin_gfx_seg; - (void)m_thin_gfx_dots; -} - - -//------------------------------------------------- -// crt9028_000_device - constructor -//------------------------------------------------- - -crt9028_000_device::crt9028_000_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) - : crt9028_device(mconfig, CRT9028_000, tag, owner, clock, - 7, 80, 20, 4, 8, false, - 24, 10, false, - 20, 4, 8, - 72, 30, 10, - 2, 8, 9, - 0x3c0, 0x038, 0x007, 0x0f, - 0x3e0, 0x020, 0x03f, 0x020, - 0x10, 0xff, 0x10, 0xff) -{ -} - - -//------------------------------------------------- -// device_config_complete - finalise device -// configuration -//------------------------------------------------- - -void crt9028_device::device_config_complete() -{ - if (!has_screen()) - return; - - if (screen().refresh_attoseconds() == 0) - { - int visible_scan_lines = m_char_rows * m_scans_per_char; - screen().set_raw(clock(), m_dots_per_char * (m_chars_per_row + m_horiz_blanking), 0, m_dots_per_char * m_chars_per_row, - visible_scan_lines + m_vert_blanking[0], 0, visible_scan_lines); - } - - if (!screen().has_screen_update()) - screen().set_screen_update(screen_update_rgb32_delegate(FUNC(crt9028_device::screen_update), this)); -} - - -//------------------------------------------------- -// memory_space_config - return the configuration -// for the address spaces -//------------------------------------------------- - -device_memory_interface::space_config_vector crt9028_device::memory_space_config() const -{ - return space_config_vector{std::make_pair(0, &m_space_config)}; -} - - -//------------------------------------------------- -// device_resolve_objects - resolve objects that -// may be needed for other devices to set -// initial conditions at start time -//------------------------------------------------- - -void crt9028_device::device_resolve_objects() -{ - m_hsync_callback.resolve_safe(); - m_vsync_callback.resolve_safe(); -} - - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void crt9028_device::device_start() -{ - m_space = &space(0); - - save_item(NAME(m_address_register)); -} - - -//------------------------------------------------- -// screen_update - screen update method -//------------------------------------------------- - -u32 crt9028_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - return 0; -} - - -//------------------------------------------------- -// chip_reset - software reset command -//------------------------------------------------- - -void crt9028_device::chip_reset() -{ - logerror("%s: Chip reset\n", machine().describe_context()); -} - - -//------------------------------------------------- -// status_r - read status register -//------------------------------------------------- - -u8 crt9028_device::status_r() -{ - return 0x80; -} - - -//------------------------------------------------- -// filadd_w - set fill address register -//------------------------------------------------- - -void crt9028_device::filadd_w(u8 data) -{ - logerror("%s: Fill address = %03X\n", machine().describe_context(), data << 4); -} - - -//------------------------------------------------- -// tosadd_w - set top of screen address register -//------------------------------------------------- - -void crt9028_device::tosadd_w(u8 data) -{ - logerror("%s: Top of screen address = %03X\n", machine().describe_context(), data << 4); -} - - -//------------------------------------------------- -// curlo_w - set cursor low register -//------------------------------------------------- - -void crt9028_device::curlo_w(u8 data) -{ - logerror("%s: Cursor low = %02X\n", machine().describe_context(), data); -} - - -//------------------------------------------------- -// curhi_w - set cursor high/scroll register -//------------------------------------------------- - -void crt9028_device::curhi_w(u8 data) -{ - logerror("%s: Cursor high = %02X\n", machine().describe_context(), data); -} - - -//------------------------------------------------- -// attdat_w - set attribute data register -//------------------------------------------------- - -void crt9028_device::attdat_w(u8 data) -{ - logerror("%s: Attribute data = %02X\n", machine().describe_context(), data); -} - - -//------------------------------------------------- -// mode_w - set mode register -//------------------------------------------------- - -void crt9028_device::mode_w(u8 data) -{ - logerror("%s: Auto increment %sabled\n", machine().describe_context(), BIT(data, 7) ? "en" : "dis"); -} - - -//------------------------------------------------- -// character_r - read character from memory -//------------------------------------------------- - -u8 crt9028_device::character_r() -{ - return 0; -} - - -//------------------------------------------------- -// character_w - write character to memory -//------------------------------------------------- - -void crt9028_device::character_w(u8 data) -{ - logerror("%s: Character = %02X\n", machine().describe_context(), data); -} - - -//------------------------------------------------- -// read - read from data or status register -//------------------------------------------------- - -u8 crt9028_device::read(offs_t offset) -{ - if (BIT(offset, 0)) - return status_r(); - else if (m_address_register == 0xe) - return character_r(); - else - { - if (!machine().side_effects_disabled()) - logerror("Read from unknown or write-only register %X\n", m_address_register); - return 0; - } -} - - -//------------------------------------------------- -// write - write to data or address register -//------------------------------------------------- - -void crt9028_device::write(offs_t offset, u8 data) -{ - if (BIT(offset, 0)) - m_address_register = data & 0x0f; - else switch (m_address_register) - { - case 0x6: - chip_reset(); - break; - - case 0x8: - tosadd_w(data); - break; - - case 0x9: - curlo_w(data); - break; - - case 0xa: - curhi_w(data); - break; - - case 0xb: - filadd_w(data); - break; - - case 0xc: - attdat_w(data); - break; - - case 0xd: - character_w(data); - break; - - case 0xe: - mode_w(data); - break; - - default: - logerror("%s: Unknown register %X = %02X\n", machine().describe_context(), m_address_register, data); - break; - } -} - - -//************************************************************************** -// INTERNAL ROM -//************************************************************************** - -ROM_START(crt9028_000) - ROM_REGION(0x400, "charset", 0) - ROM_LOAD("crt9028_000.bin", 0x000, 0x400, NO_DUMP) -ROM_END - - -//------------------------------------------------- -// rom_region - return a pointer to the implicit -// rom region description for this device -//------------------------------------------------- - -const tiny_rom_entry *crt9028_000_device::device_rom_region() const -{ - return ROM_NAME(crt9028_000); -} diff --git a/src/devices/video/crt9028.h b/src/devices/video/crt9028.h deleted file mode 100644 index f0696519ed9..00000000000 --- a/src/devices/video/crt9028.h +++ /dev/null @@ -1,142 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:AJR -/********************************************************************** - - Standard Microsystems CRT9028/9128 Video Terminal Logic Controller - -*********************************************************************** - _____ _____ - DA8 1 |* \__/ | 40 DA7 - DA9 2 | | 39 DA6 - DA10 3 | | 38 DA5 - GND 4 | | 37 DA4 - XTAL2 5 | | 36 DA3 - XTAL1 6 | | 35 DA2 - /VIDEO 7 | | 34 DA1 - INTOUT 8 | | 33 DA0 - /DWR 9 | | 32 DB7 - DD0 10 | CRT 9028 | 31 DB6 - DD1 11 | CRT 9128 | 30 DB5 - DD2 12 | | 29 DB4 - DD3 13 | | 28 DB3 - DD4 14 | | 27 DB2 - DD5 15 | | 26 DB1 - DD6 16 | | 25 DB0 - DD7 17 | | 24 A/D - HSYNC 18 | | 23 /RD or /DS - VSYNC 19 | | 22 /WR or R/W - CSYNC 20 |______________| 21 VCC - -**********************************************************************/ - -#ifndef MAME_VIDEO_CRT9028_H -#define MAME_VIDEO_CRT9028_H - -#pragma once - -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** - -// ======================> crt9028_device - -class crt9028_device : public device_t, public device_memory_interface, public device_video_interface -{ -public: - // device configuration - auto hsync_callback() { return m_hsync_callback.bind(); } - auto vsync_callback() { return m_hsync_callback.bind(); } - - // read/write handlers - u8 read(offs_t offset); - void write(offs_t offset, u8 data); - - // screen update method - u32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); - -protected: - // base type constructor - crt9028_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, - int dots_per_char, int chars_per_row, int horiz_blanking, int hsync_delay, int hsync_width, bool hsync_active, - int char_rows, int scans_per_char, bool vsync_active, - int vert_blanking, int vsync_delay, bool vsync_width, - int alt_vert_blanking, int alt_vsync_delay, bool alt_vsync_width, - int csync_delay, int csync_width, int underline, - u16 wide_gfx_seg1_4, u16 wide_gfx_seg2_5, u16 wide_gfx_seg3_6, u8 wide_gfx_pattern, - u16 thin_gfx_seg1, u16 thin_gfx_seg2, u16 thin_gfx_seg3, u16 thin_gfx_seg4, - u8 thin_gfx_dots1, u8 thin_gfx_dots2, u8 thin_gfx_dots3, u8 thin_gfx_dots4); - - // device-specific overrides - virtual void device_config_complete() override; - virtual void device_resolve_objects() override; - virtual void device_start() override; - - // device_memory_interface overrides - virtual space_config_vector memory_space_config() const override; - -private: - // register helpers - void chip_reset(); - u8 status_r(); - void filadd_w(u8 data); - void tosadd_w(u8 data); - void curlo_w(u8 data); - void curhi_w(u8 data); - void attdat_w(u8 data); - void mode_w(u8 data); - u8 character_r(); - void character_w(u8 data); - - // address space for display memory - const address_space_config m_space_config; - address_space *m_space; - - // internal character set - required_region_ptr<u8> m_charset; - - // timing callbacks - devcb_write_line m_hsync_callback; - devcb_write_line m_vsync_callback; - - // mask parameters - const int m_dots_per_char; - const int m_chars_per_row; - const int m_horiz_blanking; - const int m_hsync_delay; - const int m_hsync_width; - const bool m_hsync_active; - const int m_char_rows; - const int m_scans_per_char; - const bool m_vsync_active; - const int m_vert_blanking[2]; - const int m_vsync_delay[2]; - const int m_vsync_width[2]; - const int m_csync_delay; - const int m_csync_width; - const int m_underline; - const u16 m_wide_gfx_seg[3]; - const u8 m_wide_gfx_pattern; - const u16 m_thin_gfx_seg[4]; - const u8 m_thin_gfx_dots[4]; - - // internal state - u8 m_address_register; -}; - -// ======================> crt9028_000_device - -class crt9028_000_device : public crt9028_device -{ -public: - // device constructor - crt9028_000_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); - -protected: - // device-specific overrides - virtual const tiny_rom_entry *device_rom_region() const override; -}; - -// device type declarations -DECLARE_DEVICE_TYPE(CRT9028_000, crt9028_000_device) - -#endif // MAME_VIDEO_CRT9028_H diff --git a/src/devices/video/crtc_ega.cpp b/src/devices/video/crtc_ega.cpp index 7d03b09f131..01ee629ad43 100644 --- a/src/devices/video/crtc_ega.cpp +++ b/src/devices/video/crtc_ega.cpp @@ -51,13 +51,13 @@ void crtc_ega_device::device_post_load() } -void crtc_ega_device::address_w(uint8_t data) +WRITE8_MEMBER( crtc_ega_device::address_w ) { m_register_address_latch = data & 0x1f; } -uint8_t crtc_ega_device::register_r() +READ8_MEMBER( crtc_ega_device::register_r ) { uint8_t ret = 0; @@ -78,7 +78,7 @@ uint8_t crtc_ega_device::register_r() } -void crtc_ega_device::register_w(uint8_t data) +WRITE8_MEMBER( crtc_ega_device::register_w ) { LOG("%s CRTC_EGA: reg 0x%02x = 0x%02x\n", machine().describe_context(), m_register_address_latch, data); diff --git a/src/devices/video/crtc_ega.h b/src/devices/video/crtc_ega.h index 9d03177b494..e995cdf8a30 100644 --- a/src/devices/video/crtc_ega.h +++ b/src/devices/video/crtc_ega.h @@ -17,6 +17,34 @@ #define CRTC_EGA_END_UPDATE(_name) void _name(bitmap_ind16 &bitmap, const rectangle &cliprect) + +#define MCFG_CRTC_EGA_SET_SCREEN MCFG_VIDEO_SET_SCREEN + +#define MCFG_CRTC_EGA_BEGIN_UPDATE_CB(_class, _method) \ + downcast<crtc_ega_device &>(*device).set_begin_update_callback(crtc_ega_device::begin_update_delegate(&_class::_method, #_class "::" #_method, this)); + +#define MCFG_CRTC_EGA_ROW_UPDATE_CB(_class, _method) \ + downcast<crtc_ega_device &>(*device).set_row_update_callback(crtc_ega_device::row_update_delegate(&_class::_method, #_class "::" #_method, this)); + +#define MCFG_CRTC_EGA_END_UPDATE_CB(_class, _method) \ + downcast<crtc_ega_device &>(*device).set_end_update_callback(crtc_ega_device::end_update_delegate(&_class::_method, #_class "::" #_method, this)); + +#define MCFG_CRTC_EGA_HPIXELS_PER_COLUMN(_pix) \ + downcast<crtc_ega_device &>(*device).config_set_hpixels_per_column(_pix); + +#define MCFG_CRTC_EGA_RES_OUT_DE_CB(_devcb) \ + downcast<crtc_ega_device &>(*device).set_res_out_de_callback(DEVCB_##_devcb); + +#define MCFG_CRTC_EGA_RES_OUT_HSYNC_CB(_devcb) \ + downcast<crtc_ega_device &>(*device).set_res_out_hsync_callback(DEVCB_##_devcb); + +#define MCFG_CRTC_EGA_RES_OUT_VSYNC_CB(_devcb) \ + downcast<crtc_ega_device &>(*device).set_res_out_vsync_callback(DEVCB_##_devcb); + +#define MCFG_CRTC_EGA_RES_OUT_VBLANK_CB(_devcb) \ + downcast<crtc_ega_device &>(*device).set_res_out_vblank_callback(DEVCB_##_devcb); + + class crtc_ega_device : public device_t, public device_video_interface { @@ -29,24 +57,24 @@ public: crtc_ega_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - auto res_out_de_callback() { return m_res_out_de_cb.bind(); } - auto res_out_hsync_callback() { return m_res_out_hsync_cb.bind(); } - auto res_out_vsync_callback() { return m_res_out_vsync_cb.bind(); } - auto res_out_vblank_callback() { return m_res_out_vblank_cb.bind(); } + template <class Object> devcb_base &set_res_out_de_callback(Object &&cb) { return m_res_out_de_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_res_out_hsync_callback(Object &&cb) { return m_res_out_hsync_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_res_out_vsync_callback(Object &&cb) { return m_res_out_vsync_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_res_out_vblank_callback(Object &&cb) { return m_res_out_vblank_cb.set_callback(std::forward<Object>(cb)); } - template <typename... T> void set_begin_update_callback(T &&... args) { m_begin_update_cb = begin_update_delegate(std::forward<T>(args)...); } - template <typename... T> void set_row_update_callback(T &&... args) { m_row_update_cb = row_update_delegate(std::forward<T>(args)...); } - template <typename... T> void set_end_update_callback(T &&... args) { m_end_update_cb = end_update_delegate(std::forward<T>(args)...); } + template <typename Object> void set_begin_update_callback(Object &&cb) { m_begin_update_cb = std::forward<Object>(cb); } + template <typename Object> void set_row_update_callback(Object &&cb) { m_row_update_cb = std::forward<Object>(cb); } + template <typename Object> void set_end_update_callback(Object &&cb) { m_end_update_cb = std::forward<Object>(cb); } void config_set_hpixels_per_column(int hpixels_per_column) { m_hpixels_per_column = hpixels_per_column; } /* select one of the registers for reading or writing */ - void address_w(uint8_t data); + DECLARE_WRITE8_MEMBER( address_w ); /* read from the currently selected register */ - uint8_t register_r(); + DECLARE_READ8_MEMBER( register_r ); /* write to the currently selected register */ - void register_w(uint8_t data); + DECLARE_WRITE8_MEMBER( register_w ); /* return the current value on the MA0-MA15 pins */ uint16_t get_ma(); diff --git a/src/devices/video/decsfb.cpp b/src/devices/video/decsfb.cpp deleted file mode 100644 index 166cc98f62b..00000000000 --- a/src/devices/video/decsfb.cpp +++ /dev/null @@ -1,175 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:R. Belmont - -/* - * An emulation of the Digital Equipment Corporation SFB "Smart Frame Buffer" chip - * - * Used in: - * - * Accelerated TURBOChannel video cards for DECstations and AlphaStations - * On-board on some DECstations - * On-board on many AlphaStations - * - * Sources: - * - * http://www.hpl.hp.com/techreports/Compaq-DEC/WRL-93-1.pdf - * - */ - -#include "emu.h" -#include "decsfb.h" - -#define MODE_SIMPLE 0 -#define MODE_OPAQUESTIPPLE 1 -#define MODE_OPAQUELINE 2 -#define MODE_TRANSPARENTSTIPPLE 5 -#define MODE_TRANSPARENTLINE 6 -#define MODE_COPY 7 - -#define LOG_GENERAL (1U << 0) -#define LOG_REG (1U << 1) -#define LOG_IRQ (1U << 2) - -//#define VERBOSE (LOG_GENERAL|LOG_REG||LOG_IRQ) - -#include "logmacro.h" - -DEFINE_DEVICE_TYPE(DECSFB, decsfb_device, "decsfb", "Digital Equipment Corporation Smart Frame Buffer") - -decsfb_device::decsfb_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, DECSFB, tag, owner, clock), - m_int_cb(*this) -{ -} - -void decsfb_device::device_start() -{ - m_int_cb.resolve_safe(); - - save_item(NAME(m_vram)); - save_item(NAME(m_regs)); - save_item(NAME(m_copy_src)); -} - -void decsfb_device::device_reset() -{ - m_copy_src = 1; -} - -/* - 0x100000 copy register 0 - 0x100004 copy register 1 - 0x100008 copy register 2 - 0x10000C copy register 3 - 0x100010 copy register 4 - 0x100014 copy register 5 - 0x100018 copy register 6 - 0x10001C copy register 7 - 0x100020 foreground register - 0x100024 background register - 0x100028 plane mask - 0x10002C pixel mask - 0x100030 cxt mode - 0x100034 boolean operation - 0x100038 pixel shift - 0x10003C line address - 0x100040 bresh 1 - 0x100044 bresh 2 - 0x100048 bresh 3 - 0x10004C bresh continue - 0x100050 deep register - 0x100054 start register - 0x100058 Clear Interrupt - 0x10005C reserved 2 - 0x100060 refresh count - 0x100064 video horiz - 0x100068 video vertical - 0x10006C refresh base - 0x100070 video valid - 0x100074 Interrupt Enable -*/ - -READ32_MEMBER(decsfb_device::read) -{ - return m_regs[offset]; -} - -WRITE32_MEMBER(decsfb_device::write) -{ - COMBINE_DATA(&m_regs[offset]); - - if ((offset == (0x30/4)) && (data = 7)) - { - m_copy_src = 1; - } -} - -READ32_MEMBER(decsfb_device::vram_r) -{ - return m_vram[offset]; -} - -WRITE32_MEMBER(decsfb_device::vram_w) -{ - switch (m_regs[0x30/4]) - { - case MODE_SIMPLE: // simple - COMBINE_DATA(&m_vram[offset]); - break; - - case MODE_TRANSPARENTSTIPPLE: - { - uint8_t *pVRAM = (uint8_t *)&m_vram[offset]; - uint8_t fgs[4]; - - fgs[0] = m_regs[0x20/4] >> 24; - fgs[1] = (m_regs[0x20/4] >> 16) & 0xff; - fgs[2] = (m_regs[0x20/4] >> 8) & 0xff; - fgs[3] = m_regs[0x20/4] & 0xff; - for (int x = 0; x < 32; x++) - { - if (data & (1<<(31-x))) - { - pVRAM[x] = fgs[x & 3]; - } - } - } - break; - - case MODE_COPY: - { - uint8_t *pVRAM = (uint8_t *)&m_vram[offset]; - uint8_t *pBuffer = (uint8_t *)&m_regs[0]; // first 8 32-bit regs are the copy buffer - - if (m_copy_src) - { - m_copy_src = 0; - - for (int x = 0; x < 32; x++) - { - if (data & (1<<(31-x))) - { - pBuffer[x] = pVRAM[x]; - } - } - } - else - { - m_copy_src = 1; - - for (int x = 0; x < 32; x++) - { - if (data & (1<<(31-x))) - { - pVRAM[x] = pBuffer[x]; - } - } - } - } - break; - - default: - logerror("SFB: Unsupported VRAM write %08x (mask %08x) at %08x in mode %x\n", data, mem_mask, offset<<2, m_regs[0x30/4]); - break; - } -} diff --git a/src/devices/video/decsfb.h b/src/devices/video/decsfb.h deleted file mode 100644 index 52e6687ea40..00000000000 --- a/src/devices/video/decsfb.h +++ /dev/null @@ -1,38 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:R. Belmont - -#ifndef MAME_VIDEO_DECSFB_H -#define MAME_VIDEO_DECSFB_H - -#pragma once - -class decsfb_device : public device_t -{ -public: - decsfb_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - - auto int_cb() { return m_int_cb.bind(); } - - DECLARE_READ32_MEMBER( read ); - DECLARE_WRITE32_MEMBER( write ); - DECLARE_READ32_MEMBER( vram_r ); - DECLARE_WRITE32_MEMBER( vram_w ); - - u32 *get_vram() { return m_vram; } - -protected: - // standard device_interface overrides - virtual void device_start() override; - virtual void device_reset() override; - - devcb_write_line m_int_cb; - -private: - u32 m_vram[0x200000/4]; - u32 m_regs[0x80]; - int m_copy_src; -}; - -DECLARE_DEVICE_TYPE(DECSFB, decsfb_device) - -#endif // MAME_VIDEO_DECSFB_H diff --git a/src/devices/video/dl1416.h b/src/devices/video/dl1416.h index 446e37201dd..2f98355b95d 100644 --- a/src/devices/video/dl1416.h +++ b/src/devices/video/dl1416.h @@ -27,12 +27,24 @@ DECLARE_DEVICE_TYPE(DL1416T, dl1416_device) /*************************************************************************** + DEVICE CONFIGURATION MACROS +***************************************************************************/ + +#define MCFG_DL1414_UPDATE_HANDLER(_devcb) \ + downcast<dl1414_device &>(*device).set_update_handler(DEVCB_##_devcb); + +#define MCFG_DL1416_UPDATE_HANDLER(_devcb) \ + downcast<dl1414_device &>(*device).set_update_handler(DEVCB_##_devcb); + + +/*************************************************************************** TYPE DECLARATIONS ***************************************************************************/ class dl1414_device : public device_t { public: + template <typename Object> devcb_base &set_update_handler(Object &&cb) { return m_update_cb.set_callback(std::forward<Object>(cb)); } auto update() { return m_update_cb.bind(); } // signal-level interface diff --git a/src/devices/video/dm9368.h b/src/devices/video/dm9368.h index fb376541a07..ae9956de30b 100644 --- a/src/devices/video/dm9368.h +++ b/src/devices/video/dm9368.h @@ -23,6 +23,19 @@ #pragma once + +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define MCFG_DM9368_UPDATE_CALLBACK(cb) \ + downcast<dm9368_device &>(*device).set_update_callback(DEVCB_##cb); + +#define MCFG_DM9368_RBO_CALLBACK(cb) \ + downcast<dm9368_device &>(*device).set_rbo_callback(DEVCB_##cb); + + + //************************************************************************** // TYPE DEFINITIONS //************************************************************************** @@ -32,6 +45,8 @@ class dm9368_device : public device_t { public: + template <typename Obj> devcb_base &set_update_callback(Obj &&cb) { return m_update_cb.set_callback(std::forward<Obj>(cb)); } + template <typename Obj> devcb_base &set_rbo_callback(Obj &&cb) { return m_rbo_cb.set_callback(std::forward<Obj>(cb)); } auto update_cb() { return m_update_cb.bind(); } auto rbo_cb() { return m_rbo_cb.bind(); } diff --git a/src/devices/video/ef9340_1.h b/src/devices/video/ef9340_1.h index 4d687d227d6..88b1d91a163 100644 --- a/src/devices/video/ef9340_1.h +++ b/src/devices/video/ef9340_1.h @@ -15,18 +15,16 @@ #pragma once + +#define MCFG_EF9340_1_ADD(_tag, _clock, _screen_tag) \ + MCFG_DEVICE_ADD(_tag, EF9340_1, _clock) \ + MCFG_VIDEO_SET_SCREEN(_screen_tag) + class ef9340_1_device : public device_t, public device_video_interface { public: // construction/destruction - template <typename T> - ef9340_1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&screen_tag) - : ef9340_1_device(mconfig, tag, owner, clock) - { - set_screen(std::forward<T>(screen_tag)); - } - ef9340_1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); inline bitmap_ind16 *get_bitmap() { return &m_tmp_bitmap; } diff --git a/src/devices/video/ef9345.cpp b/src/devices/video/ef9345.cpp index 1daf7b5fde7..006d92855ba 100644 --- a/src/devices/video/ef9345.cpp +++ b/src/devices/video/ef9345.cpp @@ -35,8 +35,7 @@ DEFINE_DEVICE_TYPE(TS9347, ts9347_device, "ts9347", "TS9347") // default address map void ef9345_device::ef9345(address_map &map) { - if (!has_configured_map(0)) - map(0x0000, 0x3fff).ram(); + map(0x0000, 0x3fff).ram(); } //------------------------------------------------- @@ -114,7 +113,7 @@ ef9345_device::ef9345_device(const machine_config &mconfig, device_type type, co device_t(mconfig, type, tag, owner, clock), device_memory_interface(mconfig, *this), device_video_interface(mconfig, *this), - m_space_config("videoram", ENDIANNESS_LITTLE, 8, 16, 0, address_map_constructor(FUNC(ef9345_device::ef9345), this)), + m_space_config("videoram", ENDIANNESS_LITTLE, 8, 16, 0, address_map_constructor(), address_map_constructor(FUNC(ef9345_device::ef9345), this)), m_charset(*this, DEVICE_SELF), m_variant(variant), m_palette(*this, finder_base::DUMMY_TAG) @@ -213,7 +212,7 @@ void ef9345_device::device_timer(emu_timer &timer, device_timer_id id, int param void ef9345_device::set_busy_flag(int period) { m_bf = 1; - m_busy_timer->adjust(attotime::from_nsec(period)); + m_busy_timer->adjust(attotime::from_usec(period)); } // draw a char in 40 char line mode @@ -754,7 +753,7 @@ void ef9345_device::ef9345_exec(uint8_t cmd) { case 0x00: //KRF: R1,R2,R3->ram case 0x01: //KRF: R1,R2,R3->ram + increment - set_busy_flag(4000); + set_busy_flag(4); m_videoram->write_byte(a, m_registers[1]); m_videoram->write_byte(a + 0x0800, m_registers[2]); m_videoram->write_byte(a + 0x1000, m_registers[3]); @@ -762,14 +761,14 @@ void ef9345_device::ef9345_exec(uint8_t cmd) break; case 0x02: //KRG: R1,R2->ram case 0x03: //KRG: R1,R2->ram + increment - set_busy_flag(5500); + set_busy_flag(5.5); m_videoram->write_byte(a, m_registers[1]); m_videoram->write_byte(a + 0x0800, m_registers[2]); if (cmd&1) inc_x(7); break; case 0x08: //KRF: ram->R1,R2,R3 case 0x09: //KRF: ram->R1,R2,R3 + increment - set_busy_flag(7500); + set_busy_flag(7.5); m_registers[1] = m_videoram->read_byte(a); m_registers[2] = m_videoram->read_byte(a + 0x0800); m_registers[3] = m_videoram->read_byte(a + 0x1000); @@ -777,14 +776,14 @@ void ef9345_device::ef9345_exec(uint8_t cmd) break; case 0x0a: //KRG: ram->R1,R2 case 0x0b: //KRG: ram->R1,R2 + increment - set_busy_flag(7500); + set_busy_flag(7.5); m_registers[1] = m_videoram->read_byte(a); m_registers[2] = m_videoram->read_byte(a + 0x0800); if (cmd&1) inc_x(7); break; case 0x30: //OCT: R1->RAM, main pointer case 0x31: //OCT: R1->RAM, main pointer + inc - set_busy_flag(4000); + set_busy_flag(4); m_videoram->write_byte(indexram(7), m_registers[1]); if (cmd&1) @@ -796,7 +795,7 @@ void ef9345_device::ef9345_exec(uint8_t cmd) break; case 0x34: //OCT: R1->RAM, aux pointer case 0x35: //OCT: R1->RAM, aux pointer + inc - set_busy_flag(4000); + set_busy_flag(4); m_videoram->write_byte(indexram(5), m_registers[1]); if (cmd&1) @@ -804,7 +803,7 @@ void ef9345_device::ef9345_exec(uint8_t cmd) break; case 0x38: //OCT: RAM->R1, main pointer case 0x39: //OCT: RAM->R1, main pointer + inc - set_busy_flag(4500); + set_busy_flag(4.5); m_registers[1] = m_videoram->read_byte(indexram(7)); if (cmd&1) @@ -817,7 +816,7 @@ void ef9345_device::ef9345_exec(uint8_t cmd) break; case 0x3c: //OCT: RAM->R1, aux pointer case 0x3d: //OCT: RAM->R1, aux pointer + inc - set_busy_flag(4500); + set_busy_flag(4.5); m_registers[1] = m_videoram->read_byte(indexram(5)); if (cmd&1) @@ -825,7 +824,7 @@ void ef9345_device::ef9345_exec(uint8_t cmd) break; case 0x50: //KRL: 80 uint8_t - 12 bits write case 0x51: //KRL: 80 uint8_t - 12 bits write + inc - set_busy_flag(12500); + set_busy_flag(12.5); m_videoram->write_byte(a, m_registers[1]); switch((a / 0x0800) & 1) { @@ -851,7 +850,7 @@ void ef9345_device::ef9345_exec(uint8_t cmd) break; case 0x58: //KRL: 80 uint8_t - 12 bits read case 0x59: //KRL: 80 uint8_t - 12 bits read + inc - set_busy_flag(11500); + set_busy_flag(11.5); m_registers[1] = m_videoram->read_byte(a); switch((a / 0x0800) & 1) { @@ -880,7 +879,7 @@ void ef9345_device::ef9345_exec(uint8_t cmd) case 0x83: //IND: R1->PAT case 0x84: //IND: R1->DOR case 0x87: //IND: R1->ROR - set_busy_flag(2000); + set_busy_flag(2); switch(cmd&7) { case 1: m_tgs = m_registers[1]; break; @@ -898,7 +897,7 @@ void ef9345_device::ef9345_exec(uint8_t cmd) case 0x8b: //IND: PAT->R1 case 0x8c: //IND: DOR->R1 case 0x8f: //IND: ROR->R1 - set_busy_flag(3500); + set_busy_flag(3.5); switch(cmd&7) { case 0: m_registers[1] = m_charset[indexrom(7) & 0x1fff]; break; @@ -916,7 +915,7 @@ void ef9345_device::ef9345_exec(uint8_t cmd) case 0x99: //VSM: vertical sync mask set break; case 0xb0: //INY: increment Y - set_busy_flag(2000); + set_busy_flag(2); inc_y(6); m_state &= 0x8f; //reset S4(LXa), S5(LXm), S6(Al) break; @@ -937,7 +936,7 @@ void ef9345_device::ef9345_exec(uint8_t cmd) uint8_t n = (cmd>>4) - 0x0c; uint8_t r1 = (cmd&0x04) ? 7 : 5; uint8_t r2 = (cmd&0x04) ? 5 : 7; - int busy = 2000; + int busy = 2; for(i = 0; i < 1280; i++) { @@ -960,7 +959,7 @@ void ef9345_device::ef9345_exec(uint8_t cmd) inc_y(6); } - busy += 4000 * n; + busy += 4 * n; } m_state &= 0x8f; //reset S4(LXa), S5(LXm), S6(Al) set_busy_flag(busy); @@ -995,7 +994,7 @@ void ef9345_device::update_scanline(uint16_t scanline) if (scanline == 250) m_state &= 0xfb; - set_busy_flag(104000); + set_busy_flag(104); if (m_char_mode == MODE12x80 || m_char_mode == MODE8x80) { @@ -1048,7 +1047,7 @@ void ef9345_device::update_scanline(uint16_t scanline) } } -uint8_t ef9345_device::data_r(offs_t offset) +READ8_MEMBER( ef9345_device::data_r ) { if (offset & 7) return m_registers[offset & 7]; @@ -1061,7 +1060,7 @@ uint8_t ef9345_device::data_r(offs_t offset) return m_state; } -void ef9345_device::data_w(offs_t offset, uint8_t data) +WRITE8_MEMBER( ef9345_device::data_w ) { m_registers[offset & 7] = data; diff --git a/src/devices/video/ef9345.h b/src/devices/video/ef9345.h index d36811e8a60..dfec7d080f2 100644 --- a/src/devices/video/ef9345.h +++ b/src/devices/video/ef9345.h @@ -15,6 +15,8 @@ #include "emupal.h" +#define MCFG_EF9345_PALETTE(_palette_tag) \ + downcast<ef9345_device &>(*device).set_palette_tag(_palette_tag); //************************************************************************** // TYPE DEFINITIONS @@ -34,8 +36,8 @@ public: template <typename T> void set_palette_tag(T &&tag) { m_palette.set_tag(std::forward<T>(tag)); } // device interface - uint8_t data_r(offs_t offset); - void data_w(offs_t offset, uint8_t data); + DECLARE_READ8_MEMBER( data_r ); + DECLARE_WRITE8_MEMBER( data_w ); void update_scanline(uint16_t scanline); uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); diff --git a/src/devices/video/ef9364.cpp b/src/devices/video/ef9364.cpp index 858b7309ca6..ec324ff0e52 100644 --- a/src/devices/video/ef9364.cpp +++ b/src/devices/video/ef9364.cpp @@ -35,8 +35,7 @@ DEFINE_DEVICE_TYPE(EF9364, ef9364_device, "ef9364", "Thomson EF9364") //------------------------------------------------- void ef9364_device::ef9364(address_map &map) { - if (!has_configured_map(0)) - map(0x00000, ef9364_device::TXTPLANE_MAX_SIZE * ef9364_device::MAX_TXTPLANES - 1).ram(); + map(0x00000, ef9364_device::TXTPLANE_MAX_SIZE * ef9364_device::MAX_TXTPLANES - 1).ram(); } //------------------------------------------------- @@ -67,7 +66,7 @@ ef9364_device::ef9364_device(const machine_config &mconfig, const char *tag, dev device_t(mconfig, EF9364, tag, owner, clock), device_memory_interface(mconfig, *this), device_video_interface(mconfig, *this), - m_space_config("textram", ENDIANNESS_LITTLE, 8, 12, 0, address_map_constructor(FUNC(ef9364_device::ef9364), this)), + m_space_config("textram", ENDIANNESS_LITTLE, 8, 12, 0, address_map_constructor(), address_map_constructor(FUNC(ef9364_device::ef9364), this)), m_charset(*this, DEVICE_SELF), m_palette(*this, finder_base::DUMMY_TAG) { diff --git a/src/devices/video/ef9364.h b/src/devices/video/ef9364.h index 290ab8464df..1082173733c 100644 --- a/src/devices/video/ef9364.h +++ b/src/devices/video/ef9364.h @@ -15,6 +15,14 @@ #include "emupal.h" +#define MCFG_EF9364_PALETTE(_palette_tag) \ + downcast<ef9364_device &>(*device).set_palette_tag(_palette_tag); + +#define MCFG_EF9364_PAGES_CNT(_pages_number) \ + downcast<ef9364_device &>(*device).set_nb_of_pages(_pages_number); + +#define MCFG_EF9364_IRQ_HANDLER(_devcb) \ + downcast<ef9364_device &>(*device).set_irq_handler(DEVCB_##_devcb); //************************************************************************** // TYPE DEFINITIONS diff --git a/src/devices/video/ef9365.cpp b/src/devices/video/ef9365.cpp index 5abc7d2dde8..5023348c99e 100644 --- a/src/devices/video/ef9365.cpp +++ b/src/devices/video/ef9365.cpp @@ -168,8 +168,7 @@ const tiny_rom_entry *ef9365_device::device_rom_region() const //------------------------------------------------- void ef9365_device::ef9365(address_map &map) { - if (!has_configured_map(0)) - map(0x00000, ef9365_device::BITPLANE_MAX_SIZE * ef9365_device::MAX_BITPLANES - 1).ram(); + map(0x00000, ef9365_device::BITPLANE_MAX_SIZE * ef9365_device::MAX_BITPLANES - 1).ram(); } //------------------------------------------------- @@ -201,7 +200,7 @@ ef9365_device::ef9365_device(const machine_config &mconfig, const char *tag, dev device_t(mconfig, EF9365, tag, owner, clock), device_memory_interface(mconfig, *this), device_video_interface(mconfig, *this), - m_space_config("videoram", ENDIANNESS_LITTLE, 8, 18, 0, address_map_constructor(FUNC(ef9365_device::ef9365), this)), + m_space_config("videoram", ENDIANNESS_LITTLE, 8, 18, 0, address_map_constructor(), address_map_constructor(FUNC(ef9365_device::ef9365), this)), m_charset(*this, "ef9365"), m_palette(*this, finder_base::DUMMY_TAG), m_irq_handler(*this) @@ -1225,7 +1224,7 @@ void ef9365_device::update_scanline(uint16_t scanline) // data_r: Registers read access callback //------------------------------------------------- -uint8_t ef9365_device::data_r(offs_t offset) +READ8_MEMBER( ef9365_device::data_r ) { unsigned char return_value; @@ -1316,7 +1315,7 @@ uint8_t ef9365_device::data_r(offs_t offset) // data_w: Registers write access callback //------------------------------------------------- -void ef9365_device::data_w(offs_t offset, uint8_t data) +WRITE8_MEMBER( ef9365_device::data_w ) { LOG("EF9365 [ %s ] <WR [ 0x%.2X ] - %s\n", register_names[offset&0xF],data, machine().describe_context() ); diff --git a/src/devices/video/ef9365.h b/src/devices/video/ef9365.h index be22ae6339b..762989e6a03 100644 --- a/src/devices/video/ef9365.h +++ b/src/devices/video/ef9365.h @@ -15,6 +15,17 @@ #include "emupal.h" +#define MCFG_EF936X_PALETTE(palette_tag) \ + downcast<ef9365_device &>(*device).set_palette_tag(palette_tag); + +#define MCFG_EF936X_BITPLANES_CNT(bitplanes_number) \ + downcast<ef9365_device &>(*device).set_nb_bitplanes((bitplanes_number)); + +#define MCFG_EF936X_DISPLAYMODE(display_mode) \ + downcast<ef9365_device &>(*device).set_display_mode((ef9365_device::display_mode)); + +#define MCFG_EF936X_IRQ_HANDLER(cb) \ + downcast<ef9365_device &>(*device).set_irq_handler((DEVCB_##cb)); //************************************************************************** // TYPE DEFINITIONS @@ -43,11 +54,11 @@ public: template <typename T> void set_palette_tag(T &&tag) { m_palette.set_tag(std::forward<T>(tag)); } void set_nb_bitplanes(int nb_bitplanes ); void set_display_mode(int display_mode ); - auto irq_handler() { return m_irq_handler.bind(); } + template<class Object> devcb_base &set_irq_handler(Object object) { return m_irq_handler.set_callback(std::forward<Object>(object)); } // device interface - uint8_t data_r(offs_t offset); - void data_w(offs_t offset, uint8_t data); + DECLARE_READ8_MEMBER( data_r ); + DECLARE_WRITE8_MEMBER( data_w ); void update_scanline(uint16_t scanline); void set_color_filler( uint8_t color ); diff --git a/src/devices/video/epic12.h b/src/devices/video/epic12.h index 287dc08ebb3..a8fe41b069f 100644 --- a/src/devices/video/epic12.h +++ b/src/devices/video/epic12.h @@ -6,6 +6,12 @@ #pragma once +#define MCFG_EPIC12_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, EPIC12, 0) + +#define MCFG_EPIC12_SET_MAINRAMSIZE( _rgn ) \ + downcast<epic12_device &>(*device).set_mainramsize(_rgn); + class epic12_device : public device_t, public device_video_interface { diff --git a/src/devices/video/fixfreq.cpp b/src/devices/video/fixfreq.cpp index 58eec1722e3..a64c6d812b3 100644 --- a/src/devices/video/fixfreq.cpp +++ b/src/devices/video/fixfreq.cpp @@ -19,216 +19,194 @@ //#define VERBOSE 1 #include "logmacro.h" + /*************************************************************************** Fixed frequency monitor ***************************************************************************/ - - - // device type definition DEFINE_DEVICE_TYPE(FIXFREQ, fixedfreq_device, "fixfreq", "Fixed-Frequency Monochrome Monitor") -void fixedfreq_monitor_state::update_sync_channel(const time_type &time, const double newval) +fixedfreq_device::fixedfreq_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, type, tag, owner, clock), + device_video_interface(mconfig, *this, false), + m_htotal(0), m_vtotal(0), m_vid(0), m_last_x(0), m_last_y(0), m_cur_bm(0), + // default to NTSC "704x480@30i" + m_monitor_clock(13500000), + m_hvisible(704), + m_hfrontporch(728), + m_hsync(791), + m_hbackporch(858), + 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_vint(0), m_int_trig(0), m_mult(0), m_sig_vsync(0), m_sig_composite(0), m_sig_field(0) { - const time_type delta_time = time - m_last_sync_time; - - const int last_vsync = m_sig_vsync; - const int last_comp = m_sig_composite; - - m_vsync_filter += ((double) last_comp - m_vsync_filter) * (1.0 - exp(-delta_time * m_vsync_filter_timeconst)); - m_sig_composite = (newval < m_desc.m_sync_threshold) ? 1 : 0 ; - - m_sig_vsync = (m_vsync_filter > m_vsync_threshold) ? 1 : 0; - - if (!last_vsync && m_sig_vsync) - { - //LOG("VSYNC %d %d\n", m_last_x, m_last_y + m_sig_field); - m_last_y = m_desc.m_vbackporch - m_desc.m_vsync; - m_intf.vsync_start_cb(time - m_last_vsync_time); - m_last_vsync_time = time; - } - else if (last_vsync && !m_sig_vsync) - { - m_sig_field = last_comp; /* force false-progressive */ - m_sig_field = (m_sig_field ^ 1) ^ last_comp; /* if there is no field switch, auto switch */ - //LOG("Field: %d\n", m_sig_field); - } - - if (!last_comp && m_sig_composite) - { - /* TODO - time since last hsync and field detection */ - //LOG("HSYNC up %d\n", m_last_x); - // FIXME: pixels > 50 filters some spurious hysnc on line 27 in breakout - if (!m_sig_vsync && (m_last_x > m_desc.m_hscale * 100)) - { - m_last_y += m_desc.m_fieldcount; - m_last_x = 0; - m_line_time = time; - } - //if (m_last_y == 27) printf("HSYNC up %d %d\n", m_last_y, pixels); - } - else if (last_comp && !m_sig_composite) - { - /* falling composite */ - //LOG("HSYNC down %f %d %f\n", time * 1e6, m_last_x, m_sync_signal); - } - - m_sync_signal = newval; - m_last_sync_time = time; } -void fixedfreq_monitor_state::update_bm(const time_type &time) +fixedfreq_device::fixedfreq_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : fixedfreq_device(mconfig, FIXFREQ, tag, owner, clock) { - const int pixels = round((time - m_line_time) * m_desc.m_hscale / m_clock_period); - const int has_fields = (m_desc.m_fieldcount > 1) ? 1: 0; - - uint32_t col(0xffff0000); // Mark sync areas - - if (m_sync_signal >= m_desc.m_sync_threshold) - col = m_col; - - m_intf.plot_hline(m_last_x, m_last_y + m_sig_field * has_fields, pixels - m_last_x, col); - m_last_x = pixels; } -void fixedfreq_monitor_state::update_composite_monochrome(const time_type &time, const double data) +void fixedfreq_device::device_start() { - update_bm(time); - update_sync_channel(time, data); - - int colv = (int) ((data - m_desc.m_sync_threshold) * m_desc.m_gain * 255.0); - if (colv > 255) - colv = 255; - if (colv < 0) - m_col = 0xffff0000; - else - m_col = 0xff000000 | (colv<<16) | (colv<<8) | colv; -} + m_htotal = 0; + m_vtotal = 0; + + m_vid = 0.0; + m_last_x = 0; + m_last_y = 0; + m_last_time = attotime::zero; + m_line_time = attotime::zero; + m_last_hsync_time = attotime::zero; + m_last_vsync_time = attotime::zero; + m_refresh = attotime::zero; + m_clock_period = attotime::zero; + //bitmap_rgb32 *m_bitmap[2]; + m_cur_bm = 0; -void fixedfreq_monitor_state::update_red(const time_type &time, const double data) -{ - update_bm(time); - - int colv = (int) ((data - m_desc.m_sync_threshold) * m_desc.m_gain * 255.0); - if (colv > 255) - colv = 255; - if (colv < 0) - colv = 0; - m_col = (m_col & 0xff00ffff) | (colv<<16); -} + /* sync separator */ + m_vint = 0.0; + m_int_trig = 0.0; + m_mult = 0.0; + + m_sig_vsync = 0; + m_sig_composite = 0; + m_sig_field = 0; + + m_bitmap[0] = nullptr; + m_bitmap[1] = nullptr; + //m_vblank_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(vga_device::vblank_timer_cb),this)); + recompute_parameters(false); + + save_item(NAME(m_vid)); + save_item(NAME(m_last_x)); + save_item(NAME(m_last_y)); + save_item(NAME(m_last_time)); + save_item(NAME(m_line_time)); + save_item(NAME(m_last_hsync_time)); + save_item(NAME(m_last_vsync_time)); + save_item(NAME(m_refresh)); + save_item(NAME(m_clock_period)); + //save_item(NAME(m_bitmap[0])); + //save_item(NAME(m_bitmap[1])); + save_item(NAME(m_cur_bm)); -void fixedfreq_monitor_state::update_green(const time_type &time, const double data) -{ - update_bm(time); - //update_sync_channel(ctime, data); - - int colv = (int) ((data - m_desc.m_sync_threshold) * m_desc.m_gain * 255.0); - if (colv > 255) - colv = 255; - if (colv < 0) - colv = 0; - m_col = (m_col & 0xffff00ff) | (colv<<8); -} + /* sync separator */ + save_item(NAME(m_vint)); + save_item(NAME(m_int_trig)); + save_item(NAME(m_mult)); -void fixedfreq_monitor_state::update_blue(const time_type &time, const double data) -{ - update_bm(time); - //update_sync_channel(ctime, data); + save_item(NAME(m_sig_vsync)); + save_item(NAME(m_sig_composite)); + save_item(NAME(m_sig_field)); - int colv = (int) ((data - m_desc.m_sync_threshold) * m_desc.m_gain * 255.0); - if (colv > 255) - colv = 255; - if (colv < 0) - colv = 0; - m_col = (m_col & 0xffffff00) | colv; -} -void fixedfreq_monitor_state::update_sync(const time_type &time, const double data) -{ - update_bm(time); - update_sync_channel(time, data); } -fixedfreq_device::fixedfreq_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, type, tag, owner, clock), - device_video_interface(mconfig, *this, false), - m_cur_bm(0), - m_htotal(0), - m_vtotal(0), - m_refresh_period(time_type(0)), - m_monitor(), - m_state(m_monitor, *this) +void fixedfreq_device::device_reset() { + m_last_time = attotime::zero; + m_line_time = attotime::zero; + m_last_hsync_time = attotime::zero; + m_last_vsync_time = attotime::zero; + m_vint = 0; + } -fixedfreq_device::fixedfreq_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : fixedfreq_device(mconfig, FIXFREQ, tag, owner, clock) + +void fixedfreq_device::device_post_load() { + //recompute_parameters(true); } -void fixedfreq_device::device_config_complete() +void fixedfreq_device::recompute_parameters(bool postload) { - if (!has_screen()) - return; + bool needs_realloc = (m_htotal != m_hbackporch) && (m_vtotal != m_vbackporch); - if (!screen().refresh_attoseconds()) - screen().set_raw(m_monitor.m_monitor_clock, m_monitor.m_hbackporch, 0, - m_monitor.m_hbackporch, m_monitor.m_vbackporch, 0, - m_monitor.m_vbackporch); + if (m_bitmap[0] != nullptr || needs_realloc) + m_bitmap[0] = nullptr; + if (m_bitmap[1] != nullptr || needs_realloc) + m_bitmap[1] = nullptr; - if (!screen().has_screen_update()) - screen().set_screen_update(screen_update_rgb32_delegate(FUNC(fixedfreq_device::screen_update), this)); -} + m_htotal = m_hbackporch; + m_vtotal = m_vbackporch; -void fixedfreq_device::device_start() -{ + /* sync separator */ - m_refresh_period = time_type(0); + m_int_trig = (exp(- 3.0/(3.0+3.0))) - exp(-1.0); + m_mult = (double) (m_monitor_clock) / (double) m_htotal * 1.0; // / (3.0 + 3.0); + LOG("trigger %f with len %f\n", m_int_trig, 1e6 / m_mult); - m_cur_bm = 0; + m_bitmap[0] = std::make_unique<bitmap_rgb32>(m_htotal, m_vtotal); + m_bitmap[1] = std::make_unique<bitmap_rgb32>(m_htotal, m_vtotal); - m_htotal = m_monitor.m_hbackporch; - m_vtotal = m_monitor.m_vbackporch; - m_bitmap[0] = std::make_unique<bitmap_rgb32>(m_htotal * m_monitor.m_hscale, m_vtotal); - m_bitmap[1] = std::make_unique<bitmap_rgb32>(m_htotal * m_monitor.m_hscale, m_vtotal); - - m_state.start(); - - // FIXME: will be done by netlist going forward - save_item(NAME(m_state.m_sync_signal)); - save_item(NAME(m_state.m_last_x)); - save_item(NAME(m_state.m_last_y)); - save_item(NAME(m_state.m_last_sync_time)); - save_item(NAME(m_state.m_line_time)); - save_item(NAME(m_state.m_last_hsync_time)); - save_item(NAME(m_state.m_last_vsync_time)); - save_item(NAME(m_refresh_period)); - save_item(NAME(m_state.m_clock_period)); - //save_item(NAME(m_bitmap[0])); - //save_item(NAME(m_bitmap[1])); - save_item(NAME(m_cur_bm)); + rectangle visarea( + m_hbackporch - m_hfrontporch, + m_hbackporch - m_hfrontporch + m_hvisible - 1, + m_vbackporch - m_vfrontporch, + m_vbackporch - m_vfrontporch + m_vvisible - 1); - /* sync separator */ - save_item(NAME(m_state.m_vsync_filter)); - save_item(NAME(m_state.m_vsync_threshold)); - save_item(NAME(m_state.m_vsync_filter_timeconst)); + m_clock_period = attotime::from_hz(m_monitor_clock); - save_item(NAME(m_state.m_sig_vsync)); - save_item(NAME(m_state.m_sig_composite)); - save_item(NAME(m_state.m_sig_field)); + m_refresh = attotime::from_hz(m_monitor_clock) * m_vtotal * m_htotal; + screen().configure(m_htotal, m_vtotal, visarea, m_refresh.as_attoseconds()); } -void fixedfreq_device::device_reset() +void fixedfreq_device::update_screen_parameters(const attotime &refresh) { - m_state.reset(); + rectangle visarea( +// m_hsync - m_hvisible, +// m_hsync - 1 , + m_hbackporch - m_hfrontporch, + m_hbackporch - m_hfrontporch + m_hvisible - 1, + m_vbackporch - m_vfrontporch, + m_vbackporch - m_vfrontporch + m_vvisible - 1); + + m_refresh = refresh; + screen().configure(m_htotal, m_vtotal, visarea, m_refresh.as_attoseconds()); } -void fixedfreq_device::device_post_load() +int fixedfreq_device::sync_separator(const attotime &time, double newval) { - //recompute_parameters(); + int last_vsync = m_sig_vsync; + int last_comp = m_sig_composite; + int ret = 0; + + m_vint += ((double) last_comp - m_vint) * (1.0 - exp(-time.as_double() * m_mult)); + m_sig_composite = (newval < m_sync_threshold) ? 1 : 0 ; + + m_sig_vsync = (m_vint > m_int_trig) ? 1 : 0; + + if (!last_vsync && m_sig_vsync) + { + /* TODO - time since last hsync and field detection */ + ret |= 1; + } + if (last_vsync && !m_sig_vsync) + { + m_sig_field = last_comp; /* force false-progressive */ + m_sig_field = (m_sig_field ^ 1) ^ last_comp; /* if there is no field switch, auto switch */ + LOG("Field: %d\n", m_sig_field); + } + if (!last_comp && m_sig_composite) + { + /* TODO - time since last hsync and field detection */ + ret |= 2; + } + if (last_comp && !m_sig_composite) + { + /* falling composite */ + ret |= 4; + } + return ret; } uint32_t fixedfreq_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) @@ -238,62 +216,72 @@ uint32_t fixedfreq_device::screen_update(screen_device &screen, bitmap_rgb32 &bi return 0; } -void fixedfreq_device::vsync_start_cb(double refresh_time) -{ - // toggle bitmap - m_cur_bm ^= 1; - - rectangle visarea(m_monitor.minh(), m_monitor.maxh(), m_monitor.minv(), m_monitor.maxv()); - - m_refresh_period = refresh_time; - screen().configure(m_htotal * m_monitor.m_hscale, m_vtotal, visarea, DOUBLE_TO_ATTOSECONDS(m_refresh_period)); -} - -void fixedfreq_device::plot_hline(int x, int y, int w, uint32_t col) +NETDEV_ANALOG_CALLBACK_MEMBER(fixedfreq_device::update_vid) { bitmap_rgb32 *bm = m_bitmap[m_cur_bm].get(); - if (y < bm->height()) - bm->plot_box(x, y, w, 1, col); -} + const int has_fields = (m_fieldcount > 1) ? 1: 0; -NETDEV_ANALOG_CALLBACK_MEMBER(fixedfreq_device::update_composite_monochrome) -{ - // double is good enough for this exercise; + int pixels = round((time - m_line_time).as_double() / m_clock_period.as_double()); + attotime delta_time = (time - m_last_time); - const time_type ctime = time.as_double(); - m_state.update_composite_monochrome(ctime, data); -} + if (data == m_vid) + return; -NETDEV_ANALOG_CALLBACK_MEMBER(fixedfreq_device::update_red) -{ - // double is good enough for this exercise; + ATTR_UNUSED int sync = sync_separator(delta_time, data); - const time_type ctime = time.as_double(); - m_state.update_red(ctime, data); -} + if (m_last_y < bm->height()) + { + rgb_t col; -NETDEV_ANALOG_CALLBACK_MEMBER(fixedfreq_device::update_green) -{ - // double is good enough for this exercise; + if (m_vid < m_sync_threshold) + // Mark sync areas + col = rgb_t(255, 0, 0); + else + { + int colv = (int) ((m_vid - m_sync_threshold) * m_gain * 255.0); + if (colv > 255) + colv = 255; + col = rgb_t(colv, colv, colv); + } - const time_type ctime = time.as_double(); - m_state.update_green(ctime, data); -} + bm->plot_box(m_last_x, m_last_y + m_sig_field * has_fields, pixels - m_last_x, 1, col); + m_last_x = pixels; + } + if (sync & 1) + { + LOG("VSYNC %d %d\n", pixels, m_last_y + m_sig_field); + } + if (sync & 2) + { + LOG("HSYNC up %d\n", pixels); + //if (m_last_y == 27) printf("HSYNC up %d %d\n", m_last_y, pixels); + } + if (sync & 4) + { + LOG("HSYNC down %f %d %f\n", time.as_double()* 1e6, pixels, m_vid); + } -NETDEV_ANALOG_CALLBACK_MEMBER(fixedfreq_device::update_blue) -{ - // double is good enough for this exercise; + if (sync & 1) + { + m_last_y = m_vbackporch - m_vsync; + // toggle bitmap + m_cur_bm ^= 1; + update_screen_parameters(time - m_last_vsync_time); + m_last_vsync_time = time; + } - const time_type ctime = time.as_double(); - m_state.update_blue(ctime, data); -} + // FIXME: pixels > 50 filters some spurious hysnc on line 27 in breakout + if ((sync & 2) && !m_sig_vsync && (pixels > 100)) + { + m_last_y += m_fieldcount; + m_last_x = 0; + m_line_time = time; + } -NETDEV_ANALOG_CALLBACK_MEMBER(fixedfreq_device::update_sync) -{ - // double is good enough for this exercise; + m_last_time = time; + m_vid = data; - const time_type ctime = time.as_double(); - m_state.update_sync(ctime, data); } + /***************************************************************************/ diff --git a/src/devices/video/fixfreq.h b/src/devices/video/fixfreq.h index d85056d874b..10c52217e82 100644 --- a/src/devices/video/fixfreq.h +++ b/src/devices/video/fixfreq.h @@ -17,245 +17,139 @@ #include "machine/netlist.h" #include "screen.h" -struct fixedfreq_monitor_desc -{ - fixedfreq_monitor_desc() - // default to NTSC "704x480@30i" - : m_monitor_clock(13500000), - m_hvisible(704), - m_hfrontporch(728), - m_hsync(791), - m_hbackporch(858), - 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) - {} - - 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 m_monitor_clock; - int m_hvisible; - int m_hfrontporch; - int m_hsync; - int m_hbackporch; - int m_vvisible; - 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 plot_hline(int x, int y, int w, uint32_t col) = 0; -}; -struct fixedfreq_monitor_state -{ - using time_type = double; - - fixedfreq_monitor_state(fixedfreq_monitor_desc &desc, fixedfreq_monitor_intf &intf) - : m_desc(desc), - m_intf(intf), - m_sync_signal(0), - m_col(0), - m_last_x(0), - m_last_y(0), - m_last_sync_time(time_type(0)), - 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) - {} - - /*** - * \brief To be called after monitor parameters are set - */ - void start() - { - // FIXME: once moved to netlist this may no longer be necessary. - // Only copies constructor init +#define FIXFREQ_INTERFACE(name) \ + const fixedfreq_interface (name) = - m_sync_signal = 0.0; - m_col = rgb_t(0,0,0); - m_last_x = 0; - m_last_y = 0; - m_last_sync_time = time_type(0); - 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); +#define MCFG_FIXFREQ_ADD(_tag, _screen_tag) \ + MCFG_SCREEN_ADD(_screen_tag, RASTER) \ + MCFG_SCREEN_RAW_PARAMS(13500000, 858, 0, 858, 525, 0, 525) \ + MCFG_SCREEN_UPDATE_DEVICE(_tag, fixedfreq_device, screen_update) \ + MCFG_DEVICE_ADD(_tag, FIXFREQ, 0) \ + MCFG_VIDEO_SET_SCREEN(_screen_tag) - /* sync separator */ - m_vsync_filter = 0.0; - m_vsync_threshold = 0.0; - m_vsync_filter_timeconst = 0.0; +#define MCFG_FIXFREQ_MONITOR_CLOCK(_clock) \ + downcast<fixedfreq_device &>(*device).set_minitor_clock(_clock); - m_sig_vsync = 0; - m_sig_composite = 0; - m_sig_field = 0; +#define MCFG_FIXFREQ_HORZ_PARAMS(_visible, _frontporch, _sync, _backporch) \ + downcast<fixedfreq_device &>(*device).set_horz_params(_visible, _frontporch, _sync, _backporch); - // htotal = m_desc.m_hbackporch; - // vtotal = m_desc.m_vbackporch; +#define MCFG_FIXFREQ_VERT_PARAMS(_visible, _frontporch, _sync, _backporch) \ + downcast<fixedfreq_device &>(*device).set_vert_params(_visible, _frontporch, _sync, _backporch); - /* sync separator */ +#define MCFG_FIXFREQ_FIELDCOUNT(_count) \ + downcast<fixedfreq_device &>(*device).set_fieldcount(_count); - 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); +#define MCFG_FIXFREQ_SYNC_THRESHOLD(_threshold) \ + downcast<fixedfreq_device &>(*device).set_threshold(_threshold); - m_clock_period = 1.0 / m_desc.m_monitor_clock; - m_intf.vsync_start_cb(m_clock_period * m_desc.m_vbackporch * m_desc.m_hbackporch); +#define MCFG_FIXFREQ_GAIN(_gain) \ + downcast<fixedfreq_device &>(*device).set_gain(_gain); - } +// pre-defined configurations - void reset() - { - m_last_sync_time = time_type(0); - m_line_time = time_type(0); - m_last_hsync_time = time_type(0); - m_last_vsync_time = time_type(0); - m_vsync_filter = 0; - } - - void update_sync_channel(const time_type &time, const double newval); - void update_bm(const time_type &time); - void update_composite_monochrome(const time_type &time, const double newval); - void update_red(const time_type &time, const double data); - void update_green(const time_type &time, const double data); - void update_blue(const time_type &time, const double data); - void update_sync(const time_type &time, const double data); +//ModeLine "720x480@30i" 13.5 720 736 799 858 480 486 492 525 interlace -hsync -vsync +#define MCFG_FIXFREQ_MODE_NTSC720 \ + MCFG_FIXFREQ_MONITOR_CLOCK(13500000) \ + MCFG_FIXFREQ_HORZ_PARAMS(720, 736, 799, 858) \ + MCFG_FIXFREQ_VERT_PARAMS(480, 486, 492, 525) \ + MCFG_FIXFREQ_FIELDCOUNT(2) \ + MCFG_FIXFREQ_SYNC_THRESHOLD(0.3) - const fixedfreq_monitor_desc &m_desc; - fixedfreq_monitor_intf &m_intf; +//ModeLine "704x480@30i" 13.5 704 728 791 858 480 486 492 525 +#define MCFG_FIXFREQ_MODE_NTSC704 \ + MCFG_FIXFREQ_MONITOR_CLOCK(13500000) \ + MCFG_FIXFREQ_HORZ_PARAMS(704, 728, 791, 858) \ + MCFG_FIXFREQ_VERT_PARAMS(480, 486, 492, 525) \ + MCFG_FIXFREQ_FIELDCOUNT(2) \ + MCFG_FIXFREQ_SYNC_THRESHOLD(0.3) - double m_sync_signal; - uint32_t m_col; - int m_last_x; - int m_last_y; - time_type m_last_sync_time; - 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; - -}; -// ======================> fixedfreq_device +// ======================> vga_device -class fixedfreq_device : public device_t, public device_video_interface, - public fixedfreq_monitor_intf +class fixedfreq_device : public device_t, public device_video_interface { public: - - using time_type = fixedfreq_monitor_state::time_type; - // construction/destruction - fixedfreq_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + fixedfreq_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); // 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_minitor_clock(uint32_t clock) { m_monitor_clock = clock; } + void set_fieldcount(int count) { m_fieldcount = count; } + void set_threshold(double threshold) { m_sync_threshold = threshold; } + void set_gain(double gain) { m_gain = gain; } void 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_hvisible = visible; + m_hfrontporch = frontporch; + m_hsync = sync; + m_hbackporch = backporch; } void 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; - } - void set_horz_scale(int hscale) { m_monitor.m_hscale = hscale; } - - // pre-defined configurations - void 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); - } - void 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); + m_vvisible = visible; + m_vfrontporch = frontporch; + m_vsync = sync; + m_vbackporch = backporch; } virtual uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); - NETDEV_ANALOG_CALLBACK_MEMBER(update_composite_monochrome); - NETDEV_ANALOG_CALLBACK_MEMBER(update_red); - NETDEV_ANALOG_CALLBACK_MEMBER(update_green); - NETDEV_ANALOG_CALLBACK_MEMBER(update_blue); - NETDEV_ANALOG_CALLBACK_MEMBER(update_sync); - + NETDEV_ANALOG_CALLBACK_MEMBER(update_vid); protected: - fixedfreq_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); // device-level overrides - virtual void device_config_complete() override; virtual void device_start() override; virtual void device_reset() override; 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; - void plot_hline(int x, int y, int w, uint32_t col) override; + void recompute_parameters(bool postload); + void update_screen_parameters(const attotime &refresh); private: - std::unique_ptr<bitmap_rgb32> m_bitmap[2]; - int m_cur_bm; + int sync_separator(const attotime &time, double newval); + int m_htotal; int m_vtotal; - time_type m_refresh_period; + double m_vid; + int m_last_x; + int m_last_y; + attotime m_last_time; + attotime m_line_time; + attotime m_last_hsync_time; + attotime m_last_vsync_time; + attotime m_refresh; + attotime m_clock_period; + std::unique_ptr<bitmap_rgb32> m_bitmap[2]; + int m_cur_bm; /* adjustable by drivers */ - fixedfreq_monitor_desc m_monitor; - fixedfreq_monitor_state m_state; + uint32_t m_monitor_clock; + int m_hvisible; + int m_hfrontporch; + int m_hsync; + int m_hbackporch; + int m_vvisible; + int m_vfrontporch; + int m_vsync; + int m_vbackporch; + int m_fieldcount; + double m_sync_threshold; + double m_gain; + + /* sync separator */ + double m_vint; + double m_int_trig; + double m_mult; + int m_sig_vsync; + int m_sig_composite; + int m_sig_field; }; diff --git a/src/devices/video/gba_lcd.cpp b/src/devices/video/gba_lcd.cpp index 36214bb1ad4..36c8e83b27e 100644 --- a/src/devices/video/gba_lcd.cpp +++ b/src/devices/video/gba_lcd.cpp @@ -1807,12 +1807,11 @@ void gba_lcd_device::device_reset() m_hbl_timer->adjust(attotime::never); } -void gba_lcd_device::device_add_mconfig(machine_config &config) -{ - screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_LCD)); - screen.set_raw(XTAL(16'777'216) / 4, 308, 0, 240, 228, 0, 160); - screen.set_screen_update(FUNC(gba_lcd_device::screen_update)); - screen.set_palette("palette"); +MACHINE_CONFIG_START(gba_lcd_device::device_add_mconfig) + MCFG_SCREEN_ADD("screen", LCD) + MCFG_SCREEN_RAW_PARAMS(XTAL(16'777'216) / 4, 308, 0, 240, 228, 0, 160) + MCFG_SCREEN_UPDATE_DEVICE(DEVICE_SELF, gba_lcd_device, screen_update) + MCFG_SCREEN_PALETTE("palette") PALETTE(config, "palette", FUNC(gba_lcd_device::gba_palette), 32768); -} +MACHINE_CONFIG_END diff --git a/src/devices/video/gba_lcd.h b/src/devices/video/gba_lcd.h index ed4c258acad..1332340e175 100644 --- a/src/devices/video/gba_lcd.h +++ b/src/devices/video/gba_lcd.h @@ -26,6 +26,29 @@ DECLARE_DEVICE_TYPE(GBA_LCD, gba_lcd_device) //************************************************************************** +// DEVICE CONFIGURATION MACROS +//************************************************************************** + +#define MCFG_GBA_LCD_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, GBA_LCD, 0) + +#define MCFG_GBA_LCD_INT_HBLANK(_devcb) \ + downcast<gba_lcd_device &>(*device).set_int_hblank_callback(DEVCB_##_devcb); + +#define MCFG_GBA_LCD_INT_VBLANK(_devcb) \ + downcast<gba_lcd_device &>(*device).set_int_vblank_callback(DEVCB_##_devcb); + +#define MCFG_GBA_LCD_INT_VCOUNT(_devcb) \ + downcast<gba_lcd_device &>(*device).set_int_vcount_callback(DEVCB_##_devcb); + +#define MCFG_GBA_LCD_DMA_HBLANK(_devcb) \ + downcast<gba_lcd_device &>(*device).set_dma_hblank_callback(DEVCB_##_devcb); + +#define MCFG_GBA_LCD_DMA_VBLANK(_devcb) \ + downcast<gba_lcd_device &>(*device).set_dma_vblank_callback(DEVCB_##_devcb); + + +//************************************************************************** // TYPE DEFINITIONS //************************************************************************** @@ -76,11 +99,11 @@ public: TIMER_CALLBACK_MEMBER(perform_hbl); TIMER_CALLBACK_MEMBER(perform_scan); - auto int_hblank_callback() { return m_int_hblank_cb.bind(); } - auto int_vblank_callback() { return m_int_vblank_cb.bind(); } - auto int_vcount_callback() { return m_int_vcount_cb.bind(); } - auto dma_hblank_callback() { return m_dma_hblank_cb.bind(); } - auto dma_vblank_callback() { return m_dma_vblank_cb.bind(); } + template <class Object> devcb_base &set_int_hblank_callback(Object &&cb) { return m_int_hblank_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_int_vblank_callback(Object &&cb) { return m_int_vblank_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_int_vcount_callback(Object &&cb) { return m_int_vcount_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_dma_hblank_callback(Object &&cb) { return m_dma_hblank_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_dma_vblank_callback(Object &&cb) { return m_dma_vblank_cb.set_callback(std::forward<Object>(cb)); } protected: // device-level overrides diff --git a/src/devices/video/hd44102.h b/src/devices/video/hd44102.h index 1688a502441..a484ce77478 100644 --- a/src/devices/video/hd44102.h +++ b/src/devices/video/hd44102.h @@ -12,6 +12,19 @@ #pragma once + + +///************************************************************************* +// INTERFACE CONFIGURATION MACROS +///************************************************************************* + +#define MCFG_HD44102_ADD(_tag, _screen_tag, _sx, _sy) \ + MCFG_DEVICE_ADD(_tag, HD44102, 0) \ + MCFG_VIDEO_SET_SCREEN(_screen_tag) \ + downcast<hd44102_device &>(*device).set_offsets(_sx, _sy); + + + ///************************************************************************* // TYPE DEFINITIONS ///************************************************************************* @@ -23,14 +36,6 @@ class hd44102_device : public device_t, { public: // construction/destruction - template <typename T> - hd44102_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&screen_tag, int sx, int sy) - :hd44102_device(mconfig, tag, owner, clock) - { - set_screen(std::forward<T>(screen_tag)); - set_offsets(sx, sy); - } - hd44102_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); // inline configuration helpers diff --git a/src/devices/video/hd44780.h b/src/devices/video/hd44780.h index a6572536cf1..65544ef6828 100644 --- a/src/devices/video/hd44780.h +++ b/src/devices/video/hd44780.h @@ -12,6 +12,18 @@ #pragma once +#define MCFG_HD44780_ADD( _tag ) \ + MCFG_DEVICE_ADD( _tag, HD44780, 0 ) + +#define MCFG_KS0066_F05_ADD( _tag ) \ + MCFG_DEVICE_ADD( _tag, KS0066_F05, 0 ) + +#define MCFG_HD44780_LCD_SIZE(_lines, _chars) \ + downcast<hd44780_device &>(*device).set_lcd_size(_lines, _chars); + +#define MCFG_HD44780_PIXEL_UPDATE_CB(_class, _method) \ + downcast<hd44780_device &>(*device).set_pixel_update_cb(&_class::_method, #_class "::" #_method, this); + //************************************************************************** // TYPE DEFINITIONS //************************************************************************** diff --git a/src/devices/video/hd61830.cpp b/src/devices/video/hd61830.cpp index a608c096b1e..7d0427ff2ba 100644 --- a/src/devices/video/hd61830.cpp +++ b/src/devices/video/hd61830.cpp @@ -27,8 +27,7 @@ decltype(HD61830) HD61830B = HD61830; // default address map void hd61830_device::hd61830(address_map &map) { - if (!has_configured_map(0)) - map(0x0000, 0xffff).ram(); + map(0x0000, 0xffff).ram(); } @@ -85,7 +84,7 @@ hd61830_device::hd61830_device(const machine_config &mconfig, const char *tag, d m_cac(0), m_blink(0), m_cursor(0), - m_space_config("videoram", ENDIANNESS_LITTLE, 8, 16, 0, address_map_constructor(FUNC(hd61830_device::hd61830), this)), + m_space_config("videoram", ENDIANNESS_LITTLE, 8, 16, 0, address_map_constructor(), address_map_constructor(FUNC(hd61830_device::hd61830), this)), m_char_rom(*this, "hd61830") { } diff --git a/src/devices/video/hd61830.h b/src/devices/video/hd61830.h index f8579081ac1..ab4278f9d89 100644 --- a/src/devices/video/hd61830.h +++ b/src/devices/video/hd61830.h @@ -12,6 +12,17 @@ #pragma once + + +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define MCFG_HD61830_RD_CALLBACK(_read) \ + downcast<hd61830_device &>(*device).set_rd_rd_callback(DEVCB_##_read); + + + //************************************************************************** // TYPE DEFINITIONS //************************************************************************** @@ -26,7 +37,7 @@ public: // construction/destruction hd61830_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - auto rd_rd_callback() { return m_read_rd.bind(); } + template <class Object> devcb_base &set_rd_rd_callback(Object &&cb) { return m_read_rd.set_callback(std::forward<Object>(cb)); } DECLARE_READ8_MEMBER( status_r ); DECLARE_WRITE8_MEMBER( control_w ); diff --git a/src/devices/video/hd63484.h b/src/devices/video/hd63484.h index 73a321fc117..885761d211b 100644 --- a/src/devices/video/hd63484.h +++ b/src/devices/video/hd63484.h @@ -13,8 +13,30 @@ #pragma once + +/*************************************************************************** + DEVICE CONFIGURATION MACROS +***************************************************************************/ + +#define MCFG_HD63484_ADD(_tag, _clock, _map) \ + MCFG_DEVICE_ADD(_tag, HD63484, _clock) \ + MCFG_DEVICE_ADDRESS_MAP(0, _map) + +#define MCFG_HD63484_ADDRESS_MAP(_map) \ + MCFG_DEVICE_ADDRESS_MAP(0, _map) + +#define MCFG_HD63484_DISPLAY_CALLBACK_OWNER(_class, _method) \ + downcast<hd63484_device &>(*device).set_display_callback(hd63484_device::display_delegate(&_class::_method, #_class "::" #_method, this)); + +#define MCFG_HD63484_AUTO_CONFIGURE_SCREEN(_val) \ + downcast<hd63484_device &>(*device).set_auto_configure_screen(_val); + #define HD63484_DISPLAY_PIXELS_MEMBER(_name) void _name(bitmap_ind16 &bitmap, const rectangle &cliprect, int y, int x, uint16_t data) +#define MCFG_HD63484_EXTERNAL_SKEW(_val) \ + downcast<hd63484_device &>(*device).set_external_skew(_val); + + // ======================> hd63484_device class hd63484_device : public device_t, @@ -27,7 +49,7 @@ public: // construction/destruction hd63484_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - template <typename... T> void set_display_callback(T &&... args) { m_display_cb = display_delegate(std::forward<T>(args)...); } + template <typename Object> void set_display_callback(Object &&cb) { m_display_cb = std::forward<Object>(cb); } void set_auto_configure_screen(bool auto_configure_screen) { m_auto_configure_screen = auto_configure_screen; } void set_external_skew(int skew) { m_external_skew = skew; } diff --git a/src/devices/video/hd66421.cpp b/src/devices/video/hd66421.cpp index bb03b80252e..63283f498b0 100644 --- a/src/devices/video/hd66421.cpp +++ b/src/devices/video/hd66421.cpp @@ -74,8 +74,7 @@ DEFINE_DEVICE_TYPE(HD66421, hd66421_device, "hd66421", "Hitachi HD66421 LCD Cont // default address map void hd66421_device::hd66421(address_map &map) { - if (!has_configured_map(0)) - map(0x0000, HD66421_RAM_SIZE).ram(); + map(0x0000, HD66421_RAM_SIZE).ram(); } //------------------------------------------------- @@ -126,7 +125,7 @@ inline void hd66421_device::writebyte(offs_t address, uint8_t data) hd66421_device::hd66421_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, HD66421, tag, owner, clock) , device_memory_interface(mconfig, *this) - , m_space_config("videoram", ENDIANNESS_LITTLE, 8, 17, 0, address_map_constructor(FUNC(hd66421_device::hd66421), this)) + , m_space_config("videoram", ENDIANNESS_LITTLE, 8, 17, 0, address_map_constructor(), address_map_constructor(FUNC(hd66421_device::hd66421), this)) , m_cmd(0) , m_x(0) , m_y(0) diff --git a/src/devices/video/hlcd0515.cpp b/src/devices/video/hlcd0515.cpp index 87abf50bc0e..b7730332bfd 100644 --- a/src/devices/video/hlcd0515.cpp +++ b/src/devices/video/hlcd0515.cpp @@ -26,23 +26,27 @@ DEFINE_DEVICE_TYPE(HLCD0530, hlcd0530_device, "hlcd0530", "Hughes HLCD 0530 LCD // constructor //------------------------------------------------- -hlcd0515_device::hlcd0515_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 colmax) : - device_t(mconfig, type, tag, owner, clock), - m_colmax(colmax), - m_write_cols(*this), m_write_data(*this) -{ } +hlcd0515_device::hlcd0515_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 colmax) + : device_t(mconfig, type, tag, owner, clock) + , m_colmax(colmax) + , m_write_cols(*this), m_write_data(*this) +{ +} -hlcd0515_device::hlcd0515_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : - hlcd0515_device(mconfig, HLCD0515, tag, owner, clock, 25) -{ } +hlcd0515_device::hlcd0515_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : hlcd0515_device(mconfig, HLCD0515, tag, owner, clock, 25) +{ +} -hlcd0569_device::hlcd0569_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : - hlcd0515_device(mconfig, HLCD0569, tag, owner, clock, 24) -{ } +hlcd0569_device::hlcd0569_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : hlcd0515_device(mconfig, HLCD0569, tag, owner, clock, 24) +{ +} -hlcd0530_device::hlcd0530_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : - hlcd0515_device(mconfig, HLCD0530, tag, owner, clock, 24) -{ } +hlcd0530_device::hlcd0530_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : hlcd0515_device(mconfig, HLCD0530, tag, owner, clock, 24) +{ +} @@ -62,7 +66,7 @@ void hlcd0515_device::device_start() // zerofill m_cs = 0; - m_clk = 0; + m_pclock = 0; m_data = 0; m_count = 0; m_control = 0; @@ -75,7 +79,7 @@ void hlcd0515_device::device_start() // register for savestates save_item(NAME(m_cs)); - save_item(NAME(m_clk)); + save_item(NAME(m_pclock)); save_item(NAME(m_data)); save_item(NAME(m_count)); save_item(NAME(m_control)); @@ -153,12 +157,12 @@ void hlcd0515_device::clock_data(int col) } -WRITE_LINE_MEMBER(hlcd0515_device::clock_w) +WRITE_LINE_MEMBER(hlcd0515_device::write_clock) { state = (state) ? 1 : 0; // clock/shift data on falling edge - if (!m_cs && !state && m_clk) + if (!m_cs && !state && m_pclock) { if (m_count < 5) { @@ -175,11 +179,11 @@ WRITE_LINE_MEMBER(hlcd0515_device::clock_w) m_count++; } - m_clk = state; + m_pclock = state; } -WRITE_LINE_MEMBER(hlcd0515_device::cs_w) +WRITE_LINE_MEMBER(hlcd0515_device::write_cs) { state = (state) ? 1 : 0; diff --git a/src/devices/video/hlcd0515.h b/src/devices/video/hlcd0515.h index 1108890a1fb..5018978226d 100644 --- a/src/devices/video/hlcd0515.h +++ b/src/devices/video/hlcd0515.h @@ -50,9 +50,9 @@ public: auto write_cols() { return m_write_cols.bind(); } // COL/ROW pins (offset for ROW) auto write_data() { return m_write_data.bind(); } // DATA OUT pin, don't use on HLCD0569 - DECLARE_WRITE_LINE_MEMBER(clock_w); - DECLARE_WRITE_LINE_MEMBER(cs_w); - DECLARE_WRITE_LINE_MEMBER(data_w) { m_data = (state) ? 1 : 0; } + DECLARE_WRITE_LINE_MEMBER(write_clock); + DECLARE_WRITE_LINE_MEMBER(write_cs); + DECLARE_WRITE_LINE_MEMBER(write_data) { m_data = (state) ? 1 : 0; } protected: hlcd0515_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 colmax); @@ -67,7 +67,7 @@ protected: const u8 m_colmax; // number of column pins int m_cs; // input pin state - int m_clk; // " + int m_pclock; // " int m_data; // " int m_count; u8 m_control; diff --git a/src/devices/video/hlcd0538.cpp b/src/devices/video/hlcd0538.cpp index 12a188d07a0..c409e6be528 100644 --- a/src/devices/video/hlcd0538.cpp +++ b/src/devices/video/hlcd0538.cpp @@ -23,18 +23,22 @@ DEFINE_DEVICE_TYPE(HLCD0539, hlcd0539_device, "hlcd0539", "Hughes HLCD 0539 LCD // constructor //------------------------------------------------- -hlcd0538_device::hlcd0538_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock) : - device_t(mconfig, type, tag, owner, clock), - m_write_cols(*this), m_write_interrupt(*this) -{ } +hlcd0538_device::hlcd0538_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock) + : device_t(mconfig, type, tag, owner, clock) + , m_write_cols(*this), m_write_interrupt(*this) +{ +} + +hlcd0538_device::hlcd0538_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : hlcd0538_device(mconfig, HLCD0538, tag, owner, clock) +{ +} -hlcd0538_device::hlcd0538_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : - hlcd0538_device(mconfig, HLCD0538, tag, owner, clock) -{ } +hlcd0539_device::hlcd0539_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : hlcd0538_device(mconfig, HLCD0539, tag, owner, clock) +{ +} -hlcd0539_device::hlcd0539_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : - hlcd0538_device(mconfig, HLCD0539, tag, owner, clock) -{ } //------------------------------------------------- @@ -61,11 +65,12 @@ void hlcd0538_device::device_start() } + //------------------------------------------------- // handlers //------------------------------------------------- -WRITE_LINE_MEMBER(hlcd0538_device::clk_w) +WRITE_LINE_MEMBER(hlcd0538_device::write_clk) { state = (state) ? 1 : 0; @@ -76,7 +81,7 @@ WRITE_LINE_MEMBER(hlcd0538_device::clk_w) m_clk = state; } -WRITE_LINE_MEMBER(hlcd0538_device::lcd_w) +WRITE_LINE_MEMBER(hlcd0538_device::write_lcd) { state = (state) ? 1 : 0; diff --git a/src/devices/video/hlcd0538.h b/src/devices/video/hlcd0538.h index bc1a78d16fc..187523e1076 100644 --- a/src/devices/video/hlcd0538.h +++ b/src/devices/video/hlcd0538.h @@ -43,15 +43,15 @@ class hlcd0538_device : public device_t { public: - hlcd0538_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0); + hlcd0538_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); // configuration helpers - auto write_cols() { return m_write_cols.bind(); } // C/R pins (0538: d0-d7 for rows) - auto write_interrupt() { return m_write_interrupt.bind(); } // INTERRUPT pin + auto write_cols_callback() { return m_write_cols.bind(); } // C/R pins (0538: d0-d7 for rows) + auto write_interrupt_callback() { return m_write_interrupt.bind(); } // INTERRUPT pin - DECLARE_WRITE_LINE_MEMBER(clk_w); - DECLARE_WRITE_LINE_MEMBER(lcd_w); - DECLARE_WRITE_LINE_MEMBER(data_w) { m_data = (state) ? 1 : 0; } + DECLARE_WRITE_LINE_MEMBER(write_clk); + DECLARE_WRITE_LINE_MEMBER(write_lcd); + DECLARE_WRITE_LINE_MEMBER(write_data) { m_data = (state) ? 1 : 0; } protected: hlcd0538_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock); diff --git a/src/devices/video/huc6202.h b/src/devices/video/huc6202.h index 3ff175f0ece..a3e1a47b519 100644 --- a/src/devices/video/huc6202.h +++ b/src/devices/video/huc6202.h @@ -12,24 +12,61 @@ #pragma once +#define MCFG_HUC6202_NEXT_PIXEL_0_CB(_devcb) \ + downcast<huc6202_device &>(*device).set_next_pixel_0_callback(DEVCB_##_devcb); + +#define MCFG_HUC6202_TIME_TIL_NEXT_EVENT_0_CB(_devcb) \ + downcast<huc6202_device &>(*device).set_time_til_next_event_0_callback(DEVCB_##_devcb); + +#define MCFG_HUC6202_VSYNC_CHANGED_0_CB(_devcb) \ + downcast<huc6202_device &>(*device).set_vsync_changed_0_callback(DEVCB_##_devcb); + +#define MCFG_HUC6202_HSYNC_CHANGED_0_CB(_devcb) \ + downcast<huc6202_device &>(*device).set_hsync_changed_0_callback(DEVCB_##_devcb); + +#define MCFG_HUC6202_READ_0_CB(_devcb) \ + downcast<huc6202_device &>(*device).set_read_0_callback(DEVCB_##_devcb); + +#define MCFG_HUC6202_WRITE_0_CB(_devcb) \ + downcast<huc6202_device &>(*device).set_write_0_callback(DEVCB_##_devcb); + +#define MCFG_HUC6202_NEXT_PIXEL_1_CB(_devcb) \ + downcast<huc6202_device &>(*device).set_next_pixel_1_callback(DEVCB_##_devcb); + +#define MCFG_HUC6202_TIME_TIL_NEXT_EVENT_1_CB(_devcb) \ + downcast<huc6202_device &>(*device).set_time_til_next_event_1_callback(DEVCB_##_devcb); + +#define MCFG_HUC6202_VSYNC_CHANGED_1_CB(_devcb) \ + downcast<huc6202_device &>(*device).set_vsync_changed_1_callback(DEVCB_##_devcb); + +#define MCFG_HUC6202_HSYNC_CHANGED_1_CB(_devcb) \ + downcast<huc6202_device &>(*device).set_hsync_changed_1_callback(DEVCB_##_devcb); + +#define MCFG_HUC6202_READ_1_CB(_devcb) \ + downcast<huc6202_device &>(*device).set_read_1_callback(DEVCB_##_devcb); + +#define MCFG_HUC6202_WRITE_1_CB(_devcb) \ + downcast<huc6202_device &>(*device).set_write_1_callback(DEVCB_##_devcb); + + class huc6202_device : public device_t { public: // construction/destruction huc6202_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - auto next_pixel_0_callback() { return m_next_pixel_0_cb.bind(); } - auto time_til_next_event_0_callback() { return m_time_til_next_event_0_cb.bind(); } - auto vsync_changed_0_callback() { return m_vsync_changed_0_cb.bind(); } - auto hsync_changed_0_callback() { return m_hsync_changed_0_cb.bind(); } - auto read_0_callback() { return m_read_0_cb.bind(); } - auto write_0_callback() { return m_write_0_cb.bind(); } - auto next_pixel_1_callback() { return m_next_pixel_1_cb.bind(); } - auto time_til_next_event_1_callback() { return m_time_til_next_event_1_cb.bind(); } - auto vsync_changed_1_callback() { return m_vsync_changed_1_cb.bind(); } - auto hsync_changed_1_callback() { return m_hsync_changed_1_cb.bind(); } - auto read_1_callback() { return m_read_1_cb.bind(); } - auto write_1_callback() { return m_write_1_cb.bind(); } + template <class Object> devcb_base &set_next_pixel_0_callback(Object &&cb) { return m_next_pixel_0_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_time_til_next_event_0_callback(Object &&cb) { return m_time_til_next_event_0_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_vsync_changed_0_callback(Object &&cb) { return m_vsync_changed_0_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_hsync_changed_0_callback(Object &&cb) { return m_hsync_changed_0_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_read_0_callback(Object &&cb) { return m_read_0_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_write_0_callback(Object &&cb) { return m_write_0_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_next_pixel_1_callback(Object &&cb) { return m_next_pixel_1_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_time_til_next_event_1_callback(Object &&cb) { return m_time_til_next_event_1_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_vsync_changed_1_callback(Object &&cb) { return m_vsync_changed_1_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_hsync_changed_1_callback(Object &&cb) { return m_hsync_changed_1_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_read_1_callback(Object &&cb) { return m_read_1_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_write_1_callback(Object &&cb) { return m_write_1_cb.set_callback(std::forward<Object>(cb)); } DECLARE_READ8_MEMBER( read ); DECLARE_WRITE8_MEMBER( write ); diff --git a/src/devices/video/huc6260.h b/src/devices/video/huc6260.h index 695f60c9a05..8737d0432cf 100644 --- a/src/devices/video/huc6260.h +++ b/src/devices/video/huc6260.h @@ -12,6 +12,19 @@ #pragma once +#define MCFG_HUC6260_NEXT_PIXEL_DATA_CB(_devcb) \ + downcast<huc6260_device &>(*device).set_next_pixel_data_callback(DEVCB_##_devcb); + +#define MCFG_HUC6260_TIME_TIL_NEXT_EVENT_CB(_devcb) \ + downcast<huc6260_device &>(*device).set_time_til_next_event_callback(DEVCB_##_devcb); + +#define MCFG_HUC6260_VSYNC_CHANGED_CB(_devcb) \ + downcast<huc6260_device &>(*device).set_vsync_changed_callback(DEVCB_##_devcb); + +#define MCFG_HUC6260_HSYNC_CHANGED_CB(_devcb) \ + downcast<huc6260_device &>(*device).set_hsync_changed_callback(DEVCB_##_devcb); + + class huc6260_device : public device_t, public device_palette_interface, public device_video_interface @@ -27,6 +40,10 @@ public: // construction/destruction huc6260_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + template <class Object> devcb_base &set_next_pixel_data_callback(Object &&cb) { return m_next_pixel_data_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_time_til_next_event_callback(Object &&cb) { return m_time_til_next_event_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_vsync_changed_callback(Object &&cb) { return m_vsync_changed_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_hsync_changed_callback(Object &&cb) { return m_hsync_changed_cb.set_callback(std::forward<Object>(cb)); } auto next_pixel_data() { return m_next_pixel_data_cb.bind(); } auto time_til_next_event() { return m_time_til_next_event_cb.bind(); } auto vsync_changed() { return m_vsync_changed_cb.bind(); } diff --git a/src/devices/video/huc6261.h b/src/devices/video/huc6261.h index 33efd71fcd9..721ef88cc3a 100644 --- a/src/devices/video/huc6261.h +++ b/src/devices/video/huc6261.h @@ -15,6 +15,16 @@ #include "video/huc6272.h" +#define MCFG_HUC6261_VDC1(_tag) \ + downcast<huc6261_device &>(*device).set_vdc1_tag(_tag); + +#define MCFG_HUC6261_VDC2(_tag) \ + downcast<huc6261_device &>(*device).set_vdc2_tag(_tag); + +#define MCFG_HUC6261_KING(_tag) \ + downcast<huc6261_device &>(*device).set_king_tag(_tag); + + class huc6261_device : public device_t, public device_video_interface { diff --git a/src/devices/video/huc6270.h b/src/devices/video/huc6270.h index cd3a9f7acee..2ee9e0d6259 100644 --- a/src/devices/video/huc6270.h +++ b/src/devices/video/huc6270.h @@ -12,6 +12,12 @@ #pragma once +#define MCFG_HUC6270_VRAM_SIZE(_size) \ + downcast<huc6270_device &>(*device).set_vram_size(_size); + +#define MCFG_HUC6270_IRQ_CHANGED_CB(_devcb) \ + downcast<huc6270_device &>(*device).set_irq_changed_callback(DEVCB_##_devcb); + class huc6270_device : public device_t { public: @@ -19,6 +25,7 @@ public: huc6270_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); void set_vram_size(uint32_t vram_size) { m_vram_size = vram_size; } + template <class Object> devcb_base &set_irq_changed_callback(Object &&cb) { return m_irq_changed_cb.set_callback(std::forward<Object>(cb)); } auto irq() { return m_irq_changed_cb.bind(); } DECLARE_READ8_MEMBER( read ); diff --git a/src/devices/video/huc6271.cpp b/src/devices/video/huc6271.cpp index 9f90ba8c3b3..7af976a820a 100644 --- a/src/devices/video/huc6271.cpp +++ b/src/devices/video/huc6271.cpp @@ -29,14 +29,13 @@ DEFINE_DEVICE_TYPE(HUC6271, huc6271_device, "huc6271", "Hudson HuC6271 \"Rainbow void huc6271_device::data_map(address_map &map) { - if (!has_configured_map(0)) - map(0x000000, 0x0fffff).ram(); + map(0x000000, 0x0fffff).ram(); } huc6271_device::huc6271_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, HUC6271, tag, owner, clock) , device_memory_interface(mconfig, *this) - , m_data_space_config("data", ENDIANNESS_LITTLE, 32, 32, 0, address_map_constructor(FUNC(huc6271_device::data_map), this)) + , m_data_space_config("data", ENDIANNESS_LITTLE, 32, 32, 0, address_map_constructor(), address_map_constructor(FUNC(huc6271_device::data_map), this)) { } diff --git a/src/devices/video/huc6272.cpp b/src/devices/video/huc6272.cpp index 0fe5ec52159..c6e94bb9810 100644 --- a/src/devices/video/huc6272.cpp +++ b/src/devices/video/huc6272.cpp @@ -25,17 +25,13 @@ DEFINE_DEVICE_TYPE(HUC6272, huc6272_device, "huc6272", "Hudson HuC6272 \"King\"" void huc6272_device::microprg_map(address_map &map) { - if (!has_configured_map(0)) - map(0x00, 0x0f).ram().share("microprg_ram"); + map(0x00, 0x0f).ram().share("microprg_ram"); } void huc6272_device::kram_map(address_map &map) { - if (!has_configured_map(1)) - { - map(0x000000, 0x0fffff).ram().share("kram_page0"); - map(0x100000, 0x1fffff).ram().share("kram_page1"); - } + map(0x000000, 0x0fffff).ram().share("kram_page0"); + map(0x100000, 0x1fffff).ram().share("kram_page1"); } @@ -53,8 +49,8 @@ huc6272_device::huc6272_device(const machine_config &mconfig, const char *tag, d m_huc6271(*this, finder_base::DUMMY_TAG), m_cdda_l(*this, "cdda_l"), m_cdda_r(*this, "cdda_r"), - m_program_space_config("microprg", ENDIANNESS_LITTLE, 16, 4, 0, address_map_constructor(FUNC(huc6272_device::microprg_map), this)), - m_data_space_config("kram", ENDIANNESS_LITTLE, 32, 21, 0, address_map_constructor(FUNC(huc6272_device::kram_map), this)), + m_program_space_config("microprg", ENDIANNESS_LITTLE, 16, 4, 0, address_map_constructor(), address_map_constructor(FUNC(huc6272_device::microprg_map), this)), + m_data_space_config("kram", ENDIANNESS_LITTLE, 32, 21, 0, address_map_constructor(), address_map_constructor(FUNC(huc6272_device::kram_map), this)), m_microprg_ram(*this, "microprg_ram"), m_kram_page0(*this, "kram_page0"), m_kram_page1(*this, "kram_page1"), diff --git a/src/devices/video/huc6272.h b/src/devices/video/huc6272.h index 8d7f0583600..cd931a1dae9 100644 --- a/src/devices/video/huc6272.h +++ b/src/devices/video/huc6272.h @@ -18,6 +18,17 @@ //************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define MCFG_HUC6272_IRQ_CHANGED_CB(cb) \ + downcast<huc6272_device &>(*device).set_irq_changed_callback((DEVCB_##cb)); + +#define MCFG_HUC6272_RAINBOW(tag) \ + downcast<huc6272_device &>(*device).set_rainbow_tag((tag)); + + +//************************************************************************** // TYPE DEFINITIONS //************************************************************************** @@ -30,7 +41,7 @@ public: // construction/destruction huc6272_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - auto irq_changed_callback() { return m_irq_changed_cb.bind(); } + template <class Object> devcb_base &set_irq_changed_callback(Object &&cb) { return m_irq_changed_cb.set_callback(std::forward<Object>(cb)); } template <typename T> void set_rainbow_tag(T &&tag) { m_huc6271.set_tag(std::forward<T>(tag)); } // I/O operations diff --git a/src/devices/video/i8244.cpp b/src/devices/video/i8244.cpp index a2d142b0410..639174a84b8 100644 --- a/src/devices/video/i8244.cpp +++ b/src/devices/video/i8244.cpp @@ -130,22 +130,6 @@ i8245_device::i8245_device(const machine_config &mconfig, const char *tag, devic //------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void i8244_device::device_config_complete() -{ - if (!has_screen()) - return; - - if (!screen().refresh_attoseconds()) - screen().set_raw(clock(), LINE_CLOCKS, START_ACTIVE_SCAN, END_ACTIVE_SCAN, m_screen_lines, START_Y, START_Y + SCREEN_HEIGHT); -} - - -//------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- diff --git a/src/devices/video/i8244.h b/src/devices/video/i8244.h index 2a46163073b..0bf0174cdba 100644 --- a/src/devices/video/i8244.h +++ b/src/devices/video/i8244.h @@ -17,6 +17,25 @@ /*************************************************************************** + DEVICE CONFIGURATION MACROS +***************************************************************************/ + +#define MCFG_I8244_ADD(_tag, _clock, _screen_tag, _irq_cb, _postprocess_cb) \ + MCFG_DEVICE_ADD(_tag, I8244, _clock) \ + MCFG_VIDEO_SET_SCREEN(_screen_tag) \ + MCFG_I8244_IRQ_CB(_irq_cb) \ + MCFG_I8244_POSTPROCESS_CB(_postprocess_cb) +#define MCFG_I8244_IRQ_CB(_devcb) \ + downcast<i8244_device &>(*device).set_irq_cb(DEVCB_##_devcb); +#define MCFG_I8244_POSTPROCESS_CB(_devcb) \ + downcast<i8244_device &>(*device).set_postprocess_cb(DEVCB_##_devcb); +#define MCFG_I8245_ADD(_tag, _clock, _screen_tag, _irq_cb, _postprocess_cb) \ + MCFG_DEVICE_ADD(_tag, I8245, _clock) \ + MCFG_VIDEO_SET_SCREEN(_screen_tag) \ + MCFG_I8244_IRQ_CB(_irq_cb) \ + MCFG_I8244_POSTPROCESS_CB(_postprocess_cb ) + +/*************************************************************************** TYPE DEFINITIONS ***************************************************************************/ @@ -32,8 +51,8 @@ public: i8244_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); // configuration helpers - auto irq_cb() { return m_irq_func.bind(); } - auto postprocess_cb() { return m_postprocess_func.bind(); } + template <class Object> devcb_base &set_irq_cb(Object &&cb) { return m_irq_func.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_postprocess_cb(Object &&cb) { return m_postprocess_func.set_callback(std::forward<Object>(cb)); } DECLARE_READ8_MEMBER(read); DECLARE_WRITE8_MEMBER(write); @@ -90,7 +109,6 @@ protected: i8244_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, int lines); // device-level overrides - virtual void device_config_complete() override; virtual void device_start() override; virtual void device_reset() override; virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; diff --git a/src/devices/video/i8275.h b/src/devices/video/i8275.h index f5d6b3633bc..44bede3ace4 100644 --- a/src/devices/video/i8275.h +++ b/src/devices/video/i8275.h @@ -44,6 +44,26 @@ #define I8275_DRAW_CHARACTER_MEMBER(_name) void _name(bitmap_rgb32 &bitmap, int x, int y, uint8_t linecount, uint8_t charcode, uint8_t lineattr, uint8_t lten, uint8_t rvv, uint8_t vsp, uint8_t gpa, uint8_t hlgt) +#define MCFG_I8275_CHARACTER_WIDTH(_value) \ + downcast<i8275_device &>(*device).set_character_width(_value); + +#define MCFG_I8275_DRAW_CHARACTER_CALLBACK_OWNER(_class, _method) \ + downcast<i8275_device &>(*device).set_display_callback(&_class::_method, #_class "::" #_method, this); + +#define MCFG_I8275_DRQ_CALLBACK(_write) \ + downcast<i8275_device &>(*device).set_drq_wr_callback(DEVCB_##_write); + +#define MCFG_I8275_IRQ_CALLBACK(_write) \ + downcast<i8275_device &>(*device).set_irq_wr_callback(DEVCB_##_write); + +#define MCFG_I8275_HRTC_CALLBACK(_write) \ + downcast<i8275_device &>(*device).set_hrtc_wr_callback(DEVCB_##_write); + +#define MCFG_I8275_VRTC_CALLBACK(_write) \ + downcast<i8275_device &>(*device).set_vrtc_wr_callback(DEVCB_##_write); + + + //************************************************************************** // TYPE DEFINITIONS //************************************************************************** @@ -76,6 +96,10 @@ public: set_display_callback(draw_character_delegate(callback, name, nullptr, static_cast<FunctionClass *>(nullptr))); } + template <class Object> devcb_base &set_drq_wr_callback(Object &&cb) { return m_write_drq.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_irq_wr_callback(Object &&cb) { return m_write_irq.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_hrtc_wr_callback(Object &&cb) { return m_write_hrtc.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_vrtc_wr_callback(Object &&cb) { return m_write_vrtc.set_callback(std::forward<Object>(cb)); } auto drq_wr_callback() { return m_write_drq.bind(); } auto irq_wr_callback() { return m_write_irq.bind(); } auto hrtc_wr_callback() { return m_write_hrtc.bind(); } diff --git a/src/devices/video/ims_cvc.cpp b/src/devices/video/ims_cvc.cpp index 14ae0901769..60b76604ef5 100644 --- a/src/devices/video/ims_cvc.cpp +++ b/src/devices/video/ims_cvc.cpp @@ -10,7 +10,7 @@ * http://bitsavers.org/components/inmos/graphics/72-TRN-204-01_Graphics_Databook_Second_Edition_1990.pdf * * TODO - * - cursor + * - everything (skeleton only) */ #include "emu.h" @@ -18,10 +18,7 @@ #include "screen.h" -#define LOG_GENERAL (1U << 0) -#define LOG_CONFIG (1U << 1) - -//#define VERBOSE (LOG_GENERAL|LOG_CONFIG) +#define VERBOSE 0 #include "logmacro.h" DEFINE_DEVICE_TYPE(G300, g300_device, "g300", "INMOS G300 Colour Video Controller") @@ -30,9 +27,9 @@ DEFINE_DEVICE_TYPE(G364, g364_device, "g364", "INMOS G364 Colour Video Controlle ims_cvc_device::ims_cvc_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, type, tag, owner, clock) + , device_memory_interface(mconfig, *this) , device_palette_interface(mconfig, *this) - , m_screen(*this, finder_base::DUMMY_TAG) - , m_vram(*this, finder_base::DUMMY_TAG) + , m_space_config("shared", ENDIANNESS_LITTLE, 32, 24) { } @@ -43,12 +40,11 @@ g300_device::g300_device(const machine_config &mconfig, const char *tag, device_ g332_device::g332_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : ims_cvc_device(mconfig, type, tag, owner, clock) - , m_microport(*this, "microport") { } g332_device::g332_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : g332_device(mconfig, G332, tag, owner, clock) + : ims_cvc_device(mconfig, G332, tag, owner, clock) { } @@ -57,9 +53,11 @@ g364_device::g364_device(const machine_config &mconfig, const char *tag, device_ { } -void g332_device::device_add_mconfig(machine_config &config) +device_memory_interface::space_config_vector ims_cvc_device::memory_space_config() const { - ADDRESS_MAP_BANK(config, m_microport).set_map(&g332_device::microport_map).set_options(ENDIANNESS_LITTLE, 32, 32); + return space_config_vector{ + std::make_pair(0, &m_space_config) + }; } void g300_device::map(address_map &map) @@ -71,18 +69,18 @@ void g300_device::map(address_map &map) map(0x000 << shift, (0x0ff << shift) | 0x3).rw(FUNC(g300_device::colour_palette_r), FUNC(g300_device::colour_palette_w)); // data path registers - map(0x121 << shift, (0x121 << shift) | 0x3).rw(FUNC(g300_device::halfsync_r), FUNC(g300_device::halfsync_w)); - map(0x122 << shift, (0x122 << shift) | 0x3).rw(FUNC(g300_device::backporch_r), FUNC(g300_device::backporch_w)); - map(0x123 << shift, (0x123 << shift) | 0x3).rw(FUNC(g300_device::display_r), FUNC(g300_device::display_w)); - map(0x124 << shift, (0x124 << shift) | 0x3).rw(FUNC(g300_device::shortdisplay_r), FUNC(g300_device::shortdisplay_w)); - map(0x125 << shift, (0x125 << shift) | 0x3).rw(FUNC(g300_device::broadpulse_r), FUNC(g300_device::broadpulse_w)); - map(0x126 << shift, (0x126 << shift) | 0x3).rw(FUNC(g300_device::vsync_r), FUNC(g300_device::vsync_w)); - map(0x127 << shift, (0x127 << shift) | 0x3).rw(FUNC(g300_device::vblank_r), FUNC(g300_device::vblank_w)); - map(0x128 << shift, (0x128 << shift) | 0x3).rw(FUNC(g300_device::vdisplay_r), FUNC(g300_device::vdisplay_w)); - map(0x129 << shift, (0x129 << shift) | 0x3).rw(FUNC(g300_device::linetime_r), FUNC(g300_device::linetime_w)); - map(0x12a << shift, (0x12a << shift) | 0x3).rw(FUNC(g300_device::tos_r), FUNC(g300_device::tos_w)); - map(0x12b << shift, (0x12b << shift) | 0x3).rw(FUNC(g300_device::meminit_r), FUNC(g300_device::meminit_w)); - map(0x12c << shift, (0x12c << shift) | 0x3).rw(FUNC(g300_device::transferdelay_r), FUNC(g300_device::transferdelay_w)); + map(0x121, (0x121 << shift) | 0x3).rw(FUNC(g300_device::halfsync_r), FUNC(g300_device::halfsync_w)); + map(0x122, (0x122 << shift) | 0x3).rw(FUNC(g300_device::backporch_r), FUNC(g300_device::backporch_w)); + map(0x123, (0x123 << shift) | 0x3).rw(FUNC(g300_device::display_r), FUNC(g300_device::display_w)); + map(0x124, (0x124 << shift) | 0x3).rw(FUNC(g300_device::shortdisplay_r), FUNC(g300_device::shortdisplay_w)); + map(0x125, (0x125 << shift) | 0x3).rw(FUNC(g300_device::broadpulse_r), FUNC(g300_device::broadpulse_w)); + map(0x126, (0x126 << shift) | 0x3).rw(FUNC(g300_device::vsync_r), FUNC(g300_device::vsync_w)); + map(0x127, (0x127 << shift) | 0x3).rw(FUNC(g300_device::vblank_r), FUNC(g300_device::vblank_w)); + map(0x128, (0x128 << shift) | 0x3).rw(FUNC(g300_device::vdisplay_r), FUNC(g300_device::vdisplay_w)); + map(0x129, (0x129 << shift) | 0x3).rw(FUNC(g300_device::linetime_r), FUNC(g300_device::linetime_w)); + map(0x12a, (0x12a << shift) | 0x3).rw(FUNC(g300_device::tos_r), FUNC(g300_device::tos_w)); + map(0x12b, (0x12b << shift) | 0x3).rw(FUNC(g300_device::meminit_r), FUNC(g300_device::meminit_w)); + map(0x12c, (0x12c << shift) | 0x3).rw(FUNC(g300_device::transferdelay_r), FUNC(g300_device::transferdelay_w)); map(0x140 << shift, (0x140 << shift) | 0x3).rw(FUNC(g300_device::mask_r), FUNC(g300_device::mask_w)); map(0x160 << shift, (0x160 << shift) | 0x3).rw(FUNC(g300_device::control_r), FUNC(g300_device::control_w)); @@ -92,45 +90,37 @@ void g300_device::map(address_map &map) void g332_device::map(address_map &map) { - map(0x0000, 0x1fff).m(m_microport, FUNC(address_map_bank_device::amap32)); -} - -void g332_device::microport_map(address_map &map) -{ - // datasheet uses unshifted addresses: configure the device map for 64 bit - // address mode, bank device does handles additional shift for 32 bit mode - const int shift = 3; + // datasheet gives unshifted addresses + const int shift = 2; // TODO: 64 bit mode - map(0x000 << shift, (0x000 << shift) | 0x7).w(FUNC(g332_device::boot_w)); + map(0x000 << shift, (0x000 << shift) | 0x3).w(FUNC(g332_device::boot_w)); // data path registers - map(0x021 << shift, (0x021 << shift) | 0x7).rw(FUNC(g332_device::halfsync_r), FUNC(g332_device::halfsync_w)); - map(0x022 << shift, (0x022 << shift) | 0x7).rw(FUNC(g332_device::backporch_r), FUNC(g332_device::backporch_w)); - map(0x023 << shift, (0x023 << shift) | 0x7).rw(FUNC(g332_device::display_r), FUNC(g332_device::display_w)); - map(0x024 << shift, (0x024 << shift) | 0x7).rw(FUNC(g332_device::shortdisplay_r), FUNC(g332_device::shortdisplay_w)); - map(0x025 << shift, (0x025 << shift) | 0x7).rw(FUNC(g332_device::broadpulse_r), FUNC(g332_device::broadpulse_w)); - map(0x026 << shift, (0x026 << shift) | 0x7).rw(FUNC(g332_device::vsync_r), FUNC(g332_device::vsync_w)); - map(0x027 << shift, (0x027 << shift) | 0x7).rw(FUNC(g332_device::vpreequalise_r), FUNC(g332_device::vpreequalise_w)); - map(0x028 << shift, (0x028 << shift) | 0x7).rw(FUNC(g332_device::vpostequalise_r), FUNC(g332_device::vpostequalise_w)); - map(0x029 << shift, (0x029 << shift) | 0x7).rw(FUNC(g332_device::vblank_r), FUNC(g332_device::vblank_w)); - map(0x02a << shift, (0x02a << shift) | 0x7).rw(FUNC(g332_device::vdisplay_r), FUNC(g332_device::vdisplay_w)); - map(0x02b << shift, (0x02b << shift) | 0x7).rw(FUNC(g332_device::linetime_r), FUNC(g332_device::linetime_w)); - map(0x02c << shift, (0x02c << shift) | 0x7).rw(FUNC(g332_device::linestart_r), FUNC(g332_device::linestart_w)); - map(0x02d << shift, (0x02d << shift) | 0x7).rw(FUNC(g332_device::meminit_r), FUNC(g332_device::meminit_w)); - map(0x02e << shift, (0x02e << shift) | 0x7).rw(FUNC(g332_device::transferdelay_r), FUNC(g332_device::transferdelay_w)); - - map(0x040 << shift, (0x040 << shift) | 0x7).rw(FUNC(g332_device::mask_r), FUNC(g332_device::mask_w)); - map(0x060 << shift, (0x060 << shift) | 0x7).rw(FUNC(g332_device::control_a_r), FUNC(g332_device::control_a_w)); - map(0x070 << shift, (0x070 << shift) | 0x7).rw(FUNC(g332_device::control_b_r), FUNC(g332_device::control_b_w)); - map(0x080 << shift, (0x080 << shift) | 0x7).rw(FUNC(g332_device::tos_r), FUNC(g332_device::tos_w)); + map(0x021, (0x021 << shift) | 0x3).rw(FUNC(g332_device::halfsync_r), FUNC(g332_device::halfsync_w)); + map(0x022, (0x022 << shift) | 0x3).rw(FUNC(g332_device::backporch_r), FUNC(g332_device::backporch_w)); + map(0x023, (0x023 << shift) | 0x3).rw(FUNC(g332_device::display_r), FUNC(g332_device::display_w)); + map(0x024, (0x024 << shift) | 0x3).rw(FUNC(g332_device::shortdisplay_r), FUNC(g332_device::shortdisplay_w)); + map(0x025, (0x025 << shift) | 0x3).rw(FUNC(g332_device::broadpulse_r), FUNC(g332_device::broadpulse_w)); + map(0x026, (0x026 << shift) | 0x3).rw(FUNC(g332_device::vsync_r), FUNC(g332_device::vsync_w)); + map(0x027, (0x027 << shift) | 0x3).rw(FUNC(g332_device::vpreequalise_r), FUNC(g332_device::vpreequalise_w)); + map(0x028, (0x028 << shift) | 0x3).rw(FUNC(g332_device::vpostequalise_r), FUNC(g332_device::vpostequalise_w)); + map(0x029, (0x029 << shift) | 0x3).rw(FUNC(g332_device::vblank_r), FUNC(g332_device::vblank_w)); + map(0x02a, (0x02a << shift) | 0x3).rw(FUNC(g332_device::vdisplay_r), FUNC(g332_device::vdisplay_w)); + map(0x02b, (0x02b << shift) | 0x3).rw(FUNC(g332_device::linetime_r), FUNC(g332_device::linetime_w)); + map(0x02c, (0x02c << shift) | 0x3).rw(FUNC(g332_device::linestart_r), FUNC(g332_device::linestart_w)); + map(0x02d, (0x02d << shift) | 0x3).rw(FUNC(g332_device::meminit_r), FUNC(g332_device::meminit_w)); + map(0x02e, (0x02e << shift) | 0x3).rw(FUNC(g332_device::transferdelay_r), FUNC(g332_device::transferdelay_w)); + + map(0x040 << shift, (0x040 << shift) | 0x3).rw(FUNC(g332_device::mask_r), FUNC(g332_device::mask_w)); + map(0x060 << shift, (0x060 << shift) | 0x3).rw(FUNC(g332_device::control_a_r), FUNC(g332_device::control_a_w)); + map(0x070 << shift, (0x070 << shift) | 0x3).rw(FUNC(g332_device::control_b_r), FUNC(g332_device::control_b_w)); + map(0x080 << shift, (0x080 << shift) | 0x3).rw(FUNC(g332_device::tos_r), FUNC(g332_device::tos_w)); // cursor palette (0a1-0a3) - map(0x0a1 << shift, (0x0a3 << shift) | 0x7).rw(FUNC(g332_device::cursor_palette_r), FUNC(g332_device::cursor_palette_w)); - // checksum registers (0c0-0c2) // colour palette - map(0x100 << shift, (0x1ff << shift) | 0x7).rw(FUNC(g332_device::colour_palette_r), FUNC(g332_device::colour_palette_w)); + map(0x100 << shift, (0x1ff << shift) | 0x3).rw(FUNC(g332_device::colour_palette_r), FUNC(g332_device::colour_palette_w)); // cursor store (200-3ff) // cursor position (0c7) @@ -138,208 +128,13 @@ void g332_device::microport_map(address_map &map) void ims_cvc_device::device_start() { - save_item(NAME(m_halfsync)); - save_item(NAME(m_backporch)); - save_item(NAME(m_display)); - save_item(NAME(m_shortdisplay)); - save_item(NAME(m_broadpulse)); - save_item(NAME(m_vsync)); - save_item(NAME(m_vblank)); - save_item(NAME(m_vdisplay)); - save_item(NAME(m_linetime)); - save_item(NAME(m_meminit)); - save_item(NAME(m_transferdelay)); - - save_item(NAME(m_mask)); - save_item(NAME(m_tos)); - save_item(NAME(m_boot)); + m_space = &space(0); } void ims_cvc_device::device_reset() { } -void g300_device::device_start() -{ - ims_cvc_device::device_start(); - - save_item(NAME(m_control)); -} - -void g332_device::device_start() -{ - ims_cvc_device::device_start(); - - save_item(NAME(m_vpreequalise)); - save_item(NAME(m_vpostequalise)); - save_item(NAME(m_linestart)); - save_item(NAME(m_control_a)); - save_item(NAME(m_control_b)); -} - -void g332_device::device_reset() -{ - m_control_a = 0; -} - -u32 g300_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - offs_t address = m_tos; - - for (int y = screen.visible_area().min_y; y <= screen.visible_area().max_y; y++) - for (int x = screen.visible_area().min_x; x <= screen.visible_area().max_x; x++) - bitmap.pix(y, x) = pen_color(m_vram->read(address++) & m_mask); - - return 0; -} - -u32 g332_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) +void ims_cvc_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { - offs_t address = m_tos; - - switch (m_control_a & PIXEL_BITS) - { - case BPP_1: - for (int y = screen.visible_area().min_y; y <= screen.visible_area().max_y; y++) - for (int x = screen.visible_area().min_x; x <= screen.visible_area().max_x; x += 8) - { - u8 pixel_data = m_vram->read(address++); - - bitmap.pix(y, x + 0) = pen_color(pixel_data & 0x1 & m_mask); pixel_data >>= 1; - bitmap.pix(y, x + 1) = pen_color(pixel_data & 0x1 & m_mask); pixel_data >>= 1; - bitmap.pix(y, x + 2) = pen_color(pixel_data & 0x1 & m_mask); pixel_data >>= 1; - bitmap.pix(y, x + 3) = pen_color(pixel_data & 0x1 & m_mask); pixel_data >>= 1; - bitmap.pix(y, x + 4) = pen_color(pixel_data & 0x1 & m_mask); pixel_data >>= 1; - bitmap.pix(y, x + 5) = pen_color(pixel_data & 0x1 & m_mask); pixel_data >>= 1; - bitmap.pix(y, x + 6) = pen_color(pixel_data & 0x1 & m_mask); pixel_data >>= 1; - bitmap.pix(y, x + 7) = pen_color(pixel_data & 0x1 & m_mask); - } - break; - - case BPP_2: - for (int y = screen.visible_area().min_y; y <= screen.visible_area().max_y; y++) - for (int x = screen.visible_area().min_x; x <= screen.visible_area().max_x; x += 4) - { - u8 pixel_data = m_vram->read(address++); - - bitmap.pix(y, x + 0) = pen_color(pixel_data & 0x3 & m_mask); pixel_data >>= 2; - bitmap.pix(y, x + 1) = pen_color(pixel_data & 0x3 & m_mask); pixel_data >>= 2; - bitmap.pix(y, x + 2) = pen_color(pixel_data & 0x3 & m_mask); pixel_data >>= 2; - bitmap.pix(y, x + 3) = pen_color(pixel_data & 0x3 & m_mask); - } - break; - - case BPP_4: - for (int y = screen.visible_area().min_y; y <= screen.visible_area().max_y; y++) - for (int x = screen.visible_area().min_x; x <= screen.visible_area().max_x; x += 2) - { - u8 pixel_data = m_vram->read(address++); - - bitmap.pix(y, x + 0) = pen_color(pixel_data & 0xf & m_mask); pixel_data >>= 4; - bitmap.pix(y, x + 1) = pen_color(pixel_data & 0xf & m_mask); - } - break; - - case BPP_8: - for (int y = screen.visible_area().min_y; y <= screen.visible_area().max_y; y++) - for (int x = screen.visible_area().min_x; x <= screen.visible_area().max_x; x++) - bitmap.pix(y, x) = pen_color(m_vram->read(address++) & m_mask); - break; - } - - return 0; -} - -u32 ims_cvc_device::colour_palette_r(offs_t offset) -{ - return 0; -} - -void ims_cvc_device::colour_palette_w(offs_t offset, u32 data, u32 mem_mask) -{ - set_pen_color(offset >> 1, data >> 16, data >> 8, data >> 0); -} - -u32 g332_device::cursor_palette_r(offs_t offset) -{ - return 0; -} - -void g332_device::cursor_palette_w(offs_t offset, u32 data, u32 mem_mask) -{ - set_pen_color(256 + (offset >> 1), data >> 16, data >> 8, data >> 0); -} - -void g332_device::boot_w(offs_t offset, u32 data, u32 mem_mask) -{ - LOG("boot_w %s clock, multiplier %d, %d bit alignment (%s)\n", - (data & PLL_SELECT) ? "PLL" : "external", (data & PLL_MULTIPLIER), - (data & ALIGN_64) ? 64 : 32, machine().describe_context()); - - m_microport->set_shift((data & ALIGN_64) ? 0 : 1); - - mem_mask &= 0x00ffffffU; - COMBINE_DATA(&m_boot); -} - -void g332_device::control_a_w(offs_t offset, u32 data, u32 mem_mask) -{ - LOG("control_a_w 0x%08x (%s)\n", data, machine().describe_context()); - - mem_mask &= 0x00ffffffU; - COMBINE_DATA(&m_control_a); - - if (data & VTG_ENABLE) - { - LOGMASKED(LOG_CONFIG, "VTG %s, %s, %s mode\n", - (data & VTG_ENABLE) ? "enabled" : "disabled", - (data & INTL_ENABLE) ? ((data & INTL_FORMAT) ? "interlaced (CCIR)" : "interlaced (EIA)") : "non-interlaced", - (data & SLAVE_MODE) ? "slave" : "master"); - - LOGMASKED(LOG_CONFIG, "%s sync, %s digital sync, analogue %s\n", - (data & SYNC_PATTERN) ? "plain" : "tesselated", - (data & SYNC_FORMAT) ? "separate" : "composite", - (data & VIDEO_FORMAT) ? "video only" : "composite video + sync"); - - LOGMASKED(LOG_CONFIG, "%s, CBlank is %s, %s, %s\n", - (data & BLANK_LEVEL) ? "blanking pedestal" : "no blank pedestal", - (data & BLANK_IO) ? "ouput" : "input", - (data & BLANK_FUNC) ? "undelayed ClkDisable" : "delayed CBlank", - (data & BLANK_FORCE) ? "screen blanked" : (data & BLANK_DISABLE) ? "blanking disabled" : "blanking enabled"); - - LOGMASKED(LOG_CONFIG, "address increment %d, DMA %s, sync delay %d cycles\n", - (data & ADDR_INC) == INC_1 ? 1 : - (data & ADDR_INC) == INC_256 ? (data & INTL_ENABLE) ? 2 : 256 : - (data & ADDR_INC) == INC_512 ? 512 : 1024, - (data & DMA_DISABLE) ? "disabled" : "enabled", - (data & SYNC_DELAY) >> 15); - - LOGMASKED(LOG_CONFIG, "interleave %s, pixel sampling %s, %s bits per pixel, cursor %s\n", - (data & INTERLEAVE) ? "enabled" : "disabled", - (data & SAMPLE_DELAY) ? "delayed" : "standard", - (data & PIXEL_BITS) == BPP_1 ? "1" : - (data & PIXEL_BITS) == BPP_2 ? "2" : - (data & PIXEL_BITS) == BPP_4 ? "4" : - (data & PIXEL_BITS) == BPP_8 ? "8" : - (data & PIXEL_BITS) == BPP_15 ? "15" : - (data & PIXEL_BITS) == BPP_16 ? "16" : "unknown", - (data & CURSOR_DISABLE) ? "disabled" : "enabled"); - - LOG("display %d vdisplay %d\n", m_display, m_vdisplay); - LOG("linetime %d halfsync %d backporch %d broadpulse %d\n", m_linetime, m_halfsync, m_backporch, m_broadpulse); - LOG("vsync %d vpreequalise %d vpostequalise %d vblank %d\n", m_vsync, m_vpreequalise, m_vpostequalise, m_vblank); - - int const hbend = (m_halfsync + m_halfsync + m_backporch) << 2; - int const vbend = (m_vpreequalise + m_vpostequalise + m_vsync + m_vblank) >> 1; - int const width = m_linetime << 2; - int const height = vbend + (m_vdisplay >> 1); - - rectangle const visarea(hbend, hbend + (m_display << 2) - 1, vbend, height - 1); - - u32 const dotclock = (m_boot & PLL_SELECT) ? clock() * (m_boot & PLL_MULTIPLIER) : clock(); - attotime const refresh = attotime::from_hz(dotclock / (width * height)); - - m_screen->configure(width, height, visarea, refresh.as_attoseconds()); - m_screen->reset_origin(); - } } diff --git a/src/devices/video/ims_cvc.h b/src/devices/video/ims_cvc.h index 82acfe5c6eb..25c0163642d 100644 --- a/src/devices/video/ims_cvc.h +++ b/src/devices/video/ims_cvc.h @@ -5,22 +5,15 @@ #pragma once -#include "machine/bankdev.h" -#include "machine/ram.h" - -class ims_cvc_device - : public device_t - , public device_palette_interface +class ims_cvc_device : + public device_t, + public device_memory_interface, + public device_palette_interface { public: - static constexpr feature_type imperfect_features() { return feature::GRAPHICS; } - - // configuration - template <typename T> void set_screen(T &&tag) { m_screen.set_tag(std::forward<T>(tag)); } - template <typename T> void set_vram(T &&tag) { m_vram.set_tag(std::forward<T>(tag)); } - virtual void map(address_map &map) = 0; - virtual u32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) = 0; + + void screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); protected: ims_cvc_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); @@ -29,47 +22,51 @@ protected: virtual void device_start() override; virtual void device_reset() override; + // device_memory_interface overrides + virtual space_config_vector memory_space_config() const override; + // device_palette_interface overrides - virtual u32 palette_entries() const override { return 256; } + virtual u32 palette_entries() const override { return 256; } // FIXME - u32 colour_palette_r(const offs_t offset); - void colour_palette_w(offs_t offset, u32 data, u32 mem_mask = 0xffffffffU); + u32 colour_palette_r(const offs_t offset) { return 0; } + void colour_palette_w(const offs_t offset, const u32 data) {} u32 halfsync_r() { return m_halfsync; } - void halfsync_w(offs_t offset, u32 data, u32 mem_mask = 0xffffffffU) { COMBINE_DATA(&m_halfsync); } + void halfsync_w(const u32 data) { m_halfsync = data; } u32 backporch_r() { return m_backporch; } - void backporch_w(offs_t offset, u32 data, u32 mem_mask = 0xffffffffU) { COMBINE_DATA(&m_backporch); } + void backporch_w(const u32 data) { m_backporch = data; } u32 display_r() { return m_display; } - void display_w(offs_t offset, u32 data, u32 mem_mask = 0xffffffffU) { COMBINE_DATA(&m_display); } + void display_w(const u32 data) { m_display = data; } u32 shortdisplay_r() { return m_shortdisplay; } - void shortdisplay_w(offs_t offset, u32 data, u32 mem_mask = 0xffffffffU) { COMBINE_DATA(&m_shortdisplay); } + void shortdisplay_w(const u32 data) { m_shortdisplay = data; } u32 broadpulse_r() { return m_broadpulse; } - void broadpulse_w(offs_t offset, u32 data, u32 mem_mask = 0xffffffffU) { COMBINE_DATA(&m_broadpulse); } + void broadpulse_w(const u32 data) { m_broadpulse = data; } u32 vsync_r() { return m_vsync; } - void vsync_w(offs_t offset, u32 data, u32 mem_mask = 0xffffffffU) { COMBINE_DATA(&m_vsync); } + void vsync_w(const u32 data) { m_vsync = data; } u32 vblank_r() { return m_vblank; } - void vblank_w(offs_t offset, u32 data, u32 mem_mask = 0xffffffffU) { COMBINE_DATA(&m_vblank); } + void vblank_w(const u32 data) { m_vblank = data; } u32 vdisplay_r() { return m_vdisplay; } - void vdisplay_w(offs_t offset, u32 data, u32 mem_mask = 0xffffffffU) { COMBINE_DATA(&m_vdisplay); } + void vdisplay_w(const u32 data) { m_vdisplay = data; } u32 linetime_r() { return m_linetime; } - void linetime_w(offs_t offset, u32 data, u32 mem_mask = 0xffffffffU) { COMBINE_DATA(&m_linetime); } + void linetime_w(const u32 data) { m_linetime = data; } //u32 tos_r() { return m_tos; } //void tos_w(const u32 data) { m_tos = data; } u32 meminit_r() { return m_meminit; } - void meminit_w(offs_t offset, u32 data, u32 mem_mask = 0xffffffffU) { COMBINE_DATA(&m_meminit); } + void meminit_w(const u32 data) { m_meminit = data; } u32 transferdelay_r() { return m_transferdelay; } - void transferdelay_w(offs_t offset, u32 data, u32 mem_mask = 0xffffffffU) { COMBINE_DATA(&m_transferdelay); } + void transferdelay_w(const u32 data) { m_transferdelay = data; } u32 mask_r() { return m_mask; } - void mask_w(offs_t offset, u32 data, u32 mem_mask = 0xffffffffU) { COMBINE_DATA(&m_mask); } + void mask_w(const u32 data) { m_mask = data; } u32 tos_r() { return m_tos; } - void tos_w(offs_t offset, u32 data, u32 mem_mask = 0xffffffffU) { COMBINE_DATA(&m_tos); } + void tos_w(const u32 data) { m_tos = data; } - virtual void boot_w(offs_t offset, u32 data, u32 mem_mask = 0xffffffffU) { COMBINE_DATA(&m_boot); } + void boot_w(const u32 data) { m_boot = data; } - required_device<screen_device> m_screen; - required_device<ram_device> m_vram; +private: + // device_memory_interface members + const address_space_config m_space_config; + address_space *m_space; -protected: // device state u32 m_halfsync; u32 m_backporch; @@ -95,13 +92,9 @@ public: virtual void map(address_map &map) override; - virtual u32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) override; - protected: - virtual void device_start() override; - u32 control_r() { return m_control; } - void control_w(offs_t offset, u32 data, u32 mem_mask = 0xffffffffU) { COMBINE_DATA(&m_control); } + void control_w(const u32 data) { m_control = data; } private: u32 m_control; @@ -114,86 +107,21 @@ public: virtual void map(address_map &map) override; - virtual u32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) override; - - enum boot_mask : u32 - { - PLL_MULTIPLIER = 0x000001f, // pll multiplier - PLL_SELECT = 0x0000020, // pll clock select - ALIGN_64 = 0x0000040, // 64 bit address alignment - }; - - enum control_a_mask - { - VTG_ENABLE = 0x000001, // video timing generator enable - INTL_ENABLE = 0x000002, // interlace enable - INTL_FORMAT = 0x000004, // ccir/eia interlace format - SLAVE_MODE = 0x000008, // slave/master operating mode - SYNC_PATTERN = 0x000010, // plain/tesselated sync - SYNC_FORMAT = 0x000020, // separate/composite sync - VIDEO_FORMAT = 0x000040, // video only/composite video + sync - BLANK_LEVEL = 0x000080, // blanking pedestal/no blank pedestal - BLANK_IO = 0x000100, // CBlank is output/input - BLANK_FUNC = 0x000200, // undelayed ClkDisable/delayed CBlank - BLANK_FORCE = 0x000400, // screen blanked/no action - BLANK_DISABLE = 0x000800, // blanking disabled/enabled - ADDR_INC = 0x003000, // VRAM address increment - DMA_DISABLE = 0x004000, // DMA disabled/enabled - SYNC_DELAY = 0x038000, - INTERLEAVE = 0x040000, // interleave enabled/disabled - SAMPLE_DELAY = 0x080000, - PIXEL_BITS = 0x700000, // bits per pixel - CURSOR_DISABLE = 0x800000, // cursor disabled/enabled - }; - enum control_a_addr_inc_mask - { - INC_1 = 0x000000, - INC_256 = 0x001000, - INC_512 = 0x002000, - INC_1024 = 0x003000, - }; - enum control_a_bpp_mask - { - BPP_1 = 0x000000, - BPP_2 = 0x100000, - BPP_4 = 0x200000, - BPP_8 = 0x300000, - BPP_15 = 0x400000, - BPP_16 = 0x500000, - }; - protected: g332_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); - // device_t overrides - virtual void device_add_mconfig(machine_config &config) override; - virtual void device_start() override; - virtual void device_reset() override; - - // device_palette_interface overrides - virtual u32 palette_entries() const override { return 256 + 3; } - - virtual void microport_map(address_map &map); - - virtual void boot_w(offs_t offset, u32 data, u32 mem_mask = 0x00ffffffU) override; - - u32 cursor_palette_r(const offs_t offset); - void cursor_palette_w(offs_t offset, u32 data, u32 mem_mask = 0xffffffffU); - u32 vpreequalise_r() { return m_vpreequalise; } - void vpreequalise_w(offs_t offset, u32 data, u32 mem_mask = 0xffffffffU) { COMBINE_DATA(&m_vpreequalise); } + void vpreequalise_w(const u32 data) { m_vpreequalise = data; } u32 vpostequalise_r() { return m_vpostequalise; } - void vpostequalise_w(offs_t offset, u32 data, u32 mem_mask = 0xffffffffU) { COMBINE_DATA(&m_vpostequalise); } + void vpostequalise_w(const u32 data) { m_vpostequalise = data; } u32 linestart_r() { return m_linestart; } - void linestart_w(offs_t offset, u32 data, u32 mem_mask = 0xffffffffU) { COMBINE_DATA(&m_linestart); } + void linestart_w(const u32 data) { m_linestart = data; } u32 control_a_r() { return m_control_a; } - void control_a_w(offs_t offset, u32 data, u32 mem_mask = 0xffffffffU); + void control_a_w(const u32 data) { m_control_a = data; } u32 control_b_r() { return m_control_b; } - void control_b_w(offs_t offset, u32 data, u32 mem_mask = 0xffffffffU) { COMBINE_DATA(&m_control_b); } + void control_b_w(const u32 data) { m_control_b = data; } private: - required_device<address_map_bank_device> m_microport; - u32 m_vpreequalise; u32 m_vpostequalise; u32 m_linestart; diff --git a/src/devices/video/jangou_blitter.h b/src/devices/video/jangou_blitter.h index 8bf4f4a56ec..3ff34b50ae7 100644 --- a/src/devices/video/jangou_blitter.h +++ b/src/devices/video/jangou_blitter.h @@ -7,6 +7,14 @@ #pragma once + +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define MCFG_JANGOU_BLITTER_ADD(_tag,_freq) \ + MCFG_DEVICE_ADD(_tag, JANGOU_BLITTER, _freq) + //************************************************************************** // TYPE DEFINITIONS //************************************************************************** diff --git a/src/devices/video/m50458.cpp b/src/devices/video/m50458.cpp index 59e0f44cc43..41a6bd1651f 100644 --- a/src/devices/video/m50458.cpp +++ b/src/devices/video/m50458.cpp @@ -31,18 +31,15 @@ DEFINE_DEVICE_TYPE(M50458, m50458_device, "m50458", "Mitsubishi M50458 OSD") void m50458_device::m50458_vram(address_map &map) { - if (!has_configured_map(0)) - { - map(0x0000, 0x023f).ram(); // vram - map(0x0240, 0x0241).w(FUNC(m50458_device::vreg_120_w)); - map(0x0242, 0x0243).w(FUNC(m50458_device::vreg_121_w)); - map(0x0244, 0x0245).w(FUNC(m50458_device::vreg_122_w)); - map(0x0246, 0x0247).w(FUNC(m50458_device::vreg_123_w)); - map(0x0248, 0x0249).w(FUNC(m50458_device::vreg_124_w)); - map(0x024a, 0x024b).w(FUNC(m50458_device::vreg_125_w)); - map(0x024c, 0x024d).w(FUNC(m50458_device::vreg_126_w)); - map(0x024e, 0x024f).w(FUNC(m50458_device::vreg_127_w)); - } + map(0x0000, 0x023f).ram(); // vram + map(0x0240, 0x0241).w(FUNC(m50458_device::vreg_120_w)); + map(0x0242, 0x0243).w(FUNC(m50458_device::vreg_121_w)); + map(0x0244, 0x0245).w(FUNC(m50458_device::vreg_122_w)); + map(0x0246, 0x0247).w(FUNC(m50458_device::vreg_123_w)); + map(0x0248, 0x0249).w(FUNC(m50458_device::vreg_124_w)); + map(0x024a, 0x024b).w(FUNC(m50458_device::vreg_125_w)); + map(0x024c, 0x024d).w(FUNC(m50458_device::vreg_126_w)); + map(0x024e, 0x024f).w(FUNC(m50458_device::vreg_127_w)); } // internal GFX ROM (TODO: GFXs in here should be 12x18, not 16x18) @@ -183,7 +180,7 @@ m50458_device::m50458_device(const machine_config &mconfig, const char *tag, dev : device_t(mconfig, M50458, tag, owner, clock) , device_memory_interface(mconfig, *this) , device_video_interface(mconfig, *this) - , m_space_config("videoram", ENDIANNESS_LITTLE, 16, 16, 0, address_map_constructor(FUNC(m50458_device::m50458_vram), this)) + , m_space_config("videoram", ENDIANNESS_LITTLE, 16, 16, 0, address_map_constructor(), address_map_constructor(FUNC(m50458_device::m50458_vram), this)) { } diff --git a/src/devices/video/m50458.h b/src/devices/video/m50458.h index 07113a93afe..5be6ceaf08c 100644 --- a/src/devices/video/m50458.h +++ b/src/devices/video/m50458.h @@ -12,6 +12,16 @@ Mitsubishi M50458 OSD chip #pragma once + +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define MCFG_M50458_ADD(_tag,_freq,_screen) \ + MCFG_DEVICE_ADD(_tag, M50458,_freq) \ + MCFG_VIDEO_SET_SCREEN(_screen) + + //************************************************************************** // TYPE DEFINITIONS //************************************************************************** @@ -24,13 +34,6 @@ class m50458_device : public device_t, { public: // construction/destruction - template <typename T> - m50458_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&screen_tag) - : m50458_device(mconfig, tag, owner, clock) - { - set_screen(std::forward<T>(screen_tag)); - } - m50458_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); // I/O operations diff --git a/src/devices/video/mb88303.h b/src/devices/video/mb88303.h index f8804adff61..9c088d8d56b 100644 --- a/src/devices/video/mb88303.h +++ b/src/devices/video/mb88303.h @@ -26,6 +26,21 @@ #pragma once + +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define MCFG_MB88303_VOW_CALLBACK(_write) \ + downcast<mb88303_device &>(*device).set_vow_callback(DEVCB_##_write); + +#define MCFG_MB88303_VOBN_CALLBACK(_write) \ + downcast<mb88303_device &>(*device).set_vob_n_callback(DEVCB_##_write); + +#define MCFG_MB88303_DO_CALLBACK(_write) \ + downcast<mb88303_device &>(*device).set_do_callback(DEVCB_##_write); + + //************************************************************************** // TYPE DEFINITIONS //************************************************************************** @@ -41,9 +56,9 @@ public: // construction/destruction mb88303_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - auto vow_callback() { return m_write_vow.bind(); } - auto vobn_callback() { return m_write_vobn.bind(); } - auto do_callback() { return m_write_do.bind(); } + template <class Object> devcb_base &set_vow_callback(Object &&cb) { return m_write_vow.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_vobn_callback(Object &&cb) { return m_write_vobn.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_do_callback(Object &&cb) { return m_write_do.set_callback(std::forward<Object>(cb)); } DECLARE_WRITE8_MEMBER(da_w); DECLARE_WRITE_LINE_MEMBER(adm_w); diff --git a/src/devices/video/mb90082.cpp b/src/devices/video/mb90082.cpp index 957669fb48b..a3026aeb179 100644 --- a/src/devices/video/mb90082.cpp +++ b/src/devices/video/mb90082.cpp @@ -25,13 +25,10 @@ DEFINE_DEVICE_TYPE(MB90082, mb90082_device, "mb90082", "Fujitsu MB90082 OSD") void mb90082_device::mb90082_vram(address_map &map) { - if (!has_configured_map(0)) - { - map(0x0000, 0x023f).ram(); // main screen vram - map(0x0400, 0x063f).ram(); // main screen attr + map(0x0000, 0x023f).ram(); // main screen vram + map(0x0400, 0x063f).ram(); // main screen attr // AM_RANGE(0x0800, 0x0a3f) AM_RAM // sub screen vram // AM_RANGE(0x0c00, 0x0e3f) AM_RAM // sub screen attr - } } /* charset is undumped, but apparently a normal ASCII one is enough for the time being (for example "fnt0808.x1" in Sharp X1) */ @@ -94,7 +91,7 @@ inline void mb90082_device::write_word(offs_t address, uint16_t data) mb90082_device::mb90082_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, MB90082, tag, owner, clock) , device_memory_interface(mconfig, *this) - , m_space_config("videoram", ENDIANNESS_LITTLE, 16, 16, 0, address_map_constructor(FUNC(mb90082_device::mb90082_vram), this)) + , m_space_config("videoram", ENDIANNESS_LITTLE, 16, 16, 0, address_map_constructor(), address_map_constructor(FUNC(mb90082_device::mb90082_vram), this)) { } diff --git a/src/devices/video/mb90082.h b/src/devices/video/mb90082.h index 5c6d2c46df3..3fa203f385f 100644 --- a/src/devices/video/mb90082.h +++ b/src/devices/video/mb90082.h @@ -12,6 +12,14 @@ #pragma once + +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define MCFG_MB90082_ADD(_tag,_freq) \ + MCFG_DEVICE_ADD(_tag, MB90082, _freq) + //************************************************************************** // TYPE DEFINITIONS //************************************************************************** diff --git a/src/devices/video/mb_vcu.cpp b/src/devices/video/mb_vcu.cpp index 96acc945359..8d0f921be12 100644 --- a/src/devices/video/mb_vcu.cpp +++ b/src/devices/video/mb_vcu.cpp @@ -38,20 +38,16 @@ DEFINE_DEVICE_TYPE(MB_VCU, mb_vcu_device, "mb_vcu", "Mazer Blazer custom VCU") void mb_vcu_device::mb_vcu_vram(address_map &map) { - if (!has_configured_map(0)) - map(0x00000, 0x7ffff).ram(); // enough for a 256x256x4 x 2 pages of framebuffer with 4 layers (TODO: doubled for simplicity) + map(0x00000, 0x7ffff).ram(); // enough for a 256x256x4 x 2 pages of framebuffer with 4 layers (TODO: doubled for simplicity) } void mb_vcu_device::mb_vcu_pal_ram(address_map &map) { - if (!has_configured_map(1)) - { - map(0x0000, 0x00ff).ram(); - map(0x0200, 0x02ff).ram(); - map(0x0400, 0x04ff).ram(); - map(0x0600, 0x06ff).rw(FUNC(mb_vcu_device::mb_vcu_paletteram_r), FUNC(mb_vcu_device::mb_vcu_paletteram_w)); - } + map(0x0000, 0x00ff).ram(); + map(0x0200, 0x02ff).ram(); + map(0x0400, 0x04ff).ram(); + map(0x0600, 0x06ff).rw(FUNC(mb_vcu_device::mb_vcu_paletteram_r), FUNC(mb_vcu_device::mb_vcu_paletteram_w)); } READ8_MEMBER( mb_vcu_device::mb_vcu_paletteram_r ) @@ -68,19 +64,19 @@ WRITE8_MEMBER( mb_vcu_device::mb_vcu_paletteram_w ) /* red component */ bit1 = (m_palram[offset] >> 7) & 0x01; bit0 = (m_palram[offset] >> 6) & 0x01; - r = combine_weights(m_weights_r, bit0, bit1); + r = combine_2_weights(m_weights_r, bit0, bit1); /* green component */ bit2 = (m_palram[offset] >> 5) & 0x01; bit1 = (m_palram[offset] >> 4) & 0x01; bit0 = (m_palram[offset] >> 3) & 0x01; - g = combine_weights(m_weights_g, bit0, bit1, bit2); + g = combine_3_weights(m_weights_g, bit0, bit1, bit2); /* blue component */ bit2 = (m_palram[offset] >> 2) & 0x01; bit1 = (m_palram[offset] >> 1) & 0x01; bit0 = (m_palram[offset] >> 0) & 0x01; - b = combine_weights(m_weights_b, bit0, bit1, bit2); + b = combine_3_weights(m_weights_b, bit0, bit1, bit2); m_palette->set_pen_color(offset, rgb_t(r, g, b)); } @@ -151,8 +147,8 @@ mb_vcu_device::mb_vcu_device(const machine_config &mconfig, const char *tag, dev : device_t(mconfig, MB_VCU, tag, owner, clock) , device_memory_interface(mconfig, *this) , device_video_interface(mconfig, *this) - , m_videoram_space_config("videoram", ENDIANNESS_LITTLE, 8, 19, 0, address_map_constructor(FUNC(mb_vcu_device::mb_vcu_vram), this)) - , m_paletteram_space_config("palram", ENDIANNESS_LITTLE, 8, 16, 0, address_map_constructor(FUNC(mb_vcu_device::mb_vcu_pal_ram), this)) + , m_videoram_space_config("videoram", ENDIANNESS_LITTLE, 8, 19, 0, address_map_constructor(), address_map_constructor(FUNC(mb_vcu_device::mb_vcu_vram), this)) + , m_paletteram_space_config("palram", ENDIANNESS_LITTLE, 8, 16, 0, address_map_constructor(), address_map_constructor(FUNC(mb_vcu_device::mb_vcu_pal_ram), this)) , m_cpu(*this, finder_base::DUMMY_TAG) , m_palette(*this, finder_base::DUMMY_TAG) { @@ -478,19 +474,19 @@ WRITE8_MEMBER( mb_vcu_device::background_color_w ) /* red component */ bit1 = (m_bk_color >> 7) & 0x01; bit0 = (m_bk_color >> 6) & 0x01; - r = combine_weights(m_weights_r, bit0, bit1); + r = combine_2_weights(m_weights_r, bit0, bit1); /* green component */ bit2 = (m_bk_color >> 5) & 0x01; bit1 = (m_bk_color >> 4) & 0x01; bit0 = (m_bk_color >> 3) & 0x01; - g = combine_weights(m_weights_g, bit0, bit1, bit2); + g = combine_3_weights(m_weights_g, bit0, bit1, bit2); /* blue component */ bit2 = (m_bk_color >> 2) & 0x01; bit1 = (m_bk_color >> 1) & 0x01; bit0 = (m_bk_color >> 0) & 0x01; - b = combine_weights(m_weights_b, bit0, bit1, bit2); + b = combine_3_weights(m_weights_b, bit0, bit1, bit2); m_palette->set_pen_color(0x100, rgb_t(r, g, b)); } diff --git a/src/devices/video/mb_vcu.h b/src/devices/video/mb_vcu.h index 90f0eea422a..a8b53637a7d 100644 --- a/src/devices/video/mb_vcu.h +++ b/src/devices/video/mb_vcu.h @@ -23,8 +23,8 @@ public: mb_vcu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); // configuration - template <typename T> void set_palette_tag(T &&tag) { m_palette.set_tag(std::forward<T>(tag)); } - template <typename T> void set_cpu_tag(T &&tag) { m_cpu.set_tag(std::forward<T>(tag)); } + void set_palette_tag(const char *tag) { m_palette.set_tag(tag); } + void set_cpu_tag(const char *tag) { m_cpu.set_tag(tag); } // I/O operations DECLARE_WRITE8_MEMBER( write_vregs ); @@ -86,4 +86,15 @@ private: // device type definition DECLARE_DEVICE_TYPE(MB_VCU, mb_vcu_device) + +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define MCFG_MB_VCU_CPU(_tag) \ + downcast<mb_vcu_device &>(*device).set_cpu_tag(_tag); + +#define MCFG_MB_VCU_PALETTE(_palette_tag) \ + downcast<mb_vcu_device &>(*device).set_palette_tag(_palette_tag); + #endif // MAME_VIDEO_MB_VCU_H diff --git a/src/devices/video/mc6845.cpp b/src/devices/video/mc6845.cpp index 82ec8408130..13c1c8a6155 100644 --- a/src/devices/video/mc6845.cpp +++ b/src/devices/video/mc6845.cpp @@ -129,13 +129,13 @@ void mc6845_device::call_on_update_address(int strobe) } -void mc6845_device::address_w(uint8_t data) +void mc6845_device::write_address(uint8_t data) { m_register_address_latch = data & 0x1f; } -uint8_t mc6845_device::status_r() +uint8_t mc6845_device::read_status() { uint8_t ret = 0; @@ -178,7 +178,7 @@ void mc6845_device::transparent_update() } -uint8_t mc6845_device::register_r() +uint8_t mc6845_device::read_register() { uint8_t ret = 0; @@ -200,7 +200,7 @@ uint8_t mc6845_device::register_r() } -void mc6845_device::register_w(uint8_t data) +void mc6845_device::write_register(uint8_t data) { LOG("%s:M6845 reg 0x%02x = 0x%02x\n", machine().describe_context(), m_register_address_latch, data); @@ -253,13 +253,13 @@ void mc6845_device::register_w(uint8_t data) } -void mos8563_device::address_w(uint8_t data) +WRITE8_MEMBER( mos8563_device::address_w ) { m_register_address_latch = data & 0x3f; } -uint8_t mos8563_device::status_r() +READ8_MEMBER( mos8563_device::status_r ) { uint8_t ret = m_revision; @@ -279,7 +279,7 @@ uint8_t mos8563_device::status_r() } -uint8_t mos8563_device::register_r() +READ8_MEMBER( mos8563_device::register_r ) { uint8_t ret = 0xff; @@ -329,7 +329,7 @@ uint8_t mos8563_device::register_r() } -void mos8563_device::register_w(uint8_t data) +WRITE8_MEMBER( mos8563_device::register_w ) { LOG("%s:MOS8563 reg 0x%02x = 0x%02x\n", machine().describe_context(), m_register_address_latch, data); @@ -392,13 +392,13 @@ void mos8563_device::register_w(uint8_t data) recompute_parameters(false); } -void hd6345_device::address_w(uint8_t data) +WRITE8_MEMBER( hd6345_device::address_w ) { m_register_address_latch = data & 0x3f; } -uint8_t hd6345_device::register_r() +READ8_MEMBER( hd6345_device::register_r ) { uint8_t ret = 0xff; @@ -416,7 +416,7 @@ uint8_t hd6345_device::register_r() return ret; } -void hd6345_device::register_w(uint8_t data) +WRITE8_MEMBER( hd6345_device::register_w ) { LOG("%s:HD6345 reg 0x%02x = 0x%02x\n", machine().describe_context(), m_register_address_latch, data); @@ -582,7 +582,7 @@ void mc6845_device::recompute_parameters(bool postload) m_hsync_off_pos = hsync_off_pos; m_vsync_on_pos = vsync_on_pos; m_vsync_off_pos = vsync_off_pos; - if ( (!m_reconfigure_cb.isnull()) && (!postload) ) + if (!postload) // set m_line_counter to 0 on normal operation, but not on postload m_line_counter = 0; } } @@ -659,28 +659,6 @@ void mc6845_device::update_upd_adr_timer() } -bool mc6845_device::match_line() -{ - /* Check if we've reached the end of active display */ - if ( m_line_counter == m_vert_disp ) - { - m_line_enable_ff = false; - m_current_disp_addr = m_disp_start_addr; - } - - /* Check if VSYNC should be enabled */ - if ( m_line_counter == m_vert_sync_pos ) - { - m_vsync_width_counter = 0; - m_vsync_ff = 1; - - return true; - } - - return false; -} - - void mc6845_device::handle_line_timer() { bool new_vsync = m_vsync; @@ -720,8 +698,21 @@ void mc6845_device::handle_line_timer() m_line_counter = ( m_line_counter + 1 ) & 0x7F; m_line_address = ( m_line_address + m_horiz_disp ) & 0x3fff; - if (match_line()) + /* Check if we've reached the end of active display */ + if ( m_line_counter == m_vert_disp ) + { + m_line_enable_ff = false; + m_current_disp_addr = m_disp_start_addr; + } + + /* Check if VSYNC should be enabled */ + if ( m_line_counter == m_vert_sync_pos ) + { + m_vsync_width_counter = 0; + m_vsync_ff = 1; + new_vsync = true; + } } else { @@ -740,13 +731,6 @@ void mc6845_device::handle_line_timer() m_line_counter = 0; m_line_address = m_disp_start_addr; m_line_enable_ff = true; - - if (m_supports_vert_sync_width) - { - if (match_line()) - new_vsync = true; - } - /* also update the cursor state now */ update_cursor_state(); @@ -1454,8 +1438,7 @@ device_memory_interface::space_config_vector mos8563_device::memory_space_config // default address maps void mos8563_device::mos8563_videoram_map(address_map &map) { - if (!has_configured_map(0)) - map(0x0000, 0xffff).ram(); + map(0x0000, 0xffff).ram(); } @@ -1522,7 +1505,7 @@ mos8563_device::mos8563_device(const machine_config &mconfig, device_type type, : mc6845_device(mconfig, type, tag, owner, clock), device_memory_interface(mconfig, *this), device_palette_interface(mconfig, *this), - m_videoram_space_config("videoram", ENDIANNESS_LITTLE, 8, 16, 0, address_map_constructor(FUNC(mos8563_device::mos8563_videoram_map), this)) + m_videoram_space_config("videoram", ENDIANNESS_LITTLE, 8, 16, 0, address_map_constructor(), address_map_constructor(FUNC(mos8563_device::mos8563_videoram_map), this)) { set_clock_scale(1.0/8); } diff --git a/src/devices/video/mc6845.h b/src/devices/video/mc6845.h index 1bb0683ee85..1233651e07b 100644 --- a/src/devices/video/mc6845.h +++ b/src/devices/video/mc6845.h @@ -61,16 +61,20 @@ public: auto out_vsync_callback() { return m_out_vsync_cb.bind(); } /* select one of the registers for reading or writing */ - void address_w(uint8_t data); + DECLARE_WRITE8_MEMBER( address_w ) { write_address(data); } + void write_address(uint8_t data); /* read from the status register */ - uint8_t status_r(); + DECLARE_READ8_MEMBER( status_r ) { return read_status(); } + uint8_t read_status(); /* read from the currently selected register */ - uint8_t register_r(); + DECLARE_READ8_MEMBER( register_r ) { return read_register(); } + uint8_t read_register(); /* write to the currently selected register */ - void register_w(uint8_t data); + DECLARE_WRITE8_MEMBER( register_w ) { write_register(data); } + void write_register(uint8_t data); // read display enable line state DECLARE_READ_LINE_MEMBER( de_r ); @@ -211,7 +215,6 @@ protected: void set_hsync(int state); void set_vsync(int state); void set_cur(int state); - bool match_line(); void handle_line_timer(); virtual void update_cursor_state(); virtual uint8_t draw_scanline(int y, bitmap_rgb32 &bitmap, const rectangle &cliprect); @@ -344,9 +347,9 @@ class hd6345_device : public mc6845_device public: hd6345_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - void address_w(uint8_t data); - uint8_t register_r(); - void register_w(uint8_t data); + DECLARE_WRITE8_MEMBER(address_w); + DECLARE_READ8_MEMBER(register_r); + DECLARE_WRITE8_MEMBER(register_w); protected: virtual void device_start() override; @@ -380,10 +383,10 @@ class mos8563_device : public mc6845_device, public: mos8563_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - void address_w(uint8_t data); - uint8_t status_r(); - uint8_t register_r(); - void register_w(uint8_t data); + DECLARE_WRITE8_MEMBER( address_w ); + DECLARE_READ8_MEMBER( status_r ); + DECLARE_READ8_MEMBER( register_r ); + DECLARE_WRITE8_MEMBER( register_w ); inline uint8_t read_videoram(offs_t offset); inline void write_videoram(offs_t offset, uint8_t data); diff --git a/src/devices/video/mc6847.cpp b/src/devices/video/mc6847.cpp index 4ef156632b0..84b48bc1526 100644 --- a/src/devices/video/mc6847.cpp +++ b/src/devices/video/mc6847.cpp @@ -132,14 +132,14 @@ const uint32_t mc6847_base_device::s_palette[mc6847_base_device::PALETTE_LENGTH] mc6847_friend_device::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) : device_t(mconfig, type, tag, owner, clock) - , device_video_interface(mconfig, *this) , m_write_hsync(*this) , m_write_fsync(*this) , m_character_map(fontdata, is_mc6847t1) - , m_tpfs(tpfs) - , m_divider(divider) - , m_supports_partial_body_scanlines(supports_partial_body_scanlines) { + m_tpfs = tpfs; + m_divider = divider; + m_supports_partial_body_scanlines = supports_partial_body_scanlines; + // The MC6847 and the GIME apply field sync on different scanlines m_field_sync_falling_edge_scanline = field_sync_falling_edge_scanline; } @@ -577,31 +577,6 @@ void mc6847_base_device::setup_fixed_mode() //------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void mc6847_base_device::device_config_complete() -{ - if (!has_screen()) - return; - - if (!screen().refresh_attoseconds()) - { - // FIXME: use correct raw parameters rather than this nonsense - screen().set_refresh_hz(m_tpfs > 310.0 ? 50 : 60); - screen().set_size(320, 243); - screen().set_visarea(0, 320-1, 1, 241-1); - screen().set_vblank_time(0); - } - - if (!screen().has_screen_update()) - screen().set_screen_update(screen_update_rgb32_delegate(FUNC(mc6847_base_device::screen_update), this)); -} - - -//------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- diff --git a/src/devices/video/mc6847.h b/src/devices/video/mc6847.h index b9e8e02ed4c..3868420280b 100644 --- a/src/devices/video/mc6847.h +++ b/src/devices/video/mc6847.h @@ -19,6 +19,41 @@ // MC6847 CONFIGURATION / INTERFACE //************************************************************************** +#define MCFG_SCREEN_MC6847_NTSC_ADD(_tag, _mctag) \ + MCFG_SCREEN_ADD(_tag, RASTER) \ + MCFG_SCREEN_UPDATE_DEVICE(_mctag, mc6847_base_device, screen_update) \ + MCFG_SCREEN_REFRESH_RATE(60) \ + MCFG_SCREEN_SIZE(320, 243) \ + MCFG_SCREEN_VISIBLE_AREA(0, 320-1, 1, 241-1) \ + MCFG_SCREEN_VBLANK_TIME(0) + +#define MCFG_SCREEN_MC6847_PAL_ADD(_tag, _mctag) \ + MCFG_SCREEN_ADD(_tag, RASTER) \ + MCFG_SCREEN_UPDATE_DEVICE(_mctag, mc6847_base_device, screen_update) \ + MCFG_SCREEN_REFRESH_RATE(50) \ + MCFG_SCREEN_SIZE(320, 243) \ + MCFG_SCREEN_VISIBLE_AREA(0, 320-1, 1, 241-1) \ + MCFG_SCREEN_VBLANK_TIME(0) + +#define MCFG_MC6847_HSYNC_CALLBACK(_write) \ + downcast<mc6847_friend_device &>(*device).set_hsync_wr_callback(DEVCB_##_write); + +#define MCFG_MC6847_FSYNC_CALLBACK(_write) \ + downcast<mc6847_friend_device &>(*device).set_fsync_wr_callback(DEVCB_##_write); + +#define MCFG_MC6847_CHARROM_CALLBACK(_class, _method) \ + downcast<mc6847_friend_device &>(*device).set_get_char_rom(mc6847_friend_device::get_char_rom_delegate(&_class::_method, #_class "::" #_method, this)); + +#define MCFG_MC6847_INPUT_CALLBACK(_read) \ + downcast<mc6847_base_device &>(*device).set_input_callback(DEVCB_##_read); + +#define MCFG_MC6847_FIXED_MODE(_mode) \ + downcast<mc6847_base_device &>(*device).set_get_fixed_mode(_mode); + +#define MCFG_MC6847_BW(_bw) \ + downcast<mc6847_base_device &>(*device).set_black_and_white(_bw); + + #define MC6847_GET_CHARROM_MEMBER(_name) uint8_t _name(uint8_t ch, int line) @@ -32,7 +67,7 @@ INPUT_PORTS_EXTERN(mc6847_artifacting); //************************************************************************** // base class so that the GIME emulation can access mc6847 stuff -class mc6847_friend_device : public device_t, public device_video_interface +class mc6847_friend_device : public device_t { public: // video mode constants @@ -51,19 +86,12 @@ public: bool hs_r() const { return m_horizontal_sync; } bool fs_r() const { return m_field_sync; } + template <class Object> devcb_base &set_hsync_wr_callback(Object &&cb) { return m_write_hsync.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_fsync_wr_callback(Object &&cb) { return m_write_fsync.set_callback(std::forward<Object>(cb)); } auto hsync_wr_callback() { return m_write_hsync.bind(); } auto fsync_wr_callback() { return m_write_fsync.bind(); } template <typename Object> void set_get_char_rom(Object &&cb) { m_charrom_cb = std::forward<Object>(cb); } - void set_get_char_rom(get_char_rom_delegate cb) { m_charrom_cb = cb; } - template <class FunctionClass> void set_get_char_rom(const char *devname, uint8_t (FunctionClass::*cb)(uint8_t, int), const char *name) - { - set_get_char_rom(get_char_rom_delegate(cb, name, devname, static_cast<FunctionClass *>(nullptr))); - } - template <class FunctionClass> void set_get_char_rom(uint8_t (FunctionClass::*cb)(uint8_t, int), const char *name) - { - set_get_char_rom(get_char_rom_delegate(cb, name, nullptr, static_cast<FunctionClass *>(nullptr))); - } protected: mc6847_friend_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, @@ -451,19 +479,16 @@ private: emu_timer *m_hsync_off_timer; emu_timer *m_fsync_timer; -protected: - const double m_tpfs; - -private: // incidentals - const int m_divider; + double m_tpfs; + int m_divider; int m_field_sync_falling_edge_scanline; bool m_wide; bool m_video_changed; uint16_t m_top_border_scanlines; uint16_t m_body_scanlines; bool m_recording_scanline; - const bool m_supports_partial_body_scanlines; + bool m_supports_partial_body_scanlines; // video state uint16_t m_physical_scanline; @@ -488,6 +513,7 @@ private: class mc6847_base_device : public mc6847_friend_device { public: + template <class Object> devcb_base &set_input_callback(Object &&cb) { return m_input_cb.set_callback(std::forward<Object>(cb)); } auto input_callback() { return m_input_cb.bind(); } void set_get_fixed_mode(uint8_t mode) { m_fixed_mode = mode; } @@ -498,6 +524,18 @@ public: updating is complete, end_update() */ uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); + template <typename T, typename U> + static screen_device &add_pal_screen(machine_config &config, T &&screen_tag, U &&mc_tag) + { + screen_device &screen(SCREEN(config, std::forward<T>(screen_tag), SCREEN_TYPE_RASTER)); + screen.set_screen_update(std::forward<U>(mc_tag), FUNC(mc6847_base_device::screen_update)); + screen.set_refresh_hz(50); + screen.set_size(320, 243); + screen.set_visarea(0, 320-1, 1, 241-1); + screen.set_vblank_time(0); + return screen; + } + // 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); } @@ -512,7 +550,6 @@ 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); // device-level overrides - virtual void device_config_complete() override; virtual void device_start() override; virtual void device_reset() override; virtual ioport_constructor device_input_ports() const override; diff --git a/src/devices/video/mm5445.cpp b/src/devices/video/mm5445.cpp deleted file mode 100644 index 6b857ed19b3..00000000000 --- a/src/devices/video/mm5445.cpp +++ /dev/null @@ -1,106 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:hap -/* - - National Semiconductor MM5445 series VFD Driver - - TODO: - - brightness control input pin (sets output voltage level) - -*/ - -#include "emu.h" -#include "video/mm5445.h" - - -DEFINE_DEVICE_TYPE(MM5445, mm5445_device, "mm5445", "MM5445 VFD Driver") -DEFINE_DEVICE_TYPE(MM5446, mm5446_device, "mm5446", "MM5446 VFD Driver") -DEFINE_DEVICE_TYPE(MM5447, mm5447_device, "mm5447", "MM5447 VFD Driver") -DEFINE_DEVICE_TYPE(MM5448, mm5448_device, "mm5448", "MM5448 VFD Driver") - -//------------------------------------------------- -// constructor -//------------------------------------------------- - -mm5445_device::mm5445_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 outpins) : - device_t(mconfig, type, tag, owner, clock), - m_outmask((u64(1) << outpins) - 1), - m_write_output(*this) -{ } - -mm5445_device::mm5445_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : - mm5445_device(mconfig, MM5445, tag, owner, clock, 33) -{ } - -mm5446_device::mm5446_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : - mm5445_device(mconfig, MM5446, tag, owner, clock, 34) -{ } - -mm5447_device::mm5447_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : - mm5445_device(mconfig, MM5447, tag, owner, clock, 34) -{ } - -mm5448_device::mm5448_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : - mm5445_device(mconfig, MM5448, tag, owner, clock, 35) -{ } - - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void mm5445_device::device_start() -{ - // resolve callbacks - m_write_output.resolve_safe(); - - // zerofill - m_clk = 0; - m_enable = 0; - m_data = 0; - m_shiftreg = 0; - m_shiftcount = 0; - - // register for savestates - save_item(NAME(m_clk)); - save_item(NAME(m_enable)); - save_item(NAME(m_data)); - save_item(NAME(m_shiftreg)); - save_item(NAME(m_shiftcount)); -} - - -//------------------------------------------------- -// handlers -//------------------------------------------------- - -WRITE_LINE_MEMBER(mm5445_device::clock_w) -{ - state = (state) ? 1 : 0; - bool rise = state && !m_clk; - m_clk = state; - - // clock on rising edge - if (rise) - { - u64 data_in = u64(m_data & ~m_enable) << 34; - u64 lead_in = ~m_shiftreg & data_in; - m_shiftreg = (m_shiftreg & ((u64(1) << 34) - 1)) | data_in; - - // leading 1 triggers shift start - if (m_shiftcount == 0 && !lead_in) - return; - - // output on 35th clock - if (m_shiftcount == 35) - { - m_shiftcount = 0; - m_write_output(0, m_shiftreg & m_outmask, ~u64(0)); - } - else - { - m_shiftreg >>= 1; - m_shiftcount++; - } - } -} diff --git a/src/devices/video/mm5445.h b/src/devices/video/mm5445.h deleted file mode 100644 index 7d16d4f2ee2..00000000000 --- a/src/devices/video/mm5445.h +++ /dev/null @@ -1,101 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:hap -/* - - National Semiconductor MM5445 series VFD Driver - -*/ - -#ifndef MAME_VIDEO_MM5445_H -#define MAME_VIDEO_MM5445_H - -#pragma once - -// pinout reference - -/* - ____ ____ - VDD 1 |* \_/ | 40 O18 - O17 2 | | 39 O19 - O16 3 | | 38 O20 - O15 4 | | 37 O21 - O14 5 | | 36 O22 - O13 6 | | 35 O23 - O12 7 | | 34 O24 - O11 8 | | 33 O25 - O10 9 | | 32 O26 - O9 10 | MM5445N | 31 O27 - O8 11 | | 30 O28 - O7 12 | | 29 O29 - O6 13 | | 28 O30 - O5 14 | | 27 O31 - O4 15 | | 26 O32 - O3 16 | | 25 O33 - O2 17 | | 24 BRIGHTNESS CONTROL - O1 18 | | 23 _DATA ENABLE - VGG 19 | | 22 DATA IN - VSS 20 |___________| 21 CLOCK IN - - O# = OUTPUT BIT # - MM5446, MM5448 don't have the brightness control pin, an extra output pin instead - MM5447, MM5448 don't have the data enable pin(always enabled), but another extra output pin -*/ - - -class mm5445_device : public device_t -{ -public: - mm5445_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0); - - // configuration helpers - auto output_cb() { return m_write_output.bind(); } - - DECLARE_WRITE_LINE_MEMBER(clock_w); - DECLARE_WRITE_LINE_MEMBER(enable_w) { m_enable = (state) ? 1 : 0; } // active low, unused on MM5447 and MM5448 - DECLARE_WRITE_LINE_MEMBER(data_w) { m_data = (state) ? 1 : 0; } - -protected: - mm5445_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 outpins); - - // device-level overrides - virtual void device_start() override; - - const u64 m_outmask; - - int m_clk; // input pin state - int m_enable; // " - int m_data; // " - - u64 m_shiftreg; - int m_shiftcount; - - // callbacks - devcb_write64 m_write_output; -}; - - -class mm5446_device : public mm5445_device -{ -public: - mm5446_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); -}; - -class mm5447_device : public mm5445_device -{ -public: - mm5447_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); -}; - -class mm5448_device : public mm5445_device -{ -public: - mm5448_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); -}; - - -DECLARE_DEVICE_TYPE(MM5445, mm5445_device) -DECLARE_DEVICE_TYPE(MM5446, mm5446_device) -DECLARE_DEVICE_TYPE(MM5447, mm5447_device) -DECLARE_DEVICE_TYPE(MM5448, mm5448_device) - -#endif // MAME_VIDEO_MM5445_H diff --git a/src/devices/video/mos6566.cpp b/src/devices/video/mos6566.cpp index b88cad06c64..a671448a4ab 100644 --- a/src/devices/video/mos6566.cpp +++ b/src/devices/video/mos6566.cpp @@ -227,14 +227,12 @@ DEFINE_DEVICE_TYPE(MOS8566, mos8566_device, "mos8566", "MOS 8566 VIC-II") // default address maps void mos6566_device::mos6566_videoram_map(address_map &map) { - if (!has_configured_map(0)) - map(0x0000, 0x3fff).ram(); + map(0x0000, 0x3fff).ram(); } void mos6566_device::mos6566_colorram_map(address_map &map) { - if (!has_configured_map(1)) - map(0x000, 0x3ff).ram(); + map(0x000, 0x3ff).ram(); } @@ -589,8 +587,8 @@ mos6566_device::mos6566_device(const machine_config &mconfig, device_type type, device_execute_interface(mconfig, *this), m_icount(0), m_variant(variant), - m_videoram_space_config("videoram", ENDIANNESS_LITTLE, 8, 14, 0, address_map_constructor(FUNC(mos6566_device::mos6566_videoram_map), this)), - m_colorram_space_config("colorram", ENDIANNESS_LITTLE, 8, 10, 0, address_map_constructor(FUNC(mos6566_device::mos6566_colorram_map), this)), + m_videoram_space_config("videoram", ENDIANNESS_LITTLE, 8, 14, 0, address_map_constructor(), address_map_constructor(FUNC(mos6566_device::mos6566_videoram_map), this)), + m_colorram_space_config("colorram", ENDIANNESS_LITTLE, 8, 10, 0, address_map_constructor(), address_map_constructor(FUNC(mos6566_device::mos6566_colorram_map), this)), m_write_irq(*this), m_write_ba(*this), m_write_aec(*this), @@ -2448,7 +2446,7 @@ uint32_t mos6566_device::screen_update(screen_device &screen, bitmap_rgb32 &bitm // read - //------------------------------------------------- -uint8_t mos6566_device::read(offs_t offset) +READ8_MEMBER( mos6566_device::read ) { uint8_t val = 0; @@ -2593,7 +2591,7 @@ uint8_t mos6566_device::read(offs_t offset) // write - //------------------------------------------------- -void mos6566_device::write(offs_t offset, uint8_t data) +WRITE8_MEMBER( mos6566_device::write ) { DBG_LOG(2, "vic write", ("%.2x:%.2x\n", offset, data)); offset &= 0x3f; diff --git a/src/devices/video/mos6566.h b/src/devices/video/mos6566.h index d1d7338e151..6f3a52dbab5 100644 --- a/src/devices/video/mos6566.h +++ b/src/devices/video/mos6566.h @@ -199,8 +199,8 @@ public: virtual space_config_vector memory_space_config() const override; - uint8_t read(offs_t offset); - void write(offs_t offset, uint8_t data); + DECLARE_READ8_MEMBER( read ); + DECLARE_WRITE8_MEMBER( write ); DECLARE_WRITE_LINE_MEMBER( lp_w ); diff --git a/src/devices/video/msm6222b.h b/src/devices/video/msm6222b.h index 7a2cb00fd89..9cf3623e25f 100644 --- a/src/devices/video/msm6222b.h +++ b/src/devices/video/msm6222b.h @@ -15,6 +15,11 @@ #pragma once +#define MCFG_MSM6222B_ADD( _tag ) \ + MCFG_DEVICE_ADD( _tag, MSM6222B, 0 ) + +#define MCFG_MSM6222B_01_ADD( _tag ) \ + MCFG_DEVICE_ADD( _tag, MSM6222B_01, 0 ) class msm6222b_device : public device_t { public: diff --git a/src/devices/video/msm6255.cpp b/src/devices/video/msm6255.cpp index b1c83556103..ffca4414314 100644 --- a/src/devices/video/msm6255.cpp +++ b/src/devices/video/msm6255.cpp @@ -63,8 +63,7 @@ void msm6255_device::map(address_map &map) // default address map void msm6255_device::msm6255(address_map &map) { - if (!has_configured_map(0)) - map(0x00000, 0xfffff).ram(); + map(0x00000, 0xfffff).ram(); } @@ -81,7 +80,7 @@ msm6255_device::msm6255_device(const machine_config &mconfig, const char *tag, d device_t(mconfig, MSM6255, tag, owner, clock), device_memory_interface(mconfig, *this), device_video_interface(mconfig, *this), - m_space_config("videoram", ENDIANNESS_LITTLE, 8, 20, 0, address_map_constructor(FUNC(msm6255_device::msm6255), this)), + m_space_config("videoram", ENDIANNESS_LITTLE, 8, 20, 0, address_map_constructor(), address_map_constructor(FUNC(msm6255_device::msm6255), this)), m_cursor(0) { } diff --git a/src/devices/video/nt7534.h b/src/devices/video/nt7534.h index 75390f8acaa..06e37d2bd26 100644 --- a/src/devices/video/nt7534.h +++ b/src/devices/video/nt7534.h @@ -12,6 +12,9 @@ #pragma once +#define MCFG_NT7534_PIXEL_UPDATE_CB(_class, _method) \ + downcast<nt7534_device &>(*device).set_pixel_update_cb(nt7534_device::pixel_update_delegate(&_class::_method, #_class "::" #_method, this)); + //************************************************************************** // TYPE DEFINITIONS //************************************************************************** @@ -29,7 +32,7 @@ public: // construction/destruction nt7534_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); - template <typename... T> void set_pixel_update_cb(T &&... args) { m_pixel_update_cb = pixel_update_delegate(std::forward<T>(args)...); } + template <typename Object> void set_pixel_update_cb(Object &&cb) { m_pixel_update_cb = std::forward<Object>(cb); } // device interface virtual DECLARE_WRITE8_MEMBER(write); diff --git a/src/devices/video/pc_vga.cpp b/src/devices/video/pc_vga.cpp index 1170693a2db..9bf529f7213 100644 --- a/src/devices/video/pc_vga.cpp +++ b/src/devices/video/pc_vga.cpp @@ -2220,16 +2220,14 @@ WRITE8_MEMBER(vga_device::mem_linear_w) // device_add_mconfig - add device configuration //------------------------------------------------- -void ati_vga_device::device_add_mconfig(machine_config &config) -{ - MACH8(config, "8514a", 0).set_vga_owner(); +MACHINE_CONFIG_START(ati_vga_device::device_add_mconfig) + MCFG_MACH8_ADD_OWNER("8514a") EEPROM_93C46_16BIT(config, "ati_eeprom"); -} +MACHINE_CONFIG_END -void s3_vga_device::device_add_mconfig(machine_config &config) -{ - IBM8514A(config, "8514a", 0).set_vga_owner(); -} +MACHINE_CONFIG_START(s3_vga_device::device_add_mconfig) + MCFG_8514A_ADD_OWNER("8514a") +MACHINE_CONFIG_END /****************************************** diff --git a/src/devices/video/pc_vga.h b/src/devices/video/pc_vga.h index bab15da5673..afde9bfdfd6 100644 --- a/src/devices/video/pc_vga.h +++ b/src/devices/video/pc_vga.h @@ -415,6 +415,14 @@ private: // device type definition DECLARE_DEVICE_TYPE(IBM8514A, ibm8514a_device) +#define MCFG_8514A_ADD(_tag, _param) \ + MCFG_DEVICE_ADD(_tag, IBM8514A, 0) \ + downcast<ibm8514a_device*>(device)->set_vga(_param); + +#define MCFG_8514A_ADD_OWNER(_tag) \ + MCFG_DEVICE_ADD(_tag, IBM8514A, 0) \ + downcast<ibm8514a_device*>(device)->set_vga_owner(); + class mach8_device : public ibm8514a_device { @@ -488,6 +496,13 @@ private: // device type definition DECLARE_DEVICE_TYPE(MACH8, mach8_device) +#define MCFG_MACH8_ADD(_tag, _param) \ + MCFG_DEVICE_ADD(_tag, MACH8, 0) \ + downcast<mach8_device*>(device)->set_vga(_param); + +#define MCFG_MACH8_ADD_OWNER(_tag) \ + MCFG_DEVICE_ADD(_tag, MACH8, 0) \ + downcast<mach8_device*>(device)->set_vga_owner(); // ======================> tseng_vga_device diff --git a/src/devices/video/pcd8544.h b/src/devices/video/pcd8544.h index 069984e9483..fee6fad00d8 100644 --- a/src/devices/video/pcd8544.h +++ b/src/devices/video/pcd8544.h @@ -18,6 +18,12 @@ #define PCD8544_SCREEN_UPDATE(name) void name(device_t &device, bitmap_ind16 &bitmap, const rectangle &cliprect , uint8_t *vram, int inv) +#define MCFG_PCD8544_ADD( _tag ) \ + MCFG_DEVICE_ADD( _tag, PCD8544, 0 ) + +#define MCFG_PCD8544_SCREEN_UPDATE_CALLBACK(_class, _method) \ + downcast<pcd8544_device &>(*device).set_screen_update_cb(pcd8544_device::screen_update_delegate(&_class::_method, #_class "::" #_method, this)); + // ======================> pcd8544_device @@ -28,7 +34,7 @@ public: // construction/destruction pcd8544_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - template <typename... T> void set_screen_update_cb(T &&... args) { m_screen_update_cb = screen_update_delegate(std::forward<T>(args)...); } + template <typename Object> void set_screen_update_cb(Object &&cb) { m_screen_update_cb = std::forward<Object>(cb); } // device interface DECLARE_WRITE_LINE_MEMBER(sdin_w); diff --git a/src/devices/video/ppu2c0x.cpp b/src/devices/video/ppu2c0x.cpp index 8aa57660318..341271ed6bf 100644 --- a/src/devices/video/ppu2c0x.cpp +++ b/src/devices/video/ppu2c0x.cpp @@ -89,12 +89,9 @@ DEFINE_DEVICE_TYPE(PPU_2C05_04, ppu2c05_04_device, "ppu2c05_04", "2C05_04 PPU") // default address map void ppu2c0x_device::ppu2c0x(address_map &map) { - if (!has_configured_map(0)) - { - map(0x0000, 0x3eff).ram(); - map(0x3f00, 0x3fff).rw(FUNC(ppu2c0x_device::palette_read), FUNC(ppu2c0x_device::palette_write)); + map(0x0000, 0x3eff).ram(); + map(0x3f00, 0x3fff).rw(FUNC(ppu2c0x_device::palette_read), FUNC(ppu2c0x_device::palette_write)); // AM_RANGE(0x0000, 0x3fff) AM_RAM - } } //------------------------------------------------- @@ -128,7 +125,7 @@ ppu2c0x_device::ppu2c0x_device(const machine_config &mconfig, device_type type, , device_memory_interface(mconfig, *this) , device_video_interface(mconfig, *this) , device_palette_interface(mconfig, *this) - , m_space_config("videoram", ENDIANNESS_LITTLE, 8, 17, 0, address_map_constructor(FUNC(ppu2c0x_device::ppu2c0x), this)) + , m_space_config("videoram", ENDIANNESS_LITTLE, 8, 17, 0, address_map_constructor(), address_map_constructor(FUNC(ppu2c0x_device::ppu2c0x), this)) , m_cpu(*this, finder_base::DUMMY_TAG) , m_scanline(0) // reset the scanline count , m_int_callback(*this) @@ -232,7 +229,7 @@ void ppu2c0x_device::device_start() /* initialize the scanline handling portion */ m_scanline_timer->adjust(screen().time_until_pos(1)); - m_hblank_timer->adjust(m_cpu->cycles_to_attotime(260) / 3); // ??? FIXME - hardcoding NTSC, need better calculation + m_hblank_timer->adjust(m_cpu->cycles_to_attotime(86.67)); // ??? FIXME - hardcoding NTSC, need better calculation m_nmi_timer->adjust(attotime::never); /* allocate a screen bitmap, videomem and spriteram, a dirtychar array and the monochromatic colortable */ @@ -561,7 +558,7 @@ void ppu2c0x_device::device_timer(emu_timer &timer, device_timer_id id, int para next_scanline = 0; // Call us back when the hblank starts for this scanline - m_hblank_timer->adjust(m_cpu->cycles_to_attotime(260) / 3); // ??? FIXME - hardcoding NTSC, need better calculation + m_hblank_timer->adjust(m_cpu->cycles_to_attotime(86.67)); // ??? FIXME - hardcoding NTSC, need better calculation // trigger again at the start of the next scanline m_scanline_timer->adjust(screen().time_until_pos(next_scanline * m_scan_scale)); diff --git a/src/devices/video/ps2gs.cpp b/src/devices/video/ps2gs.cpp index 298b3779bbe..79ba24339d2 100644 --- a/src/devices/video/ps2gs.cpp +++ b/src/devices/video/ps2gs.cpp @@ -52,10 +52,9 @@ ps2_gs_device::~ps2_gs_device() { } -void ps2_gs_device::device_add_mconfig(machine_config &config) -{ - SONYPS2_GIF(config, m_gif, clock(), DEVICE_SELF, m_vu1); -} +MACHINE_CONFIG_START(ps2_gs_device::device_add_mconfig) + MCFG_DEVICE_ADD(m_gif, SONYPS2_GIF, clock(), DEVICE_SELF, m_vu1) +MACHINE_CONFIG_END void ps2_gs_device::device_start() { diff --git a/src/devices/video/ramdac.cpp b/src/devices/video/ramdac.cpp index d651235f60c..dc45e106711 100644 --- a/src/devices/video/ramdac.cpp +++ b/src/devices/video/ramdac.cpp @@ -19,13 +19,10 @@ // default address map void ramdac_device::ramdac_palram(address_map &map) { - if (!has_configured_map(0)) - { - map(0x000, 0x0ff).ram(); // R bank - map(0x100, 0x1ff).ram(); // G bank - map(0x200, 0x2ff).ram(); // B bank - map(0x300, 0x3ff).noprw(); - } + map(0x000, 0x0ff).ram(); // R bank + map(0x100, 0x1ff).ram(); // G bank + map(0x200, 0x2ff).ram(); // B bank + map(0x300, 0x3ff).noprw(); } //************************************************************************** @@ -47,7 +44,7 @@ DEFINE_DEVICE_TYPE(RAMDAC, ramdac_device, "ramdac", "RAMDAC") ramdac_device::ramdac_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, RAMDAC, tag, owner, clock), device_memory_interface(mconfig, *this), - m_space_config("videoram", ENDIANNESS_LITTLE, 8, 10, 0, address_map_constructor(FUNC(ramdac_device::ramdac_palram), this)), + m_space_config("videoram", ENDIANNESS_LITTLE, 8, 10, 0, address_map_constructor(), address_map_constructor(FUNC(ramdac_device::ramdac_palram), this)), m_palette(*this, finder_base::DUMMY_TAG), m_color_base(0), m_split_read_reg(0) diff --git a/src/devices/video/saa5050.h b/src/devices/video/saa5050.h index a9bb680f347..6e1aa5cec6a 100644 --- a/src/devices/video/saa5050.h +++ b/src/devices/video/saa5050.h @@ -29,6 +29,21 @@ #pragma once + + +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define MCFG_SAA5050_D_CALLBACK(_read) \ + downcast<saa5050_device &>(*device).set_d_rd_callback(DEVCB_##_read); + + +#define MCFG_SAA5050_SCREEN_SIZE(_cols, _rows, _size) \ + downcast<saa5050_device &>(*device).set_screen_size(_cols, _rows, _size); + + + //************************************************************************** // TYPE DEFINITIONS //************************************************************************** @@ -43,6 +58,7 @@ public: void set_screen_size(int cols, int rows, int size) { m_cols = cols; m_rows = rows; m_size = size; } + template <class Object> devcb_base &set_d_rd_callback(Object &&cb) { return m_read_d.set_callback(std::forward<Object>(cb)); } auto d_cb() { return m_read_d.bind(); } // optional information overrides diff --git a/src/devices/video/scn2674.cpp b/src/devices/video/scn2674.cpp index 1e6cf3d68b5..9baae770f4c 100644 --- a/src/devices/video/scn2674.cpp +++ b/src/devices/video/scn2674.cpp @@ -25,8 +25,7 @@ DEFINE_DEVICE_TYPE(SCN2674, scn2674_device, "scn2674", "Signetics SCN2674 AVDC") // default address map void scn2674_device::scn2674_vram(address_map &map) { - if (!has_configured_map(0)) - map(0x0000, (1 << space_config(0)->addr_width()) - 1).noprw(); + map(0x0000, (1 << space_config(0)->addr_width()) - 1).noprw(); } scn2672_device::scn2672_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) @@ -45,15 +44,12 @@ scn2674_device::scn2674_device(const machine_config &mconfig, device_type type, , device_memory_interface(mconfig, *this) , m_intr_cb(*this) , m_breq_cb(*this) - , m_mbc_cb(*this) - , m_mbc_char_cb(*this) - , m_mbc_attr_cb(*this) , m_IR_pointer(0) , m_screen1_address(0), m_screen2_address(0) , m_cursor_address(0) , m_irq_register(0), m_status_register(0), m_irq_mask(0) , m_gfx_enabled(false) - , m_display_enabled(false), m_dadd_enabled(false), m_display_enabled_field(false), m_display_enabled_scanline(false) + , m_display_enabled(false), m_display_enabled_field(false), m_display_enabled_scanline(false) , m_cursor_enabled(false) , m_hpixels_per_column(0) , m_double_ht_wd(false) @@ -87,11 +83,9 @@ scn2674_device::scn2674_device(const machine_config &mconfig, device_type type, , m_char_buffer(0), m_attr_buffer(0) , m_linecounter(0), m_address(0), m_start1change(0) , m_scanline_timer(nullptr) - , m_breq_timer(nullptr) - , m_vblank_timer(nullptr) , m_char_space(nullptr), m_attr_space(nullptr) - , m_char_space_config("charram", ENDIANNESS_LITTLE, 8, extend_addressing ? 16 : 14, 0, address_map_constructor(FUNC(scn2674_device::scn2674_vram), this)) - , m_attr_space_config("attrram", ENDIANNESS_LITTLE, 8, extend_addressing ? 16 : 14, 0) + , m_char_space_config("charram", ENDIANNESS_LITTLE, 8, extend_addressing ? 16 : 14, 0, address_map_constructor(), address_map_constructor(FUNC(scn2674_device::scn2674_vram), this)) + , m_attr_space_config("attrram", ENDIANNESS_LITTLE, 8, extend_addressing ? 16 : 14, 0, address_map_constructor(), address_map_constructor(FUNC(scn2674_device::scn2674_vram), this)) { } @@ -111,12 +105,7 @@ void scn2674_device::device_start() m_display_cb.bind_relative_to(*owner()); m_intr_cb.resolve_safe(); m_breq_cb.resolve_safe(); - m_mbc_cb.resolve_safe(); - m_mbc_char_cb.resolve(); - m_mbc_attr_cb.resolve(); - m_scanline_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(scn2674_device::scanline_timer), this)); - m_breq_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(scn2674_device::breq_timer), this)); - m_vblank_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(scn2674_device::vblank_timer), this)); + m_scanline_timer = timer_alloc(TIMER_SCANLINE); screen().register_screen_bitmap(m_bitmap); m_char_space = &space(0); @@ -134,7 +123,6 @@ void scn2674_device::device_start() save_item(NAME(m_irq_mask)); save_item(NAME(m_gfx_enabled)); save_item(NAME(m_display_enabled)); - save_item(NAME(m_dadd_enabled)); save_item(NAME(m_display_enabled_field)); save_item(NAME(m_display_enabled_scanline)); save_item(NAME(m_cursor_enabled)); @@ -186,7 +174,6 @@ void scn2674_device::device_reset() m_irq_mask = 0; m_gfx_enabled = false; m_display_enabled = false; - m_dadd_enabled = false; m_display_enabled_field = false; m_display_enabled_scanline = false; m_cursor_enabled = false; @@ -564,15 +551,9 @@ void scn2674_device::set_display_enabled(bool enabled, int n) m_display_enabled = false; if (n == 1) - { LOGMASKED(LOG_COMMAND, "%s: Display off - float DADD bus\n", machine().describe_context()); - m_dadd_enabled = false; - } else - { LOGMASKED(LOG_COMMAND, "%s: Display off - no float DADD bus\n", machine().describe_context()); - m_dadd_enabled = true; - } } else { @@ -729,9 +710,6 @@ void scn2674_device::write_delayed_command(uint8_t data) case 0xbb: // write from cursor address to pointer address // TODO: transfer only during blank - m_display_enabled = false; - m_display_enabled_field = true; - m_display_enabled_scanline = false; for (i = m_cursor_address; i != m_screen2_address; i = ((i + 1) & 0xffff)) { m_char_space->write_byte(i, m_char_buffer); @@ -784,17 +762,13 @@ void scn2674_device::write_command(uint8_t data) m_IR_pointer = 0; m_irq_register = 0x00; m_status_register = 0x20; // RDFLG activated + m_linecounter = 0; m_irq_mask = 0x00; m_gfx_enabled = false; m_display_enabled = false; - m_dadd_enabled = false; m_cursor_enabled = false; m_use_row_table = false; m_intr_cb(CLEAR_LINE); - m_breq_cb(CLEAR_LINE); - m_mbc_cb(0); - m_breq_timer->adjust(attotime::never); - m_vblank_timer->adjust(attotime::never); } else { @@ -937,8 +911,6 @@ void scn2674_device::write(offs_t offset, uint8_t data) m_screen1_address = (m_screen1_address & 0x3f00) | data; if (!screen().vblank()) m_start1change = (m_linecounter / m_scanline_per_char_row) + 1; - else - m_start1change = 0; break; case 3: @@ -952,8 +924,6 @@ void scn2674_device::write(offs_t offset, uint8_t data) } if (!screen().vblank()) m_start1change = (m_linecounter / m_scanline_per_char_row) + 1; - else - m_start1change = 0; break; case 4: @@ -997,200 +967,154 @@ void scn2674_device::recompute_parameters() rectangle visarea(0, max_visible_x, 0, max_visible_y); screen().configure(horiz_pix_total, vert_pix_total, visarea, refresh.as_attoseconds()); - m_linecounter = screen().vpos(); - m_scanline_timer->adjust(screen().time_until_pos((m_linecounter + 1) % vert_pix_total, 0), 0, screen().scan_period()); + m_scanline_timer->adjust(screen().time_until_pos(0, 0), 0, screen().scan_period()); } -TIMER_CALLBACK_MEMBER(scn2674_device::scanline_timer) +void scn2674_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { - int dw = m_double_ht_wd ? m_double[0] : 0; // double width - if (((m_display_enabled_scanline) || (m_display_enabled_field && !m_interlace_enable)) && (!m_display_enabled)) + switch (id) { - m_display_enabled = true; - m_dadd_enabled = true; - m_display_enabled_scanline = false; - m_display_enabled_field = false; - } + case TIMER_SCANLINE: + { + int dw = m_double_ht_wd ? m_double[0] : 0; // double width + if (((m_display_enabled_scanline) || (m_display_enabled_field && !m_interlace_enable)) && (!m_display_enabled)) + { + m_display_enabled = true; + m_display_enabled_scanline = false; + m_display_enabled_field = false; + } - m_linecounter++; + m_linecounter++; - if (m_linecounter >= screen().height()) - { - m_linecounter = 0; - m_address = m_screen1_address; - } + if (m_linecounter >= screen().height()) + { + m_linecounter = 0; + m_address = m_screen1_address; + } - bool lastscan = m_linecounter == (m_rows_per_screen * m_scanline_per_char_row) - 1; - if (lastscan) - { - int horz_sync_begin = 2 * (m_equalizing_constant + 2 * m_horz_sync_width) - m_horz_sync_width - m_horz_back_porch; - m_vblank_timer->adjust(clocks_to_attotime(horz_sync_begin)); - } + if (m_linecounter == (m_rows_per_screen * m_scanline_per_char_row)) + { + m_status_register |= 0x10; + if (BIT(m_irq_mask, 4)) + { + LOGMASKED(LOG_INTR, "V-Blank interrupt at line %d\n", m_linecounter); + m_irq_register |= 0x10; + m_intr_cb(ASSERT_LINE); + } + } - if (m_linecounter >= (m_rows_per_screen * m_scanline_per_char_row)) - { - if (m_buffer_mode_select == 3 && m_linecounter == (screen().height() - 1)) - m_breq_timer->adjust(clocks_to_attotime(m_character_per_row + 1), ASSERT_LINE); - return; - } + if (m_linecounter >= (m_rows_per_screen * m_scanline_per_char_row)) + break; - int charrow = m_linecounter % m_scanline_per_char_row; - int tilerow = charrow; + int charrow = m_linecounter % m_scanline_per_char_row; + int tilerow = charrow; - // should be triggered at the start of each ROW (line zero for that row) - if (charrow == 0) - { - m_status_register |= 0x08; - if (BIT(m_irq_mask, 3)) - { - LOGMASKED(LOG_INTR, "Line Zero interrupt at line %d\n", m_linecounter); - m_irq_register |= 0x08; - m_intr_cb(ASSERT_LINE); - } - if (m_buffer_mode_select == 3) - { - m_mbc_cb(1); - m_breq_timer->adjust(clocks_to_attotime(m_character_per_row + 1), CLEAR_LINE); - } - } - else if (m_buffer_mode_select == 3 && charrow == (m_scanline_per_char_row - 1) && !lastscan) - m_breq_timer->adjust(clocks_to_attotime(m_character_per_row + 1), ASSERT_LINE); + // should be triggered at the start of each ROW (line zero for that row) + if (charrow == 0) + { + m_status_register |= 0x08; + if (BIT(m_irq_mask, 3)) + { + LOGMASKED(LOG_INTR, "Line Zero interrupt at line %d\n", m_linecounter); + m_irq_register |= 0x08; + m_intr_cb(ASSERT_LINE); + } + if (m_buffer_mode_select == 3) + m_breq_cb(ASSERT_LINE); + } + else if (m_buffer_mode_select == 3) + m_breq_cb(CLEAR_LINE); - // Handle screen splits - for (int s = 0; s < 2; s++) - { - if ((m_linecounter == ((m_split_register[s] + 1) * m_scanline_per_char_row)) && m_linecounter) - { - uint8_t flag = (s == 0) ? 0x04 : 0x01; - m_status_register |= flag; - if ((m_irq_mask & flag) != 0) + // Handle screen splits + for (int s = 0; s < 2; s++) { - LOGMASKED(LOG_INTR, "Split Screen %d interrupt at line %d\n", s + 1, m_linecounter); - m_irq_register |= flag; - m_intr_cb(ASSERT_LINE); + if ((m_linecounter == ((m_split_register[s] + 1) * m_scanline_per_char_row)) && m_linecounter) + { + uint8_t flag = (s == 0) ? 0x04 : 0x01; + m_status_register |= flag; + if ((m_irq_mask & flag) != 0) + { + LOGMASKED(LOG_INTR, "Split Screen %d interrupt at line %d\n", s + 1, m_linecounter); + m_irq_register |= flag; + m_intr_cb(ASSERT_LINE); + } + if (m_spl[s]) + m_address = m_screen2_address; + if (!m_double_ht_wd) + dw = m_double[s]; + } } - if (m_spl[s]) - m_address = m_screen2_address; - if (!m_double_ht_wd) - dw = m_double[s]; - } - } - // WY-50 requires that normal row buffering take place even after a "display off" command - if (!m_dadd_enabled) - return; + if (!m_display_enabled) + break; - if (m_use_row_table) - { - if (m_double_ht_wd) - dw = m_screen1_address >> 14; - if (!charrow) - { - uint16_t addr = m_screen2_address; - uint16_t line = m_char_space->read_word(addr); - m_screen1_address = line; - if (m_double_ht_wd) + if (m_use_row_table) { - dw = line >> 14; - line &= ~0xc000; + if (m_double_ht_wd) + dw = m_screen1_address >> 14; + if (!charrow) + { + uint16_t addr = m_screen2_address; + uint16_t line = m_char_space->read_word(addr); + m_screen1_address = line; + if (m_double_ht_wd) + { + dw = line >> 14; + line &= ~0xc000; + } + m_address = line; + addr += 2; + m_screen2_address = addr & 0x3fff; + } + } + else if (m_start1change && (m_start1change == (m_linecounter / m_scanline_per_char_row))) + { + m_address = m_screen1_address; + m_start1change = 0; } - m_address = line; - addr += 2; - m_screen2_address = addr & 0x3fff; - } - } - else if (m_start1change && (m_start1change == (m_linecounter / m_scanline_per_char_row))) - { - m_address = m_screen1_address; - m_start1change = 0; - } - if (dw == 2) - tilerow >>= 1; - else if (dw == 3) - tilerow = (charrow + m_scanline_per_char_row) >> 1; + if (dw == 2) + tilerow >>= 1; + else if (dw == 3) + tilerow = (charrow + m_scanline_per_char_row) >> 1; - uint16_t address = m_address; + uint16_t address = m_address; - const bool mbc = (charrow == 0) && (m_buffer_mode_select == 3); - const bool blink_on = (screen().frame_number() & (m_character_blink_rate_divisor >> 1)) != 0; - for (int i = 0; i < m_character_per_row; i++) - { - u8 charcode, attrcode = 0; - if (mbc && !m_mbc_char_cb.isnull()) - { - // row buffering DMA - charcode = m_mbc_char_cb(address); - m_char_space->write_byte(address, charcode); - if (m_attr_space != nullptr && !m_mbc_attr_cb.isnull()) + for (int i = 0; i < m_character_per_row; i++) { - attrcode = m_mbc_attr_cb(address); - m_attr_space->write_byte(address, attrcode); + bool cursor_on = ((address & 0x3fff) == m_cursor_address); + + if (!m_display_cb.isnull()) + m_display_cb(m_bitmap, + i * m_hpixels_per_column, + m_linecounter, + tilerow, + m_char_space->read_byte(address), + m_attr_space != nullptr ? m_attr_space->read_byte(address) : 0, + address, + (charrow >= m_cursor_first_scanline) && (charrow <= m_cursor_last_scanline) && cursor_on, + dw != 0, + m_gfx_enabled, + charrow == m_cursor_underline_position, + m_cursor_blink && (screen().frame_number() & m_cursor_rate_divisor)); + address = (address + 1) & 0xffff; + + if (address > ((m_display_buffer_last_address << 10) | 0x3ff)) + address = m_display_buffer_first_address; } - } - else - { - charcode = m_char_space->read_byte(address); - if (m_attr_space != nullptr) - attrcode = m_attr_space->read_byte(address); - } - - if (m_display_enabled && !m_display_cb.isnull()) - { - bool cursor_on = ((address & 0x3fff) == m_cursor_address) - && m_cursor_enabled - && (charrow >= m_cursor_first_scanline) - && (charrow <= m_cursor_last_scanline) - && (!m_cursor_blink || (screen().frame_number() & (m_cursor_rate_divisor >> 1)) != 0); - m_display_cb(m_bitmap, - i * m_hpixels_per_column, - m_linecounter, - tilerow, - charcode, - attrcode, - address, - cursor_on, - dw != 0, - m_gfx_enabled, - charrow == m_cursor_underline_position, - blink_on); + if (m_gfx_enabled || (charrow == (m_scanline_per_char_row - 1))) + m_address = address; } - address = (address + 1) & 0xffff; - - if (address > ((m_display_buffer_last_address << 10) | 0x3ff)) - address = m_display_buffer_first_address; - } - - if (!m_display_enabled) - std::fill_n(&m_bitmap.pix32(m_linecounter), m_character_per_row * m_hpixels_per_column, rgb_t::black()); - - if (m_gfx_enabled || (charrow == (m_scanline_per_char_row - 1))) - m_address = address; -} - -TIMER_CALLBACK_MEMBER(scn2674_device::breq_timer) -{ - LOGMASKED(LOG_INTR, "BREQ %sasserted at line %d\n", (param == ASSERT_LINE) ? "" : "de", m_linecounter); - m_breq_cb(param); - if (param == CLEAR_LINE) - m_mbc_cb(0); -} - -TIMER_CALLBACK_MEMBER(scn2674_device::vblank_timer) -{ - m_status_register |= 0x10; - if (BIT(m_irq_mask, 4)) - { - LOGMASKED(LOG_INTR, "V-Blank interrupt at line %d\n", m_linecounter); - m_irq_register |= 0x10; - m_intr_cb(ASSERT_LINE); } } uint32_t scn2674_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { - copybitmap(bitmap, m_bitmap, 0, 0, 0, 0, cliprect); + if (!m_display_enabled) + m_bitmap.fill(rgb_t::black(), cliprect); + else + copybitmap(bitmap, m_bitmap, 0, 0, 0, 0, cliprect); return 0; } diff --git a/src/devices/video/scn2674.h b/src/devices/video/scn2674.h index 2b7367eeed0..3090f740f8d 100644 --- a/src/devices/video/scn2674.h +++ b/src/devices/video/scn2674.h @@ -23,9 +23,6 @@ public: // static configuration auto intr_callback() { return m_intr_cb.bind(); } auto breq_callback() { return m_breq_cb.bind(); } - auto mbc_callback() { return m_mbc_cb.bind(); } - auto mbc_char_callback() { return m_mbc_char_cb.bind(); } - auto mbc_attr_callback() { return m_mbc_attr_cb.bind(); } void set_character_width(int value) { m_hpixels_per_column = value; } template <class FunctionClass> @@ -57,20 +54,14 @@ protected: virtual void device_start() override; virtual void device_reset() override; + virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; virtual space_config_vector memory_space_config() const override; - TIMER_CALLBACK_MEMBER(scanline_timer); - TIMER_CALLBACK_MEMBER(breq_timer); - TIMER_CALLBACK_MEMBER(vblank_timer); - //protected: bitmap_rgb32 m_bitmap; devcb_write_line m_intr_cb; devcb_write_line m_breq_cb; - devcb_write_line m_mbc_cb; - devcb_read8 m_mbc_char_cb; - devcb_read8 m_mbc_attr_cb; uint8_t m_IR_pointer; uint16_t m_screen1_address; @@ -81,7 +72,6 @@ protected: uint8_t m_irq_mask; bool m_gfx_enabled; bool m_display_enabled; - bool m_dadd_enabled; bool m_display_enabled_field; bool m_display_enabled_scanline; bool m_cursor_enabled; @@ -139,12 +129,14 @@ protected: draw_character_delegate m_display_cb; emu_timer *m_scanline_timer; - emu_timer *m_breq_timer; - emu_timer *m_vblank_timer; address_space *m_char_space; address_space *m_attr_space; const address_space_config m_char_space_config; const address_space_config m_attr_space_config; + enum + { + TIMER_SCANLINE + }; }; class scn2672_device : public scn2674_device diff --git a/src/devices/video/sda5708.h b/src/devices/video/sda5708.h index 4237675b95e..eecb36e032c 100644 --- a/src/devices/video/sda5708.h +++ b/src/devices/video/sda5708.h @@ -41,6 +41,13 @@ * */ +///************************************************************************* +// INTERFACE CONFIGURATION MACROS +///************************************************************************* + +#define MCFG_SDA5708_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, SDA5708, 0) + ///************************************************************************* // TYPE DEFINITIONS diff --git a/src/devices/video/sed1200.h b/src/devices/video/sed1200.h index d6590af49ab..521bd4e027c 100644 --- a/src/devices/video/sed1200.h +++ b/src/devices/video/sed1200.h @@ -17,6 +17,17 @@ #pragma once +#define MCFG_SED1200D0A_ADD( _tag ) \ + MCFG_DEVICE_ADD( _tag, SED1200D0A, 0 ) + +#define MCFG_SED1200F0A_ADD( _tag ) \ + MCFG_DEVICE_ADD( _tag, SED1200F0A, 0 ) + +#define MCFG_SED1200D0B_ADD( _tag ) \ + MCFG_DEVICE_ADD( _tag, SED1200D0B, 0 ) + +#define MCFG_SED1200F0B_ADD( _tag ) \ + MCFG_DEVICE_ADD( _tag, SED1200F0B, 0 ) class sed1200_device : public device_t { public: diff --git a/src/devices/video/sed1330.cpp b/src/devices/video/sed1330.cpp index 75eefb18c9d..5015bb0d43b 100644 --- a/src/devices/video/sed1330.cpp +++ b/src/devices/video/sed1330.cpp @@ -68,8 +68,7 @@ DEFINE_DEVICE_TYPE(SED1330, sed1330_device, "sed1330", "Epson SED1330") // default address map void sed1330_device::sed1330(address_map &map) { - if (!has_configured_map(0)) - map(0x0000, 0xffff).ram(); + map(0x0000, 0xffff).ram(); } @@ -146,7 +145,7 @@ sed1330_device::sed1330_device(const machine_config &mconfig, const char *tag, d device_memory_interface(mconfig, *this), device_video_interface(mconfig, *this), m_bf(0), - m_space_config("videoram", ENDIANNESS_LITTLE, 8, 16, 0, address_map_constructor(FUNC(sed1330_device::sed1330), this)) + m_space_config("videoram", ENDIANNESS_LITTLE, 8, 16, 0, address_map_constructor(), address_map_constructor(FUNC(sed1330_device::sed1330), this)) { } diff --git a/src/devices/video/t6a04.h b/src/devices/video/t6a04.h index 38906063f02..0232ffc71a6 100644 --- a/src/devices/video/t6a04.h +++ b/src/devices/video/t6a04.h @@ -65,4 +65,7 @@ private: // device type definition DECLARE_DEVICE_TYPE(T6A04, t6a04_device) +#define MCFG_T6A04_SIZE(_width, _height) \ + downcast<t6a04_device &>(*device).set_size(_width, _height); + #endif // MAME_VIDEO_T6A04_H diff --git a/src/devices/video/tea1002.h b/src/devices/video/tea1002.h index 44898c625ac..067ec5583bc 100644 --- a/src/devices/video/tea1002.h +++ b/src/devices/video/tea1002.h @@ -25,6 +25,15 @@ #pragma once + +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define MCFG_TEA1002_ADD(_tag, _clock) \ + MCFG_DEVICE_ADD(_tag, TEA1002, _clock) + + //************************************************************************** // TYPE DEFINITIONS //************************************************************************** diff --git a/src/devices/video/tlc34076.cpp b/src/devices/video/tlc34076.cpp index 37dd95a40b1..c33b302a3b8 100644 --- a/src/devices/video/tlc34076.cpp +++ b/src/devices/video/tlc34076.cpp @@ -127,7 +127,7 @@ void tlc34076_device::update_pen(uint8_t i) // read - read access //------------------------------------------------- -u8 tlc34076_device::read(offs_t offset) +READ8_MEMBER( tlc34076_device::read ) { uint8_t result; @@ -161,7 +161,7 @@ u8 tlc34076_device::read(offs_t offset) // write - write access //------------------------------------------------- -void tlc34076_device::write(offs_t offset, u8 data) +WRITE8_MEMBER( tlc34076_device::write ) { // uint8_t oldval; diff --git a/src/devices/video/tlc34076.h b/src/devices/video/tlc34076.h index 7c4b021bd27..fb816dd1181 100644 --- a/src/devices/video/tlc34076.h +++ b/src/devices/video/tlc34076.h @@ -41,8 +41,8 @@ public: void set_bits(tlc34076_bits bits) { m_dacbits = bits; } // public interface - u8 read(offs_t offset); - void write(offs_t offset, u8 data); + DECLARE_READ8_MEMBER(read); + DECLARE_WRITE8_MEMBER(write); protected: // device-level overrides @@ -66,6 +66,15 @@ private: }; +/*************************************************************************** + DEVICE CONFIGURATION MACROS +***************************************************************************/ + +#define MCFG_TLC34076_ADD(tag, bits) \ + MCFG_DEVICE_ADD((tag), TLC34076, 0) \ + downcast<tlc34076_device &>(*device).set_bits((tlc34076_device::bits)); + + DECLARE_DEVICE_TYPE(TLC34076, tlc34076_device) #endif // MAME_VIDEO_TLC34076_H diff --git a/src/devices/video/tms34061.cpp b/src/devices/video/tms34061.cpp index 8204facf1a1..397b412e586 100644 --- a/src/devices/video/tms34061.cpp +++ b/src/devices/video/tms34061.cpp @@ -32,7 +32,7 @@ DEFINE_DEVICE_TYPE(TMS34061, tms34061_device, "tms34061", "TI TMS34061 VSC") -tms34061_device::tms34061_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) +tms34061_device::tms34061_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, TMS34061, tag, owner, clock), device_video_interface(mconfig, *this), m_rowshift(0), @@ -64,10 +64,10 @@ void tms34061_device::device_start() m_vrammask = m_vramsize - 1; /* allocate memory for VRAM */ - m_vram = auto_alloc_array_clear(machine(), u8, m_vramsize + 256 * 2); + m_vram = auto_alloc_array_clear(machine(), uint8_t, m_vramsize + 256 * 2); /* allocate memory for latch RAM */ - m_latchram = auto_alloc_array_clear(machine(), u8, m_vramsize + 256 * 2); + m_latchram = auto_alloc_array_clear(machine(), uint8_t, m_vramsize + 256 * 2); /* add some buffer space for VRAM and latch RAM */ m_vram += 256; @@ -171,7 +171,7 @@ TIMER_CALLBACK_MEMBER( tms34061_device::interrupt ) * *************************************/ -void tms34061_device::register_w(offs_t offset, u8 data) +void tms34061_device::register_w(address_space &space, offs_t offset, uint8_t data) { int scanline; int regnum = offset >> 2; @@ -242,10 +242,10 @@ void tms34061_device::register_w(offs_t offset, u8 data) * *************************************/ -u8 tms34061_device::register_r(offs_t offset) +uint8_t tms34061_device::register_r(address_space &space, offs_t offset) { int regnum = offset >> 2; - u16 result; + uint16_t result; /* extract the correct portion of the register */ if (regnum < ARRAY_LENGTH(m_regs)) @@ -364,7 +364,7 @@ void tms34061_device::adjust_xyaddress(int offset) } -void tms34061_device::xypixel_w(int offset, u8 data) +void tms34061_device::xypixel_w(address_space &space, int offset, uint8_t data) { /* determine the offset, then adjust it */ offs_t pixeloffs = m_regs[TMS34061_XYADDRESS]; @@ -384,7 +384,7 @@ void tms34061_device::xypixel_w(int offset, u8 data) } -u8 tms34061_device::xypixel_r(int offset) +uint8_t tms34061_device::xypixel_r(address_space &space, int offset) { /* determine the offset, then adjust it */ offs_t pixeloffs = m_regs[TMS34061_XYADDRESS]; @@ -409,7 +409,7 @@ u8 tms34061_device::xypixel_r(int offset) * *************************************/ -void tms34061_device::write(int col, int row, int func, u8 data) +void tms34061_device::write(address_space &space, int col, int row, int func, uint8_t data) { offs_t offs; @@ -419,12 +419,12 @@ void tms34061_device::write(int col, int row, int func, u8 data) /* both 0 and 2 map to register access */ case 0: case 2: - register_w(col, data); + register_w(space, col, data); break; /* function 1 maps to XY access; col is the address adjustment */ case 1: - xypixel_w(col, data); + xypixel_w(space, col, data); break; /* function 3 maps to direct access */ @@ -471,7 +471,7 @@ void tms34061_device::write(int col, int row, int func, u8 data) } -u8 tms34061_device::read(int col, int row, int func) +uint8_t tms34061_device::read(address_space &space, int col, int row, int func) { int result = 0; offs_t offs; @@ -482,12 +482,12 @@ u8 tms34061_device::read(int col, int row, int func) /* both 0 and 2 map to register access */ case 0: case 2: - result = register_r(col); + result = register_r(space, col); break; /* function 1 maps to XY access; col is the address adjustment */ case 1: - result = xypixel_r(col); + result = xypixel_r(space, col); break; /* function 3 maps to direct access */ @@ -535,13 +535,13 @@ u8 tms34061_device::read(int col, int row, int func) * *************************************/ -u8 tms34061_device::latch_r() +READ8_MEMBER( tms34061_device::latch_r ) { return m_latchdata; } -void tms34061_device::latch_w(u8 data) +WRITE8_MEMBER( tms34061_device::latch_w ) { LOG("tms34061_latch = %02X\n", data); m_latchdata = data; diff --git a/src/devices/video/tms34061.h b/src/devices/video/tms34061.h index 3b3e3d5f552..e4f92e75ac2 100644 --- a/src/devices/video/tms34061.h +++ b/src/devices/video/tms34061.h @@ -15,6 +15,17 @@ #pragma once +#define MCFG_TMS34061_ROWSHIFT(_shift) \ + downcast<tms34061_device &>(*device).set_rowshift(_shift); + +#define MCFG_TMS34061_VRAM_SIZE(_size) \ + downcast<tms34061_device &>(*device).set_vram_size(_size); + +#define MCFG_TMS34061_INTERRUPT_CB(_devcb) \ + downcast<tms34061_device &>(*device).set_interrupt_callback(DEVCB_##_devcb); + + + // ======================> tms34061_device class tms34061_device : public device_t, public device_video_interface @@ -23,35 +34,36 @@ public: /* display state structure */ struct tms34061_display { - u8 blanked; /* true if blanked */ - u8 *vram; /* base of VRAM */ - u8 *latchram; /* base of latch RAM */ - u16 *regs; /* pointer to array of registers */ + uint8_t blanked; /* true if blanked */ + uint8_t *vram; /* base of VRAM */ + uint8_t *latchram; /* base of latch RAM */ + uint16_t *regs; /* pointer to array of registers */ offs_t dispstart; /* display start */ }; // construction/destruction - tms34061_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + tms34061_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - void set_rowshift(u8 rowshift) { m_rowshift = rowshift; } - void set_vram_size(u32 vramsize) { m_vramsize = vramsize; } + void set_rowshift(uint8_t rowshift) { m_rowshift = rowshift; } + void set_vram_size(uint32_t vramsize) { m_vramsize = vramsize; } + template <class Object> devcb_base &set_interrupt_callback(Object &&cb) { return m_interrupt_cb.set_callback(std::forward<Object>(cb)); } auto int_callback() { return m_interrupt_cb.bind(); } /* reads/writes to the 34061 */ - u8 read(int col, int row, int func); - void write(int col, int row, int func, u8 data); + uint8_t read(address_space &space, int col, int row, int func); + void write(address_space &space, int col, int row, int func, uint8_t data); /* latch settings */ - u8 latch_r(); - void latch_w(u8 data); + DECLARE_READ8_MEMBER( latch_r ); + DECLARE_WRITE8_MEMBER( latch_w ); /* video update handling */ void get_display_state(); bool blanked() const { return bool(m_display.blanked); } - u8 const &vram(unsigned row) const { return m_display.vram[row << m_rowshift]; } - u16 xyoffset() const { return m_display.regs[TMS34061_XYOFFSET]; } - u16 xyaddress() const { return m_display.regs[TMS34061_XYADDRESS]; } + uint8_t const &vram(unsigned row) const { return m_display.vram[row << m_rowshift]; } + uint16_t xyoffset() const { return m_display.regs[TMS34061_XYOFFSET]; } + uint16_t xyaddress() const { return m_display.regs[TMS34061_XYADDRESS]; } // TODO: encapsulate this properly tms34061_display m_display; @@ -86,27 +98,27 @@ private: TMS34061_REGCOUNT }; - u8 m_rowshift; /* VRAM address is (row << rowshift) | col */ - u32 m_vramsize; /* size of video RAM */ + uint8_t m_rowshift; /* VRAM address is (row << rowshift) | col */ + uint32_t m_vramsize; /* size of video RAM */ devcb_write_line m_interrupt_cb; /* interrupt gen callback */ - u16 m_regs[TMS34061_REGCOUNT]; - u16 m_xmask; - u8 m_yshift; - u32 m_vrammask; - u8 * m_vram; - u8 * m_latchram; - u8 m_latchdata; - u8 * m_shiftreg; - emu_timer * m_timer; + uint16_t m_regs[TMS34061_REGCOUNT]; + uint16_t m_xmask; + uint8_t m_yshift; + uint32_t m_vrammask; + uint8_t * m_vram; + uint8_t * m_latchram; + uint8_t m_latchdata; + uint8_t * m_shiftreg; + emu_timer * m_timer; void update_interrupts(); TIMER_CALLBACK_MEMBER( interrupt ); - void register_w(offs_t offset, u8 data); - u8 register_r(offs_t offset); + void register_w(address_space &space, offs_t offset, uint8_t data); + uint8_t register_r(address_space &space, offs_t offset); void adjust_xyaddress(int offset); - void xypixel_w(int offset, u8 data); - u8 xypixel_r(int offset); + void xypixel_w(address_space &space, int offset, uint8_t data); + uint8_t xypixel_r(address_space &space, int offset); }; // device type definition diff --git a/src/devices/video/tms3556.cpp b/src/devices/video/tms3556.cpp index 80280fe5364..c856735756f 100644 --- a/src/devices/video/tms3556.cpp +++ b/src/devices/video/tms3556.cpp @@ -59,8 +59,7 @@ DEFINE_DEVICE_TYPE(TMS3556, tms3556_device, "tms3556", "Texas Instruments TMS355 // default address map void tms3556_device::tms3556(address_map &map) { - if (!has_configured_map(0)) - map(0x0000, 0xffff).ram(); + map(0x0000, 0xffff).ram(); } //------------------------------------------------- @@ -112,7 +111,7 @@ tms3556_device::tms3556_device(const machine_config &mconfig, const char *tag, d : device_t(mconfig, TMS3556, tag, owner, clock), device_memory_interface(mconfig, *this), device_video_interface(mconfig, *this), - m_space_config("videoram", ENDIANNESS_LITTLE, 8, 17, 0, address_map_constructor(FUNC(tms3556_device::tms3556), this)), + m_space_config("videoram", ENDIANNESS_LITTLE, 8, 17, 0, address_map_constructor(), address_map_constructor(FUNC(tms3556_device::tms3556), this)), m_reg(0), m_reg2(0), m_reg_access_phase(0), m_row_col_written(0), diff --git a/src/devices/video/tms3556.h b/src/devices/video/tms3556.h index e20e02d09c3..11146f8b21f 100644 --- a/src/devices/video/tms3556.h +++ b/src/devices/video/tms3556.h @@ -19,6 +19,12 @@ /* if DOUBLE_WIDTH set, the horizontal resolution is doubled */ #define TMS3556_DOUBLE_WIDTH 0 +///************************************************************************* +// INTERFACE CONFIGURATION MACROS +///************************************************************************* + +#define MCFG_TMS3556_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, TMS3556, 0) ///************************************************************************* // TYPE DEFINITIONS diff --git a/src/devices/video/tms9927.cpp b/src/devices/video/tms9927.cpp index bc8e187f8e8..9a43cb1f635 100644 --- a/src/devices/video/tms9927.cpp +++ b/src/devices/video/tms9927.cpp @@ -81,7 +81,7 @@ crt5057_device::crt5057_device(const machine_config &mconfig, const char *tag, d void tms9927_device::device_start() { assert(clock() > 0); - if (!(m_hpixels_per_column > 0)) fatalerror("TMS9927: number of pixels per column must be explicitly set using set_char_width()!\n"); + if (!(m_hpixels_per_column > 0)) fatalerror("TMS9927: number of pixels per column must be explicitly set using MCFG_TMS9927_CHAR_WIDTH()!\n"); // resolve callbacks m_write_vsyn.resolve_safe(); diff --git a/src/devices/video/tms9928a.cpp b/src/devices/video/tms9928a.cpp index c068d8b4ce8..bc31b1b1db9 100644 --- a/src/devices/video/tms9928a.cpp +++ b/src/devices/video/tms9928a.cpp @@ -52,11 +52,11 @@ DEFINE_DEVICE_TYPE(EFO90501, efo90501_device, "efo90501", "EFO90501 VDP") */ void tms9928a_device::memmap(address_map &map) { - if (!has_configured_map(0)) - map(0x0000, 0x3fff).ram(); + map.global_mask(0x3fff); + map(0x0000, 0x3fff).ram(); } -tms9928a_device::tms9928a_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint16_t horz_total, bool is_50hz, bool is_reva, bool is_99) +tms9928a_device::tms9928a_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, bool is_50hz, bool is_reva, bool is_99) : device_t(mconfig, type, tag, owner, clock) , device_memory_interface(mconfig, *this) , device_palette_interface(mconfig, *this) @@ -64,11 +64,10 @@ tms9928a_device::tms9928a_device(const machine_config &mconfig, device_type type , m_vram_size(0) , m_out_int_line_cb(*this) , m_out_gromclk_cb(*this) - , m_total_horz(horz_total) , m_50hz(is_50hz) , m_reva(is_reva) , m_99(is_99) - , m_space_config("vram", ENDIANNESS_BIG, 8, 14, 0, address_map_constructor(FUNC(tms9928a_device::memmap), this)) + , m_space_config("vram", ENDIANNESS_BIG, 8, 14, 0, address_map_constructor(), address_map_constructor(FUNC(tms9928a_device::memmap), this)) { } @@ -83,57 +82,57 @@ void tms9928a_device::device_config_complete() if (!screen().refresh_attoseconds()) { if (m_50hz) - screen().set_raw(clock() / 2, m_total_horz, HORZ_DISPLAY_START - 12, HORZ_DISPLAY_START + 256 + 12, + screen().set_raw(clock() / 2, TOTAL_HORZ, HORZ_DISPLAY_START - 12, HORZ_DISPLAY_START + 256 + 12, TOTAL_VERT_PAL, VERT_DISPLAY_START_PAL - 12, VERT_DISPLAY_START_PAL + 192 + 12); else - screen().set_raw(clock() / 2, m_total_horz, HORZ_DISPLAY_START - 12, HORZ_DISPLAY_START + 256 + 12, + screen().set_raw(clock() / 2, TOTAL_HORZ, HORZ_DISPLAY_START - 12, HORZ_DISPLAY_START + 256 + 12, TOTAL_VERT_NTSC, VERT_DISPLAY_START_NTSC - 12, VERT_DISPLAY_START_NTSC + 192 + 12); } } tms9928a_device::tms9928a_device( const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : tms9928a_device(mconfig, TMS9928A, tag, owner, clock, 342, false, true, true) + : tms9928a_device(mconfig, TMS9928A, tag, owner, clock, false, true, true) { } tms9129_device::tms9129_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : tms9928a_device(mconfig, TMS9129, tag, owner, clock, 342, true, true, false) + : tms9928a_device(mconfig, TMS9129, tag, owner, clock, true, true, false) { } tms9918_device::tms9918_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : tms9928a_device(mconfig, TMS9918, tag, owner, clock, 342, false, false, true) + : tms9928a_device(mconfig, TMS9918, tag, owner, clock, false, false, true) { } tms9918a_device::tms9918a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : tms9928a_device(mconfig, TMS9918A, tag, owner, clock, 342, false, true, true) + : tms9928a_device(mconfig, TMS9918A, tag, owner, clock, false, true, true) { } tms9118_device::tms9118_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : tms9928a_device(mconfig, TMS9118, tag, owner, clock, 342, false, true, false) + : tms9928a_device(mconfig, TMS9118, tag, owner, clock, false, true, false) { } tms9128_device::tms9128_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : tms9928a_device(mconfig, TMS9128, tag, owner, clock, 342, false, true, false) + : tms9928a_device(mconfig, TMS9128, tag, owner, clock, false, true, false) { } tms9929_device::tms9929_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : tms9928a_device(mconfig, TMS9929, tag, owner, clock, 342, true, false, true) + : tms9928a_device(mconfig, TMS9929, tag, owner, clock, true, false, true) { } tms9929a_device::tms9929a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : tms9928a_device(mconfig, TMS9929A, tag, owner, clock, 342, true, true, true) + : tms9928a_device(mconfig, TMS9929A, tag, owner, clock, true, true, true) { } efo90501_device::efo90501_device( const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : tms9928a_device(mconfig, EFO90501, tag, owner, clock, 346, true, true, true) + : tms9928a_device(mconfig, EFO90501, tag, owner, clock, true, true, true) { } @@ -144,7 +143,7 @@ device_memory_interface::space_config_vector tms9928a_device::memory_space_confi }; } -uint8_t tms9928a_device::read(offs_t offset) +READ8_MEMBER( tms9928a_device::read ) { uint8_t value = 0; @@ -156,7 +155,7 @@ uint8_t tms9928a_device::read(offs_t offset) return value; } -void tms9928a_device::write(offs_t offset, uint8_t data) +WRITE8_MEMBER( tms9928a_device::write ) { if ((offset & 1) == 0) vram_write(data); @@ -166,10 +165,10 @@ void tms9928a_device::write(offs_t offset, uint8_t data) u8 tms9928a_device::vram_read() { - uint8_t data = m_ReadAhead; - // prevent debugger from changing the address base - if (machine().side_effects_disabled()) return data; + if (machine().side_effects_disabled()) return 0; + + uint8_t data = m_ReadAhead; m_ReadAhead = m_vram_space->read_byte(m_Addr); m_Addr = (m_Addr + 1) & (m_vram_size - 1); @@ -193,10 +192,10 @@ void tms9928a_device::vram_write(u8 data) u8 tms9928a_device::register_read() { - uint8_t data = m_StatusReg; - // prevent debugger from changing the internal state - if (machine().side_effects_disabled()) return data; + if (machine().side_effects_disabled()) return 0; + + uint8_t data = m_StatusReg; m_StatusReg = m_FifthSprite; check_interrupt(); @@ -372,7 +371,7 @@ void tms9928a_device::device_timer(emu_timer &timer, device_timer_id id, int par if ( y < 0 || y >= 192 || ! (m_Regs[1] & 0x40) ) { /* Draw backdrop colour */ - for ( int i = 0; i < m_total_horz; i++ ) + for ( int i = 0; i < TOTAL_HORZ; i++ ) p[i] = pen(BackColour); /* vblank is set at the last cycle of the first inactive line */ @@ -651,7 +650,7 @@ void tms9928a_device::device_timer(emu_timer &timer, device_timer_id id, int par } /* Right border */ - for ( int i = HORZ_DISPLAY_START + 256; i < m_total_horz; i++ ) + for ( int i = HORZ_DISPLAY_START + 256; i < TOTAL_HORZ; i++ ) p[i] = pen(BackColour); } @@ -735,7 +734,7 @@ void tms9928a_device::device_start() m_vram_space = &space(AS_DATA); /* back bitmap */ - m_tmpbmp.allocate(m_total_horz, TOTAL_VERT_PAL); + m_tmpbmp.allocate(TOTAL_HORZ, TOTAL_VERT_PAL); m_line_timer = timer_alloc(TIMER_LINE); m_gromclk_timer = timer_alloc(GROMCLK); diff --git a/src/devices/video/tms9928a.h b/src/devices/video/tms9928a.h index 72c466d464b..0798183f0ea 100644 --- a/src/devices/video/tms9928a.h +++ b/src/devices/video/tms9928a.h @@ -73,8 +73,13 @@ public: auto int_callback() { return m_out_int_line_cb.bind(); } auto gromclk_callback() { return m_out_gromclk_cb.bind(); } - uint8_t read(offs_t offset); - void write(offs_t offset, uint8_t data); + DECLARE_READ8_MEMBER( read ); + DECLARE_WRITE8_MEMBER( write ); + + DECLARE_READ8_MEMBER( vram_r ) { return vram_read(); } + DECLARE_WRITE8_MEMBER( vram_w ) { vram_write(data); } + DECLARE_READ8_MEMBER( register_r ) { return register_read(); } + DECLARE_WRITE8_MEMBER( register_w ) { register_write(data); } u8 vram_read(); void vram_write(u8 data); @@ -89,7 +94,7 @@ public: void reset_line(int state) { if (state==ASSERT_LINE) device_reset(); } protected: - tms9928a_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint16_t horz_total, bool is_50hz, bool is_reva, bool is_99); + tms9928a_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, bool is_50hz, bool is_reva, bool is_99); // device-level overrides virtual void device_config_complete() override; @@ -134,7 +139,6 @@ private: uint16_t m_spritepattern; int m_colourmask; int m_patternmask; - const uint16_t m_total_horz; const bool m_50hz; const bool m_reva; const bool m_99; diff --git a/src/devices/video/upd3301.h b/src/devices/video/upd3301.h index 147c12c5b7d..80e9346eb6c 100644 --- a/src/devices/video/upd3301.h +++ b/src/devices/video/upd3301.h @@ -43,6 +43,26 @@ #define UPD3301_DRAW_CHARACTER_MEMBER(_name) void _name(bitmap_rgb32 &bitmap, int y, int sx, uint8_t cc, uint8_t lc, int hlgt, int rvv, int vsp, int sl0, int sl12, int csr, int gpa) +#define MCFG_UPD3301_CHARACTER_WIDTH(_value) \ + downcast<upd3301_device &>(*device).set_character_width(_value); + +#define MCFG_UPD3301_DRAW_CHARACTER_CALLBACK_OWNER(_class, _method) \ + downcast<upd3301_device &>(*device).set_display_callback(&_class::_method, #_class "::" #_method, this); + +#define MCFG_UPD3301_DRQ_CALLBACK(_write) \ + downcast<upd3301_device &>(*device).set_drq_wr_callback(DEVCB_##_write); + +#define MCFG_UPD3301_INT_CALLBACK(_write) \ + downcast<upd3301_device &>(*device).set_int_wr_callback(DEVCB_##_write); + +#define MCFG_UPD3301_HRTC_CALLBACK(_write) \ + downcast<upd3301_device &>(*device).set_hrtc_wr_callback(DEVCB_##_write); + +#define MCFG_UPD3301_VRTC_CALLBACK(_write) \ + downcast<upd3301_device &>(*device).set_vrtc_wr_callback(DEVCB_##_write); + + + //************************************************************************** // TYPE DEFINITIONS //************************************************************************** @@ -73,6 +93,10 @@ public: set_display_callback(draw_character_delegate(callback, name, nullptr, static_cast<FunctionClass *>(nullptr))); } + template <class Object> devcb_base &set_drq_wr_callback(Object &&cb) { return m_write_drq.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_int_wr_callback(Object &&cb) { return m_write_int.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_hrtc_wr_callback(Object &&cb) { return m_write_hrtc.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_vrtc_wr_callback(Object &&cb) { return m_write_vrtc.set_callback(std::forward<Object>(cb)); } auto drq_wr_callback() { return m_write_drq.bind(); } auto int_wr_callback() { return m_write_int.bind(); } auto hrtc_wr_callback() { return m_write_hrtc.bind(); } diff --git a/src/devices/video/upd7220.cpp b/src/devices/video/upd7220.cpp index d8697222485..16bbc507a5a 100644 --- a/src/devices/video/upd7220.cpp +++ b/src/devices/video/upd7220.cpp @@ -151,8 +151,7 @@ DEFINE_DEVICE_TYPE(UPD7220, upd7220_device, "upd7220", "NEC uPD7220") // default address map void upd7220_device::upd7220_vram(address_map &map) { - if (!has_configured_map(0)) - map(0x00000, 0x3ffff).ram(); + map(0x00000, 0x3ffff).ram(); } @@ -650,7 +649,7 @@ upd7220_device::upd7220_device(const machine_config &mconfig, const char *tag, d m_disp(0), m_gchr(0), m_bitmap_mod(0), - m_space_config("videoram", ENDIANNESS_LITTLE, 16, 18, 0, address_map_constructor(FUNC(upd7220_device::upd7220_vram), this)) + m_space_config("videoram", ENDIANNESS_LITTLE, 16, 18, 0, address_map_constructor(), address_map_constructor(FUNC(upd7220_device::upd7220_vram), this)) { for (int i = 0; i < 16; i++) { @@ -1448,7 +1447,7 @@ void upd7220_device::continue_command() // read - //------------------------------------------------- -uint8_t upd7220_device::read(offs_t offset) +READ8_MEMBER( upd7220_device::read ) { uint8_t data; @@ -1479,7 +1478,7 @@ uint8_t upd7220_device::read(offs_t offset) // write - //------------------------------------------------- -void upd7220_device::write(offs_t offset, uint8_t data) +WRITE8_MEMBER( upd7220_device::write ) { if (offset & 1) { @@ -1502,7 +1501,7 @@ void upd7220_device::write(offs_t offset, uint8_t data) // dack_r - //------------------------------------------------- -uint8_t upd7220_device::dack_r() +READ8_MEMBER( upd7220_device::dack_r ) { return 0; } @@ -1512,7 +1511,7 @@ uint8_t upd7220_device::dack_r() // dack_w - //------------------------------------------------- -void upd7220_device::dack_w(uint8_t data) +WRITE8_MEMBER( upd7220_device::dack_w ) { } diff --git a/src/devices/video/upd7220.h b/src/devices/video/upd7220.h index 7c7370c0cd9..6a9837d90eb 100644 --- a/src/devices/video/upd7220.h +++ b/src/devices/video/upd7220.h @@ -62,58 +62,19 @@ public: // construction/destruction upd7220_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - // FIXME: these should be aware of current device for resolving the tag - template <class FunctionClass> - void set_display_pixels(void (FunctionClass::*init)(bitmap_rgb32 &, int, int, uint32_t), const char *name) - { - m_display_cb = display_pixels_delegate(init, name, nullptr, static_cast<FunctionClass *>(nullptr)); - } - template <class FunctionClass> - void set_display_pixels(void (FunctionClass::*init)(bitmap_rgb32 &, int, int, uint32_t) const, const char *name) - { - m_display_cb = display_pixels_delegate(init, name, nullptr, static_cast<FunctionClass *>(nullptr)); - } - template <class FunctionClass> - void set_display_pixels(const char *devname, void (FunctionClass::*init)(bitmap_rgb32 &, int, int, uint32_t), const char *name) - { - m_display_cb = display_pixels_delegate(init, name, devname, static_cast<FunctionClass *>(nullptr)); - } - template <class FunctionClass> - void set_display_pixels(const char *devname, void (FunctionClass::*init)(bitmap_rgb32 &, int, int, uint32_t) const, const char *name) - { - m_display_cb = display_pixels_delegate(init, name, devname, static_cast<FunctionClass *>(nullptr)); - } - template <class FunctionClass> - void set_draw_text(void (FunctionClass::*init)(bitmap_rgb32 &, uint32_t, int, int, int, int, int, int), const char *name) - { - m_draw_text_cb = draw_text_delegate(init, name, nullptr, static_cast<FunctionClass *>(nullptr)); - } - template <class FunctionClass> - void set_draw_text(void (FunctionClass::*init)(bitmap_rgb32 &, uint32_t, int, int, int, int, int, int) const, const char *name) - { - m_draw_text_cb = draw_text_delegate(init, name, nullptr, static_cast<FunctionClass *>(nullptr)); - } - template <class FunctionClass> - void set_draw_text(const char *devname, void (FunctionClass::*init)(bitmap_rgb32 &, uint32_t, int, int, int, int, int, int), const char *name) - { - m_draw_text_cb = draw_text_delegate(init, name, devname, static_cast<FunctionClass *>(nullptr)); - } - template <class FunctionClass> - void set_draw_text(const char *devname, void (FunctionClass::*init)(bitmap_rgb32 &, uint32_t, int, int, int, int, int, int) const, const char *name) - { - m_draw_text_cb = draw_text_delegate(init, name, devname, static_cast<FunctionClass *>(nullptr)); - } + template <typename... T> void set_display_pixels_callback(T &&... args) { m_display_cb = display_pixels_delegate(std::forward<T>(args)...); } + template <typename... T> void set_draw_text_callback(T &&... args) { m_draw_text_cb = draw_text_delegate(std::forward<T>(args)...); } auto drq_wr_callback() { return m_write_drq.bind(); } auto hsync_wr_callback() { return m_write_hsync.bind(); } auto vsync_wr_callback() { return m_write_vsync.bind(); } auto blank_wr_callback() { return m_write_blank.bind(); } - uint8_t read(offs_t offset); - void write(offs_t offset, uint8_t data); + DECLARE_READ8_MEMBER( read ); + DECLARE_WRITE8_MEMBER( write ); - uint8_t dack_r(); - void dack_w(uint8_t data); + DECLARE_READ8_MEMBER( dack_r ); + DECLARE_WRITE8_MEMBER( dack_w ); DECLARE_WRITE_LINE_MEMBER( ext_sync_w ); DECLARE_WRITE_LINE_MEMBER( lpen_w ); diff --git a/src/devices/video/v9938.cpp b/src/devices/video/v9938.cpp index f7368efc485..d33331eaa32 100644 --- a/src/devices/video/v9938.cpp +++ b/src/devices/video/v9938.cpp @@ -369,7 +369,7 @@ uint32_t v99x8_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap return 0; } -uint8_t v99x8_device::read(offs_t offset) +READ8_MEMBER( v99x8_device::read ) { switch (offset & 3) { @@ -379,7 +379,7 @@ uint8_t v99x8_device::read(offs_t offset) return 0xff; } -void v99x8_device::write(offs_t offset, uint8_t data) +WRITE8_MEMBER( v99x8_device::write ) { switch (offset & 3) { diff --git a/src/devices/video/v9938.h b/src/devices/video/v9938.h index d0bbf7c48c5..0e1a3640cb9 100644 --- a/src/devices/video/v9938.h +++ b/src/devices/video/v9938.h @@ -54,8 +54,8 @@ public: uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); - uint8_t read(offs_t offset); - void write(offs_t offset, uint8_t data); + DECLARE_READ8_MEMBER( read ); + DECLARE_WRITE8_MEMBER( write ); uint8_t vram_r(); uint8_t status_r(); diff --git a/src/devices/video/vector.h b/src/devices/video/vector.h index 6b473c3501c..919395f043a 100644 --- a/src/devices/video/vector.h +++ b/src/devices/video/vector.h @@ -62,4 +62,7 @@ private: // device type definition DECLARE_DEVICE_TYPE(VECTOR, vector_device) +#define MCFG_VECTOR_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, VECTOR, 0) + #endif // MAME_VIDEO_VECTOR_H diff --git a/src/devices/video/vic4567.h b/src/devices/video/vic4567.h index ecadbfe19d9..e680a3ff0cf 100644 --- a/src/devices/video/vic4567.h +++ b/src/devices/video/vic4567.h @@ -110,16 +110,16 @@ public: vic3_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - template <typename T> void set_cpu_tag(T &&tag) { m_cpu.set_tag(std::forward<T>(tag)); } + void set_cpu_tag(const char *tag) { m_cpu.set_tag(tag); } void set_vic3_type(vic3_type type) { m_type = type; } - auto dma_read_callback() { return m_dma_read_cb.bind(); } - auto dma_read_color_callback() { return m_dma_read_color_cb.bind(); } - auto interrupt_callback() { return m_interrupt_cb.bind(); } - auto port_changed_callback() { return m_port_changed_cb.bind(); } - auto lightpen_button_callback() { return m_lightpen_button_cb.bind(); } - auto lightpen_x_callback() { return m_lightpen_x_cb.bind(); } - auto lightpen_y_callback() { return m_lightpen_y_cb.bind(); } - auto c64_mem_r_callback() { return m_c64_mem_r_cb.bind(); } + template <class Object> devcb_base &set_dma_read_callback(Object &&cb) { return m_dma_read_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_dma_read_color_callback(Object &&cb) { return m_dma_read_color_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_interrupt_callback(Object &&cb) { return m_interrupt_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_port_changed_callback(Object &&cb) { return m_port_changed_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_lightpen_button_callback(Object &&cb) { return m_lightpen_button_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_lightpen_x_callback(Object &&cb) { return m_lightpen_x_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_lightpen_y_callback(Object &&cb) { return m_lightpen_y_cb.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_c64_mem_r_callback(Object &&cb) { return m_c64_mem_r_cb.set_callback(std::forward<Object>(cb)); } DECLARE_WRITE8_MEMBER(port_w); DECLARE_WRITE8_MEMBER(palette_w); @@ -236,4 +236,35 @@ private: DECLARE_DEVICE_TYPE(VIC3, vic3_device) + +#define MCFG_VIC3_CPU(tag) \ + downcast<vic3_device &>(*device).set_cpu_tag(tag); + +#define MCFG_VIC3_TYPE(type) \ + downcast<vic3_device &>(*device).set_vic3_type((vic3_device::vic3_type::type)); + +#define MCFG_VIC3_DMA_READ_CB(cb) \ + downcast<vic3_device &>(*device).set_dma_read_callback((DEVCB_##cb)); + +#define MCFG_VIC3_DMA_READ_COLOR_CB(cb) \ + downcast<vic3_device &>(*device).set_dma_read_color_callback((DEVCB_##cb)); + +#define MCFG_VIC3_INTERRUPT_CB(cb) \ + downcast<vic3_device &>(*device).set_interrupt_callback((DEVCB_##cb)); + +#define MCFG_VIC3_PORT_CHANGED_CB(cb) \ + downcast<vic3_device &>(*device).set_port_changed_callback((DEVCB_##cb)); + +#define MCFG_VIC3_LIGHTPEN_BUTTON_CB(cb) \ + downcast<vic3_device &>(*device).set_lightpen_button_callback((DEVCB_##cb)); + +#define MCFG_VIC3_LIGHTPEN_X_CB(cb) \ + downcast<vic3_device &>(*device).set_lightpen_x_callback((DEVCB_##cb)); + +#define MCFG_VIC3_LIGHTPEN_Y_CB(cb) \ + downcast<vic3_device &>(*device).set_lightpen_y_callback((DEVCB_##cb)); + +#define MCFG_VIC3_C64_MEM_R_CB(cb) \ + downcast<vic3_device &>(*device).set_c64_mem_r_callback((DEVCB_##cb)); + #endif // MAME_VIDEO_VIC4567_H diff --git a/src/devices/video/voodoo.h b/src/devices/video/voodoo.h index 26475f527de..5c39e867d85 100644 --- a/src/devices/video/voodoo.h +++ b/src/devices/video/voodoo.h @@ -1429,6 +1429,32 @@ enum #define STD_VOODOO_3_CLOCK 132000000 + +/*************************************************************************** + DEVICE CONFIGURATION MACROS +***************************************************************************/ + +#define MCFG_VOODOO_FBMEM(_value) \ + downcast<voodoo_device &>(*device).set_fbmem(_value); + +#define MCFG_VOODOO_TMUMEM(_value1, _value2) \ + downcast<voodoo_device &>(*device).set_tmumem(_value1, _value2); + +#define MCFG_VOODOO_SCREEN_TAG(_tag) \ + downcast<voodoo_device &>(*device).set_screen_tag(_tag); + +#define MCFG_VOODOO_CPU_TAG(_tag) \ + downcast<voodoo_device &>(*device).set_cpu_tag(_tag); + +#define MCFG_VOODOO_VBLANK_CB(_devcb) \ + downcast<voodoo_device &>(*device).set_vblank_callback(DEVCB_##_devcb); + +#define MCFG_VOODOO_STALL_CB(_devcb) \ + downcast<voodoo_device &>(*device).set_stall_callback(DEVCB_##_devcb); + +#define MCFG_VOODOO_PCIINT_CB(_devcb) \ + downcast<voodoo_device &>(*device).set_pciint_callback(DEVCB_##_devcb); + /*************************************************************************** FUNCTION PROTOTYPES ***************************************************************************/ @@ -1444,6 +1470,9 @@ public: void set_tmumem(int value1, int value2) { m_tmumem0 = value1; m_tmumem1 = value2; } template <typename T> void set_screen_tag(T &&tag) { m_screen_finder.set_tag(std::forward<T>(tag)); } template <typename T> void set_cpu_tag(T &&tag) { m_cpu_finder.set_tag(std::forward<T>(tag)); } + template <class Object> devcb_base &set_vblank_callback(Object &&cb) { return m_vblank.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_stall_callback(Object &&cb) { return m_stall.set_callback(std::forward<Object>(cb)); } + template <class Object> devcb_base &set_pciint_callback(Object &&cb) { return m_pciint.set_callback(std::forward<Object>(cb)); } auto vblank_callback() { return m_vblank.bind(); } auto stall_callback() { return m_stall.bind(); } auto pciint_callback() { return m_pciint.bind(); } diff --git a/src/devices/video/voodoo_pci.cpp b/src/devices/video/voodoo_pci.cpp index 5a78099e01a..82fc89aaa9a 100644 --- a/src/devices/video/voodoo_pci.cpp +++ b/src/devices/video/voodoo_pci.cpp @@ -6,31 +6,27 @@ #include "screen.h" -void voodoo_1_pci_device::device_add_mconfig(machine_config &config) -{ - VOODOO_1(config, m_voodoo, STD_VOODOO_1_CLOCK); - m_voodoo->set_fbmem(4); - m_voodoo->set_tmumem(1, 0); -} - -void voodoo_2_pci_device::device_add_mconfig(machine_config &config) -{ - VOODOO_2(config, m_voodoo, STD_VOODOO_2_CLOCK); - m_voodoo->set_fbmem(4); - m_voodoo->set_tmumem(1, 0); -} - -void voodoo_banshee_pci_device::device_add_mconfig(machine_config &config) -{ - VOODOO_BANSHEE(config, m_voodoo, STD_VOODOO_BANSHEE_CLOCK); - m_voodoo->set_fbmem(16); -} - -void voodoo_3_pci_device::device_add_mconfig(machine_config &config) -{ - VOODOO_3(config, m_voodoo, STD_VOODOO_3_CLOCK); - m_voodoo->set_fbmem(16); -} +MACHINE_CONFIG_START(voodoo_1_pci_device::device_add_mconfig) + MCFG_DEVICE_ADD("voodoo", VOODOO_1, STD_VOODOO_1_CLOCK) + MCFG_VOODOO_FBMEM(4) + MCFG_VOODOO_TMUMEM(1, 0) +MACHINE_CONFIG_END + +MACHINE_CONFIG_START(voodoo_2_pci_device::device_add_mconfig) + MCFG_DEVICE_ADD("voodoo", VOODOO_2, STD_VOODOO_2_CLOCK) + MCFG_VOODOO_FBMEM(4) + MCFG_VOODOO_TMUMEM(1, 0) +MACHINE_CONFIG_END + +MACHINE_CONFIG_START(voodoo_banshee_pci_device::device_add_mconfig) + MCFG_DEVICE_ADD("voodoo", VOODOO_BANSHEE, STD_VOODOO_BANSHEE_CLOCK) + MCFG_VOODOO_FBMEM(16) +MACHINE_CONFIG_END + +MACHINE_CONFIG_START(voodoo_3_pci_device::device_add_mconfig) + MCFG_DEVICE_ADD("voodoo", VOODOO_3, STD_VOODOO_3_CLOCK) + MCFG_VOODOO_FBMEM(16) +MACHINE_CONFIG_END DEFINE_DEVICE_TYPE(VOODOO_1_PCI, voodoo_1_pci_device, "voodoo_1_pci", "Voodoo 1 PCI") DEFINE_DEVICE_TYPE(VOODOO_2_PCI, voodoo_2_pci_device, "voodoo_2_pci", "Voodoo 2 PCI") @@ -46,22 +42,22 @@ void voodoo_pci_device::config_map(address_map &map) // VOODOO_1 & VOODOO_2 map void voodoo_pci_device::voodoo_reg_map(address_map &map) { - map(0x0, 0x00ffffff).rw(m_voodoo, FUNC(voodoo_device::voodoo_r), FUNC(voodoo_device::voodoo_w)); + map(0x0, 0x00ffffff).rw("voodoo", FUNC(voodoo_device::voodoo_r), FUNC(voodoo_device::voodoo_w)); } // VOODOO_BANSHEE and VOODOO_3 maps void voodoo_pci_device::banshee_reg_map(address_map &map) { - map(0x0, 0x01ffffff).rw(m_voodoo, FUNC(voodoo_banshee_device::banshee_r), FUNC(voodoo_banshee_device::banshee_w)); + map(0x0, 0x01ffffff).rw("voodoo", FUNC(voodoo_banshee_device::banshee_r), FUNC(voodoo_banshee_device::banshee_w)); } void voodoo_pci_device::lfb_map(address_map &map) { - map(0x0, 0x01ffffff).rw(m_voodoo, FUNC(voodoo_banshee_device::banshee_fb_r), FUNC(voodoo_banshee_device::banshee_fb_w)); + map(0x0, 0x01ffffff).rw("voodoo", FUNC(voodoo_banshee_device::banshee_fb_r), FUNC(voodoo_banshee_device::banshee_fb_w)); } void voodoo_pci_device::io_map(address_map &map) { - map(0x000, 0x0ff).rw(m_voodoo, FUNC(voodoo_banshee_device::banshee_io_r), FUNC(voodoo_banshee_device::banshee_io_w)); + map(0x000, 0x0ff).rw("voodoo", FUNC(voodoo_banshee_device::banshee_io_r), FUNC(voodoo_banshee_device::banshee_io_w)); } voodoo_pci_device::voodoo_pci_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) |