Skip to content

Commit

Permalink
fixed tileBufferIsTileOnBuffer() region check
Browse files Browse the repository at this point in the history
previous version allowed drawing on outermost margins, which resulted in drawing stuff when it shouldn't be drawn
  • Loading branch information
tehKaiN committed Apr 16, 2019
1 parent 5f974de commit 5ba6a43
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/ace/managers/viewport/scrollbuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ void scrollBufferReset(
pManager->uwVpHeightPrev = 0;
pManager->uBfrBounds.sUwCoord.uwX = uwBoundWidth;
pManager->uBfrBounds.sUwCoord.uwY = uwBoundHeight;
// TODO optimize avail height to power of two so that modulo can be an AND
// Optimize avail height to power of two so that modulo can be an AND
pManager->uwBmAvailHeight = nearestPowerOf2(ubMarginWidth * (blockCountCeil(uwVpHeight, ubMarginWidth) + 4));

// Destroy old buffer bitmap
Expand Down
5 changes: 3 additions & 2 deletions src/ace/managers/viewport/tilebuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ tTileBufferManager *tileBufferCreate(void *pTags, ...) {
logWrite(
"ERR: No tile boundaries (TAG_TILEBUFFER_BOUND_TILE_X or _Y) specified!\n"
);
goto fail;
}

pManager->pTileData = 0;
Expand Down Expand Up @@ -538,9 +539,9 @@ UBYTE tileBufferIsTileOnBuffer(
) {
UBYTE ubTileShift = pManager->ubTileShift;
UWORD uwStartX = MAX(0, (pManager->pCamera->uPos.sUwCoord.uwX >> ubTileShift) -1);
UWORD uwEndX = uwStartX + (pManager->uwMarginedWidth >> ubTileShift);
UWORD uwEndX = uwStartX + ((pManager->uwMarginedWidth >> ubTileShift) - 2);
UWORD uwStartY = MAX(0, (pManager->pCamera->uPos.sUwCoord.uwY >> ubTileShift) -1);
UWORD uwEndY = uwStartY + (pManager->uwMarginedHeight >> ubTileShift);
UWORD uwEndY = uwStartY + ((pManager->uwMarginedHeight >> ubTileShift) - 2);

if(
uwStartX <= uwTileX && uwTileX <= uwEndX && uwTileX &&
Expand Down

0 comments on commit 5ba6a43

Please sign in to comment.