Skip to content

Commit

Permalink
#38
Browse files Browse the repository at this point in the history
- Added 2 new screen layouts: FlippedHybridTop and FlippedHybridBottom. These work the same as the ordinary hybrid screens, but features the large screen on the right hand side.
  • Loading branch information
roblar91 authored and JesseTG committed Oct 17, 2024
1 parent c6f9548 commit 6e913db
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/libretro/config/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ namespace MelonDsDs::config {
static constexpr const char *const ENGLISH = "en";
static constexpr const char *const EXISTING = "existing";
static constexpr const char *const FIRMWARE = "firmware";
static constexpr const char *const FLIPPED_HYBRID_BOTTOM = "flipped-hybrid-bottom";
static constexpr const char *const FLIPPED_HYBRID_TOP = "flipped-hybrid-top";
static constexpr const char *const FRENCH = "fr";
static constexpr const char *const GERMAN = "de";
static constexpr const char *const HOLD = "hold";
Expand Down
16 changes: 16 additions & 0 deletions src/libretro/config/definitions/screen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ namespace MelonDsDs::config::definitions {
{MelonDsDs::config::values::BOTTOM, "Bottom Only"},
{MelonDsDs::config::values::HYBRID_TOP, "Hybrid (Focus Top)"},
{MelonDsDs::config::values::HYBRID_BOTTOM, "Hybrid (Focus Bottom)"},
{MelonDsDs::config::values::FLIPPED_HYBRID_TOP, "Flipped Hybrid (Focus Top)"},
{MelonDsDs::config::values::FLIPPED_HYBRID_BOTTOM, "Flipped Hybrid (Focus Bottom)"},
{MelonDsDs::config::values::ROTATE_LEFT, "Rotated Left"},
{MelonDsDs::config::values::ROTATE_RIGHT, "Rotated Right"},
{MelonDsDs::config::values::UPSIDE_DOWN, "Upside Down"},
Expand All @@ -326,6 +328,8 @@ namespace MelonDsDs::config::definitions {
{MelonDsDs::config::values::BOTTOM, "Bottom Only"},
{MelonDsDs::config::values::HYBRID_TOP, "Hybrid (Focus Top)"},
{MelonDsDs::config::values::HYBRID_BOTTOM, "Hybrid (Focus Bottom)"},
{MelonDsDs::config::values::FLIPPED_HYBRID_TOP, "Flipped Hybrid (Focus Top)"},
{MelonDsDs::config::values::FLIPPED_HYBRID_BOTTOM, "Flipped Hybrid (Focus Bottom)"},
{MelonDsDs::config::values::ROTATE_LEFT, "Rotated Left"},
{MelonDsDs::config::values::ROTATE_RIGHT, "Rotated Right"},
{MelonDsDs::config::values::UPSIDE_DOWN, "Upside Down"},
Expand All @@ -350,6 +354,8 @@ namespace MelonDsDs::config::definitions {
{MelonDsDs::config::values::BOTTOM, "Bottom Only"},
{MelonDsDs::config::values::HYBRID_TOP, "Hybrid (Focus Top)"},
{MelonDsDs::config::values::HYBRID_BOTTOM, "Hybrid (Focus Bottom)"},
{MelonDsDs::config::values::FLIPPED_HYBRID_TOP, "Flipped Hybrid (Focus Top)"},
{MelonDsDs::config::values::FLIPPED_HYBRID_BOTTOM, "Flipped Hybrid (Focus Bottom)"},
{MelonDsDs::config::values::ROTATE_LEFT, "Rotated Left"},
{MelonDsDs::config::values::ROTATE_RIGHT, "Rotated Right"},
{MelonDsDs::config::values::UPSIDE_DOWN, "Upside Down"},
Expand All @@ -374,6 +380,8 @@ namespace MelonDsDs::config::definitions {
{MelonDsDs::config::values::BOTTOM, "Bottom Only"},
{MelonDsDs::config::values::HYBRID_TOP, "Hybrid (Focus Top)"},
{MelonDsDs::config::values::HYBRID_BOTTOM, "Hybrid (Focus Bottom)"},
{MelonDsDs::config::values::FLIPPED_HYBRID_TOP, "Flipped Hybrid (Focus Top)"},
{MelonDsDs::config::values::FLIPPED_HYBRID_BOTTOM, "Flipped Hybrid (Focus Bottom)"},
{MelonDsDs::config::values::ROTATE_LEFT, "Rotated Left"},
{MelonDsDs::config::values::ROTATE_RIGHT, "Rotated Right"},
{MelonDsDs::config::values::UPSIDE_DOWN, "Upside Down"},
Expand All @@ -398,6 +406,8 @@ namespace MelonDsDs::config::definitions {
{MelonDsDs::config::values::BOTTOM, "Bottom Only"},
{MelonDsDs::config::values::HYBRID_TOP, "Hybrid (Focus Top)"},
{MelonDsDs::config::values::HYBRID_BOTTOM, "Hybrid (Focus Bottom)"},
{MelonDsDs::config::values::FLIPPED_HYBRID_TOP, "Flipped Hybrid (Focus Top)"},
{MelonDsDs::config::values::FLIPPED_HYBRID_BOTTOM, "Flipped Hybrid (Focus Bottom)"},
{MelonDsDs::config::values::ROTATE_LEFT, "Rotated Left"},
{MelonDsDs::config::values::ROTATE_RIGHT, "Rotated Right"},
{MelonDsDs::config::values::UPSIDE_DOWN, "Upside Down"},
Expand All @@ -422,6 +432,8 @@ namespace MelonDsDs::config::definitions {
{MelonDsDs::config::values::BOTTOM, "Bottom Only"},
{MelonDsDs::config::values::HYBRID_TOP, "Hybrid (Focus Top)"},
{MelonDsDs::config::values::HYBRID_BOTTOM, "Hybrid (Focus Bottom)"},
{MelonDsDs::config::values::FLIPPED_HYBRID_TOP, "Flipped Hybrid (Focus Top)"},
{MelonDsDs::config::values::FLIPPED_HYBRID_BOTTOM, "Flipped Hybrid (Focus Bottom)"},
{MelonDsDs::config::values::ROTATE_LEFT, "Rotated Left"},
{MelonDsDs::config::values::ROTATE_RIGHT, "Rotated Right"},
{MelonDsDs::config::values::UPSIDE_DOWN, "Upside Down"},
Expand All @@ -446,6 +458,8 @@ namespace MelonDsDs::config::definitions {
{MelonDsDs::config::values::BOTTOM, "Bottom Only"},
{MelonDsDs::config::values::HYBRID_TOP, "Hybrid (Focus Top)"},
{MelonDsDs::config::values::HYBRID_BOTTOM, "Hybrid (Focus Bottom)"},
{MelonDsDs::config::values::FLIPPED_HYBRID_TOP, "Flipped Hybrid (Focus Top)"},
{MelonDsDs::config::values::FLIPPED_HYBRID_BOTTOM, "Flipped Hybrid (Focus Bottom)"},
{MelonDsDs::config::values::ROTATE_LEFT, "Rotated Left"},
{MelonDsDs::config::values::ROTATE_RIGHT, "Rotated Right"},
{MelonDsDs::config::values::UPSIDE_DOWN, "Upside Down"},
Expand All @@ -470,6 +484,8 @@ namespace MelonDsDs::config::definitions {
{MelonDsDs::config::values::BOTTOM, "Bottom Only"},
{MelonDsDs::config::values::HYBRID_TOP, "Hybrid (Focus Top)"},
{MelonDsDs::config::values::HYBRID_BOTTOM, "Hybrid (Focus Bottom)"},
{MelonDsDs::config::values::FLIPPED_HYBRID_TOP, "Flipped Hybrid (Focus Top)"},
{MelonDsDs::config::values::FLIPPED_HYBRID_BOTTOM, "Flipped Hybrid (Focus Bottom)"},
{MelonDsDs::config::values::ROTATE_LEFT, "Rotated Left"},
{MelonDsDs::config::values::ROTATE_RIGHT, "Rotated Right"},
{MelonDsDs::config::values::UPSIDE_DOWN, "Upside Down"},
Expand Down
2 changes: 2 additions & 0 deletions src/libretro/config/parse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ namespace MelonDsDs {
if (value == config::values::BOTTOM) return ScreenLayout::BottomOnly;
if (value == config::values::HYBRID_TOP) return ScreenLayout::HybridTop;
if (value == config::values::HYBRID_BOTTOM) return ScreenLayout::HybridBottom;
if (value == config::values::FLIPPED_HYBRID_TOP) return ScreenLayout::FlippedHybridTop;
if (value == config::values::FLIPPED_HYBRID_BOTTOM) return ScreenLayout::FlippedHybridBottom;
if (value == config::values::ROTATE_LEFT) return ScreenLayout::TurnLeft;
if (value == config::values::ROTATE_RIGHT) return ScreenLayout::TurnRight;
if (value == config::values::UPSIDE_DOWN) return ScreenLayout::UpsideDown;
Expand Down
8 changes: 5 additions & 3 deletions src/libretro/config/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ namespace MelonDsDs {
BottomOnly = 5,
HybridTop = 6,
HybridBottom = 7,
TurnLeft = 8,
TurnRight = 9,
UpsideDown = 10,
FlippedHybridTop = 8,
FlippedHybridBottom = 9,
TurnLeft = 10,
TurnRight = 11,
UpsideDown = 12,
};

enum class HybridSideScreenDisplay {
Expand Down
6 changes: 6 additions & 0 deletions src/libretro/format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,12 @@ auto fmt::formatter<MelonDsDs::ScreenLayout>::format(MelonDsDs::ScreenLayout lay
case MelonDsDs::ScreenLayout::HybridBottom:
name = "HybridBottom";
break;
case MelonDsDs::ScreenLayout::FlippedHybridTop:
name = "FlippedHybridTop";
break;
case MelonDsDs::ScreenLayout::FlippedHybridBottom:
name = "FlippedHybridBottom";
break;
case MelonDsDs::ScreenLayout::TurnLeft:
name = "TurnLeft";
break;
Expand Down
1 change: 1 addition & 0 deletions src/libretro/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ glm::uvec2 MelonDsDs::InputState::ConsoleTouchCoordinates(const ScreenLayoutData

switch (layout.Layout()) {
case ScreenLayout::HybridBottom:
case ScreenLayout::FlippedHybridBottom:
if (layout.HybridSmallScreenLayout() == HybridSideScreenDisplay::One) {
// If the touch screen is only shown in the hybrid-screen position...
clampedTouch = clamp(hybridTouchPosition, ivec2(0), NDS_SCREEN_SIZE<int> - 1);
Expand Down
6 changes: 6 additions & 0 deletions src/libretro/render/opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,15 @@ constexpr array<unsigned, 18> GetPositionIndexes(MelonDsDs::ScreenLayout layout)
}
break;
case ScreenLayout::HybridTop:
case ScreenLayout::FlippedHybridTop:
for (unsigned i = 0; i < VERTEXES_PER_SCREEN; ++i) {
indexes[i] = hybridPositionIndexes[i];
indexes[i + VERTEXES_PER_SCREEN] = bottomPositionIndexes[i];
indexes[i + VERTEXES_PER_SCREEN*2] = topPositionIndexes[i];
}
break;
case ScreenLayout::HybridBottom:
case ScreenLayout::FlippedHybridBottom:
for (unsigned i = 0; i < VERTEXES_PER_SCREEN; ++i) {
indexes[i] = hybridPositionIndexes[i];
indexes[i + VERTEXES_PER_SCREEN] = topPositionIndexes[i];
Expand All @@ -118,6 +120,8 @@ constexpr unsigned GetVertexCount(ScreenLayout layout, MelonDsDs::HybridSideScre
return 6; // 1 screen, 2 triangles
case ScreenLayout::HybridTop:
case ScreenLayout::HybridBottom:
case ScreenLayout::FlippedHybridTop:
case ScreenLayout::FlippedHybridBottom:
if (hybridScreen == MelonDsDs::HybridSideScreenDisplay::Both)
return 18; // 3 screens, 6 triangles
[[fallthrough]];
Expand Down Expand Up @@ -566,6 +570,7 @@ void MelonDsDs::OpenGLRenderState::InitVertices(const ScreenLayoutData& screenLa
}
break;
case ScreenLayout::HybridTop:
case ScreenLayout::FlippedHybridTop:
for (unsigned i = 0; i < VERTEXES_PER_SCREEN; ++i) {
// Hybrid screen
screen_vertices[i] = {
Expand All @@ -588,6 +593,7 @@ void MelonDsDs::OpenGLRenderState::InitVertices(const ScreenLayoutData& screenLa
}
break;
case ScreenLayout::HybridBottom:
case ScreenLayout::FlippedHybridBottom:
for (unsigned i = 0; i < VERTEXES_PER_SCREEN; ++i) {
// Hybrid screen
screen_vertices[i] = {
Expand Down
6 changes: 3 additions & 3 deletions src/libretro/render/software.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ void MelonDsDs::SoftwareRenderState::CombineScreens(
ScreenLayout layout = screenLayout.Layout();

if (IsHybridLayout(layout)) {
auto primaryBuffer = layout == ScreenLayout::HybridTop ? topBuffer : bottomBuffer;
auto primaryBuffer = layout == ScreenLayout::HybridTop || layout == ScreenLayout::FlippedHybridTop ? topBuffer : bottomBuffer;

hybridScaler.Scale(hybridBuffer[0], primaryBuffer.data());
buffer.CopyRows(
Expand All @@ -179,12 +179,12 @@ void MelonDsDs::SoftwareRenderState::CombineScreens(

HybridSideScreenDisplay smallScreenLayout = screenLayout.HybridSmallScreenLayout();

if (smallScreenLayout == HybridSideScreenDisplay::Both || layout == ScreenLayout::HybridBottom) {
if (smallScreenLayout == HybridSideScreenDisplay::Both || layout == ScreenLayout::HybridBottom || layout == ScreenLayout::FlippedHybridBottom) {
// If we should display both screens, or if the bottom one is the primary...
buffer.CopyRows(topBuffer.data(), screenLayout.GetTopScreenTranslation(), NDS_SCREEN_SIZE<unsigned>);
}

if (smallScreenLayout == HybridSideScreenDisplay::Both || layout == ScreenLayout::HybridTop) {
if (smallScreenLayout == HybridSideScreenDisplay::Both || layout == ScreenLayout::HybridTop || layout == ScreenLayout::FlippedHybridTop) {
// If we should display both screens, or if the top one is being focused...
buffer.CopyRows(bottomBuffer.data(), screenLayout.GetBottomScreenTranslation(), NDS_SCREEN_SIZE<unsigned>);
}
Expand Down
36 changes: 36 additions & 0 deletions src/libretro/screenlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,33 @@ constexpr mat3 HybridSoutheastMatrix(unsigned resolutionScale, unsigned hybridRa
);
}

/// For the east flipped hybrid screen
constexpr mat3 FlippedHybridEastMatrix(unsigned resolutionScale, unsigned hybridRatio) noexcept {
using namespace MelonDsDs;
return math::ts<float>(
vec2(resolutionScale * NDS_SCREEN_WIDTH, 0),
vec2(resolutionScale * hybridRatio)
);
}

/// For the northwest flipped hybrid screen
constexpr mat3 FlippedHybridNorthwestMatrix(unsigned resolutionScale, unsigned hybridRatio) noexcept {
using namespace MelonDsDs;
return math::ts<float>(
vec2(0),
vec2(resolutionScale)
);
}

/// For the southwest flipped hybrid screen
constexpr mat3 FlippedHybridSouthwestMatrix(unsigned resolutionScale, unsigned hybridRatio) noexcept {
using namespace MelonDsDs;
return math::ts<float>(
vec2(0, resolutionScale * NDS_SCREEN_HEIGHT * (hybridRatio - 1)),
vec2(resolutionScale)
);
}

mat3 MelonDsDs::ScreenLayoutData::GetTopScreenMatrix(unsigned scale) const noexcept {
ZoneScopedN(TracyFunction);
switch (Layout()) {
Expand All @@ -125,6 +152,9 @@ mat3 MelonDsDs::ScreenLayoutData::GetTopScreenMatrix(unsigned scale) const noexc
case ScreenLayout::HybridTop:
case ScreenLayout::HybridBottom:
return HybridNortheastMatrix(scale, hybridRatio);
case ScreenLayout::FlippedHybridTop:
case ScreenLayout::FlippedHybridBottom:
return FlippedHybridNorthwestMatrix(scale, hybridRatio);
default:
return mat3(1);
}
Expand All @@ -147,6 +177,9 @@ mat3 MelonDsDs::ScreenLayoutData::GetBottomScreenMatrix(unsigned scale) const no
case ScreenLayout::HybridTop:
case ScreenLayout::HybridBottom:
return HybridSoutheastMatrix(scale, hybridRatio);
case ScreenLayout::FlippedHybridTop:
case ScreenLayout::FlippedHybridBottom:
return FlippedHybridSouthwestMatrix(scale, hybridRatio);
default:
return mat3(1);
}
Expand All @@ -158,6 +191,9 @@ glm::mat3 MelonDsDs::ScreenLayoutData::GetHybridScreenMatrix(unsigned scale) con
case ScreenLayout::HybridBottom:
case ScreenLayout::HybridTop:
return HybridWestMatrix(scale, hybridRatio);
case ScreenLayout::FlippedHybridBottom:
case ScreenLayout::FlippedHybridTop:
return FlippedHybridEastMatrix(scale, hybridRatio);
default:
return mat3(1);
}
Expand Down
2 changes: 2 additions & 0 deletions src/libretro/screenlayout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ namespace MelonDsDs {
switch (layout) {
case ScreenLayout::HybridTop:
case ScreenLayout::HybridBottom:
case ScreenLayout::FlippedHybridTop:
case ScreenLayout::FlippedHybridBottom:
return true;
default:
return false;
Expand Down

0 comments on commit 6e913db

Please sign in to comment.