Skip to content

Commit

Permalink
move resources out of LUS namespace (#757)
Browse files Browse the repository at this point in the history
  • Loading branch information
briaguya-ai authored Dec 16, 2024
1 parent 109c8cb commit 8b5554d
Show file tree
Hide file tree
Showing 31 changed files with 95 additions and 99 deletions.
28 changes: 14 additions & 14 deletions src/graphic/Fast3D/gfx_pc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -889,15 +889,15 @@ static void import_texture_raw(int tile, bool importReplacement) {

uint16_t width = metadata->width;
uint16_t height = metadata->height;
LUS::TextureType type = metadata->type;
std::shared_ptr<LUS::Texture> resource = metadata->resource;
Fast::TextureType type = metadata->type;
std::shared_ptr<Fast::Texture> resource = metadata->resource;

// if texture type is CI4 or CI8 we need to apply tlut to it
switch (type) {
case LUS::TextureType::Palette4bpp:
case Fast::TextureType::Palette4bpp:
import_texture_ci4(tile, importReplacement);
return;
case LUS::TextureType::Palette8bpp:
case Fast::TextureType::Palette8bpp:
import_texture_ci8(tile, importReplacement);
return;
default:
Expand Down Expand Up @@ -2555,7 +2555,7 @@ static void gfx_s2dex_bg_copy(F3DuObjBg* bg) {
RawTexMetadata rawTexMetadata = {};

if ((bool)gfx_check_image_signature((char*)data)) {
std::shared_ptr<LUS::Texture> tex = std::static_pointer_cast<LUS::Texture>(
std::shared_ptr<Fast::Texture> tex = std::static_pointer_cast<Fast::Texture>(
Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess((char*)data));
texFlags = tex->Flags;
rawTexMetadata.width = tex->Width;
Expand Down Expand Up @@ -2594,7 +2594,7 @@ static void gfx_s2dex_bg_1cyc(F3DuObjBg* bg) {
RawTexMetadata rawTexMetadata = {};

if ((bool)gfx_check_image_signature((char*)data)) {
std::shared_ptr<LUS::Texture> tex = std::static_pointer_cast<LUS::Texture>(
std::shared_ptr<Fast::Texture> tex = std::static_pointer_cast<Fast::Texture>(
Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess((char*)data));
texFlags = tex->Flags;
rawTexMetadata.width = tex->Width;
Expand Down Expand Up @@ -2918,7 +2918,7 @@ bool gfx_movemem_handler_otr(F3DGfx** cmd0) {
if (ucode_handler_index == ucode_f3dex2) {
gfx_sp_movemem_f3dex2(index, offset, ResourceGetDataByCrc(hash));
} else {
auto light = (LUS::LightEntry*)ResourceGetDataByCrc(hash);
auto light = (Fast::LightEntry*)ResourceGetDataByCrc(hash);
uintptr_t data = (uintptr_t)&light->Ambient;
gfx_sp_movemem_f3d(index, offset, (void*)(data + (hasOffset == 1 ? 0x8 : 0)));
}
Expand Down Expand Up @@ -3297,7 +3297,7 @@ bool gfx_set_timg_handler_rdp(F3DGfx** cmd0) {

if ((i & 1) != 1) {
if (gfx_check_image_signature(imgData) == 1) {
std::shared_ptr<LUS::Texture> tex = std::static_pointer_cast<LUS::Texture>(
std::shared_ptr<Fast::Texture> tex = std::static_pointer_cast<Fast::Texture>(
Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(imgData));

if (tex == nullptr) {
Expand Down Expand Up @@ -3335,7 +3335,7 @@ bool gfx_set_timg_otr_hash_handler_custom(F3DGfx** cmd0) {
return false;
}

std::shared_ptr<LUS::Texture> texture = std::static_pointer_cast<LUS::Texture>(
std::shared_ptr<Fast::Texture> texture = std::static_pointer_cast<Fast::Texture>(
Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(ResourceGetNameByCrc(hash)));
if (texture != nullptr) {
texFlags = texture->Flags;
Expand Down Expand Up @@ -3398,7 +3398,7 @@ bool gfx_set_timg_otr_filepath_handler_custom(F3DGfx** cmd0) {
uint32_t texFlags = 0;
RawTexMetadata rawTexMetadata = {};

std::shared_ptr<LUS::Texture> texture = std::static_pointer_cast<LUS::Texture>(
std::shared_ptr<Fast::Texture> texture = std::static_pointer_cast<Fast::Texture>(
Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(fileName));
if (texture != nullptr) {
texFlags = texture->Flags;
Expand Down Expand Up @@ -4414,10 +4414,10 @@ void gfx_register_blended_texture(const char* name, uint8_t* mask, uint8_t* repl
}

if (gfx_check_image_signature(reinterpret_cast<char*>(replacement))) {
LUS::Texture* tex = std::static_pointer_cast<LUS::Texture>(
Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(
reinterpret_cast<char*>(replacement)))
.get();
Fast::Texture* tex = std::static_pointer_cast<Fast::Texture>(
Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(
reinterpret_cast<char*>(replacement)))
.get();

replacement = tex->ImageData;
}
Expand Down
4 changes: 2 additions & 2 deletions src/graphic/Fast3D/gfx_pc.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ struct LoadedVertex {
struct RawTexMetadata {
uint16_t width, height;
float h_byte_scale = 1, v_pixel_scale = 1;
std::shared_ptr<LUS::Texture> resource;
LUS::TextureType type;
std::shared_ptr<Fast::Texture> resource;
Fast::TextureType type;
};

#define MAX_BUFFERED 256
Expand Down
12 changes: 6 additions & 6 deletions src/public/bridge/resourcebridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void* ResourceGetDataByCrc(uint64_t crc) {
}

uint16_t ResourceGetTexWidthByName(const char* name) {
const auto res = static_pointer_cast<LUS::Texture>(ResourceLoad(name));
const auto res = static_pointer_cast<Fast::Texture>(ResourceLoad(name));

if (res != nullptr) {
return res->Width;
Expand All @@ -92,7 +92,7 @@ uint16_t ResourceGetTexWidthByName(const char* name) {
}

uint16_t ResourceGetTexWidthByCrc(uint64_t crc) {
const auto res = static_pointer_cast<LUS::Texture>(ResourceLoad(crc));
const auto res = static_pointer_cast<Fast::Texture>(ResourceLoad(crc));

if (res != nullptr) {
return res->Width;
Expand All @@ -103,7 +103,7 @@ uint16_t ResourceGetTexWidthByCrc(uint64_t crc) {
}

uint16_t ResourceGetTexHeightByName(const char* name) {
const auto res = static_pointer_cast<LUS::Texture>(ResourceLoad(name));
const auto res = static_pointer_cast<Fast::Texture>(ResourceLoad(name));

if (res != nullptr) {
return res->Height;
Expand All @@ -114,7 +114,7 @@ uint16_t ResourceGetTexHeightByName(const char* name) {
}

uint16_t ResourceGetTexHeightByCrc(uint64_t crc) {
const auto res = static_pointer_cast<LUS::Texture>(ResourceLoad(crc));
const auto res = static_pointer_cast<Fast::Texture>(ResourceLoad(crc));

if (res != nullptr) {
return res->Height;
Expand All @@ -125,7 +125,7 @@ uint16_t ResourceGetTexHeightByCrc(uint64_t crc) {
}

size_t ResourceGetTexSizeByName(const char* name) {
const auto res = static_pointer_cast<LUS::Texture>(ResourceLoad(name));
const auto res = static_pointer_cast<Fast::Texture>(ResourceLoad(name));

if (res != nullptr) {
return res->ImageDataSize;
Expand All @@ -136,7 +136,7 @@ size_t ResourceGetTexSizeByName(const char* name) {
}

size_t ResourceGetTexSizeByCrc(uint64_t crc) {
const auto res = static_pointer_cast<LUS::Texture>(ResourceLoad(crc));
const auto res = static_pointer_cast<Fast::Texture>(ResourceLoad(crc));

if (res != nullptr) {
return res->ImageDataSize;
Expand Down
14 changes: 5 additions & 9 deletions src/resource/ResourceType.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,22 @@
namespace Ship {

enum class ResourceType {
// Not set
None = 0x00000000,

Blob = 0x4F424C42, // OBLB
Json = 0x4A534F4E, // JSON
};
} // namespace Ship

namespace LUS {
namespace Fast {

enum class ResourceType {
// Not set
None = 0x00000000,

// Common
Archive = 0x4F415243, // OARC (UNUSED)
DisplayList = 0x4F444C54, // ODLT
Vertex = 0x4F565458, // OVTX
Light = 0x46669697, // LGTS
Matrix = 0x4F4D5458, // OMTX
Blob = 0x4F424C42, // OBLB
Texture = 0x4F544558, // OTEX
Light = 0x46669697, // LGTS
Vertex = 0x4F565458, // OVTX
};
} // namespace LUS
} // namespace Fast
4 changes: 2 additions & 2 deletions src/resource/factory/BlobFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "resource/type/Blob.h"
#include "spdlog/spdlog.h"

namespace LUS {
namespace Ship {
std::shared_ptr<Ship::IResource> ResourceFactoryBinaryBlobV0::ReadResource(std::shared_ptr<Ship::File> file) {
if (!FileHasValidFormatAndReader(file)) {
return nullptr;
Expand All @@ -21,4 +21,4 @@ std::shared_ptr<Ship::IResource> ResourceFactoryBinaryBlobV0::ReadResource(std::

return blob;
}
} // namespace LUS
} // namespace Ship
4 changes: 2 additions & 2 deletions src/resource/factory/BlobFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include "resource/Resource.h"
#include "resource/ResourceFactoryBinary.h"

namespace LUS {
namespace Ship {
class ResourceFactoryBinaryBlobV0 : public Ship::ResourceFactoryBinary {
public:
std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
};
}; // namespace LUS
}; // namespace Ship
4 changes: 2 additions & 2 deletions src/resource/factory/DisplayListFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "libultraship/libultra/gbi.h"
#include "graphic/Fast3D/lus_gbi.h"

namespace LUS {
namespace Fast {
std::unordered_map<std::string, uint32_t> renderModes = {
{ "G_RM_ZB_OPA_SURF", G_RM_ZB_OPA_SURF },
{ "G_RM_AA_ZB_OPA_SURF", G_RM_AA_ZB_OPA_SURF },
Expand Down Expand Up @@ -1127,4 +1127,4 @@ std::shared_ptr<Ship::IResource> ResourceFactoryXMLDisplayListV0::ReadResource(s

return dl;
}
} // namespace LUS
} // namespace Fast
4 changes: 2 additions & 2 deletions src/resource/factory/DisplayListFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "resource/ResourceFactoryBinary.h"
#include "resource/ResourceFactoryXML.h"

namespace LUS {
namespace Fast {
class ResourceFactoryDisplayList {
protected:
uint32_t GetCombineLERPValue(const char* valStr);
Expand All @@ -19,4 +19,4 @@ class ResourceFactoryXMLDisplayListV0 : public ResourceFactoryDisplayList, publi
public:
std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
};
} // namespace LUS
} // namespace Fast
2 changes: 1 addition & 1 deletion src/resource/factory/LightFactory.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "resource/factory/LightFactory.h"
#include "resource/type/Light.h"

std::shared_ptr<Ship::IResource> LUS::ResourceFactoryBinaryLightV0::ReadResource(std::shared_ptr<Ship::File> file) {
std::shared_ptr<Ship::IResource> Fast::ResourceFactoryBinaryLightV0::ReadResource(std::shared_ptr<Ship::File> file) {
if (!FileHasValidFormatAndReader(file)) {
return nullptr;
}
Expand Down
4 changes: 2 additions & 2 deletions src/resource/factory/LightFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include "resource/Resource.h"
#include "resource/ResourceFactoryBinary.h"

namespace LUS {
namespace Fast {
class ResourceFactoryBinaryLightV0 : public Ship::ResourceFactoryBinary {
public:
std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
};
} // namespace LUS
} // namespace Fast
4 changes: 2 additions & 2 deletions src/resource/factory/MatrixFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "resource/type/Matrix.h"
#include "spdlog/spdlog.h"

namespace LUS {
namespace Fast {
std::shared_ptr<Ship::IResource> ResourceFactoryBinaryMatrixV0::ReadResource(std::shared_ptr<Ship::File> file) {
if (!FileHasValidFormatAndReader(file)) {
return nullptr;
Expand All @@ -23,4 +23,4 @@ std::shared_ptr<Ship::IResource> ResourceFactoryBinaryMatrixV0::ReadResource(std

return matrix;
}
} // namespace LUS
} // namespace Fast
4 changes: 2 additions & 2 deletions src/resource/factory/MatrixFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include "resource/Resource.h"
#include "resource/ResourceFactoryBinary.h"

namespace LUS {
namespace Fast {
class ResourceFactoryBinaryMatrixV0 : public Ship::ResourceFactoryBinary {
public:
std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
};
} // namespace LUS
} // namespace Fast
4 changes: 2 additions & 2 deletions src/resource/factory/TextureFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "resource/type/Texture.h"
#include "spdlog/spdlog.h"

namespace LUS {
namespace Fast {

std::shared_ptr<Ship::IResource> ResourceFactoryBinaryTextureV0::ReadResource(std::shared_ptr<Ship::File> file) {
if (!FileHasValidFormatAndReader(file)) {
Expand Down Expand Up @@ -44,4 +44,4 @@ std::shared_ptr<Ship::IResource> ResourceFactoryBinaryTextureV1::ReadResource(st

return texture;
}
} // namespace LUS
} // namespace Fast
4 changes: 2 additions & 2 deletions src/resource/factory/TextureFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "resource/Resource.h"
#include "resource/ResourceFactoryBinary.h"

namespace LUS {
namespace Fast {
class ResourceFactoryBinaryTextureV0 : public Ship::ResourceFactoryBinary {
public:
std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
Expand All @@ -13,4 +13,4 @@ class ResourceFactoryBinaryTextureV1 : public Ship::ResourceFactoryBinary {
public:
std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
};
} // namespace LUS
} // namespace Fast
4 changes: 2 additions & 2 deletions src/resource/factory/VertexFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "spdlog/spdlog.h"
#include "libultraship/libultra/gbi.h"

namespace LUS {
namespace Fast {
std::shared_ptr<Ship::IResource> ResourceFactoryBinaryVertexV0::ReadResource(std::shared_ptr<Ship::File> file) {
if (!FileHasValidFormatAndReader(file)) {
return nullptr;
Expand Down Expand Up @@ -67,4 +67,4 @@ std::shared_ptr<Ship::IResource> ResourceFactoryXMLVertexV0::ReadResource(std::s

return vertex;
}
} // namespace LUS
} // namespace Fast
4 changes: 2 additions & 2 deletions src/resource/factory/VertexFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "resource/ResourceFactoryBinary.h"
#include "resource/ResourceFactoryXML.h"

namespace LUS {
namespace Fast {
class ResourceFactoryBinaryVertexV0 : public Ship::ResourceFactoryBinary {
public:
std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
Expand All @@ -14,4 +14,4 @@ class ResourceFactoryXMLVertexV0 : public Ship::ResourceFactoryXML {
public:
std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
};
} // namespace LUS
} // namespace Fast
4 changes: 2 additions & 2 deletions src/resource/type/Blob.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "Blob.h"

namespace LUS {
namespace Ship {
Blob::Blob() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {
}

Expand All @@ -11,4 +11,4 @@ void* Blob::GetPointer() {
size_t Blob::GetPointerSize() {
return Data.size() * sizeof(uint8_t);
}
} // namespace LUS
} // namespace Ship
4 changes: 2 additions & 2 deletions src/resource/type/Blob.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "resource/Resource.h"

namespace LUS {
namespace Ship {
class Blob : public Ship::Resource<void> {
public:
using Resource::Resource;
Expand All @@ -14,4 +14,4 @@ class Blob : public Ship::Resource<void> {

std::vector<uint8_t> Data;
};
}; // namespace LUS
}; // namespace Ship
4 changes: 2 additions & 2 deletions src/resource/type/DisplayList.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "resource/type/DisplayList.h"
#include <memory>

namespace LUS {
namespace Fast {
DisplayList::DisplayList() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {
}

Expand All @@ -18,4 +18,4 @@ Gfx* DisplayList::GetPointer() {
size_t DisplayList::GetPointerSize() {
return Instructions.size() * sizeof(Gfx);
}
} // namespace LUS
} // namespace Fast
Loading

0 comments on commit 8b5554d

Please sign in to comment.