summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/common_paths.h1
-rw-r--r--src/common/file_util.cpp2
-rw-r--r--src/common/file_util.h1
-rw-r--r--src/core/CMakeLists.txt2
-rw-r--r--src/core/arm/interpreter/armemu.cpp113
-rw-r--r--src/core/file_sys/archive_savedata.h3
-rw-r--r--src/core/file_sys/archive_systemsavedata.cpp33
-rw-r--r--src/core/file_sys/archive_systemsavedata.h33
-rw-r--r--src/core/hle/service/fs/archive.cpp9
9 files changed, 150 insertions, 47 deletions
diff --git a/src/common/common_paths.h b/src/common/common_paths.h
index a86889756..966402a3d 100644
--- a/src/common/common_paths.h
+++ b/src/common/common_paths.h
@@ -42,6 +42,7 @@
42#define SDMC_DIR "sdmc" 42#define SDMC_DIR "sdmc"
43#define SAVEDATA_DIR "savedata" 43#define SAVEDATA_DIR "savedata"
44#define SYSDATA_DIR "sysdata" 44#define SYSDATA_DIR "sysdata"
45#define SYSSAVEDATA_DIR "syssavedata"
45#define SHADERCACHE_DIR "shader_cache" 46#define SHADERCACHE_DIR "shader_cache"
46#define STATESAVES_DIR "state_saves" 47#define STATESAVES_DIR "state_saves"
47#define SCREENSHOTS_DIR "screenShots" 48#define SCREENSHOTS_DIR "screenShots"
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp
index 42cdf3262..20c680571 100644
--- a/src/common/file_util.cpp
+++ b/src/common/file_util.cpp
@@ -678,6 +678,7 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string &new
678 paths[D_SDMC_IDX] = paths[D_USER_IDX] + SDMC_DIR DIR_SEP; 678 paths[D_SDMC_IDX] = paths[D_USER_IDX] + SDMC_DIR DIR_SEP;
679 paths[D_SAVEDATA_IDX] = paths[D_USER_IDX] + SAVEDATA_DIR DIR_SEP; 679 paths[D_SAVEDATA_IDX] = paths[D_USER_IDX] + SAVEDATA_DIR DIR_SEP;
680 paths[D_SYSDATA_IDX] = paths[D_USER_IDX] + SYSDATA_DIR DIR_SEP; 680 paths[D_SYSDATA_IDX] = paths[D_USER_IDX] + SYSDATA_DIR DIR_SEP;
681 paths[D_SYSSAVEDATA_IDX] = paths[D_USER_IDX] + SYSSAVEDATA_DIR DIR_SEP;
681 paths[D_SHADERCACHE_IDX] = paths[D_USER_IDX] + SHADERCACHE_DIR DIR_SEP; 682 paths[D_SHADERCACHE_IDX] = paths[D_USER_IDX] + SHADERCACHE_DIR DIR_SEP;
682 paths[D_SHADERS_IDX] = paths[D_USER_IDX] + SHADERS_DIR DIR_SEP; 683 paths[D_SHADERS_IDX] = paths[D_USER_IDX] + SHADERS_DIR DIR_SEP;
683 paths[D_STATESAVES_IDX] = paths[D_USER_IDX] + STATESAVES_DIR DIR_SEP; 684 paths[D_STATESAVES_IDX] = paths[D_USER_IDX] + STATESAVES_DIR DIR_SEP;
@@ -720,6 +721,7 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string &new
720 paths[D_CACHE_IDX] = paths[D_USER_IDX] + CACHE_DIR DIR_SEP; 721 paths[D_CACHE_IDX] = paths[D_USER_IDX] + CACHE_DIR DIR_SEP;
721 paths[D_SDMC_IDX] = paths[D_USER_IDX] + SDMC_DIR DIR_SEP; 722 paths[D_SDMC_IDX] = paths[D_USER_IDX] + SDMC_DIR DIR_SEP;
722 paths[D_SAVEDATA_IDX] = paths[D_USER_IDX] + SAVEDATA_DIR DIR_SEP; 723 paths[D_SAVEDATA_IDX] = paths[D_USER_IDX] + SAVEDATA_DIR DIR_SEP;
724 paths[D_SYSSAVEDATA_IDX] = paths[D_USER_IDX] + SYSSAVEDATA_DIR DIR_SEP;
723 paths[D_SHADERCACHE_IDX] = paths[D_USER_IDX] + SHADERCACHE_DIR DIR_SEP; 725 paths[D_SHADERCACHE_IDX] = paths[D_USER_IDX] + SHADERCACHE_DIR DIR_SEP;
724 paths[D_SHADERS_IDX] = paths[D_USER_IDX] + SHADERS_DIR DIR_SEP; 726 paths[D_SHADERS_IDX] = paths[D_USER_IDX] + SHADERS_DIR DIR_SEP;
725 paths[D_STATESAVES_IDX] = paths[D_USER_IDX] + STATESAVES_DIR DIR_SEP; 727 paths[D_STATESAVES_IDX] = paths[D_USER_IDX] + STATESAVES_DIR DIR_SEP;
diff --git a/src/common/file_util.h b/src/common/file_util.h
index e691b6139..b1a60fb81 100644
--- a/src/common/file_util.h
+++ b/src/common/file_util.h
@@ -29,6 +29,7 @@ enum {
29 D_SDMC_IDX, 29 D_SDMC_IDX,
30 D_SAVEDATA_IDX, 30 D_SAVEDATA_IDX,
31 D_SYSDATA_IDX, 31 D_SYSDATA_IDX,
32 D_SYSSAVEDATA_IDX,
32 D_HIRESTEXTURES_IDX, 33 D_HIRESTEXTURES_IDX,
33 D_DUMP_IDX, 34 D_DUMP_IDX,
34 D_DUMPFRAMES_IDX, 35 D_DUMPFRAMES_IDX,
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index f71232c1a..3381524e3 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -20,6 +20,7 @@ set(SRCS
20 file_sys/archive_romfs.cpp 20 file_sys/archive_romfs.cpp
21 file_sys/archive_savedata.cpp 21 file_sys/archive_savedata.cpp
22 file_sys/archive_sdmc.cpp 22 file_sys/archive_sdmc.cpp
23 file_sys/archive_systemsavedata.cpp
23 file_sys/disk_archive.cpp 24 file_sys/disk_archive.cpp
24 file_sys/file_romfs.cpp 25 file_sys/file_romfs.cpp
25 file_sys/directory_romfs.cpp 26 file_sys/directory_romfs.cpp
@@ -101,6 +102,7 @@ set(HEADERS
101 file_sys/archive_romfs.h 102 file_sys/archive_romfs.h
102 file_sys/archive_savedata.h 103 file_sys/archive_savedata.h
103 file_sys/archive_sdmc.h 104 file_sys/archive_sdmc.h
105 file_sys/archive_systemsavedata.h
104 file_sys/disk_archive.h 106 file_sys/disk_archive.h
105 file_sys/file_backend.h 107 file_sys/file_backend.h
106 file_sys/file_romfs.h 108 file_sys/file_romfs.h
diff --git a/src/core/arm/interpreter/armemu.cpp b/src/core/arm/interpreter/armemu.cpp
index 3b1a36bdd..07d205755 100644
--- a/src/core/arm/interpreter/armemu.cpp
+++ b/src/core/arm/interpreter/armemu.cpp
@@ -5827,8 +5827,10 @@ L_stm_s_takeabort:
5827 case 0x3f: 5827 case 0x3f:
5828 printf ("Unhandled v6 insn: rbit\n"); 5828 printf ("Unhandled v6 insn: rbit\n");
5829 break; 5829 break;
5830 case 0x61: 5830 case 0x61: // SSUB16, SADD16, SSAX, and SASX
5831 if ((instr & 0xFF0) == 0xf70) { //ssub16 5831 if ((instr & 0xFF0) == 0xf70 || (instr & 0xFF0) == 0xf10 ||
5832 (instr & 0xFF0) == 0xf50 || (instr & 0xFF0) == 0xf30)
5833 {
5832 const u8 rd_idx = BITS(12, 15); 5834 const u8 rd_idx = BITS(12, 15);
5833 const u8 rm_idx = BITS(0, 3); 5835 const u8 rm_idx = BITS(0, 3);
5834 const u8 rn_idx = BITS(16, 19); 5836 const u8 rn_idx = BITS(16, 19);
@@ -5836,40 +5838,52 @@ L_stm_s_takeabort:
5836 const s16 rn_hi = ((state->Reg[rn_idx] >> 16) & 0xFFFF); 5838 const s16 rn_hi = ((state->Reg[rn_idx] >> 16) & 0xFFFF);
5837 const s16 rm_lo = (state->Reg[rm_idx] & 0xFFFF); 5839 const s16 rm_lo = (state->Reg[rm_idx] & 0xFFFF);
5838 const s16 rm_hi = ((state->Reg[rm_idx] >> 16) & 0xFFFF); 5840 const s16 rm_hi = ((state->Reg[rm_idx] >> 16) & 0xFFFF);
5839 state->Reg[rd_idx] = ((rn_lo - rm_lo) & 0xFFFF) | (((rn_hi - rm_hi) & 0xFFFF) << 16);
5840 return 1;
5841 } else if ((instr & 0xFF0) == 0xf10) { //sadd16
5842 const u8 rd_idx = BITS(12, 15);
5843 const u8 rm_idx = BITS(0, 3);
5844 const u8 rn_idx = BITS(16, 19);
5845 const s16 rm_lo = (state->Reg[rm_idx] & 0xFFFF);
5846 const s16 rm_hi = ((state->Reg[rm_idx] >> 16) & 0xFFFF);
5847 const s16 rn_lo = (state->Reg[rn_idx] & 0xFFFF);
5848 const s16 rn_hi = ((state->Reg[rn_idx] >> 16) & 0xFFFF);
5849 5841
5850 state->Reg[rd_idx] = ((rn_lo + rm_lo) & 0xFFFF) | (((rn_hi + rm_hi) & 0xFFFF) << 16); 5842 s32 lo_result;
5851 return 1; 5843 s32 hi_result;
5852 } else if ((instr & 0xFF0) == 0xf50) { //ssax 5844
5853 u8 tar = BITS(12, 15); 5845 // SSUB16
5854 u8 src1 = BITS(16, 19); 5846 if ((instr & 0xFF0) == 0xf70) {
5855 u8 src2 = BITS(0, 3); 5847 lo_result = (rn_lo - rm_lo);
5856 s16 a1 = (state->Reg[src1] & 0xFFFF); 5848 hi_result = (rn_hi - rm_hi);
5857 s16 a2 = ((state->Reg[src1] >> 0x10) & 0xFFFF); 5849 }
5858 s16 b1 = (state->Reg[src2] & 0xFFFF); 5850 // SADD16
5859 s16 b2 = ((state->Reg[src2] >> 0x10) & 0xFFFF); 5851 else if ((instr & 0xFF0) == 0xf10) {
5860 state->Reg[tar] = ((a1 + b2) & 0xFFFF) | (((a2 - b1) & 0xFFFF) << 0x10); 5852 lo_result = (rn_lo + rm_lo);
5861 return 1; 5853 hi_result = (rn_hi + rm_hi);
5862 } else if ((instr & 0xFF0) == 0xf30) { //sasx 5854 }
5863 u8 tar = BITS(12, 15); 5855 // SSAX
5864 u8 src1 = BITS(16, 19); 5856 else if ((instr & 0xFF0) == 0xf50) {
5865 u8 src2 = BITS(0, 3); 5857 lo_result = (rn_lo + rm_hi);
5866 s16 a1 = (state->Reg[src1] & 0xFFFF); 5858 hi_result = (rn_hi - rm_lo);
5867 s16 a2 = ((state->Reg[src1] >> 0x10) & 0xFFFF); 5859 }
5868 s16 b1 = (state->Reg[src2] & 0xFFFF); 5860 // SASX
5869 s16 b2 = ((state->Reg[src2] >> 0x10) & 0xFFFF); 5861 else {
5870 state->Reg[tar] = ((a1 - b2) & 0xFFFF) | (((a2 + b1) & 0xFFFF) << 0x10); 5862 lo_result = (rn_lo - rm_hi);
5863 hi_result = (rn_hi + rm_lo);
5864 }
5865
5866 state->Reg[rd_idx] = (lo_result & 0xFFFF) | ((hi_result & 0xFFFF) << 16);
5867
5868 if (lo_result >= 0) {
5869 state->Cpsr |= (1 << 16);
5870 state->Cpsr |= (1 << 17);
5871 } else {
5872 state->Cpsr &= ~(1 << 16);
5873 state->Cpsr &= ~(1 << 17);
5874 }
5875
5876 if (hi_result >= 0) {
5877 state->Cpsr |= (1 << 18);
5878 state->Cpsr |= (1 << 19);
5879 } else {
5880 state->Cpsr &= ~(1 << 18);
5881 state->Cpsr &= ~(1 << 19);
5882 }
5871 return 1; 5883 return 1;
5872 } else printf ("Unhandled v6 insn: sadd/ssub/ssax/sasx\n"); 5884 } else {
5885 printf("Unhandled v6 insn: %08x", BITS(20, 27));
5886 }
5873 break; 5887 break;
5874 case 0x62: // QSUB16 and QADD16 5888 case 0x62: // QSUB16 and QADD16
5875 if ((instr & 0xFF0) == 0xf70 || (instr & 0xFF0) == 0xf10) { 5889 if ((instr & 0xFF0) == 0xf70 || (instr & 0xFF0) == 0xf10) {
@@ -6203,18 +6217,27 @@ L_stm_s_takeabort:
6203 //ichfly 6217 //ichfly
6204 //USAT16 6218 //USAT16
6205 { 6219 {
6206 u8 tar = BITS(12, 15); 6220 const u8 rd_idx = BITS(12, 15);
6207 u8 src = BITS(0, 3); 6221 const u8 rn_idx = BITS(0, 3);
6208 u8 val = BITS(16, 19); 6222 const u8 num_bits = BITS(16, 19);
6209 s16 a1 = (state->Reg[src]); 6223 const s16 max = 0xFFFF >> (16 - num_bits);
6210 s16 a2 = (state->Reg[src] >> 0x10); 6224 s16 rn_lo = (state->Reg[rn_idx]);
6211 s16 max = 0xFFFF >> (16 - val); 6225 s16 rn_hi = (state->Reg[rn_idx] >> 16);
6212 if (max < a1) a1 = max; 6226
6213 if (max < a2) a2 = max; 6227 if (max < rn_lo)
6214 u32 temp2 = ((u32)(a2)) << 0x10; 6228 rn_lo = max;
6215 state->Reg[tar] = (a1 & 0xFFFF) | (temp2); 6229 else if (rn_lo < 0)
6230 rn_lo = 0;
6231
6232 if (max < rn_hi)
6233 rn_hi = max;
6234 else if (rn_hi < 0)
6235 rn_hi = 0;
6236
6237 state->Reg[rd_idx] = (rn_lo & 0xFFFF) | ((rn_hi << 16) & 0xFFFF);
6238 return 1;
6216 } 6239 }
6217 return 1; 6240
6218 default: 6241 default:
6219 break; 6242 break;
6220 } 6243 }
diff --git a/src/core/file_sys/archive_savedata.h b/src/core/file_sys/archive_savedata.h
index b3e561130..d394ad37e 100644
--- a/src/core/file_sys/archive_savedata.h
+++ b/src/core/file_sys/archive_savedata.h
@@ -21,8 +21,7 @@ public:
21 21
22 /** 22 /**
23 * Initialize the archive. 23 * Initialize the archive.
24 * @return CreateSaveDataResult AlreadyExists if the SaveData folder already exists, 24 * @return true if it initialized successfully
25 * Success if it was created properly and Failure if there was any error
26 */ 25 */
27 bool Initialize(); 26 bool Initialize();
28 27
diff --git a/src/core/file_sys/archive_systemsavedata.cpp b/src/core/file_sys/archive_systemsavedata.cpp
new file mode 100644
index 000000000..dc2c23b41
--- /dev/null
+++ b/src/core/file_sys/archive_systemsavedata.cpp
@@ -0,0 +1,33 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2+
3// Refer to the license.txt file included.
4
5#include <sys/stat.h>
6
7#include "common/common_types.h"
8#include "common/file_util.h"
9
10#include "core/file_sys/archive_systemsavedata.h"
11#include "core/file_sys/disk_archive.h"
12#include "core/settings.h"
13
14////////////////////////////////////////////////////////////////////////////////////////////////////
15// FileSys namespace
16
17namespace FileSys {
18
19Archive_SystemSaveData::Archive_SystemSaveData(const std::string& mount_point)
20 : DiskArchive(mount_point) {
21 LOG_INFO(Service_FS, "Directory %s set as SystemSaveData.", this->mount_point.c_str());
22}
23
24bool Archive_SystemSaveData::Initialize() {
25 if (!FileUtil::CreateFullPath(mount_point)) {
26 LOG_ERROR(Service_FS, "Unable to create SystemSaveData path.");
27 return false;
28 }
29
30 return true;
31}
32
33} // namespace FileSys
diff --git a/src/core/file_sys/archive_systemsavedata.h b/src/core/file_sys/archive_systemsavedata.h
new file mode 100644
index 000000000..360ed1e13
--- /dev/null
+++ b/src/core/file_sys/archive_systemsavedata.h
@@ -0,0 +1,33 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2+
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "common/common_types.h"
8
9#include "core/file_sys/disk_archive.h"
10#include "core/loader/loader.h"
11
12////////////////////////////////////////////////////////////////////////////////////////////////////
13// FileSys namespace
14
15namespace FileSys {
16
17/// File system interface to the SystemSaveData archive
18/// TODO(Subv): This archive should point to a location in the NAND,
19/// specifically nand:/data/<ID0>/sysdata/<SaveID-Low>/<SaveID-High>
20class Archive_SystemSaveData final : public DiskArchive {
21public:
22 Archive_SystemSaveData(const std::string& mount_point);
23
24 /**
25 * Initialize the archive.
26 * @return true if it initialized successfully
27 */
28 bool Initialize();
29
30 std::string GetName() const override { return "SystemSaveData"; }
31};
32
33} // namespace FileSys
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp
index 9c3834733..5ab82729c 100644
--- a/src/core/hle/service/fs/archive.cpp
+++ b/src/core/hle/service/fs/archive.cpp
@@ -419,6 +419,15 @@ void ArchiveInit() {
419 CreateArchive(std::move(sdmc_archive), ArchiveIdCode::SDMC); 419 CreateArchive(std::move(sdmc_archive), ArchiveIdCode::SDMC);
420 else 420 else
421 LOG_ERROR(Service_FS, "Can't instantiate SDMC archive with path %s", sdmc_directory.c_str()); 421 LOG_ERROR(Service_FS, "Can't instantiate SDMC archive with path %s", sdmc_directory.c_str());
422
423 std::string systemsavedata_directory = FileUtil::GetUserPath(D_SYSSAVEDATA_IDX);
424 auto systemsavedata_archive = std::make_unique<FileSys::Archive_SDMC>(systemsavedata_directory);
425 if (systemsavedata_archive->Initialize()) {
426 CreateArchive(std::move(systemsavedata_archive), ArchiveIdCode::SystemSaveData);
427 } else {
428 LOG_ERROR(Service_FS, "Can't instantiate SystemSaveData archive with path %s",
429 systemsavedata_directory.c_str());
430 }
422} 431}
423 432
424/// Shutdown archives 433/// Shutdown archives