ZeldaHLE: Support GBA crypto through command 0C. Reuses the pre-existing GBA crypto code from the separate UCode.
This commit is contained in:
parent
0b1af50316
commit
fbe727b0bb
|
@ -7,49 +7,8 @@
|
||||||
#include "Core/HW/DSPHLE/UCodes/GBA.h"
|
#include "Core/HW/DSPHLE/UCodes/GBA.h"
|
||||||
#include "Core/HW/DSPHLE/UCodes/UCodes.h"
|
#include "Core/HW/DSPHLE/UCodes/UCodes.h"
|
||||||
|
|
||||||
GBAUCode::GBAUCode(DSPHLE *dsphle, u32 crc)
|
void ProcessGBACrypto(u32 address)
|
||||||
: UCodeInterface(dsphle, crc)
|
|
||||||
{
|
{
|
||||||
m_mail_handler.PushMail(DSP_INIT);
|
|
||||||
}
|
|
||||||
|
|
||||||
GBAUCode::~GBAUCode()
|
|
||||||
{
|
|
||||||
m_mail_handler.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GBAUCode::Update()
|
|
||||||
{
|
|
||||||
// check if we have to send something
|
|
||||||
if (!m_mail_handler.IsEmpty())
|
|
||||||
{
|
|
||||||
DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 GBAUCode::GetUpdateMs()
|
|
||||||
{
|
|
||||||
return SConfig::GetInstance().bWii ? 3 : 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GBAUCode::HandleMail(u32 mail)
|
|
||||||
{
|
|
||||||
static bool nextmail_is_mramaddr = false;
|
|
||||||
static bool calc_done = false;
|
|
||||||
|
|
||||||
if (m_upload_setup_in_progress)
|
|
||||||
{
|
|
||||||
PrepareBootUCode(mail);
|
|
||||||
}
|
|
||||||
else if ((mail >> 16 == 0xabba) && !nextmail_is_mramaddr)
|
|
||||||
{
|
|
||||||
nextmail_is_mramaddr = true;
|
|
||||||
}
|
|
||||||
else if (nextmail_is_mramaddr)
|
|
||||||
{
|
|
||||||
nextmail_is_mramaddr = false;
|
|
||||||
u32 mramaddr = mail;
|
|
||||||
|
|
||||||
struct sec_params_t
|
struct sec_params_t
|
||||||
{
|
{
|
||||||
u16 key[2];
|
u16 key[2];
|
||||||
|
@ -61,8 +20,8 @@ void GBAUCode::HandleMail(u32 mail)
|
||||||
} sec_params;
|
} sec_params;
|
||||||
|
|
||||||
// 32 bytes from mram addr to DRAM @ 0
|
// 32 bytes from mram addr to DRAM @ 0
|
||||||
for (int i = 0; i < 8; i++, mramaddr += 4)
|
for (int i = 0; i < 8; i++, address += 4)
|
||||||
((u32*)&sec_params)[i] = HLEMemory_Read_U32(mramaddr);
|
((u32*)&sec_params)[i] = HLEMemory_Read_U32(address);
|
||||||
|
|
||||||
// This is the main decrypt routine
|
// This is the main decrypt routine
|
||||||
u16 x11 = 0, x12 = 0,
|
u16 x11 = 0, x12 = 0,
|
||||||
|
@ -117,10 +76,55 @@ void GBAUCode::HandleMail(u32 mail)
|
||||||
// Done!
|
// Done!
|
||||||
DEBUG_LOG(DSPHLE, "\n%08x -> key: %08x, len: %08x, dest_addr: %08x, unk1: %08x, unk2: %08x"
|
DEBUG_LOG(DSPHLE, "\n%08x -> key: %08x, len: %08x, dest_addr: %08x, unk1: %08x, unk2: %08x"
|
||||||
" 22: %04x, 23: %04x",
|
" 22: %04x, 23: %04x",
|
||||||
mramaddr,
|
address,
|
||||||
*(u32*)sec_params.key, sec_params.length, sec_params.dest_addr,
|
*(u32*)sec_params.key, sec_params.length, sec_params.dest_addr,
|
||||||
*(u32*)sec_params.unk1, *(u32*)sec_params.unk2,
|
*(u32*)sec_params.unk1, *(u32*)sec_params.unk2,
|
||||||
x22, x23);
|
x22, x23);
|
||||||
|
}
|
||||||
|
|
||||||
|
GBAUCode::GBAUCode(DSPHLE *dsphle, u32 crc)
|
||||||
|
: UCodeInterface(dsphle, crc)
|
||||||
|
{
|
||||||
|
m_mail_handler.PushMail(DSP_INIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
GBAUCode::~GBAUCode()
|
||||||
|
{
|
||||||
|
m_mail_handler.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GBAUCode::Update()
|
||||||
|
{
|
||||||
|
// check if we have to send something
|
||||||
|
if (!m_mail_handler.IsEmpty())
|
||||||
|
{
|
||||||
|
DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 GBAUCode::GetUpdateMs()
|
||||||
|
{
|
||||||
|
return SConfig::GetInstance().bWii ? 3 : 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GBAUCode::HandleMail(u32 mail)
|
||||||
|
{
|
||||||
|
static bool nextmail_is_mramaddr = false;
|
||||||
|
static bool calc_done = false;
|
||||||
|
|
||||||
|
if (m_upload_setup_in_progress)
|
||||||
|
{
|
||||||
|
PrepareBootUCode(mail);
|
||||||
|
}
|
||||||
|
else if ((mail >> 16 == 0xabba) && !nextmail_is_mramaddr)
|
||||||
|
{
|
||||||
|
nextmail_is_mramaddr = true;
|
||||||
|
}
|
||||||
|
else if (nextmail_is_mramaddr)
|
||||||
|
{
|
||||||
|
nextmail_is_mramaddr = false;
|
||||||
|
|
||||||
|
ProcessGBACrypto(mail);
|
||||||
|
|
||||||
calc_done = true;
|
calc_done = true;
|
||||||
m_mail_handler.PushMail(DSP_DONE);
|
m_mail_handler.PushMail(DSP_DONE);
|
||||||
|
|
|
@ -6,6 +6,11 @@
|
||||||
|
|
||||||
#include "Core/HW/DSPHLE/UCodes/UCodes.h"
|
#include "Core/HW/DSPHLE/UCodes/UCodes.h"
|
||||||
|
|
||||||
|
// Computes two 32 bit integers to be returned to the game, based on the
|
||||||
|
// provided crypto parameters at the provided MRAM address. The integers are
|
||||||
|
// written back to RAM at the dest address provided in the crypto parameters.
|
||||||
|
void ProcessGBACrypto(u32 address);
|
||||||
|
|
||||||
struct GBAUCode : public UCodeInterface
|
struct GBAUCode : public UCodeInterface
|
||||||
{
|
{
|
||||||
GBAUCode(DSPHLE *dsphle, u32 crc);
|
GBAUCode(DSPHLE *dsphle, u32 crc);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
#include "Core/HW/DSPHLE/MailHandler.h"
|
#include "Core/HW/DSPHLE/MailHandler.h"
|
||||||
|
#include "Core/HW/DSPHLE/UCodes/GBA.h"
|
||||||
#include "Core/HW/DSPHLE/UCodes/UCodes.h"
|
#include "Core/HW/DSPHLE/UCodes/UCodes.h"
|
||||||
#include "Core/HW/DSPHLE/UCodes/Zelda.h"
|
#include "Core/HW/DSPHLE/UCodes/Zelda.h"
|
||||||
|
|
||||||
|
@ -474,8 +475,7 @@ void ZeldaUCode::RunPendingCommands()
|
||||||
case 0x0C:
|
case 0x0C:
|
||||||
if (m_flags & SUPPORTS_GBA_CRYPTO)
|
if (m_flags & SUPPORTS_GBA_CRYPTO)
|
||||||
{
|
{
|
||||||
// TODO
|
ProcessGBACrypto(Read32());
|
||||||
NOTICE_LOG(DSPHLE, "Received an unhandled GBA crypto command, param: %08x", Read32());
|
|
||||||
}
|
}
|
||||||
else if (m_flags & WEIRD_CMD_0C)
|
else if (m_flags & WEIRD_CMD_0C)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue