...
|
...
|
@@ -85,6 +85,23 @@ audio_callback(void *u, Uint8 *stream, int len)
|
85
|
85
|
(void)u;
|
86
|
86
|
}
|
87
|
87
|
|
|
88
|
+static void
|
|
89
|
+set_window_size(SDL_Window *window, int w, int h)
|
|
90
|
+{
|
|
91
|
+ int win_x, win_y;
|
|
92
|
+ int win_cent_x, win_cent_y;
|
|
93
|
+ int old_win_sz_x, old_win_sz_y;
|
|
94
|
+
|
|
95
|
+ SDL_GetWindowPosition(window, &win_x, &win_y);
|
|
96
|
+ SDL_GetWindowSize(window, &old_win_sz_x, &old_win_sz_y);
|
|
97
|
+
|
|
98
|
+ win_cent_x = win_x + old_win_sz_x / 2;
|
|
99
|
+ win_cent_y = win_y + old_win_sz_y / 2;
|
|
100
|
+
|
|
101
|
+ SDL_SetWindowPosition(window, win_cent_x - w / 2, win_cent_y - h / 2);
|
|
102
|
+ SDL_SetWindowSize(window, w, h);
|
|
103
|
+}
|
|
104
|
+
|
88
|
105
|
static void
|
89
|
106
|
inspect(Ppu *p, Uint8 *stack, Uint8 wptr, Uint8 rptr, Uint8 *memory)
|
90
|
107
|
{
|
...
|
...
|
@@ -154,7 +171,7 @@ static void
|
154
|
171
|
toggle_zoom(Uxn *u)
|
155
|
172
|
{
|
156
|
173
|
zoom = zoom == 3 ? 1 : zoom + 1;
|
157
|
|
- SDL_SetWindowSize(gWindow, (ppu.width + PAD * 2) * zoom, (ppu.height + PAD * 2) * zoom);
|
|
174
|
+ set_window_size(gWindow, (ppu.width + PAD * 2) * zoom, (ppu.height + PAD * 2) * zoom);
|
158
|
175
|
redraw(u);
|
159
|
176
|
}
|
160
|
177
|
|
...
|
...
|
@@ -205,7 +222,7 @@ set_size(Uint16 width, Uint16 height, int is_resize)
|
205
|
222
|
if(gTexture == NULL || SDL_SetTextureBlendMode(gTexture, SDL_BLENDMODE_NONE))
|
206
|
223
|
return error("sdl_texture", SDL_GetError());
|
207
|
224
|
SDL_UpdateTexture(gTexture, NULL, ppu_screen, sizeof(Uint32));
|
208
|
|
- if(is_resize) SDL_SetWindowSize(gWindow, (ppu.width + PAD * 2) * zoom, (ppu.height + PAD * 2) * zoom);
|
|
225
|
+ if(is_resize) set_window_size(gWindow, (ppu.width + PAD * 2) * zoom, (ppu.height + PAD * 2) * zoom);
|
209
|
226
|
reqdraw = 1;
|
210
|
227
|
return 1;
|
211
|
228
|
}
|