Saturn front panel inputs, nw

This commit is contained in:
Angelo Salese 2011-08-20 22:36:14 +00:00
parent 5a0d918e8f
commit 0ccc767cdb
5 changed files with 214 additions and 34 deletions

View File

@ -896,7 +896,37 @@ static INPUT_CHANGED( key_stroke )
#define SATURN_KEYBOARD PORT_CONDITION("INPUT_TYPE", 0x0f, PORTCOND_EQUALS, 0x05)
static INPUT_CHANGED( nmi_reset )
{
saturn_state *state = field.machine().driver_data<saturn_state>();
/* TODO: correct? */
if(!state->m_NMI_reset)
return;
/* TODO: NMI doesn't stay held on SH-2 core so we can't use ASSERT_LINE/CLEAR_LINE with that yet */
if(newval)
device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, PULSE_LINE);
}
static INPUT_CHANGED( tray_open )
{
if(newval)
stvcd_set_tray_open(field.machine());
}
static INPUT_CHANGED( tray_close )
{
if(newval)
stvcd_set_tray_close(field.machine());
}
static INPUT_PORTS_START( saturn )
PORT_START("RESET") /* hardwired buttons */
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_CHANGED(nmi_reset,0) PORT_NAME("Reset Button")
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_CHANGED(tray_open,0) PORT_NAME("Tray Open Button")
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_CHANGED(tray_close,0) PORT_NAME("Tray Close")
PORT_START("JOY1")
SATURN_PAD_P1(0x0f, 0)

View File

@ -271,7 +271,7 @@ static TIMER_CALLBACK( smpc_change_clock )
state->m_vdp2.dotsel = param ^ 1;
stv_vdp2_dynamic_res_change(machine);
if(state->m_NMI_reset)
if(!state->m_NMI_reset)
device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, PULSE_LINE);
device_set_input_line(state->m_slave, INPUT_LINE_RESET, ASSERT_LINE);
@ -616,8 +616,8 @@ static void smpc_nmi_set(running_machine &machine,UINT8 cmd)
{
saturn_state *state = machine.driver_data<saturn_state>();
state->m_NMI_reset = cmd ^ 1;
state->m_smpc.OREG[0] = (0x80) | ((state->m_NMI_reset & 1) << 6);
state->m_NMI_reset = cmd;
//state->m_smpc.OREG[0] = (0x80) | ((state->m_NMI_reset & 1) << 6);
}
@ -670,7 +670,7 @@ static void smpc_comreg_exec(address_space *space, UINT8 data, UINT8 is_stv)
break;
/*"Interrupt Back"*/
case 0x10:
if(LOG_SMPC)
if(0)
{
saturn_state *state = space->machine().driver_data<saturn_state>();
printf ("SMPC: Status Acquire %02x %02x %02x %d\n",state->m_smpc.IREG[0],state->m_smpc.IREG[1],state->m_smpc.IREG[2],space->machine().primary_screen->vpos());

View File

@ -27,6 +27,7 @@
#include "stvcd.h"
#include "sound/cdda.h"
#include "debugger.h"
#include "coreutil.h"
// super-verbose
#if 0
@ -105,7 +106,9 @@ typedef enum
XFERTYPE_INVALID,
XFERTYPE_TOC,
XFERTYPE_FILEINFO_1,
XFERTYPE_FILEINFO_254
XFERTYPE_FILEINFO_254,
XFERTYPE_SUBQ,
XFERTYPE_SUBRW
} transT;
// 32-bit transfer types
@ -126,6 +129,8 @@ static blockT blocks[MAX_BLOCKS];
static blockT curblock;
static UINT8 tocbuf[102*4];
static UINT8 subqbuf[5*2];
static UINT8 subrwbuf[12*2];
static UINT8 finfbuf[256];
static INT32 sectlenin, sectlenout;
@ -154,6 +159,7 @@ static UINT8 cmd_pending;
static UINT8 cd_speed;
static UINT8 cdda_maxrepeat;
static UINT8 cdda_repeat_count;
static UINT8 tray_is_closed;
// iso9660 utilities
static void read_new_dir(running_machine &machine, UINT32 fileno);
@ -198,11 +204,30 @@ static int firstfile; // first non-directory file
#define CD_STAT_WAIT 0x8000 // waiting for command if set, else executed immediately
#define CD_STAT_REJECT 0xff00 // ultra-fatal error.
/* FIXME: assume Saturn CD-ROMs to have a 2 secs pre-gap for now. */
static int get_track_index(void)
{
UINT32 rel_fad;
UINT8 track;
if(cdrom_get_track_type(cdrom, cdrom_get_track(cdrom, cd_curfad)) != CD_TRACK_AUDIO)
return 1;
track = cdrom_get_track( cdrom, cd_curfad );
rel_fad = cd_curfad - cdrom_get_track_start( cdrom, track );
if(rel_fad < 150)
return 0;
return 1;
}
static void cr_standard_return(UINT16 cur_status)
{
cr1 = cur_status | (playtype << 7) | 0x00 | (cdda_repeat_count & 0xf); //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
cr2 = (cur_track == 0xff) ? 0xffff : (cdrom_get_adr_control(cdrom, cur_track)<<8 | cur_track); // TODO: fix current track
cr3 = (get_track_index()<<8) | (cd_curfad>>16); //index & 0xff00
cr4 = cd_curfad;
}
@ -214,17 +239,6 @@ static void cd_exec_command(running_machine &machine)
{
UINT32 temp;
if (!cdrom)
{
cd_stat = CD_STAT_OPEN;
cr1 = cd_stat | 0xff;
cr2 = 0xffff;
cr3 = 0xffff;
cr4 = 0xffff;
hirqreg |= CMOK;
return;
}
if(cr1 != 0 && ((cr1 & 0xff00) != 0x5100) && 1)
printf("CD: command exec %04x %04x %04x %04x %04x (stat %04x)\n", hirqreg, cr1, cr2, cr3, cr4, cd_stat);
@ -305,11 +319,13 @@ static void cd_exec_command(running_machine &machine)
CDROM_LOG(("%s:CD: Initialize CD system\n", machine.describe_context()))
if((cr1 & 0x81) == 0x00) //guess
{
//int i;
cd_stat = CD_STAT_PAUSE;
cd_curfad = 150;
//cur_track = 1;
fadstoplay = 0;
if(cd_stat != CD_STAT_NODISC && cd_stat != CD_STAT_OPEN)
{
cd_stat = CD_STAT_PAUSE;
cd_curfad = 150;
//cur_track = 1;
fadstoplay = 0;
}
in_buffer = 0;
buffull = 0;
hirqreg &= 0xffe5;
@ -585,13 +601,51 @@ static void cd_exec_command(running_machine &machine)
switch(cr1 & 0xff)
{
case 0: // Get Q
{
UINT32 msf_abs,msf_rel;
UINT8 track;
cr1 = cd_stat | 0;
cr2 = 5;
cr2 = 10/2;
cr3 = 0;
cr4 = 0;
// ...
break;
/*
Subcode Q info should be:
---- --x- S0
---- ---x S1
xxxx ---- [0] Control (bit 7 Pre-emphasis, bit 6: copy permitted, bit 5 undefined, bit 4 number of channels)
---- xxxx [0] address (0x0001 Mode 1)
xxxx xxxx [1] track number (1-99, AA lead-out), BCD format
xxxx xxxx [2] index (01 lead-out), BCD format
xxxx xxxx [3] Time within' track M
xxxx xxxx [4] Time within' track S
xxxx xxxx [5] Time within' track F
xxxx xxxx [6] Zero
xxxx xxxx [7] Absolute M
xxxx xxxx [8] Absolute S
xxxx xxxx [9] Absolute F
xxxx xxxx [10] CRCC
xxxx xxxx [11] CRCC
*/
msf_abs = lba_to_msf_alt( cd_curfad - 150 );
track = cdrom_get_track( cdrom, cd_curfad );
msf_rel = lba_to_msf_alt( cd_curfad - 150 - cdrom_get_track_start( cdrom, track ) );
xfertype = XFERTYPE_SUBQ;
xfercount = 0;
subqbuf[0] = 0x01 | ((cdrom_get_track_type(cdrom, cdrom_get_track(cdrom, track+1)) == CD_TRACK_AUDIO) ? 0x00 : 0x40);
subqbuf[1] = dec_2_bcd(track+1);
subqbuf[2] = dec_2_bcd(get_track_index());
subqbuf[3] = dec_2_bcd((msf_rel >> 16) & 0xff);
subqbuf[4] = dec_2_bcd((msf_rel >> 8) & 0xff);
subqbuf[5] = dec_2_bcd((msf_rel >> 0) & 0xff);
subqbuf[6] = 0;
subqbuf[7] = dec_2_bcd((msf_abs >> 16) & 0xff);
subqbuf[8] = dec_2_bcd((msf_abs >> 8) & 0xff);
subqbuf[9] = dec_2_bcd((msf_abs >> 0) & 0xff);
}
break;
case 1: // Get RW
cr1 = cd_stat | 0;
@ -599,7 +653,16 @@ static void cd_exec_command(running_machine &machine)
cr3 = 0;
cr4 = 0;
// ...
xfertype = XFERTYPE_SUBRW;
xfercount = 0;
/* return null data for now */
{
int i;
for(i=0;i<12*2;i++)
subrwbuf[i] = 0;
}
break;
}
hirqreg |= CMOK|DRDY;
@ -1282,13 +1345,15 @@ static void cd_exec_command(running_machine &machine)
sectorstore = 0;
xfertype32 = XFERTYPE32_INVALID;
xferdnum = 0;
cd_stat = CD_STAT_PAUSE; // force to pause
if(cd_stat != CD_STAT_NODISC && cd_stat != CD_STAT_OPEN)
cd_stat = CD_STAT_PAUSE; // force to pause
cr_standard_return(cd_stat);
break;
case 0xe000: // appears to be copy protection check. needs only to return OK.
CDROM_LOG(("%s:CD: Verify copy protection\n", machine.describe_context()))
cd_stat = CD_STAT_PAUSE;
if(cd_stat != CD_STAT_NODISC && cd_stat != CD_STAT_OPEN)
cd_stat = CD_STAT_PAUSE;
cr1 = cd_stat; // necessary to pass
cr2 = 0x4;
// hirqreg |= (CMOK|EFLS|CSCT);
@ -1298,7 +1363,8 @@ static void cd_exec_command(running_machine &machine)
case 0xe100: // get disc region
CDROM_LOG(("%s:CD: Get disc region\n", machine.describe_context()))
cd_stat = CD_STAT_PAUSE;
if(cd_stat != CD_STAT_NODISC && cd_stat != CD_STAT_OPEN)
cd_stat = CD_STAT_PAUSE;
cr1 = cd_stat; // necessary to pass
cr2 = 0x4; // (must return this value to pass bios checks)
hirqreg |= (CMOK);
@ -1322,8 +1388,11 @@ TIMER_DEVICE_CALLBACK( stv_sh1_sim )
}
cd_stat |= CD_STAT_PERI;
if(cd_stat != CD_STAT_NODISC && cd_stat != CD_STAT_OPEN)
hirqreg |= SCDQ;
cr_standard_return(cd_stat);
hirqreg |= SCDQ;
}
TIMER_DEVICE_CALLBACK( stv_sector_cb )
@ -1412,11 +1481,12 @@ void stvcd_reset(running_machine &machine)
}
else
{
cd_stat = CD_STAT_OPEN;
cd_stat = CD_STAT_NODISC;
}
cd_speed = 2;
cdda_repeat_count = 0;
tray_is_closed = 1;
sector_timer = machine.device<timer_device>("sector_timer");
sector_timer->adjust(attotime::from_hz(150)); // 150 sectors / second = 300kBytes/second
@ -1624,8 +1694,35 @@ static UINT16 cd_readWord(UINT32 addr)
}
break;
case XFERTYPE_SUBQ:
rv = subqbuf[xfercount]<<8 | subqbuf[xfercount+1];
xfercount += 2;
xferdnum += 2;
if (xfercount > 5*2)
{
xfercount = 0;
xfertype = XFERTYPE_INVALID;
}
break;
case XFERTYPE_SUBRW:
rv = subrwbuf[xfercount]<<8 | subrwbuf[xfercount+1];
xfercount += 2;
xferdnum += 2;
if (xfercount > 12*2)
{
xfercount = 0;
xfertype = XFERTYPE_INVALID;
}
break;
default:
CDROM_LOG(("STVCD: Unhandled xfer type %d\n", (int)xfertype))
printf("STVCD: Unhandled xfer type %d\n", (int)xfertype);
rv = 0;
break;
}
@ -1700,7 +1797,7 @@ static UINT32 cd_readLong(UINT32 addr)
break;
default:
CDROM_LOG(("CD: unhandled 32-bit transfer type\n"))
printf("CD: unhandled 32-bit transfer type\n");
break;
}
@ -2407,4 +2504,50 @@ static void cd_readblock(UINT32 fad, UINT8 *dat)
}
}
void stvcd_set_tray_open(running_machine &machine)
{
if(!tray_is_closed)
return;
hirqreg |= DCHG;
cd_stat = CD_STAT_OPEN;
cdrom = (cdrom_file *)NULL;
tray_is_closed = 0;
popmessage("Tray Open");
}
void stvcd_set_tray_close(running_machine &machine)
{
/* avoid user attempts to load a CD-ROM without opening the tray first (emulation asserts anyway with current framework) */
if(tray_is_closed)
return;
hirqreg |= DCHG;
#ifdef MESS
cdrom = machine.device<cdrom_image_device>("cdrom")->get_cdrom_file();
#else
cdrom = cdrom_open(get_disk_handle(machine, "cdrom"));
#endif
cdda_set_cdrom( machine.device("cdda"), cdrom );
if (cdrom)
{
CDROM_LOG(("Opened CD-ROM successfully, reading root directory\n"))
//read_new_dir(machine, 0xffffff); // read root directory
cd_stat = CD_STAT_PAUSE;
}
else
{
cd_stat = CD_STAT_NODISC;
}
cd_speed = 2;
cdda_repeat_count = 0;
tray_is_closed = 1;
popmessage("Tray Close");
}

View File

@ -18,4 +18,7 @@ TIMER_DEVICE_CALLBACK( stv_sh1_sim );
READ32_HANDLER( stvcd_r );
WRITE32_HANDLER( stvcd_w );
void stvcd_set_tray_open(running_machine &machine);
void stvcd_set_tray_close(running_machine &machine);
#endif

View File

@ -4325,6 +4325,9 @@ static void stv_vdp2_check_tilemap(running_machine &machine, bitmap_t *bitmap, c
{
if(stv2_current_tilemap.colour_depth == 2 && !stv2_current_tilemap.bitmap_enable)
popmessage("2048 color mode used on a non-bitmap plane");
/* Pukunpa */
//if(STV_VDP2_SPWINEN)
// popmessage("Sprite Window enabled");
@ -7296,6 +7299,7 @@ static void draw_normal_screen(running_machine &machine, bitmap_t *bitmap,const
int x,y;
int r,g,b;
for(y=0;y<=cliprect->max_y;y++)
{
for(x=0;x<=cliprect->max_x;x++)