@@ -55,9 +55,21 @@ NooCanvas::NooCanvas(NooFrame *frame): CANVAS_CLASS(frame, wxID_ANY, CANVAS_PARA
55
55
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
56
56
#endif
57
57
58
- // Set focus so that key presses will be registered
59
- SetFocus ();
58
+ // Create a new framebuffer or share one if the screens are split
59
+ if (frame->mainFrame )
60
+ {
61
+ framebuffer = new uint32_t [256 * 192 * 8 ];
62
+ memset (framebuffer, 0 , 256 * 192 * 8 * sizeof (uint32_t ));
63
+ }
64
+ else
65
+ {
66
+ framebuffer = frame->partner ->canvas ->framebuffer ;
67
+ }
68
+
69
+ // Update the screen layout and set focus for key presses
70
+ splitScreens = NooApp::splitScreens && ScreenLayout::screenArrangement != 3 ;
60
71
frame->SendSizeEvent ();
72
+ SetFocus ();
61
73
}
62
74
63
75
void NooCanvas::drawScreen (int x, int y, int w, int h, int wb, int hb, uint32_t *buf)
@@ -123,20 +135,22 @@ void NooCanvas::draw(wxPaintEvent &event)
123
135
glClear (GL_COLOR_BUFFER_BIT);
124
136
#endif
125
137
126
- if (frame->getCore ())
138
+ // Update the screen layout if it changed
139
+ bool gba = ScreenLayout::gbaCrop && frame->core && frame->core ->gbaMode ;
140
+ bool split = NooApp::splitScreens && ScreenLayout::screenArrangement != 3 && !gba;
141
+ if (gbaMode != gba || splitScreens != split)
127
142
{
128
- // Update the layout if GBA mode changed
129
- bool gba = (frame->getCore ()->gbaMode && ScreenLayout::gbaCrop);
130
- if (gbaMode != gba)
131
- {
132
- gbaMode = gba;
133
- frame->SendSizeEvent ();
134
- }
143
+ gbaMode = gba;
144
+ splitScreens = split;
145
+ frame->SendSizeEvent ();
146
+ }
135
147
148
+ if (frame->core )
149
+ {
136
150
// Emulation is limited by audio, so frames aren't always generated at a consistent rate
137
151
// This can mess up frame pacing at higher refresh rates when frames are ready too soon
138
152
// To solve this, use a software-based swap interval to wait before getting the next frame
139
- if (++frameCount >= swapInterval && frame->getCore () ->gpu .getFrame (framebuffer, gba))
153
+ if (frame-> mainFrame && ++frameCount >= swapInterval && frame->core ->gpu .getFrame (framebuffer, gba))
140
154
frameCount = 0 ;
141
155
142
156
// Shift the screen resolutions if high-res is enabled
@@ -148,6 +162,12 @@ void NooCanvas::draw(wxPaintEvent &event)
148
162
drawScreen (layout.topX , layout.topY , layout.topWidth ,
149
163
layout.topHeight , 240 << shift, 160 << shift, &framebuffer[0 ]);
150
164
}
165
+ else if (frame->partner )
166
+ {
167
+ // Draw one of the DS screens
168
+ drawScreen (layout.topX , layout.topY , layout.topWidth , layout.topHeight , 256 << shift,
169
+ 192 << shift, &framebuffer[!frame->mainFrame * ((256 * 192 ) << (shift * 2 ))]);
170
+ }
151
171
else
152
172
{
153
173
// Draw the DS top and bottom screens
@@ -181,7 +201,7 @@ void NooCanvas::resize(wxSizeEvent &event)
181
201
{
182
202
// Update the screen layout
183
203
wxSize size = GetSize ();
184
- layout.update (size.x , size.y , gbaMode);
204
+ layout.update (size.x , size.y , gbaMode, splitScreens );
185
205
186
206
// Full screen breaks the minimum frame size, but changing to a different value fixes it
187
207
// As a workaround, clear the minimum size on full screen and reset it shortly after
@@ -225,23 +245,23 @@ void NooCanvas::releaseKey(wxKeyEvent &event)
225
245
void NooCanvas::pressScreen (wxMouseEvent &event)
226
246
{
227
247
// Ensure the left mouse button is clicked
228
- if (!frame->isRunning () || !event.LeftIsDown ()) return ;
248
+ if (!frame->running || !event.LeftIsDown ()) return ;
229
249
230
250
// Determine the touch position relative to the emulated touch screen
231
251
int touchX = layout.getTouchX (event.GetX (), event.GetY ());
232
252
int touchY = layout.getTouchY (event.GetX (), event.GetY ());
233
253
234
254
// Send the touch coordinates to the core
235
- frame->getCore () ->input .pressScreen ();
236
- frame->getCore () ->spi .setTouch (touchX, touchY);
255
+ frame->core ->input .pressScreen ();
256
+ frame->core ->spi .setTouch (touchX, touchY);
237
257
}
238
258
239
259
void NooCanvas::releaseScreen (wxMouseEvent &event)
240
260
{
241
261
// Send a touch release to the core
242
- if (frame->isRunning () )
262
+ if (frame->running )
243
263
{
244
- frame->getCore () ->input .releaseScreen ();
245
- frame->getCore () ->spi .clearTouch ();
264
+ frame->core ->input .releaseScreen ();
265
+ frame->core ->spi .clearTouch ();
246
266
}
247
267
}
0 commit comments