summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author cam900 <dbtlrchl@naver.com>2019-09-13 23:30:07 +0900
committer R. Belmont <rb6502@users.noreply.github.com>2019-09-13 10:30:07 -0400
commit5ebacc324561582617a339d5931a654fa6125db7 (patch)
treefa69fe6f4b8dbedaf21d01f09e71995a79ac89a2
parentad4e4d1129348c74727bbab5606436f113136e09 (diff)
devices/video/315_5313.cpp : Fix 3bit color mode masking, Convert drawing routine using device_gfx_interface (#5623)
* devices/video/315_5313.cpp : Updates Fix 3bit color mode masking, Add gfx / palette viewer for debug (off for default), Simpler VRAM write / replace function * devices/video/315_5313.cpp : updates Remove #ifdef, Convert drawing routine into gfxdecode based, Add device_gfx_interface for gfxdecode, Add gfx for shadow / hilight case, Fix naming calcune.cpp : Reduce duplicates, Convert drawing routine into using vdp internal palette, Add save state 315_5124.cpp : Fix naming
-rw-r--r--src/devices/video/315_5124.cpp30
-rw-r--r--src/devices/video/315_5124.h2
-rw-r--r--src/devices/video/315_5313.cpp235
-rw-r--r--src/devices/video/315_5313.h34
-rw-r--r--src/mame/drivers/calcune.cpp142
-rw-r--r--src/mame/drivers/megadriv.cpp12
-rw-r--r--src/mame/drivers/segac2.cpp1
-rw-r--r--src/mame/drivers/segas18.cpp2
-rw-r--r--src/mame/machine/megacd.cpp33
9 files changed, 278 insertions, 213 deletions
diff --git a/src/devices/video/315_5124.cpp b/src/devices/video/315_5124.cpp
index 027663eed4d..837f1af5215 100644
--- a/src/devices/video/315_5124.cpp
+++ b/src/devices/video/315_5124.cpp
@@ -216,7 +216,7 @@ sega315_5124_device::sega315_5124_device(const machine_config &mconfig, device_t
, m_n_int_cb(*this)
, m_n_nmi_cb(*this)
, m_space_config("videoram", ENDIANNESS_LITTLE, 8, 14, 0, address_map_constructor(FUNC(sega315_5124_device::sega315_5124), this))
- , m_palette(*this, "palette")
+ , m_palette_lut(*this, "palette_lut")
, m_snsnd(*this, "snsnd")
{
}
@@ -427,7 +427,7 @@ void sega315_5124_device::device_timer(emu_timer &timer, device_timer_id id, int
/* Draw left border */
rec.min_x = LBORDER_START;
rec.max_x = LBORDER_START + LBORDER_WIDTH - 1;
- m_tmpbitmap.fill(m_palette->pen(m_current_palette[BACKDROP_COLOR]), rec);
+ m_tmpbitmap.fill(m_palette_lut->pen(m_current_palette[BACKDROP_COLOR]), rec);
m_y1_bitmap.fill((m_reg[0x07] & 0x0f) ? 1 : 0, rec);
}
break;
@@ -442,7 +442,7 @@ void sega315_5124_device::device_timer(emu_timer &timer, device_timer_id id, int
/* Draw right border */
rec.min_x = LBORDER_START + LBORDER_WIDTH + 256;
rec.max_x = rec.min_x + RBORDER_WIDTH - 1;
- m_tmpbitmap.fill(m_palette->pen(m_current_palette[BACKDROP_COLOR]), rec);
+ m_tmpbitmap.fill(m_palette_lut->pen(m_current_palette[BACKDROP_COLOR]), rec);
m_y1_bitmap.fill((m_reg[0x07] & 0x0f) ? 1 : 0, rec);
}
break;
@@ -1677,7 +1677,7 @@ void sega315_5124_device::draw_scanline(int pixel_offset_x, int pixel_plot_y, in
rec.min_x = pixel_offset_x;
rec.max_x = pixel_offset_x + 255;
- m_tmpbitmap.fill(m_palette->pen(m_current_palette[BACKDROP_COLOR]), rec);
+ m_tmpbitmap.fill(m_palette_lut->pen(m_current_palette[BACKDROP_COLOR]), rec);
m_y1_bitmap.fill((m_reg[0x07] & 0x0f) ? 1 : 0, rec);
}
else
@@ -1698,7 +1698,7 @@ void sega315_5124_device::blit_scanline(int *line_buffer, int *priority_selected
/* Fill column 0 with overscan color from m_reg[0x07] */
do
{
- p_bitmap[x] = m_palette->pen(m_current_palette[BACKDROP_COLOR]);
+ p_bitmap[x] = m_palette_lut->pen(m_current_palette[BACKDROP_COLOR]);
p_y1[x] = (m_reg[0x07] & 0x0f) ? 1 : 0;
}
while(++x < 8);
@@ -1706,7 +1706,7 @@ void sega315_5124_device::blit_scanline(int *line_buffer, int *priority_selected
do
{
- p_bitmap[x] = m_palette->pen(line_buffer[x]);
+ p_bitmap[x] = m_palette_lut->pen(line_buffer[x]);
p_y1[x] = (priority_selected[x] & 0x0f) ? 1 : 0;
}
while(++x < 256);
@@ -1728,7 +1728,7 @@ void sega315_5377_device::blit_scanline(int *line_buffer, int *priority_selected
/* border on left side of the GG active screen */
do
{
- p_bitmap[x] = m_palette->pen(m_current_palette[BACKDROP_COLOR]);
+ p_bitmap[x] = m_palette_lut->pen(m_current_palette[BACKDROP_COLOR]);
p_y1[x] = (m_reg[0x07] & 0x0f) ? 1 : 0;
}
while (++x < 48);
@@ -1737,7 +1737,7 @@ void sega315_5377_device::blit_scanline(int *line_buffer, int *priority_selected
{
do
{
- p_bitmap[x] = m_palette->pen(line_buffer[x]);
+ p_bitmap[x] = m_palette_lut->pen(line_buffer[x]);
p_y1[x] = (priority_selected[x] & 0x0f) ? 1 : 0;
}
while (++x < 208);
@@ -1747,7 +1747,7 @@ void sega315_5377_device::blit_scanline(int *line_buffer, int *priority_selected
/* top/bottom GG border */
do
{
- p_bitmap[x] = m_palette->pen(m_current_palette[BACKDROP_COLOR]);
+ p_bitmap[x] = m_palette_lut->pen(m_current_palette[BACKDROP_COLOR]);
p_y1[x] = (m_reg[0x07] & 0x0f) ? 1 : 0;
}
while (++x < 208);
@@ -1756,7 +1756,7 @@ void sega315_5377_device::blit_scanline(int *line_buffer, int *priority_selected
/* border on right side of the GG active screen */
do
{
- p_bitmap[x] = m_palette->pen(m_current_palette[BACKDROP_COLOR]);
+ p_bitmap[x] = m_palette_lut->pen(m_current_palette[BACKDROP_COLOR]);
p_y1[x] = (m_reg[0x07] & 0x0f) ? 1 : 0;
}
while (++x < 256);
@@ -2013,7 +2013,7 @@ 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);
+ PALETTE(config, m_palette_lut, 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);
}
@@ -2032,8 +2032,8 @@ 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));
+ m_palette_lut->set_entries(SEGA315_5377_PALETTE_SIZE);
+ m_palette_lut->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);
@@ -2048,6 +2048,6 @@ void sega315_5313_mode4_device::device_add_mconfig(machine_config &config)
{
sega315_5246_device::device_add_mconfig(config);
- m_palette->set_entries((512 * 3) + 64);
- m_palette->set_init(FUNC(sega315_5313_mode4_device::sega315_5313_palette));
+ m_palette_lut->set_entries((512 * 3) + 64);
+ m_palette_lut->set_init(FUNC(sega315_5313_mode4_device::sega315_5313_palette));
}
diff --git a/src/devices/video/315_5124.h b/src/devices/video/315_5124.h
index ba58220618d..f5bb3cc02f5 100644
--- a/src/devices/video/315_5124.h
+++ b/src/devices/video/315_5124.h
@@ -201,7 +201,7 @@ protected:
static constexpr device_timer_id TIMER_NMI = 6;
static constexpr device_timer_id TIMER_FLAGS = 7;
- required_device<palette_device> m_palette;
+ required_device<palette_device> m_palette_lut;
required_device<sn76496_base_device> m_snsnd;
};
diff --git a/src/devices/video/315_5313.cpp b/src/devices/video/315_5313.cpp
index f8c9a0ebac8..585cbeee732 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, u32 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_gfx_interface(mconfig, *this, nullptr, "gfx_palette")
, m_render_bitmap(nullptr)
, m_render_line(nullptr)
, m_render_line_raw(nullptr)
@@ -207,6 +208,9 @@ sega315_5313_device::sega315_5313_device(const machine_config &mconfig, const ch
, m_space68k(nullptr)
, m_cpu68k(*this, finder_base::DUMMY_TAG)
, m_ext_palette(*this, finder_base::DUMMY_TAG)
+ , m_gfx_palette(*this, "gfx_palette")
+ , m_gfx_palette_shadow(*this, "gfx_palette_shadow")
+ , m_gfx_palette_hilight(*this, "gfx_palette_hilight")
{
m_use_alt_timing = 0;
m_palwrite_base = - 1;
@@ -222,6 +226,10 @@ void sega315_5313_device::device_add_mconfig(machine_config &config)
sega315_5313_mode4_device::device_add_mconfig(config);
SEGAPSG(config.replace(), m_snsnd, DERIVED_CLOCK(1, 15)).add_route(ALL_OUTPUTS, *this, 0.5, AUTO_ALLOC_INPUT, 0);
+
+ PALETTE(config, m_gfx_palette, palette_device::BLACK).set_entries(PALETTE_PER_FRAME);
+ PALETTE(config, m_gfx_palette_shadow, palette_device::BLACK).set_entries(PALETTE_PER_FRAME);
+ PALETTE(config, m_gfx_palette_hilight, palette_device::BLACK).set_entries(PALETTE_PER_FRAME);
}
TIMER_CALLBACK_MEMBER(sega315_5313_device::irq6_on_timer_callback)
@@ -236,6 +244,39 @@ TIMER_CALLBACK_MEMBER(sega315_5313_device::irq4_on_timer_callback)
m_lv4irqline_callback(true);
}
+static const gfx_layout md_debug_8x8_layout =
+{
+ 8,8,
+ 0x10000 / ((8*8*4) / 8),
+ 4,
+ { STEP4(0,1) },
+ { 2*4,3*4,0*4,1*4,6*4,7*4,4*4,5*4 },
+ { STEP8(0,4*8) },
+ 8*8*4
+};
+
+static const gfx_layout md_debug_8x16_layout =
+{
+ 8,16,
+ 0x10000 / ((8*16*4) / 8),
+ 4,
+ { STEP4(0,1) },
+ { 2*4,3*4,0*4,1*4,6*4,7*4,4*4,5*4 },
+ { STEP16(0,4*8) },
+ 8*16*4
+};
+
+void sega315_5313_device::device_post_load()
+{
+ sega315_5313_mode4_device::device_post_load();
+ gfx(0)->mark_all_dirty();
+ gfx(1)->mark_all_dirty();
+ gfx(2)->mark_all_dirty();
+ gfx(3)->mark_all_dirty();
+ gfx(4)->mark_all_dirty();
+ gfx(5)->mark_all_dirty();
+}
+
void sega315_5313_device::device_start()
{
m_sndirqline_callback.resolve_safe();
@@ -316,6 +357,13 @@ void sega315_5313_device::device_start()
m_space68k = &m_cpu68k->space();
sega315_5313_mode4_device::device_start();
+
+ set_gfx(0, std::make_unique<gfx_element>(&palette(), md_debug_8x8_layout, (u8 *)m_vram.get(), 0, palette().entries() / 16, 0));
+ set_gfx(1, std::make_unique<gfx_element>(&palette(), md_debug_8x16_layout, (u8 *)m_vram.get(), 0, palette().entries() / 16, 0));
+ set_gfx(2, std::make_unique<gfx_element>(m_gfx_palette_shadow, md_debug_8x8_layout, (u8 *)m_vram.get(), 0, m_gfx_palette_shadow->entries() / 16, 0));
+ set_gfx(3, std::make_unique<gfx_element>(m_gfx_palette_shadow, md_debug_8x16_layout, (u8 *)m_vram.get(), 0, m_gfx_palette_shadow->entries() / 16, 0));
+ set_gfx(4, std::make_unique<gfx_element>(m_gfx_palette_hilight, md_debug_8x8_layout, (u8 *)m_vram.get(), 0, m_gfx_palette_hilight->entries() / 16, 0));
+ set_gfx(5, std::make_unique<gfx_element>(m_gfx_palette_hilight, md_debug_8x16_layout, (u8 *)m_vram.get(), 0, m_gfx_palette_hilight->entries() / 16, 0));
}
void sega315_5313_device::device_reset()
@@ -368,7 +416,7 @@ void sega315_5313_device::vdp_vram_write(u16 data)
data = ((data & 0x00ff) << 8) | ((data & 0xff00) >> 8);
}
- MEGADRIV_VDP_VRAM(m_vdp_address >> 1) = data;
+ vram_w(m_vdp_address >> 1, data);
/* The VDP stores an Internal copy of any data written to the Sprite Attribute Table.
This data is _NOT_ invalidated when the Sprite Base Address changes, thus allowing
@@ -404,9 +452,9 @@ void sega315_5313_device::write_cram_value(int offset, int data)
{
if (m_palwrite_base != - 1)
{
- m_ext_palette->set_pen_color(offset + m_palwrite_base, m_palette->pen(data));
- m_ext_palette->set_pen_color(offset + m_palwrite_base + 0x40, m_palette->pen(0x200 | data));
- m_ext_palette->set_pen_color(offset + m_palwrite_base + 0x80, m_palette->pen(0x400 | data));
+ m_ext_palette->set_pen_color(offset + m_palwrite_base, m_palette_lut->pen(data));
+ m_ext_palette->set_pen_color(offset + m_palwrite_base + 0x40, m_palette_lut->pen(0x200 | data));
+ m_ext_palette->set_pen_color(offset + m_palwrite_base + 0x80, m_palette_lut->pen(0x400 | data));
}
}
}
@@ -440,22 +488,22 @@ void sega315_5313_device::data_port_w(int data)
if (m_vdp_address & 1)
{
- MEGADRIV_VDP_VRAM((m_vdp_address >> 1)) = (MEGADRIV_VDP_VRAM((m_vdp_address >> 1)) & 0xff00) | (data & 0x00ff);
+ vram_w(m_vdp_address >> 1, data & 0x00ff, 0x00ff);
}
else
{
- MEGADRIV_VDP_VRAM((m_vdp_address >> 1)) = (MEGADRIV_VDP_VRAM((m_vdp_address >> 1)) & 0x00ff) | ((data & 0x00ff) << 8);
+ vram_w(m_vdp_address >> 1, (data & 0x00ff) << 8, 0x00ff << 8);
}
for (int count = 0; count <= m_vram_fill_length; count++) // <= for james pond 3
{
if (m_vdp_address & 1)
{
- MEGADRIV_VDP_VRAM((m_vdp_address >> 1)) = (MEGADRIV_VDP_VRAM((m_vdp_address >> 1)) & 0x00ff) | (data & 0xff00);
+ vram_w(m_vdp_address >> 1, data & 0xff00, 0xff00);
}
else
{
- MEGADRIV_VDP_VRAM((m_vdp_address >> 1)) = (MEGADRIV_VDP_VRAM((m_vdp_address >> 1)) & 0xff00) | ((data & 0xff00) >> 8);
+ vram_w(m_vdp_address >> 1, (data & 0xff00) >> 8, 0xff00 >> 8);
}
vdp_address_inc();
@@ -623,11 +671,11 @@ void sega315_5313_device::insta_vram_copy(u32 source, u16 length)
if (m_vdp_address & 1)
{
- MEGADRIV_VDP_VRAM((m_vdp_address & 0xffff) >> 1) = (MEGADRIV_VDP_VRAM((m_vdp_address & 0xffff) >> 1) & 0xff00) | source_byte;
+ vram_w((m_vdp_address & 0xffff) >> 1, source_byte, 0x00ff);
}
else
{
- MEGADRIV_VDP_VRAM((m_vdp_address & 0xffff) >> 1) = (MEGADRIV_VDP_VRAM((m_vdp_address & 0xffff) >> 1) & 0x00ff) | (source_byte << 8);
+ vram_w((m_vdp_address & 0xffff) >> 1, (source_byte << 8), 0x00ff << 8);
}
source++;
@@ -1323,6 +1371,9 @@ u16 sega315_5313_device::vdp_r(offs_t offset, u16 mem_mask)
void sega315_5313_device::render_spriteline_to_spritebuffer(int scanline)
{
+ const int ytile_shift = (m_imode == 3) ? 4 : 3;
+ const int yline_mask = (m_imode == 3) ? 0xf : 0x7;
+ gfx_element *spr_gfx = (m_imode == 3) ? gfx(1) : gfx(0);
int maxsprites = 0;
int maxpixels = 0;
u16 base_address = 0;
@@ -1391,10 +1442,7 @@ void sega315_5313_device::render_spriteline_to_spritebuffer(int scanline)
pri = (MEGADRIV_VDP_VRAM(((base_address >> 1) + spritenum * 4) + 0x2) & 0x8000) >> 15;
if (m_imode == 3)
- {
- addr <<= 1;
- addr &= 0x7ff;
- }
+ addr &= 0x3ff;
//drawwidth = width * 8;
if (pri == 1) pri = 0x80;
@@ -1416,76 +1464,64 @@ void sega315_5313_device::render_spriteline_to_spritebuffer(int scanline)
return;
/* end todo: */
+ //int xdraw;
+ int yline = scanline - drawypos;
+ const int ytile = yline >> ytile_shift;
+ if (ytile < height)
{
- //int xdraw;
- const int yline = scanline - drawypos;
+ yline &= yline_mask;
+
+ const int gfx_w = spr_gfx->width();
for (int xtile = 0; xtile < width; xtile++)
{
+ int xtile_code;
+ int ytile_code, yline_addr;
+
if (!xflip)
+ xtile_code = xtile;
+ else
+ xtile_code = (width - xtile - 1);
+
+ if (!yflip)
{
- u16 base_addr;
+ ytile_code = ytile;
+ yline_addr = yline;
+ }
+ else
+ {
+ ytile_code = (height - ytile - 1);
+ yline_addr = (spr_gfx->height() - yline - 1);
+ }
- if (m_imode == 3)
- {
- if (!yflip)
- base_addr = (addr << 4) + (xtile * (height * (2 * 16))) + (yline * 2);
- else
- base_addr = (addr << 4) + (xtile * (height * (2 * 16))) + (((height * 16) - yline - 1) * 2);
- }
- else
- {
- if (!yflip)
- base_addr = (addr << 4) + (xtile * (height * (2 * 8))) + (yline * 2);
- else
- base_addr = (addr << 4) + (xtile * (height * (2 * 8))) + (((height * 8) - yline - 1) * 2);
- }
+ xtile_code *= height;
+ yline_addr *= spr_gfx->rowbytes();
- int xxx = (xpos + xtile * 8) & 0x1ff;
+ const u8* base_addr = spr_gfx->get_data((addr + xtile_code + ytile_code) % spr_gfx->elements()) + yline_addr;
- u32 gfxdata = MEGADRIV_VDP_VRAM(base_addr + 1) | (MEGADRIV_VDP_VRAM(base_addr + 0) << 16);
+ int xxx = (xpos + xtile * gfx_w) & 0x1ff;
- for (int loopcount = 0; loopcount < 8; loopcount++)
+ if (!xflip)
+ {
+ for (int loopcount = 0; loopcount < gfx_w; loopcount++)
{
- const int dat = (gfxdata & 0xf0000000) >> 28; gfxdata <<= 4;
+ const u8 dat = base_addr[loopcount];
if (dat) { if (!m_sprite_renderline[xxx]) { m_sprite_renderline[xxx] = dat | (colour << 4) | pri; } else { m_sprite_collision = 1; } }
xxx++; xxx &= 0x1ff;
if (--maxpixels == 0x00) return;
}
-
}
else
{
- u16 base_addr;
-
- if (m_imode == 3)
- {
- if (!yflip)
- base_addr = (addr << 4) + (((width - xtile - 1)) * (height * (2 * 16))) + (yline * 2);
- else
- base_addr = (addr << 4) + (((width - xtile - 1)) * (height * (2 * 16))) + (((height * 16) - yline - 1) * 2);
- }
- else
- {
- if (!yflip)
- base_addr = (addr << 4) + (((width - xtile - 1)) * (height * (2 * 8))) + (yline * 2);
- else
- base_addr = (addr << 4) + (((width - xtile - 1)) * (height * (2 * 8))) + (((height * 8) - yline - 1) * 2);
- }
-
- int xxx = (xpos + xtile * 8) & 0x1ff;
-
- u32 gfxdata = MEGADRIV_VDP_VRAM(base_addr + 1) | (MEGADRIV_VDP_VRAM(base_addr) << 16);
-
- for (int loopcount = 0; loopcount < 8; loopcount++)
+ for (int tmpcount = gfx_w - 1, loopcount = 0; loopcount < gfx_w; tmpcount--, loopcount++)
{
- const int dat = (gfxdata & 0x0000000f) >> 0; gfxdata >>= 4;
+ const u8 dat = base_addr[tmpcount];
if (dat) { if (!m_sprite_renderline[xxx]) { m_sprite_renderline[xxx] = dat | (colour << 4) | pri; } else { m_sprite_collision = 1; } }
xxx++; xxx &= 0x1ff;
if (--maxpixels == 0x00) return;
}
-
}
+
}
}
}
@@ -1523,39 +1559,35 @@ void sega315_5313_device::get_window_tilebase(int &tile_base, u16 base, int vcol
tile_base &= 0x7fff;
}
-void sega315_5313_device::get_nametable(u16 tile_base, nametable_t &tile, int vcolumn)
+void sega315_5313_device::get_nametable(gfx_element *tile_gfx, u16 tile_base, nametable_t &tile, int vcolumn)
{
const u16 tile_dat = MEGADRIV_VDP_VRAM(tile_base);
tile.xflip = (tile_dat & 0x0800);
tile.yflip = (tile_dat & 0x1000);
tile.colour =(tile_dat & 0x6000) >> 13;
tile.pri = (tile_dat & 0x8000) >> 15;
- tile.addr = (tile_dat & 0x07ff) << 4;
+ u16 code = (tile_dat & 0x07ff);
if (m_imode == 3)
- {
- tile.addr <<= 1;
- tile.addr &= 0x7fff;
+ code &= 0x3ff;
- if (!tile.yflip) tile.addr += (vcolumn & 0xf) * 2;
- else tile.addr += ((0xf - vcolumn) & 0xf) * 2;
- }
- else
- {
- if (!tile.yflip) tile.addr += (vcolumn & 7) * 2;
- else tile.addr += ((7 - vcolumn) & 7) * 2;
- }
+ tile.gfx = tile_gfx;
+
+ const int hmask = tile.gfx->height() - 1;
+ tile.addr = tile.gfx->get_data(code % tile.gfx->elements());
+
+ if (!tile.yflip) tile.addr += (vcolumn & hmask) * tile.gfx->rowbytes();
+ else tile.addr += ((hmask - vcolumn) & hmask) * tile.gfx->rowbytes();
}
inline void sega315_5313_device::draw_tile(nametable_t tile, int start, int end, int &dpos, bool is_fg)
{
- const u32 gfxdata = (MEGADRIV_VDP_VRAM(tile.addr + 0) << 16) | MEGADRIV_VDP_VRAM(tile.addr + 1);
if (!tile.xflip)
{
/* 8 pixels */
for (int shift = start; shift < end; shift++)
{
- const int dat = (gfxdata >> (28 - (shift * 4))) & 0x000f;
+ const u8 dat = tile.addr[shift];
if (!tile.pri)
{
if (dat) m_video_renderline[dpos] = dat | (tile.colour << 4);
@@ -1577,9 +1609,9 @@ inline void sega315_5313_device::draw_tile(nametable_t tile, int start, int end,
}
else
{
- for (int shift = start; shift < end; shift++)
+ for (int tmp = tile.gfx->width() - start - 1, shift = start; shift < end; tmp--, shift++)
{
- const int dat = (gfxdata >> (shift * 4)) & 0x000f;
+ const u8 dat = tile.addr[tmp];
if (!tile.pri)
{
if (dat) m_video_renderline[dpos] = dat | (tile.colour << 4);
@@ -1604,6 +1636,7 @@ inline void sega315_5313_device::draw_tile(nametable_t tile, int start, int end,
/* Clean up this function (!) */
void sega315_5313_device::render_videoline_to_videobuffer(int scanline)
{
+ gfx_element *tile_gfx = (m_imode == 3) ? gfx(1) : gfx(0);
u16 base_w = 0;
u16 hsize = 64;
@@ -1811,7 +1844,7 @@ void sega315_5313_device::render_videoline_to_videobuffer(int scanline)
int hcolumn = ((column * 2 - 1) - (hscroll_b >> 3)) & (hsize - 1);
get_vcolumn_tilebase(vcolumn, tile_base, base_b, vscroll, scanline, vsize, hsize, hcolumn);
- get_nametable(tile_base, tile, vcolumn);
+ get_nametable(tile_gfx, tile_base, tile, vcolumn);
draw_tile(tile, hscroll_part, 8, dpos, false);
if (MEGADRIVE_REG0B_VSCROLL_MODE)
@@ -1827,7 +1860,7 @@ void sega315_5313_device::render_videoline_to_videobuffer(int scanline)
hcolumn = ((column * 2) - (hscroll_b >> 3)) & (hsize - 1);
get_vcolumn_tilebase(vcolumn, tile_base, base_b, vscroll, scanline, vsize, hsize, hcolumn);
- get_nametable(tile_base, tile, vcolumn);
+ get_nametable(tile_gfx, tile_base, tile, vcolumn);
draw_tile(tile, 0, 8, dpos, false);
if (MEGADRIVE_REG0B_VSCROLL_MODE)
@@ -1842,7 +1875,7 @@ void sega315_5313_device::render_videoline_to_videobuffer(int scanline)
hcolumn = ((column * 2 + 1) - (hscroll_b >> 3)) & (hsize - 1);
get_vcolumn_tilebase(vcolumn, tile_base, base_b, vscroll, scanline, vsize, hsize, hcolumn);
- get_nametable(tile_base, tile, vcolumn);
+ get_nametable(tile_gfx, tile_base, tile, vcolumn);
draw_tile(tile, 0, hscroll_part, dpos, false);
}
}
@@ -1860,13 +1893,13 @@ void sega315_5313_device::render_videoline_to_videobuffer(int scanline)
int hcolumn = (column * 2) & (window_hsize - 1);
get_window_tilebase(tile_base, base_w, vcolumn, window_hsize, hcolumn);
- get_nametable(tile_base, tile, vcolumn);
+ get_nametable(tile_gfx, tile_base, tile, vcolumn);
draw_tile(tile, 0, 8, dpos, true);
hcolumn = (column * 2 + 1) & (window_hsize - 1);
get_window_tilebase(tile_base, base_w, vcolumn, window_hsize, hcolumn);
- get_nametable(tile_base, tile, vcolumn);
+ get_nametable(tile_gfx, tile_base, tile, vcolumn);
draw_tile(tile, 0, 8, dpos, true);
}
@@ -1898,7 +1931,7 @@ void sega315_5313_device::render_videoline_to_videobuffer(int scanline)
else hcolumn = ((column * 2 + 1) - (hscroll_a >> 3)) & (hsize - 1);
get_vcolumn_tilebase(vcolumn, tile_base, base_a, vscroll, scanline, vsize, hsize, hcolumn);
- get_nametable(tile_base, tile, vcolumn);
+ get_nametable(tile_gfx, tile_base, tile, vcolumn);
draw_tile(tile, hscroll_part, 8, dpos, true);
if (MEGADRIVE_REG0B_VSCROLL_MODE)
@@ -1919,7 +1952,7 @@ void sega315_5313_device::render_videoline_to_videobuffer(int scanline)
}
get_vcolumn_tilebase(vcolumn, tile_base, base_a, vscroll, scanline, vsize, hsize, hcolumn);
- get_nametable(tile_base, tile, vcolumn);
+ get_nametable(tile_gfx, tile_base, tile, vcolumn);
draw_tile(tile, 0, 8, dpos, true);
if (MEGADRIVE_REG0B_VSCROLL_MODE)
@@ -1935,7 +1968,7 @@ void sega315_5313_device::render_videoline_to_videobuffer(int scanline)
else hcolumn = ((column * 2 + 1) - (hscroll_a >> 3)) & (hsize - 1);
get_vcolumn_tilebase(vcolumn, tile_base, base_a, vscroll, scanline, vsize, hsize, hcolumn);
- get_nametable(tile_base, tile, vcolumn);
+ get_nametable(tile_gfx, tile_base, tile, vcolumn);
draw_tile(tile, 0, hscroll_part, dpos, true);
}
}
@@ -2054,6 +2087,7 @@ void sega315_5313_device::render_videoline_to_videobuffer(int scanline)
/* This converts our render buffer to real screen colours */
void sega315_5313_device::render_videobuffer_to_screenbuffer(int scanline)
{
+ const unsigned palette_per_scanline = scanline * 64;
u32 *lineptr;
if (!m_use_alt_timing)
@@ -2066,29 +2100,40 @@ void sega315_5313_device::render_videobuffer_to_screenbuffer(int scanline)
else
lineptr = m_render_line.get();
+ if (m_use_cram)
+ {
+ for (int p = 0; p < 64; p++)
+ {
+ u16 clut = m_palette_lookup[p];
+ if (!MEGADRIVE_REG0_SPECIAL_PAL) // 3 bit color mode, correct?
+ clut &= 0x49; // (1 << 6) | (1 << 3) | (1 << 0);
+
+ m_gfx_palette->set_pen_color( p + palette_per_scanline, m_palette_lut->pen(clut));
+ m_gfx_palette_shadow->set_pen_color( p + palette_per_scanline, m_palette_lut->pen(0x200 | clut));
+ m_gfx_palette_hilight->set_pen_color(p + palette_per_scanline, m_palette_lut->pen(0x400 | clut));
+ }
+ }
+
for (int x = 0; x < 320; x++)
{
const u32 dat = m_video_renderline[x];
- u16 clut = m_palette_lookup[(dat & 0x3f)];
- if (!MEGADRIVE_REG0_SPECIAL_PAL) // 3 bit color mode, correct?
- clut &= 0x111;
+ const u16 clut = (dat & 0x3f) + palette_per_scanline;
if (!(dat & 0x20000))
m_render_line_raw[x] = 0x100;
else
m_render_line_raw[x] = 0x000;
-
if (!MEGADRIVE_REG0C_SHADOW_HIGLIGHT)
{
if (dat & 0x10000)
{
- lineptr[x] = m_palette->pen(clut);
+ lineptr[x] = m_gfx_palette->pen(clut);
m_render_line_raw[x] |= (dat & 0x3f) | 0x080;
}
else
{
- lineptr[x] = m_palette->pen(clut);
+ lineptr[x] = m_gfx_palette->pen(clut);
m_render_line_raw[x] |= (dat & 0x3f) | 0x040;
}
}
@@ -2103,25 +2148,25 @@ void sega315_5313_device::render_videobuffer_to_screenbuffer(int scanline)
case 0x10000: // (sprite) low priority, no shadow sprite, no highlight = shadow
case 0x12000: // (sprite) low priority, shadow sprite, no highlight = shadow
case 0x16000: // (sprite) normal pri, shadow sprite, no highlight = shadow?
- lineptr[x] = m_palette->pen(0x200 | clut);
+ lineptr[x] = m_gfx_palette_shadow->pen(clut);
m_render_line_raw[x] |= (dat & 0x3f) | 0x000;
break;
case 0x4000: // normal pri, no shadow sprite, no highlight = normal;
case 0x8000: // low pri, highlight sprite = normal;
- lineptr[x] = m_palette->pen(clut);
+ lineptr[x] = m_gfx_palette->pen(clut);
m_render_line_raw[x] |= (dat & 0x3f) | 0x040;
break;
case 0x14000: // (sprite) normal pri, no shadow sprite, no highlight = normal;
case 0x18000: // (sprite) low pri, highlight sprite = normal;
- lineptr[x] = m_palette->pen(clut);
+ lineptr[x] = m_gfx_palette->pen(clut);
m_render_line_raw[x] |= (dat & 0x3f) | 0x080;
break;
case 0x0c000: // normal pri, highlight set = highlight?
case 0x1c000: // (sprite) normal pri, highlight set = highlight?
- lineptr[x] = m_palette->pen(0x400 | clut);
+ lineptr[x] = m_gfx_palette_hilight->pen(clut);
m_render_line_raw[x] |= (dat & 0x3f) | 0x0c0;
break;
diff --git a/src/devices/video/315_5313.h b/src/devices/video/315_5313.h
index 4664385dcc9..fe68bb9d9a9 100644
--- a/src/devices/video/315_5313.h
+++ b/src/devices/video/315_5313.h
@@ -10,10 +10,11 @@
#include "cpu/m68000/m68000.h"
#include "machine/timer.h"
-
-class sega315_5313_device : public sega315_5313_mode4_device
+class sega315_5313_device : public sega315_5313_mode4_device, public device_gfx_interface
{
public:
+ static constexpr unsigned PALETTE_PER_FRAME = 64 * 313 * 2; // 313 total scanlines for PAL systems, *2 for interlaced
+
template <typename T>
sega315_5313_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock, T &&cpu_tag)
: sega315_5313_device(mconfig, tag, owner, clock)
@@ -33,7 +34,7 @@ public:
void set_alt_timing(int use_alt_timing) { m_use_alt_timing = use_alt_timing; }
void set_pal_write_base(int palwrite_base) { m_palwrite_base = palwrite_base; }
- template <typename T> void set_palette(T &&tag) { m_ext_palette.set_tag(std::forward<T>(tag)); }
+ template <typename T> void set_ext_palette(T &&tag) { m_ext_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)...); }
@@ -47,6 +48,22 @@ public:
u16 vdp_r(offs_t offset, u16 mem_mask = ~0);
void vdp_w(offs_t offset, u16 data, u16 mem_mask = ~0);
+ void vram_w(offs_t offset, u16 data, u16 mem_mask = ~0)
+ {
+ offset &= 0x7fff;
+ COMBINE_DATA(&m_vram[offset]);
+ gfx(0)->mark_dirty(offset / ((8*8*4) / 16));
+ gfx(1)->mark_dirty(offset / ((8*16*4) / 16));
+ gfx(2)->mark_dirty(offset / ((8*8*4) / 16));
+ gfx(3)->mark_dirty(offset / ((8*16*4) / 16));
+ gfx(4)->mark_dirty(offset / ((8*8*4) / 16));
+ gfx(5)->mark_dirty(offset / ((8*16*4) / 16));
+ }
+
+ device_palette_interface *gfx_palette() { return m_gfx_palette; }
+ device_palette_interface *gfx_palette_shadow() { return m_gfx_palette_shadow; }
+ device_palette_interface *gfx_palette_hilight() { return m_gfx_palette_hilight; }
+
int get_scanline_counter();
TIMER_CALLBACK_MEMBER(render_scanline);
@@ -85,6 +102,7 @@ public:
inline u16 vdp_get_word_from_68k_mem(u32 source);
protected:
+ virtual void device_post_load() override;
virtual void device_start() override;
virtual void device_reset() override;
virtual void device_add_mconfig(machine_config &config) override;
@@ -112,7 +130,8 @@ private:
// nametable
struct nametable_t {
- u16 addr;
+ gfx_element *gfx;
+ const u8* addr;
bool xflip;
bool yflip;
u16 colour;
@@ -120,7 +139,7 @@ private:
};
void get_window_tilebase(int &tile_base, u16 base, int vcolumn, int window_hsize, int hcolumn);
void get_vcolumn_tilebase(int &vcolumn, int &tile_base, u16 base, int vscroll, int scanline, int vsize, int hsize, int hcolumn);
- void get_nametable(u16 tile_base, nametable_t &tile, int vcolumn);
+ void get_nametable(gfx_element *tile_gfx, u16 tile_base, nametable_t &tile, int vcolumn);
inline void draw_tile(nametable_t tile, int start, int end, int &dpos, bool is_fg);
int m_command_pending; // 2nd half of command pending..
@@ -208,6 +227,11 @@ private:
address_space *m_space68k;
required_device<m68000_base_device> m_cpu68k;
optional_device<palette_device> m_ext_palette;
+
+ // debug functions
+ required_device<palette_device> m_gfx_palette;
+ required_device<palette_device> m_gfx_palette_shadow;
+ required_device<palette_device> m_gfx_palette_hilight;
};
diff --git a/src/mame/drivers/calcune.cpp b/src/mame/drivers/calcune.cpp
index 264f459d2be..99015786c43 100644
--- a/src/mame/drivers/calcune.cpp
+++ b/src/mame/drivers/calcune.cpp
@@ -31,13 +31,20 @@ class calcune_state : public driver_device
public:
calcune_state(const machine_config &mconfig, device_type type, const char *tag) :
driver_device(mconfig, type, tag),
- vdp_state(0),
m_maincpu(*this, "maincpu"),
- m_vdp(*this, "gen_vdp"),
- m_vdp2(*this, "gen_vdp2"),
- m_palette(*this, "palette")
+ m_vdp(*this, "gen_vdp%u", 1U)
{ }
+ void init_calcune();
+
+ void calcune(machine_config &config);
+
+private:
+ required_device<cpu_device> m_maincpu;
+ required_device_array<sega315_5313_device, 2> m_vdp;
+
+ int m_vdp_state;
+
WRITE_LINE_MEMBER(vdp_sndirqline_callback_genesis_z80);
WRITE_LINE_MEMBER(vdp_lv6irqline_callback_genesis_68k);
WRITE_LINE_MEMBER(vdp_lv4irqline_callback_genesis_68k);
@@ -47,23 +54,13 @@ public:
IRQ_CALLBACK_MEMBER(genesis_int_callback);
- void init_calcune();
-
DECLARE_READ16_MEMBER(cal_700000_r);
DECLARE_WRITE16_MEMBER(cal_770000_w);
DECLARE_READ16_MEMBER(cal_vdp_r);
DECLARE_WRITE16_MEMBER(cal_vdp_w);
uint32_t screen_update_calcune(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
- void calcune(machine_config &config);
void calcune_map(address_map &map);
-private:
- int vdp_state;
-
- required_device<cpu_device> m_maincpu;
- required_device<sega315_5313_device> m_vdp;
- required_device<sega315_5313_device> m_vdp2;
- required_device<palette_device> m_palette;
};
@@ -99,29 +96,23 @@ INPUT_PORTS_END
READ16_MEMBER(calcune_state::cal_700000_r)
{
- vdp_state = 0;
+ m_vdp_state = 0;
return 0;
}
WRITE16_MEMBER(calcune_state::cal_770000_w)
{
- vdp_state = data;
+ m_vdp_state = data;
}
READ16_MEMBER(calcune_state::cal_vdp_r)
{
- if (!vdp_state)
- return m_vdp->vdp_r(offset, mem_mask);
- else
- return m_vdp2->vdp_r(offset, mem_mask);
+ return m_vdp[m_vdp_state ? 1 : 0]->vdp_r(offset, mem_mask);
}
WRITE16_MEMBER(calcune_state::cal_vdp_w)
{
- if (!vdp_state)
- m_vdp->vdp_w(offset, data, mem_mask);
- else
- m_vdp2->vdp_w(offset, data, mem_mask);
+ m_vdp[m_vdp_state ? 1 : 0]->vdp_w(offset, data, mem_mask);
}
void calcune_state::calcune_map(address_map &map)
@@ -147,48 +138,55 @@ void calcune_state::calcune_map(address_map &map)
uint32_t calcune_state::screen_update_calcune(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
- const pen_t *paldata = m_palette->pens();
+ const pen_t *paldata = m_vdp[0]->gfx_palette()->pens();
+ const pen_t *paldata_s = m_vdp[0]->gfx_palette_shadow()->pens();
+ const pen_t *paldata_h = m_vdp[0]->gfx_palette_hilight()->pens();
+ const pen_t *paldata2 = m_vdp[1]->gfx_palette()->pens();
+ const pen_t *paldata2_s = m_vdp[1]->gfx_palette_shadow()->pens();
+ const pen_t *paldata2_h = m_vdp[1]->gfx_palette_hilight()->pens();
for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
{
+ const unsigned palette_per_scanline = 64 * y;
+
uint32_t *dst = &bitmap.pix32(y);
for (int x = cliprect.min_x; x <= cliprect.max_x; x++)
{
int pix;
- pix = m_vdp2->m_render_line_raw[x] & 0x3f;
+ pix = m_vdp[1]->m_render_line_raw[x] & 0x3f;
switch (pix & 0xc0)
{
case 0x00:
- dst[x] = paldata[pix + 0x0000 + 0xc0];
+ dst[x] = paldata2[pix + palette_per_scanline];
break;
case 0x40:
case 0x80:
- dst[x] = paldata[pix + 0x0040 + 0xc0];
+ dst[x] = paldata2_s[pix + palette_per_scanline];
break;
case 0xc0:
- dst[x] = paldata[pix + 0x0080 + 0xc0];
+ dst[x] = paldata2_h[pix + palette_per_scanline];
break;
}
- if (m_vdp->m_render_line_raw[x] & 0x100)
+ if (m_vdp[0]->m_render_line_raw[x] & 0x100)
{
- pix = m_vdp->m_render_line_raw[x] & 0x3f;
+ pix = m_vdp[0]->m_render_line_raw[x] & 0x3f;
if (pix & 0xf)
{
switch (pix & 0xc0)
{
case 0x00:
- dst[x] = paldata[pix + 0x0000];
+ dst[x] = paldata[pix + palette_per_scanline];
break;
case 0x40:
case 0x80:
- dst[x] = paldata[pix + 0x0040];
+ dst[x] = paldata_s[pix + palette_per_scanline];
break;
case 0xc0:
- dst[x] = paldata[pix + 0x0080];
+ dst[x] = paldata_h[pix + palette_per_scanline];
break;
}
}
@@ -201,8 +199,8 @@ uint32_t calcune_state::screen_update_calcune(screen_device &screen, bitmap_rgb3
MACHINE_RESET_MEMBER(calcune_state,calcune)
{
- m_vdp->device_reset_old();
- m_vdp2->device_reset_old();
+ m_vdp[0]->device_reset_old();
+ m_vdp[1]->device_reset_old();
}
@@ -210,12 +208,12 @@ IRQ_CALLBACK_MEMBER(calcune_state::genesis_int_callback)
{
if (irqline==4)
{
- m_vdp->vdp_clear_irq4_pending();
+ m_vdp[0]->vdp_clear_irq4_pending();
}
if (irqline==6)
{
- m_vdp->vdp_clear_irq6_pending();
+ m_vdp[0]->vdp_clear_irq6_pending();
}
return (0x60+irqline*4)/4; // vector address
@@ -245,8 +243,10 @@ WRITE_LINE_MEMBER(calcune_state::vdp_lv4irqline_callback_genesis_68k)
MACHINE_START_MEMBER(calcune_state,calcune)
{
- m_vdp->stop_timers();
- m_vdp2->stop_timers();
+ m_vdp[0]->stop_timers();
+ m_vdp[1]->stop_timers();
+ m_vdp_state = 0;
+ save_item(NAME(m_vdp_state));
}
void calcune_state::calcune(machine_config &config)
@@ -268,34 +268,28 @@ void calcune_state::calcune(machine_config &config)
screen.set_visarea(0, 40*8-1, 0, 28*8-1);
screen.set_screen_update(FUNC(calcune_state::screen_update_calcune));
- SEGA315_5313(config, m_vdp, OSC1_CLOCK, m_maincpu);
- m_vdp->set_is_pal(false);
- m_vdp->snd_irq().set(FUNC(calcune_state::vdp_sndirqline_callback_genesis_z80));
- m_vdp->lv6_irq().set(FUNC(calcune_state::vdp_lv6irqline_callback_genesis_68k));
- m_vdp->lv4_irq().set(FUNC(calcune_state::vdp_lv4irqline_callback_genesis_68k));
- m_vdp->set_alt_timing(1);
- m_vdp->set_pal_write_base(0x0000);
- m_vdp->set_palette(m_palette);
- m_vdp->add_route(ALL_OUTPUTS, "lspeaker", 0.25);
- m_vdp->add_route(ALL_OUTPUTS, "rspeaker", 0.25);
-
- SEGA315_5313(config, m_vdp2, OSC1_CLOCK, m_maincpu);
- m_vdp2->set_is_pal(false);
+ SEGA315_5313(config, m_vdp[0], OSC1_CLOCK, m_maincpu);
+ m_vdp[0]->set_is_pal(false);
+ m_vdp[0]->snd_irq().set(FUNC(calcune_state::vdp_sndirqline_callback_genesis_z80));
+ m_vdp[0]->lv6_irq().set(FUNC(calcune_state::vdp_lv6irqline_callback_genesis_68k));
+ m_vdp[0]->lv4_irq().set(FUNC(calcune_state::vdp_lv4irqline_callback_genesis_68k));
+ m_vdp[0]->set_alt_timing(1);
+ m_vdp[0]->add_route(ALL_OUTPUTS, "lspeaker", 0.25);
+ m_vdp[0]->add_route(ALL_OUTPUTS, "rspeaker", 0.25);
+
+ SEGA315_5313(config, m_vdp[1], OSC1_CLOCK, m_maincpu);
+ m_vdp[1]->set_is_pal(false);
// are these not hooked up or should they OR with the other lines?
-// m_vdp2->snd_irq().set(FUNC(calcune_state::vdp_sndirqline_callback_genesis_z80));
-// m_vdp2->lv6_irq().set(FUNC(calcune_state::vdp_lv6irqline_callback_genesis_68k));
-// m_vdp2->lv4_irq().set(FUNC(calcune_state::vdp_lv4irqline_callback_genesis_68k));
- m_vdp2->set_alt_timing(1);
- m_vdp2->set_pal_write_base(0x0c0);
- m_vdp2->set_palette(m_palette);
- m_vdp2->add_route(ALL_OUTPUTS, "lspeaker", 0.25);
- m_vdp2->add_route(ALL_OUTPUTS, "rspeaker", 0.25);
-
- TIMER(config, "scantimer").configure_scanline("gen_vdp", FUNC(sega315_5313_device::megadriv_scanline_timer_callback_alt_timing), "megadriv", 0, 1);
+// m_vdp[1]->snd_irq().set(FUNC(calcune_state::vdp_sndirqline_callback_genesis_z80));
+// m_vdp[1]->lv6_irq().set(FUNC(calcune_state::vdp_lv6irqline_callback_genesis_68k));
+// m_vdp[1]->lv4_irq().set(FUNC(calcune_state::vdp_lv4irqline_callback_genesis_68k));
+ m_vdp[1]->set_alt_timing(1);
+ m_vdp[1]->add_route(ALL_OUTPUTS, "lspeaker", 0.25);
+ m_vdp[1]->add_route(ALL_OUTPUTS, "rspeaker", 0.25);
+
+ TIMER(config, "scantimer").configure_scanline("gen_vdp1", FUNC(sega315_5313_device::megadriv_scanline_timer_callback_alt_timing), "megadriv", 0, 1);
TIMER(config, "scantimer2").configure_scanline("gen_vdp2", FUNC(sega315_5313_device::megadriv_scanline_timer_callback_alt_timing), "megadriv", 0, 1);
- PALETTE(config, m_palette).set_entries(0xc0*2);
-
NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0);
/* sound hardware */
@@ -309,15 +303,15 @@ void calcune_state::calcune(machine_config &config)
void calcune_state::init_calcune()
{
- m_vdp->set_use_cram(1);
- m_vdp->set_vdp_pal(false);
- m_vdp->set_framerate(60);
- m_vdp->set_total_scanlines(262);
-
- m_vdp2->set_use_cram(1);
- m_vdp2->set_vdp_pal(false);
- m_vdp2->set_framerate(60);
- m_vdp2->set_total_scanlines(262);
+ m_vdp[0]->set_use_cram(1);
+ m_vdp[0]->set_vdp_pal(false);
+ m_vdp[0]->set_framerate(60);
+ m_vdp[0]->set_total_scanlines(262);
+
+ m_vdp[1]->set_use_cram(1);
+ m_vdp[1]->set_vdp_pal(false);
+ m_vdp[1]->set_framerate(60);
+ m_vdp[1]->set_total_scanlines(262);
}
ROM_START( calcune )
diff --git a/src/mame/drivers/megadriv.cpp b/src/mame/drivers/megadriv.cpp
index 4b84971b561..2fd81336110 100644
--- a/src/mame/drivers/megadriv.cpp
+++ b/src/mame/drivers/megadriv.cpp
@@ -745,7 +745,7 @@ void md_cons_state::genesis_scd(machine_config &config)
subdevice<screen_device>("megadriv")->screen_vblank().set(FUNC(md_cons_state::screen_vblank_console));
SEGA_SEGACD_US(config, m_segacd, 0);
- m_segacd->set_palette("gen_vdp:palette");
+ m_segacd->set_palette("gen_vdp:gfx_palette");
m_segacd->set_hostcpu(m_maincpu);
m_segacd->set_screen("megadriv");
@@ -764,7 +764,7 @@ void md_cons_state::md_scd(machine_config &config)
subdevice<screen_device>("megadriv")->screen_vblank().set(FUNC(md_cons_state::screen_vblank_console));
SEGA_SEGACD_EUROPE(config, m_segacd, 0);
- m_segacd->set_palette("gen_vdp:palette");
+ m_segacd->set_palette("gen_vdp:gfx_palette");
m_segacd->set_hostcpu(m_maincpu);
m_segacd->set_screen("megadriv");
@@ -783,7 +783,7 @@ void md_cons_state::mdj_scd(machine_config &config)
subdevice<screen_device>("megadriv")->screen_vblank().set(FUNC(md_cons_state::screen_vblank_console));
SEGA_SEGACD_JAPAN(config, m_segacd, 0);
- m_segacd->set_palette("gen_vdp:palette");
+ m_segacd->set_palette("gen_vdp:gfx_palette");
m_segacd->set_hostcpu(m_maincpu);
m_segacd->set_screen("megadriv");
@@ -799,7 +799,7 @@ void md_cons_state::genesis_32x_scd(machine_config &config)
genesis_32x(config);
SEGA_SEGACD_US(config, m_segacd, 0);
- m_segacd->set_palette("gen_vdp:palette");
+ m_segacd->set_palette("gen_vdp:gfx_palette");
m_segacd->set_hostcpu(m_maincpu);
m_segacd->set_screen("megadriv");
@@ -819,7 +819,7 @@ void md_cons_state::md_32x_scd(machine_config &config)
md_32x(config);
SEGA_SEGACD_EUROPE(config, m_segacd, 0);
- m_segacd->set_palette("gen_vdp:palette");
+ m_segacd->set_palette("gen_vdp:gfx_palette");
m_segacd->set_hostcpu(m_maincpu);
m_segacd->set_screen("megadriv");
@@ -839,7 +839,7 @@ void md_cons_state::mdj_32x_scd(machine_config &config)
mdj_32x(config);
SEGA_SEGACD_JAPAN(config, m_segacd, 0);
- m_segacd->set_palette("gen_vdp:palette");
+ m_segacd->set_palette("gen_vdp:gfx_palette");
m_segacd->set_hostcpu(m_maincpu);
m_segacd->set_screen("megadriv");
diff --git a/src/mame/drivers/segac2.cpp b/src/mame/drivers/segac2.cpp
index e9fd318e4bf..aa3c42fb2c1 100644
--- a/src/mame/drivers/segac2.cpp
+++ b/src/mame/drivers/segac2.cpp
@@ -1578,6 +1578,7 @@ void segac2_state::segac(machine_config &config)
m_vdp->set_alt_timing(1);
m_vdp->set_screen("megadriv");
m_vdp->add_route(ALL_OUTPUTS, "mono", 0.50);
+ m_vdp->set_palette(m_palette);
TIMER(config, "scantimer").configure_scanline("gen_vdp", FUNC(sega315_5313_device::megadriv_scanline_timer_callback_alt_timing), "megadriv", 0, 1);
diff --git a/src/mame/drivers/segas18.cpp b/src/mame/drivers/segas18.cpp
index 9de10d48b3d..111256c5eb1 100644
--- a/src/mame/drivers/segas18.cpp
+++ b/src/mame/drivers/segas18.cpp
@@ -1343,7 +1343,7 @@ void segas18_state::system18(machine_config &config)
m_vdp->lv4_irq().set(FUNC(segas18_state::vdp_lv4irqline_callback_s18));
m_vdp->set_alt_timing(1);
m_vdp->set_pal_write_base(0x1000);
- m_vdp->set_palette(m_palette);
+ m_vdp->set_ext_palette(m_palette);
m_vdp->add_route(ALL_OUTPUTS, "mono", 0.0);
TIMER(config, "scantimer").configure_scanline("gen_vdp", FUNC(sega315_5313_device::megadriv_scanline_timer_callback_alt_timing), "screen", 0, 1);
diff --git a/src/mame/machine/megacd.cpp b/src/mame/machine/megacd.cpp
index 8e3cb49d41f..57cf8f61607 100644
--- a/src/mame/machine/megacd.cpp
+++ b/src/mame/machine/megacd.cpp
@@ -3,6 +3,7 @@
#include "emu.h"
#include "machine/megacd.h"
#include "machine/nvram.h"
+#include "video/315_5313.h"
#include "megacd.lh"
@@ -273,22 +274,22 @@ _32x32_START
_32x32_END
static GFXDECODE_START( gfx_segacd )
- GFXDECODE_DEVICE_RAM( "dataram", 0, sega_16x16_r00_f0_layout, 0, 0 )
- GFXDECODE_DEVICE_RAM( "dataram", 0, sega_16x16_r01_f0_layout, 0, 0 )
- GFXDECODE_DEVICE_RAM( "dataram", 0, sega_16x16_r10_f0_layout, 0, 0 )
- GFXDECODE_DEVICE_RAM( "dataram", 0, sega_16x16_r11_f0_layout, 0, 0 )
- GFXDECODE_DEVICE_RAM( "dataram", 0, sega_16x16_r00_f1_layout, 0, 0 )
- GFXDECODE_DEVICE_RAM( "dataram", 0, sega_16x16_r11_f1_layout, 0, 0 )
- GFXDECODE_DEVICE_RAM( "dataram", 0, sega_16x16_r10_f1_layout, 0, 0 )
- GFXDECODE_DEVICE_RAM( "dataram", 0, sega_16x16_r01_f1_layout, 0, 0 )
- GFXDECODE_DEVICE_RAM( "dataram", 0, sega_32x32_r00_f0_layout, 0, 0 )
- GFXDECODE_DEVICE_RAM( "dataram", 0, sega_32x32_r01_f0_layout, 0, 0 )
- GFXDECODE_DEVICE_RAM( "dataram", 0, sega_32x32_r10_f0_layout, 0, 0 )
- GFXDECODE_DEVICE_RAM( "dataram", 0, sega_32x32_r11_f0_layout, 0, 0 )
- GFXDECODE_DEVICE_RAM( "dataram", 0, sega_32x32_r00_f1_layout, 0, 0 )
- GFXDECODE_DEVICE_RAM( "dataram", 0, sega_32x32_r11_f1_layout, 0, 0 )
- GFXDECODE_DEVICE_RAM( "dataram", 0, sega_32x32_r10_f1_layout, 0, 0 )
- GFXDECODE_DEVICE_RAM( "dataram", 0, sega_32x32_r01_f1_layout, 0, 0 )
+ GFXDECODE_DEVICE_RAM( "dataram", 0, sega_16x16_r00_f0_layout, 0, (sega315_5313_device::PALETTE_PER_FRAME) / 16 )
+ GFXDECODE_DEVICE_RAM( "dataram", 0, sega_16x16_r01_f0_layout, 0, (sega315_5313_device::PALETTE_PER_FRAME) / 16 )
+ GFXDECODE_DEVICE_RAM( "dataram", 0, sega_16x16_r10_f0_layout, 0, (sega315_5313_device::PALETTE_PER_FRAME) / 16 )
+ GFXDECODE_DEVICE_RAM( "dataram", 0, sega_16x16_r11_f0_layout, 0, (sega315_5313_device::PALETTE_PER_FRAME) / 16 )
+ GFXDECODE_DEVICE_RAM( "dataram", 0, sega_16x16_r00_f1_layout, 0, (sega315_5313_device::PALETTE_PER_FRAME) / 16 )
+ GFXDECODE_DEVICE_RAM( "dataram", 0, sega_16x16_r11_f1_layout, 0, (sega315_5313_device::PALETTE_PER_FRAME) / 16 )
+ GFXDECODE_DEVICE_RAM( "dataram", 0, sega_16x16_r10_f1_layout, 0, (sega315_5313_device::PALETTE_PER_FRAME) / 16 )
+ GFXDECODE_DEVICE_RAM( "dataram", 0, sega_16x16_r01_f1_layout, 0, (sega315_5313_device::PALETTE_PER_FRAME) / 16 )
+ GFXDECODE_DEVICE_RAM( "dataram", 0, sega_32x32_r00_f0_layout, 0, (sega315_5313_device::PALETTE_PER_FRAME) / 16 )
+ GFXDECODE_DEVICE_RAM( "dataram", 0, sega_32x32_r01_f0_layout, 0, (sega315_5313_device::PALETTE_PER_FRAME) / 16 )
+ GFXDECODE_DEVICE_RAM( "dataram", 0, sega_32x32_r10_f0_layout, 0, (sega315_5313_device::PALETTE_PER_FRAME) / 16 )
+ GFXDECODE_DEVICE_RAM( "dataram", 0, sega_32x32_r11_f0_layout, 0, (sega315_5313_device::PALETTE_PER_FRAME) / 16 )
+ GFXDECODE_DEVICE_RAM( "dataram", 0, sega_32x32_r00_f1_layout, 0, (sega315_5313_device::PALETTE_PER_FRAME) / 16 )
+ GFXDECODE_DEVICE_RAM( "dataram", 0, sega_32x32_r11_f1_layout, 0, (sega315_5313_device::PALETTE_PER_FRAME) / 16 )
+ GFXDECODE_DEVICE_RAM( "dataram", 0, sega_32x32_r10_f1_layout, 0, (sega315_5313_device::PALETTE_PER_FRAME) / 16 )
+ GFXDECODE_DEVICE_RAM( "dataram", 0, sega_32x32_r01_f1_layout, 0, (sega315_5313_device::PALETTE_PER_FRAME) / 16 )
GFXDECODE_END