2018-10-06 20:42:33 -07:00
|
|
|
#pragma once
|
2016-03-18 17:07:31 -07:00
|
|
|
|
2022-03-03 23:47:21 -08:00
|
|
|
#include "RetroTypes.hpp"
|
2022-05-13 16:40:19 -07:00
|
|
|
#include "GX.hpp"
|
2022-03-03 23:47:21 -08:00
|
|
|
|
2016-03-18 17:07:31 -07:00
|
|
|
#include <memory>
|
|
|
|
|
2021-04-10 01:42:06 -07:00
|
|
|
namespace metaforce {
|
2022-02-26 18:18:58 -08:00
|
|
|
class CInputStream;
|
2016-03-18 17:07:31 -07:00
|
|
|
|
2022-05-13 16:40:19 -07:00
|
|
|
enum class EPaletteFormat : std::underlying_type_t<GXTlutFmt> {
|
|
|
|
IA8 = GX_TL_IA8,
|
|
|
|
RGB565 = GX_TL_RGB565,
|
|
|
|
RGB5A3 = GX_TL_RGB5A3,
|
2016-03-18 17:07:31 -07:00
|
|
|
};
|
|
|
|
|
2018-12-07 21:30:43 -08:00
|
|
|
class CGraphicsPalette {
|
2022-02-26 18:18:58 -08:00
|
|
|
static u32 sCurrentFrameCount;
|
2018-12-07 21:30:43 -08:00
|
|
|
friend class CTextRenderBuffer;
|
|
|
|
EPaletteFormat x0_fmt;
|
2022-02-26 18:18:58 -08:00
|
|
|
u32 x4_frameLoaded{};
|
|
|
|
u32 x8_entryCount;
|
2022-05-19 00:57:30 -07:00
|
|
|
std::unique_ptr<u16[]> xc_entries;
|
2022-05-13 16:40:19 -07:00
|
|
|
GXTlutObj x10_tlutObj;
|
2022-02-26 18:18:58 -08:00
|
|
|
bool x1c_locked = false;
|
2018-12-07 21:30:43 -08:00
|
|
|
|
2016-03-18 17:07:31 -07:00
|
|
|
public:
|
2022-02-26 18:18:58 -08:00
|
|
|
explicit CGraphicsPalette(EPaletteFormat fmt, int count);
|
|
|
|
explicit CGraphicsPalette(CInputStream& in);
|
2022-08-09 15:27:33 -07:00
|
|
|
~CGraphicsPalette();
|
2022-03-02 23:51:11 -08:00
|
|
|
|
2022-05-19 00:57:30 -07:00
|
|
|
u16* Lock() {
|
|
|
|
x1c_locked = true;
|
|
|
|
return xc_entries.get();
|
|
|
|
}
|
2022-05-13 16:40:19 -07:00
|
|
|
void UnLock();
|
2022-05-13 23:47:29 -07:00
|
|
|
void Load();
|
2022-03-03 23:47:21 -08:00
|
|
|
|
2022-05-19 00:57:30 -07:00
|
|
|
[[nodiscard]] const u16* GetPaletteData() const { return xc_entries.get(); }
|
2022-03-03 23:47:21 -08:00
|
|
|
|
2022-03-02 23:51:11 -08:00
|
|
|
static void SetCurrentFrameCount(u32 frameCount) { sCurrentFrameCount = frameCount; }
|
2016-03-18 17:07:31 -07:00
|
|
|
};
|
|
|
|
|
2021-04-10 01:42:06 -07:00
|
|
|
} // namespace metaforce
|