Migrate to aurora submodule

This commit is contained in:
Luke Street 2022-07-29 16:16:55 -04:00
parent 0789f28aac
commit 1e9d96c906
156 changed files with 1795 additions and 19246 deletions

12
.gitmodules vendored
View File

@ -42,18 +42,12 @@
path = extern/zeus path = extern/zeus
url = ../zeus.git url = ../zeus.git
branch = master branch = master
[submodule "extern/imgui"]
path = extern/imgui
url = https://github.com/ocornut/imgui.git
[submodule "extern/SDL"]
path = extern/SDL
url = https://github.com/libsdl-org/SDL.git
[submodule "extern/dawn"]
path = extern/dawn
url = https://github.com/encounter/dawn-cmake.git
[submodule "extern/nativefiledialog"] [submodule "extern/nativefiledialog"]
path = extern/nativefiledialog path = extern/nativefiledialog
url = https://github.com/mlabbe/nativefiledialog.git url = https://github.com/mlabbe/nativefiledialog.git
[submodule "extern/optick"] [submodule "extern/optick"]
path = extern/optick path = extern/optick
url = https://github.com/AxioDL/optick.git url = https://github.com/AxioDL/optick.git
[submodule "extern/aurora"]
path = extern/aurora
url = https://github.com/encounter/aurora.git

View File

@ -365,7 +365,6 @@ if(NOT TARGET atdna)
endif() endif()
add_subdirectory(NESEmulator EXCLUDE_FROM_ALL) add_subdirectory(NESEmulator EXCLUDE_FROM_ALL)
add_subdirectory(aurora)
add_subdirectory(Runtime) add_subdirectory(Runtime)
add_subdirectory(gbalink EXCLUDE_FROM_ALL) add_subdirectory(gbalink EXCLUDE_FROM_ALL)

View File

@ -604,9 +604,9 @@ void CNESEmulator::ProcessUserInput(const CFinalInput& input, int) {
if (GetPasswordEntryState() != EPasswordEntryState::NotPasswordScreen) { if (GetPasswordEntryState() != EPasswordEntryState::NotPasswordScreen) {
// Don't swap A/B // Don't swap A/B
inValReads[BUTTON_A] = input.DA() || input.DSpecialKey(aurora::SpecialKey::Enter) || inValReads[BUTTON_A] = input.DA() || input.DSpecialKey(ESpecialKey::Enter) ||
input.DMouseButton(EMouseButton::Primary); input.DMouseButton(EMouseButton::Primary);
inValReads[BUTTON_B] = input.DB() || input.DSpecialKey(aurora::SpecialKey::Esc); inValReads[BUTTON_B] = input.DB() || input.DSpecialKey(ESpecialKey::Esc);
} else { } else {
// Prime controls (B jumps, A shoots) // Prime controls (B jumps, A shoots)
inValReads[BUTTON_B] = input.DA() || input.DY() || input.DMouseButton(EMouseButton::Primary); inValReads[BUTTON_B] = input.DA() || input.DY() || input.DMouseButton(EMouseButton::Primary);
@ -617,8 +617,8 @@ void CNESEmulator::ProcessUserInput(const CFinalInput& input, int) {
inValReads[BUTTON_DOWN] = input.DDPDown() || input.DLADown(); inValReads[BUTTON_DOWN] = input.DDPDown() || input.DLADown();
inValReads[BUTTON_LEFT] = input.DDPLeft() || input.DLALeft(); inValReads[BUTTON_LEFT] = input.DDPLeft() || input.DLALeft();
inValReads[BUTTON_RIGHT] = input.DDPRight() || input.DLARight(); inValReads[BUTTON_RIGHT] = input.DDPRight() || input.DLARight();
inValReads[BUTTON_SELECT] = input.DZ() || input.DSpecialKey(aurora::SpecialKey::Tab); inValReads[BUTTON_SELECT] = input.DZ() || input.DSpecialKey(ESpecialKey::Tab);
inValReads[BUTTON_START] = input.DStart() || input.DSpecialKey(aurora::SpecialKey::Esc); inValReads[BUTTON_START] = input.DStart() || input.DSpecialKey(ESpecialKey::Esc);
} }
bool CNESEmulator::CheckForGameOver(const u8* vram, u8* passwordOut) { bool CNESEmulator::CheckForGameOver(const u8* vram, u8* passwordOut) {

View File

@ -35,7 +35,7 @@ private:
zeus::CColor m_color; zeus::CColor m_color;
}; };
aurora::gfx::TextureHandle m_texture; GXTexObj m_texture;
// boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf; // boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
// boo::ObjToken<boo::IGraphicsBufferS> m_vbo; // boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
// boo::ObjToken<boo::IShaderDataBinding> m_shadBind; // boo::ObjToken<boo::IShaderDataBinding> m_shadBind;

View File

@ -788,10 +788,10 @@ void CAutoMapper::SetShouldRotatingSoundBePlaying(bool shouldBePlaying) {
void CAutoMapper::ProcessMapScreenInput(const CFinalInput& input, CStateManager& mgr) { void CAutoMapper::ProcessMapScreenInput(const CFinalInput& input, CStateManager& mgr) {
zeus::CMatrix3f camRot = xa8_renderStates[0].x8_camOrientation.toTransform().buildMatrix3f(); zeus::CMatrix3f camRot = xa8_renderStates[0].x8_camOrientation.toTransform().buildMatrix3f();
if (x1bc_state == EAutoMapperState::MapScreen) { if (x1bc_state == EAutoMapperState::MapScreen) {
if ((input.PA() || input.PSpecialKey(aurora::SpecialKey::Enter)) && x328_ == 0 && HasCurrentMapUniverseWorld()) if ((input.PA() || input.PSpecialKey(ESpecialKey::Enter)) && x328_ == 0 && HasCurrentMapUniverseWorld())
BeginMapperStateTransition(EAutoMapperState::MapScreenUniverse, mgr); BeginMapperStateTransition(EAutoMapperState::MapScreenUniverse, mgr);
} else if (x1bc_state == EAutoMapperState::MapScreenUniverse && } else if (x1bc_state == EAutoMapperState::MapScreenUniverse &&
(input.PA() || input.PSpecialKey(aurora::SpecialKey::Enter))) { (input.PA() || input.PSpecialKey(ESpecialKey::Enter))) {
const CMapUniverse::CMapWorldData& mapuWld = x8_mapu->GetMapWorldData(x9c_worldIdx); const CMapUniverse::CMapWorldData& mapuWld = x8_mapu->GetMapWorldData(x9c_worldIdx);
zeus::CVector3f pointLocal = mapuWld.GetWorldTransform().inverse() * xa8_renderStates[0].x20_areaPoint; zeus::CVector3f pointLocal = mapuWld.GetWorldTransform().inverse() * xa8_renderStates[0].x20_areaPoint;
if (mapuWld.GetWorldAssetId() != g_GameState->CurrentWorldAssetId()) { if (mapuWld.GetWorldAssetId() != g_GameState->CurrentWorldAssetId()) {
@ -806,7 +806,7 @@ void CAutoMapper::ProcessMapScreenInput(const CFinalInput& input, CStateManager&
} }
x2f4_aButtonPos = 0; x2f4_aButtonPos = 0;
if (input.PA() || input.PSpecialKey(aurora::SpecialKey::Enter)) if (input.PA() || input.PSpecialKey(ESpecialKey::Enter))
x2f4_aButtonPos = 1; x2f4_aButtonPos = 1;
if (IsInPlayerControlState()) { if (IsInPlayerControlState()) {
@ -1083,8 +1083,8 @@ void CAutoMapper::ProcessControllerInput(const CFinalInput& input, CStateManager
} }
} }
if (input.PZ() || input.PSpecialKey(aurora::SpecialKey::Tab) || input.PB() || if (input.PZ() || input.PSpecialKey(ESpecialKey::Tab) || input.PB() ||
input.PSpecialKey(aurora::SpecialKey::Esc)) { input.PSpecialKey(ESpecialKey::Esc)) {
if (x328_ == 0) { if (x328_ == 0) {
if (CanLeaveMapScreenInternal(mgr)) { if (CanLeaveMapScreenInternal(mgr)) {
LeaveMapScreen(mgr); LeaveMapScreen(mgr);

View File

@ -197,10 +197,10 @@ void CMapArea::CMapAreaSurface::PostConstruct(const u8* buf, std::vector<u32>& i
CMemoryInStream r(x18_surfOffset, INT_MAX, CMemoryInStream::EOwnerShip::NotOwned); CMemoryInStream r(x18_surfOffset, INT_MAX, CMemoryInStream::EOwnerShip::NotOwned);
u32 primCount = r.ReadLong(); u32 primCount = r.ReadLong();
for (u32 i = 0; i < primCount; ++i) { for (u32 i = 0; i < primCount; ++i) {
GX::Primitive prim = GX::Primitive(r.ReadLong()); GXPrimitive prim = GXPrimitive(r.ReadLong());
u32 count = r.ReadLong(); u32 count = r.ReadLong();
switch (prim) { switch (prim) {
case GX::Primitive::TRIANGLES: { case GX_TRIANGLES: {
for (u32 v = 0; v < count; v += 3) { for (u32 v = 0; v < count; v += 3) {
if (!start) { if (!start) {
index.push_back(index.back()); index.push_back(index.back());
@ -216,7 +216,7 @@ void CMapArea::CMapAreaSurface::PostConstruct(const u8* buf, std::vector<u32>& i
} }
break; break;
} }
case GX::Primitive::TRIANGLESTRIP: { case GX_TRIANGLESTRIP: {
if (!start) { if (!start) {
index.push_back(index.back()); index.push_back(index.back());
index.push_back(r.ReadUint8()); index.push_back(r.ReadUint8());
@ -231,7 +231,7 @@ void CMapArea::CMapAreaSurface::PostConstruct(const u8* buf, std::vector<u32>& i
index.push_back(index.back()); index.push_back(index.back());
break; break;
} }
case GX::Primitive::TRIANGLEFAN: { case GX_TRIANGLEFAN: {
u8 firstVert = r.ReadUint8(); u8 firstVert = r.ReadUint8();
if (!start) { if (!start) {
index.push_back(index.back()); index.push_back(index.back());

View File

@ -27,8 +27,8 @@ public:
struct Instance { struct Instance {
CMapSurfaceShader m_surfacePrims; CMapSurfaceShader m_surfacePrims;
std::vector<CLineRenderer> m_linePrims; std::vector<CLineRenderer> m_linePrims;
Instance(aurora::ArrayRef<zeus::CVector3f> vbo, Instance(std::vector<zeus::CVector3f> vbo,
aurora::ArrayRef<u16> ibo) std::vector<u16> ibo)
: m_surfacePrims(vbo, ibo) {} : m_surfacePrims(vbo, ibo) {}
Instance(Instance&&) = default; Instance(Instance&&) = default;
Instance& operator=(Instance&&) = default; Instance& operator=(Instance&&) = default;

View File

@ -112,19 +112,19 @@ void CMappableObject::Draw(int curArea, const CMapWorldInfo& mwInfo, float alpha
SCOPED_GRAPHICS_DEBUG_GROUP("CMappableObject::Draw", zeus::skCyan); SCOPED_GRAPHICS_DEBUG_GROUP("CMappableObject::Draw", zeus::skCyan);
if (IsDoorType(x0_type)) { if (IsDoorType(x0_type)) {
std::pair<zeus::CColor, zeus::CColor> colors = GetDoorColors(curArea, mwInfo, alpha); std::pair<zeus::CColor, zeus::CColor> colors = GetDoorColors(curArea, mwInfo, alpha);
if (m_doorSurface) // TODO // TODO
for (int s = 0; s < 6; ++s) { // for (int s = 0; s < 6; ++s) {
DoorSurface& ds = *m_doorSurface; // DoorSurface& ds = *m_doorSurface;
ds.m_surface.draw(colors.first, s * 4, 4); // ds.m_surface.draw(colors.first, s * 4, 4);
CLineRenderer& line = ds.m_outline; // CLineRenderer& line = ds.m_outline;
const u16* baseIdx = &skDoorIndices[s * 4]; // const u16* baseIdx = &skDoorIndices[s * 4];
line.Reset(); // line.Reset();
line.AddVertex(skDoorVerts[baseIdx[0]], colors.second, 1.f); // line.AddVertex(skDoorVerts[baseIdx[0]], colors.second, 1.f);
line.AddVertex(skDoorVerts[baseIdx[1]], colors.second, 1.f); // line.AddVertex(skDoorVerts[baseIdx[1]], colors.second, 1.f);
line.AddVertex(skDoorVerts[baseIdx[3]], colors.second, 1.f); // line.AddVertex(skDoorVerts[baseIdx[3]], colors.second, 1.f);
line.AddVertex(skDoorVerts[baseIdx[2]], colors.second, 1.f); // line.AddVertex(skDoorVerts[baseIdx[2]], colors.second, 1.f);
line.Render(); // line.Render();
} // }
} else { } else {
CAssetId iconRes; CAssetId iconRes;
zeus::CColor iconColor = zeus::skWhite; zeus::CColor iconColor = zeus::skWhite;
@ -184,16 +184,16 @@ void CMappableObject::Draw(int curArea, const CMapWorldInfo& mwInfo, float alpha
void CMappableObject::DrawDoorSurface(int curArea, const CMapWorldInfo& mwInfo, float alpha, int surfIdx, void CMappableObject::DrawDoorSurface(int curArea, const CMapWorldInfo& mwInfo, float alpha, int surfIdx,
bool needsVtxLoad) { bool needsVtxLoad) {
std::pair<zeus::CColor, zeus::CColor> colors = GetDoorColors(curArea, mwInfo, alpha); std::pair<zeus::CColor, zeus::CColor> colors = GetDoorColors(curArea, mwInfo, alpha);
DoorSurface& ds = *m_doorSurface; // DoorSurface& ds = *m_doorSurface;
ds.m_surface.draw(colors.first, surfIdx * 4, 4); // ds.m_surface.draw(colors.first, surfIdx * 4, 4);
CLineRenderer& line = ds.m_outline; // CLineRenderer& line = ds.m_outline;
const u16* baseIdx = &skDoorIndices[surfIdx * 4]; // const u16* baseIdx = &skDoorIndices[surfIdx * 4];
line.Reset(); // line.Reset();
line.AddVertex(skDoorVerts[baseIdx[0]], colors.second, 1.f); // line.AddVertex(skDoorVerts[baseIdx[0]], colors.second, 1.f);
line.AddVertex(skDoorVerts[baseIdx[1]], colors.second, 1.f); // line.AddVertex(skDoorVerts[baseIdx[1]], colors.second, 1.f);
line.AddVertex(skDoorVerts[baseIdx[3]], colors.second, 1.f); // line.AddVertex(skDoorVerts[baseIdx[3]], colors.second, 1.f);
line.AddVertex(skDoorVerts[baseIdx[2]], colors.second, 1.f); // line.AddVertex(skDoorVerts[baseIdx[2]], colors.second, 1.f);
line.Render(); // line.Render();
} }
zeus::CVector3f CMappableObject::BuildSurfaceCenterPoint(int surfIdx) const { zeus::CVector3f CMappableObject::BuildSurfaceCenterPoint(int surfIdx) const {

View File

@ -58,14 +58,14 @@ private:
u32 xc_; u32 xc_;
zeus::CTransform x10_transform; zeus::CTransform x10_transform;
struct DoorSurface { // struct DoorSurface {
CMapSurfaceShader m_surface; // CMapSurfaceShader m_surface;
CLineRenderer m_outline; // CLineRenderer m_outline;
explicit DoorSurface() // explicit DoorSurface()
: m_surface(skDoorVerts, skDoorIndices) // : m_surface(skDoorVerts, skDoorIndices)
, m_outline(CLineRenderer::EPrimitiveMode::LineLoop, 5, {}, false, false, true) {} // , m_outline(CLineRenderer::EPrimitiveMode::LineLoop, 5, {}, false, false, true) {}
}; // };
std::optional<DoorSurface> m_doorSurface; // std::optional<DoorSurface> m_doorSurface;
zeus::CTransform AdjustTransformForType() const; zeus::CTransform AdjustTransformForType() const;
std::pair<zeus::CColor, zeus::CColor> GetDoorColors(int idx, const CMapWorldInfo& mwInfo, float alpha) const; std::pair<zeus::CColor, zeus::CColor> GetDoorColors(int idx, const CMapWorldInfo& mwInfo, float alpha) const;
@ -83,7 +83,7 @@ public:
bool IsDoorConnectedToVisitedArea(const CStateManager&) const; bool IsDoorConnectedToVisitedArea(const CStateManager&) const;
bool IsVisibleToAutoMapper(bool worldVis, const CMapWorldInfo& mwInfo) const; bool IsVisibleToAutoMapper(bool worldVis, const CMapWorldInfo& mwInfo) const;
bool GetIsSeen() const; bool GetIsSeen() const;
void CreateDoorSurface() { m_doorSurface.emplace(); } // void CreateDoorSurface() { m_doorSurface.emplace(); }
static void ReadAutoMapperTweaks(const ITweakAutoMapper&); static void ReadAutoMapperTweaks(const ITweakAutoMapper&);
static bool GetTweakIsMapVisibilityCheat(); static bool GetTweakIsMapVisibilityCheat();

View File

@ -446,7 +446,7 @@ void CGameOptions::TryRestoreDefaults(const CFinalInput& input, int category, in
if (options.second[option].option != EGameOption::RestoreDefaults) if (options.second[option].option != EGameOption::RestoreDefaults)
return; return;
if (!forceRestore && !input.PA() && !input.PSpecialKey(aurora::SpecialKey::Enter)) if (!forceRestore && !input.PA() && !input.PSpecialKey(ESpecialKey::Enter))
return; return;
if (frontend) { if (frontend) {

View File

@ -29,8 +29,8 @@
//#include <fenv.h> //#include <fenv.h>
//#pragma STDC FENV_ACCESS ON //#pragma STDC FENV_ACCESS ON
#include <SDL_main.h> #include <aurora/event.h>
#include <aurora/aurora.hpp> #include <aurora/main.h>
using namespace std::literals; using namespace std::literals;
@ -147,8 +147,10 @@ static std::string CPUFeatureString(const zeus::CPUInfo& cpuInf) {
return features; return features;
} }
struct Application : aurora::AppDelegate { struct Application {
private: private:
int m_argc;
char** m_argv;
FileStoreManager& m_fileMgr; FileStoreManager& m_fileMgr;
CVarManager& m_cvarManager; CVarManager& m_cvarManager;
CVarCommons& m_cvarCommons; CVarCommons& m_cvarCommons;
@ -171,14 +173,20 @@ private:
// is built, i.e during initialization // is built, i.e during initialization
public: public:
Application(FileStoreManager& fileMgr, CVarManager& cvarMgr, CVarCommons& cvarCmns) Application(int argc, char** argv, FileStoreManager& fileMgr, CVarManager& cvarMgr, CVarCommons& cvarCmns)
: m_fileMgr(fileMgr), m_cvarManager(cvarMgr), m_cvarCommons(cvarCmns), m_imGuiConsole(cvarMgr, cvarCmns) {} : m_argc(argc)
, m_argv(argv)
, m_fileMgr(fileMgr)
, m_cvarManager(cvarMgr)
, m_cvarCommons(cvarCmns)
, m_imGuiConsole(cvarMgr, cvarCmns) {}
void onAppLaunched() noexcept override { void onAppLaunched() noexcept {
initialize(); initialize();
auto backend = static_cast<std::string>(aurora::get_backend_string()); // TODO
aurora::set_window_title(fmt::format(FMT_STRING("Metaforce {} [{}]"), METAFORCE_WC_DESCRIBE, backend)); // auto backend = static_cast<std::string>(aurora::get_backend_string());
// aurora::set_window_title(fmt::format(FMT_STRING("Metaforce {} [{}]"), METAFORCE_WC_DESCRIBE, backend));
m_voiceEngine = boo::NewAudioVoiceEngine("metaforce", "Metaforce"); m_voiceEngine = boo::NewAudioVoiceEngine("metaforce", "Metaforce");
m_voiceEngine->setVolume(0.7f); m_voiceEngine->setVolume(0.7f);
@ -187,8 +195,8 @@ public:
#if TARGET_OS_IOS || TARGET_OS_TV #if TARGET_OS_IOS || TARGET_OS_TV
m_deferredProject = std::string{m_fileMgr.getStoreRoot()} + "game.iso"; m_deferredProject = std::string{m_fileMgr.getStoreRoot()} + "game.iso";
#else #else
for (const auto& str : aurora::get_args()) { for (int i = 1; i < m_argc; ++i) {
auto arg = static_cast<std::string>(str); std::string arg = m_argv[i];
if (m_deferredProject.empty() && !arg.starts_with('-') && !arg.starts_with('+')) if (m_deferredProject.empty() && !arg.starts_with('-') && !arg.starts_with('+'))
m_deferredProject = arg; m_deferredProject = arg;
else if (arg == "--no-sound") else if (arg == "--no-sound")
@ -202,17 +210,13 @@ public:
void initialize() { void initialize() {
zeus::detectCPU(); zeus::detectCPU();
for (const auto& str : aurora::get_args()) {
auto arg = static_cast<std::string>(str);
}
const zeus::CPUInfo& cpuInf = zeus::cpuFeatures(); const zeus::CPUInfo& cpuInf = zeus::cpuFeatures();
Log.report(logvisor::Info, FMT_STRING("CPU Name: {}"), cpuInf.cpuBrand); Log.report(logvisor::Info, FMT_STRING("CPU Name: {}"), cpuInf.cpuBrand);
Log.report(logvisor::Info, FMT_STRING("CPU Vendor: {}"), cpuInf.cpuVendor); Log.report(logvisor::Info, FMT_STRING("CPU Vendor: {}"), cpuInf.cpuVendor);
Log.report(logvisor::Info, FMT_STRING("CPU Features: {}"), CPUFeatureString(cpuInf)); Log.report(logvisor::Info, FMT_STRING("CPU Features: {}"), CPUFeatureString(cpuInf));
} }
bool onAppIdle(float realDt) noexcept override { bool onAppIdle(float realDt) noexcept {
#ifdef NDEBUG #ifdef NDEBUG
/* Ping the watchdog to let it know we're still alive */ /* Ping the watchdog to let it know we're still alive */
CInfiniteLoopDetector::UpdateWatchDog(std::chrono::system_clock::now()); CInfiniteLoopDetector::UpdateWatchDog(std::chrono::system_clock::now());
@ -258,7 +262,8 @@ public:
// Check if the user has modified the fullscreen CVar, if so set fullscreen state accordingly // Check if the user has modified the fullscreen CVar, if so set fullscreen state accordingly
if (m_cvarCommons.m_fullscreen->isModified()) { if (m_cvarCommons.m_fullscreen->isModified()) {
aurora::set_fullscreen(m_cvarCommons.getFullscreen()); // TODO
// aurora::set_fullscreen(m_cvarCommons.getFullscreen());
} }
// Let CVarManager inform all CVar listeners of the CVar's state and clear all mdoified flags if necessary // Let CVarManager inform all CVar listeners of the CVar's state and clear all mdoified flags if necessary
@ -266,7 +271,8 @@ public:
if (!g_mainMP1 && m_projectInitialized) { if (!g_mainMP1 && m_projectInitialized) {
g_mainMP1.emplace(nullptr, nullptr); g_mainMP1.emplace(nullptr, nullptr);
auto result = g_mainMP1->Init(m_fileMgr, &m_cvarManager, m_voiceEngine.get(), *m_amuseAllocWrapper); auto result =
g_mainMP1->Init(m_argc, m_argv, m_fileMgr, &m_cvarManager, m_voiceEngine.get(), *m_amuseAllocWrapper);
if (!result.empty()) { if (!result.empty()) {
Log.report(logvisor::Error, FMT_STRING("{}"), result); Log.report(logvisor::Error, FMT_STRING("{}"), result);
m_imGuiConsole.m_errorString = result; m_imGuiConsole.m_errorString = result;
@ -311,7 +317,7 @@ public:
return true; return true;
} }
void onAppDraw() noexcept override { void onAppDraw() noexcept {
OPTICK_EVENT("Draw"); OPTICK_EVENT("Draw");
if (g_Renderer != nullptr) { if (g_Renderer != nullptr) {
g_Renderer->BeginScene(); g_Renderer->BeginScene();
@ -322,7 +328,7 @@ public:
} }
} }
void onAppPostDraw() noexcept override { void onAppPostDraw() noexcept {
OPTICK_EVENT("PostDraw"); OPTICK_EVENT("PostDraw");
if (m_voiceEngine) { if (m_voiceEngine) {
m_voiceEngine->pumpAndMixVoices(); m_voiceEngine->pumpAndMixVoices();
@ -331,25 +337,17 @@ public:
++logvisor::FrameIndex; ++logvisor::FrameIndex;
} }
void onAppWindowResized(const aurora::WindowSize& size) noexcept override { void onAppWindowResized(const AuroraWindowSize& size) noexcept {
CGraphics::SetViewportResolution({static_cast<s32>(size.fb_width), static_cast<s32>(size.fb_height)}); CGraphics::SetViewportResolution({static_cast<s32>(size.fb_width), static_cast<s32>(size.fb_height)});
} }
void onAppWindowMoved(std::int32_t x, std::int32_t y) noexcept override { void onAppDisplayScaleChanged(float scale) noexcept { ImGuiEngine_Initialize(scale); }
// TODO: implement this
}
void onAppDisplayScaleChanged(float scale) noexcept override { ImGuiEngine_Initialize(scale); } void onControllerAdded(uint32_t which) noexcept { m_imGuiConsole.ControllerAdded(which); }
void onControllerButton(uint32_t idx, aurora::ControllerButton button, bool pressed) noexcept override {} void onControllerRemoved(uint32_t which) noexcept { m_imGuiConsole.ControllerRemoved(which); }
void onControllerAxis(uint32_t idx, aurora::ControllerAxis axis, int16_t value) noexcept override {} void onAppExiting() noexcept {
void onControllerAdded(uint32_t which) noexcept override { m_imGuiConsole.ControllerAdded(which); }
void onControllerRemoved(uint32_t which) noexcept override { m_imGuiConsole.ControllerRemoved(which); }
void onAppExiting() noexcept override {
m_imGuiConsole.Shutdown(); m_imGuiConsole.Shutdown();
if (m_voiceEngine) { if (m_voiceEngine) {
m_voiceEngine->unlockPump(); m_voiceEngine->unlockPump();
@ -365,127 +363,9 @@ public:
CDvdFile::Shutdown(); CDvdFile::Shutdown();
} }
void onCharKeyDown(uint8_t code, aurora::ModifierKey mods, bool isRepeat) noexcept override { void onImGuiInit(float scale) noexcept { ImGuiEngine_Initialize(scale); }
if (g_mainMP1) {
if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
as->charKeyDown(code, mods, isRepeat);
}
}
}
void onCharKeyUp(uint8_t code, aurora::ModifierKey mods) noexcept override { void onImGuiAddTextures() noexcept { ImGuiEngine_AddTextures(); }
if (g_mainMP1) {
if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
as->charKeyUp(code, mods);
}
}
}
void onSpecialKeyDown(aurora::SpecialKey key, aurora::ModifierKey mods, bool isRepeat) noexcept override {
if (g_mainMP1) {
if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
as->specialKeyDown(key, mods, isRepeat);
}
}
if (True(mods & (aurora::ModifierKey::LeftAlt | aurora::ModifierKey::RightAlt))) {
if (key == aurora::SpecialKey::Enter) {
m_fullscreenToggleRequested = true;
} else if (key == aurora::SpecialKey::F4) {
m_quitRequested = true;
}
}
}
void onSpecialKeyUp(aurora::SpecialKey key, aurora::ModifierKey mods) noexcept override {
if (g_mainMP1) {
if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
as->specialKeyUp(key, mods);
}
}
}
void onTextInput(const std::string& text) noexcept override {}
void onModifierKeyDown(aurora::ModifierKey mods, bool isRepeat) noexcept override {}
void onModifierKeyUp(aurora::ModifierKey mods) noexcept override {}
void onMouseMove(int32_t x, int32_t y, int32_t xrel, int32_t yrel, aurora::MouseButton state) noexcept override {
if (g_mainMP1) {
if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
as->mouseMove(SWindowCoord{.pixel = {x, y}});
}
}
}
void onMouseButtonDown(int32_t x, int32_t y, aurora::MouseButton button, int32_t clicks) noexcept override {
if (g_mainMP1) {
if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
EMouseButton asBtn;
switch (button) {
case aurora::MouseButton::None:
asBtn = EMouseButton::None;
break;
case aurora::MouseButton::Primary:
asBtn = EMouseButton::Primary;
break;
case aurora::MouseButton::Middle:
asBtn = EMouseButton::Middle;
break;
case aurora::MouseButton::Secondary:
asBtn = EMouseButton::Secondary;
break;
case aurora::MouseButton::Aux1:
asBtn = EMouseButton::Aux1;
break;
case aurora::MouseButton::Aux2:
asBtn = EMouseButton::Aux2;
break;
}
as->mouseDown(SWindowCoord{.pixel = {x, y}}, asBtn, {});
}
}
}
void onMouseButtonUp(int32_t x, int32_t y, aurora::MouseButton button) noexcept override {
if (g_mainMP1) {
if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
EMouseButton asBtn;
switch (button) {
case aurora::MouseButton::None:
asBtn = EMouseButton::None;
break;
case aurora::MouseButton::Primary:
asBtn = EMouseButton::Primary;
break;
case aurora::MouseButton::Middle:
asBtn = EMouseButton::Middle;
break;
case aurora::MouseButton::Secondary:
asBtn = EMouseButton::Secondary;
break;
case aurora::MouseButton::Aux1:
asBtn = EMouseButton::Aux1;
break;
case aurora::MouseButton::Aux2:
asBtn = EMouseButton::Aux2;
break;
}
as->mouseUp(SWindowCoord{.pixel = {x, y}}, asBtn, {});
}
}
}
void onImGuiInit(float scale) noexcept override { ImGuiEngine_Initialize(scale); }
void onImGuiAddTextures() noexcept override { ImGuiEngine_AddTextures(); }
[[nodiscard]] std::string getGraphicsApi() const { return m_cvarCommons.getGraphicsApi(); }
[[nodiscard]] uint32_t getSamples() const { return m_cvarCommons.getSamples(); }
[[nodiscard]] uint32_t getAnisotropy() const { return m_cvarCommons.getAnisotropy(); }
[[nodiscard]] bool getDeepColor() const { return m_cvarCommons.getDeepColor(); }
[[nodiscard]] std::chrono::nanoseconds getTargetFrameTime() const { [[nodiscard]] std::chrono::nanoseconds getTargetFrameTime() const {
if (m_cvarCommons.getVariableFrameTime()) { if (m_cvarCommons.getVariableFrameTime()) {
@ -527,10 +407,32 @@ static bool IsClientLoggingEnabled(int argc, char** argv) {
return false; return false;
} }
static void SetupLogging() { static void SetupLogging() {}
static std::unique_ptr<metaforce::Application> g_app;
static bool g_paused;
static void aurora_log_callback(AuroraLogLevel level, const char* message, unsigned int len) {
logvisor::Level severity = logvisor::Fatal;
switch (level) {
case LOG_DEBUG:
case LOG_INFO:
severity = logvisor::Info;
break;
case LOG_WARNING:
severity = logvisor::Warning;
break;
case LOG_ERROR:
severity = logvisor::Error;
break;
default:
break;
}
metaforce::Log.report(severity, FMT_STRING("{}"), message);
} }
static void aurora_imgui_init_callback(const AuroraWindowSize* size) { g_app->onImGuiInit(size->scale); }
#if !WINDOWS_STORE #if !WINDOWS_STORE
int main(int argc, char** argv) { int main(int argc, char** argv) {
// TODO: This seems to fix a lot of weird issues with rounding // TODO: This seems to fix a lot of weird issues with rounding
@ -550,6 +452,8 @@ int main(int argc, char** argv) {
args.emplace_back(argv[i]); args.emplace_back(argv[i]);
} }
auto icon = metaforce::GetIcon();
// FIXME: logvisor needs to copy this // FIXME: logvisor needs to copy this
std::string logFilePath; std::string logFilePath;
@ -583,16 +487,72 @@ int main(int argc, char** argv) {
} }
} }
auto app = std::make_unique<metaforce::Application>(fileMgr, cvarMgr, cvarCmns); g_app = std::make_unique<metaforce::Application>(argc, argv, fileMgr, cvarMgr, cvarCmns);
auto icon = metaforce::GetIcon(); std::string configPath{fileMgr.getStoreRoot()};
auto data = aurora::Icon{ const AuroraConfig config{
.data = std::move(icon.data), .appName = "Metaforce",
.width = icon.width, .configPath = configPath.c_str(),
.height = icon.height, // .desiredBackend = TODO
.msaa = cvarCmns.getSamples(),
.maxTextureAnisotropy = static_cast<uint16_t>(cvarCmns.getAnisotropy()),
.startFullscreen = cvarCmns.getFullscreen(),
.iconRGBA8 = icon.data.get(),
.iconWidth = icon.width,
.iconHeight = icon.height,
.logCallback = aurora_log_callback,
.imGuiInitCallback = aurora_imgui_init_callback,
}; };
aurora::app_run(std::move(app), std::move(data), argc, argv, fileMgr.getStoreRoot(), const auto info = aurora_initialize(argc, argv, &config);
aurora::backend_from_string(cvarCmns.getGraphicsApi()), cvarCmns.getSamples(), g_app->onImGuiAddTextures();
cvarCmns.getAnisotropy(), cvarCmns.getFullscreen()); g_app->onAppLaunched();
g_app->onAppWindowResized(info.windowSize);
while (true) {
const auto* event = aurora_update();
bool exiting = false;
while (event != nullptr && event->type != AURORA_NONE) {
switch (event->type) {
case AURORA_EXIT:
exiting = true;
break;
case AURORA_WINDOW_RESIZED:
g_app->onAppWindowResized(event->windowSize);
break;
case AURORA_CONTROLLER_ADDED:
g_app->onControllerAdded(event->controller);
break;
case AURORA_CONTROLLER_REMOVED:
g_app->onControllerRemoved(event->controller);
break;
case AURORA_PAUSED:
g_paused = true;
break;
case AURORA_UNPAUSED:
g_paused = false;
break;
default:
break;
}
if (exiting) {
break;
}
++event;
}
if (exiting) {
break;
}
if (g_paused) {
continue;
}
g_app->onAppIdle(1.f / 60.f /* TODO */);
aurora_begin_frame();
g_app->onAppDraw();
aurora_end_frame();
g_app->onAppPostDraw();
}
g_app->onAppExiting();
aurora_shutdown();
g_app.reset();
restart = cvarMgr.restartRequired(); restart = cvarMgr.restartRequired();
} while (restart); } while (restart);
return 0; return 0;

View File

@ -153,11 +153,11 @@ set(DISCORD_RPC_LIBRARY "")
if (NOT GEKKO AND NOT NX AND NOT IOS AND NOT TVOS) if (NOT GEKKO AND NOT NX AND NOT IOS AND NOT TVOS)
set(DISCORD_RPC_LIBRARY "discord-rpc") set(DISCORD_RPC_LIBRARY "discord-rpc")
endif() endif()
set(RUNTIME_LIBRARIES amuse zeus nod NESEmulator libjpeg-turbo jbus kabufuda logvisor OptickCore imgui aurora set(RUNTIME_LIBRARIES amuse zeus nod NESEmulator libjpeg-turbo jbus kabufuda logvisor OptickCore
imgui_support aurora::aurora SDL2::SDL2-static SDL2::SDL2main
boo # TODO move audiodev boo # TODO move audiodev
${DISCORD_RPC_LIBRARY} ${DISCORD_RPC_LIBRARY}
${ZLIB_LIBRARIES} ${ZLIB_LIBRARIES}
SDL2::SDL2-static SDL2::SDL2main
) )
add_runtime_common_library(RuntimeCommon ${RUNTIME_SOURCES_A}) add_runtime_common_library(RuntimeCommon ${RUNTIME_SOURCES_A})
@ -229,7 +229,7 @@ add_executable(metaforce CMain.cpp ${PLAT_SRCS}
ImGuiControllerConfig.hpp ImGuiControllerConfig.cpp ImGuiControllerConfig.hpp ImGuiControllerConfig.cpp
ImGuiEntitySupport.hpp ImGuiEntitySupport.cpp) ImGuiEntitySupport.hpp ImGuiEntitySupport.cpp)
# RUNTIME_LIBRARIES repeated here for link ordering # RUNTIME_LIBRARIES repeated here for link ordering
target_link_libraries(metaforce PUBLIC RuntimeCommon RuntimeCommonB ${RUNTIME_LIBRARIES} ${PLAT_LIBS}) target_link_libraries(metaforce PUBLIC RuntimeCommon RuntimeCommonB ${RUNTIME_LIBRARIES} ${PLAT_LIBS} aurora::main)
if (TARGET nativefiledialog) if (TARGET nativefiledialog)
target_link_libraries(metaforce PRIVATE nativefiledialog) target_link_libraries(metaforce PRIVATE nativefiledialog)
endif() endif()

View File

@ -112,7 +112,7 @@ void CCameraFilterPass::DrawFilter(EFilterType type, EFilterShape shape, const z
g_Renderer->SetBlendMode_AdditiveAlpha(); g_Renderer->SetBlendMode_AdditiveAlpha();
break; break;
case EFilterType::Subtract: case EFilterType::Subtract:
CGX::SetBlendMode(GX::BM_SUBTRACT, GX::BL_ONE, GX::BL_ONE, GX::LO_CLEAR); CGX::SetBlendMode(GX_BM_SUBTRACT, GX_BL_ONE, GX_BL_ONE, GX_LO_CLEAR);
break; break;
case EFilterType::Blend: case EFilterType::Blend:
g_Renderer->SetBlendMode_AlphaBlended(); g_Renderer->SetBlendMode_AlphaBlended();
@ -186,12 +186,12 @@ void CCameraFilterPass::DrawFullScreenTexturedQuadQuarters(const zeus::CColor& c
CGraphics::SetTevOp(ERglTevStage::Stage1, CTevCombiners::skPassThru); CGraphics::SetTevOp(ERglTevStage::Stage1, CTevCombiners::skPassThru);
g_Renderer->SetDepthReadWrite(false, false); g_Renderer->SetDepthReadWrite(false, false);
if (tex != nullptr) { if (tex != nullptr) {
tex->Load(GX::TEXMAP0, EClampMode::Repeat); tex->Load(GX_TEXMAP0, EClampMode::Repeat);
} }
CGraphics::SetCullMode(ERglCullMode::None); CGraphics::SetCullMode(ERglCullMode::None);
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
g_Renderer->SetModelMatrix(zeus::CTransform::Scale((i & 1) != 0 ? 1.f : -1.f, 0.f, (i & 2) != 0 ? 1.f : -1.f)); g_Renderer->SetModelMatrix(zeus::CTransform::Scale((i & 1) != 0 ? 1.f : -1.f, 0.f, (i & 2) != 0 ? 1.f : -1.f));
CGraphics::StreamBegin(GX::TRIANGLESTRIP); CGraphics::StreamBegin(GX_TRIANGLESTRIP);
CGraphics::StreamColor(color); CGraphics::StreamColor(color);
CGraphics::StreamTexcoord(lod, lod); CGraphics::StreamTexcoord(lod, lod);
CGraphics::StreamVertex(lt.x(), 0.f, rb.y()); CGraphics::StreamVertex(lt.x(), 0.f, rb.y());
@ -213,11 +213,11 @@ void CCameraFilterPass::DrawFullScreenTexturedQuad(const zeus::CColor& color, CT
const auto [lt, rb] = g_Renderer->SetViewportOrtho(true, -4096.f, 4096.f); const auto [lt, rb] = g_Renderer->SetViewportOrtho(true, -4096.f, 4096.f);
g_Renderer->SetDepthReadWrite(false, false); g_Renderer->SetDepthReadWrite(false, false);
if (tex != nullptr) { if (tex != nullptr) {
tex->Load(GX::TEXMAP0, EClampMode::Repeat); tex->Load(GX_TEXMAP0, EClampMode::Repeat);
} }
CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::sTevPass805a5ebc); CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::sTevPass805a5ebc);
CGraphics::SetTevOp(ERglTevStage::Stage1, CTevCombiners::skPassThru); CGraphics::SetTevOp(ERglTevStage::Stage1, CTevCombiners::skPassThru);
CGraphics::StreamBegin(GX::TRIANGLESTRIP); CGraphics::StreamBegin(GX_TRIANGLESTRIP);
CGraphics::StreamColor(color); CGraphics::StreamColor(color);
CGraphics::StreamTexcoord(u, v); CGraphics::StreamTexcoord(u, v);
CGraphics::StreamVertex(lt.x() - 1.f, 0.f, 1.f + rb.y()); CGraphics::StreamVertex(lt.x() - 1.f, 0.f, 1.f + rb.y());
@ -253,9 +253,9 @@ void CCameraFilterPass::DrawRandomStatic(const zeus::CColor& color, float alpha,
u8* out = m_randomStatic.Lock(); u8* out = m_randomStatic.Lock();
memcpy(out, buf + ROUND_UP_32(rand() & 0x7fff), m_randomStatic.GetMemoryAllocated()); memcpy(out, buf + ROUND_UP_32(rand() & 0x7fff), m_randomStatic.GetMemoryAllocated());
m_randomStatic.UnLock(); m_randomStatic.UnLock();
m_randomStatic.Load(GX::TEXMAP0, EClampMode::Clamp); m_randomStatic.Load(GX_TEXMAP0, EClampMode::Clamp);
CGraphics::StreamBegin(GX::TRIANGLESTRIP); CGraphics::StreamBegin(GX_TRIANGLESTRIP);
CGraphics::StreamColor(color); CGraphics::StreamColor(color);
CGraphics::StreamTexcoord(0.f, 1.f); CGraphics::StreamTexcoord(0.f, 1.f);
CGraphics::StreamVertex(lb.x() - 1.f, 0.01f, rt.y() + 1.f); CGraphics::StreamVertex(lb.x() - 1.f, 0.01f, rt.y() + 1.f);
@ -289,11 +289,11 @@ void CCameraFilterPass::DrawWideScreen(const zeus::CColor& color, CTexture* tex,
// g_Renderer->SetDepthReadWrite(false, false); // g_Renderer->SetDepthReadWrite(false, false);
// g_Renderer->SetModelMatrix({}); // g_Renderer->SetModelMatrix({});
// if (tex != nullptr) { // if (tex != nullptr) {
// tex->Load(GX::TEXMAP0, EClampMode::Repeat); // tex->Load(GX_TEXMAP0, EClampMode::Repeat);
// } // }
// CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::sTevPass805a5ebc); // CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::sTevPass805a5ebc);
// CGraphics::SetTevOp(ERglTevStage::Stage1, CTevCombiners::skPassThru); // CGraphics::SetTevOp(ERglTevStage::Stage1, CTevCombiners::skPassThru);
// CGraphics::StreamBegin(GX::TRIANGLESTRIP); // CGraphics::StreamBegin(GX_TRIANGLESTRIP);
// float x = rand() % 4000; // float x = rand() % 4000;
} }

70
Runtime/Flags.hpp Normal file
View File

@ -0,0 +1,70 @@
#pragma once
#include <type_traits>
namespace metaforce {
template <typename BitType>
class Flags {
public:
using MaskType = std::underlying_type_t<BitType>;
// constructors
constexpr Flags() noexcept : m_mask(0) {}
constexpr Flags(BitType bit) noexcept : m_mask(static_cast<MaskType>(bit)) {}
constexpr Flags(Flags<BitType> const& rhs) noexcept : m_mask(rhs.m_mask) {}
constexpr explicit Flags(MaskType flags) noexcept : m_mask(flags) {}
[[nodiscard]] constexpr bool IsSet(Flags<BitType> const bit) const noexcept { return bool(*this & bit); }
// relational operators
bool operator==(Flags<BitType> const& rhs) const noexcept { return m_mask == rhs.m_mask; }
// logical operator
constexpr bool operator!() const noexcept { return !m_mask; }
// bitwise operators
constexpr Flags<BitType> operator&(Flags<BitType> const& rhs) const noexcept {
return Flags<BitType>(m_mask & rhs.m_mask);
}
constexpr Flags<BitType> operator|(Flags<BitType> const& rhs) const noexcept {
return Flags<BitType>(m_mask | rhs.m_mask);
}
constexpr Flags<BitType> operator^(Flags<BitType> const& rhs) const noexcept {
return Flags<BitType>(m_mask ^ rhs.m_mask);
}
// assignment operators
constexpr Flags<BitType>& operator=(Flags<BitType> const& rhs) noexcept {
m_mask = rhs.m_mask;
return *this;
}
constexpr Flags<BitType>& operator|=(Flags<BitType> const& rhs) noexcept {
m_mask |= rhs.m_mask;
return *this;
}
constexpr Flags<BitType>& operator&=(Flags<BitType> const& rhs) noexcept {
m_mask &= rhs.m_mask;
return *this;
}
constexpr Flags<BitType>& operator^=(Flags<BitType> const& rhs) noexcept {
m_mask ^= rhs.m_mask;
return *this;
}
// cast operators
explicit constexpr operator bool() const noexcept { return m_mask != 0; }
explicit constexpr operator MaskType() const noexcept { return m_mask; }
private:
MaskType m_mask;
};
} // namespace metaforce

View File

@ -55,7 +55,7 @@ void CCubeMaterial::SetCurrent(const CModelFlags& flags, const CCubeSurface& sur
materialDataCur += 8; materialDataCur += 8;
for (u32 i = 0; i < texCount; ++i) { for (u32 i = 0; i < texCount; ++i) {
u32 texIdx = SBig(*reinterpret_cast<const u32*>(materialDataCur)); u32 texIdx = SBig(*reinterpret_cast<const u32*>(materialDataCur));
model.GetTexture(texIdx)->Load(static_cast<GX::TexMapID>(i), EClampMode::Repeat); model.GetTexture(texIdx)->Load(static_cast<GXTexMapID>(i), EClampMode::Repeat);
materialDataCur += 4; materialDataCur += 4;
} }
} }
@ -83,14 +83,14 @@ void CCubeMaterial::SetCurrent(const CModelFlags& flags, const CCubeSurface& sur
for (u32 i = 0; i < konstCount; ++i) { for (u32 i = 0; i < konstCount; ++i) {
u32 kColor = SBig(*reinterpret_cast<const u32*>(materialDataCur)); u32 kColor = SBig(*reinterpret_cast<const u32*>(materialDataCur));
materialDataCur += 4; materialDataCur += 4;
CGX::SetTevKColor(static_cast<GX::TevKColorID>(i), kColor); CGX::SetTevKColor(static_cast<GXTevKColorID>(i), kColor);
} }
} }
u32 blendFactors = SBig(*reinterpret_cast<const u32*>(materialDataCur)); u32 blendFactors = SBig(*reinterpret_cast<const u32*>(materialDataCur));
materialDataCur += 4; materialDataCur += 4;
if (g_Renderer->IsInAreaDraw()) { if (g_Renderer->IsInAreaDraw()) {
CGX::SetBlendMode(GX::BM_BLEND, GX::BL_ONE, GX::BL_ONE, GX::LO_CLEAR); CGX::SetBlendMode(GX_BM_BLEND, GX_BL_ONE, GX_BL_ONE, GX_LO_CLEAR);
} else { } else {
SetupBlendMode(blendFactors, flags, matFlags.IsSet(CCubeMaterialFlagBits::fAlphaTest)); SetupBlendMode(blendFactors, flags, matFlags.IsSet(CCubeMaterialFlagBits::fAlphaTest));
} }
@ -129,12 +129,12 @@ void CCubeMaterial::SetCurrent(const CModelFlags& flags, const CCubeSurface& sur
finalTevCount = firstTev + 1; finalTevCount = firstTev + 1;
u32 ccFlags = SBig(*reinterpret_cast<const u32*>(materialDataCur + 8)); u32 ccFlags = SBig(*reinterpret_cast<const u32*>(materialDataCur + 8));
finalCCFlags = ccFlags; finalCCFlags = ccFlags;
auto outputReg = static_cast<GX::TevRegID>(ccFlags >> 9 & 0x3); auto outputReg = static_cast<GXTevRegID>(ccFlags >> 9 & 0x3);
if (outputReg == GX::TEVREG0) { if (outputReg == GX_TEVREG0) {
materialDataCur += 20; materialDataCur += 20;
texMapTexCoordFlags += 1; texMapTexCoordFlags += 1;
finalCCFlags = SBig(*reinterpret_cast<const u32*>(materialDataCur + 8)); finalCCFlags = SBig(*reinterpret_cast<const u32*>(materialDataCur + 8));
GXSetTevColor(GX::TEVREG0, 0xc0c0c0c0); GXSetTevColor(GX_TEVREG0, GXColor{0xc0, 0xc0, 0xc0, 0xc0});
} }
finalACFlags = SBig(*reinterpret_cast<const u32*>(materialDataCur + 12)); finalACFlags = SBig(*reinterpret_cast<const u32*>(materialDataCur + 12));
HandleTev(firstTev, reinterpret_cast<const u32*>(materialDataCur), texMapTexCoordFlags, HandleTev(firstTev, reinterpret_cast<const u32*>(materialDataCur), texMapTexCoordFlags,
@ -148,8 +148,8 @@ void CCubeMaterial::SetCurrent(const CModelFlags& flags, const CCubeSurface& sur
u32 ccFlags = SBig(*reinterpret_cast<const u32*>(materialDataCur + 8)); u32 ccFlags = SBig(*reinterpret_cast<const u32*>(materialDataCur + 8));
finalCCFlags = ccFlags; finalCCFlags = ccFlags;
finalACFlags = SBig(*reinterpret_cast<const u32*>(materialDataCur + 12)); finalACFlags = SBig(*reinterpret_cast<const u32*>(materialDataCur + 12));
auto outputReg = static_cast<GX::TevRegID>(ccFlags >> 9 & 0x3); auto outputReg = static_cast<GXTevRegID>(ccFlags >> 9 & 0x3);
if (outputReg == GX::TEVREG2) { if (outputReg == GX_TEVREG2) {
usesTevReg2 = true; usesTevReg2 = true;
} }
materialDataCur += 20; materialDataCur += 20;
@ -162,13 +162,13 @@ void CCubeMaterial::SetCurrent(const CModelFlags& flags, const CCubeSurface& sur
u32 fullTcgCount = SBig(*tcgs); u32 fullTcgCount = SBig(*tcgs);
tcgCount = std::min(fullTcgCount, 2u); tcgCount = std::min(fullTcgCount, 2u);
for (u32 i = 0; i < tcgCount; ++i) { for (u32 i = 0; i < tcgCount; ++i) {
CGX::SetTexCoordGen(GX::TexCoordID(i), SBig(tcgs[i + 1])); CGX::SetTexCoordGen(GXTexCoordID(i), SBig(tcgs[i + 1]));
} }
tcgs += fullTcgCount + 1; tcgs += fullTcgCount + 1;
} else { } else {
tcgCount = SBig(*tcgs); tcgCount = SBig(*tcgs);
for (u32 i = 0; i < tcgCount; ++i) { for (u32 i = 0; i < tcgCount; ++i) {
CGX::SetTexCoordGen(GX::TexCoordID(i), SBig(tcgs[i + 1])); CGX::SetTexCoordGen(GXTexCoordID(i), SBig(tcgs[i + 1]));
} }
tcgs += tcgCount + 1; tcgs += tcgCount + 1;
} }
@ -176,10 +176,10 @@ void CCubeMaterial::SetCurrent(const CModelFlags& flags, const CCubeSurface& sur
const u32* uvAnim = tcgs; const u32* uvAnim = tcgs;
u32 animCount = SBig(uvAnim[1]); u32 animCount = SBig(uvAnim[1]);
uvAnim += 2; uvAnim += 2;
u32 texMtx = GX::TEXMTX0; u32 texMtx = GX_TEXMTX0;
u32 pttTexMtx = GX::PTTEXMTX0; u32 pttTexMtx = GX_PTTEXMTX0;
for (u32 i = 0; i < animCount; ++i) { for (u32 i = 0; i < animCount; ++i) {
u32 size = HandleAnimatedUV(uvAnim, static_cast<GX::TexMtx>(texMtx), static_cast<GX::PTTexMtx>(pttTexMtx)); u32 size = HandleAnimatedUV(uvAnim, static_cast<GXTexMtx>(texMtx), static_cast<GXPTTexMtx>(pttTexMtx));
if (size == 0) if (size == 0)
break; break;
uvAnim += size; uvAnim += size;
@ -228,17 +228,17 @@ void CCubeMaterial::SetCurrentBlack() {
const auto flags = GetFlags(); const auto flags = GetFlags();
const auto vatFlags = GetVatFlags(); const auto vatFlags = GetVatFlags();
if (flags.IsSet(CCubeMaterialFlagBits::fDepthSorting) || flags.IsSet(CCubeMaterialFlagBits::fAlphaTest)) { if (flags.IsSet(CCubeMaterialFlagBits::fDepthSorting) || flags.IsSet(CCubeMaterialFlagBits::fAlphaTest)) {
CGX::SetBlendMode(GX::BM_BLEND, GX::BL_ZERO, GX::BL_ONE, GX::LO_CLEAR); CGX::SetBlendMode(GX_BM_BLEND, GX_BL_ZERO, GX_BL_ONE, GX_LO_CLEAR);
} else { } else {
CGX::SetBlendMode(GX::BM_BLEND, GX::BL_ONE, GX::BL_ZERO, GX::LO_CLEAR); CGX::SetBlendMode(GX_BM_BLEND, GX_BL_ONE, GX_BL_ZERO, GX_LO_CLEAR);
} }
CGX::SetVtxDescv_Compressed(vatFlags); CGX::SetVtxDescv_Compressed(vatFlags);
CGX::SetTevColorIn(GX::TEVSTAGE0, GX::CC_ZERO, GX::CC_ZERO, GX::CC_ZERO, GX::CC_ZERO /* ? CC_ONE */); CGX::SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO /* ? CC_ONE */);
CGX::SetTevAlphaIn(GX::TEVSTAGE0, GX::CA_ZERO, GX::CA_ZERO, GX::CA_ZERO, GX::CA_ZERO /* ? CA_KONST */); CGX::SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO /* ? CA_KONST */);
CGX::SetTevKAlphaSel(GX::TEVSTAGE0, GX::TEV_KASEL_1); CGX::SetTevKAlphaSel(GX_TEVSTAGE0, GX_TEV_KASEL_1);
CGX::SetTexCoordGen(GX::TEXCOORD0, GX::TG_MTX2x4, GX::TG_POS, GX::IDENTITY, false, GX::PTIDENTITY); CGX::SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_POS, GX_IDENTITY, false, GX_PTIDENTITY);
CGX::SetStandardTevColorAlphaOp(GX::TEVSTAGE0); CGX::SetStandardTevColorAlphaOp(GX_TEVSTAGE0);
CGX::SetTevOrder(GX::TEVSTAGE0, GX::TEXCOORD_NULL, GX::TEXMAP_NULL, GX::COLOR_NULL); CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR_NULL);
CGX::SetNumTevStages(1); CGX::SetNumTevStages(1);
CGX::SetNumChans(0); CGX::SetNumChans(0);
CGX::SetNumTexGens(1); CGX::SetNumTexGens(1);
@ -246,35 +246,35 @@ void CCubeMaterial::SetCurrentBlack() {
} }
void CCubeMaterial::SetupBlendMode(u32 blendFactors, const CModelFlags& flags, bool alphaTest) { void CCubeMaterial::SetupBlendMode(u32 blendFactors, const CModelFlags& flags, bool alphaTest) {
auto newSrcFactor = static_cast<GX::BlendFactor>(blendFactors & 0xffff); auto newSrcFactor = static_cast<GXBlendFactor>(blendFactors & 0xffff);
auto newDstFactor = static_cast<GX::BlendFactor>(blendFactors >> 16 & 0xffff); auto newDstFactor = static_cast<GXBlendFactor>(blendFactors >> 16 & 0xffff);
if (alphaTest) { if (alphaTest) {
// discard fragments with alpha < 0.25 // discard fragments with alpha < 0.25
CGX::SetAlphaCompare(GX::GEQUAL, 64, GX::AOP_OR, GX::NEVER, 0); CGX::SetAlphaCompare(GX_GEQUAL, 64, GX_AOP_OR, GX_NEVER, 0);
newSrcFactor = GX::BL_ONE; newSrcFactor = GX_BL_ONE;
newDstFactor = GX::BL_ZERO; newDstFactor = GX_BL_ZERO;
} else { } else {
CGX::SetAlphaCompare(GX::ALWAYS, 0, GX::AOP_OR, GX::ALWAYS, 0); CGX::SetAlphaCompare(GX_ALWAYS, 0, GX_AOP_OR, GX_ALWAYS, 0);
} }
if (flags.x0_blendMode > 4 && newSrcFactor == GX::BL_ONE) { if (flags.x0_blendMode > 4 && newSrcFactor == GX_BL_ONE) {
newSrcFactor = GX::BL_SRCALPHA; newSrcFactor = GX_BL_SRCALPHA;
if (newDstFactor == GX::BL_ZERO) { if (newDstFactor == GX_BL_ZERO) {
newDstFactor = flags.x0_blendMode > 6 ? GX::BL_ONE : GX::BL_INVSRCALPHA; newDstFactor = flags.x0_blendMode > 6 ? GX_BL_ONE : GX_BL_INVSRCALPHA;
} }
} }
CGX::SetBlendMode(GX::BM_BLEND, newSrcFactor, newDstFactor, GX::LO_CLEAR); CGX::SetBlendMode(GX_BM_BLEND, newSrcFactor, newDstFactor, GX_LO_CLEAR);
} }
void CCubeMaterial::HandleDepth(CModelFlagsFlags modelFlags, CCubeMaterialFlags matFlags) { void CCubeMaterial::HandleDepth(CModelFlagsFlags modelFlags, CCubeMaterialFlags matFlags) {
GX::Compare func = GX::NEVER; GXCompare func = GX_NEVER;
if (!(modelFlags & CModelFlagBits::DepthTest)) { if (!(modelFlags & CModelFlagBits::DepthTest)) {
func = GX::ALWAYS; func = GX_ALWAYS;
} else if (modelFlags & CModelFlagBits::DepthGreater) { } else if (modelFlags & CModelFlagBits::DepthGreater) {
func = modelFlags & CModelFlagBits::DepthNonInclusive ? GX::GREATER : GX::GEQUAL; func = modelFlags & CModelFlagBits::DepthNonInclusive ? GX_GREATER : GX_GEQUAL;
} else { } else {
func = modelFlags & CModelFlagBits::DepthNonInclusive ? GX::LESS : GX::LEQUAL; func = modelFlags & CModelFlagBits::DepthNonInclusive ? GX_LESS : GX_LEQUAL;
} }
bool depthWrite = modelFlags & CModelFlagBits::DepthUpdate && matFlags & CCubeMaterialFlagBits::fDepthWrite; bool depthWrite = modelFlags & CModelFlagBits::DepthUpdate && matFlags & CCubeMaterialFlagBits::fDepthWrite;
CGX::SetZMode(true, func, depthWrite); CGX::SetZMode(true, func, depthWrite);
@ -309,14 +309,14 @@ void CCubeMaterial::EnsureViewDepStateCached(const CCubeSurface* surface) {
u32 CCubeMaterial::HandleColorChannels(u32 chanCount, u32 firstChan) { u32 CCubeMaterial::HandleColorChannels(u32 chanCount, u32 firstChan) {
if (CCubeModel::sRenderModelShadow) { if (CCubeModel::sRenderModelShadow) {
if (chanCount != 0) { if (chanCount != 0) {
CGX::SetChanAmbColor(CGX::EChannelId::Channel1, zeus::skBlack); CGX::SetChanAmbColor(CGX::EChannelId::Channel1, GX_BLACK);
CGX::SetChanMatColor(CGX::EChannelId::Channel1, zeus::skWhite); CGX::SetChanMatColor(CGX::EChannelId::Channel1, GX_WHITE);
auto chan0Lights = CGraphics::g_LightActive & ~CCubeModel::sChannel0DisableLightMask; auto chan0Lights = CGraphics::g_LightActive & ~CCubeModel::sChannel0DisableLightMask;
CGX::SetChanCtrl(CGX::EChannelId::Channel0, firstChan, chan0Lights); CGX::SetChanCtrl(CGX::EChannelId::Channel0, firstChan, chan0Lights);
CGX::SetChanCtrl(CGX::EChannelId::Channel1, CCubeModel::sChannel1EnableLightMask); CGX::SetChanCtrl(CGX::EChannelId::Channel1, CCubeModel::sChannel1EnableLightMask);
if (chan0Lights.any()) { if (chan0Lights.any()) {
CGX::SetChanMatColor(CGX::EChannelId::Channel0, zeus::skWhite); CGX::SetChanMatColor(CGX::EChannelId::Channel0, GX_WHITE);
} else { } else {
CGX::SetChanMatColor(CGX::EChannelId::Channel0, CGX::GetChanAmbColor(CGX::EChannelId::Channel0)); CGX::SetChanMatColor(CGX::EChannelId::Channel0, CGX::GetChanAmbColor(CGX::EChannelId::Channel0));
} }
@ -325,8 +325,8 @@ u32 CCubeMaterial::HandleColorChannels(u32 chanCount, u32 firstChan) {
} }
if (chanCount == 2) { if (chanCount == 2) {
CGX::SetChanAmbColor(CGX::EChannelId::Channel1, zeus::skBlack); CGX::SetChanAmbColor(CGX::EChannelId::Channel1, GX_BLACK);
CGX::SetChanMatColor(CGX::EChannelId::Channel1, zeus::skWhite); CGX::SetChanMatColor(CGX::EChannelId::Channel1, GX_WHITE);
} else { } else {
CGX::SetChanCtrl(CGX::EChannelId::Channel1, {}); CGX::SetChanCtrl(CGX::EChannelId::Channel1, {});
} }
@ -336,7 +336,7 @@ u32 CCubeMaterial::HandleColorChannels(u32 chanCount, u32 firstChan) {
} else { } else {
CGX::SetChanCtrl(CGX::EChannelId::Channel0, firstChan, CGraphics::g_LightActive); CGX::SetChanCtrl(CGX::EChannelId::Channel0, firstChan, CGraphics::g_LightActive);
if (CGraphics::g_LightActive.any()) { if (CGraphics::g_LightActive.any()) {
CGX::SetChanMatColor(CGX::EChannelId::Channel0, zeus::skWhite); CGX::SetChanMatColor(CGX::EChannelId::Channel0, GX_WHITE);
} else { } else {
CGX::SetChanMatColor(CGX::EChannelId::Channel0, CGX::GetChanAmbColor(CGX::EChannelId::Channel0)); CGX::SetChanMatColor(CGX::EChannelId::Channel0, CGX::GetChanAmbColor(CGX::EChannelId::Channel0));
} }
@ -352,15 +352,15 @@ void CCubeMaterial::HandleTev(u32 tevCur, const u32* materialDataCur, const u32*
const u32 colorOps = SBig(materialDataCur[2]); const u32 colorOps = SBig(materialDataCur[2]);
const u32 alphaOps = SBig(materialDataCur[3]); const u32 alphaOps = SBig(materialDataCur[3]);
const auto stage = static_cast<GX::TevStageID>(tevCur); const auto stage = static_cast<GXTevStageID>(tevCur);
CGX::SetStandardDirectTev_Compressed(stage, colorArgs, alphaArgs, colorOps, alphaOps); CGX::SetStandardDirectTev_Compressed(stage, colorArgs, alphaArgs, colorOps, alphaOps);
u32 tmtcFlags = SBig(*texMapTexCoordFlags); u32 tmtcFlags = SBig(*texMapTexCoordFlags);
u32 matFlags = SBig(materialDataCur[4]); u32 matFlags = SBig(materialDataCur[4]);
CGX::SetTevOrder(stage, static_cast<GX::TexCoordID>(tmtcFlags & 0xFF), CGX::SetTevOrder(stage, static_cast<GXTexCoordID>(tmtcFlags & 0xFF), static_cast<GXTexMapID>(tmtcFlags >> 8 & 0xFF),
static_cast<GX::TexMapID>(tmtcFlags >> 8 & 0xFF), static_cast<GX::ChannelID>(matFlags & 0xFF)); static_cast<GXChannelID>(matFlags & 0xFF));
CGX::SetTevKColorSel(stage, static_cast<GX::TevKColorSel>(matFlags >> 0x8 & 0xFF)); CGX::SetTevKColorSel(stage, static_cast<GXTevKColorSel>(matFlags >> 0x8 & 0xFF));
CGX::SetTevKAlphaSel(stage, static_cast<GX::TevKAlphaSel>(matFlags >> 0x10 & 0xFF)); CGX::SetTevKAlphaSel(stage, static_cast<GXTevKAlphaSel>(matFlags >> 0x10 & 0xFF));
} }
constexpr zeus::CTransform MvPostXf{ constexpr zeus::CTransform MvPostXf{
@ -368,21 +368,21 @@ constexpr zeus::CTransform MvPostXf{
{0.5f, 0.5f, 1.f}, {0.5f, 0.5f, 1.f},
}; };
u32 CCubeMaterial::HandleAnimatedUV(const u32* uvAnim, GX::TexMtx texMtx, GX::PTTexMtx pttTexMtx) { u32 CCubeMaterial::HandleAnimatedUV(const u32* uvAnim, GXTexMtx texMtx, GXPTTexMtx pttTexMtx) {
u32 type = SBig(*uvAnim); u32 type = SBig(*uvAnim);
const float* params = reinterpret_cast<const float*>(uvAnim + 1); const float* params = reinterpret_cast<const float*>(uvAnim + 1);
switch (type) { switch (type) {
case 0: { case 0: {
auto xf = CGraphics::g_ViewMatrix.inverse().multiplyIgnoreTranslation(CGraphics::g_GXModelMatrix); auto xf = CGraphics::g_ViewMatrix.inverse().multiplyIgnoreTranslation(CGraphics::g_GXModelMatrix);
xf.origin.zeroOut(); xf.origin.zeroOut();
GXLoadTexMtxImm(&xf, texMtx, GX::MTX3x4); GXLoadTexMtxImm(&xf, texMtx, GX_MTX3x4);
GXLoadTexMtxImm(&MvPostXf, pttTexMtx, GX::MTX3x4); GXLoadTexMtxImm(&MvPostXf, pttTexMtx, GX_MTX3x4);
return 1; return 1;
} }
case 1: { case 1: {
auto xf = CGraphics::g_ViewMatrix.inverse() * CGraphics::g_GXModelMatrix; auto xf = CGraphics::g_ViewMatrix.inverse() * CGraphics::g_GXModelMatrix;
GXLoadTexMtxImm(&xf, texMtx, GX::MTX3x4); GXLoadTexMtxImm(&xf, texMtx, GX_MTX3x4);
GXLoadTexMtxImm(&MvPostXf, pttTexMtx, GX::MTX3x4); GXLoadTexMtxImm(&MvPostXf, pttTexMtx, GX_MTX3x4);
return 1; return 1;
} }
case 2: { case 2: {
@ -392,7 +392,7 @@ u32 CCubeMaterial::HandleAnimatedUV(const u32* uvAnim, GX::TexMtx texMtx, GX::PT
const float f4 = SBig(params[3]); const float f4 = SBig(params[3]);
const float seconds = CGraphics::GetSecondsMod900(); const float seconds = CGraphics::GetSecondsMod900();
const auto xf = zeus::CTransform::Translate(seconds * f3 + f1, seconds * f4 + f2, 0.f); const auto xf = zeus::CTransform::Translate(seconds * f3 + f1, seconds * f4 + f2, 0.f);
GXLoadTexMtxImm(&xf, texMtx, GX::MTX3x4); GXLoadTexMtxImm(&xf, texMtx, GX_MTX3x4);
return 5; return 5;
} }
case 3: { case 3: {
@ -406,7 +406,7 @@ u32 CCubeMaterial::HandleAnimatedUV(const u32* uvAnim, GX::TexMtx texMtx, GX::PT
xf.basis[1][1] = acos; xf.basis[1][1] = acos;
xf.origin[0] = (1.f - (acos - asin)) * 0.5f; xf.origin[0] = (1.f - (acos - asin)) * 0.5f;
xf.origin[1] = (1.f - (asin + acos)) * 0.5f; xf.origin[1] = (1.f - (asin + acos)) * 0.5f;
GXLoadTexMtxImm(&xf, texMtx, GX::MTX3x4); GXLoadTexMtxImm(&xf, texMtx, GX_MTX3x4);
return 3; return 3;
} }
case 4: case 4:
@ -420,7 +420,7 @@ u32 CCubeMaterial::HandleAnimatedUV(const u32* uvAnim, GX::TexMtx texMtx, GX::PT
xf.origin.x() = 0.f; xf.origin.x() = 0.f;
xf.origin.y() = std::trunc(SBig(params[1]) * std::fmod(value, 1.f)) * SBig(params[2]); xf.origin.y() = std::trunc(SBig(params[1]) * std::fmod(value, 1.f)) * SBig(params[2]);
} }
GXLoadTexMtxImm(&xf, texMtx, GX::MTX3x4); GXLoadTexMtxImm(&xf, texMtx, GX_MTX3x4);
return 5; return 5;
} }
case 6: { case 6: {
@ -437,8 +437,8 @@ u32 CCubeMaterial::HandleAnimatedUV(const u32* uvAnim, GX::TexMtx texMtx, GX::PT
1.f, 1.f,
}, },
}; };
GXLoadTexMtxImm(&mtx, texMtx, GX::MTX3x4); GXLoadTexMtxImm(&mtx, texMtx, GX_MTX3x4);
GXLoadTexMtxImm(&postMtx, pttTexMtx, GX::MTX3x4); GXLoadTexMtxImm(&postMtx, pttTexMtx, GX_MTX3x4);
return 1; return 1;
} }
case 7: { case 7: {
@ -457,8 +457,8 @@ u32 CCubeMaterial::HandleAnimatedUV(const u32* uvAnim, GX::TexMtx texMtx, GX::PT
}, },
zeus::CVector3f{xy, z, 1.f}, zeus::CVector3f{xy, z, 1.f},
}; };
GXLoadTexMtxImm(&mtx, texMtx, GX::MTX3x4); GXLoadTexMtxImm(&mtx, texMtx, GX_MTX3x4);
GXLoadTexMtxImm(&postMtx, pttTexMtx, GX::MTX3x4); GXLoadTexMtxImm(&postMtx, pttTexMtx, GX_MTX3x4);
return 3; return 3;
} }
default: default:
@ -476,38 +476,38 @@ void CCubeMaterial::HandleTransparency(u32& finalTevCount, u32& finalKColorCount
} }
if (modelFlags.x0_blendMode == 3) { if (modelFlags.x0_blendMode == 3) {
// Stage outputting splatted KAlpha as color to reg0 // Stage outputting splatted KAlpha as color to reg0
auto stage = static_cast<GX::TevStageID>(finalTevCount); auto stage = static_cast<GXTevStageID>(finalTevCount);
CGX::SetTevColorIn(stage, GX::CC_ZERO, GX::CC_ZERO, GX::CC_ZERO, GX::CC_KONST); CGX::SetTevColorIn(stage, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_KONST);
CGX::SetTevAlphaIn(stage, GX::CA_ZERO, GX::CA_ZERO, GX::CA_ZERO, GX::CA_APREV); CGX::SetTevAlphaIn(stage, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_APREV);
CGX::SetTevColorOp(stage, GX::TEV_ADD, GX::TB_ZERO, GX::CS_SCALE_1, true, GX::TEVREG0); CGX::SetTevColorOp(stage, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVREG0);
CGX::SetTevKColorSel(stage, static_cast<GX::TevKColorSel>(finalKColorCount + GX::TEV_KCSEL_K0_A)); CGX::SetTevKColorSel(stage, static_cast<GXTevKColorSel>(finalKColorCount + GX_TEV_KCSEL_K0_A));
CGX::SetTevAlphaOp(stage, GX::TEV_ADD, GX::TB_ZERO, GX::CS_SCALE_1, true, GX::TEVPREV); CGX::SetTevAlphaOp(stage, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV);
CGX::SetTevOrder(stage, GX::TEXCOORD_NULL, GX::TEXMAP_NULL, GX::COLOR_NULL); CGX::SetTevOrder(stage, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR_NULL);
CGX::SetTevDirect(stage); CGX::SetTevDirect(stage);
// Stage interpolating from splatted KAlpha using KColor // Stage interpolating from splatted KAlpha using KColor
stage = static_cast<GX::TevStageID>(stage + 1); stage = static_cast<GXTevStageID>(stage + 1);
CGX::SetTevColorIn(stage, GX::CC_CPREV, GX::CC_C0, GX::CC_KONST, GX::CC_ZERO); CGX::SetTevColorIn(stage, GX_CC_CPREV, GX_CC_C0, GX_CC_KONST, GX_CC_ZERO);
CGX::SetTevAlphaIn(stage, GX::CA_ZERO, GX::CA_ZERO, GX::CA_ZERO, GX::CA_APREV); CGX::SetTevAlphaIn(stage, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_APREV);
CGX::SetTevKColorSel(stage, static_cast<GX::TevKColorSel>(finalKColorCount + GX::TEV_KCSEL_K0)); CGX::SetTevKColorSel(stage, static_cast<GXTevKColorSel>(finalKColorCount + GX_TEV_KCSEL_K0));
CGX::SetStandardTevColorAlphaOp(stage); CGX::SetStandardTevColorAlphaOp(stage);
CGX::SetTevDirect(stage); CGX::SetTevDirect(stage);
CGX::SetTevOrder(stage, GX::TEXCOORD_NULL, GX::TEXMAP_NULL, GX::COLOR_NULL); CGX::SetTevOrder(stage, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR_NULL);
CGX::SetTevKColor(static_cast<GX::TevKColorID>(finalKColorCount), modelFlags.x4_color); CGX::SetTevKColor(static_cast<GXTevKColorID>(finalKColorCount), modelFlags.x4_color);
finalKColorCount += 1; finalKColorCount += 1;
finalTevCount += 2; finalTevCount += 2;
} else { } else {
auto stage = static_cast<GX::TevStageID>(finalTevCount); auto stage = static_cast<GXTevStageID>(finalTevCount);
if (modelFlags.x0_blendMode == 8) { if (modelFlags.x0_blendMode == 8) {
CGX::SetTevAlphaIn(stage, GX::CA_ZERO, GX::CA_ZERO, GX::CA_ZERO, GX::CA_KONST); // Set KAlpha CGX::SetTevAlphaIn(stage, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_KONST); // Set KAlpha
} else { } else {
CGX::SetTevAlphaIn(stage, GX::CA_ZERO, GX::CA_KONST, GX::CA_APREV, GX::CA_ZERO); // Mul KAlpha CGX::SetTevAlphaIn(stage, GX_CA_ZERO, GX_CA_KONST, GX_CA_APREV, GX_CA_ZERO); // Mul KAlpha
} }
if (modelFlags.x0_blendMode == 2) { if (modelFlags.x0_blendMode == 2) {
CGX::SetTevColorIn(stage, GX::CC_ZERO, GX::CC_ONE, GX::CC_CPREV, GX::CC_KONST); // Add KColor CGX::SetTevColorIn(stage, GX_CC_ZERO, GX_CC_ONE, GX_CC_CPREV, GX_CC_KONST); // Add KColor
} else { } else {
CGX::SetTevColorIn(stage, GX::CC_ZERO, GX::CC_KONST, GX::CC_CPREV, GX::CC_ZERO); // Mul KColor CGX::SetTevColorIn(stage, GX_CC_ZERO, GX_CC_KONST, GX_CC_CPREV, GX_CC_ZERO); // Mul KColor
} }
CGX::SetStandardTevColorAlphaOp(stage); CGX::SetStandardTevColorAlphaOp(stage);
@ -515,10 +515,10 @@ void CCubeMaterial::HandleTransparency(u32& finalTevCount, u32& finalKColorCount
finalACFlags = 0x100; finalACFlags = 0x100;
CGX::SetTevDirect(stage); CGX::SetTevDirect(stage);
CGX::SetTevOrder(stage, GX::TEXCOORD_NULL, GX::TEXMAP_NULL, GX::COLOR_NULL); CGX::SetTevOrder(stage, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR_NULL);
CGX::SetTevKColor(static_cast<GX::TevKColorID>(finalKColorCount), modelFlags.x4_color); CGX::SetTevKColor(static_cast<GXTevKColorID>(finalKColorCount), modelFlags.x4_color);
CGX::SetTevKColorSel(stage, static_cast<GX::TevKColorSel>(finalKColorCount + GX::TEV_KCSEL_K0)); CGX::SetTevKColorSel(stage, static_cast<GXTevKColorSel>(finalKColorCount + GX_TEV_KCSEL_K0));
CGX::SetTevKAlphaSel(stage, static_cast<GX::TevKAlphaSel>(finalKColorCount + GX::TEV_KASEL_K0_A)); CGX::SetTevKAlphaSel(stage, static_cast<GXTevKAlphaSel>(finalKColorCount + GX_TEV_KASEL_K0_A));
finalTevCount += 1; finalTevCount += 1;
finalKColorCount += 1; finalKColorCount += 1;
@ -528,22 +528,22 @@ void CCubeMaterial::HandleTransparency(u32& finalTevCount, u32& finalKColorCount
u32 CCubeMaterial::HandleReflection(bool usesTevReg2, u32 indTexSlot, u32 r5, u32 finalTevCount, u32 texCount, u32 CCubeMaterial::HandleReflection(bool usesTevReg2, u32 indTexSlot, u32 r5, u32 finalTevCount, u32 texCount,
u32 tcgCount, u32 finalKColorCount, u32& finalCCFlags, u32& finalACFlags) { u32 tcgCount, u32 finalKColorCount, u32& finalCCFlags, u32& finalACFlags) {
u32 out = 0; u32 out = 0;
GX::TevColorArg colorArg = GX::CC_KONST; GXTevColorArg colorArg = GX_CC_KONST;
if (usesTevReg2) { if (usesTevReg2) {
colorArg = GX::CC_C2; colorArg = GX_CC_C2;
const auto stage = static_cast<GX::TevStageID>(finalTevCount); const auto stage = static_cast<GXTevStageID>(finalTevCount);
CGX::SetTevColorIn(stage, GX::CC_ZERO, GX::CC_C2, GX::CC_KONST, GX::CC_ZERO); CGX::SetTevColorIn(stage, GX_CC_ZERO, GX_CC_C2, GX_CC_KONST, GX_CC_ZERO);
CGX::SetTevAlphaIn(stage, GX::CA_ZERO, GX::CA_ZERO, GX::CA_ZERO, GX::CA_A2); CGX::SetTevAlphaIn(stage, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_A2);
CGX::SetTevColorOp(stage, GX::TEV_ADD, GX::TB_ZERO, GX::CS_SCALE_1, true, GX::TEVREG2); CGX::SetTevColorOp(stage, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVREG2);
CGX::SetTevAlphaOp(stage, GX::TEV_ADD, GX::TB_ZERO, GX::CS_SCALE_1, true, GX::TEVREG2); CGX::SetTevAlphaOp(stage, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVREG2);
CGX::SetTevOrder(stage, GX::TEXCOORD_NULL, GX::TEXMAP_NULL, GX::COLOR_ZERO); CGX::SetTevOrder(stage, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR_ZERO);
out = 1; out = 1;
} }
CGX::SetTevKColor(static_cast<GX::TevKColorID>(finalKColorCount), zeus::CColor{sReflectionAlpha, sReflectionAlpha}); CGX::SetTevKColor(static_cast<GXTevKColorID>(finalKColorCount), zeus::CColor{sReflectionAlpha, sReflectionAlpha});
CGX::SetTevKColorSel(static_cast<GX::TevStageID>(finalTevCount), CGX::SetTevKColorSel(static_cast<GXTevStageID>(finalTevCount),
static_cast<GX::TevKColorSel>(GX::TEV_KCSEL_K0 + finalKColorCount)); static_cast<GXTevKColorSel>(GX_TEV_KCSEL_K0 + finalKColorCount));
const auto stage = static_cast<GX::TevStageID>(finalTevCount + out); const auto stage = static_cast<GXTevStageID>(finalTevCount + out);
// tex = g_Renderer->GetRealReflection // tex = g_Renderer->GetRealReflection
// tex.Load(texCount, 0) // tex.Load(texCount, 0)
@ -558,10 +558,10 @@ u32 CCubeMaterial::HandleReflection(bool usesTevReg2, u32 indTexSlot, u32 r5, u3
} }
void CCubeMaterial::DoPassthru(u32 finalTevCount) { void CCubeMaterial::DoPassthru(u32 finalTevCount) {
const auto stage = static_cast<GX::TevStageID>(finalTevCount); const auto stage = static_cast<GXTevStageID>(finalTevCount);
CGX::SetTevColorIn(stage, GX::CC_ZERO, GX::CC_ZERO, GX::CC_ZERO, GX::CC_CPREV); CGX::SetTevColorIn(stage, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_CPREV);
CGX::SetTevAlphaIn(stage, GX::CA_ZERO, GX::CA_ZERO, GX::CA_ZERO, GX::CA_APREV); CGX::SetTevAlphaIn(stage, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_APREV);
CGX::SetTevOrder(stage, GX::TEXCOORD_NULL, GX::TEXMAP_NULL, GX::COLOR_NULL); CGX::SetTevOrder(stage, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR_NULL);
CGX::SetTevDirect(stage); CGX::SetTevDirect(stage);
CGX::SetStandardTevColorAlphaOp(stage); CGX::SetStandardTevColorAlphaOp(stage);
} }
@ -571,14 +571,14 @@ void CCubeMaterial::DoModelShadow(u32 texCount, u32 tcgCount) {
// TODO // TODO
} }
static GX::TevStageID sCurrentTevStage = GX::NULL_STAGE; static GXTevStageID sCurrentTevStage = GX_MAX_TEVSTAGE;
void CCubeMaterial::EnsureTevsDirect() { void CCubeMaterial::EnsureTevsDirect() {
if (sCurrentTevStage == GX::NULL_STAGE) { if (sCurrentTevStage == GX_MAX_TEVSTAGE) {
return; return;
} }
CGX::SetNumIndStages(0); CGX::SetNumIndStages(0);
CGX::SetTevDirect(sCurrentTevStage); CGX::SetTevDirect(sCurrentTevStage);
sCurrentTevStage = GX::NULL_STAGE; sCurrentTevStage = GX_MAX_TEVSTAGE;
} }
} // namespace metaforce } // namespace metaforce

View File

@ -64,7 +64,7 @@ private:
static void HandleDepth(CModelFlagsFlags modelFlags, CCubeMaterialFlags matFlags); static void HandleDepth(CModelFlagsFlags modelFlags, CCubeMaterialFlags matFlags);
static u32 HandleColorChannels(u32 chanCount, u32 firstChan); static u32 HandleColorChannels(u32 chanCount, u32 firstChan);
static void HandleTev(u32 tevCur, const u32* materialDataCur, const u32* texMapTexCoordFlags, bool shadowMapsEnabled); static void HandleTev(u32 tevCur, const u32* materialDataCur, const u32* texMapTexCoordFlags, bool shadowMapsEnabled);
static u32 HandleAnimatedUV(const u32* uvAnim, GX::TexMtx texMtx, GX::PTTexMtx pttTexMtx); static u32 HandleAnimatedUV(const u32* uvAnim, GXTexMtx texMtx, GXPTTexMtx pttTexMtx);
static void HandleTransparency(u32& finalTevCount, u32& finalKColorCount, const CModelFlags& modelFlags, static void HandleTransparency(u32& finalTevCount, u32& finalKColorCount, const CModelFlags& modelFlags,
u32 blendFactors, u32& finalCCFlags, u32& finalACFlags); u32 blendFactors, u32& finalCCFlags, u32& finalACFlags);
static u32 HandleReflection(bool usesTevReg2, u32 indTexSlot, u32 r5, u32 finalTevCount, u32 texCount, u32 tcgCount, static u32 HandleReflection(bool usesTevReg2, u32 indTexSlot, u32 r5, u32 finalTevCount, u32 texCount, u32 tcgCount,

View File

@ -177,12 +177,12 @@ void CCubeModel::DrawNormal(TConstVectorRef positions, TConstVectorRef normals,
CGX::SetNumIndStages(0); CGX::SetNumIndStages(0);
CGX::SetNumTevStages(1); CGX::SetNumTevStages(1);
CGX::SetNumTexGens(1); // TODO should this be 0? CGX::SetNumTexGens(1); // TODO should this be 0?
CGX::SetZMode(true, GX::LEQUAL, true); CGX::SetZMode(true, GX_LEQUAL, true);
CGX::SetTevOrder(GX::TEVSTAGE0, GX::TEXCOORD_NULL, GX::TEXMAP_NULL, GX::COLOR_NULL); CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR_NULL);
CGX::SetTevColorIn(GX::TEVSTAGE0, GX::CC_ZERO, GX::CC_ZERO, GX::CC_ZERO, GX::CC_ZERO); CGX::SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO);
CGX::SetTevAlphaIn(GX::TEVSTAGE0, GX::CA_ZERO, GX::CA_ZERO, GX::CA_ZERO, GX::CA_ZERO); CGX::SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO);
CGX::SetStandardTevColorAlphaOp(GX::TEVSTAGE0); CGX::SetStandardTevColorAlphaOp(GX_TEVSTAGE0);
CGX::SetBlendMode(GX::BM_BLEND, GX::BL_ZERO, GX::BL_ONE, GX::LO_CLEAR); CGX::SetBlendMode(GX_BM_BLEND, GX_BL_ZERO, GX_BL_ONE, GX_LO_CLEAR);
DrawFlat(positions, normals, surfaces); DrawFlat(positions, normals, surfaces);
} }
@ -259,8 +259,8 @@ void CCubeModel::EnableShadowMaps(const CTexture& shadowTex, const zeus::CTransf
void CCubeModel::DisableShadowMaps() { sRenderModelShadow = false; } void CCubeModel::DisableShadowMaps() { sRenderModelShadow = false; }
void CCubeModel::SetArraysCurrent() { void CCubeModel::SetArraysCurrent() {
CGX::SetArray(GX::VA_POS, x0_modelInstance.GetVertexPointer(), true); CGX::SetArray(GX_VA_POS, x0_modelInstance.GetVertexPointer(), true);
CGX::SetArray(GX::VA_NRM, x0_modelInstance.GetNormalPointer(), true); CGX::SetArray(GX_VA_NRM, x0_modelInstance.GetNormalPointer(), true);
SetStaticArraysCurrent(); SetStaticArraysCurrent();
} }
@ -280,8 +280,8 @@ void CCubeModel::SetRenderModelBlack(bool v) {
} }
void CCubeModel::SetSkinningArraysCurrent(TConstVectorRef positions, TConstVectorRef normals) { void CCubeModel::SetSkinningArraysCurrent(TConstVectorRef positions, TConstVectorRef normals) {
CGX::SetArray(GX::VA_POS, positions, false); CGX::SetArray(GX_VA_POS, positions, false);
CGX::SetArray(GX::VA_NRM, normals, false); CGX::SetArray(GX_VA_NRM, normals, false);
// colors unused // colors unused
SetStaticArraysCurrent(); SetStaticArraysCurrent();
} }
@ -294,22 +294,29 @@ void CCubeModel::SetStaticArraysCurrent() {
sUsingPackedLightmaps = false; sUsingPackedLightmaps = false;
} }
if (sUsingPackedLightmaps) { if (sUsingPackedLightmaps) {
CGX::SetArray(GX::VA_TEX0, packedTexCoords, true); CGX::SetArray(GX_VA_TEX0, packedTexCoords, true);
} else { } else {
CGX::SetArray(GX::VA_TEX0, texCoords, true); CGX::SetArray(GX_VA_TEX0, texCoords, true);
}
for (int i = GX_VA_TEX1; i <= GX_VA_TEX7; ++i) {
CGX::SetArray(static_cast<GXAttr>(i), texCoords, true);
} }
// TexCoord1 is currently used for all remaining
CGX::SetArray(GX::VA_TEX1, texCoords, true);
CCubeMaterial::KillCachedViewDepState(); CCubeMaterial::KillCachedViewDepState();
} }
void CCubeModel::SetUsingPackedLightmaps(bool v) { void CCubeModel::SetUsingPackedLightmaps(bool v) {
sUsingPackedLightmaps = v; sUsingPackedLightmaps = v;
if (v) { if (v) {
CGX::SetArray(GX::VA_TEX0, x0_modelInstance.GetPackedTCPointer(), true); CGX::SetArray(GX_VA_TEX0, x0_modelInstance.GetPackedTCPointer(), true);
} else { } else {
CGX::SetArray(GX::VA_TEX0, x0_modelInstance.GetTCPointer(), true); CGX::SetArray(GX_VA_TEX0, x0_modelInstance.GetTCPointer(), true);
} }
} }
template <>
aurora::Vec2<float> cinput_stream_helper(CInputStream& in) {
float x = in.ReadFloat();
float y = in.ReadFloat();
return {x, y};
}
} // namespace metaforce } // namespace metaforce

View File

@ -2,6 +2,7 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <aurora/math.hpp>
#include "CStopwatch.hpp" #include "CStopwatch.hpp"
#include "CToken.hpp" #include "CToken.hpp"
@ -138,4 +139,7 @@ private:
static GX::LightMask sChannel0DisableLightMask; static GX::LightMask sChannel0DisableLightMask;
static GX::LightMask sChannel1EnableLightMask; static GX::LightMask sChannel1EnableLightMask;
}; };
template <>
aurora::Vec2<float> cinput_stream_helper(CInputStream& in);
} // namespace metaforce } // namespace metaforce

View File

@ -16,6 +16,8 @@
#include "Runtime/Particle/CElementGen.hpp" #include "Runtime/Particle/CElementGen.hpp"
#include "Runtime/CDvdFile.hpp" #include "Runtime/CDvdFile.hpp"
#include <utility>
namespace metaforce { namespace metaforce {
static logvisor::Module Log("CCubeRenderer"); static logvisor::Module Log("CCubeRenderer");
@ -792,22 +794,22 @@ void CCubeRenderer::SetDebugOption(IRenderer::EDebugOption option, s32 value) {
void CCubeRenderer::BeginPrimitive(IRenderer::EPrimitiveType type, s32 nverts) { void CCubeRenderer::BeginPrimitive(IRenderer::EPrimitiveType type, s32 nverts) {
constexpr std::array vtxDescList{ constexpr std::array vtxDescList{
GX::VtxDescList{GX::VA_POS, GX::DIRECT}, GXVtxDescList{GX_VA_POS, GX_DIRECT},
GX::VtxDescList{GX::VA_NRM, GX::DIRECT}, GXVtxDescList{GX_VA_NRM, GX_DIRECT},
GX::VtxDescList{GX::VA_CLR0, GX::DIRECT}, GXVtxDescList{GX_VA_CLR0, GX_DIRECT},
GX::VtxDescList{}, GXVtxDescList{GX_VA_NULL, GX_NONE},
}; };
CGX::SetChanCtrl(CGX::EChannelId::Channel0, false, GX::SRC_REG, GX::SRC_VTX, {}, GX::DF_NONE, GX::AF_NONE); CGX::SetChanCtrl(CGX::EChannelId::Channel0, false, GX_SRC_REG, GX_SRC_VTX, {}, GX_DF_NONE, GX_AF_NONE);
CGX::SetNumChans(1); CGX::SetNumChans(1);
CGX::SetNumTexGens(0); CGX::SetNumTexGens(0);
CGX::SetNumTevStages(1); CGX::SetNumTevStages(1);
CGX::SetTevOrder(GX::TEVSTAGE0, GX::TEXCOORD_NULL, GX::TEXMAP_NULL, GX::COLOR0A0); CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0);
CGX::SetTevColorIn(GX::TEVSTAGE0, GX::CC_ZERO, GX::CC_ZERO, GX::CC_ZERO, GX::CC_RASC); CGX::SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_RASC);
CGX::SetTevAlphaIn(GX::TEVSTAGE0, GX::CA_ZERO, GX::CA_ZERO, GX::CA_ZERO, GX::CA_RASA); CGX::SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_RASA);
CGX::SetStandardTevColorAlphaOp(GX::TEVSTAGE0); CGX::SetStandardTevColorAlphaOp(GX_TEVSTAGE0);
x18_primVertCount = nverts; x18_primVertCount = nverts;
CGX::SetVtxDescv(vtxDescList.data()); CGX::SetVtxDescv(vtxDescList.data());
CGX::Begin(GX::Primitive(type), GX::VTXFMT0, nverts); CGX::Begin(GXPrimitive(type), GX_VTXFMT0, nverts);
} }
void CCubeRenderer::BeginLines(s32 nverts) { BeginPrimitive(EPrimitiveType::Lines, nverts); } void CCubeRenderer::BeginLines(s32 nverts) { BeginPrimitive(EPrimitiveType::Lines, nverts); }
@ -864,22 +866,22 @@ void CCubeRenderer::DrawThermalModel(CModel& model, const zeus::CColor& multCol,
void CCubeRenderer::DrawModelDisintegrate(CModel& model, CTexture& tex, const zeus::CColor& color, void CCubeRenderer::DrawModelDisintegrate(CModel& model, CTexture& tex, const zeus::CColor& color,
TConstVectorRef positions, TConstVectorRef normals, float t) { TConstVectorRef positions, TConstVectorRef normals, float t) {
tex.Load(GX::TEXMAP0, EClampMode::Clamp); tex.Load(GX_TEXMAP0, EClampMode::Clamp);
CGX::SetNumIndStages(0); CGX::SetNumIndStages(0);
CGX::SetNumTevStages(2); CGX::SetNumTevStages(2);
CGX::SetNumTexGens(2); CGX::SetNumTexGens(2);
CGX::SetNumChans(0); CGX::SetNumChans(0);
CGX::SetBlendMode(GX::BM_BLEND, GX::BL_SRCALPHA, GX::BL_INVSRCALPHA, GX::LO_CLEAR); CGX::SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
CGX::SetStandardTevColorAlphaOp(GX::TEVSTAGE0); CGX::SetStandardTevColorAlphaOp(GX_TEVSTAGE0);
CGX::SetStandardTevColorAlphaOp(GX::TEVSTAGE1); CGX::SetStandardTevColorAlphaOp(GX_TEVSTAGE1);
CGX::SetTevColorIn(GX::TEVSTAGE0, GX::CC_ZERO, GX::CC_ZERO, GX::CC_ZERO, GX::CC_TEXC); CGX::SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_TEXC);
CGX::SetTevAlphaIn(GX::TEVSTAGE0, GX::CA_ZERO, GX::CA_ZERO, GX::CA_ZERO, GX::CA_TEXA); CGX::SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_TEXA);
CGX::SetTevColorIn(GX::TEVSTAGE1, GX::CC_ZERO, GX::CC_TEXC, GX::CC_CPREV, GX::CC_KONST); CGX::SetTevColorIn(GX_TEVSTAGE1, GX_CC_ZERO, GX_CC_TEXC, GX_CC_CPREV, GX_CC_KONST);
CGX::SetTevAlphaIn(GX::TEVSTAGE1, GX::CA_ZERO, GX::CA_TEXA, GX::CA_APREV, GX::CA_ZERO); CGX::SetTevAlphaIn(GX_TEVSTAGE1, GX_CA_ZERO, GX_CA_TEXA, GX_CA_APREV, GX_CA_ZERO);
CGX::SetTevOrder(GX::TEVSTAGE0, GX::TEXCOORD0, GX::TEXMAP0, GX::COLOR_NULL); CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL);
CGX::SetTevOrder(GX::TEVSTAGE1, GX::TEXCOORD1, GX::TEXMAP0, GX::COLOR_NULL); CGX::SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD1, GX_TEXMAP0, GX_COLOR_NULL);
CGX::SetTevKColorSel(GX::TEVSTAGE1, GX::TEV_KCSEL_K0); CGX::SetTevKColorSel(GX_TEVSTAGE1, GX_TEV_KCSEL_K0);
CGX::SetTevKColor(GX::KCOLOR0, color); CGX::SetTevKColor(GX_KCOLOR0, color);
const auto bounds = model.GetInstance().GetBounds(); const auto bounds = model.GetInstance().GetBounds();
const auto rotation = zeus::CTransform::RotateX(zeus::degToRad(-45.f)); const auto rotation = zeus::CTransform::RotateX(zeus::degToRad(-45.f));
const auto transformedBounds = bounds.getTransformedAABox(rotation); const auto transformedBounds = bounds.getTransformedAABox(rotation);
@ -901,43 +903,43 @@ void CCubeRenderer::DrawModelDisintegrate(CModel& model, CTexture& tex, const ze
}, },
zeus::CVector3f{t, ptTex1.origin.y(), 1.f}, zeus::CVector3f{t, ptTex1.origin.y(), 1.f},
}; };
GXLoadTexMtxImm(&xf, GX::TEXMTX0, GX::MTX3x4); GXLoadTexMtxImm(&xf, GX_TEXMTX0, GX_MTX3x4);
GXLoadTexMtxImm(&ptTex0, GX::PTTEXMTX0, GX::MTX3x4); GXLoadTexMtxImm(&ptTex0, GX_PTTEXMTX0, GX_MTX3x4);
GXLoadTexMtxImm(&ptTex1, GX::PTTEXMTX1, GX::MTX3x4); GXLoadTexMtxImm(&ptTex1, GX_PTTEXMTX1, GX_MTX3x4);
CGX::SetTexCoordGen(GX::TEXCOORD0, GX::TG_MTX3x4, GX::TG_POS, GX::TEXMTX0, false, GX::PTTEXMTX0); CGX::SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX3x4, GX_TG_POS, GX_TEXMTX0, false, GX_PTTEXMTX0);
CGX::SetTexCoordGen(GX::TEXCOORD1, GX::TG_MTX3x4, GX::TG_POS, GX::TEXMTX0, false, GX::PTTEXMTX1); CGX::SetTexCoordGen(GX_TEXCOORD1, GX_TG_MTX3x4, GX_TG_POS, GX_TEXMTX0, false, GX_PTTEXMTX1);
CGX::SetAlphaCompare(GX::GREATER, 0, GX::AOP_AND, GX::ALWAYS, 0); CGX::SetAlphaCompare(GX_GREATER, 0, GX_AOP_AND, GX_ALWAYS, 0);
CGX::SetZMode(true, GX::LEQUAL, true); CGX::SetZMode(true, GX_LEQUAL, true);
model.UpdateLastFrame(); model.UpdateLastFrame();
model.GetInstance().DrawFlat(positions, normals, ESurfaceSelection::All); model.GetInstance().DrawFlat(positions, normals, ESurfaceSelection::All);
CGX::SetAlphaCompare(GX::ALWAYS, 0, GX::AOP_AND, GX::ALWAYS, 0); CGX::SetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_ALWAYS, 0);
} }
void CCubeRenderer::DrawModelFlat(CModel& model, const CModelFlags& flags, bool unsortedOnly, TConstVectorRef positions, void CCubeRenderer::DrawModelFlat(CModel& model, const CModelFlags& flags, bool unsortedOnly, TConstVectorRef positions,
TConstVectorRef normals) { TConstVectorRef normals) {
if (flags.x0_blendMode >= 7) { if (flags.x0_blendMode >= 7) {
CGX::SetBlendMode(GX::BM_BLEND, GX::BL_SRCALPHA, GX::BL_ONE, GX::LO_CLEAR); CGX::SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_ONE, GX_LO_CLEAR);
} else if (flags.x0_blendMode >= 5) { } else if (flags.x0_blendMode >= 5) {
CGX::SetBlendMode(GX::BM_BLEND, GX::BL_SRCALPHA, GX::BL_INVSRCALPHA, GX::LO_CLEAR); CGX::SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
} else { } else {
CGX::SetBlendMode(GX::BM_BLEND, GX::BL_ONE, GX::BL_ZERO, GX::LO_CLEAR); CGX::SetBlendMode(GX_BM_BLEND, GX_BL_ONE, GX_BL_ZERO, GX_LO_CLEAR);
} }
CGX::SetZMode(true, flags.x2_flags & CModelFlagBits::DepthTest ? GX::LEQUAL : GX::ALWAYS, CGX::SetZMode(true, flags.x2_flags & CModelFlagBits::DepthTest ? GX_LEQUAL : GX_ALWAYS,
flags.x2_flags.IsSet(CModelFlagBits::DepthUpdate)); flags.x2_flags.IsSet(CModelFlagBits::DepthUpdate));
CGX::SetNumTevStages(1); CGX::SetNumTevStages(1);
CGX::SetNumTexGens(1); CGX::SetNumTexGens(1);
CGX::SetNumChans(0); CGX::SetNumChans(0);
CGX::SetNumIndStages(0); CGX::SetNumIndStages(0);
CGX::SetAlphaCompare(GX::ALWAYS, 0, GX::AOP_AND, GX::ALWAYS, 0); CGX::SetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_ALWAYS, 0);
CGX::SetTevColorIn(GX::TEVSTAGE0, GX::CC_ZERO, GX::CC_ZERO, GX::CC_ZERO, GX::CC_KONST); CGX::SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_KONST);
CGX::SetTevAlphaIn(GX::TEVSTAGE0, GX::CA_ZERO, GX::CA_ZERO, GX::CA_ZERO, GX::CA_KONST); CGX::SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_KONST);
CGX::SetTevKColor(GX::KCOLOR0, flags.x4_color); CGX::SetTevKColor(GX_KCOLOR0, flags.x4_color);
CGX::SetTevKColorSel(GX::TEVSTAGE0, GX::TEV_KCSEL_K0); CGX::SetTevKColorSel(GX_TEVSTAGE0, GX_TEV_KCSEL_K0);
CGX::SetTevKAlphaSel(GX::TEVSTAGE0, GX::TEV_KASEL_K0_A); CGX::SetTevKAlphaSel(GX_TEVSTAGE0, GX_TEV_KASEL_K0_A);
CGX::SetTevOrder(GX::TEVSTAGE0, GX::TEXCOORD_NULL, GX::TEXMAP_NULL, GX::COLOR_NULL); CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR_NULL);
CGX::SetStandardTevColorAlphaOp(GX::TEVSTAGE0); CGX::SetStandardTevColorAlphaOp(GX_TEVSTAGE0);
CGX::SetTevDirect(GX::TEVSTAGE0); CGX::SetTevDirect(GX_TEVSTAGE0);
CGX::SetTexCoordGen(GX::TEXCOORD0, GX::TG_MTX2x4, GX::TG_POS, GX::IDENTITY, false, GX::PTIDENTITY); CGX::SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_POS, GX_IDENTITY, false, GX_PTIDENTITY);
model.UpdateLastFrame(); model.UpdateLastFrame();
model.GetInstance().DrawFlat(positions, normals, unsortedOnly ? ESurfaceSelection::Unsorted : ESurfaceSelection::All); model.GetInstance().DrawFlat(positions, normals, unsortedOnly ? ESurfaceSelection::Unsorted : ESurfaceSelection::All);
} }
@ -979,28 +981,29 @@ void CCubeRenderer::DoThermalBlendCold() {
const auto width = CGraphics::GetViewportWidth(); const auto width = CGraphics::GetViewportWidth();
const auto top = CGraphics::GetViewportTop(); const auto top = CGraphics::GetViewportTop();
const auto left = CGraphics::GetViewportLeft(); const auto left = CGraphics::GetViewportLeft();
CGX::SetZMode(true, GX::LEQUAL, false); CGX::SetZMode(true, GX_LEQUAL, false);
// GXSetTexCopySrc(left, top, width, height); // GXSetTexCopySrc(left, top, width, height);
// GXSetTexCopyDst(width, height, GX::TF_I4, false); // GXSetTexCopyDst(width, height, GX_TF_I4, false);
// GXCopyTex(sSpareTextureData, true); // GXCopyTex(sSpareTextureData, true);
CGraphics::ResolveSpareTexture( // TODO TODO TODO
aurora::gfx::ClipRect{ // CGraphics::ResolveSpareTexture(
.x = static_cast<int32_t>(left), // aurora::gfx::ClipRect{
.y = static_cast<int32_t>(top), // .x = static_cast<int32_t>(left),
.width = static_cast<int32_t>(width), // .y = static_cast<int32_t>(top),
.height = static_cast<int32_t>(height), // .width = static_cast<int32_t>(width),
}, // .height = static_cast<int32_t>(height),
0, GX::TF_I4); // },
// CGraphics::LoadDolphinSpareTexture(width, height, GX::TF_I4, nullptr, GX::TEXMAP7); // 0, GX_TF_I4);
CGraphics::LoadDolphinSpareTexture(0, GX::TF_I4, GX::TEXMAP7); // CGraphics::LoadDolphinSpareTexture(width, height, GX_TF_I4, nullptr, GX_TEXMAP7);
CGraphics::LoadDolphinSpareTexture(0, GX_TF_I4, GX_TEXMAP7);
// Upload random static texture (game reads from .text) // Upload random static texture (game reads from .text)
const u8* buf = CDvdFile::GetDolBuf() + 0x4f60; const u8* buf = CDvdFile::GetDolBuf() + 0x4f60;
u8* out = m_thermalRandomStatic.Lock(); u8* out = m_thermalRandomStatic.Lock();
memcpy(out, buf + ROUND_UP_32(x2a8_thermalRand.Next()), m_thermalRandomStatic.GetMemoryAllocated()); memcpy(out, buf + ROUND_UP_32(x2a8_thermalRand.Next()), m_thermalRandomStatic.GetMemoryAllocated());
m_thermalRandomStatic.UnLock(); m_thermalRandomStatic.UnLock();
m_thermalRandomStatic.Load(GX::TEXMAP0, EClampMode::Clamp); m_thermalRandomStatic.Load(GX_TEXMAP0, EClampMode::Clamp);
m_thermalRandomStatic.Load(GX::TEXMAP1, EClampMode::Clamp); m_thermalRandomStatic.Load(GX_TEXMAP1, EClampMode::Clamp);
// Configure indirect texturing // Configure indirect texturing
const float level = std::clamp(x2f0_thermalVisorLevel * 0.5f, 0.f, 0.5f); const float level = std::clamp(x2f0_thermalVisorLevel * 0.5f, 0.f, 0.5f);
@ -1009,10 +1012,10 @@ void CCubeRenderer::DoThermalBlendCold() {
aurora::Vec2{0.f, 0.f}, aurora::Vec2{0.f, 0.f},
aurora::Vec2{0.f, level}, aurora::Vec2{0.f, level},
}; };
GXSetIndTexMtx(GX::ITM_0, &mtx, -2); GXSetIndTexMtx(GX_ITM_0, &mtx, -2);
CGX::SetTevIndirect(GX::TEVSTAGE0, GX::INDTEXSTAGE0, GX::ITF_8, GX::ITB_STU, GX::ITM_0, GX::ITW_OFF, GX::ITW_OFF, CGX::SetTevIndirect(GX_TEVSTAGE0, GX_INDTEXSTAGE0, GX_ITF_8, GX_ITB_STU, GX_ITM_0, GX_ITW_OFF, GX_ITW_OFF, false,
false, false, GX::ITBA_OFF); false, GX_ITBA_OFF);
GXSetIndTexOrder(GX::INDTEXSTAGE0, GX::TEXCOORD0, GX::TEXMAP0); GXSetIndTexOrder(GX_INDTEXSTAGE0, GX_TEXCOORD0, GX_TEXMAP0);
// Configure register colors // Configure register colors
const auto color0 = zeus::CColor::lerp(x2f4_thermColor, zeus::skWhite, x2f8_thermColdScale); const auto color0 = zeus::CColor::lerp(x2f4_thermColor, zeus::skWhite, x2f8_thermColdScale);
@ -1028,40 +1031,40 @@ void CCubeRenderer::DoThermalBlendCold() {
cFac = (x2f8_thermColdScale - 0.25f) * 4.f / 3.f; cFac = (x2f8_thermColdScale - 0.25f) * 4.f / 3.f;
} }
const zeus::CColor color2{cFac, cFac}; const zeus::CColor color2{cFac, cFac};
GXSetTevColor(GX::TEVREG0, color0); GXSetTevColor(GX_TEVREG0, to_gx_color(color0));
GXSetTevColor(GX::TEVREG1, color1); GXSetTevColor(GX_TEVREG1, to_gx_color(color1));
GXSetTevColor(GX::TEVREG2, color2); GXSetTevColor(GX_TEVREG2, to_gx_color(color2));
// Configure TEV stage 0 // Configure TEV stage 0
GXSetTevSwapMode(GX::TEVSTAGE0, GX::TEV_SWAP0, GX::TEV_SWAP1); GXSetTevSwapMode(GX_TEVSTAGE0, GX_TEV_SWAP0, GX_TEV_SWAP1);
CGX::SetTevColorIn(GX::TEVSTAGE0, GX::CC_ZERO, GX::CC_TEXC, GX::CC_C0, GX::CC_C2); CGX::SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_TEXC, GX_CC_C0, GX_CC_C2);
CGX::SetTevAlphaIn(GX::TEVSTAGE0, GX::CA_ZERO, GX::CA_TEXA, GX::CA_A1, GX::CA_A2); CGX::SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_TEXA, GX_CA_A1, GX_CA_A2);
CGX::SetStandardTevColorAlphaOp(GX::TEVSTAGE0); CGX::SetStandardTevColorAlphaOp(GX_TEVSTAGE0);
CGX::SetTevOrder(GX::TEVSTAGE0, GX::TEXCOORD0, GX::TEXMAP7, GX::COLOR_NULL); CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP7, GX_COLOR_NULL);
// Configure TEV stage 1 // Configure TEV stage 1
GXSetTevSwapMode(GX::TEVSTAGE1, GX::TEV_SWAP0, GX::TEV_SWAP1); GXSetTevSwapMode(GX_TEVSTAGE1, GX_TEV_SWAP0, GX_TEV_SWAP1);
CGX::SetTevColorIn(GX::TEVSTAGE1, GX::CC_ZERO, GX::CC_TEXC, GX::CC_C1, GX::CC_CPREV); CGX::SetTevColorIn(GX_TEVSTAGE1, GX_CC_ZERO, GX_CC_TEXC, GX_CC_C1, GX_CC_CPREV);
CGX::SetTevColorOp(GX::TEVSTAGE1, GX::TEV_SUB, GX::TB_ZERO, GX::CS_SCALE_1, true, GX::TEVPREV); CGX::SetTevColorOp(GX_TEVSTAGE1, GX_TEV_SUB, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV);
CGX::SetTevAlphaIn(GX::TEVSTAGE1, GX::CA_ZERO, GX::CA_A1, GX::CA_TEXA, GX::CA_APREV); CGX::SetTevAlphaIn(GX_TEVSTAGE1, GX_CA_ZERO, GX_CA_A1, GX_CA_TEXA, GX_CA_APREV);
CGX::SetTevAlphaOp(GX::TEVSTAGE1, GX::TEV_ADD, GX::TB_ZERO, GX::CS_SCALE_4, true, GX::TEVPREV); CGX::SetTevAlphaOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_4, true, GX_TEVPREV);
CGX::SetTevOrder(GX::TEVSTAGE1, GX::TEXCOORD0, GX::TEXMAP1, GX::COLOR_NULL); CGX::SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD0, GX_TEXMAP1, GX_COLOR_NULL);
// Configure everything else // Configure everything else
CGX::SetTexCoordGen(GX::TEXCOORD0, GX::TG_MTX3x4, GX::TG_TEX0, GX::IDENTITY, false, GX::PTIDENTITY); CGX::SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX3x4, GX_TG_TEX0, GX_IDENTITY, false, GX_PTIDENTITY);
CGX::SetAlphaCompare(GX::ALWAYS, 0, GX::AOP_AND, GX::ALWAYS, 0); CGX::SetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_ALWAYS, 0);
CGX::SetNumTevStages(2); CGX::SetNumTevStages(2);
CGX::SetNumTexGens(1); CGX::SetNumTexGens(1);
CGX::SetNumChans(0); CGX::SetNumChans(0);
CGX::SetNumIndStages(1); CGX::SetNumIndStages(1);
CGX::SetZMode(false, GX::ALWAYS, false); CGX::SetZMode(false, GX_ALWAYS, false);
constexpr std::array vtxDescList{ constexpr std::array vtxDescList{
GX::VtxDescList{GX::VA_POS, GX::DIRECT}, GXVtxDescList{GX_VA_POS, GX_DIRECT},
GX::VtxDescList{GX::VA_TEX0, GX::DIRECT}, GXVtxDescList{GX_VA_TEX0, GX_DIRECT},
GX::VtxDescList{}, GXVtxDescList{GX_VA_NULL, GX_NONE},
}; };
CGX::SetVtxDescv(vtxDescList.data()); CGX::SetVtxDescv(vtxDescList.data());
CGX::SetBlendMode(GX::BM_NONE, GX::BL_ONE, GX::BL_ZERO, GX::LO_CLEAR); CGX::SetBlendMode(GX_BM_NONE, GX_BL_ONE, GX_BL_ZERO, GX_LO_CLEAR);
// Backup & set viewport/projection // Backup & set viewport/projection
const auto backupViewMatrix = CGraphics::g_ViewMatrix; const auto backupViewMatrix = CGraphics::g_ViewMatrix;
@ -1072,7 +1075,7 @@ void CCubeRenderer::DoThermalBlendCold() {
GXPixModeSync(); GXPixModeSync();
// Draw // Draw
CGX::Begin(GX::TRIANGLEFAN, GX::VTXFMT0, 4); CGX::Begin(GX_TRIANGLEFAN, GX_VTXFMT0, 4);
GXPosition3f32(0.f, 0.5f, 0.f); GXPosition3f32(0.f, 0.5f, 0.f);
GXTexCoord2f32(0.f, 0.f); GXTexCoord2f32(0.f, 0.f);
GXPosition3f32(0.f, 0.5f, static_cast<float>(height)); GXPosition3f32(0.f, 0.5f, static_cast<float>(height));
@ -1084,10 +1087,10 @@ void CCubeRenderer::DoThermalBlendCold() {
CGX::End(); CGX::End();
// Cleanup // Cleanup
GXSetTevSwapMode(GX::TEVSTAGE0, GX::TEV_SWAP0, GX::TEV_SWAP0); GXSetTevSwapMode(GX_TEVSTAGE0, GX_TEV_SWAP0, GX_TEV_SWAP0);
GXSetTevSwapMode(GX::TEVSTAGE1, GX::TEV_SWAP0, GX::TEV_SWAP0); GXSetTevSwapMode(GX_TEVSTAGE1, GX_TEV_SWAP0, GX_TEV_SWAP0);
CGX::SetNumIndStages(0); CGX::SetNumIndStages(0);
CGX::SetTevDirect(GX::TEVSTAGE0); CGX::SetTevDirect(GX_TEVSTAGE0);
GXSetDstAlpha(false, 255); GXSetDstAlpha(false, 255);
CGraphics::SetProjectionState(backupProjectionState); CGraphics::SetProjectionState(backupProjectionState);
CGraphics::SetViewPointMatrix(backupViewMatrix); CGraphics::SetViewPointMatrix(backupViewMatrix);
@ -1104,31 +1107,31 @@ void CCubeRenderer::DoThermalBlendHot() {
const auto width = CGraphics::GetViewportWidth(); const auto width = CGraphics::GetViewportWidth();
const auto top = CGraphics::GetViewportTop(); const auto top = CGraphics::GetViewportTop();
const auto left = CGraphics::GetViewportLeft(); const auto left = CGraphics::GetViewportLeft();
CGX::SetZMode(true, GX::LEQUAL, true); CGX::SetZMode(true, GX_LEQUAL, true);
// GXSetTexCopySrc(left, top, width, height); // GXSetTexCopySrc(left, top, width, height);
// GXSetTexCopyDst(width, height, GX::TF_I4, false); // GXSetTexCopyDst(width, height, GX_TF_I4, false);
// GXCopyTex(sSpareTextureData, false); // GXCopyTex(sSpareTextureData, false);
CGraphics::ResolveSpareTexture(CGraphics::g_Viewport, 0, GX::TF_I4); CGraphics::ResolveSpareTexture(CGraphics::g_Viewport, 0, GX_TF_I4);
x288_thermoPalette.Load(); x288_thermoPalette.Load();
// CGraphics::LoadDolphinSpareTexture(width, height, GX::TF_C4, GX::TLUT0, nullptr, GX::TEXMAP7); // CGraphics::LoadDolphinSpareTexture(width, height, GX_TF_C4, GX::TLUT0, nullptr, GX_TEXMAP7);
CGraphics::LoadDolphinSpareTexture(0, GX_TF_C4, GX_TLUT0, GX::TEXMAP7); CGraphics::LoadDolphinSpareTexture(0, GX_TF_C4, GX_TLUT0, GX_TEXMAP7);
CGX::SetTevColorIn(GX::TEVSTAGE0, GX::CC_ZERO, GX::CC_TEXA, GX::CC_TEXC, GX::CC_ZERO); CGX::SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_TEXA, GX_CC_TEXC, GX_CC_ZERO);
CGX::SetTevAlphaIn(GX::TEVSTAGE0, GX::CA_ZERO, GX::CA_ZERO, GX::CA_ZERO, GX::CA_TEXA); CGX::SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_TEXA);
CGX::SetStandardTevColorAlphaOp(GX::TEVSTAGE0); CGX::SetStandardTevColorAlphaOp(GX_TEVSTAGE0);
CGX::SetTevOrder(GX::TEVSTAGE0, GX::TEXCOORD0, GX::TEXMAP7, GX::COLOR_NULL); CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP7, GX_COLOR_NULL);
CGX::SetTexCoordGen(GX::TEXCOORD0, GX::TG_MTX3x4, GX::TG_TEX0, GX::IDENTITY, false, GX::PTIDENTITY); CGX::SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX3x4, GX_TG_TEX0, GX_IDENTITY, false, GX_PTIDENTITY);
CGX::SetAlphaCompare(GX::ALWAYS, 0, GX::AOP_AND, GX::ALWAYS, 0); CGX::SetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_ALWAYS, 0);
CGX::SetNumTevStages(1); CGX::SetNumTevStages(1);
CGX::SetNumTexGens(1); CGX::SetNumTexGens(1);
CGX::SetNumChans(0); CGX::SetNumChans(0);
CGX::SetZMode(false, GX::LEQUAL, false); CGX::SetZMode(false, GX_LEQUAL, false);
constexpr std::array vtxDescList{ constexpr std::array vtxDescList{
GX::VtxDescList{GX::VA_POS, GX::DIRECT}, GXVtxDescList{GX_VA_POS, GX_DIRECT},
GX::VtxDescList{GX::VA_TEX0, GX::DIRECT}, GXVtxDescList{GX_VA_TEX0, GX_DIRECT},
GX::VtxDescList{}, GXVtxDescList{GX_VA_NULL, GX_NONE},
}; };
CGX::SetVtxDescv(vtxDescList.data()); CGX::SetVtxDescv(vtxDescList.data());
CGX::SetBlendMode(GX::BM_BLEND, GX::BL_DSTALPHA, GX::BL_INVDSTALPHA, GX::LO_CLEAR); CGX::SetBlendMode(GX_BM_BLEND, GX_BL_DSTALPHA, GX_BL_INVDSTALPHA, GX_LO_CLEAR);
// Backup & set viewport/projection // Backup & set viewport/projection
const auto backupViewMatrix = CGraphics::g_ViewMatrix; const auto backupViewMatrix = CGraphics::g_ViewMatrix;
@ -1139,7 +1142,7 @@ void CCubeRenderer::DoThermalBlendHot() {
GXPixModeSync(); GXPixModeSync();
// Draw // Draw
CGX::Begin(GX::TRIANGLEFAN, GX::VTXFMT0, 4); CGX::Begin(GX_TRIANGLEFAN, GX_VTXFMT0, 4);
GXPosition3f32(0.f, 0.5f, 0.f); GXPosition3f32(0.f, 0.5f, 0.f);
GXTexCoord2f32(0.f, 0.f); GXTexCoord2f32(0.f, 0.f);
GXPosition3f32(0.f, 0.5f, static_cast<float>(height)); GXPosition3f32(0.f, 0.5f, static_cast<float>(height));
@ -1152,7 +1155,7 @@ void CCubeRenderer::DoThermalBlendHot() {
// Cleanup // Cleanup
CGX::SetNumIndStages(0); CGX::SetNumIndStages(0);
CGX::SetTevDirect(GX::TEVSTAGE0); CGX::SetTevDirect(GX_TEVSTAGE0);
GXSetAlphaUpdate(true); GXSetAlphaUpdate(true);
CGraphics::SetProjectionState(backupProjectionState); CGraphics::SetProjectionState(backupProjectionState);
CGraphics::SetViewPointMatrix(backupViewMatrix); CGraphics::SetViewPointMatrix(backupViewMatrix);
@ -1165,7 +1168,7 @@ u32 CCubeRenderer::GetStaticWorldDataSize() {
return 0; return 0;
} }
void CCubeRenderer::SetGXRegister1Color(const zeus::CColor& color) { GXSetTevColor(GX::TevRegID::TEVREG1, color); } void CCubeRenderer::SetGXRegister1Color(const zeus::CColor& color) { GXSetTevColor(GX_TEVREG1, to_gx_color(color)); }
void CCubeRenderer::SetWorldLightFadeLevel(float level) { x2fc_tevReg1Color = zeus::CColor(level, level, level, 1.f); } void CCubeRenderer::SetWorldLightFadeLevel(float level) { x2fc_tevReg1Color = zeus::CColor(level, level, level, 1.f); }
@ -1348,7 +1351,7 @@ void CCubeRenderer::DrawOverlappingWorldModelShadows(s32 alphaVal, const std::ve
} }
auto& model = *(*item.x10_models)[wordModel + j]; auto& model = *(*item.x10_models)[wordModel + j];
CGX::SetTevKColor(GX::KCOLOR0, zeus::CColor{0.f, static_cast<float>(alphaVal) / 255.f}); CGX::SetTevKColor(GX_KCOLOR0, zeus::CColor{0.f, static_cast<float>(alphaVal) / 255.f});
model.SetArraysCurrent(); model.SetArraysCurrent();
for (const auto* surf = model.GetFirstUnsortedSurface(); surf != nullptr; surf = surf->GetNextSurface()) { for (const auto* surf = model.GetFirstUnsortedSurface(); surf != nullptr; surf = surf->GetNextSurface()) {
if (surf->GetBounds().intersects(aabb)) { if (surf->GetBounds().intersects(aabb)) {
@ -1373,8 +1376,7 @@ void CCubeRenderer::SetupCGraphicsState() {
CGraphics::SetAmbientColor({0.4f}); CGraphics::SetAmbientColor({0.4f});
CGX::SetChanMatColor(CGX::EChannelId::Channel0, zeus::skWhite); CGX::SetChanMatColor(CGX::EChannelId::Channel0, zeus::skWhite);
CGraphics::SetDepthWriteMode(true, ERglEnum::LEqual, true); CGraphics::SetDepthWriteMode(true, ERglEnum::LEqual, true);
CGX::SetChanCtrl(CGX::EChannelId::Channel1, false, GX::SRC_REG, GX::SRC_REG, GX::LIGHT_NULL, GX::DF_NONE, CGX::SetChanCtrl(CGX::EChannelId::Channel1, false, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_NONE, GX_AF_NONE);
GX::AF_NONE);
CCubeMaterial::EnsureTevsDirect(); CCubeMaterial::EnsureTevsDirect();
} }
@ -1384,7 +1386,7 @@ void CCubeRenderer::SetupRendererStates(bool depthWrite) {
CGraphics::SetAmbientColor(zeus::skClear); CGraphics::SetAmbientColor(zeus::skClear);
CGraphics::SetDepthWriteMode(true, ERglEnum::LEqual, depthWrite); CGraphics::SetDepthWriteMode(true, ERglEnum::LEqual, depthWrite);
CCubeMaterial::ResetCachedMaterials(); CCubeMaterial::ResetCachedMaterials();
GXSetTevColor(GX::TEVREG1, x2fc_tevReg1Color); GXSetTevColor(GX_TEVREG1, to_gx_color(x2fc_tevReg1Color));
} }
constexpr zeus::CTransform MvPostXf{ constexpr zeus::CTransform MvPostXf{
@ -1395,26 +1397,26 @@ constexpr zeus::CTransform MvPostXf{
void CCubeRenderer::DoThermalModelDraw(CCubeModel& model, const zeus::CColor& multCol, const zeus::CColor& addCol, void CCubeRenderer::DoThermalModelDraw(CCubeModel& model, const zeus::CColor& multCol, const zeus::CColor& addCol,
TConstVectorRef positions, TConstVectorRef normals, const CModelFlags& flags) { TConstVectorRef positions, TConstVectorRef normals, const CModelFlags& flags) {
SCOPED_GRAPHICS_DEBUG_GROUP("CCubeRenderer::DoThermalModelDraw", zeus::skBlue); SCOPED_GRAPHICS_DEBUG_GROUP("CCubeRenderer::DoThermalModelDraw", zeus::skBlue);
CGX::SetTexCoordGen(GX::TEXCOORD0, GX::TG_MTX3x4, GX::TG_NRM, GX::TEXMTX0, true, GX::PTTEXMTX0); CGX::SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX3x4, GX_TG_NRM, GX_TEXMTX0, true, GX_PTTEXMTX0);
CGX::SetNumTexGens(1); CGX::SetNumTexGens(1);
CGX::SetNumChans(0); CGX::SetNumChans(0);
x220_sphereRamp.Load(GX::TEXMAP0, EClampMode::Clamp); x220_sphereRamp.Load(GX_TEXMAP0, EClampMode::Clamp);
zeus::CTransform xf = CGraphics::g_ViewMatrix.inverse().multiplyIgnoreTranslation(CGraphics::g_GXModelMatrix); zeus::CTransform xf = CGraphics::g_ViewMatrix.inverse().multiplyIgnoreTranslation(CGraphics::g_GXModelMatrix);
xf.origin.zeroOut(); xf.origin.zeroOut();
GXLoadTexMtxImm(&xf, GX::TEXMTX0, GX::MTX3x4); GXLoadTexMtxImm(&xf, GX_TEXMTX0, GX_MTX3x4);
GXLoadTexMtxImm(&MvPostXf, GX::PTTEXMTX0, GX::MTX3x4); GXLoadTexMtxImm(&MvPostXf, GX_PTTEXMTX0, GX_MTX3x4);
CGX::SetStandardTevColorAlphaOp(GX::TEVSTAGE0); CGX::SetStandardTevColorAlphaOp(GX_TEVSTAGE0);
CGX::SetTevColorIn(GX::TEVSTAGE0, GX::CC_ZERO, GX::CC_C0, GX::CC_TEXC, GX::CC_KONST); CGX::SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_C0, GX_CC_TEXC, GX_CC_KONST);
CGX::SetTevAlphaIn(GX::TEVSTAGE0, GX::CA_ZERO, GX::CA_TEXA, GX::CA_A0, GX::CA_KONST); CGX::SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_TEXA, GX_CA_A0, GX_CA_KONST);
CGX::SetTevOrder(GX::TEVSTAGE0, GX::TEXCOORD0, GX::TEXMAP0, GX::COLOR_NULL); CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL);
CGX::SetNumTevStages(1); CGX::SetNumTevStages(1);
CGX::SetTevKColor(GX::KCOLOR0, addCol); CGX::SetTevKColor(GX_KCOLOR0, addCol);
CGX::SetTevKColorSel(GX::TEVSTAGE0, GX::TEV_KCSEL_K0); CGX::SetTevKColorSel(GX_TEVSTAGE0, GX_TEV_KCSEL_K0);
CGX::SetTevKAlphaSel(GX::TEVSTAGE0, GX::TEV_KASEL_K0_A); CGX::SetTevKAlphaSel(GX_TEVSTAGE0, GX_TEV_KASEL_K0_A);
GXSetTevColor(GX::TEVREG0, multCol); GXSetTevColor(GX_TEVREG0, to_gx_color(multCol));
CGX::SetAlphaCompare(GX::ALWAYS, 0, GX::AOP_OR, GX::ALWAYS, 0); CGX::SetAlphaCompare(GX_ALWAYS, 0, GX_AOP_OR, GX_ALWAYS, 0);
CGX::SetBlendMode(GX::BM_BLEND, GX::BL_ONE, GX::BL_ONE, GX::LO_CLEAR); CGX::SetBlendMode(GX_BM_BLEND, GX_BL_ONE, GX_BL_ONE, GX_LO_CLEAR);
CGX::SetZMode(flags.x2_flags.IsSet(CModelFlagBits::DepthTest), GX::LEQUAL, CGX::SetZMode(flags.x2_flags.IsSet(CModelFlagBits::DepthTest), GX_LEQUAL,
flags.x2_flags.IsSet(CModelFlagBits::DepthUpdate)); flags.x2_flags.IsSet(CModelFlagBits::DepthUpdate));
model.DrawFlat(positions, normals, model.DrawFlat(positions, normals,
flags.x2_flags.IsSet(CModelFlagBits::ThermalUnsortedOnly) ? ESurfaceSelection::Unsorted flags.x2_flags.IsSet(CModelFlagBits::ThermalUnsortedOnly) ? ESurfaceSelection::Unsorted
@ -1458,16 +1460,16 @@ void CCubeRenderer::ReallyDrawSpaceWarp(const zeus::CVector3f& pt, float strengt
} }
const auto v2sub = v2left - v2right; const auto v2sub = v2left - v2right;
if (v2sub.x > 0 && v2sub.y > 0) { if (v2sub.x > 0 && v2sub.y > 0) {
GX::FogType fogType; GXFogType fogType;
float fogStartZ; float fogStartZ;
float fogEndZ; float fogEndZ;
float fogNearZ; float fogNearZ;
float fogFarZ; float fogFarZ;
GXColor fogColor; GXColor fogColor;
CGX::GetFog(&fogType, &fogStartZ, &fogEndZ, &fogNearZ, &fogFarZ, &fogColor); CGX::GetFog(&fogType, &fogStartZ, &fogEndZ, &fogNearZ, &fogFarZ, &fogColor);
CGX::SetFog(GX::FOG_NONE, fogStartZ, fogEndZ, fogNearZ, fogFarZ, fogColor); CGX::SetFog(GX_FOG_NONE, fogStartZ, fogEndZ, fogNearZ, fogFarZ, fogColor);
// GXSetTexCopySrc(v2right.x, v2right.y, v2sub.x, v2sub.y); // GXSetTexCopySrc(v2right.x, v2right.y, v2sub.x, v2sub.y);
// GXSetTexCopyDst(v2sub.x, v2sub.y, GX::TF_RGBA8, false); // GXSetTexCopyDst(v2sub.x, v2sub.y, GX_TF_RGBA8, false);
// GXCopyTex(sSpareTextureData, false); // GXCopyTex(sSpareTextureData, false);
// GXPixModeSync(); // GXPixModeSync();
CGraphics::ResolveSpareTexture( CGraphics::ResolveSpareTexture(
@ -1477,14 +1479,14 @@ void CCubeRenderer::ReallyDrawSpaceWarp(const zeus::CVector3f& pt, float strengt
.x8_width = static_cast<u32>(v2sub.x), .x8_width = static_cast<u32>(v2sub.x),
.xc_height = static_cast<u32>(v2sub.y), .xc_height = static_cast<u32>(v2sub.y),
}, },
1, GX::TF_RGBA8); 1, GX_TF_RGBA8);
CGraphics::LoadDolphinSpareTexture(1, GX::TF_RGBA8, GX::TEXMAP7); CGraphics::LoadDolphinSpareTexture(1, GX_TF_RGBA8, GX_TEXMAP7);
x150_reflectionTex.Load(GX::TEXMAP1, EClampMode::Clamp); x150_reflectionTex.Load(GX_TEXMAP1, EClampMode::Clamp);
CGX::SetTevColorIn(GX::TEVSTAGE0, GX::CC_ZERO, GX::CC_ZERO, GX::CC_ZERO, GX::CC_TEXC); CGX::SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_TEXC);
CGX::SetTevColorOp(GX::TEVSTAGE0, GX::TEV_ADD, GX::TB_ZERO, GX::CS_SCALE_1, true, GX::TEVPREV); CGX::SetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV);
CGX::SetTexCoordGen(GX::TEXCOORD0, GX::TG_MTX3x4, GX::TG_TEX0, GX::IDENTITY, false, GX::PTIDENTITY); CGX::SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX3x4, GX_TG_TEX0, GX_IDENTITY, false, GX_PTIDENTITY);
CGX::SetTexCoordGen(GX::TEXCOORD1, GX::TG_MTX3x4, GX::TG_TEX1, GX::IDENTITY, false, GX::PTIDENTITY); CGX::SetTexCoordGen(GX_TEXCOORD1, GX_TG_MTX3x4, GX_TG_TEX1, GX_IDENTITY, false, GX_PTIDENTITY);
CGX::SetTevOrder(GX::TEVSTAGE0, GX::TEXCOORD0, GX::TEXMAP7, GX::COLOR_NULL); CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP7, GX_COLOR_NULL);
} }
} }

View File

@ -4,27 +4,27 @@
namespace metaforce::CGX { namespace metaforce::CGX {
SGXState sGXState{}; SGXState sGXState{};
std::array<GX::VtxDescList, 12> sVtxDescList{}; std::array<GXVtxDescList, 12> sVtxDescList{};
void ResetGXStates() noexcept { void ResetGXStates() noexcept {
sGXState.x48_descList = 0; sGXState.x48_descList = 0;
GXClearVtxDesc(); GXClearVtxDesc();
sGXState.x0_arrayPtrs.fill(nullptr); sGXState.x0_arrayPtrs.fill(nullptr);
for (GX::TexMapID id = GX::TEXMAP0; id < GX::MAX_TEXMAP; id = static_cast<GX::TexMapID>(id + 1)) { for (GXTexMapID id = GX_TEXMAP0; id < GX_MAX_TEXMAP; id = static_cast<GXTexMapID>(id + 1)) {
CTexture::InvalidateTexMap(id); CTexture::InvalidateTexMap(id);
} }
for (GX::TevKColorID id = GX::KCOLOR0; const auto& item : sGXState.x58_kColors) { for (GXTevKColorID id = GX_KCOLOR0; const auto& item : sGXState.x58_kColors) {
GXSetTevKColor(id, item); GXSetTevKColor(id, item);
id = static_cast<GX::TevKColorID>(id + 1); id = static_cast<GXTevKColorID>(id + 1);
} }
GXSetTevSwapModeTable(GX::TEV_SWAP1, GX::CH_RED, GX::CH_GREEN, GX::CH_BLUE, GX::CH_RED); GXSetTevSwapModeTable(GX_TEV_SWAP1, GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_RED);
GXSetTevSwapModeTable(GX::TEV_SWAP2, GX::CH_RED, GX::CH_GREEN, GX::CH_BLUE, GX::CH_GREEN); GXSetTevSwapModeTable(GX_TEV_SWAP2, GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_GREEN);
GXSetTevSwapModeTable(GX::TEV_SWAP3, GX::CH_RED, GX::CH_GREEN, GX::CH_BLUE, GX::CH_BLUE); GXSetTevSwapModeTable(GX_TEV_SWAP3, GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_BLUE);
SetAlphaCompare(GX::ALWAYS, 0, GX::AOP_AND, GX::ALWAYS, 0); SetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_ALWAYS, 0);
// GXSetCurrentMtx(0); GXSetCurrentMtx(GX_PNMTX0);
SetNumIndStages(0); SetNumIndStages(0);
// TODO GXSetIndTexCoordScale // TODO GXSetIndTexCoordScale
for (GX::TevStageID id = GX::TEVSTAGE0; id < GX::MAX_TEVSTAGE; id = static_cast<GX::TevStageID>(id + 1)) { for (GXTevStageID id = GX_TEVSTAGE0; id < GX_MAX_TEVSTAGE; id = static_cast<GXTevStageID>(id + 1)) {
SetTevDirect(id); SetTevDirect(id);
} }
// GXSetTexCoordCylWrap // GXSetTexCoordCylWrap

View File

@ -7,8 +7,8 @@
namespace metaforce::CGX { namespace metaforce::CGX {
enum class EChannelId { enum class EChannelId {
Channel0, // GX::COLOR0 Channel0, // GX_COLOR0
Channel1, // GX::COLOR1 Channel1, // GX_COLOR1
}; };
struct STevState { struct STevState {
@ -18,8 +18,8 @@ struct STevState {
u32 xc_alphaOps = 0; u32 xc_alphaOps = 0;
u32 x10_indFlags = 0; u32 x10_indFlags = 0;
u32 x14_tevOrderFlags = 0; u32 x14_tevOrderFlags = 0;
GX::TevKColorSel x18_kColorSel = GX::TEV_KCSEL_1; GXTevKColorSel x18_kColorSel = GX_TEV_KCSEL_1;
GX::TevKAlphaSel x19_kAlphaSel = GX::TEV_KASEL_1; GXTevKAlphaSel x19_kAlphaSel = GX_TEV_KASEL_1;
}; };
struct STexState { struct STexState {
u32 x0_coordGen = 0; u32 x0_coordGen = 0;
@ -38,12 +38,12 @@ struct SGXState {
u8 x50_numTevStages = 0; u8 x50_numTevStages = 0;
u8 x51_numIndStages = 0; u8 x51_numIndStages = 0;
u8 x52_zmode = 0; u8 x52_zmode = 0;
GX::FogType x53_fogType = GX::FOG_NONE; GXFogType x53_fogType = GX_FOG_NONE;
u16 x54_lineWidthAndOffset = 0; u16 x54_lineWidthAndOffset = 0;
u16 x56_blendMode = 0; u16 x56_blendMode = 0;
std::array<GXColor, GX::MAX_KCOLOR> x58_kColors; std::array<GXColor, GX_MAX_KCOLOR> x58_kColors;
std::array<STevState, GX::MAX_TEVSTAGE> x68_tevStates; std::array<STevState, GX_MAX_TEVSTAGE> x68_tevStates;
std::array<STexState, GX::MAX_TEXCOORD> x228_texStates; std::array<STexState, GX_MAX_TEXCOORD> x228_texStates;
u32 x248_alphaCompare = 0; u32 x248_alphaCompare = 0;
float x24c_fogStartZ = 0.f; float x24c_fogStartZ = 0.f;
float x250_fogEndZ = 0.f; float x250_fogEndZ = 0.f;
@ -52,14 +52,14 @@ struct SGXState {
GXColor x25c_fogColor; GXColor x25c_fogColor;
}; };
extern SGXState sGXState; extern SGXState sGXState;
extern std::array<GX::VtxDescList, 12> sVtxDescList; extern std::array<GXVtxDescList, 12> sVtxDescList;
static inline void update_fog(u32 value) noexcept { static inline void update_fog(u32 value) noexcept {
if (sGXState.x53_fogType == GX::FOG_NONE || (sGXState.x56_blendMode & 0xE0) == (value & 0xE0)) { if (sGXState.x53_fogType == GX_FOG_NONE || (sGXState.x56_blendMode & 0xE0) == (value & 0xE0)) {
return; return;
} }
if ((value & 0xE0) == 0x20) { if ((value & 0xE0) == 0x20) {
GXSetFogColor(zeus::skClear); GXSetFogColor(GX_CLEAR);
return; return;
} }
GXSetFogColor(sGXState.x25c_fogColor); GXSetFogColor(sGXState.x25c_fogColor);
@ -72,23 +72,21 @@ static inline void FlushState() noexcept {
sGXState.x4d_prevNumChans = numChans; sGXState.x4d_prevNumChans = numChans;
} }
if ((sGXState.x4c_dirtyChans & 2) != 0) { if ((sGXState.x4c_dirtyChans & 2) != 0) {
// TODO actually COLOR0
auto flags = sGXState.x34_chanCtrls[0]; auto flags = sGXState.x34_chanCtrls[0];
GXSetChanCtrl(GX::COLOR0A0, GXBool(flags & 1), GX::ColorSrc(flags >> 1 & 1), GX::ColorSrc(flags >> 2 & 1), GXSetChanCtrl(GX_COLOR0, GXBool(flags & 1), GXColorSrc(flags >> 1 & 1), GXColorSrc(flags >> 2 & 1),
flags >> 3 & 0xFF, GX::DiffuseFn(flags >> 11 & 3), GX::AttnFn(flags >> 13 & 3)); flags >> 3 & 0xFF, GXDiffuseFn(flags >> 11 & 3), GXAttnFn(flags >> 13 & 3));
sGXState.x30_prevChanCtrls[0] = flags; sGXState.x30_prevChanCtrls[0] = flags;
} }
if ((sGXState.x4c_dirtyChans & 4) != 0) { if ((sGXState.x4c_dirtyChans & 4) != 0) {
// TODO actually COLOR1
auto flags = sGXState.x34_chanCtrls[1]; auto flags = sGXState.x34_chanCtrls[1];
GXSetChanCtrl(GX::COLOR1A1, GXBool(flags & 1), GX::ColorSrc(flags >> 1 & 1), GX::ColorSrc(flags >> 2 & 1), GXSetChanCtrl(GX_COLOR1, GXBool(flags & 1), GXColorSrc(flags >> 1 & 1), GXColorSrc(flags >> 2 & 1),
flags >> 3 & 0xFF, GX::DiffuseFn(flags >> 11 & 3), GX::AttnFn(flags >> 13 & 3)); flags >> 3 & 0xFF, GXDiffuseFn(flags >> 11 & 3), GXAttnFn(flags >> 13 & 3));
sGXState.x30_prevChanCtrls[1] = flags; sGXState.x30_prevChanCtrls[1] = flags;
} }
sGXState.x4c_dirtyChans = 0; sGXState.x4c_dirtyChans = 0;
} }
static inline void Begin(GX::Primitive primitive, GX::VtxFmt fmt, u16 nverts) noexcept { static inline void Begin(GXPrimitive primitive, GXVtxFmt fmt, u16 nverts) noexcept {
if (sGXState.x4c_dirtyChans != 0) { if (sGXState.x4c_dirtyChans != 0) {
FlushState(); FlushState();
} }
@ -111,24 +109,23 @@ static inline const GXColor& GetChanAmbColor(EChannelId id) noexcept {
void ResetGXStates() noexcept; void ResetGXStates() noexcept;
static inline void SetAlphaCompare(GX::Compare comp0, u8 ref0, GX::AlphaOp op, GX::Compare comp1, u8 ref1) noexcept { static inline void SetAlphaCompare(GXCompare comp0, u8 ref0, GXAlphaOp op, GXCompare comp1, u8 ref1) noexcept {
u32 flags = ref1 << 17 | (comp1 & 7) << 14 | (op & 7) << 11 | ref0 << 3 | (comp0 & 7); u32 flags = ref1 << 17 | (comp1 & 7) << 14 | (op & 7) << 11 | ref0 << 3 | (comp0 & 7);
if (flags != sGXState.x248_alphaCompare) { if (flags != sGXState.x248_alphaCompare) {
sGXState.x248_alphaCompare = flags; sGXState.x248_alphaCompare = flags;
GXSetAlphaCompare(comp0, ref0, op, comp1, ref1); GXSetAlphaCompare(comp0, ref0, op, comp1, ref1);
// GXSetZCompLoc(comp0 == GX::ALWAYS); GXSetZCompLoc(comp0 == GX_ALWAYS);
} }
} }
template <typename T> template <typename T>
static inline void SetArray(GX::Attr attr, const std::vector<T>* data, bool isStatic) noexcept { static inline void SetArray(GXAttr attr, const std::vector<T>* data, bool isStatic) noexcept {
if (data != nullptr && sGXState.x0_arrayPtrs[attr - GX::VA_POS] != data) { if (data != nullptr && sGXState.x0_arrayPtrs[attr - GX_VA_POS] != data) {
GXSetArray(attr, data, isStatic ? 1 : 0); GXSetArray(attr, data->data(), data->size() * sizeof(T), sizeof(T));
} }
} }
static inline void SetBlendMode(GX::BlendMode mode, GX::BlendFactor srcFac, GX::BlendFactor dstFac, static inline void SetBlendMode(GXBlendMode mode, GXBlendFactor srcFac, GXBlendFactor dstFac, GXLogicOp op) noexcept {
GX::LogicOp op) noexcept {
const u16 flags = (op & 0xF) << 8 | (dstFac & 7) << 5 | (srcFac & 7) << 2 | (mode & 3); const u16 flags = (op & 0xF) << 8 | (dstFac & 7) << 5 | (srcFac & 7) << 2 | (mode & 3);
if (flags != sGXState.x56_blendMode) { if (flags != sGXState.x56_blendMode) {
update_fog(flags); update_fog(flags);
@ -137,16 +134,19 @@ static inline void SetBlendMode(GX::BlendMode mode, GX::BlendFactor srcFac, GX::
} }
} }
static inline void SetChanAmbColor(EChannelId id, const GXColor& color) noexcept { static inline void SetChanAmbColor(EChannelId id, GXColor color) noexcept {
const auto idx = std::underlying_type_t<EChannelId>(id); const auto idx = std::underlying_type_t<EChannelId>(id);
if (color != sGXState.x38_chanAmbColors[idx]) { if (color != sGXState.x38_chanAmbColors[idx]) {
sGXState.x38_chanAmbColors[idx] = color; sGXState.x38_chanAmbColors[idx] = color;
GXSetChanAmbColor(GX::ChannelID(idx + GX::COLOR0A0), color); GXSetChanAmbColor(GXChannelID(idx + GX_COLOR0A0), color);
} }
} }
static inline void SetChanAmbColor(EChannelId id, const zeus::CColor& color) noexcept {
SetChanAmbColor(id, to_gx_color(color));
}
static inline void SetChanCtrl(EChannelId id, GXBool enable, GX::ColorSrc ambSrc, GX::ColorSrc matSrc, static inline void SetChanCtrl(EChannelId id, GXBool enable, GXColorSrc ambSrc, GXColorSrc matSrc, GX::LightMask lights,
GX::LightMask lights, GX::DiffuseFn diffFn, GX::AttnFn attnFn) noexcept { GXDiffuseFn diffFn, GXAttnFn attnFn) noexcept {
const auto idx = std::underlying_type_t<EChannelId>(id); const auto idx = std::underlying_type_t<EChannelId>(id);
if (lights.none()) { if (lights.none()) {
enable = false; enable = false;
@ -167,19 +167,22 @@ static inline void SetChanCtrl(EChannelId id, u32 flags, GX::LightMask lights) n
// Helper function for common logic // Helper function for common logic
static inline void SetChanCtrl(EChannelId id, GX::LightMask lights) noexcept { static inline void SetChanCtrl(EChannelId id, GX::LightMask lights) noexcept {
const bool hasLights = lights.any(); const bool hasLights = lights.any();
SetChanCtrl(id, hasLights, GX::SRC_REG, GX::SRC_REG, lights, hasLights ? GX::DF_CLAMP : GX::DF_NONE, SetChanCtrl(id, hasLights, GX_SRC_REG, GX_SRC_REG, lights, hasLights ? GX_DF_CLAMP : GX_DF_NONE,
hasLights ? GX::AF_SPOT : GX::AF_NONE); hasLights ? GX_AF_SPOT : GX_AF_NONE);
} }
static inline void SetChanMatColor(EChannelId id, const GXColor& color) noexcept { static inline void SetChanMatColor(EChannelId id, GXColor color) noexcept {
const auto idx = std::underlying_type_t<EChannelId>(id); const auto idx = std::underlying_type_t<EChannelId>(id);
if (color != sGXState.x40_chanMatColors[idx]) { if (color != sGXState.x40_chanMatColors[idx]) {
sGXState.x40_chanMatColors[idx] = color; sGXState.x40_chanMatColors[idx] = color;
GXSetChanMatColor(GX::ChannelID(idx + GX::COLOR0A0), color); GXSetChanMatColor(GXChannelID(idx + GX_COLOR0A0), color);
} }
} }
static inline void SetChanMatColor(EChannelId id, const zeus::CColor& color) noexcept {
SetChanMatColor(id, to_gx_color(color));
}
static inline void SetFog(GX::FogType type, float startZ, float endZ, float nearZ, float farZ, static inline void SetFog(GXFogType type, float startZ, float endZ, float nearZ, float farZ,
const GXColor& color) noexcept { const GXColor& color) noexcept {
sGXState.x25c_fogColor = color; sGXState.x25c_fogColor = color;
sGXState.x53_fogType = type; sGXState.x53_fogType = type;
@ -189,14 +192,14 @@ static inline void SetFog(GX::FogType type, float startZ, float endZ, float near
sGXState.x258_fogFarZ = farZ; sGXState.x258_fogFarZ = farZ;
auto fogColor = color; auto fogColor = color;
if ((sGXState.x56_blendMode & 0xE0) == 0x20) { if ((sGXState.x56_blendMode & 0xE0) == 0x20) {
fogColor = zeus::skClear; fogColor = GX_CLEAR;
} }
GXSetFog(type, startZ, endZ, nearZ, farZ, fogColor); GXSetFog(type, startZ, endZ, nearZ, farZ, fogColor);
} }
void SetIndTexMtxSTPointFive(GX::IndTexMtxID id, s8 scaleExp) noexcept; void SetIndTexMtxSTPointFive(GXIndTexMtxID id, s8 scaleExp) noexcept;
void SetLineWidth(u8 width, GX::TexOffset offset) noexcept; void SetLineWidth(u8 width, GXTexOffset offset) noexcept;
static inline void SetNumChans(u8 num) noexcept { static inline void SetNumChans(u8 num) noexcept {
sGXState.x4c_dirtyChans = 7; // TODO sGXState.x4c_dirtyChans = 7; // TODO
@ -227,18 +230,18 @@ static inline void SetNumTexGens(u8 num) noexcept {
} }
} }
static inline void SetStandardTevColorAlphaOp(GX::TevStageID stageId) noexcept { static inline void SetStandardTevColorAlphaOp(GXTevStageID stageId) noexcept {
auto& state = sGXState.x68_tevStates[stageId]; auto& state = sGXState.x68_tevStates[stageId];
if (state.x8_colorOps != 0x100 || state.xc_alphaOps != 0x100) { if (state.x8_colorOps != 0x100 || state.xc_alphaOps != 0x100) {
state.x8_colorOps = 0x100; state.x8_colorOps = 0x100;
state.xc_alphaOps = 0x100; state.xc_alphaOps = 0x100;
GXSetTevColorOp(stageId, GX::TEV_ADD, GX::TB_ZERO, GX::CS_SCALE_1, true, GX::TEVPREV); GXSetTevColorOp(stageId, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV);
GXSetTevAlphaOp(stageId, GX::TEV_ADD, GX::TB_ZERO, GX::CS_SCALE_1, true, GX::TEVPREV); GXSetTevAlphaOp(stageId, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV);
} }
} }
static inline void SetTevAlphaIn(GX::TevStageID stageId, GX::TevAlphaArg a, GX::TevAlphaArg b, GX::TevAlphaArg c, static inline void SetTevAlphaIn(GXTevStageID stageId, GXTevAlphaArg a, GXTevAlphaArg b, GXTevAlphaArg c,
GX::TevAlphaArg d) noexcept { GXTevAlphaArg d) noexcept {
u32 flags = (d & 31) << 15 | (c & 31) << 10 | (b & 31) << 5 | (a & 31); u32 flags = (d & 31) << 15 | (c & 31) << 10 | (b & 31) << 5 | (a & 31);
auto& state = sGXState.x68_tevStates[stageId].x4_alphaInArgs; auto& state = sGXState.x68_tevStates[stageId].x4_alphaInArgs;
if (flags != state) { if (flags != state) {
@ -247,8 +250,8 @@ static inline void SetTevAlphaIn(GX::TevStageID stageId, GX::TevAlphaArg a, GX::
} }
} }
static inline void SetTevAlphaOp(GX::TevStageID stageId, GX::TevOp op, GX::TevBias bias, GX::TevScale scale, static inline void SetTevAlphaOp(GXTevStageID stageId, GXTevOp op, GXTevBias bias, GXTevScale scale, GXBool clamp,
GXBool clamp, GX::TevRegID outReg) noexcept { GXTevRegID outReg) noexcept {
u32 flags = (outReg & 3) << 9 | (u8(clamp) & 1) << 8 | (scale & 3) << 6 | (bias & 3) << 4 | (op & 15); u32 flags = (outReg & 3) << 9 | (u8(clamp) & 1) << 8 | (scale & 3) << 6 | (bias & 3) << 4 | (op & 15);
auto& state = sGXState.x68_tevStates[stageId].xc_alphaOps; auto& state = sGXState.x68_tevStates[stageId].xc_alphaOps;
if (flags != state) { if (flags != state) {
@ -257,17 +260,17 @@ static inline void SetTevAlphaOp(GX::TevStageID stageId, GX::TevOp op, GX::TevBi
} }
} }
static inline void SetTevAlphaOp_Compressed(GX::TevStageID stageId, u32 ops) noexcept { static inline void SetTevAlphaOp_Compressed(GXTevStageID stageId, u32 ops) noexcept {
auto& state = sGXState.x68_tevStates[stageId].xc_alphaOps; auto& state = sGXState.x68_tevStates[stageId].xc_alphaOps;
if (ops != state) { if (ops != state) {
state = ops; state = ops;
GXSetTevAlphaOp(stageId, GX::TevOp(ops & 31), GX::TevBias(ops >> 4 & 3), GX::TevScale(ops >> 6 & 3), GXSetTevAlphaOp(stageId, GXTevOp(ops & 31), GXTevBias(ops >> 4 & 3), GXTevScale(ops >> 6 & 3), GXBool(ops >> 8 & 1),
GXBool(ops >> 8 & 1), GX::TevRegID(ops >> 9 & 3)); GXTevRegID(ops >> 9 & 3));
} }
} }
static inline void SetTevColorIn(GX::TevStageID stageId, GX::TevColorArg a, GX::TevColorArg b, GX::TevColorArg c, static inline void SetTevColorIn(GXTevStageID stageId, GXTevColorArg a, GXTevColorArg b, GXTevColorArg c,
GX::TevColorArg d) noexcept { GXTevColorArg d) noexcept {
u32 flags = (d & 31) << 15 | (c & 31) << 10 | (b & 31) << 5 | (a & 31); u32 flags = (d & 31) << 15 | (c & 31) << 10 | (b & 31) << 5 | (a & 31);
auto& state = sGXState.x68_tevStates[stageId].x0_colorInArgs; auto& state = sGXState.x68_tevStates[stageId].x0_colorInArgs;
if (flags != state) { if (flags != state) {
@ -276,8 +279,8 @@ static inline void SetTevColorIn(GX::TevStageID stageId, GX::TevColorArg a, GX::
} }
} }
static inline void SetTevColorOp(GX::TevStageID stageId, GX::TevOp op, GX::TevBias bias, GX::TevScale scale, static inline void SetTevColorOp(GXTevStageID stageId, GXTevOp op, GXTevBias bias, GXTevScale scale, GXBool clamp,
GXBool clamp, GX::TevRegID outReg) noexcept { GXTevRegID outReg) noexcept {
u32 flags = (outReg & 3) << 9 | (u8(clamp) & 1) << 8 | (scale & 3) << 6 | (bias & 3) << 4 | (op & 15); u32 flags = (outReg & 3) << 9 | (u8(clamp) & 1) << 8 | (scale & 3) << 6 | (bias & 3) << 4 | (op & 15);
auto& state = sGXState.x68_tevStates[stageId].x8_colorOps; auto& state = sGXState.x68_tevStates[stageId].x8_colorOps;
if (flags != state) { if (flags != state) {
@ -286,16 +289,16 @@ static inline void SetTevColorOp(GX::TevStageID stageId, GX::TevOp op, GX::TevBi
} }
} }
static inline void SetTevColorOp_Compressed(GX::TevStageID stageId, u32 ops) noexcept { static inline void SetTevColorOp_Compressed(GXTevStageID stageId, u32 ops) noexcept {
auto& state = sGXState.x68_tevStates[stageId].x8_colorOps; auto& state = sGXState.x68_tevStates[stageId].x8_colorOps;
if (ops != state) { if (ops != state) {
state = ops; state = ops;
GXSetTevColorOp(stageId, GX::TevOp(ops & 31), GX::TevBias(ops >> 4 & 3), GX::TevScale(ops >> 6 & 3), GXSetTevColorOp(stageId, GXTevOp(ops & 31), GXTevBias(ops >> 4 & 3), GXTevScale(ops >> 6 & 3), GXBool(ops >> 8 & 1),
GXBool(ops >> 8 & 1), GX::TevRegID(ops >> 9 & 3)); GXTevRegID(ops >> 9 & 3));
} }
} }
static inline void SetTevDirect(GX::TevStageID stageId) noexcept { static inline void SetTevDirect(GXTevStageID stageId) noexcept {
auto& state = sGXState.x68_tevStates[stageId].x10_indFlags; auto& state = sGXState.x68_tevStates[stageId].x10_indFlags;
if (state != 0) { if (state != 0) {
state = 0; state = 0;
@ -303,19 +306,19 @@ static inline void SetTevDirect(GX::TevStageID stageId) noexcept {
} }
} }
static inline void SetStandardDirectTev_Compressed(GX::TevStageID stageId, u32 colorArgs, u32 alphaArgs, u32 colorOps, static inline void SetStandardDirectTev_Compressed(GXTevStageID stageId, u32 colorArgs, u32 alphaArgs, u32 colorOps,
u32 alphaOps) noexcept { u32 alphaOps) noexcept {
auto& state = sGXState.x68_tevStates[stageId]; auto& state = sGXState.x68_tevStates[stageId];
SetTevDirect(stageId); SetTevDirect(stageId);
if (state.x0_colorInArgs != colorArgs) { if (state.x0_colorInArgs != colorArgs) {
state.x0_colorInArgs = colorArgs; state.x0_colorInArgs = colorArgs;
GXSetTevColorIn(stageId, GX::TevColorArg(colorArgs & 31), GX::TevColorArg(colorArgs >> 5 & 31), GXSetTevColorIn(stageId, GXTevColorArg(colorArgs & 31), GXTevColorArg(colorArgs >> 5 & 31),
GX::TevColorArg(colorArgs >> 10 & 31), GX::TevColorArg(colorArgs >> 15 & 31)); GXTevColorArg(colorArgs >> 10 & 31), GXTevColorArg(colorArgs >> 15 & 31));
} }
if (state.x4_alphaInArgs != alphaArgs) { if (state.x4_alphaInArgs != alphaArgs) {
state.x4_alphaInArgs = alphaArgs; state.x4_alphaInArgs = alphaArgs;
GXSetTevAlphaIn(stageId, GX::TevAlphaArg(alphaArgs & 31), GX::TevAlphaArg(alphaArgs >> 5 & 31), GXSetTevAlphaIn(stageId, GXTevAlphaArg(alphaArgs & 31), GXTevAlphaArg(alphaArgs >> 5 & 31),
GX::TevAlphaArg(alphaArgs >> 10 & 31), GX::TevAlphaArg(alphaArgs >> 15 & 31)); GXTevAlphaArg(alphaArgs >> 10 & 31), GXTevAlphaArg(alphaArgs >> 15 & 31));
} }
if (colorOps != alphaOps || (colorOps & 0x1FF) != 0x100) { if (colorOps != alphaOps || (colorOps & 0x1FF) != 0x100) {
SetTevColorOp_Compressed(stageId, colorOps); SetTevColorOp_Compressed(stageId, colorOps);
@ -323,27 +326,26 @@ static inline void SetStandardDirectTev_Compressed(GX::TevStageID stageId, u32 c
} else if (colorOps != state.x8_colorOps || colorOps != state.xc_alphaOps) { } else if (colorOps != state.x8_colorOps || colorOps != state.xc_alphaOps) {
state.x8_colorOps = colorOps; state.x8_colorOps = colorOps;
state.xc_alphaOps = colorOps; state.xc_alphaOps = colorOps;
const auto outReg = GX::TevRegID(colorOps >> 9 & 3); const auto outReg = GXTevRegID(colorOps >> 9 & 3);
GXSetTevColorOp(stageId, GX::TEV_ADD, GX::TB_ZERO, GX::CS_SCALE_1, true, outReg); GXSetTevColorOp(stageId, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, outReg);
GXSetTevAlphaOp(stageId, GX::TEV_ADD, GX::TB_ZERO, GX::CS_SCALE_1, true, outReg); GXSetTevAlphaOp(stageId, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, outReg);
} }
} }
static inline void SetTevIndirect(GX::TevStageID stageId, GX::IndTexStageID indStage, GX::IndTexFormat fmt, static inline void SetTevIndirect(GXTevStageID stageId, GXIndTexStageID indStage, GXIndTexFormat fmt,
GX::IndTexBiasSel biasSel, GX::IndTexMtxID mtxSel, GX::IndTexWrap wrapS, GXIndTexBiasSel biasSel, GXIndTexMtxID mtxSel, GXIndTexWrap wrapS, GXIndTexWrap wrapT,
GX::IndTexWrap wrapT, GXBool addPrev, GXBool indLod, GXBool addPrev, GXBool indLod, GXIndTexAlphaSel alphaSel) noexcept {
GX::IndTexAlphaSel alphaSel) noexcept {
// TODO // TODO
GXSetTevIndirect(stageId, indStage, fmt, biasSel, mtxSel, wrapS, wrapT, addPrev, indLod, alphaSel); GXSetTevIndirect(stageId, indStage, fmt, biasSel, mtxSel, wrapS, wrapT, addPrev, indLod, alphaSel);
} }
static inline void SetTevIndWarp(GX::TevStageID stageId, GX::IndTexStageID indStage, GXBool signedOffset, static inline void SetTevIndWarp(GXTevStageID stageId, GXIndTexStageID indStage, GXBool signedOffset,
GXBool replaceMode, GX::IndTexMtxID mtxSel) noexcept { GXBool replaceMode, GXIndTexMtxID mtxSel) noexcept {
// TODO // TODO
GXSetTevIndWarp(stageId, indStage, signedOffset, replaceMode, mtxSel); GXSetTevIndWarp(stageId, indStage, signedOffset, replaceMode, mtxSel);
} }
static inline void SetTevKAlphaSel(GX::TevStageID stageId, GX::TevKAlphaSel sel) noexcept { static inline void SetTevKAlphaSel(GXTevStageID stageId, GXTevKAlphaSel sel) noexcept {
auto& state = sGXState.x68_tevStates[stageId].x19_kAlphaSel; auto& state = sGXState.x68_tevStates[stageId].x19_kAlphaSel;
if (sel != state) { if (sel != state) {
state = sel; state = sel;
@ -351,15 +353,18 @@ static inline void SetTevKAlphaSel(GX::TevStageID stageId, GX::TevKAlphaSel sel)
} }
} }
static inline void SetTevKColor(GX::TevKColorID id, const GXColor& color) noexcept { static inline void SetTevKColor(GXTevKColorID id, const GXColor& color) noexcept {
auto& state = sGXState.x58_kColors[id]; auto& state = sGXState.x58_kColors[id];
if (color != state) { if (color != state) {
state = color; state = color;
GXSetTevKColor(id, color); GXSetTevKColor(id, color);
} }
} }
static inline void SetTevKColor(GXTevKColorID id, const zeus::CColor& color) noexcept {
SetTevKColor(id, to_gx_color(color));
}
static inline void SetTevKColorSel(GX::TevStageID stageId, GX::TevKColorSel sel) noexcept { static inline void SetTevKColorSel(GXTevStageID stageId, GXTevKColorSel sel) noexcept {
auto& state = sGXState.x68_tevStates[stageId].x18_kColorSel; auto& state = sGXState.x68_tevStates[stageId].x18_kColorSel;
if (sel != state) { if (sel != state) {
state = sel; state = sel;
@ -367,8 +372,8 @@ static inline void SetTevKColorSel(GX::TevStageID stageId, GX::TevKColorSel sel)
} }
} }
static inline void SetTevOrder(GX::TevStageID stageId, GX::TexCoordID texCoord, GX::TexMapID texMap, static inline void SetTevOrder(GXTevStageID stageId, GXTexCoordID texCoord, GXTexMapID texMap,
GX::ChannelID color) noexcept { GXChannelID color) noexcept {
u32 flags = (color & 0xFF) << 16 | (texMap & 0xFF) << 8 | (texCoord & 0xFF); u32 flags = (color & 0xFF) << 16 | (texMap & 0xFF) << 8 | (texCoord & 0xFF);
auto& state = sGXState.x68_tevStates[stageId].x14_tevOrderFlags; auto& state = sGXState.x68_tevStates[stageId].x14_tevOrderFlags;
if (flags != state) { if (flags != state) {
@ -377,9 +382,9 @@ static inline void SetTevOrder(GX::TevStageID stageId, GX::TexCoordID texCoord,
} }
} }
static inline void SetTexCoordGen(GX::TexCoordID dstCoord, GX::TexGenType fn, GX::TexGenSrc src, GX::TexMtx mtx, static inline void SetTexCoordGen(GXTexCoordID dstCoord, GXTexGenType fn, GXTexGenSrc src, GXTexMtx mtx,
GXBool normalize, GX::PTTexMtx postMtx) noexcept { GXBool normalize, GXPTTexMtx postMtx) noexcept {
u32 flags = ((postMtx - GX::PTTEXMTX0) & 63) << 15 | (u8(normalize) & 1) << 14 | ((mtx - GX::TEXMTX0) & 31) << 9 | u32 flags = ((postMtx - GX_PTTEXMTX0) & 63) << 15 | (u8(normalize) & 1) << 14 | ((mtx - GX_TEXMTX0) & 31) << 9 |
(src & 31) << 4 | (fn & 15); (src & 31) << 4 | (fn & 15);
auto& state = sGXState.x228_texStates[dstCoord].x0_coordGen; auto& state = sGXState.x228_texStates[dstCoord].x0_coordGen;
if (flags != state) { if (flags != state) {
@ -388,13 +393,13 @@ static inline void SetTexCoordGen(GX::TexCoordID dstCoord, GX::TexGenType fn, GX
} }
} }
static inline void SetTexCoordGen(GX::TexCoordID dstCoord, u32 flags) noexcept { static inline void SetTexCoordGen(GXTexCoordID dstCoord, u32 flags) noexcept {
auto& state = sGXState.x228_texStates[dstCoord].x0_coordGen; auto& state = sGXState.x228_texStates[dstCoord].x0_coordGen;
if (flags != state) { if (flags != state) {
state = flags; state = flags;
GXSetTexCoordGen2(dstCoord, GX::TexGenType(flags & 15), GX::TexGenSrc(flags >> 4 & 31), GXSetTexCoordGen2(dstCoord, GXTexGenType(flags & 15), GXTexGenSrc(flags >> 4 & 31),
GX::TexMtx((flags >> 9 & 31) + GX::TEXMTX0), GXBool(flags >> 14 & 1), GXTexMtx((flags >> 9 & 31) + GX_TEXMTX0), GXBool(flags >> 14 & 1),
GX::PTTexMtx((flags >> 15 & 63) + GX::PTTEXMTX0)); GXPTTexMtx((flags >> 15 & 63) + GX_PTTEXMTX0));
} }
} }
@ -406,28 +411,28 @@ static inline void SetVtxDescv_Compressed(u32 descList) noexcept {
u32 attrIdx = 0; u32 attrIdx = 0;
do { do {
sVtxDescList[attrIdx] = { sVtxDescList[attrIdx] = {
GX::Attr(GX::VA_POS + attrIdx), GXAttr(GX_VA_POS + attrIdx),
GX::AttrType(descList >> shift & 3), GXAttrType(descList >> shift & 3),
}; };
shift += 2; shift += 2;
++attrIdx; ++attrIdx;
--remain; --remain;
} while (remain != 0); } while (remain != 0);
sVtxDescList[attrIdx] = {}; sVtxDescList[attrIdx] = {GX_VA_NULL, GX_NONE};
GXSetVtxDescv(sVtxDescList.data()); GXSetVtxDescv(sVtxDescList.data());
sGXState.x48_descList = descList; sGXState.x48_descList = descList;
} }
} }
static inline void SetVtxDescv(const GX::VtxDescList* descList) noexcept { static inline void SetVtxDescv(const GXVtxDescList* descList) noexcept {
u32 flags = 0; u32 flags = 0;
for (; descList->attr != GX::VA_NULL; ++descList) { for (; descList->attr != GX_VA_NULL; ++descList) {
flags |= (descList->type & 3) << (descList->attr - GX::VA_POS) * 2; flags |= (descList->type & 3) << (descList->attr - GX_VA_POS) * 2;
} }
SetVtxDescv_Compressed(flags); SetVtxDescv_Compressed(flags);
} }
static inline void SetZMode(GXBool compareEnable, GX::Compare func, GXBool updateEnable) noexcept { static inline void SetZMode(GXBool compareEnable, GXCompare func, GXBool updateEnable) noexcept {
u32 flags = (func & 0xFF) << 2 | (u8(updateEnable) << 1) | (u8(compareEnable) & 1); u32 flags = (func & 0xFF) << 2 | (u8(updateEnable) << 1) | (u8(compareEnable) & 1);
auto& state = sGXState.x52_zmode; auto& state = sGXState.x52_zmode;
if (flags != state) { if (flags != state) {
@ -436,7 +441,7 @@ static inline void SetZMode(GXBool compareEnable, GX::Compare func, GXBool updat
} }
} }
static inline void GetFog(GX::FogType* fogType, float* fogStartZ, float* fogEndZ, float* fogNearZ, float* fogFarZ, static inline void GetFog(GXFogType* fogType, float* fogStartZ, float* fogEndZ, float* fogNearZ, float* fogFarZ,
GXColor* fogColor) { GXColor* fogColor) {
if (fogType != nullptr) { if (fogType != nullptr) {
*fogType = sGXState.x53_fogType; *fogType = sGXState.x53_fogType;

View File

@ -18,7 +18,7 @@ u32 CGraphics::g_FlippingState;
bool CGraphics::g_LastFrameUsedAbove = false; bool CGraphics::g_LastFrameUsedAbove = false;
bool CGraphics::g_InterruptLastFrameUsedAbove = false; bool CGraphics::g_InterruptLastFrameUsedAbove = false;
GX::LightMask CGraphics::g_LightActive{}; GX::LightMask CGraphics::g_LightActive{};
std::array<GX::LightObj, GX::MaxLights> CGraphics::g_LightObjs; std::array<GXLightObj, GX::MaxLights> CGraphics::g_LightObjs;
std::array<ELightType, GX::MaxLights> CGraphics::g_LightTypes; std::array<ELightType, GX::MaxLights> CGraphics::g_LightTypes;
zeus::CTransform CGraphics::g_GXModelView; zeus::CTransform CGraphics::g_GXModelView;
zeus::CTransform CGraphics::g_GXModelViewInvXpose; zeus::CTransform CGraphics::g_GXModelViewInvXpose;
@ -59,8 +59,8 @@ const std::array<zeus::CMatrix3f, 6> CGraphics::skCubeBasisMats{{
}}; }};
// Stream API // Stream API
static EStreamFlags sStreamFlags; static u32 sStreamFlags;
static GX::Primitive sStreamPrimitive; static GXPrimitive sStreamPrimitive;
static u32 sVerticesCount; static u32 sVerticesCount;
static zeus::CColor sQueuedColor; static zeus::CColor sQueuedColor;
// Originally writes directly to GX FIFO // Originally writes directly to GX FIFO
@ -80,7 +80,7 @@ void CGraphics::DisableAllLights() {
} }
void CGraphics::LoadLight(ERglLight light, const CLight& info) { void CGraphics::LoadLight(ERglLight light, const CLight& info) {
const auto lightId = static_cast<GX::LightID>(1 << light); const auto lightId = static_cast<GXLightID>(1 << light);
auto& obj = g_LightObjs[light]; auto& obj = g_LightObjs[light];
zeus::CVector3f pos = info.GetPosition(); zeus::CVector3f pos = info.GetPosition();
@ -97,7 +97,7 @@ void CGraphics::LoadLight(ERglLight light, const CLight& info) {
GXInitLightDir(&obj, dir.x(), dir.y(), dir.z()); GXInitLightDir(&obj, dir.x(), dir.y(), dir.z());
GXInitLightAttn(&obj, 1.f, 0.f, 0.f, info.GetAttenuationConstant(), info.GetAttenuationLinear(), GXInitLightAttn(&obj, 1.f, 0.f, 0.f, info.GetAttenuationConstant(), info.GetAttenuationLinear(),
info.GetAttenuationQuadratic()); info.GetAttenuationQuadratic());
GXInitLightSpot(&obj, info.GetSpotCutoff(), GX::SP_COS2); GXInitLightSpot(&obj, info.GetSpotCutoff(), GX_SP_COS2);
} else if (type == ELightType::Custom) { } else if (type == ELightType::Custom) {
pos = g_CameraMatrix * pos; pos = g_CameraMatrix * pos;
GXInitLightPos(&obj, pos.x(), pos.y(), pos.z()); GXInitLightPos(&obj, pos.x(), pos.y(), pos.z());
@ -114,8 +114,8 @@ void CGraphics::LoadLight(ERglLight light, const CLight& info) {
} }
g_LightTypes[light] = type; g_LightTypes[light] = type;
GX::Color col(info.GetColor().r(), info.GetColor().g(), info.GetColor().b()); zeus::CColor col(info.GetColor().r(), info.GetColor().g(), info.GetColor().b());
GXInitLightColor(&obj, col); GXInitLightColor(&obj, to_gx_color(col));
GXLoadLightObjImm(&obj, lightId); GXLoadLightObjImm(&obj, lightId);
} }
@ -130,9 +130,9 @@ void CGraphics::EnableLight(ERglLight light) {
void CGraphics::SetLightState(GX::LightMask lightState) { void CGraphics::SetLightState(GX::LightMask lightState) {
g_LightActive = lightState; g_LightActive = lightState;
const bool hasLights = lightState.any(); const bool hasLights = lightState.any();
CGX::SetChanCtrl(CGX::EChannelId::Channel0, hasLights, GX::SRC_REG, CGX::SetChanCtrl(CGX::EChannelId::Channel0, hasLights, GX_SRC_REG,
sStreamFlags & EStreamFlagBits::fHasColor ? GX::SRC_VTX : GX::SRC_REG, lightState, sStreamFlags & 2 /* fHasColor */ ? GX_SRC_VTX : GX_SRC_REG, lightState,
hasLights ? GX::DF_CLAMP : GX::DF_NONE, hasLights ? GX::AF_SPOT : GX::AF_NONE); hasLights ? GX_DF_CLAMP : GX_DF_NONE, hasLights ? GX_AF_SPOT : GX_AF_NONE);
} }
void CGraphics::SetAmbientColor(const zeus::CColor& col) { void CGraphics::SetAmbientColor(const zeus::CColor& col) {
@ -141,21 +141,21 @@ void CGraphics::SetAmbientColor(const zeus::CColor& col) {
} }
void CGraphics::SetFog(ERglFogMode mode, float startz, float endz, const zeus::CColor& color) { void CGraphics::SetFog(ERglFogMode mode, float startz, float endz, const zeus::CColor& color) {
CGX::SetFog(GX::FogType(mode), startz, endz, g_Proj.x14_near, g_Proj.x18_far, color); CGX::SetFog(GXFogType(mode), startz, endz, g_Proj.x14_near, g_Proj.x18_far, to_gx_color(color));
} }
void CGraphics::SetDepthWriteMode(bool compare_enable, ERglEnum comp, bool update_enable) { void CGraphics::SetDepthWriteMode(bool compare_enable, ERglEnum comp, bool update_enable) {
g_depthFunc = comp; g_depthFunc = comp;
CGX::SetZMode(compare_enable, GX::Compare(comp), update_enable); CGX::SetZMode(compare_enable, GXCompare(comp), update_enable);
} }
void CGraphics::SetBlendMode(ERglBlendMode mode, ERglBlendFactor src, ERglBlendFactor dst, ERglLogicOp op) { void CGraphics::SetBlendMode(ERglBlendMode mode, ERglBlendFactor src, ERglBlendFactor dst, ERglLogicOp op) {
CGX::SetBlendMode(GX::BlendMode(mode), GX::BlendFactor(src), GX::BlendFactor(dst), GX::LogicOp(op)); CGX::SetBlendMode(GXBlendMode(mode), GXBlendFactor(src), GXBlendFactor(dst), GXLogicOp(op));
} }
void CGraphics::SetCullMode(ERglCullMode mode) { void CGraphics::SetCullMode(ERglCullMode mode) {
g_cullMode = mode; g_cullMode = mode;
GXSetCullMode(GX::CullMode(mode)); GXSetCullMode(GXCullMode(mode));
} }
void CGraphics::BeginScene() { void CGraphics::BeginScene() {
@ -163,7 +163,7 @@ void CGraphics::BeginScene() {
} }
void CGraphics::EndScene() { void CGraphics::EndScene() {
CGX::SetZMode(true, GX::LEQUAL, true); CGX::SetZMode(true, GX_LEQUAL, true);
/* Spinwait until g_NumBreakpointsWaiting is 0 */ /* Spinwait until g_NumBreakpointsWaiting is 0 */
/* ++g_NumBreakpointsWaiting; */ /* ++g_NumBreakpointsWaiting; */
@ -190,10 +190,10 @@ void CGraphics::Render2D(CTexture& tex, u32 x, u32 y, u32 w, u32 h, const zeus::
const auto oldLights = g_LightActive; const auto oldLights = g_LightActive;
SetOrtho(-g_Viewport.x10_halfWidth, g_Viewport.x10_halfWidth, g_Viewport.x14_halfHeight, -g_Viewport.x14_halfHeight, SetOrtho(-g_Viewport.x10_halfWidth, g_Viewport.x10_halfWidth, g_Viewport.x14_halfHeight, -g_Viewport.x14_halfHeight,
-1.f, -10.f); -1.f, -10.f);
GXLoadPosMtxImm({}, GX::PNMTX0); GXLoadPosMtxImm({}, GX_PNMTX0);
DisableAllLights(); DisableAllLights();
SetCullMode(ERglCullMode::None); SetCullMode(ERglCullMode::None);
tex.Load(GX::TEXMAP0, EClampMode::Repeat); tex.Load(GX_TEXMAP0, EClampMode::Repeat);
// float hPad, vPad; // float hPad, vPad;
// if (CGraphics::GetViewportAspect() >= 1.78f) { // if (CGraphics::GetViewportAspect() >= 1.78f) {
@ -213,7 +213,7 @@ void CGraphics::Render2D(CTexture& tex, u32 x, u32 y, u32 w, u32 h, const zeus::
float y1 = scaledY - g_Viewport.x14_halfHeight; float y1 = scaledY - g_Viewport.x14_halfHeight;
float x2 = x1 + scaledW; float x2 = x1 + scaledW;
float y2 = y1 + scaledH; float y2 = y1 + scaledH;
StreamBegin(GX::TRIANGLESTRIP); StreamBegin(GX_TRIANGLESTRIP);
StreamColor(col); StreamColor(col);
StreamTexcoord(0.f, 0.f); StreamTexcoord(0.f, 0.f);
StreamVertex(x1, y1, 1.f); StreamVertex(x1, y1, 1.f);
@ -240,8 +240,8 @@ void CGraphics::DoRender2D(const CTexture& tex, s32 x, s32 y, s32 w1, s32 w2, s3
void CGraphics::EndRender2D(bool v) {} void CGraphics::EndRender2D(bool v) {}
void CGraphics::SetAlphaCompare(ERglAlphaFunc comp0, u8 ref0, ERglAlphaOp op, ERglAlphaFunc comp1, u8 ref1) { void CGraphics::SetAlphaCompare(ERglAlphaFunc comp0, u8 ref0, ERglAlphaOp op, ERglAlphaFunc comp1, u8 ref1) {
CGX::SetAlphaCompare(static_cast<GX::Compare>(comp0), ref0, static_cast<GX::AlphaOp>(op), CGX::SetAlphaCompare(static_cast<GXCompare>(comp0), ref0, static_cast<GXAlphaOp>(op), static_cast<GXCompare>(comp1),
static_cast<GX::Compare>(comp1), ref1); ref1);
} }
void CGraphics::SetViewPointMatrix(const zeus::CTransform& xf) { void CGraphics::SetViewPointMatrix(const zeus::CTransform& xf) {
@ -259,12 +259,12 @@ void CGraphics::SetViewMatrix() {
else else
g_GXModelView = g_CameraMatrix * g_GXModelMatrix; g_GXModelView = g_CameraMatrix * g_GXModelMatrix;
/* Load position matrix */ /* Load position matrix */
GXLoadPosMtxImm(g_GXModelView, GX::PNMTX0); GXLoadPosMtxImm(&g_GXModelView, GX_PNMTX0);
/* Inverse-transpose */ /* Inverse-transpose */
g_GXModelViewInvXpose = g_GXModelView.inverse(); g_GXModelViewInvXpose = g_GXModelView.inverse();
g_GXModelViewInvXpose.basis.transpose(); g_GXModelViewInvXpose.basis.transpose();
/* Load normal matrix */ /* Load normal matrix */
GXLoadNrmMtxImm(g_GXModelViewInvXpose, GX::PNMTX0); GXLoadNrmMtxImm(&g_GXModelViewInvXpose, GX_PNMTX0);
} }
void CGraphics::SetModelMatrix(const zeus::CTransform& xf) { void CGraphics::SetModelMatrix(const zeus::CTransform& xf) {
@ -316,7 +316,7 @@ zeus::CMatrix4f CGraphics::GetPerspectiveProjectionMatrix() {
return { return {
2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f, 0.f, 2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f, 0.f,
2.f * g_Proj.x14_near / tmb, tpb / tmb, 0.f, 2.f * g_Proj.x14_near / tmb, tpb / tmb, 0.f,
0.f, 0.f, -fpn / fmn, -2.f * g_Proj.x18_far * g_Proj.x14_near / fmn, 0.f, 0.f, -g_Proj.x14_near / fmn, -(g_Proj.x18_far * g_Proj.x14_near) / fmn,
0.f, 0.f, -1.f, 0.f, 0.f, 0.f, -1.f, 0.f,
}; };
// clang-format on // clang-format on
@ -330,7 +330,7 @@ zeus::CMatrix4f CGraphics::GetPerspectiveProjectionMatrix() {
return { return {
2.f / rml, 0.f, 0.f, -rpl / rml, 2.f / rml, 0.f, 0.f, -rpl / rml,
0.f, 2.f / tmb, 0.f, -tpb / tmb, 0.f, 2.f / tmb, 0.f, -tpb / tmb,
0.f, 0.f, -1.f / fmn, -g_Proj.x14_near / fmn, 0.f, 0.f, -1.f / fmn, -g_Proj.x18_far / fmn,
0.f, 0.f, 0.f, 1.f 0.f, 0.f, 0.f, 1.f
}; };
// clang-format on // clang-format on
@ -375,10 +375,10 @@ void CGraphics::FlushProjection() {
const auto mtx = GetPerspectiveProjectionMatrix(); const auto mtx = GetPerspectiveProjectionMatrix();
if (g_Proj.x0_persp) { if (g_Proj.x0_persp) {
// Convert and load persp // Convert and load persp
GXSetProjection(mtx, GX::PERSPECTIVE); GXSetProjection(&mtx, GX_PERSPECTIVE);
} else { } else {
// Convert and load ortho // Convert and load ortho
GXSetProjection(mtx, GX::ORTHOGRAPHIC); GXSetProjection(&mtx, GX_ORTHOGRAPHIC);
} }
} }
@ -521,14 +521,14 @@ void CGraphics::SetUseVideoFilter(bool filter) {
void CGraphics::SetClearColor(const zeus::CColor& color) { void CGraphics::SetClearColor(const zeus::CColor& color) {
g_ClearColor = color; g_ClearColor = color;
GXSetCopyClear(color, g_ClearDepthValue); GXSetCopyClear(to_gx_color(color), g_ClearDepthValue);
} }
void CGraphics::SetCopyClear(const zeus::CColor& color, float depth) { void CGraphics::SetCopyClear(const zeus::CColor& color, float depth) {
g_ClearColor = color; g_ClearColor = color;
g_ClearDepthValue = depth; // 1.6777215E7 * depth; Metroid Prime needed this to convert float [0,1] depth into 24 bit g_ClearDepthValue = depth; // 1.6777215E7 * depth; Metroid Prime needed this to convert float [0,1] depth into 24 bit
// range, we no longer have this requirement // range, we no longer have this requirement
GXSetCopyClear(g_ClearColor, g_ClearDepthValue); GXSetCopyClear(to_gx_color(g_ClearColor), g_ClearDepthValue);
} }
void CGraphics::SetIsBeginSceneClearFb(bool clear) { g_IsBeginSceneClearFb = clear; } void CGraphics::SetIsBeginSceneClearFb(bool clear) { g_IsBeginSceneClearFb = clear; }
@ -537,19 +537,19 @@ void CGraphics::SetTevOp(ERglTevStage stage, const CTevCombiners::CTevPass& pass
CTevCombiners::SetupPass(stage, pass); CTevCombiners::SetupPass(stage, pass);
} }
void CGraphics::StreamBegin(GX::Primitive primitive) { void CGraphics::StreamBegin(GXPrimitive primitive) {
// Originally ResetVertexDataStream(true); // Originally ResetVertexDataStream(true);
sQueuedVertices.clear(); sQueuedVertices.clear();
sQueuedVertices.emplace_back(sQueuedColor); sQueuedVertices.emplace_back(sQueuedColor);
sVerticesCount = 0; sVerticesCount = 0;
// End // End
sStreamFlags = EStreamFlagBits::fHasColor; sStreamFlags = 2;
sStreamPrimitive = primitive; sStreamPrimitive = primitive;
} }
void CGraphics::StreamNormal(const zeus::CVector3f& nrm) { void CGraphics::StreamNormal(const zeus::CVector3f& nrm) {
sQueuedVertices.back().normal = nrm; sQueuedVertices.back().normal = nrm;
sStreamFlags |= EStreamFlagBits::fHasNormal; sStreamFlags |= 1;
} }
void CGraphics::StreamColor(const zeus::CColor& color) { void CGraphics::StreamColor(const zeus::CColor& color) {
@ -558,12 +558,12 @@ void CGraphics::StreamColor(const zeus::CColor& color) {
} else { } else {
sQueuedColor = color; sQueuedColor = color;
} }
sStreamFlags |= EStreamFlagBits::fHasColor; sStreamFlags |= 2;
} }
void CGraphics::StreamTexcoord(const zeus::CVector2f& uv) { void CGraphics::StreamTexcoord(const zeus::CVector2f& uv) {
sQueuedVertices.back().texCoord = uv; sQueuedVertices.back().texCoord = uv;
sStreamFlags |= EStreamFlagBits::fHasTexture; sStreamFlags |= 4;
} }
void CGraphics::StreamVertex(const zeus::CVector3f& pos) { void CGraphics::StreamVertex(const zeus::CVector3f& pos) {
@ -589,35 +589,36 @@ void CGraphics::UpdateVertexDataStream() {
} }
void CGraphics::FlushStream() { void CGraphics::FlushStream() {
std::array<GX::VtxDescList, 5> vtxDescList{}; std::array<GXVtxDescList, 5> vtxDescList{};
size_t idx = 0; size_t idx = 0;
vtxDescList[idx++] = {GX::VA_POS, GX::DIRECT}; vtxDescList[idx++] = {GX_VA_POS, GX_DIRECT};
if (sStreamFlags & EStreamFlagBits::fHasNormal) { if (sStreamFlags & 1) {
vtxDescList[idx++] = {GX::VA_NRM, GX::DIRECT}; vtxDescList[idx++] = {GX_VA_NRM, GX_DIRECT};
} }
if (sStreamFlags & EStreamFlagBits::fHasColor) { if (sStreamFlags & 2) {
vtxDescList[idx++] = {GX::VA_CLR0, GX::DIRECT}; vtxDescList[idx++] = {GX_VA_CLR0, GX_DIRECT};
} }
if (sStreamFlags & EStreamFlagBits::fHasTexture) { if (sStreamFlags & 4) {
vtxDescList[idx++] = {GX::VA_TEX0, GX::DIRECT}; vtxDescList[idx++] = {GX_VA_TEX0, GX_DIRECT};
} }
vtxDescList[idx] = {GX_VA_NULL, GX_NONE};
CGX::SetVtxDescv(vtxDescList.data()); CGX::SetVtxDescv(vtxDescList.data());
SetTevStates(sStreamFlags); SetTevStates(sStreamFlags);
FullRender(); FullRender();
} }
void CGraphics::FullRender() { void CGraphics::FullRender() {
CGX::Begin(sStreamPrimitive, GX::VTXFMT0, sVerticesCount); CGX::Begin(sStreamPrimitive, GX_VTXFMT0, sVerticesCount);
for (size_t i = 0; i < sVerticesCount; ++i) { for (size_t i = 0; i < sVerticesCount; ++i) {
const auto& item = sQueuedVertices[i]; const auto& item = sQueuedVertices[i];
GXPosition3f32(item.vertex); GXPosition3f32(item.vertex);
if (sStreamFlags & EStreamFlagBits::fHasNormal) { if (sStreamFlags & 1) {
GXNormal3f32(item.normal); GXNormal3f32(item.normal);
} }
if (sStreamFlags & EStreamFlagBits::fHasColor) { if (sStreamFlags & 2) {
GXColor4f32(item.color); GXColor4f32(item.color);
} }
if (sStreamFlags & EStreamFlagBits::fHasTexture) { if (sStreamFlags & 4) {
GXTexCoord2f32(item.texCoord); GXTexCoord2f32(item.texCoord);
} }
} }
@ -638,7 +639,7 @@ void CGraphics::ResetVertexDataStream(bool end) {
} }
} }
void CGraphics::DrawPrimitive(GX::Primitive primitive, const zeus::CVector3f* pos, const zeus::CVector3f& normal, void CGraphics::DrawPrimitive(GXPrimitive primitive, const zeus::CVector3f* pos, const zeus::CVector3f& normal,
const zeus::CColor& col, s32 numVerts) { const zeus::CColor& col, s32 numVerts) {
StreamBegin(primitive); StreamBegin(primitive);
StreamColor(col); StreamColor(col);
@ -649,25 +650,25 @@ void CGraphics::DrawPrimitive(GX::Primitive primitive, const zeus::CVector3f* po
StreamEnd(); StreamEnd();
} }
void CGraphics::SetTevStates(EStreamFlags flags) noexcept { void CGraphics::SetTevStates(u32 flags) noexcept {
if (flags & EStreamFlagBits::fHasTexture) { if (flags & 4 /* fHasTexture */) {
CGX::SetNumTexGens(1); // sTextureUsed & 3? CGX::SetNumTexGens(1); // sTextureUsed & 3?
CGX::SetTevOrder(GX::TEVSTAGE0, GX::TEXCOORD0, GX::TEXMAP0, GX::COLOR0A0); CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
CGX::SetTevOrder(GX::TEVSTAGE1, GX::TEXCOORD1, GX::TEXMAP1, GX::COLOR0A0); CGX::SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD1, GX_TEXMAP1, GX_COLOR0A0);
} else { } else {
CGX::SetNumTexGens(0); CGX::SetNumTexGens(0);
CGX::SetNumTevStages(1); CGX::SetNumTevStages(1);
CGX::SetTevOrder(GX::TEVSTAGE0, GX::TEXCOORD_NULL, GX::TEXMAP_NULL, GX::COLOR0A0); CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0);
CGX::SetTevOrder(GX::TEVSTAGE1, GX::TEXCOORD_NULL, GX::TEXMAP_NULL, GX::COLOR0A0); CGX::SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0);
} }
CGX::SetNumChans(1); CGX::SetNumChans(1);
CGX::SetNumIndStages(0); CGX::SetNumIndStages(0);
CGX::SetTexCoordGen(GX::TEXCOORD0, GX::TG_MTX2x4, GX::TG_TEX0, GX::IDENTITY, false, GX::PTIDENTITY); CGX::SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY, false, GX_PTIDENTITY);
CGX::SetTexCoordGen(GX::TEXCOORD1, GX::TG_MTX2x4, GX::TG_TEX1, GX::IDENTITY, false, GX::PTIDENTITY); CGX::SetTexCoordGen(GX_TEXCOORD1, GX_TG_MTX2x4, GX_TG_TEX1, GX_IDENTITY, false, GX_PTIDENTITY);
const bool hasLights = g_LightActive.any(); const bool hasLights = g_LightActive.any();
CGX::SetChanCtrl(CGX::EChannelId::Channel0, hasLights, GX::SRC_REG, CGX::SetChanCtrl(CGX::EChannelId::Channel0, hasLights, GX_SRC_REG,
flags & EStreamFlagBits::fHasColor ? GX::SRC_VTX : GX::SRC_REG, g_LightActive, flags & 2 /* fHasColor */ ? GX_SRC_VTX : GX_SRC_REG, g_LightActive,
hasLights ? GX::DF_CLAMP : GX::DF_NONE, hasLights ? GX::AF_SPOT : GX::AF_NONE); hasLights ? GX_DF_CLAMP : GX_DF_NONE, hasLights ? GX_AF_SPOT : GX_AF_NONE);
CGX::FlushState(); // normally would be handled in FullRender TODO CGX::FlushState(); // normally would be handled in FullRender TODO
} }
@ -715,22 +716,22 @@ void CGraphics::SetDefaultVtxAttrFmt() {
// Unneeded, all attributes are expected to be full floats // Unneeded, all attributes are expected to be full floats
// Left here for reference // Left here for reference
GXSetVtxAttrFmt(GX::VTXFMT0, GX::VA_POS, GX::POS_XYZ, GX::F32, 0); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
GXSetVtxAttrFmt(GX::VTXFMT1, GX::VA_POS, GX::POS_XYZ, GX::F32, 0); GXSetVtxAttrFmt(GX_VTXFMT1, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
GXSetVtxAttrFmt(GX::VTXFMT2, GX::VA_POS, GX::POS_XYZ, GX::F32, 0); GXSetVtxAttrFmt(GX_VTXFMT2, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
GXSetVtxAttrFmt(GX::VTXFMT0, GX::VA_NRM, GX::NRM_XYZ, GX::F32, 0); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_NRM, GX_NRM_XYZ, GX_F32, 0);
GXSetVtxAttrFmt(GX::VTXFMT1, GX::VA_NRM, GX::NRM_XYZ, GX::S16, 14); GXSetVtxAttrFmt(GX_VTXFMT1, GX_VA_NRM, GX_NRM_XYZ, GX_S16, 14);
GXSetVtxAttrFmt(GX::VTXFMT2, GX::VA_NRM, GX::NRM_XYZ, GX::S16, 14); GXSetVtxAttrFmt(GX_VTXFMT2, GX_VA_NRM, GX_NRM_XYZ, GX_S16, 14);
GXSetVtxAttrFmt(GX::VTXFMT0, GX::VA_CLR0, GX::CLR_RGBA, GX::RGBA8, 0); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
GXSetVtxAttrFmt(GX::VTXFMT1, GX::VA_CLR0, GX::CLR_RGBA, GX::RGBA8, 0); GXSetVtxAttrFmt(GX_VTXFMT1, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
GXSetVtxAttrFmt(GX::VTXFMT2, GX::VA_CLR0, GX::CLR_RGBA, GX::RGBA8, 0); GXSetVtxAttrFmt(GX_VTXFMT2, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
GXSetVtxAttrFmt(GX::VTXFMT0, GX::VA_TEX0, GX::TEX_ST, GX::F32, 0); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
GXSetVtxAttrFmt(GX::VTXFMT1, GX::VA_TEX0, GX::TEX_ST, GX::F32, 0); GXSetVtxAttrFmt(GX_VTXFMT1, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
GXSetVtxAttrFmt(GX::VTXFMT2, GX::VA_TEX0, GX::TEX_ST, GX::U16, 15); GXSetVtxAttrFmt(GX_VTXFMT2, GX_VA_TEX0, GX_TEX_ST, GX_U16, 15);
for (GX::Attr attr = GX::VA_TEX1; attr <= GX::VA_TEX7; attr = GX::Attr(attr + 1)) { for (GXAttr attr = GX_VA_TEX1; attr <= GX_VA_TEX7; attr = GXAttr(attr + 1)) {
GXSetVtxAttrFmt(GX::VTXFMT0, attr, GX::TEX_ST, GX::F32, 0); GXSetVtxAttrFmt(GX_VTXFMT0, attr, GX_TEX_ST, GX_F32, 0);
GXSetVtxAttrFmt(GX::VTXFMT1, attr, GX::TEX_ST, GX::F32, 0); GXSetVtxAttrFmt(GX_VTXFMT1, attr, GX_TEX_ST, GX_F32, 0);
GXSetVtxAttrFmt(GX::VTXFMT2, attr, GX::TEX_ST, GX::F32, 0); GXSetVtxAttrFmt(GX_VTXFMT2, attr, GX_TEX_ST, GX_F32, 0);
} }
} }

View File

@ -15,7 +15,6 @@
#include <zeus/CVector2f.hpp> #include <zeus/CVector2f.hpp>
#include <zeus/CVector2i.hpp> #include <zeus/CVector2i.hpp>
#include <aurora/gfx.hpp>
#include <optick.h> #include <optick.h>
using frame_clock = std::chrono::high_resolution_clock; using frame_clock = std::chrono::high_resolution_clock;
@ -25,108 +24,108 @@ class CTexture;
extern CVar* g_disableLighting; extern CVar* g_disableLighting;
class CTimeProvider; class CTimeProvider;
enum class ERglCullMode : std::underlying_type_t<GX::CullMode> { enum class ERglCullMode : std::underlying_type_t<GXCullMode> {
None = GX::CULL_NONE, None = GX_CULL_NONE,
Front = GX::CULL_FRONT, Front = GX_CULL_FRONT,
Back = GX::CULL_BACK, Back = GX_CULL_BACK,
All = GX::CULL_ALL, All = GX_CULL_ALL,
}; };
enum class ERglBlendMode : std::underlying_type_t<GX::BlendMode> { enum class ERglBlendMode : std::underlying_type_t<GXBlendMode> {
None = GX::BM_NONE, None = GX_BM_NONE,
Blend = GX::BM_BLEND, Blend = GX_BM_BLEND,
Logic = GX::BM_LOGIC, Logic = GX_BM_LOGIC,
Subtract = GX::BM_SUBTRACT, Subtract = GX_BM_SUBTRACT,
Max = GX::MAX_BLENDMODE, Max = GX_MAX_BLENDMODE,
}; };
enum class ERglBlendFactor : std::underlying_type_t<GX::BlendFactor> { enum class ERglBlendFactor : std::underlying_type_t<GXBlendFactor> {
Zero = GX::BL_ZERO, Zero = GX_BL_ZERO,
One = GX::BL_ONE, One = GX_BL_ONE,
SrcColor = GX::BL_SRCCLR, SrcColor = GX_BL_SRCCLR,
InvSrcColor = GX::BL_INVSRCCLR, InvSrcColor = GX_BL_INVSRCCLR,
SrcAlpha = GX::BL_SRCALPHA, SrcAlpha = GX_BL_SRCALPHA,
InvSrcAlpha = GX::BL_INVSRCALPHA, InvSrcAlpha = GX_BL_INVSRCALPHA,
DstAlpha = GX::BL_DSTALPHA, DstAlpha = GX_BL_DSTALPHA,
InvDstAlpha = GX::BL_INVDSTALPHA, InvDstAlpha = GX_BL_INVDSTALPHA,
DstColor = GX::BL_DSTCLR, DstColor = GX_BL_DSTCLR,
InvDstColor = GX::BL_INVDSTCLR, InvDstColor = GX_BL_INVDSTCLR,
}; };
enum class ERglLogicOp : std::underlying_type_t<GX::LogicOp> { enum class ERglLogicOp : std::underlying_type_t<GXLogicOp> {
Clear = GX::LO_CLEAR, Clear = GX_LO_CLEAR,
And = GX::LO_AND, And = GX_LO_AND,
RevAnd = GX::LO_REVAND, RevAnd = GX_LO_REVAND,
Copy = GX::LO_COPY, Copy = GX_LO_COPY,
InvAnd = GX::LO_INVAND, InvAnd = GX_LO_INVAND,
NoOp = GX::LO_NOOP, NoOp = GX_LO_NOOP,
Xor = GX::LO_XOR, Xor = GX_LO_XOR,
Or = GX::LO_OR, Or = GX_LO_OR,
Nor = GX::LO_NOR, Nor = GX_LO_NOR,
Equiv = GX::LO_EQUIV, Equiv = GX_LO_EQUIV,
Inv = GX::LO_INV, Inv = GX_LO_INV,
RevOr = GX::LO_REVOR, RevOr = GX_LO_REVOR,
InvCopy = GX::LO_INVCOPY, InvCopy = GX_LO_INVCOPY,
InvOr = GX::LO_INVOR, InvOr = GX_LO_INVOR,
NAnd = GX::LO_NAND, NAnd = GX_LO_NAND,
Set = GX::LO_SET, Set = GX_LO_SET,
}; };
enum class ERglAlphaFunc : std::underlying_type_t<GX::Compare> { enum class ERglAlphaFunc : std::underlying_type_t<GXCompare> {
Never = GX::NEVER, Never = GX_NEVER,
Less = GX::LESS, Less = GX_LESS,
Equal = GX::EQUAL, Equal = GX_EQUAL,
LEqual = GX::LEQUAL, LEqual = GX_LEQUAL,
Greater = GX::GREATER, Greater = GX_GREATER,
NEqual = GX::NEQUAL, NEqual = GX_NEQUAL,
GEqual = GX::GEQUAL, GEqual = GX_GEQUAL,
Always = GX::ALWAYS, Always = GX_ALWAYS,
}; };
enum class ERglAlphaOp : std::underlying_type_t<GX::AlphaOp> { enum class ERglAlphaOp : std::underlying_type_t<GXAlphaOp> {
And = GX::AOP_AND, And = GX_AOP_AND,
Or = GX::AOP_OR, Or = GX_AOP_OR,
Xor = GX::AOP_XOR, Xor = GX_AOP_XOR,
XNor = GX::AOP_XNOR, XNor = GX_AOP_XNOR,
Max = GX::MAX_ALPHAOP, Max = GX_MAX_ALPHAOP,
}; };
enum class ERglEnum : std::underlying_type_t<GX::Compare> { enum class ERglEnum : std::underlying_type_t<GXCompare> {
Never = GX::NEVER, Never = GX_NEVER,
Less = GX::LESS, Less = GX_LESS,
Equal = GX::EQUAL, Equal = GX_EQUAL,
LEqual = GX::LEQUAL, LEqual = GX_LEQUAL,
Greater = GX::GREATER, Greater = GX_GREATER,
NEqual = GX::NEQUAL, NEqual = GX_NEQUAL,
GEqual = GX::GEQUAL, GEqual = GX_GEQUAL,
Always = GX::ALWAYS, Always = GX_ALWAYS,
}; };
using ERglLight = u8; using ERglLight = u8;
enum class ERglTexOffset : std::underlying_type_t<GX::TexOffset> { enum class ERglTexOffset : std::underlying_type_t<GXTexOffset> {
Zero = GX::TO_ZERO, Zero = GX_TO_ZERO,
Sixteenth = GX::TO_SIXTEENTH, Sixteenth = GX_TO_SIXTEENTH,
Eighth = GX::TO_EIGHTH, Eighth = GX_TO_EIGHTH,
Fourth = GX::TO_FOURTH, Fourth = GX_TO_FOURTH,
Half = GX::TO_HALF, Half = GX_TO_HALF,
One = GX::TO_ONE, One = GX_TO_ONE,
}; };
enum class ERglFogMode : std::underlying_type_t<GX::FogType> { enum class ERglFogMode : std::underlying_type_t<GXFogType> {
None = GX::FOG_NONE, None = GX_FOG_NONE,
PerspLin = GX::FOG_PERSP_LIN, PerspLin = GX_FOG_PERSP_LIN,
PerspExp = GX::FOG_PERSP_EXP, PerspExp = GX_FOG_PERSP_EXP,
PerspExp2 = GX::FOG_ORTHO_EXP2, PerspExp2 = GX_FOG_ORTHO_EXP2,
PerspRevExp = GX::FOG_PERSP_REVEXP, PerspRevExp = GX_FOG_PERSP_REVEXP,
PerspRevExp2 = GX::FOG_PERSP_REVEXP2, PerspRevExp2 = GX_FOG_PERSP_REVEXP2,
OrthoLin = GX::FOG_ORTHO_LIN, OrthoLin = GX_FOG_ORTHO_LIN,
OrthoExp = GX::FOG_ORTHO_EXP, OrthoExp = GX_FOG_ORTHO_EXP,
OrthoExp2 = GX::FOG_ORTHO_EXP2, OrthoExp2 = GX_FOG_ORTHO_EXP2,
OrthoRevExp = GX::FOG_ORTHO_REVEXP, OrthoRevExp = GX_FOG_ORTHO_REVEXP,
OrthoRevExp2 = GX::FOG_ORTHO_REVEXP2, OrthoRevExp2 = GX_FOG_ORTHO_REVEXP2,
}; };
struct SViewport { struct SViewport {
@ -165,13 +164,13 @@ struct SClipScreenRect {
, x20_uvYMin(uvYMin) , x20_uvYMin(uvYMin)
, x24_uvYMax(uvYMax) {} , x24_uvYMax(uvYMax) {}
SClipScreenRect(const aurora::gfx::ClipRect& rect) { // SClipScreenRect(const aurora::gfx::ClipRect& rect) {
x4_left = rect.x; // x4_left = rect.x;
x8_top = rect.y; // x8_top = rect.y;
xc_width = rect.width; // xc_width = rect.width;
x10_height = rect.height; // x10_height = rect.height;
x14_dstWidth = rect.width; // x14_dstWidth = rect.width;
} // }
SClipScreenRect(const SViewport& vp) { SClipScreenRect(const SViewport& vp) {
x4_left = vp.x0_left; x4_left = vp.x0_left;
@ -214,7 +213,7 @@ public:
static bool g_LastFrameUsedAbove; static bool g_LastFrameUsedAbove;
static bool g_InterruptLastFrameUsedAbove; static bool g_InterruptLastFrameUsedAbove;
static GX::LightMask g_LightActive; static GX::LightMask g_LightActive;
static std::array<GX::LightObj, GX::MaxLights> g_LightObjs; static std::array<GXLightObj, GX::MaxLights> g_LightObjs;
static std::array<ELightType, GX::MaxLights> g_LightTypes; static std::array<ELightType, GX::MaxLights> g_LightTypes;
static zeus::CTransform g_GXModelView; static zeus::CTransform g_GXModelView;
static zeus::CTransform g_GXModelViewInvXpose; static zeus::CTransform g_GXModelViewInvXpose;
@ -309,31 +308,33 @@ public:
static const std::array<zeus::CMatrix3f, 6> skCubeBasisMats; static const std::array<zeus::CMatrix3f, 6> skCubeBasisMats;
static void ResolveSpareTexture(const SClipScreenRect& rect, int bindIdx, GX::TextureFormat format, static void ResolveSpareTexture(const SClipScreenRect& rect, int bindIdx, GXTexFmt format, bool clearDepth = false) {
bool clearDepth = false) { // TODO
aurora::gfx::resolve_color({rect.x4_left, rect.x8_top, rect.xc_width, rect.x10_height}, bindIdx, format, // aurora::gfx::resolve_color({rect.x4_left, rect.x8_top, rect.xc_width, rect.x10_height}, bindIdx, format,
clearDepth); // clearDepth);
} }
static void LoadDolphinSpareTexture(int bindIdx, GX::TextureFormat format, GX::TexMapID id) { static void LoadDolphinSpareTexture(int bindIdx, GXTexFmt format, GXTexMapID id) {
GXTexObj obj; // TODO
GXInitTexObjResolved(&obj, bindIdx, format, GX_CLAMP, GX_CLAMP, GX_TLUT0); // GXTexObj obj;
GXInitTexObjLOD(&obj, GX_NEAR, GX_NEAR, 0.f, 0.f, 0.f, false, false, GX_ANISO_1); // GXInitTexObjResolved(&obj, bindIdx, format, GX_CLAMP, GX_CLAMP, GX_TLUT0);
GXLoadTexObj(&obj, id); // GXInitTexObjLOD(&obj, GX_NEAR, GX_NEAR, 0.f, 0.f, 0.f, false, false, GX_ANISO_1);
// GXLoadTexObj(&obj, id);
} }
static void LoadDolphinSpareTexture(int bindIdx, GXCITexFmt format, GXTlut tlut, GX::TexMapID id) { static void LoadDolphinSpareTexture(int bindIdx, GXCITexFmt format, GXTlut tlut, GXTexMapID id) {
GXTexObj obj; // TODO
GXInitTexObjResolved(&obj, bindIdx, static_cast<GX::TextureFormat>(format), GX_CLAMP, GX_CLAMP, tlut); // GXTexObj obj;
GXInitTexObjLOD(&obj, GX_NEAR, GX_NEAR, 0.f, 0.f, 0.f, false, false, GX_ANISO_1); // GXInitTexObjResolved(&obj, bindIdx, static_cast<GXTexFmt>(format), GX_CLAMP, GX_CLAMP, tlut);
GXLoadTexObj(&obj, id); // GXInitTexObjLOD(&obj, GX_NEAR, GX_NEAR, 0.f, 0.f, 0.f, false, false, GX_ANISO_1);
// GXLoadTexObj(&obj, id);
} }
static void ResolveSpareDepth(const SClipScreenRect& rect, int bindIdx = 0) { static void ResolveSpareDepth(const SClipScreenRect& rect, int bindIdx = 0) {
// aurora::gfx::resolve_depth({rect.x4_left, rect.x8_top, rect.xc_width, rect.x10_height}, bindIdx); // aurora::gfx::resolve_depth({rect.x4_left, rect.x8_top, rect.xc_width, rect.x10_height}, bindIdx);
} }
static void ResetGfxStates() noexcept; static void ResetGfxStates() noexcept;
static void SetTevStates(EStreamFlags flags) noexcept; static void SetTevStates(u32 flags) noexcept;
static void SetTevOp(ERglTevStage stage, const CTevCombiners::CTevPass& pass); static void SetTevOp(ERglTevStage stage, const CTevCombiners::CTevPass& pass);
static void StreamBegin(GX::Primitive primitive); static void StreamBegin(GXPrimitive primitive);
static void StreamNormal(const zeus::CVector3f& nrm); static void StreamNormal(const zeus::CVector3f& nrm);
static void StreamColor(const zeus::CColor& color); static void StreamColor(const zeus::CColor& color);
static inline void StreamColor(float r, float g, float b, float a) { StreamColor({r, g, b, a}); } static inline void StreamColor(float r, float g, float b, float a) { StreamColor({r, g, b, a}); }
@ -347,7 +348,7 @@ public:
static void ResetVertexDataStream(bool end); static void ResetVertexDataStream(bool end);
static void FlushStream(); static void FlushStream();
static void FullRender(); static void FullRender();
static void DrawPrimitive(GX::Primitive primitive, const zeus::CVector3f* pos, const zeus::CVector3f& normal, static void DrawPrimitive(GXPrimitive primitive, const zeus::CVector3f* pos, const zeus::CVector3f& normal,
const zeus::CColor& col, s32 numVerts); const zeus::CColor& col, s32 numVerts);
static void SetLineWidth(float width, ERglTexOffset offs); static void SetLineWidth(float width, ERglTexOffset offs);
}; };
@ -386,9 +387,13 @@ public:
}; };
#ifdef AURORA_GFX_DEBUG_GROUPS #ifdef AURORA_GFX_DEBUG_GROUPS
struct ScopedDebugGroup {
inline ScopedDebugGroup(const char* label) noexcept { push_debug_group(label); }
inline ~ScopedDebugGroup() noexcept { pop_debug_group(); }
};
#define SCOPED_GRAPHICS_DEBUG_GROUP(name, ...) \ #define SCOPED_GRAPHICS_DEBUG_GROUP(name, ...) \
OPTICK_EVENT_DYNAMIC(name); \ OPTICK_EVENT_DYNAMIC(name); \
aurora::gfx::ScopedDebugGroup _GfxDbg_{name} ScopedDebugGroup _GfxDbg_ { name }
#else #else
#define SCOPED_GRAPHICS_DEBUG_GROUP(name, ...) OPTICK_EVENT_DYNAMIC(name) #define SCOPED_GRAPHICS_DEBUG_GROUP(name, ...) OPTICK_EVENT_DYNAMIC(name)
#endif #endif

View File

@ -20,7 +20,7 @@ void CLineRenderer::Shutdown() {
//hecl::VertexBufferPool<CLineRenderer::SDrawVertNoTex> CLineRenderer::s_vertPoolNoTex = {}; //hecl::VertexBufferPool<CLineRenderer::SDrawVertNoTex> CLineRenderer::s_vertPoolNoTex = {};
//hecl::UniformBufferPool<CLineRenderer::SDrawUniform> CLineRenderer::s_uniformPool = {}; //hecl::UniformBufferPool<CLineRenderer::SDrawUniform> CLineRenderer::s_uniformPool = {};
CLineRenderer::CLineRenderer(EPrimitiveMode mode, u32 maxVerts, const aurora::gfx::TextureHandle& texture, CLineRenderer::CLineRenderer(EPrimitiveMode mode, u32 maxVerts, u32 texture,
bool additive, bool zTest, bool zGEqual) bool additive, bool zTest, bool zGEqual)
: m_mode(mode), m_maxVerts(maxVerts) { : m_mode(mode), m_maxVerts(maxVerts) {
OPTICK_EVENT(); OPTICK_EVENT();

View File

@ -51,7 +51,7 @@ public:
// hecl::UniformBufferPool<SDrawUniform>::Token m_uniformBuf; // hecl::UniformBufferPool<SDrawUniform>::Token m_uniformBuf;
// std::array<boo::ObjToken<boo::IShaderDataBinding>, 2> m_shaderBind; // std::array<boo::ObjToken<boo::IShaderDataBinding>, 2> m_shaderBind;
CLineRenderer(EPrimitiveMode mode, u32 maxVerts, const aurora::gfx::TextureHandle& texture, bool additive, CLineRenderer(EPrimitiveMode mode, u32 maxVerts, u32 texture, bool additive,
bool zTest = false, bool zGEqual = false); bool zTest = false, bool zGEqual = false);
CLineRenderer(CLineRenderer&&) = default; CLineRenderer(CLineRenderer&&) = default;

View File

@ -47,7 +47,7 @@ CMetroidModelInstance::CMetroidModelInstance(std::pair<const u8*, u32> modelHead
u32 numTexCoords = texCoords.second / 8; u32 numTexCoords = texCoords.second / 8;
CMemoryInStream stream{texCoords.first, texCoords.second}; CMemoryInStream stream{texCoords.first, texCoords.second};
for (u32 i = 0; i < numTexCoords; ++i) { for (u32 i = 0; i < numTexCoords; ++i) {
x6c_texCoords.emplace_back(stream.Get<zeus::CVector2f>()); x6c_texCoords.emplace_back(stream.Get<aurora::Vec2<float>>());
} }
} }
{ {

View File

@ -9,6 +9,7 @@
#include <zeus/CAABox.hpp> #include <zeus/CAABox.hpp>
#include <zeus/CTransform.hpp> #include <zeus/CTransform.hpp>
#include <aurora/math.hpp>
namespace metaforce { namespace metaforce {
class CCubeSurface; class CCubeSurface;
@ -45,5 +46,4 @@ public:
[[nodiscard]] const std::vector<aurora::Vec2<float>>* GetTCPointer() const { return &x6c_texCoords; } [[nodiscard]] const std::vector<aurora::Vec2<float>>* GetTCPointer() const { return &x6c_texCoords; }
[[nodiscard]] const std::vector<aurora::Vec2<float>>* GetPackedTCPointer() const { return &x70_packedTexCoords; } [[nodiscard]] const std::vector<aurora::Vec2<float>>* GetPackedTCPointer() const { return &x70_packedTexCoords; }
}; };
} // namespace metaforce } // namespace metaforce

View File

@ -91,7 +91,7 @@ CModel::CModel(std::unique_ptr<u8[]> in, u32 dataLen, IObjectStore* store)
u32 numFloatUVs = CBasics::SwapBytes(*secSizeCur) / 8; u32 numFloatUVs = CBasics::SwapBytes(*secSizeCur) / 8;
auto floatUVs = StreamFromPartData(dataCur, secSizeCur); auto floatUVs = StreamFromPartData(dataCur, secSizeCur);
for (u32 i = 0; i < numFloatUVs; ++i) { for (u32 i = 0; i < numFloatUVs; ++i) {
m_floatUVs.emplace_back(floatUVs.Get<zeus::CVector2f>()); m_floatUVs.emplace_back(floatUVs.Get<aurora::Vec2<float>>());
} }
if ((flags & 4) != 0) { if ((flags & 4) != 0) {

View File

@ -9,6 +9,7 @@
#include "Graphics/CCubeSurface.hpp" #include "Graphics/CCubeSurface.hpp"
#include "Graphics/CTexture.hpp" #include "Graphics/CTexture.hpp"
#include "IObjectStore.hpp" #include "IObjectStore.hpp"
#include "Flags.hpp"
namespace metaforce { namespace metaforce {
class CCubeMaterial; class CCubeMaterial;

View File

@ -16,18 +16,21 @@ static void MyTHPYuv2RgbTextureSetup(void* dataY, void* dataU, void* dataV, u16
GXTexObj texV; GXTexObj texV;
GXTexObj texU; GXTexObj texU;
GXTexObj texY; GXTexObj texY;
GXInitTexObj(&texY, dataY, width, height, GX::TF_I8, GX_CLAMP, GX_CLAMP, false); GXInitTexObj(&texY, dataY, width, height, GX_TF_R8_PC, GX_CLAMP, GX_CLAMP, false);
GXInitTexObjLOD(&texY, GX_NEAR, GX_NEAR, 0.0, 0.0, 0.0, false, false, GX_ANISO_1); GXInitTexObjLOD(&texY, GX_NEAR, GX_NEAR, 0.0, 0.0, 0.0, false, false, GX_ANISO_1);
GXLoadTexObj(&texY, GX::TEXMAP0); GXLoadTexObj(&texY, GX_TEXMAP0);
GXInitTexObj(&texU, dataU, width / 2, height / 2, GX::TF_I8, GX_CLAMP, GX_CLAMP, false); GXInitTexObj(&texU, dataU, width / 2, height / 2, GX_TF_R8_PC, GX_CLAMP, GX_CLAMP, false);
GXInitTexObjLOD(&texU, GX_NEAR, GX_NEAR, 0.0, 0.0, 0.0, false, false, GX_ANISO_1); GXInitTexObjLOD(&texU, GX_NEAR, GX_NEAR, 0.0, 0.0, 0.0, false, false, GX_ANISO_1);
GXLoadTexObj(&texU, GX::TEXMAP1); GXLoadTexObj(&texU, GX_TEXMAP1);
GXInitTexObj(&texV, dataV, width / 2, height / 2, GX::TF_I8, GX_CLAMP, GX_CLAMP, false); GXInitTexObj(&texV, dataV, width / 2, height / 2, GX_TF_R8_PC, GX_CLAMP, GX_CLAMP, false);
GXInitTexObjLOD(&texV, GX_NEAR, GX_NEAR, 0.0, 0.0, 0.0, false, false, GX_ANISO_1); GXInitTexObjLOD(&texV, GX_NEAR, GX_NEAR, 0.0, 0.0, 0.0, false, false, GX_ANISO_1);
GXLoadTexObj(&texV, GX::TEXMAP2); GXLoadTexObj(&texV, GX_TEXMAP2);
CTexture::InvalidateTexMap(GX::TEXMAP0); CTexture::InvalidateTexMap(GX_TEXMAP0);
CTexture::InvalidateTexMap(GX::TEXMAP1); CTexture::InvalidateTexMap(GX_TEXMAP1);
CTexture::InvalidateTexMap(GX::TEXMAP2); CTexture::InvalidateTexMap(GX_TEXMAP2);
GXDestroyTexObj(&texV);
GXDestroyTexObj(&texU);
GXDestroyTexObj(&texY);
} }
const std::array<u8, 32> InterlaceTex{ const std::array<u8, 32> InterlaceTex{
@ -35,85 +38,86 @@ const std::array<u8, 32> InterlaceTex{
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0, 0, 0, 0, 0,
}; };
static void MyTHPGXYuv2RgbSetup(bool interlaced2ndFrame, bool fieldFlip) { static void MyTHPGXYuv2RgbSetup(bool interlaced2ndFrame, bool fieldFlip) {
CGX::SetZMode(true, GX::ALWAYS, false); CGX::SetZMode(true, GX_ALWAYS, false);
CGX::SetBlendMode(GX::BM_NONE, GX::BL_ONE, GX::BL_ZERO, GX::LO_CLEAR); CGX::SetBlendMode(GX_BM_NONE, GX_BL_ONE, GX_BL_ZERO, GX_LO_CLEAR);
CGX::SetNumChans(0); CGX::SetNumChans(0);
CGX::SetTexCoordGen(GX::TEXCOORD0, GX::TG_MTX2x4, GX::TG_TEX0, GX::IDENTITY, false, GX::PTIDENTITY); CGX::SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY, false, GX_PTIDENTITY);
CGX::SetTexCoordGen(GX::TEXCOORD1, GX::TG_MTX2x4, GX::TG_TEX0, GX::IDENTITY, false, GX::PTIDENTITY); CGX::SetTexCoordGen(GX_TEXCOORD1, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY, false, GX_PTIDENTITY);
if (!fieldFlip) { if (!fieldFlip) {
CGX::SetNumTexGens(3); CGX::SetNumTexGens(3);
CGX::SetTexCoordGen(GX::TEXCOORD2, GX::TG_MTX2x4, GX::TG_POS, GX::TEXMTX0, false, GX::PTIDENTITY); CGX::SetTexCoordGen(GX_TEXCOORD2, GX_TG_MTX2x4, GX_TG_POS, GX_TEXMTX0, false, GX_PTIDENTITY);
aurora::Mat4x2<float> mtx; aurora::Mat4x2<float> mtx;
mtx.m0.x = 0.125f; mtx.m0.x = 0.125f;
mtx.m2.y = 0.25f; mtx.m2.y = 0.25f;
if (interlaced2ndFrame) { if (interlaced2ndFrame) {
mtx.m3.y = 0.25f; mtx.m3.y = 0.25f;
} }
GXLoadTexMtxImm(&mtx, GX::TEXMTX0, GX::MTX2x4); GXLoadTexMtxImm(&mtx, GX_TEXMTX0, GX_MTX2x4);
GXTexObj texObj; GXTexObj texObj;
GXInitTexObj(&texObj, InterlaceTex.data(), 8, 4, GX::TF_I8, GX_REPEAT, GX_REPEAT, false); GXInitTexObj(&texObj, InterlaceTex.data(), 8, 4, GX_TF_I8, GX_REPEAT, GX_REPEAT, false);
GXInitTexObjLOD(&texObj, GX_NEAR, GX_NEAR, 0.f, 0.f, 0.f, false, false, GX_ANISO_1); GXInitTexObjLOD(&texObj, GX_NEAR, GX_NEAR, 0.f, 0.f, 0.f, false, false, GX_ANISO_1);
GXLoadTexObj(&texObj, GX::TEXMAP3); GXLoadTexObj(&texObj, GX_TEXMAP3);
CTexture::InvalidateTexMap(GX::TEXMAP3); GXDestroyTexObj(&texObj);
CGX::SetTevOrder(GX::TEVSTAGE4, GX::TEXCOORD2, GX::TEXMAP3, GX::COLOR_NULL); CTexture::InvalidateTexMap(GX_TEXMAP3);
CGX::SetStandardTevColorAlphaOp(GX::TEVSTAGE4); CGX::SetTevOrder(GX_TEVSTAGE4, GX_TEXCOORD2, GX_TEXMAP3, GX_COLOR_NULL);
CGX::SetTevColorIn(GX::TEVSTAGE4, GX::CC_ZERO, GX::CC_ZERO, GX::CC_ZERO, GX::CC_CPREV); CGX::SetStandardTevColorAlphaOp(GX_TEVSTAGE4);
CGX::SetTevAlphaIn(GX::TEVSTAGE4, GX::CA_ZERO, GX::CA_ZERO, GX::CA_ZERO, GX::CA_TEXA); CGX::SetTevColorIn(GX_TEVSTAGE4, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_CPREV);
CGX::SetAlphaCompare(GX::LESS, 128, GX::AOP_AND, GX::ALWAYS, 0); CGX::SetTevAlphaIn(GX_TEVSTAGE4, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_TEXA);
CGX::SetAlphaCompare(GX_LESS, 128, GX_AOP_AND, GX_ALWAYS, 0);
CGX::SetNumTevStages(5); CGX::SetNumTevStages(5);
} else { } else {
CGX::SetNumTexGens(2); CGX::SetNumTexGens(2);
CGX::SetNumTevStages(4); CGX::SetNumTevStages(4);
} }
constexpr std::array vtxDescList{ constexpr std::array vtxDescList{
GX::VtxDescList{GX::VA_POS, GX::DIRECT}, GXVtxDescList{GX_VA_POS, GX_DIRECT},
GX::VtxDescList{GX::VA_TEX0, GX::DIRECT}, GXVtxDescList{GX_VA_TEX0, GX_DIRECT},
GX::VtxDescList{}, GXVtxDescList{GX_VA_NULL, GX_NONE},
}; };
CGX::SetVtxDescv(vtxDescList.data()); CGX::SetVtxDescv(vtxDescList.data());
GXSetColorUpdate(true); GXSetColorUpdate(true);
GXSetAlphaUpdate(false); GXSetAlphaUpdate(false);
GXInvalidateTexAll(); GXInvalidateTexAll();
GXSetVtxAttrFmt(GX::VTXFMT7, GX::VA_POS, GX::CLR_RGBA, GX::F32, 0); GXSetVtxAttrFmt(GX_VTXFMT7, GX_VA_POS, GX_CLR_RGBA, GX_F32, 0);
GXSetVtxAttrFmt(GX::VTXFMT7, GX::VA_TEX0, GX::CLR_RGBA, GX::RGBX8, 0); GXSetVtxAttrFmt(GX_VTXFMT7, GX_VA_TEX0, GX_CLR_RGBA, GX_RGBX8, 0);
CGX::SetTevOrder(GX::TEVSTAGE0, GX::TEXCOORD1, GX::TEXMAP1, GX::COLOR_NULL); CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD1, GX_TEXMAP1, GX_COLOR_NULL);
CGX::SetTevColorIn(GX::TEVSTAGE0, GX::CC_ZERO, GX::CC_TEXC, GX::CC_KONST, GX::CC_C0); CGX::SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_TEXC, GX_CC_KONST, GX_CC_C0);
CGX::SetTevColorOp(GX::TEVSTAGE0, GX::TEV_ADD, GX::TB_ZERO, GX::CS_SCALE_1, false, GX::TEVPREV); CGX::SetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, false, GX_TEVPREV);
CGX::SetTevAlphaIn(GX::TEVSTAGE0, GX::CA_ZERO, GX::CA_TEXA, GX::CA_KONST, GX::CA_A0); CGX::SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_TEXA, GX_CA_KONST, GX_CA_A0);
CGX::SetTevAlphaOp(GX::TEVSTAGE0, GX::TEV_SUB, GX::TB_ZERO, GX::CS_SCALE_1, false, GX::TEVPREV); CGX::SetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_SUB, GX_TB_ZERO, GX_CS_SCALE_1, false, GX_TEVPREV);
CGX::SetTevKColorSel(GX::TEVSTAGE0, GX::TEV_KCSEL_K0); CGX::SetTevKColorSel(GX_TEVSTAGE0, GX_TEV_KCSEL_K0);
CGX::SetTevKAlphaSel(GX::TEVSTAGE0, GX::TEV_KASEL_K0_A); CGX::SetTevKAlphaSel(GX_TEVSTAGE0, GX_TEV_KASEL_K0_A);
CGX::SetTevOrder(GX::TEVSTAGE1, GX::TEXCOORD1, GX::TEXMAP2, GX::COLOR_NULL); CGX::SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD1, GX_TEXMAP2, GX_COLOR_NULL);
CGX::SetTevColorIn(GX::TEVSTAGE1, GX::CC_ZERO, GX::CC_TEXC, GX::CC_KONST, GX::CC_CPREV); CGX::SetTevColorIn(GX_TEVSTAGE1, GX_CC_ZERO, GX_CC_TEXC, GX_CC_KONST, GX_CC_CPREV);
CGX::SetTevColorOp(GX::TEVSTAGE1, GX::TEV_ADD, GX::TB_ZERO, GX::CS_SCALE_2, false, GX::TEVPREV); CGX::SetTevColorOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_2, false, GX_TEVPREV);
CGX::SetTevAlphaIn(GX::TEVSTAGE1, GX::CA_ZERO, GX::CA_TEXA, GX::CA_KONST, GX::CA_APREV); CGX::SetTevAlphaIn(GX_TEVSTAGE1, GX_CA_ZERO, GX_CA_TEXA, GX_CA_KONST, GX_CA_APREV);
CGX::SetTevAlphaOp(GX::TEVSTAGE1, GX::TEV_SUB, GX::TB_ZERO, GX::CS_SCALE_1, false, GX::TEVPREV); CGX::SetTevAlphaOp(GX_TEVSTAGE1, GX_TEV_SUB, GX_TB_ZERO, GX_CS_SCALE_1, false, GX_TEVPREV);
CGX::SetTevKColorSel(GX::TEVSTAGE1, GX::TEV_KCSEL_K1); CGX::SetTevKColorSel(GX_TEVSTAGE1, GX_TEV_KCSEL_K1);
CGX::SetTevKAlphaSel(GX::TEVSTAGE1, GX::TEV_KASEL_K1_A); CGX::SetTevKAlphaSel(GX_TEVSTAGE1, GX_TEV_KASEL_K1_A);
CGX::SetTevOrder(GX::TEVSTAGE2, GX::TEXCOORD0, GX::TEXMAP0, GX::COLOR_NULL); CGX::SetTevOrder(GX_TEVSTAGE2, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL);
CGX::SetTevColorIn(GX::TEVSTAGE2, GX::CC_ZERO, GX::CC_TEXC, GX::CC_ONE, GX::CC_CPREV); CGX::SetTevColorIn(GX_TEVSTAGE2, GX_CC_ZERO, GX_CC_TEXC, GX_CC_ONE, GX_CC_CPREV);
CGX::SetTevColorOp(GX::TEVSTAGE2, GX::TEV_ADD, GX::TB_ZERO, GX::CS_SCALE_1, true, GX::TEVPREV); CGX::SetTevColorOp(GX_TEVSTAGE2, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV);
CGX::SetTevAlphaIn(GX::TEVSTAGE2, GX::CA_TEXA, GX::CA_ZERO, GX::CA_ZERO, GX::CA_APREV); CGX::SetTevAlphaIn(GX_TEVSTAGE2, GX_CA_TEXA, GX_CA_ZERO, GX_CA_ZERO, GX_CA_APREV);
CGX::SetTevAlphaOp(GX::TEVSTAGE2, GX::TEV_ADD, GX::TB_ZERO, GX::CS_SCALE_1, true, GX::TEVPREV); CGX::SetTevAlphaOp(GX_TEVSTAGE2, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV);
CGX::SetTevOrder(GX::TEVSTAGE3, GX::TEXCOORD_NULL, GX::TEXMAP_NULL, GX::COLOR_NULL); CGX::SetTevOrder(GX_TEVSTAGE3, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR_NULL);
CGX::SetTevColorIn(GX::TEVSTAGE3, GX::CC_APREV, GX::CC_CPREV, GX::CC_KONST, GX::CC_ZERO); CGX::SetTevColorIn(GX_TEVSTAGE3, GX_CC_APREV, GX_CC_CPREV, GX_CC_KONST, GX_CC_ZERO);
CGX::SetTevColorOp(GX::TEVSTAGE3, GX::TEV_ADD, GX::TB_ZERO, GX::CS_SCALE_1, true, GX::TEVPREV); CGX::SetTevColorOp(GX_TEVSTAGE3, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV);
CGX::SetTevAlphaIn(GX::TEVSTAGE3, GX::CA_ZERO, GX::CA_ZERO, GX::CA_ZERO, GX::CA_ZERO); CGX::SetTevAlphaIn(GX_TEVSTAGE3, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO);
CGX::SetTevAlphaOp(GX::TEVSTAGE3, GX::TEV_ADD, GX::TB_ZERO, GX::CS_SCALE_1, true, GX::TEVPREV); CGX::SetTevAlphaOp(GX_TEVSTAGE3, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV);
CGX::SetTevKColorSel(GX::TEVSTAGE3, GX::TEV_KCSEL_K2); CGX::SetTevKColorSel(GX_TEVSTAGE3, GX_TEV_KCSEL_K2);
GXSetTevColorS10(GX::TEVREG0, 0xffa60000ff8e0087u); GXSetTevColorS10(GX_TEVREG0, GXColorS10{-90, 0, -114, 135});
CGX::SetTevKColor(GX::KCOLOR0, zeus::Comp32(0x0000e258)); CGX::SetTevKColor(GX_KCOLOR0, GXColor{0x00, 0x00, 0xe2, 0x58});
CGX::SetTevKColor(GX::KCOLOR1, zeus::Comp32(0xb30000b6)); CGX::SetTevKColor(GX_KCOLOR1, GXColor{0xb3, 0x00, 0x00, 0xb6});
CGX::SetTevKColor(GX::KCOLOR2, zeus::Comp32(0xff00ff80)); CGX::SetTevKColor(GX_KCOLOR2, GXColor{0xff, 0x00, 0xff, 0x80});
} }
static void MyTHPGXRestore() { static void MyTHPGXRestore() {
CGX::SetZMode(true, GX::ALWAYS, false); CGX::SetZMode(true, GX_ALWAYS, false);
CGX::SetBlendMode(GX::BM_NONE, GX::BL_ONE, GX::BL_ZERO, GX::LO_SET); CGX::SetBlendMode(GX_BM_NONE, GX_BL_ONE, GX_BL_ZERO, GX_LO_SET);
CGX::SetNumTexGens(1); CGX::SetNumTexGens(1);
CGX::SetNumChans(0); CGX::SetNumChans(0);
CGX::SetNumTevStages(1); CGX::SetNumTevStages(1);
CGX::SetTevOrder(GX::TEVSTAGE0, GX::TEXCOORD0, GX::TEXMAP0, GX::COLOR_NULL); CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL);
CGX::SetAlphaCompare(GX::ALWAYS, 0, GX::AOP_AND, GX::ALWAYS, 0); CGX::SetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_ALWAYS, 0);
} }
/* used in the original to look up fixed-point dividends on a /* used in the original to look up fixed-point dividends on a
@ -295,25 +299,28 @@ CMoviePlayer::CMoviePlayer(const char* path, float preLoadSeconds, bool loop, bo
x80_textures.reserve(3); x80_textures.reserve(3);
for (int i = 0; i < 3; ++i) { for (int i = 0; i < 3; ++i) {
CTHPTextureSet& set = x80_textures.emplace_back(); CTHPTextureSet& set = x80_textures.emplace_back();
if (deinterlace) { // if (deinterlace) {
/* metaforce addition: this way interlaced THPs don't look horrible */ // /* metaforce addition: this way interlaced THPs don't look horrible */
set.Y[0] = aurora::gfx::new_dynamic_texture_2d(x6c_videoInfo.width, x6c_videoInfo.height / 2, 1, GX::TF_I8, // set.Y[0] = aurora::gfx::new_dynamic_texture_2d(x6c_videoInfo.width, x6c_videoInfo.height / 2, 1, GX_TF_I8,
fmt::format(FMT_STRING("Movie {} Texture Set {} Y[0]"), path, i)); // fmt::format(FMT_STRING("Movie {} Texture Set {} Y[0]"), path,
set.Y[1] = aurora::gfx::new_dynamic_texture_2d(x6c_videoInfo.width, x6c_videoInfo.height / 2, 1, GX::TF_I8, // i));
fmt::format(FMT_STRING("Movie {} Texture Set {} Y[1]"), path, i)); // set.Y[1] = aurora::gfx::new_dynamic_texture_2d(x6c_videoInfo.width, x6c_videoInfo.height / 2, 1, GX_TF_I8,
set.U = aurora::gfx::new_dynamic_texture_2d(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, 1, GX::TF_I8, // fmt::format(FMT_STRING("Movie {} Texture Set {} Y[1]"), path,
fmt::format(FMT_STRING("Movie {} Texture Set {} U"), path, i)); // i));
set.V = aurora::gfx::new_dynamic_texture_2d(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, 1, GX::TF_I8, // set.U = aurora::gfx::new_dynamic_texture_2d(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, 1, GX_TF_I8,
fmt::format(FMT_STRING("Movie {} Texture Set {} V"), path, i)); // fmt::format(FMT_STRING("Movie {} Texture Set {} U"), path, i));
} else { // set.V = aurora::gfx::new_dynamic_texture_2d(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, 1, GX_TF_I8,
/* normal progressive presentation */ // fmt::format(FMT_STRING("Movie {} Texture Set {} V"), path, i));
set.Y[0] = aurora::gfx::new_dynamic_texture_2d(x6c_videoInfo.width, x6c_videoInfo.height, 1, GX::TF_I8, // } else {
fmt::format(FMT_STRING("Movie {} Texture Set {} Y"), path, i)); // /* normal progressive presentation */
set.U = aurora::gfx::new_dynamic_texture_2d(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, 1, GX::TF_I8, // set.Y[0] = aurora::gfx::new_dynamic_texture_2d(x6c_videoInfo.width, x6c_videoInfo.height, 1, GX_TF_I8,
fmt::format(FMT_STRING("Movie {} Texture Set {} U"), path, i)); // fmt::format(FMT_STRING("Movie {} Texture Set {} Y"), path,
set.V = aurora::gfx::new_dynamic_texture_2d(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, 1, GX::TF_I8, // i));
fmt::format(FMT_STRING("Movie {} Texture Set {} V"), path, i)); // set.U = aurora::gfx::new_dynamic_texture_2d(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, 1, GX_TF_I8,
} // fmt::format(FMT_STRING("Movie {} Texture Set {} U"), path, i));
// set.V = aurora::gfx::new_dynamic_texture_2d(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, 1, GX_TF_I8,
// fmt::format(FMT_STRING("Movie {} Texture Set {} V"), path, i));
// }
if (xf4_25_hasAudio) if (xf4_25_hasAudio)
set.audioBuf.reset(new s16[x28_thpHead.maxAudioSamples * 2]); set.audioBuf.reset(new s16[x28_thpHead.maxAudioSamples * 2]);
} }
@ -485,22 +492,22 @@ bool CMoviePlayer::DrawVideo() {
const s32 vr = vpLeft + vpWidth + centerX; const s32 vr = vpLeft + vpWidth + centerX;
const s32 vb = vpTop + vpHeight + centerY; const s32 vb = vpTop + vpHeight + centerY;
const s32 vt = vpTop - centerY; const s32 vt = vpTop - centerY;
aurora::Vec3<float> v1; zeus::CVector3f v1;
aurora::Vec3<float> v2; zeus::CVector3f v2;
aurora::Vec3<float> v3; zeus::CVector3f v3;
aurora::Vec3<float> v4; zeus::CVector3f v4;
v1.x = vl; v1.x() = vl;
v1.y = 0.0; v1.y() = 0.0;
v1.z = vb; v1.z() = vb;
v2.x = vr; v2.x() = vr;
v2.y = 0.0; v2.y() = 0.0;
v2.z = vb; v2.z() = vb;
v3.x = vl; v3.x() = vl;
v3.y = 0.0; v3.y() = 0.0;
v3.z = vt; v3.z() = vt;
v4.x = vr; v4.x() = vr;
v4.y = 0.0; v4.y() = 0.0;
v4.z = vt; v4.z() = vt;
DrawFrame(v1, v2, v3, v4); DrawFrame(v1, v2, v3, v4);
return true; return true;
@ -525,27 +532,27 @@ void CMoviePlayer::DrawFrame(const zeus::CVector3f& v1, const zeus::CVector3f& v
vPad = CGraphics::GetViewportAspect() / 1.33f; vPad = CGraphics::GetViewportAspect() / 1.33f;
} }
/* draw appropriate field */ // /* draw appropriate field */
CTHPTextureSet& tex = x80_textures[xd0_drawTexSlot]; // CTHPTextureSet& tex = x80_textures[xd0_drawTexSlot];
aurora::gfx::queue_movie_player(tex.Y[m_deinterlace ? (xfc_fieldIndex != 0) : 0], tex.U, tex.V, hPad, vPad); // aurora::gfx::queue_movie_player(tex.Y[m_deinterlace ? (xfc_fieldIndex != 0) : 0], tex.U, tex.V, hPad, vPad);
// MyTHPGXYuv2RgbSetup(CGraphics::g_LastFrameUsedAbove, xf4_26_fieldFlip); MyTHPGXYuv2RgbSetup(CGraphics::g_LastFrameUsedAbove, xf4_26_fieldFlip);
// uintptr_t planeSize = x6c_videoInfo.width * x6c_videoInfo.height; uintptr_t planeSize = x6c_videoInfo.width * x6c_videoInfo.height;
// uintptr_t planeSizeQuarter = planeSize / 4; uintptr_t planeSizeQuarter = planeSize / 4;
// MyTHPYuv2RgbTextureSetup(m_yuvBuf.get(), m_yuvBuf.get() + planeSize, m_yuvBuf.get() + planeSize + planeSizeQuarter, MyTHPYuv2RgbTextureSetup(m_yuvBuf.get(), m_yuvBuf.get() + planeSize, m_yuvBuf.get() + planeSize + planeSizeQuarter,
// x6c_videoInfo.width, x6c_videoInfo.height); x6c_videoInfo.width, x6c_videoInfo.height);
//
// CGX::Begin(GX::TRIANGLEFAN, GX::VTXFMT7, 4); CGX::Begin(GX_TRIANGLEFAN, GX_VTXFMT7, 4);
// GXPosition3f32(v1); GXPosition3f32(v1);
// GXTexCoord2f32(0.f, 0.f); GXTexCoord2f32(0.f, 0.f);
// GXPosition3f32(v3); GXPosition3f32(v3);
// GXTexCoord2f32(0.f, 1.f); GXTexCoord2f32(0.f, 1.f);
// GXPosition3f32(v4); GXPosition3f32(v4);
// GXTexCoord2f32(1.f, 1.f); GXTexCoord2f32(1.f, 1.f);
// GXPosition3f32(v2); GXPosition3f32(v2);
// GXTexCoord2f32(1.f, 0.f); GXTexCoord2f32(1.f, 0.f);
// CGX::End(); CGX::End();
// MyTHPGXRestore(); MyTHPGXRestore();
/* ensure second field is being displayed by VI to signal advance /* ensure second field is being displayed by VI to signal advance
* (faked in metaforce with continuous xor) */ * (faked in metaforce with continuous xor) */
@ -659,25 +666,25 @@ void CMoviePlayer::DecodeFromRead(const void* data) {
uintptr_t planeSizeHalf = planeSize / 2; uintptr_t planeSizeHalf = planeSize / 2;
uintptr_t planeSizeQuarter = planeSizeHalf / 2; uintptr_t planeSizeQuarter = planeSizeHalf / 2;
if (m_deinterlace) { // if (m_deinterlace) {
/* Deinterlace into 2 discrete 60-fps half-res textures */ // /* Deinterlace into 2 discrete 60-fps half-res textures */
auto buffer = std::make_unique<u8[]>(planeSizeHalf); // auto buffer = std::make_unique<u8[]>(planeSizeHalf);
for (unsigned y = 0; y < x6c_videoInfo.height / 2; ++y) { // for (unsigned y = 0; y < x6c_videoInfo.height / 2; ++y) {
memcpy(buffer.get() + x6c_videoInfo.width * y, m_yuvBuf.get() + x6c_videoInfo.width * (y * 2), // memcpy(buffer.get() + x6c_videoInfo.width * y, m_yuvBuf.get() + x6c_videoInfo.width * (y * 2),
x6c_videoInfo.width); // x6c_videoInfo.width);
} // }
aurora::gfx::write_texture(*tex.Y[0], {buffer.get(), planeSizeHalf}); // aurora::gfx::write_texture(*tex.Y[0], {buffer.get(), planeSizeHalf});
for (unsigned y = 0; y < x6c_videoInfo.height / 2; ++y) { // for (unsigned y = 0; y < x6c_videoInfo.height / 2; ++y) {
memcpy(buffer.get() + x6c_videoInfo.width * y, m_yuvBuf.get() + x6c_videoInfo.width * (y * 2 + 1), // memcpy(buffer.get() + x6c_videoInfo.width * y, m_yuvBuf.get() + x6c_videoInfo.width * (y * 2 + 1),
x6c_videoInfo.width); // x6c_videoInfo.width);
} // }
aurora::gfx::write_texture(*tex.Y[1], {buffer.get(), planeSizeHalf}); // aurora::gfx::write_texture(*tex.Y[1], {buffer.get(), planeSizeHalf});
} else { // } else {
/* Direct planar load */ // /* Direct planar load */
aurora::gfx::write_texture(*tex.Y[0], {m_yuvBuf.get(), planeSize}); // aurora::gfx::write_texture(*tex.Y[0], {m_yuvBuf.get(), planeSize});
} // }
aurora::gfx::write_texture(*tex.U, {m_yuvBuf.get() + planeSize, planeSizeQuarter}); // aurora::gfx::write_texture(*tex.U, {m_yuvBuf.get() + planeSize, planeSizeQuarter});
aurora::gfx::write_texture(*tex.V, {m_yuvBuf.get() + planeSize + planeSizeQuarter, planeSizeQuarter}); // aurora::gfx::write_texture(*tex.V, {m_yuvBuf.get() + planeSize + planeSizeQuarter, planeSizeQuarter});
break; break;
} }

View File

@ -69,9 +69,9 @@ private:
}; };
struct CTHPTextureSet { struct CTHPTextureSet {
std::array<aurora::gfx::TextureHandle, 2> Y; std::array<GXTexObj, 2> Y;
aurora::gfx::TextureHandle U; GXTexObj U;
aurora::gfx::TextureHandle V; GXTexObj V;
u32 playedSamples = 0; u32 playedSamples = 0;
u32 audioSamples = 0; u32 audioSamples = 0;
std::unique_ptr<s16[]> audioBuf; std::unique_ptr<s16[]> audioBuf;

View File

@ -32,7 +32,7 @@ void CSimpleShadow::Render(TLockedToken<CTexture>& tex) {
CGraphics::DisableAllLights(); CGraphics::DisableAllLights();
CGraphics::SetModelMatrix(x0_xf); CGraphics::SetModelMatrix(x0_xf);
tex->Load(GX::TEXMAP0, EClampMode::Repeat); tex->Load(GX_TEXMAP0, EClampMode::Repeat);
CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::sTevPass805a5ebc); CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::sTevPass805a5ebc);
CGraphics::SetTevOp(ERglTevStage::Stage1, CTevCombiners::skPassThru); CGraphics::SetTevOp(ERglTevStage::Stage1, CTevCombiners::skPassThru);
@ -40,7 +40,7 @@ void CSimpleShadow::Render(TLockedToken<CTexture>& tex) {
CGraphics::SetDepthWriteMode(true, ERglEnum::LEqual, false); CGraphics::SetDepthWriteMode(true, ERglEnum::LEqual, false);
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::InvSrcAlpha, CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::InvSrcAlpha,
ERglLogicOp::Clear); ERglLogicOp::Clear);
CGraphics::StreamBegin(GX::QUADS); CGraphics::StreamBegin(GX_QUADS);
float radius = x34_radius * x30_scale; float radius = x34_radius * x30_scale;
CGraphics::StreamColor(zeus::CColor{1.f, x3c_heightAlpha * x38_userAlpha}); CGraphics::StreamColor(zeus::CColor{1.f, x3c_heightAlpha * x38_userAlpha});
CGraphics::StreamTexcoord(0.f, 0.f); CGraphics::StreamTexcoord(0.f, 0.f);

View File

@ -6,15 +6,15 @@ namespace metaforce::CTevCombiners {
u32 CTevPass::sNextUniquePass = 0; u32 CTevPass::sNextUniquePass = 0;
void CTevPass::Execute(ERglTevStage stage) const { void CTevPass::Execute(ERglTevStage stage) const {
const auto stageId = GX::TevStageID(stage); const auto stageId = GXTevStageID(stage);
CGX::SetTevColorIn(stageId, x4_colorPass.x0_a, x4_colorPass.x4_b, x4_colorPass.x8_c, x4_colorPass.xc_d); CGX::SetTevColorIn(stageId, x4_colorPass.x0_a, x4_colorPass.x4_b, x4_colorPass.x8_c, x4_colorPass.xc_d);
CGX::SetTevAlphaIn(stageId, x14_alphaPass.x0_a, x14_alphaPass.x4_b, x14_alphaPass.x8_c, x14_alphaPass.xc_d); CGX::SetTevAlphaIn(stageId, x14_alphaPass.x0_a, x14_alphaPass.x4_b, x14_alphaPass.x8_c, x14_alphaPass.xc_d);
CGX::SetTevColorOp(stageId, x24_colorOp.x4_op, x24_colorOp.x8_bias, x24_colorOp.xc_scale, x24_colorOp.x0_clamp, CGX::SetTevColorOp(stageId, x24_colorOp.x4_op, x24_colorOp.x8_bias, x24_colorOp.xc_scale, x24_colorOp.x0_clamp,
x24_colorOp.x10_regId); x24_colorOp.x10_regId);
CGX::SetTevAlphaOp(stageId, x38_alphaOp.x4_op, x38_alphaOp.x8_bias, x38_alphaOp.xc_scale, x38_alphaOp.x0_clamp, CGX::SetTevAlphaOp(stageId, x38_alphaOp.x4_op, x38_alphaOp.x8_bias, x38_alphaOp.xc_scale, x38_alphaOp.x0_clamp,
x38_alphaOp.x10_regId); x38_alphaOp.x10_regId);
CGX::SetTevKColorSel(stageId, GX::TevKColorSel::TEV_KCSEL_8_8); CGX::SetTevKColorSel(stageId, GX_TEV_KCSEL_8_8);
CGX::SetTevKAlphaSel(stageId, GX::TevKAlphaSel::TEV_KASEL_8_8); CGX::SetTevKAlphaSel(stageId, GX_TEV_KASEL_8_8);
} }
constexpr u32 maxTevPasses = 2; constexpr u32 maxTevPasses = 2;
@ -22,52 +22,52 @@ static u32 sNumEnabledPasses;
static std::array<bool, maxTevPasses> sValidPasses; static std::array<bool, maxTevPasses> sValidPasses;
const CTevPass skPassThru{ const CTevPass skPassThru{
{GX::TevColorArg::CC_ZERO, GX::TevColorArg::CC_ZERO, GX::TevColorArg::CC_ZERO, GX::TevColorArg::CC_RASC}, {GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_RASC},
{GX::TevAlphaArg::CA_ZERO, GX::TevAlphaArg::CA_ZERO, GX::TevAlphaArg::CA_ZERO, GX::TevAlphaArg::CA_RASA}, {GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_RASA},
}; };
const CTevPass sTevPass804bfcc0{ const CTevPass sTevPass804bfcc0{
{GX::TevColorArg::CC_C0, GX::TevColorArg::CC_TEXC, GX::TevColorArg::CC_RASC, GX::TevColorArg::CC_ZERO}, {GX_CC_C0, GX_CC_TEXC, GX_CC_RASC, GX_CC_ZERO},
{GX::TevAlphaArg::CA_ZERO, GX::TevAlphaArg::CA_ZERO, GX::TevAlphaArg::CA_ZERO, GX::TevAlphaArg::CA_RASA}, {GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_RASA},
}; };
const CTevPass sTevPass804bfe68{ const CTevPass sTevPass804bfe68{
{GX::TevColorArg::CC_ZERO, GX::TevColorArg::CC_CPREV, GX::TevColorArg::CC_RASC, GX::TevColorArg::CC_ZERO}, {GX_CC_ZERO, GX_CC_CPREV, GX_CC_RASC, GX_CC_ZERO},
{GX::TevAlphaArg::CA_ZERO, GX::TevAlphaArg::CA_APREV, GX::TevAlphaArg::CA_RASA, GX::TevAlphaArg::CA_ZERO}, {GX_CA_ZERO, GX_CA_APREV, GX_CA_RASA, GX_CA_ZERO},
}; };
const CTevPass sTevPass805a5698{ const CTevPass sTevPass805a5698{
{GX::TevColorArg::CC_ZERO, GX::TevColorArg::CC_RASC, GX::TevColorArg::CC_C0, GX::TevColorArg::CC_ZERO}, {GX_CC_ZERO, GX_CC_RASC, GX_CC_C0, GX_CC_ZERO},
{GX::TevAlphaArg::CA_ZERO, GX::TevAlphaArg::CA_RASA, GX::TevAlphaArg::CA_A0, GX::TevAlphaArg::CA_ZERO}, {GX_CA_ZERO, GX_CA_RASA, GX_CA_A0, GX_CA_ZERO},
}; };
const CTevPass sTevPass805a5e70{ const CTevPass sTevPass805a5e70{
{GX::TevColorArg::CC_ZERO, GX::TevColorArg::CC_ZERO, GX::TevColorArg::CC_ZERO, GX::TevColorArg::CC_C0}, {GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_C0},
{GX::TevAlphaArg::CA_ZERO, GX::TevAlphaArg::CA_ZERO, GX::TevAlphaArg::CA_ZERO, GX::TevAlphaArg::CA_A0}, {GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_A0},
}; };
const CTevPass sTevPass805a5ebc{ const CTevPass sTevPass805a5ebc{
{GX::TevColorArg::CC_ZERO, GX::TevColorArg::CC_RASC, GX::TevColorArg::CC_TEXC, GX::TevColorArg::CC_ZERO}, {GX_CC_ZERO, GX_CC_RASC, GX_CC_TEXC, GX_CC_ZERO},
{GX::TevAlphaArg::CA_ZERO, GX::TevAlphaArg::CA_RASA, GX::TevAlphaArg::CA_TEXA, GX::TevAlphaArg::CA_ZERO}, {GX_CA_ZERO, GX_CA_RASA, GX_CA_TEXA, GX_CA_ZERO},
}; };
const CTevPass sTevPass805a5f08{ const CTevPass sTevPass805a5f08{
{GX::TevColorArg::CC_RASC, GX::TevColorArg::CC_TEXC, GX::TevColorArg::CC_TEXA, GX::TevColorArg::CC_ZERO}, {GX_CC_RASC, GX_CC_TEXC, GX_CC_TEXA, GX_CC_ZERO},
{GX::TevAlphaArg::CA_ZERO, GX::TevAlphaArg::CA_ZERO, GX::TevAlphaArg::CA_ZERO, GX::TevAlphaArg::CA_RASA}, {GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_RASA},
}; };
const CTevPass sTevPass805a5f54{ const CTevPass sTevPass805a5f54{
{GX::TevColorArg::CC_RASC, GX::TevColorArg::CC_ONE, GX::TevColorArg::CC_TEXC, GX::TevColorArg::CC_ZERO}, {GX_CC_RASC, GX_CC_ONE, GX_CC_TEXC, GX_CC_ZERO},
{GX::TevAlphaArg::CA_ZERO, GX::TevAlphaArg::CA_TEXA, GX::TevAlphaArg::CA_RASA, GX::TevAlphaArg::CA_ZERO}, {GX_CA_ZERO, GX_CA_TEXA, GX_CA_RASA, GX_CA_ZERO},
}; };
const CTevPass sTevPass805a5fa0{ const CTevPass sTevPass805a5fa0{
{GX::TevColorArg::CC_ZERO, GX::TevColorArg::CC_ZERO, GX::TevColorArg::CC_ZERO, GX::TevColorArg::CC_TEXC}, {GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_TEXC},
{GX::TevAlphaArg::CA_ZERO, GX::TevAlphaArg::CA_ZERO, GX::TevAlphaArg::CA_ZERO, GX::TevAlphaArg::CA_TEXA}, {GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_TEXA},
}; };
const CTevPass sTevPass805a5fec{ const CTevPass sTevPass805a5fec{
{GX::TevColorArg::CC_ZERO, GX::TevColorArg::CC_ZERO, GX::TevColorArg::CC_ZERO, GX::TevColorArg::CC_RASC}, {GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_RASC},
{GX::TevAlphaArg::CA_ZERO, GX::TevAlphaArg::CA_TEXA, GX::TevAlphaArg::CA_RASA, GX::TevAlphaArg::CA_ZERO}, {GX_CA_ZERO, GX_CA_TEXA, GX_CA_RASA, GX_CA_ZERO},
}; };
const CTevPass sTevPass805a6038{ const CTevPass sTevPass805a6038{
{GX::TevColorArg::CC_ZERO, GX::TevColorArg::CC_TEXC, GX::TevColorArg::CC_RASC, GX::TevColorArg::CC_ZERO}, {GX_CC_ZERO, GX_CC_TEXC, GX_CC_RASC, GX_CC_ZERO},
{GX::TevAlphaArg::CA_ZERO, GX::TevAlphaArg::CA_KONST, GX::TevAlphaArg::CA_RASA, GX::TevAlphaArg::CA_ZERO}, {GX_CA_ZERO, GX_CA_KONST, GX_CA_RASA, GX_CA_ZERO},
}; };
const CTevPass sTevPass805a6084{ const CTevPass sTevPass805a6084{
{GX::TevColorArg::CC_ZERO, GX::TevColorArg::CC_CPREV, GX::TevColorArg::CC_APREV, GX::TevColorArg::CC_ZERO}, {GX_CC_ZERO, GX_CC_CPREV, GX_CC_APREV, GX_CC_ZERO},
{GX::TevAlphaArg::CA_ZERO, GX::TevAlphaArg::CA_ZERO, GX::TevAlphaArg::CA_ZERO, GX::TevAlphaArg::CA_APREV}, {GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_APREV},
}; };
void Init() { void Init() {

View File

@ -4,78 +4,77 @@
#include "RetroTypes.hpp" #include "RetroTypes.hpp"
namespace metaforce { namespace metaforce {
enum class ERglTevStage : std::underlying_type_t<GX::TevStageID> { enum class ERglTevStage : std::underlying_type_t<GXTevStageID> {
Stage0 = GX::TEVSTAGE0, Stage0 = GX_TEVSTAGE0,
Stage1 = GX::TEVSTAGE1, Stage1 = GX_TEVSTAGE1,
Stage2 = GX::TEVSTAGE2, Stage2 = GX_TEVSTAGE2,
Stage3 = GX::TEVSTAGE3, Stage3 = GX_TEVSTAGE3,
Stage4 = GX::TEVSTAGE4, Stage4 = GX_TEVSTAGE4,
Stage5 = GX::TEVSTAGE5, Stage5 = GX_TEVSTAGE5,
Stage6 = GX::TEVSTAGE6, Stage6 = GX_TEVSTAGE6,
Stage7 = GX::TEVSTAGE7, Stage7 = GX_TEVSTAGE7,
Stage8 = GX::TEVSTAGE8, Stage8 = GX_TEVSTAGE8,
Stage9 = GX::TEVSTAGE9, Stage9 = GX_TEVSTAGE9,
Stage10 = GX::TEVSTAGE10, Stage10 = GX_TEVSTAGE10,
Stage11 = GX::TEVSTAGE11, Stage11 = GX_TEVSTAGE11,
Stage12 = GX::TEVSTAGE12, Stage12 = GX_TEVSTAGE12,
Stage13 = GX::TEVSTAGE13, Stage13 = GX_TEVSTAGE13,
Stage14 = GX::TEVSTAGE14, Stage14 = GX_TEVSTAGE14,
Stage15 = GX::TEVSTAGE15, Stage15 = GX_TEVSTAGE15,
Max = GX::MAX_TEVSTAGE, Max = GX_MAX_TEVSTAGE,
None = GX::NULL_STAGE,
}; };
namespace CTevCombiners { namespace CTevCombiners {
struct CTevOp { struct CTevOp {
bool x0_clamp = true; bool x0_clamp = true;
GX::TevOp x4_op = GX::TevOp::TEV_ADD; GXTevOp x4_op = GX_TEV_ADD;
GX::TevBias x8_bias = GX::TevBias::TB_ZERO; GXTevBias x8_bias = GX_TB_ZERO;
GX::TevScale xc_scale = GX::TevScale::CS_SCALE_1; GXTevScale xc_scale = GX_CS_SCALE_1;
GX::TevRegID x10_regId = GX::TevRegID::TEVPREV; GXTevRegID x10_regId = GX_TEVPREV;
constexpr CTevOp() = default; constexpr CTevOp() = default;
constexpr CTevOp(bool clamp, GX::TevOp op, GX::TevBias bias, GX::TevScale scale, GX::TevRegID regId) constexpr CTevOp(bool clamp, GXTevOp op, GXTevBias bias, GXTevScale scale, GXTevRegID regId)
: x0_clamp(clamp), x4_op(op), x8_bias(bias), xc_scale(scale), x10_regId(regId) {} : x0_clamp(clamp), x4_op(op), x8_bias(bias), xc_scale(scale), x10_regId(regId) {}
constexpr CTevOp(u32 compressedDesc) constexpr CTevOp(u32 compressedDesc)
: x0_clamp((compressedDesc >> 8 & 1) != 0) : x0_clamp((compressedDesc >> 8 & 1) != 0)
, x4_op(static_cast<GX::TevOp>(compressedDesc & 0xF)) , x4_op(static_cast<GXTevOp>(compressedDesc & 0xF))
, x8_bias(static_cast<GX::TevBias>(compressedDesc >> 4 & 3)) , x8_bias(static_cast<GXTevBias>(compressedDesc >> 4 & 3))
, xc_scale(static_cast<GX::TevScale>(compressedDesc >> 6 & 3)) , xc_scale(static_cast<GXTevScale>(compressedDesc >> 6 & 3))
, x10_regId(static_cast<GX::TevRegID>(compressedDesc >> 9 & 3)) {} , x10_regId(static_cast<GXTevRegID>(compressedDesc >> 9 & 3)) {}
bool operator==(const CTevOp& rhs) const { bool operator==(const CTevOp& rhs) const {
return x0_clamp == rhs.x0_clamp && x4_op == rhs.x4_op && x8_bias == rhs.x8_bias && xc_scale == rhs.xc_scale; return x0_clamp == rhs.x0_clamp && x4_op == rhs.x4_op && x8_bias == rhs.x8_bias && xc_scale == rhs.xc_scale;
} }
}; };
struct ColorPass { struct ColorPass {
GX::TevColorArg x0_a; GXTevColorArg x0_a;
GX::TevColorArg x4_b; GXTevColorArg x4_b;
GX::TevColorArg x8_c; GXTevColorArg x8_c;
GX::TevColorArg xc_d; GXTevColorArg xc_d;
constexpr ColorPass(GX::TevColorArg a, GX::TevColorArg b, GX::TevColorArg c, GX::TevColorArg d) constexpr ColorPass(GXTevColorArg a, GXTevColorArg b, GXTevColorArg c, GXTevColorArg d)
: x0_a(a), x4_b(b), x8_c(c), xc_d(d) {} : x0_a(a), x4_b(b), x8_c(c), xc_d(d) {}
constexpr ColorPass(u32 compressedDesc) constexpr ColorPass(u32 compressedDesc)
: x0_a(static_cast<GX::TevColorArg>(compressedDesc & 0x1F)) : x0_a(static_cast<GXTevColorArg>(compressedDesc & 0x1F))
, x4_b(static_cast<GX::TevColorArg>(compressedDesc >> 5 & 0x1F)) , x4_b(static_cast<GXTevColorArg>(compressedDesc >> 5 & 0x1F))
, x8_c(static_cast<GX::TevColorArg>(compressedDesc >> 10 & 0x1F)) , x8_c(static_cast<GXTevColorArg>(compressedDesc >> 10 & 0x1F))
, xc_d(static_cast<GX::TevColorArg>(compressedDesc >> 15 & 0x1F)) {} , xc_d(static_cast<GXTevColorArg>(compressedDesc >> 15 & 0x1F)) {}
bool operator==(const ColorPass& rhs) const { return memcmp(this, &rhs, sizeof(*this)) == 0; } bool operator==(const ColorPass& rhs) const { return memcmp(this, &rhs, sizeof(*this)) == 0; }
}; };
struct AlphaPass { struct AlphaPass {
GX::TevAlphaArg x0_a; GXTevAlphaArg x0_a;
GX::TevAlphaArg x4_b; GXTevAlphaArg x4_b;
GX::TevAlphaArg x8_c; GXTevAlphaArg x8_c;
GX::TevAlphaArg xc_d; GXTevAlphaArg xc_d;
constexpr AlphaPass(GX::TevAlphaArg a, GX::TevAlphaArg b, GX::TevAlphaArg c, GX::TevAlphaArg d) constexpr AlphaPass(GXTevAlphaArg a, GXTevAlphaArg b, GXTevAlphaArg c, GXTevAlphaArg d)
: x0_a(a), x4_b(b), x8_c(c), xc_d(d) {} : x0_a(a), x4_b(b), x8_c(c), xc_d(d) {}
constexpr AlphaPass(u32 compressedDesc) constexpr AlphaPass(u32 compressedDesc)
: x0_a(static_cast<GX::TevAlphaArg>(compressedDesc & 0x1F)) : x0_a(static_cast<GXTevAlphaArg>(compressedDesc & 0x1F))
, x4_b(static_cast<GX::TevAlphaArg>(compressedDesc >> 5 & 0x1F)) , x4_b(static_cast<GXTevAlphaArg>(compressedDesc >> 5 & 0x1F))
, x8_c(static_cast<GX::TevAlphaArg>(compressedDesc >> 10 & 0x1F)) , x8_c(static_cast<GXTevAlphaArg>(compressedDesc >> 10 & 0x1F))
, xc_d(static_cast<GX::TevAlphaArg>(compressedDesc >> 15 & 0x1F)) {} , xc_d(static_cast<GXTevAlphaArg>(compressedDesc >> 15 & 0x1F)) {}
bool operator==(const AlphaPass& rhs) const { return memcmp(this, &rhs, sizeof(*this)) == 0; } bool operator==(const AlphaPass& rhs) const { return memcmp(this, &rhs, sizeof(*this)) == 0; }
}; };

View File

@ -6,7 +6,7 @@
#include <magic_enum.hpp> #include <magic_enum.hpp>
namespace metaforce { namespace metaforce {
static std::array<CTexture*, GX::MAX_TEXMAP> sLoadedTextures{}; static std::array<CTexture*, GX_MAX_TEXMAP> sLoadedTextures{};
CTexture::CTexture(ETexelFormat fmt, u16 w, u16 h, s32 mips, std::string_view label) CTexture::CTexture(ETexelFormat fmt, u16 w, u16 h, s32 mips, std::string_view label)
: x0_fmt(fmt) : x0_fmt(fmt)
@ -21,7 +21,7 @@ CTexture::CTexture(ETexelFormat fmt, u16 w, u16 h, s32 mips, std::string_view la
} }
CTexture::CTexture(CInputStream& in, std::string_view label, EAutoMipmap automip, EBlackKey blackKey) CTexture::CTexture(CInputStream& in, std::string_view label, EAutoMipmap automip, EBlackKey blackKey)
: x0_fmt(ETexelFormat(in.ReadLong())) : x0_fmt(static_cast<ETexelFormat>(in.ReadLong()))
, x4_w(in.ReadShort()) , x4_w(in.ReadShort())
, x6_h(in.ReadShort()) , x6_h(in.ReadShort())
, x8_mips(in.ReadLong()) , x8_mips(in.ReadLong())
@ -64,6 +64,8 @@ CTexture::CTexture(CInputStream& in, std::string_view label, EAutoMipmap automip
InitTextureObjs(); InitTextureObjs();
} }
CTexture::~CTexture() { GXDestroyTexObj(&x20_texObj); }
u8* CTexture::Lock() { u8* CTexture::Lock() {
xa_24_locked = true; xa_24_locked = true;
return GetBitMapData(0); return GetBitMapData(0);
@ -78,7 +80,7 @@ void CTexture::UnLock() {
m_needsTexObjDataLoad = true; m_needsTexObjDataLoad = true;
} }
void CTexture::Load(GX::TexMapID id, EClampMode clamp) { void CTexture::Load(GXTexMapID id, EClampMode clamp) {
if (sLoadedTextures[id] != this || xa_29_canLoadObj) { if (sLoadedTextures[id] != this || xa_29_canLoadObj) {
auto* data = /*x44_aramToken.GetMRAMSafe() */ x44_aramToken_x4_buff.get(); auto* data = /*x44_aramToken.GetMRAMSafe() */ x44_aramToken_x4_buff.get();
CountMemory(); CountMemory();
@ -104,7 +106,7 @@ void CTexture::Load(GX::TexMapID id, EClampMode clamp) {
} }
} }
void CTexture::LoadMipLevel(float lod, GX::TexMapID id, EClampMode clamp) { void CTexture::LoadMipLevel(float lod, GXTexMapID id, EClampMode clamp) {
// auto image_ptr = /*x44_aramToken.GetMRAMSafe() */ x44_aramToken_x4_buff.get(); // auto image_ptr = /*x44_aramToken.GetMRAMSafe() */ x44_aramToken_x4_buff.get();
// u32 width = x4_w; // u32 width = x4_w;
// u32 height = x6_h; // u32 height = x6_h;
@ -154,16 +156,16 @@ u8* CTexture::GetBitMapData(s32 mip) const { return const_cast<u8*>(GetConstBitM
void CTexture::InitBitmapBuffers(ETexelFormat fmt, u16 width, u16 height, s32 mips) { void CTexture::InitBitmapBuffers(ETexelFormat fmt, u16 width, u16 height, s32 mips) {
switch (fmt) { switch (fmt) {
case ETexelFormat::I4: case ETexelFormat::I4:
x18_gxFormat = GX::TF_I4; x18_gxFormat = GX_TF_I4;
break; break;
case ETexelFormat::I8: case ETexelFormat::I8:
x18_gxFormat = GX::TF_I8; x18_gxFormat = GX_TF_I8;
break; break;
case ETexelFormat::IA4: case ETexelFormat::IA4:
x18_gxFormat = GX::TF_IA4; x18_gxFormat = GX_TF_IA4;
break; break;
case ETexelFormat::IA8: case ETexelFormat::IA8:
x18_gxFormat = GX::TF_IA8; x18_gxFormat = GX_TF_IA8;
break; break;
case ETexelFormat::C4: case ETexelFormat::C4:
x1c_gxCIFormat = GX_TF_C4; x1c_gxCIFormat = GX_TF_C4;
@ -175,16 +177,23 @@ void CTexture::InitBitmapBuffers(ETexelFormat fmt, u16 width, u16 height, s32 mi
x1c_gxCIFormat = GX_TF_C14X2; x1c_gxCIFormat = GX_TF_C14X2;
break; break;
case ETexelFormat::RGB565: case ETexelFormat::RGB565:
x18_gxFormat = GX::TF_RGB565; x18_gxFormat = GX_TF_RGB565;
break; break;
case ETexelFormat::RGB5A3: case ETexelFormat::RGB5A3:
x18_gxFormat = GX::TF_RGB5A3; x18_gxFormat = GX_TF_RGB5A3;
break; break;
case ETexelFormat::RGBA8: case ETexelFormat::RGBA8:
x18_gxFormat = GX::TF_RGBA8; x18_gxFormat = GX_TF_RGBA8;
break; break;
case ETexelFormat::CMPR: case ETexelFormat::CMPR:
x18_gxFormat = GX::TF_CMPR; x18_gxFormat = GX_TF_CMPR;
break;
// Metaforce additions
case ETexelFormat::R8PC:
x18_gxFormat = GX_TF_R8_PC;
break;
case ETexelFormat::RGBA8PC:
x18_gxFormat = GX_TF_RGBA8_PC;
break; break;
default: default:
break; break;
@ -192,7 +201,7 @@ void CTexture::InitBitmapBuffers(ETexelFormat fmt, u16 width, u16 height, s32 mi
u32 format = (x0_fmt == ETexelFormat::C4 || x0_fmt == ETexelFormat::C8 || x0_fmt == ETexelFormat::C14X2) u32 format = (x0_fmt == ETexelFormat::C4 || x0_fmt == ETexelFormat::C8 || x0_fmt == ETexelFormat::C14X2)
? u32(x1c_gxCIFormat) ? u32(x1c_gxCIFormat)
: u32(x18_gxFormat); : x18_gxFormat;
xc_memoryAllocated = GXGetTexBufferSize(width, height, format, mips > 1, mips > 1 ? 11 : 0); xc_memoryAllocated = GXGetTexBufferSize(width, height, format, mips > 1, mips > 1 ? 11 : 0);
x44_aramToken_x4_buff = std::make_unique<u8[]>(xc_memoryAllocated); x44_aramToken_x4_buff = std::make_unique<u8[]>(xc_memoryAllocated);
/*x44_aramToken.PostConstruct(buf, xc_memoryAllocated, 1);*/ /*x44_aramToken.PostConstruct(buf, xc_memoryAllocated, 1);*/
@ -268,8 +277,7 @@ bool CTexture::sMangleMips = false;
u32 CTexture::sCurrentFrameCount = 0; u32 CTexture::sCurrentFrameCount = 0;
u32 CTexture::sTotalAllocatedMemory = 0; u32 CTexture::sTotalAllocatedMemory = 0;
void CTexture::InvalidateTexMap(GX::TexMapID id) { void CTexture::InvalidateTexMap(GXTexMapID id) {
// TODO: can we unbind in GX?
sLoadedTextures[id] = nullptr; sLoadedTextures[id] = nullptr;
} }

View File

@ -9,6 +9,24 @@
#include "GX.hpp" #include "GX.hpp"
namespace metaforce { namespace metaforce {
enum class ETexelFormat {
Invalid = -1,
I4 = 0,
I8 = 1,
IA4 = 2,
IA8 = 3,
C4 = 4,
C8 = 5,
C14X2 = 6,
RGB565 = 7,
RGB5A3 = 8,
RGBA8 = 9,
CMPR = 10,
// Metaforce addition: non-converting formats
RGBA8PC = 11,
R8PC = 12,
};
enum class EClampMode : std::underlying_type_t<GXTexWrapMode> { enum class EClampMode : std::underlying_type_t<GXTexWrapMode> {
Clamp = GX_CLAMP, Clamp = GX_CLAMP,
Repeat = GX_REPEAT, Repeat = GX_REPEAT,
@ -63,7 +81,7 @@ private:
u32 xc_memoryAllocated = 0; u32 xc_memoryAllocated = 0;
std::unique_ptr<CGraphicsPalette> x10_graphicsPalette; std::unique_ptr<CGraphicsPalette> x10_graphicsPalette;
std::unique_ptr<CDumpedBitmapDataReloader> x14_bitmapReloader; std::unique_ptr<CDumpedBitmapDataReloader> x14_bitmapReloader;
GX::TextureFormat x18_gxFormat = GX::TF_RGB565; u32 x18_gxFormat = GX_TF_RGB565;
GXCITexFmt x1c_gxCIFormat = GX_TF_C8; GXCITexFmt x1c_gxCIFormat = GX_TF_C8;
GXTexObj x20_texObj; GXTexObj x20_texObj;
EClampMode x40_clampMode = EClampMode::Repeat; EClampMode x40_clampMode = EClampMode::Repeat;
@ -86,6 +104,7 @@ public:
CTexture(ETexelFormat fmt, u16 w, u16 h, s32 mips, std::string_view label); CTexture(ETexelFormat fmt, u16 w, u16 h, s32 mips, std::string_view label);
CTexture(CInputStream& in, std::string_view label, EAutoMipmap automip = EAutoMipmap::Zero, CTexture(CInputStream& in, std::string_view label, EAutoMipmap automip = EAutoMipmap::Zero,
EBlackKey blackKey = EBlackKey::Zero); EBlackKey blackKey = EBlackKey::Zero);
~CTexture();
[[nodiscard]] ETexelFormat GetTextureFormat() const { return x0_fmt; } [[nodiscard]] ETexelFormat GetTextureFormat() const { return x0_fmt; }
[[nodiscard]] u16 GetWidth() const { return x4_w; } [[nodiscard]] u16 GetWidth() const { return x4_w; }
@ -97,8 +116,8 @@ public:
[[nodiscard]] bool HasPalette() const { return x10_graphicsPalette != nullptr; } [[nodiscard]] bool HasPalette() const { return x10_graphicsPalette != nullptr; }
[[nodiscard]] u8* Lock(); [[nodiscard]] u8* Lock();
void UnLock(); void UnLock();
void Load(GX::TexMapID id, EClampMode clamp); void Load(GXTexMapID id, EClampMode clamp);
void LoadMipLevel(float lod, GX::TexMapID id, EClampMode clamp); // was an s32 mip parameter, adjusted to use lod void LoadMipLevel(float lod, GXTexMapID id, EClampMode clamp); // was an s32 mip parameter, adjusted to use lod
// void UnloadBitmapData(u32) const; // void UnloadBitmapData(u32) const;
// void TryReloadBitmapData(CResFactory&) const; // void TryReloadBitmapData(CResFactory&) const;
// void LoadToMRAM() const; // void LoadToMRAM() const;
@ -112,7 +131,7 @@ public:
return x0_fmt == ETexelFormat::C4 || x0_fmt == ETexelFormat::C8 || x0_fmt == ETexelFormat::C14X2; return x0_fmt == ETexelFormat::C4 || x0_fmt == ETexelFormat::C8 || x0_fmt == ETexelFormat::C14X2;
} }
static void InvalidateTexMap(GX::TexMapID id); static void InvalidateTexMap(GXTexMapID id);
static void SetMangleMips(bool b) { sMangleMips = b; } static void SetMangleMips(bool b) { sMangleMips = b; }
static void SetCurrentFrameCount(u32 frameCount) { sCurrentFrameCount = frameCount; } static void SetCurrentFrameCount(u32 frameCount) { sCurrentFrameCount = frameCount; }
}; };

File diff suppressed because it is too large Load Diff

View File

@ -33,11 +33,11 @@ public:
enum class EDrawableSorting { SortedCallback, UnsortedCallback }; enum class EDrawableSorting { SortedCallback, UnsortedCallback };
enum class EDebugOption { Invalid = -1, PVSMode, PVSState, FogDisabled }; enum class EDebugOption { Invalid = -1, PVSMode, PVSState, FogDisabled };
enum class EPrimitiveType { enum class EPrimitiveType {
Triangles = GX::TRIANGLES, Triangles = GX_TRIANGLES,
TriangleFan = GX::TRIANGLEFAN, TriangleFan = GX_TRIANGLEFAN,
TriangleStrip = GX::TRIANGLESTRIP, TriangleStrip = GX_TRIANGLESTRIP,
Lines = GX::LINES, Lines = GX_LINES,
LineStrip = GX::LINESTRIP, LineStrip = GX_LINESTRIP,
}; };
virtual ~IRenderer() = default; virtual ~IRenderer() = default;

View File

@ -61,7 +61,7 @@ void CColoredStripShader::Shutdown() {
// stages.data(), nullptr, nullptr, texs.size(), texs.data(), nullptr, nullptr); // stages.data(), nullptr, nullptr, texs.size(), texs.data(), nullptr, nullptr);
//} //}
CColoredStripShader::CColoredStripShader(size_t maxVerts, Mode mode, aurora::gfx::TextureHandle tex) { CColoredStripShader::CColoredStripShader(size_t maxVerts, Mode mode, CTexture& tex) {
// CGraphics::CommitResources([this, maxVerts, mode, tex](boo::IGraphicsDataFactory::Context& ctx) { // CGraphics::CommitResources([this, maxVerts, mode, tex](boo::IGraphicsDataFactory::Context& ctx) {
// BuildResources(ctx, maxVerts, mode, tex); // BuildResources(ctx, maxVerts, mode, tex);
// return true; // return true;

View File

@ -32,7 +32,7 @@ public:
}; };
static void Initialize(); static void Initialize();
static void Shutdown(); static void Shutdown();
CColoredStripShader(size_t maxVerts, Mode mode, aurora::gfx::TextureHandle tex); CColoredStripShader(size_t maxVerts, Mode mode, CTexture& tex);
void draw(const zeus::CColor& color, size_t numVerts, const Vert* verts); void draw(const zeus::CColor& color, size_t numVerts, const Vert* verts);
}; };

View File

@ -198,7 +198,7 @@ CFluidPlaneShader::CFluidPlaneShader(EFluidType type, const TLockedToken<CTextur
const TLockedToken<CTexture>& patternTex2, const TLockedToken<CTexture>& colorTex, const TLockedToken<CTexture>& patternTex2, const TLockedToken<CTexture>& colorTex,
const TLockedToken<CTexture>& bumpMap, const TLockedToken<CTexture>& envMap, const TLockedToken<CTexture>& bumpMap, const TLockedToken<CTexture>& envMap,
const TLockedToken<CTexture>& envBumpMap, const TLockedToken<CTexture>& lightmap, const TLockedToken<CTexture>& envBumpMap, const TLockedToken<CTexture>& lightmap,
const aurora::gfx::TextureHandle& rippleMap, bool doubleLightmapBlend, CTexture& rippleMap, bool doubleLightmapBlend,
bool additive, u32 maxVertCount) bool additive, u32 maxVertCount)
: m_patternTex1(patternTex1) : m_patternTex1(patternTex1)
, m_patternTex2(patternTex2) , m_patternTex2(patternTex2)
@ -207,10 +207,11 @@ CFluidPlaneShader::CFluidPlaneShader(EFluidType type, const TLockedToken<CTextur
, m_envMap(envMap) , m_envMap(envMap)
, m_envBumpMap(envBumpMap) , m_envBumpMap(envBumpMap)
, m_lightmap(lightmap) , m_lightmap(lightmap)
, m_rippleMap(rippleMap) { //, m_rippleMap(rippleMap)
{
SFluidPlaneShaderInfo shaderInfo(type, m_patternTex1.HasReference(), m_patternTex2.HasReference(), SFluidPlaneShaderInfo shaderInfo(type, m_patternTex1.HasReference(), m_patternTex2.HasReference(),
m_colorTex.HasReference(), m_bumpMap.HasReference(), m_envMap.HasReference(), m_colorTex.HasReference(), m_bumpMap.HasReference(), m_envMap.HasReference(),
m_envBumpMap.HasReference(), m_lightmap.HasReference(), m_rippleMap.operator bool(), m_envBumpMap.HasReference(), m_lightmap.HasReference(), false/*m_rippleMap.operator bool()*/,
doubleLightmapBlend, additive); doubleLightmapBlend, additive);
// m_pipelines = _cache.GetOrBuildShader(shaderInfo); // m_pipelines = _cache.GetOrBuildShader(shaderInfo);
PrepareBinding(maxVertCount); PrepareBinding(maxVertCount);

View File

@ -106,7 +106,7 @@ private:
TLockedToken<CTexture> m_envMap; TLockedToken<CTexture> m_envMap;
TLockedToken<CTexture> m_envBumpMap; TLockedToken<CTexture> m_envBumpMap;
TLockedToken<CTexture> m_lightmap; TLockedToken<CTexture> m_lightmap;
aurora::gfx::TextureHandle m_rippleMap; // aurora::gfx::TextureHandle m_rippleMap;
// boo::ObjToken<boo::IGraphicsBufferD> m_vbo; // boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
// boo::ObjToken<boo::IGraphicsBufferD> m_pvbo; // boo::ObjToken<boo::IGraphicsBufferD> m_pvbo;
// boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf; // boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
@ -145,7 +145,7 @@ public:
const TLockedToken<CTexture>& patternTex2, const TLockedToken<CTexture>& colorTex, const TLockedToken<CTexture>& patternTex2, const TLockedToken<CTexture>& colorTex,
const TLockedToken<CTexture>& bumpMap, const TLockedToken<CTexture>& envMap, const TLockedToken<CTexture>& bumpMap, const TLockedToken<CTexture>& envMap,
const TLockedToken<CTexture>& envBumpMap, const TLockedToken<CTexture>& lightmap, const TLockedToken<CTexture>& envBumpMap, const TLockedToken<CTexture>& lightmap,
const aurora::gfx::TextureHandle& rippleMap, bool doubleLightmapBlend, bool additive, CTexture& rippleMap, bool doubleLightmapBlend, bool additive,
u32 maxVertCount); u32 maxVertCount);
CFluidPlaneShader(const TLockedToken<CTexture>& patternTex1, const TLockedToken<CTexture>& patternTex2, CFluidPlaneShader(const TLockedToken<CTexture>& patternTex1, const TLockedToken<CTexture>& patternTex2,
const TLockedToken<CTexture>& colorTex, u32 maxVertCount); const TLockedToken<CTexture>& colorTex, u32 maxVertCount);

View File

@ -54,7 +54,7 @@ void CLineRendererShaders::Shutdown() {
} }
void CLineRendererShaders::BuildShaderDataBinding(CLineRenderer& renderer, void CLineRendererShaders::BuildShaderDataBinding(CLineRenderer& renderer,
const aurora::gfx::TextureHandle& texture, bool additive, CTexture& texture, bool additive,
bool zTest, bool zGEqual) { bool zTest, bool zGEqual) {
// std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* pipeline = nullptr; // std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* pipeline = nullptr;
// //

View File

@ -26,7 +26,7 @@ public:
static void Initialize(); static void Initialize();
static void Shutdown(); static void Shutdown();
static void BuildShaderDataBinding(CLineRenderer& renderer, static void BuildShaderDataBinding(CLineRenderer& renderer,
const aurora::gfx::TextureHandle& texture, bool additive, bool zTest, CTexture& texture, bool additive, bool zTest,
bool zGEqual); bool zGEqual);
}; };

View File

@ -18,8 +18,8 @@ void CMapSurfaceShader::Shutdown() {
// s_Pipeline.reset(); // s_Pipeline.reset();
} }
CMapSurfaceShader::CMapSurfaceShader(aurora::ArrayRef<zeus::CVector3f> vbo, CMapSurfaceShader::CMapSurfaceShader(std::vector<zeus::CVector3f> vbo,
aurora::ArrayRef<uint16_t> ibo) std::vector<uint16_t> ibo)
//: m_vbo(vbo), m_ibo(ibo) //: m_vbo(vbo), m_ibo(ibo)
{ {
// m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1); // m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);

View File

@ -22,8 +22,8 @@ class CMapSurfaceShader {
public: public:
static void Initialize(); static void Initialize();
static void Shutdown(); static void Shutdown();
CMapSurfaceShader(aurora::ArrayRef<zeus::CVector3f> vbo, CMapSurfaceShader(std::vector<zeus::CVector3f> vbo,
aurora::ArrayRef<uint16_t> ibo); std::vector<uint16_t> ibo);
void draw(const zeus::CColor& color, u32 start, u32 count); void draw(const zeus::CColor& color, u32 start, u32 count);
}; };

View File

@ -35,39 +35,38 @@ void CSpaceWarpFilter::GenerateWarpRampTex() {
data[y][x][0] = data[y][x][1] = data[y][x][2]; data[y][x][0] = data[y][x][1] = data[y][x][2];
} }
} }
m_warpTex = aurora::gfx::new_static_texture_2d( m_warpTex.emplace(ETexelFormat::RGBA8PC, WARP_RAMP_RES + 1, WARP_RAMP_RES + 1, 1, "Warp Ramp");
WARP_RAMP_RES + 1, WARP_RAMP_RES + 1, 1, GX::TF_RGBA8,
{reinterpret_cast<const uint8_t*>(data.data()), (WARP_RAMP_RES + 1) * (WARP_RAMP_RES + 1) * 4}, "Warp Ramp");
} }
CSpaceWarpFilter::CSpaceWarpFilter() { CSpaceWarpFilter::CSpaceWarpFilter() {
// CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) { // CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
// GenerateWarpRampTex(ctx); // GenerateWarpRampTex(ctx);
// //
// struct Vert { // struct Vert {
// zeus::CVector2f m_pos; // zeus::CVector2f m_pos;
// zeus::CVector2f m_uv; // zeus::CVector2f m_uv;
// }; // };
// const std::array<Vert, 4> verts{{ // const std::array<Vert, 4> verts{{
// {{-1.f, -1.f}, {0.f, 0.f}}, // {{-1.f, -1.f}, {0.f, 0.f}},
// {{-1.f, 1.f}, {0.f, 1.f}}, // {{-1.f, 1.f}, {0.f, 1.f}},
// {{1.f, -1.f}, {1.f, 0.f}}, // {{1.f, -1.f}, {1.f, 0.f}},
// {{1.f, 1.f}, {1.f, 1.f}}, // {{1.f, 1.f}, {1.f, 1.f}},
// }}; // }};
// //
// m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(), 32, verts.size()); // m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(), 32, verts.size());
// m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1); // m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
// //
// const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()}; // const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
// constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex}; // constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
// const std::array<boo::ObjToken<boo::ITexture>, 2> texs{ // const std::array<boo::ObjToken<boo::ITexture>, 2> texs{
// CGraphics::g_SpareTexture.get(), // CGraphics::g_SpareTexture.get(),
// m_warpTex.get(), // m_warpTex.get(),
// }; // };
// m_dataBind = ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(), // m_dataBind = ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(),
// stages.data(), nullptr, nullptr, texs.size(), texs.data(), nullptr, nullptr); // stages.data(), nullptr, nullptr, texs.size(), texs.data(), nullptr,
// return true; // nullptr);
// } BooTrace); // return true;
// } BooTrace);
} }
void CSpaceWarpFilter::draw(const zeus::CVector3f& pt) { void CSpaceWarpFilter::draw(const zeus::CVector3f& pt) {
@ -132,15 +131,15 @@ void CSpaceWarpFilter::draw(const zeus::CVector3f& pt) {
m_uniform.m_matrix[1][1] = clipRect.x10_height / vp.y(); m_uniform.m_matrix[1][1] = clipRect.x10_height / vp.y();
m_uniform.m_matrix[3][0] = pt.x() + (1.f / vp.x()); m_uniform.m_matrix[3][0] = pt.x() + (1.f / vp.x());
m_uniform.m_matrix[3][1] = pt.y() + (1.f / vp.y()); m_uniform.m_matrix[3][1] = pt.y() + (1.f / vp.y());
// if (CGraphics::g_BooPlatform == boo::IGraphicsDataFactory::Platform::OpenGL) { // if (CGraphics::g_BooPlatform == boo::IGraphicsDataFactory::Platform::OpenGL) {
// m_uniform.m_matrix[3][2] = pt.z() * 2.f - 1.f; // m_uniform.m_matrix[3][2] = pt.z() * 2.f - 1.f;
// } else if (CGraphics::g_BooPlatform == boo::IGraphicsDataFactory::Platform::Vulkan) { // } else if (CGraphics::g_BooPlatform == boo::IGraphicsDataFactory::Platform::Vulkan) {
// m_uniform.m_matrix[1][1] *= -1.f; // m_uniform.m_matrix[1][1] *= -1.f;
// m_uniform.m_matrix[3][1] *= -1.f; // m_uniform.m_matrix[3][1] *= -1.f;
// m_uniform.m_matrix[3][2] = pt.z(); // m_uniform.m_matrix[3][2] = pt.z();
// } else { // } else {
// m_uniform.m_matrix[3][2] = pt.z(); // m_uniform.m_matrix[3][2] = pt.z();
// } // }
if (clipRect.x4_left) { if (clipRect.x4_left) {
clipRect.x4_left -= 1; clipRect.x4_left -= 1;
@ -158,15 +157,15 @@ void CSpaceWarpFilter::draw(const zeus::CVector3f& pt) {
clipRect.x4_left += CGraphics::g_CroppedViewport.x4_left; clipRect.x4_left += CGraphics::g_CroppedViewport.x4_left;
clipRect.x8_top += CGraphics::g_CroppedViewport.x8_top; clipRect.x8_top += CGraphics::g_CroppedViewport.x8_top;
clipRect.x8_top = CGraphics::GetViewportHeight() - clipRect.x10_height - clipRect.x8_top; clipRect.x8_top = CGraphics::GetViewportHeight() - clipRect.x10_height - clipRect.x8_top;
// CGraphics::ResolveSpareTexture(clipRect); // CGraphics::ResolveSpareTexture(clipRect);
m_uniform.m_strength.x() = m_uniform.m_strength.x() =
m_uniform.m_matrix[0][0] * m_strength * 0.5f * (clipRect.x10_height / float(clipRect.xc_width)); m_uniform.m_matrix[0][0] * m_strength * 0.5f * (clipRect.x10_height / float(clipRect.xc_width));
m_uniform.m_strength.y() = m_uniform.m_matrix[1][1] * m_strength * 0.5f; m_uniform.m_strength.y() = m_uniform.m_matrix[1][1] * m_strength * 0.5f;
// m_uniBuf->load(&m_uniform, sizeof(m_uniform)); // m_uniBuf->load(&m_uniform, sizeof(m_uniform));
// CGraphics::SetShaderDataBinding(m_dataBind); // CGraphics::SetShaderDataBinding(m_dataBind);
// CGraphics::DrawArray(0, 4); // CGraphics::DrawArray(0, 4);
} }
} // namespace metaforce } // namespace metaforce

View File

@ -4,6 +4,7 @@
#include "Runtime/GCNTypes.hpp" #include "Runtime/GCNTypes.hpp"
#include "Runtime/Graphics/CGraphics.hpp" #include "Runtime/Graphics/CGraphics.hpp"
#include "Runtime/Graphics/CTexture.hpp"
#include <zeus/CMatrix4f.hpp> #include <zeus/CMatrix4f.hpp>
#include <zeus/CVector3f.hpp> #include <zeus/CVector3f.hpp>
@ -17,7 +18,7 @@ class CSpaceWarpFilter {
zeus::CVector3f m_strength; zeus::CVector3f m_strength;
}; };
std::array<std::array<std::array<u8, 4>, 8>, 4> m_shiftTexture{}; std::array<std::array<std::array<u8, 4>, 8>, 4> m_shiftTexture{};
aurora::gfx::TextureHandle m_warpTex; std::optional<CTexture> m_warpTex;
// boo::ObjToken<boo::IGraphicsBufferS> m_vbo; // boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
// boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf; // boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
// boo::ObjToken<boo::IShaderDataBinding> m_dataBind; // boo::ObjToken<boo::IShaderDataBinding> m_dataBind;

View File

@ -15,7 +15,7 @@ class CXRayBlurFilter {
std::array<zeus::CMatrix4f, 8> m_uv; std::array<zeus::CMatrix4f, 8> m_uv;
}; };
TLockedToken<CTexture> m_paletteTex; TLockedToken<CTexture> m_paletteTex;
aurora::gfx::TextureHandle m_booTex; // aurora::gfx::TextureHandle m_booTex;
// boo::ObjToken<boo::IGraphicsBufferS> m_vbo; // boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
// boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf; // boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
// boo::ObjToken<boo::IShaderDataBinding> m_dataBind; // boo::ObjToken<boo::IShaderDataBinding> m_dataBind;

View File

@ -112,8 +112,8 @@ void CAuiEnergyBarT01::Draw(const CGuiWidgetDrawParms& drawParms) {
if (barOffT != barMaxT) { if (barOffT != barMaxT) {
CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::sTevPass805a5ebc); CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::sTevPass805a5ebc);
CGraphics::SetTevOp(ERglTevStage::Stage1, CTevCombiners::skPassThru); CGraphics::SetTevOp(ERglTevStage::Stage1, CTevCombiners::skPassThru);
xbc_tex->Load(GX::TEXMAP0, EClampMode::Repeat); xbc_tex->Load(GX_TEXMAP0, EClampMode::Repeat);
CGraphics::StreamBegin(GX::TRIANGLESTRIP); CGraphics::StreamBegin(GX_TRIANGLESTRIP);
CGraphics::StreamColor(useCol); CGraphics::StreamColor(useCol);
auto coords = xd8_coordFunc(barOffT); auto coords = xd8_coordFunc(barOffT);
while (barOffT < barMaxT) { while (barOffT < barMaxT) {

View File

@ -80,8 +80,8 @@ void CAuiImagePane::DoDrawImagePane(const zeus::CColor& color, CTexture& tex, in
if ((x14c_deResFactor == 0.f && alpha == 1.f) || tex.GetNumberOfMipMaps() == 1) { if ((x14c_deResFactor == 0.f && alpha == 1.f) || tex.GetNumberOfMipMaps() == 1) {
CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::sTevPass805a5ebc); CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::sTevPass805a5ebc);
CGraphics::SetTevOp(ERglTevStage::Stage1, CTevCombiners::skPassThru); CGraphics::SetTevOp(ERglTevStage::Stage1, CTevCombiners::skPassThru);
tex.LoadMipLevel(0.f, GX::TEXMAP0, EClampMode::Repeat); tex.LoadMipLevel(0.f, GX_TEXMAP0, EClampMode::Repeat);
CGraphics::StreamBegin(GX::TRIANGLESTRIP); CGraphics::StreamBegin(GX_TRIANGLESTRIP);
CGraphics::StreamColor(useColor); CGraphics::StreamColor(useColor);
for (u32 i = 0; i < useUVs->size(); ++i) { for (u32 i = 0; i < useUVs->size(); ++i) {
CGraphics::StreamTexcoord((*useUVs)[i] + xd0_uvBias0); CGraphics::StreamTexcoord((*useUVs)[i] + xd0_uvBias0);
@ -101,41 +101,41 @@ void CAuiImagePane::DoDrawImagePane(const zeus::CColor& color, CTexture& tex, in
float rgba1 = (fadeFactor - static_cast<float>(mip1)); float rgba1 = (fadeFactor - static_cast<float>(mip1));
float rgba2 = 1.f - rgba1; float rgba2 = 1.f - rgba1;
tex.LoadMipLevel(mip1, GX::TexMapID::TEXMAP0, EClampMode::Repeat); tex.LoadMipLevel(mip1, GX_TEXMAP0, EClampMode::Repeat);
tex.LoadMipLevel(mip2, GX::TexMapID::TEXMAP1, EClampMode::Repeat); tex.LoadMipLevel(mip2, GX_TEXMAP1, EClampMode::Repeat);
std::array<GX::VtxDescList, 3> list{{ std::array<GXVtxDescList, 3> list{{
{GX::VA_POS, GX::DIRECT}, {GX_VA_POS, GX_DIRECT},
{GX::VA_TEX0, GX::DIRECT}, {GX_VA_TEX0, GX_DIRECT},
GX::VtxDescList{}, {GX_VA_NULL, GX_NONE},
}}; }};
CGX::SetVtxDescv(list.data()); CGX::SetVtxDescv(list.data());
CGX::SetNumChans(0); CGX::SetNumChans(0);
CGX::SetNumTexGens(2); CGX::SetNumTexGens(2);
CGX::SetNumTevStages(2); CGX::SetNumTevStages(2);
GX::TevStageID stage = GX::TEVSTAGE0; GXTevStageID stage = GX_TEVSTAGE0;
while (stage < GX::TEVSTAGE2) { while (stage < GX_TEVSTAGE2) {
GX::TevColorArg colorD = stage == GX::TEVSTAGE0 ? GX::CC_ZERO : GX::CC_CPREV; GXTevColorArg colorD = stage == GX_TEVSTAGE0 ? GX_CC_ZERO : GX_CC_CPREV;
CGX::SetTevColorIn(stage, GX::CC_ZERO, GX::CC_TEXC, GX::CC_KONST, colorD); CGX::SetTevColorIn(stage, GX_CC_ZERO, GX_CC_TEXC, GX_CC_KONST, colorD);
GX::TevAlphaArg alphaD = stage == GX::TEVSTAGE0 ? GX::CA_ZERO : GX::CA_APREV; GXTevAlphaArg alphaD = stage == GX_TEVSTAGE0 ? GX_CA_ZERO : GX_CA_APREV;
CGX::SetTevAlphaIn(stage, GX::CA_ZERO, GX::CA_TEXA, GX::CA_KONST, alphaD); CGX::SetTevAlphaIn(stage, GX_CA_ZERO, GX_CA_TEXA, GX_CA_KONST, alphaD);
CGX::SetTevColorOp(stage, GX::TEV_ADD, GX::TB_ZERO, GX::CS_SCALE_1, true, GX::TEVPREV); CGX::SetTevColorOp(stage, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV);
CGX::SetTevAlphaOp(stage, GX::TEV_ADD, GX::TB_ZERO, GX::CS_SCALE_1, true, GX::TEVPREV); CGX::SetTevAlphaOp(stage, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV);
stage = static_cast<GX::TevStageID>(stage + GX::TEVSTAGE1); stage = static_cast<GXTevStageID>(stage + GX_TEVSTAGE1);
} }
CGX::SetTevKAlphaSel(GX::TEVSTAGE0, GX::TEV_KASEL_K0_A); CGX::SetTevKAlphaSel(GX_TEVSTAGE0, GX_TEV_KASEL_K0_A);
CGX::SetTevKColorSel(GX::TEVSTAGE0, GX::TEV_KCSEL_K0); CGX::SetTevKColorSel(GX_TEVSTAGE0, GX_TEV_KCSEL_K0);
CGX::SetTevKAlphaSel(GX::TEVSTAGE1, GX::TEV_KASEL_K1_A); CGX::SetTevKAlphaSel(GX_TEVSTAGE1, GX_TEV_KASEL_K1_A);
CGX::SetTevKColorSel(GX::TEVSTAGE1, GX::TEV_KCSEL_K1); CGX::SetTevKColorSel(GX_TEVSTAGE1, GX_TEV_KCSEL_K1);
zeus::CColor col1 = useColor * zeus::CColor(rgba2, rgba2, rgba2, rgba2); zeus::CColor col1 = useColor * zeus::CColor(rgba2, rgba2, rgba2, rgba2);
zeus::CColor col2 = useColor * zeus::CColor(rgba1, rgba1, rgba1, rgba1); zeus::CColor col2 = useColor * zeus::CColor(rgba1, rgba1, rgba1, rgba1);
CGX::SetTevKColor(GX::KCOLOR0, col1); CGX::SetTevKColor(GX_KCOLOR0, col1);
CGX::SetTevKColor(GX::KCOLOR1, col2); CGX::SetTevKColor(GX_KCOLOR1, col2);
CGX::SetTevOrder(GX::TEVSTAGE0, GX::TEXCOORD0, GX::TEXMAP0, GX::COLOR_NULL); CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL);
CGX::SetTevOrder(GX::TEVSTAGE1, GX::TEXCOORD1, GX::TEXMAP1, GX::COLOR_NULL); CGX::SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD1, GX_TEXMAP1, GX_COLOR_NULL);
CGX::SetTexCoordGen(GX::TEXCOORD0, GX::TG_MTX2x4, GX::TG_TEX0, GX::IDENTITY, false, GX::PTIDENTITY); CGX::SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY, false, GX_PTIDENTITY);
CGX::SetTexCoordGen(GX::TEXCOORD1, GX::TG_MTX2x4, GX::TG_TEX0, GX::IDENTITY, false, GX::PTIDENTITY); CGX::SetTexCoordGen(GX_TEXCOORD1, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY, false, GX_PTIDENTITY);
CGX::Begin(GX::Primitive::TRIANGLESTRIP, GX::VTXFMT0, 4); CGX::Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 4);
for (u32 idx = 0; const auto& coord : xe0_coords) { for (u32 idx = 0; const auto& coord : xe0_coords) {
GXPosition3f32(coord); GXPosition3f32(coord);
GXTexCoord2f32((*useUVs)[idx] + xd0_uvBias0); GXTexCoord2f32((*useUVs)[idx] + xd0_uvBias0);
@ -146,8 +146,8 @@ void CAuiImagePane::DoDrawImagePane(const zeus::CColor& color, CTexture& tex, in
} else { } else {
CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::sTevPass805a5fec); CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::sTevPass805a5fec);
CGraphics::SetTevOp(ERglTevStage::Stage1, CTevCombiners::skPassThru); CGraphics::SetTevOp(ERglTevStage::Stage1, CTevCombiners::skPassThru);
tex.Load(GX::TEXMAP0, EClampMode::Repeat); tex.Load(GX_TEXMAP0, EClampMode::Repeat);
CGraphics::StreamBegin(GX::TRIANGLESTRIP); CGraphics::StreamBegin(GX_TRIANGLESTRIP);
CGraphics::StreamColor(useColor); CGraphics::StreamColor(useColor);
for (u32 i = 0; i < useUVs->size(); ++i) { for (u32 i = 0; i < useUVs->size(); ++i) {
CGraphics::StreamTexcoord((*useUVs)[i]); CGraphics::StreamTexcoord((*useUVs)[i]);

View File

@ -71,12 +71,12 @@ CCompoundTargetReticle::CCompoundTargetReticle(const CStateManager& mgr)
CCompoundTargetReticle::SScanReticuleRenderer::SScanReticuleRenderer() { CCompoundTargetReticle::SScanReticuleRenderer::SScanReticuleRenderer() {
// CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx) { // CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx) {
for (size_t i = 0; i < m_lineRenderers.size(); ++i) { // for (size_t i = 0; i < m_lineRenderers.size(); ++i) {
m_lineRenderers[i].emplace(CLineRenderer::EPrimitiveMode::Lines, 8, aurora::gfx::TextureHandle{}, true, true); // m_lineRenderers[i].emplace(CLineRenderer::EPrimitiveMode::Lines, 8, {}, true, true);
for (auto& stripRenderer : m_stripRenderers[i]) { // for (auto& stripRenderer : m_stripRenderers[i]) {
stripRenderer.emplace(CLineRenderer::EPrimitiveMode::LineStrip, 4, aurora::gfx::TextureHandle{}, true, true); // stripRenderer.emplace(CLineRenderer::EPrimitiveMode::LineStrip, 4, {}, true, true);
} // }
} // }
// return true; // return true;
// } BooTrace); // } BooTrace);
} }

View File

@ -17,7 +17,7 @@ void CGuiPane::Draw(const CGuiWidgetDrawParms& parms) {
col.a() = parms.x0_alphaMod * xa8_color2.a(); col.a() = parms.x0_alphaMod * xa8_color2.a();
CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::skPassThru); CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::skPassThru);
CGraphics::DrawPrimitive(GX::Primitive::TRIANGLESTRIP, xc0_verts.data(), skDefaultNormal, col, xc0_verts.size()); CGraphics::DrawPrimitive(GX_TRIANGLESTRIP, xc0_verts.data(), skDefaultNormal, col, xc0_verts.size());
} }
CGuiWidget::Draw(parms); CGuiWidget::Draw(parms);
} }

View File

@ -32,9 +32,9 @@ CGuiTableGroup::CGuiTableGroup(const CGuiWidgetParms& parms, int elementCount, i
, xd0_selectWraparound(selectWraparound) {} , xd0_selectWraparound(selectWraparound) {}
void CGuiTableGroup::ProcessUserInput(const CFinalInput& input) { void CGuiTableGroup::ProcessUserInput(const CFinalInput& input) {
if (input.PA() || input.PSpecialKey(aurora::SpecialKey::Enter)) { if (input.PA() || input.PSpecialKey(ESpecialKey::Enter)) {
DoAdvance(); DoAdvance();
} else if (input.PB() || input.PSpecialKey(aurora::SpecialKey::Esc)) { } else if (input.PB() || input.PSpecialKey(ESpecialKey::Esc)) {
DoCancel(); DoCancel();
} else { } else {
bool decrement; bool decrement;

View File

@ -29,7 +29,7 @@ CHudRadarInterface::CHudRadarInterface(CGuiFrame& baseHud, CStateManager& stateM
void CHudRadarInterface::DoDrawRadarPaint(float radius) { void CHudRadarInterface::DoDrawRadarPaint(float radius) {
radius *= 4.f; radius *= 4.f;
CGraphics::StreamBegin(GX::TRIANGLESTRIP); CGraphics::StreamBegin(GX_TRIANGLESTRIP);
CGraphics::StreamTexcoord(0.f, 1.f); CGraphics::StreamTexcoord(0.f, 1.f);
CGraphics::StreamVertex(-radius, 0.f, radius); CGraphics::StreamVertex(-radius, 0.f, radius);
CGraphics::StreamTexcoord(0.f, 0.f); CGraphics::StreamTexcoord(0.f, 0.f);
@ -124,7 +124,7 @@ void CHudRadarInterface::Draw(const CStateManager& mgr, float alpha) {
g_Renderer->SetModelMatrix(drawParms.x3c_postTranslate); g_Renderer->SetModelMatrix(drawParms.x3c_postTranslate);
g_Renderer->SetBlendMode_AdditiveAlpha(); g_Renderer->SetBlendMode_AdditiveAlpha();
x0_txtrRadarPaint->Load(GX::TEXMAP0, EClampMode::Repeat); x0_txtrRadarPaint->Load(GX_TEXMAP0, EClampMode::Repeat);
CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::sTevPass805a5ebc); CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::sTevPass805a5ebc);
g_Renderer->SetDepthReadWrite(false, false); g_Renderer->SetDepthReadWrite(false, false);
zeus::CColor playerColor = g_tweakGuiColors->GetRadarPlayerPaintColor(); zeus::CColor playerColor = g_tweakGuiColors->GetRadarPlayerPaintColor();

View File

@ -210,26 +210,26 @@ bool CRasterFont::IsFinishedLoading() const {
} }
void CRasterFont::SetupRenderState() { void CRasterFont::SetupRenderState() {
static const GX::VtxDescList skDescList[3] = { constexpr std::array skDescList = {
{GX::VA_POS, GX::DIRECT}, GXVtxDescList{GX_VA_POS, GX_DIRECT},
{GX::VA_TEX0, GX::DIRECT}, GXVtxDescList{GX_VA_TEX0, GX_DIRECT},
{GX::VA_NULL, GX::NONE} GXVtxDescList{GX_VA_NULL, GX_NONE},
}; };
x80_texture->Load(GX::TEXMAP0, EClampMode::Clamp); x80_texture->Load(GX_TEXMAP0, EClampMode::Clamp);
CGX::SetTevKAlphaSel(GX::TEVSTAGE0, GX::TEV_KASEL_K0_A); CGX::SetTevKAlphaSel(GX_TEVSTAGE0, GX_TEV_KASEL_K0_A);
CGX::SetTevKColorSel(GX::TEVSTAGE0, GX::TEV_KCSEL_K0); CGX::SetTevKColorSel(GX_TEVSTAGE0, GX_TEV_KCSEL_K0);
CGX::SetTevColorIn(GX::TEVSTAGE0, GX::CC_ZERO, GX::CC_TEXC, GX::CC_KONST, GX::CC_ZERO); CGX::SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_TEXC, GX_CC_KONST, GX_CC_ZERO);
CGX::SetTevAlphaIn(GX::TEVSTAGE0, GX::CA_ZERO, GX::CA_TEXA, GX::CA_KONST, GX::CA_ZERO); CGX::SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_TEXA, GX_CA_KONST, GX_CA_ZERO);
CGX::SetStandardTevColorAlphaOp(GX::TEVSTAGE0); CGX::SetStandardTevColorAlphaOp(GX_TEVSTAGE0);
CGX::SetTevDirect(GX::TEVSTAGE0); CGX::SetTevDirect(GX_TEVSTAGE0);
CGX::SetVtxDescv(skDescList); CGX::SetVtxDescv(skDescList.data());
CGX::SetNumChans(0); CGX::SetNumChans(0);
CGX::SetNumTexGens(1); CGX::SetNumTexGens(1);
CGX::SetNumTevStages(1); CGX::SetNumTevStages(1);
CGX::SetNumIndStages(0); CGX::SetNumIndStages(0);
CGX::SetTevOrder(GX::TEVSTAGE0, GX::TEXCOORD0, GX::TEXMAP0, GX::COLOR_NULL); CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL);
CGX::SetTexCoordGen(GX::TEXCOORD0, GX::TG_MTX2x4, GX::TG_TEX0, GX::IDENTITY, false, GX::PTIDENTITY); CGX::SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY, false, GX_PTIDENTITY);
} }
std::unique_ptr<IObj> FRasterFontFactory([[maybe_unused]] const SObjectTag& tag, CInputStream& in, std::unique_ptr<IObj> FRasterFontFactory([[maybe_unused]] const SObjectTag& tag, CInputStream& in,
const CVParamTransfer& vparms, [[maybe_unused]] CObjectReference* selfRef) { const CVParamTransfer& vparms, [[maybe_unused]] CObjectReference* selfRef) {

View File

@ -42,7 +42,7 @@ void CScanDisplay::CDataDot::Draw(const zeus::CColor& col, float radius) {
const zeus::CTransform xf = zeus::CTransform::Translate(xc_curPos.x(), 0.f, xc_curPos.y()); const zeus::CTransform xf = zeus::CTransform::Translate(xc_curPos.x(), 0.f, xc_curPos.y());
g_Renderer->SetModelMatrix(xf); g_Renderer->SetModelMatrix(xf);
CGraphics::StreamBegin(GX::TRIANGLESTRIP); CGraphics::StreamBegin(GX_TRIANGLESTRIP);
zeus::CColor useColor = col; zeus::CColor useColor = col;
useColor.a() *= x24_alpha; useColor.a() *= x24_alpha;
CGraphics::StreamColor(useColor); CGraphics::StreamColor(useColor);
@ -84,7 +84,7 @@ void CScanDisplay::ProcessInput(const CFinalInput& input) {
return; return;
if (xc_state == EScanState::DownloadComplete && x1a4_xAlpha == 0.f) { if (xc_state == EScanState::DownloadComplete && x1a4_xAlpha == 0.f) {
if (input.PA() || input.PSpecialKey(aurora::SpecialKey::Enter) || input.PMouseButton(EMouseButton::Primary)) { if (input.PA() || input.PSpecialKey(ESpecialKey::Enter) || input.PMouseButton(EMouseButton::Primary)) {
if (xa8_message->TextSupport().GetCurTime() < xa8_message->TextSupport().GetTotalAnimationTime()) { if (xa8_message->TextSupport().GetCurTime() < xa8_message->TextSupport().GetTotalAnimationTime()) {
xa8_message->TextSupport().SetCurTime(xa8_message->TextSupport().GetTotalAnimationTime()); xa8_message->TextSupport().SetCurTime(xa8_message->TextSupport().GetTotalAnimationTime());
} else { } else {
@ -96,7 +96,7 @@ void CScanDisplay::ProcessInput(const CFinalInput& input) {
} else if (xc_state == EScanState::ViewingScan) { } else if (xc_state == EScanState::ViewingScan) {
int oldCounter = x1ac_pageCounter; int oldCounter = x1ac_pageCounter;
int totalPages = xac_scrollMessage->TextSupport().GetTotalPageCount(); int totalPages = xac_scrollMessage->TextSupport().GetTotalPageCount();
if ((input.PA() || input.PSpecialKey(aurora::SpecialKey::Enter) || input.PMouseButton(EMouseButton::Primary)) && if ((input.PA() || input.PSpecialKey(ESpecialKey::Enter) || input.PMouseButton(EMouseButton::Primary)) &&
totalPages != -1) { totalPages != -1) {
CGuiTextSupport& supp = !x1ac_pageCounter ? xa8_message->TextSupport() : xac_scrollMessage->TextSupport(); CGuiTextSupport& supp = !x1ac_pageCounter ? xa8_message->TextSupport() : xac_scrollMessage->TextSupport();
if (supp.GetCurTime() < supp.GetTotalAnimationTime()) if (supp.GetCurTime() < supp.GetTotalAnimationTime())
@ -452,7 +452,7 @@ void CScanDisplay::Draw() {
g_Renderer->SetViewportOrtho(true, -4096.f, 4096.f); g_Renderer->SetViewportOrtho(true, -4096.f, 4096.f);
g_Renderer->SetBlendMode_AdditiveAlpha(); g_Renderer->SetBlendMode_AdditiveAlpha();
CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::sTevPass805a5ebc); CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::sTevPass805a5ebc);
x0_dataDot->Load(GX::TEXMAP0, EClampMode::Repeat); x0_dataDot->Load(GX_TEXMAP0, EClampMode::Repeat);
const float vpRatio = CGraphics::GetViewportHeight() / 480.f; const float vpRatio = CGraphics::GetViewportHeight() / 480.f;
for (CDataDot& dot : xbc_dataDots) { for (CDataDot& dot : xbc_dataDots) {

View File

@ -72,13 +72,13 @@ void CSplashScreen::Draw() {
auto& tex = *x28_texture.GetObj(); auto& tex = *x28_texture.GetObj();
const auto width = tex.GetWidth(); const auto width = tex.GetWidth();
const auto height = tex.GetHeight(); const auto height = tex.GetHeight();
tex.Load(GX::TEXMAP0, EClampMode::Clamp); tex.Load(GX_TEXMAP0, EClampMode::Clamp);
if (x14_which == ESplashScreen::Nintendo || x14_which == ESplashScreen::Retro) { if (x14_which == ESplashScreen::Nintendo || x14_which == ESplashScreen::Retro) {
const auto x = static_cast<float>(133 - (width - 376) / 2); const auto x = static_cast<float>(133 - (width - 376) / 2);
const auto y = static_cast<float>(170 - (height - 104) / 2); const auto y = static_cast<float>(170 - (height - 104) / 2);
CGraphics::SetOrtho(-10.f, 650.f, -5.5f, 484.5f, -1.f, 1.f); CGraphics::SetOrtho(-10.f, 650.f, -5.5f, 484.5f, -1.f, 1.f);
CGraphics::SetCullMode(ERglCullMode::None); CGraphics::SetCullMode(ERglCullMode::None);
CGraphics::StreamBegin(GX::TRIANGLESTRIP); CGraphics::StreamBegin(GX_TRIANGLESTRIP);
CGraphics::StreamColor(color); CGraphics::StreamColor(color);
CGraphics::StreamTexcoord(0.f, 0.f); CGraphics::StreamTexcoord(0.f, 0.f);
CGraphics::StreamVertex({x, 0.f, y + static_cast<float>(height)}); CGraphics::StreamVertex({x, 0.f, y + static_cast<float>(height)});

View File

@ -130,8 +130,8 @@ void CTextRenderBuffer::Render(const zeus::CColor& color, float time) {
auto font = x4_fonts[x4c_activeFont]; auto font = x4_fonts[x4c_activeFont];
if (font && font->GetGlyph(chr) != nullptr) { if (font && font->GetGlyph(chr) != nullptr) {
const auto* glyph = font->GetGlyph(chr); const auto* glyph = font->GetGlyph(chr);
CGX::SetTevKColor(GX::KCOLOR0, chrColor * color); CGX::SetTevKColor(GX_KCOLOR0, chrColor * color);
CGX::Begin(GX::TRIANGLESTRIP, GX::VTXFMT0, 4); CGX::Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 4);
{ {
GXPosition3f32(offX, 0.f, offY); GXPosition3f32(offX, 0.f, offY);
GXTexCoord2f32(glyph->GetStartU(), glyph->GetStartV()); GXTexCoord2f32(glyph->GetStartU(), glyph->GetStartV());
@ -153,30 +153,30 @@ void CTextRenderBuffer::Render(const zeus::CColor& color, float time) {
auto imageDef = x14_images[imageIdx]; auto imageDef = x14_images[imageIdx];
auto tex = imageDef.x4_texs[static_cast<u32>(time * imageDef.x0_fps) % imageDef.x4_texs.size()]; auto tex = imageDef.x4_texs[static_cast<u32>(time * imageDef.x0_fps) % imageDef.x4_texs.size()];
if (tex) { if (tex) {
tex->Load(GX::TEXMAP0, EClampMode::Clamp); tex->Load(GX_TEXMAP0, EClampMode::Clamp);
float width = imageDef.x4_texs.front()->GetWidth() * imageDef.x14_cropFactor.x(); float width = imageDef.x4_texs.front()->GetWidth() * imageDef.x14_cropFactor.x();
float height = imageDef.x4_texs.front()->GetHeight() * imageDef.x14_cropFactor.y(); float height = imageDef.x4_texs.front()->GetHeight() * imageDef.x14_cropFactor.y();
float cropXHalf = imageDef.x14_cropFactor.x() * 0.5f; float cropXHalf = imageDef.x14_cropFactor.x() * 0.5f;
float cropYHalf = imageDef.x14_cropFactor.y() * 0.5f; float cropYHalf = imageDef.x14_cropFactor.y() * 0.5f;
CGX::SetTevKAlphaSel(GX::TEVSTAGE0, GX::TEV_KASEL_K0_A); CGX::SetTevKAlphaSel(GX_TEVSTAGE0, GX_TEV_KASEL_K0_A);
CGX::SetTevKColorSel(GX::TEVSTAGE0, GX::TEV_KCSEL_K0); CGX::SetTevKColorSel(GX_TEVSTAGE0, GX_TEV_KCSEL_K0);
CGX::SetTevColorIn(GX::TEVSTAGE0, GX::CC_ZERO, GX::CC_TEXC, GX::CC_KONST, GX::CC_ZERO); CGX::SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_TEXC, GX_CC_KONST, GX_CC_ZERO);
CGX::SetTevAlphaIn(GX::TEVSTAGE0, GX::CA_ZERO, GX::CA_TEXA, GX::CA_KONST, GX::CA_ZERO); CGX::SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_TEXA, GX_CA_KONST, GX_CA_ZERO);
CGX::SetStandardTevColorAlphaOp(GX::TEVSTAGE0); CGX::SetStandardTevColorAlphaOp(GX_TEVSTAGE0);
constexpr std::array skVtxDesc{ constexpr std::array skVtxDesc{
GX::VtxDescList{GX::VA_POS, GX::DIRECT}, GXVtxDescList{GX_VA_POS, GX_DIRECT},
GX::VtxDescList{GX::VA_TEX0, GX::DIRECT}, GXVtxDescList{GX_VA_TEX0, GX_DIRECT},
GX::VtxDescList{}, GXVtxDescList{GX_VA_NULL, GX_NONE},
}; };
CGX::SetVtxDescv(skVtxDesc.data()); CGX::SetVtxDescv(skVtxDesc.data());
CGX::SetNumChans(0); CGX::SetNumChans(0);
CGX::SetNumTexGens(1); CGX::SetNumTexGens(1);
CGX::SetNumTevStages(1); CGX::SetNumTevStages(1);
CGX::SetTevOrder(GX::TEVSTAGE0, GX::TEXCOORD0, GX::TEXMAP0, GX::COLOR_NULL); CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL);
CGX::SetTexCoordGen(GX::TEXCOORD0, GX::TG_MTX2x4, GX::TG_TEX0, GX::IDENTITY, false, GX::PTIDENTITY); CGX::SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY, false, GX_PTIDENTITY);
CGX::SetTevKColor(GX::KCOLOR0, imageColor * color); CGX::SetTevKColor(GX_KCOLOR0, imageColor * color);
CGX::Begin(GX::TRIANGLESTRIP, GX::VTXFMT0, 4); CGX::Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 4);
{ {
GXPosition3f32(offX, 0.f, offY); GXPosition3f32(offX, 0.f, offY);
GXTexCoord2f32(0.5f - cropXHalf, 0.5f + cropYHalf); GXTexCoord2f32(0.5f - cropXHalf, 0.5f + cropYHalf);

View File

@ -37,8 +37,8 @@ enum class EGameplayResult { None, Win, Lose, Playing };
class IMain { class IMain {
public: public:
virtual ~IMain() = default; virtual ~IMain() = default;
virtual std::string Init(const FileStoreManager& storeMgr, CVarManager* cvarMgr, boo::IAudioVoiceEngine* voiceEngine, virtual std::string Init(int argc, char** argv, const FileStoreManager& storeMgr, CVarManager* cvarMgr,
amuse::IBackendVoiceAllocator& backend) = 0; boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend) = 0;
virtual void Draw() = 0; virtual void Draw() = 0;
virtual bool Proc(float dt) = 0; virtual bool Proc(float dt) = 0;
virtual void Shutdown() = 0; virtual void Shutdown() = 0;

View File

@ -1,3 +1,10 @@
#include <zeus/CVector2f.hpp>
#define IM_VEC2_CLASS_EXTRA \
ImVec2(const zeus::CVector2f& v) { \
x = v.x(); \
y = v.y(); \
} \
operator zeus::CVector2f() const { return zeus::CVector2f{x, y}; }
#include "ImGuiConsole.hpp" #include "ImGuiConsole.hpp"
#include "../version.h" #include "../version.h"
@ -26,6 +33,8 @@ namespace aurora::gfx {
extern std::atomic_uint32_t queuedPipelines; extern std::atomic_uint32_t queuedPipelines;
extern std::atomic_uint32_t createdPipelines; extern std::atomic_uint32_t createdPipelines;
extern size_t g_drawCallCount;
extern size_t g_mergedDrawCallCount;
extern size_t g_lastVertSize; extern size_t g_lastVertSize;
extern size_t g_lastUniformSize; extern size_t g_lastUniformSize;
extern size_t g_lastIndexSize; extern size_t g_lastIndexSize;
@ -139,6 +148,8 @@ static void Warp(const CAssetId worldId, TAreaId aId) {
} }
} }
static inline float GetScale() { return ImGui::GetIO().DisplayFramebufferScale.x; }
void ImGuiConsole::ShowMenuGame() { void ImGuiConsole::ShowMenuGame() {
if (g_Main != nullptr) { if (g_Main != nullptr) {
m_paused = g_Main->IsPaused(); m_paused = g_Main->IsPaused();
@ -273,7 +284,7 @@ static void RenderEntityColumns(const ImGuiEntityEntry& entry) {
} }
void ImGuiConsole::ShowInspectWindow(bool* isOpen) { void ImGuiConsole::ShowInspectWindow(bool* isOpen) {
float initialWindowSize = 400.f * aurora::get_window_size().scale; float initialWindowSize = 400.f * GetScale();
ImGui::SetNextWindowSize(ImVec2{initialWindowSize, initialWindowSize * 1.5f}, ImGuiCond_FirstUseEver); ImGui::SetNextWindowSize(ImVec2{initialWindowSize, initialWindowSize * 1.5f}, ImGuiCond_FirstUseEver);
if (ImGui::Begin("Inspect", isOpen)) { if (ImGui::Begin("Inspect", isOpen)) {
@ -393,7 +404,7 @@ bool ImGuiConsole::ShowEntityInfoWindow(TUniqueId uid) {
void ImGuiConsole::ShowConsoleVariablesWindow() { void ImGuiConsole::ShowConsoleVariablesWindow() {
// For some reason the window shows up tiny without this // For some reason the window shows up tiny without this
float initialWindowSize = 350.f * aurora::get_window_size().scale; float initialWindowSize = 350.f * GetScale();
ImGui::SetNextWindowSize(ImVec2{initialWindowSize, initialWindowSize}, ImGuiCond_FirstUseEver); ImGui::SetNextWindowSize(ImVec2{initialWindowSize, initialWindowSize}, ImGuiCond_FirstUseEver);
if (ImGui::Begin("Console Variables", &m_showConsoleVariablesWindow)) { if (ImGui::Begin("Console Variables", &m_showConsoleVariablesWindow)) {
if (ImGui::Button("Clear")) { if (ImGui::Button("Clear")) {
@ -663,7 +674,7 @@ void ImGuiConsole::ShowAboutWindow(bool preLaunch) {
open = &m_showAboutWindow; open = &m_showAboutWindow;
} }
if (ImGui::Begin("About", open, flags)) { if (ImGui::Begin("About", open, flags)) {
float iconSize = 128.f * aurora::get_window_size().scale; float iconSize = 128.f * GetScale();
ImGui::SameLine(ImGui::GetWindowSize().x / 2 - iconSize + (iconSize / 2)); ImGui::SameLine(ImGui::GetWindowSize().x / 2 - iconSize + (iconSize / 2));
ImGui::Image(ImGuiEngine::metaforceIcon, ImVec2{iconSize, iconSize}); ImGui::Image(ImGuiEngine::metaforceIcon, ImVec2{iconSize, iconSize});
ImGui::PushFont(ImGuiEngine::fontLarge); ImGui::PushFont(ImGuiEngine::fontLarge);
@ -794,7 +805,7 @@ static std::string BytesToString(size_t bytes) {
void ImGuiConsole::ShowDebugOverlay() { void ImGuiConsole::ShowDebugOverlay() {
if (!m_frameCounter && !m_frameRate && !m_inGameTime && !m_roomTimer && !m_playerInfo && !m_areaInfo && if (!m_frameCounter && !m_frameRate && !m_inGameTime && !m_roomTimer && !m_playerInfo && !m_areaInfo &&
!m_worldInfo && !m_randomStats && !m_resourceStats && !m_pipelineInfo) { !m_worldInfo && !m_randomStats && !m_resourceStats && !m_pipelineInfo && !m_drawCallInfo && !m_bufferInfo) {
return; return;
} }
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
@ -957,17 +968,33 @@ void ImGuiConsole::ShowDebugOverlay() {
} }
hasPrevious = true; hasPrevious = true;
ImGuiStringViewText(fmt::format(FMT_STRING("Queued pipelines: {}\n"), aurora::gfx::queuedPipelines)); ImGuiStringViewText(fmt::format(FMT_STRING("Queued pipelines: {}\n"), aurora::gfx::queuedPipelines));
ImGuiStringViewText(fmt::format(FMT_STRING("Done pipelines: {}\n"), aurora::gfx::createdPipelines)); ImGuiStringViewText(fmt::format(FMT_STRING("Done pipelines: {}\n"), aurora::gfx::createdPipelines));
}
if (m_drawCallInfo && m_developer) {
if (hasPrevious) {
ImGui::Separator();
}
hasPrevious = true;
ImGuiStringViewText(fmt::format(FMT_STRING("Draw call count: {}\n"), aurora::gfx::g_drawCallCount));
ImGuiStringViewText(fmt::format(FMT_STRING("Merged draw calls: {}\n"), aurora::gfx::g_mergedDrawCallCount));
}
if (m_bufferInfo && m_developer) {
if (hasPrevious) {
ImGui::Separator();
}
hasPrevious = true;
ImGuiStringViewText( ImGuiStringViewText(
fmt::format(FMT_STRING("Vertex size: {}\n"), BytesToString(aurora::gfx::g_lastVertSize))); fmt::format(FMT_STRING("Vertex size: {}\n"), BytesToString(aurora::gfx::g_lastVertSize)));
ImGuiStringViewText( ImGuiStringViewText(
fmt::format(FMT_STRING("Uniform size: {}\n"), BytesToString(aurora::gfx::g_lastUniformSize))); fmt::format(FMT_STRING("Uniform size: {}\n"), BytesToString(aurora::gfx::g_lastUniformSize)));
ImGuiStringViewText( ImGuiStringViewText(
fmt::format(FMT_STRING("Index size: {}\n"), BytesToString(aurora::gfx::g_lastIndexSize))); fmt::format(FMT_STRING("Index size: {}\n"), BytesToString(aurora::gfx::g_lastIndexSize)));
ImGuiStringViewText( ImGuiStringViewText(
fmt::format(FMT_STRING("Storage size: {}\n"), BytesToString(aurora::gfx::g_lastStorageSize))); fmt::format(FMT_STRING("Storage size: {}\n"), BytesToString(aurora::gfx::g_lastStorageSize)));
ImGuiStringViewText(fmt::format(FMT_STRING("Total: {}\n"), ImGuiStringViewText(fmt::format(FMT_STRING("Total: {}\n"),
BytesToString(aurora::gfx::g_lastVertSize + aurora::gfx::g_lastUniformSize + BytesToString(aurora::gfx::g_lastVertSize + aurora::gfx::g_lastUniformSize +
aurora::gfx::g_lastIndexSize + aurora::gfx::g_lastStorageSize))); aurora::gfx::g_lastIndexSize + aurora::gfx::g_lastStorageSize)));
} }
@ -993,10 +1020,13 @@ void ImGuiConsole::ShowInputViewer() {
return; return;
} }
u32 thisWhich = aurora::get_which_controller_for_player(input.ControllerIdx()); u32 thisWhich = input.ControllerIdx();
if (m_whichController != thisWhich) { if (m_whichController != thisWhich) {
m_controllerName = static_cast<std::string>(aurora::get_controller_name(thisWhich)); const char* name = PADGetName(thisWhich);
m_whichController = thisWhich; if (name != nullptr) {
m_controllerName = name;
m_whichController = thisWhich;
}
} }
// Code -stolen- borrowed from Practice Mod // Code -stolen- borrowed from Practice Mod
@ -1009,7 +1039,7 @@ void ImGuiConsole::ShowInputViewer() {
} }
ImGui::SetNextWindowBgAlpha(0.65f); ImGui::SetNextWindowBgAlpha(0.65f);
if (ImGui::Begin("Input Overlay", nullptr, windowFlags)) { if (ImGui::Begin("Input Overlay", nullptr, windowFlags)) {
float scale = aurora::get_window_size().scale; float scale = GetScale();
if (!m_controllerName.empty()) { if (!m_controllerName.empty()) {
TextCenter(m_controllerName); TextCenter(m_controllerName);
ImGui::Separator(); ImGui::Separator();
@ -1614,7 +1644,7 @@ void ImGuiConsole::ShowItemsWindow() {
void ImGuiConsole::ShowLayersWindow() { void ImGuiConsole::ShowLayersWindow() {
// For some reason the window shows up tiny without this // For some reason the window shows up tiny without this
float initialWindowSize = 350.f * aurora::get_window_size().scale; float initialWindowSize = 350.f * GetScale();
ImGui::SetNextWindowSize(ImVec2{initialWindowSize, initialWindowSize}, ImGuiCond_FirstUseEver); ImGui::SetNextWindowSize(ImVec2{initialWindowSize, initialWindowSize}, ImGuiCond_FirstUseEver);
if (ImGui::Begin("Layers", &m_showLayersWindow)) { if (ImGui::Begin("Layers", &m_showLayersWindow)) {
@ -1856,26 +1886,28 @@ void ImGuiConsole::ShowPreLaunchSettingsWindow() {
if (ImGui::Begin("Settings", &m_showPreLaunchSettingsWindow, ImGuiWindowFlags_AlwaysAutoResize)) { if (ImGui::Begin("Settings", &m_showPreLaunchSettingsWindow, ImGuiWindowFlags_AlwaysAutoResize)) {
if (ImGui::BeginTabBar("Settings")) { if (ImGui::BeginTabBar("Settings")) {
if (ImGui::BeginTabItem("Graphics")) { if (ImGui::BeginTabItem("Graphics")) {
static auto AvailableBackends = aurora::get_available_backends(); // TODO
ImGuiStringViewText(fmt::format(FMT_STRING("Current backend: {}"), aurora::get_backend_string())); // static auto AvailableBackends = aurora::get_available_backends();
auto desiredBackend = static_cast<int>(aurora::Backend::Invalid); // ImGuiStringViewText(fmt::format(FMT_STRING("Current backend: {}"), aurora::get_backend_string()));
if (auto* cvar = m_cvarMgr.findCVar("graphicsApi")) { // auto desiredBackend = static_cast<int>(aurora::Backend::Invalid);
bool valid = false; // if (auto* cvar = m_cvarMgr.findCVar("graphicsApi")) {
const auto name = cvar->toLiteral(&valid); // bool valid = false;
if (valid) { // const auto name = cvar->toLiteral(&valid);
desiredBackend = static_cast<int>(aurora::backend_from_string(name)); // if (valid) {
} // desiredBackend = static_cast<int>(aurora::backend_from_string(name));
} // }
bool modified = false; // }
modified = ImGui::RadioButton("Auto", &desiredBackend, static_cast<int>(aurora::Backend::Invalid)); // bool modified = false;
for (const auto& item : AvailableBackends) { // modified = ImGui::RadioButton("Auto", &desiredBackend, static_cast<int>(aurora::Backend::Invalid));
modified = ImGui::RadioButton(magic_enum::enum_name(item).data(), &desiredBackend, static_cast<int>(item)) || // for (const auto& item : AvailableBackends) {
modified; // modified = ImGui::RadioButton(magic_enum::enum_name(item).data(), &desiredBackend,
} // static_cast<int>(item)) ||
if (modified) { // modified;
m_cvarCommons.m_graphicsApi->fromLiteral( // }
aurora::backend_to_string(static_cast<aurora::Backend>(desiredBackend))); // if (modified) {
} // m_cvarCommons.m_graphicsApi->fromLiteral(
// aurora::backend_to_string(static_cast<aurora::Backend>(desiredBackend)));
// }
ImGuiCVarCheckbox(m_cvarMgr, "fullscreen", "Fullscreen"); ImGuiCVarCheckbox(m_cvarMgr, "fullscreen", "Fullscreen");
ImGui::EndTabItem(); ImGui::EndTabItem();
} }

View File

@ -116,8 +116,12 @@ private:
bool m_drawLighting = m_cvarCommons.m_debugToolDrawLighting->toBoolean(); bool m_drawLighting = m_cvarCommons.m_debugToolDrawLighting->toBoolean();
#if TARGET_OS_IOS #if TARGET_OS_IOS
bool m_pipelineInfo = false; bool m_pipelineInfo = false;
bool m_drawCallInfo = false;
bool m_bufferInfo = false;
#else #else
bool m_pipelineInfo = true; // TODO cvar bool m_pipelineInfo = true; // TODO cvar
bool m_drawCallInfo = true; // TODO cvar
bool m_bufferInfo = true; // TODO cvar
#endif #endif
bool m_developer = m_cvarMgr.findCVar("developer")->toBoolean(); bool m_developer = m_cvarMgr.findCVar("developer")->toBoolean();
bool m_cheats = m_cvarMgr.findCVar("cheats")->toBoolean(); bool m_cheats = m_cvarMgr.findCVar("cheats")->toBoolean();

View File

@ -1,12 +1,10 @@
#include "Runtime/ImGuiControllerConfig.hpp" #include "Runtime/ImGuiControllerConfig.hpp"
#include "Runtime/RetroTypes.hpp"
#include "Runtime/Streams/CFileOutStream.hpp" #include "Runtime/Streams/CFileOutStream.hpp"
#include "Runtime/Streams/ContainerReaders.hpp" #include "Runtime/Streams/ContainerReaders.hpp"
#include "Runtime/Streams/ContainerWriters.hpp" #include "Runtime/Streams/ContainerWriters.hpp"
#include "aurora/pad.hpp"
#include "aurora/aurora.hpp"
#include <imgui.h> #include <imgui.h>
namespace metaforce { namespace metaforce {

View File

@ -3,7 +3,7 @@
#include "Runtime/GCNTypes.hpp" #include "Runtime/GCNTypes.hpp"
#include "Runtime/Streams/CInputStream.hpp" #include "Runtime/Streams/CInputStream.hpp"
#include "Runtime/Streams/COutputStream.hpp" #include "Runtime/Streams/COutputStream.hpp"
#include "aurora/pad.hpp" #include <dolphin/pad.h>
#include <array> #include <array>
#include <chrono> #include <chrono>
@ -52,4 +52,4 @@ private:
ControllerAtlas* m_currentAtlas = nullptr; ControllerAtlas* m_currentAtlas = nullptr;
std::vector<ControllerAtlas> m_controllerAtlases; std::vector<ControllerAtlas> m_controllerAtlases;
}; };
} // namespace metaforce } // namespace metaforce

View File

@ -1,5 +1,7 @@
#include "Runtime/Input/CDolphinController.hpp" #include "Runtime/Input/CDolphinController.hpp"
#include <dolphin/si.h>
namespace metaforce { namespace metaforce {
CDolphinController::CDolphinController() { CDolphinController::CDolphinController() {
static bool sIsInitialized = false; static bool sIsInitialized = false;
@ -31,35 +33,35 @@ float CDolphinController::GetAnalogStickMaxValue(EJoyAxis axis) {
void CDolphinController::ReadDevices() { void CDolphinController::ReadDevices() {
std::array<PADStatus, 4> status{}; std::array<PADStatus, 4> status{};
PADRead(status.data()); PADRead(status.data());
if (status[0].xa_err == PAD::ERR_NONE) { if (status[0].err == PAD_ERR_NONE) {
PADClamp(status.data()); PADClamp(status.data());
x4_status = status; x4_status = status;
} else { } else {
x4_status[0].xa_err = status[0].xa_err; x4_status[0].err = status[0].err;
x4_status[1].xa_err = status[1].xa_err; x4_status[1].err = status[1].err;
x4_status[2].xa_err = status[2].xa_err; x4_status[2].err = status[2].err;
x4_status[3].xa_err = status[3].xa_err; x4_status[3].err = status[3].err;
} }
for (u32 i = 0; i < 4; ++i) { for (u32 i = 0; i < 4; ++i) {
if (x4_status[i].xa_err != PAD::ERR_NOT_READY) { if (x4_status[i].err != PAD_ERR_NOT_READY) {
if (x4_status[i].xa_err == PAD::ERR_NONE) { if (x4_status[i].err == PAD_ERR_NONE) {
x34_gamepadStates[i].SetDeviceIsPresent(true); x34_gamepadStates[i].SetDeviceIsPresent(true);
} else if (x4_status[i].xa_err == PAD::ERR_NO_CONTROLLER) { } else if (x4_status[i].err == PAD_ERR_NO_CONTROLLER) {
x1c8_invalidControllers |= PAD::CHAN0_BIT >> i; x1c8_invalidControllers |= PAD_CHAN0_BIT >> i;
x34_gamepadStates[i].SetDeviceIsPresent(false); x34_gamepadStates[i].SetDeviceIsPresent(false);
} }
} }
if (x1b4_controllerTypePollTime[i] == 0) { if (x1b4_controllerTypePollTime[i] == 0) {
const auto type = SIProbe(i); const auto type = SIProbe(i);
if ((type & (SI::ERROR_NO_RESPONSE | SI::ERROR_UNKNOWN | SI::ERROR_BUSY)) == 0) { if ((type & (SI_ERROR_NO_RESPONSE | SI_ERROR_UNKNOWN | SI_ERROR_BUSY)) == 0) {
x1b4_controllerTypePollTime[i] = 0x3c; x1b4_controllerTypePollTime[i] = 0x3c;
if (type == SI::GC_WIRELESS) { if (type == SI_GC_WIRELESS) {
x1a4_controllerTypes[i] = skTypeWavebird; x1a4_controllerTypes[i] = skTypeWavebird;
} else if (type == SI::GBA) { /* here for completeness, the GameCube adapter does not support GBA */ } else if (type == SI_GBA) { /* here for completeness, the GameCube adapter does not support GBA */
x1a4_controllerTypes[i] = skTypeGBA; x1a4_controllerTypes[i] = skTypeGBA;
} else if (type == SI::GC_STANDARD) { } else if (type == SI_GC_STANDARD) {
x1a4_controllerTypes[i] = skTypeStandard; x1a4_controllerTypes[i] = skTypeStandard;
} }
} else { } else {
@ -94,13 +96,13 @@ void CDolphinController::ProcessAxis(u32 controller, EJoyAxis axis) {
float axisValue = 0.f; float axisValue = 0.f;
if (axis == EJoyAxis::LeftX) { if (axis == EJoyAxis::LeftX) {
axisValue = x4_status[controller].x2_stickX; axisValue = x4_status[controller].stickX;
} else if (axis == EJoyAxis::LeftY) { } else if (axis == EJoyAxis::LeftY) {
axisValue = x4_status[controller].x3_stickY; axisValue = x4_status[controller].stickY;
} else if (axis == EJoyAxis::RightX) { } else if (axis == EJoyAxis::RightX) {
axisValue = x4_status[controller].x4_substickX; axisValue = x4_status[controller].substickX;
} else if (axis == EJoyAxis::RightY) { } else if (axis == EJoyAxis::RightY) {
axisValue = x4_status[controller].x5_substickY; axisValue = x4_status[controller].substickY;
} }
axisValue *= 1.f / maxAxisValue; axisValue *= 1.f / maxAxisValue;
float absolute = zeus::clamp(kAbsoluteMinimum, axisValue, kAbsoluteMaximum); float absolute = zeus::clamp(kAbsoluteMinimum, axisValue, kAbsoluteMaximum);
@ -110,8 +112,8 @@ void CDolphinController::ProcessAxis(u32 controller, EJoyAxis axis) {
} }
static constexpr std::array<u16, size_t(EButton::MAX)> mButtonMapping{ static constexpr std::array<u16, size_t(EButton::MAX)> mButtonMapping{
PAD::BUTTON_A, PAD::BUTTON_B, PAD::BUTTON_X, PAD::BUTTON_Y, PAD::BUTTON_START, PAD::TRIGGER_Z, PAD_BUTTON_A, PAD_BUTTON_B, PAD_BUTTON_X, PAD_BUTTON_Y, PAD_BUTTON_START, PAD_TRIGGER_Z,
PAD::BUTTON_UP, PAD::BUTTON_RIGHT, PAD::BUTTON_DOWN, PAD::BUTTON_LEFT, PAD::TRIGGER_L, PAD::TRIGGER_R, PAD_BUTTON_UP, PAD_BUTTON_RIGHT, PAD_BUTTON_DOWN, PAD_BUTTON_LEFT, PAD_TRIGGER_L, PAD_TRIGGER_R,
}; };
void CDolphinController::ProcessButtons(u32 controller) { void CDolphinController::ProcessButtons(u32 controller) {
@ -119,17 +121,19 @@ void CDolphinController::ProcessButtons(u32 controller) {
ProcessDigitalButton(controller, x34_gamepadStates[controller].GetButton(EButton(i)), mButtonMapping[i]); ProcessDigitalButton(controller, x34_gamepadStates[controller].GetButton(EButton(i)), mButtonMapping[i]);
} }
ProcessAnalogButton(x4_status[controller].x6_triggerL, ProcessAnalogButton(x4_status[controller].triggerL,
x34_gamepadStates[controller].GetAnalogButton(EAnalogButton::Left)); x34_gamepadStates[controller].GetAnalogButton(EAnalogButton::Left));
ProcessAnalogButton(x4_status[controller].x7_triggerR, ProcessAnalogButton(x4_status[controller].triggerR,
x34_gamepadStates[controller].GetAnalogButton(EAnalogButton::Right)); x34_gamepadStates[controller].GetAnalogButton(EAnalogButton::Right));
} }
void CDolphinController::ProcessDigitalButton(u32 controller, CControllerButton& button, u16 mapping) { void CDolphinController::ProcessDigitalButton(u32 controller, CControllerButton& button, u16 mapping) {
bool btnPressed = (x4_status[controller].x0_buttons & mapping) != 0; bool btnPressed = (x4_status[controller].button & mapping) != 0;
button.SetPressEvent(PADButtonDown(button.GetIsPressed(), btnPressed)); button.SetPressEvent(PADButtonDown(button.GetIsPressed(), btnPressed));
button.SetReleaseEvent(PADButtonUp(button.GetIsPressed(), btnPressed)); button.SetReleaseEvent(PADButtonUp(button.GetIsPressed(), btnPressed));
button.SetIsPressed(btnPressed); button.SetIsPressed(btnPressed);
} }
void CDolphinController::ProcessAnalogButton(float value, CControllerAxis& axis) { void CDolphinController::ProcessAnalogButton(float value, CControllerAxis& axis) {
float absolute = value * (1 / 150.f); float absolute = value * (1 / 150.f);
if (value * (1 / 150.f) > kAbsoluteMaximum) { if (value * (1 / 150.f) > kAbsoluteMaximum) {
@ -168,4 +172,4 @@ bool CDolphinController::Initialize() {
Poll(); Poll();
return true; return true;
} }
} // namespace metaforce } // namespace metaforce

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "Runtime/Input/IController.hpp" #include "Runtime/Input/IController.hpp"
#include "Runtime/RetroTypes.hpp"
namespace metaforce { namespace metaforce {
@ -40,4 +40,4 @@ private:
void ProcessDigitalButton(u32 controller, CControllerButton& button, u16 mapping); void ProcessDigitalButton(u32 controller, CControllerButton& button, u16 mapping);
void ProcessAnalogButton(float value, CControllerAxis& axis); void ProcessAnalogButton(float value, CControllerAxis& axis);
}; };
} // namespace metaforce } // namespace metaforce

View File

@ -56,10 +56,10 @@ CFinalInput::CFinalInput(int cIdx, float dt, const CKeyboardMouseControllerData&
, x23_enableAnaRightYP(DRAUp() && !prevInput.DRAUp()) , x23_enableAnaRightYP(DRAUp() && !prevInput.DRAUp())
, x24_anaLeftTriggerP(DLTrigger() && !prevInput.DLTrigger()) , x24_anaLeftTriggerP(DLTrigger() && !prevInput.DLTrigger())
, x28_anaRightTriggerP(DRTrigger() && !prevInput.DRTrigger()) , x28_anaRightTriggerP(DRTrigger() && !prevInput.DRTrigger())
, x2c_b31_DPUp(data.m_specialKeys[size_t(aurora::SpecialKey::Up)]) , x2c_b31_DPUp(data.m_specialKeys[size_t(ESpecialKey::Up)])
, x2d_b24_DPRight(data.m_specialKeys[size_t(aurora::SpecialKey::Right)]) , x2d_b24_DPRight(data.m_specialKeys[size_t(ESpecialKey::Right)])
, x2d_b25_DPDown(data.m_specialKeys[size_t(aurora::SpecialKey::Down)]) , x2d_b25_DPDown(data.m_specialKeys[size_t(ESpecialKey::Down)])
, x2d_b26_DPLeft(data.m_specialKeys[size_t(aurora::SpecialKey::Left)]) , x2d_b26_DPLeft(data.m_specialKeys[size_t(ESpecialKey::Left)])
, x2d_b28_PA(DA() && !prevInput.DA()) , x2d_b28_PA(DA() && !prevInput.DA())
, x2d_b29_PB(DB() && !prevInput.DB()) , x2d_b29_PB(DB() && !prevInput.DB())
, x2d_b30_PX(DX() && !prevInput.DX()) , x2d_b30_PX(DX() && !prevInput.DX())
@ -316,11 +316,11 @@ static void pad_clamptrigger(int16_t& trigger) {
} }
void SAuroraControllerState::clamp() { void SAuroraControllerState::clamp() {
pad_clampstick(m_axes[size_t(aurora::ControllerAxis::LeftX)], m_axes[size_t(aurora::ControllerAxis::LeftY)], pad_clampstick(m_axes[size_t(EControllerAxis::LeftX)], m_axes[size_t(EControllerAxis::LeftY)],
pad_clampregion[3], pad_clampregion[4], pad_clampregion[2]); pad_clampregion[3], pad_clampregion[4], pad_clampregion[2]);
pad_clampstick(m_axes[size_t(aurora::ControllerAxis::RightX)], m_axes[size_t(aurora::ControllerAxis::RightY)], pad_clampstick(m_axes[size_t(EControllerAxis::RightX)], m_axes[size_t(EControllerAxis::RightY)],
pad_clampregion[6], pad_clampregion[7], pad_clampregion[5]); pad_clampregion[6], pad_clampregion[7], pad_clampregion[5]);
pad_clamptrigger(m_axes[size_t(aurora::ControllerAxis::TriggerLeft)]); pad_clamptrigger(m_axes[size_t(EControllerAxis::TriggerLeft)]);
pad_clamptrigger(m_axes[size_t(aurora::ControllerAxis::TriggerRight)]); pad_clamptrigger(m_axes[size_t(EControllerAxis::TriggerRight)]);
} }
} // namespace metaforce } // namespace metaforce

View File

@ -12,8 +12,8 @@ struct SAuroraControllerState {
u32 m_which = -1; u32 m_which = -1;
bool m_isGamecube = false; bool m_isGamecube = false;
bool m_hasRumble = false; bool m_hasRumble = false;
std::array<int16_t, size_t(aurora::ControllerAxis::MAX)> m_axes{}; std::array<int16_t, size_t(EControllerAxis::MAX)> m_axes{};
std::bitset<size_t(aurora::ControllerButton::MAX)> m_btns{}; std::bitset<size_t(EControllerButton::MAX)> m_btns{};
SAuroraControllerState() = default; SAuroraControllerState() = default;
SAuroraControllerState(uint32_t which, bool isGamecube, bool hasRumble) SAuroraControllerState(uint32_t which, bool isGamecube, bool hasRumble)
@ -68,7 +68,7 @@ struct CFinalInput {
std::optional<CKeyboardMouseControllerData> m_kbm; std::optional<CKeyboardMouseControllerData> m_kbm;
std::array<bool, 256> m_PCharKeys{}; std::array<bool, 256> m_PCharKeys{};
std::array<bool, size_t(aurora::SpecialKey::MAX)> m_PSpecialKeys{}; std::array<bool, size_t(ESpecialKey::MAX)> m_PSpecialKeys{};
std::array<bool, 6> m_PMouseButtons{}; std::array<bool, 6> m_PMouseButtons{};
@ -162,13 +162,13 @@ struct CFinalInput {
void InitializeAnalog(float leftDiv, float rightDiv); void InitializeAnalog(float leftDiv, float rightDiv);
bool PKey(char k) const { return m_kbm && m_PCharKeys[size_t(k)]; } bool PKey(char k) const { return m_kbm && m_PCharKeys[size_t(k)]; }
bool PSpecialKey(aurora::SpecialKey k) const { return m_kbm && m_PSpecialKeys[size_t(k)]; } bool PSpecialKey(ESpecialKey k) const { return m_kbm && m_PSpecialKeys[size_t(k)]; }
bool PMouseButton(EMouseButton k) const { return m_kbm && m_PMouseButtons[size_t(k)]; } bool PMouseButton(EMouseButton k) const { return m_kbm && m_PMouseButtons[size_t(k)]; }
bool DKey(char k) const { return m_kbm && m_kbm->m_charKeys[size_t(k)]; } bool DKey(char k) const { return m_kbm && m_kbm->m_charKeys[size_t(k)]; }
bool DSpecialKey(aurora::SpecialKey k) const { return m_kbm && m_kbm->m_specialKeys[size_t(k)]; } bool DSpecialKey(ESpecialKey k) const { return m_kbm && m_kbm->m_specialKeys[size_t(k)]; }
bool DMouseButton(EMouseButton k) const { return m_kbm && m_kbm->m_mouseButtons[size_t(k)]; } bool DMouseButton(EMouseButton k) const { return m_kbm && m_kbm->m_mouseButtons[size_t(k)]; }
float AKey(char k) const { return DKey(k) ? 1.f : 0.f; } float AKey(char k) const { return DKey(k) ? 1.f : 0.f; }
float ASpecialKey(aurora::SpecialKey k) const { return DSpecialKey(k) ? 1.f : 0.f; } float ASpecialKey(ESpecialKey k) const { return DSpecialKey(k) ? 1.f : 0.f; }
float AMouseButton(EMouseButton k) const { return DMouseButton(k) ? 1.f : 0.f; } float AMouseButton(EMouseButton k) const { return DMouseButton(k) ? 1.f : 0.f; }
const std::optional<CKeyboardMouseControllerData>& GetKBM() const { return m_kbm; } const std::optional<CKeyboardMouseControllerData>& GetKBM() const { return m_kbm; }

View File

@ -69,7 +69,7 @@ void CInputGenerator::controllerRemoved(uint32_t which) noexcept {
(*it) = SAuroraControllerState(); (*it) = SAuroraControllerState();
} }
void CInputGenerator::controllerButton(uint32_t which, aurora::ControllerButton button, bool pressed) noexcept { void CInputGenerator::controllerButton(uint32_t which, EControllerButton button, bool pressed) noexcept {
s32 player = aurora::get_controller_player_index(which); s32 player = aurora::get_controller_player_index(which);
if (player < 0) { if (player < 0) {
return; return;
@ -77,24 +77,24 @@ void CInputGenerator::controllerButton(uint32_t which, aurora::ControllerButton
m_state[player].m_btns.set(size_t(button), pressed); m_state[player].m_btns.set(size_t(button), pressed);
} }
void CInputGenerator::controllerAxis(uint32_t which, aurora::ControllerAxis axis, int16_t value) noexcept { void CInputGenerator::controllerAxis(uint32_t which, EControllerAxis axis, int16_t value) noexcept {
s32 player = aurora::get_controller_player_index(which); s32 player = aurora::get_controller_player_index(which);
if (player < 0) { if (player < 0) {
return; return;
} }
switch (axis) { switch (axis) {
case aurora::ControllerAxis::LeftY: case EControllerAxis::LeftY:
case aurora::ControllerAxis::RightY: case EControllerAxis::RightY:
/* Value is inverted compared to what we expect on the Y axis */ /* Value is inverted compared to what we expect on the Y axis */
value = int16_t(-(value + 1)); value = int16_t(-(value + 1));
[[fallthrough]]; [[fallthrough]];
case aurora::ControllerAxis::LeftX: case EControllerAxis::LeftX:
case aurora::ControllerAxis::RightX: case EControllerAxis::RightX:
value /= int16_t(256); value /= int16_t(256);
break; break;
case aurora::ControllerAxis::TriggerLeft: case EControllerAxis::TriggerLeft:
case aurora::ControllerAxis::TriggerRight: case EControllerAxis::TriggerRight:
value /= int16_t(128); value /= int16_t(128);
break; break;
default: default:

View File

@ -42,9 +42,9 @@ public:
void controllerRemoved(uint32_t which) noexcept; void controllerRemoved(uint32_t which) noexcept;
void controllerButton(uint32_t which, aurora::ControllerButton button, bool pressed) noexcept; void controllerButton(uint32_t which, EControllerButton button, bool pressed) noexcept;
void controllerAxis(uint32_t which, aurora::ControllerAxis axis, int16_t value) noexcept; void controllerAxis(uint32_t which, EControllerAxis axis, int16_t value) noexcept;
/* Keyboard and mouse events are delivered on the main game /* Keyboard and mouse events are delivered on the main game
@ -74,8 +74,8 @@ public:
return; return;
m_data.m_charKeys[charCode] = false; m_data.m_charKeys[charCode] = false;
} }
void specialKeyDown(aurora::SpecialKey key, aurora::ModifierKey, bool) { m_data.m_specialKeys[size_t(key)] = true; } void specialKeyDown(ESpecialKey key, aurora::ModifierKey, bool) { m_data.m_specialKeys[size_t(key)] = true; }
void specialKeyUp(aurora::SpecialKey key, aurora::ModifierKey) { m_data.m_specialKeys[size_t(key)] = false; } void specialKeyUp(ESpecialKey key, aurora::ModifierKey) { m_data.m_specialKeys[size_t(key)] = false; }
void modKeyDown(aurora::ModifierKey mod, bool) { m_data.m_modMask = m_data.m_modMask | mod; } void modKeyDown(aurora::ModifierKey mod, bool) { m_data.m_modMask = m_data.m_modMask | mod; }
void modKeyUp(aurora::ModifierKey mod) { m_data.m_modMask = m_data.m_modMask & ~mod; } void modKeyUp(aurora::ModifierKey mod) { m_data.m_modMask = m_data.m_modMask & ~mod; }

View File

@ -2,12 +2,119 @@
#include <array> #include <array>
#include <aurora/aurora.hpp> #include <aurora/aurora.h>
#include "GCNTypes.hpp"
namespace metaforce { namespace metaforce {
// TODO: copied from boo; should be rewritten
// TODO: copied from boo; should be rewritten and included from from aurora enum class EControllerButton : uint8_t {
A,
B,
X,
Y,
Back,
Guide,
Start,
LeftStick,
RightStick,
LeftShoulder,
RightShoulder,
DPadUp,
DPadDown,
DPadLeft,
DPadRight,
Other,
MAX,
};
enum class EControllerAxis : uint8_t {
LeftX,
LeftY,
RightX,
RightY,
TriggerLeft,
TriggerRight,
MAX,
};
enum class EMouseButton { None = 0, Primary = 1, Secondary = 2, Middle = 3, Aux1 = 4, Aux2 = 5 }; enum class EMouseButton { None = 0, Primary = 1, Secondary = 2, Middle = 3, Aux1 = 4, Aux2 = 5 };
enum class ESpecialKey : uint8_t {
None = 0,
F1 = 1,
F2 = 2,
F3 = 3,
F4 = 4,
F5 = 5,
F6 = 6,
F7 = 7,
F8 = 8,
F9 = 9,
F10 = 10,
F11 = 11,
F12 = 12,
F13 = 13,
F14 = 14,
F15 = 15,
F16 = 16,
F17 = 17,
F18 = 18,
F19 = 19,
F20 = 20,
F21 = 21,
F22 = 22,
F23 = 23,
F24 = 24,
Esc = 25,
Enter = 26,
Backspace = 27,
Insert = 28,
Delete = 29,
Home = 30,
End = 31,
PgUp = 32,
PgDown = 33,
Left = 34,
Right = 35,
Up = 36,
Down = 37,
Tab = 38,
PrintScreen = 39,
ScrollLock = 40,
Pause = 41,
NumLockClear = 42,
KpDivide = 43,
KpMultiply = 44,
KpMinus = 45,
KpPlus = 46,
KpEnter = 47,
KpNum0 = 48,
KpNum1 = 49,
KpNum2 = 50,
KpNum3 = 51,
KpNum4 = 52,
KpNum5 = 53,
KpNum6 = 54,
KpNum7 = 55,
KpNum8 = 56,
KpNum9 = 57,
KpPercent = 58,
KpPeriod = 59,
KpComma = 60,
KpEquals = 61,
Application = 62,
Power = 63,
Execute = 64,
Help = 65,
Menu = 66,
Select = 67,
Stop = 68,
Again = 69,
Undo = 70,
Cut = 71,
Paste = 72,
Find = 73,
VolumeUp = 74,
VolumeDown = 75,
MAX,
};
enum class EModifierKey { enum class EModifierKey {
None = 0, None = 0,
Ctrl = 1 << 0, Ctrl = 1 << 0,
@ -56,9 +163,9 @@ struct SScrollDelta {
struct CKeyboardMouseControllerData { struct CKeyboardMouseControllerData {
std::array<bool, 256> m_charKeys{}; std::array<bool, 256> m_charKeys{};
std::array<bool, static_cast<size_t>(aurora::SpecialKey::MAX)> m_specialKeys{}; std::array<bool, static_cast<size_t>(ESpecialKey::MAX)> m_specialKeys{};
std::array<bool, 6> m_mouseButtons{}; std::array<bool, 6> m_mouseButtons{};
aurora::ModifierKey m_modMask = aurora::ModifierKey::None; EModifierKey m_modMask = EModifierKey::None;
SWindowCoord m_mouseCoord; SWindowCoord m_mouseCoord;
SScrollDelta m_accumScroll; SScrollDelta m_accumScroll;
}; };

View File

@ -1,5 +1,4 @@
set(INPUT_SOURCES set(INPUT_SOURCES
PAD.hpp
IController.hpp DolphinIController.cpp IController.hpp DolphinIController.cpp
CControllerAxis.hpp CControllerAxis.hpp
CControllerButton.hpp CControllerButton.hpp

View File

@ -145,75 +145,75 @@ constexpr std::array<FloatReturnFn, 24> skAnalogFuncs{
}; };
constexpr std::array<ControlMapper::EKBMFunctionList, 70> skKBMMapping{ constexpr std::array<ControlMapper::EKBMFunctionList, 70> skKBMMapping{
ControlMapper::EKBMFunctionList::KeyPress + 'w', // Forward, ControlMapper::EKBMFunctionList::KeyPress + 'w', // Forward,
ControlMapper::EKBMFunctionList::KeyPress + 's', // Backward, ControlMapper::EKBMFunctionList::KeyPress + 's', // Backward,
ControlMapper::EKBMFunctionList::KeyPress + 'a', // TurnLeft, ControlMapper::EKBMFunctionList::KeyPress + 'a', // TurnLeft,
ControlMapper::EKBMFunctionList::KeyPress + 'd', // TurnRight, ControlMapper::EKBMFunctionList::KeyPress + 'd', // TurnRight,
ControlMapper::EKBMFunctionList::KeyPress + 'a', // StrafeLeft, ControlMapper::EKBMFunctionList::KeyPress + 'a', // StrafeLeft,
ControlMapper::EKBMFunctionList::KeyPress + 'd', // StrafeRight, ControlMapper::EKBMFunctionList::KeyPress + 'd', // StrafeRight,
ControlMapper::EKBMFunctionList::KeyPress + 'a', // LookLeft, ControlMapper::EKBMFunctionList::KeyPress + 'a', // LookLeft,
ControlMapper::EKBMFunctionList::KeyPress + 'd', // LookRight, ControlMapper::EKBMFunctionList::KeyPress + 'd', // LookRight,
ControlMapper::EKBMFunctionList::KeyPress + 's', // LookUp, ControlMapper::EKBMFunctionList::KeyPress + 's', // LookUp,
ControlMapper::EKBMFunctionList::KeyPress + 'w', // LookDown, ControlMapper::EKBMFunctionList::KeyPress + 'w', // LookDown,
ControlMapper::EKBMFunctionList::KeyPress + ' ', // JumpOrBoost = 10, ControlMapper::EKBMFunctionList::KeyPress + ' ', // JumpOrBoost = 10,
ControlMapper::EKBMFunctionList::MousePress + EMouseButton::Primary, // FireOrBomb = 11, ControlMapper::EKBMFunctionList::MousePress + EMouseButton::Primary, // FireOrBomb = 11,
ControlMapper::EKBMFunctionList::MousePress + EMouseButton::Secondary, // MissileOrPowerBomb = 12, ControlMapper::EKBMFunctionList::MousePress + EMouseButton::Secondary, // MissileOrPowerBomb = 12,
ControlMapper::EKBMFunctionList::KeyPress + 'c', // Morph, ControlMapper::EKBMFunctionList::KeyPress + 'c', // Morph,
ControlMapper::EKBMFunctionList::None, // AimUp, ControlMapper::EKBMFunctionList::None, // AimUp,
ControlMapper::EKBMFunctionList::None, // AimDown, ControlMapper::EKBMFunctionList::None, // AimDown,
ControlMapper::EKBMFunctionList::None, // CycleBeamUp, ControlMapper::EKBMFunctionList::None, // CycleBeamUp,
ControlMapper::EKBMFunctionList::None, // CycleBeamDown, ControlMapper::EKBMFunctionList::None, // CycleBeamDown,
ControlMapper::EKBMFunctionList::None, // CycleItem, ControlMapper::EKBMFunctionList::None, // CycleItem,
ControlMapper::EKBMFunctionList::KeyPress + '1', // PowerBeam, ControlMapper::EKBMFunctionList::KeyPress + '1', // PowerBeam,
ControlMapper::EKBMFunctionList::KeyPress + '3', // IceBeam, ControlMapper::EKBMFunctionList::KeyPress + '3', // IceBeam,
ControlMapper::EKBMFunctionList::KeyPress + '2', // WaveBeam, ControlMapper::EKBMFunctionList::KeyPress + '2', // WaveBeam,
ControlMapper::EKBMFunctionList::KeyPress + '4', // PlasmaBeam, ControlMapper::EKBMFunctionList::KeyPress + '4', // PlasmaBeam,
ControlMapper::EKBMFunctionList::None, // ToggleHolster = 23, ControlMapper::EKBMFunctionList::None, // ToggleHolster = 23,
ControlMapper::EKBMFunctionList::None, // OrbitClose, ControlMapper::EKBMFunctionList::None, // OrbitClose,
ControlMapper::EKBMFunctionList::KeyPress + 'q', // OrbitFar, ControlMapper::EKBMFunctionList::KeyPress + 'q', // OrbitFar,
ControlMapper::EKBMFunctionList::KeyPress + 'q', // OrbitObject, ControlMapper::EKBMFunctionList::KeyPress + 'q', // OrbitObject,
ControlMapper::EKBMFunctionList::None, // OrbitSelect, ControlMapper::EKBMFunctionList::None, // OrbitSelect,
ControlMapper::EKBMFunctionList::None, // OrbitConfirm, ControlMapper::EKBMFunctionList::None, // OrbitConfirm,
ControlMapper::EKBMFunctionList::KeyPress + 'a', // OrbitLeft, ControlMapper::EKBMFunctionList::KeyPress + 'a', // OrbitLeft,
ControlMapper::EKBMFunctionList::KeyPress + 'd', // OrbitRight, ControlMapper::EKBMFunctionList::KeyPress + 'd', // OrbitRight,
ControlMapper::EKBMFunctionList::KeyPress + 'w', // OrbitUp, ControlMapper::EKBMFunctionList::KeyPress + 'w', // OrbitUp,
ControlMapper::EKBMFunctionList::KeyPress + 's', // OrbitDown, ControlMapper::EKBMFunctionList::KeyPress + 's', // OrbitDown,
ControlMapper::EKBMFunctionList::KeyPress + 'e', // LookHold1, ControlMapper::EKBMFunctionList::KeyPress + 'e', // LookHold1,
ControlMapper::EKBMFunctionList::None, // LookHold2, ControlMapper::EKBMFunctionList::None, // LookHold2,
ControlMapper::EKBMFunctionList::None, // LookZoomIn, ControlMapper::EKBMFunctionList::None, // LookZoomIn,
ControlMapper::EKBMFunctionList::None, // LookZoomOut, ControlMapper::EKBMFunctionList::None, // LookZoomOut,
ControlMapper::EKBMFunctionList::None, // AimHold, ControlMapper::EKBMFunctionList::None, // AimHold,
ControlMapper::EKBMFunctionList::KeyPress + 's', // MapCircleUp, ControlMapper::EKBMFunctionList::KeyPress + 's', // MapCircleUp,
ControlMapper::EKBMFunctionList::KeyPress + 'w', // MapCircleDown, ControlMapper::EKBMFunctionList::KeyPress + 'w', // MapCircleDown,
ControlMapper::EKBMFunctionList::KeyPress + 'a', // MapCircleLeft, ControlMapper::EKBMFunctionList::KeyPress + 'a', // MapCircleLeft,
ControlMapper::EKBMFunctionList::KeyPress + 'd', // MapCircleRight, ControlMapper::EKBMFunctionList::KeyPress + 'd', // MapCircleRight,
ControlMapper::EKBMFunctionList::SpecialKeyPress + aurora::SpecialKey::Up, // MapMoveForward, ControlMapper::EKBMFunctionList::SpecialKeyPress + ESpecialKey::Up, // MapMoveForward,
ControlMapper::EKBMFunctionList::SpecialKeyPress + aurora::SpecialKey::Down, // MapMoveBack, ControlMapper::EKBMFunctionList::SpecialKeyPress + ESpecialKey::Down, // MapMoveBack,
ControlMapper::EKBMFunctionList::SpecialKeyPress + aurora::SpecialKey::Left, // MapMoveLeft, ControlMapper::EKBMFunctionList::SpecialKeyPress + ESpecialKey::Left, // MapMoveLeft,
ControlMapper::EKBMFunctionList::SpecialKeyPress + aurora::SpecialKey::Right, // MapMoveRight, ControlMapper::EKBMFunctionList::SpecialKeyPress + ESpecialKey::Right, // MapMoveRight,
ControlMapper::EKBMFunctionList::KeyPress + 'e', // MapZoomIn, ControlMapper::EKBMFunctionList::KeyPress + 'e', // MapZoomIn,
ControlMapper::EKBMFunctionList::KeyPress + 'q', // MapZoomOut, ControlMapper::EKBMFunctionList::KeyPress + 'q', // MapZoomOut,
ControlMapper::EKBMFunctionList::KeyPress + 'e', // SpiderBall, ControlMapper::EKBMFunctionList::KeyPress + 'e', // SpiderBall,
ControlMapper::EKBMFunctionList::KeyPress + 'q', // ChaseCamera, ControlMapper::EKBMFunctionList::KeyPress + 'q', // ChaseCamera,
ControlMapper::EKBMFunctionList::SpecialKeyPress + aurora::SpecialKey::Right, // XrayVisor = 50, ControlMapper::EKBMFunctionList::SpecialKeyPress + ESpecialKey::Right, // XrayVisor = 50,
ControlMapper::EKBMFunctionList::SpecialKeyPress + aurora::SpecialKey::Down, // ThermoVisor = 51, ControlMapper::EKBMFunctionList::SpecialKeyPress + ESpecialKey::Down, // ThermoVisor = 51,
ControlMapper::EKBMFunctionList::SpecialKeyPress + aurora::SpecialKey::Left, // InviroVisor = 52, ControlMapper::EKBMFunctionList::SpecialKeyPress + ESpecialKey::Left, // InviroVisor = 52,
ControlMapper::EKBMFunctionList::SpecialKeyPress + aurora::SpecialKey::Up, // NoVisor = 53, ControlMapper::EKBMFunctionList::SpecialKeyPress + ESpecialKey::Up, // NoVisor = 53,
ControlMapper::EKBMFunctionList::None, // VisorMenu, ControlMapper::EKBMFunctionList::None, // VisorMenu,
ControlMapper::EKBMFunctionList::None, // VisorUp, ControlMapper::EKBMFunctionList::None, // VisorUp,
ControlMapper::EKBMFunctionList::None, // VisorDown, ControlMapper::EKBMFunctionList::None, // VisorDown,
ControlMapper::EKBMFunctionList::KeyPress + 'e', // ShowCrosshairs, ControlMapper::EKBMFunctionList::KeyPress + 'e', // ShowCrosshairs,
ControlMapper::EKBMFunctionList::None, // UNKNOWN ControlMapper::EKBMFunctionList::None, // UNKNOWN
ControlMapper::EKBMFunctionList::None, // UseSheild = 0x3B, ControlMapper::EKBMFunctionList::None, // UseSheild = 0x3B,
ControlMapper::EKBMFunctionList::KeyPress + 'q', // ScanItem = 0x3C, ControlMapper::EKBMFunctionList::KeyPress + 'q', // ScanItem = 0x3C,
ControlMapper::EKBMFunctionList::None, // UNKNOWN ControlMapper::EKBMFunctionList::None, // UNKNOWN
ControlMapper::EKBMFunctionList::None, // UNKNOWN ControlMapper::EKBMFunctionList::None, // UNKNOWN
ControlMapper::EKBMFunctionList::None, // UNKNOWN ControlMapper::EKBMFunctionList::None, // UNKNOWN
ControlMapper::EKBMFunctionList::None, // UNKNOWN ControlMapper::EKBMFunctionList::None, // UNKNOWN
ControlMapper::EKBMFunctionList::KeyPress + 'q', // PreviousPauseScreen = 0x41, ControlMapper::EKBMFunctionList::KeyPress + 'q', // PreviousPauseScreen = 0x41,
ControlMapper::EKBMFunctionList::KeyPress + 'e', // NextPauseScreen = 0x42, ControlMapper::EKBMFunctionList::KeyPress + 'e', // NextPauseScreen = 0x42,
ControlMapper::EKBMFunctionList::None, // UNKNOWN, ControlMapper::EKBMFunctionList::None, // UNKNOWN,
ControlMapper::EKBMFunctionList::None, // None, ControlMapper::EKBMFunctionList::None, // None,
ControlMapper::EKBMFunctionList::None, ControlMapper::EKBMFunctionList::None,
}; };
@ -307,10 +307,10 @@ static float KBToWASDY(const CKeyboardMouseControllerData& data) {
static float KBToArrowsX(const CKeyboardMouseControllerData& data) { static float KBToArrowsX(const CKeyboardMouseControllerData& data) {
float retval = 0.0; float retval = 0.0;
if (data.m_specialKeys[size_t(aurora::SpecialKey::Left)]) { if (data.m_specialKeys[size_t(ESpecialKey::Left)]) {
retval -= 1.0; retval -= 1.0;
} }
if (data.m_specialKeys[size_t(aurora::SpecialKey::Right)]) { if (data.m_specialKeys[size_t(ESpecialKey::Right)]) {
retval += 1.0; retval += 1.0;
} }
return retval; return retval;
@ -318,10 +318,10 @@ static float KBToArrowsX(const CKeyboardMouseControllerData& data) {
static float KBToArrowsY(const CKeyboardMouseControllerData& data) { static float KBToArrowsY(const CKeyboardMouseControllerData& data) {
float retval = 0.0; float retval = 0.0;
if (data.m_specialKeys[size_t(aurora::SpecialKey::Down)]) { if (data.m_specialKeys[size_t(ESpecialKey::Down)]) {
retval -= 1.0; retval -= 1.0;
} }
if (data.m_specialKeys[size_t(aurora::SpecialKey::Up)]) { if (data.m_specialKeys[size_t(ESpecialKey::Up)]) {
retval += 1.0; retval += 1.0;
} }
return retval; return retval;

View File

@ -126,7 +126,7 @@ constexpr ControlMapper::EKBMFunctionList operator+(ControlMapper::EKBMFunctionL
return ControlMapper::EKBMFunctionList(static_cast<T>(a) + static_cast<T>(b)); return ControlMapper::EKBMFunctionList(static_cast<T>(a) + static_cast<T>(b));
} }
constexpr ControlMapper::EKBMFunctionList operator+(ControlMapper::EKBMFunctionList a, aurora::SpecialKey b) { constexpr ControlMapper::EKBMFunctionList operator+(ControlMapper::EKBMFunctionList a, ESpecialKey b) {
using T = std::underlying_type_t<ControlMapper::EKBMFunctionList>; using T = std::underlying_type_t<ControlMapper::EKBMFunctionList>;
return ControlMapper::EKBMFunctionList(static_cast<T>(a) + static_cast<T>(b)); return ControlMapper::EKBMFunctionList(static_cast<T>(a) + static_cast<T>(b));
} }

View File

@ -1,18 +1,17 @@
#pragma once #pragma once
#include "Runtime/Input/PAD.hpp" #include <dolphin/pad.h>
namespace metaforce { namespace metaforce {
enum class EIOPort { enum class EIOPort {
Player1, Player1 = PAD_CHAN0,
Player2, Player2 = PAD_CHAN1,
Player3, Player3 = PAD_CHAN2,
Player4, Player4 = PAD_CHAN3,
}; };
enum class EMotorState { enum class EMotorState {
Stop = 0, Stop = PAD_MOTOR_STOP,
Rumble = 1, Rumble = PAD_MOTOR_RUMBLE,
StopHard = 2, StopHard = PAD_MOTOR_STOP_HARD,
}; };
} // namespace metaforce } // namespace metaforce

View File

@ -1,6 +0,0 @@
#pragma once
#include "aurora/pad.hpp"
using PADStatus = PAD::Status;
using PADButton = PAD::BUTTON;

View File

@ -782,10 +782,10 @@ CFrontEndUI::SFusionBonusFrame::SGBALinkFrame::ProcessUserInput(const CFinalInpu
case EUIType::LinkFailed: case EUIType::LinkFailed:
case EUIType::LinkCompleteOrLinking: case EUIType::LinkCompleteOrLinking:
case EUIType::TurnOffGBA: case EUIType::TurnOffGBA:
if (input.PA() || input.PSpecialKey(aurora::SpecialKey::Enter) || input.PMouseButton(EMouseButton::Primary)) { if (input.PA() || input.PSpecialKey(ESpecialKey::Enter) || input.PMouseButton(EMouseButton::Primary)) {
PlayAdvanceSfx(); PlayAdvanceSfx();
SetUIText(NextLinkUI[size_t(x0_uiType)]); SetUIText(NextLinkUI[size_t(x0_uiType)]);
} else if (input.PB() || input.PSpecialKey(aurora::SpecialKey::Esc)) { } else if (input.PB() || input.PSpecialKey(ESpecialKey::Esc)) {
const EUIType prevUi = PrevLinkUI[size_t(x0_uiType)]; const EUIType prevUi = PrevLinkUI[size_t(x0_uiType)];
if (prevUi == EUIType::Empty) { if (prevUi == EUIType::Empty) {
break; break;
@ -981,7 +981,7 @@ CFrontEndUI::SFusionBonusFrame::EAction CFrontEndUI::SFusionBonusFrame::ProcessU
} }
} else if (x24_loadedFrame) { } else if (x24_loadedFrame) {
CFinalInput useInput = input; CFinalInput useInput = input;
if (input.PZ() || input.PSpecialKey(aurora::SpecialKey::Tab)) { if (input.PZ() || input.PSpecialKey(ESpecialKey::Tab)) {
useInput.x2d_b28_PA = true; useInput.x2d_b28_PA = true;
m_gbaOverride = true; m_gbaOverride = true;
} }
@ -1238,7 +1238,7 @@ void CFrontEndUI::SNesEmulatorFrame::ProcessUserInput(const CFinalInput& input,
switch (x0_mode) { switch (x0_mode) {
case EMode::Emulator: case EMode::Emulator:
x4_nesEmu->ProcessUserInput(input, 4); x4_nesEmu->ProcessUserInput(input, 4);
if ((input.ControllerIdx() == 0 && input.PL()) || input.PSpecialKey(aurora::SpecialKey::Esc)) if ((input.ControllerIdx() == 0 && input.PL()) || input.PSpecialKey(ESpecialKey::Esc))
SetMode(EMode::QuitNESMetroid); SetMode(EMode::QuitNESMetroid);
break; break;
case EMode::SaveProgress: case EMode::SaveProgress:
@ -1577,7 +1577,7 @@ bool CFrontEndUI::SOptionsFrontEndFrame::ProcessUserInput(const CFinalInput& inp
if (sui) if (sui)
sui->ProcessUserInput(input); sui->ProcessUserInput(input);
if (x1c_loadedFrame && x134_24_visible) { if (x1c_loadedFrame && x134_24_visible) {
if ((input.PB() || input.PSpecialKey(aurora::SpecialKey::Esc)) && x24_tablegroup_leftmenu->GetIsActive()) { if ((input.PB() || input.PSpecialKey(ESpecialKey::Esc)) && x24_tablegroup_leftmenu->GetIsActive()) {
x134_25_exitOptions = true; x134_25_exitOptions = true;
CSfxManager::SfxStart(SFXfnt_back, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId); CSfxManager::SfxStart(SFXfnt_back, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
} else { } else {
@ -1966,16 +1966,16 @@ void CFrontEndUI::ProcessUserInput(const CFinalInput& input, CArchitectureQueue&
if (x50_curScreen != x54_nextScreen) { if (x50_curScreen != x54_nextScreen) {
if (x54_nextScreen == EScreen::AttractMovie && if (x54_nextScreen == EScreen::AttractMovie &&
(input.PStart() || input.PA() || input.PSpecialKey(aurora::SpecialKey::Esc) || (input.PStart() || input.PA() || input.PSpecialKey(ESpecialKey::Esc) ||
input.PSpecialKey(aurora::SpecialKey::Enter) || input.PMouseButton(EMouseButton::Primary))) { input.PSpecialKey(ESpecialKey::Enter) || input.PMouseButton(EMouseButton::Primary))) {
/* Player wants to return to opening credits from attract movie */ /* Player wants to return to opening credits from attract movie */
SetFadeBlackTimer(std::min(1.f, x58_fadeBlackTimer)); SetFadeBlackTimer(std::min(1.f, x58_fadeBlackTimer));
PlayAdvanceSfx(); PlayAdvanceSfx();
return; return;
} }
if (input.PA() || input.PStart() || input.PSpecialKey(aurora::SpecialKey::Esc) || if (input.PA() || input.PStart() || input.PSpecialKey(ESpecialKey::Esc) ||
input.PSpecialKey(aurora::SpecialKey::Enter) || input.PMouseButton(EMouseButton::Primary)) { input.PSpecialKey(ESpecialKey::Enter) || input.PMouseButton(EMouseButton::Primary)) {
if (x50_curScreen == EScreen::OpenCredits && x54_nextScreen == EScreen::Title && x58_fadeBlackTimer > 1.f) { if (x50_curScreen == EScreen::OpenCredits && x54_nextScreen == EScreen::Title && x58_fadeBlackTimer > 1.f) {
/* Player is too impatient to view opening credits */ /* Player is too impatient to view opening credits */
xd0_playerSkipToTitle = true; xd0_playerSkipToTitle = true;
@ -1985,8 +1985,8 @@ void CFrontEndUI::ProcessUserInput(const CFinalInput& input, CArchitectureQueue&
} }
} else { } else {
if (x50_curScreen == EScreen::Title) { if (x50_curScreen == EScreen::Title) {
if (input.PStart() || input.PA() || input.PSpecialKey(aurora::SpecialKey::Esc) || if (input.PStart() || input.PA() || input.PSpecialKey(ESpecialKey::Esc) ||
input.PSpecialKey(aurora::SpecialKey::Enter) || input.PMouseButton(EMouseButton::Primary)) { input.PSpecialKey(ESpecialKey::Enter) || input.PMouseButton(EMouseButton::Primary)) {
if (x58_fadeBlackTimer < 30.f - g_tweakGame->GetPressStartDelay()) { if (x58_fadeBlackTimer < 30.f - g_tweakGame->GetPressStartDelay()) {
/* Proceed to file select UI */ /* Proceed to file select UI */
CSfxManager::SfxStart(FETransitionBackSFX[x18_rndA][0], 1.f, 0.f, false, 0x7f, false, kInvalidAreaId); CSfxManager::SfxStart(FETransitionBackSFX[x18_rndA][0], 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);

View File

@ -596,7 +596,7 @@ void CInGameGuiManager::Draw(CStateManager& stateMgr) {
float xT = 1.f - zeus::clamp(0.f, (stateMgr.GetPlayer().GetDeathTime() - xStart) / 0.5f, 1.f); float xT = 1.f - zeus::clamp(0.f, (stateMgr.GetPlayer().GetDeathTime() - xStart) / 0.5f, 1.f);
float colT = 1.f - zeus::clamp(0.f, (stateMgr.GetPlayer().GetDeathTime() - colStart) / 0.5f, 1.f); float colT = 1.f - zeus::clamp(0.f, (stateMgr.GetPlayer().GetDeathTime() - colStart) / 0.5f, 1.f);
SClipScreenRect rect(CGraphics::g_Viewport); SClipScreenRect rect(CGraphics::g_Viewport);
CGraphics::ResolveSpareTexture(rect, 0, GX::TF_RGB565); CGraphics::ResolveSpareTexture(rect, 0, GX_TF_RGB565);
CCameraFilterPass::DrawFilter(EFilterType::Blend, EFilterShape::Fullscreen, zeus::skBlack, nullptr, 1.f); CCameraFilterPass::DrawFilter(EFilterType::Blend, EFilterShape::Fullscreen, zeus::skBlack, nullptr, 1.f);
float z = 0.5f * (zT * zT * zT * zT * zT * (CGraphics::GetViewportHeight() - 12.f) + 12.f); float z = 0.5f * (zT * zT * zT * zT * zT * (CGraphics::GetViewportHeight() - 12.f) + 12.f);
float x = 0.5f * (xT * (CGraphics::GetViewportWidth() - 12.f) + 12.f); float x = 0.5f * (xT * (CGraphics::GetViewportWidth() - 12.f) + 12.f);

View File

@ -141,7 +141,7 @@ void CInventoryScreen::ProcessControllerInput(const CFinalInput& input) {
if (input.PStart()) { if (input.PStart()) {
x19c_samusDoll->BeginViewInterpolate(false); x19c_samusDoll->BeginViewInterpolate(false);
x198_26_exitPauseScreen = true; x198_26_exitPauseScreen = true;
} else if (input.PB() || input.PSpecialKey(aurora::SpecialKey::Esc)) { } else if (input.PB() || input.PSpecialKey(ESpecialKey::Esc)) {
x19c_samusDoll->BeginViewInterpolate(false); x19c_samusDoll->BeginViewInterpolate(false);
} }
} }
@ -220,7 +220,7 @@ void CInventoryScreen::ProcessControllerInput(const CFinalInput& input) {
if (input.PLAUp() || m_bodyUpClicked) if (input.PLAUp() || m_bodyUpClicked)
newPage = std::max(oldPage - 1, 0); newPage = std::max(oldPage - 1, 0);
else if (input.PLADown() || m_bodyDownClicked || else if (input.PLADown() || m_bodyDownClicked ||
((input.PA() || input.PSpecialKey(aurora::SpecialKey::Enter) || m_bodyClicked) && !lastPage)) ((input.PA() || input.PSpecialKey(ESpecialKey::Enter) || m_bodyClicked) && !lastPage))
newPage = std::min(oldPage + 1, totalCount - 1); newPage = std::min(oldPage + 1, totalCount - 1);
x174_textpane_body->TextSupport().SetPage(newPage); x174_textpane_body->TextSupport().SetPage(newPage);
if (oldPage != newPage) if (oldPage != newPage)
@ -233,8 +233,8 @@ void CInventoryScreen::ProcessControllerInput(const CFinalInput& input) {
} }
if (!x1ac_textLeaveRequested) if (!x1ac_textLeaveRequested)
x1ac_textLeaveRequested = x1ac_textLeaveRequested =
input.PB() || input.PSpecialKey(aurora::SpecialKey::Esc) || input.PB() || input.PSpecialKey(ESpecialKey::Esc) ||
((input.PA() || m_bodyClicked || input.PSpecialKey(aurora::SpecialKey::Enter)) && lastPage); ((input.PA() || m_bodyClicked || input.PSpecialKey(ESpecialKey::Enter)) && lastPage);
x1ad_textViewing = !x1ac_textLeaveRequested; x1ad_textViewing = !x1ac_textLeaveRequested;
} else { } else {
x198_29_pulseTextArrowBottom = false; x198_29_pulseTextArrowBottom = false;

View File

@ -338,7 +338,7 @@ void CLogBookScreen::ProcessControllerInput(const CFinalInput& input) {
if (input.PLAUp() || m_bodyUpClicked) if (input.PLAUp() || m_bodyUpClicked)
newPage = std::max(oldPage - 1, 0); newPage = std::max(oldPage - 1, 0);
else if (input.PLADown() || m_bodyDownClicked || else if (input.PLADown() || m_bodyDownClicked ||
((input.PA() || input.PSpecialKey(aurora::SpecialKey::Enter) || m_bodyClicked) && !lastPage)) ((input.PA() || input.PSpecialKey(ESpecialKey::Enter) || m_bodyClicked) && !lastPage))
newPage = std::min(oldPage + 1, pageCount - 1); newPage = std::min(oldPage + 1, pageCount - 1);
x174_textpane_body->TextSupport().SetPage(newPage); x174_textpane_body->TextSupport().SetPage(newPage);
if (oldPage != newPage) if (oldPage != newPage)
@ -352,8 +352,8 @@ void CLogBookScreen::ProcessControllerInput(const CFinalInput& input) {
if (!x260_26_exitTextScroll) if (!x260_26_exitTextScroll)
x260_26_exitTextScroll = x260_26_exitTextScroll =
input.PB() || input.PSpecialKey(aurora::SpecialKey::Esc) || input.PB() || input.PSpecialKey(ESpecialKey::Esc) ||
((input.PA() || input.PSpecialKey(aurora::SpecialKey::Enter) || m_bodyClicked) && lastPage); ((input.PA() || input.PSpecialKey(ESpecialKey::Enter) || m_bodyClicked) && lastPage);
if (g_tweakGui->GetLatchArticleText()) if (g_tweakGui->GetLatchArticleText())
x260_25_inTextScroll = !x260_26_exitTextScroll; x260_25_inTextScroll = !x260_26_exitTextScroll;

View File

@ -125,7 +125,7 @@ CIOWin::EMessageReturn CMFGame::OnMessage(const CArchitectureMessage& msg, CArch
if (input.ControllerIdx() == 0) { if (input.ControllerIdx() == 0) {
const CEntity* cam = x14_stateManager->GetCameraManager()->GetCurrentCamera(*x14_stateManager); const CEntity* cam = x14_stateManager->GetCameraManager()->GetCurrentCamera(*x14_stateManager);
TCastToConstPtr<CCinematicCamera> cineCam = cam; TCastToConstPtr<CCinematicCamera> cineCam = cam;
if (input.PStart() || input.PSpecialKey(aurora::SpecialKey::Esc)) { if (input.PStart() || input.PSpecialKey(ESpecialKey::Esc)) {
if (cineCam && x14_stateManager->GetSkipCinematicSpecialFunction() != kInvalidUniqueId) { if (cineCam && x14_stateManager->GetSkipCinematicSpecialFunction() != kInvalidUniqueId) {
CMidiManager::StopAll(); CMidiManager::StopAll();
x28_skippedCineCam = cineCam->GetUniqueId(); x28_skippedCineCam = cineCam->GetUniqueId();
@ -134,7 +134,7 @@ CIOWin::EMessageReturn CMFGame::OnMessage(const CArchitectureMessage& msg, CArch
} else if (!cineCam) { } else if (!cineCam) {
x14_stateManager->DeferStateTransition(EStateManagerTransition::PauseGame); x14_stateManager->DeferStateTransition(EStateManagerTransition::PauseGame);
} }
} else if ((input.PZ() || input.PSpecialKey(aurora::SpecialKey::Tab)) && !cineCam && } else if ((input.PZ() || input.PSpecialKey(ESpecialKey::Tab)) && !cineCam &&
x14_stateManager->CanShowMapScreen()) { x14_stateManager->CanShowMapScreen()) {
x14_stateManager->DeferStateTransition(EStateManagerTransition::MapScreen); x14_stateManager->DeferStateTransition(EStateManagerTransition::MapScreen);
} }

View File

@ -18,7 +18,7 @@ CMessageScreen::CMessageScreen(CAssetId msg, float delayTime) : x74_delayTime(de
void CMessageScreen::ProcessControllerInput(const CFinalInput& input) { void CMessageScreen::ProcessControllerInput(const CFinalInput& input) {
if (!x18_loadedMsgScreen || x74_delayTime > 0.f || if (!x18_loadedMsgScreen || x74_delayTime > 0.f ||
!(input.PA() || input.PSpecialKey(aurora::SpecialKey::Enter) || input.PMouseButton(EMouseButton::Primary))) !(input.PA() || input.PSpecialKey(ESpecialKey::Enter) || input.PMouseButton(EMouseButton::Primary)))
return; return;
if (x1c_textpane_message->TextSupport().GetCurTime() < x1c_textpane_message->TextSupport().GetTotalAnimationTime()) { if (x1c_textpane_message->TextSupport().GetCurTime() < x1c_textpane_message->TextSupport().GetTotalAnimationTime()) {

View File

@ -153,7 +153,7 @@ void COptionsScreen::ProcessControllerInput(const CFinalInput& input) {
CGameOptions::TryRestoreDefaults(input, x70_tablegroup_leftlog->GetUserSelection(), x1c_rightSel, false, CGameOptions::TryRestoreDefaults(input, x70_tablegroup_leftlog->GetUserSelection(), x1c_rightSel, false,
rightClicked); rightClicked);
if (x70_tablegroup_leftlog->GetUserSelection() == 4 && if (x70_tablegroup_leftlog->GetUserSelection() == 4 &&
(input.PA() || leftClicked || input.PSpecialKey(aurora::SpecialKey::Enter))) (input.PA() || leftClicked || input.PSpecialKey(ESpecialKey::Enter)))
x19c_quitGame = std::make_unique<CQuitGameScreen>(EQuitType::QuitGame); x19c_quitGame = std::make_unique<CQuitGameScreen>(EQuitType::QuitGame);
} else { } else {
CPauseScreenBase::ResetMouseState(); CPauseScreenBase::ResetMouseState();

View File

@ -202,7 +202,7 @@ void CPauseScreen::ProcessControllerInput(const CStateManager& mgr, const CFinal
if (InputEnabled()) { if (InputEnabled()) {
bool invalid = x8_curSubscreen == ESubScreen::ToGame; bool invalid = x8_curSubscreen == ESubScreen::ToGame;
if (useInput.PStart() || ((useInput.PB() || useInput.PSpecialKey(aurora::SpecialKey::Esc)) && bExits) || if (useInput.PStart() || ((useInput.PB() || useInput.PSpecialKey(ESpecialKey::Esc)) && bExits) ||
(x7c_screens[x78_activeIdx] && x7c_screens[x78_activeIdx]->ShouldExitPauseScreen())) { (x7c_screens[x78_activeIdx] && x7c_screens[x78_activeIdx]->ShouldExitPauseScreen())) {
CSfxManager::SfxStart(SFXui_pause_screen_exit, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId); CSfxManager::SfxStart(SFXui_pause_screen_exit, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
StartTransition(0.5f, mgr, ESubScreen::ToGame, 2); StartTransition(0.5f, mgr, ESubScreen::ToGame, 2);

View File

@ -353,7 +353,7 @@ void CPlayerVisor::DrawScanEffect(const CStateManager& mgr, CTargetingManager* t
rect.x8_top = int((CGraphics::GetViewportHeight() - vpH) / 2.f); rect.x8_top = int((CGraphics::GetViewportHeight() - vpH) / 2.f);
rect.xc_width = int(vpW); rect.xc_width = int(vpW);
rect.x10_height = int(vpH); rect.x10_height = int(vpH);
CGraphics::ResolveSpareTexture(rect, 0, GX::TF_RGB565); CGraphics::ResolveSpareTexture(rect, 0, GX_TF_RGB565);
{ {
SCOPED_GRAPHICS_DEBUG_GROUP("x64_scanDim Draw", zeus::skMagenta); SCOPED_GRAPHICS_DEBUG_GROUP("x64_scanDim Draw", zeus::skMagenta);
@ -366,7 +366,7 @@ void CPlayerVisor::DrawScanEffect(const CStateManager& mgr, CTargetingManager* t
const zeus::CTransform seventeenScale = zeus::CTransform::Scale(17.f * vpScale, 1.f, 17.f * vpScale); const zeus::CTransform seventeenScale = zeus::CTransform::Scale(17.f * vpScale, 1.f, 17.f * vpScale);
const zeus::CTransform mm = seventeenScale * windowScale; const zeus::CTransform mm = seventeenScale * windowScale;
g_Renderer->SetModelMatrix(mm); g_Renderer->SetModelMatrix(mm);
CGraphics::LoadDolphinSpareTexture(0, GX::TF_RGB565, GX::TEXMAP0); CGraphics::LoadDolphinSpareTexture(0, GX_TF_RGB565, GX_TEXMAP0);
if (x108_newScanPane) { if (x108_newScanPane) {
SCOPED_GRAPHICS_DEBUG_GROUP("x108_newScanPane Draw", zeus::skMagenta); SCOPED_GRAPHICS_DEBUG_GROUP("x108_newScanPane Draw", zeus::skMagenta);

View File

@ -106,7 +106,7 @@ void CQuitGameScreen::ProcessUserInput(const CFinalInput& input) {
x10_loadedFrame->ProcessMouseInput( x10_loadedFrame->ProcessMouseInput(
input, CGuiWidgetDrawParms{1.f, zeus::CVector3f{0.f, 0.f, VerticalOffsets[size_t(x0_type)]}}); input, CGuiWidgetDrawParms{1.f, zeus::CVector3f{0.f, 0.f, VerticalOffsets[size_t(x0_type)]}});
x10_loadedFrame->ProcessUserInput(input); x10_loadedFrame->ProcessUserInput(input);
if ((input.PB() || input.PSpecialKey(aurora::SpecialKey::Esc)) && x0_type != EQuitType::ContinueFromLastSave) { if ((input.PB() || input.PSpecialKey(ESpecialKey::Esc)) && x0_type != EQuitType::ContinueFromLastSave) {
x18_action = EQuitAction::No; x18_action = EQuitAction::No;
} }
} }

View File

@ -332,7 +332,7 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha) {
bool phazonSuit = x44_suit == CPlayerState::EPlayerSuit::Phazon; bool phazonSuit = x44_suit == CPlayerState::EPlayerSuit::Phazon;
if (phazonSuit) { if (phazonSuit) {
GXSetDstAlpha(true, 1.f); GXSetDstAlpha(true, 255);
} }
for (size_t i = 0; i <= x118_suitModel1and2.size(); ++i) { for (size_t i = 0; i <= x118_suitModel1and2.size(); ++i) {

View File

@ -222,18 +222,6 @@ CGameArchitectureSupport::~CGameArchitectureSupport() {
CStreamAudioManager::Shutdown(); CStreamAudioManager::Shutdown();
} }
void CGameArchitectureSupport::charKeyDown(uint8_t charCode, aurora::ModifierKey mods, bool isRepeat) {
// x30_inputGenerator.charKeyDown(charCode, mods, isRepeat);
}
void CGameArchitectureSupport::specialKeyDown(aurora::SpecialKey key, aurora::ModifierKey mods, bool isRepeat) {
// x30_inputGenerator.specialKeyDown(key, mods, isRepeat);
}
void CGameArchitectureSupport::specialKeyUp(aurora::SpecialKey key, aurora::ModifierKey mods) {
// x30_inputGenerator.specialKeyUp(key, mods);
}
CMain::CMain(IFactory* resFactory, CSimplePool* resStore) CMain::CMain(IFactory* resFactory, CSimplePool* resStore)
: xe4_gameplayResult(EGameplayResult::Playing) : xe4_gameplayResult(EGameplayResult::Playing)
, x128_globalObjects(std::make_unique<CGameGlobalObjects>(resFactory, resStore)) { , x128_globalObjects(std::make_unique<CGameGlobalObjects>(resFactory, resStore)) {
@ -518,8 +506,8 @@ void CMain::HandleDiscordErrored(int errorCode, const char* message) {
DiscordLog.report(logvisor::Error, FMT_STRING("Discord Error: {}"), message); DiscordLog.report(logvisor::Error, FMT_STRING("Discord Error: {}"), message);
} }
std::string CMain::Init(const FileStoreManager& storeMgr, CVarManager* cvarMgr, boo::IAudioVoiceEngine* voiceEngine, std::string CMain::Init(int argc, char** argv, const FileStoreManager& storeMgr, CVarManager* cvarMgr,
amuse::IBackendVoiceAllocator& backend) { boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend) {
m_cvarMgr = cvarMgr; m_cvarMgr = cvarMgr;
{ {
@ -607,11 +595,11 @@ std::string CMain::Init(const FileStoreManager& storeMgr, CVarManager* cvarMgr,
x70_tweaks.RegisterResourceTweaks(m_cvarMgr); x70_tweaks.RegisterResourceTweaks(m_cvarMgr);
AddWorldPaks(); AddWorldPaks();
auto args = aurora::get_args(); for (int i = 1; i < argc; ++i) {
for (auto it = args.begin(); it != args.end(); ++it) { std::string arg = argv[i];
if (*it == "--warp" && args.end() - it >= 3) { if (arg == "--warp" && i < argc - 2) {
const char* worldIdxStr = (*(it + 1)).c_str(); const char* worldIdxStr = argv[i + 1];
const char* areaIdxStr = (*(it + 2)).c_str(); const char* areaIdxStr = argv[i + 2];
char* endptr = nullptr; char* endptr = nullptr;
m_warpWorldIdx = TAreaId(strtoul(worldIdxStr, &endptr, 0)); m_warpWorldIdx = TAreaId(strtoul(worldIdxStr, &endptr, 0));
@ -636,8 +624,8 @@ std::string CMain::Init(const FileStoreManager& storeMgr, CVarManager* cvarMgr,
break; break;
} }
while (args.end() - it >= 4) { while (i < argc - 3) {
const char* layerStr = (*(it + 3)).c_str(); const char* layerStr = argv[i + 3];
if (!(layerStr[0] == '0' && layerStr[1] == 'x') && (layerStr[0] == '0' || layerStr[0] == '1')) { if (!(layerStr[0] == '0' && layerStr[1] == 'x') && (layerStr[0] == '0' || layerStr[0] == '1')) {
for (const auto* cur = layerStr; *cur != '\0'; ++cur) for (const auto* cur = layerStr; *cur != '\0'; ++cur)
if (*cur == '1') if (*cur == '1')
@ -645,7 +633,7 @@ std::string CMain::Init(const FileStoreManager& storeMgr, CVarManager* cvarMgr,
} else if (layerStr[0] == '0' && layerStr[1] == 'x') { } else if (layerStr[0] == '0' && layerStr[1] == 'x') {
m_warpMemoryRelays.emplace_back(TAreaId(strtoul(layerStr + 2, nullptr, 16))); m_warpMemoryRelays.emplace_back(TAreaId(strtoul(layerStr + 2, nullptr, 16)));
} }
++it; ++i;
} }
SetFlowState(EClientFlowStates::StateSetter); SetFlowState(EClientFlowStates::StateSetter);

View File

@ -90,6 +90,7 @@ public:
g_SimplePool = xcc_simplePool; g_SimplePool = xcc_simplePool;
g_CharFactoryBuilder = &xec_charFactoryBuilder; g_CharFactoryBuilder = &xec_charFactoryBuilder;
g_AiFuncMap = &x110_aiFuncMap; g_AiFuncMap = &x110_aiFuncMap;
CGraphics::Startup(); // TODO CGraphicsSys
x134_gameState = std::make_unique<CGameState>(); x134_gameState = std::make_unique<CGameState>();
g_GameState = x134_gameState.get(); g_GameState = x134_gameState.get();
g_TweakManager = &x150_tweakManager; g_TweakManager = &x150_tweakManager;
@ -124,46 +125,12 @@ class CGameArchitectureSupport {
EAudioLoadStatus x88_audioLoadStatus = EAudioLoadStatus::Uninitialized; EAudioLoadStatus x88_audioLoadStatus = EAudioLoadStatus::Uninitialized;
std::vector<TToken<CAudioGroupSet>> x8c_pendingAudioGroups; std::vector<TToken<CAudioGroupSet>> x8c_pendingAudioGroups;
aurora::WindowSize m_windowRect;
bool m_rectIsDirty = false;
void destroyed() { x4_archQueue.Push(MakeMsg::CreateRemoveAllIOWins(EArchMsgTarget::IOWinManager)); } void destroyed() { x4_archQueue.Push(MakeMsg::CreateRemoveAllIOWins(EArchMsgTarget::IOWinManager)); }
void resized(const aurora::WindowSize& rect) {
m_windowRect = rect;
m_rectIsDirty = true;
}
public: public:
CGameArchitectureSupport(CMain& parent, boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend); CGameArchitectureSupport(CMain& parent, boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend);
~CGameArchitectureSupport(); ~CGameArchitectureSupport();
void mouseDown(const SWindowCoord& coord, EMouseButton button, EModifierKey mods) {
// x30_inputGenerator.mouseDown(coord, button, mods);
}
void mouseUp(const SWindowCoord& coord, EMouseButton button, EModifierKey mods) {
// x30_inputGenerator.mouseUp(coord, button, mods);
}
void mouseMove(const SWindowCoord& coord) {
// x30_inputGenerator.mouseMove(coord);
}
void scroll(const SWindowCoord& coord, const SScrollDelta& scroll) {
// x30_inputGenerator.scroll(coord, scroll);
}
void charKeyDown(uint8_t charCode, aurora::ModifierKey mods, bool isRepeat);
void charKeyUp(uint8_t charCode, aurora::ModifierKey mods) {
// x30_inputGenerator.charKeyUp(charCode, mods);
}
void specialKeyDown(aurora::SpecialKey key, aurora::ModifierKey mods, bool isRepeat);
void specialKeyUp(aurora::SpecialKey key, aurora::ModifierKey mods);
void modKeyDown(aurora::ModifierKey mod, bool isRepeat) {
// x30_inputGenerator.modKeyDown(mod, isRepeat);
}
void modKeyUp(aurora::ModifierKey mod) {
// x30_inputGenerator.modKeyUp(mod);
}
void PreloadAudio(); void PreloadAudio();
bool LoadAudio(); bool LoadAudio();
void UnloadAudio(); void UnloadAudio();
@ -171,12 +138,6 @@ public:
void Update(float dt); void Update(float dt);
void Draw(); void Draw();
bool isRectDirty() const { return m_rectIsDirty; }
const aurora::WindowSize& getWindowRect() {
m_rectIsDirty = false;
return m_windowRect;
}
CIOWinManager& GetIOWinManager() { return x58_ioWinManager; } CIOWinManager& GetIOWinManager() { return x58_ioWinManager; }
}; };
@ -252,12 +213,11 @@ public:
// int RsMain(int argc, char** argv, boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& // int RsMain(int argc, char** argv, boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator&
// backend); // backend);
std::string Init(const FileStoreManager& storeMgr, CVarManager* cvarManager, boo::IAudioVoiceEngine* voiceEngine, std::string Init(int argc, char** argv, const FileStoreManager& storeMgr, CVarManager* cvarManager,
amuse::IBackendVoiceAllocator& backend) override; boo::IAudioVoiceEngine* voiceEngine, amuse::IBackendVoiceAllocator& backend) override;
bool Proc(float dt) override; bool Proc(float dt) override;
void Draw() override; void Draw() override;
void Shutdown() override; void Shutdown() override;
// boo::IWindow* GetMainWindow() const override;
void MemoryCardInitializePump(); void MemoryCardInitializePump();

View File

@ -91,11 +91,11 @@ void COmegaPirate::CFlash::Render(CStateManager& mgr) {
if (xf0_thermalSpot == nullptr || !xe8_thermalSpotToken) { if (xf0_thermalSpot == nullptr || !xe8_thermalSpotToken) {
return; return;
} }
xf0_thermalSpot->Load(GX::TEXMAP0, EClampMode::Repeat); xf0_thermalSpot->Load(GX_TEXMAP0, EClampMode::Repeat);
float sizeMul = 35.f; float sizeMul = 35.f;
if (visor == CPlayerState::EPlayerVisor::XRay) { if (visor == CPlayerState::EPlayerVisor::XRay) {
CGX::SetBlendMode(GX::BM_SUBTRACT, GX::BL_ONE, GX::BL_ZERO, GX::LO_CLEAR); CGX::SetBlendMode(GX_BM_SUBTRACT, GX_BL_ONE, GX_BL_ZERO, GX_LO_CLEAR);
sizeMul = 60.f; sizeMul = 60.f;
} else { } else {
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::One, ERglLogicOp::Clear); CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::One, ERglLogicOp::Clear);
@ -111,7 +111,7 @@ void COmegaPirate::CFlash::Render(CStateManager& mgr) {
CGraphics::SetTevOp(ERglTevStage::Stage1, CTevCombiners::skPassThru); CGraphics::SetTevOp(ERglTevStage::Stage1, CTevCombiners::skPassThru);
CGraphics::SetDepthWriteMode(false, ERglEnum::Always, false); CGraphics::SetDepthWriteMode(false, ERglEnum::Always, false);
CGraphics::StreamColor(zeus::CColor{1.f, std::min(1.f, size)}); CGraphics::StreamColor(zeus::CColor{1.f, std::min(1.f, size)});
CGraphics::StreamBegin(GX::TRIANGLEFAN); CGraphics::StreamBegin(GX_TRIANGLEFAN);
CGraphics::StreamTexcoord(0.f, 0.f); CGraphics::StreamTexcoord(0.f, 0.f);
CGraphics::StreamVertex(rvS + upVec); CGraphics::StreamVertex(rvS + upVec);
CGraphics::StreamTexcoord(1.f, 0.f); CGraphics::StreamTexcoord(1.f, 0.f);

View File

@ -1386,7 +1386,7 @@ void CThardus::RenderFlare(const CStateManager& mgr, float t) {
if (!x91c_flareTexture) { if (!x91c_flareTexture) {
return; return;
} }
x91c_flareTexture->Load(GX::TEXMAP0, EClampMode::Repeat); x91c_flareTexture->Load(GX_TEXMAP0, EClampMode::Repeat);
const float scale = 30.f * t; const float scale = 30.f * t;
zeus::CVector3f offset = scale * CGraphics::g_ViewMatrix.basis[2]; zeus::CVector3f offset = scale * CGraphics::g_ViewMatrix.basis[2];
@ -1398,7 +1398,7 @@ void CThardus::RenderFlare(const CStateManager& mgr, float t) {
CGraphics::SetTevOp(ERglTevStage::Stage1, CTevCombiners::skPassThru); CGraphics::SetTevOp(ERglTevStage::Stage1, CTevCombiners::skPassThru);
CGraphics::SetDepthWriteMode(false, ERglEnum::Always, false); CGraphics::SetDepthWriteMode(false, ERglEnum::Always, false);
CGraphics::StreamColor({t, t}); CGraphics::StreamColor({t, t});
CGraphics::StreamBegin(GX::TRIANGLEFAN); CGraphics::StreamBegin(GX_TRIANGLEFAN);
CGraphics::StreamTexcoord(0.f, 0.f); CGraphics::StreamTexcoord(0.f, 0.f);
CGraphics::StreamVertex(min + offset); CGraphics::StreamVertex(min + offset);
CGraphics::StreamTexcoord(1.f, 0.f); CGraphics::StreamTexcoord(1.f, 0.f);

View File

@ -913,27 +913,27 @@ void CElementGen::RenderModels() {
CParticle& target = x30_particles[0]; CParticle& target = x30_particles[0];
int partFrame = x74_curFrame - target.x28_startFrame; int partFrame = x74_curFrame - target.x28_startFrame;
cachedTex = texr->GetValueTexture(partFrame).GetObj(); cachedTex = texr->GetValueTexture(partFrame).GetObj();
cachedTex->Load(GX::TEXMAP0, EClampMode::Repeat); cachedTex->Load(GX_TEXMAP0, EClampMode::Repeat);
CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::sTevPass805a5ebc); CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::sTevPass805a5ebc);
if (moveRedToAlphaBuffer) { if (moveRedToAlphaBuffer) {
CGX::SetTevColorIn(GX::TEVSTAGE1, GX::CC_ZERO, GX::CC_CPREV, GX::CC_APREV, GX::CC_ZERO); CGX::SetTevColorIn(GX_TEVSTAGE1, GX_CC_ZERO, GX_CC_CPREV, GX_CC_APREV, GX_CC_ZERO);
CGX::SetTevAlphaIn(GX::TEVSTAGE1, GX::CA_ZERO, GX::CA_TEXA, GX::CA_APREV, GX::CA_ZERO); CGX::SetTevAlphaIn(GX_TEVSTAGE1, GX_CA_ZERO, GX_CA_TEXA, GX_CA_APREV, GX_CA_ZERO);
CGX::SetStandardTevColorAlphaOp(GX::TEVSTAGE1); CGX::SetStandardTevColorAlphaOp(GX_TEVSTAGE1);
CGX::SetTevOrder(GX::TEVSTAGE1, GX::TEXCOORD0, GX::TEXMAP0, GX::COLOR_NULL); CGX::SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL);
GXSetTevSwapMode(GX::TEVSTAGE1, GX::TEV_SWAP0, GX::TEV_SWAP1); GXSetTevSwapMode(GX_TEVSTAGE1, GX_TEV_SWAP0, GX_TEV_SWAP1);
CGX::SetNumTevStages(2); CGX::SetNumTevStages(2);
constexpr std::array vtxDescList{ constexpr std::array vtxDescList{
GX::VtxDescList{GX::VA_POS, GX::DIRECT}, GXVtxDescList{GX_VA_POS, GX_DIRECT},
GX::VtxDescList{GX::VA_CLR0, GX::DIRECT}, GXVtxDescList{GX_VA_CLR0, GX_DIRECT},
GX::VtxDescList{GX::VA_TEX0, GX::DIRECT}, GXVtxDescList{GX_VA_TEX0, GX_DIRECT},
GX::VtxDescList{}, GXVtxDescList{GX_VA_NULL, GX_NONE},
}; };
CGX::SetVtxDescv(vtxDescList.data()); CGX::SetVtxDescv(vtxDescList.data());
CGX::SetChanCtrl(CGX::EChannelId::Channel0, {}); CGX::SetChanCtrl(CGX::EChannelId::Channel0, {});
CGX::SetNumChans(1); CGX::SetNumChans(1);
CGX::SetTexCoordGen(GX::TEXCOORD0, GX::TG_MTX2x4, GX::TG_TEX0, GX::IDENTITY, false, GX::PTIDENTITY); CGX::SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY, false, GX_PTIDENTITY);
CGX::SetTevOrder(GX::TEVSTAGE0, GX::TEXCOORD0, GX::TEXMAP0, GX::COLOR0A0); CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
CGX::SetNumTexGens(1); CGX::SetNumTexGens(1);
} else { } else {
CGraphics::SetTevOp(ERglTevStage::Stage1, CTevCombiners::skPassThru); CGraphics::SetTevOp(ERglTevStage::Stage1, CTevCombiners::skPassThru);
@ -1036,7 +1036,7 @@ void CElementGen::RenderModels() {
if (desc->x45_24_x31_26_PMUS) { if (desc->x45_24_x31_26_PMUS) {
if (moveRedToAlphaBuffer) { if (moveRedToAlphaBuffer) {
CGX::Begin(GX::QUADS, GX::VTXFMT0, 4); CGX::Begin(GX_QUADS, GX_VTXFMT0, 4);
GXPosition3f32(0.5f, 0.f, 0.5f); GXPosition3f32(0.5f, 0.f, 0.5f);
GXColor4f32(col); GXColor4f32(col);
GXTexCoord2f32(uvs.xMax, uvs.yMax); GXTexCoord2f32(uvs.xMax, uvs.yMax);
@ -1051,7 +1051,7 @@ void CElementGen::RenderModels() {
GXTexCoord2f32(uvs.xMax, uvs.yMin); GXTexCoord2f32(uvs.xMax, uvs.yMin);
CGX::End(); CGX::End();
} else { } else {
CGraphics::StreamBegin(GX::QUADS); CGraphics::StreamBegin(GX_QUADS);
CGraphics::StreamColor(col); CGraphics::StreamColor(col);
CGraphics::StreamTexcoord(uvs.xMax, uvs.yMax); CGraphics::StreamTexcoord(uvs.xMax, uvs.yMax);
CGraphics::StreamVertex(0.5f, 0.f, 0.5f); CGraphics::StreamVertex(0.5f, 0.f, 0.5f);
@ -1087,7 +1087,7 @@ void CElementGen::RenderModels() {
CGraphics::SetCullMode(ERglCullMode::Front); CGraphics::SetCullMode(ERglCullMode::Front);
CTevCombiners::ResetStates(); CTevCombiners::ResetStates();
if (moveRedToAlphaBuffer) { if (moveRedToAlphaBuffer) {
GXSetTevSwapMode(GX::TEVSTAGE1, GX::TEV_SWAP0, GX::TEV_SWAP0); GXSetTevSwapMode(GX_TEVSTAGE1, GX_TEV_SWAP0, GX_TEV_SWAP0);
} }
CGraphics::SetAlphaCompare(ERglAlphaFunc::Always, 0, ERglAlphaOp::And, ERglAlphaFunc::Always, 0); CGraphics::SetAlphaCompare(ERglAlphaFunc::Always, 0, ERglAlphaOp::And, ERglAlphaFunc::Always, 0);
} }
@ -1132,7 +1132,7 @@ void CElementGen::RenderLines() {
CParticle& target = x30_particles[0]; CParticle& target = x30_particles[0];
int partFrame = x74_curFrame - target.x28_startFrame; int partFrame = x74_curFrame - target.x28_startFrame;
cachedTex = texr->GetValueTexture(partFrame).GetObj(); cachedTex = texr->GetValueTexture(partFrame).GetObj();
cachedTex->Load(GX::TEXMAP0, EClampMode::Repeat); cachedTex->Load(GX_TEXMAP0, EClampMode::Repeat);
/* Set TEXC * RASC */ /* Set TEXC * RASC */
@ -1162,7 +1162,7 @@ void CElementGen::RenderLines() {
if (!constTexr) { if (!constTexr) {
CTexture* tex = texr->GetValueTexture(partFrame).GetObj(); CTexture* tex = texr->GetValueTexture(partFrame).GetObj();
if (tex != cachedTex) { if (tex != cachedTex) {
tex->Load(GX::TEXMAP0, EClampMode::Repeat); tex->Load(GX_TEXMAP0, EClampMode::Repeat);
cachedTex = tex; cachedTex = tex;
} }
} }
@ -1253,7 +1253,7 @@ void CElementGen::RenderParticles() {
CParticle& target = x30_particles[0]; CParticle& target = x30_particles[0];
int partFrame = x74_curFrame - target.x28_startFrame; int partFrame = x74_curFrame - target.x28_startFrame;
cachedTex = texr->GetValueTexture(partFrame).GetObj(); cachedTex = texr->GetValueTexture(partFrame).GetObj();
cachedTex->Load(GX::TEXMAP0, EClampMode::Repeat); cachedTex->Load(GX_TEXMAP0, EClampMode::Repeat);
CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::sTevPass805a5ebc); CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::sTevPass805a5ebc);
if (hasModuColor) { if (hasModuColor) {
@ -1271,46 +1271,46 @@ void CElementGen::RenderParticles() {
} }
constexpr std::array vtxDescList{ constexpr std::array vtxDescList{
GX::VtxDescList{GX::VA_POS, GX::DIRECT}, GXVtxDescList{GX_VA_POS, GX_DIRECT},
GX::VtxDescList{GX::VA_CLR0, GX::DIRECT}, GXVtxDescList{GX_VA_CLR0, GX_DIRECT},
GX::VtxDescList{GX::VA_TEX0, GX::DIRECT}, GXVtxDescList{GX_VA_TEX0, GX_DIRECT},
GX::VtxDescList{}, GXVtxDescList{GX_VA_NULL, GX_NONE},
}; };
CGX::SetVtxDescv(vtxDescList.data()); CGX::SetVtxDescv(vtxDescList.data());
GX::TevStageID nextStage; GXTevStageID nextStage;
if (hasModuColor) { if (hasModuColor) {
CGX::SetNumChans(2); CGX::SetNumChans(2);
nextStage = GX::TEVSTAGE2; nextStage = GX_TEVSTAGE2;
CGX::SetTevOrder(GX::TEVSTAGE1, GX::TEXCOORD_NULL, GX::TEXMAP_NULL, GX::COLOR1A1); CGX::SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR1A1);
CGX::SetChanAmbColor(CGX::EChannelId::Channel1, zeus::skBlack); CGX::SetChanAmbColor(CGX::EChannelId::Channel1, zeus::skBlack);
CGX::SetChanMatColor(CGX::EChannelId::Channel1, x338_moduColor); CGX::SetChanMatColor(CGX::EChannelId::Channel1, x338_moduColor);
CGX::SetChanCtrl(CGX::EChannelId::Channel1, {}); CGX::SetChanCtrl(CGX::EChannelId::Channel1, {});
} else { } else {
CGX::SetNumChans(1); CGX::SetNumChans(1);
nextStage = GX::TEVSTAGE1; nextStage = GX_TEVSTAGE1;
} }
bool moveRedToAlphaBuffer = sMoveRedToAlphaBuffer; bool moveRedToAlphaBuffer = sMoveRedToAlphaBuffer;
if (g_subtractBlend) { if (g_subtractBlend) {
CGraphics::SetDepthWriteMode(x26c_28_zTest, ERglEnum::LEqual, false); CGraphics::SetDepthWriteMode(x26c_28_zTest, ERglEnum::LEqual, false);
CGX::SetBlendMode(GX::BM_SUBTRACT, GX::BL_ONE, GX::BL_ZERO, GX::LO_CLEAR); CGX::SetBlendMode(GX_BM_SUBTRACT, GX_BL_ONE, GX_BL_ZERO, GX_LO_CLEAR);
if (moveRedToAlphaBuffer) { if (moveRedToAlphaBuffer) {
CGX::SetTevColorIn(nextStage, GX::CC_ZERO, GX::CC_CPREV, GX::CC_APREV, GX::CC_ZERO); CGX::SetTevColorIn(nextStage, GX_CC_ZERO, GX_CC_CPREV, GX_CC_APREV, GX_CC_ZERO);
CGX::SetTevAlphaIn(nextStage, GX::CA_ZERO, GX::CA_TEXA, GX::CA_APREV, GX::CA_ZERO); CGX::SetTevAlphaIn(nextStage, GX_CA_ZERO, GX_CA_TEXA, GX_CA_APREV, GX_CA_ZERO);
CGX::SetStandardTevColorAlphaOp(nextStage); CGX::SetStandardTevColorAlphaOp(nextStage);
CGX::SetTevOrder(nextStage, GX::TEXCOORD0, GX::TEXMAP0, GX::COLOR_NULL); CGX::SetTevOrder(nextStage, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL);
GXSetTevSwapMode(nextStage, GX::TEV_SWAP0, GX::TEV_SWAP1); GXSetTevSwapMode(nextStage, GX_TEV_SWAP0, GX_TEV_SWAP1);
nextStage = GX::TevStageID(nextStage + 1); nextStage = GXTevStageID(nextStage + 1);
} }
} else if (moveRedToAlphaBuffer) { } else if (moveRedToAlphaBuffer) {
CGraphics::SetDepthWriteMode(x26c_28_zTest, ERglEnum::LEqual, false); CGraphics::SetDepthWriteMode(x26c_28_zTest, ERglEnum::LEqual, false);
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::One, ERglBlendFactor::One, ERglLogicOp::Clear); CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::One, ERglBlendFactor::One, ERglLogicOp::Clear);
CGX::SetTevColorIn(nextStage, GX::CC_ZERO, GX::CC_CPREV, GX::CC_APREV, GX::CC_ZERO); CGX::SetTevColorIn(nextStage, GX_CC_ZERO, GX_CC_CPREV, GX_CC_APREV, GX_CC_ZERO);
CGX::SetTevAlphaIn(nextStage, GX::CA_ZERO, GX::CA_TEXA, GX::CA_APREV, GX::CA_ZERO); CGX::SetTevAlphaIn(nextStage, GX_CA_ZERO, GX_CA_TEXA, GX_CA_APREV, GX_CA_ZERO);
CGX::SetStandardTevColorAlphaOp(nextStage); CGX::SetStandardTevColorAlphaOp(nextStage);
CGX::SetTevOrder(nextStage, GX::TEXCOORD0, GX::TEXMAP0, GX::COLOR_NULL); CGX::SetTevOrder(nextStage, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL);
GXSetTevSwapMode(nextStage, GX::TEV_SWAP0, GX::TEV_SWAP1); GXSetTevSwapMode(nextStage, GX_TEV_SWAP0, GX_TEV_SWAP1);
nextStage = GX::TevStageID(nextStage + 1); nextStage = GXTevStageID(nextStage + 1);
} else if (x26c_26_AAPH) { } else if (x26c_26_AAPH) {
CGraphics::SetDepthWriteMode(x26c_28_zTest, ERglEnum::LEqual, false); CGraphics::SetDepthWriteMode(x26c_28_zTest, ERglEnum::LEqual, false);
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::One, ERglLogicOp::Clear); CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, ERglBlendFactor::One, ERglLogicOp::Clear);
@ -1321,22 +1321,22 @@ void CElementGen::RenderParticles() {
} }
CGX::SetNumTevStages(nextStage); CGX::SetNumTevStages(nextStage);
CGX::SetNumTexGens(1); CGX::SetNumTexGens(1);
CGX::SetTevOrder(GX::TEVSTAGE0, GX::TEXCOORD0, GX::TEXMAP0, GX::COLOR0A0); CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
CGX::SetChanCtrl(CGX::EChannelId::Channel0, false, GX::SRC_REG, GX::SRC_VTX, {}, GX::DF_NONE, GX::AF_NONE); CGX::SetChanCtrl(CGX::EChannelId::Channel0, false, GX_SRC_REG, GX_SRC_VTX, {}, GX_DF_NONE, GX_AF_NONE);
CGX::SetTexCoordGen(GX::TEXCOORD0, GX::TG_MTX2x4, GX::TG_TEX0, GX::IDENTITY, false, GX::PTIDENTITY); CGX::SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY, false, GX_PTIDENTITY);
GXSetVtxAttrFmt(GX::VTXFMT6, GX::VA_POS, GX::POS_XYZ, GX::F32, 0); GXSetVtxAttrFmt(GX_VTXFMT6, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
GXSetVtxAttrFmt(GX::VTXFMT6, GX::VA_CLR0, GX::CLR_RGBA, GX::RGBA8, 0); GXSetVtxAttrFmt(GX_VTXFMT6, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
if (constUVs) { if (constUVs) {
GXSetVtxAttrFmt(GX::VTXFMT6, GX::VA_TEX0, GX::TEX_ST, GX::RGBA8, 1); GXSetVtxAttrFmt(GX_VTXFMT6, GX_VA_TEX0, GX_TEX_ST, GX_RGBA8, 1);
} else { } else {
GXSetVtxAttrFmt(GX::VTXFMT6, GX::VA_TEX0, GX::TEX_ST, GX::F32, 0); GXSetVtxAttrFmt(GX_VTXFMT6, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
} }
int mbspVal = std::max(1, x270_MBSP); int mbspVal = std::max(1, x270_MBSP);
if (x26c_30_MBLR) { if (x26c_30_MBLR) {
CGX::Begin(GX::QUADS, GX::VTXFMT6, mbspVal * x30_particles.size() * 4); CGX::Begin(GX_QUADS, GX_VTXFMT6, mbspVal * x30_particles.size() * 4);
} else { } else {
CGX::Begin(GX::QUADS, GX::VTXFMT6, mbspVal * 4); CGX::Begin(GX_QUADS, GX_VTXFMT6, mbspVal * 4);
} }
std::vector<CParticleListItem> sortItems; std::vector<CParticleListItem> sortItems;
@ -1629,7 +1629,7 @@ void CElementGen::RenderParticles() {
CGX::End(); CGX::End();
if (moveRedToAlphaBuffer) { if (moveRedToAlphaBuffer) {
GXSetTevSwapMode(GX::TevStageID(nextStage - 1), GX::TEV_SWAP0, GX::TEV_SWAP0); GXSetTevSwapMode(GXTevStageID(nextStage - 1), GX_TEV_SWAP0, GX_TEV_SWAP0);
} }
CGraphics::SetCullMode(ERglCullMode::Front); CGraphics::SetCullMode(ERglCullMode::Front);
CGraphics::SetAlphaCompare(ERglAlphaFunc::Always, 0, ERglAlphaOp::And, ERglAlphaFunc::Always, 0); CGraphics::SetAlphaCompare(ERglAlphaFunc::Always, 0, ERglAlphaOp::And, ERglAlphaFunc::Always, 0);
@ -1668,7 +1668,7 @@ void CElementGen::RenderParticlesIndirectTexture() {
CParticle& firstParticle = x30_particles[0]; CParticle& firstParticle = x30_particles[0];
int partFrame = x74_curFrame - firstParticle.x28_startFrame; int partFrame = x74_curFrame - firstParticle.x28_startFrame;
CTexture* cachedTex = texr->GetValueTexture(partFrame).GetObj(); CTexture* cachedTex = texr->GetValueTexture(partFrame).GetObj();
cachedTex->Load(GX::TEXMAP0, EClampMode::Repeat); cachedTex->Load(GX_TEXMAP0, EClampMode::Repeat);
SUVElementSet uvs = {0.f, 0.f, 1.f, 1.f}; SUVElementSet uvs = {0.f, 0.f, 1.f, 1.f};
bool constTexr = texr->HasConstantTexture(); bool constTexr = texr->HasConstantTexture();
@ -1677,7 +1677,7 @@ void CElementGen::RenderParticlesIndirectTexture() {
CUVElement* tind = desc->x58_x44_TIND.get(); CUVElement* tind = desc->x58_x44_TIND.get();
CTexture* cachedIndTex = tind->GetValueTexture(partFrame).GetObj(); CTexture* cachedIndTex = tind->GetValueTexture(partFrame).GetObj();
cachedIndTex->Load(GX::TEXMAP2, EClampMode::Repeat); cachedIndTex->Load(GX_TEXMAP2, EClampMode::Repeat);
SUVElementSet uvsInd = {0.f, 0.f, 1.f, 1.f}; SUVElementSet uvsInd = {0.f, 0.f, 1.f, 1.f};
bool constIndTexr = tind->HasConstantTexture(); bool constIndTexr = tind->HasConstantTexture();
@ -1724,7 +1724,7 @@ void CElementGen::RenderParticlesIndirectTexture() {
if (!constTexr) { if (!constTexr) {
CTexture* tex = texr->GetValueTexture(thisPartFrame).GetObj(); CTexture* tex = texr->GetValueTexture(thisPartFrame).GetObj();
if (tex != cachedTex) { if (tex != cachedTex) {
tex->Load(GX::TEXMAP0, EClampMode::Repeat); tex->Load(GX_TEXMAP0, EClampMode::Repeat);
cachedTex = tex; cachedTex = tex;
} }
} }
@ -1732,7 +1732,7 @@ void CElementGen::RenderParticlesIndirectTexture() {
if (!constIndTexr) { if (!constIndTexr) {
CTexture* tex = tind->GetValueTexture(thisPartFrame).GetObj(); CTexture* tex = tind->GetValueTexture(thisPartFrame).GetObj();
if (tex != cachedIndTex) { if (tex != cachedIndTex) {
tex->Load(GX::TEXMAP2, EClampMode::Repeat); tex->Load(GX_TEXMAP2, EClampMode::Repeat);
cachedIndTex = tex; cachedIndTex = tex;
} }
} }

View File

@ -93,22 +93,22 @@ void CParticleElectric::SetupLineGXMaterial() {
void CParticleElectric::DrawLineStrip(const std::vector<zeus::CVector3f>& verts, float width, void CParticleElectric::DrawLineStrip(const std::vector<zeus::CVector3f>& verts, float width,
const zeus::CColor& color) { const zeus::CColor& color) {
const size_t useIdx = m_nextLineRenderer; // const size_t useIdx = m_nextLineRenderer;
if (++m_nextLineRenderer > m_lineRenderers.size()) { // if (++m_nextLineRenderer > m_lineRenderers.size()) {
m_lineRenderers.resize(m_nextLineRenderer); // m_lineRenderers.resize(m_nextLineRenderer);
} // }
if (!m_lineRenderers[useIdx]) { // if (!m_lineRenderers[useIdx]) {
m_lineRenderers[useIdx] = std::make_unique<CLineRenderer>(CLineRenderer::EPrimitiveMode::LineStrip, x150_SSEG, // m_lineRenderers[useIdx] = std::make_unique<CLineRenderer>(CLineRenderer::EPrimitiveMode::LineStrip, x150_SSEG,
aurora::gfx::TextureHandle{}, true, true); // aurora::gfx::TextureHandle{}, true, true);
} // }
CLineRenderer& renderer = *m_lineRenderers[useIdx]; // CLineRenderer& renderer = *m_lineRenderers[useIdx];
const zeus::CColor useColor = x1b8_moduColor * color; // const zeus::CColor useColor = x1b8_moduColor * color;
//
renderer.Reset(); // renderer.Reset();
for (const zeus::CVector3f& vert : verts) { // for (const zeus::CVector3f& vert : verts) {
renderer.AddVertex(vert, useColor, width); // renderer.AddVertex(vert, useColor, width);
} // }
renderer.Render(); // g_Renderer->IsThermalVisorHotPass() // renderer.Render(); // g_Renderer->IsThermalVisorHotPass()
} }
void CParticleElectric::RenderLines() { void CParticleElectric::RenderLines() {

View File

@ -306,10 +306,10 @@ int CParticleSwoosh::WrapIndex(int i) const {
void CParticleSwoosh::RenderNSidedSpline() { void CParticleSwoosh::RenderNSidedSpline() {
if (x1c_desc->x44_29_WIRE) { if (x1c_desc->x44_29_WIRE) {
x1bc_prim = GX::LINES; x1bc_prim = GX_LINES;
m_lineRenderer->Reset(); m_lineRenderer->Reset();
} else { } else {
x1bc_prim = GX::QUADS; x1bc_prim = GX_QUADS;
} }
bool cros = x1c_desc->x44_25_CROS; bool cros = x1c_desc->x44_25_CROS;
@ -444,7 +444,7 @@ void CParticleSwoosh::RenderNSidedSpline() {
const auto v2 = GetSplinePoint(x16c_p0[otherK], x17c_p1[otherK], x18c_p2[otherK], x19c_p3[otherK], t1); const auto v2 = GetSplinePoint(x16c_p0[otherK], x17c_p1[otherK], x18c_p2[otherK], x19c_p3[otherK], t1);
const auto v3 = GetSplinePoint(x16c_p0[k], x17c_p1[k], x18c_p2[k], x19c_p3[k], t1); const auto v3 = GetSplinePoint(x16c_p0[k], x17c_p1[k], x18c_p2[k], x19c_p3[k], t1);
if (x1bc_prim == GX::LINES) { if (x1bc_prim == GX_LINES) {
m_lineRenderer->AddVertex(v0, color, 1.f); m_lineRenderer->AddVertex(v0, color, 1.f);
m_lineRenderer->AddVertex(v1, color, 1.f); m_lineRenderer->AddVertex(v1, color, 1.f);
m_lineRenderer->AddVertex(v1, color, 1.f); m_lineRenderer->AddVertex(v1, color, 1.f);
@ -457,7 +457,7 @@ void CParticleSwoosh::RenderNSidedSpline() {
m_lineRenderer->AddVertex(v3, color, 1.f); m_lineRenderer->AddVertex(v3, color, 1.f);
m_lineRenderer->AddVertex(v3, color, 1.f); m_lineRenderer->AddVertex(v3, color, 1.f);
m_lineRenderer->AddVertex(v0, color, 1.f); m_lineRenderer->AddVertex(v0, color, 1.f);
} else if (x1bc_prim == GX::QUADS) { } else if (x1bc_prim == GX_QUADS) {
m_cachedVerts.push_back({v0, {x1d4_uvs.xMin, x1d4_uvs.yMin}, color}); m_cachedVerts.push_back({v0, {x1d4_uvs.xMin, x1d4_uvs.yMin}, color});
m_cachedVerts.push_back({v1, {x1d4_uvs.xMin, x1d4_uvs.yMax}, color}); m_cachedVerts.push_back({v1, {x1d4_uvs.xMin, x1d4_uvs.yMax}, color});
m_cachedVerts.push_back({v2, {x1d4_uvs.xMax, x1d4_uvs.yMin}, color}); m_cachedVerts.push_back({v2, {x1d4_uvs.xMax, x1d4_uvs.yMin}, color});
@ -478,7 +478,7 @@ void CParticleSwoosh::RenderNSidedSpline() {
} }
} }
if (x1bc_prim == GX::LINES) { if (x1bc_prim == GX_LINES) {
// m_lineRenderer->Render(g_Renderer->IsThermalVisorHotPass()); // m_lineRenderer->Render(g_Renderer->IsThermalVisorHotPass());
} }
} }

View File

@ -78,7 +78,7 @@ private:
int x1b0_SPLN = 0; int x1b0_SPLN = 0;
int x1b4_LENG = 0; int x1b4_LENG = 0;
int x1b8_SIDE = 0; int x1b8_SIDE = 0;
GX::Primitive x1bc_prim{}; GXPrimitive x1bc_prim{};
CRandom16 x1c0_rand; CRandom16 x1c0_rand;
float x1c4_ = 0.f; float x1c4_ = 0.f;
float x1c8_ = 0.f; float x1c8_ = 0.f;

View File

@ -12,16 +12,16 @@
namespace metaforce { namespace metaforce {
CPlasmaProjectile::RenderObjects::RenderObjects(aurora::gfx::TextureHandle tex, aurora::gfx::TextureHandle glowTex) //CPlasmaProjectile::RenderObjects::RenderObjects(aurora::gfx::TextureHandle tex, aurora::gfx::TextureHandle glowTex)
: m_beamStrip1(8, CColoredStripShader::Mode::Additive, {}) //: m_beamStrip1(8, CColoredStripShader::Mode::Additive, {})
, m_beamStrip2(10, CColoredStripShader::Mode::FullAdditive, tex) //, m_beamStrip2(10, CColoredStripShader::Mode::FullAdditive, tex)
, m_beamStrip3(18, CColoredStripShader::Mode::FullAdditive, tex) //, m_beamStrip3(18, CColoredStripShader::Mode::FullAdditive, tex)
, m_beamStrip4(14, CColoredStripShader::Mode::Additive, glowTex) //, m_beamStrip4(14, CColoredStripShader::Mode::Additive, glowTex)
, m_beamStrip1Sub(8, CColoredStripShader::Mode::Subtractive, {}) //, m_beamStrip1Sub(8, CColoredStripShader::Mode::Subtractive, {})
, m_beamStrip2Sub(10, CColoredStripShader::Mode::Subtractive, tex) //, m_beamStrip2Sub(10, CColoredStripShader::Mode::Subtractive, tex)
, m_beamStrip3Sub(18, CColoredStripShader::Mode::Subtractive, tex) //, m_beamStrip3Sub(18, CColoredStripShader::Mode::Subtractive, tex)
, m_beamStrip4Sub(14, CColoredStripShader::Mode::Subtractive, glowTex) //, m_beamStrip4Sub(14, CColoredStripShader::Mode::Subtractive, glowTex)
, m_motionBlurStrip(16, CColoredStripShader::Mode::Alpha, {}) {} //, m_motionBlurStrip(16, CColoredStripShader::Mode::Alpha, {}) {}
CPlasmaProjectile::CPlasmaProjectile(const TToken<CWeaponDescription>& wDesc, std::string_view name, EWeaponType wType, CPlasmaProjectile::CPlasmaProjectile(const TToken<CWeaponDescription>& wDesc, std::string_view name, EWeaponType wType,
const CBeamInfo& bInfo, const zeus::CTransform& xf, EMaterialTypes matType, const CBeamInfo& bInfo, const zeus::CTransform& xf, EMaterialTypes matType,
@ -148,7 +148,7 @@ void CPlasmaProjectile::RenderMotionBlur() {
v2.m_pos = GetPointCache()[i]; v2.m_pos = GetPointCache()[i];
v2.m_color = v1.m_color; v2.m_color = v1.m_color;
} }
m_renderObjs->m_motionBlurStrip.draw(zeus::skWhite, verts.size(), verts.data()); // m_renderObjs->m_motionBlurStrip.draw(zeus::skWhite, verts.size(), verts.data());
} }
void CPlasmaProjectile::RenderBeam(s32 subdivs, float width, const zeus::CColor& color, s32 flags, void CPlasmaProjectile::RenderBeam(s32 subdivs, float width, const zeus::CColor& color, s32 flags,
@ -401,6 +401,8 @@ void CPlasmaProjectile::AddToRenderer(const zeus::CFrustum& frustum, CStateManag
void CPlasmaProjectile::Render(CStateManager& mgr) { void CPlasmaProjectile::Render(CStateManager& mgr) {
if (!GetActive()) if (!GetActive())
return; return;
// TODO
SCOPED_GRAPHICS_DEBUG_GROUP("CPlasmaProjectile::Render", zeus::skOrange); SCOPED_GRAPHICS_DEBUG_GROUP("CPlasmaProjectile::Render", zeus::skOrange);
zeus::CTransform xf = GetBeamTransform(); zeus::CTransform xf = GetBeamTransform();
@ -418,23 +420,23 @@ void CPlasmaProjectile::Render(CStateManager& mgr) {
// Pass1: alpha-controlled additive // Pass1: alpha-controlled additive
CGraphics::SetModelMatrix(xf); CGraphics::SetModelMatrix(xf);
RenderBeam(3, 0.25f * x4b8_beamWidth, zeus::CColor(1.f, 0.3f), flags | 0x4, // RenderBeam(3, 0.25f * x4b8_beamWidth, zeus::CColor(1.f, 0.3f), flags | 0x4,
(flags & 0x10) ? m_renderObjs->m_beamStrip1Sub : m_renderObjs->m_beamStrip1); // (flags & 0x10) ? m_renderObjs->m_beamStrip1Sub : m_renderObjs->m_beamStrip1);
// Pass2: textured // Pass2: textured
CGraphics::SetModelMatrix(xf * zeus::CTransform::RotateY(zeus::degToRad(x4c8_beamAngle))); CGraphics::SetModelMatrix(xf * zeus::CTransform::RotateY(zeus::degToRad(x4c8_beamAngle)));
RenderBeam(4, 0.5f * x4b8_beamWidth, x490_innerColor, flags | 0x1, // RenderBeam(4, 0.5f * x4b8_beamWidth, x490_innerColor, flags | 0x1,
(flags & 0x10) ? m_renderObjs->m_beamStrip2Sub : m_renderObjs->m_beamStrip2); // (flags & 0x10) ? m_renderObjs->m_beamStrip2Sub : m_renderObjs->m_beamStrip2);
// Pass3: textured | length-controlled UVY // Pass3: textured | length-controlled UVY
CGraphics::SetModelMatrix(xf * zeus::CTransform::RotateY(zeus::degToRad(-x4c8_beamAngle))); CGraphics::SetModelMatrix(xf * zeus::CTransform::RotateY(zeus::degToRad(-x4c8_beamAngle)));
RenderBeam(8, x4b8_beamWidth, x494_outerColor, flags | 0x3, // RenderBeam(8, x4b8_beamWidth, x494_outerColor, flags | 0x3,
(flags & 0x10) ? m_renderObjs->m_beamStrip3Sub : m_renderObjs->m_beamStrip3); // (flags & 0x10) ? m_renderObjs->m_beamStrip3Sub : m_renderObjs->m_beamStrip3);
// Pass4: textured | alpha-controlled additive | glow texture // Pass4: textured | alpha-controlled additive | glow texture
CGraphics::SetModelMatrix(xf); CGraphics::SetModelMatrix(xf);
RenderBeam(6, 1.25f * x4b8_beamWidth, x494_outerColor, flags | 0xd, // RenderBeam(6, 1.25f * x4b8_beamWidth, x494_outerColor, flags | 0xd,
(flags & 0x10) ? m_renderObjs->m_beamStrip4Sub : m_renderObjs->m_beamStrip4); // (flags & 0x10) ? m_renderObjs->m_beamStrip4Sub : m_renderObjs->m_beamStrip4);
} }
} // namespace metaforce } // namespace metaforce

View File

@ -81,19 +81,19 @@ private:
bool x548_28_drawOwnerFirst : 1; bool x548_28_drawOwnerFirst : 1;
bool x548_29_activePlayerPhazon : 1 = false; bool x548_29_activePlayerPhazon : 1 = false;
struct RenderObjects { // struct RenderObjects {
CColoredStripShader m_beamStrip1; // CColoredStripShader m_beamStrip1;
CColoredStripShader m_beamStrip2; // CColoredStripShader m_beamStrip2;
CColoredStripShader m_beamStrip3; // CColoredStripShader m_beamStrip3;
CColoredStripShader m_beamStrip4; // CColoredStripShader m_beamStrip4;
CColoredStripShader m_beamStrip1Sub; // CColoredStripShader m_beamStrip1Sub;
CColoredStripShader m_beamStrip2Sub; // CColoredStripShader m_beamStrip2Sub;
CColoredStripShader m_beamStrip3Sub; // CColoredStripShader m_beamStrip3Sub;
CColoredStripShader m_beamStrip4Sub; // CColoredStripShader m_beamStrip4Sub;
CColoredStripShader m_motionBlurStrip; // CColoredStripShader m_motionBlurStrip;
RenderObjects(aurora::gfx::TextureHandle tex, aurora::gfx::TextureHandle glowTex); // RenderObjects(CTexture& tex, CTexture& glowTex);
}; // };
std::optional<RenderObjects> m_renderObjs; // std::optional<RenderObjects> m_renderObjs;
void SetLightsActive(bool active, CStateManager& mgr); void SetLightsActive(bool active, CStateManager& mgr);
void CreatePlasmaLights(u32 sourceId, const CLight& l, CStateManager& mgr); void CreatePlasmaLights(u32 sourceId, const CLight& l, CStateManager& mgr);

View File

@ -2134,7 +2134,7 @@ zeus::CVector3f CPlayerGun::ConvertToScreenSpace(const zeus::CVector3f& pos, con
void CPlayerGun::CopyScreenTex() { void CPlayerGun::CopyScreenTex() {
// Copy lower right quadrant to gpCopyTexBuf as RGBA8 // Copy lower right quadrant to gpCopyTexBuf as RGBA8
// GXSetTexCopySrc(320, 224, 320, 224); // GXSetTexCopySrc(320, 224, 320, 224);
// GXSetTexCopyDst(320, 224, GX::TF_RGBA8, false); // GXSetTexCopyDst(320, 224, GX_TF_RGBA8, false);
// GXCopyTex(sSpareTextureData, false); // GXCopyTex(sSpareTextureData, false);
// GXPixModeSync(); // GXPixModeSync();
SViewport viewport = CGraphics::g_Viewport; SViewport viewport = CGraphics::g_Viewport;
@ -2144,7 +2144,7 @@ void CPlayerGun::CopyScreenTex() {
viewport.x4_top = viewport.xc_height; viewport.x4_top = viewport.xc_height;
viewport.x10_halfWidth *= 0.5f; viewport.x10_halfWidth *= 0.5f;
viewport.x14_halfHeight *= 0.5f; viewport.x14_halfHeight *= 0.5f;
CGraphics::ResolveSpareTexture(viewport, 2, GX::TF_RGBA8, false); CGraphics::ResolveSpareTexture(viewport, 2, GX_TF_RGBA8, false);
} }
void CPlayerGun::DrawScreenTex(float z) { void CPlayerGun::DrawScreenTex(float z) {
@ -2156,19 +2156,19 @@ void CPlayerGun::DrawScreenTex(float z) {
g_Renderer->SetViewportOrtho(false, -1.f, 1.f); g_Renderer->SetViewportOrtho(false, -1.f, 1.f);
g_Renderer->SetBlendMode_AlphaBlended(); g_Renderer->SetBlendMode_AlphaBlended();
CGraphics::SetDepthWriteMode(true, ERglEnum::GEqual, true); CGraphics::SetDepthWriteMode(true, ERglEnum::GEqual, true);
CGraphics::LoadDolphinSpareTexture(2, GX::TF_RGBA8, GX::TEXMAP7); CGraphics::LoadDolphinSpareTexture(2, GX_TF_RGBA8, GX_TEXMAP7);
constexpr std::array vtxDescList{ constexpr std::array vtxDescList{
GX::VtxDescList{GX::VA_POS, GX::DIRECT}, GXVtxDescList{GX_VA_POS, GX_DIRECT},
GX::VtxDescList{GX::VA_TEX0, GX::DIRECT}, GXVtxDescList{GX_VA_TEX0, GX_DIRECT},
GX::VtxDescList{}, GXVtxDescList{GX_VA_NULL, GX_NONE},
}; };
CGX::SetVtxDescv(vtxDescList.data()); CGX::SetVtxDescv(vtxDescList.data());
CGX::SetNumChans(0); CGX::SetNumChans(0);
CGX::SetNumTexGens(1); CGX::SetNumTexGens(1);
CGX::SetNumTevStages(1); CGX::SetNumTevStages(1);
CGX::SetTevOrder(GX::TEVSTAGE0, GX::TEXCOORD0, GX::TEXMAP7, GX::COLOR_NULL); CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP7, GX_COLOR_NULL);
CGX::SetChanCtrl(CGX::EChannelId::Channel0, false, GX::SRC_REG, GX::SRC_REG, {}, GX::DF_NONE, GX::AF_NONE); CGX::SetChanCtrl(CGX::EChannelId::Channel0, false, GX_SRC_REG, GX_SRC_REG, {}, GX_DF_NONE, GX_AF_NONE);
CGX::Begin(GX::TRIANGLESTRIP, GX::VTXFMT0, 4); CGX::Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 4);
GXPosition3f32(CGraphics::g_Viewport.x10_halfWidth, z, 0.f); GXPosition3f32(CGraphics::g_Viewport.x10_halfWidth, z, 0.f);
GXTexCoord2f32(0.f, 1.f); GXTexCoord2f32(0.f, 1.f);
GXPosition3f32(CGraphics::g_Viewport.x8_width, z, 0.f); GXPosition3f32(CGraphics::g_Viewport.x8_width, z, 0.f);

View File

@ -75,7 +75,7 @@ protected:
bool xe7_30_doTargetDistanceTest : 1 = true; bool xe7_30_doTargetDistanceTest : 1 = true;
bool xe7_31_targetable : 1 = true; bool xe7_31_targetable : 1 = true;
aurora::gfx::TextureHandle m_reflectionCube; GXTexObj m_reflectionCube;
zeus::CColor m_debugAddColor = zeus::skClear; zeus::CColor m_debugAddColor = zeus::skClear;
float m_debugAddColorTime = 0.f; float m_debugAddColorTime = 0.f;

View File

@ -269,10 +269,10 @@ CFluidPlaneShader::RenderSetupInfo CFluidPlaneCPU::RenderSetup(const CStateManag
m_cachedAdditive != (mgr.GetThermalDrawFlag() == EThermalDrawFlag::Hot)) { m_cachedAdditive != (mgr.GetThermalDrawFlag() == EThermalDrawFlag::Hot)) {
m_cachedDoubleLightmapBlend = doubleLightmapBlend; m_cachedDoubleLightmapBlend = doubleLightmapBlend;
m_cachedAdditive = mgr.GetThermalDrawFlag() == EThermalDrawFlag::Hot; m_cachedAdditive = mgr.GetThermalDrawFlag() == EThermalDrawFlag::Hot;
m_shader.emplace(x44_fluidType, x10_texPattern1, x20_texPattern2, x30_texColor, xb0_bumpMap, xc0_envMap, // m_shader.emplace(x44_fluidType, x10_texPattern1, x20_texPattern2, x30_texColor, xb0_bumpMap, xc0_envMap,
xd0_envBumpMap, xe0_lightmap, // xd0_envBumpMap, xe0_lightmap,
m_tessellation ? CFluidPlaneManager::RippleMapTex : aurora::gfx::TextureHandle{}, // m_tessellation ? CFluidPlaneManager::RippleMapTex : aurora::gfx::TextureHandle{},
m_cachedDoubleLightmapBlend, m_cachedAdditive, m_maxVertCount); // m_cachedDoubleLightmapBlend, m_cachedAdditive, m_maxVertCount);
} }
return out; return out;

Some files were not shown because too many files have changed in this diff Show More