Skip to content

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.

Celeste: decals that do what they do in the game

Mason Chen461131c9b6e9
diff --git a/games/celeste/src/celeste.h b/games/celeste/src/celeste.h
index 9a05274b..22d6088a 100644
--- a/games/celeste/src/celeste.h
+++ b/games/celeste/src/celeste.h
@@ -190,6 +190,7 @@ void gfx_clear(uint16_t c);
void gfx_tex(uint16_t tex, float x, float y, uint8_t flags, uint16_t tint, uint8_t alpha);
/* drawn like Monocle's MTexture.Draw(position, origin, color, scale, rotation, flip) */
void gfx_tex_ex(uint16_t tex, float x, float y, float ox, float oy, float sx, float sy, float rot, uint16_t tint, uint8_t alpha, uint8_t flags);
+void gfx_banner(uint16_t tex, float x, float y, uint8_t flags, uint16_t ph, uint16_t prm); /* Decal.Banner (gfx.c) */
void gfx_zoom(float zoom, float focus_x, float focus_y); /* Level.Zoom around a screen point */
void gfx_screen(bool on); /* screen coordinates for gameplay layers (zoomed with the world) */
/* part of a texture (tile sheets): sub-rect (sx, sy, w, h) of the frame */
diff --git a/games/celeste/src/ch3.c b/games/celeste/src/ch3.c
index ba78c387..69946ef9 100644
--- a/games/celeste/src/ch3.c
+++ b/games/celeste/src/ch3.c
@@ -1686,7 +1686,13 @@ static void fall_awake(Ent *e) {
f->water = ent_ref(w);
break;
}
- if (rect_solid((int)e->x, (int)y, (int)e->x + 8, (int)y + 8)) { /* Solid.BlockWaterfalls */
+ bool blocked = false; /* a solid there that blocks waterfalls (Solid.BlockWaterfalls) */
+ for (int i = 0; i < g_nents && !blocked; i++) {
+ Ent *o = &g_ents[i];
+ blocked = (o->kind & KIND_SOLID) && o->cls && o->collidable && o->dead != 1 && solid_blocks_waterfalls(o) &&
+ collide_rect(o, (int)e->x, (int)y, (int)e->x + 8, (int)y + 8);
+ }
+ if (blocked) {
f->solid = 1;
break;
}
diff --git a/games/celeste/src/data.bin b/games/celeste/src/data.bin
index c0cb7871..4601f0be 100644
Binary files a/games/celeste/src/data.bin and b/games/celeste/src/data.bin differ
diff --git a/games/celeste/src/data.h b/games/celeste/src/data.h
index 43b68367..581038eb 100644
--- a/games/celeste/src/data.h
+++ b/games/celeste/src/data.h
@@ -986,71 +986,72 @@
#define ET_trapdoor 65
#define ET_water 66
#define ET_clutterDoor 67
-#define ET_oshirodoor 68
-#define ET_colorSwitch 69
-#define ET_clutterCabinet 70
-#define ET_picoconsole 71
-#define ET_clothesline 72
-#define ET_triggerSpikesDown 73
-#define ET_friendlyGhost 74
-#define ET_resortRoofEnding 75
-#define ET_killbox 76
-#define ET_cloud 77
-#define ET_booster 78
-#define ET_cliffside_flag 79
-#define ET_moveBlock 80
-#define ET_cliffflag 81
-#define ET_ridgeGate 82
-#define ET_whiteblock 83
-#define ET_gondola 84
-#define ET_templeGate 85
-#define ET_dashSwitchH 86
-#define ET_torch 87
-#define ET_swapBlock 88
-#define ET_templeMirror 89
-#define ET_dashSwitchV 90
-#define ET_templeMirrorPortal 91
-#define ET_seeker 92
-#define ET_templeCrackedBlock 93
-#define ET_seekerStatue 94
-#define ET_seekerBarrier 95
-#define ET_conditionBlock 96
-#define ET_theoCrystalPedestal 97
-#define ET_theoCrystal 98
-#define ET_templeEye 99
-#define ET_templeBigEyeball 100
-#define ET_playerSeeker 101
-#define ET_wallSpringRight 102
-#define ET_crushBlock 103
-#define ET_bigWaterfall 104
-#define ET_infiniteStar 105
-#define ET_reflectionHeartStatue 106
-#define ET_bigSpinner 107
-#define ET_badelineBoost 108
-#define ET_tentacles 109
-#define ET_finalBoss 110
-#define ET_finalBossFallingBlock 111
-#define ET_finalBossMovingBlock 112
-#define ET_plateau 113
-#define ET_starJumpBlock 114
-#define ET_SummitBackgroundManager 115
-#define ET_wallSpringLeft 116
-#define ET_summitgem 117
-#define ET_bridgeFixed 118
-#define ET_summitcheckpoint 119
-#define ET_summitGemManager 120
-#define ET_summitcloud 121
-#define ET_heartGemDoor 122
-#define ET_wallBooster 123
-#define ET_fireBall 124
-#define ET_bounceBlock 125
-#define ET_iceBlock 126
-#define ET_coreModeToggle 127
-#define ET_fireBarrier 128
-#define ET_risingLava 129
-#define ET_sandwichLava 130
-#define ET_coreMessage 131
-#define ET_COUNT 132
+#define ET_decalSolid 68
+#define ET_oshirodoor 69
+#define ET_colorSwitch 70
+#define ET_clutterCabinet 71
+#define ET_picoconsole 72
+#define ET_clothesline 73
+#define ET_triggerSpikesDown 74
+#define ET_friendlyGhost 75
+#define ET_resortRoofEnding 76
+#define ET_killbox 77
+#define ET_cloud 78
+#define ET_booster 79
+#define ET_cliffside_flag 80
+#define ET_moveBlock 81
+#define ET_cliffflag 82
+#define ET_ridgeGate 83
+#define ET_whiteblock 84
+#define ET_gondola 85
+#define ET_templeGate 86
+#define ET_dashSwitchH 87
+#define ET_torch 88
+#define ET_swapBlock 89
+#define ET_templeMirror 90
+#define ET_dashSwitchV 91
+#define ET_templeMirrorPortal 92
+#define ET_seeker 93
+#define ET_templeCrackedBlock 94
+#define ET_seekerStatue 95
+#define ET_seekerBarrier 96
+#define ET_conditionBlock 97
+#define ET_theoCrystalPedestal 98
+#define ET_theoCrystal 99
+#define ET_templeEye 100
+#define ET_templeBigEyeball 101
+#define ET_playerSeeker 102
+#define ET_wallSpringRight 103
+#define ET_crushBlock 104
+#define ET_bigWaterfall 105
+#define ET_infiniteStar 106
+#define ET_reflectionHeartStatue 107
+#define ET_bigSpinner 108
+#define ET_badelineBoost 109
+#define ET_tentacles 110
+#define ET_finalBoss 111
+#define ET_finalBossFallingBlock 112
+#define ET_finalBossMovingBlock 113
+#define ET_plateau 114
+#define ET_starJumpBlock 115
+#define ET_SummitBackgroundManager 116
+#define ET_wallSpringLeft 117
+#define ET_summitgem 118
+#define ET_bridgeFixed 119
+#define ET_summitcheckpoint 120
+#define ET_summitGemManager 121
+#define ET_summitcloud 122
+#define ET_heartGemDoor 123
+#define ET_wallBooster 124
+#define ET_fireBall 125
+#define ET_bounceBlock 126
+#define ET_iceBlock 127
+#define ET_coreModeToggle 128
+#define ET_fireBarrier 129
+#define ET_risingLava 130
+#define ET_sandwichLava 131
+#define ET_coreMessage 132
+#define ET_COUNT 133
#define TT_cameraOffsetTrigger 0
#define TT_cameraTargetTrigger 1
#define TT_changeRespawnTrigger 2
@@ -1357,6 +1358,13 @@
#define EA_clutterDoor_type 4
#define EK_clutterDoor_type 's'
#define EA_clutterDoor__size 6
+#define EA_decalSolid_width 0
+#define EK_decalSolid_width 'i'
+#define EA_decalSolid_height 2
+#define EK_decalSolid_height 'i'
+#define EA_decalSolid_blockWaterfalls 4
+#define EK_decalSolid_blockWaterfalls 'b'
+#define EA_decalSolid__size 6
#define EA_oshirodoor__size 0
#define EA_colorSwitch_type 0
#define EK_colorSwitch_type 's'
@@ -1787,7 +1795,7 @@
#define EA_cameraAdvanceTargetTrigger_yOnly 13
#define EK_cameraAdvanceTargetTrigger_yOnly 'b'
#define EA_cameraAdvanceTargetTrigger__size 14
-static const uint8_t ENT_ATTR_SIZE[] = {2,0,2,2,4,6,0,2,2,2,4,4,4,0,6,4,2,2,2,6,4,8,0,8,8,8,10,2,2,6,2,0,0,2,2,0,8,8,2,0,0,0,4,6,0,0,2,2,6,6,0,6,2,0,4,4,0,0,4,2,0,2,2,2,2,0,6,6,0,2,0,0,0,2,0,2,2,2,2,2,8,0,8,0,2,6,6,2,6,8,6,0,0,6,2,4,10,0,0,0,0,0,2,8,6,2,0,0,6,4,8,4,6,0,6,8,2,2,2,2,0,0,8,4,12,4,4,4,4,2,0,2};
+static const uint8_t ENT_ATTR_SIZE[] = {2,0,2,2,4,6,0,2,2,2,4,4,4,0,6,4,2,2,2,6,4,8,0,8,8,8,10,2,2,6,2,0,0,2,2,0,8,8,2,0,0,0,4,6,0,0,2,2,6,6,0,6,2,0,4,4,0,0,4,2,0,2,2,2,2,0,6,6,6,0,2,0,0,0,2,0,2,2,2,2,2,8,0,8,0,2,6,6,2,6,8,6,0,0,6,2,4,10,0,0,0,0,0,2,8,6,2,0,0,6,4,8,4,6,0,6,8,2,2,2,2,0,0,8,4,12,4,4,4,4,2,0,2};
static const uint8_t TRIG_ATTR_SIZE[] = {12,14,4,8,4,4,10,14,14,6,6,4,12,4,4,6,6,14};
#define T_animatedTiles_grass_top_a00 0
@@ -7252,90 +7260,106 @@ static const uint8_t TRIG_ATTR_SIZE[] = {12,14,4,8,4,4,10,14,14,6,6,4,12,4,4,6,6
#define T_decals_6_reflection_Wood_a 5459
#define T_decals_6_reflection_rubble_f 5460
#define T_decals_7_summit_cloud_f 5461
-#define T_decals_7_summit_cloud_a 5462
-#define T_decals_7_summit_cloud_e 5463
-#define T_decals_7_summit_cloud_cc 5464
-#define T_decals_7_summit_cloud_bb 5465
-#define T_decals_7_summit_cloud_bc 5466
-#define T_decals_7_summit_cloud_d 5467
-#define T_decals_7_summit_cloud_b 5468
-#define T_decals_7_summit_cloud_db 5469
-#define T_decals_7_summit_cloud_c 5470
-#define T_decals_7_summit_cloud_dc 5471
-#define T_decals_7_summit_cloud_cb 5472
-#define T_decals_5_temple_squid_head_a 5473
-#define T_decals_7_summit_cloud_cd 5474
-#define T_decals_7_summit_cloud_dd 5475
-#define T_decals_7_summit_cloud_ce 5476
-#define T_decals_7_summit_SummitFlag00 5477
-#define T_decals_7_summit_cherry_tree 5478
-#define T_decals_8_epilogue_table_a 5479
-#define T_decals_8_epilogue_housebg 5480
-#define T_decals_8_epilogue_backpack 5481
-#define T_decals_8_epilogue_nest_front 5482
-#define T_decals_generic_algae_d 5483
-#define T_decals_generic_algae_a 5484
-#define T_decals_generic_algae_e 5485
-#define T_decals_generic_algae_c 5486
-#define T_decals_8_epilogue_nest_back 5487
-#define T_decals_9_core_stalagtite_b 5488
-#define T_decals_9_core_stalagtite 5489
-#define T_decals_9_core_column_mid_a 5490
-#define T_decals_9_core_column_mid_d 5491
-#define T_decals_9_core_stalagtite_c 5492
-#define T_decals_9_core_stalagtite_d 5493
-#define T_decals_9_core_column_mid_b 5494
-#define T_decals_9_core_column_top 5495
-#define T_decals_9_core_column_bot_b 5496
-#define T_decals_9_core_heart_bevel_a 5497
-#define T_decals_9_core_heart_bevel_b 5498
-#define T_decals_9_core_heart_bevel_c 5499
-#define T_decals_9_core_column_bot_a 5500
-#define T_decals_9_core_rock_d 5501
-#define T_decals_9_core_rock_b 5502
-#define T_decals_9_core_fossil_a 5503
-#define T_decals_9_core_rope_a 5504
-#define T_decals_9_core_rock_a 5505
-#define T_decals_9_core_rubble_b 5506
-#define T_decals_9_core_rubble_j 5507
-#define T_decals_9_core_rubble_i 5508
-#define T_decals_9_core_capsule_a 5509
-#define T_decals_9_core_rock_c 5510
-#define T_decals_9_core_rubble_d 5511
-#define T_decals_9_core_column_mid_c 5512
-#define T_decals_9_core_heart_bevel_d 5513
-#define T_decals_9_core_machine_a 5514
-#define T_decals_9_core_rubble_k 5515
-#define T_decals_9_core_rubble_l 5516
-#define T_decals_9_core_fossil_b 5517
-#define T_decals_9_core_rock_e 5518
-#define T_decals_9_core_heart_b 5519
-#define T_decals_9_core_rubble_q 5520
-#define T_decals_9_core_column_top_b 5521
-#define T_decals_9_core_capsule_b 5522
-#define T_decals_9_core_capsule_c 5523
-#define T_decals_9_core_rubble_h 5524
-#define T_decals_9_core_rubble_o 5525
-#define T_decals_9_core_Chain_top 5526
-#define T_decals_9_core_chain_mid_a 5527
-#define T_decals_9_core_chain_bot 5528
-#define T_decals_9_core_rubble_g 5529
-#define T_decals_9_core_heart_a 5530
-#define T_decals_9_core_rubble_c 5531
-#define T_decals_9_core_rubble_n 5532
-#define T_decals_9_core_heart_sphere_a 5533
-#define T_decals_9_core_rubble_p 5534
-#define T_decals_9_core_rubble_m 5535
-#define T_decals_9_core_rubble_f 5536
-#define T_decals_9_core_ball_a 5537
-#define T_decals_9_core_chain_mid_b 5538
-#define T_decals_9_core_stump_a 5539
-#define T_decals_9_core_rubble_e 5540
-#define T_decals_9_core_rubble_a 5541
-#define T_decals_9_core_nevoa_shovel 5542
-#define T_decals_9_core_Chain_heart_top 5543
-#define T_decals_9_core_rock_e_ice 5544
-#define TEX_COUNT 5545
+#define T_decals_7_summit_cloud_f_1_15 5462
+#define T_decals_7_summit_cloud_a 5463
+#define T_decals_7_summit_cloud_a_1_15 5464
+#define T_decals_7_summit_cloud_e 5465
+#define T_decals_7_summit_cloud_e_1_15 5466
+#define T_decals_7_summit_cloud_cc 5467
+#define T_decals_7_summit_cloud_cc_1_15 5468
+#define T_decals_7_summit_cloud_bb 5469
+#define T_decals_7_summit_cloud_bb_1_15 5470
+#define T_decals_7_summit_cloud_bc 5471
+#define T_decals_7_summit_cloud_bc_1_15 5472
+#define T_decals_7_summit_cloud_d 5473
+#define T_decals_7_summit_cloud_d_1_15 5474
+#define T_decals_7_summit_cloud_b 5475
+#define T_decals_7_summit_cloud_b_1_15 5476
+#define T_decals_7_summit_cloud_db 5477
+#define T_decals_7_summit_cloud_db_1_15 5478
+#define T_decals_7_summit_cloud_c 5479
+#define T_decals_7_summit_cloud_c_1_15 5480
+#define T_decals_7_summit_cloud_dc 5481
+#define T_decals_7_summit_cloud_dc_1_15 5482
+#define T_decals_7_summit_cloud_cb 5483
+#define T_decals_7_summit_cloud_cb_1_15 5484
+#define T_decals_5_temple_squid_head_a 5485
+#define T_decals_7_summit_cloud_cd 5486
+#define T_decals_7_summit_cloud_cd_1_15 5487
+#define T_decals_7_summit_cloud_dd 5488
+#define T_decals_7_summit_cloud_dd_1_15 5489
+#define T_decals_7_summit_cloud_ce 5490
+#define T_decals_7_summit_cloud_ce_1_15 5491
+#define T_decals_7_summit_SummitFlag00 5492
+#define T_decals_7_summit_cherry_tree 5493
+#define T_decals_8_epilogue_table_a 5494
+#define T_decals_8_epilogue_housebg 5495
+#define T_decals_8_epilogue_backpack 5496
+#define T_decals_8_epilogue_nest_front 5497
+#define T_decals_generic_algae_d 5498
+#define T_decals_generic_algae_a 5499
+#define T_decals_generic_algae_e 5500
+#define T_decals_generic_algae_c 5501
+#define T_decals_8_epilogue_nest_back 5502
+#define T_decals_9_core_stalagtite_b 5503
+#define T_decals_9_core_stalagtite 5504
+#define T_decals_9_core_column_mid_a 5505
+#define T_decals_9_core_column_mid_d 5506
+#define T_decals_9_core_stalagtite_c 5507
+#define T_decals_9_core_stalagtite_d 5508
+#define T_decals_9_core_column_mid_b 5509
+#define T_decals_9_core_column_top 5510
+#define T_decals_9_core_column_bot_b 5511
+#define T_decals_9_core_heart_bevel_a 5512
+#define T_decals_9_core_heart_bevel_b 5513
+#define T_decals_9_core_heart_bevel_c 5514
+#define T_decals_9_core_column_bot_a 5515
+#define T_decals_9_core_rock_d 5516
+#define T_decals_9_core_rock_b 5517
+#define T_decals_9_core_fossil_a 5518
+#define T_decals_9_core_rope_a 5519
+#define T_decals_9_core_rock_a 5520
+#define T_decals_9_core_rubble_b 5521
+#define T_decals_9_core_rubble_j 5522
+#define T_decals_9_core_rubble_i 5523
+#define T_decals_9_core_capsule_a 5524
+#define T_decals_9_core_rock_c 5525
+#define T_decals_9_core_rubble_d 5526
+#define T_decals_9_core_column_mid_c 5527
+#define T_decals_9_core_heart_bevel_d 5528
+#define T_decals_9_core_machine_a 5529
+#define T_decals_9_core_rubble_k 5530
+#define T_decals_9_core_rubble_l 5531
+#define T_decals_9_core_fossil_b 5532
+#define T_decals_9_core_rock_e 5533
+#define T_decals_9_core_rock_e_ice 5534
+#define T_decals_9_core_heart_b 5535
+#define T_decals_9_core_rubble_q 5536
+#define T_decals_9_core_column_top_b 5537
+#define T_decals_9_core_capsule_b 5538
+#define T_decals_9_core_capsule_c 5539
+#define T_decals_9_core_rubble_h 5540
+#define T_decals_9_core_rubble_o 5541
+#define T_decals_9_core_Chain_top 5542
+#define T_decals_9_core_chain_mid_a 5543
+#define T_decals_9_core_chain_bot 5544
+#define T_decals_9_core_rubble_g 5545
+#define T_decals_9_core_heart_a 5546
+#define T_decals_9_core_rubble_c 5547
+#define T_decals_9_core_rubble_n 5548
+#define T_decals_9_core_heart_sphere_a 5549
+#define T_decals_9_core_rubble_p 5550
+#define T_decals_9_core_rubble_m 5551
+#define T_decals_9_core_rubble_f 5552
+#define T_decals_9_core_ball_a 5553
+#define T_decals_9_core_ball_a_ice 5554
+#define T_decals_9_core_chain_mid_b 5555
+#define T_decals_9_core_stump_a 5556
+#define T_decals_9_core_rubble_e 5557
+#define T_decals_9_core_rubble_a 5558
+#define T_decals_9_core_nevoa_shovel 5559
+#define T_decals_9_core_Chain_heart_top 5560
+#define TEX_COUNT 5561
#define ROOM_POOL_BYTES 19448 /* 7-Summit:g-00b+g-01 */
#define SG_parallax 0
#define SG_snowFg 1
diff --git a/games/celeste/src/ent.h b/games/celeste/src/ent.h
index 1af62d0c..a201f194 100644
--- a/games/celeste/src/ent.h
+++ b/games/celeste/src/ent.h
@@ -138,6 +138,7 @@ Ent *collide_first_jumpthru_outside(const Ent *e, float x, float y); /* Collid
bool collide_jumpthru(const Ent *e, float x, float y); /* CollideCheck<JumpThru> */
Ent *collide_first_kind(const Ent *e, float x, float y, uint16_t kind);
bool rect_solid(float l, float t, float r, float b); /* Scene.CollideCheck<Solid>(rect) */
+bool solid_blocks_waterfalls(const Ent *e); /* Solid.BlockWaterfalls */
bool point_solid(float x, float y);
/* Actor */
diff --git a/games/celeste/src/entities.c b/games/celeste/src/entities.c
index 80f37fe9..24c7ef60 100644
--- a/games/celeste/src/entities.c
+++ b/games/celeste/src/entities.c
@@ -160,6 +160,21 @@ static void jumpthru_update(Ent *e) { plat_update(e); }
static const EntClass JUMPTHRU = {.size = sizeof(JumpThru), .name = "jumpThru", .update = jumpthru_update, .render = jumpthru_render,
.awake = jumpthru_awake, .kind = KIND_JUMPTHRU};
+/* ---------------------------------------------------------------- Decal.MakeSolid */
+/* the Resort's roofs and bridge columns, its broken elevator, the cliffside bridges: plain solids (safe) the converter
+ * makes from those decals; a bg decal's lets waterfalls through (Solid.BlockWaterfalls: Depth != 9000) */
+static const EntClass DSOLID = {.name = "decalSolid", .update = plat_update, .kind = KIND_SOLID};
+static const EntClass DSOLID_OPEN = {.name = "decalSolid", .update = plat_update, .kind = KIND_SOLID};
+bool solid_blocks_waterfalls(const Ent *e) { return e->cls != &DSOLID_OPEN; }
+static void new_dsolid(const EData *d) {
+ Ent *e = ent_new(EAB(d, decalSolid, blockWaterfalls) ? &DSOLID : &DSOLID_OPEN, d->x, d->y);
+ if (!e) return;
+ ent_box(e, EA(d, decalSolid, width), EA(d, decalSolid, height), 0, 0);
+ e->safe = 1;
+ e->depth = -9000; /* (Platform's) */
+ e->visible = 0;
+}
+
static void new_jumpthru(const EData *d) {
int w = (int)EA(d, jumpThru, width);
Ent *e = ent_new(&JUMPTHRU, d->x, d->y);
@@ -1298,6 +1313,7 @@ bool ent_create(const EData *d) {
if (nspawns[slot] < MAX_SPAWNS) spawns[slot][nspawns[slot]++] = v2(d->x, d->y);
return true;
case ET_jumpThru: new_jumpthru(d); return true;
+ case ET_decalSolid: new_dsolid(d); return true;
case ET_spikesUp: new_spikes(d, DIR_UP); return true;
case ET_spikesDown: new_spikes(d, DIR_DOWN); return true;
case ET_spikesLeft: new_spikes(d, DIR_LEFT); return true;
diff --git a/games/celeste/src/gfx.c b/games/celeste/src/gfx.c
index b34c53f9..b4ffe22f 100644
--- a/games/celeste/src/gfx.c
+++ b/games/celeste/src/gfx.c
@@ -22,7 +22,7 @@ static bool letterbox_dirty = true;
static char top_label[24]; /* a line in the top bar (the room's code), redrawn when it changes */
static bool top_dirty;
-enum { OP_TEX, OP_PART, OP_AFFINE, OP_RECT, OP_LINE, OP_PIXEL, OP_CUSTOM, OP_SCALED, OP_MASK, OP_TILES, OP_GRID };
+enum { OP_TEX, OP_PART, OP_AFFINE, OP_RECT, OP_LINE, OP_PIXEL, OP_CUSTOM, OP_SCALED, OP_MASK, OP_TILES, OP_BANNER, OP_GRID };
typedef struct {
uint8_t op, flags, alpha, extra;
@@ -407,6 +407,29 @@ void blit_part_ex(uint16_t *strip, int sy0, int sy1, const Tex *t, int x, int y,
}
}
+/* Decal.Banner: the frame cut in slices of 1 or 2 rows (GetSubtexture), slice i of n moved sideways by
+ * sin(sineTimer * WaveSpeed + i * 0.05) * w * amplitude + w * offset, its weight w = (easeDown ? i / n : 1 - i / n) * wind;
+ * ph: sineTimer * WaveSpeed (a turn in 65536), prm: the kind (0 grass, 1 rags, 2 flowers) | offset < 0 << 2 | wind * 64 << 8 */
+static void blit_banner(uint16_t *strip, int sy0, int sy1, const Tex *t, int x, int y, uint8_t flags, uint16_t tint,
+ uint8_t alpha, uint16_t ph, uint16_t prm) {
+ static const struct { uint8_t slice, ease_down; float amp, off; } K[3] = {{1, 0, 2, -2}, {2, 1, 3.5f, 0}, {1, 0, 2, 2}};
+ int k = prm & 3, slice = K[k].slice, n = (t->fh + slice - 1) / slice, h = t->h, w = t->w;
+ float wind = (prm >> 8) / 64.f, off = (prm & 4) ? -K[k].off : K[k].off, phase = ph * (2 * PI_F / 65536);
+ bool fx = flags & GF_FLIPX, fy = flags & GF_FLIPY;
+ prep(t->pal, tint, alpha, flags);
+ for (int r = sy0 - y > 0 ? sy0 - y : 0; r < h && y + r < sy1; r++) {
+ int src = fy ? h - 1 - r : r, i = (src + t->oy) / slice;
+ float wt = (K[k].ease_down ? (float)i / n : 1 - (float)i / n) * wind;
+ int dx = x + (int)floorf(sinf(phase + i * 0.05f) * wt * K[k].amp + wt * off + 0.5f);
+ uint16_t *row = strip + (y + r - sy0) * VIEW_W;
+ turned_src = NULL, tex_row(t, src, rowbuf);
+ for (int c = 0; c < w; c++) {
+ int X = dx + (fx ? w - 1 - c : c);
+ if ((unsigned)X < VIEW_W && rowbuf[c]) plot(row + X, rowbuf[c]);
+ }
+ }
+}
+
/* t's frame (square, 32 at most) turned q quarter turns clockwise around its center, the frame's top-left at
* strip-relative (x, y) */
void blit_turned(uint16_t *strip, int sy0, int sy1, const Tex *t, int x, int y, int q, uint8_t flags, uint16_t tint) {
@@ -813,6 +836,22 @@ void gfx_tex_ex(uint16_t tex, float x, float y, float ox, float oy, float sx, fl
}
/* a subtexture (frame rect sx, sy, w, h) drawn like MTexture.Draw with an origin (in the part), scale and rotation */
+/* a swaying decal (blit_banner): its frame's top-left at (x, y) */
+void gfx_banner(uint16_t tex, float x, float y, uint8_t flags, uint16_t ph, uint16_t prm) {
+ Tex t;
+ if (!tex_get(tex, &t)) return;
+ if (t.scale > 1) {
+ gfx_tex(tex, x, y, flags, 0xFFFF, 255);
+ return;
+ }
+ int X = sx_(x) + (flags & GF_FLIPX ? t.fw - t.ox - t.w : t.ox);
+ int Y = sy_(y) + (flags & GF_FLIPY ? t.fh - t.oy - t.h : t.oy);
+ if (X - 16 >= VIEW_W || X + t.w + 16 <= 0) return; /* (it sways 12 pixels at most) */
+ Cmd *c = add(OP_BANNER, Y, Y + t.h);
+ if (!c) return;
+ c->tex = tex, c->x = (int16_t)X, c->y = (int16_t)Y, c->flags = flags, c->a = ph, c->b = prm;
+}
+
void 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) {
Tex t;
@@ -1025,6 +1064,9 @@ static void replay(int y0, int y1, int pass) {
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;
+ case OP_BANNER:
+ if (tex_get(c->tex, &t)) blit_banner(g_strip, y0, y1, &t, c->x, c->y, c->flags, c->tint, c->alpha, c->a, c->b);
+ break;
}
}
}
diff --git a/games/celeste/src/level.c b/games/celeste/src/level.c
index 8544020c..8c204b20 100644
--- a/games/celeste/src/level.c
+++ b/games/celeste/src/level.c
@@ -184,6 +184,7 @@ static bool room_load(int slot, int index, int intro) {
rm->need = mem + rd16(mem + 2 * RB_NEED);
memset(rm->spin_gone, 0, (nspin + 7) / 8);
rm->index = index;
+ rm->decal_t = rm->flower_t = rm->smoke_timer = 0, rm->flower_wind = 1, rm->flower_sign = 1;
/* entities and triggers */
int was = g_level.room_slot;
Room *was_room = g_level.room;
diff --git a/games/celeste/src/level.h b/games/celeste/src/level.h
index e463daa6..c307ade7 100644
--- a/games/celeste/src/level.h
+++ b/games/celeste/src/level.h
@@ -61,6 +61,10 @@ typedef struct {
const uint8_t *need; /* the textures loaded with it: u16 n, ids */
uint8_t *mem; /* in the room pool */
uint32_t used;
+ /* its decals' (Decal.Banner, the smoke's ParticleEmitter), since it came: the banners' sineTimer (the flowers' runs
+ * with their WindMultiplier), the smoke's timer, the flowers' Offset sign */
+ float decal_t, flower_t, flower_wind, smoke_timer;
+ int8_t flower_sign;
} Room;
typedef struct {
@@ -316,7 +320,7 @@ bool spinners_hit_rect(float l, float t, float r, float b); /* the hitboxes of
void spinners_destroy_near(float x, float y, float r); /* Reflection's falls and the boss */
/* decals */
-void decals_render(bool fg);
+void decals_render(int layer); /* 0 bg, 1 fg, 2 the Summit's clouds (in front of all) */
/* entities (entities.c) */
void entities_load(Room *r, const uint8_t *blob, int room_slot);
diff --git a/games/celeste/src/tiles.c b/games/celeste/src/tiles.c
index 763f42fe..dbf82e96 100644
--- a/games/celeste/src/tiles.c
+++ b/games/celeste/src/tiles.c
@@ -2,6 +2,7 @@
* converted by tools/pack.py) run on the room's tile types, the visible tiles
* cached between frames, and the tile layers and decals as entities. */
#include "level.h"
+#include "fx.h"
/* ---------------------------------------------------------------- terrain tables */
static const uint8_t *terrain(int t) {
@@ -341,7 +342,9 @@ void tiles_draw(const TileQ *q, char type, int w, int h, float x, float y, uint1
}
/* ---------------------------------------------------------------- decals */
-static int decal_frames(uint16_t tex) {
+/* a decal texture's frames (animated: 12 a second) and its look in Decal.Added (pack.py DECAL_KINDS) */
+enum { DK_NONE, DK_GRASS, DK_RAGS, DK_FLOWER, DK_CHIMNEY, DK_VENT, DK_PARALLAX, DK_CORE };
+static int decal_info(uint16_t tex) {
const uint8_t *s = section(SEC_DECALANIM);
int n = rd16(s), lo = 0, hi = n - 1;
while (lo <= hi) {
@@ -353,8 +356,24 @@ static int decal_frames(uint16_t tex) {
}
return 1;
}
+/* CoreSwapImage: the hot or the cold one, as the level's core mode */
+static uint16_t core_swap(uint16_t tex) {
+#if defined(T_decals_9_core_ball_a) && defined(T_decals_9_core_ball_a_ice) && defined(T_decals_9_core_rock_e) && \
+ defined(T_decals_9_core_rock_e_ice)
+ bool cold = g_level.core_mode == 2;
+ if (tex == T_decals_9_core_ball_a || tex == T_decals_9_core_ball_a_ice) return cold ? T_decals_9_core_ball_a_ice : T_decals_9_core_ball_a;
+ if (tex == T_decals_9_core_rock_e || tex == T_decals_9_core_rock_e_ice) return cold ? T_decals_9_core_rock_e_ice : T_decals_9_core_rock_e;
+#endif
+ return tex;
+}
+/* a decal's own random sineTimer start (Calc.Random.NextFloat) */
+static float decal_phase(const Room *rm, int i) {
+ uint32_t h = ((uint32_t)i + 1) * 2654435761u ^ (uint32_t)rm->index * 40503u;
+ return (h >> 8 & 0xFFFF) / 65536.f;
+}
-void decals_render(bool fg) {
+/* layer: 0 the bg decals, 1 the fg ones, 2 the Summit's clouds (Depth -13001, in front of all), both layers' */
+static void decals_layer(int layer, bool fg) {
for (int s = 0; s < 2; s++) {
Room *rm = &g_level.rooms[s];
if (rm->index < 0) continue;
@@ -365,18 +384,68 @@ void decals_render(bool fg) {
uint8_t v = vs[i];
uint16_t tex = rd16(ids + 2 * (v & 63));
float x = rm->x + (float)rds16(xs + 2 * i), y = rm->y + (float)rds16(ys + 2 * i);
- int frames = decal_frames(tex);
+ int info = decal_info(tex), frames = info & 0xFF, kind = info >> 8;
+ if ((kind == DK_PARALLAX) != (layer == 2)) continue;
if (frames > 1) tex = (uint16_t)(tex + (int)(anim_time * 12) % frames);
- /* cull by the frame's size (TEXDIM), before loading it */
- float r = (float)tex_half_extent(tex);
+ if (kind == DK_CORE) tex = core_swap(tex);
+ if (kind == DK_PARALLAX) { /* MakeParallax(0.1): away from the view's middle */
+ x += (x - (g_level.cam.x + 160)) * 0.1f;
+ y += (y - (g_level.cam.y + 90)) * 0.1f;
+ }
+ /* cull by the frame's size (TEXDIM), before loading it (a banner sways 12 pixels at most) */
+ float r = (float)tex_half_extent(tex) + (kind >= DK_GRASS && kind <= DK_FLOWER ? 12 : 0);
if (x + r < g_camx || x - r > g_camx + 320 || y + r < g_camy || y - r > g_camy + 180) continue;
Tex t;
if (!tex_get(tex, &t)) continue;
float hw = t.fw * t.scale / 2.f, hh = t.fh * t.scale / 2.f;
- gfx_tex_ex(tex, x, y, hw, hh, (v & 0x40) ? -1.f : 1.f, (v & 0x80) ? -1.f : 1.f, 0, 0xFFFF, 255, 0);
+ if (kind >= DK_GRASS && kind <= DK_FLOWER) {
+ bool flower = kind == DK_FLOWER;
+ float wind = flower ? rm->flower_wind : 1, timer = decal_phase(rm, i) + (flower ? rm->flower_t : rm->decal_t);
+ uint16_t ph = (uint16_t)(int)(fmodf(timer * 2, 2 * PI_F) * (65536 / (2 * PI_F))); /* WaveSpeed 2 */
+ uint16_t prm = (uint16_t)((kind - DK_GRASS) | (flower && rm->flower_sign < 0 ? 4 : 0) | (int)(wind * 64 + 0.5f) << 8);
+ gfx_banner(tex, x - hw, y - hh, (v & 0x40 ? GF_FLIPX : 0) | (v & 0x80 ? GF_FLIPY : 0), ph, prm);
+ } else
+ gfx_tex_ex(tex, x, y, hw, hh, (v & 0x40) ? -1.f : 1.f, (v & 0x80) ? -1.f : 1.f, 0, 0xFFFF, 255, 0);
}
}
}
+void decals_render(int layer) {
+ if (layer < 2) decals_layer(layer, layer == 1);
+ else if (g_session.area == 7) decals_layer(2, true), decals_layer(2, false); /* (Level.LoadLevel adds the fg decals first) */
+}
+
+/* CreateSmoke: a ParticleEmitter of Chimney smoke (1 every 0.2 s, range (4, 1), up) at the chimney (house: (36, -28), in the
+ * bg particles) or the vent (in the fg); only near the view (the particles are few); not pre-warmed (SimulateCycle) */
+static void decals_smoke(const Room *rm) {
+ for (int l = 0; l < 2; l++) {
+ int n = l ? rm->nbg : rm->nfg;
+ const uint8_t *tab = l ? rm->decals_bg : rm->decals_fg;
+ const uint8_t *ids = tab + 2, *xs = ids + 2 * tab[0], *ys = xs + 2 * n, *vs = ys + 2 * n;
+ for (int i = 0; i < n; i++) {
+ int kind = decal_info(rd16(ids + 2 * (vs[i] & 63))) >> 8;
+ if (kind != DK_CHIMNEY && kind != DK_VENT) continue;
+ float x = rm->x + (float)rds16(xs + 2 * i) + (kind == DK_CHIMNEY ? 36 : 0);
+ float y = rm->y + (float)rds16(ys + 2 * i) + (kind == DK_CHIMNEY ? -28 : 0);
+ float cx = g_level.cam.x, cy = g_level.cam.y; /* (it rises up to 48 pixels and drifts left) */
+ if (x < cx - 32 || x > cx + 360 || y < cy - 16 || y > cy + 228) continue;
+ particles_emit(kind == DK_CHIMNEY ? PL_BG : PL_FG, &P_Chimney, 1, v2(x, y), v2(4, 1), -PI_F / 2);
+ }
+ }
+}
+/* the decals' Update (Decal, Banner, ParticleEmitter): not between rooms */
+static void decals_update(void) {
+ if (g_level.transitioning) return;
+ for (int s = 0; s < 2; s++) {
+ Room *rm = &g_level.rooms[s];
+ if (rm->index < 0) continue;
+ rm->decal_t += DT;
+ float wx = g_level.wind.x; /* OnlyIfWindy: WindMultiplier toward min(3, |Wind.X| * 0.004), Offset's sign Wind.X's */
+ rm->flower_wind = approach(rm->flower_wind, fminf(3, fabsf(wx) * 0.004f), DT * 4);
+ if (wx != 0) rm->flower_sign = wx > 0 ? 1 : -1;
+ rm->flower_t += DT * rm->flower_wind;
+ if ((rm->smoke_timer -= DT) <= 0) rm->smoke_timer = 0.2f, decals_smoke(rm);
+ }
+}
/* ---------------------------------------------------------------- the layers as entities */
static void bg_render(Ent *e) { (void)e; tiles_render_layer(1, D_BGTERRAIN); }
@@ -384,14 +453,20 @@ static void fg_render(Ent *e) {
(void)e;
tiles_render_layer(0, D_FGTERRAIN);
}
-static void fgdecal_render(Ent *e) { (void)e; decals_render(true); }
-static void bgdecal_render(Ent *e) { (void)e; decals_render(false); }
-static void timer_update(Ent *e) { (void)e; anim_time += DT; }
+static void fgdecal_render(Ent *e) { (void)e; decals_render(1); }
+static void bgdecal_render(Ent *e) { (void)e; decals_render(0); }
+static void frontdecal_render(Ent *e) { (void)e; decals_render(2); }
+static void timer_update(Ent *e) {
+ (void)e;
+ anim_time += DT;
+ decals_update();
+}
static const EntClass BGTILES = {.size = 0, .name = "bgtiles", .render = bg_render, .update = timer_update};
static const EntClass SOLIDTILES = {.size = 0, .name = "solidtiles", .render = fg_render, .kind = KIND_SOLID};
static const EntClass FGDECALS = {.size = 0, .name = "fgdecals", .render = fgdecal_render};
static const EntClass BGDECALS = {.size = 0, .name = "bgdecals", .render = bgdecal_render};
+static const EntClass FRONTDECALS = {.size = 0, .name = "frontdecals", .render = frontdecal_render};
void level_tiles_entities(void) {
Ent *e = ent_new(&BGTILES, 0, 0);
@@ -405,4 +480,6 @@ void level_tiles_entities(void) {
g_solidtiles = e;
e = ent_new(&FGDECALS, 0, 0);
e->depth = D_FGDECALS, e->tags = TAG_GLOBAL, e->dead = 0, e->collidable = 0;
+ e = ent_new(&FRONTDECALS, 0, 0);
+ e->depth = -13001, e->tags = TAG_GLOBAL, e->dead = 0, e->collidable = 0;
}
diff --git a/games/celeste/tools/pack.py b/games/celeste/tools/pack.py
index 8de21e2e..63578004 100644
--- a/games/celeste/tools/pack.py
+++ b/games/celeste/tools/pack.py
@@ -20,7 +20,7 @@ import xml.etree.ElementTree as ET
import numpy as np
sys.path.insert(0, os.path.dirname(__file__))
-from cel import CELESTE, Atlas, read_map # noqa: E402
+from cel import CELESTE, Atlas, Element, read_map # noqa: E402
import tiles as T # noqa: E402
import entities as E # noqa: E402
@@ -681,11 +681,119 @@ def ent_type(name, table):
return table[name]
+def decal_name(texture):
+ """Decal.Name without "decals/", lower case (the switch in Decal.Added): no extension, no trailing digits."""
+ t = texture.replace("\\", "/")
+ if "." in t.rsplit("/", 1)[-1]:
+ t = t[:t.rfind(".")]
+ return re.sub(r"\d+$", "", t).lower()
+
+
+# Decal.Added's looks (src/tiles.c, by the decal's first texture, in DECALANIM): 1-3 Banners (MakeBanner: grass; rags and
+# curtains; cliffside flowers, only if windy), 4-5 smoke (CreateSmoke: a chimney in the bg particles; a vent in the fg),
+# 6 MakeParallax(0.1) (the Summit's clouds), 7 CoreSwapImage
+DECAL_KINDS = {n: 1 for n in ("generic/grass_a", "generic/grass_b", "generic/grass_c", "generic/grass_d")}
+DECAL_KINDS.update({n: 2 for n in ("1-forsakencity/rags", "1-forsakencity/ragsb", "3-resort/curtain_side_a",
+ "3-resort/curtain_side_d")})
+DECAL_KINDS.update({"4-cliffside/flower_" + c: 3 for c in "abcd"})
+DECAL_KINDS.update({"0-prologue/house": 4, "3-resort/vent": 5})
+DECAL_KINDS.update({"7-summit/cloud_" + c: 6 for c in ("a", "b", "bb", "bc", "bd", "c", "cb", "cc", "cd", "ce", "d", "db", "dc",
+ "dd", "e", "f", "g", "h", "j", "i")})
+DECAL_KINDS.update({n: 7 for n in ("9-core/ball_a", "9-core/ball_a_ice", "9-core/rock_e", "9-core/rock_e_ice")})
+DECAL_CORE_SWAP = {"9-core/ball_a": "9-core/ball_a_ice", "9-core/ball_a_ice": "9-core/ball_a",
+ "9-core/rock_e": "9-core/rock_e_ice", "9-core/rock_e_ice": "9-core/rock_e"}
+DECAL_NOFLIP = {"9-core/heart_bevel_a", "9-core/heart_bevel_b", "9-core/heart_bevel_c", "9-core/heart_bevel_d"} # scale = 1
+# MakeMirror's: Depth 9500, behind the other bg decals (their reflections of Madeline are not drawn); the first 20 also
+# get scale.Y = 1
+DECAL_MIRROR_NOFLIPY = {"5-temple/bg_mirror_" + n for n in ["a", "b"] + ["shard_" + c for c in "abcdefghijk"] +
+ ["shard_group_" + g for g in ("a", "a_b", "a_c", "b", "c", "d", "e")]}
+DECAL_MIRROR = DECAL_MIRROR_NOFLIPY | {"5-temple/bg_mirror_c", "5-temple/statue_d", "6-reflection/crystal_reflection"}
+
+
+def decal_scaled(ids, k):
+ """The frames of a decal drawn k times bigger about its middle (the Summit's clouds: scale *= 1.15), as textures of
+ their own, the nearest pixels (point sampling)."""
+ out = []
+ for tid in ids:
+ name = TEX.list[tid].path + "@%g" % k
+ if name not in TEX.by_path:
+ img = TEX.list[tid].sub.image()
+ fh, fw = img.shape[:2]
+ W, H = int(round(fw * k)), int(round(fh * k))
+ xs = np.clip(np.floor((np.arange(W) + 0.5 - W / 2) / k + fw / 2).astype(int), 0, fw - 1)
+ ys = np.clip(np.floor((np.arange(H) + 0.5 - H / 2) / k + fh / 2).astype(int), 0, fh - 1)
+ big = img[ys][:, xs]
+ yy, xx = np.nonzero(big[..., 3])
+ y0, y1, x0, x1 = yy.min(), yy.max() + 1, xx.min(), xx.max() + 1
+ t = Tex(len(TEX.list), name, HudSub(name, big[y0:y1, x0:x1], -int(x0), -int(y0), W, H))
+ TEX.list.append(t)
+ TEX.by_path[name] = t.id
+ out.append(TEX.by_path[name])
+ return out
+
+
+# Decal.Added: the decals that are solid (MakeSolid: Position + (x, y), w x h, safe), by name: rects, and whether a
+# fg one blocks waterfalls (a bg one never does: Depth 9000)
+def _roofedge(sx):
+ return [(-8 if sx >= 0 else 0, -4, 8, 8)]
+
+
+DECAL_SOLIDS = dict([(n, lambda sx: [(-8, -4, 16, 8)]) for n in ("roofcenter", "roofcenter_b", "roofcenter_c", "roofcenter_d")] +
+ [(n, _roofedge) for n in ("roofedge", "roofedge_b", "roofedge_c", "roofedge_d")] +
+ [("bridgecolumntop", lambda sx: [(-8, -8, 16, 8), (-5, 0, 10, 8)]),
+ ("bridgecolumn", lambda sx: [(-5, -8, 10, 16)]),
+ ("brokenelevator", lambda sx: [(-16, -20, 32, 48)])])
+DECAL_SOLIDS = {"3-resort/" + k: v for k, v in DECAL_SOLIDS.items()}
+DECAL_SOLIDS["4-cliffside/bridge_a"] = lambda sx: [(-24, 0, 48, 8)]
+
+
+def decal_solids(level):
+ """The room's solid decals as "decalSolid" entities (x, y: top left; width, height; blockWaterfalls). Pieces side by
+ side, or one on top of the other, of the same kind make one solid: the same to collide with, fewer entities."""
+ rects = []
+ for layer in ("fgdecals", "bgdecals"):
+ el = level.child(layer)
+ for d in (el.children if el else []):
+ f = DECAL_SOLIDS.get(decal_name(d["texture"]))
+ if f:
+ blocks = layer == "fgdecals" or decal_name(d["texture"]) != "4-cliffside/bridge_a" # (Depth != 9000)
+ for x, y, w, h in f(d.get("scaleX", 1)):
+ rects.append([d["x"] + x, d["y"] + y, w, h, blocks])
+ for horizontal in (True, False):
+ merged = True
+ while merged:
+ merged = False
+ for a in rects:
+ for b in rects:
+ if a is b or a[4] != b[4]:
+ continue
+ if horizontal and a[1] == b[1] and a[3] == b[3] and a[0] + a[2] == b[0]:
+ a[2] += b[2]
+ elif not horizontal and a[0] == b[0] and a[2] == b[2] and a[1] + a[3] == b[1]:
+ a[3] += b[3]
+ else:
+ continue
+ rects.remove(b)
+ merged = True
+ break
+ if merged:
+ break
+ out = []
+ for x, y, w, h, fg in rects:
+ assert x == int(x) and y == int(y), (x, y)
+ e = Element("decalSolid")
+ e.attr.update({"x": int(x), "y": int(y), "width": int(w), "height": int(h), "blockWaterfalls": fg})
+ out.append(e)
+ return out
+
+
def decal_tex(path):
p = "decals/" + path.replace("\\", "/")
if p.endswith(".png"):
p = p[:-4]
- ids = TEX.family(p)
+ # Decal(): its Name has no trailing digits, and GetAtlasSubtextures(Name) its frames ("clock00" plays all of them);
+ # not Reflection's hidden game screens (secret_*: 6 to 50 frames each), for room
+ ids = (not p.startswith("decals/6-reflection/secret_") and TEX.family(re.sub(r"\d+$", "", p))) or TEX.family(p)
if not ids:
print("missing decal", p)
return ids
@@ -896,12 +1004,23 @@ def room_blob(ch, r):
ids = decal_tex(d["texture"])
if not ids:
continue
- if len(ids) > 1:
- DECAL_ANIMS[ids[0]] = len(ids)
+ name = decal_name(d["texture"])
+ kind = DECAL_KINDS.get(name, 0)
+ if kind == 6:
+ ids = decal_scaled(ids, 1.15)
+ if len(ids) > 1 or kind:
+ DECAL_ANIMS[ids[0]] = len(ids) | kind << 8
if ids[0] not in texs:
texs.append(ids[0])
fl = (1 << 6 if d.get("scaleX", 1) < 0 else 0) | (1 << 7 if d.get("scaleY", 1) < 0 else 0)
- recs.append((texs.index(ids[0]) | fl, int(round(d["x"])), int(round(d["y"]))))
+ if name in DECAL_NOFLIP:
+ fl = 0
+ if name in DECAL_MIRROR_NOFLIPY:
+ fl &= ~(1 << 7)
+ assert not (name in DECAL_MIRROR and layer == "fgdecals"), (r.name, name)
+ recs.append((texs.index(ids[0]) | fl, int(round(d["x"])), int(round(d["y"])), name in DECAL_MIRROR))
+ recs.sort(key=lambda rec: not rec[3]) # (stable: the mirrors' Depth 9500 first, then the 9000s in order)
+ recs = [rec[:3] for rec in recs]
assert len(texs) <= 64, (ch.name, r.name, layer, len(texs))
w.u16(len(recs))
w.u8(len(texs))
@@ -930,6 +1049,7 @@ def room_blob(ch, r):
resident = len(w) + ((nspin + 7) // 8 + 3 & ~3) # and a bit per spinner, once destroyed
ents = r.e.child("entities").children if r.e.child("entities") else []
ents = [e for e in ents if E.keep(e.name) and not (e.name == "spinner" and not e.get("attachToSolid", False))]
+ ents += decal_solids(r.e) # (the decals come after the entities, as Level.LoadLevel adds them)
w.u16(len(ents))
for e in ents:
write_entity(w, e, ent_type(e.name, ENT_IDS))
@@ -1525,6 +1645,9 @@ def main():
for m in ALL_MAPS:
_, root = read_map(os.path.join(CELESTE, "Maps", m + ".bin"))
for l in root.child("levels").children:
+ for e in decal_solids(l):
+ SCHEMA.see(e)
+ ent_type(e.name, ENT_IDS)
for k, table, keep in (("entities", ENT_IDS, E.keep), ("triggers", TRIG_IDS, E.keep_trigger)):
if l.child(k):
for e in l.child(k).children:
@@ -1625,7 +1748,11 @@ def main():
need.append(TEX(fgsets[c].path))
for layer in ("fgdecals", "bgdecals"):
for d in (r.e.child(layer).children if r.e.child(layer) else []):
- need += decal_tex(d["texture"])
+ ids = decal_tex(d["texture"])
+ need += decal_scaled(ids, 1.15) if DECAL_KINDS.get(decal_name(d["texture"])) == 6 else ids
+ other = DECAL_CORE_SWAP.get(decal_name(d["texture"]))
+ if other:
+ need += decal_tex(other)
r.style_mask = 0
for i, (name, a) in enumerate(ch.bgs + ch.fgs):
vis = True