Commit f21351f0 authored by Jordon Moss's avatar Jordon Moss Committed by Evan Ramos

mapster32/build: Make AlignWalls_ not a partially broken, cryptic mess....

mapster32/build: Make AlignWalls_ not a partially broken, cryptic mess. Correctly aligns textures of any size now.
parent 4c1d40cc
......@@ -10933,8 +10933,6 @@ static int32_t GetWallBaseZ(int32_t wallnum)
static void AlignWalls_(int32_t tilenum, int32_t z0, int32_t z1, int32_t doxpanning,
int32_t w0_pan, int32_t w0_rep, int32_t w1_pan, int32_t w1_rep)
{
int32_t n;
if (tilesiz[tilenum].x==0 || tilesiz[tilenum].y==0)
return;
......@@ -10942,10 +10940,31 @@ static void AlignWalls_(int32_t tilenum, int32_t z0, int32_t z1, int32_t doxpann
if (doxpanning)
wall[w1_pan].xpanning = (uint8_t)((wall[w0_pan].xpanning + (wall[w0_rep].xrepeat<<3))%tilesiz[tilenum].x);
for (n=picsiz[tilenum]>>4; (1<<n)<tilesiz[tilenum].y; n++) { }
int32_t zDiff = z1 - z0; // Z difference between current wall floor or ceiling, and the next.
uint8_t first_yPan = wall[w0_pan].ypanning; // Y panning of first wall
uint8_t first_yRepeat = wall[w0_rep].yrepeat; // Y repeat of first wall
wall[w1_rep].yrepeat = wall[w0_rep].yrepeat;
wall[w1_pan].ypanning = (uint8_t)(wall[w0_pan].ypanning + (((z1-z0)*wall[w0_rep].yrepeat)>>(n+3)));
int32_t yPan_offset = ((zDiff * first_yRepeat) / (tilesiz[tilenum].y * 8)); // y-panning offset.
uint8_t second_yPan = (uint8_t)(yPan_offset + first_yPan); // The final y-panning for the second wall
#if 0
OSD_Printf("----------------\n"
"Auto-Align Debug\n"
"w0_pan: %d\n"
"w1_pan: %d\n"
"z0: %d\n"
"z1: %d\n"
"zDiff: %d\n"
"first_yPan: %d\n"
"first_yRepeat: %d\n"
"ypan_offset: %d\n"
"second_yPan: %d\n"
, w0_pan, w1_pan, z0, z1, zDiff, first_yPan, first_yRepeat, yPan_offset, second_yPan);
#endif
wall[w1_rep].yrepeat = first_yRepeat;
wall[w1_pan].ypanning = second_yPan;
}
static void AlignWalls(int32_t w0, int32_t z0, int32_t w1, int32_t z1, int32_t doxpanning)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment