adds some info about the memcard header, taken from libogc

wip real format function for GCMemcard class
somewhat useful memcard debug window
sram header taken from libogc

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2499 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
LPFaint99 2009-03-01 07:15:10 +00:00
parent f242fbdc42
commit 4868d570bc
10 changed files with 971 additions and 29 deletions

View File

@ -0,0 +1,23 @@
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MemCardManager", "Memcard Manager.vcproj", "{413653C3-59A4-4E3A-ABB0-56558B323DFE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{413653C3-59A4-4E3A-ABB0-56558B323DFE}.Release|Win32.Build.0 = Release|Win32
{413653C3-59A4-4E3A-ABB0-56558B323DFE}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
AMDCaProjectFile = D:\Dev\Dolphin\trunk\Source\CodeAnalyst\Dolphin.caw
EndGlobalSection
GlobalSection(DPCodeReviewSolutionGUID) = preSolution
DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,535 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="MemCardManager"
ProjectGUID="{413653C3-59A4-4E3A-ABB0-56558B323DFE}"
RootNamespace="MemCardManager"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
CommandLine=""
ExcludedFromBuild="false"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="WIN32,__WXMSW__,_WINDOWS,NOPCH"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\vc_msw/toolbar.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/EHsc "
Optimization="3"
InlineFunctionExpansion="0"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="..\..\Source\Core\Common\Src;..\wxWidgets\Include;..\wxWidgets\Include\msvc;..\..\Source\Core\DolphinWX\Src;.\src"
PreprocessorDefinitions="WIN32;__WXMSW__;_WINDOWS;NOPCH;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;MEMCMAN;"
StringPooling="false"
RuntimeLibrary="0"
BufferSecurityCheck="false"
EnableFunctionLevelLinking="false"
EnableEnhancedInstructionSet="0"
FloatingPointModel="0"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
PrecompiledHeaderFile="$(IntDir)\$(TargetName).pch"
AssemblerListingLocation="$(IntDir)\"
ObjectFile="$(IntDir)\"
ProgramDataBaseFileName="$(IntDir)\vc80.pdb"
WarningLevel="4"
WarnAsError="false"
SuppressStartupBanner="true"
DebugInformationFormat="3"
ForcedIncludeFiles=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="__WXMSW__,_WINDOWS,NOPCH"
Culture="1033"
AdditionalIncludeDirectories=".\..\..\lib\vc_lib\msw;.\..\..\include;.;.\..\..\samples"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="comctl32.lib rpcrt4.lib winmm.lib"
OutputFile="&quot;../../Binary/Win32/MemoryCardManager.exe&quot;"
Version=""
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories=""
IgnoreAllDefaultLibraries="false"
IgnoreDefaultLibraryNames="msvcrt"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(TargetDir)$(TargetName).pdb"
GenerateMapFile="false"
MapFileName=""
SubSystem="2"
BaseAddress="0x00400000"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\vc_msw/toolbar.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine=""
ExcludedFromBuild="false"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
CommandLine=""
ExcludedFromBuild="false"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="WIN32,__WXMSW__,_WINDOWS,NOPCH"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="3"
TypeLibraryName=".\vc_msw/toolbar.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/EHsc "
Optimization="3"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="false"
AdditionalIncludeDirectories="..\..\Source\Core\Common\Src;..\wxWidgets\Include;..\wxWidgets\Include\msvc;..\..\Source\Core\DolphinWX\Src;.\src"
PreprocessorDefinitions="WIN32;__WXMSW__;_WINDOWS;NOPCH;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="false"
FloatingPointModel="0"
RuntimeTypeInfo="true"
UsePrecompiledHeader="0"
PrecompiledHeaderFile="$(IntDir)\$(TargetName).pch"
AssemblerListingLocation="$(IntDir)\"
ObjectFile="$(IntDir)\"
ProgramDataBaseFileName="$(IntDir)\vc80.pdb"
WarningLevel="4"
WarnAsError="false"
SuppressStartupBanner="true"
DebugInformationFormat="3"
ForcedIncludeFiles=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="__WXMSW__,_WINDOWS,NOPCH"
Culture="1033"
AdditionalIncludeDirectories=".\..\..\lib\vc_lib\msw;.\..\..\include;.;.\..\..\samples"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="comctl32.lib rpcrt4.lib"
OutputFile="../../../Binary/x64/MemoryCardManager.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories=""
GenerateDebugInformation="true"
ProgramDatabaseFile="$(TargetDir)$(TargetName).pdb"
SubSystem="2"
BaseAddress="0x00400000"
RandomizedBaseAddress="1"
FixedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\vc_msw/toolbar.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine=""
ExcludedFromBuild="false"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="src"
>
<File
RelativePath=".\src\MCMdebug.cpp"
>
</File>
<File
RelativePath=".\src\MCMdebug.h"
>
</File>
<File
RelativePath=".\src\MCMmain.cpp"
>
</File>
</Filter>
<Filter
Name="From Dolphin"
>
<Filter
Name="x86 libs"
>
<File
RelativePath="..\..\Source\Core\Common\Win32\Release\Common.lib"
>
<FileConfiguration
Name="Release|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
<FileConfiguration
Name="DebugFast|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\wxWidgets\build\msw\wxBase28_Win32\Release\wxBase28.lib"
>
<FileConfiguration
Name="Release|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
<FileConfiguration
Name="DebugFast|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\wxWidgets\build\msw\wxCore28_Win32\Release\wxCore28.lib"
>
<FileConfiguration
Name="Release|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
<FileConfiguration
Name="DebugFast|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="src"
>
<File
RelativePath="..\..\Source\Core\DolphinWX\Src\MemoryCards\GCMemcard.cpp"
>
</File>
<File
RelativePath="..\..\Source\Core\DolphinWX\Src\MemoryCards\GCMemcard.h"
>
</File>
<File
RelativePath="..\..\Source\Core\DolphinWX\Src\MemcardManager.cpp"
>
</File>
<File
RelativePath="..\..\Source\Core\DolphinWX\Src\MemcardManager.h"
>
</File>
</Filter>
<Filter
Name="x64 libs"
>
<File
RelativePath="..\..\Source\Core\Common\x64\Release\Common.lib"
>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
<FileConfiguration
Name="DebugFast|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
<FileConfiguration
Name="DebugFast|x64"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\wxWidgets\build\msw\wxBase28_x64\Release\wxBase28.lib"
>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
<FileConfiguration
Name="DebugFast|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
<FileConfiguration
Name="DebugFast|x64"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\wxWidgets\build\msw\wxCore28_x64\Release\wxCore28.lib"
>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
<FileConfiguration
Name="DebugFast|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
<FileConfiguration
Name="DebugFast|x64"
>
<Tool
Name="VCCustomBuildTool"
/>
</FileConfiguration>
</File>
</Filter>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

111
Externals/Memcard Manager/src/MCMdebug.h vendored Normal file
View File

@ -0,0 +1,111 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef __MCM_H__
#define __MCM_H__
#include "MemcardManager.h"
#include <wx/gbsizer.h>
#include <wx/notebook.h>
class CMemcardManagerDebug : public wxFrame
{
public:
CMemcardManagerDebug(wxFrame* parent, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
virtual ~CMemcardManagerDebug(){};
void updatePanels(GCMemcard ** memCard,int card);
private:
enum
{
ID_NOTEBOOK_MAIN,
ID_TAB_HDR,
ID_TAB_DIR,
ID_TAB_DIR_B,
ID_TAB_BAT,
ID_TAB_BAT_B,
};
GCMemcard **memoryCard;
wxNotebook *m_Notebook_MCMD;
wxPanel *m_Tab_HDR,
*m_Tab_DIR,
*m_Tab_DIR_b,
*m_Tab_BAT,
*m_Tab_BAT_b;
wxBoxSizer *sMain,
*sDebug,
*sDebug2;
wxStaticText *t_HDR_ser[2],
*t_HDR_fmtTime[2],
*t_HDR_SRAMBIAS[2],
*t_HDR_SRAMLANG[2],
*t_HDR_Unk2[2],
*t_HDR_devID[2],
*t_HDR_Size[2],
*t_HDR_Encoding[2],
*t_HDR_UpdateCounter[2],
*t_HDR_CheckSum1[2],
*t_HDR_CheckSum2[2],
*t_DIR_UpdateCounter[2],
*t_DIR_CheckSum1[2],
*t_DIR_CheckSum2[2],
*t_DIR_b_UpdateCounter[2],
*t_DIR_b_CheckSum1[2],
*t_DIR_b_CheckSum2[2],
*t_BAT_CheckSum1[2],
*t_BAT_CheckSum2[2],
*t_BAT_UpdateCounter[2],
*t_BAT_FreeBlocks[2],
*t_BAT_LastAllocated[2],
*t_BAT_map[256][2],
*t_BAT_b_CheckSum1[2],
*t_BAT_b_CheckSum2[2],
*t_BAT_b_UpdateCounter[2],
*t_BAT_b_FreeBlocks[2],
*t_BAT_b_LastAllocated[2];
DECLARE_EVENT_TABLE();
void Init_ChildControls();
void OnClose(wxCloseEvent& event);
void Init_HDR();
void Init_DIR();
void Init_DIR_b();
void Init_BAT();
void Init_BAT_b();
void updateHDRtab(int card);
void updateDIRtab(int card);
void updateDIRBtab(int card);
void updateBATtab(int card);
void updateBATBtab(int card);
};
#endif

View File

@ -0,0 +1,56 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
void __Log(int logNumber, const char* text, ...){logNumber; text;}
void __Logv(int log, int v, const char *format, ...){log; v; format;}
#include "MemcardManager.h"
class MCMApp
: public wxApp
{
public:
bool OnInit();
};
IMPLEMENT_APP(MCMApp)
CMemcardManager *main_frame;
#if defined HAVE_WX && HAVE_WX
bool wxMsgAlert(const char* caption, const char* text, bool yes_no, int Style)
{
return wxYES == wxMessageBox(wxString::FromAscii(text),
wxString::FromAscii(caption),
(yes_no)?wxYES_NO:wxOK);
}
#endif
bool MCMApp::OnInit()
{
// Register message box handler
#if defined(HAVE_WX) && HAVE_WX
RegisterMsgAlertHandler(&wxMsgAlert);
#endif
main_frame = new CMemcardManager((wxFrame*) NULL, wxID_ANY, wxString::FromAscii("Memcard Manager"),
wxPoint(100, 100), wxSize(800, 600));
main_frame->Show();
SetTopWindow(main_frame);
return true;
}

View File

@ -750,6 +750,10 @@
RelativePath=".\Src\HW\EXI_DeviceMic.h" RelativePath=".\Src\HW\EXI_DeviceMic.h"
> >
</File> </File>
<File
RelativePath=".\Src\HW\Sram.h"
>
</File>
</Filter> </Filter>
<Filter <Filter
Name="SI - Serial Interface" Name="SI - Serial Interface"

View File

@ -0,0 +1,78 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
// Modified code taken from libogc
/*-------------------------------------------------------------
system.h -- OS functions and initialization
Copyright (C) 2004
Michael Wiedenbauer (shagkur)
Dave Murphy (WinterMute)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
-------------------------------------------------------------*/
#ifndef __SRAM_h__
#define __SRAM_h__
#include "Common.h"
struct SRAM
{
struct _syssram { // Stored configuration value from the system SRAM area
u8 checksum[2]; // holds the block checksum.
u8 checksum_inv[2]; // holds the inverse block checksum
u8 ead0[4]; // unknown attribute
u8 ead1[4]; // unknown attribute
u8 counter_bias[4]; // bias value for the realtime clock
s8 display_offsetH; // pixel offset for the VI
u8 ntd; // unknown attribute
u8 lang; // language of system
u8 flags; // device and operations flag
}syssram;
struct _syssramex { // Stored configuration value from the extended SRAM area
u8 flash_id_1[12]; // flash_id[2][12] 96bit memorycard unlock flash ID
u8 flash_id_2[12];
u8 wirelessKbd_id[4]; // Device ID of last connected wireless keyboard
u8 wirelessPad_id[8]; // 16bit device ID of last connected pad.
u8 dvderr_code; // last non-recoverable error from DVD interface
u8 __padding0; // padding
u8 flashID_chksum[4]; // 16bit checksum of unlock flash ID
u8 __padding1[4]; // padding
}syssramex;
};
#endif

View File

@ -15,11 +15,10 @@
// Official SVN repository and contact information can be found at // Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#include "Globals.h"
#include "MemcardManager.h" #include "MemcardManager.h"
#include "Common.h" #include "Common.h"
#include "wx/mstream.h" #include "wx/mstream.h"
//#define DEBUG_MCM true
#define DEFAULTS wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator #define DEFAULTS wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator
#define ARROWS slot ? _T("") : ARROW[slot], slot ? ARROW[slot] : _T("") #define ARROWS slot ? _T("") : ARROW[slot], slot ? ARROW[slot] : _T("")
@ -119,6 +118,9 @@ CMemcardManager::CMemcardManager(wxWindow* parent, wxWindowID id, const wxString
} }
else itemsPerPage = 16; else itemsPerPage = 16;
maxPages = (128 / itemsPerPage) - 1; maxPages = (128 / itemsPerPage) - 1;
#ifdef DEBUG_MCM
MemcardManagerDebug = NULL;
#endif
CreateGUIControls(); CreateGUIControls();
} }
@ -134,6 +136,14 @@ CMemcardManager::~CMemcardManager()
delete memoryCard[SLOT_B]; delete memoryCard[SLOT_B];
memoryCard[SLOT_B] = NULL; memoryCard[SLOT_B] = NULL;
} }
#ifdef DEBUG_MCM
if (MemcardManagerDebug)
{
MemcardManagerDebug->Destroy();
delete MemcardManagerDebug;
MemcardManagerDebug = NULL;
}
#endif
MemcardManagerIni.Load(CONFIG_FILE); MemcardManagerIni.Load(CONFIG_FILE);
MemcardManagerIni.Set("MemcardManager", "Items per page", itemsPerPage); MemcardManagerIni.Set("MemcardManager", "Items per page", itemsPerPage);
@ -834,6 +844,19 @@ bool CMemcardManager::ReloadMemcard(const char *fileName, int card)
memoryCard[card]->GetFreeBlocks(), DIRLEN - nFiles); memoryCard[card]->GetFreeBlocks(), DIRLEN - nFiles);
t_Status[card]->SetLabel(wxLabel); t_Status[card]->SetLabel(wxLabel);
#ifdef DEBUG_MCM
if(MemcardManagerDebug == NULL)
{
MemcardManagerDebug = new CMemcardManagerDebug((wxFrame *)NULL, wxDefaultPosition, wxSize(950, 400));
}
if (MemcardManagerDebug != NULL)
{
MemcardManagerDebug->Show();
MemcardManagerDebug->updatePanels(memoryCard, card);
}
#endif
return true; return true;
} }

View File

@ -18,6 +18,7 @@
#ifndef __MEMCARD_MANAGER_h__ #ifndef __MEMCARD_MANAGER_h__
#define __MEMCARD_MANAGER_h__ #define __MEMCARD_MANAGER_h__
#include <wx/wx.h>
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/filepicker.h> #include <wx/filepicker.h>
#include <wx/statbmp.h> #include <wx/statbmp.h>
@ -46,8 +47,14 @@
#define E_SAVEFAILED "File write failed" #define E_SAVEFAILED "File write failed"
#define E_UNK "Unknown error" #define E_UNK "Unknown error"
#define FIRSTPAGE 0 #define FIRSTPAGE 0
#define SLOT_A 0
#define SLOT_B 1 #ifdef MEMCMAN
#undef CONFIG_FILE
#define CONFIG_FILE "./MemcardManager.ini"
#define DEBUG_MCM
#include "MCMdebug.h"
#endif
class CMemcardManager class CMemcardManager
: public wxDialog : public wxDialog
@ -67,6 +74,9 @@ class CMemcardManager
std::string DefaultMemcard[2], std::string DefaultMemcard[2],
DefaultIOPath; DefaultIOPath;
IniFile MemcardManagerIni; IniFile MemcardManagerIni;
#ifdef DEBUG_MCM
CMemcardManagerDebug * MemcardManagerDebug;
#endif
wxBoxSizer *sMain, wxBoxSizer *sMain,
*sButtons, *sButtons,

View File

@ -84,6 +84,7 @@ GCMemcard::GCMemcard(const char *filename)
} }
mcdFile = mcd; mcdFile = mcd;
format(true); format(true);
//formatWIP(0,true,false);
fclose(mcd); fclose(mcd);
mcd = fopen(filename, "r+b"); mcd = fopen(filename, "r+b");
} }
@ -1073,7 +1074,6 @@ u32 GCMemcard::ReadAnimRGBA8(u8 index, u32* buffer, u8 *delays)
return frames; return frames;
} }
bool GCMemcard::format(bool New) bool GCMemcard::format(bool New)
{ {
u32 data_size = 0x2000 * (0x80 * 0x10 - 5); u32 data_size = 0x2000 * (0x80 * 0x10 - 5);
@ -1092,31 +1092,31 @@ bool GCMemcard::format(bool New)
memset(&bat, 0, 0x2000); memset(&bat, 0, 0x2000);
memset(&bat_backup, 0, 0x2000); memset(&bat_backup, 0, 0x2000);
memset(mc_data, 0xFF, mc_data_size); memset(mc_data, 0xFF, mc_data_size);
hdr.Unk1[0] = 0xE3; hdr.serial[0] = 0xE3;
hdr.Unk1[1] = 0x63; hdr.serial[1] = 0x63;
hdr.Unk1[2] = 0x27; hdr.serial[2] = 0x27;
hdr.Unk1[3] = 0xC1; hdr.serial[3] = 0xC1;
hdr.Unk1[4] = 0x6B; hdr.serial[4] = 0x6B;
hdr.Unk1[5] = 0x11; hdr.serial[5] = 0x11;
hdr.Unk1[6] = 0xEC; hdr.serial[6] = 0xEC;
hdr.Unk1[7] = 0x47; hdr.serial[7] = 0x47;
hdr.Unk1[8] = 0xF0; hdr.serial[8] = 0xF0;
hdr.Unk1[9] = 0x12; hdr.serial[9] = 0x12;
hdr.Unk1[10] = 0x99; hdr.serial[10] = 0x99;
hdr.Unk1[11] = 0x13; hdr.serial[11] = 0x13;
hdr.fmtTime.low = 0x5CB62800; hdr.fmtTime.low = 0x5CB62800;
hdr.fmtTime.high = 0xA665E7A3; hdr.fmtTime.high = 0xA665E7A3;
hdr.SramBias[3] = 0x40; hdr.SramBias[3] = 0x40;
hdr.SramLang[0] = 0;
hdr.SramLang[1] = 0;
hdr.SramLang[2] = 0;
hdr.SramLang[3] = 0;
hdr.Unk2[0] = 0; hdr.Unk2[0] = 0;
hdr.Unk2[1] = 0; hdr.Unk2[1] = 0;
hdr.Unk2[2] = 0; hdr.Unk2[2] = 0;
hdr.Unk2[3] = 0; hdr.Unk2[3] = 0x01;
hdr.Unk2[4] = 0; hdr.deviceID[0] = 0;
hdr.Unk2[5] = 0; hdr.deviceID[1] = 0;
hdr.Unk2[6] = 0;
hdr.Unk2[7] = 0x01;
hdr.Pad1[0] = 0;
hdr.Pad1[1] = 0;
hdr.Size[0] = 0; hdr.Size[0] = 0;
hdr.Size[1] = 0x80; hdr.Size[1] = 0x80;
hdr.Encoding[0] = 0; hdr.Encoding[0] = 0;
@ -1154,3 +1154,94 @@ bool GCMemcard::format(bool New)
Save(); Save();
return true; return true;
} }
bool GCMemcard::formatWIP(int slot, bool New, bool sjis)
{//slot = 1;
u32 data_size = 0x2000 * (0x80 * 0x10 - 5);
u16 size = (((data_size / 0x2000) + 5) / 0x10);
SRAM m_SRAM;
FILE * pStream;
u64 time, rand;
if (New)
{
mc_data_size = data_size;
mc_data = new u8[mc_data_size];
}
pStream = fopen(GC_SRAM_FILE, "rb");
if (pStream == NULL)
{
return false;
}
fread(&m_SRAM, 1, 64, pStream);
fclose(pStream);
rand = time = 0XFAB12B2D9FD80700;//0x500;//gettime();
//////////////////////////////////////
PanicAlert("%2x,%2x,%4x,%4x,%4x,%x,%x,lang%x,flahs%x",BE16(m_SRAM.syssram.checksum),
BE16(m_SRAM.syssram.checksum_inv),
BE32(m_SRAM.syssram.ead0),
BE32(m_SRAM.syssram.ead1),
BE32(m_SRAM.syssram.counter_bias),
m_SRAM.syssram.display_offsetH,
m_SRAM.syssram.ntd,
m_SRAM.syssram.lang,
m_SRAM.syssram.flags);
PanicAlert("%4x%4x%4x,%4x%4x%4x,%4x,%4x,%4x,%x,%x,%4x,%4x",
BE32(m_SRAM.syssramex.flash_id_1),
BE32(&(m_SRAM.syssramex.flash_id_1[4])),
BE32(&(m_SRAM.syssramex.flash_id_1[8])),
BE32(m_SRAM.syssramex.flash_id_2),
BE32(&(m_SRAM.syssramex.flash_id_2[4])),
BE32(&(m_SRAM.syssramex.flash_id_2[8])),
BE32(m_SRAM.syssramex.wirelessKbd_id),
BE32(m_SRAM.syssramex.wirelessPad_id),
BE32(&(m_SRAM.syssramex.wirelessPad_id[4])),
m_SRAM.syssramex.dvderr_code,
m_SRAM.syssramex.__padding0,
BE32(m_SRAM.syssramex.flashID_chksum),
BE32(m_SRAM.syssramex.__padding1));
memset(&hdr, 0xFF, 0x2000);
u8 * flash_id = slot ? m_SRAM.syssramex.flash_id_2 : m_SRAM.syssramex.flash_id_1;
for(int i = 0; i < 12; i++)
{
rand = (((rand*(u64)0x0000000041c64e6d)+(u64)0x0000000000003039)>>16);
// PanicAlert("%16x",rand);
// PanicAlert("m_SRAM.syssramex.flash_id %16x",(flash_id[i]));
// PanicAlert("%16x",(flash_id[i]+(u32)rand));
// PanicAlert("%16x",(flash_id+Common::swap32((u32)rand)));
hdr.serial[i] = (flash_id[i]+(u32)rand);
rand = (((rand*(u64)0x0000000041c64e6d)+(u64)0x0000000000003039)>>16);
rand &= (u64)0x0000000000007fff;
}
hdr.fmtTime.high = (time >> 32) & 0xFFFFFFFF;
hdr.fmtTime.low = time & 0xFFFFFFFF;
*(u32*)&(hdr.SramBias) = *(u32*)&(m_SRAM.syssram.counter_bias);
*(u32*)&(hdr.SramLang) = m_SRAM.syssram.lang;
*(u32*)&(hdr.Unk2) = 0;//tmp; tmp = _viReg[55]; static vu16* const _viReg = (u16*)0xCC002000;
*(u16*)&(hdr.deviceID) = 0;
*(u16*)&(hdr.Size) = Common::swap16(size);
*(u16*)&(hdr.Encoding) = Common::swap16(sjis ? 1 : 0);
memset(&dir, 0xFF, 0x2000);
memset(&dir_backup, 0xFF, 0x2000);
*(u16*)&dir.UpdateCounter = 0;
*(u16*)&dir_backup.UpdateCounter = Common::swap16(1);
memset(&bat, 0, 0x2000);
memset(&bat_backup, 0, 0x2000);
*(u16*)&bat.UpdateCounter = 0;
*(u16*)&bat_backup.UpdateCounter = Common::swap16(1);
*(u16*)&bat.FreeBlocks = *(u16*)&bat_backup.FreeBlocks = Common::swap16(size * 0x10 - 5);
*(u16*)&bat.LastAllocated = *(u16*)&bat_backup.LastAllocated = Common::swap16(4);
memset(mc_data, 0xFF, mc_data_size);
FixChecksums();
Save();
return true;
}

View File

@ -15,13 +15,17 @@
// Official SVN repository and contact information can be found at // Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#pragma once #ifndef __GCMEMCARD_h__
#define __GCMEMCARD_h__
#include "Common.h" #include "Common.h"
#include "../../../Core/Src/HW/Sram.h"
#include "StringUtil.h" #include "StringUtil.h"
#define BE32(x) ((u32((x)[0])<<24) | (u32((x)[1])<<16) | (u32((x)[2])<<8) | u32((x)[3])) #define BE32(x) ((u32((x)[0])<<24) | (u32((x)[1])<<16) | (u32((x)[2])<<8) | u32((x)[3]))
#define BE16(x) ((u16((x)[0])<<8) | u16((x)[1])) #define BE16(x) ((u16((x)[0])<<8) | u16((x)[1]))
#define ArrayByteSwap(a) (ByteSwap(a, a+sizeof(u8))); #define ArrayByteSwap(a) (ByteSwap(a, a+sizeof(u8)));
#define SLOT_A 0
#define SLOT_B 1
enum enum
{ {
@ -53,6 +57,7 @@ enum
class GCMemcard class GCMemcard
{ {
private: private:
friend class CMemcardManagerDebug;
void* mcdFile; void* mcdFile;
u32 maxBlock; u32 maxBlock;
@ -66,11 +71,14 @@ private:
}; };
struct Header { //Offset Size Description struct Header { //Offset Size Description
u8 Unk1[12]; //0x0000 12 ? // Serial in libogc
u8 serial[12]; //0x0000 12 ?
OSTime fmtTime; //0x000c 8 time of format (OSTime value) OSTime fmtTime; //0x000c 8 time of format (OSTime value)
u8 SramBias[4]; //0x0014 4 sram bias at time of format u8 SramBias[4]; //0x0014 4 sram bias at time of format
u8 Unk2[8]; //0x0018 8 ? almost always 0 or 1 u8 SramLang[4]; //0x0018 4 sram language
u8 Pad1[2]; //0x0020 2 padding zeroes u8 Unk2[4]; //0x001c 4 ? almost always 0
// end Serial in libogc
u8 deviceID[2]; //0x0020 2 0 if formated in slot A 1 if formated in slot B
u8 Size[2]; //0x0022 2 size of memcard in Mbits u8 Size[2]; //0x0022 2 size of memcard in Mbits
u8 Encoding[2]; //0x0024 2 encoding (ASCII or japanese) u8 Encoding[2]; //0x0024 2 encoding (ASCII or japanese)
u8 Unused1[468]; //0x0026 468 unused (0xff) u8 Unused1[468]; //0x0026 468 unused (0xff)
@ -155,6 +163,7 @@ public:
bool IsOpen(); bool IsOpen();
bool Save(); bool Save();
bool format(bool New); bool format(bool New);
bool formatWIP(int slot, bool New, bool sjis);
void calc_checksumsBE(u16 *buf, u32 num, u16 *c1, u16 *c2); void calc_checksumsBE(u16 *buf, u32 num, u16 *c1, u16 *c2);
u32 TestChecksums(); u32 TestChecksums();
@ -228,3 +237,5 @@ public:
// reads the animation frames // reads the animation frames
u32 ReadAnimRGBA8(u8 index, u32* buffer, u8 *delays); u32 ReadAnimRGBA8(u8 index, u32* buffer, u8 *delays);
}; };
#endif