[Project64] Code cleanup and added some more log messages

This commit is contained in:
zilmar 2016-01-28 20:40:08 +11:00
parent a6bfe74a28
commit 3a1fc904c6
10 changed files with 105 additions and 97 deletions

View File

@ -10,7 +10,8 @@
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
enum LanguageStringID{ enum LanguageStringID
{
EMPTY_STRING = 0, EMPTY_STRING = 0,
/********************************************************************************* /*********************************************************************************

View File

@ -9,7 +9,6 @@
* * * *
****************************************************************************/ ****************************************************************************/
// Based from MAME's N64DD driver code by Happy_ // Based from MAME's N64DD driver code by Happy_
#pragma once
#include "stdafx.h" #include "stdafx.h"
#include "Disk.h" #include "Disk.h"
#include <Project64-core/N64System/N64DiskClass.h> #include <Project64-core/N64System/N64DiskClass.h>

View File

@ -8,12 +8,12 @@
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* * * *
****************************************************************************/ ****************************************************************************/
#pragma once
#include "stdafx.h" #include "stdafx.h"
#include "N64DiskClass.h" #include "N64DiskClass.h"
#include "SystemGlobals.h" #include "SystemGlobals.h"
#include <Common/Platform.h> #include <Common/Platform.h>
#include <Common/MemoryManagement.h> #include <Common/MemoryManagement.h>
#include <memory>
CN64Disk::CN64Disk() : CN64Disk::CN64Disk() :
m_DiskImage(NULL), m_DiskImage(NULL),
@ -101,7 +101,7 @@ bool CN64Disk::AllocateAndLoadDiskImage(const char * FileLoc)
if (DiskFileSize == MameFormatSize) if (DiskFileSize == MameFormatSize)
{ {
//If Disk is MAME Format (size is constant, it should be the same for every file), then continue //If Disk is MAME Format (size is constant, it should be the same for every file), then continue
WriteTrace(TraceN64System, TraceDebug, "Disk File is MAME Format", ); WriteTrace(TraceN64System, TraceDebug, "Disk File is MAME Format");
if (!AllocateDiskImage(DiskFileSize)) if (!AllocateDiskImage(DiskFileSize))
{ {
@ -285,7 +285,7 @@ void CN64Disk::ConvertDiskFormat()
{ {
OutOffset = OutStart[zone]; OutOffset = OutStart[zone];
InOffset = InStart[RevDiskTypeZones[disktype][zone]]; InOffset = InStart[RevDiskTypeZones[disktype][zone]];
m_DiskFile.Seek(InOffset, CFileBase::SeekPosition::begin); m_DiskFile.Seek(InOffset, CFileBase::begin);
block = StartBlock[disktype][zone]; block = StartBlock[disktype][zone];
atrack = 0; atrack = 0;
for (track = 0; track < ZoneTracks[zone]; track++) for (track = 0; track < ZoneTracks[zone]; track++)
@ -322,7 +322,7 @@ void CN64Disk::ConvertDiskFormat()
{ {
//OutOffset = OutStart[zone]; //OutOffset = OutStart[zone];
InOffset = InStart[RevDiskTypeZones[disktype][zone]]; InOffset = InStart[RevDiskTypeZones[disktype][zone]];
m_DiskFile.Seek(InOffset, CFileBase::SeekPosition::begin); m_DiskFile.Seek(InOffset, CFileBase::begin);
block = StartBlock[disktype][zone]; block = StartBlock[disktype][zone];
atrack = 0xB; atrack = 0xB;
for (track = 1; track < ZoneTracks[zone] + 1; track++) for (track = 1; track < ZoneTracks[zone] + 1; track++)

View File

@ -11,12 +11,12 @@
#pragma once #pragma once
//Plugin controller //Plugin controller
#include "Plugins/PluginClass.h" #include <Project64-core/Plugins/PluginClass.h>
//Base Plugin class, all plugin derive from this, handles core functions //Base Plugin class, all plugin derive from this, handles core functions
#include "Plugins/PluginBase.h" #include <Project64-core/Plugins/PluginBase.h>
#include "Plugins/GFXPlugin.h" #include "Plugins/GFXPlugin.h"
#include "Plugins/AudioPlugin.h" #include <Project64-core/Plugins/AudioPlugin.h>
#include "Plugins/ControllerPlugin.h" #include "Plugins/ControllerPlugin.h"
#include "Plugins/RSPPlugin.h" #include "Plugins/RSPPlugin.h"

View File

@ -60,10 +60,12 @@ CSettingTypeApplication::~CSettingTypeApplication()
void CSettingTypeApplication::Initialize( const char * /*AppName*/ ) void CSettingTypeApplication::Initialize( const char * /*AppName*/ )
{ {
WriteTrace(TraceAppInit, TraceDebug, "Start");
CPath BaseDir(g_Settings->LoadStringVal(Cmd_BaseDirectory).c_str(),""); CPath BaseDir(g_Settings->LoadStringVal(Cmd_BaseDirectory).c_str(),"");
if (!BaseDir.DirectoryExists()) if (!BaseDir.DirectoryExists())
{ {
printf("BaseDir does not exists, doing nothing"); WriteTrace(TraceAppInit, TraceDebug, "BaseDir does not exists, doing nothing");
WriteTrace(TraceAppInit, TraceDebug, "Done");
return; return;
} }
@ -98,6 +100,7 @@ void CSettingTypeApplication::Initialize( const char * /*AppName*/ )
} }
m_SettingsIniFile->SetAutoFlush(false); m_SettingsIniFile->SetAutoFlush(false);
WriteTrace(TraceAppInit, TraceDebug, "Done");
} }
void CSettingTypeApplication::Flush() void CSettingTypeApplication::Flush()
@ -123,7 +126,7 @@ bool CSettingTypeApplication::Load ( int /*Index*/, bool & Value ) const
bool bRes = false; bool bRes = false;
uint32_t dwValue; uint32_t dwValue;
bRes = m_SettingsIniFile->GetNumber(SectionName(),m_KeyNameIdex.c_str(),Value,dwValue); bRes = m_SettingsIniFile ? m_SettingsIniFile->GetNumber(SectionName(), m_KeyNameIdex.c_str(), Value, dwValue) : false;
if (bRes) if (bRes)
{ {
Value = dwValue != 0; Value = dwValue != 0;

View File

@ -11,8 +11,6 @@
#include "stdafx.h" #include "stdafx.h"
#include "SettingsType-Cheats.h" #include "SettingsType-Cheats.h"
CIniFile * CSettingTypeCheats::m_CheatIniFile = NULL; CIniFile * CSettingTypeCheats::m_CheatIniFile = NULL;
stdstr * CSettingTypeCheats::m_SectionIdent = NULL; stdstr * CSettingTypeCheats::m_SectionIdent = NULL;
@ -27,11 +25,13 @@ CSettingTypeCheats::~CSettingTypeCheats ( void )
void CSettingTypeCheats::Initialize ( void ) void CSettingTypeCheats::Initialize ( void )
{ {
WriteTrace(TraceAppInit, TraceDebug, "Start");
m_CheatIniFile = new CIniFile(g_Settings->LoadStringVal(SupportFile_Cheats).c_str()); m_CheatIniFile = new CIniFile(g_Settings->LoadStringVal(SupportFile_Cheats).c_str());
m_CheatIniFile->SetAutoFlush(false); m_CheatIniFile->SetAutoFlush(false);
g_Settings->RegisterChangeCB(Game_IniKey,NULL,GameChanged); g_Settings->RegisterChangeCB(Game_IniKey,NULL,GameChanged);
m_SectionIdent = new stdstr(g_Settings->LoadStringVal(Game_IniKey)); m_SectionIdent = new stdstr(g_Settings->LoadStringVal(Game_IniKey));
GameChanged(NULL); GameChanged(NULL);
WriteTrace(TraceAppInit, TraceDebug, "Done");
} }
void CSettingTypeCheats::CleanUp ( void ) void CSettingTypeCheats::CleanUp ( void )

View File

@ -37,8 +37,10 @@ CSettingTypeGame::~CSettingTypeGame()
void CSettingTypeGame::Initialize ( void ) void CSettingTypeGame::Initialize ( void )
{ {
WriteTrace(TraceAppInit, TraceDebug, "Start");
UpdateSettings(NULL); UpdateSettings(NULL);
g_Settings->RegisterChangeCB(Game_IniKey,NULL,UpdateSettings); g_Settings->RegisterChangeCB(Game_IniKey,NULL,UpdateSettings);
WriteTrace(TraceAppInit, TraceDebug, "Done");
} }
void CSettingTypeGame::CleanUp ( void ) void CSettingTypeGame::CleanUp ( void )

View File

@ -61,6 +61,8 @@ CSettingTypeRomDatabase::~CSettingTypeRomDatabase()
void CSettingTypeRomDatabase::Initialize( void ) void CSettingTypeRomDatabase::Initialize( void )
{ {
WriteTrace(TraceAppInit, TraceDebug, "Start");
m_SettingsIniFile = new CIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str()); m_SettingsIniFile = new CIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str());
m_GlideIniFile = new CIniFile(g_Settings->LoadStringVal(SupportFile_Glide64RDB).c_str()); m_GlideIniFile = new CIniFile(g_Settings->LoadStringVal(SupportFile_Glide64RDB).c_str());
@ -68,6 +70,7 @@ void CSettingTypeRomDatabase::Initialize( void )
g_Settings->RegisterChangeCB(Cmd_BaseDirectory,NULL,BaseDirChanged); g_Settings->RegisterChangeCB(Cmd_BaseDirectory,NULL,BaseDirChanged);
m_SectionIdent = new stdstr(g_Settings->LoadStringVal(Game_IniKey)); m_SectionIdent = new stdstr(g_Settings->LoadStringVal(Game_IniKey));
WriteTrace(TraceAppInit, TraceDebug, "Done");
} }
void CSettingTypeRomDatabase::CleanUp( void ) void CSettingTypeRomDatabase::CleanUp( void )

View File

@ -14,24 +14,96 @@
enum SettingDataType enum SettingDataType
{ {
Data_DWORD = 0, Data_DWORD = 0,
Data_String = 1, Data_String = 1,
Data_CPUTYPE = 2, Data_CPUTYPE = 2,
Data_SelfMod = 3, Data_SelfMod = 3,
Data_OnOff = 4, Data_OnOff = 4,
Data_YesNo = 5, Data_YesNo = 5,
Data_SaveChip = 6 Data_SaveChip = 6
}; };
class CSettings class CSettings
{ {
public: public:
typedef void (* SettingChangedFunc)(void *); typedef void(*SettingChangedFunc)(void *);
public:
CSettings(void);
~CSettings(void);
bool Initialize(const char * BaseDirectory, const char * AppName);
//return the values
bool LoadBool(SettingID Type);
bool LoadBool(SettingID Type, bool & Value);
bool LoadBoolIndex(SettingID Type, int32_t index);
bool LoadBoolIndex(SettingID Type, int32_t index, bool & Value);
uint32_t LoadDword(SettingID Type);
bool LoadDword(SettingID Type, uint32_t & Value);
uint32_t LoadDwordIndex(SettingID Type, int32_t index);
bool LoadDwordIndex(SettingID Type, int32_t index, uint32_t & Value);
stdstr LoadStringVal(SettingID Type);
bool LoadStringVal(SettingID Type, stdstr & Value);
bool LoadStringVal(SettingID Type, char * Buffer, int32_t BufferSize);
stdstr LoadStringIndex(SettingID Type, int32_t index);
bool LoadStringIndex(SettingID Type, int32_t index, stdstr & Value);
bool LoadStringIndex(SettingID Type, int32_t index, char * Buffer, int32_t BufferSize);
//Load the default value for the setting
bool LoadDefaultBool(SettingID Type);
void LoadDefaultBool(SettingID Type, bool & Value);
bool LoadDefaultBoolIndex(SettingID Type, int32_t index);
void LoadDefaultBoolIndex(SettingID Type, int32_t index, bool & Value);
uint32_t LoadDefaultDword(SettingID Type);
void LoadDefaultDword(SettingID Type, uint32_t & Value);
uint32_t LoadDefaultDwordIndex(SettingID Type, int32_t index);
void LoadDefaultDwordIndex(SettingID Type, int32_t index, uint32_t & Value);
stdstr LoadDefaultString(SettingID Type);
void LoadDefaultString(SettingID Type, stdstr & Value);
void LoadDefaultString(SettingID Type, char * Buffer, int32_t BufferSize);
stdstr LoadDefaultStringIndex(SettingID Type, int32_t index);
void LoadDefaultStringIndex(SettingID Type, int32_t index, stdstr & Value);
void LoadDefaultStringIndex(SettingID Type, int32_t index, char * Buffer, int32_t BufferSize);
//Update the settings
void SaveBool(SettingID Type, bool Value);
void SaveBoolIndex(SettingID Type, int32_t index, bool Value);
void SaveDword(SettingID Type, uint32_t Value);
void SaveDwordIndex(SettingID Type, int32_t index, uint32_t Value);
void SaveString(SettingID Type, const stdstr & Value);
void SaveStringIndex(SettingID Type, int32_t index, const stdstr & Value);
void SaveString(SettingID Type, const char * Buffer);
void SaveStringIndex(SettingID Type, int32_t index, const char * Buffer);
// Delete a setting
void DeleteSetting(SettingID Type);
void DeleteSettingIndex(SettingID Type, int32_t index);
//Register Notification of change
void RegisterChangeCB(SettingID Type, void * Data, SettingChangedFunc Func);
void UnregisterChangeCB(SettingID Type, void * Data, SettingChangedFunc Func);
// information about setting
SettingType GetSettingType(SettingID Type);
bool IndexBasedSetting(SettingID Type);
void SettingTypeChanged(SettingType Type);
// static functions for plugins
static uint32_t GetSetting(CSettings * _this, SettingID Type);
static const char * GetSettingSz(CSettings * _this, SettingID Type, char * Buffer, int32_t BufferSize);
static void SetSetting(CSettings * _this, SettingID ID, uint32_t Value);
static void SetSettingSz(CSettings * _this, SettingID ID, const char * Value);
static void RegisterSetting(CSettings * _this, SettingID ID, SettingID DefaultID, SettingDataType DataType,
SettingType Type, const char * Category, const char * DefaultStr,
uint32_t Value);
static uint32_t FindSetting(CSettings * _this, const char * Name);
static void FlushSettings(CSettings * _this);
private: private:
void AddHandler ( SettingID TypeID, CSettingType * Handler ); void AddHandler(SettingID TypeID, CSettingType * Handler);
void AddHowToHandleSetting (void); void AddHowToHandleSetting(const char * BaseDirectory);
void UnknownSetting (SettingID Type); void UnknownSetting(SettingID Type);
struct SETTING_CHANGED_CB struct SETTING_CHANGED_CB
{ {
@ -44,80 +116,8 @@ private:
typedef std::map<SettingID, CSettingType *> SETTING_MAP; typedef std::map<SettingID, CSettingType *> SETTING_MAP;
typedef SETTING_MAP::iterator SETTING_HANDLER; typedef SETTING_MAP::iterator SETTING_HANDLER;
public:
CSettings(void);
~CSettings(void);
bool Initialize ( const char * AppName );
//return the values
bool LoadBool ( SettingID Type );
bool LoadBool ( SettingID Type, bool & Value );
bool LoadBoolIndex ( SettingID Type, int32_t index );
bool LoadBoolIndex ( SettingID Type, int32_t index , bool & Value );
uint32_t LoadDword ( SettingID Type );
bool LoadDword ( SettingID Type, uint32_t & Value );
uint32_t LoadDwordIndex ( SettingID Type, int32_t index );
bool LoadDwordIndex ( SettingID Type, int32_t index, uint32_t & Value );
stdstr LoadStringVal ( SettingID Type );
bool LoadStringVal ( SettingID Type, stdstr & Value );
bool LoadStringVal ( SettingID Type, char * Buffer, int32_t BufferSize );
stdstr LoadStringIndex ( SettingID Type, int32_t index );
bool LoadStringIndex ( SettingID Type, int32_t index, stdstr & Value );
bool LoadStringIndex ( SettingID Type, int32_t index, char * Buffer, int32_t BufferSize );
//Load the default value for the setting
bool LoadDefaultBool ( SettingID Type );
void LoadDefaultBool ( SettingID Type, bool & Value );
bool LoadDefaultBoolIndex ( SettingID Type, int32_t index );
void LoadDefaultBoolIndex ( SettingID Type, int32_t index , bool & Value );
uint32_t LoadDefaultDword ( SettingID Type );
void LoadDefaultDword ( SettingID Type, uint32_t & Value);
uint32_t LoadDefaultDwordIndex ( SettingID Type, int32_t index );
void LoadDefaultDwordIndex ( SettingID Type, int32_t index, uint32_t & Value);
stdstr LoadDefaultString ( SettingID Type );
void LoadDefaultString ( SettingID Type, stdstr & Value );
void LoadDefaultString ( SettingID Type, char * Buffer, int32_t BufferSize );
stdstr LoadDefaultStringIndex ( SettingID Type, int32_t index );
void LoadDefaultStringIndex ( SettingID Type, int32_t index, stdstr & Value );
void LoadDefaultStringIndex ( SettingID Type, int32_t index, char * Buffer, int32_t BufferSize );
//Update the settings
void SaveBool ( SettingID Type, bool Value );
void SaveBoolIndex ( SettingID Type, int32_t index, bool Value );
void SaveDword ( SettingID Type, uint32_t Value );
void SaveDwordIndex ( SettingID Type, int32_t index, uint32_t Value );
void SaveString ( SettingID Type, const stdstr & Value );
void SaveStringIndex ( SettingID Type, int32_t index, const stdstr & Value );
void SaveString ( SettingID Type, const char * Buffer );
void SaveStringIndex ( SettingID Type, int32_t index, const char * Buffer );
// Delete a setting
void DeleteSetting ( SettingID Type );
void DeleteSettingIndex ( SettingID Type, int32_t index );
//Register Notification of change
void RegisterChangeCB ( SettingID Type, void * Data, SettingChangedFunc Func);
void UnregisterChangeCB ( SettingID Type, void * Data, SettingChangedFunc Func);
// information about setting
SettingType GetSettingType ( SettingID Type );
bool IndexBasedSetting ( SettingID Type );
void SettingTypeChanged ( SettingType Type );
// static functions for plugins
static uint32_t GetSetting ( CSettings * _this, SettingID Type );
static const char * GetSettingSz ( CSettings * _this, SettingID Type, char * Buffer, int32_t BufferSize );
static void SetSetting ( CSettings * _this, SettingID ID, uint32_t Value );
static void SetSettingSz ( CSettings * _this, SettingID ID, const char * Value );
static void RegisterSetting ( CSettings * _this, SettingID ID, SettingID DefaultID, SettingDataType DataType,
SettingType Type, const char * Category, const char * DefaultStr,
uint32_t Value );
static uint32_t FindSetting ( CSettings * _this, const char * Name );
static void FlushSettings ( CSettings * _this );
private: private:
void NotifyCallBacks ( SettingID Type ); void NotifyCallBacks(SettingID Type);
SETTING_MAP m_SettingInfo; SETTING_MAP m_SettingInfo;
SETTING_CALLBACK m_Callback; SETTING_CALLBACK m_Callback;

View File

@ -7,5 +7,5 @@
#include <Project64-core/Multilanguage.h> #include <Project64-core/Multilanguage.h>
#include <Project64-core/Notification.h> #include <Project64-core/Notification.h>
#include "Version.h" #include "Version.h"
#include "Settings/SettingsClass.h" #include <Project64-core/Settings/SettingsClass.h>
#include <Project64-core/TraceModulesProject64.h> #include <Project64-core/TraceModulesProject64.h>