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) {
497 int count = size + 1;
499 for (
int s = 0; s < count; s++) {
500 if (ctx.
tiles.size() >= 12) {
502 for (
int x = 0; x < 4; ++x) {
503 for (
int y = 0; y < 3; ++y) {
519 int count = size + 1;
521 for (
int s = 0; s < count; s++) {
522 if (ctx.
tiles.size() >= 8) {
524 for (
int x = 0; x < 4; ++x) {
525 for (
int y = 0; y < 2; ++y) {
540 int count = size + 1;
542 for (
int s = 0; s < count; s++) {
543 if (ctx.
tiles.size() >= 4) {
570 const int count = size + 1;
572 if (ctx.
tiles.size() < 8) {
576 for (
int s = 0; s < count; ++s) {
577 const int base_x = ctx.
object.
x_ + (s * 4);
604 const int count = size + 1;
606 if (ctx.
tiles.size() < 8) {
610 for (
int s = 0; s < count; ++s) {
611 const int base_x = ctx.
object.
x_ + (s * 12);
639 const int count = size + 1;
641 if (ctx.
tiles.size() < 12) {
645 auto draw_column = [&](
int x,
int y,
const gfx::TileInfo& t0,
652 for (
int s = 0; s < count; ++s) {
653 const int base_x = ctx.
object.
x_ + (s * 2);
660 const int right_base_x = ctx.
object.
x_ + (count * 2);
669 const int count = size + 2;
670 if (ctx.
tiles.empty()) {
674 for (
int s = 0; s < count; ++s) {
682 const int count = size + 1;
683 if (ctx.
tiles.size() < 12) {
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 < 3; ++y) {
700 const int count = size + 1;
701 if (ctx.
tiles.size() < 16) {
705 for (
int s = 0; s < count; ++s) {
706 const int base_x = ctx.
object.
x_ + (s * 4);
707 for (
int x = 0; x < 4; ++x) {
708 for (
int y = 0; y < 4; ++y) {
718 const int middle_columns = size + 2;
719 const int total_columns = size + 6;
721 if (ctx.
tiles.size() >= 15) {
722 auto draw_column = [&](
int x,
int base_idx) {
724 ctx.
tiles[base_idx + 0]);
726 ctx.
tiles[base_idx + 1]);
728 ctx.
tiles[base_idx + 2]);
737 for (
int s = 0; s < middle_columns; ++s) {
738 draw_column(ctx.
object.
x_ + 2 + s, 6);
740 draw_column(ctx.
object.
x_ + 2 + middle_columns, 9);
741 draw_column(ctx.
object.
x_ + 3 + middle_columns, 12);
745 if (ctx.
tiles.empty()) {
748 for (
int x = 0; x < total_columns; ++x) {
749 for (
int y = 0; y < 3; ++y) {
758 const int count = size + 1;
759 if (ctx.
tiles.size() < 4) {
763 for (
int s = 0; s < count; ++s) {
764 const int base_x = ctx.
object.
x_ + (s * 4);
778 const int count = size + 8;
779 if (ctx.
tiles.empty()) {
783 for (
int s = 0; s < count; ++s) {
791 const int count = size + 1;
792 if (ctx.
tiles.size() < 4) {
796 for (
int s = 0; s < count; ++s) {
797 const int base_x = ctx.
object.
x_ + (s * 2);
820 .name =
"Rightwards2x2_1to15or32",
825 .draws_to_both_bgs =
false,
834 .name =
"Rightwards2x4_1to15or26",
838 .draws_to_both_bgs =
false,
847 .name =
"Rightwards2x4_1to16",
851 .draws_to_both_bgs =
true,
860 .name =
"Weird2x4_1to16",
864 .draws_to_both_bgs =
false,
873 .name =
"Rightwards2x4_1to16_BothBG",
877 .draws_to_both_bgs =
false,
886 .name =
"Rightwards2x2_1to16",
888 .draws_to_both_bgs =
false,
897 .name =
"Rightwards1x2_1to16_plus2",
899 .draws_to_both_bgs =
false,
908 .name =
"RightwardsHasEdge1x1_1to16_plus3",
910 .draws_to_both_bgs =
false,
919 .name =
"RightwardsHasEdge1x1_1to16_plus2",
921 .draws_to_both_bgs =
false,
930 .name =
"RightwardsHasEdge1x1_1to16_plus23",
932 .draws_to_both_bgs =
false,
941 .name =
"RightwardsTopCorners1x2_1to16_plus13",
943 .draws_to_both_bgs =
false,
952 .name =
"RightwardsBottomCorners1x2_1to16_plus13",
954 .draws_to_both_bgs =
false,
963 .name =
"Rightwards4x4_1to16",
965 .draws_to_both_bgs =
false,
974 .name =
"Rightwards1x1Solid_1to16_plus3",
976 .draws_to_both_bgs =
false,
986 .name =
"RightwardsDecor4x4spaced2_1to16",
988 .draws_to_both_bgs =
false,
997 .name =
"RightwardsStatue2x3spaced2_1to16",
999 .draws_to_both_bgs =
false,
1008 .name =
"RightwardsPillar2x4spaced4_1to16",
1010 .draws_to_both_bgs =
false,
1019 .name =
"RightwardsDecor4x3spaced4_1to16",
1021 .draws_to_both_bgs =
false,
1031 .name =
"RightwardsDoubled2x2spaced2_1to16",
1033 .draws_to_both_bgs =
false,
1042 .name =
"RightwardsDecor2x2spaced12_1to16",
1044 .draws_to_both_bgs =
false,
1053 .name =
"Rightwards4x2_1to16",
1055 .draws_to_both_bgs =
false,
1064 .name =
"RightwardsDecor4x2spaced8_1to16",
1066 .draws_to_both_bgs =
false,
1075 .name =
"RightwardsCannonHole4x3_1to16",
1077 .draws_to_both_bgs =
false,
1086 .name =
"RightwardsLine1x1_1to16plus1",
1088 .draws_to_both_bgs =
false,
1097 .name =
"RightwardsBar4x3_1to16",
1099 .draws_to_both_bgs =
false,
1108 .name =
"RightwardsShelf4x4_1to16",
1110 .draws_to_both_bgs =
false,
1119 .name =
"RightwardsBigRail1x3_1to16plus5",
1121 .draws_to_both_bgs =
false,
1130 .name =
"RightwardsBlock2x2spaced2_1to16",
1132 .draws_to_both_bgs =
false,
1141 .name =
"RightwardsEdge1x1_1to16plus7",
1143 .draws_to_both_bgs =
false,
1152 .name =
"RightwardsPots2x2_1to16",
1154 .draws_to_both_bgs =
false,
1163 .name =
"RightwardsHammerPegs2x2_1to16",
1165 .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 kWeird2x4_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 4x2 decorative stamps 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.