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) {
156 int count = size + 1;
158 if (ctx.
tiles.size() < 3)
169 for (
int s = 0; s < count; s++) {
181 int count = size + 1;
183 for (
int s = 0; s < count; s++) {
184 if (ctx.
tiles.size() >= 1) {
196 const int count = size + 10;
197 if (count <= 0 || ctx.
tiles.empty()) {
201 const int base_x = ctx.
object.
x_ + 12;
212 ctx.
tiles.size() > 4 ? ctx.
tiles[4] : body_left;
228 for (
int s = 0; s < count; ++s) {
247 const int count = size + 10;
248 if (count <= 0 || ctx.
tiles.empty()) {
252 const int base_x = ctx.
object.
x_ + 12;
263 ctx.
tiles.size() > 4 ? ctx.
tiles[4] : body_right;
268 current_y, {0x00E3})) {
278 for (
int s = 0; s < count; ++s) {
295 const int count = size + 1;
296 if (ctx.
tiles.size() < 16) {
300 for (
int s = 0; s < count; ++s) {
301 const int base_y = ctx.
object.
y_ + (s * 4);
302 for (
int x = 0; x < 4; ++x) {
303 for (
int y = 0; y < 4; ++y) {
305 base_y + y, ctx.
tiles[x * 4 + y]);
313 const int count = size + 4;
314 if (ctx.
tiles.empty()) {
318 for (
int s = 0; s < count; ++s) {
326 const int count = size + 1;
327 if (ctx.
tiles.size() < 16) {
331 for (
int s = 0; s < count; ++s) {
332 const int base_y = ctx.
object.
y_ + (s * 6);
333 for (
int x = 0; x < 4; ++x) {
334 for (
int y = 0; y < 4; ++y) {
336 base_y + y, ctx.
tiles[x * 4 + y]);
344 const int count = size + 1;
345 if (ctx.
tiles.size() < 8) {
349 for (
int s = 0; s < count; ++s) {
350 const int base_y = ctx.
object.
y_ + (s * 6);
351 for (
int x = 0; x < 2; ++x) {
352 for (
int y = 0; y < 4; ++y) {
354 base_y + y, ctx.
tiles[x * 4 + y]);
362 const int count = size + 1;
363 if (ctx.
tiles.size() < 12) {
367 for (
int s = 0; s < count; ++s) {
368 const int base_y = ctx.
object.
y_ + (s * 8);
369 for (
int x = 0; x < 3; ++x) {
370 for (
int y = 0; y < 4; ++y) {
372 base_y + y, ctx.
tiles[x * 4 + y]);
380 const int count = size + 1;
381 if (ctx.
tiles.size() < 4) {
385 for (
int s = 0; s < count; ++s) {
386 const int base_y = ctx.
object.
y_ + (s * 14);
400 const int count = size + 2;
401 if (ctx.
tiles.empty()) {
405 for (
int s = 0; s < count; ++s) {
413 const int count = size + 1;
414 if (ctx.
tiles.size() < 8) {
418 for (
int s = 0; s < count; ++s) {
419 const int base_y = ctx.
object.
y_ + (s * 12);
420 for (
int x = 0; x < 2; ++x) {
421 for (
int y = 0; y < 4; ++y) {
423 base_y + y, ctx.
tiles[x * 4 + y]);
431 const int count = size + 1;
432 if (ctx.
tiles.size() < 12) {
436 for (
int s = 0; s < count; ++s) {
437 const int base_y = ctx.
object.
y_ + (s * 6);
438 for (
int x = 0; x < 3; ++x) {
439 for (
int y = 0; y < 4; ++y) {
441 base_y + y, ctx.
tiles[x * 4 + y]);
449 const int middle_rows = size + 1;
450 const int total_rows = size + 6;
452 if (ctx.
tiles.size() >= 12) {
467 for (
int row = 0; row < middle_rows; ++row) {
469 base_y + row, ctx.
tiles[4]);
471 base_y + row, ctx.
tiles[5]);
474 const int cap_y = base_y + middle_rows;
490 if (ctx.
tiles.empty() || total_rows <= 0) {
496 for (
int row = 0; row < total_rows; ++row) {
506 const int count = size + 1;
507 if (ctx.
tiles.size() < 4) {
511 for (
int s = 0; s < count; ++s) {
512 const int base_y = ctx.
object.
y_ + (s * 4);
526 const int repeat_count = size + 1;
527 if (ctx.
tiles.size() < 12) {
531 auto draw_segment = [&](
int base_y,
int tile_base) {
533 ctx.
tiles[tile_base + 0]);
535 ctx.
tiles[tile_base + 1]);
537 ctx.
tiles[tile_base + 2]);
539 ctx.
tiles[tile_base + 3]);
541 ctx.
tiles[tile_base + 4]);
543 ctx.
tiles[tile_base + 5]);
549 for (
int s = 0; s < repeat_count; ++s) {
550 draw_segment(ctx.
object.
y_ + (s * 2), 0);
552 draw_segment(ctx.
object.
y_ + (repeat_count * 2), 6);
557 const int middle_rows = (size + 2) * 2;
558 if (ctx.
tiles.size() < 4) {
569 for (
int row = 0; row < middle_rows; ++row) {
579 const int count = size + 1;
580 if (ctx.
tiles.size() < 4) {
584 for (
int s = 0; s < count; ++s) {
585 const int base_y = ctx.
object.
y_ + (s * 2);
606 .name =
"Downwards2x2_1to15or32",
608 .draws_to_both_bgs =
false,
612 .category = Category::Downwards});
616 .name =
"Downwards4x2_1to15or26",
621 .draws_to_both_bgs =
false,
625 .category = Category::Downwards});
629 .name =
"Downwards4x2_1to16_BothBG",
631 .draws_to_both_bgs =
true,
635 .category = Category::Downwards});
639 .name =
"DownwardsDecor4x2spaced4_1to16",
641 .draws_to_both_bgs =
false,
645 .category = Category::Downwards});
648 .name =
"Downwards2x2_1to16",
650 .draws_to_both_bgs =
false,
654 .category = Category::Downwards});
658 .name =
"DownwardsHasEdge1x1_1to16_plus3",
660 .draws_to_both_bgs =
false,
664 .category = Category::Downwards});
668 .name =
"DownwardsEdge1x1_1to16",
670 .draws_to_both_bgs =
false,
674 .category = Category::Downwards});
678 .name =
"DownwardsLeftCorners2x1_1to16_plus12",
680 .draws_to_both_bgs =
false,
684 .category = Category::Downwards});
688 .name =
"DownwardsRightCorners2x1_1to16_plus12",
690 .draws_to_both_bgs =
false,
694 .category = Category::Downwards});
698 .name =
"DownwardsFloor4x4_1to16",
700 .draws_to_both_bgs =
false,
704 .category = Category::Downwards});
708 .name =
"Downwards1x1Solid_1to16_plus3",
710 .draws_to_both_bgs =
false,
714 .category = Category::Downwards});
718 .name =
"DownwardsDecor4x4spaced2_1to16",
720 .draws_to_both_bgs =
false,
724 .category = Category::Downwards});
728 .name =
"DownwardsPillar2x4spaced2_1to16",
730 .draws_to_both_bgs =
false,
734 .category = Category::Downwards});
738 .name =
"DownwardsDecor3x4spaced4_1to16",
740 .draws_to_both_bgs =
false,
744 .category = Category::Downwards});
748 .name =
"DownwardsDecor2x2spaced12_1to16",
750 .draws_to_both_bgs =
false,
754 .category = Category::Downwards});
758 .name =
"DownwardsLine1x1_1to16plus1",
760 .draws_to_both_bgs =
false,
764 .category = Category::Downwards});
768 .name =
"DownwardsDecor2x4spaced8_1to16",
770 .draws_to_both_bgs =
false,
774 .category = Category::Downwards});
778 .name =
"DownwardsDecor3x4spaced2_1to16",
780 .draws_to_both_bgs =
false,
784 .category = Category::Downwards});
788 .name =
"DownwardsBigRail3x1_1to16plus5",
790 .draws_to_both_bgs =
false,
794 .category = Category::Downwards});
798 .name =
"DownwardsBlock2x2spaced2_1to16",
800 .draws_to_both_bgs =
false,
804 .category = Category::Downwards});
808 .name =
"DownwardsCannonHole3x4_1to16",
810 .draws_to_both_bgs =
false,
814 .category = Category::Downwards});
818 .name =
"DownwardsBar2x5_1to16",
820 .draws_to_both_bgs =
false,
824 .category = Category::Downwards});
828 .name =
"DownwardsPots2x2_1to16",
830 .draws_to_both_bgs =
false,
834 .category = Category::Downwards});
838 .name =
"DownwardsHammerPegs2x2_1to16",
840 .draws_to_both_bgs =
false,
844 .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 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 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.