yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
rightwards_routines.cc
Go to the documentation of this file.
2
5
6namespace yaze {
7namespace zelda3 {
8namespace draw_routines {
9
11 // Pattern: Draws 2x2 tiles rightward (object 0x00)
12 // Size byte determines how many times to repeat (1-15 or 32)
13 // ROM tile order is COLUMN-MAJOR: [col0_row0, col0_row1, col1_row0, col1_row1]
14 int size = ctx.object.size_;
15 if (size == 0)
16 size = 32; // Special case for object 0x00
17
18 for (int s = 0; s < size; s++) {
19 if (ctx.tiles.size() >= 4) {
20 // Draw 2x2 pattern in COLUMN-MAJOR order (matching assembly)
21 // tiles[0] → $BF → (col 0, row 0) = top-left
22 // tiles[1] → $CB → (col 0, row 1) = bottom-left
23 // tiles[2] → $C2 → (col 1, row 0) = top-right
24 // tiles[3] → $CE → (col 1, row 1) = bottom-right
26 ctx.object.y_, ctx.tiles[0]); // col 0, row 0
28 ctx.object.y_ + 1, ctx.tiles[1]); // col 0, row 1
29 DrawRoutineUtils::WriteTile8(ctx.target_bg, ctx.object.x_ + (s * 2) + 1,
30 ctx.object.y_, ctx.tiles[2]); // col 1, row 0
31 DrawRoutineUtils::WriteTile8(ctx.target_bg, ctx.object.x_ + (s * 2) + 1,
32 ctx.object.y_ + 1, ctx.tiles[3]); // col 1, row 1
33 }
34 }
35}
36
38 // Pattern: Draws 2x4 tiles rightward (objects 0x01-0x02)
39 // Uses RoomDraw_Nx4 with N=2, tiles are COLUMN-MAJOR:
40 // [col0_row0, col0_row1, col0_row2, col0_row3, col1_row0, col1_row1, col1_row2, col1_row3]
41 int size = ctx.object.size_;
42 if (size == 0)
43 size = 26; // Special case
44
45 for (int s = 0; s < size; s++) {
46 if (ctx.tiles.size() >= 8) {
47 // Draw 2x4 pattern in COLUMN-MAJOR order (matching RoomDraw_Nx4)
48 // Column 0 (tiles 0-3)
50 ctx.object.y_, ctx.tiles[0]); // col 0, row 0
52 ctx.object.y_ + 1, ctx.tiles[1]); // col 0, row 1
54 ctx.object.y_ + 2, ctx.tiles[2]); // col 0, row 2
56 ctx.object.y_ + 3, ctx.tiles[3]); // col 0, row 3
57 // Column 1 (tiles 4-7)
58 DrawRoutineUtils::WriteTile8(ctx.target_bg, ctx.object.x_ + (s * 2) + 1,
59 ctx.object.y_, ctx.tiles[4]); // col 1, row 0
60 DrawRoutineUtils::WriteTile8(ctx.target_bg, ctx.object.x_ + (s * 2) + 1,
61 ctx.object.y_ + 1, ctx.tiles[5]); // col 1, row 1
62 DrawRoutineUtils::WriteTile8(ctx.target_bg, ctx.object.x_ + (s * 2) + 1,
63 ctx.object.y_ + 2, ctx.tiles[6]); // col 1, row 2
64 DrawRoutineUtils::WriteTile8(ctx.target_bg, ctx.object.x_ + (s * 2) + 1,
65 ctx.object.y_ + 3, ctx.tiles[7]); // col 1, row 3
66 } else if (ctx.tiles.size() >= 4) {
67 // Fallback: with 4 tiles we can only draw 1 column (1x4 pattern)
69 ctx.object.y_, ctx.tiles[0]);
71 ctx.object.y_ + 1, ctx.tiles[1]);
73 ctx.object.y_ + 2, ctx.tiles[2]);
75 ctx.object.y_ + 3, ctx.tiles[3]);
76 }
77 }
78}
79
81 // Pattern: Draws 2x4 tiles rightward with adjacent spacing (objects 0x03-0x04)
82 // Uses RoomDraw_Nx4 with N=2, tiles are COLUMN-MAJOR
83 // ASM: GetSize_1to16 means count = size + 1
84 int size = ctx.object.size_ & 0x0F;
85 int count = size + 1;
86
87 for (int s = 0; s < count; s++) {
88 if (ctx.tiles.size() >= 8) {
89 // Draw 2x4 pattern in COLUMN-MAJOR order with adjacent spacing (s * 2)
90 // Column 0 (tiles 0-3)
92 ctx.object.y_, ctx.tiles[0]); // col 0, row 0
94 ctx.object.y_ + 1, ctx.tiles[1]); // col 0, row 1
96 ctx.object.y_ + 2, ctx.tiles[2]); // col 0, row 2
98 ctx.object.y_ + 3, ctx.tiles[3]); // col 0, row 3
99 // Column 1 (tiles 4-7)
100 DrawRoutineUtils::WriteTile8(ctx.target_bg, ctx.object.x_ + (s * 2) + 1,
101 ctx.object.y_, ctx.tiles[4]); // col 1, row 0
102 DrawRoutineUtils::WriteTile8(ctx.target_bg, ctx.object.x_ + (s * 2) + 1,
103 ctx.object.y_ + 1, ctx.tiles[5]); // col 1, row 1
104 DrawRoutineUtils::WriteTile8(ctx.target_bg, ctx.object.x_ + (s * 2) + 1,
105 ctx.object.y_ + 2, ctx.tiles[6]); // col 1, row 2
106 DrawRoutineUtils::WriteTile8(ctx.target_bg, ctx.object.x_ + (s * 2) + 1,
107 ctx.object.y_ + 3, ctx.tiles[7]); // col 1, row 3
108 } else if (ctx.tiles.size() >= 4) {
109 // Fallback: with 4 tiles we can only draw 1 column (1x4 pattern)
111 ctx.object.y_, ctx.tiles[0]);
113 ctx.object.y_ + 1, ctx.tiles[1]);
115 ctx.object.y_ + 2, ctx.tiles[2]);
117 ctx.object.y_ + 3, ctx.tiles[3]);
118 }
119 }
120}
121
123 // USDASM: RoomDraw_Rightwards2x4spaced4_1to16_BothBG ($01:8C37)
124 //
125 // Despite the "_BothBG" suffix in usdasm, this routine does NOT explicitly
126 // write to both tilemaps; it uses the current tilemap pointers and is thus
127 // single-layer.
128 //
129 // Behavior: draw a 2x4 block, then advance by an additional 4 tiles before
130 // drawing the next block (net step = 2 tile width + 4 tile gap = 6 tiles).
131 int size = ctx.object.size_ & 0x0F;
132 int count = size + 1;
133
134 constexpr int kStepTiles = 6;
135
136 for (int s = 0; s < count; s++) {
137 const int base_x = ctx.object.x_ + (s * kStepTiles);
138
139 if (ctx.tiles.size() >= 8) {
140 // Column 0 (tiles 0-3)
141 DrawRoutineUtils::WriteTile8(ctx.target_bg, base_x + 0, ctx.object.y_,
142 ctx.tiles[0]); // col 0, row 0
144 ctx.object.y_ + 1, ctx.tiles[1]); // col 0, row 1
146 ctx.object.y_ + 2, ctx.tiles[2]); // col 0, row 2
148 ctx.object.y_ + 3, ctx.tiles[3]); // col 0, row 3
149
150 // Column 1 (tiles 4-7)
151 DrawRoutineUtils::WriteTile8(ctx.target_bg, base_x + 1, ctx.object.y_,
152 ctx.tiles[4]); // col 1, row 0
154 ctx.object.y_ + 1, ctx.tiles[5]); // col 1, row 1
156 ctx.object.y_ + 2, ctx.tiles[6]); // col 1, row 2
158 ctx.object.y_ + 3, ctx.tiles[7]); // col 1, row 3
159 } else if (ctx.tiles.size() >= 4) {
160 // Fallback: with 4 tiles we can only draw 1 column (1x4 pattern)
161 DrawRoutineUtils::WriteTile8(ctx.target_bg, base_x + 0, ctx.object.y_,
162 ctx.tiles[0]);
164 ctx.object.y_ + 1, ctx.tiles[1]);
166 ctx.object.y_ + 2, ctx.tiles[2]);
168 ctx.object.y_ + 3, ctx.tiles[3]);
169 }
170 }
171}
172
174 // Pattern: Draws 2x2 tiles rightward (objects 0x07-0x08)
175 // ROM tile order is COLUMN-MAJOR: [col0_row0, col0_row1, col1_row0, col1_row1]
176 int size = ctx.object.size_ & 0x0F;
177
178 // Assembly: JSR RoomDraw_GetSize_1to16
179 // GetSize_1to16: count = size + 1
180 int count = size + 1;
181
182 for (int s = 0; s < count; s++) {
183 if (ctx.tiles.size() >= 4) {
184 // Draw 2x2 pattern in COLUMN-MAJOR order (matching assembly)
186 ctx.object.y_, ctx.tiles[0]); // col 0, row 0
188 ctx.object.y_ + 1, ctx.tiles[1]); // col 0, row 1
189 DrawRoutineUtils::WriteTile8(ctx.target_bg, ctx.object.x_ + (s * 2) + 1,
190 ctx.object.y_, ctx.tiles[2]); // col 1, row 0
191 DrawRoutineUtils::WriteTile8(ctx.target_bg, ctx.object.x_ + (s * 2) + 1,
192 ctx.object.y_ + 1, ctx.tiles[3]); // col 1, row 1
193 }
194 }
195}
196
198 // Pattern: 1x3 tiles rightward with caps (object 0x21)
199 int size = ctx.object.size_ & 0x0F;
200
201 if (ctx.tiles.size() >= 9) {
202 auto draw_column = [&](int x, int base) {
204 ctx.tiles[base + 0]);
206 ctx.tiles[base + 1]);
208 ctx.tiles[base + 2]);
209 };
210
211 draw_column(ctx.object.x_, 0);
212
213 int mid_cols = (size + 1) * 2;
214 for (int s = 0; s < mid_cols; s++) {
215 draw_column(ctx.object.x_ + 1 + s, 3);
216 }
217
218 draw_column(ctx.object.x_ + 1 + mid_cols, 6);
219 return;
220 }
221
222 int count = (size * 2) + 1;
223 for (int s = 0; s < count; s++) {
224 if (ctx.tiles.size() >= 2) {
226 ctx.object.y_, ctx.tiles[0]);
228 ctx.object.y_ + 1, ctx.tiles[1]);
229 }
230 }
231}
232
234 // Pattern: Rail with corner/middle/end (object 0x22)
235 int size = ctx.object.size_ & 0x0F;
236
237 int count = size + 2;
238 if (ctx.tiles.size() < 3) return;
239
240 int x = ctx.object.x_;
242 x++;
243 for (int s = 0; s < count; s++) {
245 x++;
246 }
248}
249
251 // Pattern: Rail with corner/middle/end (objects 0x23-0x2E, 0x3F-0x46)
252 int size = ctx.object.size_ & 0x0F;
253
254 int count = size + 1;
255 if (ctx.tiles.size() < 3) return;
256
257 int x = ctx.object.x_;
259 x++;
260 for (int s = 0; s < count; s++) {
262 x++;
263 }
265}
266
268 // Pattern: Long rail with corner/middle/end (object 0x5F)
269 int size = ctx.object.size_ & 0x0F;
270 int count = size + 21;
271 if (ctx.tiles.size() < 3) return;
272
273 int x = ctx.object.x_;
275 x++;
276 for (int s = 0; s < count; s++) {
278 x++;
279 }
281}
282
284 // Pattern: Top corner 1x2 tiles with +13 offset (object 0x2F)
285 int size = ctx.object.size_ & 0x0F;
286
287 // Assembly: GetSize_1to16_timesA(0x0A), so count = size + 10
288 int count = size + 10;
289
290 for (int s = 0; s < count; s++) {
291 if (ctx.tiles.size() >= 2) {
292 // Use first tile span for 1x2 pattern
294 ctx.object.y_, ctx.tiles[0]);
296 ctx.object.y_ + 1, ctx.tiles[1]);
297 }
298 }
299}
300
302 // Pattern: Bottom corner 1x2 tiles with +13 offset (object 0x30)
303 int size = ctx.object.size_ & 0x0F;
304
305 // Assembly: GetSize_1to16_timesA(0x0A), so count = size + 10
306 int count = size + 10;
307
308 for (int s = 0; s < count; s++) {
309 if (ctx.tiles.size() >= 2) {
310 // Use first tile span for 1x2 pattern
312 ctx.object.y_ + 1, ctx.tiles[0]);
314 ctx.object.y_ + 2, ctx.tiles[1]);
315 }
316 }
317}
318
320 // Pattern: 4x4 block rightward (object 0x33)
321 int size = ctx.object.size_ & 0x0F;
322
323 // Assembly: GetSize_1to16, so count = size + 1
324 int count = size + 1;
325
326 for (int s = 0; s < count; s++) {
327 if (ctx.tiles.size() >= 16) {
328 // Draw 4x4 pattern in COLUMN-MAJOR order (matching assembly)
329 // Iterate columns (x) first, then rows (y) within each column
330 for (int x = 0; x < 4; ++x) {
331 for (int y = 0; y < 4; ++y) {
332 DrawRoutineUtils::WriteTile8(ctx.target_bg, ctx.object.x_ + (s * 4) + x,
333 ctx.object.y_ + y, ctx.tiles[x * 4 + y]);
334 }
335 }
336 }
337 }
338}
339
341 // Pattern: 1x1 solid tiles +3 offset (object 0x34)
342 int size = ctx.object.size_ & 0x0F;
343
344 // Assembly: GetSize_1to16_timesA(4), so count = size + 4
345 int count = size + 4;
346
347 for (int s = 0; s < count; s++) {
348 if (ctx.tiles.size() >= 1) {
349 // Use first 8x8 tile from span
351 ctx.object.y_, ctx.tiles[0]);
352 }
353 }
354}
355
357 // Pattern: 4x4 decoration with spacing (objects 0x36-0x37)
358 int size = ctx.object.size_ & 0x0F;
359
360 // Assembly: GetSize_1to16, so count = size + 1
361 int count = size + 1;
362
363 for (int s = 0; s < count; s++) {
364 if (ctx.tiles.size() >= 16) {
365 // Draw 4x4 pattern with spacing in COLUMN-MAJOR order (matching assembly)
366 for (int x = 0; x < 4; ++x) {
367 for (int y = 0; y < 4; ++y) {
368 DrawRoutineUtils::WriteTile8(ctx.target_bg, ctx.object.x_ + (s * 6) + x,
369 ctx.object.y_ + y, ctx.tiles[x * 4 + y]);
370 }
371 }
372 }
373 }
374}
375
377 // Pattern: 2x3 statue with spacing (object 0x38)
378 // 2 columns × 3 rows = 6 tiles in COLUMN-MAJOR order
379 int size = ctx.object.size_ & 0x0F;
380
381 // Assembly: GetSize_1to16, so count = size + 1
382 int count = size + 1;
383
384 for (int s = 0; s < count; s++) {
385 if (ctx.tiles.size() >= 6) {
386 // Draw 2x3 pattern in COLUMN-MAJOR order (matching assembly)
387 for (int x = 0; x < 2; ++x) {
388 for (int y = 0; y < 3; ++y) {
389 DrawRoutineUtils::WriteTile8(ctx.target_bg, ctx.object.x_ + (s * 4) + x,
390 ctx.object.y_ + y, ctx.tiles[x * 3 + y]);
391 }
392 }
393 }
394 }
395}
396
398 // Pattern: 2x4 pillar with spacing (objects 0x39, 0x3D)
399 // 2 columns × 4 rows = 8 tiles in COLUMN-MAJOR order
400 int size = ctx.object.size_ & 0x0F;
401
402 // Assembly: GetSize_1to16, so count = size + 1
403 int count = size + 1;
404
405 for (int s = 0; s < count; s++) {
406 if (ctx.tiles.size() >= 8) {
407 // Draw 2x4 pattern in COLUMN-MAJOR order (matching assembly)
408 for (int x = 0; x < 2; ++x) {
409 for (int y = 0; y < 4; ++y) {
410 DrawRoutineUtils::WriteTile8(ctx.target_bg, ctx.object.x_ + (s * 6) + x,
411 ctx.object.y_ + y, ctx.tiles[x * 4 + y]);
412 }
413 }
414 }
415 }
416}
417
419 // Pattern: 4x3 decoration with spacing (objects 0x3A-0x3B)
420 // 4 columns × 3 rows = 12 tiles in COLUMN-MAJOR order
421 int size = ctx.object.size_ & 0x0F;
422
423 // Assembly: GetSize_1to16, so count = size + 1
424 int count = size + 1;
425
426 for (int s = 0; s < count; s++) {
427 if (ctx.tiles.size() >= 12) {
428 // Draw 4x3 pattern in COLUMN-MAJOR order (matching assembly)
429 for (int x = 0; x < 4; ++x) {
430 for (int y = 0; y < 3; ++y) {
431 DrawRoutineUtils::WriteTile8(ctx.target_bg, ctx.object.x_ + (s * 6) + x,
432 ctx.object.y_ + y, ctx.tiles[x * 3 + y]);
433 }
434 }
435 }
436 }
437}
438
440 // Pattern: Doubled 2x2 with spacing (object 0x3C)
441 // 4 columns × 2 rows = 8 tiles in COLUMN-MAJOR order
442 int size = ctx.object.size_ & 0x0F;
443
444 // Assembly: GetSize_1to16, so count = size + 1
445 int count = size + 1;
446
447 for (int s = 0; s < count; s++) {
448 if (ctx.tiles.size() >= 8) {
449 // Draw doubled 2x2 pattern in COLUMN-MAJOR order (matching assembly)
450 for (int x = 0; x < 4; ++x) {
451 for (int y = 0; y < 2; ++y) {
452 DrawRoutineUtils::WriteTile8(ctx.target_bg, ctx.object.x_ + (s * 6) + x,
453 ctx.object.y_ + y, ctx.tiles[x * 2 + y]);
454 }
455 }
456 }
457 }
458}
459
461 // Pattern: 2x2 decoration with large spacing (object 0x3E)
462 int size = ctx.object.size_ & 0x0F;
463
464 // Assembly: GetSize_1to16, so count = size + 1
465 int count = size + 1;
466
467 for (int s = 0; s < count; s++) {
468 if (ctx.tiles.size() >= 4) {
469 // Draw 2x2 pattern in COLUMN-MAJOR order (matching assembly)
470 // tiles[0] → col 0, row 0 = top-left
471 // tiles[1] → col 0, row 1 = bottom-left
472 // tiles[2] → col 1, row 0 = top-right
473 // tiles[3] → col 1, row 1 = bottom-right
475 ctx.object.y_, ctx.tiles[0]); // col 0, row 0
477 ctx.object.y_ + 1, ctx.tiles[1]); // col 0, row 1
478 DrawRoutineUtils::WriteTile8(ctx.target_bg, ctx.object.x_ + (s * 14) + 1,
479 ctx.object.y_, ctx.tiles[2]); // col 1, row 0
480 DrawRoutineUtils::WriteTile8(ctx.target_bg, ctx.object.x_ + (s * 14) + 1,
481 ctx.object.y_ + 1, ctx.tiles[3]); // col 1, row 1
482 }
483 }
484}
485
486void RegisterRightwardsRoutines(std::vector<DrawRoutineInfo>& registry) {
487 // Note: Routine IDs are assigned based on the assembly routine table
488 // These rightwards routines are part of the core 40 draw routines
489 // Uses canonical IDs from DrawRoutineIds namespace
490
491 registry.push_back(DrawRoutineInfo{
493 .name = "Rightwards2x2_1to15or32",
494 .function = DrawRightwards2x2_1to15or32,
495 // USDASM: RoomDraw_Rightwards2x2_1to15or32 ($01:8B89) calls
496 // RoomDraw_Rightwards2x2 ($01:9895), which writes through the current
497 // tilemap pointer set (single-layer).
498 .draws_to_both_bgs = false,
499 .base_width = 2,
500 .base_height = 2,
501 .min_tiles = 4, // 2x2 block
503 });
504
505 registry.push_back(DrawRoutineInfo{
507 .name = "Rightwards2x4_1to15or26",
508 .function = DrawRightwards2x4_1to15or26,
509 // USDASM: RoomDraw_Rightwards2x4_1to15or26 ($01:8A92) uses RoomDraw_Nx4
510 // ($01:97F0) via pointers; single-layer.
511 .draws_to_both_bgs = false,
512 .base_width = 2,
513 .base_height = 4,
514 .min_tiles = 8, // 2x4 block
516 });
517
518 registry.push_back(DrawRoutineInfo{
520 .name = "Rightwards2x4_1to16",
521 .function = DrawRightwards2x4_1to16,
522 // USDASM: RoomDraw_Rightwards2x4spaced4_1to16 ($01:8B0D) explicitly
523 // writes to both tilemaps ($7E2000 and $7E4000).
524 .draws_to_both_bgs = true,
525 .base_width = 2, // Adjacent spacing (s * 2)
526 .base_height = 4,
527 .min_tiles = 8, // 2x4 block
529 });
530
531 registry.push_back(DrawRoutineInfo{
533 .name = "Rightwards2x4_1to16_BothBG",
535 // USDASM: RoomDraw_Rightwards2x4spaced4_1to16_BothBG ($01:8C37) uses
536 // RoomDraw_Nx4 through the current tilemap pointers (single-layer).
537 .draws_to_both_bgs = false,
538 .base_width = 2, // 2x4 blocks; repeat step is 6 tiles (2 wide + 4 gap)
539 .base_height = 4,
540 .min_tiles = 8, // 2x4 block
542 });
543
544 registry.push_back(DrawRoutineInfo{
546 .name = "Rightwards2x2_1to16",
547 .function = DrawRightwards2x2_1to16,
548 .draws_to_both_bgs = false,
549 .base_width = 2,
550 .base_height = 2,
551 .min_tiles = 4, // 2x2 block
553 });
554
555 registry.push_back(DrawRoutineInfo{
557 .name = "Rightwards1x2_1to16_plus2",
559 .draws_to_both_bgs = false,
560 .base_width = 4,
561 .base_height = 3,
562 .min_tiles = 2, // cap + middle tiles
564 });
565
566 registry.push_back(DrawRoutineInfo{
568 .name = "RightwardsHasEdge1x1_1to16_plus3",
570 .draws_to_both_bgs = false,
571 .base_width = 4,
572 .base_height = 1,
573 .min_tiles = 3, // left edge + middle + right edge
575 });
576
577 registry.push_back(DrawRoutineInfo{
579 .name = "RightwardsHasEdge1x1_1to16_plus2",
581 .draws_to_both_bgs = false,
582 .base_width = 3,
583 .base_height = 1,
584 .min_tiles = 3, // left edge + middle + right edge
586 });
587
588 registry.push_back(DrawRoutineInfo{
590 .name = "RightwardsHasEdge1x1_1to16_plus23",
592 .draws_to_both_bgs = false,
593 .base_width = 23,
594 .base_height = 1,
595 .min_tiles = 3, // left edge + middle + right edge
597 });
598
599 registry.push_back(DrawRoutineInfo{
601 .name = "RightwardsTopCorners1x2_1to16_plus13",
603 .draws_to_both_bgs = false,
604 .base_width = 1,
605 .base_height = 2,
606 .min_tiles = 2, // 1x2 pattern
608 });
609
610 registry.push_back(DrawRoutineInfo{
612 .name = "RightwardsBottomCorners1x2_1to16_plus13",
614 .draws_to_both_bgs = false,
615 .base_width = 1,
616 .base_height = 2, // spans y+1 to y+2
617 .min_tiles = 2, // 1x2 pattern
619 });
620
621 registry.push_back(DrawRoutineInfo{
623 .name = "Rightwards4x4_1to16",
624 .function = DrawRightwards4x4_1to16,
625 .draws_to_both_bgs = false,
626 .base_width = 4,
627 .base_height = 4,
628 .min_tiles = 16, // 4x4 block
630 });
631
632 registry.push_back(DrawRoutineInfo{
634 .name = "Rightwards1x1Solid_1to16_plus3",
636 .draws_to_both_bgs = false,
637 .base_width = 1,
638 .base_height = 1,
639 .min_tiles = 4, // solid fill uses 4 directional tiles
641 });
642
643 registry.push_back(DrawRoutineInfo{
645 .name = "RightwardsDecor4x4spaced2_1to16",
647 .draws_to_both_bgs = false,
648 .base_width = 6, // 4 tiles + 2 spacing
649 .base_height = 4,
650 .min_tiles = 16, // 4x4 block
652 });
653
654 registry.push_back(DrawRoutineInfo{
656 .name = "RightwardsStatue2x3spaced2_1to16",
658 .draws_to_both_bgs = false,
659 .base_width = 4, // 2 tiles + 2 spacing
660 .base_height = 3,
661 .min_tiles = 6, // 2x3 block
663 });
664
665 registry.push_back(DrawRoutineInfo{
667 .name = "RightwardsPillar2x4spaced4_1to16",
669 .draws_to_both_bgs = false,
670 .base_width = 6, // 2 tiles + 4 spacing
671 .base_height = 4,
672 .min_tiles = 8, // 2x4 block
674 });
675
676 registry.push_back(DrawRoutineInfo{
678 .name = "RightwardsDecor4x3spaced4_1to16",
680 .draws_to_both_bgs = false,
681 .base_width = 6, // 4 tiles + 2 spacing (actually the calculation seems off, kept as is)
682 .base_height = 3,
683 .min_tiles = 12, // 4x3 block
685 });
686
687 registry.push_back(DrawRoutineInfo{
689 .name = "RightwardsDoubled2x2spaced2_1to16",
691 .draws_to_both_bgs = false,
692 .base_width = 6, // 4 tiles + 2 spacing
693 .base_height = 2,
694 .min_tiles = 8, // 4x2 block
696 });
697
698 registry.push_back(DrawRoutineInfo{
700 .name = "RightwardsDecor2x2spaced12_1to16",
702 .draws_to_both_bgs = false,
703 .base_width = 14, // 2 tiles + 12 spacing
704 .base_height = 2,
705 .min_tiles = 4, // 2x2 block
707 });
708}
709
710} // namespace draw_routines
711} // namespace zelda3
712} // namespace yaze
constexpr int kRightwardsBottomCorners1x2_1to16_plus13
constexpr int kRightwardsTopCorners1x2_1to16_plus13
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 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 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 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 > &registry)
Register all rightwards draw routines to the registry.
void DrawRightwardsDecor4x3spaced4_1to16(const DrawContext &ctx)
Draw 4x3 decoration with spacing.
void DrawRightwards2x4_1to16_BothBG(const DrawContext &ctx)
Draw 2x4 tiles rightward with adjacent spacing to both BG layers.
void DrawRightwardsPillar2x4spaced4_1to16(const DrawContext &ctx)
Draw 2x4 pillar with spacing.
void DrawRightwardsDecor4x4spaced2_1to16(const DrawContext &ctx)
Draw 4x4 decoration with spacing.
Context passed to draw routines containing all necessary state.
std::span< const gfx::TileInfo > tiles
gfx::BackgroundBuffer & target_bg
Metadata about a draw routine.