8namespace draw_routines {
18 for (
int s = 0; s < size; s++) {
19 if (ctx.
tiles.size() >= 4) {
49 for (
int s = 0; s < size; s++) {
50 if (ctx.
tiles.size() >= 8) {
78 }
else if (ctx.
tiles.size() >= 4) {
99 for (
int s = 0; s < count; s++) {
100 if (ctx.
tiles.size() >= 8) {
128 }
else if (ctx.
tiles.size() >= 4) {
152 int count = size + 1;
154 constexpr int kStepTiles = 6;
156 for (
int s = 0; s < count; s++) {
157 const int base_x = ctx.
object.
x_ + (s * kStepTiles);
159 if (ctx.
tiles.size() >= 8) {
179 }
else if (ctx.
tiles.size() >= 4) {
200 int count = size + 1;
202 for (
int s = 0; s < count; s++) {
203 if (ctx.
tiles.size() >= 4) {
225 if (ctx.
tiles.size() >= 9) {
226 auto draw_column = [&](
int x,
int base) {
228 ctx.
tiles[base + 0]);
230 ctx.
tiles[base + 1]);
232 ctx.
tiles[base + 2]);
237 int mid_cols = (size + 1) * 2;
238 for (
int s = 0; s < mid_cols; s++) {
239 draw_column(ctx.
object.
x_ + 1 + s, 3);
242 draw_column(ctx.
object.
x_ + 1 + mid_cols, 6);
246 int count = (size * 2) + 1;
247 for (
int s = 0; s < count; s++) {
248 if (ctx.
tiles.size() >= 2) {
261 int count = size + 2;
262 if (ctx.
tiles.size() < 3)
273 for (
int s = 0; s < count; s++) {
284 int count = size + 1;
285 if (ctx.
tiles.size() < 3)
296 for (
int s = 0; s < count; s++) {
306 int count = size + 21;
307 if (ctx.
tiles.size() < 3)
318 for (
int s = 0; s < count; s++) {
329 const int count = size + 10;
330 if (count <= 0 || ctx.
tiles.empty()) {
339 ctx.
tiles.size() > 1 ? ctx.
tiles[1] : top_fill;
341 ctx.
tiles.size() > 4 ? ctx.
tiles[4] : top_fill;
343 for (
int s = 0; s < count; ++s) {
345 : (s == count - 1) ? end_cap_top
359 const int count = size + 10;
360 if (count <= 0 || ctx.
tiles.empty()) {
368 ctx.
tiles.size() > 1 ? ctx.
tiles[1] : bottom_fill;
370 ctx.
tiles.size() > 4 ? ctx.
tiles[4] : bottom_fill;
372 for (
int s = 0; s < count; ++s) {
373 const gfx::TileInfo& bottom_tile = (s == 0) ? start_cap_bottom
374 : (s == count - 1) ? end_cap_bottom
389 int count = size + 1;
391 for (
int s = 0; s < count; s++) {
392 if (ctx.
tiles.size() >= 16) {
395 for (
int x = 0; x < 4; ++x) {
396 for (
int y = 0; y < 4; ++y) {
411 int count = size + 4;
413 for (
int s = 0; s < count; s++) {
414 if (ctx.
tiles.size() >= 1) {
427 int count = size + 1;
429 for (
int s = 0; s < count; s++) {
430 if (ctx.
tiles.size() >= 16) {
432 for (
int x = 0; x < 4; ++x) {
433 for (
int y = 0; y < 4; ++y) {
449 int count = size + 1;
451 for (
int s = 0; s < count; s++) {
452 if (ctx.
tiles.size() >= 6) {
454 for (
int x = 0; x < 2; ++x) {
455 for (
int y = 0; y < 3; ++y) {
471 int count = size + 1;
473 for (
int s = 0; s < count; s++) {
474 if (ctx.
tiles.size() >= 8) {
476 for (
int x = 0; x < 2; ++x) {
477 for (
int y = 0; y < 4; ++y) {
493 int count = size + 1;
495 for (
int s = 0; s < count; s++) {
496 if (ctx.
tiles.size() >= 12) {
498 for (
int x = 0; x < 4; ++x) {
499 for (
int y = 0; y < 3; ++y) {
515 int count = size + 1;
517 for (
int s = 0; s < count; s++) {
518 if (ctx.
tiles.size() >= 8) {
520 for (
int x = 0; x < 4; ++x) {
521 for (
int y = 0; y < 2; ++y) {
536 int count = size + 1;
538 for (
int s = 0; s < count; s++) {
539 if (ctx.
tiles.size() >= 4) {
566 const int count = size + 1;
568 if (ctx.
tiles.size() < 8) {
572 for (
int s = 0; s < count; ++s) {
573 const int base_x = ctx.
object.
x_ + (s * 4);
599 const int count = size + 1;
601 if (ctx.
tiles.size() < 8) {
605 for (
int s = 0; s < count; ++s) {
606 const int base_x = ctx.
object.
x_ + (s * 12);
607 for (
int row = 0; row < 8; ++row) {
621 const int count = size + 1;
623 if (ctx.
tiles.size() < 12) {
627 auto draw_column = [&](
int x,
int y,
const gfx::TileInfo& t0,
634 for (
int s = 0; s < count; ++s) {
635 const int base_x = ctx.
object.
x_ + (s * 2);
642 const int right_base_x = ctx.
object.
x_ + (count * 2);
651 const int count = size + 2;
652 if (ctx.
tiles.empty()) {
656 for (
int s = 0; s < count; ++s) {
664 const int count = size + 1;
665 if (ctx.
tiles.size() < 12) {
669 for (
int s = 0; s < count; ++s) {
670 const int base_x = ctx.
object.
x_ + (s * 4);
671 for (
int x = 0; x < 4; ++x) {
672 for (
int y = 0; y < 3; ++y) {
682 const int count = size + 1;
683 if (ctx.
tiles.size() < 16) {
687 for (
int s = 0; s < count; ++s) {
688 const int base_x = ctx.
object.
x_ + (s * 4);
689 for (
int x = 0; x < 4; ++x) {
690 for (
int y = 0; y < 4; ++y) {
700 const int middle_columns = size + 2;
701 const int total_columns = size + 6;
703 if (ctx.
tiles.size() >= 15) {
704 auto draw_column = [&](
int x,
int base_idx) {
706 ctx.
tiles[base_idx + 0]);
708 ctx.
tiles[base_idx + 1]);
710 ctx.
tiles[base_idx + 2]);
719 for (
int s = 0; s < middle_columns; ++s) {
720 draw_column(ctx.
object.
x_ + 2 + s, 6);
722 draw_column(ctx.
object.
x_ + 2 + middle_columns, 9);
723 draw_column(ctx.
object.
x_ + 3 + middle_columns, 12);
727 if (ctx.
tiles.empty()) {
730 for (
int x = 0; x < total_columns; ++x) {
731 for (
int y = 0; y < 3; ++y) {
740 const int count = size + 1;
741 if (ctx.
tiles.size() < 4) {
745 for (
int s = 0; s < count; ++s) {
746 const int base_x = ctx.
object.
x_ + (s * 4);
760 const int count = size + 8;
761 if (ctx.
tiles.empty()) {
765 for (
int s = 0; s < count; ++s) {
773 const int count = size + 1;
774 if (ctx.
tiles.size() < 4) {
778 for (
int s = 0; s < count; ++s) {
779 const int base_x = ctx.
object.
x_ + (s * 2);
802 .name =
"Rightwards2x2_1to15or32",
807 .draws_to_both_bgs =
false,
816 .name =
"Rightwards2x4_1to15or26",
820 .draws_to_both_bgs =
false,
829 .name =
"Rightwards2x4_1to16",
833 .draws_to_both_bgs =
true,
842 .name =
"Rightwards2x4_1to16_BothBG",
846 .draws_to_both_bgs =
false,
855 .name =
"Rightwards2x2_1to16",
857 .draws_to_both_bgs =
false,
866 .name =
"Rightwards1x2_1to16_plus2",
868 .draws_to_both_bgs =
false,
877 .name =
"RightwardsHasEdge1x1_1to16_plus3",
879 .draws_to_both_bgs =
false,
888 .name =
"RightwardsHasEdge1x1_1to16_plus2",
890 .draws_to_both_bgs =
false,
899 .name =
"RightwardsHasEdge1x1_1to16_plus23",
901 .draws_to_both_bgs =
false,
910 .name =
"RightwardsTopCorners1x2_1to16_plus13",
912 .draws_to_both_bgs =
false,
921 .name =
"RightwardsBottomCorners1x2_1to16_plus13",
923 .draws_to_both_bgs =
false,
932 .name =
"Rightwards4x4_1to16",
934 .draws_to_both_bgs =
false,
943 .name =
"Rightwards1x1Solid_1to16_plus3",
945 .draws_to_both_bgs =
false,
955 .name =
"RightwardsDecor4x4spaced2_1to16",
957 .draws_to_both_bgs =
false,
966 .name =
"RightwardsStatue2x3spaced2_1to16",
968 .draws_to_both_bgs =
false,
977 .name =
"RightwardsPillar2x4spaced4_1to16",
979 .draws_to_both_bgs =
false,
988 .name =
"RightwardsDecor4x3spaced4_1to16",
990 .draws_to_both_bgs =
false,
1000 .name =
"RightwardsDoubled2x2spaced2_1to16",
1002 .draws_to_both_bgs =
false,
1011 .name =
"RightwardsDecor2x2spaced12_1to16",
1013 .draws_to_both_bgs =
false,
1022 .name =
"Rightwards4x2_1to16",
1024 .draws_to_both_bgs =
false,
1033 .name =
"RightwardsDecor4x2spaced8_1to16",
1035 .draws_to_both_bgs =
false,
1044 .name =
"RightwardsCannonHole4x3_1to16",
1046 .draws_to_both_bgs =
false,
1055 .name =
"RightwardsLine1x1_1to16plus1",
1057 .draws_to_both_bgs =
false,
1066 .name =
"RightwardsBar4x3_1to16",
1068 .draws_to_both_bgs =
false,
1077 .name =
"RightwardsShelf4x4_1to16",
1079 .draws_to_both_bgs =
false,
1088 .name =
"RightwardsBigRail1x3_1to16plus5",
1090 .draws_to_both_bgs =
false,
1099 .name =
"RightwardsBlock2x2spaced2_1to16",
1101 .draws_to_both_bgs =
false,
1110 .name =
"RightwardsEdge1x1_1to16plus7",
1112 .draws_to_both_bgs =
false,
1121 .name =
"RightwardsPots2x2_1to16",
1123 .draws_to_both_bgs =
false,
1132 .name =
"RightwardsHammerPegs2x2_1to16",
1134 .draws_to_both_bgs =
false,
SNES 16-bit tile metadata container.
constexpr int kRightwards2x2_1to16
constexpr int kRightwardsShelf4x4_1to16
constexpr int kRightwardsHasEdge1x1_1to16_plus2
constexpr int kRightwardsEdge1x1_1to16plus7
constexpr int kRightwardsLine1x1_1to16plus1
constexpr int kRightwardsBlock2x2spaced2_1to16
constexpr int kRightwardsDecor4x4spaced2_1to16
constexpr int kRightwardsDecor2x2spaced12_1to16
constexpr int kRightwardsStatue2x3spaced2_1to16
constexpr int kRightwards4x2_1to16
constexpr int kRightwards4x4_1to16
constexpr int kRightwardsBottomCorners1x2_1to16_plus13
constexpr int kRightwards2x4_1to16_BothBG
constexpr int kRightwardsBar4x3_1to16
constexpr int kRightwards2x2_1to15or32
constexpr int kRightwardsHasEdge1x1_1to16_plus23
constexpr int kRightwardsHasEdge1x1_1to16_plus3
constexpr int kRightwards1x2_1to16_plus2
constexpr int kRightwardsDecor4x2spaced8_1to16
constexpr int kRightwardsPillar2x4spaced4_1to16
constexpr int kRightwardsTopCorners1x2_1to16_plus13
constexpr int kRightwards2x4_1to16
constexpr int kRightwards2x4_1to15or26
constexpr int kRightwardsDecor4x3spaced4_1to16
constexpr int kRightwardsHammerPegs2x2_1to16
constexpr int kRightwards1x1Solid_1to16_plus3
constexpr int kRightwardsBigRail1x3_1to16plus5
constexpr int kRightwardsDoubled2x2spaced2_1to16
constexpr int kRightwardsCannonHole4x3_1to16
constexpr int kRightwardsPots2x2_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 DrawRightwardsStatue2x3spaced2_1to16(const DrawContext &ctx)
Draw 2x3 statue with spacing.
void DrawRightwardsBar4x3_1to16(const DrawContext &ctx)
Draw rightwards 4x3 bar pattern.
void DrawRightwards2x4_1to15or26(const DrawContext &ctx)
Draw 2x4 tiles rightward (1-15 or 26 repetitions)
void DrawRightwards2x2_1to15or32(const DrawContext &ctx)
Draw 2x2 tiles rightward (1-15 or 32 repetitions)
void DrawRightwardsHasEdge1x1_1to16_plus23(const DrawContext &ctx)
Draw 1x1 tiles with edge detection +23.
void DrawRightwardsBottomCorners1x2_1to16_plus13(const DrawContext &ctx)
Draw bottom corner 1x2 tiles with +13 offset.
void DrawRightwardsTopCorners1x2_1to16_plus13(const DrawContext &ctx)
Draw top corner 1x2 tiles with +13 offset.
void DrawRightwardsHasEdge1x1_1to16_plus2(const DrawContext &ctx)
Draw 1x1 tiles with edge detection +2.
void DrawRightwardsDecor2x2spaced12_1to16(const DrawContext &ctx)
Draw 2x2 decoration with large spacing.
void DrawRightwards1x1Solid_1to16_plus3(const DrawContext &ctx)
Draw 1x1 solid tiles +3 offset.
void DrawRightwards1x2_1to16_plus2(const DrawContext &ctx)
Draw 1x3 tiles rightward with caps.
void DrawRightwardsPots2x2_1to16(const DrawContext &ctx)
Draw rightwards 2x2 pot groups.
void DrawRightwards4x2_1to16(const DrawContext &ctx)
Draw 4x2 floor tiles rightward.
void DrawRightwardsBigRail1x3_1to16plus5(const DrawContext &ctx)
Draw rightwards big rail pattern (1x3 columns with +5 extension)
void DrawRightwardsBlock2x2spaced2_1to16(const DrawContext &ctx)
Draw rightwards 2x2 blocks with 2-tile spacing.
void DrawRightwards4x4_1to16(const DrawContext &ctx)
Draw 4x4 block rightward.
void DrawRightwardsHasEdge1x1_1to16_plus3(const DrawContext &ctx)
Draw 1x1 tiles with edge detection +3.
void DrawRightwards2x2_1to16(const DrawContext &ctx)
Draw 2x2 tiles rightward (1-16 repetitions)
void DrawRightwardsHammerPegs2x2_1to16(const DrawContext &ctx)
Draw rightwards 2x2 hammer-peg groups.
void DrawRightwardsCannonHole4x3_1to16(const DrawContext &ctx)
Draw cannon-hole spans with repeated left segment and right cap.
void DrawRightwardsDoubled2x2spaced2_1to16(const DrawContext &ctx)
Draw doubled 2x2 with spacing.
void DrawRightwards2x4_1to16(const DrawContext &ctx)
Draw 2x4 tiles rightward with adjacent spacing (1-16 repetitions)
void RegisterRightwardsRoutines(std::vector< DrawRoutineInfo > ®istry)
Register all rightwards draw routines to the registry.
void DrawRightwardsDecor4x3spaced4_1to16(const DrawContext &ctx)
Draw 4x3 decoration with spacing.
void DrawRightwardsShelf4x4_1to16(const DrawContext &ctx)
Draw rightwards 4x4 shelf pattern.
void DrawRightwards2x4_1to16_BothBG(const DrawContext &ctx)
Draw 2x4 tiles rightward with adjacent spacing to both BG layers.
void DrawRightwardsDecor4x2spaced8_1to16(const DrawContext &ctx)
Draw 1x8 decorative columns with wide horizontal spacing.
void DrawRightwardsPillar2x4spaced4_1to16(const DrawContext &ctx)
Draw 2x4 pillar with spacing.
void DrawRightwardsEdge1x1_1to16plus7(const DrawContext &ctx)
Draw rightwards 1x1 edge line with +7 extension.
void DrawRightwardsDecor4x4spaced2_1to16(const DrawContext &ctx)
Draw 4x4 decoration with spacing.
void DrawRightwardsLine1x1_1to16plus1(const DrawContext &ctx)
Draw rightwards 1x1 line with +1 extension.
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.