Remove palladium out of ctrff
- Why??? cause ahving multiple diffrent libraries all depending on palladium is pain to handle as well as palladium was only used for its datatypes so theres no reason to kepp it for ctrff
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,6 +1,3 @@
|
||||
[submodule "vendor/cli-fancy"]
|
||||
path = vendor/cli-fancy
|
||||
url = https://dev.npid7.de/tobid7/cli-fancy
|
||||
[submodule "vendor/palladium"]
|
||||
path = vendor/palladium
|
||||
url = https://dev.npid7.de/tobid7/palladium.git
|
||||
|
||||
@@ -19,7 +19,6 @@ if(${CTRFF_3DS})
|
||||
endif()
|
||||
endif()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-psabi -O3")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS} -fno-rtti")
|
||||
endif()
|
||||
|
||||
add_library(ctrff STATIC
|
||||
@@ -32,7 +31,6 @@ add_library(ctrff STATIC
|
||||
source/3dsx.cpp
|
||||
)
|
||||
target_include_directories(ctrff PUBLIC include)
|
||||
target_include_directories(ctrff PRIVATE vendor/palladium/include)
|
||||
|
||||
if(${CTRFF_DESKTOP})
|
||||
add_executable(ctrff-cli tool/main.cpp)
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <ctrff/helper.hpp>
|
||||
#include <ctrff/pd_p_api.hpp>
|
||||
#include <ctrff/smdh.hpp>
|
||||
#include <pd.hpp>
|
||||
#include <ctrff/types.hpp>
|
||||
|
||||
namespace ctrff {
|
||||
class CTRFF_API _3dsx : public BinFile {
|
||||
@@ -23,24 +22,24 @@ class CTRFF_API _3dsx : public BinFile {
|
||||
void Write(std::fstream& f) const override;
|
||||
void Read(std::fstream& f) override;
|
||||
|
||||
PD::u32 Magic;
|
||||
PD::u16 HeaderSize;
|
||||
PD::u16 RelocHeaderSize;
|
||||
PD::u32 FormatVersion;
|
||||
PD::u32 Flags;
|
||||
ctrff::u32 Magic;
|
||||
ctrff::u16 HeaderSize;
|
||||
ctrff::u16 RelocHeaderSize;
|
||||
ctrff::u32 FormatVersion;
|
||||
ctrff::u32 Flags;
|
||||
// Sizes of the code, rodata and data segments +
|
||||
// size of the BSS section (uninitialized latter half of the data segment)
|
||||
PD::u32 CodeSegSize;
|
||||
PD::u32 RodataSegSize;
|
||||
PD::u32 DataSegSize;
|
||||
PD::u32 BssSize;
|
||||
ctrff::u32 CodeSegSize;
|
||||
ctrff::u32 RodataSegSize;
|
||||
ctrff::u32 DataSegSize;
|
||||
ctrff::u32 BssSize;
|
||||
/// Extended Header ///
|
||||
// smdh offset
|
||||
PD::u32 SMDHOff;
|
||||
ctrff::u32 SMDHOff;
|
||||
// smdh size
|
||||
PD::u32 SMDHSize;
|
||||
ctrff::u32 SMDHSize;
|
||||
// fs offset
|
||||
PD::u32 FsOff;
|
||||
ctrff::u32 FsOff;
|
||||
SMDH Meta;
|
||||
};
|
||||
/** Probably only germen people will understand */
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <ctrff/binutil.hpp>
|
||||
#include <ctrff/pd_p_api.hpp>
|
||||
#include <pd.hpp>
|
||||
#include <ctrff/types.hpp>
|
||||
#include <palladium>
|
||||
|
||||
namespace ctrff {
|
||||
class CTRFF_API BCSTM {
|
||||
@@ -13,38 +13,44 @@ class CTRFF_API BCSTM {
|
||||
void LoadFile(const std::string& path);
|
||||
void CleanUp();
|
||||
void ReadGotoBeginning(bool use_loop_beg = false);
|
||||
void ReadBlock(PD::u32 block, PD::u8* ref);
|
||||
void ReadBlock(ctrff::u32 block, ctrff::u8* ref);
|
||||
|
||||
/** Some useful Getters */
|
||||
PD::u8 GetNumChannels() const { return pInfoBlock.StreamInfo.ChannelCount; }
|
||||
PD::u32 GetSampleRate() const { return pInfoBlock.StreamInfo.SampleRate; }
|
||||
PD::u32 GetBlockSize() const { return pInfoBlock.StreamInfo.SampleBlockSize; }
|
||||
PD::u32 GetNumBlocks() const { return pInfoBlock.StreamInfo.SampleBlockNum; }
|
||||
PD::u32 GetBlockSamples() const {
|
||||
ctrff::u8 GetNumChannels() const {
|
||||
return pInfoBlock.StreamInfo.ChannelCount;
|
||||
}
|
||||
ctrff::u32 GetSampleRate() const { return pInfoBlock.StreamInfo.SampleRate; }
|
||||
ctrff::u32 GetBlockSize() const {
|
||||
return pInfoBlock.StreamInfo.SampleBlockSize;
|
||||
}
|
||||
ctrff::u32 GetNumBlocks() const {
|
||||
return pInfoBlock.StreamInfo.SampleBlockNum;
|
||||
}
|
||||
ctrff::u32 GetBlockSamples() const {
|
||||
return pInfoBlock.StreamInfo.SampleBlockSampleNum;
|
||||
}
|
||||
PD::u32 GetLastBlockSamples() const {
|
||||
ctrff::u32 GetLastBlockSamples() const {
|
||||
return pInfoBlock.StreamInfo.LastSampleBlockSampleNum;
|
||||
}
|
||||
bool IsLooping() const { return pInfoBlock.StreamInfo.Loop; }
|
||||
PD::u32 GetLoopStart() const {
|
||||
ctrff::u32 GetLoopStart() const {
|
||||
return pInfoBlock.StreamInfo.LoopStartFrame / GetBlockSamples();
|
||||
}
|
||||
PD::u32 GetLoopEnd() const {
|
||||
ctrff::u32 GetLoopEnd() const {
|
||||
/** Get temp references for better readability */
|
||||
const PD::u32& loop_end = pInfoBlock.StreamInfo.LoopEndFrame;
|
||||
const PD::u32& block_samples = GetBlockSamples();
|
||||
const ctrff::u32& loop_end = pInfoBlock.StreamInfo.LoopEndFrame;
|
||||
const ctrff::u32& block_samples = GetBlockSamples();
|
||||
return (loop_end % block_samples ? GetNumBlocks()
|
||||
: loop_end / block_samples);
|
||||
}
|
||||
|
||||
/** Internal Data (can be made private with private: but public by default) */
|
||||
enum Endianness : PD::u16 {
|
||||
enum Endianness : ctrff::u16 {
|
||||
Big = 0xfffe, ///< Big Endian
|
||||
Little = 0xfeff, ///< Little Endian
|
||||
};
|
||||
|
||||
enum ReferenceTypes : PD::u16 {
|
||||
enum ReferenceTypes : ctrff::u16 {
|
||||
Ref_ByteTable = 0x0100,
|
||||
Ref_ReferenceTable = 0x0101,
|
||||
Ref_DSP_ADPCM_Info = 0x0300,
|
||||
@@ -58,7 +64,7 @@ class CTRFF_API BCSTM {
|
||||
Ref_ChannelInfo = 0x4102,
|
||||
};
|
||||
|
||||
enum Encoding : PD::u8 {
|
||||
enum Encoding : ctrff::u8 {
|
||||
PCM8 = 0,
|
||||
PCM16 = 1,
|
||||
/** Only supported encoding in BCSTM-Player */
|
||||
@@ -68,50 +74,50 @@ class CTRFF_API BCSTM {
|
||||
|
||||
struct Reference {
|
||||
Reference() : TypeID(0), Padding(0), Offset(0) {}
|
||||
Reference(PD::u16 t, PD::u16 p, PD::u32 o)
|
||||
Reference(ctrff::u16 t, ctrff::u16 p, ctrff::u32 o)
|
||||
: TypeID(t), Padding(p), Offset(o) {}
|
||||
PD::u16 TypeID;
|
||||
PD::u16 Padding;
|
||||
PD::u32 Offset; /** null -> uint32_max */
|
||||
ctrff::u16 TypeID;
|
||||
ctrff::u16 Padding;
|
||||
ctrff::u32 Offset; /** null -> uint32_max */
|
||||
};
|
||||
|
||||
struct ReferenceTable {
|
||||
ReferenceTable() : Count(0) {}
|
||||
PD::u32 Count;
|
||||
ctrff::u32 Count;
|
||||
std::vector<Reference> Refs;
|
||||
};
|
||||
|
||||
struct SizedReference {
|
||||
SizedReference() : Size(0) {}
|
||||
Reference Ref;
|
||||
PD::u32 Size;
|
||||
ctrff::u32 Size;
|
||||
};
|
||||
|
||||
struct StreamInfo {
|
||||
StreamInfo();
|
||||
PD::u8 Encoding;
|
||||
PD::u8 Loop;
|
||||
PD::u8 ChannelCount;
|
||||
PD::u8 Padding;
|
||||
PD::u32 SampleRate;
|
||||
PD::u32 LoopStartFrame;
|
||||
PD::u32 LoopEndFrame;
|
||||
PD::u32 SampleBlockNum;
|
||||
PD::u32 SampleBlockSize;
|
||||
PD::u32 SampleBlockSampleNum;
|
||||
PD::u32 LastSampleBlockSize;
|
||||
PD::u32 LastSampleBlockSampleNum;
|
||||
PD::u32 LastSampleBlockPaddedSize;
|
||||
PD::u32 SeekDataSize;
|
||||
PD::u32 SeekIntervalSampleNum;
|
||||
ctrff::u8 Encoding;
|
||||
ctrff::u8 Loop;
|
||||
ctrff::u8 ChannelCount;
|
||||
ctrff::u8 Padding;
|
||||
ctrff::u32 SampleRate;
|
||||
ctrff::u32 LoopStartFrame;
|
||||
ctrff::u32 LoopEndFrame;
|
||||
ctrff::u32 SampleBlockNum;
|
||||
ctrff::u32 SampleBlockSize;
|
||||
ctrff::u32 SampleBlockSampleNum;
|
||||
ctrff::u32 LastSampleBlockSize;
|
||||
ctrff::u32 LastSampleBlockSampleNum;
|
||||
ctrff::u32 LastSampleBlockPaddedSize;
|
||||
ctrff::u32 SeekDataSize;
|
||||
ctrff::u32 SeekIntervalSampleNum;
|
||||
Reference SampleDataRef;
|
||||
};
|
||||
|
||||
struct BlockHeader {
|
||||
BlockHeader() : Magic(0), Size(0) {}
|
||||
BlockHeader(PD::u32 m, PD::u32 s) : Magic(m), Size(s) {}
|
||||
PD::u32 Magic;
|
||||
PD::u32 Size;
|
||||
BlockHeader(ctrff::u32 m, ctrff::u32 s) : Magic(m), Size(s) {}
|
||||
ctrff::u32 Magic;
|
||||
ctrff::u32 Size;
|
||||
};
|
||||
|
||||
struct InfoBlock {
|
||||
@@ -130,13 +136,13 @@ class CTRFF_API BCSTM {
|
||||
struct SD_Block {
|
||||
SD_Block() {}
|
||||
BlockHeader Header;
|
||||
std::vector<PD::u8> Data;
|
||||
std::vector<ctrff::u8> Data;
|
||||
};
|
||||
|
||||
struct DSP_ADPCM_Param {
|
||||
// Lets keep this not clean here :/
|
||||
DSP_ADPCM_Param() {}
|
||||
PD::u16 Coefficients[0x10];
|
||||
ctrff::u16 Coefficients[0x10];
|
||||
};
|
||||
|
||||
struct DSP_ADPCM_Context {
|
||||
@@ -145,10 +151,10 @@ class CTRFF_API BCSTM {
|
||||
Reserved(0),
|
||||
PreviousSample(0),
|
||||
SecondPreviousSample(0) {}
|
||||
PD::u8 PredictorScale;
|
||||
PD::u8 Reserved;
|
||||
PD::u16 PreviousSample;
|
||||
PD::u16 SecondPreviousSample;
|
||||
ctrff::u8 PredictorScale;
|
||||
ctrff::u8 Reserved;
|
||||
ctrff::u16 PreviousSample;
|
||||
ctrff::u16 SecondPreviousSample;
|
||||
};
|
||||
|
||||
struct DSP_ADPCM_Info {
|
||||
@@ -156,20 +162,20 @@ class CTRFF_API BCSTM {
|
||||
DSP_ADPCM_Param Param;
|
||||
DSP_ADPCM_Context Context;
|
||||
DSP_ADPCM_Context LoopContext;
|
||||
PD::u16 Padding;
|
||||
ctrff::u16 Padding;
|
||||
};
|
||||
|
||||
struct ByteTable {
|
||||
ByteTable(PD::u32 size = 0) : Size(size) {}
|
||||
PD::u32 Size;
|
||||
std::vector<PD::u8> Table;
|
||||
ByteTable(ctrff::u32 size = 0) : Size(size) {}
|
||||
ctrff::u32 Size;
|
||||
std::vector<ctrff::u8> Table;
|
||||
};
|
||||
|
||||
struct TrackInfo {
|
||||
TrackInfo() : Volume(0), Pan(0), Padding(0) {}
|
||||
PD::u8 Volume;
|
||||
PD::u8 Pan;
|
||||
PD::u16 Padding;
|
||||
ctrff::u8 Volume;
|
||||
ctrff::u8 Pan;
|
||||
ctrff::u16 Padding;
|
||||
Reference ChennelIndexTabRef;
|
||||
ByteTable ChannelIndexTab;
|
||||
};
|
||||
@@ -184,13 +190,13 @@ class CTRFF_API BCSTM {
|
||||
FileSize(0),
|
||||
NumBlocks(0),
|
||||
Reserved(0) {}
|
||||
PD::u32 Magic; /** CSTM */
|
||||
PD::u16 Endianness = Little; /** Default */
|
||||
PD::u16 HeaderSize; /** Header Size probably */
|
||||
PD::u32 Version; /** Format Version? */
|
||||
PD::u32 FileSize; /** File Size */
|
||||
PD::u16 NumBlocks; /** Number of blocks */
|
||||
PD::u16 Reserved; /** Reserved */
|
||||
ctrff::u32 Magic; /** CSTM */
|
||||
ctrff::u16 Endianness = Little; /** Default */
|
||||
ctrff::u16 HeaderSize; /** Header Size probably */
|
||||
ctrff::u32 Version; /** Format Version? */
|
||||
ctrff::u32 FileSize; /** File Size */
|
||||
ctrff::u16 NumBlocks; /** Number of blocks */
|
||||
ctrff::u16 Reserved; /** Reserved */
|
||||
};
|
||||
|
||||
Header pHeader;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <ctrff/binutil.hpp>
|
||||
#include <ctrff/pd_p_api.hpp>
|
||||
#include <pd.hpp>
|
||||
#include <ctrff/types.hpp>
|
||||
#include <palladium>
|
||||
|
||||
namespace ctrff {
|
||||
class CTRFF_API BCWAV {
|
||||
@@ -13,15 +13,15 @@ class CTRFF_API BCWAV {
|
||||
void LoadFile(const std::string& path);
|
||||
void CleanUp();
|
||||
void ReadGotoBeginning(bool use_loop_beg = false);
|
||||
void ReadBlock(PD::u32 block, PD::u8* ref);
|
||||
void ReadBlock(ctrff::u32 block, ctrff::u8* ref);
|
||||
|
||||
/** Internal Data (can be made private with private: but public by default) */
|
||||
enum Endianness : PD::u16 {
|
||||
enum Endianness : ctrff::u16 {
|
||||
Big = 0xfffe, ///< Big Endian
|
||||
Little = 0xfeff, ///< Little Endian
|
||||
};
|
||||
|
||||
enum ReferenceTypes : PD::u16 {
|
||||
enum ReferenceTypes : ctrff::u16 {
|
||||
Ref_DSP_ADPCM_Info = 0x0300,
|
||||
Ref_IMA_ADPCM_Info = 0x0301,
|
||||
Ref_SampleData = 0x1f00,
|
||||
@@ -30,7 +30,7 @@ class CTRFF_API BCWAV {
|
||||
Ref_ChannelInfo = 0x7100,
|
||||
};
|
||||
|
||||
enum Encoding : PD::u8 {
|
||||
enum Encoding : ctrff::u8 {
|
||||
PCM8 = 0,
|
||||
PCM16 = 1,
|
||||
/** Only supported encoding in BCSTM-Player */
|
||||
@@ -40,27 +40,27 @@ class CTRFF_API BCWAV {
|
||||
|
||||
struct Reference {
|
||||
Reference() : TypeID(0), Padding(0), Offset(0) {}
|
||||
PD::u16 TypeID;
|
||||
PD::u16 Padding;
|
||||
PD::u32 Offset; /** null -> uint32_max */
|
||||
ctrff::u16 TypeID;
|
||||
ctrff::u16 Padding;
|
||||
ctrff::u32 Offset; /** null -> uint32_max */
|
||||
};
|
||||
|
||||
struct ReferenceTable {
|
||||
ReferenceTable() : Count(0) {}
|
||||
PD::u32 Count;
|
||||
ctrff::u32 Count;
|
||||
std::vector<Reference> Refs;
|
||||
};
|
||||
|
||||
struct SizedReference {
|
||||
SizedReference() : Size(0) {}
|
||||
Reference Ref;
|
||||
PD::u32 Size;
|
||||
ctrff::u32 Size;
|
||||
};
|
||||
|
||||
struct BlockHeader {
|
||||
BlockHeader() : Magic(0), Size(0) {}
|
||||
PD::u32 Magic;
|
||||
PD::u32 Size;
|
||||
ctrff::u32 Magic;
|
||||
ctrff::u32 Size;
|
||||
};
|
||||
|
||||
struct InfoBlock {
|
||||
@@ -73,13 +73,13 @@ class CTRFF_API BCWAV {
|
||||
LoopEndFrame(0),
|
||||
Reserved(0) {}
|
||||
BlockHeader Header;
|
||||
PD::u8 Encoding;
|
||||
PD::u8 Loop;
|
||||
PD::u16 Padding;
|
||||
PD::u32 SampleRate;
|
||||
PD::u32 LoopStartFrame;
|
||||
PD::u32 LoopEndFrame;
|
||||
PD::u32 Reserved;
|
||||
ctrff::u8 Encoding;
|
||||
ctrff::u8 Loop;
|
||||
ctrff::u16 Padding;
|
||||
ctrff::u32 SampleRate;
|
||||
ctrff::u32 LoopStartFrame;
|
||||
ctrff::u32 LoopEndFrame;
|
||||
ctrff::u32 Reserved;
|
||||
ReferenceTable ChannelInfoTab;
|
||||
std::vector<Reference> ChannelInfoRefs; /** The refs of the refs ?? */
|
||||
};
|
||||
@@ -91,12 +91,12 @@ class CTRFF_API BCWAV {
|
||||
}
|
||||
}
|
||||
BlockHeader Header;
|
||||
PD::u32 Padding[3];
|
||||
std::vector<PD::u8> Data;
|
||||
ctrff::u32 Padding[3];
|
||||
std::vector<ctrff::u8> Data;
|
||||
};
|
||||
|
||||
struct DSP_ADPCM_Param {
|
||||
PD::u16 Coefficients[0x10];
|
||||
ctrff::u16 Coefficients[0x10];
|
||||
};
|
||||
struct DSP_ADPCM_Context {
|
||||
DSP_ADPCM_Context()
|
||||
@@ -104,10 +104,10 @@ class CTRFF_API BCWAV {
|
||||
Reserved(0),
|
||||
PreviousSample(0),
|
||||
SecondPreviousSample(0) {}
|
||||
PD::u8 PredictorScale;
|
||||
PD::u8 Reserved;
|
||||
PD::u16 PreviousSample;
|
||||
PD::u16 SecondPreviousSample;
|
||||
ctrff::u8 PredictorScale;
|
||||
ctrff::u8 Reserved;
|
||||
ctrff::u16 PreviousSample;
|
||||
ctrff::u16 SecondPreviousSample;
|
||||
};
|
||||
|
||||
struct DSP_ADPCM_Info {
|
||||
@@ -115,7 +115,7 @@ class CTRFF_API BCWAV {
|
||||
DSP_ADPCM_Param Param;
|
||||
DSP_ADPCM_Context Context;
|
||||
DSP_ADPCM_Context LoopContext;
|
||||
PD::u16 Padding;
|
||||
ctrff::u16 Padding;
|
||||
};
|
||||
|
||||
struct Header {
|
||||
@@ -127,13 +127,13 @@ class CTRFF_API BCWAV {
|
||||
FileSize(0),
|
||||
NumBlocks(0),
|
||||
Reserved(0) {}
|
||||
PD::u32 Magic; /** CWAV */
|
||||
PD::u16 Endianness = Little; /** Default */
|
||||
PD::u16 HeaderSize; /** Header Size probably */
|
||||
PD::u32 Version; /** Format Version? */
|
||||
PD::u32 FileSize; /** File Size */
|
||||
PD::u16 NumBlocks; /** Number of blocks */
|
||||
PD::u16 Reserved; /** Reserved */
|
||||
ctrff::u32 Magic; /** CWAV */
|
||||
ctrff::u16 Endianness = Little; /** Default */
|
||||
ctrff::u16 HeaderSize; /** Header Size probably */
|
||||
ctrff::u32 Version; /** Format Version? */
|
||||
ctrff::u32 FileSize; /** File Size */
|
||||
ctrff::u16 NumBlocks; /** Number of blocks */
|
||||
ctrff::u16 Reserved; /** Reserved */
|
||||
};
|
||||
|
||||
Header pHeader;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <ctrff/pd_p_api.hpp>
|
||||
#include <pd.hpp>
|
||||
#include <ctrff/types.hpp>
|
||||
#include <palladium>
|
||||
|
||||
namespace ctrff {
|
||||
class BinFile {
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <ctrff/pd_p_api.hpp>
|
||||
#include <pd.hpp>
|
||||
#include <ctrff/types.hpp>
|
||||
#include <palladium>
|
||||
|
||||
namespace ctrff {
|
||||
CTRFF_API void String2U16(PD::u16 *res, const std::string &src, size_t max);
|
||||
CTRFF_API std::string U16toU8(PD::u16 *in, size_t max);
|
||||
CTRFF_API void RGB565toRGBA(std::vector<PD::u8> &img, PD::u16 *icon,
|
||||
CTRFF_API void String2U16(ctrff::u16 *res, const std::string &src, size_t max);
|
||||
CTRFF_API std::string U16toU8(ctrff::u16 *in, size_t max);
|
||||
CTRFF_API void RGB565toRGBA(std::vector<ctrff::u8> &img, ctrff::u16 *icon,
|
||||
const int &w, const int &h);
|
||||
// Image can only be rgba8888
|
||||
CTRFF_API void RGBA2RGB565(PD::u16 *out, const std::vector<PD::u8> &img,
|
||||
CTRFF_API void RGBA2RGB565(ctrff::u16 *out, const std::vector<ctrff::u8> &img,
|
||||
const int &w, const int &h);
|
||||
CTRFF_API std::vector<PD::u8> DownscaleImage(const std::vector<PD::u8> &img,
|
||||
int w, int h, int scale);
|
||||
CTRFF_API std::vector<ctrff::u8> DownscaleImage(
|
||||
const std::vector<ctrff::u8> &img, int w, int h, int scale);
|
||||
} // namespace ctrff
|
||||
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <ctrff/pd_p_api.hpp>
|
||||
#include <pd.hpp>
|
||||
#include <ctrff/types.hpp>
|
||||
#include <palladium>
|
||||
|
||||
namespace ctrff {
|
||||
namespace LZ11 {
|
||||
CTRFF_API std::vector<PD::u8> Compress(const std::vector<PD::u8>& in);
|
||||
CTRFF_API std::vector<ctrff::u8> Compress(const std::vector<ctrff::u8>& in);
|
||||
}
|
||||
} // namespace ctrff
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
#include <ctrff/binutil.hpp>
|
||||
#include <ctrff/helper.hpp>
|
||||
#include <ctrff/pd_p_api.hpp>
|
||||
#include <pd.hpp>
|
||||
#include <ctrff/types.hpp>
|
||||
|
||||
// Basic Info
|
||||
// language_slots: 16
|
||||
@@ -16,16 +15,16 @@ namespace ctrff {
|
||||
// SMDH Size (Note that this needs to be declared here as
|
||||
// a sizeof(SMDH) will not return the expected size due to
|
||||
// use of Serializable)
|
||||
constexpr PD::u32 SMDH_Size = 0x36C0;
|
||||
constexpr ctrff::u32 SMDH_Size = 0x36C0;
|
||||
struct CTRFF_API SMDH {
|
||||
SMDH() {
|
||||
std::fill_n(Magic, PD::ArraySize(Magic), 0);
|
||||
std::fill_n(IconSmall, PD::ArraySize(IconSmall), 0);
|
||||
std::fill_n(IconLarge, PD::ArraySize(IconLarge), 0);
|
||||
std::fill_n(Magic, ctrff::ArraySize(Magic), 0);
|
||||
std::fill_n(IconSmall, ctrff::ArraySize(IconSmall), 0);
|
||||
std::fill_n(IconLarge, ctrff::ArraySize(IconLarge), 0);
|
||||
}
|
||||
~SMDH() = default;
|
||||
static SMDH Default();
|
||||
PD_SMART_CTOR(SMDH);
|
||||
PD_SHARED(SMDH);
|
||||
|
||||
enum Language {
|
||||
Language_Japanese,
|
||||
@@ -97,8 +96,8 @@ struct CTRFF_API SMDH {
|
||||
void Write(std::fstream &f) const;
|
||||
void Read(std::fstream &f);
|
||||
|
||||
void SetIcon(const std::vector<PD::u8> &buf);
|
||||
std::vector<PD::u8> GetIcon();
|
||||
void SetIcon(const std::vector<ctrff::u8> &buf);
|
||||
std::vector<ctrff::u8> GetIcon();
|
||||
void SetShortTitle(const std::string &t, Language l = Language_All);
|
||||
void SetLongTitle(const std::string &t, Language l = Language_All);
|
||||
void SetAuthor(const std::string &t, Language l = Language_All);
|
||||
@@ -108,36 +107,36 @@ struct CTRFF_API SMDH {
|
||||
|
||||
struct CTRFF_API Title {
|
||||
Title() {
|
||||
std::fill_n(ShortTitle, PD::ArraySize(ShortTitle), 0);
|
||||
std::fill_n(LongTitle, PD::ArraySize(LongTitle), 0);
|
||||
std::fill_n(Author, PD::ArraySize(Author), 0);
|
||||
std::fill_n(ShortTitle, ctrff::ArraySize(ShortTitle), 0);
|
||||
std::fill_n(LongTitle, ctrff::ArraySize(LongTitle), 0);
|
||||
std::fill_n(Author, ctrff::ArraySize(Author), 0);
|
||||
};
|
||||
|
||||
PD::u16 ShortTitle[0x40];
|
||||
PD::u16 LongTitle[0x80];
|
||||
PD::u16 Author[0x40];
|
||||
ctrff::u16 ShortTitle[0x40];
|
||||
ctrff::u16 LongTitle[0x80];
|
||||
ctrff::u16 Author[0x40];
|
||||
};
|
||||
|
||||
struct CTRFF_API Settings {
|
||||
Settings() { std::fill_n(Ratings, PD::ArraySize(Ratings), 0); };
|
||||
PD::u8 Ratings[16];
|
||||
PD::u32 RegionLock = 0;
|
||||
PD::u32 MatchmakerID = 0;
|
||||
PD::u64 MatchmakerBitID = 0;
|
||||
PD::u32 Flags = 0;
|
||||
PD::u16 EulaVersion = 0;
|
||||
PD::u16 Reserved = 0;
|
||||
PD::u32 OptimalBannerFrame = 0;
|
||||
PD::u32 StreetpassID = 0;
|
||||
Settings() { std::fill_n(Ratings, ctrff::ArraySize(Ratings), 0); };
|
||||
ctrff::u8 Ratings[16];
|
||||
ctrff::u32 RegionLock = 0;
|
||||
ctrff::u32 MatchmakerID = 0;
|
||||
ctrff::u64 MatchmakerBitID = 0;
|
||||
ctrff::u32 Flags = 0;
|
||||
ctrff::u16 EulaVersion = 0;
|
||||
ctrff::u16 Reserved = 0;
|
||||
ctrff::u32 OptimalBannerFrame = 0;
|
||||
ctrff::u32 StreetpassID = 0;
|
||||
};
|
||||
|
||||
char Magic[4];
|
||||
PD::u16 Version = 0;
|
||||
PD::u16 Reserved = 0;
|
||||
ctrff::u16 Version = 0;
|
||||
ctrff::u16 Reserved = 0;
|
||||
Title Titles[16];
|
||||
Settings Settings;
|
||||
PD::u64 Reserved1 = 0;
|
||||
PD::u16 IconSmall[0x240]; // 24x24
|
||||
PD::u16 IconLarge[0x900]; // 48x48
|
||||
ctrff::u64 Reserved1 = 0;
|
||||
ctrff::u16 IconSmall[0x240]; // 24x24
|
||||
ctrff::u16 IconLarge[0x900]; // 48x48
|
||||
};
|
||||
} // namespace ctrff
|
||||
@@ -47,4 +47,27 @@ SOFTWARE.
|
||||
#define CTRFF_API
|
||||
#else
|
||||
#define CTRFF_API
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
namespace ctrff {
|
||||
using u8 = unsigned char;
|
||||
using u16 = unsigned short;
|
||||
using u32 = unsigned int;
|
||||
using u64 = unsigned long long;
|
||||
|
||||
/**
|
||||
* Function to get Arraysize for any type using modern c++ to
|
||||
* get the size at compiletime instead of runtime
|
||||
* @note this function only works for Arrays declared as
|
||||
* type arr[size] and not for pointer references.
|
||||
* This function will precalculate the size at compile time
|
||||
* while keeping the code clean to not hardcode arraysizes
|
||||
* into functions like std::fill_n
|
||||
*/
|
||||
template <typename T, size_t N>
|
||||
constexpr size_t ArraySize(T (&)[N]) noexcept {
|
||||
return N;
|
||||
}
|
||||
} // namespace ctrff
|
||||
1
vendor/palladium
vendored
1
vendor/palladium
vendored
Submodule vendor/palladium deleted from a0960bd717
Reference in New Issue
Block a user