diff --git a/asm/region_map.s b/asm/region_map.s index ebbda7b9b..151d57d04 100644 --- a/asm/region_map.s +++ b/asm/region_map.s @@ -5,110 +5,6 @@ .text - thumb_func_start sub_8124BE4 -sub_8124BE4: @ 8124BE4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0xC - movs r0, 0 - mov r8, r0 - ldr r6, =gUnknown_085A1F18 - ldrh r0, [r6, 0x2] - cmp r0, 0xD5 - beq _08124C9C - mov r5, sp - adds r5, 0x6 - add r7, sp, 0x4 - ldr r1, =gSprites - mov r9, r1 - movs r0, 0x1C - add r0, r9 - mov r10, r0 -_08124C0C: - mov r1, r8 - lsls r4, r1, 2 - adds r0, r4, r6 - ldrh r0, [r0] - bl FlagGet - lsls r0, 24 - cmp r0, 0 - beq _08124C84 - adds r0, r6, 0x2 - adds r0, r4, r0 - ldrh r6, [r0] - mov r0, sp - adds r0, 0xA - str r0, [sp] - adds r0, r6, 0 - add r1, sp, 0x4 - adds r2, r5, 0 - add r3, sp, 0x8 - bl sub_8124630 - ldrh r0, [r7] - adds r0, 0x1 - lsls r0, 3 - strh r0, [r7] - ldrh r0, [r5] - adds r0, 0x2 - lsls r0, 3 - strh r0, [r5] - movs r0, 0 - ldrsh r1, [r7, r0] - movs r0, 0 - ldrsh r2, [r5, r0] - ldr r0, =gUnknown_085A1F7C - movs r3, 0xA - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x40 - beq _08124C84 - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - mov r1, r9 - adds r4, r2, r1 - ldrb r1, [r4, 0x3] - movs r0, 0x3F - ands r0, r1 - movs r1, 0x40 - orrs r0, r1 - strb r0, [r4, 0x3] - add r2, r10 - ldr r0, =sub_8124CBC - str r0, [r2] - adds r0, r4, 0 - movs r1, 0x6 - bl StartSpriteAnim - strh r6, [r4, 0x2E] -_08124C84: - mov r0, r8 - adds r0, 0x1 - lsls r0, 16 - lsrs r0, 16 - mov r8, r0 - ldr r6, =gUnknown_085A1F18 - lsls r0, 2 - adds r1, r6, 0x2 - adds r0, r1 - ldrh r0, [r0] - cmp r0, 0xD5 - bne _08124C0C -_08124C9C: - add sp, 0xC - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8124BE4 - thumb_func_start sub_8124CBC sub_8124CBC: @ 8124CBC push {lr} diff --git a/src/region_map.c b/src/region_map.c index 484f60347..b4d51889f 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -82,7 +82,7 @@ void sub_81248F4(void callback(void)); void sub_8124904(void); static void sub_8124A70(void); static void sub_8124AD4(void); -void sub_8124BE4(void); +static void sub_8124BE4(void); void sub_8124CBC(struct Sprite *sprite); void sub_8124D14(void); @@ -121,6 +121,7 @@ extern const struct { u16 flag; } gUnknown_085A1EDC[]; extern const struct SpritePalette gUnknown_085A1F10; +extern const u16 gUnknown_085A1F18[][2]; extern const struct SpriteTemplate gUnknown_085A1F7C; // .text @@ -1496,8 +1497,8 @@ static void sub_8124AD4(void) for (i = 0; i < 16; i ++) { sub_8124630(i, &x, &y, &width, &height); - x = (x + 1) * 8 + 4; - y = (y + 2) * 8 + 4; + x = (x + MAPCURSOR_X_MIN) * 8 + 4; + y = (y + MAPCURSOR_Y_MIN) * 8 + 4; if (width == 2) { shape = ST_OAM_H_RECTANGLE; @@ -1528,3 +1529,33 @@ static void sub_8124AD4(void) canFlyFlag ++; } } + +static void sub_8124BE4(void) +{ + u16 i; + u16 x; + u16 y; + u16 width; + u16 height; + u16 mapSecId; + u8 spriteId; + + for (i = 0; gUnknown_085A1F18[i][1] != MAPSEC_NONE; i ++) + { + if (FlagGet(gUnknown_085A1F18[i][0])) + { + mapSecId = gUnknown_085A1F18[i][1]; + sub_8124630(mapSecId, &x, &y, &width, &height); + x = (x + MAPCURSOR_X_MIN) * 8; + y = (y + MAPCURSOR_Y_MIN) * 8; + spriteId = CreateSprite(&gUnknown_085A1F7C, x, y, 10); + if (spriteId != MAX_SPRITES) + { + gSprites[spriteId].oam.size = 1; + gSprites[spriteId].callback = sub_8124CBC; + StartSpriteAnim(&gSprites[spriteId], 6); + gSprites[spriteId].data0 = mapSecId; + } + } + } +}