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 garbage column in bunny scroll #1952

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
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
10 changes: 6 additions & 4 deletions src/doomtype.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,12 @@ typedef byte lighttable_t;

#define BETWEEN(l, u, x) ((l) > (x) ? (l) : (x) > (u) ? (u) : (x))

inline static int DivRoundClosest(const int n, const int d)
{
return ((n < 0) == (d < 0)) ? ((n + d / 2) / d) : ((n - d / 2) / d);
}
#define DIV_ROUND_FLOOR(n, d) (((n) - (d) / 2) / (d))

#define DIV_ROUND_CEIL(n, d) (((n) + (d) / 2) / (d))

#define DIV_ROUND_CLOSEST(n, d) \
(((n) < 0) == ((d) < 0)) ? DIV_ROUND_CEIL(n, d) : DIV_ROUND_FLOOR(n, d)

#if defined(_MSC_VER) && !defined(__cplusplus)
#define inline __inline
Expand Down
4 changes: 2 additions & 2 deletions src/f_finale.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,13 +696,13 @@ void F_BunnyScroll (void)

scrolled = 320 - (finalecount-230)/2;

int p1offset = DivRoundClosest(video.unscaledw - SHORT(p1->width), 2);
int p1offset = DIV_ROUND_CEIL(video.unscaledw - SHORT(p1->width), 2);
if (SHORT(p1->width) == 320)
{
p1offset += (SHORT(p2->width) - 320) / 2;
}

int p2offset = DivRoundClosest(video.unscaledw - SHORT(p2->width), 2);
int p2offset = DIV_ROUND_CEIL(video.unscaledw - SHORT(p2->width), 2);

if (scrolled <= 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/v_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ void V_DrawPatchTRTR(int x, int y, patch_t *patch, byte *outr1, byte *outr2)

void V_DrawPatchFullScreen(patch_t *patch)
{
const int x = DivRoundClosest(video.unscaledw - SHORT(patch->width), 2);
const int x = DIV_ROUND_CLOSEST(video.unscaledw - SHORT(patch->width), 2);

patch->leftoffset = 0;
patch->topoffset = 0;
Expand Down