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
Cookie Clicker: a big app of its own, drawn faster, tested
Mason36387baedd92587
diff --git a/Makefile b/Makefileindex 8a0a564d..ee3d695f 100644--- a/Makefile+++ b/Makefile@@ -24,7 +24,7 @@ RAM_LIMIT = 148928# custom builds of Epsilon 25.2's source give apps less: 133652 bytes; every game fits there too, in NumPlay and on# its own (their big buffers are on the stack, 32 KB apart from that RAM, or in the RAM the software has left)CUSTOM_RAM = 133652-BIG_APPS = Celeste HollowKnight Undertale ChampionIsland FinalEarth2 NumPowder NumBlocks NumDrive SubwaySurfers FiveNightsAtFreddys Doom BindingOfIsaac HillClimbRacing PlantsVsZombies SonicTheHedgehog+BIG_APPS = Celeste HollowKnight Undertale ChampionIsland FinalEarth2 NumPowder NumBlocks NumDrive SubwaySurfers FiveNightsAtFreddys Doom BindingOfIsaac HillClimbRacing PlantsVsZombies SonicTheHedgehog CookieClicker# the calculator's space for installed apps (0x90200000 to 0x903F0000 in its flash)APP_SPACE = 2031616# Upsilon, the N0110 and N0115's custom software, gives .nwa apps less RAM: NumPlay-Upsilon.nwa has@@ -216,6 +216,7 @@ APP_doom = games/doom/output/doom.nwa:Doom.nwaAPP_isaac = games/isaac/output/isaac.nwa:BindingOfIsaac.nwaAPP_pvz = games/pvz/output/pvz.nwa:PlantsVsZombies.nwaAPP_sonic = games/sonic/output/sonic.nwa:SonicTheHedgehog.nwa+APP_cookieclicker = games/cookieclicker/output/cookieclicker.nwa:CookieClicker.nwaapps: | $(B)$(MAKE) -C games/numdash build NWLINK="node node_modules/nwlink/bin/nwlink"@@ -239,6 +240,7 @@ apps: | $(B)$(MAKE) -C games/isaac build NWLINK="$(NWLINK)"$(MAKE) -C games/pvz build NWLINK="$(NWLINK)"$(MAKE) -C games/sonic build NWLINK="$(NWLINK)"+ $(MAKE) -C games/cookieclicker build NWLINK="$(NWLINK)"cd games/tetris/tetris && NWLINK="$(NWLINK)" $(CARGO) build --release --quietcp $(word 1,$(subst :, ,$(APP_numdash))) $(B)/apps/$(word 2,$(subst :, ,$(APP_numdash)))cp $(word 1,$(subst :, ,$(APP_crossyroad))) $(B)/apps/$(word 2,$(subst :, ,$(APP_crossyroad)))@@ -262,6 +264,7 @@ apps: | $(B)cp $(word 1,$(subst :, ,$(APP_isaac))) $(B)/apps/$(word 2,$(subst :, ,$(APP_isaac)))cp $(word 1,$(subst :, ,$(APP_pvz))) $(B)/apps/$(word 2,$(subst :, ,$(APP_pvz)))cp $(word 1,$(subst :, ,$(APP_sonic))) $(B)/apps/$(word 2,$(subst :, ,$(APP_sonic)))+ cp $(word 1,$(subst :, ,$(APP_cookieclicker))) $(B)/apps/$(word 2,$(subst :, ,$(APP_cookieclicker)))arm-none-eabi-strip --strip-unneeded $(B)/apps/Tetris.nwaSTD_APPS = $(foreach g,$(STD_GAMES),$(B)/apps/$(NWA_$(g)))@@ -326,5 +329,6 @@ clean:-$(MAKE) -C games/isaac clean-$(MAKE) -C games/pvz clean-$(MAKE) -C games/sonic clean+ -$(MAKE) -C games/cookieclicker clean-cd games/tetris/tetris && $(CARGO) clean-$(foreach g,$(STD_GAMES),$(MAKE) -C games/$(g) clean;)diff --git a/games/cookieclicker/src/ascend.c b/games/cookieclicker/src/ascend.cindex 9f859c4c..5c6230b9 100644--- a/games/cookieclicker/src/ascend.c+++ b/games/cookieclicker/src/ascend.c@@ -137,7 +137,7 @@ static void draw_heavens(void) {int slot = permanent_slot_of(u);if (slot >= 0 && bought && S.permanent[slot]) gfx_icon_scaled(upgrade_rec(S.permanent[slot] - 1)->icon, x + 2, y + 2, 12, 256);}- gfx_image_scaled(IM_BORDER_SOFT, 0, 0, SCREEN_W, SCREEN_H, 256);+ gfx_image_scaled_fast(IM_BORDER_SOFT, 0, 0, SCREEN_W, SCREEN_H, 256);/* the top: prestige, the chips, Reincarnate */char a[48], t[64];beautify(S.prestige, 0, a);diff --git a/games/cookieclicker/src/data.bin b/games/cookieclicker/src/data.binindex 87ffbfa6..b18cfe14 100644Binary files a/games/cookieclicker/src/data.bin and b/games/cookieclicker/src/data.bin differdiff --git a/games/cookieclicker/src/data.h b/games/cookieclicker/src/data.hindex 875699a4..d202df7c 100644--- a/games/cookieclicker/src/data.h+++ b/games/cookieclicker/src/data.h@@ -5,7 +5,7 @@#define MILK_TILE 178#define ICON_COLS 36#define ICON_ROWS 37-#define OFF_ICONS 1397016+#define OFF_ICONS 1421904#define F_TITLE 0#define F_NAME 1#define F_NAME_SMALL 2@@ -15,8 +15,8 @@#define F_ITALIC 6#define F_SMALL 7#define F_KAVOON 8-#define OFF_FONTS 1447600-#define OFF_BUILDINGS 1447640+#define OFF_FONTS 1472488+#define OFF_BUILDINGS 1472528#define N_BUILDINGS 20#define B_CURSOR 0#define B_GRANDMA 1@@ -38,7 +38,7 @@#define B_IDLEVERSE 17#define B_CORTEX_BAKER 18#define B_YOU 19-#define OFF_TIERS 1448760+#define OFF_TIERS 1473648#define N_TIERS 18#define TIER__1 0#define TIER__2 1@@ -58,7 +58,7 @@#define TIER_SYNERGY1 15#define TIER_SYNERGY2 16#define TIER_FORTUNE 17-#define OFF_UPGRADES 1449192+#define OFF_UPGRADES 1474080#define N_UPGRADES 876#define U_REINFORCED_INDEX_FINGER 0#define U_CARPAL_TUNNEL_PREVENTION_CREAM 1@@ -936,7 +936,7 @@#define U_UNDECILLION_FINGERS 873#define U_OMNIPLAST_MOUSE 874#define U_WRINKLER_AMBERGRIS 875-#define OFF_ACHIEVS 1505256+#define OFF_ACHIEVS 1530144#define N_ACHIEVS 643#define A_WAKE_AND_BAKE 0#define A_MAKING_SOME_DOUGH 1@@ -1582,49 +1582,49 @@#define A_ALL_ON_DECK 641#define A_A_ROUND_OF_APPLAUSE 642#define N_MILKS 25-#define OFF_MILKS 1518116-#define OFF_BUILDING_LINKS 1518320-#define OFF_TIER_UNSHACKLE 1520880+#define OFF_MILKS 1543004+#define OFF_BUILDING_LINKS 1543208+#define OFF_TIER_UNSHACKLE 1545768#define N_TIER_UNSHACKLE 18-#define OFF_COOKIE_UPGRADES 1520916+#define OFF_COOKIE_UPGRADES 1545804#define N_COOKIE_UPGRADES 248-#define OFF_GRANDMA_SYNERGIES 1521412+#define OFF_GRANDMA_SYNERGIES 1546300#define N_GRANDMA_SYNERGIES 18-#define OFF_KITTENS 1521448+#define OFF_KITTENS 1546336#define N_KITTENS 18-#define OFF_GOLDEN_UPGRADES 1521484+#define OFF_GOLDEN_UPGRADES 1546372#define N_GOLDEN_UPGRADES 10-#define OFF_LASTING 1521504+#define OFF_LASTING 1546392#define N_LASTING 8-#define OFF_NO_PERM 1521520+#define OFF_NO_PERM 1546408#define N_NO_PERM 6-#define OFF_HEAVENLY 1521532+#define OFF_HEAVENLY 1546420#define N_HEAVENLY 129-#define OFF_EASTER_EGGS 1521792+#define OFF_EASTER_EGGS 1546680#define N_EASTER_EGGS 20-#define OFF_HALLOWEEN_DROPS 1521832+#define OFF_HALLOWEEN_DROPS 1546720#define N_HALLOWEEN_DROPS 7-#define OFF_HEART_DROPS 1521848+#define OFF_HEART_DROPS 1546736#define N_HEART_DROPS 7-#define OFF_SANTA_DROPS 1521864+#define OFF_SANTA_DROPS 1546752#define N_SANTA_DROPS 14-#define OFF_REINDEER_DROPS 1521892+#define OFF_REINDEER_DROPS 1546780#define N_REINDEER_DROPS 7-#define OFF_FORTUNES 1521908+#define OFF_FORTUNES 1546796#define N_FORTUNES 25-#define OFF_SHOW_IF 1521960+#define OFF_SHOW_IF 1546848#define N_SHOW_IF 3-#define OFF_CONFIRM 1521968+#define OFF_CONFIRM 1546856#define N_CONFIRM 6-#define OFF_BANK_ACHIEVS 1521984+#define OFF_BANK_ACHIEVS 1546872#define N_BANK_ACHIEVS 48-#define OFF_CPS_ACHIEVS 1522752+#define OFF_CPS_ACHIEVS 1547640#define N_CPS_ACHIEVS 48-#define OFF_UNLOCK_AT 1523520+#define OFF_UNLOCK_AT 1548408#define N_UNLOCK_AT 213-#define OFF_TEXT 1528632-#define OFF_IMAGES 1715284-#define N_IMAGES 1524+#define OFF_TEXT 1553520+#define OFF_IMAGES 1740172+#define N_IMAGES 1556#define IM_COOKIE 0#define IM_COOKIE_SHADOW 1#define IM_FLARE 2@@ -1650,235 +1650,267 @@#define IM_SMALL_COOKIE6 22#define IM_SMALL_COOKIE7 23#define IM_CURSOR 24-#define IM_GOLD_COOKIE 25-#define IM_WRATH_COOKIE 26-#define IM_MILK_PLAIN 27-#define IM_MILK_CHOCOLATE 28-#define IM_MILK_RASPBERRY 29-#define IM_MILK_ORANGE 30-#define IM_MILK_CARAMEL 31-#define IM_MILK_BANANA 32-#define IM_MILK_LIME 33-#define IM_MILK_BLUEBERRY 34-#define IM_MILK_STRAWBERRY 35-#define IM_MILK_VANILLA 36-#define IM_MILK_HONEY 37-#define IM_MILK_COFFEE 38-#define IM_MILK_TEA 39-#define IM_MILK_COCONUT 40-#define IM_MILK_CHERRY 41-#define IM_MILK_SPICED 42-#define IM_MILK_MAPLE 43-#define IM_MILK_MINT 44-#define IM_MILK_LICORICE 45-#define IM_MILK_ROSE 46-#define IM_MILK_DRAGONFRUIT 47-#define IM_MILK_MELON 48-#define IM_MILK_BLACKCURRANT 49-#define IM_MILK_PEACH 50-#define IM_MILK_HAZELNUT 51-#define IM_WRINKLER 52-#define IM_SHINY_WRINKLER 53-#define IM_SHIMMERING_VEIL 54-#define IM_DRAGON_BG 55-#define IM_BROKEN_COOKIE0 56-#define IM_BROKEN_COOKIE1 57-#define IM_BROKEN_COOKIE2 58-#define IM_BROKEN_COOKIE3 59-#define IM_BROKEN_COOKIE4 60-#define IM_BROKEN_COOKIE5 61-#define IM_BROKEN_COOKIE6 62-#define IM_BROKEN_COOKIE7 63-#define IM_BROKEN_COOKIE8 64-#define IM_BROKEN_COOKIE9 65-#define IM_BROKEN_HALO 66-#define IM_SHINE_SPOKE 67-#define IM_HEAVEN_RING1 68-#define IM_HEAVEN_RING2 69-#define IM_STARS 70-#define IM_STORE_TILE0 71-#define IM_STORE_TILE1 72-#define IM_STORE_TILE2 73-#define IM_STORE_TILE3 74-#define IM_UPGRADE_FRAME 75-#define IM_MONEY 76-#define IM_HEAVENLY_MONEY 77-#define IM_LUMP_MONEY 78-#define IM_PANEL_V 79-#define IM_PANEL_H 80-#define IM_DARK_NOISE 81-#define IM_BUILD_CURSOR 82-#define IM_BUILD_CURSOR_OFF 83-#define IM_BUILD_GRANDMA 84-#define IM_BUILD_GRANDMA_OFF 85-#define IM_BUILD_FARM 86-#define IM_BUILD_FARM_OFF 87-#define IM_BUILD_MINE 88-#define IM_BUILD_MINE_OFF 89-#define IM_BUILD_FACTORY 90-#define IM_BUILD_FACTORY_OFF 91-#define IM_BUILD_BANK 92-#define IM_BUILD_BANK_OFF 93-#define IM_BUILD_TEMPLE 94-#define IM_BUILD_TEMPLE_OFF 95-#define IM_BUILD_WIZARD_TOWER 96-#define IM_BUILD_WIZARD_TOWER_OFF 97-#define IM_BUILD_SHIPMENT 98-#define IM_BUILD_SHIPMENT_OFF 99-#define IM_BUILD_ALCHEMY_LAB 100-#define IM_BUILD_ALCHEMY_LAB_OFF 101-#define IM_BUILD_PORTAL 102-#define IM_BUILD_PORTAL_OFF 103-#define IM_BUILD_TIME_MACHINE 104-#define IM_BUILD_TIME_MACHINE_OFF 105-#define IM_BUILD_ANTIMATTER_CONDENSER 106-#define IM_BUILD_ANTIMATTER_CONDENSER_OFF 107-#define IM_BUILD_PRISM 108-#define IM_BUILD_PRISM_OFF 109-#define IM_BUILD_CHANCEMAKER 110-#define IM_BUILD_CHANCEMAKER_OFF 111-#define IM_BUILD_FRACTAL_ENGINE 112-#define IM_BUILD_FRACTAL_ENGINE_OFF 113-#define IM_BUILD_JAVASCRIPT_CONSOLE 114-#define IM_BUILD_JAVASCRIPT_CONSOLE_OFF 115-#define IM_BUILD_IDLEVERSE 116-#define IM_BUILD_IDLEVERSE_OFF 117-#define IM_BUILD_CORTEX_BAKER 118-#define IM_BUILD_CORTEX_BAKER_OFF 119-#define IM_BUILD_YOU 120-#define IM_BUILD_YOU_OFF 121-#define IM_ROW_BG_GRANDMA 122-#define IM_ROW_GRANDMA 123-#define IM_ROW_BG_FARM 124-#define IM_ROW_FARM 125-#define IM_ROW_BG_MINE 126-#define IM_ROW_MINE 127-#define IM_ROW_BG_FACTORY 128-#define IM_ROW_FACTORY 129-#define IM_ROW_BG_BANK 130-#define IM_ROW_BANK 131-#define IM_ROW_BG_TEMPLE 132-#define IM_ROW_TEMPLE 133-#define IM_ROW_BG_WIZARDTOWER 134-#define IM_ROW_WIZARDTOWER 135-#define IM_ROW_BG_SHIPMENT 136-#define IM_ROW_SHIPMENT 137-#define IM_ROW_BG_ALCHEMYLAB 138-#define IM_ROW_ALCHEMYLAB 139-#define IM_ROW_BG_PORTAL 140-#define IM_ROW_PORTAL 141-#define IM_ROW_BG_TIMEMACHINE 142-#define IM_ROW_TIMEMACHINE 143-#define IM_ROW_BG_ANTIMATTERCONDENSER 144-#define IM_ROW_ANTIMATTERCONDENSER 145-#define IM_ROW_BG_PRISM 146-#define IM_ROW_PRISM 147-#define IM_ROW_BG_CHANCEMAKER 148-#define IM_ROW_CHANCEMAKER 149-#define IM_ROW_BG_FRACTALENGINE 150-#define IM_ROW_FRACTALENGINE 151-#define IM_ROW_BG_JAVASCRIPTCONSOLE 152-#define IM_ROW_JAVASCRIPTCONSOLE0 153-#define IM_ROW_JAVASCRIPTCONSOLE1 154-#define IM_ROW_BG_IDLEVERSE 155-#define IM_ROW_IDLEVERSE0 156-#define IM_ROW_IDLEVERSE1 157-#define IM_ROW_IDLEVERSE2 158-#define IM_ROW_IDLEVERSE3 159-#define IM_ROW_BG_CORTEX 160-#define IM_ROW_CORTEX0 161-#define IM_ROW_CORTEX1 162-#define IM_ROW_CORTEX2 163-#define IM_ROW_CORTEX3 164-#define IM_ROW_BG_YOU 165-#define IM_ROW_YOU 166-#define IM_ROW_FARMERGRANDMA 167-#define IM_ROW_WORKERGRANDMA 168-#define IM_ROW_MINERGRANDMA 169-#define IM_ROW_COSMICGRANDMA 170-#define IM_ROW_TRANSMUTEDGRANDMA 171-#define IM_ROW_ALTEREDGRANDMA 172-#define IM_ROW_GRANDMASGRANDMA 173-#define IM_ROW_ANTIGRANDMA 174-#define IM_ROW_RAINBOWGRANDMA 175-#define IM_ROW_BANKGRANDMA 176-#define IM_ROW_TEMPLEGRANDMA 177-#define IM_ROW_WITCHGRANDMA 178-#define IM_ROW_LUCKYGRANDMA 179-#define IM_ROW_METAGRANDMA 180-#define IM_ROW_SCRIPTGRANDMA 181-#define IM_ROW_ALTERNATEGRANDMA 182-#define IM_ROW_BRAINYGRANDMA 183-#define IM_ROW_CLONEGRANDMA 184-#define IM_ROW_ELFGRANDMA 185-#define IM_ROW_BUNNYGRANDMA 186-#define IM_MG_BG_GRIMOIRE 187-#define IM_MG_BG_PANTHEON 188-#define IM_MG_BG_GARDEN 189-#define IM_MG_BG_MARKET 190-#define IM_DRAGON0 191-#define IM_DRAGON1 192-#define IM_DRAGON2 193-#define IM_DRAGON3 194-#define IM_DRAGON4 195-#define IM_DRAGON5 196-#define IM_DRAGON6 197-#define IM_DRAGON7 198-#define IM_DRAGON8 199-#define IM_SANTA0 200-#define IM_SANTA1 201-#define IM_SANTA2 202-#define IM_SANTA3 203-#define IM_SANTA4 204-#define IM_SANTA5 205-#define IM_SANTA6 206-#define IM_SANTA7 207-#define IM_SANTA8 208-#define IM_SANTA9 209-#define IM_SANTA10 210-#define IM_SANTA11 211-#define IM_SANTA12 212-#define IM_SANTA13 213-#define IM_SANTA14 214-#define IM_SPELL_BG 215-#define IM_ASCEND_SLOT0 216-#define IM_ASCEND_SLOT1 217-#define IM_ASCEND_SLOT2 218-#define IM_REINDEER 219-#define IM_GOLD_WREATH 220-#define IM_WRATH_WREATH 221-#define IM_HEART0_0 222-#define IM_HEART0_1 223-#define IM_HEART0_2 224-#define IM_HEART0_3 225-#define IM_HEART0_4 226-#define IM_HEART0_5 227-#define IM_HEART0_6 228-#define IM_HEART0_7 229-#define IM_HEART1_0 230-#define IM_HEART1_1 231-#define IM_HEART1_2 232-#define IM_HEART1_3 233-#define IM_HEART1_4 234-#define IM_HEART1_5 235-#define IM_HEART1_6 236-#define IM_HEART1_7 237-#define IM_BUNNY0_0 238-#define IM_BUNNY0_1 239-#define IM_BUNNY0_2 240-#define IM_BUNNY0_3 241-#define IM_BUNNY1_0 242-#define IM_BUNNY1_1 243-#define IM_BUNNY1_2 244-#define IM_BUNNY1_3 245-#define IM_FAMILIAR0_0 246-#define IM_FAMILIAR0_1 247-#define IM_FAMILIAR0_2 248-#define IM_FAMILIAR0_3 249-#define IM_FAMILIAR1_0 250-#define IM_FAMILIAR1_1 251-#define IM_FAMILIAR1_2 252-#define IM_FAMILIAR1_3 253-#define DATA_SIZE 1739668+#define IM_CURSOR_R0 25+#define IM_CURSOR_R1 26+#define IM_CURSOR_R2 27+#define IM_CURSOR_R3 28+#define IM_CURSOR_R4 29+#define IM_CURSOR_R5 30+#define IM_CURSOR_R6 31+#define IM_CURSOR_R7 32+#define IM_CURSOR_R8 33+#define IM_CURSOR_R9 34+#define IM_CURSOR_R10 35+#define IM_CURSOR_R11 36+#define IM_CURSOR_R12 37+#define IM_CURSOR_R13 38+#define IM_CURSOR_R14 39+#define IM_CURSOR_R15 40+#define IM_CURSOR_R16 41+#define IM_CURSOR_R17 42+#define IM_CURSOR_R18 43+#define IM_CURSOR_R19 44+#define IM_CURSOR_R20 45+#define IM_CURSOR_R21 46+#define IM_CURSOR_R22 47+#define IM_CURSOR_R23 48+#define IM_CURSOR_R24 49+#define IM_CURSOR_R25 50+#define IM_CURSOR_R26 51+#define IM_CURSOR_R27 52+#define IM_CURSOR_R28 53+#define IM_CURSOR_R29 54+#define IM_CURSOR_R30 55+#define IM_CURSOR_R31 56+#define IM_GOLD_COOKIE 57+#define IM_WRATH_COOKIE 58+#define IM_MILK_PLAIN 59+#define IM_MILK_CHOCOLATE 60+#define IM_MILK_RASPBERRY 61+#define IM_MILK_ORANGE 62+#define IM_MILK_CARAMEL 63+#define IM_MILK_BANANA 64+#define IM_MILK_LIME 65+#define IM_MILK_BLUEBERRY 66+#define IM_MILK_STRAWBERRY 67+#define IM_MILK_VANILLA 68+#define IM_MILK_HONEY 69+#define IM_MILK_COFFEE 70+#define IM_MILK_TEA 71+#define IM_MILK_COCONUT 72+#define IM_MILK_CHERRY 73+#define IM_MILK_SPICED 74+#define IM_MILK_MAPLE 75+#define IM_MILK_MINT 76+#define IM_MILK_LICORICE 77+#define IM_MILK_ROSE 78+#define IM_MILK_DRAGONFRUIT 79+#define IM_MILK_MELON 80+#define IM_MILK_BLACKCURRANT 81+#define IM_MILK_PEACH 82+#define IM_MILK_HAZELNUT 83+#define IM_WRINKLER 84+#define IM_SHINY_WRINKLER 85+#define IM_SHIMMERING_VEIL 86+#define IM_DRAGON_BG 87+#define IM_BROKEN_COOKIE0 88+#define IM_BROKEN_COOKIE1 89+#define IM_BROKEN_COOKIE2 90+#define IM_BROKEN_COOKIE3 91+#define IM_BROKEN_COOKIE4 92+#define IM_BROKEN_COOKIE5 93+#define IM_BROKEN_COOKIE6 94+#define IM_BROKEN_COOKIE7 95+#define IM_BROKEN_COOKIE8 96+#define IM_BROKEN_COOKIE9 97+#define IM_BROKEN_HALO 98+#define IM_SHINE_SPOKE 99+#define IM_HEAVEN_RING1 100+#define IM_HEAVEN_RING2 101+#define IM_STARS 102+#define IM_STORE_TILE0 103+#define IM_STORE_TILE1 104+#define IM_STORE_TILE2 105+#define IM_STORE_TILE3 106+#define IM_UPGRADE_FRAME 107+#define IM_MONEY 108+#define IM_HEAVENLY_MONEY 109+#define IM_LUMP_MONEY 110+#define IM_PANEL_V 111+#define IM_PANEL_H 112+#define IM_DARK_NOISE 113+#define IM_BUILD_CURSOR 114+#define IM_BUILD_CURSOR_OFF 115+#define IM_BUILD_GRANDMA 116+#define IM_BUILD_GRANDMA_OFF 117+#define IM_BUILD_FARM 118+#define IM_BUILD_FARM_OFF 119+#define IM_BUILD_MINE 120+#define IM_BUILD_MINE_OFF 121+#define IM_BUILD_FACTORY 122+#define IM_BUILD_FACTORY_OFF 123+#define IM_BUILD_BANK 124+#define IM_BUILD_BANK_OFF 125+#define IM_BUILD_TEMPLE 126+#define IM_BUILD_TEMPLE_OFF 127+#define IM_BUILD_WIZARD_TOWER 128+#define IM_BUILD_WIZARD_TOWER_OFF 129+#define IM_BUILD_SHIPMENT 130+#define IM_BUILD_SHIPMENT_OFF 131+#define IM_BUILD_ALCHEMY_LAB 132+#define IM_BUILD_ALCHEMY_LAB_OFF 133+#define IM_BUILD_PORTAL 134+#define IM_BUILD_PORTAL_OFF 135+#define IM_BUILD_TIME_MACHINE 136+#define IM_BUILD_TIME_MACHINE_OFF 137+#define IM_BUILD_ANTIMATTER_CONDENSER 138+#define IM_BUILD_ANTIMATTER_CONDENSER_OFF 139+#define IM_BUILD_PRISM 140+#define IM_BUILD_PRISM_OFF 141+#define IM_BUILD_CHANCEMAKER 142+#define IM_BUILD_CHANCEMAKER_OFF 143+#define IM_BUILD_FRACTAL_ENGINE 144+#define IM_BUILD_FRACTAL_ENGINE_OFF 145+#define IM_BUILD_JAVASCRIPT_CONSOLE 146+#define IM_BUILD_JAVASCRIPT_CONSOLE_OFF 147+#define IM_BUILD_IDLEVERSE 148+#define IM_BUILD_IDLEVERSE_OFF 149+#define IM_BUILD_CORTEX_BAKER 150+#define IM_BUILD_CORTEX_BAKER_OFF 151+#define IM_BUILD_YOU 152+#define IM_BUILD_YOU_OFF 153+#define IM_ROW_BG_GRANDMA 154+#define IM_ROW_GRANDMA 155+#define IM_ROW_BG_FARM 156+#define IM_ROW_FARM 157+#define IM_ROW_BG_MINE 158+#define IM_ROW_MINE 159+#define IM_ROW_BG_FACTORY 160+#define IM_ROW_FACTORY 161+#define IM_ROW_BG_BANK 162+#define IM_ROW_BANK 163+#define IM_ROW_BG_TEMPLE 164+#define IM_ROW_TEMPLE 165+#define IM_ROW_BG_WIZARDTOWER 166+#define IM_ROW_WIZARDTOWER 167+#define IM_ROW_BG_SHIPMENT 168+#define IM_ROW_SHIPMENT 169+#define IM_ROW_BG_ALCHEMYLAB 170+#define IM_ROW_ALCHEMYLAB 171+#define IM_ROW_BG_PORTAL 172+#define IM_ROW_PORTAL 173+#define IM_ROW_BG_TIMEMACHINE 174+#define IM_ROW_TIMEMACHINE 175+#define IM_ROW_BG_ANTIMATTERCONDENSER 176+#define IM_ROW_ANTIMATTERCONDENSER 177+#define IM_ROW_BG_PRISM 178+#define IM_ROW_PRISM 179+#define IM_ROW_BG_CHANCEMAKER 180+#define IM_ROW_CHANCEMAKER 181+#define IM_ROW_BG_FRACTALENGINE 182+#define IM_ROW_FRACTALENGINE 183+#define IM_ROW_BG_JAVASCRIPTCONSOLE 184+#define IM_ROW_JAVASCRIPTCONSOLE0 185+#define IM_ROW_JAVASCRIPTCONSOLE1 186+#define IM_ROW_BG_IDLEVERSE 187+#define IM_ROW_IDLEVERSE0 188+#define IM_ROW_IDLEVERSE1 189+#define IM_ROW_IDLEVERSE2 190+#define IM_ROW_IDLEVERSE3 191+#define IM_ROW_BG_CORTEX 192+#define IM_ROW_CORTEX0 193+#define IM_ROW_CORTEX1 194+#define IM_ROW_CORTEX2 195+#define IM_ROW_CORTEX3 196+#define IM_ROW_BG_YOU 197+#define IM_ROW_YOU 198+#define IM_ROW_FARMERGRANDMA 199+#define IM_ROW_WORKERGRANDMA 200+#define IM_ROW_MINERGRANDMA 201+#define IM_ROW_COSMICGRANDMA 202+#define IM_ROW_TRANSMUTEDGRANDMA 203+#define IM_ROW_ALTEREDGRANDMA 204+#define IM_ROW_GRANDMASGRANDMA 205+#define IM_ROW_ANTIGRANDMA 206+#define IM_ROW_RAINBOWGRANDMA 207+#define IM_ROW_BANKGRANDMA 208+#define IM_ROW_TEMPLEGRANDMA 209+#define IM_ROW_WITCHGRANDMA 210+#define IM_ROW_LUCKYGRANDMA 211+#define IM_ROW_METAGRANDMA 212+#define IM_ROW_SCRIPTGRANDMA 213+#define IM_ROW_ALTERNATEGRANDMA 214+#define IM_ROW_BRAINYGRANDMA 215+#define IM_ROW_CLONEGRANDMA 216+#define IM_ROW_ELFGRANDMA 217+#define IM_ROW_BUNNYGRANDMA 218+#define IM_MG_BG_GRIMOIRE 219+#define IM_MG_BG_PANTHEON 220+#define IM_MG_BG_GARDEN 221+#define IM_MG_BG_MARKET 222+#define IM_DRAGON0 223+#define IM_DRAGON1 224+#define IM_DRAGON2 225+#define IM_DRAGON3 226+#define IM_DRAGON4 227+#define IM_DRAGON5 228+#define IM_DRAGON6 229+#define IM_DRAGON7 230+#define IM_DRAGON8 231+#define IM_SANTA0 232+#define IM_SANTA1 233+#define IM_SANTA2 234+#define IM_SANTA3 235+#define IM_SANTA4 236+#define IM_SANTA5 237+#define IM_SANTA6 238+#define IM_SANTA7 239+#define IM_SANTA8 240+#define IM_SANTA9 241+#define IM_SANTA10 242+#define IM_SANTA11 243+#define IM_SANTA12 244+#define IM_SANTA13 245+#define IM_SANTA14 246+#define IM_SPELL_BG 247+#define IM_ASCEND_SLOT0 248+#define IM_ASCEND_SLOT1 249+#define IM_ASCEND_SLOT2 250+#define IM_REINDEER 251+#define IM_GOLD_WREATH 252+#define IM_WRATH_WREATH 253+#define IM_HEART0_0 254+#define IM_HEART0_1 255+#define IM_HEART0_2 256+#define IM_HEART0_3 257+#define IM_HEART0_4 258+#define IM_HEART0_5 259+#define IM_HEART0_6 260+#define IM_HEART0_7 261+#define IM_HEART1_0 262+#define IM_HEART1_1 263+#define IM_HEART1_2 264+#define IM_HEART1_3 265+#define IM_HEART1_4 266+#define IM_HEART1_5 267+#define IM_HEART1_6 268+#define IM_HEART1_7 269+#define IM_BUNNY0_0 270+#define IM_BUNNY0_1 271+#define IM_BUNNY0_2 272+#define IM_BUNNY0_3 273+#define IM_BUNNY1_0 274+#define IM_BUNNY1_1 275+#define IM_BUNNY1_2 276+#define IM_BUNNY1_3 277+#define IM_FAMILIAR0_0 278+#define IM_FAMILIAR0_1 279+#define IM_FAMILIAR0_2 280+#define IM_FAMILIAR0_3 281+#define IM_FAMILIAR1_0 282+#define IM_FAMILIAR1_1 283+#define IM_FAMILIAR1_2 284+#define IM_FAMILIAR1_3 285+#define DATA_SIZE 1765068#endifdiff --git a/games/cookieclicker/src/gfx.c b/games/cookieclicker/src/gfx.cindex b5220b8f..06618abc 100644--- a/games/cookieclicker/src/gfx.c+++ b/games/cookieclicker/src/gfx.c@@ -210,19 +210,40 @@ static inline uint16_t texel(const Img *m, int x, int y, int *a) {return m->col[i];}+/* a row of n pixels of the picture from (sx, sy), on p: each format its own loop (most of what is drawn) */+static void row(const Img *m, int sx, int sy, int n, uint16_t *p, int alpha) {+ bool plain = alpha >= 256 && blend_mode == BLEND_NORMAL;+ if (m->fmt == FMT_RGB) {+ const uint16_t *src = m->col + sy * m->w + sx;+ if (plain)+ for (int i = 0; i < n; i++) p[i] = src[i];+ else+ for (int i = 0; i < n; i++) put(p + i, src[i], alpha);+ } else if (m->fmt == FMT_P8) {+ const uint8_t *src = m->px + sy * m->w + sx;+ for (int i = 0; i < n; i++) {+ int k = src[i], a = m->opa[k];+ if (!a) continue;+ if (a == 255 && plain) p[i] = m->col[k];+ else put(p + i, m->col[k], (a + (a >> 7)) * alpha >> 8);+ }+ } else {+ const uint8_t *src = m->px + sy * ((m->w + 1) >> 1);+ for (int i = 0; i < n; i++) {+ int x = sx + i, k = x & 1 ? src[x >> 1] >> 4 : src[x >> 1] & 15, a = m->opa[k];+ if (!a) continue;+ if (a == 255 && plain) p[i] = m->col[k];+ else put(p + i, m->col[k], (a + (a >> 7)) * alpha >> 8);+ }+ }+}+void gfx_image_part(int im, int sx, int sy, int sw, int sh, int x, int y, int alpha) {Img m = img(im);int dx = x, dy = y, w = sw, h = sh;if (alpha <= 0 || !clipr(&dx, &dy, &w, &h)) return;sx += dx - x, sy += dy - y;- for (int r = 0; r < h; r++) {- uint16_t *p = at(dx, dy + r);- for (int i = 0; i < w; i++) {- int a;- uint16_t c = texel(&m, sx + i, sy + r, &a);- if (a) put(p + i, c, (a + (a >> 7)) * alpha >> 8);- }- }+ for (int r = 0; r < h; r++) row(&m, sx, sy + r, w, at(dx, dy + r), alpha);}void gfx_image(int im, int x, int y, int alpha) { gfx_image_part(im, 0, 0, gfx_image_w(im), gfx_image_h(im), x, y, alpha); }@@ -240,34 +261,69 @@ void gfx_image_dark(int im, int x, int y, int alpha) {}}+/* the index of pixel (x, y) of a paletted picture (inside it) */+static inline int index_at(const Img *m, int x, int y) {+ if (m->fmt == FMT_P8) return m->px[y * m->w + x];+ uint8_t b = m->px[y * ((m->w + 1) >> 1) + (x >> 1)];+ return x & 1 ? b >> 4 : b & 15;+}+/* the colour at (u, v), in 1/256ths of a pixel of the picture, between its four nearest pixels;- * opacity 0..255. wrap: tiled, else clear outside */+ * opacity 0..255. wrap: tiled, else clear outside. (Flat areas and opaque ones take shortcuts: this+ * runs for most pixels drawn.) */static uint16_t bilinear(const Img *m, int u, int v, bool wrap, int *a_out) {u -= 128, v -= 128;- int x0 = u >> 8, y0 = v >> 8, fx = u & 255, fy = v & 255;+ int x0 = u >> 8, y0 = v >> 8, fx = (u & 255) >> 4, fy = (v & 255) >> 4;+ int x1 = x0 + 1, y1 = y0 + 1;+ bool in0x = true, in1x = true, in0y = true, in1y = true;+ if (wrap) {+ if ((unsigned)x0 >= (unsigned)m->w) x0 %= m->w, x0 += x0 < 0 ? m->w : 0;+ if ((unsigned)y0 >= (unsigned)m->h) y0 %= m->h, y0 += y0 < 0 ? m->h : 0;+ x1 = x0 + 1 == m->w ? 0 : x0 + 1, y1 = y0 + 1 == m->h ? 0 : y0 + 1;+ } else {+ in0x = (unsigned)x0 < (unsigned)m->w, in1x = (unsigned)x1 < (unsigned)m->w;+ in0y = (unsigned)y0 < (unsigned)m->h, in1y = (unsigned)y1 < (unsigned)m->h;+ }+ uint16_t c[4];+ int a[4];+ if (m->fmt == FMT_RGB) {+ c[0] = in0x && in0y ? m->col[y0 * m->w + x0] : 0, a[0] = in0x && in0y ? 255 : 0;+ c[1] = in1x && in0y ? m->col[y0 * m->w + x1] : 0, a[1] = in1x && in0y ? 255 : 0;+ c[2] = in0x && in1y ? m->col[y1 * m->w + x0] : 0, a[2] = in0x && in1y ? 255 : 0;+ c[3] = in1x && in1y ? m->col[y1 * m->w + x1] : 0, a[3] = in1x && in1y ? 255 : 0;+ } else {+ int i0 = in0x && in0y ? index_at(m, x0, y0) : -1, i1 = in1x && in0y ? index_at(m, x1, y0) : -1;+ int i2 = in0x && in1y ? index_at(m, x0, y1) : -1, i3 = in1x && in1y ? index_at(m, x1, y1) : -1;+ if (i0 == i1 && i0 == i2 && i0 == i3) { /* (a flat area) */+ *a_out = i0 < 0 ? 0 : m->opa[i0];+ return i0 < 0 ? 0 : m->col[i0];+ }+ c[0] = i0 < 0 ? 0 : m->col[i0], a[0] = i0 < 0 ? 0 : m->opa[i0];+ c[1] = i1 < 0 ? 0 : m->col[i1], a[1] = i1 < 0 ? 0 : m->opa[i1];+ c[2] = i2 < 0 ? 0 : m->col[i2], a[2] = i2 < 0 ? 0 : m->opa[i2];+ c[3] = i3 < 0 ? 0 : m->col[i3], a[3] = i3 < 0 ? 0 : m->opa[i3];+ }+ int w[4] = {(16 - fx) * (16 - fy), fx * (16 - fy), (16 - fx) * fy, fx * fy}; /* (sum 256) */+ if ((a[0] & a[1] & a[2] & a[3]) == 255) { /* (opaque: no weighting by opacity) */+ uint32_t R = 0, G = 0, B = 0;+ for (int k = 0; k < 4; k++) R += (c[k] >> 11) * w[k], G += ((c[k] >> 5) & 63) * w[k], B += (c[k] & 31) * w[k];+ *a_out = 255;+ return (uint16_t)((R >> 8) << 11 | (G >> 8) << 5 | (B >> 8));+ }uint32_t R = 0, G = 0, B = 0, A = 0;for (int k = 0; k < 4; k++) {- int x = x0 + (k & 1), y = y0 + (k >> 1);- int w = (k & 1 ? fx : 256 - fx) * (k >> 1 ? fy : 256 - fy); /* 0..65536 */- if (!w) continue;- if (wrap) {- x %= m->w, y %= m->h;- if (x < 0) x += m->w;- if (y < 0) y += m->h;- } else if ((unsigned)x >= (unsigned)m->w || (unsigned)y >= (unsigned)m->h)- continue;- int a;- uint16_t c = texel(m, x, y, &a);- if (!a) continue;- uint32_t wa = (uint32_t)(w >> 8) * (uint32_t)a; /* 0..65280 */- R += (c >> 11) * wa, G += ((c >> 5) & 63) * wa, B += (c & 31) * wa, A += wa;+ uint32_t wa = (uint32_t)(w[k] * a[k]); /* 0..65280 */+ R += (c[k] >> 11) * wa, G += ((c[k] >> 5) & 63) * wa, B += (c[k] & 31) * wa, A += wa;}*a_out = (int)(A >> 8);if (!A) return 0;return (uint16_t)((R / A) << 11 | (G / A) << 5 | (B / A));}-void gfx_image_scaled(int im, float x, float y, float w, float h, int alpha) {+/* scaled: the picture's pixels in steps of su, sv (1/256ths of its pixels per screen pixel); nearest+ * picks the nearest pixel (smooth overlays), lo samples every other pixel in both directions (soft+ * pictures: the flares) */+static void scaled(int im, float x, float y, float w, float h, int alpha, bool nearest) {if (w < 0.5f || h < 0.5f || alpha <= 0) return;int x0 = (int)floorf(x), y0 = (int)floorf(y), x1 = (int)ceilf(x + w), y1 = (int)ceilf(y + h);if (x0 < g_x0) x0 = g_x0;@@ -276,19 +332,37 @@ void gfx_image_scaled(int im, float x, float y, float w, float h, int alpha) {if (y1 > g_y1) y1 = g_y1;if (x1 <= x0 || y1 <= y0) return;Img m = img(im);- float su = m.w / w * 256, sv = m.h / h * 256;+ int su = (int)(m.w / w * 256);+ int u0 = (int)((x0 + 0.5f - x) * m.w / w * 256);for (int py = y0; py < y1; py++) {- int v = (int)((py + 0.5f - y) * sv);+ int v = (int)((py + 0.5f - y) * m.h / h * 256);uint16_t *p = at(x0, py);- for (int px = x0; px < x1; px++, p++) {- int u = (int)((px + 0.5f - x) * su), a;- uint16_t c = bilinear(&m, u, v, false, &a);+ int u = u0;+ for (int px = x0; px < x1; px++, p++, u += su) {+ int a;+ uint16_t c;+ if (nearest) {+ int tx = u >> 8, ty = v >> 8;+ if ((unsigned)tx >= (unsigned)m.w || (unsigned)ty >= (unsigned)m.h) continue;+ c = texel(&m, tx, ty, &a);+ } else+ c = bilinear(&m, u, v, false, &a);if (a) put(p, c, (a + (a >> 7)) * alpha >> 8);}}}-void gfx_image_rotated(int im, float cx, float cy, float w, float h, float angle, int alpha) {+void gfx_image_scaled(int im, float x, float y, float w, float h, int alpha) {+ const ImageRec *r = image_rec(im);+ if (fabsf(w - r->w) < 0.05f && fabsf(h - r->h) < 0.05f) { /* (its own size: as it is) */+ gfx_image(im, (int)floorf(x + 0.5f), (int)floorf(y + 0.5f), alpha);+ return;+ }+ scaled(im, x, y, w, h, alpha, false);+}+void gfx_image_scaled_fast(int im, float x, float y, float w, float h, int alpha) { scaled(im, x, y, w, h, alpha, true); }++static void rotated(int im, float cx, float cy, float w, float h, float angle, int alpha, int step) {if (w < 0.5f || h < 0.5f || alpha <= 0) return;float c = cosf(angle), s = sinf(angle);float ex = (fabsf(c) * w + fabsf(s) * h) / 2, ey = (fabsf(s) * w + fabsf(c) * h) / 2;@@ -301,48 +375,76 @@ void gfx_image_rotated(int im, float cx, float cy, float w, float h, float angleImg m = img(im);float ku = m.w / w * 256, kv = m.h / h * 256;/* screen (dx, dy) from the centre -> picture: turned back by angle */- float uxs = c * ku, uys = s * ku, vxs = -s * kv, vys = c * kv;- float hu = m.w * 128.f, hv = m.h * 128.f;+ int uxs = (int)(c * ku), uys = (int)(s * ku), vxs = (int)(-s * kv), vys = (int)(c * kv);+ int hu = m.w * 128, hv = m.h * 128, umax = (m.w + 1) * 256, vmax = (m.h + 1) * 256;+ if (step > 1) { /* (every other pixel, both ways: on even screen coordinates, so that bands agree) */+ y0 &= ~1, x0 &= ~1;+ for (int py = y0; py < y1; py += 2) {+ float dy = py + 1 - cy, dx = x0 + 1 - cx;+ int u = hu + (int)(dx * uxs + dy * uys), v = hv + (int)(dx * vxs + dy * vys);+ for (int px = x0; px < x1; px += 2, u += 2 * uxs, v += 2 * vxs) {+ if (u < -256 || v < -256 || u >= umax || v >= vmax) continue;+ int a;+ uint16_t col = bilinear(&m, u, v, false, &a);+ if (!a) continue;+ a = (a + (a >> 7)) * alpha >> 8;+ for (int yy = py; yy < py + 2; yy++) {+ if (yy < g_y0 || yy >= g_y1) continue;+ uint16_t *p = at(px, yy);+ if (px >= g_x0 && px < g_x1) put(p, col, a);+ if (px + 1 >= g_x0 && px + 1 < g_x1) put(p + 1, col, a);+ }+ }+ }+ return;+ }for (int py = y0; py < y1; py++) {float dy = py + 0.5f - cy, dx = x0 + 0.5f - cx;- float u = hu + dx * uxs + dy * uys, v = hv + dx * vxs + dy * vys;+ int u = hu + (int)(dx * uxs + dy * uys), v = hv + (int)(dx * vxs + dy * vys);uint16_t *p = at(x0, py);for (int px = x0; px < x1; px++, p++, u += uxs, v += vxs) {- if (u < -256 || v < -256 || u >= (m.w + 1) * 256.f || v >= (m.h + 1) * 256.f) continue;+ if (u < -256 || v < -256 || u >= umax || v >= vmax) continue;int a;- uint16_t col = bilinear(&m, (int)u, (int)v, false, &a);+ uint16_t col = bilinear(&m, u, v, false, &a);if (a) put(p, col, (a + (a >> 7)) * alpha >> 8);}}}+void gfx_image_rotated(int im, float cx, float cy, float w, float h, float angle, int alpha) {+ rotated(im, cx, cy, w, h, angle, alpha, 1);+}+void gfx_image_rotated_soft(int im, float cx, float cy, float w, float h, float angle, int alpha) {+ rotated(im, cx, cy, w, h, angle, alpha, 2);+}void gfx_pattern(int im, int x, int y, int w, int h, float tw, float th, float ox, float oy, int alpha) {if (alpha <= 0 || !clipr(&x, &y, &w, &h)) return;Img m = img(im);bool same = fabsf(tw - m.w) < 0.01f && fabsf(th - m.h) < 0.01f;- float su = m.w / tw * 256, sv = m.h / th * 256;+ int su = (int)(m.w / tw * 256), sv = (int)(m.h / th * 256);for (int r = 0; r < h; r++) {uint16_t *p = at(x, y + r);float fy = y + r + 0.5f - oy;- if (same) {+ if (same) { /* (the tiles as they are: in runs of a row of the picture) */int ty = (int)floorf(fy) % m.h;if (ty < 0) ty += m.h;int tx = (int)floorf(x + 0.5f - ox) % m.w;if (tx < 0) tx += m.w;- for (int i = 0; i < w; i++, p++) {- int a;- uint16_t c = texel(&m, tx, ty, &a);- if (a) put(p, c, (a + (a >> 7)) * alpha >> 8);- if (++tx == m.w) tx = 0;+ for (int i = 0; i < w;) {+ int n = m.w - tx < w - i ? m.w - tx : w - i;+ row(&m, tx, ty, n, p + i, alpha);+ i += n, tx = 0;}continue;}- int v = (int)(fy * sv);- for (int i = 0; i < w; i++, p++) {+ int v = (int)(fy * m.h / th * 256);+ int u = (int)((x + 0.5f - ox) * m.w / tw * 256);+ for (int i = 0; i < w; i++, p++, u += su) {int a;- uint16_t c = bilinear(&m, (int)((x + i + 0.5f - ox) * su), v, true, &a);+ uint16_t c = bilinear(&m, u, v, true, &a);if (a) put(p, c, (a + (a >> 7)) * alpha >> 8);}+ (void)sv;}}@@ -396,7 +498,7 @@ static int draw_char(int f, int x, int y, unsigned char ch, uint16_t c, int alphif (xx < g_x0 || xx >= g_x1) continue;uint8_t b = d[r * stride + (i >> 1)];int cov = i & 1 ? b >> 4 : b & 15;- if (cov) put(at(xx, yy), c, cov * alpha / 15);+ if (cov) put(at(xx, yy), c, cov == 15 ? alpha : cov * alpha / 15);}}}@@ -425,11 +527,47 @@ int gfx_text_center(int f, int cx, int y, const char *s, uint16_t c, int alpha)int gfx_text_right(int f, int rx, int y, const char *s, uint16_t c, int alpha) {return gfx_text(f, rx - gfx_text_width(f, s), y, s, c, alpha);}+/* a character's black outline (the pixels next to it, and a shadow below): made in a little mask, then+ * blended in one go */+static int draw_char_outline(int f, int x, int y, unsigned char ch, int alpha) {+ const uint8_t *d;+ const Glyph *g = glyph(f, ch, &d);+ if (!g) return x;+ int gx = x + g->x - 1, gy = y + g->y - 1, W = g->w + 2, H = g->h + 4;+ if (g->w && W <= 40 && H <= 44 && gfx_visible(gx, gy, W, H)) {+ uint8_t m[40 * 44];+ memset(m, 0, (size_t)(W * H));+ int stride = (g->w + 1) >> 1;+ for (int r = 0; r < g->h; r++)+ for (int i = 0; i < g->w; i++) {+ uint8_t b = d[r * stride + (i >> 1)];+ int cov = (i & 1 ? b >> 4 : b & 15) * 17, third = cov / 3;+ if (!cov) continue;+ uint8_t *o = m + (r + 1) * W + (i + 1);+#define MAX(p, v) (*(p) < (v) ? *(p) = (uint8_t)(v) : 0)+ MAX(o - 1, cov), MAX(o + 1, cov), MAX(o - W, cov), MAX(o + W, cov);+ MAX(o - W - 1, third), MAX(o - W + 1, third), MAX(o + W - 1, third), MAX(o + W + 1, third);+ MAX(o + 2 * W, third);+#undef MAX+ }+ for (int r = 0; r < H; r++) {+ int yy = gy + r;+ if (yy < g_y0 || yy >= g_y1) continue;+ for (int i = 0; i < W; i++) {+ int xx = gx + i, a = m[r * W + i];+ if (a && xx >= g_x0 && xx < g_x1) put(at(xx, yy), BLACK, (a + (a >> 7)) * alpha >> 8);+ }+ }+ }+ return x + g->adv;+}++/* (the outlines first, then the letters over them) */void gfx_text_outline(int f, int x, int y, const char *s, uint16_t c, int alpha) {- static const int8_t d[8][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}, {-1, -1}, {1, -1}, {-1, 1}, {1, 1}};- for (int i = 0; i < 8; i++) gfx_text(f, x + d[i][0], y + d[i][1], s, BLACK, i < 4 ? alpha : alpha / 3);- gfx_text(f, x, y + 2, s, BLACK, alpha / 3);- gfx_text(f, x, y, s, c, alpha);+ int x0 = x;+ for (const char *p = s; *p; p++)+ if ((unsigned char)*p >= 32) x = draw_char_outline(f, x, y, (unsigned char)*p, alpha);+ gfx_text(f, x0, y, s, c, alpha);}void gfx_text_outline_center(int f, int cx, int y, const char *s, uint16_t c, int alpha) {gfx_text_outline(f, cx - gfx_text_width(f, s) / 2, y, s, c, alpha);diff --git a/games/cookieclicker/src/gfx.h b/games/cookieclicker/src/gfx.hindex d53abc04..a17c8d70 100644--- a/games/cookieclicker/src/gfx.h+++ b/games/cookieclicker/src/gfx.h@@ -42,10 +42,13 @@ int gfx_image_w(int im);int gfx_image_h(int im);void gfx_image(int im, int x, int y, int alpha);void gfx_image_part(int im, int sx, int sy, int sw, int sh, int x, int y, int alpha);-/* scaled to w x h at (x, y), smoothly */+/* scaled to w x h at (x, y), smoothly; or fast, from its nearest pixels (smooth overlays) */void gfx_image_scaled(int im, float x, float y, float w, float h, int alpha);+void gfx_image_scaled_fast(int im, float x, float y, float w, float h, int alpha);/* centred on (cx, cy), w x h, turned by angle (radians, clockwise on screen) */void gfx_image_rotated(int im, float cx, float cy, float w, float h, float angle, int alpha);+/* the same, sampled every other pixel both ways (soft pictures, drawn large: the flares) */+void gfx_image_rotated_soft(int im, float cx, float cy, float w, float h, float angle, int alpha);/* the rectangle tiled with the picture at tw x th, the tiles shifted by (ox, oy) */void gfx_pattern(int im, int x, int y, int w, int h, float tw, float th, float ox, float oy, int alpha);/* an icon of the game's sheet (its index: y * ICON_COLS + x), 24 pixels, or scaled to size */diff --git a/games/cookieclicker/src/grimoire.c b/games/cookieclicker/src/grimoire.cindex 6a8abcba..a6c0a3a8 100644--- a/games/cookieclicker/src/grimoire.c+++ b/games/cookieclicker/src/grimoire.c@@ -342,7 +342,7 @@ static void spell_pos(int s, int *x, int *y) {void grimoire_draw(void) {gfx_clip(GX, NEWS_H, GW, SCREEN_H - NEWS_H);gfx_pattern(IM_MG_BG_GRIMOIRE, GX, NEWS_H, GW, SCREEN_H - NEWS_H, 192, 48, GX, NEWS_H, 256);- gfx_image_scaled(IM_BORDER_SOFT, GX, NEWS_H, GW, SCREEN_H - NEWS_H, 256);+ gfx_image_scaled_fast(IM_BORDER_SOFT, GX, NEWS_H, GW, SCREEN_H - NEWS_H, 256);gfx_text_outline_center(F_KAVOON, GX + GW / 2, NEWS_H + 20, "Grimoire", WHITE, 256);for (int s = 0; s < N_SPELLS; s++) {int x, y;diff --git a/games/cookieclicker/src/menus.c b/games/cookieclicker/src/menus.cindex a6abce75..ff0d94d9 100644--- a/games/cookieclicker/src/menus.c+++ b/games/cookieclicker/src/menus.c@@ -31,7 +31,7 @@ extern bool g_quit;static void panel(const char *title) {gfx_pattern(IM_DARK_NOISE, 0, PANEL_Y, SCREEN_W, PANEL_H, 128, 128, 0, 0, 256);- gfx_image_scaled(IM_BORDER_SOFT, 0, PANEL_Y, SCREEN_W, PANEL_H, 256);+ gfx_image_scaled_fast(IM_BORDER_SOFT, 0, PANEL_Y, SCREEN_W, PANEL_H, 256);for (int x = 0; x < SCREEN_W; x += 128) gfx_image(IM_PANEL_H, x, PANEL_Y, 256);if (title) gfx_text_outline_center(F_KAVOON, SCREEN_W / 2, PANEL_Y + 20, title, WHITE, 256);}diff --git a/games/cookieclicker/src/ui.c b/games/cookieclicker/src/ui.cindex d6834184..9c15d224 100644--- a/games/cookieclicker/src/ui.c+++ b/games/cookieclicker/src/ui.c@@ -190,6 +190,7 @@ static void news_text(const char *s, int alpha, int dy) {gfx_text_outline_center(F_SMALL, NEWS_X + w / 2 + 2, 9 + dy, lines[0], c, alpha);gfx_text_outline_center(F_SMALL, NEWS_X + w / 2 + 2, 18 + dy, lines[1], c, alpha);} else { /* too long: it goes by */+ U.news_long = true;int tw = gfx_text_width(F_SMALL, s);int x = SCREEN_W - (int)(U.news_t * 1.2f) % (tw + SCREEN_W - NEWS_X);gfx_clip(NEWS_X, 0, SCREEN_W - NEWS_X, NEWS_H);@@ -200,6 +201,7 @@ static void news_text(const char *s, int alpha, int dy) {void draw_news(void) {if (!gfx_visible(0, 0, SCREEN_W, NEWS_H)) return;+ U.news_long = false;gfx_pattern(IM_DARK_NOISE, 0, 0, SCREEN_W, NEWS_H, 128, 128, 0, 0, 256);gfx_vgrad(0, 0, SCREEN_W, NEWS_H, BLACK, 140, 60);for (int x = 0; x < SCREEN_W; x += 128) gfx_image(IM_PANEL_H, x, NEWS_H - 3, 256);@@ -260,6 +262,7 @@ static void scroll_to_selection(void) {}void ui_keys(uint32_t pressed, uint32_t held) {+ if (pressed) U.dirty = 2;/* the arrows repeat while held */uint32_t arrows = held & (K_LEFT | K_RIGHT | K_UP | K_DOWN);if (arrows && arrows == repeat_held) {@@ -402,8 +405,19 @@ void ui_tick(void) {if (U.news_t > FPS * 10) ui_news_next();}+/* what is drawn: the left column every frame (it moves all the time), the rest of the screen when a key+ * was pressed and five times a second (prices, notes), the news while it changes; the pages that fill+ * the screen when pressed and three times a second */void ui_frame(void) {ui_store_layout();- gfx_render(0, 0, SCREEN_W, SCREEN_H, draw_all);+ bool page = U.overlay == OV_OPTIONS || U.overlay == OV_STATS || U.overlay == OV_INFO || U.overlay == OV_KEYS;+ bool full = U.dirty > 0 || G.on_ascend || G.ascend_timer > 0 || G.reincarnate_timer > 0 ||+ G.draw_t % (page ? 10 : 6) == 0;+ if (U.dirty > 0) U.dirty--;+ if (full) gfx_render(0, 0, SCREEN_W, SCREEN_H, draw_all);+ else if (!page) {+ gfx_render(0, NEWS_H, LEFT_W, SCREEN_H - NEWS_H, draw_all);+ if (U.news_fade > 0 || U.news_long || G.draw_t % 3 == 0) gfx_render(0, 0, SCREEN_W, NEWS_H, draw_all);+ }G.draw_t++;}diff --git a/games/cookieclicker/src/ui.h b/games/cookieclicker/src/ui.hindex 8e1bf30e..1d63d648 100644--- a/games/cookieclicker/src/ui.h+++ b/games/cookieclicker/src/ui.h@@ -46,6 +46,8 @@ typedef struct {int asc_mode; /* ascension: the challenge mode chosen */float asc_x, asc_y, asc_tx, asc_ty; /* where the heavens are (and are going) */bool store_dirty;+ bool news_long; /* the news goes by (too long for two lines) */+ int dirty; /* frames still to draw whole */} Ui;extern Ui U;diff --git a/games/cookieclicker/src/ui_left.c b/games/cookieclicker/src/ui_left.cindex 60f8a9d7..cac0a815 100644--- a/games/cookieclicker/src/ui_left.c+++ b/games/cookieclicker/src/ui_left.c@@ -36,7 +36,7 @@ static void background(void) {if (d >= 1 && d < 2) r = d - 1, fade = IM_BG_GRANDMAS1;else if (d >= 2 && d < 3) r = d - 2, bg = IM_BG_GRANDMAS1, fade = IM_BG_GRANDMAS2;else if (d >= 3) r = d - 3 > 1 ? 1 : d - 3, bg = IM_BG_GRANDMAS2, fade = IM_BG_GRANDMAS3;- float tile = 512 * SC;+ float tile = (float)gfx_image_w(IM_BG_BLUE); /* (512 x 0.37, as it is packed) */gfx_pattern(bg, 0, NEWS_H, LEFT_W, PANEL_H, tile, tile, 0, NEWS_H, 256);if (fade >= 0 && r > 0) gfx_pattern(fade, 0, NEWS_H, LEFT_W, PANEL_H, tile, tile, 0, NEWS_H, (int)(r * 256));}@@ -54,7 +54,7 @@ static void shower(void) {float opacity = 1;if (d >= 1 && !S.prefs.not_scary) opacity = 1 - ((d < 1.5f ? d : 1.5f) - 1) / 0.5f;float y = fmodf(floorf(G.real_t * 2), 512) * SC;- gfx_pattern(pic, 0, NEWS_H, LEFT_W, PANEL_H, 512 * SC, 512 * SC, 0, NEWS_H + y, (int)(opacity * 256));+ gfx_pattern(pic, 0, NEWS_H, LEFT_W, PANEL_H, (float)gfx_image_w(pic), (float)gfx_image_h(pic), 0, NEWS_H + y, (int)(opacity * 256));}static void particles(int kind) {@@ -80,8 +80,8 @@ static void flares(float cx, float cy) {float rot = fmodf(G.real_t * 0.5f, 360) / 360 * 2 * (float)M_PI;float s1 = 512 * SC * (0.5f + sqrtf(r1)), s2 = 512 * SC * (0.5f + sqrtf(r2));gfx_blend(BLEND_NORMAL);- gfx_image_rotated(pic, cx, cy, s1, s1, rot, (int)(sinf(r1 * (float)M_PI) * alpha_mult * 256));- gfx_image_rotated(pic, cx, cy, s2, s2, rot + (float)M_PI, (int)(sinf(r2 * (float)M_PI) * alpha_mult * 256));+ gfx_image_rotated_soft(pic, cx, cy, s1, s1, rot, (int)(sinf(r1 * (float)M_PI) * alpha_mult * 256));+ gfx_image_rotated_soft(pic, cx, cy, s2, s2, rot + (float)M_PI, (int)(sinf(r2 * (float)M_PI) * alpha_mult * 256));}static void cursors(float cx, float cy) {@@ -108,7 +108,9 @@ static void cursors(float cx, float cy) {float lx = 16, ly = y + 16;float sx = cx + (lx * cosf(rot) - ly * sinf(rot)) * SC, sy = cy + (lx * sinf(rot) + ly * cosf(rot)) * SC;if (!gfx_visible((int)sx - 7, (int)sy - 7, 14, 14)) continue;- gfx_image_rotated(IM_CURSOR, sx, sy, 32 * SC, 32 * SC, rot, dragon ? 64 : 256);+ /* (turned beforehand: the nearest of 32 turns) */+ int k = (int)floorf(rot / (2 * (float)M_PI) * 32 + 0.5f) & 31;+ gfx_image(IM_CURSOR_R0 + k, (int)floorf(sx - 7.5f), (int)floorf(sy - 7.5f), dragon ? 64 : 256);}}@@ -250,7 +252,7 @@ void draw_left(void) {float s = 300 * 2 * (1 + sinf(G.real_t * 0.013f) * 0.1f) * SC;gfx_image_scaled(IM_DRAGON_BG, cx - s / 2, cy - s / (1.4f + 0.2f * sinf(G.real_t * 0.01f)), s, s, 256);}- float s = 256 * G.big_size * SC;+ float s = gfx_image_w(IM_COOKIE) * (fabsf(G.big_size - 1) < 0.004f ? 1 : G.big_size); /* (as it is, but when it wobbles) */if (S.prefs.fancy) gfx_image_scaled(IM_COOKIE_SHADOW, cx - s / 2, cy - s / 2 + 20 * SC, s, s, 256);gfx_image_scaled(IM_COOKIE, cx - s / 2, cy - s / 2, s, s, 256);if (good_buff && S.prefs.particles) {@@ -284,12 +286,12 @@ void draw_left(void) {}int border = good_buff ? IM_BORDER_GOLD : bad_buff ? IM_BORDER_RED : IM_BORDER_SOFT;if (good_buff && S.prefs.fancy) gfx_blend(BLEND_ADD);- gfx_image_scaled(border, 0, NEWS_H, LEFT_W, PANEL_H, 256);+ gfx_image_scaled_fast(border, 0, NEWS_H, LEFT_W, PANEL_H, 256);gfx_blend(BLEND_NORMAL);bakery_box();counter();} else- gfx_image_scaled(IM_BORDER_SOFT, 0, NEWS_H, LEFT_W, PANEL_H, 256);+ gfx_image_scaled_fast(IM_BORDER_SOFT, 0, NEWS_H, LEFT_W, PANEL_H, 256);gfx_unclip();}diff --git a/games/cookieclicker/src/ui_store.c b/games/cookieclicker/src/ui_store.cindex 740e1e73..c966996a 100644--- a/games/cookieclicker/src/ui_store.c+++ b/games/cookieclicker/src/ui_store.c@@ -272,7 +272,7 @@ const ParaStyle PS_SMALL = {F_BODY, F_BOLD, F_ITALIC, 0xCE79, WHITE, WHITE, 11,void draw_frame_box(int x, int y, int w, int h) {gfx_pattern(IM_DARK_NOISE, x, y, w, h, 128, 128, 0, 0, 256);- gfx_image_scaled(IM_BORDER_SOFT, (float)x, (float)y, (float)w, (float)h, 256);+ gfx_image_scaled_fast(IM_BORDER_SOFT, (float)x, (float)y, (float)w, (float)h, 256);/* the gold frame (frameBorder.png's colours) */gfx_rect(x, y, w, h, 0xEF16 /* #ece2b6 */, 256);gfx_fill(x + 1, y + h - 2, w - 2, 1, 0x7144);diff --git a/games/cookieclicker/tools/pack.py b/games/cookieclicker/tools/pack.pyindex 54b5e856..8b251db7 100644--- a/games/cookieclicker/tools/pack.py+++ b/games/cookieclicker/tools/pack.py@@ -307,8 +307,9 @@ def main(ref, game_json):# ---- the left columnL = lambda name, rel, size, fmt="p8", box=None, n=256: P.image(name, scaled(ref, rel, size, box), fmt, n)- L("COOKIE", "perfectCookie.png", (104, 104))- L("COOKIE_SHADOW", "cookieShadow.png", (40, 40))+ big = round(256 * S) # (drawn as they are, but when the cookie wobbles)+ L("COOKIE", "perfectCookie.png", (big, big))+ L("COOKIE_SHADOW", "cookieShadow.png", (big, big))L("FLARE", "flare.png", (112, 112))L("FLARE_GOLD", "flareGold.png", (112, 112))L("FLARE_RED", "flareSuckRed.png", (112, 112))@@ -324,16 +325,26 @@ def main(ref, game_json):for i in range(8):L(f"SMALL_COOKIE{i}", "smallCookies.png", (24, 24), box=(64 * i, 0, 64 * i + 64, 64))L("CURSOR", "cursor.png", (32, 32), box=(0, 0, 32, 32))+ # the cursors around the cookie, turned beforehand: 32 turns of the 12-pixel cursor (drawn 4 times larger,+ # turned, then reduced: smooth)+ cur = load(ref, "cursor.png").crop((0, 0, 32, 32))+ side = round(32 * S)+ for k in range(32):+ big4 = Image.new("RGBA", (64, 64), (0, 0, 0, 0))+ c4 = premul_resize(cur, (side * 4, side * 4))+ big4.paste(c4, ((64 - side * 4) // 2, (64 - side * 4) // 2))+ turned = big4.rotate(-k * 360 / 32, resample=Image.BICUBIC)+ P.image(f"CURSOR_R{k}", premul_resize(turned, (16, 16)), "p4")L("GOLD_COOKIE", "goldCookie.png", (48, 48))L("WRATH_COOKIE", "wrathCookie.png", (48, 48))- # the milks: the game draws its 240-pixel pictures at 480; here at 120, drawn at 178 (480 x S): the top of- # them that the milk shows, at most 0.35 of the column+ # the milks: the game draws its 240-pixel pictures at 480; here at 178 (480 x S): the top of them that the+ # milk shows, at most 0.35 of the columnmilk_tile = round(480 * S)- milk_w, milk_h = 120, math.ceil((0.35 * 220 + 2) * 120 / milk_tile)+ milk_w, milk_h = milk_tile, math.ceil(0.35 * 220 + 3) # (at the size drawn, 16 colours)defs.append(f"#define MILK_TILE {milk_tile}")for m in G["milks"]:rows = round(milk_h / milk_w * 240)- L("MILK_" + cname(m["name"].replace(" milk", "")), m["pic"], (milk_w, milk_h), box=(0, 0, 240, rows))+ L("MILK_" + cname(m["name"].replace(" milk", "")), m["pic"], (milk_w, milk_h), "p4", box=(0, 0, 240, rows))L("WRINKLER", "wrinkler.png", (38, 76))L("SHINY_WRINKLER", "shinyWrinkler.png", (38, 76))L("SHIMMERING_VEIL", "shimmeringVeil.png", (64, 64))diff --git a/tests/test_games.py b/tests/test_games.pyindex 7c3316ef..e5cd4761 100644--- a/tests/test_games.py+++ b/tests/test_games.py@@ -197,6 +197,10 @@ GAMES = {"sonic": ("SonicTheHedgehog.nwa", "sonic.sav",presses((1500, "ok"), (5500, "ok"), (7000, "ok"), (9000, "right", 6000)), 16000,presses((5500, "ok"), (7000, "ok"), (9500, "right", 2000)), 13000),+ # past the keys, the big cookie clicked three times; Home saves the bakery. Next time, from the copy, two more+ "cookieclicker": ("CookieClicker.nwa", "cookieclicker.sav",+ presses((2500, "ok"), (3500, "ok"), (4000, "ok"), (4500, "ok")), 6500,+ presses((3000, "ok"), (3600, "ok")), 5500),# a level, its message, then play; then back to the level select"portal": ("PortalReturns.nwa", "portal.sav",presses((1500, "ok"), (2500, "ok"), (3500, "ok")) + every(4000, 7000, 400, "right", 300), 8000,@@ -227,7 +231,8 @@ COPIES = {"championisland": "champion_saves.py", "numblocks": "numblocks_saves.p"hollowknight": "hollowknight_saves.py", "finalearth2": "finalearth2_saves.py","numpowder": "numpowder_saves.py", "undertale": "undertale_saves.py", "subway": "subway_saves.py","fnaf": "fnaf_saves.py", "doom": "doom_saves.py", "isaac": "isaac_saves.py",- "hillclimb": "hillclimb_saves.py", "pvz": "pvz_saves.py", "sonic": "sonic_saves.py"}+ "hillclimb": "hillclimb_saves.py", "pvz": "pvz_saves.py", "sonic": "sonic_saves.py",+ "cookieclicker": "cookieclicker_saves.py"}CHECKS = {# the island remembers where Lucky was; after the reinstall, from the copy"championisland": (lambda v: v[:3] == b"CI1" and b"PLAYER_LOC" in v,) * 2,@@ -319,6 +324,10 @@ CHECKS = {lambda v: v[5] == 3 and v[34] == 2),# how to play seen and the first level played last; then the second"sokoban": (lambda v: len(v) == 314 and v[:4] == b"S\1\1\0", lambda v: len(v) == 314 and v[:4] == b"S\1\1\1"),+ # the bakery kept ("CCK1", the cookies at 8, the clicks at 48): 3 clicks; after the reinstall, from the copy, 5+ "cookieclicker": (lambda v: v[:4] == b"CCK1" and struct.unpack_from("<d", v, 48)[0] == 3+ and struct.unpack_from("<d", v, 8)[0] >= 3,+ lambda v: v[:4] == b"CCK1" and struct.unpack_from("<d", v, 48)[0] == 5),"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# Air Hockey and the easy computer chosen; then the normal computer and Tanks, the tallies keptdiff --git a/tools/release.py b/tools/release.pyindex 99d751dc..7cfee37a 100644--- a/tools/release.py+++ b/tools/release.py@@ -55,6 +55,10 @@ ALONE = {"sonic": ("Sonic the Hedgehog", "the whole 1991 game: Green Hill to Scrap Brain, the Final Zone, the Special ""Stages and the six Chaos Emeralds, and the ending. Too big to share the calculator with NumPlay: install ""it on its own"),+ "cookieclicker": ("Cookie Clicker", "the whole game, with its own pictures: every building and upgrade, golden and "+ "wrath cookies, the grandmapocalypse, ascension and the heavenly upgrades, sugar lumps, the "+ "dragon, Santa and the Grimoire. Too big to share the calculator with NumPlay: install it on its "+ "own"),}VARIANTS = [("NumPlay-Invisible.nwa", "The same app, hidden: a blank icon with no name"),