Clean-ups, 279 lines removed from machine/namcos2.cpp (nw)

This commit is contained in:
angelosa 2016-12-31 22:45:30 +01:00
parent 1c533823ba
commit 8e00c03a0e
6 changed files with 15 additions and 310 deletions

View File

@ -1695,7 +1695,7 @@ MACHINE_CONFIG_END
TIMER_DEVICE_CALLBACK_MEMBER(namcos2_state::screen_scanline)
{
int scanline = param;
int cur_posirq = get_posirq_scanline();
int cur_posirq = get_pos_irq_scanline();
if(scanline == 240)
{

View File

@ -130,18 +130,15 @@ public:
bool is_system21();
int m_gametype;
emu_timer *m_posirq_timer;
int m_mcu_analog_ctrl;
int m_mcu_analog_data;
int m_mcu_analog_complete;
std::unique_ptr<uint8_t[]> m_eeprom;
uint16_t m_68k_master_C148[0x20];
uint16_t m_68k_slave_C148[0x20];
uint16_t m_68k_gpu_C148[0x20];
DECLARE_WRITE8_MEMBER(sound_reset_w);
DECLARE_WRITE8_MEMBER(system_reset_w);
void reset_all_subcpus(int state);
TIMER_DEVICE_CALLBACK_MEMBER(screen_scanline);
// C123 Tilemap Emulation
@ -228,23 +225,9 @@ public:
// general
void zdrawgfxzoom(screen_device &screen, bitmap_ind16 &dest_bmp, const rectangle &clip, gfx_element *gfx, uint32_t code, uint32_t color, int flipx, int flipy, int sx, int sy, int scalex, int scaley, int zpos);
void zdrawgfxzoom(screen_device &screen, bitmap_rgb32 &dest_bmp, const rectangle &clip, gfx_element *gfx, uint32_t code, uint32_t color, int flipx, int flipy, int sx, int sy, int scalex, int scaley, int zpos);
INTERRUPT_GEN_MEMBER(namcos2_68k_master_vblank);
INTERRUPT_GEN_MEMBER(namcos2_68k_slave_vblank);
INTERRUPT_GEN_MEMBER(namcos2_68k_gpu_vblank);
TIMER_CALLBACK_MEMBER(namcos2_posirq_tick);
void adjust_posirq_timer( int scanline );
void init_c148();
void reset_all_subcpus(int state);
uint16_t readwrite_c148( address_space &space, offs_t offset, uint16_t data, int bWrite );
int get_posirq_scanline();
DECLARE_WRITE8_MEMBER( namcos2_68k_eeprom_w );
DECLARE_READ8_MEMBER( namcos2_68k_eeprom_r );
DECLARE_WRITE16_MEMBER( namcos2_68k_master_C148_w );
DECLARE_READ16_MEMBER( namcos2_68k_master_C148_r );
DECLARE_WRITE16_MEMBER( namcos2_68k_slave_C148_w );
DECLARE_READ16_MEMBER( namcos2_68k_slave_C148_r );
DECLARE_WRITE8_MEMBER( namcos2_mcu_port_d_w );
DECLARE_READ8_MEMBER( namcos2_mcu_port_d_r );
@ -254,9 +237,6 @@ public:
DECLARE_READ8_MEMBER( namcos2_mcu_analog_port_r );
DECLARE_WRITE8_MEMBER( namcos2_sound_bankselect_w );
/* TODO: this should belong to namcos21_state */
DECLARE_WRITE16_MEMBER( namcos21_68k_gpu_C148_w );
DECLARE_READ16_MEMBER( namcos21_68k_gpu_C148_r );
required_device<cpu_device> m_maincpu;
optional_device<cpu_device> m_audiocpu;
optional_device<cpu_device> m_slave;

View File

@ -73,7 +73,7 @@ public:
optional_device<namco_c148_device> m_gpu_intc;
std::unique_ptr<uint8_t[]> m_videoram;
std::unique_ptr<uint8_t[]> m_colorram;
std::unique_ptr<uint8_t[]> m_maskram;
std::unique_ptr<uint16_t[]> m_winrun_dspcomram;
uint16_t m_winrun_poly_buf[WINRUN_MAX_POLY_PARAM];
int m_winrun_poly_index;
@ -168,6 +168,7 @@ public:
uint8_t m_gearbox_state;
DECLARE_CUSTOM_INPUT_MEMBER(driveyes_gearbox_r);
DECLARE_DRIVER_INIT(driveyes);
DECLARE_DRIVER_INIT(winrun);
DECLARE_DRIVER_INIT(starblad);
@ -182,6 +183,7 @@ public:
void allocate_poly_framebuffer();
void clear_poly_framebuffer();
void copy_visible_poly_framebuffer(bitmap_ind16 &bitmap, const rectangle &clip, int zlo, int zhi);
void winrun_bitmap_draw(bitmap_ind16 &bitmap, const rectangle &cliprect);
void renderscanline_flat(const edge *e1, const edge *e2, int sy, unsigned color, int depthcueenable);
void rendertri(const n21_vertex *v0, const n21_vertex *v1, const n21_vertex *v2, unsigned color, int depthcueenable);
void draw_quad(int sx[4], int sy[4], int zcode[4], int color);
@ -193,6 +195,5 @@ public:
int init_dsp();
void render_slave_output(uint16_t data);
void winrun_flush_poly();
void winrun_bitmap_draw(bitmap_ind16 &bitmap, const rectangle &cliprect);
void init(int game_type);
};

View File

@ -97,38 +97,16 @@ WRITE8_MEMBER(namcos2_shared_state::sound_reset_w)
}
}
// TODO:
WRITE8_MEMBER(namcos2_shared_state::system_reset_w)
{
address_space &masterspace = m_maincpu->space(AS_PROGRAM);
m_slave->set_input_line(INPUT_LINE_RESET, data & 1 ? CLEAR_LINE : ASSERT_LINE);
m_mcu->set_input_line(INPUT_LINE_RESET, data & 1 ? CLEAR_LINE : ASSERT_LINE);
reset_all_subcpus(data & 1 ? CLEAR_LINE : ASSERT_LINE);
switch( m_gametype )
if (data & 0x01)
{
case NAMCOS21_SOLVALOU:
case NAMCOS21_STARBLADE:
case NAMCOS21_AIRCOMBAT:
case NAMCOS21_CYBERSLED:
m_dspmaster->set_input_line(INPUT_LINE_RESET, data & 1 ? CLEAR_LINE : ASSERT_LINE);
m_dspslave->set_input_line(INPUT_LINE_RESET, data & 1 ? CLEAR_LINE : ASSERT_LINE);
break;
}
if (data & 0x01)
address_space &masterspace = m_maincpu->space(AS_PROGRAM);
masterspace.device().execute().yield();
#if 0
if (data & 0x01)
{ /* Resume execution */
//reset_all_subcpus(CLEAR_LINE);
/* Give the new CPU an immediate slice of the action */
}
else
{ /* Suspend execution */
//reset_all_subcpus(ASSERT_LINE);
}
#endif
}
void namcos2_shared_state::reset_all_subcpus(int state)
@ -164,7 +142,6 @@ MACHINE_START_MEMBER(namcos2_shared_state,namcos2)
namcos2_kickstart = nullptr;
m_eeprom = std::make_unique<uint8_t[]>(m_eeprom_size);
machine().device<nvram_device>("nvram")->set_base(m_eeprom.get(), m_eeprom_size);
m_posirq_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(namcos2_shared_state::namcos2_posirq_tick),this));
}
MACHINE_RESET_MEMBER(namcos2_shared_state, namcos2)
@ -184,12 +161,6 @@ MACHINE_RESET_MEMBER(namcos2_shared_state, namcos2)
/* Place CPU2 & CPU3 into the reset condition */
reset_all_subcpus(ASSERT_LINE);
/* Initialise interrupt handlers */
init_c148();
/* reset POSIRQ timer */
m_posirq_timer->adjust(attotime::never);
m_player_mux = 0;
}
@ -495,252 +466,6 @@ bool namcos2_shared_state::is_system21()
}
}
void namcos2_shared_state::init_c148()
{
for(int loop = 0; loop < 0x20; loop++)
{
m_68k_master_C148[loop] = 0;
m_68k_slave_C148[loop] = 0;
m_68k_gpu_C148[loop] = 0;
}
}
uint16_t namcos2_shared_state::readwrite_c148( address_space &space, offs_t offset, uint16_t data, int bWrite )
{
offs_t addr = ((offset * 2) + 0x1c0000) & 0x1fe000;
device_t *altcpu = nullptr;
uint16_t *pC148Reg = nullptr;
uint16_t *pC148RegAlt = nullptr;
uint16_t result = 0;
if (&space.device() == m_maincpu)
{
pC148Reg = m_68k_master_C148;
altcpu = m_slave;
pC148RegAlt = m_68k_slave_C148;
}
else if (&space.device() == m_slave)
{
pC148Reg = m_68k_slave_C148;
altcpu = m_maincpu;
pC148RegAlt = m_68k_master_C148;
}
else if (&space.device() == m_gpu)
{
pC148Reg = m_68k_gpu_C148;
altcpu = m_maincpu;
pC148RegAlt = m_68k_master_C148;
}
if( bWrite )
{
int reg = (addr >> 13) & 0x1f;
// If writing an IRQ priority register, clear any pending IRQs.
// Dirt Fox and Winning Run require this behaviour
if (reg < 8)
space.device().execute().set_input_line(pC148Reg[reg], CLEAR_LINE);
pC148Reg[reg] = data & 0x0007;
}
switch(addr)
{
case 0x1c0000: break; /* ? NAMCOS2_C148_0 */
case 0x1c2000: break; /* ? NAMCOS2_C148_1 */
case 0x1c4000: break; /* ? NAMCOS2_C148_2 */
/* IRQ level */
case 0x1c6000: break; /* NAMCOS2_C148_CPUIRQ */
case 0x1c8000: break; /* NAMCOS2_C148_EXIRQ */
case 0x1ca000: break; /* NAMCOS2_C148_POSIRQ */
case 0x1cc000: break; /* NAMCOS2_C148_SERIRQ */
case 0x1ce000: break; /* NAMCOS2_C148_VBLANKIRQ */
case 0x1d0000: /* ? NAMCOS2_C148_0 */
if( bWrite )
{
// osd_printf_debug( "cpu(%d) RAM[0x%06x] = 0x%x\n", cpu, addr, data );
/* Dubious to assert IRQ for other CPU here, but Starblade seems to rely on it.
It fails to show large polygons otherwise. */
altcpu->execute().set_input_line(pC148RegAlt[NAMCOS2_C148_CPUIRQ], ASSERT_LINE);
}
break;
case 0x1d2000: break; /* ? NAMCOS2_C148_1 */
case 0x1d4000: /* ? NAMCOS2_C148_2 */
if( bWrite )
{
// osd_printf_debug( "cpu(%d) RAM[0x%06x] = 0x%x\n", cpu, addr, data );
/* Dubious to assert IRQ for other CPU here: Rolling Thunder 2 and Fine Hour break. */
// altcpu->execute().set_input_line(pC148RegAlt[NAMCOS2_C148_CPUIRQ], ASSERT_LINE);
}
break;
/* IRQ ack */
case 0x1d6000: /* NAMCOS2_C148_CPUIRQ */
// if( bWrite ) osd_printf_debug( "cpu(%d) RAM[0x%06x] = 0x%x\n", cpu, addr, data );
space.device().execute().set_input_line(pC148Reg[NAMCOS2_C148_CPUIRQ], CLEAR_LINE);
break;
case 0x1d8000: /* NAMCOS2_C148_EXIRQ */
// if( bWrite ) osd_printf_debug( "cpu(%d) RAM[0x%06x] = 0x%x\n", cpu, addr, data );
space.device().execute().set_input_line(pC148Reg[NAMCOS2_C148_EXIRQ], CLEAR_LINE);
break;
case 0x1da000: /* NAMCOS2_C148_POSIRQ */
// if( bWrite ) osd_printf_debug( "cpu(%d) RAM[0x%06x] = 0x%x\n", cpu, addr, data );
space.device().execute().set_input_line(pC148Reg[NAMCOS2_C148_POSIRQ], CLEAR_LINE);
break;
case 0x1dc000: /* NAMCOS2_C148_SERIRQ */
// if( bWrite ) osd_printf_debug( "cpu(%d) RAM[0x%06x] = 0x%x\n", cpu, addr, data );
space.device().execute().set_input_line(pC148Reg[NAMCOS2_C148_SERIRQ], CLEAR_LINE);
break;
case 0x1de000: /* NAMCOS2_C148_VBLANKIRQ */
space.device().execute().set_input_line(pC148Reg[NAMCOS2_C148_VBLANKIRQ], CLEAR_LINE);
break;
case 0x1e0000: /* EEPROM Status Register */
result = ~0; /* Only BIT0 used: 1=EEPROM READY 0=EEPROM BUSY */
break;
case 0x1e2000: /* Sound CPU Reset control */
if (&space.device() == m_maincpu) /* ? */
{
if (data & 0x01)
{
/* Resume execution */
m_audiocpu->set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
space.device().execute().yield();
}
else
{
/* Suspend execution */
m_audiocpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
}
if (namcos2_kickstart != nullptr)
{
//printf( "dspkick=0x%x\n", data );
if (data & 0x04)
{
(*namcos2_kickstart)(space.machine(), 1);
}
}
}
break;
case 0x1e4000: /* Alt 68000 & IO CPU Reset */
if (&space.device() == m_maincpu) /* ? */
{
if (data & 0x01)
{ /* Resume execution */
reset_all_subcpus(CLEAR_LINE);
/* Give the new CPU an immediate slice of the action */
space.device().execute().yield();
}
else
{ /* Suspend execution */
reset_all_subcpus(ASSERT_LINE);
}
}
break;
case 0x1e6000: /* Watchdog reset kicker */
/* watchdog_reset_w(0,0); */
break;
default:
break;
}
return result;
}
WRITE16_MEMBER( namcos2_shared_state::namcos2_68k_master_C148_w )
{
(void)readwrite_c148(space, offset, data, 1);
}
READ16_MEMBER( namcos2_shared_state::namcos2_68k_master_C148_r )
{
return readwrite_c148(space, offset, 0, 0);
}
WRITE16_MEMBER( namcos2_shared_state::namcos2_68k_slave_C148_w )
{
(void)readwrite_c148(space, offset, data, 1);
}
READ16_MEMBER( namcos2_shared_state::namcos2_68k_slave_C148_r )
{
return readwrite_c148(space, offset, 0, 0);
}
WRITE16_MEMBER( namcos2_shared_state::namcos21_68k_gpu_C148_w )
{
(void)readwrite_c148(space, offset, data, 1);
}
READ16_MEMBER( namcos2_shared_state::namcos21_68k_gpu_C148_r )
{
return readwrite_c148(space, offset, 0, 0);
}
int namcos2_shared_state::get_posirq_scanline()
{
if (is_system21()) return 0;
return downcast<namcos2_state *>(this)->get_pos_irq_scanline();
}
TIMER_CALLBACK_MEMBER(namcos2_shared_state::namcos2_posirq_tick)
{
if (is_system21()) {
if (m_68k_gpu_C148[NAMCOS2_C148_POSIRQ]) {
m_screen->update_partial(param);
m_gpu->set_input_line(m_68k_gpu_C148[NAMCOS2_C148_POSIRQ] , ASSERT_LINE);
}
return;
}
if (m_68k_master_C148[NAMCOS2_C148_POSIRQ]|m_68k_slave_C148[NAMCOS2_C148_POSIRQ]) {
m_screen->update_partial(param);
if (m_68k_master_C148[NAMCOS2_C148_POSIRQ]) m_maincpu->set_input_line(m_68k_master_C148[NAMCOS2_C148_POSIRQ] , ASSERT_LINE);
if (m_68k_slave_C148[NAMCOS2_C148_POSIRQ]) m_slave->set_input_line(m_68k_slave_C148[NAMCOS2_C148_POSIRQ] , ASSERT_LINE);
}
}
void namcos2_shared_state::adjust_posirq_timer( int scanline )
{
m_posirq_timer->adjust(m_screen->time_until_pos(scanline, 80), scanline);
}
INTERRUPT_GEN_MEMBER(namcos2_shared_state::namcos2_68k_master_vblank)
{
if (!is_system21()) adjust_posirq_timer(get_posirq_scanline());
device.execute().set_input_line(m_68k_master_C148[NAMCOS2_C148_VBLANKIRQ], HOLD_LINE);
}
INTERRUPT_GEN_MEMBER(namcos2_shared_state::namcos2_68k_slave_vblank)
{
if (!is_system21()) adjust_posirq_timer(get_posirq_scanline());
device.execute().set_input_line(m_68k_slave_C148[NAMCOS2_C148_VBLANKIRQ], HOLD_LINE);
}
INTERRUPT_GEN_MEMBER(namcos2_shared_state::namcos2_68k_gpu_vblank)
{
/* only used by namcos21 */
//int scanline = get_posirq_scanline();
int32_t scanline = 0x50+0x89; /* HACK for Winning Run */
//printf( "namcos2_68k_gpu_vblank(%d)\n",m_68k_gpu_C148[NAMCOS2_C148_POSIRQ] );
adjust_posirq_timer(scanline);
device.execute().set_input_line(m_68k_gpu_C148[NAMCOS2_C148_VBLANKIRQ], HOLD_LINE);
}
/**************************************************************/
/* Sound sub-system */

View File

@ -348,10 +348,9 @@ WRITE16_MEMBER( namcos2_state::paletteram_word_w )
/* register 5: POSIRQ scanline (only 8 bits used) */
/*case 0x180a:*/ case 0x180b:
if (data^m_paletteram[offset]) {
//if (data^m_paletteram[offset]) {
m_paletteram[offset] = data;
adjust_posirq_timer(get_pos_irq_scanline());
}
//}
break;
/* registers 6,7: nothing? */

View File

@ -60,14 +60,14 @@ WRITE16_MEMBER(namcos21_state::winrun_gpu_videoram_w)
if( mask&(0x01<<i) )
{
m_videoram[(offset+i)&0x7ffff] = color;
m_colorram[(offset+i)&0x7ffff] = mask;
m_maskram[(offset+i)&0x7ffff] = mask;
}
}
}
READ16_MEMBER(namcos21_state::winrun_gpu_videoram_r)
{
return (m_videoram[offset]<<8) | m_colorram[offset];
return (m_videoram[offset]<<8) | m_maskram[offset];
}
void namcos21_state::allocate_poly_framebuffer()
@ -362,7 +362,7 @@ VIDEO_START_MEMBER(namcos21_state,namcos21)
if( m_gametype == NAMCOS21_WINRUN91 )
{
m_videoram = std::make_unique<uint8_t[]>(0x80000);
m_colorram = std::make_unique<uint8_t[]>(0x80000);
m_maskram = std::make_unique<uint8_t[]>(0x80000);
}
allocate_poly_framebuffer();
c355_obj_init(