From aef22c147b48508a9c6fac6c0725edd8d3737242 Mon Sep 17 00:00:00 2001 From: luigiblood Date: Sun, 28 Aug 2016 18:36:56 +0200 Subject: [PATCH 1/2] [64DD] Added TOOL/USA IPL support --- Source/Project64-core/N64System/Mips/Dma.cpp | 1 + Source/Project64-core/N64System/N64Class.cpp | 7 +++++-- Source/Project64-core/N64System/N64RomClass.cpp | 2 ++ Source/Project64-core/N64System/N64Types.h | 2 +- Source/Project64/UserInterface/RomBrowserClass.cpp | 4 ++++ Source/Project64/UserInterface/RomInformationClass.cpp | 1 + 6 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Source/Project64-core/N64System/Mips/Dma.cpp b/Source/Project64-core/N64System/Mips/Dma.cpp index 26d62defa..abfa03ab3 100644 --- a/Source/Project64-core/N64System/Mips/Dma.cpp +++ b/Source/Project64-core/N64System/Mips/Dma.cpp @@ -37,6 +37,7 @@ void CDMA::OnFirstDMA() case CIC_NUS_6101: offset = +0x0318; break; case CIC_NUS_5167: offset = +0x0318; break; case CIC_NUS_8303: offset = +0x0318; break; + case CIC_NUS_DDUS: offset = +0x0318; break; case CIC_UNKNOWN: case CIC_NUS_6102: offset = +0x0318; break; case CIC_NUS_6103: offset = +0x0318; break; diff --git a/Source/Project64-core/N64System/N64Class.cpp b/Source/Project64-core/N64System/N64Class.cpp index 5db5bad7b..8ba9ab41d 100644 --- a/Source/Project64-core/N64System/N64Class.cpp +++ b/Source/Project64-core/N64System/N64Class.cpp @@ -271,7 +271,7 @@ bool CN64System::RunFileImage(const char * FileLoc) WriteTrace(TraceN64System, TraceDebug, "Loading \"%s\"", FileLoc); if (g_Rom->LoadN64Image(FileLoc)) { - if (g_Rom->CicChipID() == CIC_NUS_8303) + if (g_Rom->CicChipID() == CIC_NUS_8303 || g_Rom->CicChipID() == CIC_NUS_DDUS) { //64DD IPL if (g_DDRom == NULL) @@ -356,7 +356,7 @@ bool CN64System::RunFileImageIPL(const char * FileLoc) WriteTrace(TraceN64System, TraceDebug, "Loading \"%s\"", FileLoc); if (g_DDRom->LoadN64ImageIPL(FileLoc)) { - if (g_DDRom->CicChipID() != CIC_NUS_8303) + if (g_DDRom->CicChipID() != CIC_NUS_8303 && g_DDRom->CicChipID() != CIC_NUS_DDUS) { //If not 64DD IPL then it's wrong WriteTrace(TraceN64System, TraceError, "LoadN64ImageIPL failed (\"%s\")", FileLoc); @@ -885,6 +885,9 @@ void CN64System::InitRegisters(bool bPostPif, CMipsMemoryVM & MMU) case CIC_NUS_5167: //64DD CONVERSION CIC m_Reg.m_GPR[22].DW = 0x00000000000000DD; break; + case CIC_NUS_DDUS: //64DD US IPL CIC + m_Reg.m_GPR[22].DW = 0x00000000000000DE; + break; case CIC_UNKNOWN: case CIC_NUS_6102: m_Reg.m_GPR[1].DW = 0x0000000000000001; diff --git a/Source/Project64-core/N64System/N64RomClass.cpp b/Source/Project64-core/N64System/N64RomClass.cpp index 7f6097829..2ba038ad6 100644 --- a/Source/Project64-core/N64System/N64RomClass.cpp +++ b/Source/Project64-core/N64System/N64RomClass.cpp @@ -288,6 +288,8 @@ CICChip CN64Rom::GetCicChipID(uint8_t * RomData, uint64_t * CRC) case 0x000000D6D5BE5580: return CIC_NUS_6106; case 0x000001053BC19870: return CIC_NUS_5167; //64DD CONVERSION CIC case 0x000000D2E53EF008: return CIC_NUS_8303; //64DD IPL + case 0x000000D2E53EF39F: return CIC_NUS_8303; //64DD IPL TOOL + case 0x000000D2E53E5DDA: return CIC_NUS_DDUS; //64DD IPL US (different CIC) default: return CIC_UNKNOWN; } diff --git a/Source/Project64-core/N64System/N64Types.h b/Source/Project64-core/N64System/N64Types.h index 0d4043f97..ed64221c7 100644 --- a/Source/Project64-core/N64System/N64Types.h +++ b/Source/Project64-core/N64System/N64Types.h @@ -65,7 +65,7 @@ enum CICChip { CIC_UNKNOWN = -1, CIC_NUS_6101 = 1, CIC_NUS_6102 = 2, CIC_NUS_6103 = 3, CIC_NUS_6104 = 4, CIC_NUS_6105 = 5, CIC_NUS_6106 = 6, CIC_NUS_5167 = 7, - CIC_NUS_8303 = 8 + CIC_NUS_8303 = 8, CIC_NUS_DDUS = 9 }; enum Country diff --git a/Source/Project64/UserInterface/RomBrowserClass.cpp b/Source/Project64/UserInterface/RomBrowserClass.cpp index feb1cb310..0cd5a496f 100644 --- a/Source/Project64/UserInterface/RomBrowserClass.cpp +++ b/Source/Project64/UserInterface/RomBrowserClass.cpp @@ -735,6 +735,10 @@ void CRomBrowser::RomList_GetDispInfo(uint32_t pnmh) { swprintf(lpdi->item.pszText, lpdi->item.cchTextMax / sizeof(wchar_t), L"CIC-NUS-5167", pRomInfo->CicChip); } + else if (pRomInfo->CicChip == CIC_NUS_DDUS) + { + swprintf(lpdi->item.pszText, lpdi->item.cchTextMax / sizeof(wchar_t), L"CIC-NUS-????", pRomInfo->CicChip); + } else { swprintf(lpdi->item.pszText, lpdi->item.cchTextMax / sizeof(wchar_t), L"CIC-NUS-610%d", pRomInfo->CicChip); diff --git a/Source/Project64/UserInterface/RomInformationClass.cpp b/Source/Project64/UserInterface/RomInformationClass.cpp index abb4c2c30..7bddc61f6 100644 --- a/Source/Project64/UserInterface/RomInformationClass.cpp +++ b/Source/Project64/UserInterface/RomInformationClass.cpp @@ -117,6 +117,7 @@ DWORD CALLBACK RomInfoProc(HWND hDlg, DWORD uMsg, DWORD wParam, DWORD lParam) case CIC_UNKNOWN: CicChip = L"Unknown"; break; case CIC_NUS_8303: CicChip = L"CIC-NUS-8303"; break; case CIC_NUS_5167: CicChip = L"CIC-NUS-5167"; break; + case CIC_NUS_DDUS: CicChip = L"CIC-NUS-????"; break; default: CicChip = stdstr_f("CIC-NUS-610%d", _this->m_pRomInfo->CicChipID()).ToUTF16(); break; } SetDlgItemTextW(hDlg, IDC_INFO_CIC, CicChip.c_str()); From b08305015929fc86a3b7b3f164e7e91b3cd7ec7d Mon Sep 17 00:00:00 2001 From: luigiblood Date: Sun, 28 Aug 2016 18:37:16 +0200 Subject: [PATCH 2/2] [64DD] US region disk dump support --- Source/Project64-core/N64System/N64DiskClass.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/Project64-core/N64System/N64DiskClass.cpp b/Source/Project64-core/N64System/N64DiskClass.cpp index 4eb7d3c94..ef5b4869e 100644 --- a/Source/Project64-core/N64System/N64DiskClass.cpp +++ b/Source/Project64-core/N64System/N64DiskClass.cpp @@ -115,6 +115,7 @@ void CN64Disk::SwapDiskImage(const char * FileLoc) bool CN64Disk::IsValidDiskImage(uint8_t Test[4]) { if (*((uint32_t *)&Test[0]) == 0x16D348E8) { return true; } + else if (*((uint32_t *)&Test[0]) == 0x56EE6322) { return true; } return false; } @@ -248,6 +249,7 @@ void CN64Disk::ByteSwapDisk() switch (*((uint32_t *)&m_DiskImage[0])) { case 0x16D348E8: + case 0x56EE6322: for (count = 0; count < m_DiskFileSize; count += 4) { m_DiskImage[count] ^= m_DiskImage[count + 3]; @@ -259,6 +261,7 @@ void CN64Disk::ByteSwapDisk() } break; case 0xE848D316: break; + case 0x2263EE56: break; default: g_Notify->DisplayError(stdstr_f("ByteSwapDisk: %X", m_DiskImage[0]).c_str()); }