8namespace draw_routines {
17 for (
int s = 0; s < size; s++) {
18 if (ctx.
tiles.size() >= 4) {
48 for (
int s = 0; s < size; s++) {
49 if (ctx.
tiles.size() >= 8) {
69 }
else if (ctx.
tiles.size() >= 4) {
98 for (
int s = 0; s < count; s++) {
99 if (ctx.
tiles.size() >= 8) {
102 const int base_y = ctx.
object.
y_ + (s * 6);
128 int count = size + 1;
130 for (
int s = 0; s < count; s++) {
131 if (ctx.
tiles.size() >= 4) {
163 int count = size + 2;
165 if (ctx.
tiles.size() < 3)
176 for (
int s = 0; s < count; s++) {
188 int count = size + 1;
190 for (
int s = 0; s < count; s++) {
191 if (ctx.
tiles.size() >= 1) {
203 const int count = size + 10;
204 if (count <= 0 || ctx.
tiles.empty()) {
208 const int base_x = ctx.
object.
x_ + 12;
218 ctx.
tiles.size() > 4 ? ctx.
tiles[4] : body_left;
223 current_y, {0x00E3})) {
234 for (
int s = 0; s < count; ++s) {
253 const int count = size + 10;
254 if (count <= 0 || ctx.
tiles.empty()) {
258 const int base_x = ctx.
object.
x_ + 12;
268 ctx.
tiles.size() > 4 ? ctx.
tiles[4] : body_right;
273 current_y, {0x00E3})) {
283 for (
int s = 0; s < count; ++s) {
300 const int count = size + 1;
301 if (ctx.
tiles.size() < 16) {
305 for (
int s = 0; s < count; ++s) {
306 const int base_y = ctx.
object.
y_ + (s * 4);
307 for (
int x = 0; x < 4; ++x) {
308 for (
int y = 0; y < 4; ++y) {
310 base_y + y, ctx.
tiles[x * 4 + y]);
318 const int count = size + 4;
319 if (ctx.
tiles.empty()) {
323 for (
int s = 0; s < count; ++s) {
331 const int count = size + 1;
332 if (ctx.
tiles.size() < 16) {
336 for (
int s = 0; s < count; ++s) {
337 const int base_y = ctx.
object.
y_ + (s * 6);
338 for (
int x = 0; x < 4; ++x) {
339 for (
int y = 0; y < 4; ++y) {
341 base_y + y, ctx.
tiles[x * 4 + y]);
349 const int count = size + 1;
350 if (ctx.
tiles.size() < 8) {
354 for (
int s = 0; s < count; ++s) {
355 const int base_y = ctx.
object.
y_ + (s * 6);
356 for (
int x = 0; x < 2; ++x) {
357 for (
int y = 0; y < 4; ++y) {
359 base_y + y, ctx.
tiles[x * 4 + y]);
367 const int count = size + 1;
368 if (ctx.
tiles.size() < 12) {
372 for (
int s = 0; s < count; ++s) {
373 const int base_y = ctx.
object.
y_ + (s * 8);
374 for (
int x = 0; x < 3; ++x) {
375 for (
int y = 0; y < 4; ++y) {
377 base_y + y, ctx.
tiles[x * 4 + y]);
385 const int count = size + 1;
386 if (ctx.
tiles.size() < 4) {
390 for (
int s = 0; s < count; ++s) {
391 const int base_y = ctx.
object.
y_ + (s * 14);
405 const int count = size + 2;
406 if (ctx.
tiles.empty()) {
410 for (
int s = 0; s < count; ++s) {
418 const int count = size + 1;
419 if (ctx.
tiles.size() < 8) {
423 for (
int s = 0; s < count; ++s) {
424 const int base_y = ctx.
object.
y_ + (s * 12);
425 for (
int x = 0; x < 2; ++x) {
426 for (
int y = 0; y < 4; ++y) {
428 base_y + y, ctx.
tiles[x * 4 + y]);
436 const int count = size + 1;
437 if (ctx.
tiles.size() < 12) {
441 for (
int s = 0; s < count; ++s) {
442 const int base_y = ctx.
object.
y_ + (s * 6);
443 for (
int x = 0; x < 3; ++x) {
444 for (
int y = 0; y < 4; ++y) {
446 base_y + y, ctx.
tiles[x * 4 + y]);
454 const int middle_rows = size + 1;
455 const int total_rows = size + 6;
457 if (ctx.
tiles.size() >= 12) {
472 for (
int row = 0; row < middle_rows; ++row) {
474 base_y + row, ctx.
tiles[4]);
476 base_y + row, ctx.
tiles[5]);
479 const int cap_y = base_y + middle_rows;
495 if (ctx.
tiles.empty() || total_rows <= 0) {
501 for (
int row = 0; row < total_rows; ++row) {
511 const int count = size + 1;
512 if (ctx.
tiles.size() < 4) {
516 for (
int s = 0; s < count; ++s) {
517 const int base_y = ctx.
object.
y_ + (s * 4);
531 const int repeat_count = size + 1;
532 if (ctx.
tiles.size() < 12) {
536 auto draw_segment = [&](
int base_y,
int tile_base) {
538 ctx.
tiles[tile_base + 0]);
540 ctx.
tiles[tile_base + 1]);
542 ctx.
tiles[tile_base + 2]);
544 ctx.
tiles[tile_base + 3]);
546 ctx.
tiles[tile_base + 4]);
548 ctx.
tiles[tile_base + 5]);
554 for (
int s = 0; s < repeat_count; ++s) {
555 draw_segment(ctx.
object.
y_ + (s * 2), 0);
557 draw_segment(ctx.
object.
y_ + (repeat_count * 2), 6);
562 const int middle_rows = (size + 2) * 2;
563 if (ctx.
tiles.size() < 4) {
574 for (
int row = 0; row < middle_rows; ++row) {
584 const int count = size + 1;
585 if (ctx.
tiles.size() < 4) {
589 for (
int s = 0; s < count; ++s) {
590 const int base_y = ctx.
object.
y_ + (s * 2);
608 if (ctx.
tiles.empty()) {
612 for (
int row = 0; row < count; ++row) {
623 .name =
"Downwards2x2_1to15or32",
625 .draws_to_both_bgs =
false,
629 .category = Category::Downwards});
633 .name =
"Downwards4x2_1to15or26",
638 .draws_to_both_bgs =
false,
642 .category = Category::Downwards});
646 .name =
"Downwards4x2_1to16_BothBG",
648 .draws_to_both_bgs =
true,
652 .category = Category::Downwards});
656 .name =
"DownwardsDecor4x2spaced4_1to16",
658 .draws_to_both_bgs =
false,
662 .category = Category::Downwards});
665 .name =
"Downwards2x2_1to16",
667 .draws_to_both_bgs =
false,
671 .category = Category::Downwards});
675 .name =
"DownwardsHasEdge1x1_1to16_plus3",
677 .draws_to_both_bgs =
false,
684 .category = Category::Downwards});
688 .name =
"DownwardsEdge1x1_1to16",
690 .draws_to_both_bgs =
false,
694 .category = Category::Downwards});
698 .name =
"DownwardsLeftCorners2x1_1to16_plus12",
700 .draws_to_both_bgs =
false,
704 .category = Category::Downwards});
708 .name =
"DownwardsRightCorners2x1_1to16_plus12",
710 .draws_to_both_bgs =
false,
714 .category = Category::Downwards});
718 .name =
"DownwardsFloor4x4_1to16",
720 .draws_to_both_bgs =
false,
724 .category = Category::Downwards});
728 .name =
"Downwards1x1Solid_1to16_plus3",
730 .draws_to_both_bgs =
false,
734 .category = Category::Downwards});
738 .name =
"DownwardsDecor4x4spaced2_1to16",
740 .draws_to_both_bgs =
false,
744 .category = Category::Downwards});
748 .name =
"DownwardsPillar2x4spaced2_1to16",
750 .draws_to_both_bgs =
false,
754 .category = Category::Downwards});
758 .name =
"DownwardsDecor3x4spaced4_1to16",
760 .draws_to_both_bgs =
false,
764 .category = Category::Downwards});
768 .name =
"DownwardsDecor2x2spaced12_1to16",
770 .draws_to_both_bgs =
false,
774 .category = Category::Downwards});
778 .name =
"DownwardsLine1x1_1to16plus1",
780 .draws_to_both_bgs =
false,
784 .category = Category::Downwards});
788 .name =
"DownwardsDecor2x4spaced8_1to16",
790 .draws_to_both_bgs =
false,
794 .category = Category::Downwards});
798 .name =
"DownwardsDecor3x4spaced2_1to16",
800 .draws_to_both_bgs =
false,
804 .category = Category::Downwards});
808 .name =
"DownwardsBigRail3x1_1to16plus5",
810 .draws_to_both_bgs =
false,
814 .category = Category::Downwards});
818 .name =
"DownwardsBlock2x2spaced2_1to16",
820 .draws_to_both_bgs =
false,
824 .category = Category::Downwards});
828 .name =
"DownwardsCannonHole3x4_1to16",
830 .draws_to_both_bgs =
false,
834 .category = Category::Downwards});
838 .name =
"DownwardsBar2x5_1to16",
840 .draws_to_both_bgs =
false,
844 .category = Category::Downwards});
848 .name =
"DownwardsPots2x2_1to16",
850 .draws_to_both_bgs =
false,
854 .category = Category::Downwards});
858 .name =
"DownwardsHammerPegs2x2_1to16",
860 .draws_to_both_bgs =
false,
864 .category = Category::Downwards});
868 .name =
"DownwardsEdge1x1_1to16plus7",
870 .draws_to_both_bgs =
false,
874 .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 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 +12 offset downward.
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 +12 offset downward.
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.