Free games for graphing calculators: NumWorks, TI-Nspire CX, Casio fx-CG50 and soon TI-84 Plus CE. Balatro, Celeste, Hollow Knight, Minecraft and more.
C calculatorcalculator-gamescasiochesscrossy-roaddrive-madfx-cg50gamesgeometry-dashgraphing-calculatorndlessnumworksnumworks-appsnumworks-calculatornumworks-gamenumworks-gamestetristi-84-plus-ceti-nspire
Block Blast: Hungry Studio's puzzle, after Buckshot Roulette
Mason363713278f69c4d
diff --git a/Makefile b/Makefileindex 809ad845..d590bb42 100644--- a/Makefile+++ b/Makefile@@ -30,7 +30,7 @@ APP_SPACE = 2031616# Upsilon, the N0110 and N0115's custom software, gives .nwa apps less RAM: NumPlay-Upsilon.nwa has# the games that fit it (NumPlay draws their text there: see launcher/src/compat.c)UPSILON_RAM = 107674-UPSILON_GAMES = crossyroad portal tetris chess flappybird pacman snake connectfour solitaire g2048 minesweeper \+UPSILON_GAMES = crossyroad blockblast portal tetris chess flappybird pacman snake connectfour solitaire g2048 minesweeper \breakout numvisuals# NumPlay and its discreet versions: the same app, with another name and icondiff --git a/README.md b/README.mdindex d918d177..df3eb4c2 100644--- a/README.md+++ b/README.md@@ -36,24 +36,27 @@ All of these come in one app, **NumPlay.nwa**.<table><tr>- <td align="center" width="16%"><a href="games/numdash/README.md"><img src="docs/media/thumb_numdash.png" width="120" alt="NumDash"><br><b>NumDash</b></a></td>- <td align="center" width="16%"><a href="games/crossyroad/README.md"><img src="docs/media/thumb_crossyroad.png" width="120" alt="Crossy Road"><br><b>Crossy Road</b></a></td>- <td align="center" width="16%"><a href="games/numblocks/README.md"><img src="docs/media/thumb_numblocks.png" width="120" alt="NumBlocks"><br><b>NumBlocks</b></a></td>- <td align="center" width="16%"><a href="games/numdrive/README.md"><img src="docs/media/thumb_numdrive.png" width="120" alt="NumDrive"><br><b>NumDrive</b></a></td>- <td align="center" width="16%"><a href="games/balatro/README.md"><img src="docs/media/thumb_balatro.png" width="120" alt="Balatro"><br><b>Balatro</b></a></td>- <td align="center" width="16%"><a href="games/buckshot/README.md"><img src="docs/media/thumb_buckshot.png" width="120" alt="Buckshot Roulette"><br><b>Buckshot Roulette</b></a></td>+ <td align="center" width="20%"><a href="games/numdash/README.md"><img src="docs/media/thumb_numdash.png" width="120" alt="NumDash"><br><b>NumDash</b></a></td>+ <td align="center" width="20%"><a href="games/crossyroad/README.md"><img src="docs/media/thumb_crossyroad.png" width="120" alt="Crossy Road"><br><b>Crossy Road</b></a></td>+ <td align="center" width="20%"><a href="games/numblocks/README.md"><img src="docs/media/thumb_numblocks.png" width="120" alt="NumBlocks"><br><b>NumBlocks</b></a></td>+ <td align="center" width="20%"><a href="games/numdrive/README.md"><img src="docs/media/thumb_numdrive.png" width="120" alt="NumDrive"><br><b>NumDrive</b></a></td>+ <td align="center" width="20%"><a href="games/balatro/README.md"><img src="docs/media/thumb_balatro.png" width="120" alt="Balatro"><br><b>Balatro</b></a></td></tr><tr>+ <td align="center"><a href="games/buckshot/README.md"><img src="docs/media/thumb_buckshot.png" width="120" alt="Buckshot Roulette"><br><b>Buckshot Roulette</b></a></td>+ <td align="center"><a href="games/blockblast/README.md"><img src="docs/media/thumb_blockblast.png" width="120" alt="Block Blast"><br><b>Block Blast</b></a></td><td align="center"><a href="games/portal/README.md"><img src="docs/media/thumb_portal.png" width="120" alt="Portal Returns"><br><b>Portal Returns</b></a></td><td align="center"><a href="games/tetris/README.md"><img src="docs/media/thumb_tetris.png" width="120" alt="Tetris"><br><b>Tetris</b></a></td><td align="center"><a href="games/chess/README.md"><img src="docs/media/thumb_chess.png" width="120" alt="Chess"><br><b>Chess</b></a></td>+ </tr>+ <tr><td align="center"><a href="games/flappybird/README.md"><img src="docs/media/thumb_flappybird.png" width="120" alt="Flappy Bird"><br><b>Flappy Bird</b></a></td><td align="center"><a href="games/pacman/README.md"><img src="docs/media/thumb_pacman.png" width="120" alt="Pac-Man"><br><b>Pac-Man</b></a></td><td align="center"><a href="games/snake/README.md"><img src="docs/media/thumb_snake.png" width="120" alt="Snake"><br><b>Snake</b></a></td>- </tr>- <tr><td align="center"><a href="games/connectfour/README.md"><img src="docs/media/thumb_connectfour.png" width="120" alt="Connect Four"><br><b>Connect Four</b></a></td><td align="center"><a href="games/solitaire/README.md"><img src="docs/media/thumb_solitaire.png" width="120" alt="Solitaire"><br><b>Solitaire</b></a></td>+ </tr>+ <tr><td align="center"><a href="games/g2048/README.md"><img src="docs/media/thumb_g2048.png" width="120" alt="2048"><br><b>2048</b></a></td><td align="center"><a href="games/minesweeper/README.md"><img src="docs/media/thumb_minesweeper.png" width="120" alt="Minesweeper"><br><b>Minesweeper</b></a></td><td align="center"><a href="games/breakout/README.md"><img src="docs/media/thumb_breakout.png" width="120" alt="Block Breaker"><br><b>Block Breaker</b></a></td>@@ -101,7 +104,7 @@ You need your calculator, its USB cable, and a computer with **Google Chrome** o| --- | --- | --- || N0120 | Epsilon 23.2 or newer (the calculator's own software) | Everything || N0110, N0115 | Epsilon 23.2 or newer | Everything. These models are about 2.5 times slower, so the big games show fewer frames per second, but they keep their speed. |-| N0110, N0115 | Upsilon | NumPlay-Upsilon.nwa: 13 games (see Other versions) |+| N0110, N0115 | Upsilon | NumPlay-Upsilon.nwa: 14 games (see Other versions) || Any | Custom software built from Epsilon 25.2's source | Everything. These builds can give apps less memory (133 KB): on one that gives even less, a game that needs more says how much on its card. |To see your calculator's model and software, open **Settings**, then **About**. To update the software, go to [my.numworks.com](https://my.numworks.com) with the calculator plugged in.@@ -117,7 +120,7 @@ To see your calculator's model and software, open **Settings**, then **About**.| [NumPlay-Matrices.nwa](https://github.com/Mason363/NumPlay/releases/latest/download/NumPlay-Matrices.nwa) | The same app, in disguise: it looks like a math app called **Matrices**. || [NumPlay-French.nwa](https://github.com/Mason363/NumPlay/releases/latest/download/NumPlay-French.nwa) | NumPlay en français : tous les jeux, en français. || [NumPlay-Chinese.nwa](https://github.com/Mason363/NumPlay/releases/latest/download/NumPlay-Chinese.nwa) | NumPlay 中文版:所有游戏,简体中文。 |-| [NumPlay-Upsilon.nwa](https://github.com/Mason363/NumPlay/releases/latest/download/NumPlay-Upsilon.nwa) | For calculators running **Upsilon**: the 13 games that fit in the memory it gives apps. |+| [NumPlay-Upsilon.nwa](https://github.com/Mason363/NumPlay/releases/latest/download/NumPlay-Upsilon.nwa) | For calculators running **Upsilon**: the 14 games that fit in the memory it gives apps. |<img src="docs/media/home_invisible.png" width="240" alt="The home screen with NumPlay-Invisible: the spot after Settings looks empty"> <img src="docs/media/home_matrices.png" width="240" alt="The home screen with NumPlay-Matrices among the calculator's own apps">@@ -167,13 +170,13 @@ Filmed on my own calculator, no emulator.- [x] Minecraft 1.8 (NumBlocks)- [x] The Final Earth 2- [x] The Powder Toy (NumPowder)+- [x] Block Blast- [ ] Undertale (the fights)- [ ] The Binding of Isaac- [ ] Plants vs. Zombies- [ ] Doom- [ ] Five Nights at Freddy's- [ ] Pong and more two-player games-- [ ] Block Blast- [ ] Cookie Clicker- [ ] Level Devil- [ ] Sonic the Hedgehog@@ -188,6 +191,7 @@ NumPlay is a fan project, made out of love for these games and for the NumWorks- **[Tatone26](https://github.com/Tatone26/Numworks-games)**'s **All the Apps** inspired NumPlay's list of classics. Flappy Bird, Pac-Man, Snake, Connect Four, Solitaire and 2048 are written in C for NumPlay and keep its options, with no code copied from it. Tetris is Tatone26's own, which they released into the public domain, adapted for NumPlay.- **[Gabriele Cirulli](https://github.com/gabrielecirulli/2048)** made 2048.+- **Block Blast!** by [Hungry Studio](https://www.hungrystudio.com) inspired NumPlay's Block Blast, written in C for NumPlay with no code or art from it. Its blocks, scoring and colours follow measurements of the app by the players behind [blockblast-Self-Improvement-loop](https://github.com/Kucze3205/blockblast-Self-Improvement-loop).- Snake, Solitaire and Block Breaker look and play like **Google's games** in Search. They are drawn from scratch; nothing is taken from Google.- **[gd3ds](https://github.com/AleFunky/gd3ds)** by AleFunky and friends, whose research into Geometry Dash made NumDash possible. Clubstep, Deadlocked and Dash also rely on [gdsolver](https://github.com/gdsolver/gdsolver)'s measurements of Geometry Dash 2.2, level data from [gmdkit](https://github.com/UHDanke/gmdkit) by HDanke and checks against [GDRWeb](https://github.com/iliasHDZ/GDRWeb) by IliasHDZ.- **Balatro** by LocalThunk inspired NumPlay's Balatro, which uses art adapted from the game and the **m6x11** font by Daniel Linssen.@@ -210,7 +214,7 @@ NumPlay is a fan project, made out of love for these games and for the NumWorksNumPlay is licensed under the [GNU General Public License v3.0](LICENSE). Copyright (c) 2026 Mason Chen. Code and fonts from others keep their own licenses: the `UNLICENSE` files in the games' folders and the [LICENSES](LICENSES) folder. The names, artwork and music of the games NumPlay is inspired by belong to their makers and are not covered by it.-<sub>Unofficial fan games, not affiliated with NumWorks, RobTop Games (Geometry Dash), Hipster Whale (Crossy Road), the makers of Drive Mad, LocalThunk or Playstack (Balatro), Mike Klubnika or Critical Reflex (Buckshot Roulette), Mojang or Microsoft (Minecraft), Maddy Makes Games (Celeste), Team Cherry (Hollow Knight), Florian van Strien (The Final Earth 2), The Powder Toy's developers (The Powder Toy), MateoConLechuga (Portal Returns), Valve (Portal), .GEARS (Flappy Bird), Bandai Namco (Pac-Man), Hasbro (Connect Four), Google (Snake, Solitaire, Block Breaker, Doodle Champion Island Games), STUDIO4°C or Microsoft (Minesweeper). Tetris is a trademark of The Tetris Company, Minecraft of Mojang Synergies AB, Pac-Man of Bandai Namco and Connect Four of Hasbro.</sub>+<sub>Unofficial fan games, not affiliated with NumWorks, RobTop Games (Geometry Dash), Hipster Whale (Crossy Road), the makers of Drive Mad, LocalThunk or Playstack (Balatro), Mike Klubnika or Critical Reflex (Buckshot Roulette), Hungry Studio (Block Blast!), Mojang or Microsoft (Minecraft), Maddy Makes Games (Celeste), Team Cherry (Hollow Knight), Florian van Strien (The Final Earth 2), The Powder Toy's developers (The Powder Toy), MateoConLechuga (Portal Returns), Valve (Portal), .GEARS (Flappy Bird), Bandai Namco (Pac-Man), Hasbro (Connect Four), Google (Snake, Solitaire, Block Breaker, Doodle Champion Island Games), STUDIO4°C or Microsoft (Minesweeper). Tetris is a trademark of The Tetris Company, Minecraft of Mojang Synergies AB, Pac-Man of Bandai Namco and Connect Four of Hasbro.</sub>## Gallery@@ -227,32 +231,35 @@ NumPlay is licensed under the [GNU General Public License v3.0](LICENSE). Copyri</tr><tr><td align="center"><img src="docs/media/gallery/buckshot.gif" width="100%" alt="Buckshot Roulette on a real NumWorks calculator: picking up the shotgun"><br><a href="games/buckshot/README.md"><b>Buckshot Roulette</b></a></td>+ <td align="center"><img src="docs/media/gallery/blockblast.gif" width="100%" alt="Block Blast: two rows clear for Good!, then a combo of 3"><br><a href="games/blockblast/README.md"><b>Block Blast</b></a></td><td align="center"><img src="docs/media/gallery/portal.gif" width="100%" alt="Portal Returns: jumping through portals in a test chamber"><br><a href="games/portal/README.md"><b>Portal Returns</b></a></td>- <td align="center"><img src="docs/media/gallery/tetris.gif" width="100%" alt="Tetris on a real NumWorks calculator: pieces drop and a line clears"><br><a href="games/tetris/README.md"><b>Tetris</b></a></td></tr><tr>+ <td align="center"><img src="docs/media/gallery/tetris.gif" width="100%" alt="Tetris on a real NumWorks calculator: pieces drop and a line clears"><br><a href="games/tetris/README.md"><b>Tetris</b></a></td><td align="center"><img src="docs/media/gallery/chess.gif" width="100%" alt="Chess: the opening moves of a game against a bot"><br><a href="games/chess/README.md"><b>Chess</b></a></td><td align="center"><img src="docs/media/gallery/flappybird.gif" width="100%" alt="Flappy Bird: flapping through the pipes"><br><a href="games/flappybird/README.md"><b>Flappy Bird</b></a></td>- <td align="center"><img src="docs/media/gallery/pacman.gif" width="100%" alt="Pac-Man: eating dots in the maze"><br><a href="games/pacman/README.md"><b>Pac-Man</b></a></td></tr><tr>+ <td align="center"><img src="docs/media/gallery/pacman.gif" width="100%" alt="Pac-Man: eating dots in the maze"><br><a href="games/pacman/README.md"><b>Pac-Man</b></a></td><td align="center"><img src="docs/media/gallery/snake.gif" width="100%" alt="Snake: the snake eats apples and grows"><br><a href="games/snake/README.md"><b>Snake</b></a></td><td align="center"><img src="docs/media/gallery/connectfour.gif" width="100%" alt="Connect Four: winning a round against the computer"><br><a href="games/connectfour/README.md"><b>Connect Four</b></a></td>- <td align="center"><img src="docs/media/gallery/solitaire.gif" width="100%" alt="Solitaire: moving cards between the columns"><br><a href="games/solitaire/README.md"><b>Solitaire</b></a></td></tr><tr>+ <td align="center"><img src="docs/media/gallery/solitaire.gif" width="100%" alt="Solitaire: moving cards between the columns"><br><a href="games/solitaire/README.md"><b>Solitaire</b></a></td><td align="center"><img src="docs/media/gallery/g2048.gif" width="100%" alt="2048: sliding and merging tiles up to 128"><br><a href="games/g2048/README.md"><b>2048</b></a></td><td align="center"><img src="docs/media/gallery/minesweeper.gif" width="100%" alt="Minesweeper: opening the field, flagging the mines and winning"><br><a href="games/minesweeper/README.md"><b>Minesweeper</b></a></td>- <td align="center"><img src="docs/media/gallery/breakout.gif" width="100%" alt="Block Breaker: the ball breaks bricks"><br><a href="games/breakout/README.md"><b>Block Breaker</b></a></td></tr><tr>+ <td align="center"><img src="docs/media/gallery/breakout.gif" width="100%" alt="Block Breaker: the ball breaks bricks"><br><a href="games/breakout/README.md"><b>Block Breaker</b></a></td><td align="center"><img src="docs/media/gallery/numvisuals.gif" width="100%" alt="NumVisuals: moving backgrounds, from northern lights to a lava lamp"><br><a href="games/numvisuals/README.md"><b>NumVisuals</b></a></td><td align="center"><img src="docs/media/gallery/numpowder.gif" width="100%" alt="NumPowder: water floods the sand, then lava pours in and boils it"><br><a href="games/numpowder/README.md"><b>NumPowder</b></a></td>- <td align="center"><img src="docs/media/gallery/finalearth2.gif" width="100%" alt="The Final Earth 2: building a house in a city on a floating island"><br><a href="games/finalearth2/README.md"><b>The Final Earth 2</b></a></td></tr><tr>+ <td align="center"><img src="docs/media/gallery/finalearth2.gif" width="100%" alt="The Final Earth 2: building a house in a city on a floating island"><br><a href="games/finalearth2/README.md"><b>The Final Earth 2</b></a></td><td align="center"><img src="docs/media/gallery/hollowknight.gif" width="100%" alt="Hollow Knight: fighting the False Knight and Hornet"><br><a href="games/hollowknight/README.md"><b>Hollow Knight</b></a></td><td align="center"><img src="docs/media/gallery/celeste.gif" width="100%" alt="Celeste on a real NumWorks calculator: Madeline climbs the first level"><br><a href="games/celeste/README.md"><b>Celeste</b></a></td>+ </tr>+ <tr><td align="center"><img src="docs/media/gallery/championisland.gif" width="100%" alt="Champion Island: climbing, artistic swimming and the marathon"><br><a href="games/championisland/README.md"><b>Champion Island</b></a></td></tr></table>diff --git a/_config.yml b/_config.ymlindex e9c2d846..837d6a04 100644--- a/_config.yml+++ b/_config.yml@@ -1,4 +1,4 @@title: NumPlay-description: "17 games for the NumWorks calculator in one app: NumDash, Crossy Road, NumBlocks, NumDrive, Balatro, Buckshot Roulette, Portal Returns, Tetris, Chess, Flappy Bird, Pac-Man, Snake and more, plus NumVisuals."+description: "18 games for the NumWorks calculator in one app: NumDash, Crossy Road, NumBlocks, NumDrive, Balatro, Buckshot Roulette, Block Blast, Portal Returns, Tetris, Chess, Flappy Bird, Pac-Man, Snake and more, plus NumVisuals."theme: jekyll-theme-caymanexclude: [games, launcher, tools, tests, build, LICENSES, Makefile, .github]diff --git a/docs/media/gallery/blockblast.gif b/docs/media/gallery/blockblast.gifnew file mode 100644index 00000000..7c9dd69aBinary files /dev/null and b/docs/media/gallery/blockblast.gif differdiff --git a/docs/media/launcher.gif b/docs/media/launcher.gifindex 3dd31393..fc3512c5 100644Binary files a/docs/media/launcher.gif and b/docs/media/launcher.gif differdiff --git a/docs/media/thumb_blockblast.png b/docs/media/thumb_blockblast.pngnew file mode 100644index 00000000..3828c841Binary files /dev/null and b/docs/media/thumb_blockblast.png differdiff --git a/docs/play.md b/docs/play.mdindex 24e9101d..d99446b0 100644--- a/docs/play.md+++ b/docs/play.md@@ -212,6 +212,21 @@ Shooting yourself with a blank keeps your turn.<br clear="right">+## Block Blast++<img src="../games/blockblast/docs/shot.png" width="320" align="right" alt="Block Blast">++| Key | What it does |+| --- | --- |+| **1, 2, 3** | Take that block |+| **Arrows** | Move it on the board |+| **OK** | Place it |+| **Back** | Menu (with How to play and Quit) |++Fill a row or a column to clear it; blocks never turn. The lines a block would fill light up in its colour before you place it. Clear again within three blocks for a combo, which multiplies the points. The game ends when none of your three blocks fits; your game and best score are saved.++<br clear="right">+## Champion Island<img src="media/championisland.gif" width="320" align="right" alt="Champion Island: Lucky crossing the island, then the island map">diff --git a/games/blockblast/.gitignore b/games/blockblast/.gitignorenew file mode 100644index 00000000..ea1472ec--- /dev/null+++ b/games/blockblast/.gitignore@@ -0,0 +1 @@+output/diff --git a/games/blockblast/Makefile b/games/blockblast/Makefilenew file mode 100644index 00000000..a01a71b0--- /dev/null+++ b/games/blockblast/Makefile@@ -0,0 +1,70 @@+# Block Blast — fit the blocks on the 8 x 8 board, fill rows and columns to clear them.+# make build output/blockblast.nwa+# make check link the app like the calculator does (output/blockblast.bin)+#+# In NumPlay the game draws with the launcher's strips, shapes and fonts and saves through its+# file functions (module.o leaves them to the launcher); on its own it brings them along.+Q ?= @+CC = arm-none-eabi-gcc+NWLINK ?= npx --yes -- [email protected]+BUILD_DIR = output+SRC = src/main.c+HEADERS = ../common/epsilon_app.h ../common/epsilon_files.h ../common/np_text.h ../../launcher/src/gfx.h \+ ../../launcher/src/np.h ../../launcher/src/font.h++CFLAGS = -std=c11 $(shell $(NWLINK) eadk-cflags-device)+CFLAGS += -Os -Wall -Wextra -Wno-unused-parameter -fno-math-errno -fsingle-precision-constant+CFLAGS += -fno-tree-loop-distribute-patterns -flto -fno-fat-lto-objects -fwhole-program -fvisibility=internal+LDFLAGS = -Wl,--relocatable -nostartfiles --specs=nano.specs+LDFLAGS += -Wl,-e,main -Wl,-u,eadk_app_name -Wl,-u,eadk_app_icon -Wl,-u,eadk_api_level+LDFLAGS += -Wl,--gc-sections -flinker-output=nolto-rel++.PHONY: build check clean+build: $(BUILD_DIR)/blockblast.nwa++check: $(BUILD_DIR)/blockblast.nwa+ $(Q) $(NWLINK) nwa-bin $< $(BUILD_DIR)/blockblast.bin+ @echo "BIN $(BUILD_DIR)/blockblast.bin: $$(wc -c < $(BUILD_DIR)/blockblast.bin) bytes"++# compiled, then linked (the link options would upset the compiler)+$(BUILD_DIR)/main.o: $(SRC) $(HEADERS) | $(BUILD_DIR)+ @echo "CC $<"+ $(Q) $(CC) $(CFLAGS) -c $(SRC) -o $@+$(BUILD_DIR)/gfx.o: ../../launcher/src/gfx.c $(HEADERS) | $(BUILD_DIR)+ $(Q) $(CC) $(CFLAGS) -c $< -o $@+$(BUILD_DIR)/font_data.o: ../../launcher/src/font_data.c ../../launcher/src/font.h | $(BUILD_DIR)+ $(Q) $(CC) $(CFLAGS) -c $< -o $@+$(BUILD_DIR)/xfont.o: ../../launcher/src/xfont.c ../../launcher/src/np_xfont.h $(HEADERS) | $(BUILD_DIR)+ $(Q) $(CC) $(CFLAGS) -c $< -o $@++$(BUILD_DIR)/blockblast.nwa: $(BUILD_DIR)/main.o $(BUILD_DIR)/gfx.o $(BUILD_DIR)/font_data.o $(BUILD_DIR)/xfont.o \+ $(BUILD_DIR)/icon.o+ @echo "LD $@"+ $(Q) $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@+ $(Q) arm-none-eabi-strip --strip-unneeded $@++$(BUILD_DIR)/icon.o: src/icon.png | $(BUILD_DIR)+ @echo "ICON $<"+ $(Q) $(NWLINK) png-icon-o $< $@++$(BUILD_DIR):+ $(Q) mkdir -p $@++clean:+ $(Q) rm -rf $(BUILD_DIR)++# NumPlay launcher: the app as a module (see ../../tools/npmodule.py) for the+# calculator, and as a relocatable object for the simulator build.+.PHONY: module sim-module+module: $(BUILD_DIR)/module.o+$(BUILD_DIR)/module-main.o: $(SRC) $(HEADERS) | $(BUILD_DIR)+ $(Q) $(CC) $(CFLAGS) -DNP_MODULE=1 -c $(SRC) -o $@+$(BUILD_DIR)/module.o: $(BUILD_DIR)/module-main.o+ $(Q) $(CC) $(CFLAGS) -Wl,--relocatable -nostartfiles -nostdlib -Wl,-e,main -flinker-output=nolto-rel $< -o $@++sim-module: $(BUILD_DIR)/sim-module.o+$(BUILD_DIR)/sim-module.o: $(SRC) $(HEADERS) | $(BUILD_DIR)+ $(Q) mkdir -p $(BUILD_DIR)/sim+ $(Q) cc -std=c11 -O2 -fPIC $(shell $(NWLINK) eadk-cflags-simulator) -DNP_MODULE=1 -Dmain=np_blockblast_main \+ -c $(SRC) -o $(BUILD_DIR)/sim/main.o+ $(Q) ld -r $(BUILD_DIR)/sim/main.o -exported_symbol _np_blockblast_main -o $@diff --git a/games/blockblast/README.md b/games/blockblast/README.mdnew file mode 100644index 00000000..9f14efd1--- /dev/null+++ b/games/blockblast/README.md@@ -0,0 +1,31 @@+# Block Blast++Fit the blocks on the 8×8 board; fill a row or a column and it blasts away. Hungry Studio's puzzle for the NumWorks calculator, playing and looking like the phone game.++<img src="docs/shot.png" width="320" alt="A game of Block Blast: a red T block in hand would complete the bottom row">++- **Three blocks at a time**, placed in any order. None of them turns, and new ones come when all three are down.+- **The game's 41 blocks**: lines of 1 to 5, squares, rectangles, corners, L, T, S and Z shapes and diagonals, each one coming as often as it does in the app.+- **Scoring like the original**: a point for each square placed, 10 for a line, 20, 60, 120... for two, three, four lines at once, times your combo. Clear again within three blocks to keep the combo going, and empty the whole board for 300 more.+- **Good!, Great!, Excellent!, Amazing!, Unbelievable!** for big clears, and your combo counted on screen.+- The rows and columns a block would fill light up in its colour before you place it, and blocks that can't go anywhere turn grey in the tray.+- The game ends when none of your blocks fits. Your game and best score are saved, so you can stop and carry on later.++## Controls++| Key | Action |+| --- | --- |+| 1, 2, 3 | Take that block |+| Arrows | Move it on the board |+| OK or EXE | Place it |+| Back | Menu: Resume, New game, How to play, Quit |++## Credits++Block Blast! is **[Hungry Studio](https://www.hungrystudio.com)**'s game (2022). This version is written in C for NumPlay, with no code or art from the original: its blocks, scoring and colours follow what players have measured from the app.++Inside NumPlay it draws with the launcher's own shapes and fonts and saves through its file functions, so the game itself is about 5 KB.++It comes inside [NumPlay](https://github.com/Mason363/NumPlay), or on its own as `BlockBlast.nwa` from the [latest release](https://github.com/Mason363/NumPlay/releases/latest).++Build: `make` (needs `arm-none-eabi-gcc` and Node.js for nwlink).diff --git a/games/blockblast/docs/shot.png b/games/blockblast/docs/shot.pngnew file mode 100644index 00000000..824fddc5Binary files /dev/null and b/games/blockblast/docs/shot.png differdiff --git a/games/blockblast/lang/fr.txt b/games/blockblast/lang/fr.txtnew file mode 100644index 00000000..08993fbf--- /dev/null+++ b/games/blockblast/lang/fr.txt@@ -0,0 +1,29 @@+# Block Blast in French: the English text as in the source, a tab, the translation (see tools/lang.py).+Resume Reprendre+New game Nouvelle partie+How to play Comment jouer+Quit Quitter+Play again Rejouer+1 2 3 1 2 3+choose a block choisir un bloc+Arrows Flèches+move it le déplacer+OK OK+place it le poser+Back Retour+menu menu+Paused Pause+Fill a row or a column to clear it. Blocks never turn. Remplis une ligne ou une colonne pour la vider. Les blocs ne tournent pas.+Play Jouer+New best! Record !+Game over Partie terminée+Best Record+OK place OK poser+Back menu Retour menu+Good! Bien !+Great! Super !+Excellent! Excellent !+Amazing! Incroyable !+Unbelievable! Fantastique !+Combo Combo+Board clear! Plateau vide !diff --git a/games/blockblast/lang/zh.txt b/games/blockblast/lang/zh.txtnew file mode 100644index 00000000..1589e0e9--- /dev/null+++ b/games/blockblast/lang/zh.txt@@ -0,0 +1,29 @@+# Block Blast in Chinese: the English text as in the source, a tab, the translation (see tools/lang.py).+Resume 继续+New game 新游戏+How to play 玩法+Quit 退出+Play again 再来一局+1 2 3 1 2 3+choose a block 选择方块+Arrows 方向键+move it 移动+OK OK+place it 放置+Back 返回+menu 菜单+Paused 暂停+Fill a row or a column to clear it. Blocks never turn. 填满一行或一列即可消除。方块不能旋转。+Play 开始+New best! 新纪录!+Game over 游戏结束+Best 最高分+OK place OK 放置+Back menu 返回 菜单+Good! 不错!+Great! 很棒!+Excellent! 优秀!+Amazing! 惊人!+Unbelievable! 难以置信!+Combo 连击+Board clear! 全部清空!diff --git a/games/blockblast/src/icon.png b/games/blockblast/src/icon.pngnew file mode 100644index 00000000..8868ff02Binary files /dev/null and b/games/blockblast/src/icon.png differdiff --git a/games/blockblast/src/main.c b/games/blockblast/src/main.cnew file mode 100644index 00000000..97e77c0a--- /dev/null+++ b/games/blockblast/src/main.c@@ -0,0 +1,467 @@+/* Block Blast: fit the blocks on the 8 x 8 board; fill a row or a column and it clears.+ *+ * Hungry Studio's puzzle as it plays on phones: three blocks at a time, placed in any order,+ * none of them turns; full rows and columns clear together, clearing again within three blocks+ * keeps a combo going, and the game ends when none of the blocks left fits. Its 41 blocks, how+ * often each one comes, its scoring and its colours follow what players measured from the app.+ *+ * Inside NumPlay it draws with the launcher's strips, shapes and fonts (launcher/src/gfx.c) and+ * saves through its file functions, so the game is only its rules and its screen. On its own+ * (BlockBlast.nwa) it brings them along. */+#include <eadk.h>+#include "../../../launcher/src/gfx.h"+#include "../../common/np_text.h"++#if NP_MODULE /* (np_file_read and np_file_write: NumPlay's, launcher/src/np.h) */+#define np_app_begin()+#define np_app_end() 0+#else+#include "../../common/epsilon_app.h"+#include "../../common/epsilon_files.h"+#define np_file_read ef_read+#define np_file_write ef_write+const char eadk_app_name[] __attribute__((section(".rodata.eadk_app_name"))) = "Block Blast";+const uint32_t eadk_api_level __attribute__((section(".rodata.eadk_api_level"))) = 0;+void np_push(int x, int y, int w, int h, const color_t *px) {+ eadk_display_push_rect((eadk_rect_t){(uint16_t)x, (uint16_t)y, (uint16_t)w, (uint16_t)h}, px);+}+#endif++#define KEY(k) (1ull << (k))+#define N 8+#define P 25 /* from one cell of the board to the next */+#define BX 8 /* the board's first cell */+#define BY 35+#define TX 216 /* the tray */+#define TS 12 /* a cell of the blocks waiting there */+#define WHITE 0xFFFF+#define NAVY HEX(0x1A264C)+#define GOLD HEX(0xFDE70A)++/* The blocks, as five rows of five cells (the first one leftmost), and how often each comes+ (in the top 7 bits): every way a block faces is a block of its own. */+#define B(w, a, b, c, d, e) ((uint32_t)(w) << 25 | (a) << 20 | (b) << 15 | (c) << 10 | (d) << 5 | (e))+#define I 0x10+static const uint32_t pieces[] = {+ B(9, I, 0, 0, 0, 0), /* one */+ B(14, 030, 0, 0, 0, 0), B(14, I, I, 0, 0, 0), /* lines of 2 to 5 */+ B(10, 034, 0, 0, 0, 0), B(4, I, I, I, 0, 0),+ B(6, 036, 0, 0, 0, 0), B(14, I, I, I, I, 0),+ B(3, 037, 0, 0, 0, 0), B(4, I, I, I, I, I),+ B(16, 030, 030, 0, 0, 0), B(9, 034, 034, 0, 0, 0), /* squares and rectangles */+ B(9, 030, 030, 030, 0, 0), B(4, 034, 034, 034, 0, 0),+ B(6, 030, I, 0, 0, 0), B(6, 030, 010, 0, 0, 0), /* small corners */+ B(6, I, 030, 0, 0, 0), B(6, 010, 030, 0, 0, 0),+ B(3, I, I, 030, 0, 0), B(3, 010, 010, 030, 0, 0), /* L and J */+ B(3, 030, I, I, 0, 0), B(3, 030, 010, 010, 0, 0),+ B(3, 034, I, 0, 0, 0), B(3, 034, 004, 0, 0, 0),+ B(3, I, 034, 0, 0, 0), B(3, 004, 034, 0, 0, 0),+ B(2, 034, I, I, 0, 0), B(2, 034, 004, 004, 0, 0), /* big corners */+ B(2, I, I, 034, 0, 0), B(2, 004, 004, 034, 0, 0),+ B(2, I, 010, 0, 0, 0), B(2, 010, I, 0, 0, 0), /* diagonals */+ B(2, I, 010, 004, 0, 0), B(2, 004, 010, I, 0, 0),+ B(3, 014, 030, 0, 0, 0), B(3, 030, 014, 0, 0, 0), /* S and Z */+ B(3, I, 030, 010, 0, 0), B(3, 010, 030, I, 0, 0),+ B(3, 034, 010, 0, 0, 0), B(3, 010, 034, 0, 0, 0), /* T */+ B(3, I, 030, I, 0, 0), B(3, 010, 030, 010, 0, 0),+};+#define NP (int)(sizeof pieces / sizeof pieces[0])+/* every cell of block p, row r and column c (shifted up, its first cell is the top bit) */+#define EACH(p) \+ for (uint32_t m_ = pieces[p] << 7, b_ = 0; m_; m_ <<= 1, b_++) \+ for (int r = (int)b_ / 5, c = (int)b_ % 5, o_ = (int32_t)m_ < 0; o_; o_ = 0)++/* blue, orange, green, purple, yellow, cyan, red, and grey for what can't go anywhere */+static const uint32_t faces[9] = {0, 0x345CEF, 0xF35C17, 0x28CB30, 0x9655E5, 0xFBD008, 0x19C4F0, 0xD53D38, 0x737A9C};+static color_t shade[9][5]; /* bottom, right, left, top, face */++/* blockblast.sav: the best score, and the game in progress (kept as it is played) */+static struct {+ uint8_t magic, version, flags, combo; /* flags: 1 a game to continue, 2 the guide was read */+ uint8_t miss, cur, cx, cy; /* miss: blocks placed since a line last cleared */+ uint32_t best, score, best0; /* best0: the best when this game started */+ int8_t tray[3]; /* the blocks waiting, -1 once placed */+ uint8_t tcol[3];+ uint8_t board[N * N]; /* each cell's colour, 0 if empty */+} sv;+#define SAVE_NAME "blockblast.sav"++static color_t strip[SCREEN_W * STRIP_H];+static uint32_t now, seed, total, shown, fx_t, pop_t, gain, tray_t, over_t;+static uint8_t fx[N * N]; /* the cells that just cleared, bursting: their colour */+static int fx_x, fx_y, pop_lines, pop_combo, pop_clear, hl, ov, sel, w, h, lines;+static bool over, fits_here, can[3];++static uint32_t rnd(void) {+ seed ^= seed << 13;+ seed ^= seed >> 17;+ return seed ^= seed << 5;+}+static char *num(char *o, uint32_t v) { /* v in o, then the end of it */+ char t[10];+ int n = 0;+ do t[n++] = (char)('0' + v % 10); while (v /= 10);+ while (n) *o++ = t[--n];+ *o = 0;+ return o;+}+/* a text, then a number */+static char *label(char *o, const char *s, uint32_t v) {+ char *e = o;+ while (*s) *e++ = *s++;+ num(e, v);+ return o;+}+static uint32_t ago(uint32_t t) { return now - t; }++/* ------------------------------------------------------------ the rules */+static void measure(int p) { /* w and h: the columns any of its rows reach, the rows down to its last cell */+ uint32_t m = pieces[p] << 7, cols = (m | m << 5 | m << 10 | m << 15 | m << 20) >> 27;+ w = 5 - __builtin_ctz(cols), h = (31 - __builtin_ctz(m)) / 5 + 1;+}+static bool fits(int p, int x, int y) {+ EACH(p) if (x + c >= N || y + r >= N || sv.board[(y + r) * N + x + c]) return false;+ return true;+}+static bool placeable(int p) {+ for (int k = 0; k < N * N; k++)+ if (fits(p, k % N, k / N)) return true;+ return false;+}+/* the full rows (bits 0-7) and columns (bits 8-15) of b; how many in lines */+static int full(const uint8_t *b) {+ int m = 0;+ lines = 0;+ for (int i = 0; i < N; i++) {+ int row = 1, col = 1;+ for (int j = 0; j < N; j++) row &= b[i * N + j] != 0, col &= b[j * N + i] != 0;+ m |= row << i | col << (i + 8), lines += row + col;+ }+ return m;+}+static bool in_line(int m, int k) { return (m >> (k / N) & 1) || (m >> (N + k % N) & 1); }++/* keeps the block in hand on the board */+static void clamp(void) {+ measure(sv.tray[sv.cur]);+ if (sv.cx > N - w) sv.cx = (uint8_t)(N - w);+ if (sv.cy > N - h) sv.cy = (uint8_t)(N - h);+}++static void save(void) {+ sv.magic = 'B', sv.version = 1;+ np_file_write(SAVE_NAME, &sv, sizeof sv);+}++/* three new blocks, each its own colour; at least one of them fits somewhere */+static void new_tray(void) {+ for (int t = 0; t < 40; t++) {+ bool any = false;+ for (int k = 0; k < 3; k++) {+ int r = (int)(rnd() % total), p = 0;+ while (r >= (int)(pieces[p] >> 25)) r -= (int)(pieces[p++] >> 25);+ sv.tray[k] = (int8_t)p;+ do sv.tcol[k] = (uint8_t)(1 + rnd() % 7);+ while ((k && sv.tcol[k] == sv.tcol[0]) || (k == 2 && sv.tcol[2] == sv.tcol[1]));+ any |= placeable(p);+ }+ if (any) break;+ }+ sv.cur = 0, tray_t = now;+ clamp();+}++/* the next block to take in hand, after the one just placed: one that fits if there is one */+static void next_block(void) {+ for (int pass = 0; pass < 2; pass++)+ for (int i = 1; i <= 3; i++) {+ int k = (sv.cur + i) % 3;+ if (sv.tray[k] >= 0 && (pass || placeable(sv.tray[k]))) {+ sv.cur = (uint8_t)k;+ clamp();+ return;+ }+ }+ new_tray();+}++static void check_over(void) {+ for (int k = 0; k < 3; k++)+ if (sv.tray[k] >= 0 && placeable(sv.tray[k])) return;+ over = true, over_t = now, sv.flags &= (uint8_t)~1;+}++static void new_game(void) {+ for (int k = 0; k < N * N; k++) sv.board[k] = fx[k] = 0;+ sv.score = shown = 0, sv.combo = sv.miss = 0, sv.flags |= 1, sv.best0 = sv.best;+ sv.cx = sv.cy = 3, over = false, ov = 0, pop_t = now - 9999;+ new_tray();+ save();+}++/* Scoring, as the app does it: a point a cell placed; lines cleared at once bring 10, 20, 60,+ 120, 200... times the combo (how many placements in a row cleared lines, none of them more+ than three blocks apart), and an empty board 300 more. */+static void place(void) {+ int p = sv.tray[sv.cur], col = sv.tcol[sv.cur], cells = 0;+ measure(p);+ EACH(p) sv.board[(sv.cy + r) * N + sv.cx + c] = (uint8_t)col, cells++;+ int m = full(sv.board);+ bool empty = true;+ for (int k = 0; k < N * N; k++) {+ fx[k] = 0;+ if (in_line(m, k)) fx[k] = (uint8_t)col, sv.board[k] = 0;+ if (sv.board[k]) empty = false;+ }+ fx_t = now, fx_x = 2 * sv.cx + w, fx_y = 2 * sv.cy + h; /* the bursts start from its middle */+ sv.score += (uint32_t)cells;+ if (lines) {+ sv.combo++, sv.miss = 0;+ gain = sv.combo * (uint32_t)(lines == 1 ? 10 : 10 * lines * (lines - 1)) + (empty ? 300 : 0);+ sv.score += gain, pop_t = now, pop_lines = lines, pop_combo = sv.combo, pop_clear = empty;+ } else if (++sv.miss >= 3) {+ sv.combo = 0;+ }+ if (sv.score > sv.best) sv.best = sv.score;+ sv.tray[sv.cur] = -1;+ next_block();+ check_over();+ save();+}++/* ------------------------------------------------------------ drawing */+/* a block, s pixels a side: its face framed by bevels, the top lightest, then the left, the+ right, and the bottom darkest, meeting on the diagonals */+static void block(int x, int y, int s, int c) {+ const color_t *k = shade[c];+ gfx_fill(x, y, s, s, k[4]);+ for (int i = 0, b = s > 14 ? 4 : 2; i < b; i++) {+ int e = s - 2 * i;+ gfx_fill(x + i, y + i, e, 1, k[3]);+ gfx_fill(x + i, y + s - 1 - i, e, 1, k[0]);+ gfx_fill(x + i, y + i + 1, 1, e - 2, k[2]);+ gfx_fill(x + s - 1 - i, y + i + 1, 1, e - 2, k[1]);+ }+}++static void crown(int x, int y, int k, color_t c) {+ gfx_fill(x, y + 3 * k, 8 * k, 4 * k, c);+ gfx_fill(x, y + k, 2 * k, 2 * k, c);+ gfx_fill(x + 3 * k, y, 2 * k, 3 * k, c);+ gfx_fill(x + 6 * k, y + k, 2 * k, 2 * k, c);+}++/* text with a dark rim and a shadow, to read over any block */+static void say(const np_font_t *f, int cx, int base, const char *s, color_t c, int a) {+ for (int i = 0; i < 5; i++) gfx_text_center(f, cx + (i & 1 ? 1 : -1) * (i < 4), base + (i & 2 ? 1 : -1) + 3 * (i == 4), s, NAVY, a * 3 >> 2);+ gfx_text_center(f, cx, base, s, c, a);+}++static void button(int y, const char *s, bool on) {+ gfx_rrect(90, y, 140, 26, 13, on ? GOLD : HEX(0x3F56B4), 256);+ gfx_text_center(&np_font_body, 160, y + 18, s, on ? NAVY : WHITE, 256);+}++enum { OV_NONE, OV_MENU, OV_HELP, OV_OVER };+static const char *const menu_items[] = {T("Resume"), T("New game"), T("How to play"), T("Quit")};+static const char *const over_items[] = {T("Play again"), T("Quit")};+static const char *const help_keys[][2] = {+ {T("1 2 3"), T("choose a block")}, {T("Arrows"), T("move it")}, {T("OK"), T("place it")}, {T("Back"), T("menu")}};++static void overlay(void) {+ char s[12];+ gfx_fill_alpha(0, 0, SCREEN_W, SCREEN_H, 0, 120);+ gfx_rrect(56, 34, 208, 200, 14, HEX(0x2B3E8E), 256);+ gfx_rrect_outline(56, 34, 208, 200, 14, 2, HEX(0x6F8BE0), 256);+ if (ov == OV_MENU) {+ say(&np_font_title, 160, 68, T("Paused"), WHITE, 256);+ for (int i = 0; i < 4; i++) button(84 + 34 * i, menu_items[i], sel == i);+ } else if (ov == OV_HELP) {+ say(&np_font_title, 160, 64, T("How to play"), WHITE, 256);+ gfx_paragraph(&np_font_body, 160, 86, 184, 15, T("Fill a row or a column to clear it. Blocks never turn."),+ WHITE, 256);+ for (int i = 0; i < 4; i++) {+ gfx_text_right(&np_font_body, 150, 132 + 17 * i, help_keys[i][0], GOLD, 256);+ gfx_text(&np_font_body, 160, 132 + 17 * i, help_keys[i][1], WHITE, 256);+ }+ button(200, T("Play"), true);+ } else { /* the score, under a crown and a ribbon when it is the best yet */+ bool rec = sv.score > sv.best0;+ crown(148, 44, 3, rec ? GOLD : HEX(0x6F8BE0));+ if (rec) gfx_rrect(96, 74, 128, 24, 6, HEX(0x8A3FD1), 256);+ say(&np_font_title, 160, 93, rec ? T("New best!") : T("Game over"), WHITE, 256);+ num(s, sv.score);+ say(&np_font_title, 160, 128, s, GOLD, 256);+ if (!rec) gfx_text_center(&np_font_body, 160, 150, label(s, T("Best "), sv.best), HEX(0xB8C6F5), 256);+ for (int i = 0; i < 2; i++) button(166 + 34 * i, over_items[i], sel == i);+ }+}++static void scene(void *ctx) {+ char s[12];+ gfx_vgrad(0, 0, SCREEN_W, SCREEN_H, 0x3F56B4, 0x516FC5);+ /* the best score with its crown, the score, the keys */+ crown(8, 9, 2, GOLD);+ num(s, sv.best);+ gfx_text(&np_font_body, 28, 22, s, GOLD, 256);+ num(s, shown);+ say(&np_font_title, BX + 4 * P, 27, s, WHITE, 256);+ gfx_text_right(&np_font_small, 314, 13, T("OK place"), HEX(0xD8E2FF), 220);+ gfx_text_right(&np_font_small, 314, 26, T("Back menu"), HEX(0xD8E2FF), 220);++ /* the board; the lines the block in hand would fill take its colour */+ gfx_rrect(BX - 3, BY - 3, 8 * P + 5, 8 * P + 5, 5, NAVY, 256);+ int p = sv.tray[sv.cur], col = sv.tcol[sv.cur];+ for (int k = 0; k < N * N; k++) {+ int x = BX + k % N * P, y = BY + k / N * P, c = sv.board[k];+ if (y >= gfx_y1 || y + P <= gfx_y0) continue;+ if (c && over) c = ago(over_t) > (uint32_t)(N - 1 - k / N) * 60 ? 8 : c; /* greying, from the bottom up */+ if (c && in_line(hl, k)) c = col;+ if (c) block(x, y, P - 1, c);+ else gfx_fill(x, y, P - 1, P - 1, HEX(0x242C53));+ if (fx[k]) { /* bursting: flashes, then shrinks away, from where the block went outwards */+ int ax = 2 * (k % N) + 1 - fx_x, ay = 2 * (k / N) + 1 - fx_y;+ int t = (int)ago(fx_t) - ((ax < 0 ? -ax : ax) + (ay < 0 ? -ay : ay)) * 14;+ if (t < 0) t = 0;+ if (t < 240) {+ int z = (P - 1) * (240 - t) / 240, o = (P - 1 - z) / 2;+ block(x + o, y + o, z, fx[k]);+ gfx_fill_alpha(x + o, y + o, z, z, WHITE, 230 - t);+ }+ }+ }+ if (over) gfx_fill_alpha(BX - 3, BY - 3, 8 * P + 5, 8 * P + 5, 0, ago(over_t) > 600 ? 110 : (int)ago(over_t) * 110 / 600);+ else if (p >= 0) { /* the block in hand: glowing where it fits, see-through where it doesn't */+ int g = (int)(now % 1000), a = g < 500 ? g : 1000 - g;+ EACH(p) {+ int x = BX + (sv.cx + c) * P, y = BY + (sv.cy + r) * P;+ if (fits_here) {+ block(x, y, P - 1, col);+ gfx_fill_alpha(x, y, P - 1, P - 1, WHITE, a / 6);+ } else {+ gfx_fill_alpha(x, y, P - 1, P - 1, HEX(faces[col]), 150);+ }+ }+ }++ /* the tray: each block in its place, under the key that takes it */+ for (int k = 0; k < 3; k++) {+ int y0 = 32 + 69 * k, q = sv.tray[k], on = k == sv.cur && !over;+ if (on) {+ gfx_rrect(TX, y0, 100, 67, 10, WHITE, 40);+ gfx_rrect_outline(TX, y0, 100, 67, 10, 2, WHITE, 150);+ }+ gfx_circle(TX + 11, y0 + 11, 7, on ? GOLD : HEX(0x2B3E8E), 256);+ s[0] = (char)('1' + k), s[1] = 0;+ gfx_text_center(&np_font_small, TX + 11, y0 + 15, s, on ? NAVY : WHITE, 256);+ if (q < 0) continue;+ int z = ago(tray_t) < 160 ? TS * (int)ago(tray_t) / 160 : TS; /* new blocks grow in */+ measure(q);+ EACH(q) block(TX + 50 + (2 * c - w) * z / 2, y0 + 34 + (2 * r - h) * z / 2, z - 1, can[k] ? sv.tcol[k] : 8);+ }++ /* what the last clear was worth */+ uint32_t t = ago(pop_t);+ if (t < 1100) {+ static const char *const praise[] = {T("Good!"), T("Great!"), T("Excellent!"), T("Amazing!"), T("Unbelievable!")};+ int a = t < 700 ? 256 : (int)(1100 - t) * 256 / 400, y = 140 - (int)t / 60;+ if (pop_combo > 1) say(&np_font_title, BX + 4 * P, y - 26, label(s, T("Combo "), (uint32_t)pop_combo), WHITE, a);+ if (pop_clear) say(&np_font_title, BX + 4 * P, y, T("Board clear!"), GOLD, a);+ else if (pop_lines > 1) say(&np_font_title, BX + 4 * P, y, praise[pop_lines > 6 ? 4 : pop_lines - 2], GOLD, a);+ say(&np_font_body, BX + 4 * P, y + 20, label(s, "+", gain), WHITE, a);+ }+ if (ov) overlay();+}++/* ------------------------------------------------------------ the game */+static void load(void) {+ uint32_t len = 0;+ const uint8_t *d = np_file_read(SAVE_NAME, &len);+ uint8_t *v = (uint8_t *)&sv;+ bool ok = d && len == sizeof sv && d[0] == 'B' && d[1] == 1;+ for (uint32_t i = 0; i < sizeof sv; i++) v[i] = ok ? d[i] : 0;+ /* whatever it holds, a game this one could have saved */+ for (int k = 0; k < N * N; k++)+ if (sv.board[k] > 7) sv.board[k] = 0;+ for (int k = 0; k < 3; k++) {+ if (sv.tray[k] >= NP || sv.tray[k] < -1) sv.flags &= (uint8_t)~1;+ if (sv.tcol[k] < 1 || sv.tcol[k] > 7) sv.tcol[k] = 1;+ }+ if (sv.cur > 2 || sv.tray[sv.cur] < 0 || sv.cx >= N || sv.cy >= N) sv.flags &= (uint8_t)~1;+ if (sv.best < sv.score) sv.best = sv.score;+}++int main(void) {+ np_app_begin();+ color_t *their_strip = gfx_buf;+ gfx_buf = strip;+ for (int c = 1; c < 9; c++) {+ static const uint8_t by[5] = {115, 60, 50, 120, 0}; /* towards black, then white */+ for (int i = 0; i < 5; i++) shade[c][i] = gfx_rgb(gfx_lerp888(faces[c], i < 2 ? 0 : 0xFFFFFF, by[i]));+ }+ for (int p = 0; p < NP; p++) total += pieces[p] >> 25;+ now = (uint32_t)eadk_timing_millis();+ seed = eadk_random() ^ now;+ if (!seed) seed = 1;+ load();+ shown = sv.score, pop_t = now - 9999;+ if (sv.flags & 1) clamp(), check_over();+ else new_game();+ if (!(sv.flags & 2)) ov = OV_HELP, sv.flags |= 2;+ uint64_t held = eadk_keyboard_scan(), stale = held; /* keys still down from the launcher wait to be let go */+ uint32_t repeat_at = 0;+ for (;;) {+ now = (uint32_t)eadk_timing_millis();+ uint64_t k = eadk_keyboard_scan(), hit = k & ~held;+ const uint64_t arrows = KEY(eadk_key_left) | KEY(eadk_key_right) | KEY(eadk_key_up) | KEY(eadk_key_down);+ stale &= k;+ if (hit & arrows) repeat_at = now + 220;+ else if ((k & arrows & ~stale) && (int32_t)(now - repeat_at) >= 0) hit |= k & arrows & ~stale, repeat_at = now + 70;+ held = k;+ if (k & (KEY(eadk_key_home) | KEY(eadk_key_on_off))) break;+ bool ok = hit & (KEY(eadk_key_ok) | KEY(eadk_key_exe));+ int dx = !!(hit & KEY(eadk_key_right)) - !!(hit & KEY(eadk_key_left));+ int dy = !!(hit & KEY(eadk_key_down)) - !!(hit & KEY(eadk_key_up));+ if (over && !ov && ago(over_t) > 1300) ov = OV_OVER, sel = 0;+ if (ov) {+ int n = ov == OV_MENU ? 4 : ov == OV_OVER ? 2 : 1;+ sel = (sel + dy + n) % n;+ if (hit & KEY(eadk_key_back) && ov != OV_OVER) ov = OV_NONE;+ if (ok) {+ int choice = ov == OV_OVER ? (sel ? 3 : 1) : ov == OV_MENU ? sel : 0;+ ov = OV_NONE;+ if (choice == 1) new_game();+ else if (choice == 2) ov = OV_HELP;+ else if (choice == 3) break;+ }+ } else if (hit & KEY(eadk_key_back)) {+ ov = OV_MENU, sel = 0;+ save();+ } else if (!over) {+ for (int i = 0; i < 3; i++)+ if (hit & KEY(eadk_key_one + i) && sv.tray[i] >= 0) sv.cur = (uint8_t)i, clamp();+ measure(sv.tray[sv.cur]);+ if (sv.cx + dx >= 0 && sv.cx + dx <= N - w) sv.cx = (uint8_t)(sv.cx + dx);+ if (sv.cy + dy >= 0 && sv.cy + dy <= N - h) sv.cy = (uint8_t)(sv.cy + dy);+ if (ok && fits(sv.tray[sv.cur], sv.cx, sv.cy)) place();+ }+ /* what the frame shows: where the block in hand would go, and what it would clear */+ int p = sv.tray[sv.cur];+ fits_here = !over && p >= 0 && fits(p, sv.cx, sv.cy), hl = 0;+ if (fits_here) {+ uint8_t b[N * N];+ for (int i = 0; i < N * N; i++) b[i] = sv.board[i];+ EACH(p) b[(sv.cy + r) * N + sv.cx + c] = 1;+ hl = full(b);+ }+ for (int i = 0; i < 3; i++) can[i] = sv.tray[i] >= 0 && placeable(sv.tray[i]);+ if (shown != sv.score) shown += (sv.score - shown + 5) / 6;+ eadk_display_wait_for_vblank();+ gfx_render(scene, 0, 0, SCREEN_H);+ uint32_t spent = (uint32_t)eadk_timing_millis() - now;+ if (spent < 30) eadk_timing_msleep(30 - spent);+ }+ save();+ gfx_buf = their_strip;+ return np_app_end();+}diff --git a/games/games.json b/games/games.jsonindex d8eb19c2..eb9f6c92 100644--- a/games/games.json+++ b/games/games.json@@ -141,6 +141,24 @@],"repo": "https://github.com/Mason363/NumPlay/tree/main/games/buckshot"},+ {+ "id": "blockblast",+ "title": "Block Blast",+ "tagline": "Fit the blocks, blast the lines",+ "credit": "Based on Block Blast! by Hungry Studio",+ "top": "0x516FC5",+ "bottom": "0x1A264C",+ "accent": "0xFBD008",+ "colors": 16,+ "records": [+ "blockblast.sav"+ ],+ "shots": [+ "docs/shot.png"+ ],+ "app": "BlockBlast.nwa",+ "repo": "https://github.com/Mason363/NumPlay/tree/main/games/blockblast"+ },{"id": "portal","title": "Portal Returns",diff --git a/launcher/lang/fr.txt b/launcher/lang/fr.txtindex ae2541a5..28fd6d58 100644--- a/launcher/lang/fr.txt+++ b/launcher/lang/fr.txt@@ -72,6 +72,8 @@ Balatro BalatroPoker hands, wild jokers Mains de poker, jokers fousBuckshot Roulette Buckshot RouletteYou, the Dealer, one shotgun Toi, le croupier, un fusil+Block Blast Block Blast+Fit the blocks, blast the lines Place les blocs, fais sauter les lignesPortal Returns Portal ReturnsThink with portals Pense avec les portailsTetris Tetris@@ -105,6 +107,7 @@ Inspired by Minecraft, not affiliated with Mojang Inspiré de Minecraft, sans liBy Tatone26, from All the Apps Par Tatone26, tiré d'All the AppsInspired by Tatone26's All the Apps Inspiré d'All the Apps de Tatone26Based on 2048 by Gabriele Cirulli D'après 2048 de Gabriele Cirulli+Based on Block Blast! by Hungry Studio D'après Block Blast! de Hungry Studio# a game the RAM of the calculator's software is too small forNeeds Il manqueKB more memory Ko de mémoirediff --git a/launcher/lang/zh.txt b/launcher/lang/zh.txtindex 20e96b6d..dfc156aa 100644--- a/launcher/lang/zh.txt+++ b/launcher/lang/zh.txt@@ -71,6 +71,8 @@ Balatro 小丑牌Poker hands, wild jokers 扑克牌型,狂野小丑Buckshot Roulette 恶魔轮盘You, the Dealer, one shotgun 你、庄家、一把霰弹枪+Block Blast 方块爆破+Fit the blocks, blast the lines 摆放方块,消除整行Portal Returns 传送门归来Think with portals 用传送门思考Tetris 俄罗斯方块@@ -104,6 +106,7 @@ Inspired by Minecraft, not affiliated with Mojang 灵感来自《我的世界》By Tatone26, from All the Apps 作者 Tatone26,出自 All the AppsInspired by Tatone26's All the Apps 灵感来自 Tatone26 的 All the AppsBased on 2048 by Gabriele Cirulli 改编自 Gabriele Cirulli 的 2048+Based on Block Blast! by Hungry Studio 改编自 Hungry Studio 的 Block Blast!# a game the RAM of the calculator's software is too small forNeeds 内存还差KB more memory KBdiff --git a/launcher/src/np.h b/launcher/src/np.hindex 1b798bdc..2d20be6a 100644--- a/launcher/src/np.h+++ b/launcher/src/np.h@@ -75,6 +75,9 @@ void np_game_run(int i);/* ---- storage (storage.c): Epsilon's record file system */bool np_storage_delete(const char *name); /* true if gone (or never there) */uint32_t np_storage_record_size(const char *name);+/* a record's content (NULL if none), and writing one: for the games too */+const uint8_t *np_file_read(const char *name, uint32_t *len);+bool np_file_write(const char *name, const void *data, uint32_t len);/* deletes a game's progress (np_game_t.progress); true if all of it is gone */bool np_reset_game(int game);diff --git a/launcher/src/storage.c b/launcher/src/storage.cindex b668083d..8ca7f8b8 100644--- a/launcher/src/storage.c+++ b/launcher/src/storage.c@@ -92,6 +92,10 @@ bool np_bg_save(int mode) {return ef_write(BG_NAME, d, sizeof d);}+/* A game's save, for a game that uses NumPlay's file functions instead of its own (Block Blast). */+const uint8_t *np_file_read(const char *name, uint32_t *len) { return ef_read(name, len); }+bool np_file_write(const char *name, const void *data, uint32_t len) { return ef_write(name, data, len); }+/* ---------------------------------------------------------------- progress copy* Installing apps restarts the calculator, which empties its file system; the* NumWorks installer puts back the Python scripts only. So NumPlay keeps everydiff --git a/tests/test_games.py b/tests/test_games.pyindex d8521eab..0e5b4d65 100644--- a/tests/test_games.py+++ b/tests/test_games.py@@ -96,6 +96,10 @@ GAMES = {# start, then through the bathroom and the hallway to the table; then continue"buckshot": ("BuckshotRoulette.nwa", "buckshot.sav", every(1500, 14000, 900, "ok"), 16000,presses((1500, "ok")), 4000),+ # the guide, then a block placed in the middle; next time the game goes on: one more in the corner+ "blockblast": ("BlockBlast.nwa", "blockblast.sav", presses((1500, "ok"), (2000, "ok")), 3000,+ presses(*[(1500 + 250 * i, "up") for i in range(4)], *[(2500 + 250 * i, "left") for i in range(4)],+ (3600, "ok")), 4500),# the intro film is skipped (seen), Lucky walks up the dock and talks to the# guardians; next time the game starts where it was left"championisland": ("ChampionIsland.nwa", "champion.sav",@@ -197,6 +201,10 @@ CHECKS = {# the world's record: its magic, then (offset 16) the time of day, which goes on from one session to the next"numblocks": (lambda v: v[:4] == b"NBW3" and struct.unpack_from("<I", v, 16)[0] > 0,lambda v: v[:4] == b"NBW3" and struct.unpack_from("<I", v, 16)[0] > 60),+ # a game kept (guide read) with a block's points, the best as high; then a second block's+ "blockblast": (lambda v: len(v) == 92 and v[:3] == b"B\1\3" and struct.unpack_from("<I", v, 12)[0] >= 1+ and struct.unpack_from("<I", v, 8)[0] >= struct.unpack_from("<I", v, 12)[0],+ lambda v: v[2] & 1 and struct.unpack_from("<I", v, 12)[0] >= 2),"breakout": (lambda v: len(v) == 12 and v[:2] == b"B\2" and v[4] == 1 and struct.unpack_from("<I", v, 8)[0] >= 10,lambda v: v[4] == 0 and struct.unpack_from("<I", v, 8)[0] >= 1), # best kept, shake off}diff --git a/tests/test_upsilon.py b/tests/test_upsilon.pyindex 3fecdd03..d06fbfbd 100644--- a/tests/test_upsilon.py+++ b/tests/test_upsilon.py@@ -31,13 +31,14 @@ def main():st = os.path.join(a.out, "storage.bin")save = bytes(range(30))write_storage(st, [("pi.py", b"\x01print(3.14159)\n\x00"), ("snake.sav", save)])- # the home screen: Crossy Road, Portal Returns, Tetris, Chess...: Right three times, OK+ # the home screen: Crossy Road, Block Blast, Portal Returns, Tetris, Chess...: Right four times, OKc = emu.Calculator(a.nwa, storage_file=st)c.enable_checks(reads=True)- c.keys = presses((1200, "right"), (1600, "right"), (2000, "right"), (2600, "ok")) + [(7000, 7400, emu.KEYS["home"])]+ c.keys = presses((1200, "right"), (1600, "right"), (2000, "right"), (2400, "right"), (3000, "ok")) + \+ [(7400, 7800, emu.KEYS["home"])]menu = os.path.join(a.out, "chess.png")- c.pending_shots = [(6500, menu)]- c.run(10000)+ c.pending_shots = [(6900, menu)]+ c.run(10400)problems = sorted(set(c.violations))if not c.exited:problems.append("did not quit on Home")diff --git a/tools/release.py b/tools/release.pyindex 0650af2b..8063f0b6 100644--- a/tools/release.py+++ b/tools/release.py@@ -43,7 +43,7 @@ LANGUAGES = [("NumPlay-French.nwa", "NumPlay en français : tous les jeux, en français"),("NumPlay-Chinese.nwa", "NumPlay 中文版:所有游戏,简体中文"),]-UPSILON = ("NumPlay-Upsilon.nwa", "For calculators running Upsilon (N0110, N0115): the 13 games that fit in the memory "+UPSILON = ("NumPlay-Upsilon.nwa", "For calculators running Upsilon (N0110, N0115): the 14 games that fit in the memory ""Upsilon gives apps. Install it with nwlink, see the README")