namcofl.cpp: killed anonymous timers, moved to configured banking, added save state support. Also moved some remaining functions inside the class (nw)

This commit is contained in:
Ivan Vangelista 2017-04-12 18:46:31 +02:00
parent f7af97c497
commit 89b5f23499
10 changed files with 156 additions and 164 deletions

View File

@ -2112,6 +2112,7 @@ void i960_cpu_device::device_start()
save_item(NAME(m_immediate_irq));
save_item(NAME(m_immediate_vector));
save_item(NAME(m_immediate_pri));
save_item(NAME(m_bursting));
state_add( I960_SAT, "sat", m_SAT).formatstr("%08X");
state_add( I960_PRCB, "prcb", m_PRCB).formatstr("%08X");

View File

@ -191,13 +191,13 @@ WRITE32_MEMBER(namcofl_state::namcofl_sysreg_w)
{
if (data == 0) // RAM at 00000000, ROM at 10000000
{
membank("bank1")->set_base(m_workram.get());
membank("bank2")->set_base(memregion("maincpu")->base() );
membank("bank1")->set_entry(1);
membank("bank2")->set_entry(1);
}
else // ROM at 00000000, RAM at 10000000
{
membank("bank1")->set_base(memregion("maincpu")->base() );
membank("bank2")->set_base(m_workram.get());
membank("bank1")->set_entry(0);
membank("bank2")->set_entry(0);
}
}
}
@ -214,26 +214,13 @@ WRITE8_MEMBER(namcofl_state::namcofl_c116_w)
}
}
READ32_MEMBER(namcofl_state::namcofl_share_r)
{
return (m_shareram[offset*2+1] << 16) | m_shareram[offset*2];
}
WRITE32_MEMBER(namcofl_state::namcofl_share_w)
{
COMBINE_DATA(m_shareram+offset*2);
data >>= 16;
mem_mask >>= 16;
COMBINE_DATA(m_shareram+offset*2+1);
}
static ADDRESS_MAP_START( namcofl_mem, AS_PROGRAM, 32, namcofl_state )
AM_RANGE(0x00000000, 0x000fffff) AM_RAMBANK("bank1")
AM_RANGE(0x10000000, 0x100fffff) AM_RAMBANK("bank2")
AM_RANGE(0x20000000, 0x201fffff) AM_ROM AM_REGION("data", 0)
AM_RANGE(0x30000000, 0x30001fff) AM_RAM AM_SHARE("nvram") /* nvram */
AM_RANGE(0x30100000, 0x30100003) AM_WRITE(namcofl_spritebank_w)
AM_RANGE(0x30284000, 0x3028bfff) AM_READWRITE(namcofl_share_r, namcofl_share_w)
AM_RANGE(0x30284000, 0x3028bfff) AM_RAM AM_SHARE("shareram")
AM_RANGE(0x30300000, 0x30303fff) AM_RAM /* COMRAM */
AM_RANGE(0x30380000, 0x303800ff) AM_READ(fl_network_r ) /* network registers */
AM_RANGE(0x30400000, 0x30407fff) AM_DEVREAD8("c116", namco_c116_device,read,0xffffffff) AM_WRITE8(namcofl_c116_w,0xffffffff)
@ -528,14 +515,14 @@ GFXDECODE_END
TIMER_CALLBACK_MEMBER(namcofl_state::network_interrupt_callback)
{
m_maincpu->set_input_line(I960_IRQ0, ASSERT_LINE);
machine().scheduler().timer_set(m_screen->frame_period(), timer_expired_delegate(FUNC(namcofl_state::network_interrupt_callback),this));
m_network_interrupt_timer->adjust(m_screen->frame_period());
}
TIMER_CALLBACK_MEMBER(namcofl_state::vblank_interrupt_callback)
{
m_maincpu->set_input_line(I960_IRQ2, ASSERT_LINE);
machine().scheduler().timer_set(m_screen->frame_period(), timer_expired_delegate(FUNC(namcofl_state::vblank_interrupt_callback),this));
m_vblank_interrupt_timer->adjust(m_screen->frame_period());
}
@ -565,18 +552,28 @@ TIMER_DEVICE_CALLBACK_MEMBER(namcofl_state::mcu_adc_cb)
MACHINE_START_MEMBER(namcofl_state,namcofl)
{
m_raster_interrupt_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(namcofl_state::raster_interrupt_callback),this));
m_network_interrupt_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(namcofl_state::network_interrupt_callback),this));
m_vblank_interrupt_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(namcofl_state::vblank_interrupt_callback),this));
membank("bank1")->configure_entry(0, memregion("maincpu")->base());
membank("bank1")->configure_entry(1, m_workram.get());
membank("bank1")->set_entry(0);
membank("bank2")->configure_entry(0, m_workram.get());
membank("bank2")->configure_entry(1, memregion("maincpu")->base());
membank("bank2")->set_entry(0);
}
MACHINE_RESET_MEMBER(namcofl_state,namcofl)
{
machine().scheduler().timer_set(m_screen->time_until_pos(m_screen->visible_area().max_y + 3), timer_expired_delegate(FUNC(namcofl_state::network_interrupt_callback),this));
machine().scheduler().timer_set(m_screen->time_until_pos(m_screen->visible_area().max_y + 1), timer_expired_delegate(FUNC(namcofl_state::vblank_interrupt_callback),this));
membank("bank1")->set_base(memregion("maincpu")->base() );
membank("bank2")->set_base(m_workram.get() );
m_network_interrupt_timer->adjust(m_screen->time_until_pos(m_screen->visible_area().max_y + 3));
m_vblank_interrupt_timer->adjust(m_screen->time_until_pos(m_screen->visible_area().max_y + 1));
memset(m_workram.get(), 0x00, 0x100000);
membank("bank1")->set_entry(0);
membank("bank2")->set_entry(0);
}
@ -794,9 +791,10 @@ ROM_END
void namcofl_state::common_init()
{
m_workram = std::make_unique<uint32_t[]>(0x100000/4);
save_pointer(NAME(m_workram.get()), 0x100000/4),
membank("bank1")->set_base(memregion("maincpu")->base() );
membank("bank2")->set_base(m_workram.get());
save_item(NAME(m_mcu_port6));
save_item(NAME(m_sprbank));
}
DRIVER_INIT_MEMBER(namcofl_state,speedrcr)
@ -811,7 +809,7 @@ DRIVER_INIT_MEMBER(namcofl_state,finalapr)
m_gametype = NAMCOFL_FINAL_LAP_R;
}
GAME ( 1995, speedrcr, 0, namcofl, speedrcr, namcofl_state, speedrcr, ROT0, "Namco", "Speed Racer", MACHINE_IMPERFECT_GRAPHICS )
GAMEL( 1995, finalapr, 0, namcofl, finalapr, namcofl_state, finalapr, ROT0, "Namco", "Final Lap R (Rev. B)", 0, layout_namcofl )
GAMEL( 1995, finalapro, finalapr, namcofl, finalapr, namcofl_state, finalapr, ROT0, "Namco", "Final Lap R", 0, layout_namcofl )
GAMEL( 1995, finalaprj, finalapr, namcofl, finalapr, namcofl_state, finalapr, ROT0, "Namco", "Final Lap R (Japan Rev. C)", 0, layout_namcofl )
GAME ( 1995, speedrcr, 0, namcofl, speedrcr, namcofl_state, speedrcr, ROT0, "Namco", "Speed Racer", MACHINE_IMPERFECT_GRAPHICS | MACHINE_SUPPORTS_SAVE )
GAMEL( 1995, finalapr, 0, namcofl, finalapr, namcofl_state, finalapr, ROT0, "Namco", "Final Lap R (Rev. B)", MACHINE_SUPPORTS_SAVE, layout_namcofl )
GAMEL( 1995, finalapro, finalapr, namcofl, finalapr, namcofl_state, finalapr, ROT0, "Namco", "Final Lap R", MACHINE_SUPPORTS_SAVE, layout_namcofl )
GAMEL( 1995, finalaprj, finalapr, namcofl, finalapr, namcofl_state, finalapr, ROT0, "Namco", "Final Lap R (Japan Rev. C)", MACHINE_SUPPORTS_SAVE, layout_namcofl )

View File

@ -33,7 +33,7 @@ public:
m_accel(*this, "ACCEL"),
m_brake(*this, "BRAKE"),
m_wheel(*this, "WHEEL"),
m_shareram(*this, "shareram") { }
m_shareram(*this, "shareram", 32) { }
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_mcu;
@ -46,6 +46,8 @@ public:
optional_ioport m_brake;
optional_ioport m_wheel;
emu_timer *m_raster_interrupt_timer;
emu_timer *m_vblank_interrupt_timer;
emu_timer *m_network_interrupt_timer;
std::unique_ptr<uint32_t[]> m_workram;
required_shared_ptr<uint16_t> m_shareram;
uint8_t m_mcu_port6;
@ -56,8 +58,6 @@ public:
DECLARE_READ32_MEMBER(namcofl_sysreg_r);
DECLARE_WRITE32_MEMBER(namcofl_sysreg_w);
DECLARE_WRITE8_MEMBER(namcofl_c116_w);
DECLARE_READ32_MEMBER(namcofl_share_r);
DECLARE_WRITE32_MEMBER(namcofl_share_w);
DECLARE_WRITE16_MEMBER(mcu_shared_w);
DECLARE_READ8_MEMBER(port6_r);
DECLARE_WRITE8_MEMBER(port6_w);
@ -84,4 +84,6 @@ public:
TIMER_DEVICE_CALLBACK_MEMBER(mcu_irq2_cb);
TIMER_DEVICE_CALLBACK_MEMBER(mcu_adc_cb);
void common_init();
int FLobjcode2tile(int code);
void TilemapCB(uint16_t code, int *tile, int *mask);
};

View File

@ -97,10 +97,6 @@ C102 - Controls CPU access to ROZ Memory Area.
/*----------- defined in drivers/namcoic.c -----------*/
void namco_tilemap_draw( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri );
void namco_tilemap_invalidate( void );
/***********************************************************************************/

View File

@ -119,4 +119,6 @@ public:
int NB1objcode2tile(int code);
int NB2objcode2tile(int code);
void NB1TilemapCB(uint16_t code, int *tile, int *mask);
void NB2TilemapCB(uint16_t code, int *tile, int *mask);
};

View File

@ -94,7 +94,6 @@ enum
NAMCOFL_FINAL_LAP_R
};
// fix me -- most of this should be devices eventually
class namcos2_shared_state : public driver_device
{
@ -158,7 +157,36 @@ public:
TILE_GET_INFO_MEMBER( get_tile_info3 );
TILE_GET_INFO_MEMBER( get_tile_info4 );
TILE_GET_INFO_MEMBER( get_tile_info5 );
void namco_tilemap_init(int gfxbank, void *pMaskROM, void (*cb)( running_machine &machine, uint16_t code, int *gfx, int *mask) );
typedef delegate<void (uint16_t, int*, int*)> c123_tilemap_delegate;
void c123_tilemap_init(int gfxbank, void *pMaskROM, c123_tilemap_delegate tilemap_cb);
void c123_tilemap_invalidate(void);
void c123_tilemap_draw(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri);
void c123_SetTilemapVideoram(int offset, uint16_t newword);
void c123_SetTilemapControl(int offset, uint16_t newword);
struct c123_mTilemapInfo
{
uint16_t control[0x40/2];
/**
* [0x1] 0x02/2 tilemap#0.scrollx
* [0x3] 0x06/2 tilemap#0.scrolly
* [0x5] 0x0a/2 tilemap#1.scrollx
* [0x7] 0x0e/2 tilemap#1.scrolly
* [0x9] 0x12/2 tilemap#2.scrollx
* [0xb] 0x16/2 tilemap#2.scrolly
* [0xd] 0x1a/2 tilemap#3.scrollx
* [0xf] 0x1e/2 tilemap#3.scrolly
* 0x20/2 priority
* 0x30/2 color
*/
tilemap_t *tmap[6];
std::unique_ptr<uint16_t[]> videoram;
int gfxbank;
uint8_t *maskBaseAddr;
c123_tilemap_delegate cb;
};
c123_mTilemapInfo m_c123_TilemapInfo;
// C169 ROZ Layer Emulation
public:
@ -357,6 +385,7 @@ public:
void GollyGhostUpdateLED_c8( int data );
void GollyGhostUpdateLED_ca( int data );
void GollyGhostUpdateDiorama_c0( int data );
void TilemapCB(uint16_t code, int *tile, int *mask);
};

View File

@ -6,136 +6,108 @@
/**************************************************************************************/
static struct
{
uint16_t control[0x40/2];
/**
* [0x1] 0x02/2 tilemap#0.scrollx
* [0x3] 0x06/2 tilemap#0.scrolly
* [0x5] 0x0a/2 tilemap#1.scrollx
* [0x7] 0x0e/2 tilemap#1.scrolly
* [0x9] 0x12/2 tilemap#2.scrollx
* [0xb] 0x16/2 tilemap#2.scrolly
* [0xd] 0x1a/2 tilemap#3.scrollx
* [0xf] 0x1e/2 tilemap#3.scrolly
* 0x20/2 priority
* 0x30/2 color
*/
tilemap_t *tmap[6];
std::unique_ptr<uint16_t[]> videoram;
int gfxbank;
uint8_t *maskBaseAddr;
void (*cb)( running_machine &machine, uint16_t code, int *gfx, int *mask);
} mTilemapInfo;
void namco_tilemap_invalidate( void )
void namcos2_shared_state::c123_tilemap_invalidate(void)
{
int i;
for( i=0; i<6; i++ )
for( int i = 0; i < 6; i++ )
{
mTilemapInfo.tmap[i]->mark_all_dirty();
m_c123_TilemapInfo.tmap[i]->mark_all_dirty();
}
} /* namco_tilemap_invalidate */
inline void namcos2_shared_state::namcoic_get_tile_info(tile_data &tileinfo,int tile_index,uint16_t *vram)
{
int tile, mask;
mTilemapInfo.cb( machine(), vram[tile_index], &tile, &mask );
tileinfo.mask_data = mTilemapInfo.maskBaseAddr+mask*8;
SET_TILE_INFO_MEMBER(mTilemapInfo.gfxbank,tile,0,0);
m_c123_TilemapInfo.cb( vram[tile_index], &tile, &mask );
tileinfo.mask_data = m_c123_TilemapInfo.maskBaseAddr+mask*8;
SET_TILE_INFO_MEMBER(m_c123_TilemapInfo.gfxbank,tile,0,0);
} /* get_tile_info */
TILE_GET_INFO_MEMBER( namcos2_shared_state::get_tile_info0 ) { namcoic_get_tile_info(tileinfo,tile_index,&mTilemapInfo.videoram[0x0000]); }
TILE_GET_INFO_MEMBER( namcos2_shared_state::get_tile_info1 ) { namcoic_get_tile_info(tileinfo,tile_index,&mTilemapInfo.videoram[0x1000]); }
TILE_GET_INFO_MEMBER( namcos2_shared_state::get_tile_info2 ) { namcoic_get_tile_info(tileinfo,tile_index,&mTilemapInfo.videoram[0x2000]); }
TILE_GET_INFO_MEMBER( namcos2_shared_state::get_tile_info3 ) { namcoic_get_tile_info(tileinfo,tile_index,&mTilemapInfo.videoram[0x3000]); }
TILE_GET_INFO_MEMBER( namcos2_shared_state::get_tile_info4 ) { namcoic_get_tile_info(tileinfo,tile_index,&mTilemapInfo.videoram[0x4008]); }
TILE_GET_INFO_MEMBER( namcos2_shared_state::get_tile_info5 ) { namcoic_get_tile_info(tileinfo,tile_index,&mTilemapInfo.videoram[0x4408]); }
TILE_GET_INFO_MEMBER( namcos2_shared_state::get_tile_info0 ) { namcoic_get_tile_info(tileinfo,tile_index,&m_c123_TilemapInfo.videoram[0x0000]); }
TILE_GET_INFO_MEMBER( namcos2_shared_state::get_tile_info1 ) { namcoic_get_tile_info(tileinfo,tile_index,&m_c123_TilemapInfo.videoram[0x1000]); }
TILE_GET_INFO_MEMBER( namcos2_shared_state::get_tile_info2 ) { namcoic_get_tile_info(tileinfo,tile_index,&m_c123_TilemapInfo.videoram[0x2000]); }
TILE_GET_INFO_MEMBER( namcos2_shared_state::get_tile_info3 ) { namcoic_get_tile_info(tileinfo,tile_index,&m_c123_TilemapInfo.videoram[0x3000]); }
TILE_GET_INFO_MEMBER( namcos2_shared_state::get_tile_info4 ) { namcoic_get_tile_info(tileinfo,tile_index,&m_c123_TilemapInfo.videoram[0x4008]); }
TILE_GET_INFO_MEMBER( namcos2_shared_state::get_tile_info5 ) { namcoic_get_tile_info(tileinfo,tile_index,&m_c123_TilemapInfo.videoram[0x4408]); }
void namcos2_shared_state::namco_tilemap_init( int gfxbank, void *maskBaseAddr,
void (*cb)( running_machine &machine, uint16_t code, int *gfx, int *mask) )
void namcos2_shared_state::c123_tilemap_init( int gfxbank, void *maskBaseAddr, c123_tilemap_delegate tilemap_cb )
{
int i;
mTilemapInfo.gfxbank = gfxbank;
mTilemapInfo.maskBaseAddr = (uint8_t *)maskBaseAddr;
mTilemapInfo.cb = cb;
mTilemapInfo.videoram = std::make_unique<uint16_t[]>( 0x10000 );
m_c123_TilemapInfo.gfxbank = gfxbank;
m_c123_TilemapInfo.maskBaseAddr = (uint8_t *)maskBaseAddr;
m_c123_TilemapInfo.cb = tilemap_cb;
m_c123_TilemapInfo.videoram = std::make_unique<uint16_t[]>( 0x10000 );
/* four scrolling tilemaps */
mTilemapInfo.tmap[0] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(namcos2_shared_state::get_tile_info0),this),TILEMAP_SCAN_ROWS,8,8,64,64);
mTilemapInfo.tmap[1] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(namcos2_shared_state::get_tile_info1),this),TILEMAP_SCAN_ROWS,8,8,64,64);
mTilemapInfo.tmap[2] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(namcos2_shared_state::get_tile_info2),this),TILEMAP_SCAN_ROWS,8,8,64,64);
mTilemapInfo.tmap[3] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(namcos2_shared_state::get_tile_info3),this),TILEMAP_SCAN_ROWS,8,8,64,64);
m_c123_TilemapInfo.tmap[0] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(namcos2_shared_state::get_tile_info0),this),TILEMAP_SCAN_ROWS,8,8,64,64);
m_c123_TilemapInfo.tmap[1] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(namcos2_shared_state::get_tile_info1),this),TILEMAP_SCAN_ROWS,8,8,64,64);
m_c123_TilemapInfo.tmap[2] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(namcos2_shared_state::get_tile_info2),this),TILEMAP_SCAN_ROWS,8,8,64,64);
m_c123_TilemapInfo.tmap[3] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(namcos2_shared_state::get_tile_info3),this),TILEMAP_SCAN_ROWS,8,8,64,64);
/* two non-scrolling tilemaps */
mTilemapInfo.tmap[4] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(namcos2_shared_state::get_tile_info4),this),TILEMAP_SCAN_ROWS,8,8,36,28);
mTilemapInfo.tmap[5] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(namcos2_shared_state::get_tile_info5),this),TILEMAP_SCAN_ROWS,8,8,36,28);
m_c123_TilemapInfo.tmap[4] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(namcos2_shared_state::get_tile_info4),this),TILEMAP_SCAN_ROWS,8,8,36,28);
m_c123_TilemapInfo.tmap[5] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(namcos2_shared_state::get_tile_info5),this),TILEMAP_SCAN_ROWS,8,8,36,28);
/* define offsets for scrolling */
for( i=0; i<4; i++ )
for( int i = 0; i < 4; i++ )
{
static const int adj[4] = { 4,2,1,0 };
int dx = 44+adj[i];
mTilemapInfo.tmap[i]->set_scrolldx( -dx, 288+dx );
mTilemapInfo.tmap[i]->set_scrolldy( -24, 224+24 );
m_c123_TilemapInfo.tmap[i]->set_scrolldx( -dx, 288+dx );
m_c123_TilemapInfo.tmap[i]->set_scrolldy( -24, 224+24 );
}
save_item(NAME(mTilemapInfo.control));
save_pointer(NAME(mTilemapInfo.videoram.get()), 0x10000);
} /* namco_tilemap_init */
save_item(NAME(m_c123_TilemapInfo.control));
save_pointer(NAME(m_c123_TilemapInfo.videoram.get()), 0x10000);
}
void
namco_tilemap_draw( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri )
void namcos2_shared_state::c123_tilemap_draw( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri )
{
int i;
for( i=0; i<6; i++ )
for( int i = 0; i < 6; i++ )
{
/* note: priority is only in range 0..7, but Point Blank uses 0xf to hide a layer */
if( (mTilemapInfo.control[0x20/2+i]&0xf) == pri )
if( (m_c123_TilemapInfo.control[0x20/2+i]&0xf) == pri )
{
int color = mTilemapInfo.control[0x30/2+i] & 0x07;
mTilemapInfo.tmap[i]->set_palette_offset( color*256 );
mTilemapInfo.tmap[i]->draw(screen, bitmap,cliprect,0,0);
int color = m_c123_TilemapInfo.control[0x30/2+i] & 0x07;
m_c123_TilemapInfo.tmap[i]->set_palette_offset( color*256 );
m_c123_TilemapInfo.tmap[i]->draw(screen, bitmap,cliprect,0,0);
}
}
} /* namco_tilemap_draw */
} /* c123_tilemap_draw */
static void
SetTilemapVideoram( int offset, uint16_t newword )
void namcos2_shared_state::c123_SetTilemapVideoram(int offset, uint16_t newword)
{
mTilemapInfo.videoram[offset] = newword;
m_c123_TilemapInfo.videoram[offset] = newword;
if( offset<0x4000 )
{
mTilemapInfo.tmap[offset>>12]->mark_tile_dirty(offset&0xfff);
m_c123_TilemapInfo.tmap[offset>>12]->mark_tile_dirty(offset&0xfff);
}
else if( offset>=0x8010/2 && offset<0x87f0/2 )
{ /* fixed plane#1 */
offset-=0x8010/2;
mTilemapInfo.tmap[4]->mark_tile_dirty( offset );
m_c123_TilemapInfo.tmap[4]->mark_tile_dirty( offset );
}
else if( offset>=0x8810/2 && offset<0x8ff0/2 )
{ /* fixed plane#2 */
offset-=0x8810/2;
mTilemapInfo.tmap[5]->mark_tile_dirty( offset );
m_c123_TilemapInfo.tmap[5]->mark_tile_dirty( offset );
}
} /* SetTilemapVideoram */
WRITE16_MEMBER( namcos2_shared_state::c123_tilemap_videoram_w )
{
uint16_t newword = mTilemapInfo.videoram[offset];
uint16_t newword = m_c123_TilemapInfo.videoram[offset];
COMBINE_DATA( &newword );
SetTilemapVideoram( offset, newword );
c123_SetTilemapVideoram( offset, newword );
}
READ16_MEMBER( namcos2_shared_state::c123_tilemap_videoram_r )
{
return mTilemapInfo.videoram[offset];
return m_c123_TilemapInfo.videoram[offset];
}
static void
SetTilemapControl( int offset, uint16_t newword )
void namcos2_shared_state::c123_SetTilemapControl(int offset, uint16_t newword)
{
mTilemapInfo.control[offset] = newword;
m_c123_TilemapInfo.control[offset] = newword;
if( offset<0x20/2 )
{
if( offset == 0x02/2 )
@ -145,54 +117,54 @@ SetTilemapControl( int offset, uint16_t newword )
int i;
for( i=0; i<=5; i++ )
{
mTilemapInfo.tmap[i]->set_flip(attrs);
m_c123_TilemapInfo.tmap[i]->set_flip(attrs);
}
}
}
newword &= 0x1ff;
if( mTilemapInfo.control[0x02/2]&0x8000 )
if( m_c123_TilemapInfo.control[0x02/2]&0x8000 )
{
newword = -newword;
}
switch( offset )
{
case 0x02/2:
mTilemapInfo.tmap[0]->set_scrollx( 0, newword );
m_c123_TilemapInfo.tmap[0]->set_scrollx( 0, newword );
break;
case 0x06/2:
mTilemapInfo.tmap[0]->set_scrolly( 0, newword );
m_c123_TilemapInfo.tmap[0]->set_scrolly( 0, newword );
break;
case 0x0a/2:
mTilemapInfo.tmap[1]->set_scrollx( 0, newword );
m_c123_TilemapInfo.tmap[1]->set_scrollx( 0, newword );
break;
case 0x0e/2:
mTilemapInfo.tmap[1]->set_scrolly( 0, newword );
m_c123_TilemapInfo.tmap[1]->set_scrolly( 0, newword );
break;
case 0x12/2:
mTilemapInfo.tmap[2]->set_scrollx( 0, newword );
m_c123_TilemapInfo.tmap[2]->set_scrollx( 0, newword );
break;
case 0x16/2:
mTilemapInfo.tmap[2]->set_scrolly( 0, newword );
m_c123_TilemapInfo.tmap[2]->set_scrolly( 0, newword );
break;
case 0x1a/2:
mTilemapInfo.tmap[3]->set_scrollx( 0, newword );
m_c123_TilemapInfo.tmap[3]->set_scrollx( 0, newword );
break;
case 0x1e/2:
mTilemapInfo.tmap[3]->set_scrolly( 0, newword );
m_c123_TilemapInfo.tmap[3]->set_scrolly( 0, newword );
break;
}
} /* SetTilemapControl */
WRITE16_MEMBER( namcos2_shared_state::c123_tilemap_control_w )
{
uint16_t newword = mTilemapInfo.control[offset];
uint16_t newword = m_c123_TilemapInfo.control[offset];
COMBINE_DATA( &newword );
SetTilemapControl( offset, newword );
c123_SetTilemapControl( offset, newword );
}
READ16_MEMBER( namcos2_shared_state::c123_tilemap_control_r )
{
return mTilemapInfo.control[offset];
return m_c123_TilemapInfo.control[offset];
}
@ -350,8 +322,7 @@ void namcos2_shared_state::zdrawgfxzoom(
/* nop */
}
void
namcos2_state::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri, int control )
void namcos2_state::draw_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri, int control )
{
int offset = (control & 0x000f) * (128*4);
int loop;

View File

@ -1,6 +1,6 @@
// license:BSD-3-Clause
// copyright-holders:R. Belmont, ElSemi
/* video/namcofl.c */
/* video/namcofl.cpp */
#include "emu.h"
#include "includes/namcoic.h"
@ -47,7 +47,7 @@ nth_byte32( const uint32_t *pSource, int which )
} /* nth_byte32 */
#endif
static void TilemapCB(running_machine &machine, uint16_t code, int *tile, int *mask )
void namcofl_state::TilemapCB(uint16_t code, int *tile, int *mask)
{
*tile = code;
*mask = code;
@ -64,7 +64,7 @@ uint32_t namcofl_state::screen_update_namcofl(screen_device &screen, bitmap_ind1
{
c169_roz_draw(screen, bitmap, cliprect, pri);
if((pri&1)==0)
namco_tilemap_draw( screen, bitmap, cliprect, pri>>1 );
c123_tilemap_draw( screen, bitmap, cliprect, pri>>1 );
c355_obj_draw(screen, bitmap, cliprect, pri );
}
@ -80,17 +80,16 @@ WRITE32_MEMBER(namcofl_state::namcofl_spritebank_w)
COMBINE_DATA(&m_sprbank);
}
static int FLobjcode2tile( running_machine &machine, int code )
int namcofl_state::FLobjcode2tile(int code)
{
namcofl_state *state = machine.driver_data<namcofl_state>();
if ((code & 0x2000) && (state->m_sprbank & 2)) { code += 0x4000; }
if ((code & 0x2000) && (m_sprbank & 2)) { code += 0x4000; }
return code;
}
VIDEO_START_MEMBER(namcofl_state,namcofl)
{
namco_tilemap_init(NAMCOFL_TILEGFX, memregion(NAMCOFL_TILEMASKREGION)->base(), TilemapCB );
c355_obj_init(NAMCOFL_SPRITEGFX,0x0,namcos2_shared_state::c355_obj_code2tile_delegate(&FLobjcode2tile, &machine()));
c123_tilemap_init(NAMCOFL_TILEGFX, memregion(NAMCOFL_TILEMASKREGION)->base(), namcos2_shared_state::c123_tilemap_delegate(&namcofl_state::TilemapCB, this));
c355_obj_init(NAMCOFL_SPRITEGFX,0x0,namcos2_shared_state::c355_obj_code2tile_delegate(&namcofl_state::FLobjcode2tile, this));
c169_roz_init(NAMCOFL_ROTGFX,NAMCOFL_ROTMASKREGION);
}

View File

@ -40,24 +40,21 @@ nth_byte32( const uint32_t *pSource, int which )
}
} /* nth_byte32 */
static void
NB1TilemapCB(running_machine &machine, uint16_t code, int *tile, int *mask )
void namconb1_state::NB1TilemapCB(uint16_t code, int *tile, int *mask)
{
*tile = code;
*mask = code;
} /* NB1TilemapCB */
static void
NB2TilemapCB(running_machine &machine, uint16_t code, int *tile, int *mask )
void namconb1_state::NB2TilemapCB(uint16_t code, int *tile, int *mask )
{
namconb1_state *state = machine.driver_data<namconb1_state>();
int mangle;
if( state->m_gametype == NAMCONB2_MACH_BREAKERS )
if( m_gametype == NAMCONB2_MACH_BREAKERS )
{
/* 00010203 04050607 00010203 04050607 (normal) */
/* 00010718 191a1b07 00010708 090a0b07 (alt bank) */
int bank = nth_byte32( state->m_tilebank32, (code>>13)+8 );
int bank = nth_byte32( m_tilebank32, (code>>13)+8 );
mangle = (code&0x1fff) + bank*0x2000;
*tile = mangle;
*mask = mangle;
@ -84,7 +81,7 @@ void namconb1_state::video_update_common(screen_device &screen, bitmap_ind16 &bi
c169_roz_draw(screen, bitmap, cliprect, pri);
if( (pri&1)==0 )
{
namco_tilemap_draw( screen, bitmap, cliprect, pri/2 );
c123_tilemap_draw( screen, bitmap, cliprect, pri/2 );
}
c355_obj_draw(screen, bitmap, cliprect, pri );
}
@ -93,7 +90,7 @@ void namconb1_state::video_update_common(screen_device &screen, bitmap_ind16 &bi
{
for( pri=0; pri<8; pri++ )
{
namco_tilemap_draw( screen, bitmap, cliprect, pri );
c123_tilemap_draw( screen, bitmap, cliprect, pri );
c355_obj_draw(screen, bitmap, cliprect, pri );
}
}
@ -128,7 +125,7 @@ int namconb1_state::NB1objcode2tile( int code )
VIDEO_START_MEMBER(namconb1_state,namconb1)
{
namco_tilemap_init(NAMCONB1_TILEGFX, memregion(NAMCONB1_TILEMASKREGION)->base(), NB1TilemapCB );
c123_tilemap_init(NAMCONB1_TILEGFX, memregion(NAMCONB1_TILEMASKREGION)->base(), namcos2_shared_state::c123_tilemap_delegate(&namconb1_state::NB1TilemapCB, this));
c355_obj_init(NAMCONB1_SPRITEGFX,0x0,namcos2_shared_state::c355_obj_code2tile_delegate(&namconb1_state::NB1objcode2tile, this));
save_item(NAME(m_tilemap_tile_bank));
@ -152,7 +149,7 @@ uint32_t namconb1_state::screen_update_namconb2(screen_device &screen, bitmap_in
if( memcmp(m_tilemap_tile_bank,m_tilebank32,sizeof(m_tilemap_tile_bank))!=0 )
{
namco_tilemap_invalidate();
c123_tilemap_invalidate();
memcpy(m_tilemap_tile_bank,m_tilebank32,sizeof(m_tilemap_tile_bank));
}
video_update_common( screen, bitmap, clip, 1 );
@ -186,7 +183,7 @@ int namconb1_state::NB2objcode2tile( int code )
VIDEO_START_MEMBER(namconb1_state,namconb2)
{
namco_tilemap_init(NAMCONB1_TILEGFX, memregion(NAMCONB1_TILEMASKREGION)->base(), NB2TilemapCB );
c123_tilemap_init(NAMCONB1_TILEGFX, memregion(NAMCONB1_TILEMASKREGION)->base(), namcos2_shared_state::c123_tilemap_delegate(&namconb1_state::NB2TilemapCB, this));
c355_obj_init(NAMCONB1_SPRITEGFX,0x0,namcos2_shared_state::c355_obj_code2tile_delegate(&namconb1_state::NB2objcode2tile, this));
c169_roz_init(NAMCONB1_ROTGFX,NAMCONB1_ROTMASKREGION);

View File

@ -7,14 +7,11 @@
#include "includes/namcos2.h"
#include "includes/namcoic.h"
static void
TilemapCB( running_machine &machine, uint16_t code, int *tile, int *mask )
//void namcos2_shared_state::tilemap_cb(uint16_t code, int *tile, int *mask)
void namcos2_state::TilemapCB(uint16_t code, int *tile, int *mask)
{
*mask = code;
namcos2_shared_state *state = machine.driver_data<namcos2_shared_state>();
switch( state->m_gametype )
switch( m_gametype )
{
case NAMCOS2_FINAL_LAP_2:
case NAMCOS2_FINAL_LAP_3:
@ -401,7 +398,7 @@ void namcos2_state::draw_sprite_init()
void namcos2_state::video_start()
{
namco_tilemap_init(2, memregion("gfx4")->base(), TilemapCB);
c123_tilemap_init(2, memregion("gfx4")->base(), namcos2_shared_state::c123_tilemap_delegate(&namcos2_state::TilemapCB, this));
m_tilemap_roz = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(FUNC(namcos2_state::roz_tile_info), this), TILEMAP_SCAN_ROWS, 8,8,256,256);
m_tilemap_roz->set_transparent_pen(0xff);
draw_sprite_init();
@ -433,7 +430,7 @@ uint32_t namcos2_state::screen_update(screen_device &screen, bitmap_ind16 &bitma
{
if( (pri&1)==0 )
{
namco_tilemap_draw( screen, bitmap, clip, pri/2 );
c123_tilemap_draw( screen, bitmap, clip, pri/2 );
if( ((m_gfx_ctrl & 0x7000) >> 12)==pri/2 )
{
@ -449,7 +446,7 @@ uint32_t namcos2_state::screen_update(screen_device &screen, bitmap_ind16 &bitma
void namcos2_state::video_start_finallap()
{
namco_tilemap_init(2,memregion("gfx4")->base(),TilemapCB);
c123_tilemap_init(2,memregion("gfx4")->base(),namcos2_shared_state::c123_tilemap_delegate(&namcos2_state::TilemapCB, this));
draw_sprite_init();
}
@ -466,7 +463,7 @@ uint32_t namcos2_state::screen_update_finallap(screen_device &screen, bitmap_ind
{
if( (pri&1)==0 )
{
namco_tilemap_draw( screen, bitmap, clip, pri/2 );
c123_tilemap_draw( screen, bitmap, clip, pri/2 );
}
m_c45_road->draw(bitmap,clip,pri);
draw_sprites(screen,bitmap,clip,pri,m_gfx_ctrl );
@ -478,7 +475,7 @@ uint32_t namcos2_state::screen_update_finallap(screen_device &screen, bitmap_ind
void namcos2_state::video_start_luckywld()
{
namco_tilemap_init(2,memregion("gfx4")->base(),TilemapCB);
c123_tilemap_init(2,memregion("gfx4")->base(),namcos2_shared_state::c123_tilemap_delegate(&namcos2_state::TilemapCB, this));
c355_obj_init( 0, 0x0, namcos2_shared_state::c355_obj_code2tile_delegate() );
if( m_gametype==NAMCOS2_LUCKY_AND_WILD )
{
@ -499,7 +496,7 @@ uint32_t namcos2_state::screen_update_luckywld(screen_device &screen, bitmap_ind
{
if( (pri&1)==0 )
{
namco_tilemap_draw( screen, bitmap, clip, pri/2 );
c123_tilemap_draw( screen, bitmap, clip, pri/2 );
}
m_c45_road->draw(bitmap,clip,pri);
if( m_gametype==NAMCOS2_LUCKY_AND_WILD )
@ -515,7 +512,7 @@ uint32_t namcos2_state::screen_update_luckywld(screen_device &screen, bitmap_ind
void namcos2_state::video_start_sgunner()
{
namco_tilemap_init(2,memregion("gfx4")->base(),TilemapCB);
c123_tilemap_init(2,memregion("gfx4")->base(),namcos2_shared_state::c123_tilemap_delegate(&namcos2_state::TilemapCB, this));
c355_obj_init( 0, 0x0, namcos2_shared_state::c355_obj_code2tile_delegate() );
}
@ -530,7 +527,7 @@ uint32_t namcos2_state::screen_update_sgunner(screen_device &screen, bitmap_ind1
for( pri=0; pri<8; pri++ )
{
namco_tilemap_draw( screen, bitmap, clip, pri );
c123_tilemap_draw( screen, bitmap, clip, pri );
c355_obj_draw(screen, bitmap, clip, pri );
}
return 0;
@ -541,7 +538,7 @@ uint32_t namcos2_state::screen_update_sgunner(screen_device &screen, bitmap_ind1
void namcos2_state::video_start_metlhawk()
{
namco_tilemap_init(2,memregion("gfx4")->base(),TilemapCB);
c123_tilemap_init(2,memregion("gfx4")->base(),namcos2_shared_state::c123_tilemap_delegate(&namcos2_state::TilemapCB, this));
c169_roz_init(1, "gfx5");
}
@ -558,7 +555,7 @@ uint32_t namcos2_state::screen_update_metlhawk(screen_device &screen, bitmap_ind
{
if( (pri&1)==0 )
{
namco_tilemap_draw( screen, bitmap, clip, pri/2 );
c123_tilemap_draw( screen, bitmap, clip, pri/2 );
}
c169_roz_draw(screen, bitmap, clip, pri);
draw_sprites_metalhawk(screen,bitmap,clip,pri );