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
Celeste: big blocks are drawn whole
Mason Chendffbe384fc64
diff --git a/games/celeste/src/celeste.h b/games/celeste/src/celeste.hindex 60b13f08..0dd7b671 100644--- a/games/celeste/src/celeste.h+++ b/games/celeste/src/celeste.h@@ -192,6 +192,9 @@ void gfx_screen(bool on); /* screen coordinates for gameplay layers (zoomed wivoid gfx_tex_part_ex(uint16_t tex, float x, float y, int sx, int sy, int w, int h, float ox, float oy, float scx, float scy,float rot, uint16_t tint, uint8_t alpha, uint8_t flags);void gfx_tex_part(uint16_t tex, float x, float y, int sx, int sy, int w, int h, uint8_t flags, uint16_t tint, uint8_t alpha);+#define TILE_POOL 1600+extern uint8_t g_tile_pool[TILE_POOL]; /* the blocks' tiles (entities.c), which gfx_tiles draws */+void gfx_tiles(uint16_t tex, const uint8_t *q, int w, int h, float x, float y, uint16_t tint, uint8_t alpha);void gfx_rect(float x, float y, float w, float h, uint16_t c, uint8_t alpha);void gfx_hollow_rect(float x, float y, float w, float h, uint16_t c, uint8_t alpha);void gfx_line(float x0, float y0, float x1, float y1, uint16_t c, uint8_t alpha);diff --git a/games/celeste/src/ch0.c b/games/celeste/src/ch0.cindex 1ed8be34..74fe151d 100644--- a/games/celeste/src/ch0.c+++ b/games/celeste/src/ch0.c@@ -93,7 +93,7 @@ typedef struct {float time;int8_t shakex, shakey;float shake_timer;- TileQ tiles[7 * 4];+ TileQ *tiles;uint8_t tw, th;} Crusher;static void crusher_shake(Crusher *c, float t) { c->shake_timer = t; }@@ -148,13 +148,12 @@ static void crusher_update(Ent *e) {}static void crusher_render(Ent *e) {Crusher *c = ST(e, Crusher);- tiles_draw(c->tiles, c->tw, c->th, e->x + c->shakex, e->y + c->shakey, 0xFFFF, 255);+ if (c->tiles) tiles_draw(c->tiles, '3', c->tw, c->th, e->x + c->shakex, e->y + c->shakey, 0xFFFF, 255);}static const EntClass CRUSHER = {.size = sizeof(Crusher), .name = "introCrusher", .update = crusher_update, .render = crusher_render,.kind = KIND_SOLID};static void new_crusher(const EData *d) {int w = (int)EA(d, introCrusher, width), h = (int)EA(d, introCrusher, height);- if (w / 8 * (h / 8) > 7 * 4) return;Ent *e = ent_new(&CRUSHER, d->x, d->y);if (!e) return;ent_box(e, (float)w, (float)h, 0, 0);@@ -164,7 +163,7 @@ static void new_crusher(const EData *d) {c->start = v2(d->x, d->y);c->end = ed_node(d, 0);c->tw = (uint8_t)(w / 8), c->th = (uint8_t)(h / 8);- tiles_box('3', c->tw, c->th, c->tiles);+ if ((c->tiles = blocks_new_tiles(c->tw * c->th))) tiles_box('3', c->tw, c->th, c->tiles);if (level_visited("1") || level_visited("0b")) {e->x = c->end.x, e->y = c->end.y;c->co.co = -1;diff --git a/games/celeste/src/ch6.c b/games/celeste/src/ch6.cindex e95f6dfd..e71aefe0 100644--- a/games/celeste/src/ch6.c+++ b/games/celeste/src/ch6.c@@ -1315,44 +1315,18 @@ static void new_hstatue(const EData *d) {}}/* ---------------------------------------------------------------- the boss's blocks: tiles 'g', highlighted 'G' */-/* their tiles live in a small pool, in runs of 8, owned by the block */-#define BT_CHUNK 8-#define BT_CHUNKS 48-static TileQ bt_pool[BT_CHUNKS * BT_CHUNK];-static uint8_t bt_owner[BT_CHUNKS]; /* 0: free, else the block's entity + 1 */-static int bt_alloc(Ent *e, int n) {- int k = (n + BT_CHUNK - 1) / BT_CHUNK, run = 0;- for (int i = 0; i < BT_CHUNKS; i++) {- run = bt_owner[i] ? 0 : run + 1;- if (run == k) {- for (int j = i - k + 1; j <= i; j++) bt_owner[j] = (uint8_t)(ent_ref(e) + 1);- return (i - k + 1) * BT_CHUNK;- }- }- return -1;-}-static void bt_free(Ent *e) {- for (int i = 0; i < BT_CHUNKS; i++)- if (bt_owner[i] == ent_ref(e) + 1) bt_owner[i] = 0;-}+/* their tiles: in the blocks' pool (entities.c), with the room *//* the tiles at alpha a, and the same box in 'G' (the same random picks) at alpha hl */-static void bt_draw(int t0, int w, int h, float x, float y, float a, float hl) {- if (t0 < 0) return;- const TileQ *q = bt_pool + t0;- if (a > 0) tiles_draw(q, w, h, x, y, 0xFFFF, a8(a));- if (hl > 0) {- TileQ tmp[BT_CHUNKS * BT_CHUNK / 2];- int n = w * h, g = terrain_of(0, 'G');- if (n > (int)(sizeof tmp / sizeof tmp[0]) || g < 0) return;- for (int i = 0; i < n; i++) tmp[i].quad = q[i].quad, tmp[i].terrain = q[i].terrain == 255 ? 255 : (uint8_t)g;- tiles_draw(tmp, w, h, x, y, 0xFFFF, a8(hl));- }+static void bt_draw(const TileQ *q, int w, int h, float x, float y, float a, float hl) {+ if (!q) return;+ if (a > 0) tiles_draw(q, 'g', w, h, x, y, 0xFFFF, a8(a));+ if (hl > 0) tiles_draw(q, 'G', w, h, x, y, 0xFFFF, a8(hl));}/* FallingBlock(finalBoss: true), the map's finalBossFallingBlock */typedef struct {float wait, timer, delay, speed, hl, hl_from, hl_to, hl_p;- int16_t t0;+ TileQ *q;uint8_t w, h, step, triggered, hl_run, pad;} BFall;static void bfall_highlight(BFall *b, float to) { /* HighlightFade(to): its coroutine starts next frame */@@ -1461,11 +1435,11 @@ static void bfall_update(Ent *e) {}static void bfall_render(Ent *e) {BFall *b = ST(e, BFall);- bt_draw(b->t0, b->w, b->h, e->x + e->shakex, e->y + e->shakey, 1 - b->hl, b->hl);+ bt_draw(b->q, b->w, b->h, e->x + e->shakex, e->y + e->shakey, 1 - b->hl, b->hl);}static void bfall_shake(Ent *e, V2 a) { plat_static_movers_shake(e, a); }static const EntClass BFALL = {.name = "finalBossFallingBlock", .size = sizeof(BFall), .update = bfall_update, .render = bfall_render,- .removed = bt_free, .on_shake = bfall_shake, .kind = KIND_SOLID};+ .on_shake = bfall_shake, .kind = KIND_SOLID};static void new_bfall(const EData *d) {float w = EA(d, finalBossFallingBlock, width), h = EA(d, finalBossFallingBlock, height);Ent *e = ent_new(&BFALL, d->x, d->y);@@ -1473,8 +1447,7 @@ static void new_bfall(const EData *d) {ent_box(e, w, h, 0, 0);BFall *b = ST(e, BFall);b->w = (uint8_t)(w / 8), b->h = (uint8_t)(h / 8);- b->t0 = (int16_t)bt_alloc(e, b->w * b->h);- if (b->t0 >= 0) tiles_box('g', b->w, b->h, bt_pool + b->t0);+ if ((b->q = blocks_new_tiles(b->w * b->h))) tiles_box('g', b->w, b->h, b->q);}/* FinalBossMovingBlock */@@ -1484,7 +1457,7 @@ typedef struct {Tween tw;V2 from, to;int16_t nodes[BM_NODES][2];- int16_t t0;+ TileQ *q;uint8_t w, h, node, nnodes, boss_node, step, highlighted, tw_on;} BMove;static const EntClass BMOVE;@@ -1612,7 +1585,7 @@ static void bmove_update(Ent *e) {static void bmove_render(Ent *e) {BMove *b = ST(e, BMove);float x = e->x + e->shakex, y = e->y + e->shakey;- bt_draw(b->t0, b->w, b->h, x, y, 1 - b->hl, b->hl);+ bt_draw(b->q, b->w, b->h, x, y, 1 - b->hl, b->hl);if (b->hl > 0 && b->hl < 1) { /* a hollow rect closing in, Color.Lerp(Purple, Pink, 0.7) */int n = (int)((1 - b->hl) * 16);gfx_hollow_rect(x - n, y - n, e->cw + 2 * n, e->ch + 2 * n, rgb(0xD886B4), 255);@@ -1620,7 +1593,7 @@ static void bmove_render(Ent *e) {}static void bmove_shake(Ent *e, V2 a) { plat_static_movers_shake(e, a); }static const EntClass BMOVE = {.name = "finalBossMovingBlock", .size = sizeof(BMove), .update = bmove_update, .render = bmove_render,- .removed = bt_free, .on_shake = bmove_shake, .kind = KIND_SOLID};+ .on_shake = bmove_shake, .kind = KIND_SOLID};static void new_bmove(const EData *d) {float w = EA(d, finalBossMovingBlock, width), h = EA(d, finalBossMovingBlock, height);Ent *e = ent_new(&BMOVE, d->x, d->y);@@ -1636,8 +1609,7 @@ static void new_bmove(const EData *d) {b->nodes[n][0] = (int16_t)v.x, b->nodes[n][1] = (int16_t)v.y;}b->nnodes = (uint8_t)n;- b->t0 = (int16_t)bt_alloc(e, b->w * b->h);- if (b->t0 >= 0) tiles_box('g', b->w, b->h, bt_pool + b->t0);+ if ((b->q = blocks_new_tiles(b->w * b->h))) tiles_box('g', b->w, b->h, b->q);}/* ---------------------------------------------------------------- FinalBossShot */diff --git a/games/celeste/src/entities.c b/games/celeste/src/entities.cindex 158fb1ef..ce410b15 100644--- a/games/celeste/src/entities.c+++ b/games/celeste/src/entities.c@@ -750,31 +750,40 @@ static void new_zip(const EData *d) {}/* ---------------------------------------------------------------- tile blocks */-/* the tiles of blocks come from a pool, one half per room slot */-#define POOL_TILES 400-static TileQ tile_pool[2][POOL_TILES];+/* the tiles of blocks come from one pool: the rooms in slot 0 take them from its start, in slot 1 from its end */+TileQ g_tile_pool[TILE_POOL];static int tile_pool_n[2];static TileQ *pool_tiles(int slot, int n) {- if (tile_pool_n[slot] + n > POOL_TILES) return NULL;- TileQ *q = tile_pool[slot] + tile_pool_n[slot];+ if (tile_pool_n[0] + tile_pool_n[1] + n > TILE_POOL) return NULL;tile_pool_n[slot] += n;- return q;+ return slot ? g_tile_pool + TILE_POOL - tile_pool_n[1] : g_tile_pool + tile_pool_n[0] - n;}+TileQ *blocks_new_tiles(int n) { return pool_tiles(g_level.room_slot, n); }+void blocks_free_tiles(int slot) { tile_pool_n[slot] = 0; }+enum { BF_OVERLAY = 0x80 }; /* Block.flags: the tiles blend into the room's (TileGrid of the level's grid) */typedef struct {char type;uint8_t w, h, mode;- uint8_t flags; /* fallingBlock: climbFall; dashBlock: permanent, canDash */+ uint8_t flags; /* fallingBlock: climbFall; dashBlock: permanent, canDash; BF_OVERLAY */int step;float timer, speed, alpha;bool triggered;uint32_t hash;TileQ *q;} Block;+/* its tiles from the pool; with too many in the two rooms, it tries again when drawn, once in the level's room */+static bool block_tiles(Ent *e) {+ Block *b = ST(e, Block);+ if (e->room != g_level.room_slot || !(b->q = pool_tiles(e->room, b->w * b->h))) return false;+ if (b->flags & BF_OVERLAY) tiles_overlay(b->type, (int)(e->x / 8), (int)(e->y / 8), b->w, b->h, b->q);+ else tiles_box(b->type, b->w, b->h, b->q);+ return true;+}static void block_render(Ent *e) {Block *b = ST(e, Block);- if (!b->q) return;- tiles_draw(b->q, b->w, b->h, e->x + e->shakex, e->y + e->shakey, 0xFFFF, (uint8_t)(b->alpha * 255));+ if (!b->q && !block_tiles(e)) return;+ tiles_draw(b->q, b->type, b->w, b->h, e->x + e->shakex, e->y + e->shakey, 0xFFFF, (uint8_t)(b->alpha * 255));}/* FallingBlock */@@ -861,7 +870,7 @@ static void block_shake(Ent *e, V2 a) { plat_static_movers_shake(e, a); }static const EntClass FALLING = {.size = sizeof(Block), .name = "fallingBlock", .update = falling_update, .render = block_render,.on_staticmover_trigger = falling_trigger, .on_shake = block_shake, .kind = KIND_SOLID};-static Ent *new_block(const EntClass *cls, const EData *d, float w, float h, char type) {+static Ent *new_block(const EntClass *cls, const EData *d, float w, float h, char type, bool overlay) {Ent *e = ent_new(cls, d->x, d->y);if (!e) return NULL;ent_box(e, w, h, 0, 0);@@ -870,8 +879,8 @@ static Ent *new_block(const EntClass *cls, const EData *d, float w, float h, chab->w = (uint8_t)(w / 8), b->h = (uint8_t)(h / 8);b->alpha = 1;b->hash = level_entity_hash(d);- b->q = pool_tiles(g_level.room_slot, b->w * b->h);- if (b->q) tiles_box(type, b->w, b->h, b->q);+ b->flags = overlay ? BF_OVERLAY : 0;+ block_tiles(e);return e;}/* data.Char("tiletype", '3'): a number in some maps, a letter in others (data.bin keeps those as text) */@@ -1173,53 +1182,39 @@ bool ent_create(const EData *d) {case ET_zipMover: new_zip(d); return true;case ET_fallingBlock: {Ent *e = new_block(&FALLING, d, EA(d, fallingBlock, width), EA(d, fallingBlock, height),- TILE_ATTR(d, fallingBlock, tiletype));+ TILE_ATTR(d, fallingBlock, tiletype), false);if (!e) return true;if (EAB(d, fallingBlock, behind)) e->depth = 5000;- ST(e, Block)->flags = EAB(d, fallingBlock, climbFall) ? 1 : 0;+ ST(e, Block)->flags |= EAB(d, fallingBlock, climbFall) ? 1 : 0;return true;}case ET_dashBlock: {- char t = TILE_ATTR(d, dashBlock, tiletype);- Ent *e = new_block(&DASHBLOCK, d, EA(d, dashBlock, width), EA(d, dashBlock, height), t);+ bool blend = EAB(d, dashBlock, blendin);+ Ent *e = new_block(&DASHBLOCK, d, EA(d, dashBlock, width), EA(d, dashBlock, height), TILE_ATTR(d, dashBlock, tiletype),+ blend);if (!e) return true;- e->depth = -12999;+ e->depth = blend ? -10501 : -12999;e->safe = 1;- Block *b = ST(e, Block);- b->flags = (EAB(d, dashBlock, permanent) ? 1 : 0) | (EAB(d, dashBlock, canDash) ? 2 : 0);- if (EAB(d, dashBlock, blendin)) {- e->depth = -10501;- if (b->q) tiles_overlay(t, (int)(d->x / 8), (int)(d->y / 8), b->w, b->h, b->q);- }+ ST(e, Block)->flags |= (EAB(d, dashBlock, permanent) ? 1 : 0) | (EAB(d, dashBlock, canDash) ? 2 : 0);return true;}case ET_fakeWall: {- char t = TILE_ATTR(d, fakeWall, tiletype);- Ent *e = new_block(&FAKEWALL, d, EA(d, fakeWall, width), EA(d, fakeWall, height), t);- if (!e) return true;- e->depth = -13000;- Block *b = ST(e, Block);- if (b->q) tiles_overlay(t, (int)(d->x / 8), (int)(d->y / 8), b->w, b->h, b->q);+ Ent *e = new_block(&FAKEWALL, d, EA(d, fakeWall, width), EA(d, fakeWall, height), TILE_ATTR(d, fakeWall, tiletype), true);+ if (e) e->depth = -13000;return true;}case ET_coverupWall: {- char t = TILE_ATTR(d, coverupWall, tiletype);- Ent *e = new_block(&COVERUP, d, EA(d, coverupWall, width), EA(d, coverupWall, height), t);- if (!e) return true;- e->depth = -13000;- Block *b = ST(e, Block);- if (b->q) tiles_overlay(t, (int)(d->x / 8), (int)(d->y / 8), b->w, b->h, b->q);+ Ent *e = new_block(&COVERUP, d, EA(d, coverupWall, width), EA(d, coverupWall, height), TILE_ATTR(d, coverupWall, tiletype),+ true);+ if (e) e->depth = -13000;return true;}case ET_exitBlock: {- char t = TILE_ATTR(d, exitBlock, tileType);- Ent *e = new_block(&EXITBLOCK, d, EA(d, exitBlock, width), EA(d, exitBlock, height), t);+ Ent *e = new_block(&EXITBLOCK, d, EA(d, exitBlock, width), EA(d, exitBlock, height), TILE_ATTR(d, exitBlock, tileType), true);if (!e) return true;e->depth = -13000;e->collidable = 0;- Block *b = ST(e, Block);- b->alpha = 0;- if (b->q) tiles_overlay(t, (int)(d->x / 8), (int)(d->y / 8), b->w, b->h, b->q);+ ST(e, Block)->alpha = 0;return true;}case ET_killbox: {diff --git a/games/celeste/src/gfx.c b/games/celeste/src/gfx.cindex 74f797a0..503aec1b 100644--- a/games/celeste/src/gfx.c+++ b/games/celeste/src/gfx.c@@ -19,7 +19,7 @@ static bool hud, ui; /* hud: screen coordinates; ui: the interface (drawn aftestatic uint16_t clear_color;static bool letterbox_dirty = true;-enum { OP_TEX, OP_PART, OP_AFFINE, OP_RECT, OP_LINE, OP_PIXEL, OP_CUSTOM, OP_SCALED, OP_MASK };+enum { OP_TEX, OP_PART, OP_AFFINE, OP_RECT, OP_LINE, OP_PIXEL, OP_CUSTOM, OP_SCALED, OP_MASK, OP_TILES };typedef struct {uint8_t op, flags, alpha, extra;@@ -445,6 +445,29 @@ void blit_cells(uint16_t *strip, int sy0, int sy1, const Tex *t, float x, float}}+/* a block's tiles: a grid of w x h 8x8 tiles of t (quads, ty * 8 + tx, 255 for none) at strip-relative (x, y) */+static void blit_tiles(uint16_t *strip, int sy0, int sy1, const Tex *t, int x, int y, const uint8_t *q, int w, int h,+ uint16_t tint, uint8_t alpha) {+ prep(t->pal, tint, alpha, 0);+ int r0 = y > sy0 ? y : sy0, r1 = y + h * 8 < sy1 ? y + h * 8 : sy1;+ for (int vy = r0; vy < r1; vy++) {+ const uint8_t *qr = q + ((vy - y) >> 3) * w;+ uint16_t *row = strip + (vy - sy0) * VIEW_W;+ int cached = -1;+ for (int i = 0; i < w; i++) {+ int k = qr[i], dx = x + i * 8;+ if (k == 255 || dx >= VIEW_W || dx + 8 <= 0) continue;+ int sr = (k >> 3) * 8 + ((vy - y) & 7) - t->oy;+ if (sr < 0 || sr >= t->h) continue;+ if (sr != cached) turned_src = NULL, tex_row(t, sr, rowbuf), cached = sr;+ for (int px = 0; px < 8; px++) {+ int c = (k & 7) * 8 + px - t->ox;+ if ((unsigned)(dx + px) < VIEW_W && c >= 0 && c < t->w && rowbuf[c]) plot(row + dx + px, rowbuf[c]);+ }+ }+ }+}+/* a palette's first 16 colors as drawn (tint folded in) and their alphas (0..256) */void pal_lut(uint16_t pal, uint16_t tint, uint16_t *col, uint16_t *alpha) {int n;@@ -756,6 +779,18 @@ void gfx_tex_part(uint16_t tex, float x, float y, int sx, int sy, int w, int h,c->a = (uint16_t)(sx | sy << 8), c->b = (uint16_t)(w | h << 8);}+/* a block's w x h tiles of tex (q: TileQ in g_tile_pool), its top-left at (x, y): one command */+void gfx_tiles(uint16_t tex, const uint8_t *q, int w, int h, float x, float y, uint16_t tint, uint8_t alpha) {+ Tex t;+ if (!alpha || w > 255 || h > 127 || q < g_tile_pool || q + w * h > g_tile_pool + TILE_POOL || !tex_get(tex, &t)) return;+ int X = sx_(x), Y = sy_(y);+ if (X >= VIEW_W || X + w * 8 <= 0) return;+ Cmd *c = add(OP_TILES, Y, Y + h * 8);+ if (!c) return;+ c->tex = tex, c->x = (int16_t)X, c->y = (int16_t)Y, c->tint = tint, c->alpha = alpha;+ c->flags = (uint8_t)w, c->extra |= (uint8_t)(h << 1), c->a = (uint16_t)(q - g_tile_pool);+}+void gfx_rect(float x, float y, float w, float h, uint16_t col, uint8_t alpha) {if (!alpha) return;int X = sx_(x), Y = sy_(y), W_ = (int)floorf(w + 0.5f), H_ = (int)floorf(h + 0.5f);@@ -857,6 +892,10 @@ static void replay(int y0, int y1, int pass) {case OP_RECT: fill(g_strip, y0, y1, c->x, c->y, c->a, c->b, c->tint, c->alpha); break;case OP_LINE: line(g_strip, y0, y1, c->x, c->y, (int16_t)c->a, (int16_t)c->b, c->tint, c->alpha); break;case OP_CUSTOM: customs[c->a].fn(g_strip, y0, y1, customs[c->a].ctx); break;+ case OP_TILES:+ if (tex_get(c->tex, &t))+ blit_tiles(g_strip, y0, y1, &t, c->x, c->y, g_tile_pool + c->a, c->flags, c->extra >> 1, c->tint, c->alpha);+ break;}}}diff --git a/games/celeste/src/level.c b/games/celeste/src/level.cindex c83e3d2b..4df1a93e 100644--- a/games/celeste/src/level.c+++ b/games/celeste/src/level.c@@ -371,6 +371,7 @@ static float spawn_fx = 0, spawn_fy = 1; /* LoadLevel's spawn: the one neareststatic bool just_started; /* Session.JustStarted: the session's first room is loading */static void load_into_current(int index, int intro) {ents_clear(false);+ blocks_free_tiles(1); /* (slot 0's go when it loads) */g_level.rooms[0].index = g_level.rooms[1].index = -1;g_level.room_slot = 0;g_level.room = &g_level.rooms[0];@@ -575,6 +576,7 @@ static void transition_update(void) {if (arrived && g_level.tr_at >= 1) {int old = g_level.room_slot ^ 1;ents_remove_room(old);+ blocks_free_tiles(old);g_level.rooms[old].index = -1;V2 sp = player_spawn_near(v2(pe->x, pe->y)); /* Session.RespawnPoint = the closest spawn */g_session.rx = (int32_t)sp.x, g_session.ry = (int32_t)sp.y;diff --git a/games/celeste/src/level.h b/games/celeste/src/level.hindex adca1e17..c5b0b963 100644--- a/games/celeste/src/level.h+++ b/games/celeste/src/level.h@@ -276,10 +276,7 @@ bool level_do_not_load(uint32_t id);void level_set_do_not_load(uint32_t id);/* tiles (tiles.c) */-typedef struct {- uint8_t terrain; /* 255: none */- uint8_t quad; /* ty * 8 + tx in the tile sheet */-} TileQ;+typedef uint8_t TileQ; /* a block's tile: its quad, ty * 8 + tx in the tile sheet (255: none) */int autotile(int layer, char (*get)(int x, int y, void *ctx), void *ctx, int x, int y, uint8_t *quad, int variant);void tiles_render_layer(int layer, int depth);void tiles_invalidate(void);@@ -288,7 +285,9 @@ uint16_t terrain_tex(int t);/* a box of tiles of one type, as Celeste's GenerateBox (falling blocks...) */void tiles_box(char type, int w, int h, TileQ *out);void tiles_overlay(char type, int x, int y, int w, int h, TileQ *out); /* blended into the room (dash blocks) */-void tiles_draw(const TileQ *q, int w, int h, float x, float y, uint16_t tint, uint8_t alpha);+void tiles_draw(const TileQ *q, char type, int w, int h, float x, float y, uint16_t tint, uint8_t alpha);+TileQ *blocks_new_tiles(int n); /* n tiles for an entity of the room being made (NULL: none left), until it goes */+void blocks_free_tiles(int slot); /* the room in that slot is gone: its blocks' tiles (entities.c) *//* stylegrounds (style.c) */void style_init(void);diff --git a/games/celeste/src/tiles.c b/games/celeste/src/tiles.cindex a3d1c9b7..f464842f 100644--- a/games/celeste/src/tiles.c+++ b/games/celeste/src/tiles.c@@ -284,13 +284,11 @@ static char box_get(int x, int y, void *ctx) {void tiles_box(char type, int w, int h, TileQ *out) {BoxCtx b = {type, w, h};AutoCtx a = {box_get, &b, NULL, false};- int t = terrain_of(0, type);for (int y = 0; y < h; y++)for (int x = 0; x < w; x++) {int ov;int q = autotile_at(0, type, &a, x, y, &ov, 3);- out[y * w + x].terrain = q < 0 ? 255 : (uint8_t)t;- out[y * w + x].quad = q < 0 ? 0 : (uint8_t)q;+ out[y * w + x] = q < 0 ? 255 : (uint8_t)q;}}@@ -307,24 +305,17 @@ static bool over_in(int x, int y, void *ctx) {void tiles_overlay(char type, int x, int y, int w, int h, TileQ *out) {OverCtx o = {type, x, y, w, h};AutoCtx a = {over_get, &o, over_in, true};- int t = terrain_of(0, type);for (int j = 0; j < h; j++)for (int i = 0; i < w; i++) {int ov;int q = autotile_at(0, type, &a, x + i, y + j, &ov, 0);- out[j * w + i].terrain = q < 0 ? 255 : (uint8_t)t;- out[j * w + i].quad = q < 0 ? 0 : (uint8_t)q;+ out[j * w + i] = q < 0 ? 255 : (uint8_t)q;}}-void tiles_draw(const TileQ *q, int w, int h, float x, float y, uint16_t tint, uint8_t alpha) {- for (int j = 0; j < h; j++)- for (int i = 0; i < w; i++) {- const TileQ *t = &q[j * w + i];- if (t->terrain == 255) continue;- uint16_t tex = terrain_tex(t->terrain);- gfx_tex_part(tex, x + i * 8, y + j * 8, (t->quad & 7) * 8, (t->quad >> 3) * 8, 8, 8, 0, tint, alpha);- }+void tiles_draw(const TileQ *q, char type, int w, int h, float x, float y, uint16_t tint, uint8_t alpha) {+ int t = terrain_of(0, type);+ if (t >= 0) gfx_tiles(terrain_tex(t), q, w, h, x, y, tint, alpha);}/* ---------------------------------------------------------------- decals */diff --git a/games/celeste/tests/play.c b/games/celeste/tests/play.cindex 2e1f30eb..814d118d 100644--- a/games/celeste/tests/play.c+++ b/games/celeste/tests/play.c@@ -3,6 +3,7 @@* [--draw N: draw every N frames (else only for shots and the last frame)]* [--load F:ROOM:INTRO:FX:FY: at frame F, LoadLevel(INTRO) into ROOM at the spawn nearest (FX, FY) of it]* [--record A-B:DIR: every frame from A to B as DIR/NNNNN.ppm (for the README's GIFs)]+ * [--nowipe: no wipe into the room] [--cam X,Y: the view's top-left there (in the room) when drawn]* keys: l r u d j(ump) x(dash) g(rab) p(ause) o(k) b(ack) */#include <stdio.h>#include <stdlib.h>@@ -12,6 +13,7 @@#include "../src/text.h"#include "../src/player.h"#include "../src/entities.h"+#include "../src/wipe.h"extern uint32_t host_keys, host_time;void host_shot(const char *path);@@ -48,11 +50,13 @@ int main(int argc, char **argv) {fread(data, 1, n, f);fclose(f);cel_bin = data;- int frames = 120, chapter = -1, area = -1, checkpoint = -1, at_set = 0, dash_code = 0, list = 0, draw = 0, load_at = -1, load_intro = 0;+ int frames = 120, chapter = -1, area = -1, checkpoint = -1, at_set = 0, dash_code = 0, list = 0, draw = 0, load_at = -1, load_intro = 0,+ nowipe = 0;const char *load_room = NULL, *rec_dir = NULL;int rec_from = -1, rec_to = -1;float load_fx = 0, load_fy = 1;- float at_x = 0, at_y = 0;+ float at_x = 0, at_y = 0, cam_x = 0, cam_y = 0;+ int cam_set = 0;const char *keys = "", *room = NULL, *saves = "build/no-saves", *say = NULL;const char *shots[64];int shot_at[64], nshots = 0;@@ -66,6 +70,8 @@ int main(int argc, char **argv) {else if (!strcmp(argv[i], "--saves")) saves = argv[++i];else if (!strcmp(argv[i], "--say")) say = argv[++i];else if (!strcmp(argv[i], "--dash-code")) dash_code = 1;+ else if (!strcmp(argv[i], "--nowipe")) nowipe = 1;+ else if (!strcmp(argv[i], "--cam")) sscanf(argv[++i], "%f,%f", &cam_x, &cam_y), cam_set = 1;else if (!strcmp(argv[i], "--draw")) draw = atoi(argv[++i]);else if (!strcmp(argv[i], "--record")) {char *a = argv[++i];@@ -108,6 +114,7 @@ int main(int argc, char **argv) {level_start(room ? INTRO_NONE : session_intro(true));g_in_level = true, g_menu = 0;}+ if (nowipe) g_wipe.active = false; /* --nowipe: the room at once (no wipe in) */if (at_set) { /* --at X,Y: the player there (in the room) */g_player.ent->x = g_level.room->x + at_x, g_player.ent->y = g_level.room->y + at_y;g_level.cam = player_camera_target(&g_player);@@ -157,6 +164,7 @@ int main(int argc, char **argv) {if (shot_at[i] == fr) want = true;bool rec = rec_dir && fr >= rec_from && fr <= rec_to;if (want || rec || fr == frames - 1 || (draw && fr % draw == 0)) {+ if (cam_set) g_level.cam = v2(g_level.room->x + cam_x, g_level.room->y + cam_y); /* --cam X,Y: the view there */game_draw();if (rec) {char path[512];