mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-05-13 09:51:21 +00:00
Minor cleanup, fix CGraphics::Render2D
This commit is contained in:
parent
476be87c89
commit
bc7519d175
@ -272,7 +272,7 @@ static constexpr GXVtxDescList skPosColorTexDirect[] = {
|
||||
|
||||
void CGraphics::Render2D(CTexture& tex, u32 x, u32 y, u32 w, u32 h, const zeus::CColor& col) {
|
||||
Mtx44 proj;
|
||||
MTXOrtho(proj, mViewport.mHeight / 2, -mViewport.mHeight / 2, -mViewport.mWidth / 2, mViewport.mWidth / 2, -1.f,
|
||||
MTXOrtho(proj, mViewport.mHeight / 2, -(mViewport.mHeight / 2), -(mViewport.mWidth / 2), mViewport.mWidth / 2, -1.f,
|
||||
-10.f);
|
||||
GXSetProjection(proj, GX_ORTHOGRAPHIC);
|
||||
uint c = col.toRGBA();
|
||||
@ -280,12 +280,15 @@ void CGraphics::Render2D(CTexture& tex, u32 x, u32 y, u32 w, u32 h, const zeus::
|
||||
Mtx mtx;
|
||||
MTXIdentity(mtx);
|
||||
GXLoadPosMtxImm(mtx, GX_PNMTX0);
|
||||
const float scaledX = static_cast<float>(x) / 640.f * static_cast<float>(mViewport.mWidth);
|
||||
const float scaledY = static_cast<float>(y) / 448.f * static_cast<float>(mViewport.mHeight);
|
||||
const float scaledW = static_cast<float>(w) / 640.f * static_cast<float>(mViewport.mWidth);
|
||||
const float scaledH = static_cast<float>(h) / 448.f * static_cast<float>(mViewport.mHeight);
|
||||
|
||||
float x2, y2, x1, y1;
|
||||
x1 = x - mViewport.mWidth / 2;
|
||||
y1 = y - mViewport.mHeight / 2;
|
||||
x2 = x1 + w;
|
||||
y2 = y1 + h;
|
||||
const float x1 = scaledX - (mViewport.mWidth / 2);
|
||||
const float y1 = scaledY - (mViewport.mHeight / 2);
|
||||
const float x2 = x1 + scaledW;
|
||||
const float y2 = y1 + scaledH;
|
||||
|
||||
// Save state + setup
|
||||
CGX::SetVtxDescv(skPosColorTexDirect);
|
||||
@ -298,6 +301,7 @@ void CGraphics::Render2D(CTexture& tex, u32 x, u32 y, u32 w, u32 h, const zeus::
|
||||
SetCullMode(ERglCullMode::None);
|
||||
|
||||
// Draw
|
||||
tex.Load(GX_TEXMAP0, EClampMode::Repeat);
|
||||
CGX::Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 4);
|
||||
GXPosition3f32(x1, y1, 1.f);
|
||||
GXColor1u32(c);
|
||||
@ -543,24 +547,24 @@ CGraphics::CClippedScreenRect CGraphics::ClipScreenRectFromVS(const CVector3f& p
|
||||
return CClippedScreenRect();
|
||||
}
|
||||
|
||||
int right = minX + maxX + 2 & ~1;
|
||||
int right = minX + ((maxX + 2) & ~1);
|
||||
if (right <= mViewport.mLeft) {
|
||||
return CClippedScreenRect();
|
||||
}
|
||||
left = std::max(left, mViewport.mLeft) & ~1;
|
||||
right = std::min(right, mViewport.mLeft + mViewport.mWidth) + 1 & ~1;
|
||||
right = (std::min(right, mViewport.mLeft + mViewport.mWidth) + 1) & ~1;
|
||||
|
||||
int top = minY & ~1;
|
||||
if (top >= mViewport.mTop + mViewport.mHeight) {
|
||||
return CClippedScreenRect();
|
||||
}
|
||||
|
||||
int bottom = minY + maxY + 2 & ~1;
|
||||
int bottom = minY + ((maxY + 2) & ~1);
|
||||
if (bottom <= mViewport.mTop) {
|
||||
return CClippedScreenRect();
|
||||
}
|
||||
top = std::max(top, mViewport.mTop) & ~1;
|
||||
bottom = std::min(bottom, mViewport.mTop + mViewport.mHeight) + 1 & ~1;
|
||||
bottom = (std::min(bottom, mViewport.mTop + mViewport.mHeight) + 1) & ~1;
|
||||
|
||||
float minV = static_cast<float>(minY - top) / static_cast<float>(bottom - top);
|
||||
float maxV = static_cast<float>(maxY + (minY - top) + 1) / static_cast<float>(bottom - top);
|
||||
@ -578,9 +582,11 @@ CGraphics::CClippedScreenRect CGraphics::ClipScreenRectFromVS(const CVector3f& p
|
||||
case ETexelFormat::RGBA8:
|
||||
texAlign = 2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
int texWidth = texAlign + (right - left) - 1 & ~(texAlign - 1);
|
||||
int texWidth = (texAlign + ((right - left) - 1)) & ~(texAlign - 1);
|
||||
float minU = static_cast<float>(minX - left) / static_cast<float>(texWidth);
|
||||
float maxU = static_cast<float>(maxX + (minX - left) + 1) / static_cast<float>(texWidth);
|
||||
return CClippedScreenRect(left, top, right - left, bottom - top, texWidth, minU, maxU, minV, maxV);
|
||||
|
@ -45,7 +45,7 @@ static void MyTHPGXYuv2RgbSetup(bool interlaced2ndFrame, bool fieldFlip) {
|
||||
CGX::SetNumChans(0);
|
||||
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);
|
||||
if (!fieldFlip) {
|
||||
if (false && !fieldFlip) {
|
||||
CGX::SetNumTexGens(3);
|
||||
CGX::SetTexCoordGen(GX_TEXCOORD2, GX_TG_MTX2x4, GX_TG_POS, GX_TEXMTX0, false, GX_PTIDENTITY);
|
||||
float n = interlaced2ndFrame ? 0.25f : 0.f;
|
||||
@ -299,28 +299,6 @@ CMoviePlayer::CMoviePlayer(const char* path, float preLoadSeconds, bool loop, bo
|
||||
x80_textures.reserve(3);
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
CTHPTextureSet& set = x80_textures.emplace_back();
|
||||
// if (deinterlace) {
|
||||
// /* 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,
|
||||
// fmt::format("Movie {} Texture Set {} Y[0]", path,
|
||||
// i));
|
||||
// set.Y[1] = aurora::gfx::new_dynamic_texture_2d(x6c_videoInfo.width, x6c_videoInfo.height / 2, 1, GX_TF_I8,
|
||||
// fmt::format("Movie {} Texture Set {} Y[1]", path,
|
||||
// i));
|
||||
// set.U = aurora::gfx::new_dynamic_texture_2d(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, 1, GX_TF_I8,
|
||||
// fmt::format("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("Movie {} Texture Set {} V", path, i));
|
||||
// } else {
|
||||
// /* normal progressive presentation */
|
||||
// set.Y[0] = aurora::gfx::new_dynamic_texture_2d(x6c_videoInfo.width, x6c_videoInfo.height, 1, GX_TF_I8,
|
||||
// fmt::format("Movie {} Texture Set {} Y", path,
|
||||
// i));
|
||||
// set.U = aurora::gfx::new_dynamic_texture_2d(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, 1, GX_TF_I8,
|
||||
// fmt::format("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("Movie {} Texture Set {} V", path, i));
|
||||
// }
|
||||
if (xf4_25_hasAudio)
|
||||
set.audioBuf.reset(new s16[x28_thpHead.maxAudioSamples * 2]);
|
||||
}
|
||||
|
@ -1159,8 +1159,7 @@ void CFrontEndUI::SFrontEndFrame::HandleActiveChange(CGuiTableGroup* active) {
|
||||
active->SetColors(zeus::skWhite, zeus::CColor{0.627450f, 0.627450f, 0.627450f, 0.784313f});
|
||||
}
|
||||
|
||||
void CFrontEndUI::SFrontEndFrame::DoCancel(CGuiTableGroup* caller) { /* Intentionally empty */
|
||||
}
|
||||
void CFrontEndUI::SFrontEndFrame::DoCancel(CGuiTableGroup* caller) { /* Intentionally empty */ }
|
||||
|
||||
void CFrontEndUI::SFrontEndFrame::DoSelectionChange(CGuiTableGroup* caller, int oldSel) {
|
||||
CSfxManager::SfxStart(SFXfnt_selection_change, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
|
||||
@ -1395,7 +1394,8 @@ void CFrontEndUI::SOptionsFrontEndFrame::DoMenuSelectionChange(CGuiTableGroup* c
|
||||
|
||||
if (option.option == EGameOption::Rumble && caller->GetUserSelection() > 0) {
|
||||
x40_rumbleGen.HardStopAll();
|
||||
x40_rumbleGen.Rumble(RumbleFxTable[size_t(ERumbleFxId::PlayerBump)], 1.f, ERumblePriority::One, EIOPort::Player1);
|
||||
x40_rumbleGen.Rumble(RumbleFxTable[size_t(ERumbleFxId::PlayerBump)], 1.f, ERumblePriority::One,
|
||||
EIOPort::Player1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1643,18 +1643,16 @@ CFrontEndUI::CFrontEndUI() : CIOWin("FrontEndUI") {
|
||||
|
||||
CFrontEndUI::~CFrontEndUI() {
|
||||
if (x14_phase >= EPhase::DisplayFrontEnd) {
|
||||
//CAudioSys::RemoveAudioGroup(x44_frontendAudioGrp->GetAudioGroupData());
|
||||
// CAudioSys::RemoveAudioGroup(x44_frontendAudioGrp->GetAudioGroupData());
|
||||
}
|
||||
}
|
||||
|
||||
void CFrontEndUI::StartSlideShow(CArchitectureQueue& queue) {
|
||||
//xf4_curAudio->StopMixing();
|
||||
// xf4_curAudio->StopMixing();
|
||||
queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11, std::make_shared<CSlideShow>()));
|
||||
}
|
||||
|
||||
std::string CFrontEndUI::GetAttractMovieFileName(int idx) {
|
||||
return fmt::format("Video/attract{}.thp", idx);
|
||||
}
|
||||
std::string CFrontEndUI::GetAttractMovieFileName(int idx) { return fmt::format("Video/attract{}.thp", idx); }
|
||||
|
||||
std::string CFrontEndUI::GetNextAttractMovieFileName() {
|
||||
std::string ret = GetAttractMovieFileName(xbc_nextAttract);
|
||||
@ -1771,9 +1769,9 @@ void CFrontEndUI::CompleteStateTransition() {
|
||||
case EScreen::FileSelect:
|
||||
SetCurrentMovie(EMenuMovie::FileSelectLoop);
|
||||
if (oldScreen == EScreen::Title) {
|
||||
//xf4_curAudio->StopMixing();
|
||||
//xf4_curAudio = xd8_audio2.get();
|
||||
//xf4_curAudio->StartMixing();
|
||||
// xf4_curAudio->StopMixing();
|
||||
// xf4_curAudio = xd8_audio2.get();
|
||||
// xf4_curAudio->StartMixing();
|
||||
}
|
||||
if (xdc_saveUI)
|
||||
xdc_saveUI->ResetCardDriver();
|
||||
@ -1829,8 +1827,8 @@ void CFrontEndUI::Draw() {
|
||||
g_Renderer->SetDepthReadWrite(false, false);
|
||||
const auto width = x38_pressStart->GetWidth();
|
||||
const auto height = x38_pressStart->GetHeight();
|
||||
CGraphics::Render2D(*x38_pressStart, 320 - width / 2, 72 - height / 2, width, height,
|
||||
zeus::CColor{1.f, x64_pressStartAlpha});
|
||||
CGraphics::Render2D(*x38_pressStart, 320 - (width / 2), 72 - (height / 2), width,
|
||||
height, zeus::CColor{1.f, x64_pressStartAlpha});
|
||||
}
|
||||
|
||||
if (xc0_attractCount > 0) {
|
||||
@ -1966,16 +1964,16 @@ void CFrontEndUI::ProcessUserInput(const CFinalInput& input, CArchitectureQueue&
|
||||
|
||||
if (x50_curScreen != x54_nextScreen) {
|
||||
if (x54_nextScreen == EScreen::AttractMovie &&
|
||||
(input.PStart() || input.PA() || input.PSpecialKey(ESpecialKey::Esc) ||
|
||||
input.PSpecialKey(ESpecialKey::Enter) || input.PMouseButton(EMouseButton::Primary))) {
|
||||
(input.PStart() || input.PA() || input.PSpecialKey(ESpecialKey::Esc) || input.PSpecialKey(ESpecialKey::Enter) ||
|
||||
input.PMouseButton(EMouseButton::Primary))) {
|
||||
/* Player wants to return to opening credits from attract movie */
|
||||
SetFadeBlackTimer(std::min(1.f, x58_fadeBlackTimer));
|
||||
PlayAdvanceSfx();
|
||||
return;
|
||||
}
|
||||
|
||||
if (input.PA() || input.PStart() || input.PSpecialKey(ESpecialKey::Esc) ||
|
||||
input.PSpecialKey(ESpecialKey::Enter) || input.PMouseButton(EMouseButton::Primary)) {
|
||||
if (input.PA() || input.PStart() || input.PSpecialKey(ESpecialKey::Esc) || input.PSpecialKey(ESpecialKey::Enter) ||
|
||||
input.PMouseButton(EMouseButton::Primary)) {
|
||||
if (x50_curScreen == EScreen::OpenCredits && x54_nextScreen == EScreen::Title && x58_fadeBlackTimer > 1.f) {
|
||||
/* Player is too impatient to view opening credits */
|
||||
xd0_playerSkipToTitle = true;
|
||||
@ -2046,7 +2044,7 @@ void CFrontEndUI::ProcessUserInput(const CFinalInput& input, CArchitectureQueue&
|
||||
StartStateTransition(EScreen::FileSelect);
|
||||
return;
|
||||
case SFusionBonusFrame::EAction::PlayNESMetroid:
|
||||
//xf4_curAudio->StopMixing();
|
||||
// xf4_curAudio->StopMixing();
|
||||
xec_emuFrme = std::make_unique<SNesEmulatorFrame>();
|
||||
if (xdc_saveUI)
|
||||
xdc_saveUI->SetInGame(true);
|
||||
@ -2119,9 +2117,9 @@ CIOWin::EMessageReturn CFrontEndUI::Update(float dt, CArchitectureQueue& queue)
|
||||
}
|
||||
xe8_frontendNoCardFrme = std::make_unique<SFrontEndFrame>(x1c_rndB);
|
||||
x38_pressStart.GetObj();
|
||||
//CAudioSys::AddAudioGroup(x44_frontendAudioGrp->GetAudioGroupData());
|
||||
// xd4_audio1 = std::make_unique<CStaticAudioPlayer>("Audio/frontend_1.rsf", 416480, 1973664);
|
||||
// xd8_audio2 = std::make_unique<CStaticAudioPlayer>("Audio/frontend_2.rsf", 273556, 1636980);
|
||||
// CAudioSys::AddAudioGroup(x44_frontendAudioGrp->GetAudioGroupData());
|
||||
// xd4_audio1 = std::make_unique<CStaticAudioPlayer>("Audio/frontend_1.rsf", 416480, 1973664);
|
||||
// xd8_audio2 = std::make_unique<CStaticAudioPlayer>("Audio/frontend_2.rsf", 273556, 1636980);
|
||||
x14_phase = EPhase::LoadFrames;
|
||||
}
|
||||
if (x14_phase == EPhase::LoadDeps)
|
||||
@ -2136,8 +2134,8 @@ CIOWin::EMessageReturn CFrontEndUI::Update(float dt, CArchitectureQueue& queue)
|
||||
if (/*!xd4_audio1->IsReady() || !xd8_audio2->IsReady() || */ !xe0_frontendCardFrme->PumpLoad() ||
|
||||
!xe8_frontendNoCardFrme->PumpLoad() || !xdc_saveUI->PumpLoad())
|
||||
return EMessageReturn::Exit;
|
||||
// xf4_curAudio = xd4_audio1.get();
|
||||
// xf4_curAudio->StartMixing();
|
||||
// xf4_curAudio = xd4_audio1.get();
|
||||
// xf4_curAudio->StartMixing();
|
||||
x14_phase = EPhase::LoadMovies;
|
||||
[[fallthrough]];
|
||||
|
||||
@ -2178,7 +2176,7 @@ CIOWin::EMessageReturn CFrontEndUI::Update(float dt, CArchitectureQueue& queue)
|
||||
xec_emuFrme.reset();
|
||||
if (xdc_saveUI)
|
||||
xdc_saveUI->SetInGame(false);
|
||||
//xf4_curAudio->StartMixing();
|
||||
// xf4_curAudio->StartMixing();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -2186,7 +2184,7 @@ CIOWin::EMessageReturn CFrontEndUI::Update(float dt, CArchitectureQueue& queue)
|
||||
if (xd2_deferSlideShow) {
|
||||
/* Start mixing slideshow music */
|
||||
xd2_deferSlideShow = false;
|
||||
//xf4_curAudio->StartMixing();
|
||||
// xf4_curAudio->StartMixing();
|
||||
if (xdc_saveUI)
|
||||
xdc_saveUI->ResetCardDriver();
|
||||
}
|
||||
|
2
extern/aurora
vendored
2
extern/aurora
vendored
@ -1 +1 @@
|
||||
Subproject commit fee77b3d2592b3ec18af9a70e285e7e8515b29ca
|
||||
Subproject commit 788c65592f07c3ca8e8b8bff303f4777fd2dd0cd
|
Loading…
x
Reference in New Issue
Block a user