Fix incorrect arguments on CopyRectToBgTilemapBufferRect

This commit is contained in:
GriffinR 2021-10-29 11:51:47 -04:00
parent 07bf225f94
commit 901cd476b6
4 changed files with 20 additions and 21 deletions

View File

@ -950,7 +950,7 @@ void CopyToBgTilemapBufferRect_ChangePalette(u8 bg, const void *src, u8 destX, u
CopyRectToBgTilemapBufferRect(bg, src, 0, 0, rectWidth, rectHeight, destX, destY, rectWidth, rectHeight, palette, 0, 0); CopyRectToBgTilemapBufferRect(bg, src, 0, 0, rectWidth, rectHeight, destX, destY, rectWidth, rectHeight, palette, 0, 0);
} }
void CopyRectToBgTilemapBufferRect(u8 bg, const void *src, u8 srcX, u8 srcY, u8 srcWidth, u8 unused, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, s16 palette1, s16 tileOffset) void CopyRectToBgTilemapBufferRect(u8 bg, const void *src, u8 srcX, u8 srcY, u8 srcWidth, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette1, s16 tileOffset, s16 palette2)
{ {
u16 screenWidth, screenHeight, screenSize; u16 screenWidth, screenHeight, screenSize;
u16 var; u16 var;
@ -966,28 +966,28 @@ void CopyRectToBgTilemapBufferRect(u8 bg, const void *src, u8 srcX, u8 srcY, u8
{ {
case BG_TYPE_NORMAL: case BG_TYPE_NORMAL:
srcPtr = src + ((srcY * srcWidth) + srcX) * 2; srcPtr = src + ((srcY * srcWidth) + srcX) * 2;
for (i = destX; i < (destX + rectWidth); i++) for (i = destY; i < (destY + rectHeight); i++)
{ {
for (j = srcHeight; j < (srcHeight + destY); j++) for (j = destX; j < (destX + rectWidth); j++)
{ {
u16 index = GetTileMapIndexFromCoords(j, i, screenSize, screenWidth, screenHeight); u16 index = GetTileMapIndexFromCoords(j, i, screenSize, screenWidth, screenHeight);
CopyTileMapEntry(srcPtr, sGpuBgConfigs2[bg].tilemap + (index * 2), rectHeight, palette1, tileOffset); CopyTileMapEntry(srcPtr, sGpuBgConfigs2[bg].tilemap + (index * 2), palette1, tileOffset, palette2);
srcPtr += 2; srcPtr += 2;
} }
srcPtr += (srcWidth - destY) * 2; srcPtr += (srcWidth - rectWidth) * 2;
} }
break; break;
case BG_TYPE_AFFINE: case BG_TYPE_AFFINE:
srcPtr = src + ((srcY * srcWidth) + srcX); srcPtr = src + ((srcY * srcWidth) + srcX);
var = GetBgMetricAffineMode(bg, 0x1); var = GetBgMetricAffineMode(bg, 0x1);
for (i = destX; i < (destX + rectWidth); i++) for (i = destY; i < (destY + rectHeight); i++)
{ {
for (j = srcHeight; j < (srcHeight + destY); j++) for (j = destX; j < (destX + rectWidth); j++)
{ {
*(u8*)(sGpuBgConfigs2[bg].tilemap + ((var * i) + j)) = *(u8*)(srcPtr) + palette1; *(u8*)(sGpuBgConfigs2[bg].tilemap + ((var * i) + j)) = *(u8*)(srcPtr) + tileOffset;
srcPtr++; srcPtr++;
} }
srcPtr += (srcWidth - destY); srcPtr += (srcWidth - rectWidth);
} }
break; break;
} }

View File

@ -72,7 +72,7 @@ void CopyToBgTilemapBuffer(u8 bg, const void *src, u16 mode, u16 destOffset);
void CopyBgTilemapBufferToVram(u8 bg); void CopyBgTilemapBufferToVram(u8 bg);
void CopyToBgTilemapBufferRect(u8 bg, const void* src, u8 destX, u8 destY, u8 width, u8 height); void CopyToBgTilemapBufferRect(u8 bg, const void* src, u8 destX, u8 destY, u8 width, u8 height);
void CopyToBgTilemapBufferRect_ChangePalette(u8 bg, const void *src, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette); void CopyToBgTilemapBufferRect_ChangePalette(u8 bg, const void *src, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette);
void CopyRectToBgTilemapBufferRect(u8 bg, const void *src, u8 srcX, u8 srcY, u8 srcWidth, u8 unused, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, s16 palette1, s16 tileOffset); void CopyRectToBgTilemapBufferRect(u8 bg, const void *src, u8 srcX, u8 srcY, u8 srcWidth, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette1, s16 tileOffset, s16 palette2);
void FillBgTilemapBufferRect_Palette0(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height); void FillBgTilemapBufferRect_Palette0(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height);
void FillBgTilemapBufferRect(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height, u8 palette); void FillBgTilemapBufferRect(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height, u8 palette);
void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 width, u8 height, u8 paletteSlot, s16 tileNumDelta); void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 width, u8 height, u8 paletteSlot, s16 tileNumDelta);

View File

@ -2792,7 +2792,7 @@ static void SwitchSelectedMons(u8 taskId)
// returns FALSE if the slot has slid fully offscreen / back onscreen // returns FALSE if the slot has slid fully offscreen / back onscreen
static bool8 TryMovePartySlot(s16 x, s16 width, u8 *leftMove, u8 *newX, u8 *newWidth) static bool8 TryMovePartySlot(s16 x, s16 width, u8 *leftMove, u8 *newX, u8 *newWidth)
{ {
if ((x + width) < 0) if (x + width < 0)
return FALSE; return FALSE;
if (x > 31) if (x > 31)
return FALSE; return FALSE;
@ -2807,7 +2807,7 @@ static bool8 TryMovePartySlot(s16 x, s16 width, u8 *leftMove, u8 *newX, u8 *newW
{ {
*leftMove = 0; *leftMove = 0;
*newX = x; *newX = x;
if ((x + width) > 31) if (x + width > 31)
*newWidth = 32 - x; *newWidth = 32 - x;
else else
*newWidth = width; *newWidth = width;
@ -2818,14 +2818,13 @@ static bool8 TryMovePartySlot(s16 x, s16 width, u8 *leftMove, u8 *newX, u8 *newW
static void MoveAndBufferPartySlot(const void *rectSrc, s16 x, s16 y, s16 width, s16 height, s16 dir) static void MoveAndBufferPartySlot(const void *rectSrc, s16 x, s16 y, s16 width, s16 height, s16 dir)
{ {
// The use of the dimension parameters here is a mess u8 srcX, newX, newWidth;
u8 leftMove, newX, newWidth; // leftMove is used as a srcX, newX is used as both x and srcHeight, newWidth is used as both width and destY
if (TryMovePartySlot(x, width, &leftMove, &newX, &newWidth)) if (TryMovePartySlot(x, width, &srcX, &newX, &newWidth))
{ {
FillBgTilemapBufferRect_Palette0(0, 0, newX, y, newWidth, height); FillBgTilemapBufferRect_Palette0(0, 0, newX, y, newWidth, height);
if (TryMovePartySlot(x + dir, width, &leftMove, &newX, &newWidth)) if (TryMovePartySlot(x + dir, width, &srcX, &newX, &newWidth))
CopyRectToBgTilemapBufferRect(0, rectSrc, leftMove, 0, width, height, newX, y, newWidth, height, 17, 0, 0); CopyRectToBgTilemapBufferRect(0, rectSrc, srcX, 0, width, height, newX, y, newWidth, height, 17, 0, 0);
} }
} }

View File

@ -5437,16 +5437,16 @@ static bool32 WaitForWallpaperGfxLoad(void)
static void DrawWallpaper(const void *tilemap, s8 direction, u8 offset) static void DrawWallpaper(const void *tilemap, s8 direction, u8 offset)
{ {
s16 var = offset * 256; s16 tileOffset = offset * 256;
s16 var2 = (offset * 2) + 3; s16 paletteNum = (offset * 2) + 3;
s16 x = ((sStorage->bg2_X / 8 + 10) + (direction * 24)) & 0x3F; s16 x = ((sStorage->bg2_X / 8 + 10) + (direction * 24)) & 0x3F;
CopyRectToBgTilemapBufferRect(2, tilemap, 0, 0, 0x14, 0x12, x, 2, 0x14, 0x12, 0x11, var, var2); CopyRectToBgTilemapBufferRect(2, tilemap, 0, 0, 20, 18, x, 2, 20, 18, 17, tileOffset, paletteNum);
if (direction == 0) if (direction == 0)
return; return;
if (direction > 0) if (direction > 0)
x += 0x14; x += 20;
else else
x -= 4; x -= 4;