Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Rubberduckycooly
GitHub Repository: Rubberduckycooly/RSDKv5-Decompilation
Path: blob/master/RSDKv5/RSDK/Graphics/Legacy/v3/DrawingLegacyv3.cpp
1171 views
1
2
void RSDK::Legacy::v3::DrawObjectList(int32 group)
3
{
4
int32 size = drawListEntries[group].listSize;
5
for (int32 i = 0; i < size; ++i) {
6
objectLoop = drawListEntries[group].entityRefs[i];
7
int32 type = objectEntityList[objectLoop].type;
8
9
if (type) {
10
activePlayer = 0;
11
if (scriptCode[objectScriptList[type].subDraw.scriptCodePtr] > 0)
12
ProcessScript(objectScriptList[type].subDraw.scriptCodePtr, objectScriptList[type].subDraw.jumpTablePtr, SUB_DRAW);
13
}
14
}
15
}
16
17
void RSDK::Legacy::v3::DrawStageGFX()
18
{
19
waterDrawPos = waterLevel - yScrollOffset;
20
21
if (waterDrawPos < 0)
22
waterDrawPos = 0;
23
24
if (waterDrawPos > SCREEN_YSIZE)
25
waterDrawPos = SCREEN_YSIZE;
26
27
DrawObjectList(0);
28
if (activeTileLayers[0] < LEGACY_LAYER_COUNT) {
29
switch (stageLayouts[activeTileLayers[0]].type) {
30
case LAYER_HSCROLL: DrawHLineScrollLayer(0); break;
31
case LAYER_VSCROLL: DrawVLineScrollLayer(0); break;
32
case LAYER_3DFLOOR: Draw3DFloorLayer(0); break;
33
case LAYER_3DSKY: Draw3DSkyLayer(0); break;
34
default: break;
35
}
36
}
37
38
DrawObjectList(1);
39
if (activeTileLayers[1] < LEGACY_LAYER_COUNT) {
40
switch (stageLayouts[activeTileLayers[1]].type) {
41
case LAYER_HSCROLL: DrawHLineScrollLayer(1); break;
42
case LAYER_VSCROLL: DrawVLineScrollLayer(1); break;
43
case LAYER_3DFLOOR: Draw3DFloorLayer(1); break;
44
case LAYER_3DSKY: Draw3DSkyLayer(1); break;
45
default: break;
46
}
47
}
48
49
DrawObjectList(2);
50
if (activeTileLayers[2] < LEGACY_LAYER_COUNT) {
51
switch (stageLayouts[activeTileLayers[2]].type) {
52
case LAYER_HSCROLL: DrawHLineScrollLayer(2); break;
53
case LAYER_VSCROLL: DrawVLineScrollLayer(2); break;
54
case LAYER_3DFLOOR: Draw3DFloorLayer(2); break;
55
case LAYER_3DSKY: Draw3DSkyLayer(2); break;
56
default: break;
57
}
58
}
59
60
DrawObjectList(3);
61
DrawObjectList(4);
62
if (activeTileLayers[3] < LEGACY_LAYER_COUNT) {
63
switch (stageLayouts[activeTileLayers[3]].type) {
64
case LAYER_HSCROLL: DrawHLineScrollLayer(3); break;
65
case LAYER_VSCROLL: DrawVLineScrollLayer(3); break;
66
case LAYER_3DFLOOR: Draw3DFloorLayer(3); break;
67
case LAYER_3DSKY: Draw3DSkyLayer(3); break;
68
default: break;
69
}
70
}
71
72
DrawObjectList(5);
73
// Extra Origins draw list
74
DrawObjectList(7);
75
DrawObjectList(6);
76
77
if (fadeMode > 0)
78
DrawRectangle(0, 0, SCREEN_XSIZE, SCREEN_YSIZE, fadeR, fadeG, fadeB, fadeA);
79
80
#if !RETRO_USE_ORIGINAL_CODE
81
DrawDebugOverlays();
82
#endif
83
}
84
85
#if !RETRO_USE_ORIGINAL_CODE
86
void RSDK::Legacy::v3::DrawDebugOverlays()
87
{
88
if (showHitboxes) {
89
90
for (int32 i = 0; i < debugHitboxCount; ++i) {
91
DebugHitboxInfo *info = &debugHitboxList[i];
92
int32 x = info->pos.x + (info->hitbox.left << 16);
93
int32 y = info->pos.y + (info->hitbox.top << 16);
94
int32 w = abs((info->pos.x + (info->hitbox.right << 16)) - x) >> 16;
95
int32 h = abs((info->pos.y + (info->hitbox.bottom << 16)) - y) >> 16;
96
x = (x >> 16) - xScrollOffset;
97
y = (y >> 16) - yScrollOffset;
98
99
switch (info->type) {
100
case H_TYPE_TOUCH:
101
if (showHitboxes & 1)
102
DrawRectangle(x, y, w, h, info->collision ? 0x80 : 0xFF, info->collision ? 0x80 : 0x00, 0x00, 0x60);
103
break;
104
105
case H_TYPE_BOX:
106
if (showHitboxes & 1) {
107
DrawRectangle(x, y, w, h, 0x00, 0x00, 0xFF, 0x60);
108
if (info->collision & 1) // top
109
DrawRectangle(x, y, w, 1, 0xFF, 0xFF, 0x00, 0xC0);
110
111
if (info->collision & 8) // bottom
112
DrawRectangle(x, y + h, w, 1, 0xFF, 0xFF, 0x00, 0xC0);
113
114
if (info->collision & 2) { // left
115
int32 sy = y;
116
int32 sh = h;
117
if (info->collision & 1) {
118
sy++;
119
sh--;
120
}
121
if (info->collision & 8)
122
sh--;
123
DrawRectangle(x, sy, 1, sh, 0xFF, 0xFF, 0x00, 0xC0);
124
}
125
126
if (info->collision & 4) { // right
127
int32 sy = y;
128
int32 sh = h;
129
if (info->collision & 1) {
130
sy++;
131
sh--;
132
}
133
if (info->collision & 8)
134
sh--;
135
DrawRectangle(x + w, sy, 1, sh, 0xFF, 0xFF, 0x00, 0xC0);
136
}
137
}
138
break;
139
140
case H_TYPE_PLAT:
141
if (showHitboxes & 1) {
142
DrawRectangle(x, y, w, h, 0x00, 0xFF, 0x00, 0x60);
143
144
if (info->collision & 1) // top
145
DrawRectangle(x, y, w, 1, 0xFF, 0xFF, 0x00, 0xC0);
146
147
if (info->collision & 8) // bottom
148
DrawRectangle(x, y + h, w, 1, 0xFF, 0xFF, 0x00, 0xC0);
149
}
150
break;
151
152
case H_TYPE_HAMMER:
153
if (showHitboxes & 1)
154
DrawRectangle(x, y, w, h, info->collision ? 0xA0 : 0xFF, info->collision ? 0xA0 : 0xFF, 0x00, 0x60);
155
break;
156
}
157
}
158
}
159
160
if (engine.showPaletteOverlay) {
161
for (int32 p = 0; p < LEGACY_PALETTE_COUNT; ++p) {
162
int32 x = (SCREEN_XSIZE - (0x10 << 3));
163
int32 y = (SCREEN_YSIZE - (0x10 << 2));
164
165
for (int32 c = 0; c < PALETTE_BANK_SIZE; ++c) {
166
uint32 clr = GetPaletteEntryPacked(p, c);
167
168
DrawRectangle(x + ((c & 0xF) << 1) + ((p % (LEGACY_PALETTE_COUNT / 2)) * (2 * 16)),
169
y + ((c >> 4) << 1) + ((p / (LEGACY_PALETTE_COUNT / 2)) * (2 * 16)), 2, 2, (clr >> 16) & 0xFF, (clr >> 8) & 0xFF,
170
(clr >> 0) & 0xFF, 0xFF);
171
}
172
}
173
}
174
}
175
#endif
176
177
bool32 RSDK::Legacy::v3::VideoSkipCB() { return controller->keyStart.press || controller->keyA.press || controller->keyB.press; }
178