imgread.ImagePath clean up. ggpo: poll input late if !thread

This commit is contained in:
Flyinghead 2021-09-30 14:24:17 +02:00
parent 0d2e6f5e98
commit 2803ee8274
26 changed files with 195 additions and 281 deletions

View File

@ -114,7 +114,7 @@ static int showhelp()
bool ParseCommandLine(int argc,char* argv[])
{
settings.imgread.ImagePath[0] = '\0';
settings.content.path.clear();
int cl=argc-2;
char** arg=argv+1;
while(cl>=0)
@ -145,18 +145,18 @@ bool ParseCommandLine(int argc,char* argv[])
|| stricmp(extension, ".gdi") == 0 || stricmp(extension, ".cue") == 0))
{
INFO_LOG(COMMON, "Using '%s' as cd image", *arg);
strcpy(settings.imgread.ImagePath, *arg);
settings.content.path = *arg;
}
else if (extension && stricmp(extension, ".elf") == 0)
{
INFO_LOG(COMMON, "Using '%s' as reios elf file", *arg);
cfgSetVirtual("config", "bios.UseReios", "yes");
strcpy(settings.imgread.ImagePath, *arg);
settings.content.path = *arg;
}
else
{
INFO_LOG(COMMON, "Using '%s' as rom", *arg);
strcpy(settings.imgread.ImagePath, *arg);
settings.content.path = *arg;
}
}
arg++;

View File

@ -70,10 +70,6 @@ public:
cfgSetAutoSave(true);
}
const std::string& getGameId() const {
return gameId;
}
void setGameId(const std::string& gameId) {
this->gameId = gameId;
}
@ -125,7 +121,7 @@ public:
void load() override {
if (PerGameOption && settings.hasPerGameConfig())
set(doLoad(settings.getGameId(), section + "." + name));
set(doLoad(settings.gameId, section + "." + name));
else
{
set(doLoad(section, name));
@ -149,7 +145,7 @@ public:
return;
}
if (PerGameOption && settings.hasPerGameConfig())
doSave(settings.getGameId(), section + "." + name);
doSave(settings.gameId, section + "." + name);
else
doSave(section, name);
}

View File

@ -247,7 +247,7 @@ public:
void restart()
{
emu.unloadGame();
emu.loadGame(settings.imgread.ImagePath);
emu.loadGame(settings.content.path);
emu.start();
}

View File

@ -301,7 +301,6 @@ void dc_reset(bool hard)
if (hard)
_vmem_unprotect_vram(0, VRAM_SIZE);
libPvr_Reset(hard);
libGDR_Reset(hard);
libAICA_Reset(hard);
libARM_Reset(hard);
sh4_cpu.Reset(true);
@ -357,7 +356,6 @@ void Emulator::init()
setPlatform(DC_PLATFORM_DREAMCAST);
libPvr_Init();
libGDR_Init();
libAICA_Init();
libARM_Init();
mem_Init();
@ -405,9 +403,9 @@ void Emulator::loadGame(const char *path)
DEBUG_LOG(BOOT, "Loading game %s", path == nullptr ? "(nil)" : path);
if (path != nullptr)
strcpy(settings.imgread.ImagePath, path);
settings.content.path = path;
else
settings.imgread.ImagePath[0] = '\0';
settings.content.path.clear();
setPlatform(getGamePlatform(path));
mem_map_default();
@ -423,15 +421,14 @@ void Emulator::loadGame(const char *path)
// Boot BIOS
if (!LoadRomFiles())
throw FlycastException("No BIOS file found in " + hostfs::getFlashSavePath("", ""));
TermDrive();
InitDrive();
InitDrive("");
}
else
{
std::string extension = get_file_extension(settings.imgread.ImagePath);
std::string extension = get_file_extension(settings.content.path);
if (extension != "elf")
{
if (InitDrive())
if (InitDrive(settings.content.path))
{
loadGameSpecificSettings();
if (config::UseReios || !LoadRomFiles())
@ -443,10 +440,10 @@ void Emulator::loadGame(const char *path)
else
{
// Content load failed. Boot the BIOS
settings.imgread.ImagePath[0] = '\0';
settings.content.path.clear();
if (!LoadRomFiles())
throw FlycastException("This media cannot be loaded");
InitDrive();
InitDrive("");
}
}
else
@ -472,7 +469,7 @@ void Emulator::loadGame(const char *path)
else if (settings.platform.system == DC_PLATFORM_ATOMISWAVE)
mcfg_CreateAtomisWaveControllers();
}
cheatManager.reset(config::Settings::instance().getGameId());
cheatManager.reset(settings.content.gameId);
if (cheatManager.isWidescreen())
{
gui_display_notification("Widescreen cheat activated", 1000);
@ -521,6 +518,8 @@ void Emulator::unloadGame()
config::Settings::instance().reset();
config::Settings::instance().load(false);
settings.content.path.clear();
settings.content.gameId.clear();
state = Init;
}
}
@ -535,7 +534,6 @@ void Emulator::term()
custom_texture.Terminate(); // lr: avoid deadlock on exit (win32)
libARM_Term();
libAICA_Term();
libGDR_Term();
libPvr_Term();
mem_Term();
_vmem_release();
@ -601,6 +599,7 @@ void loadGameSpecificSettings()
// Default per-game settings
loadSpecialSettings();
settings.content.gameId = reios_id;
config::Settings::instance().setGameId(reios_id);
// Reload per-game settings

View File

@ -10,6 +10,7 @@ void WriteMem_gdrom(u32 Addr, u32 data, u32 sz);
void libCore_CDDA_Sector(s16* sector);
void libCore_gdrom_disc_change();
u32 gd_get_subcode(u32 format, u32 fad, u8 *subc_info);
void gd_setdisc();
enum DiscType
{
@ -22,6 +23,5 @@ enum DiscType
NoDisk=0x1, //These are a bit hacky .. but work for now ...
Open=0x2, //tray is open :)
Busy=0x3 //busy -> needs to be automatically done by gdhost
};

View File

@ -16,9 +16,9 @@
int gdrom_schid;
//Sense: ASC - ASCQ - Key
signed int sns_asc=0;
signed int sns_ascq=0;
signed int sns_key=0;
int sns_asc;
int sns_ascq;
int sns_key;
u32 set_mode_offset;
read_params_t read_params ;
@ -265,14 +265,8 @@ void gd_setdisc()
GDStatus.DRDY=1;
break;
case Busy:
SecNumber.Status = GD_BUSY;
GDStatus.BSY=1;
GDStatus.DRDY=0;
break;
default :
if (SecNumber.Status==GD_BUSY)
if (SecNumber.Status == GD_BUSY)
SecNumber.Status = GD_PAUSE;
else
SecNumber.Status = GD_STANDBY;
@ -281,15 +275,8 @@ void gd_setdisc()
break;
}
if (gd_disk_type==Busy && newd!=Busy)
{
GDStatus.BSY=0;
GDStatus.DRDY=1;
}
gd_disk_type=newd;
SecNumber.DiscFormat=gd_disk_type>>4;
gd_disk_type = newd;
SecNumber.DiscFormat = gd_disk_type >> 4;
}
void gd_reset()
@ -493,7 +480,7 @@ u32 gd_get_subcode(u32 format, u32 fad, u8 *subc_info)
case 0: // Raw subcode
subc_info[2] = 0;
subc_info[3] = 100;
libGDR_ReadSubChannel(subc_info + 4, 0, 100 - 4);
libGDR_ReadSubChannel(subc_info + 4, 100 - 4);
break;
case 1: // Q data only
@ -637,7 +624,7 @@ void gd_process_spi_cmd()
u32 toc_gd[102];
//toc - dd/sd
libGDR_GetToc(&toc_gd[0],packet_cmd.data_8[1]&0x1);
libGDR_GetToc(&toc_gd[0], (DiskArea)(packet_cmd.data_8[1] & 1));
gd_spi_pio_end((u8*)&toc_gd[0], std::min((u32)packet_cmd.data_8[4] | (packet_cmd.data_8[3] << 8), (u32)sizeof(toc_gd)));
}
@ -1209,6 +1196,7 @@ void GDROM_DmaEnable(u32 addr, u32 data)
void gdrom_reg_Init()
{
gdrom_schid = sh4_sched_register(0, &GDRomschd);
libCore_gdrom_disc_change();
}
void gdrom_reg_Term()
@ -1260,5 +1248,5 @@ void gdrom_reg_Reset(bool hard)
GDStatus = {};
ByteCount = {};
gd_setdisc();
libCore_gdrom_disc_change();
}

View File

@ -231,6 +231,10 @@ struct GD_HardwareInfo_t
};
extern GD_HardwareInfo_t GD_HardwareInfo;
extern int sns_asc;
extern int sns_ascq;
extern int sns_key;
#define GD_BUSY 0x00 // State transition
#define GD_PAUSE 0x01 // Pause
#define GD_STANDBY 0x02 // Standby (drive stop)

View File

@ -401,7 +401,7 @@ void GDCartridge::find_file(const char *name, const u8 *dir_sector, u32 &file_st
int fnlen = 0;
if(!(dir_sector[pos+25] & 2)) {
int len = dir_sector[pos+32];
// printf("file: [%s]\n", &dir_sector[pos+33+fnlen]);
//printf("file: [%s]\n", &dir_sector[pos+33+fnlen]);
for(fnlen=0; fnlen < FILENAME_LENGTH; fnlen++) {
if((dir_sector[pos+33+fnlen] == ';') && (name[fnlen] == 0)) {
fnlen = FILENAME_LENGTH+1;
@ -494,15 +494,15 @@ void GDCartridge::device_start()
u8 buffer[2048];
std::string gdrom_path = get_game_basename() + "/" + gdrom_name;
Disc *gdrom = OpenDisc((gdrom_path + ".chd").c_str());
Disc *gdrom = OpenDisc(gdrom_path + ".chd");
if (gdrom == nullptr)
gdrom = OpenDisc((gdrom_path + ".gdi").c_str());
gdrom = OpenDisc(gdrom_path + ".gdi");
if (gdrom_parent_name != nullptr && gdrom == nullptr)
{
std::string gdrom_parent_path = get_game_dir() + "/" + gdrom_parent_name + "/" + gdrom_name;
gdrom = OpenDisc((gdrom_parent_path + ".chd").c_str());
gdrom = OpenDisc(gdrom_parent_path + ".chd");
if (gdrom == nullptr)
gdrom = OpenDisc((gdrom_parent_path + ".gdi").c_str());
gdrom = OpenDisc(gdrom_parent_path + ".gdi");
}
if (gdrom == nullptr)
throw NaomiCartException("Naomi GDROM: Cannot open " + gdrom_path + ".chd or " + gdrom_path + ".gdi");

View File

@ -1,30 +1,6 @@
// nullGDR.cpp : Defines the entry point for the DLL application.
//
//Get a copy of the operators for structs ... ugly , but works :)
#include "common.h"
void GetSessionInfo(u8* out,u8 ses);
void libGDR_ReadSubChannel(u8 * buff, u32 format, u32 len)
{
if (format==0)
{
memcpy(buff,q_subchannel,len);
}
}
void libGDR_ReadSector(u8 * buff,u32 StartSector,u32 SectorCount,u32 secsz)
{
GetDriveSector(buff,StartSector,SectorCount,secsz);
//if (CurrDrive)
// CurrDrive->ReadSector(buff,StartSector,SectorCount,secsz);
}
void libGDR_GetToc(u32* toc,u32 area)
{
GetDriveToc(toc,(DiskArea)area);
}
extern Disc* disc;
u32 libGDR_GetTrackNumber(u32 sector, u32& elapsed)
{
@ -57,36 +33,3 @@ bool libGDR_GetTrack(u32 track_num, u32& start_fad, u32& end_fad)
return true;
}
//TODO : fix up
u32 libGDR_GetDiscType()
{
if (disc)
return disc->type;
else
return NullDriveDiscType;
}
void libGDR_GetSessionInfo(u8* out,u8 ses)
{
GetDriveSessionInfo(out,ses);
}
//It's supposed to reset everything (if not a soft reset)
void libGDR_Reset(bool hard)
{
libCore_gdrom_disc_change();
}
//called when entering sh4 thread , from the new thread context (for any thread specific init)
s32 libGDR_Init()
{
libCore_gdrom_disc_change();
return 0;
}
//called when exiting from sh4 thread , from the new thread context (for any thread specific init) :P
void libGDR_Term()
{
TermDrive();
}

View File

@ -1,4 +1,5 @@
#include "common.h"
#include "hw/gdrom/gdromv3.h"
Disc* chd_parse(const char* file);
Disc* gdi_parse(const char* file);
@ -11,7 +12,7 @@ Disc* ioctl_parse(const char* file);
u32 NullDriveDiscType;
Disc* disc;
Disc*(*drivers[])(const char* path)=
constexpr Disc* (*drivers[])(const char* path)
{
chd_parse,
gdi_parse,
@ -20,12 +21,11 @@ Disc*(*drivers[])(const char* path)=
#ifdef _WIN32
ioctl_parse,
#endif
0
};
u8 q_subchannel[96];
bool ConvertSector(u8* in_buff , u8* out_buff , int from , int to,int sector)
static bool convertSector(u8* in_buff , u8* out_buff , int from , int to,int sector)
{
//get subchannel data, if any
if (from == 2448)
@ -80,50 +80,50 @@ bool ConvertSector(u8* in_buff , u8* out_buff , int from , int to,int sector)
return true;
}
Disc* OpenDisc(const char* fn)
Disc* OpenDisc(const std::string& path)
{
Disc* rv = NULL;
for (auto driver : drivers)
{
Disc *disc = driver(path.c_str());
for (unat i=0; drivers[i] && !rv; i++) { // ;drivers[i] && !(rv=drivers[i](fn));
rv = drivers[i](fn);
if (rv && cdi_parse == drivers[i]) {
const char warn_str[] = "Warning: CDI Image Loaded! Many CDI images are known to be defective, GDI, CUE or CHD format is preferred. "
"Please only file bug reports when using images known to be good (GDI, CUE or CHD).";
WARN_LOG(GDROM, "%s", warn_str);
break;
if (disc != nullptr)
{
if (cdi_parse == driver) {
const char warn_str[] = "Warning: CDI Image Loaded! Many CDI images are known to be defective, GDI, CUE or CHD format is preferred. "
"Please only file bug reports when using images known to be good (GDI, CUE or CHD).";
WARN_LOG(GDROM, "%s", warn_str);
}
return disc;
}
}
return rv;
return nullptr;
}
bool InitDrive_(char* fn)
static bool loadDisk(const std::string& path)
{
TermDrive();
//try all drivers
disc = OpenDisc(fn);
disc = OpenDisc(path);
if (disc != NULL)
{
INFO_LOG(GDROM, "gdrom: Opened image \"%s\"", fn);
NullDriveDiscType = Busy;
INFO_LOG(GDROM, "gdrom: Opened image \"%s\"", path.c_str());
}
else
{
INFO_LOG(GDROM, "gdrom: Failed to open image \"%s\"", fn);
NullDriveDiscType = NoDisk; //no disc :)
INFO_LOG(GDROM, "gdrom: Failed to open image \"%s\"", path.c_str());
NullDriveDiscType = NoDisk;
}
libCore_gdrom_disc_change();
return disc != NULL;
}
bool InitDrive()
bool InitDrive(const std::string& path)
{
bool rc = DiscSwap();
bool rc = DiscSwap(path);
// not needed at startup and confuses some games
sns_asc = 0;
sns_ascq = 0;
@ -142,21 +142,21 @@ void DiscOpenLid()
sns_key = 0x6;
}
bool DiscSwap()
bool DiscSwap(const std::string& path)
{
// These Additional Sense Codes mean "The lid was closed"
sns_asc = 0x28;
sns_ascq = 0x00;
sns_key = 0x6;
if (settings.imgread.ImagePath[0] == '\0')
if (path.empty())
{
NullDriveDiscType = NoDisk;
gd_setdisc();
return true;
}
if (InitDrive_(settings.imgread.ImagePath))
if (loadDisk(path))
return true;
NullDriveDiscType = NoDisk;
@ -196,13 +196,13 @@ static u32 CreateTrackInfo_se(u32 ctrl, u32 addr, u32 tracknum)
return *(u32*)p;
}
void GetDriveSector(u8 * buff,u32 StartSector,u32 SectorCount,u32 secsz)
void libGDR_ReadSector(u8 *buff, u32 startSector, u32 sectorCount, u32 sectorSize)
{
if (disc != nullptr)
disc->ReadSectors(StartSector, SectorCount, buff, secsz);
disc->ReadSectors(startSector, sectorCount, buff, sectorSize);
}
void GetDriveToc(u32* to,DiskArea area)
void libGDR_GetToc(u32* to, DiskArea area)
{
if (!disc)
return;
@ -240,7 +240,7 @@ void GetDriveToc(u32* to,DiskArea area)
to[i]=CreateTrackInfo(disc->tracks[i].CTRL,disc->tracks[i].ADDR,disc->tracks[i].StartFAD);
}
void GetDriveSessionInfo(u8* to,u8 session)
void libGDR_GetSessionInfo(u8* to, u8 session)
{
if (!disc)
return;
@ -274,3 +274,77 @@ DiscType GuessDiscType(bool m1, bool m2, bool da)
else
return CdRom;
}
void Disc::ReadSectors(u32 FAD, u32 count, u8* dst, u32 fmt)
{
u8 temp[2448];
SectorFormat secfmt;
SubcodeFormat subfmt;
u32 progress = ~0;
for (u32 i = 1; i <= count; i++)
{
if (count >= 1000)
{
if (loading_canceled)
break;
// Progress report when loading naomi gd-rom games
const u32 new_progress = i * 100 / count;
if (progress != new_progress)
{
progress = new_progress;
char status_str[16];
sprintf(status_str, "%d%%", progress);
gui_display_notification(status_str, 2000);
}
}
if (ReadSector(FAD,temp,&secfmt,q_subchannel,&subfmt))
{
//TODO: Proper sector conversions
if (secfmt==SECFMT_2352)
{
convertSector(temp,dst,2352,fmt,FAD);
}
else if (fmt == 2048 && secfmt==SECFMT_2336_MODE2)
memcpy(dst,temp+8,2048);
else if (fmt==2048 && (secfmt==SECFMT_2048_MODE1 || secfmt==SECFMT_2048_MODE2_FORM1 ))
{
memcpy(dst,temp,2048);
}
else if (fmt==2352 && (secfmt==SECFMT_2048_MODE1 || secfmt==SECFMT_2048_MODE2_FORM1 ))
{
INFO_LOG(GDROM, "GDR:fmt=2352;secfmt=2048");
memcpy(dst,temp,2048);
}
else if (fmt==2048 && secfmt==SECFMT_2448_MODE2)
{
// Pier Solar and the Great Architects
convertSector(temp, dst, 2448, fmt, FAD);
}
else
{
WARN_LOG(GDROM, "ERROR: UNABLE TO CONVERT SECTOR. THIS IS FATAL. Format: %d Sector format: %d", fmt, secfmt);
//verify(false);
}
}
else
{
WARN_LOG(GDROM, "Sector Read miss FAD: %d", FAD);
}
dst+=fmt;
FAD++;
}
}
void libGDR_ReadSubChannel(u8 * buff, u32 len)
{
memcpy(buff, q_subchannel, len);
}
u32 libGDR_GetDiscType()
{
if (disc)
return disc->type;
else
return NullDriveDiscType;
}

View File

@ -6,8 +6,6 @@
#include "hw/gdrom/gdrom_if.h"
#include "rend/gui.h"
extern u32 NullDriveDiscType;
/*
Mode2 Subheader:
@ -63,21 +61,10 @@ enum DiskArea
DoubleDensity
};
bool ConvertSector(u8* in_buff , u8* out_buff , int from , int to,int sector);
bool InitDrive();
bool InitDrive(const std::string& path);
void TermDrive();
bool DiscSwap();
bool DiscSwap(const std::string& path);
void DiscOpenLid();
extern signed int sns_asc;
extern signed int sns_ascq;
extern signed int sns_key;
void GetDriveToc(u32* to,DiskArea area);
void GetDriveSector(u8 * buff,u32 StartSector,u32 SectorCount,u32 secsz);
void GetDriveSessionInfo(u8* to,u8 session);
extern u8 q_subchannel[96];
struct Session
{
@ -114,14 +101,12 @@ struct Track
struct Disc
{
std::wstring path;
std::vector<Session> sessions; //info for sessions
std::vector<Track> tracks; //info for tracks
Track LeadOut; //info for lead out track (can't read from here)
u32 EndFAD; //Last valid disc sector
DiscType type;
//functions !
bool ReadSector(u32 FAD,u8* dst,SectorFormat* sector_type,u8* subcode,SubcodeFormat* subcode_type)
{
for (size_t i=tracks.size();i-->0;)
@ -134,66 +119,8 @@ struct Disc
return false;
}
void ReadSectors(u32 FAD,u32 count,u8* dst,u32 fmt)
{
u8 temp[2448];
SectorFormat secfmt;
SubcodeFormat subfmt;
void ReadSectors(u32 FAD,u32 count,u8* dst,u32 fmt);
u32 progress = ~0;
for (u32 i = 1; i <= count; i++)
{
if (count >= 1000)
{
if (loading_canceled)
break;
// Progress report when loading naomi gd-rom games
const u32 new_progress = i * 100 / count;
if (progress != new_progress)
{
progress = new_progress;
char status_str[16];
sprintf(status_str, "%d%%", progress);
gui_display_notification(status_str, 2000);
}
}
if (ReadSector(FAD,temp,&secfmt,q_subchannel,&subfmt))
{
//TODO: Proper sector conversions
if (secfmt==SECFMT_2352)
{
ConvertSector(temp,dst,2352,fmt,FAD);
}
else if (fmt == 2048 && secfmt==SECFMT_2336_MODE2)
memcpy(dst,temp+8,2048);
else if (fmt==2048 && (secfmt==SECFMT_2048_MODE1 || secfmt==SECFMT_2048_MODE2_FORM1 ))
{
memcpy(dst,temp,2048);
}
else if (fmt==2352 && (secfmt==SECFMT_2048_MODE1 || secfmt==SECFMT_2048_MODE2_FORM1 ))
{
INFO_LOG(GDROM, "GDR:fmt=2352;secfmt=2048");
memcpy(dst,temp,2048);
}
else if (fmt==2048 && secfmt==SECFMT_2448_MODE2)
{
// Pier Solar and the Great Architects
ConvertSector(temp, dst, 2448, fmt, FAD);
}
else
{
WARN_LOG(GDROM, "ERROR: UNABLE TO CONVERT SECTOR. THIS IS FATAL. Format: %d Sector format: %d", fmt, secfmt);
//verify(false);
}
}
else
{
WARN_LOG(GDROM, "Sector Read miss FAD: %d", FAD);
}
dst+=fmt;
FAD++;
}
}
virtual ~Disc()
{
for (auto& track : tracks)
@ -244,9 +171,7 @@ struct Disc
}
};
extern Disc* disc;
Disc* OpenDisc(const char* fn);
Disc* OpenDisc(const std::string& path);
struct RawTrackFile : TrackFile
{
@ -294,17 +219,11 @@ struct RawTrackFile : TrackFile
};
DiscType GuessDiscType(bool m1, bool m2, bool da);
void gd_setdisc();
//GDR
s32 libGDR_Init();
void libGDR_Reset(bool hard);
void libGDR_Term();
//IO
void libGDR_ReadSector(u8 * buff,u32 StartSector,u32 SectorCount,u32 secsz);
void libGDR_ReadSubChannel(u8 * buff, u32 format, u32 len);
void libGDR_GetToc(u32* toc,u32 area);
void libGDR_ReadSubChannel(u8 * buff, u32 len);
void libGDR_GetToc(u32 *toc, DiskArea area);
u32 libGDR_GetDiscType();
void libGDR_GetSessionInfo(u8* pout,u8 session);
u32 libGDR_GetTrackNumber(u32 sector, u32& elapsed);

View File

@ -463,7 +463,7 @@ static FILE *get_record_input(bool write)
return NULL;
if (!write && !cfgLoadBool("record", "replay_input", false))
return NULL;
std::string game_dir = settings.imgread.ImagePath;
std::string game_dir = settings.content.path;
size_t slash = game_dir.find_last_of("/");
size_t dot = game_dir.find_last_of(".");
std::string input_file = "scripts/" + game_dir.substr(slash + 1, dot - slash) + "input";

View File

@ -20,6 +20,7 @@
#include "hw/maple/maple_cfg.h"
#include "hw/maple/maple_devs.h"
#include "input/gamepad_device.h"
#include "cfg/option.h"
void UpdateInputState();
@ -31,6 +32,8 @@ constexpr u32 BTN_TRIGGER_RIGHT = DC_BTN_RELOAD << 2;
static void getLocalInput(MapleInputState inputState[4])
{
if (!config::ThreadedRendering)
UpdateInputState();
for (int player = 0; player < 4; player++)
{
MapleInputState& state = inputState[player];
@ -367,7 +370,7 @@ void startSession(int localPort, int localPlayerNum)
cb.log_game_state = log_game_state;
#ifdef SYNC_TEST
GGPOErrorCode result = ggpo_start_synctest(&ggpoSession, &cb, config::Settings::instance().getGameId().c_str(), MAX_PLAYERS, sizeof(kcode[0]), 1);
GGPOErrorCode result = ggpo_start_synctest(&ggpoSession, &cb, settings.content.gameId.c_str(), MAX_PLAYERS, sizeof(kcode[0]), 1);
if (result != GGPO_OK)
{
WARN_LOG(NETWORK, "GGPO start sync session failed: %d", result);
@ -405,7 +408,7 @@ void startSession(int localPort, int localPlayerNum)
NOTICE_LOG(NETWORK, "GGPO: Using %d full analog axes", analogAxes);
}
u32 inputSize = sizeof(kcode[0]) + analogAxes + (int)absPointerPos * 4;
GGPOErrorCode result = ggpo_start_session(&ggpoSession, &cb, config::Settings::instance().getGameId().c_str(), MAX_PLAYERS, inputSize, localPort);
GGPOErrorCode result = ggpo_start_session(&ggpoSession, &cb, settings.content.gameId.c_str(), MAX_PLAYERS, inputSize, localPort);
if (result != GGPO_OK)
{
WARN_LOG(NETWORK, "GGPO start session failed: %d", result);

View File

@ -240,7 +240,7 @@ void dc_cancel_load()
loading_canceled = true;
loadingDone.get();
}
settings.imgread.ImagePath[0] = '\0';
settings.content.path.clear();
}
void dc_get_load_status()

View File

@ -77,7 +77,7 @@ std::string findNaomiBios(const std::string& name)
std::string getSavestatePath(int index, bool writable)
{
std::string state_file = settings.imgread.ImagePath;
std::string state_file = settings.content.path;
size_t lastindex = state_file.find_last_of('/');
#ifdef _WIN32
size_t lastindex2 = state_file.find_last_of('\\');

View File

@ -49,7 +49,7 @@ static void GDROM_HLE_ReadTOC()
}
u32 toc[102];
libGDR_GetToc(toc, area);
libGDR_GetToc(toc, (DiskArea)area);
// Swap results to LE
for (int i = 0; i < 102; i++) {

View File

@ -643,11 +643,11 @@ static void reios_boot()
//Infinite loop for arm !
WriteMem32(0x80800000, 0xEAFFFFFE);
std::string extension = get_file_extension(settings.imgread.ImagePath);
std::string extension = get_file_extension(settings.content.path);
if (extension == "elf")
{
if (!reios_loadElf(settings.imgread.ImagePath))
throw FlycastException(std::string("Failed to open ELF ") + settings.imgread.ImagePath);
if (!reios_loadElf(settings.content.path))
throw FlycastException(std::string("Failed to open ELF ") + settings.content.path);
reios_setup_state(0x8C010000);
}
else {

View File

@ -84,7 +84,7 @@ void CustomTexture::LoaderThread()
std::string CustomTexture::GetGameId()
{
std::string game_id(config::Settings::instance().getGameId());
std::string game_id(settings.content.gameId);
const size_t str_end = game_id.find_last_not_of(' ');
if (str_end == std::string::npos)
return "";

View File

@ -79,12 +79,12 @@ static void emuEventCallback(Event event)
break;
case Event::Start:
GamepadDevice::load_system_mappings();
if (config::AutoLoadState && settings.imgread.ImagePath[0] != '\0')
if (config::AutoLoadState && !settings.content.path.empty())
// TODO don't load state if using naomi networking
dc_loadstate(config::SavestateSlot);
break;
case Event::Terminate:
if (config::AutoSaveState && settings.imgread.ImagePath[0] != '\0')
if (config::AutoSaveState && !settings.content.path.empty())
dc_savestate(config::SavestateSlot);
break;
default:
@ -401,6 +401,7 @@ void gui_open_settings()
{
gui_state = GuiState::Commands;
HideOSD();
emu.stop();
}
else if (gui_state == GuiState::VJoyEdit)
{
@ -440,7 +441,6 @@ void gui_stop_game(const std::string& message)
emu.unloadGame();
gui_state = GuiState::Main;
game_started = false;
settings.imgread.ImagePath[0] = '\0';
reset_vmus();
if (!message.empty())
error_msg = "Flycast has stopped.\n\n" + message;
@ -454,8 +454,6 @@ void gui_stop_game(const std::string& message)
static void gui_display_commands()
{
emu.stop();
display_vmus();
centerNextWindow();
@ -463,7 +461,7 @@ static void gui_display_commands()
ImGui::Begin("##commands", NULL, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize);
bool loadSaveStateDisabled = settings.imgread.ImagePath[0] == '\0' || settings.online;
bool loadSaveStateDisabled = settings.content.path.empty() || settings.online;
if (loadSaveStateDisabled)
{
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
@ -2104,9 +2102,9 @@ static void gui_display_content()
{
if (gui_state == GuiState::SelectDisk)
{
strcpy(settings.imgread.ImagePath, game.path.c_str());
settings.content.path = game.path;
try {
DiscSwap();
DiscSwap(game.path);
gui_state = GuiState::Closed;
} catch (const FlycastException& e) {
error_msg = e.what();
@ -2204,7 +2202,7 @@ static void gui_network_start()
else
{
gui_state = GuiState::Main;
settings.imgread.ImagePath[0] = '\0';
settings.content.path.clear();
}
}
else
@ -2223,7 +2221,7 @@ static void gui_network_start()
NetworkHandshake::instance->stop();
networkStatus.get();
gui_state = GuiState::Main;
settings.imgread.ImagePath[0] = '\0';
settings.content.path.clear();
}
ImGui::PopStyleVar();
@ -2263,8 +2261,8 @@ static void gui_display_loadscreen()
#ifdef TEST_AUTOMATION
die("Game load failed");
#endif
emu.unloadGame();
gui_state = GuiState::Main;
settings.imgread.ImagePath[0] = '\0';
}
}
else
@ -2293,13 +2291,12 @@ void gui_display_ui()
return;
if (gui_state == GuiState::Main)
{
std::string game_file = settings.imgread.ImagePath;
if (!game_file.empty())
if (!settings.content.path.empty())
{
#ifndef __ANDROID__
commandLineStart = true;
#endif
gui_start_game(game_file);
gui_start_game(settings.content.path);
return;
}
}

View File

@ -74,9 +74,6 @@ extern MemChip *sys_nvmem;
//./core/hw/gdrom/gdromv3.o
extern int gdrom_schid;
extern signed int sns_asc;
extern signed int sns_ascq;
extern signed int sns_key;
extern packet_cmd_t packet_cmd;
extern u32 set_mode_offset;
extern read_params_t read_params ;

View File

@ -111,7 +111,7 @@ size_t get_last_slash_pos(const std::string& path)
std::string get_game_save_prefix()
{
std::string save_file = settings.imgread.ImagePath;
std::string save_file = settings.content.path;
size_t lastindex = get_last_slash_pos(save_file);
if (lastindex != std::string::npos)
save_file = save_file.substr(lastindex + 1);
@ -120,7 +120,7 @@ std::string get_game_save_prefix()
std::string get_game_basename()
{
std::string game_dir = settings.imgread.ImagePath;
std::string game_dir = settings.content.path;
size_t lastindex = game_dir.find_last_of('.');
if (lastindex != std::string::npos)
game_dir = game_dir.substr(0, lastindex);
@ -129,7 +129,7 @@ std::string get_game_basename()
std::string get_game_dir()
{
std::string game_dir = settings.imgread.ImagePath;
std::string game_dir = settings.content.path;
size_t lastindex = get_last_slash_pos(game_dir);
if (lastindex != std::string::npos)
game_dir = game_dir.substr(0, lastindex + 1);

View File

@ -349,8 +349,9 @@ struct settings_t
struct
{
char ImagePath[512];
} imgread;
std::string path;
std::string gameId;
} content;
struct {
JVS JammaSetup;

View File

@ -249,8 +249,7 @@ extern "C" JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_setGameUri
// Get filename string from Java
const char* file_path = env->GetStringUTFChars(fileName, 0);
NOTICE_LOG(BOOT, "Game Disk URI: '%s'", file_path);
strncpy(settings.imgread.ImagePath, strlen(file_path) >= 7 && !memcmp(file_path, "file://", 7) ? file_path + 7 : file_path, sizeof(settings.imgread.ImagePath));
settings.imgread.ImagePath[sizeof(settings.imgread.ImagePath) - 1] = '\0';
settings.content.path = strlen(file_path) >= 7 && !memcmp(file_path, "file://", 7) ? file_path + 7 : file_path;
env->ReleaseStringUTFChars(fileName, file_path);
// TODO game paused/settings/...
if (game_started) {
@ -307,7 +306,7 @@ extern "C" JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_stop(JNIEn
}
emu.unloadGame();
gui_state = GuiState::Main;
settings.imgread.ImagePath[0] = '\0';
settings.content.path.clear();
}
static void *render_thread_func(void *)

View File

@ -66,7 +66,7 @@ static bool emulatorRunning;
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
if (config::AutoSaveState && settings.imgread.ImagePath[0] != '\0')
if (config::AutoSaveState && !settings.content.path.empty())
dc_savestate(config::SavestateSlot);
}

View File

@ -152,7 +152,7 @@ static void init_disk_control_interface();
static bool read_m3u(const char *file);
void UpdateInputState();
static char *game_data;
static std::string game_data;
static char g_base_name[128];
static char game_dir[1024];
char game_dir_no_slash[1024];
@ -865,11 +865,11 @@ void retro_run()
is_dupe = true;
}
static bool loadGame(const char *path)
static bool loadGame()
{
mute_messages = true;
try {
emu.loadGame(path);
emu.loadGame(game_data.c_str());
} catch (const FlycastException& e) {
ERROR_LOG(BOOT, "%s", e.what());
mute_messages = false;
@ -888,7 +888,7 @@ void retro_reset()
emu.unloadGame();
config::ScreenStretching = 100;
loadGame(settings.imgread.ImagePath);
loadGame();
if (rotate_game)
config::Widescreen.override(false);
config::Rotate90 = false;
@ -1571,7 +1571,7 @@ bool retro_load_game(const struct retro_game_info *game)
boot_to_bios = false;
if (boot_to_bios)
game_data = nullptr;
game_data.clear();
// if an m3u file was loaded, disk_paths will already be populated so load the game from there
else if (disk_paths.size() > 0)
{
@ -1584,7 +1584,7 @@ bool retro_load_game(const struct retro_game_info *game)
&& disk_paths[disk_initial_index].compare(disk_initial_path) == 0)
disk_index = disk_initial_index;
game_data = strdup(disk_paths[disk_index].c_str());
game_data = disk_paths[disk_index];
}
else
{
@ -1596,7 +1596,7 @@ bool retro_load_game(const struct retro_game_info *game)
fill_short_pathname_representation(disk_label, game->path, sizeof(disk_label));
disk_labels.push_back(disk_label);
game_data = strdup(game->path);
game_data = game->path;
}
{
@ -1670,7 +1670,7 @@ bool retro_load_game(const struct retro_game_info *game)
}
config::ScreenStretching = 100;
if (!loadGame(game_data))
if (!loadGame())
return false;
rotate_game = config::Rotate90;
@ -1698,8 +1698,7 @@ void retro_unload_game()
frontend_clear_thread_waits_cb(1, nullptr);
emu.stop();
frontend_clear_thread_waits_cb(0, nullptr);
free(game_data);
game_data = nullptr;
game_data.clear();
disk_paths.clear();
disk_labels.clear();
blankVmus();
@ -2719,7 +2718,7 @@ static bool retro_set_eject_state(bool ejected)
else
{
try {
return DiscSwap();
return DiscSwap(disk_paths[disk_index]);
} catch (const FlycastException& e) {
ERROR_LOG(GDROM, "%s", e.what());
return false;
@ -2743,17 +2742,16 @@ static bool retro_set_image_index(unsigned index)
if (disk_index >= disk_paths.size())
{
// No disk in drive
settings.imgread.ImagePath[0] = '\0';
settings.content.path.clear();
return true;
}
strncpy(settings.imgread.ImagePath, disk_paths[index].c_str(), sizeof(settings.imgread.ImagePath));
settings.imgread.ImagePath[sizeof(settings.imgread.ImagePath) - 1] = '\0';
settings.content.path = disk_paths[index];
if (disc_tray_open)
return true;
try {
return DiscSwap();
return DiscSwap(settings.content.path);
} catch (const FlycastException& e) {
ERROR_LOG(GDROM, "%s", e.what());
return false;

View File

@ -32,10 +32,6 @@ public:
void save() {}
const std::string& getGameId() const {
return gameId;
}
void setGameId(const std::string& gameId) {
this->gameId = gameId;
}