Skip to content

Commit

Permalink
nn_acp: Add ACPDevice enum values, add save related functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Maschell authored and GaryOderNichts committed Aug 10, 2024
1 parent 15b28d8 commit 55a4708
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cafe/nn_acp.def
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ ACPGetTitleMetaXmlByTitleListType
ACPGetTitleSaveDir
ACPGetTitleSaveDirEx
ACPGetTitleSaveDirExWithoutMetaCheck
ACPGetTitleSaveMetaXml
ACPGetWoodTin
ACPImportSaveDataFromBuffer
ACPImportSaveDirOfAccountWithEncryption
Expand Down Expand Up @@ -161,3 +160,4 @@ WaitExternalStorage__Q2_2nn3acpFv

:TEXT_WRAP
ACPGetTitleMetaXml
ACPGetTitleSaveMetaXml
9 changes: 8 additions & 1 deletion include/nn/acp/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@
extern "C" {
#endif

typedef int32_t ACPDeviceType;
typedef enum ACPDeviceType {
ACP_DEVICE_TYPE_AUTO = 1,
ACP_DEVICE_TYPE_ODD = 2,
ACP_DEVICE_TYPE_HFIODISC = 2, /* when ApplicationDevice is emulated */
ACP_DEVICE_TYPE_MLC = 3,
ACP_DEVICE_TYPE_HFIOMLC = 3, /* when ApplicationDevice is emulated */
ACP_DEVICE_TYPE_USB = 4,
} ACPDeviceType;

ACPResult
ACPCheckApplicationDeviceEmulation(BOOL* emulation);
Expand Down
69 changes: 68 additions & 1 deletion include/nn/acp/save.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,26 @@
extern "C" {
#endif

typedef uint64_t ACPTitleId;
typedef struct ACPSaveDirInfo ACPSaveDirInfo;

struct WUT_PACKED ACPSaveDirInfo {
WUT_UNKNOWN_BYTES(0x8);
uint32_t persistentId;
WUT_UNKNOWN_BYTES(0x14);
char path[0x40];
WUT_PADDING_BYTES(0x80 - 0x60);
};
WUT_CHECK_OFFSET(ACPSaveDirInfo, 0x08, persistentId);
WUT_CHECK_OFFSET(ACPSaveDirInfo, 0x20, path);
WUT_CHECK_SIZE(ACPSaveDirInfo,0x80);

ACPResult
ACPCreateSaveDir(uint32_t persistentId,
ACPDeviceType deviceType);

ACPResult
ACPIsExternalStorageRequired(BOOL* required);
ACPIsExternalStorageRequired(BOOL *required);

ACPResult
ACPMountExternalStorage();
Expand Down Expand Up @@ -79,6 +93,59 @@ ACPUnmountExternalStorage();
ACPResult
ACPUnmountSaveDir();

/**
* Gets all titles id which have save data
*
* @param deviceType
* @param titlesOut needs to be aligned to 0x40
* @param maxCount needs to be a multiple of 8
* @param countOut
* @return ACP_RESULT_SUCCESS on success.
*/
ACPResult
ACPGetSaveDataTitleIdList(ACPDeviceType deviceType,
uint64_t *titlesOut,
uint32_t maxCount,
uint32_t *countOut);

/**
* Gets a list of all saves dir for a given title id
*
* @param titleId
* @param deviceType
* @param u1 seems to be always 0
* @param saveDirInfo needs to be aligned to 0x40
* @param maxCount
* @param countOut
* @return ACP_RESULT_SUCCESS on success.
*/
ACPResult
ACPGetTitleSaveDirEx(uint64_t titleId,
ACPDeviceType deviceType,
uint32_t u1,
ACPSaveDirInfo *saveDirInfo,
uint32_t maxCount,
uint32_t *countOut);

/**
* Gets a list of all saves dir for a given title id
*
* @param titleId
* @param deviceType
* @param u1 seems to be always 0
* @param saveDirInfo needs to be aligned to 0x40
* @param maxCount
* @param countOut
* @return ACP_RESULT_SUCCESS on success.
*/
ACPResult
ACPGetTitleSaveDirExWithoutMetaCheck(uint64_t titleId,
ACPDeviceType deviceType,
uint32_t u1,
ACPSaveDirInfo *saveDirInfo,
uint32_t maxCount,
uint32_t *countOut);

#ifdef __cplusplus
}
#endif
Expand Down
23 changes: 23 additions & 0 deletions include/nn/acp/title.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,29 @@ ACPGetTitleMetaXml(ACPTitleId titleId,
return RPLWRAP(ACPGetTitleMetaXml)(titleId, metaXml);
}

ACPResult
RPLWRAP(ACPGetTitleSaveMetaXml)(uint64_t titleId,
ACPMetaXml* metaXml,
ACPDeviceType deviceType);

/**
* Gets the save dir MetaXML for a given title id
* @param titleId
* @param metaXml must be aligned to 0x40
* @param deviceType
* @return ACP_RESULT_SUCCESS on success,
* ACP_RESULT_INVALID_PARAMETER if metaXml is not aligned properly
*/
static inline ACPResult
ACPGetTitleSaveMetaXml(ACPTitleId titleId,
ACPMetaXml *metaXml,
ACPDeviceType deviceType) {
if ((uintptr_t) metaXml & 0x3F) {
return ACP_RESULT_INVALID_PARAMETER;
}
return RPLWRAP(ACPGetTitleSaveMetaXml)(titleId, metaXml, deviceType);
}

ACPResult
ACPGetTitleMetaDir(ACPTitleId titleId,
char *directory,
Expand Down

0 comments on commit 55a4708

Please sign in to comment.