diff --git a/data/paratroopers.ld b/data/paratroopers.ld index 4ec7365..7217387 100644 --- a/data/paratroopers.ld +++ b/data/paratroopers.ld @@ -23,8 +23,7 @@ ParatroopersInvers = { -# TRANSLATORS: Apparently, "Paratroopers" is the name of a computer game. - name = "Paratroopers" + name = "Parachutists" description = "the other way around" author = "brl" diff --git a/data/summary.ld b/data/summary.ld index a9af46e..afca718 100644 --- a/data/summary.ld +++ b/data/summary.ld @@ -61,11 +61,6 @@ Wachsen = { name = "Growing" author = "Immi" } -ASCII = { - filename = "ascii.ld" - name = "ASCII" - author = "Immi" -} Tiere = { filename = "tiere.ld" name = "Tiling Animals" @@ -111,11 +106,6 @@ Letters = { name = "Letters" author = "Berni" } -Tetris = { - filename = "tetris.ld" - name = "Tetris" - author = "Berni" -} Memory = { filename = "memory.ld" name = "Memory" @@ -371,7 +361,7 @@ ReversiBRL = { } ParatroopersInvers = { filename = "paratroopers.ld" - name = "Paratroopers" + name = "Parachutists" author = "brl" } Springer = { @@ -384,11 +374,6 @@ Baggis = { name = "Baggis" author = "Simon" } -Pacman = { - filename = "pacman.ld" - name = "Pacman" - author = "Simon" -} mfs = { filename = "mfs.ld" name = "mfs" @@ -414,7 +399,7 @@ level[all]= Baender, # Introduces neighbours_diagonal HexKugeln, # First level with randomgreys Schemen, Bonus,Pfeile,Fische,Theater,Rechnen, - Jahreszeiten,Disco,Wohnungen,Baggis,Tetris, + Jahreszeiten,Disco,Wohnungen,Baggis, Kacheln_Viereck, Rollenspiel, # First level with different numexplodes Himmel, # Introduces mirror=1 @@ -464,7 +449,6 @@ level[main,hard]= level[game]= Springer, - Tetris, Rollenspiel,Aliens, Puzzle,Letters, BoniMali2,Dungeon, @@ -506,7 +490,7 @@ level[nofx,easy]= level[weird]= Schemen,Bonus,Fische,Rechnen, - Disco,Baggis,Tetris, + Disco,Baggis, Rollenspiel,Kolben,Baelle,Aliens, Slime,Flechtwerk, Explosive,Gold,Zahn,Doors,Bunt, @@ -517,7 +501,7 @@ level[weird]= level[weird,hard]= Schemen,Bonus,Fische,Rechnen, - Disco,Baggis,Tetris, + Disco,Baggis, Rollenspiel,Kolben,Baelle,Aliens, Slime,Flechtwerk, Explosive,Gold,Zahn,Doors,Bunt, @@ -528,7 +512,7 @@ level[weird,hard]= level[weird,easy]= Schemen,Bonus,Fische,Rechnen, - Disco,Baggis,Tetris, + Disco,Baggis, Rollenspiel,Kolben,Baelle,Aliens, Slime,Flechtwerk, Explosive,Gold,Zahn,Doors,Bunt, @@ -537,7 +521,7 @@ level[weird,easy]= Go,Tennis, Walls,Kacheln_azyklisch,Trees2,NoVIPs,Wachsen,GoII -level[contrib]=ASCII,Xtradick,Pressure,mfs,ParatroopersInvers,Ziehlen,Pacman +level[contrib]=Xtradick,Pressure,mfs,ParatroopersInvers,Ziehlen ordered[contrib]=0 globals=globals.ld diff --git a/src/blatt.cpp b/src/blatt.cpp index 550efd8..74d8487 100644 --- a/src/blatt.cpp +++ b/src/blatt.cpp @@ -460,8 +460,11 @@ void BlattMenu::keyEvent(const SDL_keysym & taste) { Art wie Pfeiltasten wirken. (Manchmal macht SDL das automatisch; das scheint aber buggy zu sein.) */ - if (t>=SDLK_KP0 && t<=SDLK_KP9) - t = keypadersatz[t-SDLK_KP0]; + /* (In SDL 2 the keypad key 0 comes after 9.) */ + if (t>=SDLK_KP1 && t<=SDLK_KP9) + t = keypadersatz[t-SDLK_KP1+1]; + else if (t==SDLK_KP0) + t = keypadersatz[0]; // /* Keycode normalisieren */ diff --git a/src/cuyointl.h b/src/cuyointl.h index eb61420..0fca891 100644 --- a/src/cuyointl.h +++ b/src/cuyointl.h @@ -39,6 +39,7 @@ Modified 2001,2008-2011 by the cuyo developers #define _(String) (String) #define N_(String) (String) + #define ngettext(singular, plural, n) ((n) == 1 ? (singular) : (plural)) #endif diff --git a/src/cysdl12.cpp b/src/cysdl12.cpp new file mode 100644 index 0000000..4344fbf --- /dev/null +++ b/src/cysdl12.cpp @@ -0,0 +1,118 @@ +/* + * cysdl12.cpp: see cysdl12.h. The game draws on the surface of SDL_SetVideoMode (here a 32-bit surface in + * memory); SDL_UpdateRect(s) uploads it to a streaming texture and shows it. + * Copyright (C) 2026 FredyGames. Distributed under the GNU GPL version 2 or later, like the game. + */ +#include "cysdl12.h" + +#undef SDL_PollEvent +#undef SDL_Delay + +static SDL_Window * window = NULL; +static SDL_Renderer * renderer = NULL; +static SDL_Texture * texture = NULL; +static SDL_Surface * screen = NULL; + +SDL_Surface * cy_SetVideoMode(int width, int height, int bpp, Uint32 flags) { + (void) bpp; (void) flags; + if (window == NULL) { + window = SDL_CreateWindow("Cuyo", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, 0); + if (window == NULL) + return NULL; + renderer = SDL_CreateRenderer(window, -1, 0); + if (renderer == NULL) + return NULL; + } + if (texture != NULL) + SDL_DestroyTexture(texture); + if (screen != NULL) + SDL_FreeSurface(screen); + SDL_SetWindowSize(window, width, height); + texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_STREAMING, width, height); + screen = SDL_CreateRGBSurfaceWithFormat(0, width, height, 32, SDL_PIXELFORMAT_RGB888); + return screen; +} + +SDL_Surface * cy_GetVideoSurface(void) { + return screen; +} + +static void present() { + if (texture == NULL) + return; + SDL_UpdateTexture(texture, NULL, screen->pixels, screen->pitch); + SDL_RenderClear(renderer); + SDL_RenderCopy(renderer, texture, NULL, NULL); + SDL_RenderPresent(renderer); +} + +void cy_UpdateRect(SDL_Surface * s, Sint32 x, Sint32 y, Uint32 w, Uint32 h) { + (void) s; (void) x; (void) y; (void) w; (void) h; + present(); +} + +void cy_UpdateRects(SDL_Surface * s, int numrects, SDL_Rect * rects) { + (void) s; (void) rects; + if (numrects > 0) + present(); +} + +SDL_Surface * cy_DisplayFormat(SDL_Surface * surface) { + return SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_RGB888, 0); +} + +SDL_Surface * cy_DisplayFormatAlpha(SDL_Surface * surface) { + return SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ABGR8888, 0); +} + +/* Only one "video mode": the game then uses its preferred window size. */ +SDL_Rect ** cy_ListModes(SDL_PixelFormat * format, Uint32 flags) { + (void) format; (void) flags; + static SDL_Rect mode = {0, 0, 656, 496}; + static SDL_Rect * modes[2] = {&mode, NULL}; + return modes; +} + +void cy_WM_SetCaption(const char * title, const char * icon) { + (void) icon; + if (window != NULL && title != NULL) + SDL_SetWindowTitle(window, title); +} + +int cy_EnableUNICODE(int enable) { + (void) enable; + return 0; +} + +/* The character a key press types on a US keyboard (0 for keys that type none). */ +static Uint16 typed(SDL_Keycode sym, Uint16 mod) { + if (sym < 32 || sym >= 127) + return 0; + bool shift = (mod & KMOD_SHIFT) != 0; + if (!shift) + return sym; + if (sym >= 'a' && sym <= 'z') + return sym - 'a' + 'A'; + switch (sym) { + case '1': return '!'; case '2': return '@'; case '3': return '#'; case '4': return '$'; + case '5': return '%'; case '6': return '^'; case '7': return '&'; case '8': return '*'; + case '9': return '('; case '0': return ')'; case '-': return '_'; case '=': return '+'; + case '[': return '{'; case ']': return '}'; case '\\': return '|'; case ';': return ':'; + case '\'': return '"'; case ',': return '<'; case '.': return '>'; case '/': return '?'; + case '`': return '~'; + } + return sym; +} + +SDL_keysym::SDL_keysym(const SDL_Keysym & k) + : scancode(k.scancode), sym(k.sym), mod(k.mod), unicode(typed(k.sym, k.mod)) {} + +/* SDL 1.2 had no key repeat unless asked for; SDL 2 always has it. Repeats are dropped here. */ +int cy_PollEvent(SDL_Event * event) { + while (SDL_PollEvent(event)) { + if (event->type == SDL_KEYDOWN && event->key.repeat) + continue; + return 1; + } + return 0; +} diff --git a/src/cysdl12.h b/src/cysdl12.h new file mode 100644 index 0000000..d4d1dad --- /dev/null +++ b/src/cysdl12.h @@ -0,0 +1,76 @@ +/* + * cysdl12.h: the part of the SDL 1.2 API that Cuyo uses, on top of SDL 2, for the fredygames.com browser + * build (Emscripten). Included before every source file (-include). Written for that build. + * Copyright (C) 2026 FredyGames. Distributed under the GNU GPL version 2 or later, like the game. + */ +#ifndef CYSDL12_H +#define CYSDL12_H + +#include +#include + +typedef SDL_Keycode SDLKey; + +#define SDL_HWSURFACE 0x00000001 +#define SDL_ANYFORMAT 0x10000000 +#define SDL_DOUBLEBUF 0x40000000 +#define SDL_FULLSCREEN 0x80000000 +#define SDL_SRCCOLORKEY 0x00001000 +/* Events SDL 2 does not have: the page keeps the window at one size and always has the focus. */ +#define SDL_VIDEORESIZE 0x7ffe +#define SDL_ACTIVEEVENT 0x7ffd +#define KMOD_META KMOD_GUI + +/* SDL 1.2 key names that SDL 2 spells differently. */ +#define SDLK_KP0 SDLK_KP_0 +#define SDLK_KP1 SDLK_KP_1 +#define SDLK_KP2 SDLK_KP_2 +#define SDLK_KP3 SDLK_KP_3 +#define SDLK_KP4 SDLK_KP_4 +#define SDLK_KP5 SDLK_KP_5 +#define SDLK_KP6 SDLK_KP_6 +#define SDLK_KP7 SDLK_KP_7 +#define SDLK_KP8 SDLK_KP_8 +#define SDLK_KP9 SDLK_KP_9 +#define SDLK_PRINT SDLK_PRINTSCREEN +#define SDLK_BREAK SDLK_PAUSE + +#define SDLK_EURO SDLK_UNKNOWN + +/* SDL 1.2 key event symbol: SDL 2 has no "unicode" member; it is worked out from the key and the shift state + (letters and digits, and the symbols of the US layout; 0 for the other keys). */ +struct SDL_keysym { + SDL_Scancode scancode; + SDL_Keycode sym; + Uint16 mod; + Uint16 unicode; + SDL_keysym() : scancode(SDL_SCANCODE_UNKNOWN), sym(SDLK_UNKNOWN), mod(0), unicode(0) {} + SDL_keysym(const SDL_Keysym & k); +}; + +SDL_Surface * cy_SetVideoMode(int width, int height, int bpp, Uint32 flags); +SDL_Surface * cy_GetVideoSurface(void); +void cy_UpdateRect(SDL_Surface * screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h); +void cy_UpdateRects(SDL_Surface * screen, int numrects, SDL_Rect * rects); +SDL_Surface * cy_DisplayFormat(SDL_Surface * surface); +SDL_Surface * cy_DisplayFormatAlpha(SDL_Surface * surface); +int cy_PollEvent(SDL_Event * event); +SDL_Rect ** cy_ListModes(SDL_PixelFormat * format, Uint32 flags); +void cy_WM_SetCaption(const char * title, const char * icon); +int cy_EnableUNICODE(int enable); + +#define SDL_SetVideoMode cy_SetVideoMode +#define SDL_GetVideoSurface cy_GetVideoSurface +#define SDL_UpdateRect cy_UpdateRect +#define SDL_UpdateRects cy_UpdateRects +#define SDL_DisplayFormat cy_DisplayFormat +#define SDL_DisplayFormatAlpha cy_DisplayFormatAlpha +#define SDL_PollEvent cy_PollEvent +#define SDL_ListModes cy_ListModes +#define SDL_WM_SetCaption cy_WM_SetCaption +#define SDL_EnableUNICODE cy_EnableUNICODE +/* The main loop waits for the next step with SDL_Delay: here that hands the page back to the browser (Asyncify). */ +#undef SDL_Delay +#define SDL_Delay(ms) emscripten_sleep(ms) + +#endif diff --git a/src/sdltools.cpp b/src/sdltools.cpp index d81aa11..9ef71f0 100644 --- a/src/sdltools.cpp +++ b/src/sdltools.cpp @@ -201,7 +201,7 @@ void computeMaskedFormat() { gMaskedFormat.palette = neupal; if (ncolours < 255) { - gMaskedFormat.colorkey = ncolours + 1; + /* (no colour key in SDL 2; palettes are not used in the browser build) */ gColkeyErsatz = 0; // Wird eh nicht benutzt... } else { @@ -231,7 +231,6 @@ void computeMaskedFormat() { #undef DIST - gMaskedFormat.colorkey = c2best; gColkeyErsatz = c1best; } } @@ -458,9 +457,7 @@ SDL_Surface * maskedDisplayFormat(SDL_Surface * src) { Seufz. Also selber nachbearbeiten. */ SDLASSERT(!SDL_MUSTLOCK(src) && !SDL_MUSTLOCK(ret)); - ret->flags |= SDL_SRCCOLORKEY; - Uint8 colkey = gMaskedFormat.colorkey; - ret->format->colorkey = colkey; + Uint8 colkey = 0; Uint32 amask = src->format->Amask; Uint8 * srcrow = (Uint8 *) src->pixels; Uint8 * retrow = (Uint8 *) ret->pixels; @@ -596,9 +593,7 @@ bool pollEvent(SDL_Event & evt) { if (!SDL_PollEvent(&evt)) return false; - if (evt.type == SDL_VIDEORESIZE) { - setVideoMode(evt.resize.w, evt.resize.h); - } else if (evt.type == SDL_MOUSEMOTION) { + if (evt.type == SDL_MOUSEMOTION) { evt.motion.x -= gShiftX; evt.motion.y -= gShiftY; /* We have to ensure: