Skip to content

Commit

Permalink
[MX] Reformat rasterizer code
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFakeMontyOnTheRun committed Aug 13, 2023
1 parent 6c0b7f3 commit cb9ccfb
Showing 1 changed file with 44 additions and 43 deletions.
87 changes: 44 additions & 43 deletions mx_frontend/base3d/src/CRenderer_Rasterization.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ void maskWall(
if (dX == 0) {
return;
} else {
FixP_t oneOverDx;

if (dX > 0 && dX < intToFix(320) ) {
oneOverDx = divLut[limit - x];
} else {
oneOverDx = Div(intToFix(1), dX);
}
FixP_t oneOverDx;

if (dX > 0 && dX < intToFix(320)) {
oneOverDx = divLut[limit - x];
} else {
oneOverDx = Div(intToFix(1), dX);
}

upperDyDx = Mul(upperDy, oneOverDx);
lowerDyDx = Mul(lowerDy, oneOverDx);
}
Expand Down Expand Up @@ -277,13 +277,13 @@ void drawWall(FixP_t x0,
if (dX == 0) {
return;
} else {
FixP_t oneOverDx;
FixP_t oneOverDx;

if (dX > 0 && dX < intToFix(320)) {
oneOverDx = divLut[limit - x];
} else {
oneOverDx = Div(intToFix(1), dX);
}
if (dX > 0 && dX < intToFix(320)) {
oneOverDx = divLut[limit - x];
} else {
oneOverDx = Div(intToFix(1), dX);
}

upperDyDx = Mul(upperDy, oneOverDx);
lowerDyDx = Mul(lowerDy, oneOverDx);
Expand Down Expand Up @@ -484,10 +484,10 @@ void drawFrontWall(FixP_t x0,
return;
}

if (diffX > 0 && diffX < intToFix(320) ) {
du = Mul(FIXP_NATIVE_TEXTURE_SIZE, divLut[iX1 - iX0]);
if (diffX > 0 && diffX < intToFix(320)) {
du = Mul(FIXP_NATIVE_TEXTURE_SIZE, divLut[iX1 - iX0]);
} else {
du = Div(FIXP_NATIVE_TEXTURE_SIZE, diffX);
du = Div(FIXP_NATIVE_TEXTURE_SIZE, diffX);
}


Expand Down Expand Up @@ -640,13 +640,13 @@ void maskFloor(FixP_t y0, FixP_t y1, FixP_t x0y0, FixP_t x1y0, FixP_t x0y1, FixP
if (dY == 0) {
return;
} else {
FixP_t oneOverDy;
if (dY > 0 && dY < intToFix(320) ) {
oneOverDy = divLut[limit - y];
} else {
oneOverDy = Div(intToFix(1), dY);
}
FixP_t oneOverDy;
if (dY > 0 && dY < intToFix(320)) {
oneOverDy = divLut[limit - y];
} else {
oneOverDy = Div(intToFix(1), dY);
}

leftDxDy = Mul(leftDX, oneOverDy);
rightDxDy = Mul(rightDX, oneOverDy);
}
Expand Down Expand Up @@ -795,13 +795,13 @@ void drawFloor(FixP_t y0,
if (dY == 0) {
return;
} else {
FixP_t oneOverDy;
if (dY > 0 && dY < intToFix(320) ) {
oneOverDy = divLut[limit - y];
} else {
oneOverDy = Div(intToFix(1), dY);
}
FixP_t oneOverDy;
if (dY > 0 && dY < intToFix(320)) {
oneOverDy = divLut[limit - y];
} else {
oneOverDy = Div(intToFix(1), dY);
}

leftDxDy = Mul(leftDX, oneOverDy);
rightDxDy = Mul(rightDX, oneOverDy);
dv = Mul(FIXP_NATIVE_TEXTURE_SIZE, oneOverDy);
Expand Down Expand Up @@ -844,7 +844,7 @@ void drawFloor(FixP_t y0,
iX1 = fixToInt(x1);

if (diffX != lastDiffX) {
if (diffX > 0 && diffX < intToFix(320) ) {
if (diffX > 0 && diffX < intToFix(320)) {
du = Mul(FIXP_NATIVE_TEXTURE_SIZE, divLut[iX1 - iX0]);
} else {
du = Div(FIXP_NATIVE_TEXTURE_SIZE, diffX);
Expand Down Expand Up @@ -1177,12 +1177,12 @@ void drawTexturedBottomFlatTriangle(int *coords, uint8_t *uvCoords, struct Textu

if (limit) {
uint8_t *destination;
if (limit > 0 && limit < 320 ) {
oneOverLimit = divLut[limit];
} else {
oneOverLimit = Div(intToFix(1), (fX1 - fX0));
}
if (limit > 0 && limit < 320) {
oneOverLimit = divLut[limit];
} else {
oneOverLimit = Div(intToFix(1), (fX1 - fX0));
}


destination = &framebuffer[(XRES_FRAMEBUFFER * y) + iFX0];

Expand Down Expand Up @@ -1330,11 +1330,11 @@ void drawTexturedTopFlatTriangle(int *coords, uint8_t *uvCoords, struct Texture

if (limit) {
uint8_t *destination;
if (limit > 0 && limit < 320 ) {
oneOverLimit = divLut[limit];
} else {
oneOverLimit = Div(intToFix(1), (fX1 - fX0));
}
if (limit > 0 && limit < 320) {
oneOverLimit = divLut[limit];
} else {
oneOverLimit = Div(intToFix(1), (fX1 - fX0));
}


destination = &framebuffer[(XRES_FRAMEBUFFER * y) + iFX0];
Expand Down Expand Up @@ -1454,6 +1454,7 @@ void drawTexturedTriangle(int *coords, uint8_t *uvCoords, struct Texture *textur
#ifdef AGS
__attribute__((target("arm"), section(".iwram"), noinline))
#endif

void fill(
const int x,
const int y,
Expand Down

0 comments on commit cb9ccfb

Please sign in to comment.