mirror of https://github.com/AxioDL/metaforce.git
Migrate to aurora submodule
This commit is contained in:
parent
0789f28aac
commit
1e9d96c906
|
@ -42,18 +42,12 @@
|
|||
path = extern/zeus
|
||||
url = ../zeus.git
|
||||
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"]
|
||||
path = extern/nativefiledialog
|
||||
url = https://github.com/mlabbe/nativefiledialog.git
|
||||
[submodule "extern/optick"]
|
||||
path = extern/optick
|
||||
url = https://github.com/AxioDL/optick.git
|
||||
[submodule "extern/aurora"]
|
||||
path = extern/aurora
|
||||
url = https://github.com/encounter/aurora.git
|
||||
|
|
|
@ -365,7 +365,6 @@ if(NOT TARGET atdna)
|
|||
endif()
|
||||
|
||||
add_subdirectory(NESEmulator EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(aurora)
|
||||
add_subdirectory(Runtime)
|
||||
add_subdirectory(gbalink EXCLUDE_FROM_ALL)
|
||||
|
||||
|
|
|
@ -604,9 +604,9 @@ void CNESEmulator::ProcessUserInput(const CFinalInput& input, int) {
|
|||
|
||||
if (GetPasswordEntryState() != EPasswordEntryState::NotPasswordScreen) {
|
||||
// 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);
|
||||
inValReads[BUTTON_B] = input.DB() || input.DSpecialKey(aurora::SpecialKey::Esc);
|
||||
inValReads[BUTTON_B] = input.DB() || input.DSpecialKey(ESpecialKey::Esc);
|
||||
} else {
|
||||
// Prime controls (B jumps, A shoots)
|
||||
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_LEFT] = input.DDPLeft() || input.DLALeft();
|
||||
inValReads[BUTTON_RIGHT] = input.DDPRight() || input.DLARight();
|
||||
inValReads[BUTTON_SELECT] = input.DZ() || input.DSpecialKey(aurora::SpecialKey::Tab);
|
||||
inValReads[BUTTON_START] = input.DStart() || input.DSpecialKey(aurora::SpecialKey::Esc);
|
||||
inValReads[BUTTON_SELECT] = input.DZ() || input.DSpecialKey(ESpecialKey::Tab);
|
||||
inValReads[BUTTON_START] = input.DStart() || input.DSpecialKey(ESpecialKey::Esc);
|
||||
}
|
||||
|
||||
bool CNESEmulator::CheckForGameOver(const u8* vram, u8* passwordOut) {
|
||||
|
|
|
@ -35,7 +35,7 @@ private:
|
|||
zeus::CColor m_color;
|
||||
};
|
||||
|
||||
aurora::gfx::TextureHandle m_texture;
|
||||
GXTexObj m_texture;
|
||||
// boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
// boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
||||
// boo::ObjToken<boo::IShaderDataBinding> m_shadBind;
|
||||
|
|
|
@ -788,10 +788,10 @@ void CAutoMapper::SetShouldRotatingSoundBePlaying(bool shouldBePlaying) {
|
|||
void CAutoMapper::ProcessMapScreenInput(const CFinalInput& input, CStateManager& mgr) {
|
||||
zeus::CMatrix3f camRot = xa8_renderStates[0].x8_camOrientation.toTransform().buildMatrix3f();
|
||||
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);
|
||||
} 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);
|
||||
zeus::CVector3f pointLocal = mapuWld.GetWorldTransform().inverse() * xa8_renderStates[0].x20_areaPoint;
|
||||
if (mapuWld.GetWorldAssetId() != g_GameState->CurrentWorldAssetId()) {
|
||||
|
@ -806,7 +806,7 @@ void CAutoMapper::ProcessMapScreenInput(const CFinalInput& input, CStateManager&
|
|||
}
|
||||
|
||||
x2f4_aButtonPos = 0;
|
||||
if (input.PA() || input.PSpecialKey(aurora::SpecialKey::Enter))
|
||||
if (input.PA() || input.PSpecialKey(ESpecialKey::Enter))
|
||||
x2f4_aButtonPos = 1;
|
||||
|
||||
if (IsInPlayerControlState()) {
|
||||
|
@ -1083,8 +1083,8 @@ void CAutoMapper::ProcessControllerInput(const CFinalInput& input, CStateManager
|
|||
}
|
||||
}
|
||||
|
||||
if (input.PZ() || input.PSpecialKey(aurora::SpecialKey::Tab) || input.PB() ||
|
||||
input.PSpecialKey(aurora::SpecialKey::Esc)) {
|
||||
if (input.PZ() || input.PSpecialKey(ESpecialKey::Tab) || input.PB() ||
|
||||
input.PSpecialKey(ESpecialKey::Esc)) {
|
||||
if (x328_ == 0) {
|
||||
if (CanLeaveMapScreenInternal(mgr)) {
|
||||
LeaveMapScreen(mgr);
|
||||
|
|
|
@ -197,10 +197,10 @@ void CMapArea::CMapAreaSurface::PostConstruct(const u8* buf, std::vector<u32>& i
|
|||
CMemoryInStream r(x18_surfOffset, INT_MAX, CMemoryInStream::EOwnerShip::NotOwned);
|
||||
u32 primCount = r.ReadLong();
|
||||
for (u32 i = 0; i < primCount; ++i) {
|
||||
GX::Primitive prim = GX::Primitive(r.ReadLong());
|
||||
GXPrimitive prim = GXPrimitive(r.ReadLong());
|
||||
u32 count = r.ReadLong();
|
||||
switch (prim) {
|
||||
case GX::Primitive::TRIANGLES: {
|
||||
case GX_TRIANGLES: {
|
||||
for (u32 v = 0; v < count; v += 3) {
|
||||
if (!start) {
|
||||
index.push_back(index.back());
|
||||
|
@ -216,7 +216,7 @@ void CMapArea::CMapAreaSurface::PostConstruct(const u8* buf, std::vector<u32>& i
|
|||
}
|
||||
break;
|
||||
}
|
||||
case GX::Primitive::TRIANGLESTRIP: {
|
||||
case GX_TRIANGLESTRIP: {
|
||||
if (!start) {
|
||||
index.push_back(index.back());
|
||||
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());
|
||||
break;
|
||||
}
|
||||
case GX::Primitive::TRIANGLEFAN: {
|
||||
case GX_TRIANGLEFAN: {
|
||||
u8 firstVert = r.ReadUint8();
|
||||
if (!start) {
|
||||
index.push_back(index.back());
|
||||
|
|
|
@ -27,8 +27,8 @@ public:
|
|||
struct Instance {
|
||||
CMapSurfaceShader m_surfacePrims;
|
||||
std::vector<CLineRenderer> m_linePrims;
|
||||
Instance(aurora::ArrayRef<zeus::CVector3f> vbo,
|
||||
aurora::ArrayRef<u16> ibo)
|
||||
Instance(std::vector<zeus::CVector3f> vbo,
|
||||
std::vector<u16> ibo)
|
||||
: m_surfacePrims(vbo, ibo) {}
|
||||
Instance(Instance&&) = default;
|
||||
Instance& operator=(Instance&&) = default;
|
||||
|
|
|
@ -112,19 +112,19 @@ void CMappableObject::Draw(int curArea, const CMapWorldInfo& mwInfo, float alpha
|
|||
SCOPED_GRAPHICS_DEBUG_GROUP("CMappableObject::Draw", zeus::skCyan);
|
||||
if (IsDoorType(x0_type)) {
|
||||
std::pair<zeus::CColor, zeus::CColor> colors = GetDoorColors(curArea, mwInfo, alpha);
|
||||
if (m_doorSurface) // TODO
|
||||
for (int s = 0; s < 6; ++s) {
|
||||
DoorSurface& ds = *m_doorSurface;
|
||||
ds.m_surface.draw(colors.first, s * 4, 4);
|
||||
CLineRenderer& line = ds.m_outline;
|
||||
const u16* baseIdx = &skDoorIndices[s * 4];
|
||||
line.Reset();
|
||||
line.AddVertex(skDoorVerts[baseIdx[0]], 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[2]], colors.second, 1.f);
|
||||
line.Render();
|
||||
}
|
||||
// TODO
|
||||
// for (int s = 0; s < 6; ++s) {
|
||||
// DoorSurface& ds = *m_doorSurface;
|
||||
// ds.m_surface.draw(colors.first, s * 4, 4);
|
||||
// CLineRenderer& line = ds.m_outline;
|
||||
// const u16* baseIdx = &skDoorIndices[s * 4];
|
||||
// line.Reset();
|
||||
// line.AddVertex(skDoorVerts[baseIdx[0]], 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[2]], colors.second, 1.f);
|
||||
// line.Render();
|
||||
// }
|
||||
} else {
|
||||
CAssetId iconRes;
|
||||
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,
|
||||
bool needsVtxLoad) {
|
||||
std::pair<zeus::CColor, zeus::CColor> colors = GetDoorColors(curArea, mwInfo, alpha);
|
||||
DoorSurface& ds = *m_doorSurface;
|
||||
ds.m_surface.draw(colors.first, surfIdx * 4, 4);
|
||||
CLineRenderer& line = ds.m_outline;
|
||||
const u16* baseIdx = &skDoorIndices[surfIdx * 4];
|
||||
line.Reset();
|
||||
line.AddVertex(skDoorVerts[baseIdx[0]], 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[2]], colors.second, 1.f);
|
||||
line.Render();
|
||||
// DoorSurface& ds = *m_doorSurface;
|
||||
// ds.m_surface.draw(colors.first, surfIdx * 4, 4);
|
||||
// CLineRenderer& line = ds.m_outline;
|
||||
// const u16* baseIdx = &skDoorIndices[surfIdx * 4];
|
||||
// line.Reset();
|
||||
// line.AddVertex(skDoorVerts[baseIdx[0]], 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[2]], colors.second, 1.f);
|
||||
// line.Render();
|
||||
}
|
||||
|
||||
zeus::CVector3f CMappableObject::BuildSurfaceCenterPoint(int surfIdx) const {
|
||||
|
|
|
@ -58,14 +58,14 @@ private:
|
|||
u32 xc_;
|
||||
zeus::CTransform x10_transform;
|
||||
|
||||
struct DoorSurface {
|
||||
CMapSurfaceShader m_surface;
|
||||
CLineRenderer m_outline;
|
||||
explicit DoorSurface()
|
||||
: m_surface(skDoorVerts, skDoorIndices)
|
||||
, m_outline(CLineRenderer::EPrimitiveMode::LineLoop, 5, {}, false, false, true) {}
|
||||
};
|
||||
std::optional<DoorSurface> m_doorSurface;
|
||||
// struct DoorSurface {
|
||||
// CMapSurfaceShader m_surface;
|
||||
// CLineRenderer m_outline;
|
||||
// explicit DoorSurface()
|
||||
// : m_surface(skDoorVerts, skDoorIndices)
|
||||
// , m_outline(CLineRenderer::EPrimitiveMode::LineLoop, 5, {}, false, false, true) {}
|
||||
// };
|
||||
// std::optional<DoorSurface> m_doorSurface;
|
||||
|
||||
zeus::CTransform AdjustTransformForType() 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 IsVisibleToAutoMapper(bool worldVis, const CMapWorldInfo& mwInfo) const;
|
||||
bool GetIsSeen() const;
|
||||
void CreateDoorSurface() { m_doorSurface.emplace(); }
|
||||
// void CreateDoorSurface() { m_doorSurface.emplace(); }
|
||||
|
||||
static void ReadAutoMapperTweaks(const ITweakAutoMapper&);
|
||||
static bool GetTweakIsMapVisibilityCheat();
|
||||
|
|
|
@ -446,7 +446,7 @@ void CGameOptions::TryRestoreDefaults(const CFinalInput& input, int category, in
|
|||
if (options.second[option].option != EGameOption::RestoreDefaults)
|
||||
return;
|
||||
|
||||
if (!forceRestore && !input.PA() && !input.PSpecialKey(aurora::SpecialKey::Enter))
|
||||
if (!forceRestore && !input.PA() && !input.PSpecialKey(ESpecialKey::Enter))
|
||||
return;
|
||||
|
||||
if (frontend) {
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
//#include <fenv.h>
|
||||
//#pragma STDC FENV_ACCESS ON
|
||||
|
||||
#include <SDL_main.h>
|
||||
#include <aurora/aurora.hpp>
|
||||
#include <aurora/event.h>
|
||||
#include <aurora/main.h>
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
|
@ -147,8 +147,10 @@ static std::string CPUFeatureString(const zeus::CPUInfo& cpuInf) {
|
|||
return features;
|
||||
}
|
||||
|
||||
struct Application : aurora::AppDelegate {
|
||||
struct Application {
|
||||
private:
|
||||
int m_argc;
|
||||
char** m_argv;
|
||||
FileStoreManager& m_fileMgr;
|
||||
CVarManager& m_cvarManager;
|
||||
CVarCommons& m_cvarCommons;
|
||||
|
@ -171,14 +173,20 @@ private:
|
|||
// is built, i.e during initialization
|
||||
|
||||
public:
|
||||
Application(FileStoreManager& fileMgr, CVarManager& cvarMgr, CVarCommons& cvarCmns)
|
||||
: m_fileMgr(fileMgr), m_cvarManager(cvarMgr), m_cvarCommons(cvarCmns), m_imGuiConsole(cvarMgr, cvarCmns) {}
|
||||
Application(int argc, char** argv, FileStoreManager& fileMgr, CVarManager& cvarMgr, CVarCommons& 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();
|
||||
|
||||
auto backend = static_cast<std::string>(aurora::get_backend_string());
|
||||
aurora::set_window_title(fmt::format(FMT_STRING("Metaforce {} [{}]"), METAFORCE_WC_DESCRIBE, backend));
|
||||
// TODO
|
||||
// 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->setVolume(0.7f);
|
||||
|
@ -187,8 +195,8 @@ public:
|
|||
#if TARGET_OS_IOS || TARGET_OS_TV
|
||||
m_deferredProject = std::string{m_fileMgr.getStoreRoot()} + "game.iso";
|
||||
#else
|
||||
for (const auto& str : aurora::get_args()) {
|
||||
auto arg = static_cast<std::string>(str);
|
||||
for (int i = 1; i < m_argc; ++i) {
|
||||
std::string arg = m_argv[i];
|
||||
if (m_deferredProject.empty() && !arg.starts_with('-') && !arg.starts_with('+'))
|
||||
m_deferredProject = arg;
|
||||
else if (arg == "--no-sound")
|
||||
|
@ -202,17 +210,13 @@ public:
|
|||
void initialize() {
|
||||
zeus::detectCPU();
|
||||
|
||||
for (const auto& str : aurora::get_args()) {
|
||||
auto arg = static_cast<std::string>(str);
|
||||
}
|
||||
|
||||
const zeus::CPUInfo& cpuInf = zeus::cpuFeatures();
|
||||
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 Features: {}"), CPUFeatureString(cpuInf));
|
||||
}
|
||||
|
||||
bool onAppIdle(float realDt) noexcept override {
|
||||
bool onAppIdle(float realDt) noexcept {
|
||||
#ifdef NDEBUG
|
||||
/* Ping the watchdog to let it know we're still alive */
|
||||
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
|
||||
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
|
||||
|
@ -266,7 +271,8 @@ public:
|
|||
|
||||
if (!g_mainMP1 && m_projectInitialized) {
|
||||
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()) {
|
||||
Log.report(logvisor::Error, FMT_STRING("{}"), result);
|
||||
m_imGuiConsole.m_errorString = result;
|
||||
|
@ -311,7 +317,7 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
void onAppDraw() noexcept override {
|
||||
void onAppDraw() noexcept {
|
||||
OPTICK_EVENT("Draw");
|
||||
if (g_Renderer != nullptr) {
|
||||
g_Renderer->BeginScene();
|
||||
|
@ -322,7 +328,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void onAppPostDraw() noexcept override {
|
||||
void onAppPostDraw() noexcept {
|
||||
OPTICK_EVENT("PostDraw");
|
||||
if (m_voiceEngine) {
|
||||
m_voiceEngine->pumpAndMixVoices();
|
||||
|
@ -331,25 +337,17 @@ public:
|
|||
++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)});
|
||||
}
|
||||
|
||||
void onAppWindowMoved(std::int32_t x, std::int32_t y) noexcept override {
|
||||
// TODO: implement this
|
||||
}
|
||||
void onAppDisplayScaleChanged(float scale) noexcept { ImGuiEngine_Initialize(scale); }
|
||||
|
||||
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 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 {
|
||||
void onAppExiting() noexcept {
|
||||
m_imGuiConsole.Shutdown();
|
||||
if (m_voiceEngine) {
|
||||
m_voiceEngine->unlockPump();
|
||||
|
@ -365,127 +363,9 @@ public:
|
|||
CDvdFile::Shutdown();
|
||||
}
|
||||
|
||||
void onCharKeyDown(uint8_t code, aurora::ModifierKey mods, bool isRepeat) noexcept override {
|
||||
if (g_mainMP1) {
|
||||
if (MP1::CGameArchitectureSupport* as = g_mainMP1->GetArchSupport()) {
|
||||
as->charKeyDown(code, mods, isRepeat);
|
||||
}
|
||||
}
|
||||
}
|
||||
void onImGuiInit(float scale) noexcept { ImGuiEngine_Initialize(scale); }
|
||||
|
||||
void onCharKeyUp(uint8_t code, aurora::ModifierKey mods) noexcept override {
|
||||
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(); }
|
||||
void onImGuiAddTextures() noexcept { ImGuiEngine_AddTextures(); }
|
||||
|
||||
[[nodiscard]] std::chrono::nanoseconds getTargetFrameTime() const {
|
||||
if (m_cvarCommons.getVariableFrameTime()) {
|
||||
|
@ -527,10 +407,32 @@ static bool IsClientLoggingEnabled(int argc, char** argv) {
|
|||
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
|
||||
int main(int argc, char** argv) {
|
||||
// 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]);
|
||||
}
|
||||
|
||||
auto icon = metaforce::GetIcon();
|
||||
|
||||
// FIXME: logvisor needs to copy this
|
||||
std::string logFilePath;
|
||||
|
||||
|
@ -583,16 +487,72 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
}
|
||||
|
||||
auto app = std::make_unique<metaforce::Application>(fileMgr, cvarMgr, cvarCmns);
|
||||
auto icon = metaforce::GetIcon();
|
||||
auto data = aurora::Icon{
|
||||
.data = std::move(icon.data),
|
||||
.width = icon.width,
|
||||
.height = icon.height,
|
||||
g_app = std::make_unique<metaforce::Application>(argc, argv, fileMgr, cvarMgr, cvarCmns);
|
||||
std::string configPath{fileMgr.getStoreRoot()};
|
||||
const AuroraConfig config{
|
||||
.appName = "Metaforce",
|
||||
.configPath = configPath.c_str(),
|
||||
// .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(),
|
||||
aurora::backend_from_string(cvarCmns.getGraphicsApi()), cvarCmns.getSamples(),
|
||||
cvarCmns.getAnisotropy(), cvarCmns.getFullscreen());
|
||||
const auto info = aurora_initialize(argc, argv, &config);
|
||||
g_app->onImGuiAddTextures();
|
||||
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();
|
||||
} while (restart);
|
||||
return 0;
|
||||
|
|
|
@ -153,11 +153,11 @@ set(DISCORD_RPC_LIBRARY "")
|
|||
if (NOT GEKKO AND NOT NX AND NOT IOS AND NOT TVOS)
|
||||
set(DISCORD_RPC_LIBRARY "discord-rpc")
|
||||
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
|
||||
${DISCORD_RPC_LIBRARY}
|
||||
${ZLIB_LIBRARIES}
|
||||
SDL2::SDL2-static SDL2::SDL2main
|
||||
)
|
||||
|
||||
add_runtime_common_library(RuntimeCommon ${RUNTIME_SOURCES_A})
|
||||
|
@ -229,7 +229,7 @@ add_executable(metaforce CMain.cpp ${PLAT_SRCS}
|
|||
ImGuiControllerConfig.hpp ImGuiControllerConfig.cpp
|
||||
ImGuiEntitySupport.hpp ImGuiEntitySupport.cpp)
|
||||
# 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)
|
||||
target_link_libraries(metaforce PRIVATE nativefiledialog)
|
||||
endif()
|
||||
|
|
|
@ -112,7 +112,7 @@ void CCameraFilterPass::DrawFilter(EFilterType type, EFilterShape shape, const z
|
|||
g_Renderer->SetBlendMode_AdditiveAlpha();
|
||||
break;
|
||||
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;
|
||||
case EFilterType::Blend:
|
||||
g_Renderer->SetBlendMode_AlphaBlended();
|
||||
|
@ -186,12 +186,12 @@ void CCameraFilterPass::DrawFullScreenTexturedQuadQuarters(const zeus::CColor& c
|
|||
CGraphics::SetTevOp(ERglTevStage::Stage1, CTevCombiners::skPassThru);
|
||||
g_Renderer->SetDepthReadWrite(false, false);
|
||||
if (tex != nullptr) {
|
||||
tex->Load(GX::TEXMAP0, EClampMode::Repeat);
|
||||
tex->Load(GX_TEXMAP0, EClampMode::Repeat);
|
||||
}
|
||||
CGraphics::SetCullMode(ERglCullMode::None);
|
||||
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));
|
||||
CGraphics::StreamBegin(GX::TRIANGLESTRIP);
|
||||
CGraphics::StreamBegin(GX_TRIANGLESTRIP);
|
||||
CGraphics::StreamColor(color);
|
||||
CGraphics::StreamTexcoord(lod, lod);
|
||||
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);
|
||||
g_Renderer->SetDepthReadWrite(false, false);
|
||||
if (tex != nullptr) {
|
||||
tex->Load(GX::TEXMAP0, EClampMode::Repeat);
|
||||
tex->Load(GX_TEXMAP0, EClampMode::Repeat);
|
||||
}
|
||||
CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::sTevPass805a5ebc);
|
||||
CGraphics::SetTevOp(ERglTevStage::Stage1, CTevCombiners::skPassThru);
|
||||
CGraphics::StreamBegin(GX::TRIANGLESTRIP);
|
||||
CGraphics::StreamBegin(GX_TRIANGLESTRIP);
|
||||
CGraphics::StreamColor(color);
|
||||
CGraphics::StreamTexcoord(u, v);
|
||||
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();
|
||||
memcpy(out, buf + ROUND_UP_32(rand() & 0x7fff), m_randomStatic.GetMemoryAllocated());
|
||||
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::StreamTexcoord(0.f, 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->SetModelMatrix({});
|
||||
// if (tex != nullptr) {
|
||||
// tex->Load(GX::TEXMAP0, EClampMode::Repeat);
|
||||
// tex->Load(GX_TEXMAP0, EClampMode::Repeat);
|
||||
// }
|
||||
// CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::sTevPass805a5ebc);
|
||||
// CGraphics::SetTevOp(ERglTevStage::Stage1, CTevCombiners::skPassThru);
|
||||
// CGraphics::StreamBegin(GX::TRIANGLESTRIP);
|
||||
// CGraphics::StreamBegin(GX_TRIANGLESTRIP);
|
||||
// float x = rand() % 4000;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
|
@ -55,7 +55,7 @@ void CCubeMaterial::SetCurrent(const CModelFlags& flags, const CCubeSurface& sur
|
|||
materialDataCur += 8;
|
||||
for (u32 i = 0; i < texCount; ++i) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -83,14 +83,14 @@ void CCubeMaterial::SetCurrent(const CModelFlags& flags, const CCubeSurface& sur
|
|||
for (u32 i = 0; i < konstCount; ++i) {
|
||||
u32 kColor = SBig(*reinterpret_cast<const u32*>(materialDataCur));
|
||||
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));
|
||||
materialDataCur += 4;
|
||||
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 {
|
||||
SetupBlendMode(blendFactors, flags, matFlags.IsSet(CCubeMaterialFlagBits::fAlphaTest));
|
||||
}
|
||||
|
@ -129,12 +129,12 @@ void CCubeMaterial::SetCurrent(const CModelFlags& flags, const CCubeSurface& sur
|
|||
finalTevCount = firstTev + 1;
|
||||
u32 ccFlags = SBig(*reinterpret_cast<const u32*>(materialDataCur + 8));
|
||||
finalCCFlags = ccFlags;
|
||||
auto outputReg = static_cast<GX::TevRegID>(ccFlags >> 9 & 0x3);
|
||||
if (outputReg == GX::TEVREG0) {
|
||||
auto outputReg = static_cast<GXTevRegID>(ccFlags >> 9 & 0x3);
|
||||
if (outputReg == GX_TEVREG0) {
|
||||
materialDataCur += 20;
|
||||
texMapTexCoordFlags += 1;
|
||||
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));
|
||||
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));
|
||||
finalCCFlags = ccFlags;
|
||||
finalACFlags = SBig(*reinterpret_cast<const u32*>(materialDataCur + 12));
|
||||
auto outputReg = static_cast<GX::TevRegID>(ccFlags >> 9 & 0x3);
|
||||
if (outputReg == GX::TEVREG2) {
|
||||
auto outputReg = static_cast<GXTevRegID>(ccFlags >> 9 & 0x3);
|
||||
if (outputReg == GX_TEVREG2) {
|
||||
usesTevReg2 = true;
|
||||
}
|
||||
materialDataCur += 20;
|
||||
|
@ -162,13 +162,13 @@ void CCubeMaterial::SetCurrent(const CModelFlags& flags, const CCubeSurface& sur
|
|||
u32 fullTcgCount = SBig(*tcgs);
|
||||
tcgCount = std::min(fullTcgCount, 2u);
|
||||
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;
|
||||
} else {
|
||||
tcgCount = SBig(*tcgs);
|
||||
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;
|
||||
}
|
||||
|
@ -176,10 +176,10 @@ void CCubeMaterial::SetCurrent(const CModelFlags& flags, const CCubeSurface& sur
|
|||
const u32* uvAnim = tcgs;
|
||||
u32 animCount = SBig(uvAnim[1]);
|
||||
uvAnim += 2;
|
||||
u32 texMtx = GX::TEXMTX0;
|
||||
u32 pttTexMtx = GX::PTTEXMTX0;
|
||||
u32 texMtx = GX_TEXMTX0;
|
||||
u32 pttTexMtx = GX_PTTEXMTX0;
|
||||
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)
|
||||
break;
|
||||
uvAnim += size;
|
||||
|
@ -228,17 +228,17 @@ void CCubeMaterial::SetCurrentBlack() {
|
|||
const auto flags = GetFlags();
|
||||
const auto vatFlags = GetVatFlags();
|
||||
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 {
|
||||
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::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::SetTevKAlphaSel(GX::TEVSTAGE0, GX::TEV_KASEL_1);
|
||||
CGX::SetTexCoordGen(GX::TEXCOORD0, GX::TG_MTX2x4, GX::TG_POS, GX::IDENTITY, false, GX::PTIDENTITY);
|
||||
CGX::SetStandardTevColorAlphaOp(GX::TEVSTAGE0);
|
||||
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 /* ? CC_ONE */);
|
||||
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::SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_POS, GX_IDENTITY, false, GX_PTIDENTITY);
|
||||
CGX::SetStandardTevColorAlphaOp(GX_TEVSTAGE0);
|
||||
CGX::SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR_NULL);
|
||||
CGX::SetNumTevStages(1);
|
||||
CGX::SetNumChans(0);
|
||||
CGX::SetNumTexGens(1);
|
||||
|
@ -246,35 +246,35 @@ void CCubeMaterial::SetCurrentBlack() {
|
|||
}
|
||||
|
||||
void CCubeMaterial::SetupBlendMode(u32 blendFactors, const CModelFlags& flags, bool alphaTest) {
|
||||
auto newSrcFactor = static_cast<GX::BlendFactor>(blendFactors & 0xffff);
|
||||
auto newDstFactor = static_cast<GX::BlendFactor>(blendFactors >> 16 & 0xffff);
|
||||
auto newSrcFactor = static_cast<GXBlendFactor>(blendFactors & 0xffff);
|
||||
auto newDstFactor = static_cast<GXBlendFactor>(blendFactors >> 16 & 0xffff);
|
||||
if (alphaTest) {
|
||||
// discard fragments with alpha < 0.25
|
||||
CGX::SetAlphaCompare(GX::GEQUAL, 64, GX::AOP_OR, GX::NEVER, 0);
|
||||
newSrcFactor = GX::BL_ONE;
|
||||
newDstFactor = GX::BL_ZERO;
|
||||
CGX::SetAlphaCompare(GX_GEQUAL, 64, GX_AOP_OR, GX_NEVER, 0);
|
||||
newSrcFactor = GX_BL_ONE;
|
||||
newDstFactor = GX_BL_ZERO;
|
||||
} 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) {
|
||||
newSrcFactor = GX::BL_SRCALPHA;
|
||||
if (newDstFactor == GX::BL_ZERO) {
|
||||
newDstFactor = flags.x0_blendMode > 6 ? GX::BL_ONE : GX::BL_INVSRCALPHA;
|
||||
if (flags.x0_blendMode > 4 && newSrcFactor == GX_BL_ONE) {
|
||||
newSrcFactor = GX_BL_SRCALPHA;
|
||||
if (newDstFactor == GX_BL_ZERO) {
|
||||
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) {
|
||||
GX::Compare func = GX::NEVER;
|
||||
GXCompare func = GX_NEVER;
|
||||
if (!(modelFlags & CModelFlagBits::DepthTest)) {
|
||||
func = GX::ALWAYS;
|
||||
func = GX_ALWAYS;
|
||||
} else if (modelFlags & CModelFlagBits::DepthGreater) {
|
||||
func = modelFlags & CModelFlagBits::DepthNonInclusive ? GX::GREATER : GX::GEQUAL;
|
||||
func = modelFlags & CModelFlagBits::DepthNonInclusive ? GX_GREATER : GX_GEQUAL;
|
||||
} 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;
|
||||
CGX::SetZMode(true, func, depthWrite);
|
||||
|
@ -309,14 +309,14 @@ void CCubeMaterial::EnsureViewDepStateCached(const CCubeSurface* surface) {
|
|||
u32 CCubeMaterial::HandleColorChannels(u32 chanCount, u32 firstChan) {
|
||||
if (CCubeModel::sRenderModelShadow) {
|
||||
if (chanCount != 0) {
|
||||
CGX::SetChanAmbColor(CGX::EChannelId::Channel1, zeus::skBlack);
|
||||
CGX::SetChanMatColor(CGX::EChannelId::Channel1, zeus::skWhite);
|
||||
CGX::SetChanAmbColor(CGX::EChannelId::Channel1, GX_BLACK);
|
||||
CGX::SetChanMatColor(CGX::EChannelId::Channel1, GX_WHITE);
|
||||
|
||||
auto chan0Lights = CGraphics::g_LightActive & ~CCubeModel::sChannel0DisableLightMask;
|
||||
CGX::SetChanCtrl(CGX::EChannelId::Channel0, firstChan, chan0Lights);
|
||||
CGX::SetChanCtrl(CGX::EChannelId::Channel1, CCubeModel::sChannel1EnableLightMask);
|
||||
if (chan0Lights.any()) {
|
||||
CGX::SetChanMatColor(CGX::EChannelId::Channel0, zeus::skWhite);
|
||||
CGX::SetChanMatColor(CGX::EChannelId::Channel0, GX_WHITE);
|
||||
} else {
|
||||
CGX::SetChanMatColor(CGX::EChannelId::Channel0, CGX::GetChanAmbColor(CGX::EChannelId::Channel0));
|
||||
}
|
||||
|
@ -325,8 +325,8 @@ u32 CCubeMaterial::HandleColorChannels(u32 chanCount, u32 firstChan) {
|
|||
}
|
||||
|
||||
if (chanCount == 2) {
|
||||
CGX::SetChanAmbColor(CGX::EChannelId::Channel1, zeus::skBlack);
|
||||
CGX::SetChanMatColor(CGX::EChannelId::Channel1, zeus::skWhite);
|
||||
CGX::SetChanAmbColor(CGX::EChannelId::Channel1, GX_BLACK);
|
||||
CGX::SetChanMatColor(CGX::EChannelId::Channel1, GX_WHITE);
|
||||
} else {
|
||||
CGX::SetChanCtrl(CGX::EChannelId::Channel1, {});
|
||||
}
|
||||
|
@ -336,7 +336,7 @@ u32 CCubeMaterial::HandleColorChannels(u32 chanCount, u32 firstChan) {
|
|||
} else {
|
||||
CGX::SetChanCtrl(CGX::EChannelId::Channel0, firstChan, CGraphics::g_LightActive);
|
||||
if (CGraphics::g_LightActive.any()) {
|
||||
CGX::SetChanMatColor(CGX::EChannelId::Channel0, zeus::skWhite);
|
||||
CGX::SetChanMatColor(CGX::EChannelId::Channel0, GX_WHITE);
|
||||
} else {
|
||||
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 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);
|
||||
|
||||
u32 tmtcFlags = SBig(*texMapTexCoordFlags);
|
||||
u32 matFlags = SBig(materialDataCur[4]);
|
||||
CGX::SetTevOrder(stage, static_cast<GX::TexCoordID>(tmtcFlags & 0xFF),
|
||||
static_cast<GX::TexMapID>(tmtcFlags >> 8 & 0xFF), static_cast<GX::ChannelID>(matFlags & 0xFF));
|
||||
CGX::SetTevKColorSel(stage, static_cast<GX::TevKColorSel>(matFlags >> 0x8 & 0xFF));
|
||||
CGX::SetTevKAlphaSel(stage, static_cast<GX::TevKAlphaSel>(matFlags >> 0x10 & 0xFF));
|
||||
CGX::SetTevOrder(stage, static_cast<GXTexCoordID>(tmtcFlags & 0xFF), static_cast<GXTexMapID>(tmtcFlags >> 8 & 0xFF),
|
||||
static_cast<GXChannelID>(matFlags & 0xFF));
|
||||
CGX::SetTevKColorSel(stage, static_cast<GXTevKColorSel>(matFlags >> 0x8 & 0xFF));
|
||||
CGX::SetTevKAlphaSel(stage, static_cast<GXTevKAlphaSel>(matFlags >> 0x10 & 0xFF));
|
||||
}
|
||||
|
||||
constexpr zeus::CTransform MvPostXf{
|
||||
|
@ -368,21 +368,21 @@ constexpr zeus::CTransform MvPostXf{
|
|||
{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);
|
||||
const float* params = reinterpret_cast<const float*>(uvAnim + 1);
|
||||
switch (type) {
|
||||
case 0: {
|
||||
auto xf = CGraphics::g_ViewMatrix.inverse().multiplyIgnoreTranslation(CGraphics::g_GXModelMatrix);
|
||||
xf.origin.zeroOut();
|
||||
GXLoadTexMtxImm(&xf, texMtx, GX::MTX3x4);
|
||||
GXLoadTexMtxImm(&MvPostXf, pttTexMtx, GX::MTX3x4);
|
||||
GXLoadTexMtxImm(&xf, texMtx, GX_MTX3x4);
|
||||
GXLoadTexMtxImm(&MvPostXf, pttTexMtx, GX_MTX3x4);
|
||||
return 1;
|
||||
}
|
||||
case 1: {
|
||||
auto xf = CGraphics::g_ViewMatrix.inverse() * CGraphics::g_GXModelMatrix;
|
||||
GXLoadTexMtxImm(&xf, texMtx, GX::MTX3x4);
|
||||
GXLoadTexMtxImm(&MvPostXf, pttTexMtx, GX::MTX3x4);
|
||||
GXLoadTexMtxImm(&xf, texMtx, GX_MTX3x4);
|
||||
GXLoadTexMtxImm(&MvPostXf, pttTexMtx, GX_MTX3x4);
|
||||
return 1;
|
||||
}
|
||||
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 seconds = CGraphics::GetSecondsMod900();
|
||||
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;
|
||||
}
|
||||
case 3: {
|
||||
|
@ -406,7 +406,7 @@ u32 CCubeMaterial::HandleAnimatedUV(const u32* uvAnim, GX::TexMtx texMtx, GX::PT
|
|||
xf.basis[1][1] = acos;
|
||||
xf.origin[0] = (1.f - (acos - asin)) * 0.5f;
|
||||
xf.origin[1] = (1.f - (asin + acos)) * 0.5f;
|
||||
GXLoadTexMtxImm(&xf, texMtx, GX::MTX3x4);
|
||||
GXLoadTexMtxImm(&xf, texMtx, GX_MTX3x4);
|
||||
return 3;
|
||||
}
|
||||
case 4:
|
||||
|
@ -420,7 +420,7 @@ u32 CCubeMaterial::HandleAnimatedUV(const u32* uvAnim, GX::TexMtx texMtx, GX::PT
|
|||
xf.origin.x() = 0.f;
|
||||
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;
|
||||
}
|
||||
case 6: {
|
||||
|
@ -437,8 +437,8 @@ u32 CCubeMaterial::HandleAnimatedUV(const u32* uvAnim, GX::TexMtx texMtx, GX::PT
|
|||
1.f,
|
||||
},
|
||||
};
|
||||
GXLoadTexMtxImm(&mtx, texMtx, GX::MTX3x4);
|
||||
GXLoadTexMtxImm(&postMtx, pttTexMtx, GX::MTX3x4);
|
||||
GXLoadTexMtxImm(&mtx, texMtx, GX_MTX3x4);
|
||||
GXLoadTexMtxImm(&postMtx, pttTexMtx, GX_MTX3x4);
|
||||
return 1;
|
||||
}
|
||||
case 7: {
|
||||
|
@ -457,8 +457,8 @@ u32 CCubeMaterial::HandleAnimatedUV(const u32* uvAnim, GX::TexMtx texMtx, GX::PT
|
|||
},
|
||||
zeus::CVector3f{xy, z, 1.f},
|
||||
};
|
||||
GXLoadTexMtxImm(&mtx, texMtx, GX::MTX3x4);
|
||||
GXLoadTexMtxImm(&postMtx, pttTexMtx, GX::MTX3x4);
|
||||
GXLoadTexMtxImm(&mtx, texMtx, GX_MTX3x4);
|
||||
GXLoadTexMtxImm(&postMtx, pttTexMtx, GX_MTX3x4);
|
||||
return 3;
|
||||
}
|
||||
default:
|
||||
|
@ -476,38 +476,38 @@ void CCubeMaterial::HandleTransparency(u32& finalTevCount, u32& finalKColorCount
|
|||
}
|
||||
if (modelFlags.x0_blendMode == 3) {
|
||||
// Stage outputting splatted KAlpha as color to reg0
|
||||
auto stage = static_cast<GX::TevStageID>(finalTevCount);
|
||||
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::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::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);
|
||||
auto stage = static_cast<GXTevStageID>(finalTevCount);
|
||||
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::SetTevColorOp(stage, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVREG0);
|
||||
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::SetTevOrder(stage, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR_NULL);
|
||||
CGX::SetTevDirect(stage);
|
||||
|
||||
// Stage interpolating from splatted KAlpha using KColor
|
||||
stage = static_cast<GX::TevStageID>(stage + 1);
|
||||
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::SetTevKColorSel(stage, static_cast<GX::TevKColorSel>(finalKColorCount + GX::TEV_KCSEL_K0));
|
||||
stage = static_cast<GXTevStageID>(stage + 1);
|
||||
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::SetTevKColorSel(stage, static_cast<GXTevKColorSel>(finalKColorCount + GX_TEV_KCSEL_K0));
|
||||
|