8namespace draw_routines {
13 if (ctx.
tiles.size() < 6) {
20 const int body_count = (ctx.
object.
size_ & 0x0F) + 10;
21 const int edge_x = ctx.
object.
x_ + (edge_is_left ? 0 : 1);
22 const int fill_x = ctx.
object.
x_ + (edge_is_left ? 1 : 0);
33 for (
int i = 0; i < body_count; ++i, ++y) {
53 for (
int s = 0; s < size; s++) {
54 if (ctx.
tiles.size() >= 4) {
84 for (
int s = 0; s < size; s++) {
85 if (ctx.
tiles.size() >= 8) {
105 }
else if (ctx.
tiles.size() >= 4) {
124 if (ctx.
tiles.size() < 8) {
128 for (
int s = 0; s < count; ++s) {
129 const int y = ctx.
object.
y_ + (s * 2);
155 int count = size + 1;
157 for (
int s = 0; s < count; s++) {
158 if (ctx.
tiles.size() >= 8) {
161 const int base_y = ctx.
object.
y_ + (s * 6);
187 int count = size + 1;
189 for (
int s = 0; s < count; s++) {
190 if (ctx.
tiles.size() >= 4) {
222 int count = size + 2;
224 if (ctx.
tiles.size() < 3)
235 for (
int s = 0; s < count; s++) {
247 int count = size + 1;
249 for (
int s = 0; s < count; s++) {
250 if (ctx.
tiles.size() >= 1) {
259 DrawDownwardsCorners2x1(ctx,
true);
263 DrawDownwardsCorners2x1(ctx,
false);
268 const int count = size + 1;
269 if (ctx.
tiles.size() < 16) {
273 for (
int s = 0; s < count; ++s) {
274 const int base_y = ctx.
object.
y_ + (s * 4);
275 for (
int x = 0; x < 4; ++x) {
276 for (
int y = 0; y < 4; ++y) {
278 base_y + y, ctx.
tiles[x * 4 + y]);
286 const int count = size + 4;
287 if (ctx.
tiles.empty()) {
291 for (
int s = 0; s < count; ++s) {
299 const int count = size + 1;
300 if (ctx.
tiles.size() < 16) {
304 for (
int s = 0; s < count; ++s) {
305 const int base_y = ctx.
object.
y_ + (s * 6);
306 for (
int x = 0; x < 4; ++x) {
307 for (
int y = 0; y < 4; ++y) {
309 base_y + y, ctx.
tiles[x * 4 + y]);
317 const int count = size + 1;
318 if (ctx.
tiles.size() < 8) {
322 for (
int s = 0; s < count; ++s) {
323 const int base_y = ctx.
object.
y_ + (s * 6);
324 for (
int x = 0; x < 2; ++x) {
325 for (
int y = 0; y < 4; ++y) {
327 base_y + y, ctx.
tiles[x * 4 + y]);
335 const int count = size + 1;
336 if (ctx.
tiles.size() < 12) {
340 for (
int s = 0; s < count; ++s) {
341 const int base_y = ctx.
object.
y_ + (s * 8);
342 for (
int x = 0; x < 3; ++x) {
343 for (
int y = 0; y < 4; ++y) {
345 base_y + y, ctx.
tiles[x * 4 + y]);
353 const int count = size + 1;
354 if (ctx.
tiles.size() < 4) {
358 for (
int s = 0; s < count; ++s) {
359 const int base_y = ctx.
object.
y_ + (s * 14);
373 const int count = size + 2;
374 if (ctx.
tiles.empty()) {
378 for (
int s = 0; s < count; ++s) {
386 const int count = size + 1;
387 if (ctx.
tiles.size() < 8) {
391 for (
int s = 0; s < count; ++s) {
392 const int base_y = ctx.
object.
y_ + (s * 12);
393 for (
int x = 0; x < 2; ++x) {
394 for (
int y = 0; y < 4; ++y) {
396 base_y + y, ctx.
tiles[x * 4 + y]);
404 const int count = size + 1;
405 if (ctx.
tiles.size() < 12) {
409 for (
int s = 0; s < count; ++s) {
410 const int base_y = ctx.
object.
y_ + (s * 6);
411 for (
int x = 0; x < 3; ++x) {
412 for (
int y = 0; y < 4; ++y) {
414 base_y + y, ctx.
tiles[x * 4 + y]);
422 const int middle_rows = size + 1;
423 const int total_rows = size + 6;
425 if (ctx.
tiles.size() >= 12) {
440 for (
int row = 0; row < middle_rows; ++row) {
442 base_y + row, ctx.
tiles[4]);
444 base_y + row, ctx.
tiles[5]);
447 const int cap_y = base_y + middle_rows;
463 if (ctx.
tiles.empty() || total_rows <= 0) {
469 for (
int row = 0; row < total_rows; ++row) {
479 const int count = size + 1;
480 if (ctx.
tiles.size() < 4) {
484 for (
int s = 0; s < count; ++s) {
485 const int base_y = ctx.
object.
y_ + (s * 4);
502 if (ctx.
tiles.size() < 18) {
506 auto draw_segment = [&](
int segment,
int first) {
507 for (
int y = 0; y < 2; ++y) {
508 for (
int x = 0; x < 3; ++x) {
511 ctx.
tiles[first + y * 3 + x]);
516 for (
int s = 1; s < count; ++s) {
519 draw_segment(count, 12);
524 const int middle_rows = (size + 2) * 2;
525 if (ctx.
tiles.size() < 4) {
536 for (
int row = 0; row < middle_rows; ++row) {
546 const int count = size + 1;
547 if (ctx.
tiles.size() < 4) {
551 for (
int s = 0; s < count; ++s) {
552 const int base_y = ctx.
object.
y_ + (s * 2);
570 if (ctx.
tiles.empty()) {
574 for (
int row = 0; row < count; ++row) {
585 .name =
"Downwards2x2_1to15or32",
587 .draws_to_both_bgs =
false,
591 .category = Category::Downwards});
595 .name =
"Downwards4x2_1to15or26",
600 .draws_to_both_bgs =
false,
604 .category = Category::Downwards});
608 .name =
"Downwards4x2_1to16_BothBG",
610 .draws_to_both_bgs =
true,
614 .category = Category::Downwards});
618 .name =
"DownwardsDecor4x2spaced4_1to16",
620 .draws_to_both_bgs =
false,
624 .category = Category::Downwards});
627 .name =
"Downwards2x2_1to16",
629 .draws_to_both_bgs =
false,
633 .category = Category::Downwards});
637 .name =
"DownwardsHasEdge1x1_1to16_plus3",
639 .draws_to_both_bgs =
false,
646 .category = Category::Downwards});
650 .name =
"DownwardsEdge1x1_1to16",
652 .draws_to_both_bgs =
false,
656 .category = Category::Downwards});
660 .name =
"DownwardsLeftCorners2x1_1to16_plus12",
662 .draws_to_both_bgs =
false,
666 .category = Category::Downwards});
670 .name =
"DownwardsRightCorners2x1_1to16_plus12",
672 .draws_to_both_bgs =
false,
676 .category = Category::Downwards});
680 .name =
"DownwardsFloor4x4_1to16",
682 .draws_to_both_bgs =
false,
686 .category = Category::Downwards});
690 .name =
"Downwards1x1Solid_1to16_plus3",
692 .draws_to_both_bgs =
false,
696 .category = Category::Downwards});
700 .name =
"DownwardsDecor4x4spaced2_1to16",
702 .draws_to_both_bgs =
false,
706 .category = Category::Downwards});
710 .name =
"DownwardsPillar2x4spaced2_1to16",
712 .draws_to_both_bgs =
false,
716 .category = Category::Downwards});
720 .name =
"DownwardsDecor3x4spaced4_1to16",
722 .draws_to_both_bgs =
false,
726 .category = Category::Downwards});
730 .name =
"DownwardsDecor2x2spaced12_1to16",
732 .draws_to_both_bgs =
false,
736 .category = Category::Downwards});
740 .name =
"DownwardsLine1x1_1to16plus1",
742 .draws_to_both_bgs =
false,
746 .category = Category::Downwards});
750 .name =
"DownwardsDecor2x4spaced8_1to16",
752 .draws_to_both_bgs =
false,
756 .category = Category::Downwards});
760 .name =
"DownwardsDecor3x4spaced2_1to16",
762 .draws_to_both_bgs =
false,
766 .category = Category::Downwards});
770 .name =
"DownwardsBigRail3x1_1to16plus5",
772 .draws_to_both_bgs =
false,
776 .category = Category::Downwards});
780 .name =
"DownwardsBlock2x2spaced2_1to16",
782 .draws_to_both_bgs =
false,
786 .category = Category::Downwards});
790 .name =
"DownwardsCannonHole3x4_1to16",
792 .draws_to_both_bgs =
false,
796 .category = Category::Downwards});
800 .name =
"DownwardsBar2x5_1to16",
802 .draws_to_both_bgs =
false,
806 .category = Category::Downwards});
810 .name =
"DownwardsPots2x2_1to16",
812 .draws_to_both_bgs =
false,
816 .category = Category::Downwards});
820 .name =
"DownwardsHammerPegs2x2_1to16",
822 .draws_to_both_bgs =
false,
826 .category = Category::Downwards});
830 .name =
"DownwardsEdge1x1_1to16plus7",
832 .draws_to_both_bgs =
false,
836 .category = Category::Downwards});
SNES 16-bit tile metadata container.
constexpr int kDownwardsBigRail3x1_1to16plus5
constexpr int kDownwardsBlock2x2spaced2_1to16
constexpr int kDownwardsDecor3x4spaced4_1to16
constexpr int kDownwardsCannonHole3x4_1to16
constexpr int kDownwardsDecor2x4spaced8_1to16
constexpr int kDownwardsDecor3x4spaced2_1to16
constexpr int kDownwardsEdge1x1_1to16plus7
constexpr int kDownwardsPillar2x4spaced2_1to16
constexpr int kDownwardsFloor4x4_1to16
constexpr int kDownwardsDecor2x2spaced12_1to16
constexpr int kDownwards1x1Solid_1to16_plus3
constexpr int kDownwardsDecor4x4spaced2_1to16
constexpr int kDownwardsHammerPegs2x2_1to16
constexpr int kDownwardsLine1x1_1to16plus1
constexpr int kDownwardsPots2x2_1to16
constexpr int kDownwardsBar2x5_1to16
bool ExistingTileMatchesAny(const gfx::BackgroundBuffer &bg, int tile_x, int tile_y, std::initializer_list< uint16_t > tile_ids)
void WriteTile8(gfx::BackgroundBuffer &bg, int tile_x, int tile_y, const gfx::TileInfo &tile_info)
Write an 8x8 tile to the background buffer.
void DrawDownwardsCorners2x1(const DrawContext &ctx, bool edge_is_left)
void DrawDownwards1x1Solid_1to16_plus3(const DrawContext &ctx)
Draw downwards 1x1 solid line with +3 extension.
void DrawDownwardsDecor2x4spaced8_1to16(const DrawContext &ctx)
Draw downwards 2x4 decoration with 8-tile spacing.
void DrawDownwards4x2_1to15or26(const DrawContext &ctx)
Draw 4x2 tiles downward pattern (1-15 or 26 iterations)
void DrawDownwardsEdge1x1_1to16(const DrawContext &ctx)
Draw 1x1 edge tiles downward (1-16 iterations)
void DrawDownwardsBar2x5_1to16(const DrawContext &ctx)
Draw downwards 2x5 bar pattern.
void DrawDownwardsDecor2x2spaced12_1to16(const DrawContext &ctx)
Draw downwards 2x2 decoration with 12-tile spacing.
void DrawDownwards2x2_1to15or32(const DrawContext &ctx)
Draw 2x2 tiles downward pattern (1-15 or 32 iterations)
void DrawDownwards2x2_1to16(const DrawContext &ctx)
Draw 2x2 tiles downward pattern (1-16 iterations)
void RegisterDownwardsRoutines(std::vector< DrawRoutineInfo > ®istry)
Register all downwards draw routines to the registry.
void DrawDownwardsDecor4x4spaced2_1to16(const DrawContext &ctx)
Draw downwards 4x4 decoration with 2-tile spacing.
void DrawDownwardsEdge1x1_1to16plus7(const DrawContext &ctx)
Draw a single tile downward for size + 8 rows.
void DrawDownwardsHasEdge1x1_1to16_plus3(const DrawContext &ctx)
Draw 1x1 tiles with edge detection +3 downward.
void DrawDownwardsLine1x1_1to16plus1(const DrawContext &ctx)
Draw downwards 1x1 line with +1 extension.
void DrawDownwardsCannonHole3x4_1to16(const DrawContext &ctx)
Draw downwards cannon-hole 3x4 pattern.
void DrawDownwardsLeftCorners2x1_1to16_plus12(const DrawContext &ctx)
Draw left corner 2x1 tiles with opening and closing caps.
void DrawDownwardsPots2x2_1to16(const DrawContext &ctx)
Draw downwards 2x2 pots pattern.
void DrawDownwardsBlock2x2spaced2_1to16(const DrawContext &ctx)
Draw downwards 2x2 block pattern with 2-tile spacing.
void DrawDownwardsBigRail3x1_1to16plus5(const DrawContext &ctx)
Draw downwards big rail pattern (3x1 family, +5 extension)
void DrawDownwardsFloor4x4_1to16(const DrawContext &ctx)
Draw downwards 4x4 floor blocks.
void DrawDownwardsRightCorners2x1_1to16_plus12(const DrawContext &ctx)
Draw right corner 2x1 tiles with opening and closing caps.
void DrawDownwardsHammerPegs2x2_1to16(const DrawContext &ctx)
Draw downwards 2x2 hammer pegs pattern.
void DrawDownwardsDecor4x2spaced4_1to16(const DrawContext &ctx)
Draw 4x2 decoration downward with spacing (1-16 iterations)
void DrawDownwardsPillar2x4spaced2_1to16(const DrawContext &ctx)
Draw downwards 2x4 pillar with 2-tile spacing.
void DrawDownwardsDecor3x4spaced2_1to16(const DrawContext &ctx)
Draw downwards 3x4 decoration with 2-tile spacing.
void DrawDownwardsDecor3x4spaced4_1to16(const DrawContext &ctx)
Draw downwards 3x4 decoration with 4-tile spacing.
void DrawDownwards4x2_1to16_BothBG(const DrawContext &ctx)
Draw 4x2 tiles downward pattern for both BG layers.
Context passed to draw routines containing all necessary state.
std::span< const gfx::TileInfo > tiles
gfx::BackgroundBuffer & target_bg
const RoomObject & object
Metadata about a draw routine.