summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/drivers/skyarmy.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/drivers/skyarmy.cpp')
-rw-r--r--src/mame/drivers/skyarmy.cpp90
1 files changed, 43 insertions, 47 deletions
diff --git a/src/mame/drivers/skyarmy.cpp b/src/mame/drivers/skyarmy.cpp
index 3f86596e7b8..c16ee02e5f4 100644
--- a/src/mame/drivers/skyarmy.cpp
+++ b/src/mame/drivers/skyarmy.cpp
@@ -36,18 +36,23 @@
class skyarmy_state : public driver_device
{
public:
- skyarmy_state(const machine_config &mconfig, device_type type, const char *tag)
- : driver_device(mconfig, type, tag),
+ skyarmy_state(const machine_config &mconfig, device_type type, const char *tag) :
+ driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette"),
m_videoram(*this, "videoram"),
m_colorram(*this, "colorram"),
m_spriteram(*this, "spriteram"),
- m_scrollram(*this, "scrollram") { }
+ m_scrollram(*this, "scrollram")
+ { }
void skyarmy(machine_config &config);
+protected:
+ virtual void machine_start() override;
+ virtual void video_start() override;
+
private:
required_device<cpu_device> m_maincpu;
required_device<gfxdecode_device> m_gfxdecode;
@@ -70,9 +75,7 @@ private:
TILE_GET_INFO_MEMBER(get_tile_info);
- virtual void machine_start() override;
- virtual void video_start() override;
- DECLARE_PALETTE_INIT(skyarmy);
+ void skyarmy_palette(palette_device &palette) const;
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
@@ -99,7 +102,7 @@ WRITE_LINE_MEMBER(skyarmy_state::flip_screen_y_w)
TILE_GET_INFO_MEMBER(skyarmy_state::get_tile_info)
{
int code = m_videoram[tile_index];
- int attr = bitswap<8>(m_colorram[tile_index], 7, 6, 5, 4, 3, 0, 1, 2) & 7;
+ int attr = bitswap<3>(m_colorram[tile_index], 0, 1, 2);
SET_TILE_INFO_MEMBER(0, code, attr, 0);
}
@@ -116,32 +119,29 @@ WRITE8_MEMBER(skyarmy_state::colorram_w)
m_tilemap->mark_tile_dirty(offset);
}
-PALETTE_INIT_MEMBER(skyarmy_state, skyarmy)
+void skyarmy_state::skyarmy_palette(palette_device &palette) const
{
- const uint8_t *color_prom = memregion("proms")->base();
- int i;
-
- for (i = 0;i < 32;i++)
+ uint8_t const *const color_prom = memregion("proms")->base();
+ for (int i = 0; i < 32; i++)
{
- int bit0,bit1,bit2,r,g,b;
+ int bit0, bit1, bit2;
- bit0 = (*color_prom >> 0) & 0x01;
- bit1 = (*color_prom >> 1) & 0x01;
- bit2 = (*color_prom >> 2) & 0x01;
- r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
+ bit0 = BIT(color_prom[i], 0);
+ bit1 = BIT(color_prom[i], 1);
+ bit2 = BIT(color_prom[i], 2);
+ int const r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
- bit0 = (*color_prom >> 3) & 0x01;
- bit1 = (*color_prom >> 4) & 0x01;
- bit2 = (*color_prom >> 5) & 0x01;
- g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
+ bit0 = BIT(color_prom[i], 3);
+ bit1 = BIT(color_prom[i], 4);
+ bit2 = BIT(color_prom[i], 5);
+ int const g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
- bit0=0;
- bit1 = (*color_prom >> 6) & 0x01;
- bit2 = (*color_prom >> 7) & 0x01;
- b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
+ bit0 = 0;
+ bit1 = BIT(color_prom[i], 6);
+ bit2 = BIT(color_prom[i], 7);
+ int const b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
- palette.set_pen_color(i,rgb_t(r,g,b));
- color_prom++;
+ palette.set_pen_color(i, rgb_t(r, g, b));
}
}
@@ -154,22 +154,19 @@ void skyarmy_state::video_start()
uint32_t skyarmy_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
- int sx, sy, flipx, flipy, offs,pal;
- int i;
-
- for(i=0;i<0x20;i++)
- m_tilemap->set_scrolly(i,m_scrollram[i]);
+ for (int i = 0; i < 0x20; i++)
+ m_tilemap->set_scrolly(i, m_scrollram[i]);
- m_tilemap->draw(screen, bitmap, cliprect, 0,0);
+ m_tilemap->draw(screen, bitmap, cliprect, 0, 0);
- for (offs = 0 ; offs < 0x40; offs+=4)
+ for (int offs = 0; offs < 0x40; offs += 4)
{
- pal = bitswap<8>(m_spriteram[offs+2], 7, 6, 5, 4, 3, 0, 1, 2) & 7;
+ int const pal = bitswap<3>(m_spriteram[offs + 2], 0, 1, 2);
- sx = m_spriteram[offs+3];
- sy = 240-(m_spriteram[offs]+1);
- flipy = (m_spriteram[offs+1]&0x80)>>7;
- flipx = (m_spriteram[offs+1]&0x40)>>6;
+ int sx = m_spriteram[offs + 3];
+ int sy = 240 - (m_spriteram[offs] + 1);
+ int flipy = BIT(m_spriteram[offs + 1], 7);
+ int flipx = BIT(m_spriteram[offs + 1], 6);
if (flip_screen_x())
{
@@ -183,10 +180,10 @@ uint32_t skyarmy_state::screen_update(screen_device &screen, bitmap_ind16 &bitma
}
m_gfxdecode->gfx(1)->transpen(bitmap,cliprect,
- m_spriteram[offs+1]&0x3f,
- pal,
- flipx,flipy,
- sx,sy,0);
+ m_spriteram[offs + 1] & 0x3f,
+ pal,
+ flipx, flipy,
+ sx, sy, 0);
}
return 0;
@@ -345,11 +342,10 @@ MACHINE_CONFIG_START(skyarmy_state::skyarmy)
MCFG_SCREEN_SIZE(32*8,32*8)
MCFG_SCREEN_VISIBLE_AREA(0*8,32*8-1,1*8,31*8-1)
MCFG_SCREEN_UPDATE_DRIVER(skyarmy_state, screen_update)
- MCFG_SCREEN_PALETTE("palette")
+ MCFG_SCREEN_PALETTE(m_palette)
- MCFG_DEVICE_ADD("gfxdecode", GFXDECODE, "palette", gfx_skyarmy)
- MCFG_PALETTE_ADD("palette", 32)
- MCFG_PALETTE_INIT_OWNER(skyarmy_state, skyarmy)
+ GFXDECODE(config, m_gfxdecode, m_palette, gfx_skyarmy);
+ PALETTE(config, m_palette, FUNC(skyarmy_state::skyarmy_palette), 32);
/* sound hardware */
SPEAKER(config, "mono").front_center();