gs: core code and components merged up to gs

This commit is contained in:
Gauvain 'GovanifY' Roussel-Tarbouriech 2021-05-11 18:29:01 +02:00 committed by Kojin
parent ada56a1c03
commit b284ab7566
11 changed files with 77 additions and 66 deletions

View File

@ -144,7 +144,7 @@ void LoadConf()
if (doc == NULL) if (doc == NULL)
{ {
SysMessage("Unable to parse configuration file! Suggest deleting it and starting over."); Console.Error("Unable to parse configuration file! Suggest deleting it and starting over.");
} }
for (cur_node = xmlDocGetRootElement(doc)->children; cur_node; cur_node = cur_node->next) for (cur_node = xmlDocGetRootElement(doc)->children; cur_node; cur_node = cur_node->next)

View File

@ -167,11 +167,11 @@ int GetMACAddress(char* adapter, mac_address* addr)
} }
else else
{ {
SysMessage("Could not get MAC address for adapter: %s", adapter); Console.Error("Could not get MAC address for adapter: %s", adapter);
} }
close(fd); close(fd);
#else #else
SysMessage("Could not get MAC address for adapter, OS not supported"); Console.Error("Could not get MAC address for adapter, OS not supported");
#endif #endif
return retval; return retval;
} }
@ -230,7 +230,7 @@ int pcap_io_init(char* adapter, bool switched, mac_address virtual_mac)
//case DLT_IEEE802_11: //case DLT_IEEE802_11:
break; break;
default: default:
SysMessage("ERROR: Unsupported DataLink Type (%d): %s", dlt, dlt_name); Console.Error("ERROR: Unsupported DataLink Type (%d): %s", dlt, dlt_name);
pcap_close(adhandle); pcap_close(adhandle);
return -1; return -1;
} }
@ -391,7 +391,7 @@ PCAPAdapter::PCAPAdapter()
if (pcap_io_init(config.Eth, config.EthApi == NetApi::PCAP_Switched, newMAC) == -1) if (pcap_io_init(config.Eth, config.EthApi == NetApi::PCAP_Switched, newMAC) == -1)
{ {
SysMessage("Can't open Device '%s'\n", config.Eth); Console.Error("Can't open Device '%s'\n", config.Eth);
} }
} }
bool PCAPAdapter::blocks() bool PCAPAdapter::blocks()

View File

@ -318,8 +318,8 @@ void emac3_write(u32 addr)
} }
dev9Ru32(addr) = wswap(value); dev9Ru32(addr) = wswap(value);
} }
EXPORT_C_(u8)
smap_read8(u32 addr) u8 smap_read8(u32 addr)
{ {
switch (addr) switch (addr)
{ {
@ -341,8 +341,8 @@ smap_read8(u32 addr)
DevCon.WriteLn("DEV9: SMAP : error , 8 bit read @ %X,v=%X", addr, dev9Ru8(addr)); DevCon.WriteLn("DEV9: SMAP : error , 8 bit read @ %X,v=%X", addr, dev9Ru8(addr));
return dev9Ru8(addr); return dev9Ru8(addr);
} }
EXPORT_C_(u16)
smap_read16(u32 addr) u16 smap_read16(u32 addr)
{ {
int rv = dev9Ru16(addr); int rv = dev9Ru16(addr);
if (addr >= SMAP_BD_TX_BASE && addr < (SMAP_BD_TX_BASE + SMAP_BD_SIZE)) if (addr >= SMAP_BD_TX_BASE && addr < (SMAP_BD_TX_BASE + SMAP_BD_SIZE))
@ -495,8 +495,7 @@ smap_read16(u32 addr)
return rv; return rv;
} }
EXPORT_C_(u32) u32 smap_read32(u32 addr)
smap_read32(u32 addr)
{ {
if (addr >= SMAP_EMAC3_REGBASE && addr < SMAP_EMAC3_REGEND) if (addr >= SMAP_EMAC3_REGBASE && addr < SMAP_EMAC3_REGEND)
{ {
@ -532,8 +531,8 @@ smap_read32(u32 addr)
return dev9Ru32(addr); return dev9Ru32(addr);
} }
} }
EXPORT_C_(void)
smap_write8(u32 addr, u8 value) void smap_write8(u32 addr, u8 value)
{ {
std::unique_lock<std::mutex> reset_lock(reset_mutex, std::defer_lock); std::unique_lock<std::mutex> reset_lock(reset_mutex, std::defer_lock);
std::unique_lock<std::mutex> counter_lock(frame_counter_mutex, std::defer_lock); std::unique_lock<std::mutex> counter_lock(frame_counter_mutex, std::defer_lock);
@ -606,8 +605,8 @@ smap_write8(u32 addr, u8 value)
return; return;
} }
} }
EXPORT_C_(void)
smap_write16(u32 addr, u16 value) void smap_write16(u32 addr, u16 value)
{ {
if (addr >= SMAP_BD_TX_BASE && addr < (SMAP_BD_TX_BASE + SMAP_BD_SIZE)) if (addr >= SMAP_BD_TX_BASE && addr < (SMAP_BD_TX_BASE + SMAP_BD_SIZE))
{ {
@ -792,8 +791,8 @@ smap_write16(u32 addr, u16 value)
return; return;
} }
} }
EXPORT_C_(void)
smap_write32(u32 addr, u32 value) void smap_write32(u32 addr, u32 value)
{ {
if (addr >= SMAP_EMAC3_REGBASE && addr < SMAP_EMAC3_REGEND) if (addr >= SMAP_EMAC3_REGBASE && addr < SMAP_EMAC3_REGEND)
{ {
@ -814,8 +813,8 @@ smap_write32(u32 addr, u32 value)
return; return;
} }
} }
EXPORT_C_(void)
smap_readDMA8Mem(u32* pMem, int size) void smap_readDMA8Mem(u32* pMem, int size)
{ {
if (dev9Ru16(SMAP_R_RXFIFO_CTRL) & SMAP_RXFIFO_DMAEN) if (dev9Ru16(SMAP_R_RXFIFO_CTRL) & SMAP_RXFIFO_DMAEN)
{ {
@ -835,8 +834,8 @@ smap_readDMA8Mem(u32* pMem, int size)
dev9Ru16(SMAP_R_RXFIFO_CTRL) &= ~SMAP_RXFIFO_DMAEN; dev9Ru16(SMAP_R_RXFIFO_CTRL) &= ~SMAP_RXFIFO_DMAEN;
} }
} }
EXPORT_C_(void)
smap_writeDMA8Mem(u32* pMem, int size) void smap_writeDMA8Mem(u32* pMem, int size)
{ {
if (dev9Ru16(SMAP_R_TXFIFO_CTRL) & SMAP_TXFIFO_DMAEN) if (dev9Ru16(SMAP_R_TXFIFO_CTRL) & SMAP_TXFIFO_DMAEN)
{ {
@ -858,8 +857,8 @@ smap_writeDMA8Mem(u32* pMem, int size)
dev9Ru16(SMAP_R_TXFIFO_CTRL) &= ~SMAP_TXFIFO_DMAEN; dev9Ru16(SMAP_R_TXFIFO_CTRL) &= ~SMAP_TXFIFO_DMAEN;
} }
} }
EXPORT_C_(void)
smap_async(u32 cycles) void smap_async(u32 cycles)
{ {
if (fireIntR) if (fireIntR)
{ {

View File

@ -16,23 +16,14 @@
#pragma once #pragma once
#include "DEV9.h" #include "DEV9.h"
EXPORT_C_(u8) u8 smap_read8(u32 addr);
smap_read8(u32 addr); u16 smap_read16(u32 addr);
EXPORT_C_(u16) u32 smap_read32(u32 addr);
smap_read16(u32 addr);
EXPORT_C_(u32)
smap_read32(u32 addr);
EXPORT_C_(void) void smap_write8(u32 addr, u8 value);
smap_write8(u32 addr, u8 value); void smap_write16(u32 addr, u16 value);
EXPORT_C_(void) void smap_write32(u32 addr, u32 value);
smap_write16(u32 addr, u16 value);
EXPORT_C_(void)
smap_write32(u32 addr, u32 value);
EXPORT_C_(void) void smap_readDMA8Mem(u32* pMem, int size);
smap_readDMA8Mem(u32* pMem, int size); void smap_writeDMA8Mem(u32* pMem, int size);
EXPORT_C_(void) void smap_async(u32 cycles);
smap_writeDMA8Mem(u32* pMem, int size);
EXPORT_C_(void)
smap_async(u32 cycles);

View File

@ -1441,12 +1441,6 @@ struct GSKeyEventData
uint32 key, type; uint32 key, type;
}; };
enum
{
FREEZE_LOAD = 0,
FREEZE_SAVE = 1,
FREEZE_SIZE = 2
};
struct GSFreezeData struct GSFreezeData
{ {
int size; int size;

View File

@ -200,6 +200,7 @@ typedef int64 sint64;
#define ASSERT assert #define ASSERT assert
/*
#ifdef _M_AMD64 #ifdef _M_AMD64
// Yeah let use mips naming ;) // Yeah let use mips naming ;)
#ifdef _WIN64 #ifdef _WIN64
@ -218,6 +219,7 @@ typedef int64 sint64;
#define t1 r9 #define t1 r9
#endif #endif
#endif #endif
*/
// sse // sse
#if defined(__GNUC__) #if defined(__GNUC__)

View File

@ -462,7 +462,7 @@ void SysMtgsThread::ExecuteTaskInThread()
{ {
MTGS_FreezeData* data = (MTGS_FreezeData*)tag.pointer; MTGS_FreezeData* data = (MTGS_FreezeData*)tag.pointer;
int mode = tag.data[0]; int mode = tag.data[0];
data->retval = GetCorePlugins().DoFreeze(PluginId_GS, mode, data->fdata); data->retval = GSfreeze(mode, (GSFreezeData*)data->fdata);
} }
break; break;

View File

@ -30,6 +30,7 @@
#include "Utilities/SafeArray.inl" #include "Utilities/SafeArray.inl"
#include "SPU2/spu2.h" #include "SPU2/spu2.h"
#include "gui/ConsoleLogger.h"
using namespace R5900; using namespace R5900;
@ -240,23 +241,12 @@ SaveStateBase& SaveStateBase::FreezeInternals()
return *this; return *this;
} }
SaveStateBase& SaveStateBase::FreezePlugins()
{
for (uint i=0; i<PluginId_Count; ++i)
{
FreezeTag( FastFormatAscii().Write("Plugin:%s", tbl_PluginInfo[i].shortname) );
GetCorePlugins().Freeze( (PluginsEnum_t)i, *this );
}
return *this;
}
SaveStateBase& SaveStateBase::FreezeAll() SaveStateBase& SaveStateBase::FreezeAll()
{ {
FreezeMainMemory(); FreezeMainMemory();
FreezeBios(); FreezeBios();
FreezeInternals(); FreezeInternals();
FreezePlugins(); //TODO: ADD BACK FREEZE PLUGINS HERE
return *this; return *this;
} }
@ -323,3 +313,22 @@ void memLoadingState::FreezeMem( void* data, int size )
m_idx += size; m_idx += size;
memcpy( data, src, size ); memcpy( data, src, size );
} }
wxString Exception::SaveStateLoadError::FormatDiagnosticMessage() const
{
FastFormatUnicode retval;
retval.Write("Savestate is corrupt or incomplete!\n");
OSDlog(Color_Red, false, "Error: Savestate is corrupt or incomplete!");
_formatDiagMsg(retval);
return retval;
}
wxString Exception::SaveStateLoadError::FormatDisplayMessage() const
{
FastFormatUnicode retval;
retval.Write(_("The savestate cannot be loaded, as it appears to be corrupt or incomplete."));
retval.Write("\n");
OSDlog(Color_Red, false, "Error: The savestate cannot be loaded, as it appears to be corrupt or incomplete.");
_formatUserMsg(retval);
return retval;
}

View File

@ -15,7 +15,12 @@
#pragma once #pragma once
#define FREEZE_LOAD 0
#define FREEZE_SAVE 1
#define FREEZE_SIZE 2
#include "System.h" #include "System.h"
#include "Utilities/Exceptions.h"
// Savestate Versioning! // Savestate Versioning!
// If you make changes to the savestate version, please increment the value below. // If you make changes to the savestate version, please increment the value below.
@ -212,3 +217,16 @@ public:
bool IsFinished() const { return m_idx >= m_memory->GetSizeInBytes(); } bool IsFinished() const { return m_idx >= m_memory->GetSizeInBytes(); }
}; };
namespace Exception
{
// Exception thrown when a corrupted or truncated savestate is encountered.
class SaveStateLoadError : public BadStream
{
DEFINE_STREAM_EXCEPTION(SaveStateLoadError, BadStream)
virtual wxString FormatDiagnosticMessage() const;
virtual wxString FormatDisplayMessage() const;
};
}; // namespace Exception

View File

@ -678,7 +678,7 @@ SIO_WRITE sioWriteMemcard(u8 data)
sio2.packet.recvVal3 = 0x83; sio2.packet.recvVal3 = 0x83;
mc_command_0x26_tag cmd; mc_command_0x26_tag cmd;
PS2E_McdSizeInfo info; McdSizeInfo info;
mcd->GetSizeInfo(info); mcd->GetSizeInfo(info);

View File

@ -69,11 +69,9 @@ void vif1TransferToMemory()
} }
GetMTGS().WaitGS(); GetMTGS().WaitGS();
if (GSinitReadFIFO2) {
GetMTGS().SendPointerPacket(GS_RINGTYPE_INIT_READ_FIFO2, size, pMem); GetMTGS().SendPointerPacket(GS_RINGTYPE_INIT_READ_FIFO2, size, pMem);
GetMTGS().WaitGS(false); // wait without reg sync GetMTGS().WaitGS(false); // wait without reg sync
} GSreadFIFO2((u8*)pMem, size);
GSreadFIFO2((u64*)pMem, size);
// pMem += size; // pMem += size;
//Some games such as Alex Ferguson's Player Manager 2001 reads less than GSLastDownloadSize by VIF then reads the remainder by FIFO //Some games such as Alex Ferguson's Player Manager 2001 reads less than GSLastDownloadSize by VIF then reads the remainder by FIFO