toaplan1.c: fix and cleanup palette handling [Alex Jackson]

This commit is contained in:
Alex W. Jackson 2014-02-28 19:40:37 +00:00
parent ea8043c2d6
commit 790e204ee0
3 changed files with 30 additions and 51 deletions

View File

@ -656,8 +656,8 @@ static ADDRESS_MAP_START( rallybik_main_map, AS_PROGRAM, 16, toaplan1_rallybik_s
// AM_RANGE(0x140000, 0x140001) AM_WRITE(?? video frame related ??)
AM_RANGE(0x140002, 0x140003) AM_WRITE(toaplan1_intenable_w)
AM_RANGE(0x140008, 0x14000f) AM_WRITE(toaplan1_bcu_control_w)
AM_RANGE(0x144000, 0x1447ff) AM_READWRITE(toaplan1_colorram1_r, toaplan1_colorram1_w) AM_SHARE("colorram1")
AM_RANGE(0x146000, 0x1467ff) AM_READWRITE(toaplan1_colorram2_r, toaplan1_colorram2_w) AM_SHARE("colorram2")
AM_RANGE(0x144000, 0x1447ff) AM_RAM_WRITE(toaplan1_bgpalette_w) AM_SHARE("bgpalette")
AM_RANGE(0x146000, 0x1467ff) AM_RAM_WRITE(toaplan1_fgpalette_w) AM_SHARE("fgpalette")
AM_RANGE(0x180000, 0x180fff) AM_READWRITE(toaplan1_shared_r, toaplan1_shared_w)
AM_RANGE(0x1c0000, 0x1c0003) AM_WRITE(toaplan1_tile_offsets_w)
AM_RANGE(0x1c8000, 0x1c8001) AM_WRITE(toaplan1_reset_sound_w)
@ -678,8 +678,8 @@ static ADDRESS_MAP_START( truxton_main_map, AS_PROGRAM, 16, toaplan1_state )
// AM_RANGE(0x140000, 0x140001) AM_WRITE(?? video frame related ??)
AM_RANGE(0x140002, 0x140003) AM_WRITE(toaplan1_intenable_w)
AM_RANGE(0x140008, 0x14000f) AM_WRITE(toaplan1_bcu_control_w)
AM_RANGE(0x144000, 0x1447ff) AM_READWRITE(toaplan1_colorram1_r, toaplan1_colorram1_w) AM_SHARE("colorram1")
AM_RANGE(0x146000, 0x1467ff) AM_READWRITE(toaplan1_colorram2_r, toaplan1_colorram2_w) AM_SHARE("colorram2")
AM_RANGE(0x144000, 0x1447ff) AM_RAM_WRITE(toaplan1_bgpalette_w) AM_SHARE("bgpalette")
AM_RANGE(0x146000, 0x1467ff) AM_RAM_WRITE(toaplan1_fgpalette_w) AM_SHARE("fgpalette")
AM_RANGE(0x180000, 0x180fff) AM_READWRITE(toaplan1_shared_r, toaplan1_shared_w)
AM_RANGE(0x1c0000, 0x1c0003) AM_WRITE(toaplan1_tile_offsets_w)
AM_RANGE(0x1c0006, 0x1c0007) AM_WRITE(toaplan1_fcu_flipscreen_w)
@ -693,8 +693,8 @@ static ADDRESS_MAP_START( hellfire_main_map, AS_PROGRAM, 16, toaplan1_state )
// AM_RANGE(0x080000, 0x080001) AM_WRITE(?? video frame related ??)
AM_RANGE(0x080002, 0x080003) AM_WRITE(toaplan1_intenable_w)
AM_RANGE(0x080008, 0x08000f) AM_WRITE(toaplan1_bcu_control_w)
AM_RANGE(0x084000, 0x0847ff) AM_READWRITE(toaplan1_colorram1_r, toaplan1_colorram1_w) AM_SHARE("colorram1")
AM_RANGE(0x086000, 0x0867ff) AM_READWRITE(toaplan1_colorram2_r, toaplan1_colorram2_w) AM_SHARE("colorram2")
AM_RANGE(0x084000, 0x0847ff) AM_RAM_WRITE(toaplan1_bgpalette_w) AM_SHARE("bgpalette")
AM_RANGE(0x086000, 0x0867ff) AM_RAM_WRITE(toaplan1_fgpalette_w) AM_SHARE("fgpalette")
AM_RANGE(0x0c0000, 0x0c0fff) AM_READWRITE(toaplan1_shared_r, toaplan1_shared_w)
AM_RANGE(0x100000, 0x100001) AM_WRITE(toaplan1_bcu_flipscreen_w)
AM_RANGE(0x100002, 0x100003) AM_READWRITE(toaplan1_tileram_offs_r, toaplan1_tileram_offs_w)
@ -719,8 +719,8 @@ static ADDRESS_MAP_START( zerowing_main_map, AS_PROGRAM, 16, toaplan1_state )
// AM_RANGE(0x400000, 0x400001) AM_WRITE(?? video frame related ??)
AM_RANGE(0x400002, 0x400003) AM_WRITE(toaplan1_intenable_w)
AM_RANGE(0x400008, 0x40000f) AM_WRITE(toaplan1_bcu_control_w)
AM_RANGE(0x404000, 0x4047ff) AM_READWRITE(toaplan1_colorram1_r, toaplan1_colorram1_w) AM_SHARE("colorram1")
AM_RANGE(0x406000, 0x4067ff) AM_READWRITE(toaplan1_colorram2_r, toaplan1_colorram2_w) AM_SHARE("colorram2")
AM_RANGE(0x404000, 0x4047ff) AM_RAM_WRITE(toaplan1_bgpalette_w) AM_SHARE("bgpalette")
AM_RANGE(0x406000, 0x4067ff) AM_RAM_WRITE(toaplan1_fgpalette_w) AM_SHARE("fgpalette")
AM_RANGE(0x440000, 0x440fff) AM_READWRITE(toaplan1_shared_r, toaplan1_shared_w)
AM_RANGE(0x480000, 0x480001) AM_WRITE(toaplan1_bcu_flipscreen_w)
AM_RANGE(0x480002, 0x480003) AM_READWRITE(toaplan1_tileram_offs_r, toaplan1_tileram_offs_w)
@ -738,8 +738,8 @@ static ADDRESS_MAP_START( demonwld_main_map, AS_PROGRAM, 16, toaplan1_state )
// AM_RANGE(0x400000, 0x400001) AM_WRITE(?? video frame related ??)
AM_RANGE(0x400002, 0x400003) AM_WRITE(toaplan1_intenable_w)
AM_RANGE(0x400008, 0x40000f) AM_WRITE(toaplan1_bcu_control_w)
AM_RANGE(0x404000, 0x4047ff) AM_READWRITE(toaplan1_colorram1_r, toaplan1_colorram1_w) AM_SHARE("colorram1")
AM_RANGE(0x406000, 0x4067ff) AM_READWRITE(toaplan1_colorram2_r, toaplan1_colorram2_w) AM_SHARE("colorram2")
AM_RANGE(0x404000, 0x4047ff) AM_RAM_WRITE(toaplan1_bgpalette_w) AM_SHARE("bgpalette")
AM_RANGE(0x406000, 0x4067ff) AM_RAM_WRITE(toaplan1_fgpalette_w) AM_SHARE("fgpalette")
AM_RANGE(0x600000, 0x600fff) AM_READWRITE(toaplan1_shared_r, toaplan1_shared_w)
AM_RANGE(0x800000, 0x800001) AM_WRITE(toaplan1_bcu_flipscreen_w)
AM_RANGE(0x800002, 0x800003) AM_READWRITE(toaplan1_tileram_offs_r, toaplan1_tileram_offs_w)
@ -766,8 +766,8 @@ static ADDRESS_MAP_START( samesame_main_map, AS_PROGRAM, 16, toaplan1_state )
// AM_RANGE(0x100000, 0x100001) AM_WRITE(?? video frame related ??)
AM_RANGE(0x100002, 0x100003) AM_WRITE(toaplan1_intenable_w)
AM_RANGE(0x100008, 0x10000f) AM_WRITE(toaplan1_bcu_control_w)
AM_RANGE(0x104000, 0x1047ff) AM_READWRITE(toaplan1_colorram1_r, toaplan1_colorram1_w) AM_SHARE("colorram1")
AM_RANGE(0x106000, 0x1067ff) AM_READWRITE(toaplan1_colorram2_r, toaplan1_colorram2_w) AM_SHARE("colorram2")
AM_RANGE(0x104000, 0x1047ff) AM_RAM_WRITE(toaplan1_bgpalette_w) AM_SHARE("bgpalette")
AM_RANGE(0x106000, 0x1067ff) AM_RAM_WRITE(toaplan1_fgpalette_w) AM_SHARE("fgpalette")
AM_RANGE(0x140000, 0x140001) AM_READ_PORT("P1")
AM_RANGE(0x140002, 0x140003) AM_READ_PORT("P2")
AM_RANGE(0x140004, 0x140005) AM_READ_PORT("DSWA")
@ -803,8 +803,8 @@ static ADDRESS_MAP_START( outzone_main_map, AS_PROGRAM, 16, toaplan1_state )
// AM_RANGE(0x300000, 0x300001) AM_WRITE(?? video frame related ??)
AM_RANGE(0x300002, 0x300003) AM_WRITE(toaplan1_intenable_w)
AM_RANGE(0x300008, 0x30000f) AM_WRITE(toaplan1_bcu_control_w)
AM_RANGE(0x304000, 0x3047ff) AM_READWRITE(toaplan1_colorram1_r, toaplan1_colorram1_w) AM_SHARE("colorram1")
AM_RANGE(0x306000, 0x3067ff) AM_READWRITE(toaplan1_colorram2_r, toaplan1_colorram2_w) AM_SHARE("colorram2")
AM_RANGE(0x304000, 0x3047ff) AM_RAM_WRITE(toaplan1_bgpalette_w) AM_SHARE("bgpalette")
AM_RANGE(0x306000, 0x3067ff) AM_RAM_WRITE(toaplan1_fgpalette_w) AM_SHARE("fgpalette")
AM_RANGE(0x340000, 0x340003) AM_WRITE(toaplan1_tile_offsets_w)
AM_RANGE(0x340006, 0x340007) AM_WRITE(toaplan1_fcu_flipscreen_w)
ADDRESS_MAP_END
@ -821,8 +821,8 @@ static ADDRESS_MAP_START( vimana_main_map, AS_PROGRAM, 16, toaplan1_state )
// AM_RANGE(0x400000, 0x400001) AM_WRITE(?? video frame related ??)
AM_RANGE(0x400002, 0x400003) AM_WRITE(toaplan1_intenable_w)
AM_RANGE(0x400008, 0x40000f) AM_WRITE(toaplan1_bcu_control_w)
AM_RANGE(0x404000, 0x4047ff) AM_READWRITE(toaplan1_colorram1_r, toaplan1_colorram1_w) AM_SHARE("colorram1")
AM_RANGE(0x406000, 0x4067ff) AM_READWRITE(toaplan1_colorram2_r, toaplan1_colorram2_w) AM_SHARE("colorram2")
AM_RANGE(0x404000, 0x4047ff) AM_RAM_WRITE(toaplan1_bgpalette_w) AM_SHARE("bgpalette")
AM_RANGE(0x406000, 0x4067ff) AM_RAM_WRITE(toaplan1_fgpalette_w) AM_SHARE("fgpalette")
AM_RANGE(0x440000, 0x440005) AM_READWRITE(vimana_mcu_r, vimana_mcu_w) /* shared memory from 0x440000 to 0x44ffff ? */
AM_RANGE(0x440006, 0x440007) AM_READ_PORT("DSWA")
AM_RANGE(0x440008, 0x440009) AM_READ(vimana_system_port_r) /* "SYSTEM" + coinage simulation */

View File

@ -11,8 +11,8 @@ class toaplan1_state : public driver_device
public:
toaplan1_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_colorram1(*this, "colorram1"),
m_colorram2(*this, "colorram2"),
m_bgpaletteram(*this, "bgpalette"),
m_fgpaletteram(*this, "fgpalette"),
m_sharedram(*this, "sharedram"),
m_spriteram(*this, "spriteram"),
m_maincpu(*this, "maincpu"),
@ -20,8 +20,8 @@ public:
m_dsp(*this, "dsp"),
m_gfxdecode(*this, "gfxdecode") { }
required_shared_ptr<UINT16> m_colorram1;
required_shared_ptr<UINT16> m_colorram2;
required_shared_ptr<UINT16> m_bgpaletteram;
required_shared_ptr<UINT16> m_fgpaletteram;
optional_shared_ptr<UINT8> m_sharedram;
@ -103,10 +103,8 @@ public:
DECLARE_WRITE16_MEMBER(toaplan1_fcu_flipscreen_w);
DECLARE_READ16_MEMBER(toaplan1_spriteram_offs_r);
DECLARE_WRITE16_MEMBER(toaplan1_spriteram_offs_w);
DECLARE_READ16_MEMBER(toaplan1_colorram1_r);
DECLARE_WRITE16_MEMBER(toaplan1_colorram1_w);
DECLARE_READ16_MEMBER(toaplan1_colorram2_r);
DECLARE_WRITE16_MEMBER(toaplan1_colorram2_w);
DECLARE_WRITE16_MEMBER(toaplan1_bgpalette_w);
DECLARE_WRITE16_MEMBER(toaplan1_fgpalette_w);
DECLARE_READ16_MEMBER(toaplan1_spriteram16_r);
DECLARE_WRITE16_MEMBER(toaplan1_spriteram16_w);
DECLARE_READ16_MEMBER(toaplan1_spritesizeram16_r);
@ -139,7 +137,6 @@ public:
void demonwld_restore_dsp();
void toaplan1_create_tilemaps();
void toaplan1_paletteram_alloc();
void toaplan1_vram_alloc();
void toaplan1_spritevram_alloc();
void toaplan1_set_scrolls();

View File

@ -222,13 +222,6 @@ void toaplan1_state::toaplan1_create_tilemaps()
m_pf4_tilemap->set_transparent_pen(0);
}
void toaplan1_state::toaplan1_paletteram_alloc()
{
UINT32 bytes = (m_colorram1.bytes() + m_colorram2.bytes())/2;
m_generic_paletteram_16.allocate(bytes);
}
void toaplan1_state::toaplan1_vram_alloc()
{
m_pf1_tilevram16 = auto_alloc_array_clear(machine(), UINT16, TOAPLAN1_TILEVRAM_SIZE/2);
@ -301,7 +294,6 @@ VIDEO_START_MEMBER(toaplan1_rallybik_state,rallybik)
m_spritegen->set_gfx_region(1);
toaplan1_create_tilemaps();
toaplan1_paletteram_alloc();
toaplan1_vram_alloc();
m_buffered_spriteram = auto_alloc_array_clear(machine(), UINT16, m_spriteram.bytes()/2);
@ -325,7 +317,6 @@ VIDEO_START_MEMBER(toaplan1_rallybik_state,rallybik)
VIDEO_START_MEMBER(toaplan1_state,toaplan1)
{
toaplan1_create_tilemaps();
toaplan1_paletteram_alloc();
toaplan1_vram_alloc();
toaplan1_spritevram_alloc();
@ -403,29 +394,20 @@ WRITE16_MEMBER(toaplan1_state::toaplan1_spriteram_offs_w)
}
/* tile palette */
READ16_MEMBER(toaplan1_state::toaplan1_colorram1_r)
WRITE16_MEMBER(toaplan1_state::toaplan1_bgpalette_w)
{
return m_colorram1[offset];
COMBINE_DATA(&m_bgpaletteram[offset]);
data = m_bgpaletteram[offset];
m_palette->set_pen_color(offset, pal5bit(data>>0), pal5bit(data>>5), pal5bit(data>>10));
}
WRITE16_MEMBER(toaplan1_state::toaplan1_colorram1_w)
WRITE16_MEMBER(toaplan1_state::toaplan1_fgpalette_w)
{
COMBINE_DATA(&m_colorram1[offset]);
m_palette->write(space, offset, data, mem_mask);
COMBINE_DATA(&m_fgpaletteram[offset]);
data = m_fgpaletteram[offset];
m_palette->set_pen_color(offset + 64*16, pal5bit(data>>0), pal5bit(data>>5), pal5bit(data>>10));
}
/* sprite palette */
READ16_MEMBER(toaplan1_state::toaplan1_colorram2_r)
{
return m_colorram2[offset];
}
WRITE16_MEMBER(toaplan1_state::toaplan1_colorram2_w)
{
COMBINE_DATA(&m_colorram2[offset]);
m_palette->write(space, offset+(m_colorram1.bytes()/2), data, mem_mask);
}
READ16_MEMBER(toaplan1_state::toaplan1_spriteram16_r)
{