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) {
88 if (ctx.
tiles.size() < 8) {
92 for (
int s = 0; s < count; ++s) {
93 const int y = ctx.
object.
y_ + (s * 2);
119 int count = size + 1;
121 for (
int s = 0; s < count; s++) {
122 if (ctx.
tiles.size() >= 8) {
125 const int base_y = ctx.
object.
y_ + (s * 6);
151 int count = size + 1;
153 for (
int s = 0; s < count; s++) {
154 if (ctx.
tiles.size() >= 4) {
186 int count = size + 2;
188 if (ctx.
tiles.size() < 3)
199 for (
int s = 0; s < count; s++) {
211 int count = size + 1;
213 for (
int s = 0; s < count; s++) {
214 if (ctx.
tiles.size() >= 1) {
226 const int count = size + 10;
227 if (count <= 0 || ctx.
tiles.empty()) {
231 const int base_x = ctx.
object.
x_ + 12;
241 ctx.
tiles.size() > 4 ? ctx.
tiles[4] : body_left;
246 current_y, {0x00E3})) {
257 for (
int s = 0; s < count; ++s) {
276 const int count = size + 10;
277 if (count <= 0 || ctx.
tiles.empty()) {
281 const int base_x = ctx.
object.
x_ + 12;
291 ctx.
tiles.size() > 4 ? ctx.
tiles[4] : body_right;
296 current_y, {0x00E3})) {
306 for (
int s = 0; s < count; ++s) {
323 const int count = size + 1;
324 if (ctx.
tiles.size() < 16) {
328 for (
int s = 0; s < count; ++s) {
329 const int base_y = ctx.
object.
y_ + (s * 4);
330 for (
int x = 0; x < 4; ++x) {
331 for (
int y = 0; y < 4; ++y) {
333 base_y + y, ctx.
tiles[x * 4 + y]);
341 const int count = size + 4;
342 if (ctx.
tiles.empty()) {
346 for (
int s = 0; s < count; ++s) {
354 const int count = size + 1;
355 if (ctx.
tiles.size() < 16) {
359 for (
int s = 0; s < count; ++s) {
360 const int base_y = ctx.
object.
y_ + (s * 6);
361 for (
int x = 0; x < 4; ++x) {
362 for (
int y = 0; y < 4; ++y) {
364 base_y + y, ctx.
tiles[x * 4 + y]);
372 const int count = size + 1;
373 if (ctx.
tiles.size() < 8) {
377 for (
int s = 0; s < count; ++s) {
378 const int base_y = ctx.
object.
y_ + (s * 6);
379 for (
int x = 0; x < 2; ++x) {
380 for (
int y = 0; y < 4; ++y) {
382 base_y + y, ctx.
tiles[x * 4 + y]);
390 const int count = size + 1;
391 if (ctx.
tiles.size() < 12) {
395 for (
int s = 0; s < count; ++s) {
396 const int base_y = ctx.
object.
y_ + (s * 8);
397 for (
int x = 0; x < 3; ++x) {
398 for (
int y = 0; y < 4; ++y) {
400 base_y + y, ctx.
tiles[x * 4 + y]);
408 const int count = size + 1;
409 if (ctx.
tiles.size() < 4) {
413 for (
int s = 0; s < count; ++s) {
414 const int base_y = ctx.
object.
y_ + (s * 14);
428 const int count = size + 2;
429 if (ctx.
tiles.empty()) {
433 for (
int s = 0; s < count; ++s) {
441 const int count = size + 1;
442 if (ctx.
tiles.size() < 8) {
446 for (
int s = 0; s < count; ++s) {
447 const int base_y = ctx.
object.
y_ + (s * 12);
448 for (
int x = 0; x < 2; ++x) {
449 for (
int y = 0; y < 4; ++y) {
451 base_y + y, ctx.
tiles[x * 4 + y]);
459 const int count = size + 1;
460 if (ctx.
tiles.size() < 12) {
464 for (
int s = 0; s < count; ++s) {
465 const int base_y = ctx.
object.
y_ + (s * 6);
466 for (
int x = 0; x < 3; ++x) {
467 for (
int y = 0; y < 4; ++y) {
469 base_y + y, ctx.
tiles[x * 4 + y]);
477 const int middle_rows = size + 1;
478 const int total_rows = size + 6;
480 if (ctx.
tiles.size() >= 12) {
495 for (
int row = 0; row < middle_rows; ++row) {
497 base_y + row, ctx.
tiles[4]);
499 base_y + row, ctx.
tiles[5]);
502 const int cap_y = base_y + middle_rows;
518 if (ctx.
tiles.empty() || total_rows <= 0) {
524 for (
int row = 0; row < total_rows; ++row) {
534 const int count = size + 1;
535 if (ctx.
tiles.size() < 4) {
539 for (
int s = 0; s < count; ++s) {
540 const int base_y = ctx.
object.
y_ + (s * 4);
554 const int repeat_count = size + 1;
555 if (ctx.
tiles.size() < 12) {
559 auto draw_segment = [&](
int base_y,
int tile_base) {
561 ctx.
tiles[tile_base + 0]);
563 ctx.
tiles[tile_base + 1]);
565 ctx.
tiles[tile_base + 2]);
567 ctx.
tiles[tile_base + 3]);
569 ctx.
tiles[tile_base + 4]);
571 ctx.
tiles[tile_base + 5]);
577 for (
int s = 0; s < repeat_count; ++s) {
578 draw_segment(ctx.
object.
y_ + (s * 2), 0);
580 draw_segment(ctx.
object.
y_ + (repeat_count * 2), 6);
585 const int middle_rows = (size + 2) * 2;
586 if (ctx.
tiles.size() < 4) {
597 for (
int row = 0; row < middle_rows; ++row) {
607 const int count = size + 1;
608 if (ctx.
tiles.size() < 4) {
612 for (
int s = 0; s < count; ++s) {
613 const int base_y = ctx.
object.
y_ + (s * 2);
631 if (ctx.
tiles.empty()) {
635 for (
int row = 0; row < count; ++row) {
646 .name =
"Downwards2x2_1to15or32",
648 .draws_to_both_bgs =
false,
652 .category = Category::Downwards});
656 .name =
"Downwards4x2_1to15or26",
661 .draws_to_both_bgs =
false,
665 .category = Category::Downwards});
669 .name =
"Downwards4x2_1to16_BothBG",
671 .draws_to_both_bgs =
true,
675 .category = Category::Downwards});
679 .name =
"DownwardsDecor4x2spaced4_1to16",
681 .draws_to_both_bgs =
false,
685 .category = Category::Downwards});
688 .name =
"Downwards2x2_1to16",
690 .draws_to_both_bgs =
false,
694 .category = Category::Downwards});
698 .name =
"DownwardsHasEdge1x1_1to16_plus3",
700 .draws_to_both_bgs =
false,
707 .category = Category::Downwards});
711 .name =
"DownwardsEdge1x1_1to16",
713 .draws_to_both_bgs =
false,
717 .category = Category::Downwards});
721 .name =
"DownwardsLeftCorners2x1_1to16_plus12",
723 .draws_to_both_bgs =
false,
727 .category = Category::Downwards});
731 .name =
"DownwardsRightCorners2x1_1to16_plus12",
733 .draws_to_both_bgs =
false,
737 .category = Category::Downwards});
741 .name =
"DownwardsFloor4x4_1to16",
743 .draws_to_both_bgs =
false,
747 .category = Category::Downwards});
751 .name =
"Downwards1x1Solid_1to16_plus3",
753 .draws_to_both_bgs =
false,
757 .category = Category::Downwards});
761 .name =
"DownwardsDecor4x4spaced2_1to16",
763 .draws_to_both_bgs =
false,
767 .category = Category::Downwards});
771 .name =
"DownwardsPillar2x4spaced2_1to16",
773 .draws_to_both_bgs =
false,
777 .category = Category::Downwards});
781 .name =
"DownwardsDecor3x4spaced4_1to16",
783 .draws_to_both_bgs =
false,
787 .category = Category::Downwards});
791 .name =
"DownwardsDecor2x2spaced12_1to16",
793 .draws_to_both_bgs =
false,
797 .category = Category::Downwards});
801 .name =
"DownwardsLine1x1_1to16plus1",
803 .draws_to_both_bgs =
false,
807 .category = Category::Downwards});
811 .name =
"DownwardsDecor2x4spaced8_1to16",
813 .draws_to_both_bgs =
false,
817 .category = Category::Downwards});
821 .name =
"DownwardsDecor3x4spaced2_1to16",
823 .draws_to_both_bgs =
false,
827 .category = Category::Downwards});
831 .name =
"DownwardsBigRail3x1_1to16plus5",
833 .draws_to_both_bgs =
false,
837 .category = Category::Downwards});
841 .name =
"DownwardsBlock2x2spaced2_1to16",
843 .draws_to_both_bgs =
false,
847 .category = Category::Downwards});
851 .name =
"DownwardsCannonHole3x4_1to16",
853 .draws_to_both_bgs =
false,
857 .category = Category::Downwards});
861 .name =
"DownwardsBar2x5_1to16",
863 .draws_to_both_bgs =
false,
867 .category = Category::Downwards});
871 .name =
"DownwardsPots2x2_1to16",
873 .draws_to_both_bgs =
false,
877 .category = Category::Downwards});
881 .name =
"DownwardsHammerPegs2x2_1to16",
883 .draws_to_both_bgs =
false,
887 .category = Category::Downwards});
891 .name =
"DownwardsEdge1x1_1to16plus7",
893 .draws_to_both_bgs =
false,
897 .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.