From b6ae4cc5d0e97c9da4c2a2372b128bfeeb7fa89f Mon Sep 17 00:00:00 2001 From: Angelo Salese Date: Tue, 9 Aug 2011 00:50:57 +0000 Subject: [PATCH] Putted SMPC Slave CPU behind a timer, plus minor misc changes, nw --- src/mame/drivers/saturn.c | 7 ++++--- src/mame/machine/smpc.c | 30 +++++++++++++++------------- src/mame/machine/stvcd.c | 41 +++++++++++++++++++++------------------ src/mame/video/stvvdp2.c | 14 +++++++++---- 4 files changed, 53 insertions(+), 39 deletions(-) diff --git a/src/mame/drivers/saturn.c b/src/mame/drivers/saturn.c index 1e4bc702fd8..7bb75157099 100644 --- a/src/mame/drivers/saturn.c +++ b/src/mame/drivers/saturn.c @@ -713,7 +713,10 @@ static void scu_dma_direct(address_space *space, UINT8 dma_ch) if(cd_transfer_flag) { int i; - state->m_scu.dst_add[dma_ch] <<= 1; + if((WORK_RAM_H(dma_ch))) + state->m_scu.dst_add[dma_ch] = 4; + else + state->m_scu.dst_add[dma_ch] <<= 1; for (i = 0; i < state->m_scu.size[dma_ch];i+=state->m_scu.dst_add[dma_ch]) { @@ -933,9 +936,7 @@ static ADDRESS_MAP_START( saturn_mem, AS_PROGRAM, 32 ) AM_RANGE(0x00100000, 0x0010007f) AM_READWRITE8(saturn_SMPC_r, saturn_SMPC_w,0xffffffff) AM_RANGE(0x00180000, 0x0018ffff) AM_READWRITE(saturn_backupram_r, saturn_backupram_w) AM_SHARE("share1") AM_BASE_MEMBER(saturn_state,m_backupram) AM_RANGE(0x00200000, 0x002fffff) AM_RAM AM_MIRROR(0x20100000) AM_SHARE("share2") AM_BASE_MEMBER(saturn_state,m_workram_l) -// AM_RANGE(0x01000000, 0x01000003) AM_MIRROR(0x7ffffc) AM_WRITE(minit_w) AM_RANGE(0x01000000, 0x017fffff) AM_WRITE(minit_w) -// AM_RANGE(0x01800000, 0x01800003) AM_MIRROR(0x7ffffc) AM_WRITE(sinit_w) AM_RANGE(0x01800000, 0x01ffffff) AM_WRITE(sinit_w) AM_RANGE(0x02000000, 0x023fffff) AM_ROM AM_SHARE("share7") AM_REGION("maincpu", 0x80000) // cartridge space // AM_RANGE(0x02400000, 0x027fffff) AM_RAM //cart RAM area, dynamically allocated diff --git a/src/mame/machine/smpc.c b/src/mame/machine/smpc.c index 04b4da93c2c..da92fba704a 100644 --- a/src/mame/machine/smpc.c +++ b/src/mame/machine/smpc.c @@ -211,11 +211,13 @@ static void smpc_master_on(running_machine &machine) device_set_input_line(state->m_maincpu, INPUT_LINE_RESET, CLEAR_LINE); } -static void smpc_slave_enable(running_machine &machine,UINT8 cmd) +static TIMER_CALLBACK( smpc_slave_enable ) { saturn_state *state = machine.driver_data(); - device_set_input_line(state->m_slave, INPUT_LINE_RESET, cmd ? ASSERT_LINE : CLEAR_LINE); + device_set_input_line(state->m_slave, INPUT_LINE_RESET, param ? ASSERT_LINE : CLEAR_LINE); + state->m_smpc_ram[0x5f] = param + 0x02; //read-back for last command issued + state->m_smpc_ram[0x63] = 0x00; //clear hand-shake flag } static void smpc_sound_enable(running_machine &machine,UINT8 cmd) @@ -259,7 +261,7 @@ static void smpc_change_clock(running_machine &machine, UINT8 cmd) stv_vdp2_dynamic_res_change(machine); device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, PULSE_LINE); // ff said this causes nmi, should we set a timer then nmi? - smpc_slave_enable(machine,1); + device_set_input_line(state->m_slave, INPUT_LINE_RESET, ASSERT_LINE); // command also asserts slave cpu /* TODO: VDP1 / VDP2 / SCU / SCSP default power ON values */ } @@ -326,7 +328,7 @@ static TIMER_CALLBACK( intback_peripheral ) /* doesn't work? */ //pad_num = state->m_smpc.intback_stage - 1; - if(LOG_PAD_CMD) printf("%d\n",pad_num); + if(LOG_PAD_CMD) printf("%d\n",state->m_smpc.intback_stage - 1); // 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++) @@ -354,9 +356,8 @@ static TIMER_CALLBACK( intback_peripheral ) else state->m_scu.ist |= (IRQ_SMPC); - /* clear hand-shake flag */ - state->m_smpc_ram[0x63] = 0x00; - + state->m_smpc_ram[0x5f] = 0x10; /* callback for last command issued */ + state->m_smpc_ram[0x63] = 0x00; /* clear hand-shake flag */ } static TIMER_CALLBACK( saturn_smpc_intback ) @@ -417,6 +418,7 @@ 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; + state->m_smpc_ram[0x5f] = 0x10; if(!(state->m_scu.ism & IRQ_SMPC)) device_set_input_line_and_vector(state->m_maincpu, 8, HOLD_LINE, 0x47); @@ -551,7 +553,7 @@ WRITE8_HANDLER( stv_SMPC_w ) case 0x02: case 0x03: if(LOG_SMPC) printf ("SMPC: Slave %s\n",(data & 1) ? "off" : "on"); - smpc_slave_enable(space->machine(),(data & 1)); + space->machine().scheduler().timer_set(attotime::from_usec(100), FUNC(smpc_slave_enable),data & 1); break; case 0x06: case 0x07: @@ -598,9 +600,11 @@ WRITE8_HANDLER( stv_SMPC_w ) } // we've processed the command, clear status flag - state->m_smpc_ram[0x5f] = data; //read-back command - if(data != 0x10) + if(data != 0x10 && data != 0x02 && data != 0x03) + { + state->m_smpc_ram[0x5f] = data; //read-back command state->m_smpc_ram[0x63] = 0x00; + } /*TODO:emulate the timing of each command...*/ } } @@ -689,7 +693,7 @@ WRITE8_HANDLER( saturn_SMPC_w ) if(LOG_PAD_CMD) printf("SMPC: CONTINUE request\n"); space->machine().scheduler().timer_set(attotime::from_usec(200), FUNC(intback_peripheral),0); /* TODO: is timing correct? */ state->m_smpc_ram[0x1f] = 0x10; - state->m_smpc_ram[0x63] = 0x01; //TODO: set hand-shake flag? + //state->m_smpc_ram[0x63] = 0x01; //TODO: set hand-shake flag? } } } @@ -731,7 +735,7 @@ WRITE8_HANDLER( saturn_SMPC_w ) case 0x02: case 0x03: if(LOG_SMPC) printf ("SMPC: Slave %s\n",(data & 1) ? "off" : "on"); - smpc_slave_enable(space->machine(),data & 1); + space->machine().scheduler().timer_set(attotime::from_usec(100), FUNC(smpc_slave_enable),data & 1); break; case 0x06: case 0x07: @@ -791,7 +795,7 @@ WRITE8_HANDLER( saturn_SMPC_w ) } // we've processed the command, clear status flag - if(data != 0x10) + if(data != 0x10 && data != 2 && data != 3) { state->m_smpc_ram[0x5f] = data; //read-back for last command issued state->m_smpc_ram[0x63] = 0x00; //clear hand-shake flag diff --git a/src/mame/machine/stvcd.c b/src/mame/machine/stvcd.c index d5f53ab710c..5dfe495e025 100644 --- a/src/mame/machine/stvcd.c +++ b/src/mame/machine/stvcd.c @@ -186,7 +186,7 @@ static int firstfile; // first non-directory file static void cr_standard_return(UINT16 cur_status) { - cr1 = cur_status | 0x00; //options << 4 | repeat & 0xf + cr1 = cur_status | (playtype << 7) | 0x00; //options << 4 | repeat & 0xf cr2 = (cur_track == 0xff) ? 0xffff : (cdrom_get_adr_control(cdrom, cur_track)<<8 | cur_track); cr3 = (0x01<<8) | (cd_curfad>>16); //index & 0xff00 cr4 = cd_curfad; @@ -255,20 +255,29 @@ static void cd_exec_command(running_machine &machine) case 0: // get total session info / disc end cr3 = 0x0100 | tocbuf[(101*4)+1]; cr4 = tocbuf[(101*4)+2]<<8 | tocbuf[(101*4)+3]; + cd_stat = CD_STAT_PAUSE; + cr1 = cd_stat; + cr2 = 0; break; case 1: // get total session info / disc start cr3 = 0x0100; // sessions in high byte, session start in lower cr4 = 0; + cd_stat = CD_STAT_PAUSE; + cr1 = cd_stat; + cr2 = 0; break; default: + /* TODO: Assault Suits Leynos 2 does spurious commands when does read file commands */ mame_printf_error("CD: Unknown request to Get Session Info %x\n", cr1 & 0xff); + cr1 = cd_stat; + cr2 = 0; + cr3 = 0; + cr4 = 0; break; } - cd_stat = CD_STAT_PAUSE; - cr1 = cd_stat; - cr2 = 0; + hirqreg |= (CMOK); break; @@ -290,8 +299,8 @@ static void cd_exec_command(running_machine &machine) in_buffer = 0; buffull = 0; hirqreg &= 0xffe5; + cd_speed = (cr1 & 0x10) ? 1 : 2; } - cd_speed = (cr1 & 0x10) ? 1 : 2; hirqreg |= (CMOK|ESEL); cr_standard_return(cd_stat); @@ -383,7 +392,6 @@ static void cd_exec_command(running_machine &machine) if (!(cr3 & 0x8000)) // preserve current position if bit 7 set { start_pos = ((cr1&0xff)<<16) | cr2; - //fadstoplay = ((cr3&0xff)<<16) | cr4; end_pos = ((cr3&0xff)<<16) | cr4; if (start_pos & 0x800000) @@ -544,12 +552,6 @@ static void cd_exec_command(running_machine &machine) hirqreg |= CMOK|DRDY; break; - case 0x2100: - case 0x2300: - popmessage("%08x %08x",cd_curfad,fadstoplay); - hirqreg |= (CMOK); - break; - case 0x3000: // Set CD Device connection { UINT8 parm; @@ -1155,7 +1157,7 @@ static void cd_exec_command(running_machine &machine) playtype = 1; - hirqreg |= (CMOK); + hirqreg |= (CMOK|EHST); break; @@ -1199,7 +1201,7 @@ TIMER_DEVICE_CALLBACK( stv_sh1_sim ) { sh1_timer->adjust(attotime::from_hz(16667)); - if(cmd_pending) + if(cmd_pending && (!(hirqreg & CMOK))) { cd_exec_command(timer.machine()); return; @@ -1216,8 +1218,7 @@ TIMER_DEVICE_CALLBACK( stv_sector_cb ) //popmessage("%08x %08x %d %d",cd_curfad,fadstoplay,cmd_pending,cd_speed); - if (fadstoplay) - cd_playdata(); + cd_playdata(); if(cdrom_get_track_type(cdrom, cdrom_get_track(cdrom, cd_curfad)) == CD_TRACK_AUDIO) sector_timer->adjust(attotime::from_hz(75)); // 75 sectors / second = 150kBytes/second (cdda track ignores cd_speed setting) @@ -1979,7 +1980,7 @@ static void cd_readTOC(void) tocbuf[tocptr+11] = fad&0xff; } -static partitionT *cd_filterdata(filterT *flt, int trktype) +static partitionT *cd_filterdata(filterT *flt, int trktype, UINT8 *p_ok) { int match = 1, keepgoing = 2; partitionT *filterprt = (partitionT *)NULL; @@ -2057,6 +2058,7 @@ static partitionT *cd_filterdata(filterT *flt, int trktype) // reject sector if no match on either connector if ((lastbuf == 0xff) || (keepgoing < 2)) { + *p_ok = 0; return (partitionT *)NULL; } @@ -2074,6 +2076,7 @@ static partitionT *cd_filterdata(filterT *flt, int trktype) // did the allocation succeed? if (filterprt->blocks[filterprt->numblks] == (blockT *)NULL) { + *p_ok = 0; return (partitionT *)NULL; } @@ -2120,6 +2123,7 @@ static partitionT *cd_filterdata(filterT *flt, int trktype) filterprt->size += filterprt->blocks[filterprt->numblks]->size; filterprt->numblks++; + *p_ok = 1; return filterprt; } @@ -2130,7 +2134,6 @@ static partitionT *cd_read_filtered_sector(INT32 fad, UINT8 *p_ok) if ((cddevice != NULL) && (!buffull)) { - *p_ok = 1; // find out the track's type trktype = cdrom_get_track_type(cdrom, cdrom_get_track(cdrom, fad-150)); @@ -2166,7 +2169,7 @@ static partitionT *cd_read_filtered_sector(INT32 fad, UINT8 *p_ok) } } - return cd_filterdata(cddevice, trktype); + return cd_filterdata(cddevice, trktype, &*p_ok); } *p_ok = 0; diff --git a/src/mame/video/stvvdp2.c b/src/mame/video/stvvdp2.c index c2ad67480fe..1018db3edbc 100644 --- a/src/mame/video/stvvdp2.c +++ b/src/mame/video/stvvdp2.c @@ -5579,10 +5579,13 @@ READ32_HANDLER ( saturn_vdp2_regs_r ) if(!STV_VDP2_EXLTEN) { /* TODO: handle various h/v settings. */ - state->m_vdp2.h_count = space->machine().primary_screen->hpos() & 0x3ff; - state->m_vdp2.v_count = space->machine().primary_screen->vpos() & (STV_VDP2_LSMD == 3 ? 0x7ff : 0x3ff); - /* latch flag */ - state->m_vdp2.exltfg |= 1; + if(!space->debugger_access()) + { + state->m_vdp2.h_count = space->machine().primary_screen->hpos() & 0x3ff; + state->m_vdp2.v_count = space->machine().primary_screen->vpos() & (STV_VDP2_LSMD == 3 ? 0x7ff : 0x3ff); + /* latch flag */ + state->m_vdp2.exltfg |= 1; + } } break; @@ -5868,6 +5871,9 @@ static UINT8 get_odd_bit(running_machine &machine) if(STV_VDP2_HRES & 4) //exclusive monitor mode makes this bit to be always 1 return 1; + if(STV_VDP2_LSMD == 0) // same for non-interlace mode + return 1; + if(cur_v % 2) return 1;