Core: Add ISViewerHandler
This commit is contained in:
parent
f0ee90990a
commit
acd5f8ecd5
|
@ -0,0 +1,82 @@
|
|||
#include "stdafx.h"
|
||||
#include "ISViewerHandler.h"
|
||||
#include <Project64-core\N64System\N64System.h>
|
||||
#include <Common/path.h>
|
||||
|
||||
ISViewerHandler::ISViewerHandler(CN64System & System) :
|
||||
m_hLogFile(nullptr),
|
||||
m_BufferPos(0)
|
||||
{
|
||||
memset(m_Buffer, 0, sizeof(m_Buffer));
|
||||
System.RegisterCallBack(CN64SystemCB_Reset, this, (CN64System::CallBackFunction)stSystemReset);
|
||||
}
|
||||
|
||||
bool ISViewerHandler::Read32(uint32_t Address, uint32_t & Value)
|
||||
{
|
||||
Value = ((Address & 0xFFFF) << 16) | (Address & 0xFFFF);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ISViewerHandler::Write32(uint32_t Address, uint32_t Value, uint32_t Mask)
|
||||
{
|
||||
uint32_t MaskedValue = Value & Mask;
|
||||
if (m_Data.empty())
|
||||
{
|
||||
m_Data.resize(0x10000);
|
||||
}
|
||||
*((uint32_t *)&m_Data[Address & 0xFFFC]) = Swap32by8(MaskedValue);
|
||||
|
||||
if ((Address & 0xFFFC) == 0x14 && MaskedValue > 0)
|
||||
{
|
||||
if (m_BufferPos + MaskedValue <= (sizeof(m_Buffer) / sizeof(m_Buffer[0])))
|
||||
{
|
||||
memcpy(&m_Buffer[m_BufferPos], (const char *)&m_Data[0x20], MaskedValue);
|
||||
m_BufferPos += MaskedValue;
|
||||
char * NewLine = (char *)memchr((void *)&m_Buffer[0], '\n', m_BufferPos);
|
||||
if (NewLine != nullptr)
|
||||
{
|
||||
m_BufferPos = 0;
|
||||
if (m_hLogFile == nullptr)
|
||||
{
|
||||
CPath LogFile(g_Settings->LoadStringVal(Directory_Log).c_str(), "ISViewer.log");
|
||||
m_hLogFile = std::make_unique<CFile>(LogFile, CFileBase::modeCreate | CFileBase::modeWrite);
|
||||
}
|
||||
if (m_hLogFile != nullptr && NewLine != m_Buffer)
|
||||
{
|
||||
m_hLogFile->Write(m_Buffer, (NewLine - m_Buffer) + 1);
|
||||
m_hLogFile->Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_BufferPos = 0;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t ISViewerHandler::Swap32by8(uint32_t Value)
|
||||
{
|
||||
const uint32_t Swapped =
|
||||
#if defined(_MSC_VER)
|
||||
_byteswap_ulong(Value)
|
||||
#elif defined(__GNUC__)
|
||||
__builtin_bswap32(Value)
|
||||
#else
|
||||
(Value & 0x000000FFul) << 24
|
||||
| (Value & 0x0000FF00ul) << 8
|
||||
| (Value & 0x00FF0000ul) >> 8
|
||||
| (Value & 0xFF000000ul) >> 24
|
||||
#endif
|
||||
;
|
||||
return (Swapped & 0xFFFFFFFFul);
|
||||
}
|
||||
|
||||
void ISViewerHandler::SystemReset(void)
|
||||
{
|
||||
m_hLogFile.reset(nullptr);
|
||||
m_Data.clear();
|
||||
memset(m_Buffer, 0, sizeof(m_Buffer));
|
||||
m_BufferPos = 0;
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
#pragma once
|
||||
#include "MemoryHandler.h"
|
||||
#include <Common/File.h>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
|
||||
class CN64System;
|
||||
|
||||
class ISViewerHandler :
|
||||
public MemoryHandler
|
||||
{
|
||||
public:
|
||||
ISViewerHandler(CN64System & System);
|
||||
|
||||
bool Read32(uint32_t Address, uint32_t & Value);
|
||||
bool Write32(uint32_t Address, uint32_t Value, uint32_t Mask);
|
||||
|
||||
private:
|
||||
ISViewerHandler();
|
||||
ISViewerHandler(const ISViewerHandler &);
|
||||
ISViewerHandler & operator=(const ISViewerHandler &);
|
||||
|
||||
static void stSystemReset(ISViewerHandler * _this) { _this->SystemReset(); }
|
||||
static uint32_t Swap32by8(uint32_t Value);
|
||||
|
||||
void SystemReset(void);
|
||||
|
||||
std::unique_ptr<CFile> m_hLogFile;
|
||||
std::vector<uint8_t> m_Data;
|
||||
char m_Buffer[0x1000];
|
||||
uint32_t m_BufferPos;
|
||||
};
|
|
@ -27,6 +27,7 @@ CMipsMemoryVM::CMipsMemoryVM(CN64System & System, bool SavesReadOnly) :
|
|||
m_CartridgeDomain2Address2Handler(System, System.m_Reg, *this, SavesReadOnly),
|
||||
m_RDRAMRegistersHandler(System.m_Reg),
|
||||
m_DPCommandRegistersHandler(System, System.GetPlugins(), System.m_Reg),
|
||||
m_ISViewerHandler(System),
|
||||
m_MIPSInterfaceHandler(System.m_Reg),
|
||||
m_PeripheralInterfaceHandler(System, *this, System.m_Reg, m_CartridgeDomain2Address2Handler),
|
||||
m_PifRamHandler(*this, System.m_Reg),
|
||||
|
@ -839,6 +840,7 @@ bool CMipsMemoryVM::SW_NonMemory(uint32_t VAddr, uint32_t Value)
|
|||
case 0x05000000: m_CartridgeDomain2Address1Handler.Write32(PAddr, Value, 0xFFFFFFFF); break;
|
||||
case 0x06000000: m_CartridgeDomain1Address1Handler.Write32(PAddr, Value, 0xFFFFFFFF); break;
|
||||
case 0x08000000: m_CartridgeDomain2Address2Handler.Write32(PAddr, Value, 0xFFFFFFFF); break;
|
||||
case 0x13F00000: m_ISViewerHandler.Write32(PAddr, Value, 0xFFFFFFFF); break;
|
||||
case 0x1FC00000: m_PifRamHandler.Write32(PAddr, Value, 0xFFFFFFFF); break;
|
||||
case 0x1FF00000: m_CartridgeDomain1Address3Handler.Write32(PAddr, Value, 0xFFFFFFFF); break;
|
||||
default:
|
||||
|
@ -846,6 +848,10 @@ bool CMipsMemoryVM::SW_NonMemory(uint32_t VAddr, uint32_t Value)
|
|||
{
|
||||
m_RomMemoryHandler.Write32(PAddr, Value, 0xFFFFFFFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <Project64-core\N64System\MemoryHandler\CartridgeDomain2Address1Handler.h>
|
||||
#include <Project64-core\N64System\MemoryHandler\CartridgeDomain2Address2Handler.h>
|
||||
#include <Project64-core\N64System\MemoryHandler\DisplayControlRegHandler.h>
|
||||
#include <Project64-core\N64System\MemoryHandler\ISViewerHandler.h>
|
||||
#include <Project64-core\N64System\MemoryHandler\MIPSInterfaceHandler.h>
|
||||
#include <Project64-core\N64System\MemoryHandler\PeripheralInterfaceHandler.h>
|
||||
#include <Project64-core\N64System\MemoryHandler\PifRamHandler.h>
|
||||
|
@ -176,6 +177,7 @@ private:
|
|||
CartridgeDomain2Address1Handler m_CartridgeDomain2Address1Handler;
|
||||
CartridgeDomain2Address2Handler m_CartridgeDomain2Address2Handler;
|
||||
DisplayControlRegHandler m_DPCommandRegistersHandler;
|
||||
ISViewerHandler m_ISViewerHandler;
|
||||
MIPSInterfaceHandler m_MIPSInterfaceHandler;
|
||||
PeripheralInterfaceHandler m_PeripheralInterfaceHandler;
|
||||
PifRamHandler m_PifRamHandler;
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
<ClCompile Include="N64System\MemoryHandler\CartridgeDomain2Address1Handler.cpp" />
|
||||
<ClCompile Include="N64System\MemoryHandler\CartridgeDomain2Address2Handler.cpp" />
|
||||
<ClCompile Include="N64System\MemoryHandler\DisplayControlRegHandler.cpp" />
|
||||
<ClCompile Include="N64System\MemoryHandler\ISViewerHandler.cpp" />
|
||||
<ClCompile Include="N64System\MemoryHandler\MIPSInterfaceHandler.cpp" />
|
||||
<ClCompile Include="N64System\MemoryHandler\PeripheralInterfaceHandler.cpp" />
|
||||
<ClCompile Include="N64System\MemoryHandler\PifRamHandler.cpp" />
|
||||
|
@ -172,6 +173,7 @@
|
|||
<ClInclude Include="N64System\MemoryHandler\CartridgeDomain2Address1Handler.h" />
|
||||
<ClInclude Include="N64System\MemoryHandler\CartridgeDomain2Address2Handler.h" />
|
||||
<ClInclude Include="N64System\MemoryHandler\DisplayControlRegHandler.h" />
|
||||
<ClInclude Include="N64System\MemoryHandler\ISViewerHandler.h" />
|
||||
<ClInclude Include="N64System\MemoryHandler\MemoryHandler.h" />
|
||||
<ClInclude Include="N64System\MemoryHandler\MIPSInterfaceHandler.h" />
|
||||
<ClInclude Include="N64System\MemoryHandler\PeripheralInterfaceHandler.h" />
|
||||
|
|
|
@ -405,6 +405,9 @@
|
|||
<ClCompile Include="N64System\Mips\R4300iInstruction.cpp">
|
||||
<Filter>Source Files\N64 System\Mips</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="N64System\MemoryHandler\ISViewerHandler.cpp">
|
||||
<Filter>Source Files\N64 System\MemoryHandler</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="stdafx.h">
|
||||
|
@ -791,6 +794,9 @@
|
|||
<ClInclude Include="N64System\Mips\R4300iOpcode.h">
|
||||
<Filter>Header Files\N64 System\Mips</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="N64System\MemoryHandler\ISViewerHandler.h">
|
||||
<Filter>Header Files\N64 System\MemoryHandler</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Version.h.in">
|
||||
|
|
Loading…
Reference in New Issue