summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/gaplus.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/video/gaplus.cpp')
-rw-r--r--src/mame/video/gaplus.cpp182
1 files changed, 82 insertions, 100 deletions
diff --git a/src/mame/video/gaplus.cpp b/src/mame/video/gaplus.cpp
index a7a492bc588..3ef083b6f79 100644
--- a/src/mame/video/gaplus.cpp
+++ b/src/mame/video/gaplus.cpp
@@ -25,46 +25,43 @@
***************************************************************************/
-PALETTE_INIT_MEMBER(gaplus_state, gaplus)
+PALETTE_INIT_MEMBER(gaplus_base_state, gaplus)
{
- const uint8_t *color_prom = memregion("proms")->base();
- int i;
-
- for (i = 0;i < 256;i++)
+ const uint8_t *color_prom = m_proms_region->base();
+ for (int i = 0; i < 256; i++)
{
- int bit0,bit1,bit2,bit3,r,g,b;
-
/* red component */
- bit0 = (color_prom[i] >> 0) & 0x01;
- bit1 = (color_prom[i] >> 1) & 0x01;
- bit2 = (color_prom[i] >> 2) & 0x01;
- bit3 = (color_prom[i] >> 3) & 0x01;
- r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
- /* green component */
- bit0 = (color_prom[i + 0x100] >> 0) & 0x01;
- bit1 = (color_prom[i + 0x100] >> 1) & 0x01;
- bit2 = (color_prom[i + 0x100] >> 2) & 0x01;
- bit3 = (color_prom[i + 0x100] >> 3) & 0x01;
- g = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
+ int bit0 = BIT(color_prom[i], 0);
+ int bit1 = BIT(color_prom[i], 1);
+ int bit2 = BIT(color_prom[i], 2);
+ int bit3 = BIT(color_prom[i], 3);
+ int r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
+
+ /* green component */
+ bit0 = BIT(color_prom[i + 0x100], 0);
+ bit1 = BIT(color_prom[i + 0x100], 1);
+ bit2 = BIT(color_prom[i + 0x100], 2);
+ bit3 = BIT(color_prom[i + 0x100], 3);
+ int g = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
/* blue component */
- bit0 = (color_prom[i + 0x200] >> 0) & 0x01;
- bit1 = (color_prom[i + 0x200] >> 1) & 0x01;
- bit2 = (color_prom[i + 0x200] >> 2) & 0x01;
- bit3 = (color_prom[i + 0x200] >> 3) & 0x01;
- b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
+ bit0 = BIT(color_prom[i + 0x200], 0);
+ bit1 = BIT(color_prom[i + 0x200], 1);
+ bit2 = BIT(color_prom[i + 0x200], 2);
+ bit3 = BIT(color_prom[i + 0x200], 3);
+ int b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
- palette.set_indirect_color(i,rgb_t(r,g,b));
+ palette.set_indirect_color(i, rgb_t(r, g, b));
}
color_prom += 0x300;
/* color_prom now points to the beginning of the lookup table */
/* characters use colors 0xf0-0xff */
- for (i = 0;i < m_gfxdecode->gfx(0)->colors() * m_gfxdecode->gfx(0)->granularity();i++)
+ for (int i = 0; i < m_gfxdecode->gfx(0)->colors() * m_gfxdecode->gfx(0)->granularity(); i++)
palette.set_pen_indirect(m_gfxdecode->gfx(0)->colorbase() + i, 0xf0 + (*color_prom++ & 0x0f));
/* sprites */
- for (i = 0;i < m_gfxdecode->gfx(1)->colors() * m_gfxdecode->gfx(1)->granularity();i++)
+ for (int i = 0; i < m_gfxdecode->gfx(1)->colors() * m_gfxdecode->gfx(1)->granularity(); i++)
{
palette.set_pen_indirect(m_gfxdecode->gfx(1)->colorbase() + i, (color_prom[0] & 0x0f) + ((color_prom[0x200] & 0x0f) << 4));
color_prom++;
@@ -80,23 +77,18 @@ PALETTE_INIT_MEMBER(gaplus_state, gaplus)
***************************************************************************/
/* convert from 32x32 to 36x28 */
-TILEMAP_MAPPER_MEMBER(gaplus_state::tilemap_scan)
+TILEMAP_MAPPER_MEMBER(gaplus_base_state::tilemap_scan)
{
- int offs;
-
row += 2;
col -= 2;
if (col & 0x20)
- offs = row + ((col & 0x1f) << 5);
- else
- offs = col + (row << 5);
-
- return offs;
+ return row + ((col & 0x1f) << 5);
+ return col + (row << 5);
}
-TILE_GET_INFO_MEMBER(gaplus_state::get_tile_info)
+TILE_GET_INFO_MEMBER(gaplus_base_state::get_tile_info)
{
- uint8_t attr = m_videoram[tile_index + 0x400];
+ const uint8_t attr = m_videoram[tile_index + 0x400];
tileinfo.category = (attr & 0x40) >> 6;
tileinfo.group = attr & 0x3f;
SET_TILE_INFO_MEMBER(0,
@@ -123,42 +115,40 @@ TILE_GET_INFO_MEMBER(gaplus_state::get_tile_info)
#define SPEED_2 1.0f
#define SPEED_3 2.0f
-void gaplus_state::starfield_init()
+void gaplus_base_state::starfield_init()
{
- struct star *stars = m_stars;
int generator = 0;
- int x,y;
int set = 0;
- int width = m_screen->width();
- int height = m_screen->height();
+ const int width = m_screen->width();
+ const int height = m_screen->height();
m_total_stars = 0;
/* precalculate the star background */
/* this comes from the Galaxian hardware, Gaplus is probably different */
- for ( y = 0;y < height; y++ ) {
- for ( x = width*2 - 1; x >= 0; x--) {
- int bit1,bit2;
-
+ for (int y = 0; y < height; y++)
+ {
+ for (int x = width * 2 - 1; x >= 0; x--)
+ {
generator <<= 1;
- bit1 = (~generator >> 17) & 1;
- bit2 = (generator >> 5) & 1;
+ const int bit1 = (~generator >> 17) & 1;
+ const int bit2 = (generator >> 5) & 1;
if (bit1 ^ bit2) generator |= 1;
- if ( ((~generator >> 16) & 1) && (generator & 0xff) == 0xff) {
- int color;
-
- color = (~(generator >> 8)) & 0x3f;
- if ( color && m_total_stars < MAX_STARS ) {
- stars[m_total_stars].x = x;
- stars[m_total_stars].y = y;
- stars[m_total_stars].col = color;
- stars[m_total_stars].set = set++;
-
- if ( set == 3 )
+ if (BIT(~generator, 16) && (generator & 0xff) == 0xff)
+ {
+ const int color = ~(generator >> 8) & 0x3f;
+ if (color && m_total_stars < MAX_STARS)
+ {
+ m_stars[m_total_stars].x = x;
+ m_stars[m_total_stars].y = y;
+ m_stars[m_total_stars].col = color;
+ m_stars[m_total_stars].set = set++;
+
+ if (set == 3)
set = 0;
m_total_stars++;
@@ -176,7 +166,7 @@ void gaplus_state::starfield_init()
***************************************************************************/
-void gaplus_state::video_start()
+void gaplus_base_state::video_start()
{
m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(gaplus_state::get_tile_info),this),tilemap_mapper_delegate(FUNC(gaplus_state::tilemap_scan),this),8,8,36,28);
@@ -202,16 +192,15 @@ void gaplus_state::video_start()
***************************************************************************/
-WRITE8_MEMBER(gaplus_state::videoram_w)
+WRITE8_MEMBER(gaplus_base_state::videoram_w)
{
m_videoram[offset] = data;
m_bg_tilemap->mark_tile_dirty(offset & 0x3ff);
}
-WRITE8_MEMBER(gaplus_state::starfield_control_w)
+WRITE8_MEMBER(gaplus_base_state::starfield_control_w)
{
- offset &= 3;
- m_starfield_control[offset] = data;
+ m_starfield_control[offset & 3] = data;
}
@@ -222,41 +211,35 @@ WRITE8_MEMBER(gaplus_state::starfield_control_w)
***************************************************************************/
-void gaplus_state::starfield_render(bitmap_ind16 &bitmap)
+void gaplus_base_state::starfield_render(bitmap_ind16 &bitmap)
{
- struct star *stars = m_stars;
- int i;
-
- int width = m_screen->width();
- int height = m_screen->height();
-
/* check if we're running */
- if ( ( m_starfield_control[0] & 1 ) == 0 )
+ if ((m_starfield_control[0] & 1) == 0)
return;
- /* draw the starfields */
- for ( i = 0; i < m_total_stars; i++ )
- {
- int x, y;
+ const int width = m_screen->width();
+ const int height = m_screen->height();
- x = stars[i].x;
- y = stars[i].y;
+ /* draw the starfields */
+ for (int i = 0; i < m_total_stars; i++)
+ {
+ int x = m_stars[i].x;
+ int y = m_stars[i].y;
- if ( x >=0 && x < width && y >= 0 && y < height )
+ if (x >= 0 && x < width && y >= 0 && y < height)
{
- bitmap.pix16(y, x) = stars[i].col;
+ bitmap.pix16(y, x) = m_stars[i].col;
}
}
}
-void gaplus_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect )
+void gaplus_base_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect ) const
{
uint8_t *spriteram = m_spriteram + 0x780;
uint8_t *spriteram_2 = spriteram + 0x800;
uint8_t *spriteram_3 = spriteram_2 + 0x800;
- int offs;
- for (offs = 0;offs < 0x80;offs += 2)
+ for (int offs = 0;offs < 0x80;offs += 2)
{
/* is it on? */
if ((spriteram_3[offs+1] & 2) == 0)
@@ -266,16 +249,15 @@ void gaplus_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect
{ 0, 1 },
{ 2, 3 }
};
- int sprite = spriteram[offs] | ((spriteram_3[offs] & 0x40) << 2);
- int color = spriteram[offs+1] & 0x3f;
- int sx = spriteram_2[offs+1] + 0x100 * (spriteram_3[offs+1] & 1) - 71;
+ const int sprite = spriteram[offs] | ((spriteram_3[offs] & 0x40) << 2);
+ const int color = spriteram[offs+1] & 0x3f;
+ const int sx = spriteram_2[offs+1] + 0x100 * (spriteram_3[offs+1] & 1) - 71;
int sy = 256 - spriteram_2[offs] - 8;
- int flipx = (spriteram_3[offs] & 0x01);
- int flipy = (spriteram_3[offs] & 0x02) >> 1;
- int sizex = (spriteram_3[offs] & 0x08) >> 3;
- int sizey = (spriteram_3[offs] & 0x20) >> 5;
- int duplicate = spriteram_3[offs] & 0x80;
- int x,y;
+ int flipx = BIT(spriteram_3[offs], 0);
+ int flipy = BIT(spriteram_3[offs], 1);
+ const int sizex = BIT(spriteram_3[offs], 3);
+ const int sizey = BIT(spriteram_3[offs], 5);
+ const int duplicate = spriteram_3[offs] & 0x80;
if (flip_screen())
{
@@ -286,15 +268,15 @@ void gaplus_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect
sy -= 16 * sizey;
sy = (sy & 0xff) - 32; // fix wraparound
- for (y = 0;y <= sizey;y++)
+ for (int y = 0;y <= sizey; y++)
{
- for (x = 0;x <= sizex;x++)
+ for (int x = 0; x <= sizex; x++)
{
- m_gfxdecode->gfx(1)->transmask(bitmap,cliprect,
+ m_gfxdecode->gfx(1)->transmask(bitmap, cliprect,
sprite + (duplicate ? 0 : (gfx_offs[y ^ (sizey * flipy)][x ^ (sizex * flipx)])),
color,
flipx,flipy,
- sx + 16*x,sy + 16*y,
+ sx + 16 * x, sy + 16 * y,
m_palette->transpen_mask(*m_gfxdecode->gfx(1), color, 0xff));
}
}
@@ -302,28 +284,28 @@ void gaplus_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect
}
}
-uint32_t gaplus_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
+uint32_t gaplus_base_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
/* flip screen control is embedded in RAM */
- flip_screen_set(m_spriteram[0x1f7f-0x800] & 1);
+ flip_screen_set(m_spriteram[0x1f7f - 0x800] & 1);
bitmap.fill(0, cliprect);
starfield_render(bitmap);
/* draw the low priority characters */
- m_bg_tilemap->draw(screen, bitmap, cliprect, 0,0);
+ m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0);
draw_sprites(bitmap, cliprect);
/* draw the high priority characters */
/* (I don't know if this feature is used by Gaplus, but it's shown in the schematics) */
- m_bg_tilemap->draw(screen, bitmap, cliprect, 1,0);
+ m_bg_tilemap->draw(screen, bitmap, cliprect, 1, 0);
return 0;
}
-WRITE_LINE_MEMBER(gaplus_state::screen_vblank)/* update starfields */
+WRITE_LINE_MEMBER(gaplus_base_state::screen_vblank)/* update starfields */
{
// falling edge
if (!state)