2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2016-02-06 00:34:40 +00:00
|
|
|
|
2019-09-28 02:53:03 +00:00
|
|
|
#include "Runtime/CFactoryMgr.hpp"
|
2022-02-27 02:18:58 +00:00
|
|
|
#include "Runtime/Graphics/CGraphics.hpp"
|
|
|
|
#include "Runtime/Graphics/CGraphicsPalette.hpp"
|
2022-03-04 07:47:21 +00:00
|
|
|
#include "Runtime/Graphics/GX.hpp"
|
|
|
|
#include "Runtime/IObj.hpp"
|
|
|
|
#include "Runtime/Streams/CInputStream.hpp"
|
2019-09-28 02:53:03 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2018-12-08 05:30:43 +00:00
|
|
|
class CTexture {
|
2022-02-27 02:18:58 +00:00
|
|
|
class CDumpedBitmapDataReloader {
|
|
|
|
int x0_;
|
|
|
|
u32 x4_;
|
|
|
|
int x8_;
|
|
|
|
u32 xc_;
|
|
|
|
bool x10_;
|
|
|
|
int x14_;
|
|
|
|
void* x18_;
|
|
|
|
};
|
|
|
|
|
2017-01-29 03:58:16 +00:00
|
|
|
public:
|
2022-03-04 07:47:21 +00:00
|
|
|
enum class EAutoMipmap {
|
|
|
|
Zero,
|
|
|
|
One,
|
2022-02-27 02:18:58 +00:00
|
|
|
};
|
|
|
|
|
2022-03-04 07:47:21 +00:00
|
|
|
enum class EBlackKey { Zero, One };
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
enum class EFontType {
|
|
|
|
None = -1,
|
|
|
|
OneLayer = 0, /* Fill bit0 */
|
|
|
|
OneLayerOutline = 1, /* Fill bit0, Outline bit1 */
|
|
|
|
FourLayers = 2,
|
|
|
|
TwoLayersOutlines = 3, /* Fill bit0/2, Outline bit1/3 */
|
|
|
|
TwoLayers = 4, /* Fill bit0/1 and copied to bit2/3 */
|
|
|
|
TwoLayersOutlines2 = 8 /* Fill bit2/3, Outline bit0/1 */
|
|
|
|
};
|
2017-01-29 03:58:16 +00:00
|
|
|
|
|
|
|
private:
|
2022-03-04 07:47:21 +00:00
|
|
|
static bool sMangleMips;
|
2022-02-27 20:12:02 +00:00
|
|
|
static u32 sCurrentFrameCount;
|
2022-03-04 07:47:21 +00:00
|
|
|
static u32 sTotalAllocatedMemory;
|
|
|
|
|
|
|
|
ETexelFormat x0_fmt = ETexelFormat::Invalid;
|
|
|
|
u16 x4_w = 0;
|
|
|
|
u16 x6_h = 0;
|
|
|
|
u8 x8_mips = 0;
|
|
|
|
u8 x9_bitsPerPixel = 0;
|
|
|
|
bool xa_24_locked : 1 = false;
|
|
|
|
bool xa_25_canLoadPalette : 1 = false;
|
|
|
|
bool xa_26_isPowerOfTwo : 1 = false;
|
|
|
|
bool xa_27_noSwap : 1 = true;
|
|
|
|
bool xa_28_counted : 1 = false;
|
|
|
|
bool xa_29_canLoadObj : 1 = false;
|
|
|
|
u32 xc_memoryAllocated = 0;
|
2022-02-27 02:18:58 +00:00
|
|
|
std::unique_ptr<CGraphicsPalette> x10_graphicsPalette;
|
|
|
|
std::unique_ptr<CDumpedBitmapDataReloader> x14_bitmapReloader;
|
2022-03-04 07:47:21 +00:00
|
|
|
u32 x18_gxFormat = GX::TF_RGB565;
|
|
|
|
u32 x1c_gxCIFormat = GX::TF_C8;
|
|
|
|
aurora::gfx::TextureHandle x20_texObj; // was GXTexObj
|
2022-02-27 20:12:02 +00:00
|
|
|
EClampMode x40_clampMode = EClampMode::Repeat;
|
2022-03-04 07:47:21 +00:00
|
|
|
std::unique_ptr<u8[]> x44_aramToken_x4_buff; // was CARAMToken
|
2022-02-27 20:12:02 +00:00
|
|
|
u32 x64_frameAllocated{};
|
2022-02-27 02:18:58 +00:00
|
|
|
|
2022-03-04 07:47:21 +00:00
|
|
|
// Metaforce additions
|
|
|
|
std::string m_label;
|
2016-02-16 05:50:41 +00:00
|
|
|
|
2022-03-04 07:47:21 +00:00
|
|
|
void InitBitmapBuffers(ETexelFormat fmt, u16 width, u16 height, s32 mips);
|
|
|
|
void InitTextureObjs(bool write); // write param is added
|
|
|
|
void CountMemory();
|
|
|
|
void UncountMemory();
|
|
|
|
void MangleMipmap(u32 mip);
|
|
|
|
static u32 TexelFormatBitsPerPixel(ETexelFormat fmt);
|
2022-02-27 02:18:58 +00:00
|
|
|
|
2016-02-06 00:34:40 +00:00
|
|
|
public:
|
2022-03-04 07:47:21 +00:00
|
|
|
// Label parameters are new for Metaforce
|
|
|
|
CTexture(ETexelFormat fmt, u16 w, u16 h, s32 mips, std::string_view label);
|
|
|
|
CTexture(CInputStream& in, std::string_view label, EAutoMipmap automip = EAutoMipmap::Zero,
|
|
|
|
EBlackKey blackKey = EBlackKey::Zero);
|
|
|
|
|
|
|
|
[[nodiscard]] ETexelFormat GetTextureFormat() const { return x0_fmt; }
|
2022-02-27 20:12:02 +00:00
|
|
|
[[nodiscard]] u16 GetWidth() const { return x4_w; }
|
|
|
|
[[nodiscard]] u16 GetHeight() const { return x6_h; }
|
2022-03-04 07:47:21 +00:00
|
|
|
[[nodiscard]] u8 GetNumberOfMipMaps() const { return x8_mips; }
|
|
|
|
[[nodiscard]] u32 GetBitDepth() const { return x9_bitsPerPixel; }
|
|
|
|
[[nodiscard]] u32 GetMemoryAllocated() const { return xc_memoryAllocated; }
|
|
|
|
[[nodiscard]] const std::unique_ptr<CGraphicsPalette>& GetPalette() const { return x10_graphicsPalette; }
|
|
|
|
[[nodiscard]] bool HasPalette() const { return x10_graphicsPalette != nullptr; }
|
|
|
|
[[nodiscard]] u8* Lock();
|
|
|
|
void UnLock();
|
|
|
|
void Load(GX::TexMapID id, EClampMode clamp);
|
|
|
|
void LoadMipLevel(s32 mip, GX::TexMapID id, EClampMode clamp);
|
|
|
|
// void UnloadBitmapData(u32) const;
|
|
|
|
// void TryReloadBitmapData(CResFactory&) const;
|
|
|
|
// void LoadToMRAM() const;
|
|
|
|
// void LoadToARAM() const;
|
|
|
|
// bool IsARAMTransferInProgress() const { return false; }
|
|
|
|
void MakeSwappable();
|
2019-08-04 00:02:53 +00:00
|
|
|
|
2022-03-04 07:47:21 +00:00
|
|
|
[[nodiscard]] const u8* GetConstBitMapData(s32 mip) const;
|
|
|
|
[[nodiscard]] u8* GetBitMapData(s32 mip) const;
|
|
|
|
[[nodiscard]] bool IsCITexture() const {
|
|
|
|
return x0_fmt == ETexelFormat::C4 || x0_fmt == ETexelFormat::C8 || x0_fmt == ETexelFormat::C14X2;
|
|
|
|
}
|
2022-02-27 02:18:58 +00:00
|
|
|
|
2022-03-04 07:47:21 +00:00
|
|
|
static void InvalidateTexMap(GX::TexMapID id);
|
|
|
|
static void SetMangleMips(bool b) { sMangleMips = b; }
|
2022-03-03 07:51:11 +00:00
|
|
|
static void SetCurrentFrameCount(u32 frameCount) { sCurrentFrameCount = frameCount; }
|
2016-02-06 00:34:40 +00:00
|
|
|
};
|
|
|
|
|
2022-03-04 07:47:21 +00:00
|
|
|
CFactoryFnReturn FTextureFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
|
|
|
|
CObjectReference* selfRef);
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|