libnedit
Lightweight C++ library for Nintendo DS(i) formats
Loading...
Searching...
No Matches
fmt_NCLR.hpp
1
2#pragma once
3#include <ntr/fmt/fmt_Common.hpp>
4#include <ntr/gfx/gfx_Base.hpp>
5
6namespace ntr::fmt {
7
8 struct NCLR : public fs::FileFormat {
9
10 struct Header : public CommonMultiMagicHeader<0x4E434C52 /* "RLCN" */, 0x4E435052 /* "RPCN" */> {
11 };
12
13 struct PaletteDataBlock : public CommonBlock<0x504C5454 /* "TTLP" */ > {
14 gfx::PixelFormat pix_fmt;
15 bool has_extended_palette;
16 u8 pad[3];
17 u32 data_size;
18 u32 unk;
19 };
20
21 // TODO: is this block used at all?
22
23 struct PaletteCompressDataBlock : public CommonBlock<0x50434D50 /* "PMCP" */ > {
24 u16 palette_count;
25 u8 pad[2];
26 u32 palette_idx_table_unk;
27 };
28
29 Header header;
30 PaletteDataBlock palette;
31 u8 *data;
32
33 NCLR() : data(nullptr) {}
34 NCLR(const NCLR&) = delete;
35
36 ~NCLR() {
37 if(this->data != nullptr) {
38 delete[] this->data;
39 this->data = nullptr;
40 }
41 }
42
43 Result ValidateImpl(const std::string &path, std::shared_ptr<fs::FileHandle> file_handle, const fs::FileCompression comp) override;
44 Result ReadImpl(const std::string &path, std::shared_ptr<fs::FileHandle> file_handle, const fs::FileCompression comp) override;
45 Result WriteImpl(const std::string &path, std::shared_ptr<fs::FileHandle> file_handle, const fs::FileCompression comp) override;
46 };
47
48}
Definition fmt_Common.hpp:53
Definition fmt_Common.hpp:44
Definition fmt_NCLR.hpp:10
Definition fmt_NCLR.hpp:13
Definition fmt_NCLR.hpp:8
Definition fs_Base.hpp:45