Compare commits

5 Commits
6 changed files with 10 additions and 75 deletions
+3 -3
View File
@@ -29,13 +29,13 @@ class CTRFF_API BCSTM {
}
bool IsLooping() const { return pInfoBlock.StreamInfo.Loop; }
PD::u32 GetLoopStart() const {
return pInfoBlock.StreamInfo.LoopStartFrame / GetNumBlocks();
return pInfoBlock.StreamInfo.LoopStartFrame / GetBlockSamples();
}
PD::u32 GetLoopEnd() const {
/** Get temp references for better readability */
const PD::u32& loop_end = pInfoBlock.StreamInfo.LoopEndFrame;
const PD::u32& block_samples = GetNumBlocks();
return (loop_end % block_samples ? block_samples
const PD::u32& block_samples = GetBlockSamples();
return (loop_end % block_samples ? GetNumBlocks()
: loop_end / block_samples);
}
-24
View File
@@ -1,24 +0,0 @@
#pragma once
#include <ctrff/helper.hpp>
#include <ctrff/pd_p_api.hpp>
#include <ctrff/smdh.hpp>
#include <pd.hpp>
namespace ctrff {
class Cia : public BinFile {
public:
Cia() {}
~Cia() {}
PD::u32 HeaderSize;
PD::u16 Type;
PD::u16 Version;
PD::u32 CertChainSize;
PD::u32 TikSize;
PD::u32 TmdFileSize;
PD::u32 MetaSize;
PD::u64 ContentSize;
PD::u8 ContentIndex[0x2000];
};
} // namespace ctrff
-44
View File
@@ -1,44 +0,0 @@
#pragma once
#include <ctrff/helper.hpp>
#include <ctrff/pd_p_api.hpp>
#include <ctrff/smdh.hpp>
#include <pd.hpp>
namespace ctrff {
class NCCH : public BinFile {
public:
NCCH() {}
~NCCH() {}
PD::u8 Sig[0x100];
PD::u32 Magic;
PD::u32 ContentLen; // 1 (Media Unit) = 0x200 bytes
PD::u64 PartitionID;
PD::u16 MarkerCode;
PD::u16 Version;
PD::u32 Wtf;
PD::u64 ProgramID;
PD::u8 Reserved[0x10];
PD::u8 LogoHash[0x20]; // Firm 5.0.0-11+
PD::u8 ProdCode[0x10];
PD::u8 ExHeaderHash[0x20];
PD::u32 ExHeaderLen;
PD::u32 Reserved1;
PD::u64 Flags;
PD::u32 PlainRegionOff; // In Media Units
PD::u32 PlainRegionSize;
PD::u32 LogoRegionOff;
PD::u32 LogoRegionSize;
PD::u32 ExeFsOff;
PD::u32 ExeFsSize;
PD::u32 ExeFsHashRegionSize;
PD::u32 Reserved2;
PD::u32 RomFsOff;
PD::u32 RomFsSize;
PD::u32 RomFsHashRegionSize;
PD::u32 Reserved;
PD::u8 ExeFsSuperBlockHash[0x20];
PD::u8 RomFsSuperBlockHash[0x20];
};
} // namespace ctrff
+4 -1
View File
@@ -162,9 +162,12 @@ CTRFF_API void BCSTM::ReadGotoBeginning(bool use_loop_beg) {
}
CTRFF_API void BCSTM::ReadBlock(PD::u32 block, PD::u8* ref) {
if (!ref) {
throw std::runtime_error("BCSTM: pointer ref is nullptr!");
}
if (pFile.tellg() > pHeader.FileSize || block >= GetNumBlocks()) {
throw std::runtime_error(std::format(
"BCSTM: Decode block Out of range! ({} > {})", block, GetNumBlocks()));
"BCSTM: Decode block out of range! ({}/{})", block, GetNumBlocks()));
}
pFile.read(
reinterpret_cast<char*>(ref),