yaze
0.3.2
Link to the Past ROM Editor
Loading...
Searching...
No Matches
diagonal_routines.cc
Go to the documentation of this file.
1
#include "
diagonal_routines.h
"
2
3
#include "
zelda3/dungeon/draw_routines/draw_routine_registry.h
"
4
#include "
zelda3/dungeon/room_object.h
"
5
6
namespace
yaze
{
7
namespace
zelda3 {
8
namespace
draw_routines {
9
10
namespace
{
11
12
// USDASM routines 5/6 load size+7, then enter the shared loop at the label
13
// that decrements once before the first draw. Routines 17/18 load size+6 and
14
// enter before the draw. Both paths therefore render exactly size+6 columns.
15
void
DrawDiagonalColumns
(
const
DrawContext
& ctx,
int
y_step) {
16
if
(ctx.
tiles
.size() < 5) {
17
return
;
18
}
19
20
const
int
count = (ctx.
object
.
size_
& 0x0F) + 6;
21
for
(
int
step = 0; step < count; ++step) {
22
const
int
tile_x = ctx.
object
.
x_
+ step;
23
const
int
tile_y = ctx.
object
.
y_
+ step * y_step;
24
for
(
int
row = 0; row < 5; ++row) {
25
DrawRoutineUtils::WriteTile8
(ctx.
target_bg
, tile_x, tile_y + row,
26
ctx.
tiles
[row]);
27
}
28
}
29
}
30
31
}
// namespace
32
33
void
DrawDiagonalAcute_1to16
(
const
DrawContext
& ctx) {
34
DrawDiagonalColumns(ctx,
/*y_step=*/
-1);
35
}
36
37
void
DrawDiagonalGrave_1to16
(
const
DrawContext
& ctx) {
38
DrawDiagonalColumns(ctx,
/*y_step=*/
1);
39
}
40
41
void
DrawDiagonalAcute_1to16_BothBG
(
const
DrawContext
& ctx) {
42
DrawDiagonalColumns(ctx,
/*y_step=*/
-1);
43
}
44
45
void
DrawDiagonalGrave_1to16_BothBG
(
const
DrawContext
& ctx) {
46
DrawDiagonalColumns(ctx,
/*y_step=*/
1);
47
}
48
49
void
RegisterDiagonalRoutines
(std::vector<DrawRoutineInfo>& registry) {
50
// Note: Routine IDs are assigned based on the assembly routine table
51
// These diagonal routines are part of the core 40 draw routines
52
53
registry.push_back(
DrawRoutineInfo
{
54
.
id
= 5,
// RoomDraw_DiagonalAcute_1to16
55
.name =
"DiagonalAcute_1to16"
,
56
.function =
DrawDiagonalAcute_1to16
,
57
.draws_to_both_bgs =
false
,
58
.base_width = 0,
// Variable based on size parameter
59
.base_height = 5,
60
.min_tiles = 5,
// 2x2 + 1 diagonal step
61
.category =
DrawRoutineInfo::Category::Diagonal
,
62
});
63
64
registry.push_back(
DrawRoutineInfo
{
65
.
id
= 6,
// RoomDraw_DiagonalGrave_1to16
66
.name =
"DiagonalGrave_1to16"
,
67
.function =
DrawDiagonalGrave_1to16
,
68
.draws_to_both_bgs =
false
,
69
.base_width = 0,
// Variable based on size parameter
70
.base_height = 5,
71
.min_tiles = 5,
// 2x2 + 1 diagonal step
72
.category =
DrawRoutineInfo::Category::Diagonal
,
73
});
74
75
registry.push_back(
DrawRoutineInfo
{
76
.
id
= 17,
// RoomDraw_DiagonalAcute_1to16_BothBG
77
.name =
"DiagonalAcute_1to16_BothBG"
,
78
.function =
DrawDiagonalAcute_1to16_BothBG
,
79
.draws_to_both_bgs =
true
,
80
.base_width = 0,
// Variable based on size parameter
81
.base_height = 5,
82
.min_tiles = 5,
// 2x2 + 1 diagonal step
83
.category =
DrawRoutineInfo::Category::Diagonal
,
84
});
85
86
registry.push_back(
DrawRoutineInfo
{
87
.
id
= 18,
// RoomDraw_DiagonalGrave_1to16_BothBG
88
.name =
"DiagonalGrave_1to16_BothBG"
,
89
.function =
DrawDiagonalGrave_1to16_BothBG
,
90
.draws_to_both_bgs =
true
,
91
.base_width = 0,
// Variable based on size parameter
92
.base_height = 5,
93
.min_tiles = 5,
// 2x2 + 1 diagonal step
94
.category =
DrawRoutineInfo::Category::Diagonal
,
95
});
96
}
97
98
}
// namespace draw_routines
99
}
// namespace zelda3
100
}
// namespace yaze
yaze::zelda3::RoomObject::x_
uint8_t x_
Definition
room_object.h:195
yaze::zelda3::RoomObject::size_
uint8_t size_
Definition
room_object.h:197
yaze::zelda3::RoomObject::y_
uint8_t y_
Definition
room_object.h:196
diagonal_routines.h
draw_routine_registry.h
yaze::zelda3::DrawRoutineUtils::WriteTile8
void WriteTile8(gfx::BackgroundBuffer &bg, int tile_x, int tile_y, const gfx::TileInfo &tile_info)
Write an 8x8 tile to the background buffer.
Definition
draw_routine_types.cc:30
yaze::zelda3::draw_routines::anonymous_namespace{diagonal_routines.cc}::DrawDiagonalColumns
void DrawDiagonalColumns(const DrawContext &ctx, int y_step)
Definition
diagonal_routines.cc:15
yaze::zelda3::draw_routines::RegisterDiagonalRoutines
void RegisterDiagonalRoutines(std::vector< DrawRoutineInfo > ®istry)
Register all diagonal draw routines to the registry.
Definition
diagonal_routines.cc:49
yaze::zelda3::draw_routines::DrawDiagonalGrave_1to16_BothBG
void DrawDiagonalGrave_1to16_BothBG(const DrawContext &ctx)
Draw diagonal grave () pattern for both BG layers.
Definition
diagonal_routines.cc:45
yaze::zelda3::draw_routines::DrawDiagonalAcute_1to16_BothBG
void DrawDiagonalAcute_1to16_BothBG(const DrawContext &ctx)
Draw diagonal acute (/) pattern for both BG layers.
Definition
diagonal_routines.cc:41
yaze::zelda3::draw_routines::DrawDiagonalAcute_1to16
void DrawDiagonalAcute_1to16(const DrawContext &ctx)
Draw diagonal acute (/) pattern - draws 5 tiles vertically, moves up-right.
Definition
diagonal_routines.cc:33
yaze::zelda3::draw_routines::DrawDiagonalGrave_1to16
void DrawDiagonalGrave_1to16(const DrawContext &ctx)
Draw diagonal grave () pattern - draws 5 tiles vertically, moves down-right.
Definition
diagonal_routines.cc:37
yaze
Definition
patch_export_usage.cc:8
room_object.h
yaze::zelda3::DrawContext
Context passed to draw routines containing all necessary state.
Definition
draw_routine_types.h:27
yaze::zelda3::DrawContext::tiles
std::span< const gfx::TileInfo > tiles
Definition
draw_routine_types.h:30
yaze::zelda3::DrawContext::target_bg
gfx::BackgroundBuffer & target_bg
Definition
draw_routine_types.h:28
yaze::zelda3::DrawContext::object
const RoomObject & object
Definition
draw_routine_types.h:29
yaze::zelda3::DrawRoutineInfo
Metadata about a draw routine.
Definition
draw_routine_types.h:59
yaze::zelda3::DrawRoutineInfo::id
int id
Definition
draw_routine_types.h:60
yaze::zelda3::DrawRoutineInfo::Category::Diagonal
@ Diagonal
src
zelda3
dungeon
draw_routines
diagonal_routines.cc
Generated by
1.10.0