saturn.cpp: Add Korean BIOS placeholder (#8608)

* saturn.cpp: add Korean BIOS placeholder, refactored init routines, add enumerator for regions

* hash/saturn.xml: marked all Korean set with NTSC-K, also part I of SW list QA overhaul

* stvcd.cpp: guard against deleting partial sectors in cmd_delete_sector_data, fixes pstarcol Phantasy Star 2 crash after first attract cycle

* smpc.cpp: NMI is unconditionally requested for screen clock change commands, fixes booting in bigichig, capgen1, capgen4, capgen5

* stvcd.cpp: add fixed status for NetLink, allow dragndrm to actually boot (on -non drc)

* stvcd.cpp: fix clang build, put another QA point for Dragon's Dream

* More QA up to J
This commit is contained in:
Angelo Salese 2021-09-25 14:56:19 +02:00 committed by GitHub
parent 71e5e67ef1
commit e2331a7eed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 351 additions and 216 deletions

File diff suppressed because it is too large Load Diff

View File

@ -594,11 +594,17 @@ void smpc_hle_device::device_timer(emu_timer &timer, device_timer_id id, int par
// ...
m_command_in_progress = false;
m_oreg[31] = m_comreg;
sf_ack(true); //clear hand-shake flag (TODO: diagnostic wants this to have bit 3 high)
// TODO: diagnostic also wants this to have bit 3 high
sf_ack(true); //set hand-shake flag
return;
// case 0x0a: // NETLINKON
// case 0x0b: // NETLINKOFF
case 0x0a: // NETLINKON
// TODO: understand where NetLink actually lies and implement delegation accordingly
// (is it really an SH1 device like suggested by the space access or it overlays on CS2 bus?)
popmessage("%s: NetLink enabled", this->tag());
[[fallthrough]];
case 0x0b: // NETLINKOFF
break;
case 0x0d: // SYSRES
// send a 1 -> 0 to device reset lines
@ -614,10 +620,6 @@ void smpc_hle_device::device_timer(emu_timer &timer, device_timer_id id, int par
case 0x0f: // CKCHG320
m_dotsel(m_comreg & 1);
// send a NMI to Master SH2 if enabled
if(m_NMI_reset == false)
master_sh2_nmi();
// assert Slave SH2 line
m_sshres(1);
// clear PLL system halt
@ -625,6 +627,12 @@ void smpc_hle_device::device_timer(emu_timer &timer, device_timer_id id, int par
// setup the new dot select
m_cur_dotsel = (m_comreg & 1) ^ 1;
// send a NMI to Master SH2 if enabled
// it is unconditionally requested:
// bigichig, capgen1, capgen4 and capgen5 triggers a SLEEP opcode from BIOS call and expects this to wake them up.
//if(m_NMI_reset == false)
master_sh2_nmi();
break;
case 0x10: // INTBACK
@ -659,7 +667,7 @@ void smpc_hle_device::device_timer(emu_timer &timer, device_timer_id id, int par
break;
default:
logerror("%s unemulated %02x command\n",this->tag(),m_comreg);
logerror("%s: unemulated %02x command\n",this->tag(),m_comreg);
return;
}

View File

@ -135,6 +135,10 @@ void stvcd_device::io_regs(address_map &map)
map(0x9001c, 0x9001f).mirror(0x08000).rw(FUNC(stvcd_device::cr2_r), FUNC(stvcd_device::cr2_w)).umask32(0xffffffff);
map(0x90020, 0x90023).mirror(0x08000).rw(FUNC(stvcd_device::cr3_r), FUNC(stvcd_device::cr3_w)).umask32(0xffffffff);
map(0x90024, 0x90027).mirror(0x08000).rw(FUNC(stvcd_device::cr4_r), FUNC(stvcd_device::cr4_w)).umask32(0xffffffff);
// NetLink access
// dragndrm expects this value, most likely for status
map(0x8502a, 0x8502a).lr8(NAME([] () -> u8 { return 0x11; }));
}
u32 stvcd_device::datatrns_r(offs_t offset, uint32_t mem_mask)
@ -221,14 +225,14 @@ inline u32 stvcd_device::dataxfer_long_r()
transpart->size -= xferdnum;
transpart->numblks -= xfersectnum;
/* TODO: is this correct? */
// TODO: is this correct?
xfertype32 = XFERTYPE32_INVALID;
}
}
break;
default:
osd_printf_error("CD: unhandled 32-bit transfer type\n");
osd_printf_error("CD: unhandled 32-bit transfer type %d\n", (int)xfertype32);
break;
}
@ -269,7 +273,7 @@ inline void stvcd_device::dataxfer_long_w(u32 data)
break;
default:
printf("CD: unhandled 32-bit transfer type write\n");
printf("CD: unhandled 32-bit transfer type write %d\n", (int)xfertype32);
break;
}
}
@ -462,7 +466,9 @@ void stvcd_device::stvcd_w(offs_t offset, uint32_t data, uint32_t mem_mask)
*/
int stvcd_device::get_timing_command(void)
{
/* TODO: calculate timings based off command params */
// TODO: calculate timings based off command params
// given the CMOK returns it looks like SH2 expects way slower responses
// (loops for 0x7xx times at most, max number of iterations is 0x240000)
return 16667;
}
@ -769,7 +775,7 @@ void stvcd_device::cmd_play_disc()
}
else
{
/* TODO: Waku Waku 7 sets up track 0, that basically doesn't make any sense. Just skip it for now. */
// FIXME: Waku Waku 7 sets up track 0, that basically doesn't make any sense. Just skip it for now.
popmessage("Warning: track mode == 0, contact MAMEdev");
cr_standard_return(cd_stat);
hirqreg |= (CMOK);
@ -814,9 +820,12 @@ void stvcd_device::cmd_play_disc()
else
{
/* resume from a pause state */
/* TODO: Galaxy Fight calls 10ff ffff ffff ffff, but then it calls 0x04->0x02->0x06->0x11->0x04->0x02->0x06 command sequence
(and current implementation nukes start/end FAD addresses at 0x04). I'm sure that this doesn't work like this, but there could
be countless possible combinations ... */
// FIXME: verify implementation with Galaxy Fight
// it calls 10ff ffff ffff ffff, but then it follows up with
// 0x04->0x02->0x06->0x11->0x04->0x02->0x06 command sequence
// (and current implementation nukes start/end FAD addresses at 0x04).
// I'm sure that this doesn't work like this, but there could
// be countless possible combinations ...
if(fadstoplay == 0)
{
cd_curfad = cdrom_get_track_start(cdrom, cur_track-1);
@ -1130,7 +1139,8 @@ void stvcd_device::cmd_get_filter_mode()
void stvcd_device::cmd_set_filter_connection()
{
// Set Filter Connection
/* TODO: maybe condition false is cr3 low? */
// FIXME: verify usage of cr3 LSB
// (false condition?)
uint8_t fnum = (cr3>>8)&0xff;
LOG("%s:CD: Set Filter Connection %x => mode %x parm %04x\n", machine().describe_context(), fnum, cr1 & 0xf, cr2);
@ -1181,7 +1191,7 @@ void stvcd_device::cmd_reset_selector()
}
/* reset false filter output conditions */
/* TODO: check these two. */
/// TODO: verify default value for these two
if(cr1 & 0x80)
{
for(i=0;i<MAX_FILTERS;i++)
@ -1396,8 +1406,9 @@ void stvcd_device::cmd_get_sector_data()
if (bufnum >= MAX_FILTERS)
{
// TODO: find actual SW that does this
// (may conceal a bigger issue)
osd_printf_error("CD: invalid buffer number\n");
/* TODO: why this is happening? */
cr_standard_return(CD_STAT_REJECT);
hirqreg |= (CMOK|EHST);
return;
@ -1439,14 +1450,15 @@ void stvcd_device::cmd_delete_sector_data()
if (bufnum >= MAX_FILTERS)
{
// TODO: mustn't happen
osd_printf_error("CD: invalid buffer number\n");
/* TODO: why this is happening? */
cr_standard_return(CD_STAT_REJECT);
hirqreg |= (CMOK|EHST);
return;
}
/* TODO: Phantasy Star 2 throws this one. */
// pstarcol PS2 does this
// TODO: verify if implementation is correct
if (partitions[bufnum].numblks == 0)
{
osd_printf_error("CD: buffer is already empty\n");
@ -1459,10 +1471,15 @@ void stvcd_device::cmd_delete_sector_data()
for (i = sectofs; i < (sectofs + sectnum); i++)
{
partitions[bufnum].size -= partitions[bufnum].blocks[i]->size;
cd_free_block(partitions[bufnum].blocks[i]);
partitions[bufnum].blocks[i] = (blockT *)nullptr;
partitions[bufnum].bnum[i] = 0xff;
// pstarcol PS2 tries to delete partial partitions,
// need to guard against it (otherwise it would crash after first attract cycle)
if (partitions[bufnum].size > 0)
{
partitions[bufnum].size -= partitions[bufnum].blocks[i]->size;
cd_free_block(partitions[bufnum].blocks[i]);
partitions[bufnum].blocks[i] = (blockT *)nullptr;
partitions[bufnum].bnum[i] = 0xff;
}
}
cd_defragblocks(&partitions[bufnum]);
@ -1492,14 +1509,15 @@ void stvcd_device::cmd_get_and_delete_sector_data()
if (bufnum >= MAX_FILTERS)
{
// TODO: mustn't happen
osd_printf_error("CD: invalid buffer number\n");
/* TODO: why this is happening? */
cr_standard_return(CD_STAT_REJECT);
hirqreg |= (CMOK|EHST);
return;
}
/* Yoshimoto Mahjong uses the REJECT status to verify when the data is ready. */
// TODO: verify again if it's really REJECT or something else
if (partitions[bufnum].numblks < sectnum)
{
osd_printf_error("CD: buffer is not full %08x %08x\n",partitions[bufnum].numblks,sectnum);
@ -1708,7 +1726,11 @@ void stvcd_device::cmd_get_target_file_info()
cr3 = 0;
cr4 = 0;
printf("%08x %08x\n",curdir[temp].firstfad,curdir[temp].length);
// TODO: chaossd and sengblad does this
// (iso9660 parsing doesn't read beyond the first sector)
if (curdir[temp].firstfad == 0 || curdir[temp].length == 0)
throw emu_fatalerror("File ID not found in XFERTYPE_FILEINFO_1");
// printf("%08x %08x\n",curdir[temp].firstfad,curdir[temp].length);
// first 4 bytes = FAD
finfbuf[0] = (curdir[temp].firstfad>>24)&0xff;
finfbuf[1] = (curdir[temp].firstfad>>16)&0xff;
@ -1724,6 +1746,7 @@ void stvcd_device::cmd_get_target_file_info()
finfbuf[10] = temp;
finfbuf[11] = curdir[temp].flags;
xfertype = XFERTYPE_FILEINFO_1;
xfercount = 0;
}
@ -1988,8 +2011,9 @@ TIMER_DEVICE_CALLBACK_MEMBER( stvcd_device::stv_sector_cb )
else
m_sector_timer->adjust(attotime::from_hz(75*cd_speed)); // 75 / 150 sectors / second = 150 / 300kBytes/second
/* TODO: doesn't boot if a disk isn't in? */
/* TODO: Check out when this really happens. (Daytona USA original version definitely wants it to be on).*/
// TODO: Saturn refuses to boot with this if a disk isn't in and condition is applied!?
// TODO: Check out actual timing of SCDQ acquisition.
// (Daytona USA original version definitely wants it to be on).
//if(((cd_stat & 0x0f00) != CD_STAT_NODISC) && ((cd_stat & 0x0f00) != CD_STAT_OPEN))
hirqreg |= SCDQ;

View File

@ -463,26 +463,50 @@ public:
void saturnjp(machine_config &config);
void saturneu(machine_config &config);
void saturnus(machine_config &config);
void saturnkr(machine_config &config);
void init_saturnus();
void init_saturneu();
void init_saturnjp();
template <bool is_pal> void init_saturn();
DECLARE_INPUT_CHANGED_MEMBER(tray_open);
DECLARE_INPUT_CHANGED_MEMBER(tray_close);
private:
DECLARE_MACHINE_START(saturn);
DECLARE_MACHINE_RESET(saturn);
// SMPC region codes, hardwired via jumper setting.
// - Given the scheme bit 3 should determine if the region is PAL or NTSC.
// - 0 and F are "prohibited", others are "Sega reserved".
// - Documentation states that 2 is "TAIWAN" and 6 is "KOREA",
// but games on latter definitely wants 2 rather than 6.
// We currently swap, former actual slot needs to be confirmed.
enum {
REGION_NTSC_0 = 0,
REGION_NTSC_JAPAN,
// REGION_NTSC_TAIWAN,
REGION_NTSC_KOREA,
REGION_NTSC_3,
REGION_NTSC_USA, // & Canada, Mexico
REGION_NTSC_BRAZIL,
// REGION_NTSC_KOREA,
REGION_NTSC_TAIWAN, // & Philippines
REGION_NTSC_7,
REGION_PAL_8,
REGION_PAL_9,
REGION_PAL_ASIA, // China, Middle East, East Asia not covered above
REGION_PAL_B,
REGION_PAL_EUROPE, // Australia, South Africa
REGION_PAL_AMERICA, // Non-NTSC Central/South America
REGION_PAL_E,
REGION_PAL_F
};
uint8_t saturn_cart_type_r();
uint32_t abus_dummy_r(offs_t offset);
uint32_t saturn_null_ram_r();
void saturn_null_ram_w(uint32_t data);
void saturn_init_driver(int rgn);
uint8_t saturn_pdr1_direct_r();
uint8_t saturn_pdr2_direct_r();
void saturn_pdr1_direct_w(uint8_t data);
@ -548,7 +572,7 @@ void sat_console_state::saturn_mem(address_map &map)
map(0x05f80000, 0x05fbffff).rw(FUNC(sat_console_state::saturn_vdp2_regs_r), FUNC(sat_console_state::saturn_vdp2_regs_w));
map(0x05fe0000, 0x05fe00cf).m(m_scu, FUNC(sega_scu_device::regs_map)); //rw(FUNC(sat_console_state::saturn_scu_r), FUNC(sat_console_state::saturn_scu_w));
map(0x06000000, 0x060fffff).ram().mirror(0x21f00000).share("workram_h");
map(0x45000000, 0x46ffffff).nopw();
map(0x40000000, 0x46ffffff).nopw(); // associative purge page
map(0x60000000, 0x600003ff).nopw(); // cache address array
map(0xc0000000, 0xc0000fff).ram(); // cache data array, Dragon Ball Z sprites relies on this
}
@ -884,7 +908,7 @@ void sat_console_state::saturnus(machine_config &config)
SATURN_CART_SLOT(config, "exp", saturn_cart, nullptr);
SOFTWARE_LIST(config, "cart_list").set_original("sat_cart");
m_smpc_hle->set_region_code(4);
m_smpc_hle->set_region_code(REGION_NTSC_USA);
}
void sat_console_state::saturneu(machine_config &config)
@ -897,7 +921,7 @@ void sat_console_state::saturneu(machine_config &config)
SATURN_CART_SLOT(config, "exp", saturn_cart, nullptr);
SOFTWARE_LIST(config, "cart_list").set_original("sat_cart");
m_smpc_hle->set_region_code(12);
m_smpc_hle->set_region_code(REGION_PAL_EUROPE);
}
void sat_console_state::saturnjp(machine_config &config)
@ -910,13 +934,27 @@ void sat_console_state::saturnjp(machine_config &config)
SATURN_CART_SLOT(config, "exp", saturn_cart, nullptr);
SOFTWARE_LIST(config, "cart_list").set_original("sat_cart");
m_smpc_hle->set_region_code(1);
m_smpc_hle->set_region_code(REGION_NTSC_JAPAN);
}
void sat_console_state::saturnkr(machine_config &config)
{
saturn(config);
SATURN_CDB(config, "saturn_cdb", 16000000);
SOFTWARE_LIST(config, "cd_list").set_original("saturn").set_filter("NTSC-K");
SATURN_CART_SLOT(config, "exp", saturn_cart, nullptr);
SOFTWARE_LIST(config, "cart_list").set_original("sat_cart");
m_smpc_hle->set_region_code(REGION_NTSC_KOREA);
}
void sat_console_state::saturn_init_driver(int rgn)
template <bool is_pal> void sat_console_state::init_saturn()
{
m_vdp2.pal = (rgn == 12) ? 1 : 0;
// TODO: setter for (missing) VDP2 device
m_vdp2.pal = is_pal;
// set compatible options
m_maincpu->sh2drc_set_options(SH2DRC_STRICT_VERIFY|SH2DRC_STRICT_PCREL);
@ -939,25 +977,8 @@ void sat_console_state::saturn_init_driver(int rgn)
m_backupram = make_unique_clear<uint8_t[]>(0x8000);
}
void sat_console_state::init_saturnus()
{
saturn_init_driver(4);
}
void sat_console_state::init_saturneu()
{
saturn_init_driver(12);
}
void sat_console_state::init_saturnjp()
{
saturn_init_driver(1);
}
/* Japanese Saturn */
ROM_START(saturnjp)
ROM_REGION32_BE( 0x80000, "bios", ROMREGION_ERASEFF ) /* SH2 code */
ROM_START( saturnjp )
ROM_REGION32_BE( 0x80000, "bios", ROMREGION_ERASEFF )
ROM_SYSTEM_BIOS(0, "101", "Japan v1.01 (941228)")
ROMX_LOAD("sega_101.bin", 0x00000000, 0x00080000, CRC(224b752c) SHA1(df94c5b4d47eb3cc404d88b33a8fda237eaf4720), ROM_BIOS(0))
ROM_SYSTEM_BIOS(1, "1003", "Japan v1.003 (941012)")
@ -966,9 +987,8 @@ ROM_START(saturnjp)
ROMX_LOAD("sega_100.bin", 0x00000000, 0x00080000, CRC(2aba43c2) SHA1(2b8cb4f87580683eb4d760e4ed210813d667f0a2), ROM_BIOS(2))
ROM_END
/* Overseas Saturn */
ROM_START(saturn)
ROM_REGION32_BE( 0x80000, "bios", ROMREGION_ERASEFF ) /* SH2 code */
ROM_START( saturn )
ROM_REGION32_BE( 0x80000, "bios", ROMREGION_ERASEFF )
ROM_SYSTEM_BIOS(0, "101a", "Overseas v1.01a (941115)")
/* Confirmed by ElBarto */
ROMX_LOAD("mpr-17933.bin", 0x00000000, 0x00080000, CRC(4afcf0fa) SHA1(faa8ea183a6d7bbe5d4e03bb1332519800d3fbc3), ROM_BIOS(0))
@ -976,8 +996,8 @@ ROM_START(saturn)
ROMX_LOAD("sega_100a.bin", 0x00000000, 0x00080000, CRC(f90f0089) SHA1(3bb41feb82838ab9a35601ac666de5aacfd17a58), ROM_BIOS(1))
ROM_END
ROM_START(saturneu)
ROM_REGION32_BE( 0x80000, "bios", ROMREGION_ERASEFF ) /* SH2 code */
ROM_START( saturneu )
ROM_REGION32_BE( 0x80000, "bios", ROMREGION_ERASEFF )
ROM_SYSTEM_BIOS(0, "101a", "Overseas v1.01a (941115)")
/* Confirmed by ElBarto */
ROMX_LOAD("mpr-17933.bin", 0x00000000, 0x00080000, CRC(4afcf0fa) SHA1(faa8ea183a6d7bbe5d4e03bb1332519800d3fbc3), ROM_BIOS(0))
@ -985,13 +1005,20 @@ ROM_START(saturneu)
ROMX_LOAD("sega_100a.bin", 0x00000000, 0x00080000, CRC(f90f0089) SHA1(3bb41feb82838ab9a35601ac666de5aacfd17a58), ROM_BIOS(1))
ROM_END
ROM_START(vsaturn)
ROM_REGION32_BE( 0x80000, "bios", ROMREGION_ERASEFF ) /* SH2 code */
ROM_START( saturnkr )
ROM_REGION32_BE( 0x80000, "bios", ROMREGION_ERASEFF )
// undumped, uses Japanese VA1 motherboard with v1.02a BIOS rev,
// with extra checks for region jumpers that disables Japanese language if setting matches '2' (no Korea option tho)
ROM_LOAD("sega_101.bin", 0x00000000, 0x00080000, BAD_DUMP CRC(224b752c) SHA1(df94c5b4d47eb3cc404d88b33a8fda237eaf4720) )
ROM_END
ROM_START( vsaturn )
ROM_REGION32_BE( 0x80000, "bios", ROMREGION_ERASEFF )
ROM_LOAD("vsaturn.bin", 0x00000000, 0x00080000, CRC(e4d61811) SHA1(4154e11959f3d5639b11d7902b3a393a99fb5776))
ROM_END
ROM_START(hisaturn)
ROM_REGION32_BE( 0x80000, "bios", ROMREGION_ERASEFF ) /* SH2 code */
ROM_START( hisaturn )
ROM_REGION32_BE( 0x80000, "bios", ROMREGION_ERASEFF )
ROM_SYSTEM_BIOS(0, "102", "v1.02 (950519)")
ROMX_LOAD("mpr-18100.bin", 0x000000, 0x080000, CRC(3408dbf4) SHA1(8a22710e09ce75f39625894366cafe503ed1942d), ROM_BIOS(0))
ROM_SYSTEM_BIOS(1, "101", "v1.01 (950130)")
@ -999,8 +1026,9 @@ ROM_START(hisaturn)
ROM_END
/* YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS */
CONS( 1994, saturn, 0, 0, saturnus, saturn, sat_console_state, init_saturnus, "Sega", "Saturn (USA)", MACHINE_NOT_WORKING )
CONS( 1994, saturnjp, saturn, 0, saturnjp, saturn, sat_console_state, init_saturnjp, "Sega", "Saturn (Japan)", MACHINE_NOT_WORKING )
CONS( 1994, saturneu, saturn, 0, saturneu, saturn, sat_console_state, init_saturneu, "Sega", "Saturn (PAL)", MACHINE_NOT_WORKING )
CONS( 1995, vsaturn, saturn, 0, saturnjp, saturn, sat_console_state, init_saturnjp, "JVC", "V-Saturn", MACHINE_NOT_WORKING )
CONS( 1995, hisaturn, saturn, 0, saturnjp, saturn, sat_console_state, init_saturnjp, "Hitachi", "HiSaturn", MACHINE_NOT_WORKING )
CONS( 1994, saturn, 0, 0, saturnus, saturn, sat_console_state, init_saturn<false>, "Sega", "Saturn (USA)", MACHINE_NOT_WORKING )
CONS( 1994, saturnjp, saturn, 0, saturnjp, saturn, sat_console_state, init_saturn<false>, "Sega", "Saturn (Japan)", MACHINE_NOT_WORKING )
CONS( 1994, saturneu, saturn, 0, saturneu, saturn, sat_console_state, init_saturn<true>, "Sega", "Saturn (PAL)", MACHINE_NOT_WORKING )
CONS( 1995, saturnkr, saturn, 0, saturnkr, saturn, sat_console_state, init_saturn<false>, "Samsung", "Saturn (Korea)", MACHINE_NOT_WORKING )
CONS( 1995, vsaturn, saturn, 0, saturnjp, saturn, sat_console_state, init_saturn<false>, "JVC", "V-Saturn", MACHINE_NOT_WORKING )
CONS( 1995, hisaturn, saturn, 0, saturnjp, saturn, sat_console_state, init_saturn<false>, "Hitachi", "HiSaturn", MACHINE_NOT_WORKING )

View File

@ -36970,6 +36970,7 @@ hisaturn // Hitachi HiSaturn
saturn // 1995 Sega Saturn (USA)
saturneu // 1995 Sega Saturn (Europe)
saturnjp // 1994 Sega Saturn (Japan)
saturnkr // 1995 Samsung Saturn (Korea)
vsaturn // JVC V-Saturn
@source:sauro.cpp