added global alpha bit

This commit is contained in:
Michaël Banaan Ananas 2014-09-03 18:30:19 +00:00
parent 8347ded8bf
commit d6935e3a35
3 changed files with 75 additions and 52 deletions

View File

@ -904,7 +904,7 @@ WRITE8_MEMBER(seibuspi_state::eeprom_w)
WRITE8_MEMBER(seibuspi_state::spi_layerbanks_eeprom_w)
{
// low bits: tile banks
spi_set_layer_banks_w(space, 0, data);
rf2_layer_bank_w(space, 0, data);
// high bits: eeprom
eeprom_w(space, 0, data);
@ -942,7 +942,7 @@ READ8_MEMBER(seibuspi_state::sb_coin_r)
READ32_MEMBER(seibuspi_state::ejsakura_keyboard_r)
{
switch(m_ejsakura_input_port)
switch (m_ejsakura_input_port)
{
case 0x01:
return ioport("INPUT01")->read();
@ -1000,7 +1000,7 @@ static ADDRESS_MAP_START( spi_map, AS_PROGRAM, 32, seibuspi_state )
AM_RANGE(0x00000684, 0x00000687) AM_READ8(sound_fifo_status_r, 0x000000ff)
AM_RANGE(0x00000688, 0x0000068b) AM_WRITE8(z80_prg_transfer_w, 0x000000ff)
AM_RANGE(0x0000068c, 0x0000068f) AM_WRITE8(z80_enable_w, 0x000000ff)
AM_RANGE(0x0000068c, 0x0000068f) AM_WRITE8(spi_set_layer_banks_w, 0x00ff0000)
AM_RANGE(0x0000068c, 0x0000068f) AM_WRITE8(rf2_layer_bank_w, 0x00ff0000)
AM_RANGE(0x000006d0, 0x000006d3) AM_DEVWRITE8("ds2404", ds2404_device, ds2404_1w_reset_w, 0x000000ff)
AM_RANGE(0x000006d4, 0x000006d7) AM_DEVWRITE8("ds2404", ds2404_device, ds2404_data_w, 0x000000ff)
AM_RANGE(0x000006d8, 0x000006db) AM_DEVWRITE8("ds2404", ds2404_device, ds2404_clk_w, 0x000000ff)
@ -1968,11 +1968,11 @@ DRIVER_INIT_MEMBER(seibuspi_state,sys386f)
UINT16 tmp[0x40 / 2], offset;
// sprite_reorder() only
for(i = 0; i < memregion("gfx3")->bytes() / 0x40; i++)
for (i = 0; i < memregion("gfx3")->bytes() / 0x40; i++)
{
memcpy(tmp, src, 0x40);
for(j = 0; j < 0x40 / 2; j++)
for (j = 0; j < 0x40 / 2; j++)
{
offset = (j >> 1) | (j << 4 & 0x10);
*src++ = tmp[offset];
@ -3758,7 +3758,7 @@ GAME( 1995, viprp1ot, viprp1, spi, spi_3button, seibuspi_state, viprp1,
GAME( 1995, viprp1oj, viprp1, spi, spi_3button, seibuspi_state, viprp1o, ROT270, "Seibu Kaihatsu", "Viper Phase 1 (Japan)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
GAME( 1995, viprp1hk, viprp1, spi, spi_3button, seibuspi_state, viprp1, ROT270, "Seibu Kaihatsu (Metrotainment license)", "Viper Phase 1 (Hong Kong)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) /* "=HONG KONG=" seems part of title */
GAME( 1996, ejanhs, 0, spi, spi_ejanhs, seibuspi_state, ejanhs, ROT0, "Seibu Kaihatsu", "E-Jan High School (Japan)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
GAME( 1996, ejanhs, 0, spi, spi_ejanhs, seibuspi_state, ejanhs, ROT0, "Seibu Kaihatsu", "E-Jan High School (Japan)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND )
GAME( 1996, rdft, 0, spi, spi_3button, seibuspi_state, rdft, ROT270, "Seibu Kaihatsu", "Raiden Fighters (Japan set 1)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
GAME( 1996, rdftj, rdft, spi, spi_3button, seibuspi_state, rdft, ROT270, "Seibu Kaihatsu", "Raiden Fighters (Japan set 2)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )

View File

@ -57,11 +57,16 @@ public:
UINT32 m_video_dma_address;
UINT32 m_layer_enable;
UINT32 m_layer_bank;
int m_rf2_layer_bank;
UINT8 m_rf2_layer_bank;
int m_alpha_enable;
int m_rowscroll_enable;
int m_midl_layer_offset;
int m_fore_layer_offset;
int m_text_layer_offset;
int m_fore_layer_d13;
int m_back_layer_d14;
int m_midl_layer_d14;
int m_fore_layer_d14;
UINT32 *m_tilemap_ram;
UINT32 *m_palette_ram;
UINT32 *m_sprite_ram;
@ -69,14 +74,14 @@ public:
UINT32 m_palette_ram_size;
UINT32 m_sprite_ram_size;
UINT32 m_bg_fore_layer_position;
UINT8 m_alpha_table[8192];
UINT8 m_alpha_table[0x2000];
int m_sprite_bpp;
DECLARE_READ32_MEMBER(spi_layer_bank_r);
DECLARE_WRITE32_MEMBER(spi_layer_bank_w);
DECLARE_READ32_MEMBER(spi_layer_enable_r);
DECLARE_WRITE32_MEMBER(spi_layer_enable_w);
DECLARE_WRITE8_MEMBER(spi_set_layer_banks_w);
DECLARE_WRITE8_MEMBER(rf2_layer_bank_w);
DECLARE_WRITE32_MEMBER(tilemap_dma_start_w);
DECLARE_WRITE32_MEMBER(palette_dma_start_w);
DECLARE_WRITE16_MEMBER(sprite_dma_start_w);

View File

@ -26,6 +26,11 @@ void seibuspi_state::set_layer_offsets()
m_midl_layer_offset = 0x2000 / 4 / 2;
m_text_layer_offset = 0x3000 / 4 / 2;
}
m_fore_layer_d13 = m_layer_bank >> 14 & 0x2000;
m_back_layer_d14 = m_rf2_layer_bank << 14 & 0x4000;
m_midl_layer_d14 = m_rf2_layer_bank << 13 & 0x4000;
m_fore_layer_d14 = m_rf2_layer_bank << 12 & 0x4000;
}
READ32_MEMBER(seibuspi_state::spi_layer_bank_r)
@ -35,36 +40,40 @@ READ32_MEMBER(seibuspi_state::spi_layer_bank_r)
WRITE32_MEMBER(seibuspi_state::spi_layer_bank_w)
{
// r000f000 0010100x 00000000 00000000
// r000f000 0010100a 00000000 00000000
// r: rowscroll enable
// f: fore layer d13
// x: ? (0 in ejanhs, 1 in all other games)
// a: global alpha blending enable (0 in ejanhs, 1 in all other games)
UINT32 prev = m_layer_bank;
COMBINE_DATA(&m_layer_bank);
if ((prev ^ m_layer_bank) & 0x80000000)
{
m_rowscroll_enable = m_layer_bank >> 31 & 1;
set_layer_offsets();
}
m_rowscroll_enable = m_layer_bank >> 31 & 1;
m_alpha_enable = m_layer_bank >> 16 & 1;
set_layer_offsets();
if ((prev ^ m_layer_bank) & 0x08000000)
m_fore_layer->mark_all_dirty();
}
WRITE8_MEMBER(seibuspi_state::spi_set_layer_banks_w)
WRITE8_MEMBER(seibuspi_state::rf2_layer_bank_w)
{
if ((m_rf2_layer_bank ^ data) & 1)
// 00000fmb
// f: fore layer d14
// m: middle layer d14
// b: back layer d14
UINT8 prev = m_rf2_layer_bank;
m_rf2_layer_bank = data;
set_layer_offsets();
if ((prev ^ m_rf2_layer_bank) & 1)
m_back_layer->mark_all_dirty();
if ((m_rf2_layer_bank ^ data) & 2)
if ((prev ^ m_rf2_layer_bank) & 2)
m_midl_layer->mark_all_dirty();
if ((m_rf2_layer_bank ^ data) & 4)
if ((prev ^ m_rf2_layer_bank) & 4)
m_fore_layer->mark_all_dirty();
m_rf2_layer_bank = data;
}
WRITE32_MEMBER(seibuspi_state::spi_layer_enable_w)
@ -313,8 +322,7 @@ void seibuspi_state::drawgfx_blend(bitmap_rgb32 &bitmap, const rectangle &clipre
if (pen != trans_pen)
{
int global_pen = pen + (color << m_sprite_bpp);
UINT8 alpha = m_alpha_table[global_pen];
if (alpha)
if (m_alpha_enable && m_alpha_table[global_pen])
{
p[i] = alpha_blend_r32(p[i], pens[global_pen], 0x7f);
}
@ -454,8 +462,7 @@ void seibuspi_state::combine_tilemap(bitmap_rgb32 &bitmap, const rectangle &clip
if (opaque || (t[i & xscroll_mask] & (TILEMAP_PIXEL_LAYER0 | TILEMAP_PIXEL_LAYER1)))
{
UINT16 pen = s[i & xscroll_mask];
UINT8 alpha = m_alpha_table[pen];
if (alpha)
if (m_alpha_enable && m_alpha_table[pen])
{
*d = alpha_blend_r32(*d, m_palette->pen(pen), 0x7f);
}
@ -555,7 +562,7 @@ TILE_GET_INFO_MEMBER(seibuspi_state::get_back_tile_info)
int color = (tile >> 13) & 0x7;
tile &= 0x1fff;
tile |= m_rf2_layer_bank << 14 & 0x4000; // (d0)
tile |= m_back_layer_d14;
SET_TILE_INFO_MEMBER(1, tile, color, 0);
}
@ -568,7 +575,7 @@ TILE_GET_INFO_MEMBER(seibuspi_state::get_midl_tile_info)
tile &= 0x1fff;
tile |= 0x2000;
tile |= m_rf2_layer_bank << 13 & 0x4000; // (d1)
tile |= m_midl_layer_d14;
SET_TILE_INFO_MEMBER(1, tile, color + 16, 0);
}
@ -581,8 +588,8 @@ TILE_GET_INFO_MEMBER(seibuspi_state::get_fore_tile_info)
tile &= 0x1fff;
tile |= m_bg_fore_layer_position;
tile |= m_layer_bank >> 14 & 0x2000; // (d27)
tile |= m_rf2_layer_bank << 12 & 0x4000; // (d2)
tile |= m_fore_layer_d13;
tile |= m_fore_layer_d14;
SET_TILE_INFO_MEMBER(1, tile, color + 8, 0);
}
@ -590,13 +597,13 @@ TILE_GET_INFO_MEMBER(seibuspi_state::get_fore_tile_info)
void seibuspi_state::video_start()
{
int i;
m_video_dma_length = 0;
m_video_dma_address = 0;
m_layer_enable = 0;
m_layer_bank = 0;
m_rf2_layer_bank = 0;
m_alpha_enable = 0;
m_rowscroll_enable = 0;
set_layer_offsets();
UINT32 region_length = memregion("gfx2")->bytes();
@ -627,26 +634,28 @@ void seibuspi_state::video_start()
m_midl_layer->set_transparent_pen(63);
m_fore_layer->set_transparent_pen(63);
memset(m_alpha_table, 0, 8192);
// alpha blending (preliminary)
memset(m_alpha_table, 0, 0x2000);
// sprites
//for (i = 1792; i < 1808; i++) { m_alpha_table[i] = 1; } // breaks rdft
for (i = 1840; i < 1856; i++) { m_alpha_table[i] = 1; }
for (i = 1920; i < 1952; i++) { m_alpha_table[i] = 1; }
//for (i = 1984; i < 2048; i++) { m_alpha_table[i] = 1; } // breaks batlball
//for (i = 3840; i < 3904; i++) { m_alpha_table[i] = 1; } // breaks rdft
for (i = 4032; i < 4096; i++) { m_alpha_table[i] = 1; }
// sprites(0000-0fff):
//memset(m_alpha_table + 0x700, 1, 0x10); // breaks rdft
memset(m_alpha_table + 0x730, 1, 0x10);
memset(m_alpha_table + 0x780, 1, 0x20);
//memset(m_alpha_table + 0x7c0, 1, 0x40); // breaks batlball
//memset(m_alpha_table + 0xf00, 1, 0x40); // breaks rdft
memset(m_alpha_table + 0xfc0, 1, 0x40);
// middle layer
for (i = 4960; i < 4992; i++) { m_alpha_table[i] = 1; } // breaks ejanhs
for (i = 5040; i < 5056; i++) { m_alpha_table[i] = 1; } // breaks ejanhs
for (i = 5104; i < 5120; i++) { m_alpha_table[i] = 1; }
// fore layer
for (i = 5552; i < 5568; i++) { m_alpha_table[i] = 1; } // breaks ejanhs
for (i = 5616; i < 5632; i++) { m_alpha_table[i] = 1; } // breaks ejanhs
// text layer
for (i = 6000; i < 6016; i++) { m_alpha_table[i] = 1; }
for (i = 6128; i < 6144; i++) { m_alpha_table[i] = 1; }
// back layer(1000-11ff): nope
// fore layer(1200-13ff):
memset(m_alpha_table + 0x1200 + 0x160, 1, 0x20);
memset(m_alpha_table + 0x1200 + 0x1b0, 1, 0x10);
memset(m_alpha_table + 0x1200 + 0x1f0, 1, 0x10);
// midl layer(1400-15ff)
memset(m_alpha_table + 0x1400 + 0x1b0, 1, 0x10);
memset(m_alpha_table + 0x1400 + 0x1f0, 1, 0x10);
// text layer(1600-17ff)
memset(m_alpha_table + 0x1600 + 0x170, 1, 0x10);
memset(m_alpha_table + 0x1600 + 0x1f0, 1, 0x10);
register_video_state();
}
@ -658,7 +667,10 @@ VIDEO_START_MEMBER(seibuspi_state,sys386f)
m_layer_enable = 0;
m_layer_bank = 0;
m_rf2_layer_bank = 0;
m_alpha_enable = 0;
m_rowscroll_enable = 0;
set_layer_offsets();
m_tilemap_ram_size = 0;
m_palette_ram_size = 0x4000;
m_sprite_ram_size = 0x2000;
@ -668,7 +680,7 @@ VIDEO_START_MEMBER(seibuspi_state,sys386f)
m_palette_ram = auto_alloc_array_clear(machine(), UINT32, m_palette_ram_size/4);
m_sprite_ram = auto_alloc_array_clear(machine(), UINT32, m_sprite_ram_size/4);
memset(m_alpha_table, 0, 8192);
memset(m_alpha_table, 0, 0x2000);
register_video_state();
}
@ -680,10 +692,16 @@ void seibuspi_state::register_video_state()
save_item(NAME(m_layer_enable));
save_item(NAME(m_layer_bank));
save_item(NAME(m_rf2_layer_bank));
save_item(NAME(m_alpha_enable));
save_item(NAME(m_rowscroll_enable));
save_item(NAME(m_midl_layer_offset));
save_item(NAME(m_fore_layer_offset));
save_item(NAME(m_text_layer_offset));
save_item(NAME(m_fore_layer_d13));
save_item(NAME(m_back_layer_d14));
save_item(NAME(m_midl_layer_d14));
save_item(NAME(m_fore_layer_d14));
if (m_tilemap_ram != NULL) save_pointer(NAME(m_tilemap_ram), m_tilemap_ram_size/4);
save_pointer(NAME(m_palette_ram), m_palette_ram_size/4);