From 2a441a97b002686a2c4717f1e6e50c43145f81f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Banaan=20Ananas?= Date: Tue, 9 Jul 2013 10:03:46 +0000 Subject: [PATCH] added video enable bits --- src/mame/drivers/raiden.c | 25 +++-- src/mame/includes/raiden.h | 16 ++- src/mame/video/raiden.c | 198 ++++++++++++++++++++++++------------- 3 files changed, 154 insertions(+), 85 deletions(-) diff --git a/src/mame/drivers/raiden.c b/src/mame/drivers/raiden.c index 693de9e1b83..464b8b18b74 100644 --- a/src/mame/drivers/raiden.c +++ b/src/mame/drivers/raiden.c @@ -9,9 +9,9 @@ driver by Oliver Bergmann, Bryan McPhail, Randy Mongenel - The alternate hardware version is probably earlier than the main set. - It looks closer to Dynamite Duke (1989 game), while the main set looks - closer to the newer 68000 games in terms of graphics registers used, etc. + The alternate hardware version is probably newer than the main sets. + It looks closer to the newer 68000 games, while the main set looks + closer to Dynamite Duke (1989 game) in terms of graphics registers used, etc. As well as different graphics registers the alternate set has a different memory map, and different fix char layer memory layout! @@ -52,8 +52,9 @@ static ADDRESS_MAP_START( main_map, AS_PROGRAM, 16, raiden_state ) AM_RANGE(0x0a000, 0x0a00d) AM_READWRITE_LEGACY(seibu_main_word_r, seibu_main_word_w) AM_RANGE(0x0c000, 0x0c7ff) AM_WRITE(raiden_text_w) AM_SHARE("videoram") AM_RANGE(0x0e000, 0x0e001) AM_READ_PORT("P1_P2") - AM_RANGE(0x0e000, 0x0e007) AM_WRITE(raiden_control_w) AM_RANGE(0x0e002, 0x0e003) AM_READ_PORT("DSW") + AM_RANGE(0x0e004, 0x0e005) AM_WRITENOP // watchdog? + AM_RANGE(0x0e006, 0x0e007) AM_WRITE8(raiden_control_w, 0x00ff) AM_RANGE(0x0f000, 0x0f03f) AM_WRITEONLY AM_SHARE("scroll_ram") AM_RANGE(0xa0000, 0xfffff) AM_ROM ADDRESS_MAP_END @@ -65,7 +66,7 @@ static ADDRESS_MAP_START( sub_map, AS_PROGRAM, 16, raiden_state ) AM_RANGE(0x03000, 0x03fff) AM_RAM_WRITE(paletteram_xxxxBBBBGGGGRRRR_word_w) AM_SHARE("paletteram") AM_RANGE(0x04000, 0x04fff) AM_RAM AM_SHARE("shared_ram") AM_RANGE(0x07ffe, 0x07fff) AM_WRITENOP // ? - AM_RANGE(0x08000, 0x08001) AM_WRITENOP // ? + AM_RANGE(0x08000, 0x08001) AM_WRITENOP // watchdog? AM_RANGE(0x0a000, 0x0a001) AM_WRITENOP // ? AM_RANGE(0xc0000, 0xfffff) AM_ROM ADDRESS_MAP_END @@ -80,7 +81,8 @@ static ADDRESS_MAP_START( raidenu_main_map, AS_PROGRAM, 16, raiden_state ) AM_RANGE(0x0a000, 0x0afff) AM_RAM AM_SHARE("shared_ram") AM_RANGE(0x0b000, 0x0b001) AM_READ_PORT("P1_P2") AM_RANGE(0x0b002, 0x0b003) AM_READ_PORT("DSW") - AM_RANGE(0x0b000, 0x0b007) AM_WRITE(raiden_control_w) + AM_RANGE(0x0b004, 0x0b005) AM_WRITENOP // watchdog? + AM_RANGE(0x0b006, 0x0b007) AM_WRITE8(raiden_control_w, 0x00ff) AM_RANGE(0x0c000, 0x0c7ff) AM_WRITE(raiden_text_w) AM_SHARE("videoram") AM_RANGE(0x0d000, 0x0d00d) AM_READWRITE_LEGACY(seibu_main_word_r, seibu_main_word_w) AM_RANGE(0xa0000, 0xfffff) AM_ROM @@ -93,7 +95,7 @@ static ADDRESS_MAP_START( raidenu_sub_map, AS_PROGRAM, 16, raiden_state ) AM_RANGE(0x07000, 0x07fff) AM_RAM_WRITE(paletteram_xxxxBBBBGGGGRRRR_word_w) AM_SHARE("paletteram") AM_RANGE(0x08000, 0x08fff) AM_RAM AM_SHARE("shared_ram") AM_RANGE(0x0a000, 0x0a001) AM_WRITENOP // ? - AM_RANGE(0x0c000, 0x0c001) AM_WRITENOP // ? + AM_RANGE(0x0c000, 0x0c001) AM_WRITENOP // watchdog? AM_RANGE(0xc0000, 0xfffff) AM_ROM ADDRESS_MAP_END @@ -106,10 +108,13 @@ static ADDRESS_MAP_START( raidenb_main_map, AS_PROGRAM, 16, raiden_state ) AM_RANGE(0x0a000, 0x0afff) AM_RAM AM_SHARE("shared_ram") AM_RANGE(0x0b000, 0x0b001) AM_READ_PORT("P1_P2") AM_RANGE(0x0b002, 0x0b003) AM_READ_PORT("DSW") - AM_RANGE(0x0b000, 0x0b007) AM_WRITE(raidenb_control_w) + AM_RANGE(0x0b004, 0x0b005) AM_WRITENOP // watchdog? + AM_RANGE(0x0b006, 0x0b007) AM_WRITE8(raidenb_control_w, 0x00ff) AM_RANGE(0x0c000, 0x0c7ff) AM_WRITE(raiden_text_w) AM_SHARE("videoram") AM_RANGE(0x0d000, 0x0d00d) AM_READWRITE_LEGACY(seibu_main_word_r, seibu_main_word_w) + AM_RANGE(0x0d05c, 0x0d05d) AM_WRITE8(raidenb_layer_enable_w, 0x00ff) AM_RANGE(0x0d060, 0x0d067) AM_WRITEONLY AM_SHARE("scroll_ram") + AM_RANGE(0x0d040, 0x0d08f) AM_WRITENOP // sei_crtc is here AM_RANGE(0xa0000, 0xfffff) AM_ROM ADDRESS_MAP_END @@ -608,14 +613,14 @@ DRIVER_INIT_MEMBER(raiden_state,raidenu) /* Same PCB, differ by region byte(s) */ GAME( 1990, raiden, 0, raiden, raiden, raiden_state, raiden, ROT270, "Seibu Kaihatsu", "Raiden (set 1)", 0 ) GAME( 1990, raidena, raiden, raiden, raiden, raiden_state, raiden, ROT270, "Seibu Kaihatsu", "Raiden (set 2)", 0 ) -GAME( 1990, raidenu, raiden, raiden, raiden, raiden_state, raiden, ROT270, "Seibu Kaihatsu (Fabtek license)", "Raiden (US)", 0 ) +GAME( 1990, raidenu, raiden, raiden, raiden, raiden_state, raiden, ROT270, "Seibu Kaihatsu (Fabtek license)", "Raiden (US set 1)", 0 ) GAME( 1990, raident, raiden, raiden, raiden, raiden_state, raiden, ROT270, "Seibu Kaihatsu (Liang HWA Electronics license)", "Raiden (Taiwan)", 0 ) /* Same as above, but the sound CPU code is not encrypted */ GAME( 1990, raidenk, raiden, raiden, raiden, raiden_state, raidenk, ROT270, "Seibu Kaihatsu (IBL Corporation license)", "Raiden (Korea)", 0 ) /* Alternate hardware; SEI8904 + SEI9008 PCBs. Main & Sub CPU code not encrypted */ -GAME( 1990, raidenua, raiden, raidenu, raiden, raiden_state, raidenu, ROT270, "Seibu Kaihatsu (Fabtek license)", "Raiden (US, newer?)", 0 ) +GAME( 1990, raidenua, raiden, raidenu, raiden, raiden_state, raidenu, ROT270, "Seibu Kaihatsu (Fabtek license)", "Raiden (US set 2)", 0 ) /* Alternate hardware. Main, Sub & Sound CPU code not encrypted - could possibly be a bootleg?? */ GAME( 1990, raidenb, raiden, raidenb, raiden, driver_device, 0, ROT270, "Seibu Kaihatsu", "Raiden (set 3)", 0 ) diff --git a/src/mame/includes/raiden.h b/src/mame/includes/raiden.h index ade4539c72d..a7f8fc231df 100644 --- a/src/mame/includes/raiden.h +++ b/src/mame/includes/raiden.h @@ -31,14 +31,19 @@ public: tilemap_t *m_bg_layer; tilemap_t *m_fg_layer; tilemap_t *m_tx_layer; - int m_flipscreen; + UINT8 m_bg_layer_enabled; + UINT8 m_fg_layer_enabled; + UINT8 m_tx_layer_enabled; + UINT8 m_sp_layer_enabled; + UINT8 m_flipscreen; - DECLARE_READ16_MEMBER(sub_cpu_spin_r); DECLARE_WRITE16_MEMBER(raiden_background_w); DECLARE_WRITE16_MEMBER(raiden_foreground_w); DECLARE_WRITE16_MEMBER(raiden_text_w); - DECLARE_WRITE16_MEMBER(raiden_control_w); - DECLARE_WRITE16_MEMBER(raidenb_control_w); + DECLARE_WRITE8_MEMBER(raiden_control_w); + DECLARE_WRITE8_MEMBER(raidenb_control_w); + DECLARE_WRITE8_MEMBER(raidenb_layer_enable_w); + DECLARE_WRITE16_MEMBER(raiden_scroll_w); DECLARE_DRIVER_INIT(raidenu); DECLARE_DRIVER_INIT(raidenk); DECLARE_DRIVER_INIT(raiden); @@ -47,9 +52,10 @@ public: TILE_GET_INFO_MEMBER(get_text_tile_info); virtual void video_start(); DECLARE_VIDEO_START(raidenb); + UINT32 screen_update_common(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT16 *scrollregs); UINT32 screen_update_raiden(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); UINT32 screen_update_raidenb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); INTERRUPT_GEN_MEMBER(raiden_interrupt); - void draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect,int pri_mask); + void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int pri_mask); void common_decrypt(); }; diff --git a/src/mame/video/raiden.c b/src/mame/video/raiden.c index 2cdd972977b..cee5ecd5082 100644 --- a/src/mame/video/raiden.c +++ b/src/mame/video/raiden.c @@ -31,105 +31,163 @@ WRITE16_MEMBER(raiden_state::raiden_text_w) } -WRITE16_MEMBER(raiden_state::raiden_control_w) +WRITE8_MEMBER(raiden_state::raiden_control_w) { - /* All other bits unknown - could be playfield enables */ + // d0: back layer disable + // d1: fore layer disable + // d2: text layer disable + // d3: sprite layer disable + // d4: unused + // d5: unused + // d6: flipscreen + // d7: toggles, maybe spriteram bank? (for buffering) + m_bg_layer_enabled = ~data & 0x01; + m_fg_layer_enabled = ~data & 0x02; + m_tx_layer_enabled = ~data & 0x04; + m_sp_layer_enabled = ~data & 0x08; - /* Flipscreen */ - if (offset==3 && ACCESSING_BITS_0_7) { - m_flipscreen=data&0x40; - machine().tilemap().set_flip_all(m_flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); - } + m_flipscreen = data & 0x40; + machine().tilemap().set_flip_all(m_flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); } -WRITE16_MEMBER(raiden_state::raidenb_control_w) +WRITE8_MEMBER(raiden_state::raidenb_control_w) { - /* raidenb uses 0x02 instead of 0x40 */ + // d1: flipscreen + // d2: toggles, maybe spriteram bank? (for buffering) + // d3: text layer disable (i guess raidenb textlayer isn't part of sei_crtc?) + // other bits: unused + m_tx_layer_enabled = ~data & 0x08; - /* Flipscreen */ - if (offset==3 && ACCESSING_BITS_0_7) { - m_flipscreen=data&0x2; - machine().tilemap().set_flip_all(m_flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); - } + m_flipscreen = data & 0x02; + machine().tilemap().set_flip_all(m_flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); +} + +WRITE8_MEMBER(raiden_state::raidenb_layer_enable_w) +{ + // d0: back layer disable + // d1: fore layer disable + // d4: sprite layer disable + // other bits: unused? (d2-d3 always set, d5-d7 always clear) + m_bg_layer_enabled = ~data & 0x01; + m_fg_layer_enabled = ~data & 0x02; + m_sp_layer_enabled = ~data & 0x10; } /******************************************************************************/ -void raiden_state::draw_sprites(bitmap_ind16 &bitmap,const rectangle &cliprect,int pri_mask) +void raiden_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int pri_mask) { - UINT16 *buffered_spriteram16 = m_spriteram->buffer(); - int offs,fx,fy,x,y,color,sprite; + if (!m_sp_layer_enabled) + return; + + UINT16 *sprites = m_spriteram->buffer(); + gfx_element *gfx = machine().gfx[3]; - for (offs = 0x1000/2-4;offs >= 0;offs -= 4) + for (int offs = 0x1000/2-4; offs >= 0; offs -= 4) { - if (!(pri_mask&(buffered_spriteram16[offs+2]>>8))) continue; + /* + Word #0 + x------- -------- active + -x------ -------- flipy + --x----- -------- flipx + ---x---- -------- unused + ----xxxx -------- color + -------- xxxxxxxx y - fx = buffered_spriteram16[offs+0] & 0x2000; - fy = buffered_spriteram16[offs+0] & 0x4000; - color = (buffered_spriteram16[offs+0] & 0x0f00) >> 8; - y = buffered_spriteram16[offs+0] & 0x00ff; + Word #1 + x------- -------- ? (set when groundboss explodes) + -xxx---- -------- unused + ----xxxx xxxxxxxx code - sprite = buffered_spriteram16[offs+1]; - sprite &= 0x0fff; + Word #2 + xx------ -------- priority + --xxxxx- -------- unused + -------x xxxxxxxx x (signed) - x = buffered_spriteram16[offs+2] & 0xff; - if (buffered_spriteram16[offs+2] & 0x100) x=0-(0x100-x); + Word #3 unused + */ + + if (!(sprites[offs + 0] & 0x8000)) + continue; + + int priority = sprites[offs + 2] >> 14 & 0x3; + if ((priority & pri_mask) == 0) + continue; - if (m_flipscreen) { - x=240-x; - y=240-y; - if (fx) fx=0; else fx=1; - if (fy) fy=0; else fy=1; + int flipy = sprites[offs + 0] & 0x4000; + int flipx = sprites[offs + 0] & 0x2000; + int color = (sprites[offs + 0] & 0xf00) >> 8; + int code = sprites[offs + 1] & 0xfff; + + int y = sprites[offs + 0] & 0xff; + int x = sprites[offs + 2] & 0xff; + if (sprites[offs + 2] & 0x100) + x = -(0x100 - x); + + if (m_flipscreen) + { + x = 240 - x; + y = 240 - y; + flipy = !flipy; + flipx = !flipx; } - drawgfx_transpen(bitmap,cliprect,machine().gfx[3], - sprite, - color,fx,fy,x,y,15); + drawgfx_transpen(bitmap, cliprect, gfx, code, color, flipx, flipy, x, y, 15); } } +UINT32 raiden_state::screen_update_common(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, UINT16 *scrollregs) +{ + // set tilemaps scroll + m_bg_layer->set_scrollx(0, scrollregs[0]); + m_bg_layer->set_scrolly(0, scrollregs[1]); + m_fg_layer->set_scrollx(0, scrollregs[2]); + m_fg_layer->set_scrolly(0, scrollregs[3]); + + bitmap.fill(get_black_pen(machine()), cliprect); + + // back layer + if (m_bg_layer_enabled) + m_bg_layer->draw(bitmap, cliprect, 0, 0); + + // draw sprites underneath foreground + draw_sprites(bitmap, cliprect, 1); + + // fore layer + if (m_fg_layer_enabled) + m_fg_layer->draw(bitmap, cliprect, 0, 0); + + // rest of sprites + draw_sprites(bitmap, cliprect, 2); + + // text layer + if (m_tx_layer_enabled) + m_tx_layer->draw(bitmap, cliprect, 0, 0); + + return 0; +} + UINT32 raiden_state::screen_update_raiden(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { - m_bg_layer->set_scrolly(0, ((m_scroll_ram[0x01]&0x30)<<4)+((m_scroll_ram[0x02]&0x7f)<<1)+((m_scroll_ram[0x02]&0x80)>>7)); - m_bg_layer->set_scrollx(0, ((m_scroll_ram[0x09]&0x30)<<4)+((m_scroll_ram[0x0a]&0x7f)<<1)+((m_scroll_ram[0x0a]&0x80)>>7)); - m_fg_layer->set_scrolly(0, ((m_scroll_ram[0x11]&0x30)<<4)+((m_scroll_ram[0x12]&0x7f)<<1)+((m_scroll_ram[0x12]&0x80)>>7)); - m_fg_layer->set_scrollx(0, ((m_scroll_ram[0x19]&0x30)<<4)+((m_scroll_ram[0x1a]&0x7f)<<1)+((m_scroll_ram[0x1a]&0x80)>>7)); - - m_bg_layer->draw(bitmap, cliprect, 0,0); - - /* Draw sprites underneath foreground */ - draw_sprites(bitmap,cliprect,0x40); - m_fg_layer->draw(bitmap, cliprect, 0,0); - - /* Rest of sprites */ - draw_sprites(bitmap,cliprect,0x80); - - /* Text layer */ - m_tx_layer->draw(bitmap, cliprect, 0,0); - return 0; + // set up scrollregs + // scroll_ram is only 8 bits wide. 4 bytes per scroll, skip uneven ones + // 00-03: 28 *0 ** ae - bg layer scroll y + // 08-0b: 28 *0 ** b9 - bg layer scroll x + // 10-13: 28 *0 ** ae - fg layer scroll y + // 18-1b: 28 *0 ** b9 - fg layer scroll x + UINT16 scrollregs[4]; + scrollregs[0] = ((m_scroll_ram[0x09] & 0xf0) << 4) | ((m_scroll_ram[0x0a] & 0x7f) << 1) | ((m_scroll_ram[0x0a] & 0x80) >> 7); + scrollregs[1] = ((m_scroll_ram[0x01] & 0xf0) << 4) | ((m_scroll_ram[0x02] & 0x7f) << 1) | ((m_scroll_ram[0x02] & 0x80) >> 7); + scrollregs[2] = ((m_scroll_ram[0x19] & 0xf0) << 4) | ((m_scroll_ram[0x1a] & 0x7f) << 1) | ((m_scroll_ram[0x1a] & 0x80) >> 7); + scrollregs[3] = ((m_scroll_ram[0x11] & 0xf0) << 4) | ((m_scroll_ram[0x12] & 0x7f) << 1) | ((m_scroll_ram[0x12] & 0x80) >> 7); + + return screen_update_common(screen, bitmap, cliprect, scrollregs); } UINT32 raiden_state::screen_update_raidenb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { - /* raidenb has different scroll positions */ - m_bg_layer->set_scrollx(0, m_scroll_ram[0]); - m_bg_layer->set_scrolly(0, m_scroll_ram[1]); - m_fg_layer->set_scrollx(0, m_scroll_ram[2]); - m_fg_layer->set_scrolly(0, m_scroll_ram[3]); - - m_bg_layer->draw(bitmap, cliprect, 0,0); - - /* Draw sprites underneath foreground */ - draw_sprites(bitmap,cliprect,0x40); - m_fg_layer->draw(bitmap, cliprect, 0,0); - - /* Rest of sprites */ - draw_sprites(bitmap,cliprect,0x80); - - /* Text layer */ - m_tx_layer->draw(bitmap, cliprect, 0,0); - return 0; + return screen_update_common(screen, bitmap, cliprect, m_scroll_ram); }