8namespace draw_routines {
13 if (ctx.
tiles.size() < 6) {
20 const int body_count = (ctx.
object.
size_ & 0x0F) + 10;
21 const int edge_y = ctx.
object.
y_ + (edge_is_top ? 0 : 1);
22 const int fill_y = ctx.
object.
y_ + (edge_is_top ? 1 : 0);
33 for (
int i = 0; i < body_count; ++i, ++x) {
54 for (
int s = 0; s < size; s++) {
55 if (ctx.
tiles.size() >= 4) {
85 for (
int s = 0; s < size; s++) {
86 if (ctx.
tiles.size() >= 8) {
114 }
else if (ctx.
tiles.size() >= 4) {
133 int count = size + 1;
135 for (
int s = 0; s < count; s++) {
136 if (ctx.
tiles.size() >= 8) {
164 }
else if (ctx.
tiles.size() >= 4) {
188 int count = size + 1;
190 constexpr int kStepTiles = 6;
192 for (
int s = 0; s < count; s++) {
193 const int base_x = ctx.
object.
x_ + (s * kStepTiles);
195 if (ctx.
tiles.size() >= 8) {
215 }
else if (ctx.
tiles.size() >= 4) {
236 int count = size + 1;
238 for (
int s = 0; s < count; s++) {
239 if (ctx.
tiles.size() >= 4) {
261 if (ctx.
tiles.size() >= 9) {
262 auto draw_column = [&](
int x,
int base) {
264 ctx.
tiles[base + 0]);
266 ctx.
tiles[base + 1]);
268 ctx.
tiles[base + 2]);
273 int mid_cols = (size + 1) * 2;
274 for (
int s = 0; s < mid_cols; s++) {
275 draw_column(ctx.
object.
x_ + 1 + s, 3);
278 draw_column(ctx.
object.
x_ + 1 + mid_cols, 6);
282 int count = (size * 2) + 1;
283 for (
int s = 0; s < count; s++) {
284 if (ctx.
tiles.size() >= 2) {
297 int count = size + 2;
298 if (ctx.
tiles.size() < 3)
309 for (
int s = 0; s < count; s++) {
320 int count = size + 1;
321 if (ctx.
tiles.size() < 3)
328 ctx, x, ctx.
object.
y_, {0x01DB, 0x01A6, 0x01DD, 0x01FC})) {
332 for (
int s = 0; s < count; s++) {
342 int count = size + 21;
343 if (ctx.
tiles.size() < 3)
354 for (
int s = 0; s < count; s++) {
362 DrawRightwardsCorners1x2(ctx,
true);
366 DrawRightwardsCorners1x2(ctx,
false);
374 int count = size + 1;
376 for (
int s = 0; s < count; s++) {
377 if (ctx.
tiles.size() >= 16) {
380 for (
int x = 0; x < 4; ++x) {
381 for (
int y = 0; y < 4; ++y) {
392 if (ctx.
tiles.empty()) {
399 for (
int s = 0; s < count; ++s) {
410 int count = size + 1;
412 for (
int s = 0; s < count; s++) {
413 if (ctx.
tiles.size() >= 16) {
415 for (
int x = 0; x < 4; ++x) {
416 for (
int y = 0; y < 4; ++y) {
432 int count = size + 1;
434 for (
int s = 0; s < count; s++) {
435 if (ctx.
tiles.size() >= 6) {
437 for (
int x = 0; x < 2; ++x) {
438 for (
int y = 0; y < 3; ++y) {
454 int count = size + 1;
456 for (
int s = 0; s < count; s++) {
457 if (ctx.
tiles.size() >= 8) {
459 for (
int x = 0; x < 2; ++x) {
460 for (
int y = 0; y < 4; ++y) {
480 int count = size + 1;
482 for (
int s = 0; s < count; s++) {
483 if (ctx.
tiles.size() >= 12) {
485 for (
int x = 0; x < 4; ++x) {
486 for (
int y = 0; y < 3; ++y) {
502 if (ctx.
tiles.size() < 8) {
506 for (
int s = 0; s < count; ++s) {
507 const int base_x = ctx.
object.
x_ + s * 4;
508 for (
int block = 0; block < 2; ++block) {
509 const int base_y = ctx.
object.
y_ + block * 6;
510 const int first = block * 4;
511 for (
int x = 0; x < 2; ++x) {
512 for (
int y = 0; y < 2; ++y) {
514 ctx.
tiles[first + x * 2 + y]);
526 int count = size + 1;
528 for (
int s = 0; s < count; s++) {
529 if (ctx.
tiles.size() >= 4) {
556 const int count = size + 1;
558 if (ctx.
tiles.size() < 8) {
562 for (
int s = 0; s < count; ++s) {
563 const int base_x = ctx.
object.
x_ + (s * 4);
590 const int count = size + 1;
592 if (ctx.
tiles.size() < 8) {
596 for (
int s = 0; s < count; ++s) {
597 const int base_x = ctx.
object.
x_ + (s * 12);
624 if (ctx.
tiles.size() < 18) {
628 auto draw_segment = [&](
int segment,
int first) {
629 for (
int x = 0; x < 2; ++x) {
630 for (
int y = 0; y < 3; ++y) {
633 ctx.
tiles[first + x * 3 + y]);
638 for (
int s = 1; s < count; ++s) {
641 draw_segment(count, 12);
646 const int count = size + 2;
647 if (ctx.
tiles.empty()) {
651 for (
int s = 0; s < count; ++s) {
658 if (ctx.
tiles.size() < 9) {
665 const int middle_columns = 2 * ((ctx.
object.
size_ & 0x0F) + 1);
666 auto draw_column = [&](
int x,
int tile_base) {
667 for (
int row = 0; row < 3; ++row) {
669 ctx.
tiles[tile_base + row]);
673 for (
int column = 0; column < middle_columns; ++column) {
674 draw_column(ctx.
object.
x_ + 1 + column, 3);
676 draw_column(ctx.
object.
x_ + 1 + middle_columns, 6);
685 if (ctx.
tiles.size() < 16) {
689 auto draw_column = [&](
int x,
int first) {
690 for (
int y = 0; y < 4; ++y) {
692 ctx.
tiles[first + y]);
696 for (
int s = 0; s < count; ++s) {
697 draw_column(ctx.
object.
x_ + 1 + s * 2, 4);
698 draw_column(ctx.
object.
x_ + 2 + s * 2, 8);
700 draw_column(ctx.
object.
x_ + 1 + count * 2, 12);
705 const int middle_columns = size + 2;
706 const int total_columns = size + 6;
708 if (ctx.
tiles.size() >= 15) {
709 auto draw_column = [&](
int x,
int base_idx) {
711 ctx.
tiles[base_idx + 0]);
713 ctx.
tiles[base_idx + 1]);
715 ctx.
tiles[base_idx + 2]);
724 for (
int s = 0; s < middle_columns; ++s) {
725 draw_column(ctx.
object.
x_ + 2 + s, 6);
727 draw_column(ctx.
object.
x_ + 2 + middle_columns, 9);
728 draw_column(ctx.
object.
x_ + 3 + middle_columns, 12);
732 if (ctx.
tiles.empty()) {
735 for (
int x = 0; x < total_columns; ++x) {
736 for (
int y = 0; y < 3; ++y) {
745 const int count = size + 1;
746 if (ctx.
tiles.size() < 4) {
750 for (
int s = 0; s < count; ++s) {
751 const int base_x = ctx.
object.
x_ + (s * 4);
765 const int count = size + 8;
766 if (ctx.
tiles.empty()) {
770 for (
int s = 0; s < count; ++s) {
778 const int count = size + 1;
779 if (ctx.
tiles.size() < 4) {
783 for (
int s = 0; s < count; ++s) {
784 const int base_x = ctx.
object.
x_ + (s * 2);
807 .name =
"Rightwards2x2_1to15or32",
812 .draws_to_both_bgs =
false,
821 .name =
"Rightwards2x4_1to15or26",
825 .draws_to_both_bgs =
false,
834 .name =
"Rightwards2x4_1to16",
838 .draws_to_both_bgs =
true,
847 .name =
"Weird2x4_1to16",
851 .draws_to_both_bgs =
false,
860 .name =
"Rightwards2x4_1to16_BothBG",
864 .draws_to_both_bgs =
false,
873 .name =
"Rightwards2x2_1to16",
875 .draws_to_both_bgs =
false,
884 .name =
"Rightwards1x2_1to16_plus2",
886 .draws_to_both_bgs =
false,
895 .name =
"RightwardsHasEdge1x1_1to16_plus3",
897 .draws_to_both_bgs =
false,
906 .name =
"RightwardsHasEdge1x1_1to16_plus2",
908 .draws_to_both_bgs =
false,
917 .name =
"RightwardsHasEdge1x1_1to16_plus23",
919 .draws_to_both_bgs =
false,
928 .name =
"RightwardsTopCorners1x2_1to16_plus13",
930 .draws_to_both_bgs =
false,
939 .name =
"RightwardsBottomCorners1x2_1to16_plus13",
941 .draws_to_both_bgs =
false,
950 .name =
"Rightwards4x4_1to16",
952 .draws_to_both_bgs =
false,
961 .name =
"Rightwards1x1Solid_1to16_plus3",
963 .draws_to_both_bgs =
false,
973 .name =
"RightwardsDecor4x4spaced2_1to16",
975 .draws_to_both_bgs =
false,
984 .name =
"RightwardsStatue2x3spaced2_1to16",
986 .draws_to_both_bgs =
false,
995 .name =
"RightwardsPillar2x4spaced4_1to16",
997 .draws_to_both_bgs =
false,
1006 .name =
"RightwardsDecor4x3spaced4_1to16",
1008 .draws_to_both_bgs =
false,
1018 .name =
"RightwardsDoubled2x2spaced2_1to16",
1020 .draws_to_both_bgs =
false,
1029 .name =
"RightwardsDecor2x2spaced12_1to16",
1031 .draws_to_both_bgs =
false,
1040 .name =
"Rightwards4x2_1to16",
1042 .draws_to_both_bgs =
false,
1051 .name =
"RightwardsDecor4x2spaced8_1to16",
1053 .draws_to_both_bgs =
false,
1062 .name =
"RightwardsCannonHole4x3_1to16",
1064 .draws_to_both_bgs =
false,
1073 .name =
"RightwardsLine1x1_1to16plus1",
1075 .draws_to_both_bgs =
false,
1084 .name =
"RightwardsBar4x3_1to16",
1086 .draws_to_both_bgs =
false,
1095 .name =
"RightwardsShelf4x4_1to16",
1097 .draws_to_both_bgs =
false,
1106 .name =
"RightwardsBigRail1x3_1to16plus5",
1108 .draws_to_both_bgs =
false,
1117 .name =
"RightwardsBlock2x2spaced2_1to16",
1119 .draws_to_both_bgs =
false,
1128 .name =
"RightwardsEdge1x1_1to16plus7",
1130 .draws_to_both_bgs =
false,
1139 .name =
"RightwardsPots2x2_1to16",
1141 .draws_to_both_bgs =
false,
1150 .name =
"RightwardsHammerPegs2x2_1to16",
1152 .draws_to_both_bgs =
false,
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 DrawRightwardsCorners1x2(const DrawContext &ctx, bool edge_is_top)
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 opening and closing caps.
void DrawRightwardsTopCorners1x2_1to16_plus13(const DrawContext &ctx)
Draw top corner 1x2 tiles with opening and closing caps.
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 with a +3 extent.
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.