summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine
diff options
context:
space:
mode:
author David Haywood <28625134+DavidHaywood@users.noreply.github.com>2020-05-30 14:55:57 +0100
committer GitHub <noreply@github.com>2020-05-30 09:55:57 -0400
commitceccc2f7e335ea12e505ddfceefd35e19ddb814f (patch)
tree952390bd31a00ba9fb59f44a9615a124b4a1bb46 /src/devices/machine
parent1984fb5f94637abf295ab909000bf748e7495811 (diff)
new WORKING machines (Plug & Play) (#6764)
* new WORKING machines ---- Super Sonic Gold (Radica Plug & Play) (USA) [Sean Riddle, David Haywood, Kev (FBN), anonymous] Street Fighter II: Special Champion Edition [Ghouls'n Ghosts] (Radica, Arcade Legends) (USA) [Sean Riddle, David Haywood, Kev (FBN), anonymous] new NOT WORKING machines ---- Speed Racer (Senario) [Sean Riddle, Kamaal Brown] My Arcade Go Gamer Portable (Family Sport 220-in-1) [Sean Riddle, Kev (FBN), anonymous]
Diffstat (limited to 'src/devices/machine')
-rw-r--r--src/devices/machine/generalplus_gpl16250soc_video.cpp12
-rw-r--r--src/devices/machine/spg2xx.cpp3
-rw-r--r--src/devices/machine/spg2xx_video.cpp749
-rw-r--r--src/devices/machine/spg2xx_video.h54
4 files changed, 410 insertions, 408 deletions
diff --git a/src/devices/machine/generalplus_gpl16250soc_video.cpp b/src/devices/machine/generalplus_gpl16250soc_video.cpp
index 96132e851fe..262c26becf5 100644
--- a/src/devices/machine/generalplus_gpl16250soc_video.cpp
+++ b/src/devices/machine/generalplus_gpl16250soc_video.cpp
@@ -934,8 +934,8 @@ void gcm394_base_video_device::draw_sprite(const rectangle& cliprect, uint32_t s
}
else
{
- flip_x = 0;// (attr & TILE_X_FLIP);
- yflipmask = 0;// attr& TILE_Y_FLIP ? h - 1 : 0;
+ flip_x = 0;// (attr & 0x0004);
+ yflipmask = 0;// attr& 0x0008 ? h - 1 : 0;
bpp = attr & 0x0003;
palette_offset = (attr & 0x0f00) >> 4;
@@ -998,10 +998,10 @@ uint32_t gcm394_base_video_device::screen_update(screen_device &screen, bitmap_r
uint16_t ctrl3 = m_tmap3_regs[1];
popmessage(
- "p0ctrl u:%02x Bl:%d HC:%d u:%d u:%d RS:%d E:%d WP:%d Rg:%d Bm:%d\n"
- "p1ctrl u:%02x Bl:%d HC:%d u:%d u:%d RS:%d E:%d WP:%d Rg:%d Bm:%d\n"
- "p2ctrl u:%02x Bl:%d HC:%d u:%d u:%d RS:%d E:%d WP:%d Rg:%d Bm:%d\n"
- "p3ctrl u:%02x Bl:%d HC:%d u:%d u:%d RS:%d E:%d WP:%d Rg:%d Bm:%d\n"
+ "p0ctrl u:%02x Bl:%d HC:%d Ycmp:%d Hcmp:%d RS:%d E:%d WP:%d Rg:%d Bm:%d\n"
+ "p1ctrl u:%02x Bl:%d HC:%d Ycmp:%d Hcmp:%d RS:%d E:%d WP:%d Rg:%d Bm:%d\n"
+ "p2ctrl u:%02x Bl:%d HC:%d Ycmp:%d Hcmp:%d RS:%d E:%d WP:%d Rg:%d Bm:%d\n"
+ "p3ctrl u:%02x Bl:%d HC:%d Ycmp:%d Hcmp:%d RS:%d E:%d WP:%d Rg:%d Bm:%d\n"
"p0attr u:%01x Z:%d P:%d V:%d H:%d FY:%d FX:%d D:%d\n"
"p1attr u:%01x Z:%d P:%d V:%d H:%d FY:%d FX:%d D:%d\n"
"p2attr u:%01x Z:%d P:%d V:%d H:%d FY:%d FX:%d D:%d\n"
diff --git a/src/devices/machine/spg2xx.cpp b/src/devices/machine/spg2xx.cpp
index 88f63c55f00..a70ef14dfd1 100644
--- a/src/devices/machine/spg2xx.cpp
+++ b/src/devices/machine/spg2xx.cpp
@@ -70,7 +70,8 @@ void spg2xx_device::internal_map(address_map &map)
{
map(0x000000, 0x0027ff).ram();
map(0x002800, 0x0028ff).rw(m_spg_video, FUNC(spg2xx_video_device::video_r), FUNC(spg2xx_video_device::video_w));
- map(0x002900, 0x002aff).ram().share("spgvideo:scrollram");
+ map(0x002900, 0x0029ff).ram().share("spgvideo:scrollram");
+ map(0x002a00, 0x002aff).ram().share("spgvideo:hcompram"); // not all models?
map(0x002b00, 0x002bff).ram().share("spgvideo:paletteram");
map(0x002c00, 0x002fff).ram().share("spgvideo:spriteram");
map(0x003000, 0x0031ff).rw(m_spg_audio, FUNC(spg2xx_audio_device::audio_r), FUNC(spg2xx_audio_device::audio_w));
diff --git a/src/devices/machine/spg2xx_video.cpp b/src/devices/machine/spg2xx_video.cpp
index 942b31d4dab..24b5b45cf59 100644
--- a/src/devices/machine/spg2xx_video.cpp
+++ b/src/devices/machine/spg2xx_video.cpp
@@ -23,8 +23,6 @@ DEFINE_DEVICE_TYPE(SPG24X_VIDEO, spg24x_video_device, "spg24x_video", "SPG240-se
#define VERBOSE (0)
#include "logmacro.h"
-#define SPG_DEBUG_VIDEO (0)
-
#define VIDEO_IRQ_ENABLE m_video_regs[0x62]
#define VIDEO_IRQ_STATUS m_video_regs[0x63]
@@ -36,6 +34,7 @@ spg2xx_video_device::spg2xx_video_device(const machine_config &mconfig, device_t
m_cpu(*this, finder_base::DUMMY_TAG),
m_screen(*this, finder_base::DUMMY_TAG),
m_scrollram(*this, "scrollram"),
+ m_hcompram(*this, "hcompram"),
m_paletteram(*this, "paletteram"),
m_spriteram(*this, "spriteram"),
m_video_irq_cb(*this)
@@ -66,14 +65,6 @@ void spg2xx_video_device::device_start()
m_screenpos_timer = timer_alloc(TIMER_SCREENPOS);
m_screenpos_timer->adjust(attotime::never);
- save_item(NAME(m_hide_page0));
- save_item(NAME(m_hide_page1));
- save_item(NAME(m_hide_sprites));
- save_item(NAME(m_debug_sprites));
- save_item(NAME(m_debug_blit));
- save_item(NAME(m_debug_palette));
- save_item(NAME(m_sprite_index_to_debug));
-
save_item(NAME(m_video_regs));
m_sprlimit_read_cb.resolve_safe(0);
@@ -90,130 +81,18 @@ void spg2xx_video_device::device_reset()
m_video_regs[0x3c] = 0x0020;
m_video_regs[0x42] = 0x0001;
- m_hide_page0 = false;
- m_hide_page1 = false;
- m_hide_sprites = false;
- m_debug_sprites = false;
- m_debug_blit = false;
- m_debug_palette = false;
- m_sprite_index_to_debug = 0;
+ for (int i = 0; i < 480; i++)
+ {
+ m_ycmp_table[i] = -1;
+ }
}
/*************************
* Video Hardware *
*************************/
-// Perform a lerp between a and b
-inline uint8_t spg2xx_video_device::mix_channel(uint8_t bottom, uint8_t top)
-{
- uint8_t alpha = (m_video_regs[0x2a] & 3) << 6;
- return ((256 - alpha) * bottom + alpha * top) >> 8;
-}
-
-template<spg2xx_video_device::blend_enable_t Blend, spg2xx_video_device::rowscroll_enable_t RowScroll, spg2xx_video_device::flipx_t FlipX>
-void spg2xx_video_device::draw(const rectangle &cliprect, uint32_t line, uint32_t xoff, uint32_t yoff, uint32_t bitmap_addr, uint16_t tile, int32_t h, int32_t w, uint8_t bpp, uint32_t yflipmask, uint32_t palette_offset, int yscroll)
-{
- address_space &space = m_cpu->space(AS_PROGRAM);
-
- uint32_t nc_bpp = ((bpp) + 1) << 1;
-
- if (SPG_DEBUG_VIDEO && m_debug_blit)
- {
- printf("s:%d line:%d xy:%08x,%08x bitmap_addr:%08x tile:%04x\n", cliprect.min_x, line, xoff, yoff, bitmap_addr, tile);
- printf("hw:%d,%d yfm:%d nc_bppols:%d pobs:%02x ", w, h, yflipmask, nc_bpp, palette_offset);
- }
- palette_offset >>= nc_bpp;
- palette_offset <<= nc_bpp;
- if (SPG_DEBUG_VIDEO && m_debug_blit)
- {
- printf("poas:%02x\n", palette_offset);
- }
-
- uint32_t bits_per_row = nc_bpp * w / 16;
- uint32_t words_per_tile = bits_per_row * h;
- uint32_t m = bitmap_addr + words_per_tile * tile + bits_per_row * (line ^ yflipmask);
- uint32_t bits = 0;
- uint32_t nbits = 0;
- uint32_t y = line;
-
- int yy = (yoff + y) & 0x1ff;
- if (yy >= 0x01c0)
- yy -= 0x0200;
-
- if (yy > 240 || yy < 0)
- return;
-
- if (SPG_DEBUG_VIDEO && m_debug_blit)
- printf("%3d:\n", yy);
-
- int y_index = yy * 320;
-
- for (int32_t x = FlipX ? (w - 1) : 0; FlipX ? x >= 0 : x < w; FlipX ? x-- : x++)
- {
- int xx = xoff + x;
-
- bits <<= nc_bpp;
- if (SPG_DEBUG_VIDEO && m_debug_blit)
- printf(" %08x:%d ", bits, nbits);
- if (nbits < nc_bpp)
- {
- uint16_t b = space.read_word(m++ & 0x3fffff);
- b = (b << 8) | (b >> 8);
- bits |= b << (nc_bpp - nbits);
- nbits += 16;
- if (SPG_DEBUG_VIDEO && m_debug_blit)
- printf("(%04x:%08x:%d) ", b, bits, nbits);
- }
- nbits -= nc_bpp;
-
- uint32_t pal = palette_offset + (bits >> 16);
- if (SPG_DEBUG_VIDEO && m_debug_blit)
- printf("%02x:%02x:%04x ", bits >> 16, pal, bits & 0xffff);
- bits &= 0xffff;
-
- if (RowScroll)
- {
- xx -= (int16_t)m_scrollram[(yy + yscroll) & 0xff];
- }
-
- xx &= 0x01ff;
- if (xx >= 0x01c0)
- xx -= 0x0200;
-
- if (xx >= 0 && xx < 320)
- {
- int pix_index = xx + y_index;
-
- uint16_t rgb = m_paletteram[pal];
- if (SPG_DEBUG_VIDEO && m_debug_blit)
- printf("rgb:%04x ", rgb);
- if (!(rgb & 0x8000))
- {
- if (Blend)
- {
- if (SPG_DEBUG_VIDEO && m_debug_blit)
- printf("M\n");
- m_screenbuf[pix_index] = (mix_channel((uint8_t)(m_screenbuf[pix_index] >> 16), m_rgb5_to_rgb8[(rgb >> 10) & 0x1f]) << 16) |
- (mix_channel((uint8_t)(m_screenbuf[pix_index] >> 8), m_rgb5_to_rgb8[(rgb >> 5) & 0x1f]) << 8) |
- (mix_channel((uint8_t)(m_screenbuf[pix_index] >> 0), m_rgb5_to_rgb8[rgb & 0x1f]));
- }
- else
- {
- if (SPG_DEBUG_VIDEO && m_debug_blit)
- printf("S\n");
- m_screenbuf[pix_index] = m_rgb555_to_rgb888[rgb];
- }
- }
- else if (SPG_DEBUG_VIDEO && m_debug_blit)
- {
- printf("X\n");
- }
- }
- }
-}
-
-void spg2xx_video_device::draw_bitmap(const rectangle& cliprect, uint32_t scanline, int priority, uint32_t bitmap_addr, uint16_t* regs)
+void spg2xx_video_device::draw_linemap(const rectangle& cliprect, uint32_t* dst, uint32_t scanline, int priority, uint32_t tilegfxdata_addr, uint16_t* regs)
{
if ((scanline < 0) || (scanline >= 240))
return;
@@ -246,8 +125,6 @@ void spg2xx_video_device::draw_bitmap(const rectangle& cliprect, uint32_t scanli
//const int linewidth = 320 / 2;
int sourcebase = tile | (palette << 16);
- uint32_t* dest = &m_screenbuf[320 * scanline];
-
uint32_t ctrl = regs[3];
if (ctrl & 0x80) // HiColor mode (rad_digi)
@@ -258,7 +135,7 @@ void spg2xx_video_device::draw_bitmap(const rectangle& cliprect, uint32_t scanli
if (!(data & 0x8000))
{
- dest[i] = m_rgb555_to_rgb888[data & 0x7fff];
+ dst[i] = m_rgb555_to_rgb888[data & 0x7fff];
}
}
}
@@ -275,7 +152,7 @@ void spg2xx_video_device::draw_bitmap(const rectangle& cliprect, uint32_t scanli
if (!(color & 0x8000))
{
- dest[(i * 2) + 0] = m_rgb555_to_rgb888[color & 0x7fff];
+ dst[(i * 2) + 0] = m_rgb555_to_rgb888[color & 0x7fff];
}
palette_entry = (data & 0xff00) >> 8;
@@ -283,134 +160,224 @@ void spg2xx_video_device::draw_bitmap(const rectangle& cliprect, uint32_t scanli
if (!(color & 0x8000))
{
- dest[(i * 2) + 1] = m_rgb555_to_rgb888[color & 0x7fff];
+ dst[(i * 2) + 1] = m_rgb555_to_rgb888[color & 0x7fff];
}
}
}
}
-void spg2xx_video_device::draw_page(const rectangle &cliprect, uint32_t scanline, int priority, uint32_t bitmap_addr, uint16_t *regs)
+
+bool spg2xx_video_device::get_tile_info(uint32_t tilemap_rambase, uint32_t palettemap_rambase, uint32_t x0, uint32_t y0, uint32_t tile_count_x, uint32_t ctrl, uint32_t attr, uint16_t& tile, bool& blend, bool& flip_x, bool& flip_y, uint32_t& palette_offset)
{
- uint32_t xscroll = regs[0];
- uint32_t yscroll = regs[1];
- uint32_t attr = regs[2];
- uint32_t ctrl = regs[3];
- uint32_t tilemap = regs[4];
- uint32_t palette_map = regs[5];
address_space &space = m_cpu->space(AS_PROGRAM);
+ uint32_t tile_address = x0 + (tile_count_x * y0);
- if (!(ctrl & PAGE_ENABLE_MASK))
- {
- return;
+ tile = (ctrl & 0x0004) ? space.read_word(tilemap_rambase) : space.read_word(tilemap_rambase + tile_address);
+
+ if (!tile)
+ return false;
+
+ uint32_t tileattr = attr;
+ uint32_t tilectrl = ctrl;
+ if ((ctrl & 2) == 0)
+ { // -(1) bld(1) flip(2) pal(4)
+
+ uint16_t palette = (ctrl & 0x0004) ? space.read_word(palettemap_rambase) : space.read_word(palettemap_rambase + tile_address / 2);
+ if (x0 & 1)
+ palette >>= 8;
+ else
+ palette &= 0x00ff;
+
+
+ tileattr &= ~0x000c;
+ tileattr |= (palette >> 2) & 0x000c; // flip
+
+ tileattr &= ~0x0f00;
+ tileattr |= (palette << 8) & 0x0f00; // palette
+
+ tilectrl &= ~0x0100;
+ tilectrl |= (palette << 2) & 0x0100; // blend
}
- if (((attr & PAGE_PRIORITY_FLAG_MASK) >> PAGE_PRIORITY_FLAG_SHIFT) != priority)
+ blend = (tileattr & 0x4000 || tilectrl & 0x0100);
+ flip_x = (tileattr & 0x0004);
+ flip_y= (tileattr & 0x0008);
+
+ palette_offset = (tileattr & 0x0f00) >> 4;
+
+
+ return true;
+}
+
+
+void spg2xx_video_device::update_vcmp_table()
+{
+ for (int i = 0; i < 480; i++)
{
- return;
+ int currentline = 0;
+
+ if (i < m_video_regs[0x1d])
+ {
+ m_ycmp_table[i] = -1;
+ }
+ else
+ {
+ if (currentline < 240)
+ {
+ m_ycmp_table[i] = currentline;
+ currentline += m_video_regs[0x1c];
+ }
+ else
+ {
+ m_ycmp_table[i] = -1;
+ }
+ }
}
+}
- if (ctrl & 0x0001) // Bitmap mode!
+// Perform a lerp between a and b
+inline uint8_t spg2xx_video_device::mix_channel(uint8_t bottom, uint8_t top)
+{
+ uint8_t alpha = (m_video_regs[0x2a] & 3) << 6;
+ return ((256 - alpha) * bottom + alpha * top) >> 8;
+}
+
+template<spg2xx_video_device::blend_enable_t Blend, spg2xx_video_device::flipx_t FlipX>
+void spg2xx_video_device::draw_tilestrip(const rectangle& cliprect, uint32_t* dst, uint32_t tile_h, uint32_t tile_w, uint32_t tilegfxdata_addr, uint16_t tile, uint32_t tile_scanline, int drawx, bool flip_y, uint32_t palette_offset, const uint32_t nc_bpp, const uint32_t bits_per_row, const uint32_t words_per_tile)
+{
+ address_space &space = m_cpu->space(AS_PROGRAM);
+ const uint32_t yflipmask = flip_y ? tile_h - 1 : 0;
+ uint32_t m = tilegfxdata_addr + words_per_tile * tile + bits_per_row * (tile_scanline ^ yflipmask);
+ uint32_t bits = 0;
+ uint32_t nbits = 0;
+
+ for (int32_t x = FlipX ? (tile_w - 1) : 0; FlipX ? x >= 0 : x < tile_w; FlipX ? x-- : x++)
{
- draw_bitmap(cliprect, scanline, priority, bitmap_addr, regs);
- return;
- }
+ int realdrawpos = (drawx + x) & 0x1ff;
+ bits <<= nc_bpp;
- uint32_t tile_h = 8 << ((attr & PAGE_TILE_HEIGHT_MASK) >> PAGE_TILE_HEIGHT_SHIFT);
- uint32_t tile_w = 8 << ((attr & PAGE_TILE_WIDTH_MASK) >> PAGE_TILE_WIDTH_SHIFT);
+ if (nbits < nc_bpp)
+ {
+ uint16_t b = space.read_word(m++ & 0x3fffff);
+ b = (b << 8) | (b >> 8);
+ bits |= b << (nc_bpp - nbits);
+ nbits += 16;
+ }
+ nbits -= nc_bpp;
- uint32_t tile_count_x = 512 / tile_w;
+ uint32_t pal = palette_offset + (bits >> 16);
+ bits &= 0xffff;
+
+ if (realdrawpos >= 0 && realdrawpos < 320)
+ {
+ uint16_t rgb = m_paletteram[pal];
+
+ if (!(rgb & 0x8000))
+ {
+ if (Blend)
+ {
+ dst[realdrawpos] = (mix_channel((uint8_t)(dst[realdrawpos] >> 16), m_rgb5_to_rgb8[(rgb >> 10) & 0x1f]) << 16) |
+ (mix_channel((uint8_t)(dst[realdrawpos] >> 8), m_rgb5_to_rgb8[(rgb >> 5) & 0x1f]) << 8) |
+ (mix_channel((uint8_t)(dst[realdrawpos] >> 0), m_rgb5_to_rgb8[rgb & 0x1f]));
+ }
+ else
+ {
+ dst[realdrawpos] = m_rgb555_to_rgb888[rgb];
+ }
+ }
+ }
+ }
+}
- uint32_t bitmap_y = (scanline + yscroll) & 0xff;
- uint32_t y0 = bitmap_y / tile_h;
- uint32_t tile_scanline = bitmap_y % tile_h;
- uint32_t tile_address = tile_count_x * y0;
- if (SPG_DEBUG_VIDEO && machine().input().code_pressed(KEYCODE_H))
- printf("s:%3d | baddr:%08x | yscr:%3d | bity:%3d | y0:%2d | ts:%2d\n", scanline, bitmap_addr, yscroll, bitmap_y, y0, tile_scanline);
+void spg2xx_video_device::draw_page(const rectangle &cliprect, uint32_t* dst, uint32_t scanline, int priority, uint32_t tilegfxdata_addr, uint16_t *regs)
+{
+ const uint32_t attr = regs[2];
+ const uint32_t ctrl = regs[3];
- if (SPG_DEBUG_VIDEO && machine().input().code_pressed(KEYCODE_EQUALS))
- m_debug_blit = true;
- for (uint32_t x0 = 0; x0 < tile_count_x; x0++, tile_address++)
+ if (!(ctrl & 0x0008))
{
- uint32_t yy = ((tile_h * y0 - yscroll + 0x10) & 0xff) - 0x10;
- uint32_t xx = (tile_w * x0 - xscroll) & 0x1ff;
- uint16_t tile = (ctrl & PAGE_WALLPAPER_MASK) ? space.read_word(tilemap) : space.read_word(tilemap + tile_address);
+ return;
+ }
- if (!tile)
- continue;
+ if (((attr & 0x3000) >> 12) != priority)
+ {
+ return;
+ }
- uint32_t tileattr = attr;
- uint32_t tilectrl = ctrl;
- if ((ctrl & 2) == 0)
- { // -(1) bld(1) flip(2) pal(4)
+ if (ctrl & 0x0001) // Bitmap / Linemap mode! (basically screen width tile mode)
+ {
+ draw_linemap(cliprect, dst, scanline, priority, tilegfxdata_addr, regs);
+ return;
+ }
- uint16_t palette = (ctrl & PAGE_WALLPAPER_MASK) ? space.read_word(palette_map) : space.read_word(palette_map + tile_address / 2);
- if (x0 & 1)
- palette >>= 8;
- else
- palette &= 0x00ff;
+ const uint32_t xscroll = regs[0];
+ const uint32_t yscroll = regs[1];
+ const uint32_t tilemap_rambase = regs[4];
+ const uint32_t palettemap_rambase = regs[5];
+ const int tile_width = (attr & 0x0030) >> 4;
+ const uint32_t tile_h = 8 << ((attr & 0x00c0) >> 6);
+ const uint32_t tile_w = 8 << (tile_width);
+ const uint32_t tile_count_x = 512 / tile_w; // all tilemaps are 512 pixels wide
+ const uint32_t bitmap_y = (scanline + yscroll) & 0xff; // all tilemaps are 256 pixels high
+ const uint32_t y0 = bitmap_y / tile_h;
+ const uint32_t tile_scanline = bitmap_y % tile_h;
+ const uint8_t bpp = attr & 0x0003;
+ const uint32_t nc_bpp = ((bpp)+1) << 1;
+ const uint32_t bits_per_row = nc_bpp * tile_w / 16;
+ const uint32_t words_per_tile = bits_per_row * tile_h;
+ const bool row_scroll = (ctrl & 0x0010);
+ int realxscroll = xscroll;
+ if (row_scroll)
+ {
+ realxscroll += (int16_t)m_scrollram[scanline & 0xff];
+ }
- tileattr &= ~0x000c;
- tileattr |= (palette >> 2) & 0x000c; // flip
+ for (uint32_t x0 = 0; x0 < (320+tile_w)/tile_w; x0++)
+ {
- tileattr &= ~0x0f00;
- tileattr |= (palette << 8) & 0x0f00; // palette
+ bool blend, flip_x, flip_y;
+ uint16_t tile;
+ uint32_t palette_offset;
- tilectrl &= ~0x0100;
- tilectrl |= (palette << 2) & 0x0100; // blend
- }
+ if (!get_tile_info(tilemap_rambase, palettemap_rambase, (x0 + (realxscroll >> (tile_width+3))) & (tile_count_x-1) , y0, tile_count_x, ctrl, attr, tile, blend, flip_x, flip_y, palette_offset))
+ continue;
- const bool blend = (tileattr & 0x4000 || tilectrl & 0x0100);
- const bool row_scroll = (tilectrl & 0x0010);
- const bool flip_x = (tileattr & TILE_X_FLIP);
- const uint32_t yflipmask = tileattr & TILE_Y_FLIP ? tile_h - 1 : 0;
- const uint32_t palette_offset = (tileattr & 0x0f00) >> 4;
+ palette_offset >>= nc_bpp;
+ palette_offset <<= nc_bpp;
- const uint8_t bpp = tileattr & 0x0003;
+ int drawx = (x0 * tile_w);
+ drawx = drawx - (realxscroll & (tile_w-1));
if (blend)
{
- if (row_scroll)
+ if (flip_x)
{
- if (flip_x)
- draw<BlendOn, RowScrollOn, FlipXOn>(cliprect, tile_scanline, xx, yy, bitmap_addr, tile, tile_h, tile_w, bpp, yflipmask, palette_offset, yscroll);
- else
- draw<BlendOn, RowScrollOn, FlipXOff>(cliprect, tile_scanline, xx, yy, bitmap_addr, tile, tile_h, tile_w, bpp, yflipmask, palette_offset, yscroll);
+ draw_tilestrip<BlendOn, FlipXOn>(cliprect, dst, tile_h, tile_w, tilegfxdata_addr, tile, tile_scanline, drawx, flip_y, palette_offset, nc_bpp, bits_per_row, words_per_tile);
}
else
{
- if (flip_x)
- draw<BlendOn, RowScrollOff, FlipXOn>(cliprect, tile_scanline, xx, yy, bitmap_addr, tile, tile_h, tile_w, bpp, yflipmask, palette_offset, yscroll);
- else
- draw<BlendOn, RowScrollOff, FlipXOff>(cliprect, tile_scanline, xx, yy, bitmap_addr, tile, tile_h, tile_w, bpp, yflipmask, palette_offset, yscroll);
+ draw_tilestrip<BlendOn, FlipXOff>(cliprect, dst, tile_h, tile_w, tilegfxdata_addr, tile, tile_scanline, drawx, flip_y, palette_offset, nc_bpp, bits_per_row, words_per_tile);
}
}
else
{
- if (row_scroll)
+ if (flip_x)
{
- if (flip_x)
- draw<BlendOff, RowScrollOn, FlipXOn>(cliprect, tile_scanline, xx, yy, bitmap_addr, tile, tile_h, tile_w, bpp, yflipmask, palette_offset, yscroll);
- else
- draw<BlendOff, RowScrollOn, FlipXOff>(cliprect, tile_scanline, xx, yy, bitmap_addr, tile, tile_h, tile_w, bpp, yflipmask, palette_offset, yscroll);
+ draw_tilestrip<BlendOff, FlipXOn>(cliprect, dst, tile_h, tile_w, tilegfxdata_addr, tile, tile_scanline, drawx, flip_y, palette_offset, nc_bpp, bits_per_row, words_per_tile);
}
else
{
- if (flip_x)
- draw<BlendOff, RowScrollOff, FlipXOn>(cliprect, tile_scanline, xx, yy, bitmap_addr, tile, tile_h, tile_w, bpp, yflipmask, palette_offset, yscroll);
- else
- draw<BlendOff, RowScrollOff, FlipXOff>(cliprect, tile_scanline, xx, yy, bitmap_addr, tile, tile_h, tile_w, bpp, yflipmask, palette_offset, yscroll);
+ draw_tilestrip<BlendOff, FlipXOff>(cliprect, dst, tile_h, tile_w, tilegfxdata_addr, tile, tile_scanline, drawx, flip_y, palette_offset, nc_bpp, bits_per_row, words_per_tile);
}
}
}
- if (SPG_DEBUG_VIDEO && machine().input().code_pressed(KEYCODE_EQUALS))
- m_debug_blit = false;
}
-void spg2xx_video_device::draw_sprite(const rectangle &cliprect, uint32_t scanline, int priority, uint32_t base_addr)
+void spg2xx_video_device::draw_sprite(const rectangle& cliprect, uint32_t* dst, uint32_t scanline, int priority, uint32_t base_addr)
{
- uint32_t bitmap_addr = 0x40 * m_video_regs[0x22];
+ uint32_t tilegfxdata_addr = 0x40 * m_video_regs[0x22];
uint16_t tile = m_spriteram[base_addr + 0];
int16_t x = m_spriteram[base_addr + 1];
int16_t y = m_spriteram[base_addr + 2];
@@ -421,115 +388,165 @@ void spg2xx_video_device::draw_sprite(const rectangle &cliprect, uint32_t scanli
return;
}
- if (((attr & PAGE_PRIORITY_FLAG_MASK) >> PAGE_PRIORITY_FLAG_SHIFT) != priority)
+ if (((attr & 0x3000) >> 12) != priority)
{
return;
}
- const uint32_t h = 8 << ((attr & PAGE_TILE_HEIGHT_MASK) >> PAGE_TILE_HEIGHT_SHIFT);
- const uint32_t w = 8 << ((attr & PAGE_TILE_WIDTH_MASK) >> PAGE_TILE_WIDTH_SHIFT);
+ const uint32_t tile_h = 8 << ((attr & 0x00c0) >> 6);
+ const uint32_t tile_w = 8 << ((attr & 0x0030) >> 4);
- if (!(m_video_regs[0x42] & SPRITE_COORD_TL_MASK))
+ if (!(m_video_regs[0x42] & 0x0002))
{
- x = (160 + x) - w / 2;
- y = (120 - y) - (h / 2) + 8;
+ x = (160 + x) - tile_w / 2;
+ y = (120 - y) - (tile_h / 2) + 8;
}
x &= 0x01ff;
y &= 0x01ff;
- uint32_t tile_line = ((scanline - y) + 0x200) % h;
- int16_t test_y = (y + tile_line) & 0x1ff;
- if (test_y >= 0x01c0)
- test_y -= 0x0200;
-
- if (test_y != scanline)
- {
- return;
- }
+ int firstline = y;
+ int lastline = y + (tile_h - 1);
+ lastline &= 0x1ff;
bool blend = (attr & 0x4000);
- bool flip_x = (attr & TILE_X_FLIP);
+ bool flip_x = (attr & 0x0004);
const uint8_t bpp = attr & 0x0003;
- const uint32_t yflipmask = attr & TILE_Y_FLIP ? h - 1 : 0;
+ const uint32_t nc_bpp = ((bpp)+1) << 1;
+ const uint32_t bits_per_row = nc_bpp * tile_w / 16;
+ const uint32_t words_per_tile = bits_per_row * tile_h;
+
+ bool flip_y = (attr & 0x0008);
const uint32_t palette_offset = (attr & 0x0f00) >> 4;
-#if SPG_DEBUG_VIDEO
- if (m_debug_sprites && machine().input().code_pressed(KEYCODE_MINUS))
- m_debug_blit = true;
- if (blend)
+ if (firstline < lastline)
{
- if (flip_x)
- draw<BlendOn, RowScrollOff, FlipXOn>(cliprect, tile_line, x, y, bitmap_addr, tile, h, w, bpp, yflipmask, palette_offset, 0);
- else
- draw<BlendOn, RowScrollOff, FlipXOff>(cliprect, tile_line, x, y, bitmap_addr, tile, h, w, bpp, yflipmask, palette_offset, 0);
- }
- else
- {
- if (flip_x)
- draw<BlendOff, RowScrollOff, FlipXOn>(cliprect, tile_line, x, y, bitmap_addr, tile, h, w, bpp, yflipmask, palette_offset, 0);
- else
- draw<BlendOff, RowScrollOff, FlipXOff>(cliprect, tile_line, x, y, bitmap_addr, tile, h, w, bpp, yflipmask, palette_offset, 0);
- }
- m_debug_blit = false;
-#else
- if (blend)
- {
- if (flip_x)
- draw<BlendOn, RowScrollOff, FlipXOn>(cliprect, tile_line, x, y, bitmap_addr, tile, h, w, bpp, yflipmask, palette_offset, 0);
- else
- draw<BlendOn, RowScrollOff, FlipXOff>(cliprect, tile_line, x, y, bitmap_addr, tile, h, w, bpp, yflipmask, palette_offset, 0);
+ int scanx = scanline - firstline;
+
+ if ((scanx >= 0) && (scanline <= lastline))
+ {
+ if (blend)
+ {
+ if (flip_x)
+ {
+ draw_tilestrip<BlendOn, FlipXOn>(cliprect, dst, tile_h, tile_w, tilegfxdata_addr, tile, scanx, x, flip_y, palette_offset, nc_bpp, bits_per_row, words_per_tile);
+ }
+ else
+ {
+ draw_tilestrip<BlendOn, FlipXOff>(cliprect, dst, tile_h, tile_w, tilegfxdata_addr, tile, scanx, x, flip_y, palette_offset, nc_bpp, bits_per_row, words_per_tile);
+ }
+ }
+ else
+ {
+ if (flip_x)
+ {
+ draw_tilestrip<BlendOff, FlipXOn>(cliprect, dst, tile_h, tile_w, tilegfxdata_addr, tile, scanx, x, flip_y, palette_offset, nc_bpp, bits_per_row, words_per_tile);
+ }
+ else
+ {
+ draw_tilestrip<BlendOff, FlipXOff>(cliprect, dst, tile_h, tile_w, tilegfxdata_addr, tile, scanx, x, flip_y, palette_offset, nc_bpp, bits_per_row, words_per_tile);
+ }
+ }
+ }
}
else
{
- if (flip_x)
- draw<BlendOff, RowScrollOff, FlipXOn>(cliprect, tile_line, x, y, bitmap_addr, tile, h, w, bpp, yflipmask, palette_offset, 0);
- else
- draw<BlendOff, RowScrollOff, FlipXOff>(cliprect, tile_line, x, y, bitmap_addr, tile, h, w, bpp, yflipmask, palette_offset, 0);
+ // clipped from top
+ int tempfirstline = firstline - 0x200;
+ int templastline = lastline;
+ int scanx = scanline - tempfirstline;
+
+ if ((scanx >= 0) && (scanline <= templastline))
+ {
+ if (blend)
+ {
+ if (flip_x)
+ {
+ draw_tilestrip<BlendOn, FlipXOn>(cliprect, dst, tile_h, tile_w, tilegfxdata_addr, tile, scanx, x, flip_y, palette_offset, nc_bpp, bits_per_row, words_per_tile);
+ }
+ else
+ {
+ draw_tilestrip<BlendOn, FlipXOff>(cliprect, dst, tile_h, tile_w, tilegfxdata_addr, tile, scanx, x, flip_y, palette_offset, nc_bpp, bits_per_row, words_per_tile);
+ }
+ }
+ else
+ {
+ if (flip_x)
+ {
+ draw_tilestrip<BlendOff, FlipXOn>(cliprect, dst, tile_h, tile_w, tilegfxdata_addr, tile, scanx, x, flip_y, palette_offset, nc_bpp, bits_per_row, words_per_tile);
+ }
+ else
+ {
+ draw_tilestrip<BlendOff, FlipXOff>(cliprect, dst, tile_h, tile_w, tilegfxdata_addr, tile, scanx, x, flip_y, palette_offset, nc_bpp, bits_per_row, words_per_tile);
+ }
+ }
+ }
+ // clipped against the bottom
+ tempfirstline = firstline;
+ templastline = lastline + 0x200;
+ scanx = scanline - tempfirstline;
+
+ if ((scanx >= 0) && (scanline <= templastline))
+ {
+ if (blend)
+ {
+ if (flip_x)
+ {
+ draw_tilestrip<BlendOn, FlipXOn>(cliprect, dst, tile_h, tile_w, tilegfxdata_addr, tile, scanx, x, flip_y, palette_offset, nc_bpp, bits_per_row, words_per_tile);
+ }
+ else
+ {
+ draw_tilestrip<BlendOn, FlipXOff>(cliprect, dst, tile_h, tile_w, tilegfxdata_addr, tile, scanx, x, flip_y, palette_offset, nc_bpp, bits_per_row, words_per_tile);
+ }
+ }
+ else
+ {
+ if (flip_x)
+ {
+ draw_tilestrip<BlendOff, FlipXOn>(cliprect, dst, tile_h, tile_w, tilegfxdata_addr, tile, scanx, x, flip_y, palette_offset, nc_bpp, bits_per_row, words_per_tile);
+ }
+ else
+ {
+ draw_tilestrip<BlendOff, FlipXOff>(cliprect, dst, tile_h, tile_w, tilegfxdata_addr, tile, scanx, x, flip_y, palette_offset, nc_bpp, bits_per_row, words_per_tile);
+ }
+ }
+ }
}
-#endif
}
-void spg2xx_video_device::draw_sprites(const rectangle &cliprect, uint32_t scanline, int priority)
+void spg2xx_video_device::draw_sprites(const rectangle &cliprect, uint32_t* dst, uint32_t scanline, int priority)
{
- if (!(m_video_regs[0x42] & SPRITE_ENABLE_MASK))
+ if (!(m_video_regs[0x42] & 0x0001))
{
return;
}
-#if SPG_DEBUG_VIDEO
- if (!m_debug_sprites)
+ for (uint32_t n = 0; n < m_sprlimit_read_cb(); n++)
{
-#endif
- for (uint32_t n = 0; n < m_sprlimit_read_cb(); n++)
- {
- draw_sprite(cliprect, scanline, priority, 4 * n);
- }
-#if SPG_DEBUG_VIDEO
- }
- else
- {
- draw_sprite(cliprect, scanline, priority, 4 * m_sprite_index_to_debug);
+ draw_sprite(cliprect, dst, scanline, priority, 4 * n);
}
-#endif
}
-void spg2xx_video_device::apply_saturation(const rectangle &cliprect)
+void spg2xx_video_device::apply_saturation_and_fade(bitmap_rgb32& bitmap, const rectangle& cliprect, int scanline)
{
static const float s_u8_to_float = 1.0f / 255.0f;
static const float s_gray_r = 0.299f;
static const float s_gray_g = 0.587f;
static const float s_gray_b = 0.114f;
const float sat_adjust = (0xff - (m_video_regs[0x3c] & 0x00ff)) / (float)(0xff - 0x20);
- for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
+
+ const uint16_t fade_offset = m_video_regs[0x30];
+
+ uint32_t* src = &bitmap.pix32(scanline, cliprect.min_x);
+
+ for (int x = cliprect.min_x; x <= cliprect.max_x; x++)
{
- uint32_t *src = &m_screenbuf[cliprect.min_x + 320 * y];
- for (int x = cliprect.min_x; x <= cliprect.max_x; x++)
+ if ((m_video_regs[0x3c] & 0x00ff) != 0x0020) // apply saturation
{
const uint32_t src_rgb = *src;
const float src_r = (uint8_t)(src_rgb >> 16) * s_u8_to_float;
- const float src_g = (uint8_t)(src_rgb >> 8) * s_u8_to_float;
- const float src_b = (uint8_t)(src_rgb >> 0) * s_u8_to_float;
+ const float src_g = (uint8_t)(src_rgb >> 8) * s_u8_to_float;
+ const float src_b = (uint8_t)(src_rgb >> 0) * s_u8_to_float;
const float luma = src_r * s_gray_r + src_g * s_gray_g + src_b * s_gray_b;
const float adjusted_r = luma + (src_r - luma) * sat_adjust;
const float adjusted_g = luma + (src_g - luma) * sat_adjust;
@@ -537,92 +554,76 @@ void spg2xx_video_device::apply_saturation(const rectangle &cliprect)
const int integer_r = (int)floor(adjusted_r * 255.0f);
const int integer_g = (int)floor(adjusted_g * 255.0f);
const int integer_b = (int)floor(adjusted_b * 255.0f);
- *src++ = (integer_r > 255 ? 0xff0000 : (integer_r < 0 ? 0 : ((uint8_t)integer_r << 16))) |
- (integer_g > 255 ? 0x00ff00 : (integer_g < 0 ? 0 : ((uint8_t)integer_g << 8))) |
- (integer_b > 255 ? 0x0000ff : (integer_b < 0 ? 0 : (uint8_t)integer_b));
+ *src = (integer_r > 255 ? 0xff0000 : (integer_r < 0 ? 0 : ((uint8_t)integer_r << 16))) |
+ (integer_g > 255 ? 0x00ff00 : (integer_g < 0 ? 0 : ((uint8_t)integer_g << 8))) |
+ (integer_b > 255 ? 0x0000ff : (integer_b < 0 ? 0 : (uint8_t)integer_b));
+
}
- }
-}
-void spg2xx_video_device::apply_fade(const rectangle &cliprect)
-{
- const uint16_t fade_offset = m_video_regs[0x30];
- for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
- {
- uint32_t *src = &m_screenbuf[cliprect.min_x + 320 * y];
- for (int x = cliprect.min_x; x <= cliprect.max_x; x++)
+ if (fade_offset != 0) // apply fade
{
const uint32_t src_rgb = *src;
const uint8_t src_r = (src_rgb >> 16) & 0xff;
- const uint8_t src_g = (src_rgb >> 8) & 0xff;
- const uint8_t src_b = (src_rgb >> 0) & 0xff;
+ const uint8_t src_g = (src_rgb >> 8) & 0xff;
+ const uint8_t src_b = (src_rgb >> 0) & 0xff;
const uint8_t r = src_r - fade_offset;
const uint8_t g = src_g - fade_offset;
const uint8_t b = src_b - fade_offset;
- *src++ = (r > src_r ? 0 : (r << 16)) |
- (g > src_g ? 0 : (g << 8)) |
- (b > src_b ? 0 : (b << 0));
+ *src = (r > src_r ? 0 : (r << 16)) |
+ (g > src_g ? 0 : (g << 8)) |
+ (b > src_b ? 0 : (b << 0));
}
+
+ src++;
}
+
+
}
+
uint32_t spg2xx_video_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
- memset(&m_screenbuf[320 * cliprect.min_y], 0, 4 * 320 * ((cliprect.max_y - cliprect.min_y) + 1));
+ if (0)
+ {
+ uint16_t attr1 = m_video_regs[0x12];
+ uint16_t ctrl1 = m_video_regs[0x13];
+ uint16_t attr2 = m_video_regs[0x18];
+ uint16_t ctrl2 = m_video_regs[0x19];
+
+ // attr --zz pppp ssss FFbb
+ // ctrl ---- ---b hZzR ewrb
+
+ popmessage("Pg1 Attr = %04x (unused: %01x, Depth:%d, Palette:%d, VSize:%d, HSize:%d, FlipY:%d, FlipX:%d, BPP:%d)\n"
+ "Pg2 Attr = %04x (unused: %01x, Depth:%d, Palette:%d, VSize:%d, HSize:%d, FlipY:%d, FlipX:%d, BPP:%d)\n"
+ "Pg1 Ctrl = %04x (unused: %04x, Blend:%d, HiColor:%d, Ycmp:%d, Hcmp:%d, RowScroll:%d, Enable:%d, Wallpaper:%d, RegSet:%d, Bitmap:%d)\n"
+ "Pg2 Ctrl = %04x (unused: %04x, Blend:%d, HiColor:%d, Ycmp:%d, Hcmp:%d, RowScroll:%d, Enable:%d, Wallpaper:%d, RegSet:%d, Bitmap:%d)\n",
+ attr1, (attr1 & 0xc000) >> 14, (attr1 >> 12) & 3, (attr1 >> 8) & 15, 8 << ((attr1 >> 6) & 3), 8 << ((attr1 >> 4) & 3), BIT(attr1, 3), BIT(attr1, 2), 2 * ((attr1 & 3) + 1),
+ attr2, (attr2 & 0xc000) >> 14, (attr2 >> 12) & 3, (attr2 >> 8) & 15, 8 << ((attr2 >> 6) & 3), 8 << ((attr2 >> 4) & 3), BIT(attr2, 3), BIT(attr2, 2), 2 * ((attr2 & 3) + 1),
+ ctrl1, (ctrl1 & 0xfe00), BIT(ctrl1, 8), BIT(ctrl1, 7), BIT(ctrl1, 6), BIT(ctrl1, 5), BIT(ctrl1, 4), BIT(ctrl1, 3), BIT(ctrl1, 2), BIT(ctrl1, 1), BIT(ctrl1, 0),
+ ctrl2, (ctrl2 & 0xfe00), BIT(ctrl2, 8), BIT(ctrl2, 7), BIT(ctrl2, 6), BIT(ctrl2, 5), BIT(ctrl2, 4), BIT(ctrl2, 3), BIT(ctrl2, 2), BIT(ctrl2, 1), BIT(ctrl2, 0));
+
+ }
+
const uint32_t page1_addr = 0x40 * m_video_regs[0x20];
const uint32_t page2_addr = 0x40 * m_video_regs[0x21];
uint16_t *page1_regs = m_video_regs + 0x10;
uint16_t *page2_regs = m_video_regs + 0x16;
+ bitmap.fill(0, cliprect);
+
for (uint32_t scanline = (uint32_t)cliprect.min_y; scanline <= (uint32_t)cliprect.max_y; scanline++)
{
+ uint32_t* dst = &bitmap.pix32(scanline, cliprect.min_x);
+
for (int i = 0; i < 4; i++)
{
- if (!SPG_DEBUG_VIDEO || !m_hide_page0)
- draw_page(cliprect, scanline, i, page1_addr, page1_regs);
- if (!SPG_DEBUG_VIDEO || !m_hide_page1)
- draw_page(cliprect, scanline, i, page2_addr, page2_regs);
- if (!SPG_DEBUG_VIDEO || !m_hide_sprites)
- draw_sprites(cliprect, scanline, i);
+ draw_page(cliprect, dst, scanline, i, page1_addr, page1_regs);
+ draw_page(cliprect, dst, scanline, i, page2_addr, page2_regs);
+ draw_sprites(cliprect, dst, scanline, i);
}
- }
- if ((m_video_regs[0x3c] & 0x00ff) != 0x0020)
- {
- apply_saturation(cliprect);
- }
-
- if (m_video_regs[0x30] != 0)
- {
- apply_fade(cliprect);
- }
-
- for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
- {
- uint32_t *dest = &bitmap.pix32(y, cliprect.min_x);
- uint32_t *src = &m_screenbuf[cliprect.min_x + 320 * y];
- memcpy(dest, src, sizeof(uint32_t) * ((cliprect.max_x - cliprect.min_x) + 1));
- }
-
- if (SPG_DEBUG_VIDEO && m_debug_palette)
- {
- for (int y = cliprect.min_y; y <= cliprect.max_y && y < 128; y++)
- {
- const uint16_t high_nybble = (y / 8) << 4;
- uint32_t *dest = &bitmap.pix32(y, cliprect.min_x);
- for (int x = cliprect.min_x; x <= cliprect.max_x && x < 256; x++)
- {
- const uint16_t low_nybble = x / 16;
- const uint16_t palette_entry = high_nybble | low_nybble;
- const uint16_t color = m_paletteram[palette_entry];
- if (!(color & 0x8000))
- {
- *dest = m_rgb555_to_rgb888[color & 0x7fff];
- }
- dest++;
- }
- }
+ apply_saturation_and_fade(bitmap, cliprect, scanline);
}
return 0;
@@ -655,6 +656,15 @@ READ16_MEMBER(spg2xx_video_device::video_r)
{
switch (offset)
{
+ case 0x10: // Page 1 X scroll
+ LOGMASKED(LOG_PPU_WRITES, "video_r: Page 1 X Scroll\n");
+ return m_video_regs[offset];
+
+ case 0x11: // Page 1 Y scroll
+ LOGMASKED(LOG_PPU_WRITES, "video_r: Page 1 Y Scroll\n");
+ return m_video_regs[offset];
+
+
case 0x38: // Current Line
LOGMASKED(LOG_VLINES, "video_r: Current Line: %04x\n", m_screen->vpos());
return m_screen->vpos();
@@ -697,16 +707,22 @@ WRITE16_MEMBER(spg2xx_video_device::video_w)
break;
case 0x12: // Page 1 Attributes
- LOGMASKED(LOG_PPU_WRITES, "video_w: Page 1 Attributes = %04x (Depth:%d, Palette:%d, VSize:%d, HSize:%d, FlipY:%d, FlipX:%d, BPP:%d)\n", data
- , (data >> 12) & 3, (data >> 8) & 15, 8 << ((data >> 6) & 3), 8 << ((data >> 4) & 3), BIT(data, 3), BIT(data, 2), 2 * ((data & 3) + 1));
+ {
+ uint16_t attr1 = data;
+ LOGMASKED(LOG_PPU_WRITES, "video_w: Pg1 Attr = %04x (unused: %01x, Depth:%d, Palette:%d, VSize:%d, HSize:%d, FlipY:%d, FlipX:%d, BPP:%d)\n",
+ attr1, (attr1 & 0xc000) >> 14, (attr1 >> 12) & 3, (attr1 >> 8) & 15, 8 << ((attr1 >> 6) & 3), 8 << ((attr1 >> 4) & 3), BIT(attr1, 3), BIT(attr1, 2), 2 * ((attr1 & 3) + 1));
m_video_regs[offset] = data;
break;
+ }
case 0x13: // Page 1 Control
- LOGMASKED(LOG_PPU_WRITES, "video_w: Page 1 Control = %04x (Blend:%d, HiColor:%d, RowScroll:%d, Enable:%d, Wallpaper:%d, RegSet:%d, Bitmap:%d)\n", data
- , BIT(data, 8), BIT(data, 7), BIT(data, 4), BIT(data, 3), BIT(data, 2), BIT(data, 1), BIT(data, 0));
+ {
+ uint16_t ctrl1 = data;
+ LOGMASKED(LOG_PPU_WRITES, "video_w Pg1 Ctrl = %04x (unused: %04x, Blend:%d, HiColor:%d, Ycmp:%d, Hcmp:%d, RowScroll:%d, Enable:%d, Wallpaper:%d, RegSet:%d, Bitmap:%d)\n",
+ ctrl1, (ctrl1 & 0xfe00), BIT(ctrl1, 8), BIT(ctrl1, 7), BIT(ctrl1, 6), BIT(ctrl1, 5), BIT(ctrl1, 4), BIT(ctrl1, 3), BIT(ctrl1, 2), BIT(ctrl1, 1), BIT(ctrl1, 0));
m_video_regs[offset] = data;
break;
+ }
case 0x14: // Page 1 Tile Address
LOGMASKED(LOG_PPU_WRITES, "video_w: Page 1 Tile Address = %04x\n", data & 0x1fff);
@@ -729,27 +745,51 @@ WRITE16_MEMBER(spg2xx_video_device::video_w)
break;
case 0x18: // Page 2 Attributes
- LOGMASKED(LOG_PPU_WRITES, "video_w: Page 2 Attributes = %04x (Depth:%d, Palette:%d, VSize:%d, HSize:%d, FlipY:%d, FlipX:%d, BPP:%d)\n", data
- , (data >> 12) & 3, (data >> 8) & 15, 8 << ((data >> 6) & 3), 8 << ((data >> 4) & 3), BIT(data, 3), BIT(data, 2), 2 * ((data & 3) + 1));
+ {
+ uint16_t attr2 = data;
+ LOGMASKED(LOG_PPU_WRITES, "video_w: Pg2 Attr = %04x (unused: %01x, Depth:%d, Palette:%d, VSize:%d, HSize:%d, FlipY:%d, FlipX:%d, BPP:%d)\n",
+ attr2, (attr2 & 0xc000) >> 14, (attr2 >> 12) & 3, (attr2 >> 8) & 15, 8 << ((attr2 >> 6) & 3), 8 << ((attr2 >> 4) & 3), BIT(attr2, 3), BIT(attr2, 2), 2 * ((attr2 & 3) + 1));
m_video_regs[offset] = data;
break;
+ }
case 0x19: // Page 2 Control
- LOGMASKED(LOG_PPU_WRITES, "video_w: Page 2 Control = %04x (Blend:%d, HiColor:%d, RowScroll:%d, Enable:%d, Wallpaper:%d, RegSet:%d, Bitmap:%d)\n", data
- , BIT(data, 8), BIT(data, 7), BIT(data, 4), BIT(data, 3), BIT(data, 2), BIT(data, 1), BIT(data, 0));
+ {
+ uint16_t ctrl2 = data;
+ LOGMASKED(LOG_PPU_WRITES, "video_w: Pg2 Ctrl = %04x (unused: %04x, Blend:%d, HiColor:%d, Ycmp:%d, Hcmp:%d, RowScroll:%d, Enable:%d, Wallpaper:%d, RegSet:%d, Bitmap:%d)\n",
+ ctrl2, (ctrl2 & 0xfe00), BIT(ctrl2, 8), BIT(ctrl2, 7), BIT(ctrl2, 6), BIT(ctrl2, 5), BIT(ctrl2, 4), BIT(ctrl2, 3), BIT(ctrl2, 2), BIT(ctrl2, 1), BIT(ctrl2, 0));
m_video_regs[offset] = data;
break;
+ }
case 0x1a: // Page 2 Tile Address
- LOGMASKED(LOG_PPU_WRITES, "video_w: Page 2 Tile Address = %04x\n", data & 0x1fff);
+ LOGMASKED(LOG_PPU_WRITES, "video_w: Page 2 Tile Address = %04x\n", data);
m_video_regs[offset] = data;
break;
case 0x1b: // Page 2 Attribute Address
- LOGMASKED(LOG_PPU_WRITES, "video_w: Page 2 Attribute Address = %04x\n", data & 0x1fff);
+ LOGMASKED(LOG_PPU_WRITES, "video_w: Page 2 Attribute Address = %04x\n", data);
m_video_regs[offset] = data;
break;
+ case 0x1c: // vertical compression, amount, 0x20 = no scale? (not on spg288?)
+ LOGMASKED(LOG_PPU_WRITES, "video_w: Ycmp_Value = %04x\n", data);
+ m_video_regs[offset] = data;
+ update_vcmp_table();
+ break;
+
+ case 0x1d: // (not on spg288?)
+ LOGMASKED(LOG_PPU_WRITES, "video_w: Ycmp_Y_Offset = %04x\n", data);
+ m_video_regs[offset] = data;
+ update_vcmp_table();
+ break;
+
+ case 0x1e: // (not on spg288?)
+ LOGMASKED(LOG_PPU_WRITES, "video_w: Ycmp_Step = %04x\n", data);
+ m_video_regs[offset] = data;
+ update_vcmp_table();
+ break;
+
case 0x20: // Page 1 Segment Address
LOGMASKED(LOG_PPU_WRITES, "video_w: Page 1 Segment Address = %04x\n", data);
m_video_regs[offset] = data;
@@ -874,23 +914,6 @@ WRITE_LINE_MEMBER(spg2xx_video_device::vblank)
return;
}
-#if SPG_DEBUG_VIDEO
- if (machine().input().code_pressed_once(KEYCODE_5))
- m_hide_page0 = !m_hide_page0;
- if (machine().input().code_pressed_once(KEYCODE_6))
- m_hide_page1 = !m_hide_page1;
- if (machine().input().code_pressed_once(KEYCODE_7))
- m_hide_sprites = !m_hide_sprites;
- if (machine().input().code_pressed_once(KEYCODE_8))
- m_debug_sprites = !m_debug_sprites;
- if (machine().input().code_pressed_once(KEYCODE_9))
- m_sprite_index_to_debug--;
- if (machine().input().code_pressed_once(KEYCODE_0))
- m_sprite_index_to_debug++;
- if (machine().input().code_pressed_once(KEYCODE_L))
- m_debug_palette = !m_debug_palette;
-#endif
-
if (VIDEO_IRQ_ENABLE & 1)
{
VIDEO_IRQ_STATUS |= 1;
diff --git a/src/devices/machine/spg2xx_video.h b/src/devices/machine/spg2xx_video.h
index 6debca5de2c..cb7a7f4cb62 100644
--- a/src/devices/machine/spg2xx_video.h
+++ b/src/devices/machine/spg2xx_video.h
@@ -38,25 +38,6 @@ protected:
devcb_read16 m_guny_in;
devcb_read16 m_gunx_in;
- enum
- {
- PAGE_ENABLE_MASK = 0x0008,
- PAGE_WALLPAPER_MASK = 0x0004,
-
- SPRITE_ENABLE_MASK = 0x0001,
- SPRITE_COORD_TL_MASK = 0x0002,
-
- PAGE_PRIORITY_FLAG_MASK = 0x3000,
- PAGE_PRIORITY_FLAG_SHIFT = 12,
- PAGE_TILE_HEIGHT_MASK = 0x00c0,
- PAGE_TILE_HEIGHT_SHIFT = 6,
- PAGE_TILE_WIDTH_MASK = 0x0030,
- PAGE_TILE_WIDTH_SHIFT = 4,
- TILE_X_FLIP = 0x0004,
- TILE_Y_FLIP = 0x0008
- };
-
-
inline void check_video_irq();
static const device_timer_id TIMER_SCREENPOS = 2;
@@ -67,47 +48,43 @@ protected:
void do_sprite_dma(uint32_t len);
- enum blend_enable_t : bool
+ enum blend_enable_t : const bool
{
BlendOff = false,
BlendOn = true
};
- enum rowscroll_enable_t : bool
+ enum rowscroll_enable_t : const bool
{
RowScrollOff = false,
RowScrollOn = true
};
- enum flipx_t : bool
+ enum flipx_t : const bool
{
FlipXOff = false,
FlipXOn = true
};
- void apply_saturation(const rectangle &cliprect);
- void apply_fade(const rectangle &cliprect);
+ void apply_saturation_and_fade(bitmap_rgb32& bitmap, const rectangle& cliprect, int scanline);
+
+ void draw_page(const rectangle &cliprect, uint32_t* dst, uint32_t scanline, int priority, uint32_t tilegfxdata_addr, uint16_t *regs);
+ void draw_sprites(const rectangle &cliprect, uint32_t* dst, uint32_t scanline, int priority);
+
+ inline void draw_sprite(const rectangle &cliprect, uint32_t* dst, uint32_t scanline, int priority, uint32_t base_addr);
+ inline void draw_linemap(const rectangle& cliprect, uint32_t* dst, uint32_t scanline, int priority, uint32_t tilegfxdata_addr, uint16_t* regs);
+ inline bool get_tile_info(uint32_t tilemap_rambase, uint32_t palettemap_rambase, uint32_t x0, uint32_t y0, uint32_t tile_count_x, uint32_t ctrl, uint32_t attr, uint16_t& tile, bool& blend, bool& flip_x, bool& flip_y, uint32_t& palette_offset);
- template<blend_enable_t Blend, rowscroll_enable_t RowScroll, flipx_t FlipX>
- void draw(const rectangle &cliprect, uint32_t line, uint32_t xoff, uint32_t yoff, uint32_t bitmap_addr, uint16_t tile, int32_t h, int32_t w, uint8_t bpp, uint32_t yflipmask, uint32_t palette_offset, int yscroll);
- void draw_bitmap(const rectangle& cliprect, uint32_t scanline, int priority, uint32_t bitmap_addr, uint16_t* regs);
- void draw_page(const rectangle &cliprect, uint32_t scanline, int priority, uint32_t bitmap_addr, uint16_t *regs);
- void draw_sprite(const rectangle &cliprect, uint32_t scanline, int priority, uint32_t base_addr);
- void draw_sprites(const rectangle &cliprect, uint32_t scanline, int priority);
+ template<spg2xx_video_device::blend_enable_t Blend, spg2xx_video_device::flipx_t FlipX>
+ inline void draw_tilestrip(const rectangle& cliprect, uint32_t* dst, uint32_t tile_h, uint32_t tile_w, uint32_t tilegfxdata_addr, uint16_t tile, uint32_t tile_scanline, int drawx, bool flip_y, uint32_t palette_offset, const uint32_t nc_bpp, const uint32_t bits_per_row, const uint32_t words_per_tile);
uint8_t mix_channel(uint8_t a, uint8_t b);
- uint32_t m_screenbuf[320 * 240];
uint8_t m_rgb5_to_rgb8[32];
uint32_t m_rgb555_to_rgb888[0x8000];
- bool m_hide_page0;
- bool m_hide_page1;
- bool m_hide_sprites;
- bool m_debug_sprites;
- bool m_debug_blit;
- bool m_debug_palette;
- uint8_t m_sprite_index_to_debug;
+ int m_ycmp_table[480];
+ void update_vcmp_table();
uint16_t m_video_regs[0x100];
@@ -118,6 +95,7 @@ protected:
required_device<unsp_device> m_cpu;
required_device<screen_device> m_screen;
required_shared_ptr<uint16_t> m_scrollram;
+ required_shared_ptr<uint16_t> m_hcompram;
required_shared_ptr<uint16_t> m_paletteram;
required_shared_ptr<uint16_t> m_spriteram;