DSPHLE: Cleanup ROM.{cpp,h}
This commit is contained in:
parent
090e7637c8
commit
18ca5b880e
|
@ -7,17 +7,18 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "Common/Hash.h"
|
#include "Common/Hash.h"
|
||||||
|
#include "Common/StringUtil.h"
|
||||||
|
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
#include "Core/HW/Memmap.h"
|
#include "Core/HW/Memmap.h"
|
||||||
#include "Core/HW/DSPHLE/UCodes/ROM.h"
|
#include "Core/HW/DSPHLE/UCodes/ROM.h"
|
||||||
#include "Core/HW/DSPHLE/UCodes/UCodes.h"
|
#include "Core/HW/DSPHLE/UCodes/UCodes.h"
|
||||||
|
|
||||||
ROMUCode::ROMUCode(DSPHLE *dsp_hle, u32 crc)
|
ROMUCode::ROMUCode(DSPHLE *dsphle, u32 crc)
|
||||||
: UCodeInterface(dsp_hle, crc)
|
: UCodeInterface(dsphle, crc)
|
||||||
, m_CurrentUCode()
|
, m_current_ucode()
|
||||||
, m_BootTask_numSteps(0)
|
, m_boot_task_num_steps(0)
|
||||||
, m_NextParameter(0)
|
, m_next_parameter(0)
|
||||||
{
|
{
|
||||||
DEBUG_LOG(DSPHLE, "UCode_Rom - initialized");
|
DEBUG_LOG(DSPHLE, "UCode_Rom - initialized");
|
||||||
m_mail_handler.Clear();
|
m_mail_handler.Clear();
|
||||||
|
@ -30,46 +31,46 @@ ROMUCode::~ROMUCode()
|
||||||
void ROMUCode::Update(int cycles)
|
void ROMUCode::Update(int cycles)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void ROMUCode::HandleMail(u32 _uMail)
|
void ROMUCode::HandleMail(u32 mail)
|
||||||
{
|
{
|
||||||
if (m_NextParameter == 0)
|
if (m_next_parameter == 0)
|
||||||
{
|
{
|
||||||
// wait for beginning of UCode
|
// wait for beginning of UCode
|
||||||
if ((_uMail & 0xFFFF0000) != 0x80F30000)
|
if ((mail & 0xFFFF0000) != 0x80F30000)
|
||||||
{
|
{
|
||||||
u32 Message = 0xFEEE0000 | (_uMail & 0xFFFF);
|
u32 Message = 0xFEEE0000 | (mail & 0xFFFF);
|
||||||
m_mail_handler.PushMail(Message);
|
m_mail_handler.PushMail(Message);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_NextParameter = _uMail;
|
m_next_parameter = mail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (m_NextParameter)
|
switch (m_next_parameter)
|
||||||
{
|
{
|
||||||
case 0x80F3A001:
|
case 0x80F3A001:
|
||||||
m_CurrentUCode.m_RAMAddress = _uMail;
|
m_current_ucode.m_ram_address = mail;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x80F3A002:
|
case 0x80F3A002:
|
||||||
m_CurrentUCode.m_Length = _uMail & 0xffff;
|
m_current_ucode.m_length = mail & 0xffff;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x80F3B002:
|
case 0x80F3B002:
|
||||||
m_CurrentUCode.m_DMEMLength = _uMail & 0xffff;
|
m_current_ucode.m_dmem_length = mail & 0xffff;
|
||||||
if (m_CurrentUCode.m_DMEMLength) {
|
if (m_current_ucode.m_dmem_length) {
|
||||||
NOTICE_LOG(DSPHLE,"m_CurrentUCode.m_DMEMLength = 0x%04x.", m_CurrentUCode.m_DMEMLength);
|
NOTICE_LOG(DSPHLE,"m_current_ucode.m_dmem_length = 0x%04x.", m_current_ucode.m_dmem_length);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x80F3C002:
|
case 0x80F3C002:
|
||||||
m_CurrentUCode.m_IMEMAddress = _uMail & 0xffff;
|
m_current_ucode.m_imem_address = mail & 0xffff;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x80F3D001:
|
case 0x80F3D001:
|
||||||
m_CurrentUCode.m_StartPC = _uMail & 0xffff;
|
m_current_ucode.m_start_pc = mail & 0xffff;
|
||||||
BootUCode();
|
BootUCode();
|
||||||
return; // Important! BootUCode indirectly does "delete this;". Must exit immediately.
|
return; // Important! BootUCode indirectly does "delete this;". Must exit immediately.
|
||||||
|
|
||||||
|
@ -78,29 +79,33 @@ void ROMUCode::HandleMail(u32 _uMail)
|
||||||
}
|
}
|
||||||
|
|
||||||
// THE GODDAMN OVERWRITE WAS HERE. Without the return above, since BootUCode may delete "this", well ...
|
// THE GODDAMN OVERWRITE WAS HERE. Without the return above, since BootUCode may delete "this", well ...
|
||||||
m_NextParameter = 0;
|
m_next_parameter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ROMUCode::BootUCode()
|
void ROMUCode::BootUCode()
|
||||||
{
|
{
|
||||||
u32 ector_crc = HashEctor(
|
u32 ector_crc = HashEctor(
|
||||||
(u8*)HLEMemory_Get_Pointer(m_CurrentUCode.m_RAMAddress),
|
(u8*)HLEMemory_Get_Pointer(m_current_ucode.m_ram_address),
|
||||||
m_CurrentUCode.m_Length);
|
m_current_ucode.m_length);
|
||||||
|
|
||||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||||
char binFile[MAX_PATH];
|
std::string ucode_dump_path = StringFromFormat(
|
||||||
sprintf(binFile, "%sDSP_UC_%08X.bin", File::GetUserPath(D_DUMPDSP_IDX).c_str(), ector_crc);
|
"%sDSP_UC_%08X.bin", File::GetUserPath(D_DUMPDSP_IDX).c_str(), ector_crc);
|
||||||
|
|
||||||
File::IOFile pFile(binFile, "wb");
|
File::IOFile fp(ucode_dump_path, "wb");
|
||||||
pFile.WriteArray((u8*)Memory::GetPointer(m_CurrentUCode.m_RAMAddress), m_CurrentUCode.m_Length);
|
if (fp)
|
||||||
|
{
|
||||||
|
fp.WriteArray((u8*)HLEMemory_Get_Pointer(m_current_ucode.m_ram_address),
|
||||||
|
m_current_ucode.m_length);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DEBUG_LOG(DSPHLE, "CurrentUCode SOURCE Addr: 0x%08x", m_CurrentUCode.m_RAMAddress);
|
DEBUG_LOG(DSPHLE, "CurrentUCode SOURCE Addr: 0x%08x", m_current_ucode.m_ram_address);
|
||||||
DEBUG_LOG(DSPHLE, "CurrentUCode Length: 0x%08x", m_CurrentUCode.m_Length);
|
DEBUG_LOG(DSPHLE, "CurrentUCode Length: 0x%08x", m_current_ucode.m_length);
|
||||||
DEBUG_LOG(DSPHLE, "CurrentUCode DEST Addr: 0x%08x", m_CurrentUCode.m_IMEMAddress);
|
DEBUG_LOG(DSPHLE, "CurrentUCode DEST Addr: 0x%08x", m_current_ucode.m_imem_address);
|
||||||
DEBUG_LOG(DSPHLE, "CurrentUCode DMEM Length: 0x%08x", m_CurrentUCode.m_DMEMLength);
|
DEBUG_LOG(DSPHLE, "CurrentUCode DMEM Length: 0x%08x", m_current_ucode.m_dmem_length);
|
||||||
DEBUG_LOG(DSPHLE, "CurrentUCode init_vector: 0x%08x", m_CurrentUCode.m_StartPC);
|
DEBUG_LOG(DSPHLE, "CurrentUCode init_vector: 0x%08x", m_current_ucode.m_start_pc);
|
||||||
DEBUG_LOG(DSPHLE, "CurrentUCode CRC: 0x%08x", ector_crc);
|
DEBUG_LOG(DSPHLE, "CurrentUCode CRC: 0x%08x", ector_crc);
|
||||||
DEBUG_LOG(DSPHLE, "BootTask - done");
|
DEBUG_LOG(DSPHLE, "BootTask - done");
|
||||||
|
|
||||||
|
@ -114,9 +119,9 @@ u32 ROMUCode::GetUpdateMs()
|
||||||
|
|
||||||
void ROMUCode::DoState(PointerWrap &p)
|
void ROMUCode::DoState(PointerWrap &p)
|
||||||
{
|
{
|
||||||
p.Do(m_CurrentUCode);
|
p.Do(m_current_ucode);
|
||||||
p.Do(m_BootTask_numSteps);
|
p.Do(m_boot_task_num_steps);
|
||||||
p.Do(m_NextParameter);
|
p.Do(m_next_parameter);
|
||||||
|
|
||||||
DoStateShared(p);
|
DoStateShared(p);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,28 +9,28 @@
|
||||||
class ROMUCode : public UCodeInterface
|
class ROMUCode : public UCodeInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ROMUCode(DSPHLE *dsp_hle, u32 _crc);
|
ROMUCode(DSPHLE *dsphle, u32 crc);
|
||||||
virtual ~ROMUCode();
|
virtual ~ROMUCode();
|
||||||
u32 GetUpdateMs() override;
|
u32 GetUpdateMs() override;
|
||||||
|
|
||||||
void HandleMail(u32 _uMail) override;
|
void HandleMail(u32 mail) override;
|
||||||
void Update(int cycles) override;
|
void Update(int cycles) override;
|
||||||
|
|
||||||
void DoState(PointerWrap &p) override;
|
void DoState(PointerWrap &p) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct SUCode
|
struct UCodeBootInfo
|
||||||
{
|
{
|
||||||
u32 m_RAMAddress;
|
u32 m_ram_address;
|
||||||
u32 m_Length;
|
u32 m_length;
|
||||||
u32 m_IMEMAddress;
|
u32 m_imem_address;
|
||||||
u32 m_DMEMLength;
|
u32 m_dmem_length;
|
||||||
u32 m_StartPC;
|
u32 m_start_pc;
|
||||||
};
|
};
|
||||||
SUCode m_CurrentUCode;
|
UCodeBootInfo m_current_ucode;
|
||||||
int m_BootTask_numSteps;
|
int m_boot_task_num_steps;
|
||||||
|
|
||||||
u32 m_NextParameter;
|
u32 m_next_parameter;
|
||||||
|
|
||||||
void BootUCode();
|
void BootUCode();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue