From 0f6d24f385df2891b8c0836a3973a27fa19f96f5 Mon Sep 17 00:00:00 2001 From: Angelo Salese Date: Fri, 5 Aug 2011 19:33:35 +0000 Subject: [PATCH] Port from MESS, nw --- src/mame/drivers/saturn.c | 39 ++++++++++++++++++++++++++++++++------- src/mame/machine/smpc.c | 7 +++---- src/mame/video/stvvdp2.c | 9 +++++---- 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/src/mame/drivers/saturn.c b/src/mame/drivers/saturn.c index a74b8a75c6c..a99542ecc98 100644 --- a/src/mame/drivers/saturn.c +++ b/src/mame/drivers/saturn.c @@ -1773,7 +1773,7 @@ static TIMER_DEVICE_CALLBACK( saturn_scanline ) vblank_line = (state->m_vdp2.pal) ? 288 : 240; -// popmessage("%08x %d %08x %08x",state->m_scu.ism ^ 0xffffffff,max_y,state->m_scu_regs[36],state->m_scu_regs[38]); + //popmessage("%08x %d T0 %d T1 %d %08x",state->m_scu.ism ^ 0xffffffff,max_y,state->m_scu_regs[36],state->m_scu_regs[37],state->m_scu_regs[38]); if(scanline == 0*y_step) { @@ -1819,15 +1819,19 @@ static TIMER_DEVICE_CALLBACK( saturn_scanline ) } /* TODO: this isn't completely correct */ - if((state->m_scu_regs[38] & 0x81) == 0x01 && ((scanline % y_step) == 0)) + if(state->m_scu_regs[38] & 0x1) { - if(!(state->m_scu.ism & IRQ_TIMER_1)) + if((!(state->m_scu_regs[38] & 0x100) && (scanline % y_step) == 0) || + ((state->m_scu_regs[38] & 0x100) && (scanline == (state->m_scu_regs[36] & 0x3ff)*y_step))) { - device_set_input_line_and_vector(state->m_maincpu, 0xb, HOLD_LINE, 0x44 ); - scu_do_transfer(timer.machine(),4); + if(!(state->m_scu.ism & IRQ_TIMER_1)) + { + device_set_input_line_and_vector(state->m_maincpu, 0xb, HOLD_LINE, 0x44 ); + scu_do_transfer(timer.machine(),4); + } + else + state->m_scu.ist |= (IRQ_TIMER_1); } - else - state->m_scu.ist |= (IRQ_TIMER_1); } if(scanline == vblank_line*y_step) @@ -1844,6 +1848,26 @@ static TIMER_DEVICE_CALLBACK( saturn_scanline ) } } +static TIMER_DEVICE_CALLBACK( saturn_slave_scanline ) +{ + saturn_state *state = timer.machine().driver_data(); + int scanline = param; + int max_y = timer.machine().primary_screen->height(); + int y_step,vblank_line; + + y_step = 2; + + if((max_y == 263 && state->m_vdp2.pal == 0) || (max_y == 313 && state->m_vdp2.pal == 1)) + y_step = 1; + + vblank_line = (state->m_vdp2.pal) ? 288 : 240; + + if(scanline == vblank_line*y_step) + device_set_input_line_and_vector(state->m_slave, 0x6, HOLD_LINE, 0x43); + else if((scanline % y_step) == 0 && scanline < vblank_line*y_step) + device_set_input_line_and_vector(state->m_slave, 0x2, HOLD_LINE, 0x41); +} + static READ32_HANDLER( saturn_cart_dram0_r ) { saturn_state *state = space->machine().driver_data(); @@ -1977,6 +2001,7 @@ static MACHINE_CONFIG_START( saturn, saturn_state ) MCFG_CPU_ADD("slave", SH2, MASTER_CLOCK_352/2) // 28.6364 MHz MCFG_CPU_PROGRAM_MAP(saturn_mem) MCFG_CPU_CONFIG(sh2_conf_slave) + MCFG_TIMER_ADD_SCANLINE("slave_scantimer", saturn_slave_scanline, "screen", 0, 1) MCFG_CPU_ADD("audiocpu", M68000, 11289600) //11.2896 MHz MCFG_CPU_PROGRAM_MAP(sound_mem) diff --git a/src/mame/machine/smpc.c b/src/mame/machine/smpc.c index 2ce31520d3c..e1a9a977f0f 100644 --- a/src/mame/machine/smpc.c +++ b/src/mame/machine/smpc.c @@ -153,7 +153,7 @@ TODO: #include "machine/eeprom.h" #define LOG_SMPC 0 -#define LOG_PAD_CMD 1 +#define LOG_PAD_CMD 0 READ8_HANDLER( stv_SMPC_r ) { @@ -324,12 +324,12 @@ static TIMER_CALLBACK( intback_peripheral ) static const char *const padnames[] = { "JOY1", "JOY2" }; /* doesn't work? */ - pad_num = state->m_smpc.intback_stage - 1; + //pad_num = state->m_smpc.intback_stage - 1; if(LOG_PAD_CMD) printf("%d\n",pad_num); // if (LOG_SMPC) logerror("SMPC: providing PAD data for intback, pad %d\n", intback_stage-2); - //for(pad_num=0;pad_num<2;pad_num++) + for(pad_num=0;pad_num<2;pad_num++) { pad = input_port_read(machine, padnames[pad_num]); state->m_smpc_ram[0x21+pad_num*8] = 0xf1; // no tap, direct connect @@ -417,7 +417,6 @@ static TIMER_CALLBACK( saturn_smpc_intback ) state->m_smpc.intback_stage = (state->m_smpc_ram[3] & 8) >> 3; // first peripheral state->m_smpc.smpcSR = 0x40 | state->m_smpc.intback_stage << 5; state->m_smpc.pmode = state->m_smpc_ram[1]>>4; - machine.scheduler().timer_set(attotime::from_usec(15000), FUNC(intback_peripheral),0); if(!(state->m_scu.ism & IRQ_SMPC)) device_set_input_line_and_vector(state->m_maincpu, 8, HOLD_LINE, 0x47); diff --git a/src/mame/video/stvvdp2.c b/src/mame/video/stvvdp2.c index 3f838d18a98..6345203e52e 100644 --- a/src/mame/video/stvvdp2.c +++ b/src/mame/video/stvvdp2.c @@ -1425,7 +1425,7 @@ bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09 #define STV_VDP2_BKTAL ((state->m_vdp2_regs[0x0ac/4] >> 0) & 0xffff) - #define STV_VDP2_BKTA (((STV_VDP2_BKTAU & 0x0007) << 16) | (STV_VDP2_BKTAL & 0xfffe)) + #define STV_VDP2_BKTA (((STV_VDP2_BKTAU & 0x0007) << 16) | (STV_VDP2_BKTAL & 0xffff)) /* 1800b0 - RPMD - Rotation Parameter Mode bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ @@ -4342,7 +4342,8 @@ static void stv_vdp2_check_tilemap(running_machine &machine, bitmap_t *bitmap, c // popmessage("%s shadow select bit enabled, contact MAMEdev",STV_VDP2_SDCTL & 0x100 ? "Transparent" : "Back"); /* Langrisser III bit 3 normal, bit 1 during battle field */ - if(STV_VDP2_SFSEL & ~0xa) + /* Metal Slug bit 0 during gameplay */ + if(STV_VDP2_SFSEL & ~0xb) popmessage("Special Function Code Select enable %04x %04x, contact MAMEdev",STV_VDP2_SFSEL,STV_VDP2_SFCODE); /* Albert Odyssey Gaiden 0x0001 */ @@ -5470,7 +5471,7 @@ static void stv_vdp2_draw_back(running_machine &machine, bitmap_t *bitmap, const interlace = (STV_VDP2_LSMD == 3)+1; - //popmessage("Back screen %08x %08x %08x",STV_VDP2_BDCLMD,STV_VDP2_BKCLMD,STV_VDP2_BKTA); +// popmessage("Back screen %08x %08x %08x",STV_VDP2_BDCLMD,STV_VDP2_BKCLMD,STV_VDP2_BKTA); /* draw black if BDCLMD and DISP are cleared */ if(!(STV_VDP2_BDCLMD) && !(STV_VDP2_DISP)) @@ -5481,7 +5482,7 @@ static void stv_vdp2_draw_back(running_machine &machine, bitmap_t *bitmap, const for(y=cliprect->min_y;y<=cliprect->max_y;y++) { - base_offs = ((STV_VDP2_BKTA + 1) & base_mask) << 1; + base_offs = ((STV_VDP2_BKTA ) & base_mask) << 1; if(STV_VDP2_BKCLMD) base_offs += ((y / interlace) << 1);