Handle 64DD loading from ROM Browser, Recent Games, RomInfo

Partially handles settings (loads from RDB and CFG, but unused as emulation starts)
This commit is contained in:
LuigiBlood 2019-01-25 08:11:40 +01:00
parent 2d8afa9217
commit cd80e4f0a4
11 changed files with 462 additions and 151 deletions

View File

@ -344,9 +344,12 @@ bool CN64System::LoadFileImage(const char * FileLoc)
g_Settings->SaveBool(Setting_EnableDisk, true);
}
g_System->RefreshGameSettings();
g_System->RefreshGameSettings();
g_Settings->SaveString(Game_File, FileLoc);
if (g_Rom->CicChipID() != CIC_NUS_8303 && g_Rom->CicChipID() != CIC_NUS_DDUS)
{
g_Settings->SaveString(Game_File, FileLoc);
}
g_Settings->SaveBool(GameRunning_LoadingInProgress, false);
WriteTrace(TraceN64System, TraceDebug, "Finished Loading (GoodName: %s)", g_Settings->LoadStringVal(Rdb_GoodName).c_str());
@ -371,6 +374,11 @@ bool CN64System::RunFileImage(const char * FileLoc)
{
return false;
}
if (g_Rom == g_DDRom && g_Rom != NULL && g_DDRom != NULL && g_Disk != NULL)
{
g_Settings->SaveString(Game_IniKey, g_Disk->GetDiskIdent().c_str());
g_System->RefreshGameSettings();
}
if (g_Settings->LoadBool(Setting_AutoStart) != 0)
{
WriteTrace(TraceN64System, TraceDebug, "Automattically starting rom");
@ -451,7 +459,7 @@ bool CN64System::RunFileImageIPL(const char * FileLoc)
return true;
}
bool CN64System::RunDiskImage(const char * FileLoc)
bool CN64System::RunDiskImage(const char * FileLoc, const bool Expansion)
{
CloseSystem();
if (g_Settings->LoadBool(GameRunning_LoadingInProgress))
@ -480,7 +488,10 @@ bool CN64System::RunDiskImage(const char * FileLoc)
{
g_System->RefreshGameSettings();
//g_Settings->SaveString(Game_File, FileLoc);
if (!Expansion)
{
g_Settings->SaveString(Game_File, FileLoc);
}
g_Settings->SaveBool(GameRunning_LoadingInProgress, false);
}
else

View File

@ -60,7 +60,7 @@ public:
static bool LoadFileImage(const char * FileLoc);
static bool RunFileImage(const char * FileLoc);
static bool RunFileImageIPL(const char * FileLoc);
static bool RunDiskImage(const char * FileLoc);
static bool RunDiskImage(const char * FileLoc, const bool Expansion);
static void RunLoadedImage(void);
static void CloseSystem(void);

View File

@ -50,12 +50,24 @@ bool CN64Disk::LoadDiskImage(const char * FileLoc)
}
}
if (g_Disk == this)
{
g_Settings->SaveBool(GameRunning_LoadingInProgress, false);
}
char RomName[5];
//Get the disk ID from the disk image
RomName[0] = (char)*(m_DiskImage + 0x43673);
RomName[1] = (char)*(m_DiskImage + 0x43672);
RomName[2] = (char)*(m_DiskImage + 0x43671);
RomName[3] = (char)*(m_DiskImage + 0x43670);
RomName[4] = '\0';
m_RomName = RomName;
m_FileName = FileLoc;
m_DiskIdent.Format("%08X-%08X-C:%X", *(uint32_t *)(&m_DiskImage[0]), *(uint32_t *)(&m_DiskImage[0x43670]), m_DiskImage[0x43670]);
m_Country = (Country)m_DiskImage[0x43670];
if (g_Disk == this)
{
g_Settings->SaveBool(GameRunning_LoadingInProgress, false);
SaveDiskSettingID(false);
}
return true;
}
@ -120,6 +132,34 @@ bool CN64Disk::IsValidDiskImage(uint8_t Test[4])
return false;
}
//Save the settings of the loaded rom, so all loaded settings about rom will be identified with
//this rom
void CN64Disk::SaveDiskSettingID(bool temp)
{
g_Settings->SaveBool(Game_TempLoaded, temp);
g_Settings->SaveString(Game_GameName, m_RomName.c_str());
g_Settings->SaveString(Game_IniKey, m_DiskIdent.c_str());
//g_Settings->SaveString(Game_UniqueSaveDir, stdstr_f("%s-%s", m_RomName.c_str(), m_MD5.c_str()).c_str());
switch (GetCountry())
{
case Germany: case french: case Italian:
case Europe: case Spanish: case Australia:
case X_PAL: case Y_PAL:
g_Settings->SaveDword(Game_SystemType, SYSTEM_PAL);
break;
default:
g_Settings->SaveDword(Game_SystemType, SYSTEM_NTSC);
break;
}
}
void CN64Disk::ClearDiskSettingID()
{
g_Settings->SaveString(Game_GameName, "");
g_Settings->SaveString(Game_IniKey, "");
}
bool CN64Disk::AllocateDiskImage(uint32_t DiskFileSize)
{
WriteTrace(TraceN64System, TraceDebug, "Allocating memory for disk");

View File

@ -9,6 +9,8 @@
* *
****************************************************************************/
#pragma once
#include <Project64-core/N64System/N64Types.h>
#include <Common/stdtypes.h>
class CN64Disk
@ -21,9 +23,15 @@ public:
bool SaveDiskImage();
void SwapDiskImage(const char * FileLoc);
static bool IsValidDiskImage(uint8_t Test[4]);
void SaveDiskSettingID(bool temp);
void ClearDiskSettingID();
uint8_t * GetDiskAddress() { return m_DiskImage; }
uint8_t * GetDiskAddressBuffer() { return m_DiskImage + m_DiskBufAddress; }
void SetDiskAddressBuffer(uint32_t address) { m_DiskBufAddress = address; }
stdstr GetRomName() const { return m_RomName; }
stdstr GetFileName() const { return m_FileName; }
stdstr GetDiskIdent() const { return m_DiskIdent; }
Country GetCountry() const { return m_Country; }
void UnallocateDiskImage();
LanguageStringID GetError() const { return m_ErrorMsg; }
@ -48,7 +56,8 @@ private:
uint32_t m_DiskFileSize;
uint32_t m_DiskBufAddress;
LanguageStringID m_ErrorMsg;
stdstr m_FileName, m_DiskIdent;
Country m_Country;
stdstr m_RomName, m_FileName, m_DiskIdent;
uint8_t m_DiskFormat; //0 = MAME, 1 = SDK
//disk convert

View File

@ -12,6 +12,7 @@
#include "RomList.h"
#include <Project64-core/3rdParty/zip.h>
#include <Project64-core/N64System/N64RomClass.h>
#include <Project64-core/N64System/N64DiskClass.h>
#ifdef _WIN32
#include <Project64-core/3rdParty/7zip.h>
@ -32,6 +33,7 @@ static const char* ROM_extensions[] =
"usa",
"eur",
"bin",
"ndd",
};
CRomList::CRomList() :
@ -397,27 +399,46 @@ bool CRomList::LoadDataFromRomFile(const char * FileName, uint8_t * Data, int32_
}
FileFormat = Format_Zip;
}
else
{
CFile File;
if (!File.Open(FileName, CFileBase::modeRead))
{
return false;
}
File.SeekToBegin();
if (!File.Read(Test, sizeof(Test)))
{
return false;
}
if (!CN64Rom::IsValidRomImage(Test))
{
return false;
}
File.SeekToBegin();
if (!File.Read(Data, DataLen))
{
return false;
}
else
{
CFile File;
if (!File.Open(FileName, CFileBase::modeRead))
{
return false;
}
File.SeekToBegin();
if (!File.Read(Test, sizeof(Test)))
{
return false;
}
if (!CN64Rom::IsValidRomImage(Test) && !CN64Disk::IsValidDiskImage(Test))
{
return false;
}
if (CN64Rom::IsValidRomImage(Test))
{
File.SeekToBegin();
if (!File.Read(Data, DataLen))
{
return false;
}
}
if (CN64Disk::IsValidDiskImage(Test))
{
//Is a Disk Image
File.SeekToBegin();
if (!File.Read(Data, 0x20))
{
return false;
}
File.Seek(0x43670, CFileBase::begin);
if (!File.Read(Data + 0x20, 0x20))
{
return false;
}
}
*RomSize = File.GetLength();
FileFormat = Format_Uncompressed;
}
@ -439,19 +460,38 @@ bool CRomList::FillRomInfo(ROM_INFO * pRomInfo)
{
strncpy(pRomInfo->FileName, g_Settings->LoadBool(RomList_ShowFileExtensions) ? CPath(pRomInfo->szFullFileName).GetNameExtension().c_str() : CPath(pRomInfo->szFullFileName).GetName().c_str(), sizeof(pRomInfo->FileName) / sizeof(pRomInfo->FileName[0]));
}
char InternalName[22];
memcpy(InternalName, (void *)(RomData + 0x20), 20);
CN64Rom::CleanRomName(InternalName);
strcpy(pRomInfo->InternalName, InternalName);
pRomInfo->CartID[0] = *(RomData + 0x3F);
pRomInfo->CartID[1] = *(RomData + 0x3E);
pRomInfo->CartID[2] = '\0';
pRomInfo->Manufacturer = *(RomData + 0x38);
pRomInfo->Country = *(RomData + 0x3D);
pRomInfo->CRC1 = *(uint32_t *)(RomData + 0x10);
pRomInfo->CRC2 = *(uint32_t *)(RomData + 0x14);
pRomInfo->CicChip = CN64Rom::GetCicChipID(RomData);
FillRomExtensionInfo(pRomInfo);
if (CPath(pRomInfo->szFullFileName).GetExtension() != "ndd")
{
char InternalName[22];
memcpy(InternalName, (void *)(RomData + 0x20), 20);
CN64Rom::CleanRomName(InternalName);
strcpy(pRomInfo->InternalName, InternalName);
pRomInfo->CartID[0] = *(RomData + 0x3F);
pRomInfo->CartID[1] = *(RomData + 0x3E);
pRomInfo->CartID[2] = '\0';
pRomInfo->Manufacturer = *(RomData + 0x38);
pRomInfo->Country = *(RomData + 0x3D);
pRomInfo->CRC1 = *(uint32_t *)(RomData + 0x10);
pRomInfo->CRC2 = *(uint32_t *)(RomData + 0x14);
pRomInfo->CicChip = CN64Rom::GetCicChipID(RomData);
FillRomExtensionInfo(pRomInfo);
}
else
{
char InternalName[22];
memcpy(InternalName, (void *)(RomData + 0x20), 4);
strcpy(pRomInfo->InternalName, InternalName);
pRomInfo->CartID[0] = *(RomData + 0x20);
pRomInfo->CartID[1] = *(RomData + 0x21);
pRomInfo->CartID[2] = *(RomData + 0x22);
pRomInfo->Manufacturer = '\0';
pRomInfo->Country = *(RomData + 0x20);
pRomInfo->CRC1 = *(uint32_t *)(RomData + 0x00);
pRomInfo->CRC2 = *(uint32_t *)(RomData + 0x20);
pRomInfo->CicChip = CIC_NUS_8303;
FillRomExtensionInfo(pRomInfo);
}
return true;
}
return false;
@ -525,6 +565,9 @@ void CRomList::ByteSwapRomData(uint8_t * Data, int32_t DataLen)
switch (*((uint32_t *)&Data[0]))
{
case 0x12408037:
case 0x07408027: //64DD IPL
case 0xD316E848: //64DD JP Disk
case 0xEE562263: //64DD US Disk
for (count = 0; count < DataLen; count += 4)
{
Data[count] ^= Data[count + 2];
@ -536,6 +579,8 @@ void CRomList::ByteSwapRomData(uint8_t * Data, int32_t DataLen)
}
break;
case 0x40072780: //64DD IPL
case 0x16D348E8: //64DD JP Disk
case 0x56EE6322: //64DD US Disk
case 0x40123780:
for (count = 0; count < DataLen; count += 4)
{
@ -547,7 +592,11 @@ void CRomList::ByteSwapRomData(uint8_t * Data, int32_t DataLen)
Data[count + 1] ^= Data[count + 2];
}
break;
case 0x80371240: break;
case 0x80371240:
case 0x80270740: //64DD IPL
case 0xE848D316: //64DD JP Disk
case 0x2263EE56: //64DD US Disk
break;
}
}

View File

@ -126,7 +126,7 @@ void CMainMenu::OnOpenRom(HWND hWnd)
return;
}
// Open Disk
if (!g_BaseSystem->RunDiskImage(File.c_str()))
if (!g_BaseSystem->RunDiskImage(File.c_str(), false))
{
return;
}
@ -144,7 +144,12 @@ void CMainMenu::OnOpenRom(HWND hWnd)
void CMainMenu::OnRomInfo(HWND hWnd)
{
if (g_Rom)
if (g_Disk)
{
RomInformation Info(g_Disk);
Info.DisplayInformation(hWnd);
}
else if (g_Rom)
{
RomInformation Info(g_Rom);
Info.DisplayInformation(hWnd);
@ -545,7 +550,24 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI
if (UISettingsLoadStringIndex(File_RecentGameFileIndex, MenuID - ID_RECENT_ROM_START, FileName) &&
FileName.length() > 0)
{
g_BaseSystem->RunFileImage(FileName.c_str());
if (CPath(FileName).GetExtension() != "ndd")
g_BaseSystem->RunFileImage(FileName.c_str());
else
{
if (g_BaseSystem->RunDiskImage(FileName.c_str(), false))
{
stdstr IPLROM = g_Settings->LoadStringVal(File_DiskIPLPath);
if ((IPLROM.length() <= 0) || (!g_BaseSystem->RunFileImage(IPLROM.c_str())))
{
const char * Filter = "64DD IPL ROM Image (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0";
CPath FileNameIPL;
if (FileNameIPL.SelectFile(hWnd, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true))
{
g_BaseSystem->RunFileImage(FileNameIPL);
}
}
}
}
}
}
if (MenuID >= ID_RECENT_DIR_START && MenuID < ID_RECENT_DIR_END)

View File

@ -13,6 +13,7 @@
#include <commctrl.h>
#include <Project64-core/Settings/SettingType/SettingsType-Application.h>
#include <Project64-core/N64System/N64DiskClass.h>
void EnterLogOptions(HWND hwndOwner);
@ -980,7 +981,30 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO
if (_this == NULL) { break; }
switch (LOWORD(wParam)) {
case ID_POPUPMENU_PLAYGAME: g_BaseSystem->RunFileImage(_this->CurrentedSelectedRom()); break;
case ID_POPUPMENU_PLAYGAME:
{
if (CPath(_this->CurrentedSelectedRom()).GetExtension() != "ndd")
{
g_BaseSystem->RunFileImage(_this->CurrentedSelectedRom());
}
else
{
if (g_BaseSystem->RunDiskImage(_this->CurrentedSelectedRom(), false))
{
stdstr IPLROM = g_Settings->LoadStringVal(File_DiskIPLPath);
if ((IPLROM.length() <= 0) || (!g_BaseSystem->RunFileImage(IPLROM.c_str())))
{
CPath FileName;
const char * Filter = "64DD IPL ROM Image (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0";
if (FileName.SelectFile(hWnd, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true))
{
g_BaseSystem->RunFileImage(FileName);
}
}
}
}
break;
}
case ID_POPUPMENU_PLAYGAMEWITHDISK:
{
stdstr IPLROM = g_Settings->LoadStringVal(File_DiskIPLPath);
@ -995,7 +1019,7 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO
const char * N64DDFilter = "N64DD Disk Image (*.ndd)\0*.ndd\0All files (*.*)\0*.*\0";
if (FileName.SelectFile(hWnd, g_Settings->LoadStringVal(RomList_GameDir).c_str(), N64DDFilter, true))
{
if (g_BaseSystem->RunDiskImage(FileName))
if (g_BaseSystem->RunDiskImage(FileName, true))
{
g_BaseSystem->RunFileImage(_this->CurrentedSelectedRom());
}
@ -1009,7 +1033,7 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO
const char * Filter = "N64DD Disk Image (*.ndd)\0*.ndd\0All files (*.*)\0*.*\0";
if (FileName.SelectFile(hWnd, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true))
{
if (g_BaseSystem->RunDiskImage(FileName))
if (g_BaseSystem->RunDiskImage(FileName, true))
{
g_BaseSystem->RunFileImage(_this->CurrentedSelectedRom());
}
@ -1029,38 +1053,76 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO
case ID_POPUPMENU_EDITCHEATS:
case ID_POPUPMENU_CHOOSEENHANCEMENT:
{
CN64Rom Rom;
Rom.LoadN64Image(_this->CurrentedSelectedRom(), true);
Rom.SaveRomSettingID(true);
if (LOWORD(wParam) == ID_POPUPMENU_EDITSETTINGS)
{
CSettingConfig SettingConfig(true);
SettingConfig.Display(hWnd);
}
else if (LOWORD(wParam) == ID_POPUPMENU_CHOOSEENHANCEMENT)
if (CPath(_this->CurrentedSelectedRom()).GetExtension() != "ndd")
{
CEnhancementConfig().Display(hWnd);
}
else if (LOWORD(wParam) == ID_POPUPMENU_EDITCHEATS)
{
CCheatsUI * cheatUI = new CCheatsUI;
g_cheatUI = cheatUI;
cheatUI->SelectCheats(hWnd, true);
if (g_cheatUI == cheatUI)
{
g_cheatUI = NULL;
}
}
CN64Rom Rom;
Rom.LoadN64Image(_this->CurrentedSelectedRom(), true);
Rom.SaveRomSettingID(true);
if (g_Rom)
{
g_Rom->SaveRomSettingID(false);
}
else
{
Rom.ClearRomSettingID();
}
if (LOWORD(wParam) == ID_POPUPMENU_EDITSETTINGS)
{
CSettingConfig SettingConfig(true);
SettingConfig.Display(hWnd);
}
else if (LOWORD(wParam) == ID_POPUPMENU_CHOOSEENHANCEMENT)
{
CEnhancementConfig().Display(hWnd);
}
else if (LOWORD(wParam) == ID_POPUPMENU_EDITCHEATS)
{
CCheatsUI * cheatUI = new CCheatsUI;
g_cheatUI = cheatUI;
cheatUI->SelectCheats(hWnd, true);
if (g_cheatUI == cheatUI)
{
g_cheatUI = NULL;
}
}
if (g_Rom)
{
g_Rom->SaveRomSettingID(false);
}
else
{
Rom.ClearRomSettingID();
}
}
else
{
CN64Disk Disk;
Disk.LoadDiskImage(_this->CurrentedSelectedRom());
Disk.SaveDiskSettingID(true);
if (LOWORD(wParam) == ID_POPUPMENU_EDITSETTINGS)
{
CSettingConfig SettingConfig(true);
SettingConfig.Display(hWnd);
}
else if (LOWORD(wParam) == ID_POPUPMENU_CHOOSEENHANCEMENT)
{
CEnhancementConfig().Display(hWnd);
}
else if (LOWORD(wParam) == ID_POPUPMENU_EDITCHEATS)
{
CCheatsUI * cheatUI = new CCheatsUI;
g_cheatUI = cheatUI;
cheatUI->SelectCheats(hWnd, true);
if (g_cheatUI == cheatUI)
{
g_cheatUI = NULL;
}
}
if (g_Disk)
{
g_Disk->SaveDiskSettingID(false);
}
else
{
Disk.ClearDiskSettingID();
}
}
}
break;
default:
@ -1133,7 +1195,7 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO
else
{
// Open Disk
if (CN64System::RunDiskImage(filename))
if (CN64System::RunDiskImage(filename, false))
{
stdstr IPLROM = g_Settings->LoadStringVal(File_DiskIPLPath);
if ((IPLROM.length() <= 0) || (!CN64System::RunFileImage(IPLROM.c_str())))

View File

@ -807,7 +807,24 @@ void CRomBrowser::RomList_OpenRom(uint32_t /*pnmh*/)
delete g_DDRom;
g_DDRom = NULL;
CN64System::RunFileImage(pRomInfo->szFullFileName);
if (CPath(pRomInfo->szFullFileName).GetExtension() != "ndd")
CN64System::RunFileImage(pRomInfo->szFullFileName);
else
{
if (CN64System::RunDiskImage(pRomInfo->szFullFileName, false))
{
stdstr IPLROM = g_Settings->LoadStringVal(File_DiskIPLPath);
if ((IPLROM.length() <= 0) || (!CN64System::RunFileImage(IPLROM.c_str())))
{
CPath FileName;
const char * Filter = "64DD IPL ROM Image (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0";
if (FileName.SelectFile(m_MainWindow, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true))
{
CN64System::RunFileImage(FileName);
}
}
}
}
}
void CRomBrowser::RomList_PopupMenu(uint32_t /*pnmh*/)

View File

@ -10,33 +10,60 @@
****************************************************************************/
#include "stdafx.h"
#include "RomInformationClass.h"
#include <Project64-core/N64System/N64DiskClass.h>
RomInformation::RomInformation(const char * RomFile) :
m_DeleteRomInfo(true),
m_DeleteDiskInfo(true),
m_FileName(RomFile ? RomFile : ""),
m_pRomInfo(NULL)
m_pRomInfo(NULL),
m_pDiskInfo(NULL)
{
if (m_FileName.length() == 0) { return; }
m_pRomInfo = new CN64Rom;
if (!m_pRomInfo->LoadN64Image(m_FileName.c_str()))
{
delete m_pRomInfo;
m_pRomInfo = NULL;
return;
}
if (CPath(m_FileName).GetExtension() != "ndd")
{
m_pRomInfo = new CN64Rom;
if (!m_pRomInfo->LoadN64Image(m_FileName.c_str()))
{
delete m_pRomInfo;
m_pRomInfo = NULL;
return;
}
}
else
{
m_pDiskInfo = new CN64Disk;
if (!m_pDiskInfo->LoadDiskImage(m_FileName.c_str()))
{
delete m_pDiskInfo;
m_pDiskInfo = NULL;
return;
}
}
}
RomInformation::RomInformation(CN64Rom * RomInfo) :
m_DeleteRomInfo(false),
m_DeleteDiskInfo(false),
m_FileName(RomInfo ? RomInfo->GetFileName().c_str() : ""),
m_pRomInfo(RomInfo)
{
}
RomInformation::RomInformation(CN64Disk * DiskInfo) :
m_DeleteRomInfo(false),
m_DeleteDiskInfo(false),
m_FileName(DiskInfo ? DiskInfo->GetFileName().c_str() : ""),
m_pDiskInfo(DiskInfo)
{
}
RomInformation::~RomInformation()
{
if (m_DeleteRomInfo)
delete m_pRomInfo;
if (m_DeleteDiskInfo)
delete m_pDiskInfo;
}
#include <windows.h>
@ -53,74 +80,145 @@ DWORD CALLBACK RomInfoProc(HWND hDlg, DWORD uMsg, DWORD wParam, DWORD lParam)
{
case WM_INITDIALOG:
{
//record class for future usage
SetProp(hDlg, "this", (RomInformation *)lParam);
RomInformation * _this = (RomInformation *)lParam;
//record class for future usage
SetProp(hDlg, "this", (RomInformation *)lParam);
RomInformation * _this = (RomInformation *)lParam;
SetWindowTextW(hDlg, wGS(INFO_TITLE).c_str());
if (_this->m_pDiskInfo == NULL)
{
SetWindowTextW(hDlg, wGS(INFO_TITLE).c_str());
SetDlgItemTextW(hDlg, IDC_ROM_NAME, wGS(INFO_ROM_NAME_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_FILE_NAME, wGS(INFO_FILE_NAME_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_LOCATION, wGS(INFO_LOCATION_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_ROM_MD5, wGS(INFO_MD5_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_ROM_SIZE, wGS(INFO_SIZE_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_CART_ID, wGS(INFO_CART_ID_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_MANUFACTURER, wGS(INFO_MANUFACTURER_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_COUNTRY, wGS(INFO_COUNTRY_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_CRC1, wGS(INFO_CRC1_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_CRC2, wGS(INFO_CRC2_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_CIC_CHIP, wGS(INFO_CIC_CHIP_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_CLOSE_BUTTON, wGS(BOTTOM_CLOSE).c_str());
SetDlgItemTextW(hDlg, IDC_ROM_NAME, wGS(INFO_ROM_NAME_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_FILE_NAME, wGS(INFO_FILE_NAME_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_LOCATION, wGS(INFO_LOCATION_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_ROM_MD5, wGS(INFO_MD5_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_ROM_SIZE, wGS(INFO_SIZE_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_CART_ID, wGS(INFO_CART_ID_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_MANUFACTURER, wGS(INFO_MANUFACTURER_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_COUNTRY, wGS(INFO_COUNTRY_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_CRC1, wGS(INFO_CRC1_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_CRC2, wGS(INFO_CRC2_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_CIC_CHIP, wGS(INFO_CIC_CHIP_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_CLOSE_BUTTON, wGS(BOTTOM_CLOSE).c_str());
SetDlgItemTextW(hDlg, IDC_INFO_ROMNAME, _this->m_pRomInfo->GetRomName().ToUTF16(stdstr::CODEPAGE_932).c_str());
SetDlgItemTextW(hDlg, IDC_INFO_ROMNAME, _this->m_pRomInfo->GetRomName().ToUTF16(stdstr::CODEPAGE_932).c_str());
SetDlgItemTextW(hDlg, IDC_INFO_FILENAME, stdstr(CPath(_this->m_pRomInfo->GetFileName()).GetNameExtension()).ToUTF16(CP_ACP).c_str());
SetDlgItemTextW(hDlg, IDC_INFO_LOCATION, stdstr(CPath(_this->m_pRomInfo->GetFileName()).GetDriveDirectory()).ToUTF16(CP_ACP).c_str());
SetDlgItemTextW(hDlg, IDC_INFO_FILENAME, stdstr(CPath(_this->m_pRomInfo->GetFileName()).GetNameExtension()).ToUTF16(CP_ACP).c_str());
SetDlgItemTextW(hDlg, IDC_INFO_LOCATION, stdstr(CPath(_this->m_pRomInfo->GetFileName()).GetDriveDirectory()).ToUTF16(CP_ACP).c_str());
SetDlgItemTextW(hDlg, IDC_INFO_MD5, _this->m_pRomInfo->GetRomMD5().ToUTF16().c_str());
SetDlgItemTextW(hDlg, IDC_INFO_ROMSIZE, stdstr_f("%.1f MBit", (float)_this->m_pRomInfo->GetRomSize() / 0x20000).ToUTF16().c_str());
SetDlgItemTextW(hDlg, IDC_INFO_MD5, _this->m_pRomInfo->GetRomMD5().ToUTF16().c_str());
SetDlgItemTextW(hDlg, IDC_INFO_ROMSIZE, stdstr_f("%.1f MBit", (float)_this->m_pRomInfo->GetRomSize() / 0x20000).ToUTF16().c_str());
BYTE * RomHeader = _this->m_pRomInfo->GetRomAddress();
SetDlgItemTextW(hDlg, IDC_INFO_CARTID, stdstr_f("%c%c", RomHeader[0x3F], RomHeader[0x3E]).ToUTF16().c_str());
BYTE * RomHeader = _this->m_pRomInfo->GetRomAddress();
SetDlgItemTextW(hDlg, IDC_INFO_CARTID, stdstr_f("%c%c", RomHeader[0x3F], RomHeader[0x3E]).ToUTF16().c_str());
switch (RomHeader[0x38])
{
case 'N': SetDlgItemTextW(hDlg, IDC_INFO_MANUFACTURER, L"Nintendo"); break;
case 0: SetDlgItemTextW(hDlg, IDC_INFO_MANUFACTURER, L"None"); break;
default: SetDlgItemTextW(hDlg, IDC_INFO_MANUFACTURER, L"(Unknown)"); break;
}
switch (RomHeader[0x38])
{
case 'N': SetDlgItemTextW(hDlg, IDC_INFO_MANUFACTURER, L"Nintendo"); break;
case 0: SetDlgItemTextW(hDlg, IDC_INFO_MANUFACTURER, L"None"); break;
default: SetDlgItemTextW(hDlg, IDC_INFO_MANUFACTURER, L"(Unknown)"); break;
}
switch (RomHeader[0x3D])
{
case NTSC_BETA: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"Beta"); break;
case X_NTSC: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"NTSC"); break;
case Germany: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"Germany"); break;
case USA: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"America"); break;
case french: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"France"); break;
case Italian: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"Italy"); break;
case Japan: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"Japan"); break;
case Europe: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"Europe"); break;
case Spanish: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"Spain"); break;
case Australia: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"Australia"); break;
case X_PAL: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"PAL"); break;
case Y_PAL: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"PAL"); break;
case 0: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"None"); break;
default:
SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, stdstr_f(" Unknown %c (%02X)", RomHeader[0x3D], RomHeader[0x3D]).ToUTF16().c_str());
}
SetDlgItemTextW(hDlg, IDC_INFO_CRC1, stdstr_f("0x%08X", *(uint32_t *)(RomHeader + 0x10)).ToUTF16().c_str());
SetDlgItemTextW(hDlg, IDC_INFO_CRC2, stdstr_f("0x%08X", *(DWORD *)(RomHeader + 0x14)).ToUTF16().c_str());
switch (RomHeader[0x3D])
{
case NTSC_BETA: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"Beta"); break;
case X_NTSC: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"NTSC"); break;
case Germany: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"Germany"); break;
case USA: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"America"); break;
case french: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"France"); break;
case Italian: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"Italy"); break;
case Japan: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"Japan"); break;
case Europe: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"Europe"); break;
case Spanish: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"Spain"); break;
case Australia: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"Australia"); break;
case X_PAL: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"PAL"); break;
case Y_PAL: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"PAL"); break;
case 0: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"None"); break;
default:
SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, stdstr_f(" Unknown %c (%02X)", RomHeader[0x3D], RomHeader[0x3D]).ToUTF16().c_str());
}
SetDlgItemTextW(hDlg, IDC_INFO_CRC1, stdstr_f("0x%08X", *(uint32_t *)(RomHeader + 0x10)).ToUTF16().c_str());
SetDlgItemTextW(hDlg, IDC_INFO_CRC2, stdstr_f("0x%08X", *(DWORD *)(RomHeader + 0x14)).ToUTF16().c_str());
std::wstring CicChip;
switch (_this->m_pRomInfo->CicChipID())
{
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());
std::wstring CicChip;
switch (_this->m_pRomInfo->CicChipID())
{
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());
}
else
{
SetWindowTextW(hDlg, wGS(INFO_TITLE).c_str());
SetDlgItemTextW(hDlg, IDC_ROM_NAME, wGS(INFO_ROM_NAME_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_FILE_NAME, wGS(INFO_FILE_NAME_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_LOCATION, wGS(INFO_LOCATION_TEXT).c_str());
//SetDlgItemTextW(hDlg, IDC_ROM_MD5, wGS(INFO_MD5_TEXT).c_str());
//SetDlgItemTextW(hDlg, IDC_ROM_SIZE, wGS(INFO_SIZE_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_CART_ID, wGS(INFO_CART_ID_TEXT).c_str());
//SetDlgItemTextW(hDlg, IDC_MANUFACTURER, wGS(INFO_MANUFACTURER_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_COUNTRY, wGS(INFO_COUNTRY_TEXT).c_str());
//SetDlgItemTextW(hDlg, IDC_CRC1, wGS(INFO_CRC1_TEXT).c_str());
//SetDlgItemTextW(hDlg, IDC_CRC2, wGS(INFO_CRC2_TEXT).c_str());
//SetDlgItemTextW(hDlg, IDC_CIC_CHIP, wGS(INFO_CIC_CHIP_TEXT).c_str());
SetDlgItemTextW(hDlg, IDC_CLOSE_BUTTON, wGS(BOTTOM_CLOSE).c_str());
SetDlgItemTextW(hDlg, IDC_INFO_ROMNAME, _this->m_pDiskInfo->GetRomName().ToUTF16(stdstr::CODEPAGE_932).c_str());
SetDlgItemTextW(hDlg, IDC_INFO_FILENAME, stdstr(CPath(_this->m_pDiskInfo->GetFileName()).GetNameExtension()).ToUTF16(CP_ACP).c_str());
SetDlgItemTextW(hDlg, IDC_INFO_LOCATION, stdstr(CPath(_this->m_pDiskInfo->GetFileName()).GetDriveDirectory()).ToUTF16(CP_ACP).c_str());
//SetDlgItemTextW(hDlg, IDC_INFO_MD5, _this->m_pRomInfo->GetRomMD5().ToUTF16().c_str());
//SetDlgItemTextW(hDlg, IDC_INFO_ROMSIZE, stdstr_f("%.1f MBit", (float)_this->m_pDiskInfo->GetRomSize() / 0x20000).ToUTF16().c_str());
BYTE * DiskHeader = _this->m_pDiskInfo->GetDiskAddress() + 0x43670;
SetDlgItemTextW(hDlg, IDC_INFO_CARTID, stdstr_f("%c%c", DiskHeader[0x02], DiskHeader[0x01]).ToUTF16().c_str());
/*switch (DiskHeader[0x00])
{
case 'N': SetDlgItemTextW(hDlg, IDC_INFO_MANUFACTURER, L"Nintendo"); break;
case 0: SetDlgItemTextW(hDlg, IDC_INFO_MANUFACTURER, L"None"); break;
default: SetDlgItemTextW(hDlg, IDC_INFO_MANUFACTURER, L"(Unknown)"); break;
}*/
switch (DiskHeader[0x00])
{
case NTSC_BETA: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"Beta"); break;
case X_NTSC: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"NTSC"); break;
case Germany: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"Germany"); break;
case USA: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"America"); break;
case french: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"France"); break;
case Italian: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"Italy"); break;
case Japan: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"Japan"); break;
case Europe: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"Europe"); break;
case Spanish: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"Spain"); break;
case Australia: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"Australia"); break;
case X_PAL: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"PAL"); break;
case Y_PAL: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"PAL"); break;
case 0: SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, L"None"); break;
default:
SetDlgItemTextW(hDlg, IDC_INFO_COUNTRY, stdstr_f(" Unknown %c (%02X)", DiskHeader[0x03], DiskHeader[0x03]).ToUTF16().c_str());
}
SetDlgItemTextW(hDlg, IDC_INFO_CRC1, stdstr_f("0x%08X", *(uint32_t *)(_this->m_pDiskInfo->GetDiskAddress())).ToUTF16().c_str());
SetDlgItemTextW(hDlg, IDC_INFO_CRC2, stdstr_f("0x%08X", *(DWORD *)(DiskHeader)).ToUTF16().c_str());
/*
std::wstring CicChip;
switch (_this->m_pRomInfo->CicChipID())
{
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());
*/
}
}
break;
case WM_COMMAND:

View File

@ -13,14 +13,17 @@
class RomInformation
{
bool const m_DeleteRomInfo;
bool const m_DeleteDiskInfo;
stdstr const m_FileName;
CN64Rom * m_pRomInfo;
CN64Disk * m_pDiskInfo;
friend DWORD CALLBACK RomInfoProc(HWND, DWORD, DWORD, DWORD);
public:
RomInformation(const char* RomFile);
RomInformation(CN64Rom* RomInfo);
RomInformation(CN64Disk* DiskInfo);
~RomInformation();
void DisplayInformation(HWND hParent) const;

View File

@ -37,7 +37,7 @@ int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /
else
{
//Ext is *.ndd, so it should be a disk file.
if (CN64System::RunDiskImage(g_Settings->LoadStringVal(Cmd_RomFile).c_str()))
if (CN64System::RunDiskImage(g_Settings->LoadStringVal(Cmd_RomFile).c_str(), false))
{
stdstr IPLROM = g_Settings->LoadStringVal(File_DiskIPLPath);
if ((IPLROM.length() <= 0) || (!CN64System::RunFileImage(IPLROM.c_str())))