Brogue CE 1.15.1: integration with the page that hosts the game at fredygames.com (Emscripten). - sdl2-platform.c: in the browser the window is the page, so the keys that resize the window or switch to full screen (Page Up/Down, +/-/=, F11, F12, Alt+Enter) do nothing; and the event loop gives the browser its turn even when there is no time left to wait (emscripten_sleep(0)), so that frames are drawn and input arrives; - tiles.c: the window starts at the size of the canvas, which the page stretches over the whole frame, and never goes full screen by itself. Part of the source of the build served at fredygames.com (AGPL-3.0-or-later, like Brogue CE). diff -ru a/src/platform/sdl2-platform.c b/src/platform/sdl2-platform.c --- a/src/platform/sdl2-platform.c 2026-10-14 18:58:19.137394343 -0400 +++ b/src/platform/sdl2-platform.c 2026-10-14 19:00:34.950348709 -0400 @@ -6,6 +6,9 @@ #include #include "platform.h" #include "tiles.h" +#ifdef __EMSCRIPTEN__ +#include +#endif #define PAUSE_BETWEEN_EVENT_POLLING 36L//17 #define MAX_REMAPS 128 @@ -166,6 +169,9 @@ } else if (event.type == SDL_KEYDOWN) { SDL_Keycode key = event.key.keysym.sym; +#ifndef __EMSCRIPTEN__ + // fredygames.com: in the browser the window is the page, so the keys that resize it or + // switch to full screen do nothing there (the player has its own full-screen button). if (key == SDLK_PAGEUP) { resizeWindow(max(windowWidth * 11/10, windowWidth + 1), max(windowHeight * 11/10, windowHeight + 1)); continue; @@ -179,6 +185,7 @@ resizeWindow(-1, -1); // Reset to starting resolution continue; } +#endif if (eventFromKey(returnEvent, key)) { returnEvent->eventType = KEYSTROKE; @@ -196,12 +203,14 @@ if (!textInput) { c = applyRemaps(c); +#ifndef __EMSCRIPTEN__ if (c == '=' || c == '+') { resizeWindow(max(windowWidth * 11/10, windowWidth + 1), max(windowHeight * 11/10, windowHeight + 1)); } else if (c == '-') { fullScreen = false; resizeWindow(max(windowWidth * 10/11, 1), max(windowHeight * 10/11, 1)); } +#endif } returnEvent->eventType = KEYSTROKE; @@ -293,6 +302,13 @@ if (ms > 0) { SDL_Delay(ms); } // else delaying further would go past the time we want to delay until +#ifdef __EMSCRIPTEN__ + // fredygames.com: SDL_Delay gives the browser its turn (Asyncify); when there is no time left + // to wait, still give it, so that the page draws the frame and delivers input. + else { + emscripten_sleep(0); + } +#endif lastDelayTime = SDL_GetTicks(); } diff -ru a/src/platform/tiles.c b/src/platform/tiles.c --- a/src/platform/tiles.c 2026-10-14 18:58:19.138037082 -0400 +++ b/src/platform/tiles.c 2026-10-14 19:00:34.950764702 -0400 @@ -3,6 +3,9 @@ #include #include "platform.h" #include "tiles.h" +#ifdef __EMSCRIPTEN__ +#include +#endif #define PI 3.14159265358979323846 @@ -742,6 +745,16 @@ SDL_DisplayMode mode; if (SDL_GetCurrentDisplayMode(0, &mode) < 0) sdlfatal(__FILE__, __LINE__); +#ifdef __EMSCRIPTEN__ + // fredygames.com: the window is the canvas, which the page stretches over the whole frame + // (SDL resizes it with the frame). Full screen is the page's job. + (void)mode; + fullScreen = false; + if (width < 0 || height < 0) { + width = EM_ASM_INT({ return Module.canvas.clientWidth; }); + height = EM_ASM_INT({ return Module.canvas.clientHeight; }); + } +#else // By default the window will have an aspect ratio of 16:10 // and either 80% of monitor width or 80% of monitor height, whichever is smaller if (width < 0) width = min(mode.w * 8/10, mode.h * 8*16/(10*10)); @@ -749,6 +762,7 @@ // go to fullscreen mode if the window is as big as the screen if (width >= mode.w && height >= mode.h) fullScreen = true; +#endif if (Win == NULL) { // create the window