Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rendering of fancy headups #254

Merged
merged 1 commit into from
Dec 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions src/DETHRACE/common/graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -2148,6 +2148,7 @@ void DRPixelmapRectangleShearedCopy(br_pixelmap* pDest, br_int_16 pDest_x, br_in
int last_shear_x;
int current_shear_x;
int shear_x_difference;
int pWidth_orig;
tU8 the_byte;
tU8* source_ptr;
tU8* dest_ptr;
Expand Down Expand Up @@ -2186,13 +2187,27 @@ void DRPixelmapRectangleShearedCopy(br_pixelmap* pDest, br_int_16 pDest_x, br_in
pDest_x = 0;
}
if (pDest->width > pDest_x) {
if (pDest_x + pWidth > pDest->width) {
shear_x_difference = pDest_x + pWidth - pDest->width;
pWidth = pDest->width - pDest_x;
source_row_wrap += shear_x_difference;
dest_row_wrap += shear_x_difference;
}
pWidth_orig = pWidth;
for (y_count = 0; pHeight > y_count; ++y_count) {
#if !defined(DETHRACE_FIX_BUGS)
/*
* The OG compares against pWidth instead of pWidth_orig, which
* ends up clipped to the dest pixelmap width. This effectively
* clips the consecutive rows of pixels along the shear, leaving
* a visible gap on the screen. Instead, when comparing against
* pWidth_orig, the clip takes place vertically along the dest
* pixelmap edge, allowing all pixels to be displayed.
*
* Simulate OG behavior by overwriting pWidth_orig with pWidth.
*/
pWidth_orig = pWidth;
#endif
if (pDest_x + pWidth_orig > pDest->width) {
shear_x_difference = pDest_x + pWidth - pDest->width;
pWidth = pDest->width - pDest_x;
source_row_wrap += shear_x_difference;
dest_row_wrap += shear_x_difference;
}
for (x_count = 0; pWidth > x_count; ++x_count) {
the_byte = *source_ptr++;
if (the_byte) {
Expand All @@ -2217,12 +2232,6 @@ void DRPixelmapRectangleShearedCopy(br_pixelmap* pDest, br_int_16 pDest_x, br_in
if (pDest->width <= pDest_x) {
break;
}
if (pDest_x + pWidth > pDest->width) {
shear_x_difference = pDest_x + pWidth - pDest->width;
pWidth = pDest->width - pDest_x;
source_row_wrap += shear_x_difference;
dest_row_wrap += shear_x_difference;
}
}
}
}
Expand Down