Compare commits
5
Commits
indev
...
f6b81d701a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6b81d701a
|
||
|
|
7197ecff02
|
||
|
|
43c735b0b2
|
||
|
|
f1d4884d99
|
||
|
|
8f175aebe1 |
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -162,8 +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("BCSTM: Decode block Out of range!");
|
||||
throw std::runtime_error(std::format(
|
||||
"BCSTM: Decode block out of range! ({}/{})", block, GetNumBlocks()));
|
||||
}
|
||||
pFile.read(
|
||||
reinterpret_cast<char*>(ref),
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ void BinUtil::Read(T& v) {
|
||||
// Read data into buffer
|
||||
m_file.read(reinterpret_cast<char*>(buf.data()), sizeof(T));
|
||||
// Loop or in be reverse loop and chift the values
|
||||
for (int i = 0; i < sizeof(T); i++) {
|
||||
for (size_t i = 0; i < sizeof(T); i++) {
|
||||
v |= static_cast<T>(buf[m_big ? sizeof(T) - 1 - i : i]) << (8 * i);
|
||||
}
|
||||
}
|
||||
@@ -38,4 +38,4 @@ void BinUtil::Write(const T& v) {
|
||||
// Write buffer into file
|
||||
m_file.write(reinterpret_cast<const char*>(buf.data()), sizeof(T));
|
||||
}
|
||||
} // namespace ctrff
|
||||
} // namespace ctrff
|
||||
|
||||
+6
-6
@@ -31,8 +31,8 @@ CTRFF_API void ctrff::RGB565toRGBA(std::vector<PD::u8> &img, PD::u16 *icon,
|
||||
img.resize(48 * 48 * 4);
|
||||
img.clear();
|
||||
}
|
||||
for (PD::u32 y = 0; y < h; y++) {
|
||||
for (PD::u32 x = 0; x < w; x++) {
|
||||
for (int y = 0; y < h; y++) {
|
||||
for (int x = 0; x < w; x++) {
|
||||
auto idx = TileIndex(x, y, w);
|
||||
PD::u32 pos = (y * w + x) * 4;
|
||||
MakePixelRGBA(img[pos + 0], img[pos + 1], img[pos + 2], img[pos + 3],
|
||||
@@ -45,8 +45,8 @@ CTRFF_API void ctrff::RGBA2RGB565(PD::u16 *out, const std::vector<PD::u8> &img,
|
||||
const int &w, const int &h) {
|
||||
if (img.size() != size_t(w * h * 4)) return;
|
||||
std::vector<PD::u8> px8 = img;
|
||||
for (PD::u32 y = 0; y < h; y++) {
|
||||
for (PD::u32 x = 0; x < w; x++) {
|
||||
for (int y = 0; y < h; y++) {
|
||||
for (int x = 0; x < w; x++) {
|
||||
auto idx = TileIndex(x, y, w);
|
||||
PD::u32 pos = (y * w + x) * 4;
|
||||
out[idx] = MakePixel565(img[pos], img[pos + 1], img[pos + 2]);
|
||||
@@ -148,7 +148,7 @@ CTRFF_API std::string ctrff::U16toU8(PD::u16 *in, size_t max) {
|
||||
result.push_back(static_cast<char>(0x80 | (c & 0x3F)));
|
||||
} else if (c < 0x10000) {
|
||||
result.push_back(static_cast<char>(0xE0 | (c >> 12)));
|
||||
result.push_back(static_cast<char>(0x80 | ((c >> 6) & 0x3F)));
|
||||
result.push_back(static_cast<char>(0x80 | ((c >> 6) & 0x3F)));
|
||||
result.push_back(static_cast<char>(0x80 | (c & 0x3F)));
|
||||
} else {
|
||||
continue;
|
||||
@@ -156,4 +156,4 @@ CTRFF_API std::string ctrff::U16toU8(PD::u16 *in, size_t max) {
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
Submodule vendor/palladium updated: ea76a304d4...a0960bd717
Reference in New Issue
Block a user