libretro: better error handling. fix reset issue with rotated games

compilation warnings, clean up
This commit is contained in:
Flyinghead 2021-07-21 16:19:57 +02:00
parent de060d66ab
commit c453d14352
6 changed files with 37 additions and 59 deletions

View File

@ -455,7 +455,7 @@ void dc_start_game(const char *path)
{
// Boot BIOS
if (!LoadRomFiles())
throw FlycastException("No BIOS file found in " + get_writable_data_path(""));
throw FlycastException("No BIOS file found in " + hostfs::getFlashSavePath("", ""));
TermDrive();
InitDrive();
}

View File

@ -284,7 +284,7 @@ void NaomiM3Comm::startThread()
auto duration = the_clock::now() - token_time;
if (duration < target_duration)
{
DEBUG_LOG(NAOMI, "Sleeping for %ld ms", std::chrono::duration_cast<std::chrono::milliseconds>(target_duration - duration).count());
DEBUG_LOG(NAOMI, "Sleeping for %ld ms", (long)std::chrono::duration_cast<std::chrono::milliseconds>(target_duration - duration).count());
std::this_thread::sleep_for(target_duration - duration);
}
token_time = the_clock::now();

View File

@ -301,7 +301,6 @@ sh4dec(i1111_1011_1111_1101)
Emit(shop_frswap,regv_xmtrx,regv_fmtrx,regv_xmtrx,0,rmn,regv_fmtrx);
}
//not-so-elegant, but avoids extra opcodes and temporalities ..
//rotcl
sh4dec(i0100_nnnn_0010_0100)
{
@ -309,13 +308,6 @@ sh4dec(i0100_nnnn_0010_0100)
Sh4RegType rn=(Sh4RegType)(reg_r0+n);
Emit(shop_rocl,rn,rn,reg_sr_T,0,shil_param(),reg_sr_T);
/*
Emit(shop_ror,rn,rn,mk_imm(31));
Emit(shop_xor,rn,rn,reg_sr_T); //Only affects last bit (swap part a)
Emit(shop_xor,reg_sr_T,reg_sr_T,rn); //srT -> rn
Emit(shop_and,reg_sr_T,reg_sr_T,mk_imm(1)); //Keep only last bit
Emit(shop_xor,rn,rn,reg_sr_T); //Only affects last bit (swap part b)
*/
}
//rotcr
@ -325,14 +317,6 @@ sh4dec(i0100_nnnn_0010_0101)
Sh4RegType rn=(Sh4RegType)(reg_r0+n);
Emit(shop_rocr,rn,rn,reg_sr_T,0,shil_param(),reg_sr_T);
/*
Emit(shop_xor,rn,rn,reg_sr_T); //Only affects last bit (swap part a)
Emit(shop_xor,reg_sr_T,reg_sr_T,rn); //srT -> rn
Emit(shop_and,reg_sr_T,reg_sr_T,mk_imm(1)); //Keep only last bit
Emit(shop_xor,rn,rn,reg_sr_T); //Only affects last bit (swap part b)
Emit(shop_ror,rn,rn,mk_imm(1));
*/
}
static const Sh4RegType SREGS[] =
@ -619,21 +603,13 @@ static bool MatchDiv32u(u32 op,u32 pc)
if (config::DynarecSafeMode)
return false;
div_som_reg1=NoReg;
div_som_reg2=NoReg;
div_som_reg3=NoReg;
div_som_reg1 = NoReg;
div_som_reg2 = NoReg;
div_som_reg3 = NoReg;
u32 match=MatchDiv32(pc+2,div_som_reg1,div_som_reg2,div_som_reg3);
u32 match = MatchDiv32(pc + 2, div_som_reg1, div_som_reg2, div_som_reg3);
//log("DIV32U matched %d%% @ 0x%X\n",match*100/65,pc);
if (match==65)
{
//DIV32U was perfectly matched :)
return true;
}
else //no match ...
return false;
return match == 65;
}
static bool MatchDiv32s(u32 op,u32 pc)
@ -644,29 +620,13 @@ static bool MatchDiv32s(u32 op,u32 pc)
u32 n = GetN(op);
u32 m = GetM(op);
div_som_reg1=NoReg;
div_som_reg2=(Sh4RegType)m;
div_som_reg3=(Sh4RegType)n;
div_som_reg1 = NoReg;
div_som_reg2 = (Sh4RegType)m;
div_som_reg3 = (Sh4RegType)n;
u32 match=MatchDiv32(pc+2,div_som_reg1,div_som_reg2,div_som_reg3);
//printf("DIV32S matched %d%% @ 0x%X\n",match*100/65,pc);
u32 match = MatchDiv32(pc + 2, div_som_reg1, div_som_reg2, div_som_reg3);
if (match==65)
{
//DIV32S was perfectly matched :)
//printf("div32s %d/%d/%d\n",div_som_reg1,div_som_reg2,div_som_reg3);
return true;
}
else //no match ...
{
/*
printf("%04X\n",IReadMem16(pc-2));
printf("%04X\n",IReadMem16(pc-0));
printf("%04X\n",IReadMem16(pc+2));
printf("%04X\n",IReadMem16(pc+4));
printf("%04X\n",IReadMem16(pc+6));*/
return false;
}
return match == 65;
}
/*

View File

@ -131,7 +131,7 @@ void NaomiNetwork::processBeacon()
}
else
{
DEBUG_LOG(NETWORK, "NaomiServer: beacon received %ld bytes", n);
DEBUG_LOG(NETWORK, "NaomiServer: beacon received %ld bytes", (long)n);
if (n == sizeof(buf) && !strncmp(buf, "flycast", n))
sendto(beacon_sock, buf, n, 0, (const struct sockaddr *)&addr, addrlen);
}

View File

@ -45,10 +45,10 @@ bool reios_loadElf(const std::string& elf) {
u8* ptr = GetMemPtr(dest, len);
if (ptr == NULL)
{
WARN_LOG(REIOS, "Invalid load address for section %d: %08lx", i, dest);
WARN_LOG(REIOS, "Invalid load address for section %d: %08lx", i, (long)dest);
continue;
}
DEBUG_LOG(REIOS, "Loading section %d to %08lx - %08lx", i, dest, dest + len - 1);
DEBUG_LOG(REIOS, "Loading section %d to %08lx - %08lx", i, (long)dest, (long)(dest + len - 1));
memcpy(ptr, src, len);
ptr += len;
memset(ptr, 0, elf_getProgramHeaderMemorySize(elfFile, i) - len);

View File

@ -862,6 +862,22 @@ void retro_run()
is_dupe = true;
}
static bool loadGame(const char *path)
{
mute_messages = true;
try {
dc_start_game(path);
} catch (const FlycastException& e) {
ERROR_LOG(BOOT, "%s", e.what());
mute_messages = false;
gui_display_notification(e.what(), 2000);
return false;
}
mute_messages = false;
return true;
}
void retro_reset()
{
std::lock_guard<std::mutex> lock(mtx_serialization);
@ -870,7 +886,10 @@ void retro_reset()
dc_stop();
config::ScreenStretching = 100;
dc_start_game(settings.imgread.ImagePath);
loadGame(settings.imgread.ImagePath);
if (rotate_game)
config::Widescreen.override(false);
config::Rotate90 = false;
setFramebufferSize();
retro_game_geometry geometry;
@ -1647,9 +1666,8 @@ bool retro_load_game(const struct retro_game_info *game)
}
config::ScreenStretching = 100;
mute_messages = true;
dc_start_game(game_data);
mute_messages = false;
if (!loadGame(game_data))
return false;
rotate_game = config::Rotate90;
if (rotate_game)