Skip to content

Commit

Permalink
Implement skeleton for Triforce backup support
Browse files Browse the repository at this point in the history
  • Loading branch information
Zopolis4 committed Nov 8, 2021
1 parent 75cd68e commit fced217
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions Source/Core/Common/CommonPaths.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

// Subdirs in the User dir returned by GetUserPath(D_USER_IDX)
#define GC_USER_DIR "GC"
#define TRI_USER_DIR "Triforce"
#define GBA_USER_DIR "GBA"
#define WII_USER_DIR "Wii"
#define CONFIG_DIR "Config"
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Common/FileUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,7 @@ static void RebuildUserDirectories(unsigned int dir_index)
{
case D_USER_IDX:
s_user_paths[D_GCUSER_IDX] = s_user_paths[D_USER_IDX] + GC_USER_DIR DIR_SEP;
s_user_paths[D_TRIUSER_IDX] = s_user_paths[D_USER_IDX] + TRI_USER_DIR DIR_SEP;
s_user_paths[D_WIIROOT_IDX] = s_user_paths[D_USER_IDX] + WII_USER_DIR;
s_user_paths[D_CONFIG_IDX] = s_user_paths[D_USER_IDX] + CONFIG_DIR DIR_SEP;
s_user_paths[D_GAMESETTINGS_IDX] = s_user_paths[D_USER_IDX] + GAMESETTINGS_DIR DIR_SEP;
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Common/FileUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ enum
{
D_USER_IDX,
D_GCUSER_IDX,
D_TRIUSER_IDX,
D_WIIROOT_IDX, // always points to User/Wii or global user-configured directory
D_SESSION_WIIROOT_IDX, // may point to minimal temporary directory for determinism
D_CONFIG_IDX, // global settings
Expand Down
22 changes: 21 additions & 1 deletion Source/Core/Core/HW/EXI/EXI_DeviceBaseboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,32 @@

#include "Common/Assert.h"
#include "Common/ChunkFile.h"
#include "Common/CommonPaths.h"
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/IOFile.h"
#include "Common/Logging/Log.h"

namespace ExpansionInterface
{
CEXIBaseboard::CEXIBaseboard() = default;
CEXIBaseboard::CEXIBaseboard()
{
EEPROM_filename = File::GetUserPath(D_TRIUSER_IDX) + "EEPROM.raw";
if (File::Exists(EEPROM_filename))
{
m_EEPROM = std::make_unique<File::IOFile>(EEPROM_filename, "rb+");
}
else
{
m_EEPROM = std::make_unique<File::IOFile>(EEPROM_filename, "wb+");
}
}

CEXIBaseboard::~CEXIBaseboard()
{
m_EEPROM->Close();
File::Delete(EEPROM_filename);
}

void CEXIBaseboard::SetCS(int cs)
{
Expand Down
6 changes: 6 additions & 0 deletions Source/Core/Core/HW/EXI/EXI_DeviceBaseboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include "Core/HW/EXI/EXI_Device.h"

#include "Common/IOFile.h"

class PointerWrap;

namespace ExpansionInterface
Expand All @@ -13,11 +15,15 @@ class CEXIBaseboard : public IEXIDevice
{
public:
CEXIBaseboard();
~CEXIBaseboard();
void SetCS(int CS) override;
bool IsPresent() const override;
void DoState(PointerWrap& p) override;

private:
std::string EEPROM_filename;
std::unique_ptr<File::IOFile> m_EEPROM;

// STATE_TO_SAVE
u32 m_position = 0;
u32 m_command = 0;
Expand Down
1 change: 1 addition & 0 deletions Source/Core/UICommon/UICommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ void CreateDirectories()
File::CreateFullPath(File::GetUserPath(D_SHADERS_IDX));
File::CreateFullPath(File::GetUserPath(D_SHADERS_IDX) + ANAGLYPH_DIR DIR_SEP);
File::CreateFullPath(File::GetUserPath(D_STATESAVES_IDX));
File::CreateFullPath(File::GetUserPath(D_TRIUSER_IDX));
#ifndef ANDROID
File::CreateFullPath(File::GetUserPath(D_THEMES_IDX));
File::CreateFullPath(File::GetUserPath(D_STYLES_IDX));
Expand Down

0 comments on commit fced217

Please sign in to comment.