Skip to content

Commit 1e71088

Browse files
committed
Add single screen layouts
1 parent b41cb3b commit 1e71088

File tree

9 files changed

+73
-32
lines changed

9 files changed

+73
-32
lines changed

src/android/java/com/hydra/noods/NooRenderer.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,10 @@ public void onDrawFrame(GL10 unused)
180180
else
181181
{
182182
// Draw the DS top and bottom screens
183-
drawScreen(getTopX(), getTopY(), getTopWidth(), getTopHeight(), 0.0f, 0.0f, 1.0f, 0.5f);
184-
drawScreen(getBotX(), getBotY(), getBotWidth(), getBotHeight(), 0.0f, 0.5f, 1.0f, 1.0f);
183+
if (SettingsMenu.getScreenArrangement() != 3 || SettingsMenu.getScreenSizing() < 2)
184+
drawScreen(getTopX(), getTopY(), getTopWidth(), getTopHeight(), 0.0f, 0.0f, 1.0f, 0.5f);
185+
if (SettingsMenu.getScreenArrangement() != 3 || SettingsMenu.getScreenSizing() == 2)
186+
drawScreen(getBotX(), getBotY(), getBotWidth(), getBotHeight(), 0.0f, 0.5f, 1.0f, 1.0f);
185187
}
186188
}
187189

src/android/res/values/arrays.xml

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<item>Automatic</item>
3333
<item>Vertical</item>
3434
<item>Horizontal</item>
35+
<item>Single Screen</item>
3536
</string-array>
3637

3738
<string-array name="screen_sizing_entries">

src/common/screen_layout.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ void ScreenLayout::update(int winWidth, int winHeight, bool gbaMode)
5252
this->winWidth = winWidth;
5353
this->winHeight = winHeight;
5454

55-
if (gbaMode && gbaCrop)
55+
if (screenArrangement == 3 || (gbaMode && gbaCrop)) // Single screen
5656
{
5757
// Determine the screen dimensions based on the current rotation
58-
int width = (screenRotation ? 160 : 240);
59-
int height = (screenRotation ? 240 : 160);
58+
int width = (gbaMode && gbaCrop) ? (screenRotation ? 160 : 240) : (screenRotation ? 192 : 256);
59+
int height = (gbaMode && gbaCrop) ? (screenRotation ? 240 : 160) : (screenRotation ? 256 : 192);
6060

6161
// Set the minimum dimensions for the layout
6262
minWidth = width;
@@ -71,26 +71,26 @@ void ScreenLayout::update(int winWidth, int winHeight, bool gbaMode)
7171
if (integerScale) scale = (int)scale;
7272

7373
// Calculate the dimensions of the screen
74-
topWidth = scale * width;
75-
topHeight = scale * height;
74+
topWidth = botWidth = scale * width;
75+
topHeight = botHeight = scale * height;
7676

7777
// Position the screen horizontally
7878
if (screenPosition == 3) // Left
79-
topX = 0;
79+
topX = botX = 0;
8080
else if (screenPosition == 4) // Right
81-
topX = winWidth - topWidth;
81+
topX = botX = winWidth - topWidth;
8282
else // Center, Top, Bottom
83-
topX = (winWidth - topWidth) / 2;
83+
topX = botX = (winWidth - topWidth) / 2;
8484

8585
// Position the screen vertically
8686
if (screenPosition == 1) // Top
87-
topY = 0;
87+
topY = botY = 0;
8888
else if (screenPosition == 2) // Bottom
89-
topY = winHeight - topHeight;
89+
topY = botY = winHeight - topHeight;
9090
else // Center, Left, Right
91-
topY = (winHeight - topHeight) / 2;
91+
topY = botY = (winHeight - topHeight) / 2;
9292
}
93-
else // NDS mode
93+
else // Dual screens
9494
{
9595
// Determine the screen arrangement based on the current settings
9696
// In automatic mode, the arrangement is horizontal if rotated and vertical otherwise

src/console/console_ui.cpp

+15-9
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ bool ConsoleUI::running;
5353
std::string ConsoleUI::ndsPath, ConsoleUI::gbaPath;
5454
std::string ConsoleUI::basePath, ConsoleUI::curPath;
5555

56-
ScreenLayout ConsoleUI::layout;
5756
uint32_t ConsoleUI::framebuffer[256 * 192 * 8];
57+
ScreenLayout ConsoleUI::layout;
5858
bool ConsoleUI::gbaMode;
5959
bool ConsoleUI::changed;
6060

@@ -249,14 +249,20 @@ void ConsoleUI::mainLoop(MenuTouch (*specialTouch)(), ScreenLayout *touchLayout)
249249
else // DS mode
250250
{
251251
// Draw the DS top screen
252-
topTexture = createTexture(&framebuffer[0], 256 << shift, 192 << shift);
253-
drawTexture(topTexture, 0, 0, 256 << shift, 192 << shift, layout.topX, layout.topY,
254-
layout.topWidth, layout.topHeight, screenFilter, ScreenLayout::screenRotation);
252+
if (ScreenLayout::screenArrangement != 3 || ScreenLayout::screenSizing < 2)
253+
{
254+
topTexture = createTexture(&framebuffer[0], 256 << shift, 192 << shift);
255+
drawTexture(topTexture, 0, 0, 256 << shift, 192 << shift, layout.topX, layout.topY,
256+
layout.topWidth, layout.topHeight, screenFilter, ScreenLayout::screenRotation);
257+
}
255258

256259
// Draw the DS bottom screen
257-
botTexture = createTexture(&framebuffer[(256 * 192) << (shift * 2)], 256 << shift, 192 << shift);
258-
drawTexture(botTexture, 0, 0, 256 << shift, 192 << shift, layout.botX, layout.botY,
259-
layout.botWidth, layout.botHeight, screenFilter, ScreenLayout::screenRotation);
260+
if (ScreenLayout::screenArrangement != 3 || ScreenLayout::screenSizing == 2)
261+
{
262+
botTexture = createTexture(&framebuffer[(256 * 192) << (shift * 2)], 256 << shift, 192 << shift);
263+
drawTexture(botTexture, 0, 0, 256 << shift, 192 << shift, layout.botX, layout.botY,
264+
layout.botWidth, layout.botHeight, screenFilter, ScreenLayout::screenRotation);
265+
}
260266
}
261267

262268
// Draw the FPS counter if enabled
@@ -755,7 +761,7 @@ void ConsoleUI::settingsMenu()
755761
const std::vector<std::string> toggle = { "Off", "On" };
756762
const std::vector<std::string> position = { "Center", "Top", "Bottom", "Left", "Right" };
757763
const std::vector<std::string> rotation = { "None", "Clockwise", "Counter-Clockwise" };
758-
const std::vector<std::string> arrangement = { "Automatic", "Vertical", "Horizontal" };
764+
const std::vector<std::string> arrangement = { "Automatic", "Vertical", "Horizontal", "Single Screen" };
759765
const std::vector<std::string> sizing = { "Even", "Enlarge Top", "Enlarge Bottom" };
760766
const std::vector<std::string> gap = { "None", "Quarter", "Half", "Full" };
761767
const std::vector<std::string> theme = { "Dark", "Light" };
@@ -799,7 +805,7 @@ void ConsoleUI::settingsMenu()
799805
case 4: Settings::highRes3D = (Settings::highRes3D + 1) % 2; break;
800806
case 5: ScreenLayout::screenPosition = (ScreenLayout::screenPosition + 1) % 5; break;
801807
case 6: ScreenLayout::screenRotation = (ScreenLayout::screenRotation + 1) % 3; break;
802-
case 7: ScreenLayout::screenArrangement = (ScreenLayout::screenArrangement + 1) % 3; break;
808+
case 7: ScreenLayout::screenArrangement = (ScreenLayout::screenArrangement + 1) % 4; break;
803809
case 8: ScreenLayout::screenSizing = (ScreenLayout::screenSizing + 1) % 3; break;
804810
case 9: ScreenLayout::screenGap = (ScreenLayout::screenGap + 1) % 4; break;
805811
case 10: ScreenLayout::integerScale = (ScreenLayout::integerScale + 1) % 2; break;

src/console/console_ui.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class ConsoleUI
7171
public:
7272
static Core *core;
7373
static bool running;
74+
static uint32_t framebuffer[256 * 192 * 8];
7475
static ScreenLayout layout;
7576
static bool gbaMode;
7677

@@ -111,7 +112,6 @@ class ConsoleUI
111112

112113
static std::string ndsPath, gbaPath;
113114
static std::string basePath, curPath;
114-
static uint32_t framebuffer[256 * 192 * 8];
115115
static bool changed;
116116

117117
static std::thread *coreThread, *saveThread;

src/console/main_wiiu.cpp

+20-1
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@
3232
#include <SDL2/SDL.h>
3333

3434
#include "console_ui.h"
35+
#include "../settings.h"
36+
3537
#define MAX_DRAWS 1024
3638
extern const uint8_t shader_wiiu_gsh[];
3739

3840
ScreenLayout gpLayout;
41+
GX2Texture *gpTexture;
3942
int tvWidth, tvHeight;
4043
int bufOffset;
4144
bool firstScreen;
@@ -72,6 +75,13 @@ void ConsoleUI::endFrame()
7275
WHBGfxFinishRenderDRC();
7376
WHBGfxFinishRender();
7477

78+
// Free the gamepad screen texture if it was overridden
79+
if (gpTexture)
80+
{
81+
destroyTexture(gpTexture);
82+
gpTexture = nullptr;
83+
}
84+
7585
// Reset the frame status
7686
bufOffset = 0;
7787
firstScreen = true;
@@ -194,12 +204,21 @@ void ConsoleUI::drawTexture(void *texture, float tx, float ty, float tw, float t
194204
GX2SetPixelSampler(&samplers[filter], group.pixelShader->samplerVars[0].location);
195205
GX2DrawEx(GX2_PRIMITIVE_MODE_QUADS, 4, 0, 1);
196206

207+
// Override the gamepad screen texture with the other screen in single screen mode
208+
GX2Texture *tempTexture = nullptr;
209+
if (running && tw >= 240 && ScreenLayout::screenArrangement == 3)
210+
{
211+
int shift = Settings::highRes3D;
212+
uint32_t *data = &ConsoleUI::framebuffer[(256 * 192 * (ScreenLayout::screenSizing < 2)) << (shift * 2)];
213+
tempTexture = gpTexture = (GX2Texture*)createTexture(data, 256 << shift, 192 << shift);
214+
}
215+
197216
// Draw a texture on the gamepad
198217
WHBGfxBeginRenderDRC();
199218
GX2RSetAttributeBuffer(&posBuffer, 0, posBuffer.elemSize, bufOffset * 2 + 8 * sizeof(float));
200219
GX2RSetAttributeBuffer(&texBuffer, 1, texBuffer.elemSize, bufOffset);
201220
GX2RSetAttributeBuffer(&colBuffer, 2, colBuffer.elemSize, bufOffset * 2);
202-
GX2SetPixelTexture((GX2Texture*)texture, group.pixelShader->samplerVars[0].location);
221+
GX2SetPixelTexture(tempTexture ? tempTexture : (GX2Texture*)texture, group.pixelShader->samplerVars[0].location);
203222
GX2SetPixelSampler(&samplers[filter], group.pixelShader->samplerVars[0].location);
204223
GX2DrawEx(GX2_PRIMITIVE_MODE_QUADS, 4, 0, 1);
205224

src/desktop/layout_dialog.cpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ enum LayoutEvent
3535
ARRANGE_AUTO,
3636
ARRANGE_VERT,
3737
ARRANGE_HORI,
38+
ARRANGE_SING,
3839
SIZE_EVEN,
3940
SIZE_TOP,
4041
SIZE_BOT,
@@ -59,6 +60,7 @@ EVT_RADIOBUTTON(ROTATE_CCW, LayoutDialog::rotateCcw)
5960
EVT_RADIOBUTTON(ARRANGE_AUTO, LayoutDialog::arrangeAuto)
6061
EVT_RADIOBUTTON(ARRANGE_VERT, LayoutDialog::arrangeVert)
6162
EVT_RADIOBUTTON(ARRANGE_HORI, LayoutDialog::arrangeHori)
63+
EVT_RADIOBUTTON(ARRANGE_SING, LayoutDialog::arrangeSing)
6264
EVT_RADIOBUTTON(SIZE_EVEN, LayoutDialog::sizeEven)
6365
EVT_RADIOBUTTON(SIZE_TOP, LayoutDialog::sizeTop)
6466
EVT_RADIOBUTTON(SIZE_BOT, LayoutDialog::sizeBot)
@@ -106,21 +108,22 @@ LayoutDialog::LayoutDialog(NooApp *app): wxDialog(nullptr, wxID_ANY, "Screen Lay
106108
wxRadioButton *rotateBtns[3];
107109
wxBoxSizer *rotateSizer = new wxBoxSizer(wxHORIZONTAL);
108110
rotateSizer->Add(new wxStaticText(this, wxID_ANY, "Rotation:", wxDefaultPosition,
109-
wxSize(wxDefaultSize.GetWidth(), size)), 1, wxALIGN_CENTRE | wxRIGHT, size / 8);
111+
wxSize(wxDefaultSize.GetWidth(), size)), 0, wxALIGN_CENTRE | wxRIGHT, size / 8);
110112
rotateSizer->Add(rotateBtns[0] = new wxRadioButton(this, ROTATE_NONE, "None",
111113
wxDefaultPosition, wxDefaultSize, wxRB_GROUP), 0, wxLEFT, size / 8);
112114
rotateSizer->Add(rotateBtns[1] = new wxRadioButton(this, ROTATE_CW, "Clockwise"), 0, wxLEFT, size / 8);
113115
rotateSizer->Add(rotateBtns[2] = new wxRadioButton(this, ROTATE_CCW, "Counter-Clockwise"), 0, wxLEFT, size / 8);
114116

115117
// Set up the arrangement settings
116-
wxRadioButton *arrangeBtns[3];
118+
wxRadioButton *arrangeBtns[4];
117119
wxBoxSizer *arrangeSizer = new wxBoxSizer(wxHORIZONTAL);
118120
arrangeSizer->Add(new wxStaticText(this, wxID_ANY, "Arrangement:", wxDefaultPosition,
119121
wxSize(wxDefaultSize.GetWidth(), size)), 0, wxALIGN_CENTRE | wxRIGHT, size / 8);
120122
arrangeSizer->Add(arrangeBtns[0] = new wxRadioButton(this, ARRANGE_AUTO, "Automatic",
121123
wxDefaultPosition, wxDefaultSize, wxRB_GROUP), 0, wxLEFT, size / 8);
122124
arrangeSizer->Add(arrangeBtns[1] = new wxRadioButton(this, ARRANGE_VERT, "Vertical"), 0, wxLEFT, size / 8);
123125
arrangeSizer->Add(arrangeBtns[2] = new wxRadioButton(this, ARRANGE_HORI, "Horizontal"), 0, wxLEFT, size / 8);
126+
arrangeSizer->Add(arrangeBtns[3] = new wxRadioButton(this, ARRANGE_SING, "Single Screen"), 0, wxLEFT, size / 8);
124127

125128
// Set up the sizing settings
126129
wxRadioButton *sizeBtns[3];
@@ -155,7 +158,7 @@ LayoutDialog::LayoutDialog(NooApp *app): wxDialog(nullptr, wxID_ANY, "Screen Lay
155158
posBtns[ScreenLayout::screenPosition]->SetValue(true);
156159
if (ScreenLayout::screenRotation < 3)
157160
rotateBtns[ScreenLayout::screenRotation]->SetValue(true);
158-
if (ScreenLayout::screenArrangement < 3)
161+
if (ScreenLayout::screenArrangement < 4)
159162
arrangeBtns[ScreenLayout::screenArrangement]->SetValue(true);
160163
if (ScreenLayout::screenSizing < 3)
161164
sizeBtns[ScreenLayout::screenSizing]->SetValue(true);
@@ -271,6 +274,13 @@ void LayoutDialog::arrangeHori(wxCommandEvent &event)
271274
app->updateLayouts();
272275
}
273276

277+
void LayoutDialog::arrangeSing(wxCommandEvent &event)
278+
{
279+
// Set the screen arrangement setting to single screen
280+
ScreenLayout::screenArrangement = 3;
281+
app->updateLayouts();
282+
}
283+
274284
void LayoutDialog::sizeEven(wxCommandEvent &event)
275285
{
276286
// Set the screen sizing setting to even

src/desktop/layout_dialog.h

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class LayoutDialog: public wxDialog
4545
void arrangeAuto(wxCommandEvent &event);
4646
void arrangeVert(wxCommandEvent &event);
4747
void arrangeHori(wxCommandEvent &event);
48+
void arrangeSing(wxCommandEvent &event);
4849
void sizeEven(wxCommandEvent &event);
4950
void sizeTop(wxCommandEvent &event);
5051
void sizeBot(wxCommandEvent &event);

src/desktop/noo_canvas.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,12 @@ void NooCanvas::draw(wxPaintEvent &event)
151151
else
152152
{
153153
// Draw the DS top and bottom screens
154-
drawScreen(layout.topX, layout.topY, layout.topWidth, layout.topHeight,
155-
256 << resShift, 192 << resShift, &framebuffer[0]);
156-
drawScreen(layout.botX, layout.botY, layout.botWidth, layout.botHeight,
157-
256 << resShift, 192 << resShift, &framebuffer[(256 * 192) << (resShift * 2)]);
154+
if (ScreenLayout::screenArrangement != 3 || ScreenLayout::screenSizing < 2)
155+
drawScreen(layout.topX, layout.topY, layout.topWidth, layout.topHeight,
156+
256 << resShift, 192 << resShift, &framebuffer[0]);
157+
if (ScreenLayout::screenArrangement != 3 || ScreenLayout::screenSizing == 2)
158+
drawScreen(layout.botX, layout.botY, layout.botWidth, layout.botHeight,
159+
256 << resShift, 192 << resShift, &framebuffer[(256 * 192) << (resShift * 2)]);
158160
}
159161
}
160162

0 commit comments

Comments
 (0)