diff --git a/src/mame/drivers/senjyo.c b/src/mame/drivers/senjyo.c index 47c8eece399..b6e7fec9a4d 100644 --- a/src/mame/drivers/senjyo.c +++ b/src/mame/drivers/senjyo.c @@ -118,28 +118,13 @@ WRITE8_MEMBER(senjyo_state::sound_cmd_w) m_pio->strobe_a(1); } -WRITE8_MEMBER(senjyo_state::paletteram_w) -{ - int r = (data << 2) & 0xC; - int g = (data ) & 0xC; - int b = (data >> 2) & 0xC; - int i = (data >> 6) & 0x3; - - int rr = r|((r!=0)?i:0); - int gg = g|((g!=0)?i:0); - int bb = b|((b!=0)?i:0); - - m_generic_paletteram_8[offset] = data; - m_palette->set_pen_color(offset, pal4bit(rr), pal4bit(gg), pal4bit(bb) ); -} - static ADDRESS_MAP_START( senjyo_map, AS_PROGRAM, 8, senjyo_state ) AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x8000, 0x8fff) AM_RAM AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(fgvideoram_w) AM_SHARE("fgvideoram") AM_RANGE(0x9400, 0x97ff) AM_RAM_WRITE(fgcolorram_w) AM_SHARE("fgcolorram") AM_RANGE(0x9800, 0x987f) AM_RAM AM_SHARE("spriteram") - AM_RANGE(0x9c00, 0x9dff) AM_RAM_WRITE(paletteram_w) AM_SHARE("paletteram") + AM_RANGE(0x9c00, 0x9dff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") AM_RANGE(0x9e00, 0x9e1f) AM_RAM AM_SHARE("fgscroll") AM_RANGE(0x9e20, 0x9e21) AM_RAM AM_SHARE("scrolly3") /* AM_RANGE(0x9e22, 0x9e23) height of the layer (Senjyo only, fixed at 0x380) */ @@ -210,7 +195,7 @@ static ADDRESS_MAP_START( starforb_map, AS_PROGRAM, 8, senjyo_state ) AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(fgvideoram_w) AM_SHARE("fgvideoram") AM_RANGE(0x9400, 0x97ff) AM_RAM_WRITE(fgcolorram_w) AM_SHARE("fgcolorram") AM_RANGE(0x9800, 0x987f) AM_RAM AM_SHARE("spriteram") - AM_RANGE(0x9c00, 0x9dff) AM_RAM_WRITE(paletteram_w) AM_SHARE("paletteram") + AM_RANGE(0x9c00, 0x9dff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") /* The format / use of the ram here is different on the bootleg */ AM_RANGE(0x9e20, 0x9e21) AM_RAM AM_SHARE("scrolly3") AM_RANGE(0x9e25, 0x9e25) AM_RAM AM_SHARE("scrollx3") @@ -588,11 +573,14 @@ static MACHINE_CONFIG_START( senjyo, senjyo_state ) MCFG_SCREEN_SIZE(32*8, 32*8) MCFG_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1) MCFG_SCREEN_UPDATE_DRIVER(senjyo_state, screen_update) - MCFG_SCREEN_PALETTE("palette") MCFG_GFXDECODE_ADD("gfxdecode", "palette", senjyo) - MCFG_PALETTE_ADD_INIT_BLACK("palette", 512+2) /* 512 real palette + 2 for the radar */ + MCFG_PALETTE_ADD_INIT_BLACK("palette", 512) + MCFG_PALETTE_FORMAT(IIBBGGRR) + + MCFG_PALETTE_ADD("radar_palette", 2) + MCFG_PALETTE_INIT_OWNER(senjyo_state, radar) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") diff --git a/src/mame/includes/senjyo.h b/src/mame/includes/senjyo.h index 7ed3af920b9..6bdf965683c 100644 --- a/src/mame/includes/senjyo.h +++ b/src/mame/includes/senjyo.h @@ -15,6 +15,7 @@ public: m_dac(*this, "dac"), m_gfxdecode(*this, "gfxdecode"), m_palette(*this, "palette"), + m_radar_palette(*this, "radar_palette"), m_spriteram(*this, "spriteram"), m_fgscroll(*this, "fgscroll"), m_scrollx1(*this, "scrollx1"), @@ -30,7 +31,6 @@ public: m_bg3videoram(*this, "bg3videoram"), m_radarram(*this, "radarram"), m_bgstripesram(*this, "bgstripesram"), - m_generic_paletteram_8(*this, "paletteram"), m_decrypted_opcodes(*this, "decrypted_opcodes") { } /* devices */ @@ -39,6 +39,7 @@ public: required_device m_dac; required_device m_gfxdecode; required_device m_palette; + required_device m_radar_palette; /* memory pointers */ required_shared_ptr m_spriteram; @@ -56,7 +57,6 @@ public: required_shared_ptr m_bg3videoram; required_shared_ptr m_radarram; required_shared_ptr m_bgstripesram; - required_shared_ptr m_generic_paletteram_8; optional_shared_ptr m_decrypted_opcodes; // game specific initialization @@ -73,7 +73,6 @@ public: tilemap_t *m_bg3_tilemap; DECLARE_WRITE8_MEMBER(flip_screen_w); - DECLARE_WRITE8_MEMBER(paletteram_w); DECLARE_WRITE8_MEMBER(starforb_scrolly2); DECLARE_WRITE8_MEMBER(starforb_scrollx2); DECLARE_WRITE8_MEMBER(fgvideoram_w); @@ -87,6 +86,8 @@ public: DECLARE_WRITE8_MEMBER(irq_ctrl_w); DECLARE_READ8_MEMBER(pio_pa_r); + DECLARE_PALETTE_INIT(radar); + DECLARE_DRIVER_INIT(starfora); DECLARE_DRIVER_INIT(senjyo); DECLARE_DRIVER_INIT(starfore); @@ -101,10 +102,10 @@ public: virtual void machine_start(); virtual void machine_reset(); virtual void video_start(); - UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - void draw_bgbitmap(bitmap_ind16 &bitmap,const rectangle &cliprect); - void draw_radar(bitmap_ind16 &bitmap,const rectangle &cliprect); - void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect,int priority); + UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); + void draw_bgbitmap(bitmap_rgb32 &bitmap, const rectangle &cliprect); + void draw_radar(bitmap_rgb32 &bitmap, const rectangle &cliprect); + void draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect,int priority); }; /*----------- defined in audio/senjyo.c -----------*/ diff --git a/src/mame/video/senjyo.c b/src/mame/video/senjyo.c index 3356d7efe01..e3628a71978 100644 --- a/src/mame/video/senjyo.c +++ b/src/mame/video/senjyo.c @@ -108,6 +108,12 @@ void senjyo_state::video_start() m_fg_tilemap->set_scroll_cols(32); } +PALETTE_INIT_MEMBER( senjyo_state, radar ) +{ + // two colors for the radar dots (verified on the real board) + m_radar_palette->set_pen_color(0, rgb_t(0xff, 0x00, 0x00)); // red for enemies + m_radar_palette->set_pen_color(1, rgb_t(0xff, 0xff, 0x00)); // yellow for player +} /*************************************************************************** @@ -148,10 +154,10 @@ WRITE8_MEMBER(senjyo_state::bg3videoram_w) ***************************************************************************/ -void senjyo_state::draw_bgbitmap(bitmap_ind16 &bitmap,const rectangle &cliprect) +void senjyo_state::draw_bgbitmap(bitmap_rgb32 &bitmap, const rectangle &cliprect) { if (m_bgstripes == 0xff) /* off */ - bitmap.fill(0, cliprect); + bitmap.fill(m_palette->pen_color(0), cliprect); else { int flip = flip_screen(); @@ -166,10 +172,10 @@ void senjyo_state::draw_bgbitmap(bitmap_ind16 &bitmap,const rectangle &cliprect) { if (flip) for (int y = 0;y < 256;y++) - bitmap.pix16(y, 255 - x) = 384 + pen; + bitmap.pix32(y, 255 - x) = m_palette->pen_color(384 + pen); else for (int y = 0;y < 256;y++) - bitmap.pix16(y, x) = 384 + pen; + bitmap.pix32(y, x) = m_palette->pen_color(384 + pen); count += 0x10; if (count >= strwid) @@ -181,7 +187,7 @@ void senjyo_state::draw_bgbitmap(bitmap_ind16 &bitmap,const rectangle &cliprect) } } -void senjyo_state::draw_radar(bitmap_ind16 &bitmap,const rectangle &cliprect) +void senjyo_state::draw_radar(bitmap_rgb32 &bitmap, const rectangle &cliprect) { for (int offs = 0;offs < 0x400;offs++) for (int x = 0;x < 8;x++) @@ -199,11 +205,11 @@ void senjyo_state::draw_radar(bitmap_ind16 &bitmap,const rectangle &cliprect) } if (cliprect.contains(sx, sy)) - bitmap.pix16(sy, sx) = offs < 0x200 ? 512 : 513; + bitmap.pix32(sy, sx) = m_radar_palette->pen_color(offs < 0x200 ? 0 : 1); } } -void senjyo_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect,int priority) +void senjyo_state::draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, int priority) { for (int offs = m_spriteram.bytes() - 4; offs >= 0; offs -= 4) { @@ -250,44 +256,38 @@ void senjyo_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect,i } } -UINT32 senjyo_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +UINT32 senjyo_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { - /* two colors for the radar dots (verified on the real board) */ - m_palette->set_pen_color(512,rgb_t(0xff,0x00,0x00)); /* red for enemies */ - m_palette->set_pen_color(513,rgb_t(0xff,0xff,0x00)); /* yellow for player */ + int flip = flip_screen(); + for (int i = 0;i < 32;i++) + m_fg_tilemap->set_scrolly(i, m_fgscroll[i]); + + int scrollx = m_scrollx1[0]; + int scrolly = m_scrolly1[0] + 256 * m_scrolly1[1]; + if (flip) + scrollx = -scrollx; + m_bg1_tilemap->set_scrollx(0, scrollx); + m_bg1_tilemap->set_scrolly(0, scrolly); + + scrollx = m_scrollx2[0]; + scrolly = m_scrolly2[0] + 256 * m_scrolly2[1]; + if (m_scrollhack) /* Star Force, but NOT the encrypted version */ { - int flip = flip_screen(); - - for (int i = 0;i < 32;i++) - m_fg_tilemap->set_scrolly(i, m_fgscroll[i]); - - int scrollx = m_scrollx1[0]; - int scrolly = m_scrolly1[0] + 256 * m_scrolly1[1]; - if (flip) - scrollx = -scrollx; - m_bg1_tilemap->set_scrollx(0, scrollx); - m_bg1_tilemap->set_scrolly(0, scrolly); - - scrollx = m_scrollx2[0]; - scrolly = m_scrolly2[0] + 256 * m_scrolly2[1]; - if (m_scrollhack) /* Star Force, but NOT the encrypted version */ - { - scrollx = m_scrollx1[0]; - scrolly = m_scrolly1[0] + 256 * m_scrolly1[1]; - } - if (flip) - scrollx = -scrollx; - m_bg2_tilemap->set_scrollx(0, scrollx); - m_bg2_tilemap->set_scrolly(0, scrolly); - - scrollx = m_scrollx3[0]; - scrolly = m_scrolly3[0] + 256 * m_scrolly3[1]; - if (flip) - scrollx = -scrollx; - m_bg3_tilemap->set_scrollx(0, scrollx); - m_bg3_tilemap->set_scrolly(0, scrolly); + scrollx = m_scrollx1[0]; + scrolly = m_scrolly1[0] + 256 * m_scrolly1[1]; } + if (flip) + scrollx = -scrollx; + m_bg2_tilemap->set_scrollx(0, scrollx); + m_bg2_tilemap->set_scrolly(0, scrolly); + + scrollx = m_scrollx3[0]; + scrolly = m_scrolly3[0] + 256 * m_scrolly3[1]; + if (flip) + scrollx = -scrollx; + m_bg3_tilemap->set_scrollx(0, scrollx); + m_bg3_tilemap->set_scrolly(0, scrolly); draw_bgbitmap(bitmap, cliprect); draw_sprites(bitmap, cliprect, 0);