summaryrefslogtreecommitdiff
path: root/src/scroll.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/scroll.c')
-rw-r--r--src/scroll.c85
1 files changed, 32 insertions, 53 deletions
diff --git a/src/scroll.c b/src/scroll.c
index 97843104..47f0ae33 100644
--- a/src/scroll.c
+++ b/src/scroll.c
@@ -419,64 +419,43 @@ void Scroll5Sub5(RoomControls* controls) {
}
u32 sub_08080278(void) {
- u32 width;
- u32 height;
- u32 tilePos;
- u16* bottomMapDataPtr;
- u16* topMapDataPtr;
- u32 result;
- u16* bottomMapDataClonePtr;
- u16* topMapDataClonePtr;
- u32 indexX;
- FORCE_REGISTER(u32 indexY, r10);
- int iVar10;
- u16* ptr1;
- u32 tmp;
+ u16* ptr1 = (u16*)gUnk_02022830;
+ u16* mapBottomData = gMapBottom.mapData;
+ u16* mapTopData = gMapTop.mapData;
+ u16* mapBottomDataClone = gMapBottom.mapDataClone;
+ u16* mapTopDataClone = gMapTop.mapDataClone;
+ u32 width = gRoomControls.width >> 4;
+ u32 height = (gRoomControls.height >> 4) << 6;
- ptr1 = gUnk_02022830;
- width = gRoomControls.width >> 4;
- height = (gRoomControls.height >> 4) << 6;
- result = 0;
- indexY = 0;
- if (result < height) {
- iVar10 = 0;
- do {
- indexX = 0;
- if (indexX < width) {
- topMapDataPtr = (u16*)((int)gMapTop.mapData + iVar10);
- topMapDataClonePtr = (u16*)((int)gMapTop.mapDataClone + iVar10);
- bottomMapDataPtr = (u16*)((int)gMapBottom.mapData + iVar10);
- bottomMapDataClonePtr = (u16*)((int)gMapBottom.mapDataClone + iVar10);
- while (indexX < width) {
- tilePos = indexY + indexX;
- if ((bottomMapDataClonePtr[0] != bottomMapDataPtr[0]) && (bottomMapDataPtr[0] < 0x4000)) {
- ptr1[0] = tilePos | 0x4000;
- ptr1[1] = bottomMapDataPtr[0];
- ptr1 += 2;
- result++;
- if (result >= 0x600) {
- return result;
- }
+ u32 result;
+ u32 y, x;
+
+ for (result = 0, y = 0; y < height; y += 0x40) {
+ for (x = 0; x < width; x++) {
+ u32 tilePos = y + x;
+ if (mapBottomDataClone[tilePos] != mapBottomData[tilePos]) {
+ if (mapBottomData[tilePos] < 0x4000) {
+ ptr1[0] = tilePos | 0x4000;
+ ptr1[1] = mapBottomData[tilePos];
+ ptr1 += 2;
+ result++;
+ if (result >= 0x600) {
+ return result;
}
- if ((topMapDataClonePtr[0] != topMapDataPtr[0]) && (topMapDataPtr[0] < 0x4000)) {
- ptr1[0] = tilePos | 0x8000;
- ptr1[1] = topMapDataPtr[0];
- ptr1 += 2;
- result++;
- if (result >= 0x800) {
- return result;
- }
+ }
+ }
+ if (mapTopDataClone[tilePos] != mapTopData[tilePos]) {
+ if (mapTopData[tilePos] < 0x4000) {
+ ptr1[0] = tilePos | 0x8000;
+ ptr1[1] = mapTopData[tilePos];
+ ptr1 += 2;
+ result++;
+ if (result >= 0x800) {
+ return result;
}
- topMapDataPtr++;
- topMapDataClonePtr++;
- bottomMapDataPtr++;
- bottomMapDataClonePtr++;
- indexX++;
}
}
- iVar10 += 0x80;
- indexY += 0x40;
- } while (indexY < height);
+ }
}
return result;
}